akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define inf (int)(3e18)
#define all(v) v.begin(),v.end()
#define mod (int)(1e9+7)

template<class T> inline void chmin(T &a, T b) {
	a = min(a, b);
}
template<class T> inline void chmax(T &a, T b) {
	a = max(a, b);
}

int mod_pow(int x, int y, int m = mod) {
	int res = 1;
	x %= m;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int perm[1000005];
void init_perm(){
	perm[0]=1;
	REP(i,1000005)perm[i]=perm[i-1]*i%mod;
}
int nCk(int x,int y){
	if(x<y)return 0;
	return perm[x]*mod_pow(perm[x-y],mod-2)%mod*mod_pow(perm[y],mod-2)%mod;
}

int N;
int ansdown[200005],cntdown[200005];
int ansup[200005],cntup[200005];
vector<int>G[200005];
bool used[200005];
void dfs1(int x,int par){
	cntdown[x]=1;
	for(int i:G[x])if(i!=par){
		dfs1(i,x);
		cntdown[x]+=cntdown[i];
	}
	ansdown[x]=1;
	int now=cntdown[x]-1;
	for(int i:G[x])if(i!=par){
		ansdown[x]*=nCk(now,cntdown[i])*ansdown[i]%mod;
		ansdown[x]%=mod;
		now-=cntdown[i];
	}
}
int ans[200005];
void dfs2(int x,int par){
	ans[x]=ansup[x]*nCk(N-1,N-cntdown[x])%mod;
	ans[x]*=ansdown[x];
	ans[x]%=mod;
	for(int i:G[x])if(i!=par){
		ansup[i]=ans[x]*mod_pow(nCk(N-1,cntdown[i]),mod-2)%mod*mod_pow(ansdown[i],mod-2)%mod;
		dfs2(i,x);
	}
}
signed main() {
	init_perm();
	cin>>N;
	rep(i,N-1){
		int a,b;cin>>a>>b;a--;b--;
		G[a].push_back(b);G[b].push_back(a);
	}
	dfs1(0,0);
	ansup[0]=1;
	dfs2(0,0);
	rep(i,N)cout<<ans[i]<<endl;
}



Measured memory_bytes: 30320
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  bool x;
  cin >> x;
  cout << !x << '\n';
  return 0;
}


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

#define rep(i, s, n) for(int i = s; i < n; ++i)
#define rrep(i, n) for(int i = n - 1; i > -1; --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
const long long INF = 1000000000;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n;
    cin >> n;
    int cnt = 0;
    rep(i, 1, n + 1){
        if(to_string(i).size() % 2 == 1){
            cnt++;
        }
    }
    cout << cnt << endl;
}


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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

const ll MOD = 1000000007;

int N;
string s[2];
ll dp[60][9];

int main() {
	cin >> N >> s[0] >> s[1];
	dp[1][1] = 1;//01
	dp[0][1] = 1;

	for (int i = 2; i <= N; ++i) {
		rep(j, 9) {
			if (j % 3 == j / 3) continue;
			rep(k, 9) {
				if (k % 3 == k / 3) continue;
				if (j % 3 == k % 3 || j / 3 == k / 3) continue;
				dp[i][k] = (dp[i][k] + dp[i-1][j]) % MOD;
			}
		}
	}

	vi pos;
	pos.pb(-1);
	rep(i, N) if (s[0][i] == s[1][i]) pos.pb(i);
	pos.pb(N);

	ll ret = 0;

	if (pos.size() == 2) {
		rep(j, 9) {
			ret = (ret + dp[N/2][j]) % MOD;
		}
		ret = ret * 6 % MOD;
	} else {
		for (int i = 0; i + 1 < pos.size(); ++i) {
			if (i == 0) {
				if (pos[i+1] == 0) {
					ret = 3;
				} else {
					ret = 0;
					rep(j, 9) ret = (ret + dp[pos[1] / 2][j]) % MOD;
					ret = ret * 6 % MOD;
				}
			} else {
				ll s = 0;
				if (pos[i+1] == pos[i] + 1) {
					if (pos[i+1] == N) s = 1;
					else s = 2;
				} else {
					rep(j, 9) {
						s = (s + dp[(pos[i+1]-pos[i]-1)/2][j]) % MOD;
					}
					s = s * 2;
				}
				ret = ret * s % MOD;
			}
		}
	}

	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 256
N=int(input())
xu=[]
for i in range(N):
    xu.append(list(map(str,input().split())))
a=0
for i in range(N):
    if xu[i][1]=='JPY':
        a+=float(xu[i][0])
    if xu[i][1]=='BTC':
        a+=float(xu[i][0])*(380000.0)
print(a)

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

namespace PaizaTest
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            var dic = new Dictionary<string, int>();
            int maxCount = 1;
            for (int i = 0; i < n; i++)
            {
                var oneLine = Console.ReadLine();
                if (dic.ContainsKey(oneLine))
                {
                    dic[oneLine]++;
                    maxCount = dic[oneLine] > maxCount ? dic[oneLine] : maxCount;
                }
                else
                {
                    dic[oneLine] = 1;
                }
            }

            var list = dic.Where(x => x.Value == maxCount).Select(x => x.Key).ToList();
            list.Sort(StringComparer.OrdinalIgnoreCase);

            for (int i = 0; i < list.Count; i++)
            {
                Console.WriteLine(list[i]);
            }
        }
    }
}


