akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define sqr(x) ((x)*(x))
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define vi vector<int>
#define HEAP(...) priority_queue<__VA_ARGS__ >
#define heap(...) priority_queue<__VA_ARGS__,vector<__VA_ARGS__ >,greater<__VA_ARGS__ > > 
#define pii pair<int,int> 
#define pb push_back
#define mp make_pair
#define debuge cerr<<"isok"<<endl
#define debug(x) cerr<<#x<<"="<<x<<endl
#define dprintf(...) fprintf(stderr,__VA_ARGS__)
#define SS second
#define FF first
#define ls (k<<1)
#define rs (k<<1|1)
#define clr(a,x) memset(a,x,sizeof(a))
#define cpy(a,x) memcpy(a,x,sizeof(a))
#define file(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout)
#define SZ(x) ((int)x.size())
using namespace std;
template<class T> inline void gmin(T &x,const T &y){if(x>y) x=y;}
template<class T> inline void gmax(T &x,const T &y){if(x<y) x=y;}
const int BufferSize=1<<16;
char buffer[BufferSize],*Bufferhead,*Buffertail;
bool Terminal;
inline char Getchar(){
	if(Bufferhead==Buffertail){
		int l=fread(buffer,1,BufferSize,stdin);
		if(!l){Terminal=1;return 0;}
		Buffertail=(Bufferhead=buffer)+l;
	}
	return *Bufferhead++;
}
template<class T>inline bool read(T &x){
	x=0;char c=Getchar(),rev=0;
	while(c<'0'||c>'9'){rev|=c=='-';c=Getchar();if(Terminal)return 0;}
	while(c>='0'&&c<='9') x=x*10+c-'0',c=Getchar();
	if(c=='.'){
		c=Getchar();double t=0.1;
		while(c>='0'&&c<='9') x=x+(c-'0')*t,c=Getchar(),t=t/10;
	}
	x=rev?-x:x;
	return 1;
}
template<class T1,class T2> inline bool read(T1 &x,T2 &y){return read(x)&read(y);}
template<class T1,class T2,class T3> inline bool read(T1 &x,T2 &y,T3 &z){return read(x)&read(y)&read(z);}
template<class T1,class T2,class T3,class T4> inline bool read(T1 &x,T2 &y,T3 &z,T4 &w){return read(x)&read(y)&read(z)&read(w);}
inline bool reads(char *x){
	char c=Getchar();
	while(c<33||c>126){c=Getchar();if(Terminal)return 0;}
	while(c>=33&&c<=126) (*x++)=c,c=Getchar();
	*x=0;return 1;
}
template<class T>inline void print(T x,const char c='\n'){
	if(!x){putchar('0');putchar(c);return;}
	if(x<0) putchar('-'),x=-x;
	int m=0,a[20];
	while(x) a[m++]=x%10,x/=10;
	while(m--) putchar(a[m]+'0');
	putchar(c);
}
//--------------------------------head---------------------------------------------

const int inf=0x3f3f3f3f;
const int N=2005,M=100005,mod=1e9+7;
template<class T,class S> inline void ch(T &x,const S y){x=(x+y)%mod;}
inline int exp(int x,int y,const int mod=::mod){
	int ans=1;
	while(y){
		if(y&1) ans=(ll)ans*x%mod;
		x=(ll)x*x%mod;y>>=1;
	}return ans;
}

int n,k,dp[2][N],fac[N*N],ifac[N*N];

inline int c(int x,int y){
	return (ll)fac[x+y]*ifac[x]%mod*ifac[y]%mod;
}

int main(){
#ifdef rqgao2014
	freopen("input.txt","r",stdin);
#endif
	read(n,k);fac[0]=1;
	if(k==1){puts("1");return 0;}
	for(int i=1;i<=n*k;i++) fac[i]=(ll)fac[i-1]*i%mod;
	ifac[n*k]=exp(fac[n*k],mod-2);
	for(int i=n*k;i;i--) ifac[i-1]=(ll)ifac[i]*i%mod;
	
	dp[0][0]=1;
	for(int i=0;i<=n;i++)
		for(int j=1;j<=n;j++){
			if(i>j){dp[i&1][j]=0;continue;}
			dp[i&1][j]=((ll)dp[i&1][j-1]*c(i+(j-1)*(k-1),k-2)+dp[i-1&1][j])%mod;
		}
	printf("%lld\n",(ll)dp[n&1][n]*fac[n]%mod);
	return 0;
}

Measured memory_bytes: 31616
from copy import deepcopy
N, K = map(int, input().split())
A = list(map(int, input().split()))

partial = []
for i in range(N):
    tmp = list()
    for j in range(i, N):
        tmp.append(A[j])
        partial.append(sum(tmp))


ret = 0
p = 1
x = 0
for i in range(50, -1, -1):
    p = pow(2, i)
    k = 0
    for a in partial:
        if (p+x) & a == (p+x):
            k += 1
    if k >= K:
        ret += p
        x += p

print(ret)


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

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#ifdef VAMP
     #define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template < typename Arg1 >
    void __f(const char* name, Arg1&& arg1){
        cout << name << " = " << arg1 << std::endl;
    }
    template < typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names+1, ',');
        cout.write(names, comma - names) << " = " << arg1 <<" | ";
        __f(comma+1, args...);
    }
#else
    #define debug(...)
#endif

#define MAX 300005
#define ff first
#define ss second
#define FOR(i, x, y) for(int i = x; i < y; i++)
#define ROF(i, x, y) for(int i = x; i >= y; i--)
#define sf scanf

struct Node{
    int ff, ss;
    bool operator<(const Node &a)const{
        return ff>a.ff;
    }
};
priority_queue<Node> Q;

inline void insertToSet(int val, int cnt){
    if(Q.empty() or (Q.top().ff > val)) Q.push({val, cnt});//, debug("inserting", val, cnt);
    else {
        auto now = Q.top();
        Q.pop();
        Q.push({val, now.ss + cnt});
        // debug("inserting", val, now.ss + cnt);
    }
}

