akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <math.h>
#include <string>
#include <string.h>
#include <stack>
#include <queue>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <stdlib.h>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 10000000000LL
#define rep(i,n) for(i=0;i<n;i++)

typedef pair<int,int> pii;
int i,j;

int main(void) {
  while(1){
    int n,l;
    cin>>n>>l;
    if(n==0 && l==0)break;
    char a[25][10]={};
    rep(i,l){
      a[0][l-1-i]=n%10;
      n/=10;
    }
    rep(i,20){
      char now[10]={};
      rep(j,l)
        now[j]=a[i][j];
      sort(now,now+l);
      char a_min[10]={};
      char a_max[10]={};
      rep(j,l){
        a_min[j]=now[j];
        a_max[l-j-1]=now[j];
      }
      int amin=0;
      int amax=0;
      int temp=1;
      for(j=l-1;j>=0;j--){
        amin+=a_min[j]*temp;
        amax+=a_max[j]*temp;
        temp*=10;
      }
      amax=amax-amin;
      amin=amax;
      for(j=l-1;j>=0;j--){
        a[i+1][j]=amax%10;
        amax/=10;
      }
      bool ans=false;
      rep(j,i+1)
        if(strcmp(a[j],a[i+1])==0){
          printf("%d %d %d\n",j,amin,i+1-j);
          ans=true;
          break;
        }
      if(ans)break;
    }

  }
  return 0;
}

Measured memory_bytes: 3248
#include <iostream>
using namespace std;
int main(void){
    int H;
    int W;
     while(1){
    cin>>H;
    cin>>W;
    
        if(W==0&&H==0)  break;
        else{
            for ( int i = 0; i < H; i++ ){
                for ( int j = 0; j < W; j++ ){
                    cout << "#";
                }
                cout << endl;
             
        }
        cout<<endl;
         
    }}
     
}


Measured memory_bytes: 3076
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<map>
using namespace std;
typedef long long ll;
const int maxn = 3000005;
const int maxm = maxn*2;
const ll inf = 0x3f3f3f3f;
const ll mod = 1e9 + 7;

int n,m,cnt;
map<pair<int,int>,int>mp;
ll ans[10];
int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>n>>m>>cnt;
    for(int i = 1;i<=cnt;i++) {
        int x,y; cin>>x>>y;
        for(int i = max(1,x-2);i<=min(x,n-2);i++)
            for(int j = max(1,y-2);j<=min(m-2,y);j++) mp[make_pair(i,j)]++;
    }
    ans[0] = 1ll*(n-2)*(m-2);
    map<pair<int,int>,int> :: iterator it;
    for(auto x : mp) {
        ans[x.second]++;
        ans[0]--;
    }
    for(int i = 0;i<10;i++) cout<<ans[i]<<'\n';
    return 0;
}


Measured memory_bytes: 56576
N = int(input())
A = list(map(int, input().split()))
approved = True
for i in range(N):
    a = A[i]
    if a % 2 == 0:
        if a % 3 != 0 and a % 5 != 0:
            approved = False

if approved:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 38384
import sys
input=sys.stdin.readline
import math

#input = open(sys.argv[1], "r").readline

def main():
    N,K = map(int,input().split())
    W = []
    for _ in range(N):
        W.append(int(input()))

    # (lb, ub] の間を二分探索
    lb = max(W)-1   # 最大の w さえ積めれば良い場合が p の取り得る最小値
    ub = sum(W)     # 全てを 1 台のトラックに積む必要がある場合が p の取り得る最大値

    while ub - lb > 1:
        p = (lb + ub)//2

        v = 0
        k = 1
        for w in W:
            if v + w <= p: # 積載オーバーしなければ積む
                v += w
            else:
                k += 1
                v = w

        if k <= K:
            # p が条件を満たしている ⇒ 解の存在範囲を (lb, p] に更新
            ub = p
        else:
            # p が条件を満たしていない ⇒ 解の存在範囲を (p, ub] に更新
            lb = p
#        print(p,k,lb,ub)

    # この時点で lb + 1 = ub となっている
    print(ub)

if __name__ == '__main__':
    main()



Measured memory_bytes: 9616
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio();
    cin.tie(0);
    
    int n,d,x,y,c=0;
    double s;
    
    cin >> n >> d;
    
    while(n--)
    {
        cin >> x >> y;
        s = sqrt(pow(x,2)+pow(y,2));
        if(s<=d)
            c++;
    }
    cout<<c;
    
    return 0;
}

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

