akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

long long int n=1,cnt=0,ans=0,a[100000],b,c,cmp=0,data,m,h,x,y,xcmp=0,ycmp=0,sum=0,cmpp;

string s,w;

vector<int> z;

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);

        cin >> n;
        rep(i,2*n){
            cin >> a[i];
        }
        sort(a,a+2*n);
        reverse(a,a+2*n);
        for(int i=1;i<2*n;i+=2){
        ans+=a[i];
        }
        Cout(ans);
return 0;
}


Measured memory_bytes: 764
let rsa () = stdin.ReadLine().Split(' ')
let ria () = rsa () |> Array.map (fun x -> int x)

let [| A; B |] = ria()

let answer x y =
  let add = x + y
  let mul = x * y
  let sub = x - y
  if add >= mul && add >= sub then add
  elif mul >= add && mul >= sub then mul
  else sub
  

let _ans = answer A B
printfn "%d" _ans

Measured memory_bytes: 14044
while True:
    S=[]
    n,m=map(int,input().split())
    if n==0 and m==0:
        break
    else:
        a=list(map(int,input().split()))
        a.sort(reverse=True)
        ans="NONE"
        for i in range(n-1):
            for j in range(i+1,n):
                s=a[i]+a[j]
                S.append(s)
        S.sort(reverse=True)
        for k in range (len(S)):
            if S[k]<=m:
                ans=S[k]
                break
            else:
                pass
        print(ans)


Measured memory_bytes: 26312
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define clear(x) memset(x,0,sizeof(x))
#define pf pop_front
#define ff first
#define ss second
#define mp make_pair
using namespace std;
const ll size=1e6+7;
const ll mod=1e9+7;
ll arr[size];
ll sum(ll n)
{
    ll ans=0;
    while(n!=0)ans+=(n%10),n=n/10;
    return ans;
}
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll n;cin>>n;
    ll ans=1e15;
    for(ll i=1;i<=n/2;i++)
    {
        ans=min(ans,sum(i)+sum(n-i));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll n,b;
	cin>>n>>b;
	ll an=(log(n)/log(b)+1);
	cout<<an;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int n;
	cin >> n;
	vector<int> cnt(1000010), ans(1000010);
	rep(i, n) {
		int a;
		cin >> a;
		cnt[a]++; ans[a]++;
	}
	for (int i = 1; i <= 1000000; i++) {
		for (int j = i; j <= 1000000; j += i) {
			if (cnt[i] >= 2) ans[j] = 0;
			else if (cnt[i] == 1 && i != j) ans[j] = 0;
		}
	}
	int res = 0;
	rep(i, 1000010) res += ans[i];
	cout << res << '\n';
}

Measured memory_bytes: 11116
#include <algorithm>
#include <bitset>
#include <cmath>
#include <ctime>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(a) begin(a),end(a)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
ll gcd(ll a, ll b){
  if (b==0) return a;
  else return gcd(b,a%b);
}
int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}