inline void addToSet(int add){
    // debug("adding", add);
    while(add){
        auto now = Q.top();
        Q.pop();
        // debug("now", add, now.ff, now.ss);
        if(now.ss <= add){
            insertToSet(now.ff+1, now.ss);
            add -= now.ss;
        }
        else{
            insertToSet(now.ff + 1, add);
            insertToSet(now.ff, now.ss - add);
            add = 0;
        }
    }
}

int ar[MAX];
int f[MAX];
int ff[MAX];
int ans[MAX];

int main(){
    #ifdef VAMP
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    memset(ans, -1, sizeof(ans));
    int n; sf("%d", &n);
    FOR(i, 0, n){
        sf("%d", &ar[i]);
        ++f[ar[i]];
    }
    sort(f+1, f+n+1);
    FOR(i, 1, n+1){
        ++ff[f[i]];
    }
    FOR(i, 0, n+1){
        if(ff[i]){
            // debug(i, ff[i]);
            Q.push({i, ff[i]});
        }
    }
    ROF(i, n, 1){
        if(Q.empty()) continue;
        auto now = Q.top();
        Q.pop();
        ans[i-1] = now.ff;
        // debug(i, ar[i-1]);
        if(i == 1) break;
        if(now.ss - 1 > 0) Q.push({now.ff, now.ss - 1});
        if(now.ff) addToSet(now.ff);
    }
    FOR(i, 0, n) printf("%d\n", ans[i]);

    return 0;
}

Measured memory_bytes: 4736
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=3000;
const int MAXH=100000;
const int MAXW=100000;
const int MOD=1000000007;
void inc(int &a,int b) { if((a+=b)>=MOD) a-=MOD; }
void dec(int &a,int b) { inc(a,MOD-b); }
struct P { int x,y; };
bool operator<(const P &a,const P &b) { if(a.x!=b.x) return a.x<b.x; return a.y<b.y; }

int h,w;
int n;
P p[MAXN];
P s,t;

int inv[MAXH+MAXW+1];
int fac[MAXH+MAXW+1];
int ifac[MAXH+MAXW+1];
int C(int n,int k) { if(k<0||k>n) return 0; return (ll)fac[n]*ifac[k]%MOD*ifac[n-k]%MOD; }
int calc(const P &a,const P &b) { if(a.x>b.x||a.y>b.y) return 0; return C(b.x-a.x+b.y-a.y,b.x-a.x); }

int dp[MAXN][2];

int solve() {
	inv[1]=1; FORE(i,2,MAXH+MAXW) inv[i]=(ll)(MOD-MOD/i)*inv[MOD%i]%MOD;
	fac[0]=1; FORE(i,1,MAXH+MAXW) fac[i]=(ll)fac[i-1]*i%MOD;
	ifac[0]=1; FORE(i,1,MAXH+MAXW) ifac[i]=(ll)ifac[i-1]*inv[i]%MOD;
	s.x=0,s.y=0,t.x=h-1,t.y=w-1;

	sort(p,p+n);
	REP(i,n) {
		dp[i][0]=0; dp[i][1]=calc(s,p[i]);
		REP(j,i) REP(k,2) inc(dp[i][1-k],(ll)dp[j][k]*calc(p[j],p[i])%MOD);
		//printf("(%d,%d): %d %d\n",p[i].x,p[i].y,dp[i][0],dp[i][1]);
	}
	int ret=calc(s,t);
	REP(i,n) REP(k,2) {
		if(k==0) inc(ret,(ll)dp[i][k]*calc(p[i],t)%MOD);
		if(k==1) dec(ret,(ll)dp[i][k]*calc(p[i],t)%MOD);
	}
	return ret;
}

void run() {
	scanf("%d%d%d",&h,&w,&n);
	REP(i,n) scanf("%d%d",&p[i].x,&p[i].y),--p[i].x,--p[i].y;
	printf("%d\n",solve());

}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 2688
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define VAL 100000
#define ll  long long
#define INF 10000000000000000LL
#define pll pair<long long , long long>
const int MAX=1e6+10;
const ll MOD=1e9+7;
const int TOT_PRIMES=19;
const int MAX_A=70;
using namespace std;
vector<int>adj[MAX];
ll take_p5(ll n){
	return (n*n*n*n*n);
}
int main() 
{
	ll n;
	cin>>n;
	ll arr[n+1];
	for(int i=1;i<=n;i++)
		cin>>arr[i];
	map<ll, ll>mp;
	ll ans=0;
	for(int i=1;i<=n;i++){
		ll p=i-arr[i];
		ans=ans+mp[p];
		mp[i+arr[i]]++;
	}
	cout<<ans;
}

Measured memory_bytes: 51316
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll,ll> pll;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define MOD 1000000007
#define ARRAY_MAX 100005

const ll INF = 1e9+7;


int main(){

    ll n,k,x = 0;
    cin >> n >> k;
    ll maxi = -1;
    vector<ll> a(n);

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

    for(ll i = 40;i >= 0;i--){
        ll cnt = 0;
        for(ll j = 0;j < n;j++){
            if((a[j]>>i)&1LL){
                //a[j]のiビット目が立っている場合
                cnt++;
            }
        }
        if((cnt < n-cnt) && (x | (1LL << i)) <= k){
            x |= (1LL << i);
        }
    }
    
    ll ans = 0;
    for(int i = 0;i < n;i++){
        ans += x^a[i];
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 1024
import sys
from itertools import product

sys.setrecursionlimit(200000)


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n + 1)]
        self.rank = [0] * (n + 1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)