int main(){
    string S;
    cin >> S;
    /*map<char,int> mp;
    mp['0'] = 0;
    mp['1'] = 1;*/
    string op[3];
    vector<int> A(4);
    for (int i = 0; i < 4; i++)
    {
        A[i] = S[i] - '0';
        cerr << A[i] << endl;
    }
    

    for (int bit = 0; bit < (1<<3); bit++)
    {
        int sum = A[0];
        for (int i = 0; i < 3; i++)
        {
            if (bit & (1<<i))
            {
                sum += A[i + 1];
                op[i] = "+";
            } else
            {
                sum -= A[i + 1];
                op[i] = "-";
            }
        }
        cerr << A[0] << op[0] << A[1] << op[1] << A[2] << op[2] << A[3] << "=" << sum << endl;
        if (sum == 7)
        {
            break;
        }
        
        
    }
    
        

    cout << A[0] << op[0] << A[1] << op[1] << A[2] << op[2] << A[3] << "=" << 7 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

struct Point {
  ll x, y;

  Point () {}
  Point(ll x, ll y): x(x), y(y) {}

  Point operator + (Point& p) {
    return Point(x + p.x, y + p.y);
  }
};

bool cross(Point a, Point b) {
  return a.x * b.y - a.y * b.x > 0;
}

vector<Point> argsort(vector<Point> p) {
  int n = p.size();
  vector<Point> q[4];
  rep(i, n) {
    if (p[i].x > 0 && p[i].y >= 0) q[0].push_back(p[i]);
    else if (p[i].x <= 0 && p[i].y > 0) q[1].push_back(p[i]);
    else if (p[i].x < 0 && p[i].y <= 0) q[2].push_back(p[i]);
    else if (p[i].x >= 0 && p[i].y < 0) q[3].push_back(p[i]);
  }
  rep(i, 4) sort(q[i].begin(), q[i].end(), cross);
  vector<Point> ps;
  rep(i, 4) {
    rep(j, q[i].size()) {
      ps.push_back(q[i][j]);
    }
  }
  return ps;
}

ll norm(Point p) {
  return p.x * p.x + p.y * p.y;
}

int main() {
  int n;
  cin >> n;
  vector<Point> p(n);
  rep(i, n) cin >> p[i].x >> p[i].y;

  p = argsort(p);
  n = p.size();
  rep(i, n) {
    p.push_back(p[i]);
  }
  ll ans2 = 0;
  FOR(i, 1, n + 1) {
    rep(j, n) {
      Point res = {0, 0};
      rep(k, i) {
        res = res + p[j + k];
      }
      ll res2 = norm(res);
      ans2 = max(ans2, res2);
    }
  }
  ld ans = sqrt(ans2);
  cout << setprecision(20) << ans << endl;



  
  return 0;
}


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

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

using namespace std;

class mint{
	static const int MOD=1e9+7;
	int x;
public:
	mint():x(0){}
	mint(long long y){ x=y%MOD; if(x<0) x+=MOD; }

	mint& operator+=(const mint& m){ x+=m.x; if(x>=MOD) x-=MOD; return *this; }
	mint& operator-=(const mint& m){ x-=m.x; if(x<   0) x+=MOD; return *this; }
	mint& operator*=(const mint& m){ x=1LL*x*m.x%MOD; return *this; }
	mint& operator/=(const mint& m){ return *this*=inverse(m); }
	mint operator+(const mint& m)const{ return mint(*this)+=m; }
	mint operator-(const mint& m)const{ return mint(*this)-=m; }
	mint operator*(const mint& m)const{ return mint(*this)*=m; }
	mint operator/(const mint& m)const{ return mint(*this)/=m; }
	mint operator-()const{ return mint(-x); }

	friend mint inverse(const mint& m){
		int a=m.x,b=MOD,u=1,v=0;
		while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
		return u;
	}

	friend istream& operator>>(istream& is,mint& m){ long long t; is>>t; m=mint(t); return is; }
	friend ostream& operator<<(ostream& os,const mint& m){ return os<<m.x; }
	int to_int()const{ return x; }
};

mint fact(int n){
	static vector<mint> memo={1};
	if(memo.size()<=n){
		int k=memo.size();
		memo.resize(n+1);
		for(;k<=n;k++) memo[k]=memo[k-1]*k;
	}
	return memo[n];
}

int main(){
	int n,tar; scanf("%d%d",&n,&tar);
	vector<int> a(n);
	rep(i,n) scanf("%d",&a[i]);

	mint dp[101][256]; // dp[length][xor]
	dp[0][0]=1;
	rep(i,n) for(int j=i;j>=0;j--) rep(x,256) dp[j+1][x^a[i]]+=dp[j][x];

	mint ans=0;
	for(int j=1;j<=n;j++) ans+=dp[j][tar]*fact(j);
	printf("%d\n",ans.to_int());

	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double EPS=1e-10;
const double PI=acos(-1);

const ll N=50;
ll dp[N][2][2];

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vector<ll> a(n);
	ll x=0,sum=0;
	rep(i,n){
		cin>>a[i];
		if(i>=2){
			x^=a[i];
		}else{
			sum+=a[i];
		}
	}
	rep(i,N)rep(j,2)rep(k,2) dp[i][j][k]=-1;
	dp[0][0][0]=0;
	rep(i,N-1)rep(j,2)rep(k,2){
		if(dp[i][j][k]==-1) continue;
		rep(na,2)rep(nb,2){
			ll ni=i+1,nj=j,nk=0;
			if((na^nb)!=((x>>i) & 1)) continue;
			ll nsum=na+nb+k;
			if((nsum%2)!=((sum>>i) & 1)) continue;
			if(nsum>=2){//繰り上がりあり
				nk=1;
			}
			ll c=((a[0]>>i) & 1);
			if(na<c){
				nj=0;
			}else if(na==c){
				nj=j;
			}else{
				nj=1;
			}
			chmax(dp[ni][nj][nk],dp[i][j][k]|((1ll<<i)*na));
		}
	}
	ll ans=dp[N-1][0][0];
	if(ans==-1 || ans==0){
		cout<<-1<<endl;
	}else{
		cout<<a[0]-ans<<endl;
	}
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define maxn 100001
int N;
struct Node
{
    int X;
    int L;
};
Node nodes[maxn];
int cmp(Node x, Node y)
{
    if(x.X + x.L != y.X + y.L)
        return x.X + x.L < y.X + y.L;
    return x.L < y.L;
}
int main(void)
{
    cin>>N;
    for(int i = 0;i < N;i ++)
    {
        cin>>nodes[i].X>>nodes[i].L;
    }
    sort(nodes,nodes + N,cmp);
    int ans = 1;
    int now = nodes[0].X + nodes[0].L;
    for(int i =1 ;i <N;i ++)
    {
        if(nodes[i].X - nodes[i].L >= now)
        {
            ans ++;
            now = nodes[i].X + nodes[i].L;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
def numba_compile(numba_config):
    import os, sys
    if sys.argv[-1] == "ONLINE_JUDGE":
        from numba import njit
        from numba.pycc import CC
        cc = CC("my_module")
        for func, signature in numba_config:
            globals()[func.__name__] = njit(signature)(func)
            cc.export(func.__name__, signature)(func)
        cc.compile()
        exit()
    elif os.name == "posix":
        exec(f"from my_module import {','.join(func.__name__ for func, _ in numba_config)}")
        for func, _ in numba_config:
            globals()[func.__name__] = vars()[func.__name__]
    else:
        from numba import njit
        for func, signature in numba_config:
            globals()[func.__name__] = njit(signature, cache=True)(func)
        print("compiled!", file=sys.stderr)

import numpy as np

def solve(N, S, A):
    mod = 998244353
    dp = np.zeros((N+1, S+1), dtype=np.int64)
    dp[0, 0] = 1
    ans = 0
    for i, a in enumerate(A, 1):
        for j in range(S+1):
            dp[i, j] += dp[i-1, j]
            if j-a >= 0:
                dp[i, j] += dp[i-1, j-a]
            dp[i, j] %= mod
        dp[i, 0] += 1
        ans += dp[i, S]
    print(ans % mod)

numba_compile([
    [solve, "void(i8,i8,i8[:])"]
])

N, S = map(int, input().split())
A = np.array(input().split(), dtype=np.int64)
solve(N, S, A)


Measured memory_bytes: 97576
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();

		int ans_n =( n * (n-1) ) / 2;
		int ans_m =( m * (m-1) ) / 2;

		System.out.println( ans_n + ans_m );

		sc.close();

	}

}


Measured memory_bytes: 22612
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

const ll MOD = 998244353;


ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}

const int MAXN = 310;

bitset<MAXN> bb[MAXN];

int n, m;

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	cin >> n >> m;
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < m; ++j) {
			int x;
			cin >> x;
			bb[i][j] = x;
		}
	int now = 0;
	for (int i = 0; i < m; ++i) {
		int fl = 0;
		for (int j = now; j < n; ++j)
			if (bb[j][i]) {
				fl = 1;
				swap(bb[j], bb[now]);
				break;
			}
		if (!fl)
			continue;
		for (int j = now + 1; j < n; ++j) {
			if (bb[j][i])
				bb[j] ^= bb[now];
		}
		++now;
	}
	ll go = (pw(2, n) + MOD - pw(2, n - now)) % MOD;
	cout << (go * pw(2, m - 1)) % MOD << "\n";
	return 0;
}




Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        int[][] d = new int[h + 1][w + 1];
        for (int i = 1; i <= h; i++) {
            for (int j = 1; j <= w; j++) {
                d[i][j] = sc.nextInt();
            }
        }

        List<String> ans = new ArrayList<>();
        for (int i = 1; i <= h; i++) {
            for (int j = 1; j <= w; j++) {
                if (i == h && j == w) {
                    continue;
                }
                int x = i;
                int y = 0;
                if (i % 2 == 1) {
                    y = j;
                } else {
                    y = w - j + 1;
                }
                if (d[x][y] % 2 == 0) {
                    continue;
                }
                StringBuilder sb = new StringBuilder();
                if ((y == w && x % 2 == 1)) {
                    sb.append(x);
                    sb.append(" ");
                    sb.append(y);
                    sb.append(" ");
                    sb.append(x + 1);
                    sb.append(" ");
                    sb.append(y);
                    ans.add(sb.toString());
                    d[x + 1][y]++;
                } else if ((y == 1 && x % 2 == 0)) {
                    sb.append(x);
                    sb.append(" ");
                    sb.append(y);
                    sb.append(" ");
                    sb.append(x + 1);
                    sb.append(" ");
                    sb.append(y);
                    ans.add(sb.toString());
                    d[x + 1][y]++;
                } else if ((x % 2 == 1)) {
                    sb.append(x);
                    sb.append(" ");
                    sb.append(y);
                    sb.append(" ");
                    sb.append(x);
                    sb.append(" ");
                    sb.append(y + 1);
                    ans.add(sb.toString());
                    d[x][y + 1]++;
                } else if ((x % 2 == 0)) {
                    sb.append(x);
                    sb.append(" ");
                    sb.append(y);
                    sb.append(" ");
                    sb.append(x);
                    sb.append(" ");
                    sb.append(y - 1);
                    ans.add(sb.toString());
                    d[x][y - 1]++;
                }
            }
        }

        System.out.println(ans.size());
        for (String s : ans) {
            System.out.println(s);
        }
    }
}