int main(){
  int a,b;
  cin >> a >> b;
  a--,b--;
  cout << a * b << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main(){
    string s ;
    cin >> s ;
    int a = 0 ;
    int b = 0 ;
    if (s.at(0) == s.at(1))
    {
        a += 2 ;
        if (s.at(0) == s.at(2))
        {
            a += 1 ;
        }
        else 
        {
            if ( s.at(2) == s.at(3) )
            {
                b += 2 ;
            }
            
        }
        
        
        
    }
    else
    {
        a += 1 ;
        b += 1 ;
        for (int i = 2; i < 4; i++)
        {
            if ( s.at(i) == s.at(0))
            {
                a += 1 ;
            }
            if ( s.at(i) == s.at(1))
            {
                b += 1 ;
            }
            
        }
        
    }
    
    if ( a == 2 && b == 2)
    {
        cout << "Yes" << endl ;
    }else
    {
        cout << "No" << endl ;
    }
    
    
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC114A
{
    class Program
    {
        static void Main(string[] args)
        {
            int x;

            var word = Console.ReadLine().Split(' ');

            x = int.Parse(word[0]);

            if (x == 7 || x == 5 || x == 3)
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");

            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <map>
#include <cmath>
#include <cstring>
#include <vector>
using namespace std;

#define REP(i,n) for(int i=0; i<n; i++)

int n;
vector<int> v;
long long s[5000];

int main(){
    while(cin>>n,n){
        v=vector<int>(n);
        REP(i,n)cin>>v[i];
        long long ans=-(1<<30);
        REP(i,n){
            s[i]=v[i];
            ans=max(s[i],ans);
            for(int j=i+1; j<n; j++){
                s[j]=s[j-1]+v[j];
                ans=max(s[j],ans);
            }
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 1236
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i = 0; i < n; i++)
#define rep2(i,start,end) for(ll i = start; i < end; i++)
#define dwn(i,n) for(int i = n; i >= 0; i--)
#define dwn2(i,start,end) for(ll i = start; i >= end; i--)
#define pll pair<ll,ll>
#define mk(x,y) make_pair(x,y)
#define pdl pair<double, ll>
const ll N = 4e5 + 200;
const ll INF = 0x3f3f3f;
const ll mod = 1e9 + 7;


int main(){
	int a,b;
	cin>>a>>b;
	if(a > 0 && a < 10 && b < 10 && b > 0){
		cout<<a*b<<endl;
	}else{
		cout<<-1<<endl;
	}



	return 0;
}






Measured memory_bytes: 256
s = input()
n = len(s)
dp0 = [0] * (n + 1) #以下非確定
dp1 = [0] * (n + 1) #以下確定
mod = 10 ** 9 + 7
dp0[0] = 1
for i in range(n):
    #以下確定している部分dp1の推移(足される側がdp1)
    dp1[i + 1] += dp1[i] * 3# 各々のa, b組み合わせにおいてさらに (0,0) (0,1) (1,0)が追加
    dp1[i + 1] %= mod
    #以下非確定(i桁目まで完全一致させている組み合わせにおいての推移)
    if s[i] == '0': #0のときは(0, 0)として合わせるしかないので増えない
        dp0[i + 1] += dp0[i]
        dp0[i + 1] %= mod
    else: #1のときは(0,1) (1,0)で一致させていく、つもり非確定状態を保つ場合と、(0,0)を当てる(つまり以下のものを作る)
        dp0[i + 1] += dp0[i] * 2
        dp1[i + 1] += dp0[i]
        dp0[i + 1] %= mod
        dp1[i + 1] %= mod
        
print((dp0[n] + dp1[n]) % mod)









Measured memory_bytes: 41456
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

ll gcd(ll x, ll y)
{
	return y==0 ? x:gcd(y,x % y);
}

ll lcm(ll number1,ll number2){
	return number1 / gcd(number1,number2) * number2;	
}


int main()
{
    int N;
    cin >> N;
    vector<ll> T(N);
    rep(i,N) cin >> T[i];
    ll ans = T[0];
    for( ll i = 1;i < N;i++)
    {
        ans = lcm(ans, T[i]);
    }
 
    cout << ans << endl;
        
 
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
	int n, i;
	double a[100], b[100], sumb = 0;
	scanf("%d", &n);
	for (i = 0; i < n; i++)
		scanf("%lf", &a[i]);

	for (i = 0; i < n; i++)
		b[i] = 1 / a[i];

	for (i = 0; i < n; i++)
		sumb += b[i];

	printf("%lf", 1 / sumb);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define U [7<<15]={}
#define G )+((c=A[a]+A[P[a]]+C[a])%k?c:0)-M(
typedef long long L;using namespace std;map<L,L>T U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U;L M(L f){return f?B[f]+M(f^f&-f):0;}L S(L a,L i){for(a=M(i++G i);i<2e5;i+=i&-i)B[i]+=a;}L D(L f){L d;for(map<L,L>::iterator I=T[f].begin();I!=T[f].end();I++)d=I->first,d-P[f]?P[d]=f,E[d]=E[f]+1,C[d]=I->second,D(d),Z[f]+=++Z[d],Z[H[f]]<Z[d]?H[f]=d:0:0;}L K(L f){a=X[f];n=X[b];return a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f]G O[a])+K(P[a]):abs(M(O[f])-M(O[b]));}main(){for(cin>>n>>k;--*Z+n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;for(n=D(0);Z[a=H[P[n]]-n?n:0];n++)for(;!O[a];S(a=H[a],O[a]=++b))X[a]=n;for(cin>>a;cin>>s>>a>>b;S(H[a],O[a]),S(a,O[a]-1))*s&2?cout<<K(a)<<endl,0:A[a]+=b;}

Measured memory_bytes: 38112
#include<bits/stdc++.h>

using namespace std;

int main(void)
{
    int A,B,C,D,i;

    cin >> A >> B >> C >> D;
    
    for(i=0;i<100;i++){
        C -= B;
        A -= D;
        if(C <= 0){
            cout << "Yes" << endl;
            break;
        }
        if(A <=0){
            cout << "No" << endl;
            break;
        }
    }
    

    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;

int a[100010];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);

    int n;
    cin>>n;

    for(int i=0;i<n;i++)cin>>a[i];

    int ans=0;

    for(int i=0;i<n;i++)if(a[a[i]-1]==i+1)ans++;

    ans/=2;

    cout<<ans<<"\n";

    return 0;
}


Measured memory_bytes: 3988
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;
int MX=100000;
int N,M;
ll o[1000][1000];
ll inf = 1e13;
vector<ll> getnext(vector<ll> a){
	int N = a.size();
	vector<ll> b(N);
	rep(i,N) b[i]=a[i];
	rep(i,N-1) b[i+1]+=b[i];
	return b;
}
ll need(vector<ll> a,vector<ll> b){	//need b++
//	puts("-------------ned");
	if(a[0]<b[0]) return -inf;
	assert(a[0]==b[0]);
	int N = a.size();

	if(a>=b){
		ll nd = (a[1]-b[1]+b[0]-1)/b[0];
		if(a[1]<nd*b[0]+b[1]) return nd;
		assert(a[1]==nd*b[0]+b[1]);
		if(N==2) return nd+1;

		ll nb2 = b[2] + nd*b[1] + nd*(nd+1)/2*b[0];
//		show(nd);
//		show(nb2);
		if(nb2>a[2]) return nd;

		//assert(nd<=10000)
		rep(t,10000000){
			if(a<b) return t;
			b = getnext(b);
		}
	}else{
		a.back()++;
		return 1-need(b,a);
	}
}
ll brute(){
	vector<ll> a(M),b(M);
	rep(i,M) a[i]=o[0][i];
	ll ans=0;
	rep(i,N-1){
		rep(j,M) b[j]=o[i+1][j];
		ll nd=-1;
		rep(t,100000){
			if(a<b){
				nd=t;
				break;
			}
			b=getnext(b);
		}
//		show(nd);
		if(nd==-1) return -1;
		ans+=nd;
		a=b;
	}
	return ans;
}
ll ns[1000];
ll br;
ll solve(){
	cin>>N>>M;
	rep(i,N) rep(j,M) cin>>o[i][j];
	// N=rand()%5+1,M=rand()%5+1;
	// int r0 = rand()%10+1;
	// rep(i,N){
	// 	o[i][0] = r0;
	// 	rep1(j,M-1) o[i][j] = rand()%10+1;
	// }
//	br = brute();
	if(N==1){
		return 0;
	}
	rep(i,N-1) if(o[i][0]>o[i+1][0]){
		return -1;
	}
	if(M==1){
		rep(i,N-1) if(o[i][0]==o[i+1][0]){
			return -1;
		}
		return 0;
	}

	rep(i,N-1){
		vector<ll> a(M),b(M);
		rep(j,M) a[j]=o[i][j],b[j]=o[i+1][j];
		ns[i] = need(a,b);
//		show(ns[i]);
		assert(ns[i]!=inf);
	}

	ll ans = 0;
	ll prev = 0;
	rep(i,N-1){
		ll nd = ns[i] + prev;
		if(nd<0) nd=0;
//		show(nd);
		ans+=nd;
		prev=nd;
	}
	return ans;
}
int main(){
	// srand((unsigned)time(NULL));
	// while(true){
	// 	ll slv = solve();
	// 	// show(slv);
	// 	// show(br);
	// 	if(br != slv){
	// 		puts("0-----");
	// 		cout<<N<<" "<<M<<endl;
	// 		rep(i,N){
	// 			rep(j,M) cout<<o[i][j]<<" ";
	// 			puts("");
	// 		}
	// 		assert(0);
	// 	}
	// 	puts("ok");
//		cout<<solve()<<endl;
//	}
	cout<<solve()<<endl;
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>

using namespace std;

#define lli long long int
#define REP(i,s,n) for(lli i=s;i<n;i++)
#define RREP(i,s,n) for(lli i=s;i>=n;i--)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 1
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

signed main(){

	lli n;
	cin>>n;
	lli k,q;
	cin>>k>>q;

	vector<lli> ans(n,k-q);
	REP(i,0,q){
		lli a;
		cin>>a;
		a--;
		ans[a]++;
	}

	REP(i,0,n){
		cout<<((ans[i]>0)?"Yes":"No")<<endl;
	}

	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <climits>
using namespace std;

int main(){
    
    int N;
    cin >> N;
    
    int A[N];
    for(int i = 0; i < N;i++)cin >> A[i];
    
    int ans = INT_MAX;
    int cost = 0;
    for(int i = -100; i <= 100;i++){
        cost = 0;
        for(int j = 0; j < N;j++)cost += (A[j] - i)*(A[j] - i);
        ans = min(ans,cost);
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 256
import Text.Printf

main = do
  s <- getLine
  let [a, b] = map read $ words s :: [Integer]
  let x = a `div` b
  let y = a `mod` b
  let z = fromIntegral a / fromIntegral b :: Double
  putStrLn $ show x ++ " " ++ show y ++ " " ++ printf "%.6f" z

Measured memory_bytes: 3952
#include<stdio.h>

int main(){
    
    int h = 0;
    int w = 0;
    int i = 0;
    int j = 0;
    
    while(1){
        scanf("%d%d",&h,&w);
        
        if(h==0 && w==0){
            break;
        }
        
        for(i=0;i<h;i++)
        {
            for(j=0;j<w;j++)
            {
                if((i==0||i==h-1)||(j==0 || j== w-1)){
                    printf("#");  
                }else{
                    printf(".");
                }
                
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2052
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int a,b;
    cin>>a>>b;
    if (a+b==15)
        cout<<"+\n";
    else if (a*b==15)
        cout<<"*\n";
    else
        cout<<"x\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <numeric>
#include <string>
#include <cstring>
#include <cmath>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long int int64;


const int N = 105;
int a[N];


int main(int,  char **)
{
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif

    int len, n;
    scanf("%d%d", &len, &n);
    for (int i = 0; i < n; i++)
        scanf("%d", &a[i]);

    int odd = 0;
    for (int i = 0; i < n; i++)
        if (a[i] % 2)
        {
            swap(a[i], a[odd]);
            odd++;
        }

    if (odd > 2)
    {
        printf("Impossible\n");
        return 0;
    }

    int sum = 0;
    sort(a + odd, a + n);
    if (odd == 2)
        rotate(a + 1, a + 2, a + n);

    vector <int> b;
    if (a[0] != 1)
    {
        b.push_back(a[0] - 1);
        sum += a[0] - 1;
    }
    for (int i = 1; i < n - 1; i++)
    {
        b.push_back(a[i]);
        sum += a[i];
    }
    if (sum != len)
        b.push_back(len - sum);

    for (int i = 0; i < n; i++)
        printf("%d ", a[i]);
    printf("\n%d\n", (int) b.size());
    for (int x : b)
        printf("%d ", x);
    printf("\n");



	return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <fstream>

using namespace std;

int main()
{
    int N;
    int A[110];
    cin >> N;
    for (int i = 0; i < N; i++) cin >> A[i];

    int min = *min_element(A, A + N);
    int max = *max_element(A, A + N);

    cout << max - min << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repr(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
#define mod 1000000007

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}

int main(){
    ll a,b,c,ans=0;
    cin >> a >> b >> c;
    ll k;
    cin >> k;
    while(a>=b){
        ans++;
        b*=2;
    }
    while(b>=c){
        ans++;
        c*=2;
    }
    if(ans<=k) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}











Measured memory_bytes: 3628
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var N = Sarray()[0];
            var S = ReadLine();
            var dct = new Dictionary<char, long>();
            foreach(var s in S)
            {
                if (!dct.ContainsKey(s)) dct[s] = 0;
                ++dct[s];
            }
            var ans = 1L;
            foreach(var d in dct)
                ans = (ans * (d.Value + 1)) % Mod;
            WriteLine(ans - 1);

            //Out.Flush();
        }
    }
}

Measured memory_bytes: 13792
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = 0;
            for (var i = 0; i < 4; i++)
            {
                n += int.Parse(Console.ReadLine());
            }
            var ts = new TimeSpan(0, 0, n);
            Console.WriteLine(ts.Minutes);
            Console.WriteLine(ts.Seconds);
        }
    }
}

Measured memory_bytes: 5616
#include <bits/stdc++.h>
using namespace std;
int n , k, cmmdc;
inline int euclid(int a , int b)
{
    int rest;
    while (b)
    {
        rest = a % b;
        a = b;
        b = rest;
    }
    return a;
}
int main()
{
    //freopen("in" , "r", stdin);
    //freopen("out" , "w", stdout);

    scanf("%d %d\n", &n, &k);
    int maxy = 0;
    for (int i = 1; i<=n; ++i)
    {
        int x;
        scanf("%d", &x);
        maxy = max(maxy , x);
        if (i == 1)
            cmmdc = x;
        else cmmdc = euclid(cmmdc , x);
    }
    if (k % cmmdc == 0 && k >= cmmdc && k <= maxy)
        printf("POSSIBLE");
    else printf("IMPOSSIBLE");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a, Ts... ts) {return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }

template<typename T,typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v){ t = v; }

template<typename T,typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v){ for(auto &e : t) fill_v(e, v); }

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    REP(i, n) cin >> x[i] >> y[i];

    if(n == 1)
    {
        cout << 1 << endl;
        return 0;
    }

    vector<vector<P>> dis(n, vector<P>(n));
    map<P, int> mp;
    REP(i, n) REP(j, n)
    {
        if(i == j) continue;
        //dis[i][j] = make_pair(x[i] - x[j], y[i] - y[j]);
        mp[make_pair(x[i] - x[j], y[i] - y[j])]++;
    }
    int num = INF;
    for(auto x : mp)
    {
        num = min(n - x.second, num);
    }
    cout << num << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll ngcd(vector<ll> a){
    ll res;
    res = a[0];
    for(ll i = 1; i < a.size() && res != 1; i++) {
        res = gcd(a[i], res);
    }
    return res;
}

int main() {
    int k;
    cin >> k;
    ll sum = 0;
    for(int a = 1;a <= k;a++){
        for(int b = 1;b <= k;b++){
            for(int c = 1; c <= k;c++){
                vector<ll> v = {a,b,c};
                sum += ngcd(v);
            }
        }
    }
    cout << sum << endl;
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 3628
#include <iostream>

int w, h;
int map[50][50];

void dfs(int y, int x){
  map[y][x] = 0;
  for(int dy=-1; dy <= 1; dy++){
    for(int dx=-1; dx <= 1; dx++){
      if(0 <= y+dy && y+dy < h && 0 <= x+dx && x+dx < w && map[y+dy][x+dx] == 1){
        dfs(y+dy, x+dx);
      }
    }
  }
}

int main(void){
  while(1){
    int cnt = 0;
    std::cin >> w >> h;
    if(w == 0 && h == 0)  return 0;
    for(int i=0; i < h; i++){
      for(int j=0; j < w; j++){
        std::cin >> map[i][j];
      }
    }

    for(int i=0; i < h; i++){
      for(int j=0; j < w; j++){
        if(map[i][j] == 1){
          cnt++;
          dfs(i, j);
        }
      }
    }

    std::cout << cnt << std::endl;

  }
}

Measured memory_bytes: 1348
#include <vector> 
#include <list> 
 #include <map>
 #include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '(L' << __LINE__ << ')' << ' ' << __FILE__ << endl;

int main(){
 
    int N;
    int ans=0;
    cin>>N;

    REP(i,N){
        int a,b;
        cin>>a>>b;
        ans+=(b-a+1);
    }


    cout<<ans<<endl;
}



Measured memory_bytes: 256
#include<stdio.h>
main(){
  int N=0,i=0,a[1000]={0},b[1000]={0},c[1000]={0},x[1000]={0};
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d %d %d",&a[i],&b[i],&c[i]);
    if(c[i]*c[i] == a[i]*a[i]+b[i]*b[i]){
      x[i] = 1;
    }
    else if(b[i]*b[i] == a[i]*a[i]+c[i]*c[i]){
      x[i] = 1;
    }
    else if(a[i]*a[i] == c[i]*c[i]+b[i]*b[i]){
      x[i] = 1;
    }
  }
  for(i=0;i<N;i++){
    if(x[i] == 1){
      printf("YES\n");
    }
    else{
      printf("NO\n");
    }
  }
  return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;





int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	ll h, w;
	cin >> h >> w;
	if (w == 1 || h == 1) {
		cout << 1;
		return 0;
	}
	cout << ((w + 1) / 2) * ((h + 1) / 2) + (w / 2) * (h / 2);
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 10000000


int main()
{
    
    int n;
    cin>>n;
    vector<int > dp(n+1,-1);
    vector<int > h(n+1);
    int i;
    for(i=0;i<n;i++){
        cin>>h[i+1];
    }
    
  dp[1]=0;
  dp[2]=abs(h[2]-h[1]);
  for(i=3;i<=n;i++)
  dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
   cout<<dp[n]<<endl;
   
    
    return 0;
    
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;

int main() {
    ll N;
    cin >> N;
    map<ll,ll> mp;
    for(int i=0;i<N;i++){
        ll A;
        cin >> A;
        mp[A]++;
    }
    ll ans =0;
    ll evenNum =0;
    for(auto itr = mp.begin();itr != mp.end();++itr){
        ans++;
        if((itr->second)%2==0){
            evenNum++;
        }
    }
    cout << ans -evenNum%2 << endl;

    return 0;
}

Measured memory_bytes: 6528
/**
  @file a.cpp
  @title A - Transfer
  @url https://atcoder.jp/contests/abc136/tasks/abc136_a
**/

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, N) for (int i = 0; i < (N); ++i)

int main() {
  int A, B, C;
  cin >> A >> B >> C;

  cout << max(C - (A - B), 0) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P =pair<int,int>;

int main(){
	int N,K;
	string S;
	cin>>N>>S>>K;
	rep(i,N){
		if(S.at(i)!=S.at(K-1)){
			S.at(i)='*';
		}
	}
	cout<<S;
return 0;}

/*compile
g++ code.cpp
./a.out
run*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
using namespace std;
typedef vector<int> vi;
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
const int maxn = 110000, maxd = 11;
int c[maxn][maxd];
int col[maxn];
vector<int> e[maxn];
int main() {
    int n, m, q;
    cin >> n >> m;
    forn(i, m) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        e[a].pb(b);
        e[b].pb(a);
    }
    cin >> q;
    forn(i, q) {
        int v, d;
        cin >> v >> d >> col[i + 1];
        --v;
        c[v][d] = i + 1;
    }
    ford(i, maxd - 1) forn(v, n) for (int u: e[v]) uax(c[u][i], c[v][i + 1]);
    forn(v, n) {
        int res = 0;
        forn(d, maxd) uax(res, c[v][d]);
        cout << col[res] << '\n';
    }
    return 0;
}

Measured memory_bytes: 11512
import Data.Char -- for words func.
import Control.Monad -- for forM_ replicateM func.
import Numeric -- for showFFloat func. 

type Vector = (Double, Double)
type Scalar = Double

------------------------------------------------------------------
-- represent the RealFloat result with 'numOfDecimal' decimals. --
------------------------------------------------------------------

formatFloatN :: (RealFloat a) => a -> Int -> String
formatFloatN floatNum numOfDecimals = showFFloat (Just numOfDecimals) floatNum ""

---------------------------------------------------
-- arithmetic functions for vector calculations. --
---------------------------------------------------
vadd :: Vector -> Vector -> Vector
vadd (x, y) (z, w) = (x + z, y + w)

vsub :: Vector -> Vector -> Vector
vsub (x, y) (z, w) = (x - z, y - w)

vdot :: Vector -> Vector -> Scalar
-- vdot defines dot product for 2D vector.
vdot (x, y) (z, w) = x * z + y * w

smul :: Scalar -> Vector -> Vector
-- smul defines scalar multiplication of 2D vector.
smul a (x, y) = (a * x, a * y)

sqnorm :: Vector -> Scalar
-- calculate squared euclidean norm(sqnorm(x) = ||x||^2).
sqnorm (x, y) = x * x + y * y

projection_point :: Vector -> Vector -> Vector -> Vector
-- find the projection point when p_1, p_2, p are geven.
-- p_1, p_2 are the point on a straight line called l.
-- projection point are defined as the point on the l
-- is the most close to point p.
projection_point p_1 p_2 p
  | p_1 /= p_2 = (a `vdot` b / sqnorm a) `smul` a `vadd` p_1
  | otherwise  = p_1
  where
    a = p_2 `vsub` p_1
    b = p `vsub` p_1

--------------------------------------
-- functions for string formatting. --
--------------------------------------
line2ps :: String -> [Vector]
-- this function formatting line include p_1 and p_2 value
-- to list of p_1 and p_2.
-- e.g.
-- input: "0 0 2 0" -- i.e. "p_1x p_1y p_2x p_2y"
-- output: [(0, 0), (2, 0)] -- i.e. [p_1, p_2]
line2ps line = [p_1, p_2]
  where
    ps = words line
    p_1 = line2p . unwords $ take 2 ps
    p_2 = line2p . unwords $ drop 2 ps

line2p :: String -> Vector
-- transform string to vector.
-- input: "0 1" -- i.e. "p_x p_y"
-- output: (0, 1)
line2p line = p
  where
    ps = words line
    p_x = read (ps!!0) :: Double
    p_y = read (ps!!1) :: Double
    p = (p_x, p_y)

vec2line :: Vector -> String
vec2line (x, y) = (formatFloatN x 8) ++ " " ++ (formatFloatN y 8)

---------------------
-- main statement. --
---------------------
main :: IO()
main = do
  ps <- getLine
  q  <- getLine
  plist <- replicateM (read q) getLine
  let proj p = vec2line $ projection_point ((line2ps ps)!!0) ((line2ps ps)!!1) (line2p p) in
    putStrLn . init . unlines $ map proj plist


Measured memory_bytes: 5076
def main():
  N=int(input())
  vA=list(map(int,input().split()))
  T = 10**18
  
  if 0 in vA:
    print(0)
    return
  
  res = 1
  for a in vA:
    res *= a
    if res > T:
      print(-1)
      return
    
  print(res)

main()


Measured memory_bytes: 21648
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn dfs(
    n: usize,
    a: i64,
    b: i64,
    c: i64,
    ls: &[i64],
    i: usize,
    curr_a: i64,
    curr_b: i64,
    curr_c: i64,
) -> i64 {
    if i == n {
        if curr_a == 0 || curr_b == 0 || curr_c == 0 {
            const MAX_COST: i64 = 1 << 60;
            return MAX_COST;
        }
        const COST_FIRST_ADD: i64 = -30;
        return (a - curr_a).abs() as i64
            + (b - curr_b).abs() as i64
            + (c - curr_c).abs() as i64
            + COST_FIRST_ADD;
    }
    let arr = [
        dfs(n, a, b, c, ls, i + 1, curr_a, curr_b, curr_c),
        dfs(n, a, b, c, ls, i + 1, curr_a + ls[i], curr_b, curr_c) + 10,
        dfs(n, a, b, c, ls, i + 1, curr_a, curr_b + ls[i], curr_c) + 10,
        dfs(n, a, b, c, ls, i + 1, curr_a, curr_b, curr_c + ls[i]) + 10,
    ];
    *arr.iter().min().unwrap()
}

fn main() {
    input! {
        n: usize,
        a: i64,
        b: i64,
        c: i64,
        ls: [i64; n],
    }
    println!("{}", dfs(n, a, b, c, &ls, 0, 0, 0, 0));
}


Measured memory_bytes: 4352
#include <iostream>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    long long iNum1,iNum2;
    while (cin>>iNum1>>iNum2){
        if (iNum1 % 2 == 0 || iNum2 % 2 == 0)
            cout<<"Even\n";
        else
            cout<<"Odd\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <time.h>
#include<stdlib.h>
#include<string.h>

int main(void){
	int n, k, h, ans = 0;

	scanf("%d %d", &n, &k);

	for (int i = 0; i < n; i++) {
		scanf("%d", &h);
		if (h >= k) {
			ans++;
		}
	}
	printf("%d", ans);
}

Measured memory_bytes: 1704
A, B = [int(_) for _ in input().split()]

#A, B = 500, 400
pat = "#."

if A > B:
    A, B = B, A
    pat = pat[1] + pat[0]

h, w = 100, 100

rows = [[1] * w for _ in range(h)]

i = 0
x = 0
y = 3
while i < B:
    rows[y][x] = 0
    rows[y][x + 1] = 0
    rows[y][x + 2] = 0
    x += 4
    if x >= w:
        x = 0
        y += 4
    i += 1

i = 1
x = 0
y = 1
while i < A:
    rows[y][x] = 0
    rows[y][x + 1] = 0
    rows[y][x + 2] = 0
    rows[y + 1][x] = 0
    rows[y + 1][x + 2] = 0
    x += 4
    if x >= w:
        x = 0
        y += 4
    i += 1

print(h, w)
for y, row in enumerate(rows):
    print("".join(pat[c] for c in row))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define ELEM(array)  (sizeof (array) / sizeof *(array))
#define MOD 1000000007
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

int main(){
    ll n,k,q;
    cin>>n>>k>>q;
    vector<ll> a(n,k-q);
    rep(i,q){
        ll x;
        cin>>x;
        a[x-1]++;
    }
    rep(i,n){
        if(a[i]>0) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }

    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int> 
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int grid[501][501];
int n;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        for(int cnt=1;cnt<=30;cnt++){
            if(pow(2,cnt-1)+i>n) break;
            int now=pow(2,cnt);
            for(int j=i+pow(2,cnt-1);j<=n;j+=now)
                grid[i][j]=cnt;
        }
    }
    for(int i=1;i<n;i++){
        for(int j=i+1;j<=n;j++)
            cout<<grid[i][j]<<" ";
        cout<<endl;
    }
    return 0;
}
//2 3 4 5 6 7 8 9

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=190;
int read(){
	int f=1,g=0;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int n,m,f[N][N][N],g[N][N][N],tf[N][N][N],tg[N][N][N];
char a[N][N];
void chkmax(int &x,int y){if (x<y) x=y;}
int main(){
	n=read();m=read();
	for (int i=1;i<=n;i++) scanf(" %s",a[i]+1);
	for (int i=n;i;i--)
	for (int l=1;l<=m;l++)
	for (int r=l;(r<=m)&&(a[i][l]==a[i][r]);r++)
		f[i][l][r]=(a[i][l]==a[i+1][l]) ? (f[i+1][l][r]+1) : 1;
	for (int i=m;i;i--)
	for (int l=1;l<=n;l++)
	for (int r=l;(r<=n)&&(a[l][i]==a[r][i]);r++)
		g[i][l][r]=(a[l][i]==a[l][i+1]) ? (g[i+1][l][r]+1) : 1;
	int ans;
	for (ans=0;f[1][1][m]<n;ans++){
		for (int i=1;i<=n;i++)
		for (int l=1;l<=m;l++)
		for (int r=l;r<=m;r++){
			f[i][l][r]+=f[i+f[i][l][r]][l][r];
			chkmax(tg[l][i][i+f[i][l][r]-1],r-l+1);
		}
		for (int i=1;i<=m;i++)
		for (int l=1;l<=n;l++)
		for (int r=l;r<=n;r++){
			g[i][l][r]+=g[i+g[i][l][r]][l][r];
			chkmax(tf[l][i][i+g[i][l][r]-1],r-l+1);
		}
		for (int i=1;i<=n;i++)
		for (int l=1;l<=m;l++)
		for (int r=m;r>=l;r--)
			chkmax(f[i][l][r],max(tf[i][l][r],f[i][l][r+1]));
		for (int i=1;i<=m;i++)
		for (int l=1;l<=n;l++)
		for (int r=n;r>=l;r--)
			chkmax(g[i][l][r],max(tg[i][l][r],g[i][l][r+1]));
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 106880
#include <bits/stdc++.h>
using namespace std;

using ll=int64_t;
//#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#ifdef MAROON_LOCAL
#define cerr (cerr<<"-- line "<<__LINE__<<" -- ")
#else
class CerrDummy{}cerrDummy;
template<class T>
CerrDummy& operator<<(CerrDummy&cd,const T&){
	return cd;
}
using charTDummy=char;
using traitsDummy=char_traits<charTDummy>;
CerrDummy& operator<<(CerrDummy&cd,basic_ostream<charTDummy,traitsDummy>&(basic_ostream<charTDummy,traitsDummy>&)){
	return cd;
}
#define cerr cerrDummy
#endif
#define REACH cerr<<"reached"<<endl
#define DMP(x) cerr<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))
#define ONE(x) memset(x,-1,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"{";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

ll read(){
	ll i;
	scanf("%" SCNd64,&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(ll x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341000];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341000];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(b<a)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

#define CAPITAL
void Yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<endl;
	#else
	cout<<"Yes"<<endl;
	#endif
	if(ex)exit(0);
}
void No(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<endl;
	#else
	cout<<"No"<<endl;
	#endif
	if(ex)exit(0);
}

const ll infLL=LLONG_MAX/3;

#ifdef int
const int inf=infLL;
#else
const int inf=INT_MAX/2-100;
#endif

const int Smax=4010;
const int Nmax=2010;
int pos[2][Nmax],sum[2][Smax][Nmax],dp[Nmax][Nmax];

signed main(){
	int n=read();
	int s=n*2;
	REP(i,s){
		string c=readString();
		int a=read()-1,k=-1;
		if(c=="W"){
			k=0;
		}else{
			k=1;
		}
		pos[k][a]=i;
		sum[k][i][a]++;
	}
	REP(k,2){
		REP(i,s)for(int j=n-1;j>=1;j--)
			sum[k][i][j-1]+=sum[k][i][j];
		REP(i,s-1)REP(j,n)
			sum[k][i+1][j]+=sum[k][i][j];
	}
	REP(i,n+1)REP(j,n+1)dp[i][j]=inf;
	dp[0][0]=0;
	REP(i,n+1)REP(j,n+1){
		if(i<n){
			int p=pos[0][i];
			chmin(dp[i+1][j],dp[i][j]+sum[0][p][i+1]+sum[1][p][j]);
		}
		if(j<n){
			int p=pos[1][j];
			chmin(dp[i][j+1],dp[i][j]+sum[0][p][i]+sum[1][p][j+1]);
		}
	}
	print(dp[n][n]);
}


Measured memory_bytes: 82176
#include<iostream>

using namespace std;

int main(){
  
  int a,b;
  cin>>a>>b;
  
  if(b%2!=0)
  {
    cout<<"No";
   
  }
  else
    if(a*4<b || a*2>b){
     cout<<"No";
    
    }else
        if(a*2<=b &&b<=a*4){
            cout<<"Yes";
}
  return 0;
}


Measured memory_bytes: 3636
// 最小値がボトルネックになり、題意からボトルネックだけ考えればよさそう
// あとは問題文をろくに読まずサンプルだけ見た
// サンプル見たらボトルネックの位置も関係ある そりゃそうだ
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	minA := int(1e18)
	for i := 0; i < 5; i++ {
		var V int
		fmt.Scan(&V)
		minA = min(minA, V)
	}
	if N%minA != 0 {
		fmt.Println(N/minA + 1 + 4)
	} else {
		fmt.Println(N/minA + 4)
	}
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}


Measured memory_bytes: 512
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

int main() {
    string S;
    cin >> S;
    
    if ((((S.at(0) == S.at(1) && S.at(2) == S.at(3)) || (S.at(0) == S.at(2) && S.at(1) == S.at(3)) || (S.at(0) == S.at(3) && S.at(2) == S.at(1))) && !(S.at(0) == S.at(1) && S.at(0) == S.at(2) && S.at(0) == S.at(3)))){
        cout << "Yes" << endl;

    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;

const int maxn=2e5+10;
int n;
vector<int> vec;

bool chk(int ans){
	map<int,int> mp;
	for(int i=1;i<vec.size();++i)
		if(vec[i-1]>=vec[i]){
			while(!mp.empty()&&mp.rend()->first>vec[i])
				mp.erase(prev(mp.end()));
			int pos=vec[i];
			while(mp[pos]==ans-1)
				mp.erase(mp.find(pos)),--pos;
			++mp[pos];
		}
	return mp.begin()->first>0;
}

int main(){
	cin>>n;
	for(int i=1,a;i<=n;++i){
		cin>>a;
		vec.push_back(a);
	}
	{
		bool ans1=true;
		for(int i=1;i<vec.size();++i)
			if(vec[i-1]>=vec[i])
				ans1=false;
		if(ans1){
			puts("1");
			return 0;
		}
	}
	int l=2,r=n;
	while(l<r){
		int mid=l+r>>1;
		if(chk(mid))
			r=mid;
		else
			l=mid+1;
	}
	cout<<l<<endl;
	return 0;
}

Measured memory_bytes: 3828
//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <vector>

namespace n91 {

	using i8 = std::int_least8_t;
	using i32 = std::int_least32_t;
	using i64 = std::int_least64_t;
	using u8 = std::uint_least8_t;
	using u32 = std::uint_least32_t;
	using u64 = std::uint_least64_t;
	using isize = std::ptrdiff_t;
	using usize = std::size_t;

	class rep {
		const usize f, l;

	public:
		class itr {
			friend rep;
			usize i;
			constexpr itr(const usize x) noexcept : i(x) {}

		public:
			void operator++() noexcept { ++i; }
			constexpr usize operator*() const noexcept { return i; }
			constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
		};
		constexpr rep(const usize first, const usize last) noexcept
			: f(first), l(last) {}
		constexpr itr begin() const noexcept { return itr(f); }
		constexpr itr end() const noexcept { return itr(l); }
	};
	class revrep {
		const usize f, l;

	public:
		class itr {
			friend revrep;
			usize i;
			constexpr itr(usize x) noexcept : i(x) {}

		public:
			void operator++() noexcept { --i; }
			constexpr usize operator*() const noexcept { return i; }
			constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
		};
		constexpr revrep(usize first, usize last) noexcept : f(--first), l(--last) {}
		constexpr itr begin() const noexcept { return itr(l); }
		constexpr itr end() const noexcept { return itr(f); }
	};
	template <class T> using vec_alias = std::vector<T>;
	template <class T> auto md_vec(const usize n, const T &value) {
		return std::vector<T>(n, value);
	}
	template <class... Args> auto md_vec(const usize n, Args... args) {
		return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
	}
	template <class T> constexpr T difference(const T &a, const T &b) {
		return a < b ? b - a : a - b;
	}

} // namespace n91

#include <utility>

namespace n91 {
	template <class T> T gcd(T m, T n) {
		if (n == 0) {
			return m;
		}
		while (m %= n)
			::std::swap(m, n);
		return n;
	}
} // namespace n91

#include <algorithm>
#include <iostream>
#include <utility>

namespace n91 {

	void main_() {
		usize n;
		std::cin >> n;
		u32 ans = 0;
		std::vector<u32> a(n);
		for (auto &e : a) {
			std::cin >> e;
		}
		std::vector<u32> l(n + 1), r(n + 1);
		l[0] = 0;
		r[n] = 0;
		for (const auto i : rep(0, n)) {
			l[i + 1] = gcd(l[i], a[i]);
		}
		for (const auto i : revrep(0, n)) {
			r[i] = gcd(r[i + 1], a[i]);
		}
		for (const auto i : rep(0, n)) {
			ans = std::max(ans, gcd(l[i], r[i + 1]));
		}
		std::cout << ans << std::endl;
	}

} // namespace n91

int main() {
	n91::main_();
	return 0;
}


Measured memory_bytes: 1408