H, W = il()
S = imi(H, str)
tree = UnionFind(H * W)
for i, j in product(range(H), range(W)):
    for d in ((-1, 0), (0, -1), (1, 0), (0, 1)):
        x = i + d[0]
        y = j + d[1]
        if 0 <= x < H and 0 <= y < W:
            if S[i][j] != S[x][y]:
                tree.union((i * W + j), (x * W + y))

dot = [0] * (H * W)
sharp = [0] * (H * W)
for i, j in product(range(H), range(W)):
    if S[i][j] == ".":
        dot[tree.find(i * W + j)] += 1
    else:
        sharp[tree.find(i * W + j)] += 1

ans = 0
for i in range(H * W):
    ans += dot[i] * sharp[i]
print(ans)

Measured memory_bytes: 13512
#include <bits/stdc++.h>
#define fastio() ios_base::sync_with_stdio(false);
#define rmod(x,y) ((((x)%y)+y)%y)
using namespace std;
typedef long long ll;
typedef long double ld;

const int maxn = 1e5+5, maxd = 101;
const ll mod = 1e9+7;

string S;
int N, D;

ll dp[2][maxn][maxd][2];

ll solve(bool st, int n, int s, bool can){
	if (n == N) return st&&(s == 0);
	if (dp[st][n][s][can] != -1) return dp[st][n][s][can];
	ll ret = 0;
	//put zero
	ret += solve(st,n+1, s, can||(S[n]>'0'));
	if (!can){
		for(char i = '1'; i<S[n]; i++) //put smaller char
			(ret+= solve(1, n+1, (s+(i-'0'))%D, 1))%mod;
		if (S[n]>'0') ret+= solve(1, n+1, (s+(S[n]-'0'))%D, 0);
	}
	else{ //put whatever
		for(int i = 1; i<10; i++)
			(ret += solve(1, n+1,(s+i)%D, 1))%=mod;
	}
	return dp[st][n][s][can] = ret%mod;
}

int main(){
	memset(dp, -1, sizeof(dp));
	cin >> S >> D;
	N = S.size();
	cout << solve(0,0,0,0) << endl;
	return 0;
}


Measured memory_bytes: 316672
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""


input:
5 12
0 1 4
0 2 3
1 1 2
1 3 4
1 1 4
1 3 2
0 1 3
1 2 4
1 3 0
0 0 4
1 0 2
1 3 0

output:
0
0
1
1
1
0
1
1