Measured memory_bytes: 121028
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define inN(x, N) rep(i, N) in(x[i])
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());

    string S, T;
    in2(S, T);

    outl(T + S);

    return 0;
} 

Measured memory_bytes: 3596
N=int(input())
*A,=map(int,input().split())
M=max(A)
B=[1]*(M+1)
B[0]=B[1]=1
i=2
while i<=M:
    if B[i]:
        j=2
        while i*j<=M:
            B[i*j]=0
            j+=1
    i+=1

C=[0]*(M+1)
for a in A:
    C[a]=1

from math import*
now=A[0]
for a in A:
    now=gcd(now,a)
if now==1:
    ans='pairwise coprime'
    i=2
    while i<=M:
        if B[i]:
            count=0
            j=1
            while i*j<=M:
                count+=C[i*j]
                j+=1
            if count>1:
                ans='setwise coprime' 
        i+=1
    print(ans)
else:
    print('not coprime')

Measured memory_bytes: 232268
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
	ll N;
	cin >> N;
	ll a[N + 1];
	for (ll i = 0; i < N; i++) {
		cin >> a[i];
	}
	ll sum = 0;
	for (ll i = 0; i < N; i++) {
		while (a[i] % 2 == 0) {
			a[i] = a[i] / 2;
			sum++;
		}
	}
	cout << sum << endl;
}



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