Measured memory_bytes: 42332
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <deque>
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
void print(vec v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vecll v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}


#define INF 1e9+7
#define LLINF 1e18+7
const ll MOD=1e9+7;
const int N=500000;

main(){
    int n;cin>>n;
    string s;
    cin>>s;
    int ans=0;
    vector<char> c(3);
    for(c[0]='0';c[0]<='9';c[0]++){
        for(c[1]='0';c[1]<='9';c[1]++){
            for(c[2]='0';c[2]<='9';c[2]++){
                int now=0;
                rep(i,n){
                    if(now>2)continue;
                    if(s[i]==c[now])now++;
                }
                if(now==3)ans++;
            }
        }
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B;
  cin >> A >> B;
  int Ans = -1;
  for (int i = 13; i <= 10000; i++) {
    if (i * 8 / 100 == A && i / 10 == B) {
      Ans = i;
      break;
    }
  }
  cout << Ans;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  char s[111111];
  int i;
  
  scanf("%s", s);
  for(i = 0; s[i] != '\0'; i++) {
    if(i % 2 == 0) {
      printf("%c", s[i]);
    }
  }
  printf("\n");
  
  return 0;
}
    
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,u,v,d,e,maxi1=INT_MIN,mini1=INT_MAX,maxi2=INT_MIN,mini2=INT_MAX;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>u>>v;
        d=(u+v);
        if(mini1>d)
        {
            mini1=d;
            }
        if(maxi1<d)
        {
            maxi1=d;

        }
        e=u-v;
        if(mini2>e)
        {
            mini2=e;

        }
        if(maxi2<e)
        {
            maxi2=e;
        }
    }
    cout<<max(maxi1-mini1,maxi2-mini2)<<endl;
}


Measured memory_bytes: 3648
n = int(input())
lis=list(map(int,input().split()))
li=[]
y=0
g=0
for i in range(n):
    li.append(lis[i])
    if len(li)>=2:
        if li[-2]>li[-1]:
            y=1
        if y==1 and li[-2]<li[-1]:
            g+=max(li[:-2])-li[-2]
            y=0
            li=[li[-1]]
g+=max(li)
print(g)

Measured memory_bytes: 3064
import java.io.*;
import java.util.*;

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

        int pt = 0;
        int px = 0;
        int py = 0;
        for (int i = 0; i < n; i++) {
            int t = sc.nextInt();
            int x = sc.nextInt();
            int y = sc.nextInt();

            int d = Math.abs(px - x) + Math.abs(py - y);
            if (t - pt < d || ((t - pt) + d) % 2 == 1) {
                System.out.println("No");
                return;
            }
        }

        System.out.println("Yes");
    }
}


Measured memory_bytes: 86964
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k=1,m=0;
	scanf("%d",&n);
	while (k*k<n)
	{	
		m=(n/k-k)*2+m+1;
		if (n%k==0) m-=2;
		k++;
	 
	}

	printf("%d",m);
	return 0;
 }

Measured memory_bytes: 3812
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

using namespace std;

class DelaySegmentTree {
private:
	class Monoid {
	public:
		long long value;
		int index;

		Monoid() {}
		Monoid(long long value, int index) : value(value), index(index) {}
	};

	vector<Monoid> nodes;
	vector<long long> delayValues;
	int maxDepth;			// 0-indexed

	Monoid func(const Monoid &m1, const Monoid &m2) {
		if (m1.index == -1 && m2.index == -1) return Monoid(0, -1);
		if (m1.index == -1) return m2;
		if (m2.index == -1) return m1;

		return Monoid(m1.value + m2.value, m1.index);
	}

	void calcNode(int idx) {
		if (idx >= (1 << maxDepth)) return;

		int left = idx << 1;
		int right = left + 1;

		nodes[idx] = func(nodes[left], nodes[right]);
	}

	void add(long long value, int l, int r, int idx, int minI, int maxI) {
		if (r < minI || maxI < l) return;
		if (l <= minI && maxI <= r) {
			delayValues[idx] += value * (maxI - minI + 1);
			return;
		}
		int border = (maxI + minI) >> 1;
		add(value, l, r, idx << 1, minI, border);
		add(value, l, r, (idx << 1) + 1, border + 1, maxI);
	}

	Monoid query(int l, int r, int idx, int minI, int maxI) {
		int lchild = idx << 1;
		int rchild = lchild + 1;

		if (r < minI || maxI < l) return Monoid(0, -1);

		if (delayValues[idx]) {
			if (idx < (1 << maxDepth)) {
				delayValues[lchild] += delayValues[idx] >> 1;
				delayValues[rchild] += delayValues[idx] >> 1;
			}
			nodes[idx].value += delayValues[idx];
			delayValues[idx] = 0;
		}

		if (l == minI && r == maxI) return nodes[idx];

		int border = (maxI + minI) >> 1;
		Monoid m1 = query(l, r, lchild, minI, border);
		Monoid m2 = query(l, r, rchild, border + 1, maxI);
		return func(m1, m2);
	}

public:
	DelaySegmentTree(const vector<int> &v) {
		maxDepth = 0;
		int len = 1;
		while (len < v.size()) {
			len <<= 1;
			maxDepth++;
		}
		nodes.resize(2 * len);
		delayValues.resize(2 * len);

		for (int i = 0; i < len; i++) {
			int idx = len + i;
			if (i < v.size()) {
				nodes[idx].value = v[i];
				nodes[idx].index = i;
			} else {
				nodes[idx].index = -1;
			}
		}

		for (int idx = len - 1; idx >= 1; idx--) {
			calcNode(idx);
		}
	}

