akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
            #include <ext/pb_ds/assoc_container.hpp>
            #include <ext/pb_ds/tree_policy.hpp>
            using namespace std;
            using namespace __gnu_pbds;
            #define rep(i,a,b) for(ll i =a; i<b;++i)
            #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
            #define nl "\n"
            #define pb push_back
            #define F first
            #define S second
            #define print(a)       for(auto x : a) cout << x << " "; cout << endl
            #define print1(a)      for(auto x : a) cout << x.F << " " << x.S << endl
            #define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << endl
            #define mk(x,y)  make_pair(x,y)
            typedef long long int ll;
            const ll N =  1e6+ 5 ;
            const ll mod = 1e9+7;
            const ll inf = 1e18;
            ll   n  , m  , k,u,v , xors , sum , fact[N] , inv_fact[N] ,ans  , a[N];
            set <ll> row ,col;
    ll pow_mod_m(ll a , ll n)
    {
        if(!n)
            return 1;
        ll pt =  pow_mod_m(a,n/2);
        pt *= pt , pt %= mod; ;
        if(n&1)
            pt *= a  , pt %= mod;
        return pt;
    }

    int main()
    {
         IOS;
         int ts =1;
       ///  cin >> ts ;
         while(ts--)
         {
             cin >> n;
             rep(i,1,n+1) cin >> a[i];
             sort(a+1 , a+n+1);
             for(int i = n-1 ; i>= 0 ;i--)
             {
                 ll val = n - (i);
              ///   cout << " for current i as  : n - " << i << " current vals are : n - " << 2*val << "  :  n - " << 2*val+1 << endl;
                 if(n - 2*val >= 1)
                 {
                     ans += a[i];
                 }
                 else
                    break;
                 if(n - (2*val +1) >= 1)
                 {
                     ans += a[i];
                 }
                 else break;
             }
             cout << ans + a[n] << endl;
         }
    }


Measured memory_bytes: 5196
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int K = Integer.parseInt(sc.next());
    Integer[] val = new Integer[N];
    for(int i = 0; i < N; i++){
      val[i] = Integer.parseInt(sc.next());
    }
    Arrays.sort(val, Comparator.reverseOrder());
    
    int sum = 0;
    for(int i = 0; i < K; i++){
      sum += val[i];
    }
    
    System.out.println(sum);
  }
}

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

int main() {
    ll N, M; cin >> N >> M;
    if(N == 1 && M == 1){
        cout << 1 << endl;
    } else if(N == 1){
        cout << M-2 << endl;
    } else if(M == 1){
        cout << N-2 << endl;
    } else {
        ll ans = (N-2) * (M-2);
        cout << ans << endl;
    }

    return 0;
}

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

int main() {
  
  int A=0, B=0, C=0;
  
  cin >> A >> B >> C;
  
  vector<int> vec = {A, B, C};
  
  sort(vec.begin(), vec.end());
  
  int one = vec.at(2)-vec.at(1);
  int two = vec.at(1)-vec.at(0);
  int cost = one+two;
  
  
  cout << cost << endl;
  
}

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


using namespace std;

#define endl '\n'
#define PB push_back
#define MP make_pair
#define LL long long
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())



int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout << setprecision(5);
    cout << fixed;

    int a, b, k;

    cin >> a >> b >> k;

    for(int i = min(a, b); i >= 1; i--) {

        if(a%i == 0 && b%i == 0) {

                k--;
                if(k == 0) {

                    cout << i << endl;
                    return 0;
                }
        }

    }


    return 0;
}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int A = Integer.parseInt(scan.next());
		int B = Integer.parseInt(scan.next());

		if (A % 2 == 0 || B % 2 == 0) {
			System.out.println("No");
			return;
		}
		System.out.println("Yes");
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

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

	long long A, B, K;
	cin >> A >> B >> K;

	if (A < K)
	{
		K -= A;
		B -= K;

		cout << 0 << " " << max(B, 0LL);
	}
	else
	{
		cout << A - K << " " << B;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int ct,n,q,sx,tx,sy,ty;
set<int> ans;
set<int>::iterator it;
struct node{
	int x,y,id;
}a[500010];
struct p{
	int vx,vy,l,r,id;
}tree[500010];
bool cmpx(node a,node b){return a.x<b.x;}
bool cmpy(node a,node b){return a.y<b.y;}
int build(int l,int r,int dep){//l~(r-1)
	//cout<<l<<" "<<r<<" "<<dep<<endl;
	if(l>=r) return -1;
	int mid=(l+r)>>1;
	if(dep%2==0){
		sort(a+l,a+r,cmpx);//Å¼Êý£ºx
		while(a[mid+1].x==a[mid].x&&mid+1<r){
			mid++;
		}
	}
	else{
		sort(a+l,a+r,cmpy);//ÆæÊý£ºy
		while(a[mid+1].y==a[mid].y&&mid+1<r){
			mid++;
		}
	}
	int t=ct++;
	//cout<<t<<" "<<mid<<":"<<a[mid].x<<" "<<a[mid].y<<"("<<a[mid].id<<")"<<endl;
	
	tree[t].vx=a[mid].x;
	tree[t].vy=a[mid].y;
	tree[t].id=a[mid].id;
	tree[t].l=build(l,mid,dep+1);
	tree[t].r=build(mid+1,r,dep+1);
	//cout<<tree[t].id<<":"<<tree[t].vx<<" "<<tree[t].vy<<" "<<tree[tree[t].l].id<<" "<<tree[tree[t].r].id<<endl;
	return t;
}
void find(int num,int dep,int sx,int tx,int sy,int ty){
	//cout<<num<<"*"<<endl;
	if(tree[num].vx>=sx&&tree[num].vx<=tx&&tree[num].vy>=sy&&tree[num].vy<=ty){
		ans.insert(tree[num].id);
	}
	if(dep%2==0){
		if(sx<=tree[num].vx&&tree[num].l!=-1) find(tree[num].l,dep+1,sx,tx,sy,ty);
		if(tx>tree[num].vx&&tree[num].r!=-1) find(tree[num].r,dep+1,sx,tx,sy,ty);
	}
	else {
		if(sy<=tree[num].vy&&tree[num].l!=-1) find(tree[num].l,dep+1,sx,tx,sy,ty);
		if(ty>tree[num].vy&&tree[num].r!=-1) find(tree[num].r,dep+1,sx,tx,sy,ty);
	}
}
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d%d",&a[i].x,&a[i].y);	
		a[i].id=i;
	}
	sort(a,a+n,cmpx);
	//cout<<endl;
	//for(int i=0;i<n;i++) cout<<a[i].x<<" "<<a[i].y<<endl;
	build(0,n,0);
	scanf("%d",&q);
	for(int i=1;i<=q;i++){
		scanf("%d%d%d%d",&sx,&tx,&sy,&ty);
		ans.clear();
		find(0,0,sx,tx,sy,ty);
		for(it=ans.begin();it!=ans.end();it++){
			printf("%d\n",*it);
		}
		printf("\n");
	}
}