int n,t,m[1000],l[1000],k[1000];

bool check(int x){
  int c[1001]={},used[1000]={},cnt=0;
  for(int i=0;i<t;i++){
    x+=c[i];
    for(int j=0;j<n&&x;j++){
      if(used[j])continue;
      if(i+m[j]>t)return 0;
      if(i%(l[j]+k[j])<=l[j])c[i+m[j]]++,cnt++,used[j]=1,x--;
    }
  }
  return cnt==n;
}

int main(){
  while(scanf("%d%d",&n,&t),n){
    for(int i=0;i<n;i++)scanf("%d%d%d",&m[i],&l[i],&k[i]);
    int ans=0;
    for(int i=1;i<=n&&!ans;i++)if(check(i))ans=i;
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3164
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import permutations,combinations
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
# from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint

def myinput():
    return map(int,input().split())

def mylistinput(n):
    return [ list(myinput()) for _ in range(n) ]

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

a,b,c,d = myinput()

while True:
    # 高橋ターン
    c -= b
    if c<=0:
        print("Yes")
        exit()
    else:
        pass
    # 青木ターン
    a -= d
    if a<=0:
        print("No")
        exit()

Measured memory_bytes: 68300
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <cstdint>
#include <numeric>
#define INF 1000000000
#define LLINF 2000000000000000
#define MOD 1000000007
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
#define int long long

signed main(){
  int a,b,c;
  int n;
  string s,t;
  int ans = 0;
  cin >> n;
  n = n%10;
  if(n==3){
    cout << "bon" << endl;
  }else if(n==0 || n==1 || n==6 || n==8){
    cout << "pon" << endl;
  }else{
    cout << "hon" << endl;
  }
}


Measured memory_bytes: 3624
#include <stdio.h>
#include<string.h>


int main() {
char s[100];
scanf("%s", s);
int i;
int f;
char b;
for(i=0;i<=strlen(s);i++){
  if(s[i]>=65&&s[i]<=90)
    s[i]=s[i]+32;
    b = s[i-1];
}

char a = s[0];

i = i-3;
printf("%c%d%c\n",a,i,b);

return 0;


}


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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , "; logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */

int main(){
    int a,b; cin>>a>>b;
    if((a*b)%2) out("Odd"); else out("Even");
}

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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 10;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<P> &s, P a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);


void print_line(vector<ll> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}


typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;
const int mod = 1000000007;

// https://onlinejudge.u-aizu.ac.jp/solutions/problem/DSL_2_F/review/3380631/face4/C++14
class STlazy {
private:
    int n;
    vector<int> node, lazy;

public:
    STlazy() {
        n = (1 << 17) - 1;
        node.resize(2 * n - 1, 0);
        lazy.resize(2 * n - 1, -1001);
    }

    void eval(int k, int l, int r) {
        if (lazy[k] == -1001) return;
        node[k] = (r - l) * lazy[k];
        if (r - l > 1) {
            lazy[2 * k + 1] = lazy[k];
            lazy[2 * k + 2] = lazy[k];
        }
        lazy[k] = -1001;
    }

    void update(int a, int b, int x, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        eval(k, l, r);
        if (r <= a || b <= l) return;
        if (a <= l && r <= b) {
            lazy[k] = x;
            eval(k, l, r);
            return;
        }
        update(a, b, x, 2 * k + 1, l, (l + r) / 2);
        update(a, b, x, 2 * k + 2, (l + r) / 2, r);
        node[k] = node[2 * k + 1] + node[2 * k + 2];
    }

    int query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        if (r <= a || b <= l) return 0;
        eval(k, l, r);
        if (a <= l && r <= b) return node[k];
        int lx = query(a, b, 2 * k + 1, l, (l + r) / 2);
        int rx = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return lx + rx;
    }
};