"""

import sys


class UnionFind(object):
    __slots__ = ('size', 'height_rank', 'ancestors')

    def __init__(self, size):
        self.size = int(size)
        self.height_rank = [0] * self.size
        self.ancestors = [i for i in range(self.size)]

    def __find(self, x):
        if x != self.ancestors[x]:
            self.ancestors[x] = self.__find(self.ancestors[x])
        return self.ancestors[x]

    def same(self, x, y):
        return self.__find(x) == self.__find(y)

    def __link(self, x, y):
        if self.height_rank[x] > self.height_rank[y]:
            self.ancestors[y] = x
        else:
            self.ancestors[x] = y
            if self.height_rank[x] == self.height_rank[y]:
                self.height_rank[y] += 1

    def union(self, x, y):
        self.__link(self.__find(x), self.__find(y))


def action(cmd_list):
    for each in cmd_list:
        cmd, ele_1, ele_2 = map(int, each)
        if cmd == 0:
            case.union(ele_1, ele_2)
        elif cmd == 1:
            print(int(case.same(ele_1, ele_2)))
    return case


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    e_num, c_num = map(int, _input[0].split())
    c_list = map(lambda x: x.split(), _input[1:])

    case = UnionFind(size=e_num)

    ans = action(c_list)

Measured memory_bytes: 16540
#include<algorithm> 
#include<bitset> 
#include<memory.h> 
#include<cstdio> 
#include<cmath>
#include<cstring> 
#define maxn 400010
#define ll long long
#define pa pair<ll,ll> 
#define ld long double 
#define For(i,x,y)  for(ll i=x;i<=y;++i) 
#define FOr(i,x,y)  for(ll i=x;i>=y;--i) 
using namespace std; 
inline ll read(){   ll x=0,f=1;char ch=getchar();   while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}  while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}  return x*f; } 
inline void write(ll x){    if (x<0) putchar('-'),x=-x; if (x>=10) write(x/10);   putchar(x%10+'0');  } 
inline void writeln(ll x){ write(x);   puts("");   }
char s[maxn];
ll n,a[maxn],ans;
int main(){
	scanf("%s",s+1);	n=strlen(s+1);
	For(i,1,n)	ans+=i-a[s[i]],a[s[i]]++;
	writeln(ans-n+1);
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <stack>
using namespace std;
int main(){
  string s,f;
  cin >> s;
  f=s;
  stack<char> st;
  while(s!="ABC"&&s.size()>2){
    char x;
    int ss=s.size();
    if(s.substr(0,3)=="ABC")x='A';
    else if(s.substr(ss-3)=="ABC")x='C';
    else x='B';
    int i,j;
    string t="";
    for(i=0;i<ss-2;i++){
      if(s.substr(i,3)=="ABC"){
        t+=x;
        i+=2;
      }
      else t+=s[i];
    }
    t+=s.substr(i);
    //cout << t << endl;
    if(s==t)break;
    st.push(x);
    s=t;
  }
  if(s=="ABC"){
    while(!st.empty()){
      int ss=s.size();
      char x = st.top();
      st.pop();
      string t="";
      for(int i=0;i<ss;i++){
        if(s[i]==x)t+="ABC";
        else t+=s[i];
      }
      s=t;
    }
    if(s==f)cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  else cout << "No" << endl;
  return 0;
}



Measured memory_bytes: 3260
#include<iostream>

using namespace std;


int main()
{
    int L,R;cin >> L >> R;

    if(R - L > 2019)
    {
        cout << 0 << endl;
        return 0;
    }
    int res= 2019*2019;
    for(int i=L;i < R; ++i)
    {
        for(int j = i +1;j<=R;++j)
        {
            res = min(res,(i%2019) * (j%2019) %2019);
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;using namespace std;int main() {int n; cin >> n;ll x[1005],y[1005];int a;for (int i=0;i<n;i++){cin>>x[i]>>y[i];if(i==0)a=abs(x[i]+y[i])%2;else if(a!=abs(x[i]+y[i])%2){cout<<-1<<endl;return 0;}}vector<string> w(n,""),p(n,"");if(a==0){cout<<32<<endl<<1<<" ";for(int i=0;i<=30;i++)cout<<(1<<i)<<" ";for (int i=0;i<n;i++){p[i]+="R";x[i]-=1;}}else{cout <<31<<endl;for (int i=0;i<=30;i++)cout<<(1<<i)<<" ";}cout<<endl;for(int i=0;i<n;i++){for (int j=30;j>=0;j--){ll d=1<<j;ll nx=d-1;if(abs(x[i]-d)+abs(y[i])<=nx){w[i]="R"+w[i];x[i]-=d;}else if(abs(x[i]+d)+abs(y[i])<=nx){w[i]="L"+w[i];x[i]+=d;}else if(abs(x[i])+abs(y[i]+d)<=nx){w[i]="D"+w[i];y[i]+=d;}else{w[i]="U"+w[i];y[i]-=d;}}cout<<p[i]+w[i]<<endl;}return 0;}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<bitset>
#include<string>

using namespace std;

int main() {
	string s;
	int x, y;
	cin >> s >> x >> y;
	
	vector<int> move_x, move_y;
	bool is_x = true;//x軸の方向を向いてるか？
	int streak = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'F')streak++;
		else {
			if (is_x && streak != 0)move_x.push_back(streak);
			else if(streak != 0)move_y.push_back(streak);
			streak = 0;
			is_x = !is_x;
		}
	}
	if (streak != 0) {
		if (is_x && streak != 0)move_x.push_back(streak);
		else if (streak != 0)move_y.push_back(streak);
		streak = 0;
	}

	bitset<20000> dpx, dpy;
	const int geta = 10000;
	dpx[geta + 0] = true;
	for (int i = 0; i < move_x.size(); i++) {
		if (s[0] == 'F' && i == 0) {
			auto tmp = (dpx << move_x[i]);
			dpx = tmp;
			//最初は右にしか行けない
		}
		else {
			auto tmp = (dpx << move_x[i]);
			tmp |= (dpx >> move_x[i]);
			dpx = tmp;
		}
	}

	dpy[geta + 0] = true;
	for (int i = 0; i < move_y.size(); i++) {
		auto tmp = (dpy << move_y[i]);
		tmp |= (dpy >> move_y[i]);
		dpy = tmp;
	}
	if (dpx[geta + x] && dpy[geta + y]) {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"

#define rep(i,n) for (int i = 0; i < (n); i++)
#define ru(a,b) (((a)+((b)-1)) / (b))   //切り上げ(a/b)
#define dump(x)  cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
	int n;
	cin >> n;

	vector<int> a(n);
	rep(i, n) cin >> a[i];

	rep(i, n)
	{
		if (a[i] % 2 == 0)
		{
			if ((a[i] % 3 == 0) || (a[i] % 5 == 0))
			{
			}
			else
			{
				cout << "DENIED" << endl;
				return 0;
			}
		}
	}


	cout << "APPROVED" << endl;
	return 0;
}

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

#define rep(i, n) for(int i=0; i < (n); ++i)
#define ll long long

const int mod = 1000000007;
//const int mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; }}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; }}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    double h , a; cin >> h >> a;

    int ans = ceil(h / a);
    cout << ans << '\n';
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES  // M_PI等のフラグ

#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <map>
#include <vector>
#include <list>

#define MOD 1000000007
#define COUNTOF(array) (sizeof(array)/sizeof(array[0]))

using namespace std;

string replace_with_str(string str, string str_from, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(str_from, pos), pos != string::npos) {
        str.replace(pos, str_from.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

void solve(){
    string S;
    string T;
    cin >> S >> T;

    int ans = 0;
    for(int i=0; i<S.size(); i++) {
        if (S[i] != T[i]) ans++;
    }

    cout << ans << endl;
}

int main(int argc, char const *argv[]){
    solve();
    return 0;
}

Measured memory_bytes: 3844
#include<stdio.h>
int main(void){
	int a,b,c;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	if(a<b&&b<c){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

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

int main(void){
    int n;
    map<int, int> m1;
    map<int, int> m2;
    pair<int, int> max1;
    pair<int, int> max1_;
    pair<int, int> max2;
    pair<int, int> max2_;

    cin >> n;

    int tmp;
    max1 = {0, 0};
    max2 = {0, 0};
    rep(i, n){
        cin >> tmp;
        if(i % 2 == 1){
            m1[tmp]++;
            if(max1.second <= m1[tmp]){
                if(max1.first == tmp)
                    max1.second = m1[tmp];
                else{
                    max1_ = {max1.first, max1.second};
                    max1 = {tmp, m1[tmp]};
                }
            }else if(max1_.second <= m1[tmp]){
                if(max1.first == tmp)
                    max1_.second = m1[tmp];
                else{
                    max1_ = {tmp, m1[tmp]};
                }
            }
        }
        else{
            m2[tmp]++;
            if(max2.second <= m2[tmp]){
                if(max2.first == tmp)
                    max2.second = m2[tmp];
                else{
                    max2_ = {max2.first, max2.second};
                    max2 = {tmp, m2[tmp]};
                }
            }else if(max2_.second <= m2[tmp]){
                if(max2.first == tmp)
                    max2_.second = m2[tmp];
                else{
                    max2_ = {tmp, m2[tmp]};
                }
            }
        }
    }

    if(max1.first != max2.first){
        cout << n - max1.second - max2.second;
    }else{
        cout << min(n - max1.second - max2_.second, n - max1_.second -max2.second);
    }
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<ll,ll>;
const int inf=1e9+7;
const ll INF=9e18;
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

ll dp[1100][1100][2][2][2];
//dp[i][j][k][l][m]=iこ目　jこ選んだ時の絶対値の最大値 k,l,mは正負を表す　0 - 1 +

int main(){cout<<fixed<<setprecision(20);
		   //dpかな
           ll n,m;
           cin>>n>>m;
           vll x(n+1),y(n+1),z(n+1);
           rep(i,0,n){
             cin>>x[i+1]>>y[i+1]>>z[i+1];
           }
           rep(i,1,n+1)rep(j,0,m+1)rep(p,0,2)rep(q,0,2)rep(r,0,2){
             //選ばない
             dp[i][j][p][q][r]+=dp[i-1][j][p][q][r];
             
             //選ぶ
             if(j-1>=0){
               if(j!=i)chmax(dp[i][j][p][q][r],dp[i-1][j-1][p][q][r]+(p ? x[i]:-x[i])+(q ? y[i]:-y[i])+(r ? z[i]:-z[i]));
               
               else dp[i][j][p][q][r]=dp[i-1][j-1][p][q][r]+(p ? x[i]:-x[i])+(q ? y[i]:-y[i])+(r ? z[i]:-z[i]);
             }
           }
           ll ans=0;
           rep(i,0,2)rep(j,0,2)rep(k,0,2)chmax(ans,dp[n][m][i][j][k]);
           cout<<ans<<endl;
}



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

int main() {
    int N;
    cin >> N;
    vector<string> edge(N);
    for (int i = 0; i < N; i++) {
        cin >> edge[i];
    }
    vector<int> bi(N, -1);
    queue<pair<int, int>> q;
    q.push({0, -1});
    while (!q.empty()) {
        int pos = q.front().first;
        int pre = q.front().second;
        q.pop();
        if (bi[pos] != -1){
            if (bi[pre] == bi[pos]) {
                cout << "-1\n";
                return 0;
            }
            else continue;
        }
        if (pos == 0) bi[0] = 0;
        else bi[pos] = 1 - bi[pre];
        for (int i = 0; i < N; i++) {
            if (edge[pos][i] == '1') q.push({i, pos});
        }
    }
    
    vector<vector<int>> dist(N, vector<int>(N, 200));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (edge[i][j] == '1') dist[i][j] = 1;
            if (i == j) dist[i][j] = 0;
        }
    }
    
    for (int k = 0; k < N; k++) {
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
    
    int ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            ans = max(ans, dist[i][j]);
        }
    }
    cout << ans+1 << endl;
    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

class Main {

	int W = 0,H = 0,I = 0,F = 0;

	public void pr() {

		Scanner sc = new Scanner(System.in);

		H = sc.nextInt();

		W = sc.nextInt();

		while(H != 0 || W != 0) {

			for(I = 0;I < H; I++) {

				for(F = 0;F < W; F++) {

					System.out.print("#");

					if(F == W-1) {

						System.out.println();

					}

				}

			}

				System.out.println();

			H = sc.nextInt();

			W = sc.nextInt();

		}

	}

	public static void main(String[] args) {

		new Main().pr();

	}

}

Measured memory_bytes: 35692
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}

//INSERT ABOVE HERE
signed main(){
  int n;
  string s;
  cin>>n>>s;
  if(s.substr(0,n/2)+s.substr(0,n/2)==s) drop("Yes");
  drop("No");
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
double f(double x){
    return x * x;
}

int main(void){
    double s[1001], n, m, sum, ans;
    while(1){
        cin >> n;
        if(n == 0)  break;
        sum = 0;
        for(int i = 0; i < n; i++){
            cin >> s[i];
            sum += s[i];
        }
        m = sum / n;
        ans = 0;
        for(int i = 0; i < n; i++){
            ans += f(s[i] - m);
        }
        cout << fixed << setprecision(8) << sqrt(ans / n) << endl;

    }
    
    return 0;
}



Measured memory_bytes: 3260
findstr = raw_input().strip()
findstr = findstr.lower()
inlist = []
while True:
    tmplist = (raw_input().replace("\r"," ")).split()
    # print tmplist
    if tmplist[0] == "END_OF_TEXT":
        break
    inlist.extend(tmplist)
count = 0
for i in xrange(len(inlist)):
    if inlist[i].lower() == findstr.lower():
        count+=1
print count

Measured memory_bytes: 6308
#include <bits/stdc++.h>
using namespace std;
#define DEBUG(x)                   cout << '>' << #x << ':' << x << endl;
typedef long long int ll;
int main()
{
    int n,k,arr[100010];
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    sort(arr,arr+n);
    int ans=lower_bound(arr,arr+n,k)-arr;
    cout<<n-ans<<endl;
}



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

vector<int> divisor(int n){
	vector<int> res;
	for(int i = 1; i*i <= n; i++){
		if(n%i==0){
			res.push_back(i);
			if(i*i != n) res.push_back(n/i);
		}
	}
	sort(res.rbegin(), res.rend());
	return res;
}

int main(){
	int n,k;
	cin >> n >> k;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	
	int sum = 0;
	rep(i,n) sum += a[i];
	
	vector<int> div;
	div = divisor(sum);
	
	rep(i,div.size()-1){
		vector<int> moda(n);
		rep(j,n) moda[j] = a[j] % div[i];
		sort(moda.begin(), moda.end());
		
		vector<int> moda2(n);
		rep(j,n) moda2[j] = div[i] - moda[j];
		reverse(moda2.begin(), moda2.end());
		
		vector<int> minus(n-1);
		minus[0] = moda[0];
		rep(j,n-2) minus[j+1] = minus[j] + moda[j+1];
		
		vector<int> plus(n-1);
		plus[0] = moda2[0];
		rep(j,n-2) plus[j+1] = plus[j] + moda2[j+1];
		
		rep(j,n-1){
			if(minus[j] == plus[n-2-j] && minus[j] <= k){
				cout << div[i] << endl;
				return 0;
			}
		}
	}

	cout << 1 << endl;
	return 0;
}

Measured memory_bytes: 256
import sys

def main():
    N, X = map(int, input().split())
    A = list(map(int, input().split()))

    cnt = 0
    D = 0
    for a in A:
        D += a
        cnt += 1
        if D > X:
            cnt -= 1
            break

    return cnt+1


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 3060
# -*- coding: utf-8 -*-

def solve():
    N = int(input())
    if N % 2:
        res = 0
    else:
        q = 10
        p5 = 0
        while N // q:
            p5 += N // q
            q *= 5
        q = 2
        p2 = 0
        while N // q:
            p2 += N // q
            q *= 2
        res = min(p2, p5)
    return str(res)

if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 3060
#include<iostream>
using namespace std;

int main() {
	int A, B, C, X;
	cin >> A >> B >> C >> X;
	int sum = 0; // 組み合わせの数
	for (int i = 0;i <= A;i ++) { // 500円玉を使う枚数
		for (int j = 0;j <= B;j ++) { // 100円玉を使う枚数
			if (i * 500 + j * 100 > X || X - i * 500 - j * 100 > C * 50) continue;
			sum ++;
			// もし、この500円玉と100円玉でXを超えず、なおかつ残った額を50円玉で払いきれるならこの組み合わせを追加
			// cout << "(" << i << "," << j << "," << (X - i * 500 - j * 100) / 50 << ")" << endl; // デバッグ用
		}
	}
	cout << sum;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

二変数以上の変数がある時は、ある変数を固定して考えると分かりやすくなる
この場合、まず500円玉をi枚、100円玉をj枚使う時、50円玉を払う払い方は何通りか……と考えると、当然だが0か1
後は0<=i<=A、0<=j<=Bについて順に考えてから総和すればおｋ
オーダーはO(AB)、全然余裕
*/

Measured memory_bytes: 256
import java.io.*;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) {
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		try {
			int n;
			
			while(true){
				/* input from here */
				String[] l = r.readLine().split(" ");
				n = Integer.parseInt(l[0]);
				if(n==0){
					break;
				}
				int begin = Integer.parseInt(l[1])+1, end = Integer.parseInt(l[2]);
				
				int[] available = new int[end-begin+2];
				Arrays.fill(available,n);
				

				int[][][] cmduration = new int[n][10][2];
				int[] numofcm = new int[n];
				for(int i=0;i<n;i++){
					numofcm[i] = 0;
					int c = Integer.parseInt(r.readLine());
					String[] cms = r.readLine().split(" ");
					for(int j=0;j<c;j++){
						cmduration[i][j][0] = Integer.parseInt(cms[2*j])+1;
						cmduration[i][j][1] = Integer.parseInt(cms[2*j+1]);
						numofcm[i]++;
					}
				}
				
				//look for available channels
				int[] cmpos = new int[n];
				Arrays.fill(cmpos, 0);
				for(int i=0;i<n;i++){
					while(cmpos[i]<numofcm[i]){
						for(int j=cmduration[i][cmpos[i]][0];j<=cmduration[i][cmpos[i]][1];j++){
							available[j-begin] -= 1;
						}
						cmpos[i]++;
					}
				}
				
				int longest = 0;
				for(int i=0;i<=end-begin;i++){
					//System.out.print(i + " " + available[i] + " ");
					int sum = 0;
					while(available[i]!=0&&i<available.length-1){
						if(i%100>=60){
							i++;
							continue;
						}
						i++;
						sum++;
					}
					if(sum>longest){
						longest = sum;
					}
				}
				System.out.println(longest);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

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

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

using namespace std;
using i64 = long long int;

using P = pair<i64, i64>;

int main(){
    i64 n, m;
    cin >> n >> m;
    vector<i64> a(m), b(m), c(m);
    rep(i, m){
        cin >> a[i] >> b[i];
        vector<bool> f(13, false);
        rep(j, b[i]){
            i64 tc;
            cin >> tc;
            f[tc] = true;
        }
        rep(j, 12){
            if(f[12 - j]) c[i] = c[i] * 2 + 1;
            else c[i] *= 2;
        }
    }
    vector<i64> dp(1<<n, -1);
    dp[0] = 0;
    rep(i, 1<<n){
        if(dp[i] == -1) continue;
        rep(j, m){
            if(dp[i | c[j]] == -1 || dp[i | c[j]] > dp[i] + a[j]){
                dp[i | c[j]] = dp[i] + a[j];
            }
        }
    }
    cout << dp[(1<<n) - 1] << endl;
}

// dp[S]

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

#define llint long long int

using namespace std;

int main(){
    int N;

    cin >> N;

    vector<llint> A(N);

    for(int i = 0; i < N; i ++){
        cin >> A[i];
    }
    sort(A.begin(), A.end(), greater<llint>());

    llint ans = A[0];

    for(int i = 1, j = 1; i < N - 1; i ++){
        ans += A[j];

        if(i % 2 == 0){
            j ++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4840
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {

    int N,M;
    String[] s,t;

    private void solve() {
        N = nextInt();
        s = new String[N];
        for(int i = 0;i < N;i++) {
            s[i] = next();
        }

        M = nextInt();
        t = new String[M];
        for(int i = 0;i < M;i++) {
            t[i] = next();
        }

        HashMap<String,Integer> map = new HashMap<>();
        for(int i = 0;i < N;i++) {
            if (map.containsKey(s[i])) {
                map.put(s[i],map.get(s[i]) + 1);
            } else {
                map.put(s[i],1);
            }
        }

        for(int i = 0;i < M;i++) {
            if (map.containsKey(t[i])) {
                map.put(t[i],map.get(t[i]) - 1);
            } else {
                map.put(t[i], -1);
            }
        }

        int ans = 0;
        for(String st : map.keySet()) {
            if (map.get(st) > 0 && map.get(st) > ans) {
                ans = map.get(st);
            }
        }

        out.println(ans);

    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[2048];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Measured memory_bytes: 21332
#include <iostream>

int main()
{
  int n, s;
  while(std::cin >> n && n > 0){
    int average = 0;
    int max = 0;
    int min = 1000;
    for(int i=0; i<n; i++){
      int tmp;
      std::cin >> tmp;
      if(tmp > max){ max = tmp; };
      if(tmp < min){ min = tmp; };
      average += tmp;
    }
    average -= (max + min);
    std::cout << (average / (n - 2)) << std::endl;
  }
  return 0;
}

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

#define int long long

int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int A, B, C, D;

signed main() {
    cin >> A >> B >> C >> D;
    if (A + B < C + D) {
        cout << "Right" << endl;
    } else if (A + B > C + D) {
        cout << "Left" << endl;
    } else {
        cout << "Balanced" << endl;
    }
    return 0;
}


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

using namespace std;

class ExtendedEuclid{
public:
    long X, Y;
    long A, B, C;
    // C = GCD(X, Y)
    // C = A*X + B*Y

    ExtendedEuclid(long x, long y){
        X = x;
        Y = y;
    }

    void calc_gcd(){
        long a, b;
        long r, q;
        long u_2=1, u_1=0, v_2=0, v_1=1, u, v;
        a=X;
        b=Y;

        r=a%b;
        q=a/b;
        u=u_2-q*u_1;
        v=v_2-q*v_1;

        while(r!=0){
            a=b;
            b=r;
            r=a%b;

            q=a/b;
            u_2=u_1;
            u_1=u;
            v_2=v_1;
            v_1=v;

            u=u_2-q*u_1;
            v=v_2-q*v_1;
        }
        A = u_1;
        B = v_1;
        C = b;
    }
};

int main(){
    int N;
    cin>>N;
    vector<long> A(N);

    for(int i=0; i<N; ++i){
        cin>>A[i];
    }
    if(N==2){
        cout<<max(A[0], A[1])<<endl;
        return 0;
    }
    sort(A.begin(), A.end());

    vector<long> l(N), r(N);
    l[0] = A[0];
    for(int i=1; i<N; ++i){
        ExtendedEuclid extendedeuclid2(l[i-1], A[i]);
        extendedeuclid2.calc_gcd();
        l[i] = extendedeuclid2.C;
    }

    r[N-1] = A[N-1];
    for(int i=N-2; i>=0; --i){
        ExtendedEuclid extendedeuclid2(r[i+1], A[i]);
        extendedeuclid2.calc_gcd();
        r[i] = extendedeuclid2.C;
    }

    long m = max(l[N-2], r[1]);
    for(int i=0; i<N-2; ++i){
        ExtendedEuclid extendedeuclid2(l[i], r[i+2]);
        extendedeuclid2.calc_gcd();
        m = max(m, extendedeuclid2.C);
    }

    cout<<m<<endl;

    return 0;
}


Measured memory_bytes: 2560
#define  REP(i, s, e) for (int i = s; i <= e; i++)
#define DREP(i, s, e) for (int i = s; i >= e; i--)
#define DEBUG fprintf(stderr, "Passing [%s] in Line %d\n", __FUNCTION__, __LINE__)

#define chkmax(a, b) a = max(a, b)
#define chkmin(a, b) a = min(a, b)

#include <iostream>
#include <cstdio>
#define int long long
using namespace std;
const int maxn = 5000 + 10, MOD = 1e9 + 7; 

int bg[maxn], ne[maxn << 1], to[maxn << 1], e;
inline void add(int x, int y)
{
	e++;
	to[e] = y;
	ne[e] = bg[x];
	bg[x] = e;
}
int n, a[maxn]; 

int g[maxn], dp[maxn][maxn], siz[maxn]; 

int t[maxn];
void dfs(int x, int fa = -1)
{
	dp[x][1] = 1;
	siz[x] = 1;
	for (int i = bg[x]; i ; i = ne[i])
		if (to[i] ^ fa)
		{
			dfs(to[i], x);
			REP(j, 0, siz[x])
				REP(k, 0, siz[to[i]])
					(t[j + k] += dp[x][j] * dp[to[i]][k] % MOD) %= MOD; 
			siz[x] += siz[to[i]];
			REP(j, 0, siz[x]) dp[x][j] = t[j], t[j] = 0;
		}
	int &sum = dp[x][0];
	sum = 0;
	REP(i, 0, siz[x]) sum += -dp[x][i] * g[i] % MOD, i++;
	sum %= MOD;
}

signed main()
{
#ifdef CraZYali
	freopen("E.in", "r", stdin);
	freopen("E.out", "w", stdout);
#endif
	cin >> n;
	REP(i, 2, n)
	{
		int x, y;
		scanf("%lld%lld", &x, &y);
		add(x, y);add(y, x);
	}
	g[0] = 1; 
	REP(i, 2, n) g[i] = g[i-2] * (i-1) % MOD, i++;
	dfs(1);  
	cout << (-dp[1][0] % MOD + MOD) % MOD << endl;
	return 0; 
} 


Measured memory_bytes: 195072
// Aizu 2204: Final Examination!
// 2017.9.20 bal4u@uu

#include <stdio.h>

int main()
{
	int n, max, min, i, a, s;

	while (scanf("%d", &n) && n) {
		max = 0, min = 500;
		while (n-- > 0) {
			for (s = i = 0; i < 5; i++) scanf("%d", &a), s += a;
			if (s < min) min = s;
			if (s > max) max = s;
		}
		printf("%d %d\n", max, min);
	}
	return 0;
}

Measured memory_bytes: 1720
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int matrix[][] = new int[2][n];
		for(int i=0; i<2; i++) {
			for(int j=0; j<n; j++) {
				matrix[i][j] = scan.nextInt();
			}
		}
		scan.close();
		int cur, ans = 0;
		
		for(int i=0; i<n; i++) {
			cur = 0;
			for(int j=0, k=0; j<n; j++) {
				cur += matrix[k][j];
				if(j == n-(i+1)) {
					k++;
					cur += matrix[k][j];
				}
			}
			if(cur > ans) ans = cur;
		}
		
		System.out.println(ans);
	}

}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

string ans = "";
int a,b,c;
int main() {
    cin >> a >> b >> c;

    if (a < b)
    {
        if(c < b && c > a)
            ans = "Yes";
        else
            ans = "No";
    }
    else
    {
        if(c > b && c < a)
            ans = "Yes";
        else
            ans = "No";
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
let k=[0;1;2;3];;
let h()=Scanf.scanf"%d %d %d %d "(fun a b c d->[a;b;c;d]);;
let rec f()=
  let a,b=h(),h()in
  let g(m,n)s i=
    let z(m,n)x j=
      if x=s then
        if i=j then(m+1,n) else(m,n+1)
      else(m,n)
    in
    List.fold_left2 z(m,n)a k
  in
  let m,n=List.fold_left2 g(0,0)b k in
  f(Printf.printf "%d %d\n"m n);;
try f()with _->()

Measured memory_bytes: 2368
#include <stdio.h>
int main(void)
{
  int x;
  scanf("%d", &x);
  if (x == 0)
  {
    printf("%d", 1);
  }
  else
  {
    if (x == 1)
    {
      printf("%d", 0);
    }
    else
    {
    }
  }
  return 0;
}

Measured memory_bytes: 1708
#include <iostream>
#include <vector>

using namespace std;

int main(void) {
  int N, M;
  cin >> N >> M;
  vector<int> A(N);
  int total = 0;
  for (auto &x : A) {
    cin >> x;
    total += x;
  }

  int cnt = 0;
  for (auto x : A) {
    if (x * 4 * M >= total)
      cnt++;
  }

  cout << (cnt >= M ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a=[list(map(int,input().split())) for i in range(n)]
a.sort()
dr=0
i=0
pr=0
while(dr<m):
  if dr+a[i][1]>=m:
    pr+=(m-dr)*a[i][0]
    dr+=m-dr
  else:
    dr+=a[i][1]
    pr+=a[i][0]*a[i][1]
  i+=1
print(pr)


Measured memory_bytes: 27760
#include<iostream>
using namespace std;

int main()
{
  int n;
  long long int minimum;
  cin>>n;
  long long int* data = new long long int[n];
  for(int i=0;i<n;i++)
  {
    cin>>data[i];
  }
  long long int** cost = new long long int*[n];
  long long int** sum = new long long int*[n];
  for(int i=0;i<n;i++)
  {
    cost[i] = new long long int[n];
  }
  for(int i=0;i<n;i++)
  {
    sum[i] = new long long int[n];
  }
  for(int i=0; i<n; i++)
  {
    cost[i][i] = 0;
    sum[i][i] = data[i];
  }
  for(int j=1; j<n;j++)
  {
    for(int i=0; i+j<n;i++)
    {
      minimum = cost[i][i] + cost[i+1][i+j];
      for(int k=1; k<j; k++)
      {
        minimum = min(minimum ,  cost[i][i+k] + cost[i+k+1][i+j] );
      }
      sum[i][i+j] = sum[i][i+j-1] + data[i+j];
      cost[i][i+j] = minimum + sum[i][i+j];
    }
  }
  cout<<cost[0][n-1];
  return 0;
}


Measured memory_bytes: 2816
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;

int N;
int d[100], cnt[100];

int main(){
	cin >> N;
	
	for(int i=0; i<100; i++){
		cnt[i] = 0;
	}
	
	for(int i=0; i<N; i++){
		cin >> d[i];
		if(cnt[d[i]-1] == 0){cnt[d[i]-1] = 1;}
	}
	
	int ans = 0;
	for(int i=0; i<100; i++){
		ans += cnt[i];
	}
	
	cout << ans << endl;
	
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
long long N,h,n;
cin>>N;
for(h=1;h<3051;h++){
for(n=h;n<3501;n++){
if (4*h*n == N*n + N*h){continue;}
if( N*h*n % (4*h*n - N*n - N*h) || (N*h*n / (4*h*n - N*n - N*h) <1) ){continue;}
cout<<n<<" "<<h<<" "<<(N*h*n / (4*h*n - N*n - N*h));
return 0;
}
}
}

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

int main ()
{
    int ara[200];
    memset (ara, 0, sizeof(ara));
    string s;
    cin >> s;
    for (int i = 0; s[i]; i++){
        int x = s[i];
        ara[x]++;
    }
    for (int i = 97; i<=122; i++){
        if (ara[i]==0){
            char ch = i;
            cout << ch;
            return 0;
        }
    }
    cout << "None";
    return 0;
}



Measured memory_bytes: 512
MOD = 10**9 + 7


def main():
    S = input()
    N = len(S)
    pre_hatena = S[:1].count("?")
    a = S[:1].count("A")
    post_hatena = S[2:].count("?")
    c = S[2:].count("C")

    ans = 0
    for i in range(1, N-1):
        if S[i] == "?" or S[i] == "B":
            pre_pow = pow(3, pre_hatena-1, MOD)
            pre = ((pre_pow * 3) % MOD) * a + pre_pow * pre_hatena
            post_pow = pow(3, post_hatena-1, MOD)
            post = ((post_pow * 3) % MOD) * c + post_pow * post_hatena
            ans += pre * post
            ans %= MOD
        if S[i] == "?":
            pre_hatena += 1
        if S[i] == "A":
            a += 1
        if S[i+1] == "?":
            post_hatena -= 1
        if S[i+1] == "C":
            c -= 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9156