Measured memory_bytes: 18320
n=int(input())
A=list(map(int, input().split()))
q=int(input())
Key = list(map(int, input().split()))
def BinarySearch(A, n, key):
	left = 0
	right = n
	while (left < right):
		mid = (left + right) // 2
		if (key == A[mid]):
			return 1
		if (key > A[mid]):
			left = mid + 1
		elif (key < A[mid]):
			right = mid
	return 0
cnt = 0
for i in range(q):
	if (BinarySearch(A, n, Key[i])):
		cnt+=1
print(cnt)



Measured memory_bytes: 16712
#N円の品物、K個の嫌いな数字
N, K = map(int, input().split())

#いろはちゃんの嫌いな数字のリスト
d_list = map(int, input().split())

d_set = set(d_list)

num_set = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}

#いろはちゃんの好きな数字のセット
fav_num = d_set ^ num_set

#N ~ 10Nの間の数字で、fav_numの中の数字のみから作られる
#payを1つずつ探す

for pay in range(N, 10*N):
	num_N = list(map(int, str(pay)))
	num_Ns = set(num_N)
	
	if num_Ns <= fav_num:
		print(pay)
		break
	
	else:
		pay = pay + 1
		

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

int main(){
    ll h,w; cin >> h >> w;
    int n; cin >> n;
    ll a[n], b[n]; rep(i,n) cin >> a[i] >> b[i];
    map<pair<ll,ll>,int> m;
    // 区間を左上マスで数える
    rep(i,n){
        rep(j,3) rep(k,3){
            if(a[i]-j > 0 && a[i]-j <= h-2 && b[i]-k > 0 && b[i]-k <= w-2) m[make_pair(a[i]-j,b[i]-k)]++;
        }
    }
    vector<ll> ans(10,0LL);
    for(auto i:m) ans[i.second]++;
    ans[0] = (h-2)*(w-2);
    rep(i,9) ans[0] -= ans[i+1];
    rep(i,10) cout << ans[i] << "\n";
}