int main() {

    int n, q;
    cin >> n >> q;

    STlazy st;

    rep(i, q) {
        int query;
        cin >> query;

        if (query == 0) {
            int s, t, x;
            cin >> s >> t >> x;
            t++;
            st.update(s, t, x);
        } else if (query == 1) {
            int s, t;
            cin >> s >> t;
            t++;
            cout << st.query(s, t) << endl;
        }

    }

}



Measured memory_bytes: 4968
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define all(n) n.begin(),n.end()
#define yn(x) cout << (x ? "Yes":"No") << endl;
 

int main() {
  ll n,s,k;
  cin >> n >> k >> s;
  if(s==1000000000){
    rep(i,k) cout << s << " " ;
    rep(i,n-k) cout << 1 << " " ;
  }
  else{
    rep(i,k) cout << s << " " ;
    rep(i,n-k) cout << s+1 << " " ;
  }
  cout << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

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;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  int N, M;
  cin >> N;
  cin >> M;
  vector<bool> from(N, false);
  vector<bool> to(N, false);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a > b) swap(a, b);
    if (a == 0) from[b] = true;
    if (b == N - 1) to[a] = true;
  }
  bool judge = false;
  for (int i = 1; i < N - 1; i++) { judge |= (from[i] && to[i]); }
  if (judge) {
    cout << "POSSIBLE" << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp5
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var list = new List<int>();
            var l = Console.ReadLine().Split(' ');
            foreach (var item in l)
            {
                list.Add(int.Parse(item));
            }
            var max = list.Max();
            list.Remove(max);
            var sum = list.Sum();

            if (max < sum)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 13268
#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main()
{
	string s;
	cin >> s;
	for (int i = 0; i < 8; i++) {
		s.pop_back();
	}
	cout << s << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import itertools
import math
from operator import mul
from functools import reduce


MOD = 1000000007  # type: int

def combination_(n,k,mod):
    r = min(n-k,k)
    k = max(n-k,k)
    res = 1

    for i in range(k+1,n+1):
        res = res * i
        if res > mod:
            res = res % mod

    res = res % mod
    for i in range(1,r+1):
        res = res//i
    return res

def combination(n, r, mod):
    numerator = reduce(lambda x, y: x * y % mod, [n - r + k + 1 for k in range(r)])
    denominator = reduce(lambda x, y: x * y % mod, [k + 1 for k in range(r)])
    return numerator * pow(denominator, mod - 2, mod) % mod

def solve(n: int, a: int, b: int):
    print((pow(2, n, MOD) - combination(n, a, MOD) - combination(n, b, MOD) - 1) % MOD)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    solve(n, a, b)

if __name__ == '__main__':
    main()


Measured memory_bytes: 11524
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Set set = new HashSet<>();
		char s[] = sc.next().toCharArray();
		for (int i=0; i<s.length; i++) {
			set.add(s[i]);
		}

		System.out.println(set.size()==2 ? "Yes" : "No");

//		if (set.size()==2) {
//			System.out.println("Yes");
//		} else {
//			System.out.println("No");
//		}

	}
}

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

int main() {

	int n;
	cin >> n;

	int p = 0;
	for (int i = 0;i < n;i++) {
		if (pow(2, i) > n) {
			p = i - 1;
			break;
		}
	}

	cout << pow(2, p) << endl;
}


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


