akhauriyash/Code-Regression huggingface dataset:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)


def combination(n, r, mod=10 ** 9 + 7):
    n1, r = n + 1, min(r, n - r)
    numer = denom = 1
    for i in range(1, r + 1):
        numer = numer * (n1 - i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod - 2, mod) % mod


x, y = map(int, readline().split())
if (x + y) % 3 != 0 or not (x <= 2 * y and y <= 2 * x):
    print(0)
else:
    n = (x + y) // 3
    print(combination(n, y - n))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int LOG = 18;
const int MAXN = 53;

LL nCr[MAXN][MAXN];

LL f(int n, int k) {
    LL ans = 0;
    for (int i = 1; i <= n && i <= k; i++) {
        ans += nCr[n][i];
    }
    return ans;
}

int main() {
    nCr[0][0] = 1;
    for (int n = 1; n < MAXN; n++) {
        nCr[n][0] = 1;
        for (int r = 1; r <= n; r++) {
            nCr[n][r] = nCr[n-1][r]+nCr[n-1][r-1];
        }
    }

    int n, k, s, t;
    cin >> n >> k >> s >> t;

    if ((s&t) != s) {
        cout << 0 << endl;
        return 0;
    }

    vector< int >A;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;

        bool okay = true;
        int y = 0;
        for (int j = 0, l = 0; j < LOG && okay; j++) {
            int _x = (x>>j)&1;
            int _s = (s>>j)&1;
            int _t = (t>>j)&1;

            if (_s == 1 && _x == 0)         okay = false;
            else if (_t == 0 && _x == 1)    okay = false;
            else if (_s == 0 && _t == 1) {
                y |= _x << l;
                l++;
            }
        }

        if (okay) {
//            cout << x << " -> " << y << endl;
            A.push_back(y);
        }
    }

    int L = 0;
    for (int j = 0; j < LOG; j++) {
        int _s = (s>>j)&1;
        int _t = (t>>j)&1;
        L += (_s==0)&&(_t==1);
    }

//    cout << "L : " << L << endl;

    LL ans = 0;
    for (int msk = 0; msk < (1<<L); msk++) {
        vector< int >B(A);
        for (int &x : B) x &= msk;
        sort(B.begin(), B.end());
//        cout << "mask: " << bitset<2>(msk) << endl;
//        for (int u : B) cout << u << " ";
//        cout << endl;

        LL z = 0;
        for (int i = 0; i < B.size(); i++) {
            int j = i;
            while (j+1 < B.size() && B[j+1]==B[i]) j++;
            z += f(j-i+1, k);
            i = j;
        }

        if (__builtin_popcount(msk)&1) ans -= z;
        else ans += z;
    }

    cout << ans << endl;


    return 0;
}


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

using namespace std;

int reverse(char s) {
  if (s == 'S') return 'W';
  if (s == 'W') return 'S';
  return 0;
}
int may_reverse(bool flag, char s) {
  if (flag) {
    if (s == 'S') return 'W';
    if (s == 'W') return 'S';
  }
  return s;
}

int n;
int next(int i) {
  if (++i == n) return 0;
  return i;
}
int prev(int i) {
  if (--i < 0) return n-1;
  return i;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  string s;
  cin >> n >> s;

  string assume;
  assume.resize(n);
  char type[] = "SW";
  for (int i = 0; i < 2; ++i) {
    for (int j = 0; j < 2; ++j) {
      assume[1] = type[j];
      assume[0] = type[i];

      int pos = 1;
      for (int k = 0; k < n + 2; ++k) {
        assume[next(pos)] =
          may_reverse(assume[pos] == 'S' ^ s[pos] == 'o',
                      assume[prev(pos)]);
        pos = next(pos);
      }
      if (assume[0] == type[i] && assume[1] == type[j]) {
        cout << assume <<" \n";
        return 0;
      }

    }
  }
  cout << -1 << "\n";
}


Measured memory_bytes: 640
import sys
input = sys.stdin.readline

S = input().rstrip()
S32 = S[2:-1]
trimed_S = S32.replace('C', '', 1)
ac_cut_S = S.replace('A', '', 1).replace('C', '', 1)

ans = 'AC'
if S[0] != 'A':
  ans = 'WA'
elif (not ac_cut_S.islower()) or len(S32) - len(trimed_S) != 1:
  ans = 'WA'

print(ans)