	void add(long long value, int l, int r) {
		add(value, l, r, 1, 0, (1 << maxDepth) - 1);
	}

	Monoid query(int l, int r) {
		return query(l, r, 1, 0, (1 << maxDepth) - 1);
	}

	long long operator[] (int idx) {
		return query(idx, idx).value;
	}
};

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

	vector<int> v(n);

	DelaySegmentTree tree(v);

	for (int i = 0; i < q; i++) {
		int type;
		scanf("%d", &type);

		if (type == 0) {
			int s, t, x;
			scanf("%d %d %d", &s, &t, &x);
			tree.add(x, s - 1, t - 1);
		} else {
			int t;
			scanf("%d", &t);
			printf("%d\n", tree[t - 1]);
		}
	}

    return 0;
}



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

N,W = map(int,input().split())
wv_l= []
for i in range(N):
    wv_l.append(list(map(int,input().split())))
DP = [[0]*(W+1) for i in range(N+1)]

for i in range(N):
    for sum_w in range(W+1):
#        print(DP)
#        print(i,sum_w)
        if sum_w-wv_l[i][0] >= 0:
            DP[i+1][sum_w] = max(DP[i+1][sum_w],DP[i][sum_w-wv_l[i][0]]+wv_l[i][1])
        DP[i+1][sum_w] = max(DP[i+1][sum_w],DP[i][sum_w])
        
print(DP[N][W])

Measured memory_bytes: 120684
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <map>
#include <queue>
#include <math.h>
#include <set>
#include <stack>
#include <deque>
#include <bitset>
using namespace std;

int main()
{
	string s;
	cin >> s;
	s.at(3) = '8';
	cout << s << endl;
}


Measured memory_bytes: 256
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as BS
import qualified Data.Set as Set

main :: IO ()
main = do
  n <- readLn
  s <- replicateM n BS.getLine
  print $ length $ ordNub s
  
ordNub :: Ord a => [a] -> [a]
ordNub xs = foldr (\x k s -> if Set.member x s then k s else x:k(Set.insert x s)) (const[]) xs Set.empty

Measured memory_bytes: 77660
//tree DP
//ABC036-D
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<time.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}

typedef struct{
int val;
int node;
}sd;

int sdsortfnc(const void *a,const void *b){
if(((sd*)a)->val > ((sd*)b)->val){return -1;}
if(((sd*)a)->val < ((sd*)b)->val){return 1;}
return 0;
}

typedef struct{
    long long st;
    long long fi;
    long long kr;
}rs;

typedef struct{
    long long st;
    long long kz;
}mkj;

int sortfnc(const void *a,const void *b){
if(((rs*)a)->st == ((rs*)b)->st){return 0;}
if(((rs*)a)->st < ((rs*)b)->st){return -1;}
return 1;
}

void makemkj(rs g[],mkj x[],long long n){
    long long i,ms=0,nst=g[0].st;
    for(i=1;i<n;i++){
        if(g[i].st!=g[i-1].st){
            x[nst].kz=i-ms;
            x[nst].st=ms;
            nst=g[i].st;ms=i;
        }
    }
    x[nst].kz=n-ms;
    x[nst].st=ms;
}

void dfs(long long t,long long l,rs g[],mkj x[],long long dist[]){
  long long i;
  if(dist[t]<=l){return;}
  dist[t]=l;
  for(i=x[t].st;i<x[t].st+x[t].kz;i++){
    dfs(g[i].fi,l+1,g,x,dist);
  }
}

int main(void){
    long long i,j,n,m,k,a,b,c,h,w,r=0,l,t;
    long long res=0;
    long long td[524288],ad[524288];
    rs g[524288];
    mkj x[524288];
    scanf("%lld%lld%lld",&n,&h,&w);
    for(i=0;i<(n-1);i++){
      scanf("%lld%lld",&a,&b);
      g[2*i].st=a;
      g[2*i].fi=b;
      g[2*i].kr=1;
      g[2*i+1].st=b;
      g[2*i+1].fi=a;
      g[2*i+1].kr=1;
    }
    qsort(g,2*(n-1),sizeof(g[0]),sortfnc);
    makemkj(g,x,2*(n-1));
    for(i=0;i<=n;i++){
      td[i]=inf;
      ad[i]=inf;
    }
    dfs(h,0,g,x,td);
    dfs(w,0,g,x,ad);
    c=inf;
    for(i=1;i<=n;i++){
      if(td[i]>ad[i]){continue;}
      if(td[i]==ad[i]){c=min(td[i],c);continue;}
      r=max(td[i]+(ad[i]-td[i])-1,r);
    }
    if(c==inf){c=0;}
    printf("%lld\n",max(r,c));
    return 0;
}