int main(void) {
    double a, b, c, d, e, f;
    double x, y;
    
    while(cin >> a >> b >> c >> d >> e >> f) {
        x = (c*e - b*f) / (a*e - b*d);
        y = (c*d - a*f) / (b*d - a*e);
        
        if(x == 0) x = 0;
        if(y == 0) y = 0;
        printf("%.3lf %.3lf", x, y);
        cout << endl;
    }
}


Measured memory_bytes: 3176
#include<bits/stdc++.h>
#define maxn 100010
#define pb push_back
using namespace std;

int a[maxn],b[maxn],c[maxn],d[maxn],fa[maxn],sz[maxn],n,cnt=0,cnt2=0;
bool vis[maxn];
vector<int> v;
int find(int x){
	return fa[x]==x?x:fa[x]=find(fa[x]);
}
int main(){
	ios::sync_with_stdio(0);
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i],a[n+1]^=a[i],v.pb(a[i]);
	v.pb(a[n+1]);
	for(int i=1;i<=n;i++)
		cin>>b[i],b[n+1]^=b[i];
	memcpy(c,a,sizeof(a));
	memcpy(d,b,sizeof(b));
	sort(c+1,c+n+2),sort(d+1,d+n+2);
	for(int i=1;i<=n+1;i++){
		if(c[i]!=d[i])
			return cout<<"-1"<<endl,0;
	}
	sort(v.begin(),v.end());
	v.erase(unique(v.begin(),v.end()),v.end());
	for(int i=0;i<v.size();i++)
		fa[i]=i,sz[i]=1;
	for(int i=1;i<=n+1;i++){
		int x=lower_bound(v.begin(),v.end(),a[i])-v.begin();
		int y=lower_bound(v.begin(),v.end(),b[i])-v.begin();
		if(a[i]!=b[i]||i==n+1)
			cnt+=i<=n,vis[x]=vis[y]=1;
		if(find(x)!=find(y))
			fa[find(x)]=find(y);
	}
	if(!cnt)
		return cout<<"0"<<endl,0;
	for(int i=0;i<v.size();i++)
		cnt+=vis[i]&&find(i)==i;
	cout<<cnt-1<<endl;
	return 0;
}

Measured memory_bytes: 4728
#include<bits/stdc++.h>
using namespace std;
#define NL            "\n"
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
int main()
{
    _SAD()
    int n,k;
    cin>>n;
    for(int i=1;i<=sqrt(n);i++)
    {
       if((i*i)<=n)
       {
           k=i*i;
       }
    }
    cout<<k<<NL;
    return 0;
}


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

int gcd(int a,int b){
    while(1) {
        if(a < b) swap(a, b);
        if(!b) break;
        a %= b;
    }
    return a;
}