Measured memory_bytes: 58112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
int main()
{
    int n;
    string s;
    cin >> n >> s;
    string ss = s.substr(0, n / 2);

    if ((ss + ss) == s)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3616
import java.util.*;

public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    
    String s = sc.nextLine();
    int count = 0;
    if(String.valueOf(s.charAt(0)).equals("1")){
      count+=1;
    }
    if(String.valueOf(s.charAt(1)).equals("1")){
      count+=1;
    }
    if(String.valueOf(s.charAt(2)).equals("1")){
      count+=1;
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <cstdio>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define F first
#define S second
void YES(bool che){
    if(che)cout<<"YES\n";
    else cout<<"NO\n";
}
void Yes(bool che){
    if(che)cout<<"Yes\n";
    else cout<<"No\n";
}
int main(void){
   int n;
   cin>>n;
   cout<<n/3<<endl;
    
}


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

using namespace std;

#define endl "\n"
typedef long long int ll;

inline void fastio(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
inline void setPrecision(int n){cout.precision(n);}

//DEBUG
#define dbg(x) cerr<<(#x)<<": "<<x<<endl
#define dbgV(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<it<<" "; cerr<<endl;
#define dbgS(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<it<<" "; cerr<<endl;
#define dbgM(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<"["<<it.f<<", "<<it.s<<"] "; cerr<<endl;
#define dbg2D(x) cerr<<(#x)<<": \n"; for(auto y: x) { for(auto it: y) cerr<<it<<" "; cerr<<endl; } cerr<<endl;
#define dbgA(x, n) cerr<<(#x)<<": "; for(int i=0;i<n;++i) cerr<<x[i]<<" "; cerr<<endl;
#define dbgVP(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<"["<<it.f<<", "<<it.s<<"] "; cerr<<endl;

ll INF = 1e10;
ll MOD = 1e9+7;

int n;
bool a[22][22];
bool wamen[22];

int done[(1<<22)];

int base = 0;
ll pairs(int now){
    if(now == n) return 1;
    if(done[base] != -1) return done[base];
    ll ans = 0;
    for(int j=0;j<n;++j){
        if(a[now][j] && !wamen[j]){
            wamen[j] = 1;
            base += 1<<j;
            ans += pairs(now+1);
            wamen[j] = 0;
            base -= 1<<j;
            if(ans >= MOD) ans-=MOD;
        }
    }
    done[base] = ans;
    //dbg(now); dbg(ans); dbgA(wamen, n); cerr<<endl;
    return ans;
}

int main(){
    #ifndef ONLINE_JUDGE
        freopen("debug.txt", "w", stderr);
    #endif
    fastio();
    cin>>n;
    for(int i=0;i<n;++i)
        for(int j=0;j<n;++j){
            int x;
            cin>>x;
            a[i][j] = x==1;
        }
    memset(done, -1, sizeof(done));
    cout<<pairs(0);
    return 0;
}


Measured memory_bytes: 20056
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int k; cin>>k;
	string s;
	cin>>s;
	if(s.length()<=k){
	cout<<s<<endl;
}
	else
	{
	for(int i=0;i<k;i++)
	cout<<s[i];
	cout<<"...";

}
}


Measured memory_bytes: 3628
#include <stdio.h>
int main (){
int a[51],i,k=0,n;
  scanf ("%d",&n);
  for (i=0;i<n;i++){
  scanf ("%d",&a[i]);
  if (a[i]!=i+1){
  k=k+1;
  }
  }
  if (k==2 || k==0){
printf ("YES");}
    else {
    printf ("NO");
    }
return 0;
}

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

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<PII> VP;


//REPEAT
//------------------------------------------
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i > n;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,m)  RFOR(i,m,0)

//container util
//------------------------------------------
#define pb(a) push_back(a)
#define fst first
#define snd second
#define SORT(V) sort((V).begin(),(V).end())
#define REV(V) reverse((V).begin(),(V).end())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//grobal variable
//------------------------------------------
int dp[101][4][4][4]; //AGCT -> 0123

//def function
//------------------------------------------
int f(int A){
  int ans = 0;
  A++;
  //10^12は2進数で40桁くらい
  REP(i, 50){
    int loop = (1LL << i+1);
    int count = (A/loop)*(loop/2);
    count += max(0LL, (A%loop) - (loop/2));
    if(count%2==1){
      ans += 1LL << i;
    }
  }
  return ans;
}

//main
//------------------------------------------

signed main(){
  int A, B;
  cin >> A >> B;
  int ans = f(B)^f(A-1);

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
def calculate(A,B,C,D):
    if A+B+C+D == 7:
        return (str(A)+"+"+str(B)+"+"+str(C)+"+"+str(D)+"=7")
    if A+B+C-D == 7:
        return (str(A)+"+"+str(B)+"+"+str(C)+"-"+str(D)+"=7")
    if A+B-C+D == 7:
        return (str(A)+"+"+str(B)+"-"+str(C)+"+"+str(D)+"=7")
    if A-B+C+D == 7:
        return (str(A)+"-"+str(B)+"+"+str(C)+"+"+str(D)+"=7")
    if A+B-C-D == 7:
        return (str(A)+"+"+str(B)+"-"+str(C)+"-"+str(D)+"=7")
    if A-B-C+D == 7:
        return (str(A)+"-"+str(B)+"-"+str(C)+"+"+str(D)+"=7")
    if A-B+C-D == 7:
        return (str(A)+"-"+str(B)+"+"+str(C)+"-"+str(D)+"=7")
    if A-B-C-D == 7:
        return (str(A)+"-"+str(B)+"-"+str(C)+"-"+str(D)+"=7")
    
ABCD = input()
A = int(ABCD[0])
B = int(ABCD[1])
C = int(ABCD[2])
D = int(ABCD[3])

ans = calculate(A,B,C,D)
print(ans)

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

char change(char a){
  int i;
  i=(int)((a-'A')/('B'-'A'));
  return 'A'+('B'-'A')*((i+23)%26);
}

int main(){
  char str[1001];
  int i,n;
  scanf("%s",str);
  n=strlen(str);
  for(i=0;i<n;i++){
    printf("%c",change(str[i]));
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <bits/stdc++.h>
#include <set>
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define vii vector<pair<int, int> >
#define si stack<int>
#define pb push_back
#define mp make_pair
#define ALL(T) (T).begin(), (T).end()
#define MODU 1000000007
typedef long long ll;
using namespace std;

ll intmax = (1LL<<32)-1;
ll llmax = (1LL<<60)-1;

const int INF = 1e9 + 5;

class fastio{
public:
	fastio(){
		ios_base::sync_with_stdio(false);
		cin.tie(NULL);
	}
} __fastio;

template <typename T>
T abs(T x){
	if(x<0)	return -x;
	else return x;
}

void DFSVisit(int u, vector<int> g[], vector<bool> &visited){ 
    visited[u] = true;
    for(int i=0; i<g[u].size(); i++){
        if(!visited[g[u][i]]){
            DFSVisit(g[u][i], g, visited); 
        }
    }
} 
  
void DFS(vector<int> adj[], int V){
    vector<bool> visited(V, false); 
    for(int u=0; u<V; u++) 
        if(!visited[u]) 
            DFSVisit(u, adj, visited);
}


void solve(){
	
}

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

int main(){
    int N; cin >> N;
    vector<int> A(N+2);
    for(int i=1;i<=N;i++) cin >> A[i];
    A[0] = A[N+1] = 0;
    int sum = 0;
    for(int i=0;i<=N;i++){
        sum += abs(A[i] - A[i+1]);
    }

    for(int j=1;j<=N;j++){
        int ans = sum;
        ans = ans - abs(A[j]-A[j+1]) - abs(A[j-1] - A[j]) + abs(A[j-1] - A[j+1]);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
typedef long long int uli;
const int mx=2e5+10;
int a[mx];
int main(){
  int n;
  scanf("%d",&n);
  for(int i=0;i<n;i++)scanf("%d",a+i);
  int r=0;
  int sm=0,xr=0;
  uli ans=0;
  for(int i=0;i<n;i++){
    while(r<n && sm+a[r]==(xr^a[r])){
      sm+=a[r];
      xr^=a[r];
      r++;
    }
    ans+=r-i;

    sm-=a[i];
    xr^=a[i];
  }
  cout<<ans<<endl;
  return 0;
}


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

int main(){
  int a,b,x; cin >> a >> b >> x;
  if(x<a||a+b<x) cout << "NO";
  else cout << "YES";
  return 0;
}

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

const int N = 100005;
struct point {
	int x, y, w;
	bool operator < (const point &p) const {
		return x < p.x;
	}
} p[N];
int d[N], mx[N], pa[N], last[N];
int n, m, K, u, v, w, a, b;

inline int getpa(int x) {
	if (pa[x] == x) return x;
	int p = getpa(pa[x]);
	d[x] += d[pa[x]];
	return pa[x] = p;
}

int main() {
	scanf("%d%d%d", &n, &m, &K);
	rep (i, 1, K) {
		scanf("%d%d%d", &p[i].x, &p[i].y, &p[i].w);
	}
	sort(p + 1, p + K + 1);
	rep (i, 1, n) pa[i] = i;
	rep (i, 1, K) {
		if (last[p[i].y]) {
			u = p[i].x, v = p[last[p[i].y]].x;
			w = p[last[p[i].y]].w - p[i].w;
			a = getpa(u), b = getpa(v);
			if (a == b) {
				if (w != d[u] - d[v]) {
					puts("No");
					return 0;
				}
			}
			else {
				d[a] = w - d[u] + d[v];
				pa[a] = b;
			}
		}
		last[p[i].y] = i;
	}
	rep (i, 1, K) {
		u = p[i].x, getpa(u);
		mx[pa[u]] = max(mx[pa[u]], d[u]);
	}
	rep (i, 1, K) {
		u = p[i].x, getpa(u);
		if (p[i].w + d[u] - mx[pa[u]] < 0) {
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define vv(T) std::vector<std::vector<T>>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;

int		main(void)
{
	ll a;
	long double b;
	cin >> a >> b;

	ll c = a * b;
	printf("%lld\n", c);
}



Measured memory_bytes: 3788
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  int a[n][3];
  for(int i=0;i<n;i++)cin>>a[i][0]>>a[i][1]>>a[i][2];
  int dp[n+1][3];
  for(int i=0;i<=n;i++)for(int j=0;j<3;j++)dp[i][j]=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<3;j++){
      for(int k=0;k<3;k++){
        if(j==k)continue;
        dp[i+1][k]=max(dp[i][j]+a[i][k],dp[i+1][k]);
      }
    }
  }
  int ans=max(dp[n][0],dp[n][1]);
  cout<<max(dp[n][2],ans)<<endl;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()
#define CHMIN(x,y) x = min(x, y)
#define CHMAX(x,y) x = max(x, y)

const int MAX = 810;
const int DX[4] = {-1, 0, 1, 0};
const int DY[4] = {0, -1, 0, 1};

int H, W, K, sx, sy;
bool f[MAX][MAX];

ll solve() {
    set<ii> pos;
    vii p;
    ii sxy(sx, sy);
    pos.insert(sxy);
    p.push_back(sxy);
    REP (k, K) {
        vii p1;
        FORE (r, p) {
            REP (i, 4) {
                int x = r.first+DX[i], y = r.second+DY[i];
                ii q = ii(x,y);
                if (!f[y][x] && pos.find(q) == pos.end()) {
                    pos.insert(q);
                    p1.push_back(q);
                    if (x == 0 || y == 0 || x == W-1 || y == H-1) return 1;
                }
            }
        }
        swap(p, p1);
    }

    ll d = min(H, W);
    for (auto iter = pos.begin(); iter != pos.end(); iter++) {
        ll x = (*iter).first, y = (*iter).second;
        CHMIN(d, min({x, y, W-x-1, H-y-1}));
    }
    return (d + K - 1) / K + 1;
}

int main() {
    cin >> H >> W >> K;
    REP (h, H) {
        string a;
        cin >> a;
        REP (w, W) {
            if (a[w] == 'S') {
                sx = w;
                sy = h;
            } else if (a[w] == '#') {
                f[h][w] = true;
            }
        }
    }
    cout << solve() << endl;
}

Measured memory_bytes: 4352
import java.util.*;

public class Main {

    int n, m, ans;
    boolean[] visited;
    List<Integer>[] lists;

    void run() {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        m = sc.nextInt();
        lists = new List[n];

        for (int i = 0; i < n; i++) {
            lists[i] = new ArrayList<>();
        }
        for (int i = 0; i < m; i++) {
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;
            lists[a].add(b);
            lists[b].add(a);
        }

        ans = 0;
        visited = new boolean[n];
        visited[0] = true;
        dfs(0, 1);

        System.out.println(ans);

    }

    void dfs(int i, int visitedCount) {
        if (visitedCount == n) {
            ans++;
            return;
        }
        List<Integer> nexts = lists[i];
        for (int next : nexts) {
            if (!visited[next]) {
                visited[next] = true;
                dfs(next, visitedCount + 1);
                visited[next] = false;
            }
        }
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

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

}


Measured memory_bytes: 22868
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    while (true){
        int a, d, n; cin >> a >> d >> n;
        if(a == 0 and d == 0 and n == 0) return 0;
        else{
            int count = 0, ans;
            for(int i = a; i <= 10e6; i += d){
                if(i == 1) continue; // 1は素数ではない
                bool flag = true;
                FOR(j, 2, sqrt(i) + 1){
                    if(i % j == 0){
                        flag = false;
                        break;
                    }
                }
                if(flag or i == 2) count++;
                if(count == n){
                    ans = i;
                    break;
                }
            }
            cout << ans << endl;
        }
    }
    
}


Measured memory_bytes: 2988
#include <iostream>

using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;

    int count = 0;
    for (int i = a; i <= b; ++i)
    {
        if (c % i == 0) ++count;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 1160
#pragma G++ optimize (2)
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <assert.h>

using namespace std;

inline char gc()
{
	static char buf[262144],*p1 = buf,*p2 = buf;
	return p1 == p2 && (p2 = (p1 = buf) + fread(buf,1,262144,stdin),p1 == p2) ? EOF : *p1++;
}

inline void read(int &v)
{
	v = 0;
	char c = gc();
	while (c < '0' || c > '9')
		c = gc();
	while (c >= '0' && c <= '9')
	{
		v = v * 10 + c - '0';
		c = gc();
	}
}

const int MAXN = 200005;

struct Edge
{
	int to;
	int next;
}edge[MAXN << 1];

int n,id;
int L[MAXN];
int R[MAXN];
int fa[MAXN];
int cnt[MAXN];
int dfn[MAXN];
int pre[MAXN];
int ans[MAXN];
int rdfn[MAXN];
int size[MAXN];
int first[MAXN];

vector<int> nxt[MAXN];

int getroot(int p)
{
	return p == pre[p] ? p : pre[p] = getroot(pre[p]);
}

void addE(int u,int v)
{
	edge[++id] = (Edge){v,first[u]};
	first[u] = id;
}

void dfs(int now,int MAX,int f)
{
	fa[now] = MAX;
	nxt[MAX].push_back(now);
	MAX = max(MAX,now);
	rdfn[dfn[now] = L[now] = ++id] = now;
	for (int i = first[now];i;i = edge[i].next)
		if (edge[i].to != f)
			dfs(edge[i].to,MAX,now);
	R[now] = id;
}

int main()
{
	read(n);
	for (int u,v,i = 1;i < n;i++)
	{
		read(u),read(v);
		addE(u,v);
		addE(v,u);
	}
	id = 0;
	dfs(1,0,0);
	for (int i = 1;i <= n;i++)
	{
		pre[i] = i;
		size[i] = 1;
	}
	for (int i = 1;i <= n;i++)
	{
		for (int j = 0;j < nxt[i].size();j++)
		{
			if (nxt[i][j] < i)
				ans[nxt[i][j]] = size[getroot(nxt[i][j])];
			else
			{
				int l = 0,to = nxt[i][j];
				for (int k = first[to];k;k = edge[k].next)
					if (edge[k].to < i)
					{
						ans[to] += size[getroot(edge[k].to)];
						if (dfn[edge[k].to] > dfn[to])
						{
							while (l < nxt[to].size() && dfn[nxt[to][l]] < L[edge[k].to])
								l++;
							while (l < nxt[to].size() && dfn[nxt[to][l]] >= L[edge[k].to] && dfn[nxt[to][l]] <= R[edge[k].to])
								cnt[nxt[to][l++]] = size[getroot(edge[k].to)];
						}
					}
				ans[nxt[i][j]]++;
			}
		}
		for (int j = first[i];j;j = edge[j].next)
			if (edge[j].to < i)
			{
				size[i] += size[getroot(edge[j].to)];
				pre[getroot(edge[j].to)] = i;
			}
	}
	for (int i = 1;i <= n;i++)
		ans[rdfn[i]] += ans[fa[rdfn[i]]] - cnt[rdfn[i]];
	for (int i = 2;i <= n;i++)
		printf("%d ",ans[i]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 27764
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define Return(expr) { Cout(expr); return 0; }
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, n);
    Rep(n){
        Cin(int, x);
        if(x % 2 == 0 && x % 3 != 0 && x % 5 != 0) Return("DENIED");
    }
    Return("APPROVED");
}


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

int main(void){
  int n, w;
  cin >> n >> w;

  vector<int> nap(w, 0);
  vector<int> vecv(n), vecw(n);
  for(int i=0; i<n; i++){
    cin >> vecv[i] >> vecw[i];
  }

  for(int i=0; i<n; i++){
    for(int j=w-1; j>vecw[i]-2; j--)
      if(nap[j] < nap[j-vecw[i]] + vecv[i])
	nap[j] = nap[j-vecw[i]] + vecv[i];
  }

  cout << nap[w-1] << endl;

  return 0;
}

Measured memory_bytes: 3104
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

#include<bits/stdc++.h>
#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>
using namespace std;

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell          1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
// if (str.find(str2) != string::npos)


template <typename T>
T pow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}






int solve( ){
double a,b;
cin>>a>>b;
cout<<a/b;


return 0;

}


int main()
{  int t=1;


 ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);



  clock_t time_req;

    // Without using pow function
    time_req = clock();
    
//cin>>t;
    bool flag=true;
   while(t--)
     { 
      solve();
     }

         time_req = clock() - time_req;
    //cout << "Processor time taken is "
      // << (double)time_req/CLOCKS_PER_SEC << " seconds" << endl;


    return 0;
}



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

int a[101];
int main(){
  int N;
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> a[i];
  }
  int ac = 0;
  for(int i = 0; i < N; i++){
    if(a[i] % 2 != 0 && ( (i+1) % 2 ) != 0){
      ac++;
    }
  }
  cout << ac << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define LLI long long int
#define fst first
#define snd second

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(x) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}


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

  int N,Q;

  while(cin >> N >> Q){
    vector<LLI> a(N); cin >> a;
    vector<LLI> xs(Q); cin >> xs;

    vector<LLI> sum_odd(N+2);
    vector<LLI> sum_even(N+2);

    REP(i,N) sum_even[i+1] += sum_even[i] + (i%2==1?a[i]:0);
    REP(i,N) sum_odd[i+1] += sum_odd[i] + (i%2==0?a[i]:0);

    //    assert(N%2==0);

    vector<LLI> sum(N+1);
    REP(i,N) sum[i+1] += sum[i] + a[i];

    for(auto x : xs){
      auto f = [&](LLI k){return abs(a[N-(k+1)/2-1]-x) < abs(a[N-k-1]-x);};

      int lb=0, ub=N, mid;
      while(abs(lb-ub) > 1){
	mid = (lb+ub)/2;

	if(f(mid)){
	  ub = mid;
	}else{
	  lb = mid;
	}
      }

      int t = ub;
      dump(t);
      
      LLI ans = sum[N]-sum[N-(t+1)/2];
      if(N%2==0) ans += sum_even[N-t] - sum_even[0];
      else ans += sum_odd[N-t] - sum_odd[0];
	
      cout << ans << endl;
    }
  }
  
  return 0;
}


Measured memory_bytes: 5632
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
  
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
        
const int  N = 2e5 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 2019;
const double eps = 1e-9;
ll bp(ll a, ll n){
    ll res = 1;
    while(n) {
        if(n & 1)
            res = (res * a) % MOD;
        a = (a * a) % MOD;
        n /= 2;
    }return res;
}
void solve(){
    string s;
    cin >> s;
    map <int,int> mp;
    ll sum = 0;
    int n = (int)s.size(); 
    ll ans = 0; 
    mp[0] = 1;
    for(int i = 0; i < n; ++i) { 
        sum += (s[i] - '0')* bp(10,n - i - 1);
        sum %= MOD; 
        ans += mp[sum];
        mp[sum] ++;
    }cout << ans;
}

 
int main(){
    speed();
    int t = 1;
    // cin >> t;
    while(t--)solve();
}

Measured memory_bytes: 3704
#include <stdio.h>

void disp(int A[],int N){
	int i;
	for(i=0;i<N;i++){
		if(i>0){
			printf(" ");
		}
		printf("%d",A[i]);
	}
			printf("\n");
}

void trace(int A[],int N){
	int i,j,v;
	for(i=1;i<=N-1;i++){
		v=A[i];
		j=i-1;
		while(j>=0 && A[j]>v){
			A[j+1]=A[j];
			j--;
			}
			A[j+1]=v;
		disp(A,N);
		}
}

int main (void){
	
	int i,N;
	scanf("%d",&N);
	
	int A[N];
	for(i=0;i<N;i++){
		scanf("%d",&A[i]);
	}
	disp(A,N);
	trace(A,N);
	return 0;
}


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

int main(){
  int a,b,c,x;
  cin >> a >> b >> c >> x;
  int ans = 0;
  rep(i,a){
    rep(j,b){
      rep(k,c){
        if(500*i + 100*j + 50*k == x) ++ans;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

S = '-' + input().rstrip()
N = len(S) - 1

def solve(S):
    if S[1] == '0':
        print(-1)
        exit()
    if S[N] == '1':
        print(-1)
        exit()
    prev = 1
    graph = []
    for n in range(1,N//2 + 1):
        if S[n] != S[N-n]:
            return None
        if S[n] == '0':
            continue
        for i in range(prev,n):
            graph.append('{} {}'.format(i,n))
        prev = n
    for i in range(prev,N):
        graph.append('{} {}'.format(i,N))
    return graph

graph = solve(S)

if graph is None:
    print(-1)
else:
    print('\n'.join(graph))


Measured memory_bytes: 14232
import java.io.*;
import java.util.*;
import java.lang.*;
public class Main {
		
	public static void main(String[] args) {
		MyScanner sc = new MyScanner();
		int a=sc.nextInt();
		int b=sc.nextInt();
		int q=sc.nextInt();
		long s[]=new long[a+2];
		long t[]=new long[b+2];
		long ans[]=new long[q];
		for (int i = 1; i <= a; i++) {
			s[i]=sc.nextLong();
		}
		for (int i = 1; i <= b; i++) {
			t[i]=sc.nextLong();
		}
		s[0]=-100000000000L;
		t[0]=-100000000000L;
		s[a+1]=100000000000L;
		t[b+1]=100000000000L;
		
		long x[]=new long[q];
		for (int i = 0; i < q; i++) {
			x[i]=sc.nextLong();
		}
		
		

		int sl[]=new int[q];
		int tl[]=new int[q];
		long temp1;
		long temp2;
		for (int i = 0; i < q; i++) {
			sl[i]=nib(s,x[i],0,a+1);
			tl[i]=nib(t,x[i],0,b+1);
			ans[i]=Long.MAX_VALUE;
			for(int m=0;m<2;m++) {
				for(int n=0;n<2;n++) {
					temp1=Math.abs(x[i]-t[tl[i]+m])+Math.abs(t[tl[i]+m]-s[sl[i]+n]);
					temp2=Math.abs(x[i]-s[sl[i]+n])+Math.abs(t[tl[i]+m]-s[sl[i]+n]);
					ans[i]=Math.min(ans[i],temp1);
					ans[i]=Math.min(ans[i],temp2);
				}
				
			}
		
		}
		
		for (int i = 0; i < q; i++) { 
			System.out.println(ans[i]);
		}
		
		
	}
	static int nib(long[] a,long x,int l,int r) {
		int an;
		
		
		if(a[l]<x&&x<a[r]) {
			
			if(r-l==1) {
				an=l;
				
			}else {
				
				an=nib(a,x,0,(l+r)/2);
				if(an==-1) {
					an=nib(a,x,(l+r)/2,r);
				}
				
			}
		}else {
			
			an=-1;
		}
		
		
		return an;
	}
	
	
	
//----------------------------------------------------------
	static int l_min(int[] a) {
		Arrays.sort(a);
		return a[0];
	}
	static int l_max(int[] a) {
		int l=a.length;
		Arrays.sort(a);
		return a[l-1];
	}
	
	public static PrintWriter out;

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

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

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

	}
	

}


Measured memory_bytes: 53160
#include<stdio.h>

int isPrime(int x)
{
  int i;
  if(x<2)
    {
      return 0;
    }
  else if(x==2)
    {
      return 1;
    }
  if(x%2==0)
    {
      return 0;
    }
  for(i=3;i*i<=x;i+=2)
    {
      if(x%i==0)
	{
	  return 0;
	}
    }
  return 1;
    
}


int main()
{
  int i,x,n;
  int count=0;

  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d",&x);
      if(isPrime(x))
	{
	  count++;
	}
    }

  printf("%d\n",count);
  return 0;
}



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

using namespace std ;

/*const int MAX = 1000 ;
int dp[MAX][MAX][2] ;

int solve(int x , int y , int turn)
{
	if(x <= 1 && y <= 1)
		return (!turn) ;
	int &ret = dp[x][y][turn] ;
	if(ret != -1)
		return ret ;
	ret = !turn ;
	for(int i = 1 ; ; ++i)
	{
		if(2*i > x && 2*i > y)
			break ;
		if(2*i <= x)
		{
			int a = solve(x-2*i , y+i , !turn) ;
			if(a == turn)
				ret = turn ;
		}
		if(2 * i <= y)
		{
			int a = solve(x+i , y-2*i , !turn) ;
			if(a == turn)
				ret = turn ;
		}
	}
	return ret ;
}*/

int main()
{
	//memset(dp , -1 , sizeof(dp)) ;
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	long long x , y ;
	cin>>x>>y ;
	if(max(x , y) >= min(x , y)+2)
		return cout<<"Alice\n" , 0 ;
	return cout<<"Brown\n" , 0 ;
} 

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<cstring>

using namespace std;

int main(){
	int a[1001]={0},b[1001]={0};
	int c,d;
	char tp[9];
	while(strcmp(fgets(tp,8,stdin),"\n")!=0){
		sscanf(tp,"%d,%d",&c,&d);
		a[c]++;
	}
	while(scanf("%d,%d",&c,&d)!=EOF){
		b[c]++;
	}
	for(int i=1;i<=1000;i++){
		if(a[i]>0&&b[i]>0)
		printf("%d %d\n",i,a[i]+b[i]);
	}
}


Measured memory_bytes: 3136
#include<stdio.h>

int search(int A[], int n, int key) {
  int i = 0;
  A[n] = key;
  while (A[i] != key) i++;
  return i != n;
}

int main() {
  int i, n, A[10000+1], q, key, sum = 0;
  
  scanf("%d", &n);
  for ( i = 0; i < n; i++) scanf("%d", &A[i]);
  
  scanf("%d", &q);
  for( i = 0; i < q; i++) { 
    scanf("%d", &key);
    if ( search(A, n, key) ) sum++;
  }
  printf("%d\n", sum);

  return 0;
}


Measured memory_bytes: 2724
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int[][] arr = new int[n][2];

        for (int i=0; i<n; i++){
            arr[i][0] = sc.nextInt();
            arr[i][1] = sc.nextInt();
        }

        Data[] d = new Data[n];
        for (int i=0; i<n; i++){
            d[i] = new Data(arr[i][0], arr[i][1]);
        }

        Arrays.sort(d);

//        Arrays.sort(arr, (a,b)->Integer.compare(a[0],b[0]));
//        Arrays.sort(arr, (a,b)->Integer.compare(a[1],b[1]));

        int ans = n;

        Map<P, Integer> map = new HashMap<>();

        for (int i=0; i<n; i++){
            for (int j=i+1; j<n; j++){
                int s = d[j].a-d[i].a;
                int t = d[j].b-d[i].b;
//                int s = arr[j][0]-arr[i][0];
//                int t = arr[j][1]-arr[i][1];
//                int s = Math.abs(arr[j][0]-arr[i][0]);
//                int t = Math.abs(arr[j][1]-arr[i][1]);

//                System.out.println(s);
//                System.out.println(t);
                P p = new P(s, t);
                if (map.containsKey(p)){
                    int tmp = map.get(p);
                    map.put(p, tmp+1);
                }else {
                    map.put(p, 1);
                }
            }
        }

        int max = 0;

        for (P key: map.keySet()){
            max = Math.max(max, map.get(key));
//            System.out.println(map.get(key));
        }
        if (n==1 || n==2){
            System.out.println(1);
            return;
        }

        System.out.println(n-max);
    }

    public static class P{
        int s;
        int t;
        public P(int s, int t){
            this.s = s;
            this.t = t;
        }
        @Override
        public boolean equals(Object obj){
            if (obj instanceof P){
                P key = (P) obj;
                return this.s==key.s && this.t==key.t;
            }else {
                return false;
            }
        }
        @Override
        public int hashCode(){
            return Objects.hash(s, t);
        }
    }
    public static class Data implements Comparable<Data>{
        int a, b;
        public Data(int a, int b){
            this.a = a;
            this.b = b;
        }
        public int compareTo(Data other){
            if (this.a==other.a){
                return this.b - other.b;
            }else {
                return this.a - other.a;
            }
        }
    }
}

		

Measured memory_bytes: 23636
ans = 100000000000000000000000000
N, A, B, C = map(int,input().split())
l = [int(input()) for _ in range(N)]

#rec part
def rec(a,b,c,gousei,now):
    global ans

    if(a != 0 and b != 0 and c != 0):
        ans = min(ans,(abs(a-A)+abs(b-B)+abs(c-C)+gousei*10))

        #print(a,b,c,ans) 

    if now == N:
        return 0


    #A
    rec(a,b,c, gousei,now+1)
    rec(a+l[now],b,c,gousei+1 if a!= 0 else gousei,now+1)
    rec(a,b+l[now],c,gousei+1 if b!= 0 else gousei,now+1)
    rec(a,b,c+l[now],gousei+1 if c!= 0 else gousei,now+1)


    
rec(0,0,0,0,0)
print(ans)

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

typedef pair<int,int> pi;
typedef vector<int> vi;
 
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define pb push_back

template<typename T> void max_self(T &a, T b) { a = max(a,b); return;}
template<typename T> void min_self(T &a, T b) { a = min(a,b); return;}
 
const int nax = 2e5 + 5;
const int mod = 1e9 + 7;

int modExpo(int a,int b,int c){
	if(b == 0) return 1;
	int answer = 1;
	while(b){
		if(b & 1) answer = ((answer % c) * (a % c)) % c;
		a = ((a % c) * (a % c)) % c;
		b /= 2; 
	}
	
	return answer;
}

signed main(){
	
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int t = 1;
	//cin >> t;
	while(t--){
		int n,m,k;
		cin >> n >> m >> k;

		vector<int> a(n + 1,0);
		vector<int> b(m + 1,0);

		FOR(i,1,(n + 1)){
			cin >> a[i];
			a[i] += a[i - 1];
		}
		
		FOR(i,1,(m + 1)){
			cin >> b[i];
			b[i] += b[i - 1];
		}
		
		int answer = 0;
		int j = m;
		
		for(int i = 0; i <= n; ++i){
			if(a[i] > k) break;
			
			while(b[j] > k - a[i]) --j;
			answer = max(answer,i + j);
		}
		
		cout << answer;
	}
    
    return 0;
}


Measured memory_bytes: 6352
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr << # x << "; "<< x << endl


int main() {
	int X, Y;
	cin >> X >> Y;
	if (Y <= 4 * X && Y >= 2 * X && (Y % 4 == 0 || Y % 4 == 2)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i++; i<N)
#define RVROOP(i, N) for(int i=N; i--; i>=0)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
  int N; cin>>N;
  string S; cin>>S;

  int chg=0;
  
  for(int i=0; i<N-1; i++){
    if(S.at(i)!=S.at(i+1)){
      chg++;
    }
  }

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


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

int main() {
	
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
     
      long long n,i,j,k,sum=0,count=0,ans=0,x,y,l,r;
      cin>>n;
      k=26;
      count=26;
      long long a[12];
      a[0]=0;
      for(i=1;i<11;i++)
      {
          a[i]=k;
          k+=count*26;
          count=count*26;
      
      }
      for(i=0;i<11;i++)
      {
          if(a[i]>=n)
          break;
      }
      if(a[i]==n)
      {
          for(j=0;j<i;j++)
          cout<<'z';
      }
      else
      {
          k=a[i-1];
          sum=n-a[i-1]-1;
          ans=i;
          string s2="";
          while(ans>0)
          {
              s2+=char('a'+sum%26);
              sum=sum/26;
              ans--;
          }
          reverse(s2.begin(),s2.end());
          cout<<s2;
      }
	return 0;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

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

	ll cnt = 15-sz(s);
	for (char c: s) cnt += c == 'o';

	cout << (cnt >= 8 ? "YES" : "NO") << endl;

}



Measured memory_bytes: 256
X,K,D=map(int, input().split())

X = abs(X)
a = X / D
b = round(a)

c = K - b
e = 0

if c < 0:
    print(X-(K*D))
    e = 1
elif c % 2 != 0:
    if a > b:
        b = b + 1
    else:
        b = b - 1
if e == 0:
    d = abs(X - (D*b))
    print(d)

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

#ifndef __TOPCYBERFLOWER
#define debug(...) 0
#else
#define debug(...) cout << " [-] ", _dbg(#__VA_ARGS__, __VA_ARGS__)
template<class TH> void _dbg(const char *sdbg, TH h){ cout << sdbg << '=' << h << endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
    while(*sdbg != ',') cout << *sdbg++;
    cout << '=' << (h) << ','; 
    _dbg(sdbg+1, a...);
}
#endif

#define TYPEMAX(type)   numeric_limits<type>::max()
#define TYPEMIN(type)   numeric_limits<type>::min()
typedef long long ll;
typedef pair<int,int> pii;

int main(void){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int a,b,c; cin>>a>>b>>c;
    if((a==b || a==c || b==c) && !(a==b && b==c)) cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 256