Measured memory_bytes: 25388
import sys
import numpy as np


def solve(N: int):
    FB = list(range(N+1))
    FB = np.array(FB)

    FB = FB[(FB % 3 != 0) & (FB % 5 != 0) ]

    FB = FB.tolist()

    S = sum(FB)

    print(S)

    return


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
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 73924
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;
const int MOD = 1e9 + 7;

int N;
Graph G;
vector<bool> seen;

bool dfs(int v, int s, int t) {
    seen[v] = true;
    for(auto nv : G[v]) {
        if(seen[t])
            break;
        if(seen[nv])
            continue;
        if(v == s && nv == t)
            continue;
        dfs(nv, s, t);
    }
    return seen[t];
}

int main() {
    int M, ans;
    cin >> N >> M;
    vector<pii> edge(M);
    G.resize(N);
    for(int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        edge[i] = make_pair(a, b);
        G[a].push_back(b);
        G[b].push_back(a);
    }

    ans = 0;
    for(auto e : edge) {
        seen.assign(N, false);
        ans += !dfs(e.first, e.first, e.second);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	if(a<0LL)return 0;
	if(b<0LL)return 0;
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
// ここから編集しろ
int p[11000];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%d",p+i);
	int ret=0;
	for(int i=0;i<a;i++){
		while(p[i]%2==0){ret++;p[i]/=2;}
	}printf("%d\n",ret);
}

Measured memory_bytes: 256
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def nn(v, min_v, max_v):
	min_n = (min_v + v - 1) // v
	max_n = max_v // v
	#pa((min_n, max_n))
	if max_n < min_n:
		return -1, -1
	return v * min_n, v * max_n + v - 1

def main():
	n = int(input())
	#b , c = tin()
	#s = input()
	al = lin()
	al = al[::-1]
	min_v, max_v = 2, 2
	for v in al:
		min_v, max_v = nn(v, min_v, max_v)
		if min_v == -1:
			return -1
	print(min_v, max_v)
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 85972
#include<bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int _b=(b),i=(a);i<=_b;++i)
#define ROF(i, b, a) for(int _a=(a),i=(b);i>=_a;--i)
#define REP(n) for(int _n=(n);_n--;)
#define _1 first
#define _2 second
#define PB(x) push_back(x)
#define SZ(x) int((x).size())
#define ALL(x) (x).begin(), (x).end()
#define MSET(m,v) memset(m,v,sizeof(m))
#define MAX_PQ(T) priority_queue<T>
#define MIN_PQ(T) priority_queue<T,vector<T>,greater<T>>
#define IO(){ios_base::sync_with_stdio(0);cin.tie(0);}
#define cint1(a) int a;cin>>a
#define cint2(a,b) int a,b;cin>>a>>b
#define cint3(a,b,c) int a,b,c;cin>>a>>b>>c
typedef long long int ll; typedef pair<int,int> PII;typedef unsigned long long int ull;
typedef vector<int>VI; typedef vector<ll> VL; typedef vector<PII> VP;
template<class A,class B>inline bool mina(A &x,const B &y){return(y<x)?(x=y,1):0;}
template<class A,class B>inline bool maxa(A &x,const B &y){return(x<y)?(x=y,1):0;}
     
int main() {
    IO();
    cint2(N, K);
    int out = K;
    FOR(i, 2, N) out *= (K - 1);
    cout << out << endl;
    return 0;
}

Measured memory_bytes: 256
H,W=map(int,raw_input().split(' '))

if (H*W)%3==0:
    print 0
else:
    s_min=float('inf')
    for _ in range(2):
        for h in range(1,H+1):
            w=W/2
            v1=(h*W,(H-h)*w,(H-h)*(W-w))
            s1=max(v1)-min(v1)
            h_p=(H-h)/2
            v2=(h*W,h_p*W,(H-h-h_p)*W)
            s2=max(v2)-min(v2)
            s=min(s1,s2)
            if s_min>s:
                s_min=s
        H,W=W,H

    print s_min

Measured memory_bytes: 7796
// https://atcoder.jp/contests/abc178/tasks/abc178_d
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

const int MOD = 1e9 + 7;
const int SZ = 2e5;

template <int N, typename T, T M> struct factorial_mod {
    T mod[N + 1];
    T inv_mod[N + 1];

    constexpr factorial_mod() : mod(), inv_mod() {
        mod[0] = 1;
        for (int i = 0; i < N; ++i) {
            mod[i + 1] = (mod[i] * (i + 1)) % M;
        }
        inv_mod[N] = power(mod[N], M - 2);
        for (int i = N - 1; i >= 0; --i) {
            inv_mod[i] = (inv_mod[i + 1] * (i + 1)) % M;
        }
    }

    constexpr T power(T a, T b) {
        T r = 1;
        while (b > 0) {
            if ((b & 1) != 0)
                r = (r * a) % M;
            a = (a * a) % M;
            b >>= 1;
        }
        return r;
    }

    constexpr T permutation(T n, T r) { return (mod[n] * inv_mod[n - r]) % M; }
    constexpr T combination(T n, T r) {
        return (((mod[n] * inv_mod[r]) % M) * inv_mod[n - r]) % M;
    }
    constexpr T homogenious(T n, T r) {
        return (n == 0 and r == 0 ? 1 : combination(n + r - 1, r));
    }
};
factorial_mod<SZ, long long, MOD> facmod;

void solve() {
    int N;
    cin >> N;
    int ans = 0;
    // 重複組み合わせで解く。分割数は1 〜 N/3
    FOR(i, 1, N / 3 + 1) {
        ans += facmod.homogenious(N - i * 3 + 1, i - 1);
        ans %= MOD;
    }
    cout << ans << endl;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 3784
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=998244353 ;

int main(){
	int n,y;
	cin>>n>>y;
	vector<ll> a(n);
	rep(i,n)cin>>a[i];
	ll sum=0;
	rep(i,n)sum+=a[i];
	sum/=5;
	ll ans = 0;
	rep(_,n){
		vector<vector<ll>> dp(n+1,vector<ll>(6,0));
		dp[0][0]=1;
		rep(i,n){
			ll cur = 0;
			for(int j=i;j>=0;--j){
				cur += a[j];
				if(cur+y>=sum){
					rep(k,5){
						dp[i+1][k+1]+=dp[j][k];
					}
				}
			}
		}
		ans +=dp[n][5];
		rotate(a.begin(),a.begin()+1,a.end());
	}
	cout<<ans/5<<endl;
	return 0;
}


Measured memory_bytes: 3192
#include<iostream>
#include<string>
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!";
  }
  else
  {
    cout<<":(";
  }

  cout<<endl;

  return 0;

}