int main(){
    int K;
    int sum=0;
    cin >> K;
    for(int i=1;i<=K;i++){
        for(int j=1;j<=K;j++){
            for(int h=1;h<=K;h++){
                int a,b;
                a=gcd(i,j);
                b=gcd(a,h);
                sum += b;
            }
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d,e,k;
  cin >> a >> b >> c >> d >> e >> k;
  if(e- a <= k){
    cout << "Yay!" << endl;
  }
  else cout << ":(" << endl;
}


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

using namespace std;

vector<vector<pair<int, int>>> G;
vector<bool> used;
vector<int> color;

void dfs(int v, bool c) {
    used[v] = true;
    color[v] = c;

    for(auto e : G[v]) {
        if(used[e.first]) continue;
        if(e.second % 2) {
            dfs(e.first, !c);
        } else {
            dfs(e.first, c);
        }
    }
}

int main() {
    int N;
    int u, v;
    long long w;
    cin >> N;

    used.resize(N);
    color.resize(N);
    G.resize(N);

    fill(used.begin(), used.end(), false);

    for(int i = 0; i < N-1; i++) {
        cin >> u >> v >> w;
        u--;
        v--;
        bool p = (w%2==1);
        G[u].emplace_back(make_pair(v, p));
        G[v].emplace_back(make_pair(u, p));
    }

    dfs(0, 0);

    for(int i = 0; i < N; i++) {
        cout << color[i] << endl;
    }
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
#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 ALL(v) v.begin(), v.end()
#define MOD 1000000007
typedef long long ll;

using namespace std;

const int AMAX = 100000;
ll cnt[AMAX + 1];

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

  REP(i, n) {
    int A, B;
    cin >> A >> B;
    cnt[A] += B;
  }

  FOR(i, 1, AMAX+1){
    if (k <= cnt[i]) {
      cout << i << endl;
      break;
    }
    k -= cnt[i];
  }

  return (0);
}

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

int main() {
  int H, W;
  cin >> H >> W;
  int cnt = 0;
  vector<vector<char>> S(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> S.at(i).at(j);
      if (S.at(i).at(j) == '.') cnt++;
    }
  }
  vector<vector<int>> dist(H, vector<int>(W, -1));
  int h = 0;
  int w = 0;
  dist.at(h).at(w) = 0;
  vector<int> mh(4), mw(4);
  mh = {-1, 0, 1, 0};
  mw = {0, 1, 0, -1};
  queue<pair<int,int>> Q;
  Q.push({h, w});
  while (Q.size()) {
    int h = Q.front().first;
    int w = Q.front().second;
    Q.pop();
    for (int i = 0; i < 4; i++) {
      int nh = h + mh.at(i);
      int nw = w + mw.at(i);
      if (nh < 0 || nh >= H || nw < 0 || nw >= W) continue;
      if (S.at(nh).at(nw) == '#') continue;
      if (dist.at(nh).at(nw) == -1) {
        dist.at(nh).at(nw) = dist.at(h).at(w) + 1;
        Q.push({nh, nw});
      }
    }
  }
  if (dist.at(H - 1).at(W - 1) == -1) return cout << -1 << "\n", 0;
  cout << cnt - dist.at(H - 1).at(W - 1) - 1 << "\n";
}

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

queue<int> q;

void search(const vector< vector<int> >& v, vector<int>& d) {
    int i = q.front();
    q.pop();
    for (const auto& a : v[i]) {
        if (d[a] == -1) {
            d[a] = i;
            q.push(a);
        }
    }
}

int main() {
    int n, m;
    cin >> n >> m;
    vector< vector<int> > v(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        v[a - 1].push_back(b - 1);
        v[b - 1].push_back(a - 1);
    }

    vector<int> d(n, -1);
    d[0] = 0;
    q.push(0);
    while (!q.empty())
        search(v, d);

    cout << "Yes\n";
    for (int i = 1; i < n; i++) cout << d[i] + 1 << endl;
}

Measured memory_bytes: 10120
#include<bits/stdc++.h>
#define MAXN 10000

using namespace std;
typedef long long ll;

int main()
{
	//freopen("t.txt","r",stdin);
	string s; cin>>s;
	if (s[0]==s[1]||s[1]==s[2]||s[2]==s[3])
	{
		cout<< "Bad"; return 0;
	}
	cout<<"Good";
}

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


public class Main {

	final static long MOD = 1000000007;
	//final static long MOD = 998244353;

	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static long cnt=0;
	public static PrintWriter pw = new PrintWriter(System.out);
	public static void main(String[] args) throws Exception {
		solutionA(args);
		if(in!=null){
			in.close();
		}
		pw.flush();
		pw.close();
	}

	public static void solutionA(String[] args) throws Exception{

		int N=nextInt();
		int[] A = nextInts();
		int[] check = new int[N];
		for(int i=0;i<N;i++) {
			check[A[i]]++;
		}
		if(N%2==1) {
			if(check[0]!=1) {
				pw.println(0);
				return;
			}
			for(int i=2;i<check.length;i+=2) {
				if(check[i]!=2) {
					pw.println(0);
					return;
				}
			}
		}else {
			for(int i=1;i<check.length;i+=2) {
				if(check[i]!=2) {
					pw.println(0);
					return;
				}
			}

		}

		long ans ;
		if(N%2==0) {
			ans=2;
			N-=2;
		}else {
			ans=1;
			N-=1;
		}
		for(int i=0;i<N/2;i++) {
			ans*=2;
			ans%=MOD;
		}
		pw.println(ans);


	}



	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}

}



Measured memory_bytes: 38868
s=input()
from collections import deque
def kaibun_search(str):
    d=deque(str)
    while len(d)>1:
        a=d.popleft()
        b=d.pop()
        if a!=b:
            return -1

    return 0