Measured memory_bytes: 38256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i) sort((i).begin(),(i).end(), greater<int>());
#define F first
#define S second
constexpr auto INF = 1000000000;
constexpr auto LLINF = 9223372036854775807;
constexpr auto mod = 1000000007;
int main() {

	int h, w;
	cin >> h >> w;
	vector<string> a(h);
	FOR(i, h)cin >> a[i];
	queue<pair<int,pair<int, int>>> b;
	FOR(i, h)FOR(j, w) {
		if (a[i][j] == '#')b.push(make_pair(0,make_pair(i, j)));
	}
	int dx[4] = { -1,0,1,0 }, dy[4] = { 0,-1,0,1 };
	int ans = 0;
	while (b.size()) {
		int p = b.front().first, y = b.front().second.first, x = b.front().second.second;
		b.pop();
		ans = p;
		FOR(i, 4) {
			int Y = y + dy[i], X = x + dx[i];
			if(Y>=0&&Y<h&&X>=0&&X<w)if (a[Y][X] == '.') {
				a[Y][X] = '#';
				b.push(make_pair(p + 1, make_pair(Y, X)));
			}
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 13456
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define N 5005
const int mod=1e9+7;
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n,f[N][2],dp[N][2],g[N],A,B,ans;
#define ck(x) (x>=mod?x-mod:x) 
int qpow(int a,int b){
	int ans=1;
	while(b){
		if(b&1)ans=1LL*ans*a%mod;
		a=1LL*a*a%mod;
		b>>=1;
	}
	return ans;
}
int main(){
	n=read(),A=read(),B=read();
	if(A>B)swap(A,B);
	f[0][0]=f[0][1]=1;
	for(int i=1;i<B;++i){
		for(int j=A;j<=i;++j){
			f[i][0]=ck(f[i][0]+f[i-j][1]);
		}
		for(int j=1;j<=i;++j){
			f[i][1]=ck(f[i][1]+f[i-j][0]);
		}
	}
	g[0]=1;
	for(int i=1;i<B;++i){
		g[i]=ck(f[i][0]+f[i][1]);
	}
	for(int i=1;i<n;++i){
		dp[i][0]+=(i<A);
		dp[i][1]+=(i<B?f[i][1]:0);
		for(int j=1;j<min(i,A);++j){
			dp[i][0]=ck(dp[i][0]+dp[i-j][1]);
		}
		for(int j=1;j<min(i,B);++j){
			dp[i][1]=(dp[i][1]+1LL*dp[i-j][0]*(j==1?1:g[j-2]))%mod;
		}
		if(n-i<A)ans=ck(ans+dp[i][1]);
		if(n-i<B)ans=(ans+1LL*dp[i][0]*g[n-i-1])%mod;
	}
	printf("%d\n",(qpow(2,n)-ans+mod)%mod);	
	return 0;
}


Measured memory_bytes: 3828
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
	private static int[] numbers2 = IntStream.range(0, 16).map(i -> (int) Math.pow(2, i)).toArray();

	public static void main(String[] args) {
		var sc = new Scanner(System.in);
		var n = sc.nextInt();
		var x = new int[n];
		var y = new int[n];
		var p = new int[n];
		for (var i = 0; i < n; i++) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
			p[i] = sc.nextInt();
		}
		sc.close();

		var mins = new long[n + 1];
		for (var i = 0; i <= n; i++) {
			mins[i] = Long.MAX_VALUE;
		}
		check(x, y, p, mins);
		for (var i = 0; i <= n; i++) {
			System.out.println(mins[i]);
		}
	}

	private static void check(int[] x, int[] y, int[] p, long[] mins) {
		var xdists = new int[x.length][x.length];
		var ydists = new int[x.length][x.length];
		for (var i = 0; i < x.length; i++) {
			for (var j = 0; j < x.length; j++) {
				xdists[i][j] = Math.abs(x[i] - x[j]);
				ydists[i][j] = Math.abs(y[i] - y[j]);
			}
		}

		var xmins = new int[x.length][(int) Math.pow(2, x.length)];
		var ymins = new int[x.length][(int) Math.pow(2, x.length)];
		for (var i = 0; i < x.length; i++) {
			var values2 = new int[x.length + 1];
			for (var j = 0; j < (int) Math.pow(2, x.length); j++) {
				xmins[i][j] = Math.abs(x[i]);
				ymins[i][j] = Math.abs(y[i]);
				for (var k = 0; k < x.length; k++) {
					if (values2[k] == 1) {
						xmins[i][j] = Math.min(xmins[i][j], xdists[i][k]);
						ymins[i][j] = Math.min(ymins[i][j], ydists[i][k]);
					}
				}
				incValues(values2, 2);
			}
		}

		var values3 = new int[x.length + 1];
		for (var i = 0; i < Math.pow(3, x.length); i++) {
			var count = 0;
			var xnumber = 0;
			var ynumber = 0;
			for (var j = 0; j < x.length; j++) {
				if (values3[j] == 1) {
					xnumber += numbers2[j];
					count++;
				} else if (values3[j] == 2) {
					ynumber += numbers2[j];
					count++;
				}
			}

			var sum = 0L;
			for (var j = 0; j < x.length; j++) {
				sum += (long) Math.min(xmins[j][xnumber], ymins[j][ynumber]) * p[j];
			}
			mins[count] = Math.min(mins[count], sum);
			incValues(values3, 3);
		}
	}

	public static void incValues(int[] values, int b) {
		values[0]++;
		for (var i = 0; i < values.length; i++) {
			if (values[i] < b) {
				break;
			}
			values[i] = 0;
			values[i + 1]++;
		}
	}
}


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

typedef long long ll;
typedef pair<int,int> P;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int n,y;
    cin >> n >> y;
    vector<int> v(n);
    for (int i = 0;i < n;++i) cin >> v[i];
    int ans = 0;
    for (int k = 0;k <= y;++k) {
        if (k > 2*n) continue;
        for (int i = 0;i <= k/2;++i) {
            for (int j = 0;j <= min(n,k-i);++j) {
                vector<int> a;
                int s = min(n,k-i);
                for (int x = 0;x < j;++x) a.push_back(v[x]);
                s -= j;
                for (int x = n-s;x < n;++x) a.push_back(v[x]);
                sort(a.begin(),a.end());
                reverse(a.begin(),a.end());
                int ret = 0;
                for (int x = 0;x < min(n,k-i)-i;++x) ret += a[x];
                ans = max(ans,ret);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
#define N_MAX 200000
#define input(d) cin >> d;
#define inputs(n,d) for(int i=0;i<n;i++) {cin >> d[i];}
#define inputxy(n,x,y) for(int i=0;i<n;i++) {cin >> x[i] >> y[i];}
#define output(d) cout << d << endl;
#define outputs(n,d) for(int i=0;i<n;i++) {cout << d[i] << endl;}
#define outputxy(n,x,y) for(int i=0;i<n;i++) {cout << x[i] << y[i] << endl;}
#define f0(i,n) for(int i=0;i<n;i++)
#define f(i,a,b) for(int i=a;i<b;i++)
#define l long
#define ll long long
#define s string

int main(){
    ll n,d=0,x=0,y,ans=0;
    char data;
    f0(i,3){
        input(data);
        if(data == 'R'){
            if(x==1){
                d=0;
            }
            d++;
        }else if(data == 'S' && d != 0){
            x=1;
        }
    }
    

    output(d);
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) for(auto&& x : v){cout << x << " ";} cout << endl
#define printVV(vv) for(auto&& v : vv){for(auto&& x : v){cout << x << " ";}cout << endl;}
#define printP(p) cout << p.first << " " << p.second << endl
#define printVP(vp) for(auto&& p : vp) printP(p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
const int inf = 1e9;
const int mod = 1e9 + 7;
template<typename T> using Graph = vector<vector<T>>;

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int N, M;
    cin >> N >> M;
    int ans = 0;
    rep(i, N) {
        cout << "lst " << i << endl;
        int k;
        cin >> k;
        ans += k * (k - 1);
        rep(j, k) {
            int v;
            cin >> v;
        }
    }
    cout << "ans " << ans << endl;
}

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

using namespace std;

#define ll 			long long
#define db			double
#define up(i,j,n)		for (int i = j; i <= n; i++)
#define down(i,j,n)	for (int i = j; i >= n; i--)
#define cadd(a,b)		a = add (a, b)
#define cpop(a,b)		a = pop (a, b)
#define cmul(a,b)		a = mul (a, b)
#define pr			pair<int, int>
#define fi			first
#define se			second
#define SZ(x)		(int)x.size()
#define bin(i)		(1 << (i))
#define Auto(i,node)	for (int i = LINK[node]; i; i = e[i].next)

template<typename T> inline bool cmax(T & x, T y){return y > x ? x = y, true : false;}
template<typename T> inline bool cmin(T & x, T y){return y < x ? x = y, true : false;}

const int MAXN = 1e5 + 5;
const int MAXM = 2005;

int col[MAXN], N, K, mark[2][MAXM][MAXM], cnt[2][MAXM][MAXM];
pr a[MAXN];
char s[5];

pair<pr, int> get(pr o, int c, int x, int y){
	int mx = o.fi - x, my = o.se - y;
	int dx = (max(mx, 0) + K - 1) / K, dy = (max(my, 0) + K - 1) / K;
	mx -= dx * K; my -= dy * K;
	c ^= (dx & 1) ^ (dy & 1);
	return make_pair(make_pair(-mx, -my), c);
}

void work(int v, int o, int sx, int sy){
	up (i, 0, K - 1) up (j, 0, K - 1) 
		cnt[v][i][j] += mark[o][sx + i][sy + j];
}

int main(){
	scanf("%d%d", &N, &K);
	up (i, 1, N) {
		scanf("%d%d%s", &a[i].fi, &a[i].se, s);
		col[i] = s[0] == 'B' ? 1 : 0;
	}
	up (i, 1, N) {
		pr low[2], upp[2];
		up (j, 0, 1) low[j] = make_pair(0, 0);
		up (j, 0, 1) upp[j] = make_pair(K - 1, K - 1);
		pair<pr, int> vv = get(a[i], col[i], 0, 0);
		int o = vv.se, x = vv.fi.fi, y = vv.fi.se;
		mark[o][x][y]++;
		mark[o][x + K][y]--;
		mark[o][x][y + K]--;
		mark[o][x + K][y + K]++;
	}
	up (o, 0, 1) up (i, 0, K + K - 1) up (j, 0, K + K - 1) {
		if (j > 0) mark[o][i][j] += mark[o][i][j - 1];
		if (i > 0) mark[o][i][j] += mark[o][i - 1][j];
		if (i > 0 && j > 0) mark[o][i][j] -= mark[o][i - 1][j - 1];
	}
	work(0, 0, 0, 0);
	work(0, 0, K, K);
	work(1, 0, K, 0);
	work(1, 0, 0, K);
	work(1, 1, 0, 0);
	work(1, 1, K, K);
	work(0, 1, 0, K);
	work(0, 1, K, 0);
	int ans = 0;
	up (o, 0, 1) up (i, 0, K - 1) up (j, 0, K - 1) cmax(ans, cnt[o][i][j]);
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 51968
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
void debug(int* v,int sz){
	printf("[");
	for(int i=0;i<sz;i++)printf("%d%c",v[i],(i==sz-1)?']':',');
	printf("\n");
}
string A,B;
int N;
int sumA,sumB;
vector<int> vec;
deque<int> deq;
int one;
int L[2010],R[2010];
bool comp(int a,int b){
	return L[a]>L[b];
}
int main(){
	cin >> A;
	cin >> B;
	N = A.size();
	for(int i=0;i<N;i++){
		if(A[i]=='1'){
			sumA++;
			vec.pb(1);
		}else vec.pb(0);
		if(B[i]=='1'){
			sumB++,one=i;
			deq.pb(1);
		}else deq.pb(0);
	}
	if(sumB==0){
		if(sumA==0)printf("0\n");
		else printf("-1\n");
		return 0;
	}
	int prev = -1;
	for(int i=one;i<one+N;i++){
		int idx = i;
		if(idx>=N)idx-=N;
		if(B[idx]=='1')L[idx]=0;
		else L[idx]=prev+1;
		prev = L[idx];
	}
	for(int i=one;i>one-N;i--){
		int idx = i;
		if(idx<0)idx+=N;
		if(B[idx]=='1')R[idx]=0;
		else R[idx]=prev+1;
		prev = R[idx];
	}
	//debug(L,N);
	//debug(R,N);
	int ans = INF;
	for(int i=0;i<N;i++){
		vector<int> d;
		for(int j=0;j<N;j++){
			if(vec[j]!=deq[j])d.pb(j);
		}
		sort(all(d),comp);
		int Lmax=0,Rmax=0;
		int ds = d.size();
		for(int j=0;j<=ds;j++){
			int ret,diff;
			if(j<ds)Lmax=L[d[j]];
			else Lmax=0;
			if(j>0)Rmax=max(Rmax,R[d[j-1]]);
			{
				ret = ds+2*Lmax+Rmax;
				diff = abs(Rmax+i);
				diff%=N;
				chmin(diff,N-diff);
				ret += diff;
				chmin(ans,ret);	
			}
			{
				ret = ds+2*Rmax+Lmax;
				diff = abs(-Lmax+i);
				diff%=N;
				chmin(diff,N-diff);
				ret += diff;
				chmin(ans,ret);
			}
		}
		deq.push_front(deq.back()); //shift right
		deq.pop_back();
		//cout << ans << endl;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import itertools
n,m=map(int,input().split())
a=[]
for i in range(0,n):
  a.append(list(map(int,input().split())))
  del a[i][0]
a=list(itertools.chain.from_iterable(a))
count=0
for i in range(0,m):
  if a.count(i+1)==n:
    count=count+1
print(count)

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

using namespace std;
const int N = 2e5 + 10;
int p[N], mark[N];

int main()
{
    int n, k; cin >> n >> k;
    if (k == 1 || k == 2 * n - 1) return cout <<"No\n", 0;
    cout << "Yes\n";
    if (k == 2) {
        p[n] = 2;
        p[n-1] = 3;
        p[n+1] = 1;
        p[n+2] = 4;
        mark[1] = mark[2] = mark[3] = mark[4] = true;
    }
    else {
        p[n] = k;
        p[n-1] = k-1;
        p[n+1] = k+1;
        p[n+2] = k-2;
        mark[k-2] = mark[k-1] = mark[k] = mark[k+1] = true;
    }
    int pnt = 1;
    for (int i = 1; i <= 2 * n - 1; i++) {
        if (!p[i]) {
            while (mark[pnt]) pnt++;
            p[i] = pnt++;
        }
        cout << p[i] << " ";
    }
    cout << "\n";

    return 0;
}


Measured memory_bytes: 2304
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
#include<deque>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
int main() {
	int x, y, a, b, c, f, g, h;cin >> x >> y >> a >> b >> c;ll sum = 0;
	priority_queue<int> p, q, r;
	p.push(0);q.push(0);r.push(0);
	rep(i, a) {
		cin >> f;p.push(f);
	}
	rep(i, b) {
		cin >> f;q.push(f);
	}
	rep(i, c) {
		cin >> f;r.push(f);
	}
	rep(i, x) {
		r.push(p.top()); p.pop();
	}
	rep(i, y) {
		r.push(q.top()); q.pop();
	}
	rep(i, x + y) {
		sum += r.top(); r.pop();
	}
	cout << sum << endl;
}

Measured memory_bytes: 3188
# N = 2
# M = 5
# ARR = [
#     [1, 'WA'],
#     [1, 'AC'],
#     [2, 'WA'],
#     [2, 'AC'],
#     [2, 'WA']
# ]
#
#
#
# N = 100000
# M = 3
# ARR = [
#     [7777, 'AC'],
#     [7777, 'AC'],
#     [7777, 'AC'],
# ]
#
#
# N = 6
# M = 0
# ARR = []

N, M = map(int, input().split())
ARR = []

for i in range(M):
    index, value = input().split()
    ARR.append([int(index), value])


def calculate(n, m, arr):
    acResult = [-1 for i in range(n)]
    waResult = [0 for i in range(n)]

    for index in range(m):
        i = arr[index][0] - 1
        if arr[index][1] == 'AC':
           if acResult[i] == -1:
               acResult[i] = index
           else:
               if acResult[i] > index:
                   acResult[i] = index

    for index in range(m):
        i = arr[index][0] - 1
        if arr[index][1] == 'WA':
            if index < acResult[i] and acResult[i] > -1:
                waResult[i] = waResult[i] + 1


    result1 = 0
    result2 = 0
    for index,ac in enumerate(acResult):
        if ac > -1:
            result1 = result1 + 1
            result2 = result2 + waResult[index]



    print(result1,result2)

calculate(N, M, ARR)


Measured memory_bytes: 26852
N, A, B = map(int, input().split())
ans = 0
for i in range(N+1):
    lis = [int(i) for i in str(i)]
    if A <= sum(lis) <= B:
        num = ""
        for j in lis:
            num += str(j)
        ans += int(num)
print(ans)

Measured memory_bytes: 2940
#include<cstdio>
#include<algorithm>
#include<cmath> 
#define INF 0x7fffffff/2
using namespace std;

struct TH{
	int a,b;
	int wi;
}th[45];

int dp[405][405]={0};

int main(){
	for(int i=0;i<405;i++){
		for(int j=0;j<405;j++){
			dp[i][j]=INF;
		}
	}
	dp[0][0]=0;
	int n,ma,mb;
	scanf("%d %d %d",&n,&ma,&mb);
	int maxa=0,maxb=0;
	for(int i=1;i<=n;i++){
		scanf("%d %d %d",&th[i].a,&th[i].b,&th[i].wi);
		maxa+=th[i].a;
		maxb+=th[i].b;
	}
	for(int k=1;k<=n;k++){
		for(int i=maxa;i>=th[k].a;i--){
			for(int j=maxb;j>=th[k].b;j--){//01背包问题 
				int x=i-th[k].a;
				int y=j-th[k].b;
				dp[i][j]=min(dp[i][j],dp[x][y]+th[k].wi);
			}
		}
	}
	int ans=INF;
	for(int i=1;ma*i<=maxa&&mb*i<=maxb;i++){
		ans=min(ans,dp[ma*i][mb*i]);
	}
	if(ans==INF){
		printf("-1\n"); 
	}
	else {
		printf("%d\n",ans);
	}
	return 0;
} 


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

#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (ll i = m; i < (n); i++)

using ll = long long;
using pii = pair<int, int>;
using Vi = vector<int>;

int main() {
  int a,b;
  string op;
  cin >> a >> op >> b;
  if(op == "+"){
    cout << a+b << endl;
  }
  else{
    cout << a-b << endl;
  }
  
  
}
     

Measured memory_bytes: 3544
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;

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

template <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

namespace detail
{
  template <typename T, std::size_t NDIMS>
  struct vector_builder
  {
    using type = std::vector<typename vector_builder<T, NDIMS - 1>::type>;

    static type make(std::vector<std::size_t> dims, const T &v = {})
    {
      const auto vec = std::vector<T>(dims.empty() ? 0 : dims.back(), v);
      if (!dims.empty())
        dims.pop_back();
      return vector_builder<std::vector<T>, NDIMS - 1>::make(dims, vec);
    }
  };

  template <typename T>
  struct vector_builder<T, 1>
  {
    using type = std::vector<T>;

    static type make(std::vector<std::size_t> dims, const T &v = {})
    {
      return type(dims.empty() ? 0 : dims.back(), v);
    }
  };
} // namespace detail

template <typename T, typename... SIZE_T>
auto exvector(const T &v, SIZE_T... dims)
{
  static_assert(sizeof...(dims) != 0, "invalid dimension");
  std::vector<std::size_t> vec_dims{dims...};
  return detail::vector_builder<T, sizeof...(dims)>::make(vec_dims, v);
}

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T &data, vector<int> &iter)
{
  cout << data << " ";
}
template <typename T>
void dump(const vector<T> &data, vector<int> &iter)
{
  for (auto elem : data)
    dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>> &data, vector<int> &iter)
{
  for (auto elem : iter)
  {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++)
  {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T> &data, int dummy)
{
  for (int i = 0; i < data.size(); i++)
  {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T &data)
{ // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////

void solve(long long X, long long Y, long long Z)
{
  swap(X, Y);
  swap(X, Z);
  cout << X << " " << Y << " " << Z << endl;
}

int main()
{
  cout << setprecision(10);
  long long X;
  scanf("%lld", &X);
  long long Y;
  scanf("%lld", &Y);
  long long Z;
  scanf("%lld", &Z);
  solve(X, Y, Z);
  return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
//cin.sync_with_stdio(false);

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

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;

int main(int argc, char const *argv[])
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	char c[3][3];

	rep(i,3){
		rep(j,3){
			cin >> c[i][j];
		}
	}

	cout << c[0][0] << c[1][1] << c[2][2] << endl;
	
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
#include <random>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define REPE(i, n) for (int (i)=0; (i) <= (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
#define CONTAINS_SET(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
//void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }


signed main()
{
	string s;
	cin >> s;
	YesNo((s[0] == s[1] && s[1] == s[2]) || s[1] == s[2] && s[2] == s[3]);
}




Measured memory_bytes: 3588
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (unsigned long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (unsigned long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end())
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return 1;} return 0; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl

// gcc拡張マクロ
#define gcd __gcd
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using  ll = long long;
using ull = unsigned long long;
using  ld = long double;
using namespace std;

// モジュール
constexpr ll p = 1000000007ll;
constexpr int GENOM_EMPTY = 0;
constexpr int GENOM_A = 1;
constexpr int GENOM_T = 2;
constexpr int GENOM_G = 3;
constexpr int GENOM_C = 4;

// 処理内容
int main() {
    
    ll n;
    cin >> n;

    vector<vector<ll>> dp(n+1, vector<ll>(125, 0));

    dp[0][0] = 1;

    RANGE(i, 0, n-1) {
        REP(j, 125) {
            int pre3 = j / 25;
            int pre2 = (j % 25) / 5;
            int pre1 = j % 5;
            int next = (j % 25) * 5;
            dp[i+1][next + GENOM_A] += dp[i][j];
            dp[i+1][next + GENOM_A] %= p;
            dp[i+1][next + GENOM_T] += dp[i][j];
            dp[i+1][next + GENOM_T] %= p;
            if (!(
                pre2 == GENOM_A &&
                pre1 == GENOM_C
            )) {
                dp[i+1][next + GENOM_G] += dp[i][j];
                dp[i+1][next + GENOM_G] %= p;
            }
            if (!(
                pre2 == GENOM_G &&
                pre1 == GENOM_A
            ) && !(
                pre2 == GENOM_A &&
                pre1 == GENOM_G
            ) && !(
                pre3 == GENOM_A &&
                pre2 != GENOM_EMPTY &&
                pre1 == GENOM_G
            ) && !(
                pre3 == GENOM_A &&
                pre2 == GENOM_G &&
                pre1 != GENOM_EMPTY
            )) {
                dp[i+1][next + GENOM_C] += dp[i][j];
                dp[i+1][next + GENOM_C] %= p;
            }
        }
    }

    ll ans = 0;
    REP(j, 125) {
        ans += dp[n][j];
        ans %= p;
    }

    cout << ans << endl;
    
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  ll N, K;
  cin >> N >> K;
  vector<pll> ab(N);
  for (ll i = 0; i < N; ++i) {
    ll a, b;
    cin >> a >> b;
    ab.at(i) = {a, b};
  }
  sort(ab.begin(), ab.end());
  ll cnt = 0;
  for (ll i = 0; i < N; ++i) {
    if (cnt + ab.at(i).second >= K) {
      cout << ab.at(i).first << "\n";
      return 0;
    }
    else {
      cnt += ab.at(i).second;
    }
  }
}


Measured memory_bytes: 1792
#include<stdio.h>

int main()
{
	float a,b,c,d,e,f,x,y;
	
	while(scanf("%f %f %f %f %f %f",&a,&b,&c,&d,&e,&f)!=EOF)
	{
		y = (c*d-f*a)/(b*d-e*a);
		x = (c-b*y)/a;
		printf("%.3f %.3f\n",x,y);
	}
	return 0;
}

Measured memory_bytes: 1076
#include <iostream>

using namespace std;

int main()
{
    int N, K;
    cin>>N>>K;
    bool D[10] = {};
    for (int i=0; i<K; i++)
    {
        int d;
        cin>>d;
        D[d] = true;
    }

    while (true)
    {
        int n = N;
        bool ok = true;
        for (; n>0; n/=10)
        {
            if (D[n%10])
                ok = false;
        }
        if (ok)
            break;
        N++;
    }

    cout<<N<<endl;
}


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

int main() {
	int n; cin >> n;
	
	vector<pair<int, int>> s(n), t(n);
	for (auto&& x : s)cin >> x.first >> x.second;
	for (auto&& x : t)cin >> x.first >> x.second;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int cur = -1;
		for (int j = 0; j < n; j++) {
			if (s[j].first > t[i].first) break;
			if (t[i].second < s[j].second) continue;
			if (cur == -1) {
				cur = j; ans++;
			}
			else {
				if (s[cur].second < s[j].second) cur = j;
			}
		}
		if (cur != -1)  s[cur].second = 100000;
	}
	cout << ans << endl;

	return 0;
}

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

typedef long long ll;

static const int MAX = 1e6;
static const int NIL = -1;
static const ll INF = 1<<21;
static const ll MOD = 1e9 + 7;

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) {
    return arg1.first > arg2.first;
}

int main(void) {
    int N;
    cin >> N;

    list<int> L;
    vector<int> ans(N);
    int b;
    for(int i=0;i<N;i++) {
        cin >> b;
        L.push_back(b);
    }

    int now_val, j;
    auto now_itr = L.begin();
    for(int i=0;i<N;i++) {
        j = 1;
        now_val = 0;
        now_itr = L.begin();
        for(auto itr=L.begin();itr!=L.end();++itr) {
            if(*itr==j) { 
                now_val = *itr;
                now_itr = itr;
            }
            j++;
        }
        if(now_val) {
            ans.at(i) = now_val;
            L.erase(now_itr);
        }
        else {
            cout << -1 << endl;
            return 0;
        }
    }

    for(int i=N-1;i>=0;i--) {
        cout << ans.at(i) << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;

const ll MOD = 1e9+7;


int main()
{
	int n;
	ll ans=0;
	cin>>n;
	cout<<180*(n-2)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define uint unsigned long long
#define ll long long
#define db double
#define ls rt << 1
#define rs rt << 1 | 1
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define ept 1e-9
#define INF 0x3f3f3f3f
#define sz(x) (x).size()
using namespace std;
inline int read()
{
	int 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 ll read1()
{
	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;
}
const int N=3033;
 
ll qpow(ll a,ll b,ll MOD){ll c=1;for(;b;b>>=1,a=a*a%MOD)if(b&1)c=c*a%MOD;return c;}
 
int n,MOD;
 
int f[N][N],C[N][N];
 
int ans;
 
int main()
{
	scanf("%d%d",&n,&MOD);
 
	f[0][0]=1;
	for(int i=1;i<N;i++)
		for(int j=0;j<N;j++)
			f[i][j]=((ll)f[i-1][j]*j+f[i-1][j-1]+f[i-1][j])%MOD;
	for(int i=0;i<N;i++)C[i][0]=1;
	for(int i=1;i<N;i++)
		for(int j=1;j<N;j++)
			C[i][j]=(C[i-1][j]+C[i-1][j-1])%MOD;
 
	int tmp=qpow(2,n,MOD-1);
	ans=qpow(2,tmp,MOD);
 
	for(int cnt=1;cnt<=n;cnt++)
	{
		int sum=0;
 
		int u=qpow(2,n-cnt,MOD-1);
		int v=qpow(2,n-cnt,MOD);
 
		for(int z=0;z<=cnt;z++)
		{
			int res=f[cnt][z];
			res=(ll)res*qpow(v,z,MOD)%MOD*qpow(2,u,MOD)%MOD;
			sum=(sum+res)%MOD;
		}
		sum=(ll)sum*C[n][cnt]%MOD;
 
		if(cnt&1)ans=(ans-sum)%MOD;
		else ans=(ans+sum)%MOD;
	}
 
	ans=(ans+MOD)%MOD;
	printf("%d\n",ans);
 
	return 0;
}

Measured memory_bytes: 72064
n,m = map(int,input().split())
abd = [list(map(int,input().split())) for i in range(m)]
graph = [[] for i in range(n+1)]
for a,b,d in abd:
  graph[a].append((b,d))
for i in range(1,n):
  graph[i+1].append((i,0))
import heapq as hq
dist = [10**18]*(n+1)
dist[1] = 0
q = [(0,1)]
hq.heapify(q)
while q:
  d,x = hq.heappop(q)
  for y,dd in graph[x]:
    if dist[y] > dist[x]+dd:
      dist[y] = dist[x]+dd
      hq.heappush(q,(dist[y],y))
if dist[n] == 10**18:
  print(-1)
else:
  print(dist[n])

Measured memory_bytes: 90328
#include<stdio.h>
main()
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a==5&&b==5&&c==7) printf("YES");
    else if(a==5&&b==7&&c==5) printf("YES");
    else if(a==7&&b==5&&c==5) printf("YES");
    else printf("NO");
}

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

public class Program
{
    private static int[] nums;
    private static int sum;
    private static int[] elem;

    public static void Main(string[] args)
    {
        Input();
        Method();
        System.Console.ReadLine();
    }

    private static void Input()
    {
        Console.ReadLine();
        nums = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        sum = nums.Aggregate((s, el) => s + el);
        Console.ReadLine();
        elem = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
    }

    private static bool Solve(int p, int t)
    {
        if (t > sum)
        {
            return false;
        }
        if (p >= nums.Length)
        {
            return false;
        }
        if (t - nums[p] == 0)
        {
            return true;
        }
        return Solve(p + 1, t - nums[p]) || Solve(p + 1, t);
    }

    private static void Method()
    {
        var results = new StringBuilder();
        for (int i = 0; i < elem.Length; i++)
        {
            bool res = Solve(0, elem[i]);
            results.AppendLine(res ? "yes" : "no");
        }
        Console.Write(results.ToString());
    }
}

Measured memory_bytes: 9208
#include "bits/stdc++.h"
#define MOD 1000000007
#define INF 2000000114514
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL N, M, a[2123], b[2123], c[2123];
LL ans;

struct edge { LL from, to, cost; };
edge G[2123];
LL d[1123];
bool negative[1123];

// s 番目の頂点から各頂点への最短距離を求める
void bellman_ford(LL s)
{
	std::fill_n(d, N + 1, INF);
	d[s] = 0;
	rep(i, N - 1)
	{
		rep(j, M)
		{
			auto e = G[j];
			if (d[e.from] == INF) { continue; }
			d[e.to] = std::min(d[e.to], d[e.from] + e.cost);
		}
	}
}

// negative[N] == true なら負の閉路が存在する
void find_negative_loop()
{
	memset(negative, false, sizeof(false));
	rep(i, N)
	{
		rep(j, M)
		{
			auto e = G[j];
			if (d[e.from] == INF) { continue; }
			if (d[e.to] > d[e.from] + e.cost)
			{
				d[e.to] = d[e.from] + e.cost;
				negative[e.to] = true;
			}
			if (negative[e.from]) { negative[e.to] = true; }
		}
	}
}

int main()
{
	in >> N >> M;
	rep(i, M)
	{
		in >> a[i] >> b[i] >> c[i];
		G[i] = { a[i],b[i],-c[i] };
	}

	bellman_ford(1);
	ans = d[N];
	find_negative_loop();
	if (negative[N]) { out << "inf" << std::endl; }
	else { out << -ans << std::endl; }
	return 0;
}

Measured memory_bytes: 384
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int
var t float64

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	a, b, c, d := intScanner(), intScanner(), intScanner(), intScanner()
	dp := make([][]int, c+1)
	e := 998244353
	for i, _ := range dp {
		dp[i] = make([]int, d+1)
	}
	for i := a; i < c+1; i++ {
		for j := b; j < d+1; j++ {
			if i == a && j == b {
				dp[i][j] = 1
			} else {
				dp[i][j] = dp[i-1][j]*j%e + dp[i][j-1]*i%e - dp[i-1][j-1]*(i-1)*(j-1)%e
				dp[i][j] %= e
			}
		}
	}
	if dp[c][d] < 0 {
		dp[c][d] += e
	}
	fmt.Println(dp[c][d])
}


Measured memory_bytes: 76852
import java.util.Scanner;

public class Main{
	public static void main(String[]args) {
		Scanner sc = new Scanner(System.in);
		int taro =0;
		int hanako = 0;
		int n = sc.nextInt(); //ｎ枚のカードを入力

		for(int i=0; i<n;i++) { //nの数だけ処理を繰り返す
			String taros = sc.next(); //太郎のカードを入力
			String hanakos = sc.next(); //花子
		if(taros.compareTo(hanakos)>0) { //太郎のカードが大きい場合3点
			taro=taro+3;
		}else if(taros.compareTo(hanakos)<0) { //太郎のカードが小さい場合花子に3点
			hanako=hanako+3;
		}else if(taros.compareTo(hanakos)==0) { //同じ場合は二人に1点
			taro++; hanako++;
		}
		}
		System.out.println(taro + " " + hanako);
	}

}


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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  int gusu = 0, kisu = 0;
  if (A % 2 == 0) gusu++;
  else kisu++;
  if (B % 2 == 0) gusu++;
  else kisu++;
  if (C % 2 == 0) gusu++;
  else kisu++;
  
  if (gusu == 2){
    if (A % 2 == 0) A++;
    if (B % 2 == 0) B++;
    if (C % 2 == 0) C++;
  }
  if (kisu == 2){
    if (A % 2 == 1) A++;
    if (B % 2 == 1) B++;
    if (C % 2 == 1) C++;
  }
  if (gusu == 3 || kisu == 3){
    if (A >= B && A >= C) cout << (2 * A - B - C) / 2 << endl;
    else if (B >= A && B >= C) cout << (2 * B - A - C) / 2 << endl;
    else if (C >= A && C >= B) cout << (2 * C - A - B) / 2 << endl;
  }
  else {
    if (A >= B && A >= C) cout << (2 * A - B - C) / 2 + 1 << endl;
    else if (B >= A && B >= C) cout << (2 * B - A - C) / 2 + 1 << endl;
    else if (C >= A && C >= B) cout << (2 * C - A - B) / 2 + 1 << endl;
  }
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> inline bool chmin(T&x,T y){if(x>y){x=y;return true;}return false;}
template<class T> inline bool chmax(T&x,T y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
 int a,b;
 cin>>a>>b;
 cout<<max(0,a-2*b);
}

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

typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve(){
  int n;
  cin >> n;
  if(n==3 || n==5 || n==7)cout << "YES";
  else cout << "NO";
  cout << endl;
}

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


Measured memory_bytes: 256
c500 = int(input())
c100 = int(input())
c50 = int(input())
x = int(input())
count = 0
 
for c500_n in range(c500+1):
  for c100_n in range(c100+1):
    for c50_n in range(c50+1):
      if c500_n*500 + c100_n*100 + c50_n*50 == x:
        count += 1
 
print(count)

Measured memory_bytes: 9092
#include<cstdio>
#include<algorithm>

using namespace std;

int n;
int a[200010];

int main(){
	int i,s;
	scanf("%d",&n);
	for(i = 1; i <= n; i++) scanf("%d",&a[i]);
	for(i = n; i > 0; i -= 2) printf("%d ",a[i]);
	if(n & 1) s = 2; else s = 1;
	for(i = s; i <= n; i += 2) printf("%d ",a[i]);
	return 0;
}

Measured memory_bytes: 2816
n = int(input())
a = list(map(int, input().split()))
s = 0
c = 0
j = 0
ans = 0
for i in range(n):
    if s + a[i] == s ^ a[i]:
        s += a[i]
        c += 1
        ans += c
    else:
        while s + a[i] != s ^ a[i]:
            s -= a[j]
            c -= 1
            j += 1
        else:
            s += a[i]
            c += 1
            ans += c
print(ans)

Measured memory_bytes: 24584
/* Atcoder abc171b
 * See tasks at: https://atcoder.jp/contests/abc171/tasks/abc171_b
 */
#include <bits/stdc++.h>

#define until(symbol, max) for (int symbol = 0; (symbol) < (max); (symbol)++)

using namespace std;
using ll = long long;
int main()
{
    int n, k;
    cin >> n >> k;
    
    vector<int> p(n);
    until(i, n)
    {
        int val;
        cin >> val;
        p[i] = val;
    }
    
    sort(p.begin(), p.end());
    p.resize(k);
    cout << accumulate(p.begin(), p.end(), 0);
    return 0;
}


Measured memory_bytes: 3588
n,m=map(int,input().split())
A=list(map(int,input().split()))
D={1:2,2:5,3:5,4:4,5:5,6:6,7:3,8:7,9:6}
C=[]
for i in range(1,10):
    if i in A:
        C.append(D[i])
DP=[-float('inf')]*(n+1)
DP[0]=0
for i in range(1,n+1):
    for j in C:
        if i>=j:
            tmp=DP[i-j]+1
            DP[i]=max(DP[i],tmp)
A=sorted(A,reverse=True)
ans=''
while n>0:
    for i in A:
        if n-D[i]<0:
            continue
        if DP[n-D[i]]==DP[n]-1:
            ans+=str(i)
            n-=D[i]
            break
print(ans)

Measured memory_bytes: 3408
#include <iostream>
#include <map>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair< pair<int,int>,pair<int,int> > NODE;
#define NY first.first
#define NX first.second
#define SY second.first
#define SX second.second

int X,Y,n,ret;
vector< vector<int> > solve;
map<int,vector<NODE> > able;
vector< vector<int> > data(20,vector<int>(20));
vector< vector<int> > none(20,vector<int>(20));
vector< vector<int> > rec(20,vector<int>(20));

void bt(int dp){
	if(ret>1)return;
	vector<vector<int> > tt = rec;
	bool flag;
	if(dp==n){
		flag = true;
		rep(i,Y)rep(j,X)if(!rec[i][j])flag = false;
		if(flag){
			ret++;
			solve = rec;
		}
		return;
	}
	map<int,vector<NODE> >::iterator it = able.begin();
	for(int i=0;i<dp;i++)it++;
	for(int i=0;i<(*it).second.size();i++){
		flag = true;
		rep(y,(*it).second[i].SY)rep(x,(*it).second[i].SX){
			if(rec[(*it).second[i].NY+y][(*it).second[i].NX+x])flag = false;
			rec[(*it).second[i].NY+y][(*it).second[i].NX+x]=(*it).first;
		}
		if(flag)bt(dp+1);
		rec = tt;
	}
	return;
}

int main()
{
	map<int,int> buy;
	
	int b,k;
	int name,cnt;
	pair<int,int> coord;
	while(cin >> X >> Y >> n , X){
		ret = 0;/*	rep(i,Y){
		rep(j,X)cout << rec[i][j];
		cout << endl;
	}
*/
		able.clear();
		buy.clear();
		rep(i,Y)rep(j,X)data[i][j]=0;
		rep(i,n){
			cin >> b >> k;
			buy[b] = k;
		}
		rep(i,Y)rep(j,X)cin >> data[i][j];

		rep(i,Y)rep(j,X){
			rep(y,Y)rep(x,X){
				if( j+x > X-1 || i+y > Y-1 )continue;
				cnt = 0;
				rep(YY,i+1)rep(XX,j+1)
					if(data[y+YY][x+XX]){
						cnt++;
						name = data[y+YY][x+XX];
						coord = make_pair(y,x);
					}
				if(cnt == 1 && (i+1)*(j+1) == buy[name] ){
					able[name].push_back( make_pair(coord,make_pair(i+1,j+1)) );
				}
			}
		}
/*		map<int,vector<NODE> >::iterator it = able.begin();
		while(it != able.end()){
			for(int i=0;i<(*it).second.size();i++)
				cout << (*it).first << "=" << (*it).second[i].NX << "," << (*it).second[i].NY << " -> " << (*it).second[i].SX << "," << (*it).second[i].SY << endl;
			++it;
		}
*/
		rec = none;
		if(n == able.size() )bt(0);
		if(ret==1){
			rep(i,Y){
				rep(j,X){if(j)cout << " ";cout << solve[i][j];}
				cout << endl;
			}
		}else{
			cout << "NA" << endl;
		}
	}
}

Measured memory_bytes: 960
import sys
sys.setrecursionlimit(1000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import bisect_left, bisect_right
from collections import defaultdict
INF = float("inf")

N, M = map(int, input().split())
num = [-1]*N
flg = 1
for i in range(M):
    s, c = map(int, input().split())
    s -= 1
    if num[s] == -1:
        num[s] = c
    elif num[s] != c:
        flg = 0
if N == 2:
    if num[0] == 0:
        flg = 0
elif N == 3:
    if num[0] == 0:
        flg = 0
if flg:
    for i in range(N):
        if num[i] == -1:
            if i == 0 and N > 1:
                num[i] = 1
            else:
                num[i] = 0
        print(num[i], end = '')
    print()
else:
    print(-1)


Measured memory_bytes: 38256
//C
#include <cassert>
//#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//ここまで標準include

using namespace std;

long aCb(long a, long b) {
	long out = 1;
	for (long i = 1; i <= b; i++) {
		out = out * (a + 1 - i) / i;
	}
	return out;
}

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (b + c <= a) {
		cout << 0 << endl;
	}
	else {
		cout << b + c - a << endl;
	}
}
	


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define endl '\n'
#define ll long long
#define mod 1000000007
#define inf 1000000000000000000
int main()
{
	fastio;
	#ifdef APNA_IO
		freopen("input.txt" , "rt" ,stdin);
		freopen("output.txt" , "wt" ,stdout);
	#endif
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	double e;
	e=(a*b*1.0);
	e=e/2;
	cout<<e<<" ";
	if(2*c==a &&2*d==b)
		cout<<1<<endl;
	else
		cout<<0<<endl;
	return 0;
}





Measured memory_bytes: 256