Measured memory_bytes: 256
a,b,x=map(int, input().split())
import math

org_S = x/a

if org_S>=a*b/2:
  delta=(a*b)-org_S
  tan_theta=2*delta/(a*a)
  theta=math.atan(tan_theta)
  print(math.degrees(theta))
else:
  t=(2*org_S)/b
  tan_theta=t/b
  theta=math.atan(tan_theta)
  print(90-math.degrees(theta))


Measured memory_bytes: 3060
import itertools
h, w = map(int, input().split())
map_lst = []
for i in range(h):
    map_lst.append(list(input()))
dp = [[200] * (w) for i in range(h)]
if map_lst[0][0] == '.': dp[0][0] = 0
else: dp[0][0] = 1
# for i in dp:
#     print(i)
for c in range(w):
    for r in range(h):
        over = 0
        left = 0
        if r > 0:
            if map_lst[r-1][c] == '.' and map_lst[r][c] == '#':
                over = 1
        if c > 0:
            if map_lst[r][c-1] == '.' and map_lst[r][c] == '#':
                left = 1
        if r == 0 and c == 0:
            continue
        elif r == 0:
            dp[r][c] = dp[r][c-1] + left
        elif c == 0:
            dp[r][c] = dp[r-1][c] + over
        else:
            dp[r][c] = min(dp[r-1][c] + over, dp[r][c-1] + left)
# for i in dp:
#     print(i)
print(dp[-1][-1])

Measured memory_bytes: 44272
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class EHopscotchAddict {
public:
    static constexpr int kStressIterations = 0;

    static void generateTest(std::ostream& test) {
    }

    int N, M, S, T;
    vector<vector<int>> G;

    void solve(std::istream& cin, std::ostream& cout) {
        cin >> N >> M;
        G.resize(3 * (N + 1));
        REP(i, M) {
            int u, v;
            cin >> u >> v;
            G[u * 3].push_back(v * 3 + 1);
            G[u * 3 + 1].push_back(v * 3 + 2);
            G[u * 3 + 2].push_back(v * 3);
        }
        cin >> S >> T;

        queue<P> q;
        map<int, bool> used;
        q.push({S * 3, 0});

        vector<int> dist(3 * (N+1), INF);
        while (!q.empty()) {
            auto kv = q.front();
            q.pop();
            if (used[kv.first]) continue;
            used[kv.first] = true;
            dist[kv.first] = kv.second;
            REP(i, G[kv.first].size()) {
                int t = G[kv.first][i];
                if (used[t]) continue;
                q.push({t, kv.second + 1});
            }
        }

        int res = dist[T * 3];
        if (res == INF) {
            cout << -1 << endl;
            return;
        }
        cout << res / 3 << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    EHopscotchAddict solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 37888
// OURL: https://atcoder.jp/contests/arc061/tasks/arc061_a
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define RREP(i,a,n) for(int i=(a),i##_len=(n);i<i##_len;++i)
#define MAT1D(V,T,a) vector<T> V (a)
#define MAT2D(V,T,a,b) vector<vector<T>> V (a, vector<T>(b))
#define MAT3D(V,T,a,b,c) vector<vector<vector<T>>> V (a, vector<vector<T>>(b, vector<T>(c)))

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){ return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }

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

template <typename A>
string to_string(A v) { bool first = true; string res = "{"; for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); } res += "}"; return res; }

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
string to_string(vector<bool>::reference b) { return to_string(bool(b)); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A>
string to_string(vector<vector<A>> v) { string res; for(const auto &x : v) {res+="\n ";res += to_string(x);} return res;}

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); }

#ifdef LOCAL
#define debug(...) cerr << "[L" << to_string(__LINE__) << ":" <<#__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