if kaibun_search(s)==0 and kaibun_search(s[0:(len(s)-1)//2])==0 and kaibun_search(s[(len(s)+3)//2-1:len(s)])==0:
    print("Yes")
else:
    print("No")
    #print(s[(len(s) + 3) // 2 - 1:len(s)])
    #print(s[0:(len(s)-1)//2-1])

Measured memory_bytes: 38256
const BKRT = "\n";
const SPAC = " ";
const NOSP = "";

function Main(input){
	input = [].concat(...input.trim().split(BKRT).map(a=>a.split(SPAC)));
  const strShift = ()=>input.shift();
  const intShift = ()=>~~input.shift();
  
  var a = intShift();
  var b = intShift();
  var c = b - a; 
  
  return c * (c+1) /2 - b;
}

// If you are interested in the algorithms I used, 
// there is no need to read down from this line.

((b,c,d)=>"undefined"!=typeof require?console.log(Main(require("fs").readFileSync("/dev/stdin","utf8"))):[b=b.split("\n").slice(1,-1).join("\n"),c=function(){try{return Main(b)}catch(f){return f.stack||f.message}}(),d=typeof c,"string"==d||(c=JSON.stringify(c)),$("<form>").append([[10,b],0,[1,d],0,[10,c]].map(f=>$(f?"<textarea>":"<br>",f&&{rows:f[0],cols:40,text:f[1]}))).appendTo("body")])(`
54 65
`);

Measured memory_bytes: 7372
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		a += 11;
		a %= 13;
		b += 11;
		b %= 13;
		if (a < b) {
			System.out.println("Bob");
		} else if (b < a) {
			System.out.println("Alice");
		} else {
			System.out.println("Draw");
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}


Measured memory_bytes: 20820
//gauravsinghh
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define ll long long int
#define sz(s) (int)s.size()
#define rep(i,n) for(ll i = 0; i < n; i++)
#define fo(i, a, b) for(int i = a; i <= b; i++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

void io_set() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

signed main(){ 
    IOS
    //io_set();
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll x = (a-1)/c;
    ll y = b/c;
    y -= x;
    ll m = (a-1)/ d;
    ll n = b/d;
    n -= m;
    ll pk = (c*d)/__gcd(c,d);
    ll p = (a-1)/pk;
    ll q = b/pk;
    q -= p;
    cout << (b-a+1) - y - n + q << endl;;
    return 0;
}



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

int main() {
  int A,B,C;
  string S;
  cin>>A>>B;
  if(A%3==0||B%3==0||(A+B)%3==0) S="Possible";
  else S="Impossible";
  
  cout<<S<<endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int N = sc.nextInt();

        long [] Li =new long[101];
		for(int i=0;i<N;i++){
        	Li[i] = sc.nextInt();
        }
        
		int step;
        step=0;
      
		for(int i=0;i<N-2;i++){
        	for(int j=i+1;j<N-1;j++){
        		for(int k=j+1;k<N;k++){
                  if(Li[i]!=Li[j] && Li[j]!=Li[k] && Li[k]!=Li[i]){
                	if(Li[i]+Li[j]>Li[k] && Li[i]+Li[k]>Li[j] && Li[k]+Li[j]>Li[i]){
                      step=step+1;
                    }
                  }  
        		}
        	}
        }        
      
        // 出力
        System.out.println(step);
    }
}


Measured memory_bytes: 36724
import sys
N = int(input())
dp = [ 100000 for i in range(N+1)]
dp[0] = 0
for i in range(1,N+1):
    power = 1
    while power <= i:
        dp[i] = min(dp[i],dp[i-power]+1)
        power *= 6
    power = 1
    while power <= i:
        dp[i] = min(dp[i],dp[i-power]+1)
        power *= 9
    while power <= i:
        dp[i] = min(dp[i],dp[i-power]+1)
        power += 1
print(dp[N])



Measured memory_bytes: 3864
#include <iostream>
#include <string>

int main(){
    std::string s;
    std::cin >> s;

    int n = s.length();
    int ans = n;
    for(int k = 0; k < n - 1; ++k){
        if(s[k] != s[k+1]){
            ans = std::min(ans, std::max(k + 1, n - k - 1));
        }
    }

    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 512
#!/usr/bin/env python3
import sys


def solve(a: int, b: int, c: int, d: int):
    ans1 = max(a, b) * max(c, d)
    ans2 = max(a, b) * min(c, d)
    ans3 = min(a, b) * max(c, d)
    ans4 = min(a, b) * min(c, d)
    print(max(ans1, max(ans2, max(ans3, ans4))))
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    c = int(next(tokens))  # type: int
    d = int(next(tokens))  # type: int
    solve(a, b, c, d)

if __name__ == '__main__':
    main()


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

int main()
{
    int n;
    cin >> n;
    string s;
    map <string ,int> mp;
    for(int i=0; i<n; i++){
        cin >> s;
        sort(s.begin() ,s.end());
        mp[s]++;
    }
    long long ans = 0LL;
    for(auto p : mp)
        ans += 1LL*p.second*(p.second-1)/2;
    cout << ans << endl;
}


Measured memory_bytes: 11136
import java.util.Scanner;


public class Main {
	
	public static int oRank,tRank,jRank=0;
	
	public static void main(String[] args){
		Scanner reader = new Scanner(System.in);
		String str1 = reader.nextLine();
		
		String[] fLine = str1.split(" ");
		int N =Integer.parseInt(fLine[0]);
		int A =Integer.parseInt(fLine[1]);
		int B =Integer.parseInt(fLine[2]);
		
		String sLine = reader.nextLine();
		
		for (char s: sLine.toCharArray()){
			if(s == 'a'){
				if(tRank<A+B){
					jRank++;
					tRank++;
					System.out.println("Yes");
				}
				else
					System.out.println("No");
			}
			else if (s == 'b'){
				
				if(tRank<A+B && oRank<B){
					oRank++;
					tRank++;
					System.out.println("Yes");
				}
				else
					System.out.println("No");
			}
			else if (s == 'c')
				System.out.println("No");
		}
	}
}


Measured memory_bytes: 23808