string s;
vector<vector<ll>> memo(11,vector<ll>(11));
ll _stoi(int i, int j) {
  if (memo[i][j] > 0) return memo[i][j];

  ll v=0;
  RREP(x,i,j) {
    v += (s[x] - '0') * pow(10, j-x-1);
  }
  memo[i][j] = v;
  return  v;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> s;
  int bit = 0;
  ll ans = 0;
  int bitmax = 0;
  int keta = s.size();
  REP(i,keta-1) {
    bitmax += (1<<i);
  }
  for(bit=0; bit<=bitmax; bit++) {
    ll tmp=0;
    int pre=0;
    REP(i,keta-1) {
      if (bit & (1<<i)) {
        tmp += _stoi(pre,i+1);
        pre = i+1;
      }
    }
    tmp += _stoi(pre,keta);
    stringstream ss;
    ss << bitset<9>(bit);
    // debug(ss.str(), tmp);
    ans += tmp;
  }
  // debug(memo);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
// Aizu Vol-5 0529: Darts
// 2017.9.4 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define HASHSIZ 2000081
int hash[HASHSIZ + 5], *hashend = hash + HASHSIZ;

int lookup(int n)
{
	int *p = hash + n % HASHSIZ;
	while (*p) {
		if (*p == n) return 1;
		if (++p == hashend) p = hash;
	}
	return 0;
}

void insert(int n)
{
	int *p = hash + n % HASHSIZ;
	while (*p) {
		if (*p == n) return;
		if (++p == hashend) p = hash;
	}
	*p = n;
}

int p[1003], len;

int cmp(int *a, int *b) { return *a - *b; }

int main()
{
	int n, m, a, i, j, ans;

	while (scanf("%d%d", &n, &m) && n) {
		memset(hash, 0, sizeof(hash));
		for (ans = len = 0, i = 0; i < n; i++) {
			scanf("%d", &a);
			if (a == m) ans = m;
			else if (a < m) p[len++] = a, insert(a);
		}
		if (ans > 0) goto Done;
		qsort(p, len, sizeof(int), cmp);
		for (i = 0; i < len; i++) for (j = i; j < len; j++) {
			if ((ans = p[i] + p[j]) == m) goto Done;
			if (ans > m) break;
			insert(ans);
		}
		for (ans = m; ans > 0; ans--) {
			if (lookup(ans)) goto Done;
			for (i = 0; i < len; i++) for (j = i; j < len; j++) {
				if ((a = p[i] + p[j]) > m) break;
				if (lookup(ans - a)) goto Done;
			}
		}
Done:	printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 9496
b = input().split() #aの文字列を空白で区切る
c = [int(s) for s in b] #bのそれぞれの要素に対して数値にしてリストに格納
num5 = 0
num7 = 0
for i in range(len(c)):
    if c[i] == 5:
        num5 += 1
        continue
    if c[i] == 7:
        num7 +=1
        continue
if num5 == 2 and num7 == 1:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3060
#include <iostream>

int main() {
 std:: string s;
 std::cin>>s;
 if (s.size()==19){
   
    for(int i=0;i<s.size();i++){

         if(s[i]==','){
            s[i]=' ';
         }
      }

    }
    std::cout<<s;
 }

Measured memory_bytes: 256
#pypyは内包表記使わない
def main():
    import sys
    #input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

    a = input().rstrip()
    b = input().rstrip()
    c = input().rstrip()
    print(a[0]+b[1]+c[2])


if __name__ == '__main__':
    main()

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


#define ll long long
#define ld long double
#define ull unsigned long long
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long ,long long>
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x,0,sizeof(x))
#define mod 1000000007LL
#define INF 1000000000007


 
//     long long power(long long x, long long y, long long p) 
// { 
//     long long res = 1;      
  
//     x = x % p;  
  
//     while (y > 0) 
//     { 
      
//         if (y & 1) 
//             res = (res*x) % p; 

//         y = y>>1; 
//         x = (x*x) % p; 
//     } 
//     return res; 
// } 
  

// long long modInverse(long long n, long long p) 
// { 
//     return power(n, p-2, p); 
// }  

// long long ncrp(long long n, long long r, long long p) 
// { 
   
//    if (r==0) 
//       return 1; 
  
    
//     long long fac[n+1]; 
//     fac[0] = 1; 
//     // for (long long i=1 ; i<=n; i++) 
//     //     fac[i] = fac[i-1]*i%p; 
  
//     return (fac[n]* modInverse(fac[r], p) % p * 
//             modInverse(fac[n-r], p) % p) % p; 
// }




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


   if (fopen("input.txt", "r")) {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    }


    ll n,w;
    cin>>n>>w;

    vector<pll> v;

    ll i;
    ll x,val;

    for(i=0;i<n;i++)
    {
       cin>>x>>val;

       v.pb(mp(x,val));
       
    }

    vll dp[n+1];
    ll j;
    for(i=0;i<=n;i++)
    {

        for(j=0;j<=w;j++)
        {
            if(i==0||j==0)
            {
                dp[i].pb(0);
            }
            else if(v[i-1].first<=j)
            {
                dp[i].pb(max(dp[i-1][j-v[i-1].first]+v[i-1].second,dp[i-1][j]));
            }
            else{
                dp[i].pb(dp[i-1][j]);
            }
        }
        dp[i].resize(w+1);
    }


    cout<<dp[n][w]<<endl;


 



  

    return 0;
}

Measured memory_bytes: 80256
#include<iostream>
#include<vector>
#include<cstdio>

using namespace std;

int main()

{
  int n,w;
  while(scanf("%d%d", &n, &w)){
    if(n==0&&w==0)break;
    int hist[20000] = {0,};
    int maxheight = 0;
    int bars = 0;
    double res = 0;
    for(int i = 0; i < n; ++i){
      int v;
      scanf("%d", &v);
      for(int j = 0; 1; ++j){
	//cout << "v = " << v << endl;
	if( w*j <= v && v < w*(j+1) ){
	  hist[j]++;
	  //cout << w << ' ' << j << endl;
	  maxheight = max(maxheight, hist[j]);
	  bars = max(bars,1+j);
	  break;
	}
      }
    }
    /*
    cout << bars << endl;
    for(int i = 0; i < bars; ++i){
      cout << hist[i] << ' ' ;
    }
    cout << endl;
    */
    double dens = 1;
    double tore = 1./(double)(bars-1);
    for(int i = 0; i < bars; ++i){
      res += dens * ((double)hist[i] / maxheight);
      dens -= tore;
    }
    res += 0.01;
    printf("%.11lf\n", res);
  }
  return 0;
}

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

int main()
{
  string s;
  int i;
  cin>>s;
  for(i=0;i<3;i++)
  {
    if(s[i]==s[i+1])
      break;
  }
  if(i<3)
    cout<<"Bad\n";
  else cout<<"Good\n";
return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
#include <vector>
#include <list>
#include <queue>
#include <stack>

using namespace std;
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl '\n'
int main(void) {
    fast_cin();

    int test_case;
    cin >> test_case;
    string verdicts[4] = {"AC", "WA", "TLE", "RE"};
    int sol[4] ={};
    for (int i = 0; i < test_case; i++) {
        string ans;
        cin >> ans;
        for (int j = 0; j < 4; j++) {
            if (ans == verdicts[j]) {
                sol[j]++;
            }
        }
    }
    cout << "AC x " << sol[0] << endl;
    cout << "WA x " << sol[1] << endl;
    cout << "TLE x " << sol[2] << endl;
    cout << "RE x " << sol[3] << endl;

    return 0;
}


Measured memory_bytes: 3660
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <map>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <string>

const int MAX_N = 200050;
std::string A;
int memo[MAX_N];

int cal_length_from(const int begin) {
    if (memo[begin] != -1) {
        return memo[begin];
    }

    bool array[26] = {};
    int ret = 1;
    int num = 0;
    for (int i = begin; i < A.size(); i++) {
        if (!array[A[i] - 'a']) {
            array[A[i] - 'a'] = true;
            num++;
            if (num == 26) {
                ret += cal_length_from(i + 1);
                break;
            }
        }
    }
    memo[begin] = ret;
    return ret;
}

int main(int argc, char **argv) {
    std::cin >> A;

    for (int i = 0; i < MAX_N; i++) {
        memo[i] = -1;
    }

    int length = cal_length_from(0);

    //std::cout << "length:" << length << std::endl;

    std::string ret;
    int begin = 0;
    for (int i = 0; i < length; i++) {
        bool pushed = false;
        for (char tmp = 'a'; tmp <= 'z'; tmp++) {
            bool found = false;
            for (int j = begin; j < A.size(); j++) {
                if (A[j] == tmp) {
                    found = true;
                    if (cal_length_from(j+1) == length - i - 1) {
                        //std::cout << i << " " << begin << " " << tmp << " " << j + 1 << " " << length - i - 1 << std::endl;
                        ret.push_back(tmp);
                        begin = j + 1;
                        pushed = true;
                    }
                    break;
                }
            }
            if (i == length - 1 && !found) {
                ret.push_back(tmp);
                break;
            }
            if (pushed) {
                break;
            }
        }
    }
    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 1924
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;
set<ll> SET;
int main()
{
  int N;cin>>N;
  int ans = 0;
  FOR(i,0,N) {
    ll in;cin>>in;
    if(in==2 || SET.count(in)) {
      ans++;
      continue;
    }
    bool ok = true;
    FOR(i,2,sqrt(in)+1) {
      if(in%i==0) {
        ok = false;
        break;
      }
    }
    if(ok) {
      ans++;
      SET.insert(ans);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3104
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

template<class T> void chmin(T &a, const T &b){ a = (a < b ? a : b); }
template<class T> void chmax(T &a, const T &b){ a = (a > b ? a : b); }

int main() {
    int c, n;
    cin >> c >> n;
    vector<vector<bool>> v(n, vector<bool>(n, false));
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        for (int j = 0; j < n; ++j) {
            v[i][j] = s[j]-'0';
        }
    }
    auto dp1 = make_v(n, n/2, 0);
    auto dp2 = make_v(n/2, n, 0);
    int cnt1 = 0, cnt2 = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n/2; ++j) {
            dp1[i][j] = v[i][j]^v[i][n-j-1];
            cnt1 += dp1[i][j];
        }
    }
    for (int i = 0; i < n/2; ++i) {
        for (int j = 0; j < n; ++j) {
            dp2[i][j] = v[i][j]^v[n-i-1][j];
            cnt2 += dp2[i][j];
        }
    }
    int ans = 0;
    if(!cnt1 && !cnt2) ans++;
    for (int _ = 1; _ < c; ++_) {
        int d;
        cin >> d;
        for (int i = 0; i < d; ++i) {
            int y, x;
            cin >> y >> x;
            y--; x--;
            cnt1 -= dp1[y][min(x, n-x-1)];
            dp1[y][min(x, n-x-1)] ^= 1;
            cnt1 += dp1[y][min(x, n-x-1)];
            cnt2 -= dp2[min(y, n-y-1)][x];
            dp2[min(y, n-y-1)][x] ^= 1;
            cnt2 += dp2[min(y, n-y-1)][x];
        }
        if(!cnt1 && !cnt2) ans++;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 7180
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e4;
int n, c[N], ans[N];
queue<int> q;
set<int> e[N];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(_, 1, n){
    int a, b;
    cin >> a >> b;
    a--; b--;
    e[a].insert(b);
    e[b].insert(a);
  }
  FOR(i, 0, n){
    cin >> c[i];
    if(sz(e[i])==1) q.push(i);
  }
  sort(c, c+n);
  ll s = 0;
  FOR(i, 0, n-1){
    int a = q.front(), b = *e[a].begin();
    s += c[i];
    q.pop();
    ans[a] = c[i];
    e[b].erase(a);
    e[a].erase(b);
    if(sz(e[b])==1) q.push(b);
  }
  cout << s << endl;
  FOR(i, 0, n) cout << (ans[i] ? ans[i] : c[n-1]) << endl;
}

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

int main() {
  int N;
  string S, T;
  cin >> N;
  cin >> S >> T;
  for(int i=0; i<N*2; i++){
    if(i%2 == 0){
      cout << S.at(i/2);
    }
    else {
      cout << T.at(i/2);
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <numeric>
using namespace std;
int N, D;
int X[20][20];
int ans = 0;
int main() {
	double drc; //キョリ
	cin >> N >> D;
	for (int j = 0;j < N;j++) {
		for (int i = 0;i < D;i++) {
			cin >> X[j][i];
		}
	}
	for (int i = 0;i < N;i++) {
		for (int j = 0;j < N;j++) {
			if (i < j) {
				drc = 0;
				for (int k = 0;k < D;k++) {
					drc += pow((X[i][k]-X[j][k]), 2.0);
				}
				if (ceil(sqrt(drc)) == floor(sqrt(drc))) {
					ans++;
				}

			}
		}
	}

	cout << ans;
	return 0;
}


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

int main() {
	string s,t;
	cin>>s>>t;
	int c[s.length()+1][t.length()+1];
	unordered_map<char,int> h;
	for(int i=0;i<=s.length();i++){
	for(int j=0;j<=t.length();j++){
	if(i==0||j==0){
	    c[i][j]=0;
	}
	else if(s[i-1]==t[j-1]){
	    c[i][j]=c[i-1][j-1]+ 1;
	}
	 else{
	    c[i][j]=c[i-1][j]>c[i][j-1]?c[i-1][j]:c[i][j-1];
	 }   
	}}
	int index=c[s.length()][t.length()];
	string lcs="";
	int i=s.length(),j=t.length();
	while(i>0&& j>0){
	    if (s[i-1] == t[j-1]) 
      { 
          lcs=s[i-1]+lcs; 
          i--; j--; index--;      
      } 
  
      
      else if (c[i-1][j] > c[i][j-1]) 
         i--; 
      else
         j--;
	}
	cout<<lcs;
	return 0;
}

Measured memory_bytes: 38828
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <map>
#include <sstream>
#include <vector>
#include <set>
#include <string>
#include <iterator>
#include <queue>
#include <cmath>
#include <cassert>

typedef long long ll;
using namespace std;
#define REP(i,n) for (int i = 0; i < n; i++)

int N;
int u[100010];
int v[100010];
int w[100010];

struct Edge {
    int to;
    int cost;
    Edge (int _t, int _c) {
        to = _t;
        cost = _c;
    }
};

vector < Edge > G[100010];

ll dist[100010];
bool color[100010];
void dfs (int v, ll tc) 
{
    if (dist[v] < 1e18) return;
    dist[v] = tc;
    REP(i,G[v].size()) {
        int to = G[v][i].to;
        ll ct = G[v][i].cost;
        dfs (to, ct + tc);
    }
}

int main ()
{
    cin >> N;
    REP(i,N - 1) cin >> u[i] >> v[i] >> w[i];
    REP(i,N - 1) {
        G[u[i]].push_back(Edge(v[i], w[i]));
        G[v[i]].push_back(Edge(u[i], w[i]));
    }
    fill (dist, dist + 100010, 1e18);
    dfs (1, 0);

    for (int i = 1; i <= N; i++) {
        if (dist[i] % 2 == 0) {
            color[i] = false;
        } else {
            color[i] = true;
        }
    }

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

    return 0;
}


Measured memory_bytes: 9984