akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for (Int i = 0; i < (Int)n; i++)
#define rep2(i, s, n) for (Int i = s; i < (Int)(n); i++)
#define rep3(i, n, s) for (Int i = n - 1; i >= s; i--)
#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).end()
 
double EPS = 1e-10;
Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int main() {
    Int a[3];
    rep(i, 3) cin >> a[i];
    sort(a, a + 3);
    Int res = 0;
    res += (a[2] - a[0]) / 2;
    a[0] += (a[2] - a[0]) / 2 * 2;
    res += (a[2] - a[1]) / 2;
    a[1] += (a[2] - a[1]) / 2 * 2;
    sort(a, a + 3);
    //rep(i, 3) cout << a[i] << " "; cout << endl;
    if (a[0] < a[2] and a[0] == a[1]) {
        res++;
    } else if (a[0] < a[2] and a[0] < a[1]) {
        res += 2;
    }
    dump(res);
    return 0;
}

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



int main(){
	int H,W;
	cin>>H>>W;
	vector<vector<int>> V(H,vector<int>(W));
	
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			cin>>V[i][j];
		}
	}
	vector<pair<pair<int,int>,pair<int,int>>> ans;
	
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(V[i][j]%2==1){
				if(j==W-1){
					if(i==H-1)break;
					ans.push_back(make_pair(make_pair(i+1,j+1),make_pair(i+2,j+1)));
					V[i+1][j]++;
				}
				else{
					ans.push_back(make_pair(make_pair(i+1,j+1),make_pair(i+1,j+2)));
					V[i][j+1]++;
				}
			}
		}
	}
	
	cout<<ans.size()<<endl;
	
	for(int i=0;i<ans.size();i++){
		cout<<ans[i].first.first<<' '<<ans[i].first.second<<' '<<ans[i].second.first<<' '<<ans[i].second.second<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 5232
#include<bits/stdc++.h>
using namespace std;
///////////////////////////////////////////////////////////////////////////////////////////////////////
int n;
const int maxn=1e5+10;
int a[maxn];
int dp[maxn];
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	dp[1]=abs(a[0]-a[1]);
	for(int i=2;i<n;i++){
		dp[i]=min(abs(a[i]-a[i-1])+dp[i-1],abs(a[i]-a[i-2])+dp[i-2]);
	}
	cout<<dp[n-1];
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  lint N,M,K;
  cin>>N>>M>>K;
  lint A[N],B[M];
  REP(i,N)cin>>A[i];
  REP(i,M)cin>>B[i];
  lint SA[N+1],SB[M+1];
  SA[0]=0;
  SB[0]=0;
  FOR(i,1,N+1)SA[i]=SA[i-1]+A[i-1];
  FOR(i,1,M+1)SB[i]=SB[i-1]+B[i-1];
  lint ans=0;
  REP(i,N+1){
    if(SA[i]>K)break;
    lint temp=i;
    if(K!=SA[i]){
      auto itr=upper_bound(SB,SB+M+1,K-SA[i]);
      temp+=distance(SB,itr)-1;
      // cerr<<i<<" "<<SA[i]<<" "<<*(itr-1)<<endl;
    }
    ans=max(ans,temp);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 9872
#include<iostream>
using namespace std;
int main(){
  int n, x, l[101], total=0, cnt=1;
  cin >> n >> x;
  for(int i=0; i<n; i++){
    cin >> l[i];
  }
  for(int i=0; i<n; i++){
    total += l[i];
    if(total <= x)cnt++;
  }
  cout << cnt << endl;
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define S 100000
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
vector<int>E[S];
int u[2 * S], v[2 * S], r[2 * S], ans[2 * S], d[S], cnt = 1, b[2 * S], ok[S]{ 1 };
queue<int>que;
void bfs(int u, int t) {
	que.push(u); while (!que.empty()) {
		int p = que.front(); que.pop(); for (int v : E[p]) {
			if (t) {
				if (d[v] > d[p] && !ok[v]) {
					ok[v] = 1; cnt++; que.push(v);
				}
			}
			else if (!~d[v]) {
				d[v] = d[p] + 1; que.push(v);
			}
		}
	}
}
int main() {
	int n, m, q; scanf("%d%d%d", &n, &m, &q);
	rep(i, m) {
		scanf("%d%d", &u[i], &v[i]);
		u[i]--; v[i]--;
		E[u[i]].push_back(v[i]); E[v[i]].push_back(u[i]);
	}
	memset(d, -1, sizeof(d));
	d[0] = 0; bfs(0, 0);
	rep(i, m) {
		if (d[u[i]] > d[v[i]])swap(u[i], v[i]);
	}
	rep(i, n)E[i].clear();
	rep(i, q) {
		scanf("%d", &r[i]); r[i]--;
		b[r[i]] = 1;
	}
	rep(i, m) {
		if (!b[i]) {
			if (d[v[i]] > d[u[i]]) {
				E[u[i]].push_back(v[i]);
			}
		}
	}
	bfs(0, 1);
	for (int i = q - 1; i >= 0; i--) {
		ans[i] = n - cnt;
		if (d[v[r[i]]] > d[u[r[i]]] && !ok[v[r[i]]]) {
			E[u[r[i]]].push_back(v[r[i]]);
			if (ok[u[r[i]]]) {
				cnt++; ok[v[r[i]]] = 1;
				bfs(v[r[i]], 1);
			}
		}
	}
	rep(i, q)printf("%d\n", ans[i]);
}

Measured memory_bytes: 14512
#include <bits/stdc++.h>
using namespace std;
 
 
#define FAST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pi       acos(-1)
#define mp make_pair
#define pb push_back
#define int long long ////////////
#define MOD 1000000007    ////////
#define POD 998244353 ////////
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))  
#define REVERSE(v) reverse(ALL(v))
#define maxc(v) max_element(all(v))
#define minc(v) min_element(all(v))
#define F first
#define S second
#define ppb pop_back
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) (m*n)/GCD(m,n)
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define initarr(a,n,x) for (int i=0;i<n;++i) a[i]=x
#define rep(i,a,n)  for(int i=a ; i<n ; i++)
#define repe(i,a,n) for(int i=a;i<=n;i++)
#define rev(i,a,b) for(int i=a;i>=b;i--)
//define ll long long
#define ld long double 
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vvvi> vvvvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<vvc> vvvc;
typedef vector<pii > vpii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef map<int,int> mii;
typedef unordered_map<int,int> umii;
typedef map<char,int> mci;
 
#define itv for(auto it= v.begin(); it != v.end(); ++it )
 
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element) (find(ALL(container),element) != container.end())
//#define invect(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.pb(tmp);commands}
//#define inset(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.insert(tmp);commands}
//#define trav(a, x) for(auto& a : x)
//#define display(x) trav(a,x) cout<<a<<" ";cout<<endl
 
 
#define bs binary_search
#define  lb(v,val)  lower_bound(ALL(v), val); 
 
#define dbg1(a) cout<<" *"<<a<<" ";
#define dbg2(a,b) cout<<" *"<<a<<" **"<<b<<" "     /////
#define dbg cout<<"hi"
#define nl "\n";
#define sz(s)         (int)((s).size())
#define coutsp(k)   cout<<setprecision(k)  //set precision (total length k icluding decimal and non decimal)
#define coutfsp(k)   cout<<fixed<<setprecision(k)  //fixed set precision(after decimal fixing)
#define  INF   (int)2e18 
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define vin(v,n)   vi v(n); rep(i,0,n)  cin>>v[i];
//#define siz  (int)1e8
#define N 300000



void quickly_quickly_kro()
{
   int h,w; cin>>h>>w;


   char a[h+1][w+1];

   rep(i,1,h+1)
   {
    rep(j,1,w+1)
    cin>>a[i][j];
   }

   int dp[h+1][w+1];


   rep(i,1,h+1)
   {
    rep(j,1,w+1)
    {
      if(a[i][j]=='#')
        dp[i][j]=0;
      else
      {
        if(i==1&&j==1)
          dp[i][j]=1;

        else if(i==1)
          dp[i][j]=dp[i][j-1]%MOD;
         else if(j==1)
          dp[i][j]=dp[i-1][j]%MOD;
         else
          dp[i][j]=(dp[i-1][j]+dp[i][j-1])%MOD;

      }
    }
   }


   cout<<dp[h][w];
  














  
















 }
 
 
 
 
signed main()
{
 
 
 
   FAST
   
   int t; 
      t=1;              
  //   cin>>t;
    while(t--)
    {
    
      quickly_quickly_kro();
      cout<<nl;
          
}
 
 
 
 
 
   return 0;
}

Measured memory_bytes: 9088
N, A, B = map(int, input().split())

ans = 0

for n in range(1, N+1):
    mn = str(n)
    lst_n = list(mn)
    sum = 0
    for i in range(len(lst_n)):
        sum += int(lst_n[i])
    if (sum >= A) and (sum <= B):
        ans += n

print(ans)

Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
using namespace std;

#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)

int m, n;

int main() {
  cin >> m >> n;
  int ans = -1, temp;
  rep (i,m) {
    int cnt = 0;
    rep (j,n) {
      cin >> temp;
      if (temp) cnt++;
    }
    ans = max(ans, cnt);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 0
m[31][50];main(n,p,d,x){
  long long int a[50],b;
  for(;scanf("%d",&n),n;){
    memset(m,0,6200);
    for(p=0;p<n;a[p]=(long long int)1<<p,p++)
      for(scanf("%d",&x);x;x--)scanf("%d",&d),m[d][p]=1;
    for(d=1;d<31;d++){
      for(b=p=0;p<n;p++)if(m[d][p])b|=a[p];
      for(p=0;p<n;p++)
        if(m[d][p]){
          a[p]=b;
          if(a[p]==((long long int)1<<n)-1){printf("%d\n",d);goto s;}
        }
    }
    puts("-1");s:;
  }
  return 0;
}

Measured memory_bytes: 0
open System
open System.Collections.Generic

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f
    let readChars() = read string |> Seq.toArray
    let readInts() = readChars() |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

[<AutoOpen>]
module Cout =
    let writer = new IO.StreamWriter(new IO.BufferedStream(Console.OpenStandardOutput()))
    let print (s: string) = writer.Write s
    let println (s: string) = writer.WriteLine s
    let inline puts (s: ^a) = string s |> println

let [| H; W |] = reada int
let maze = Array2D.init H W (fun _ _ -> '.')

for y in 0 .. H - 1 do
    let s = read string
    for x in 0 .. W - 1 do
        maze.[y, x] <- s.[x]

let mutable ok = true

for y in 0 .. H - 2 do
    let line = maze.[y, *]
    let mutable r = 0
    for x in 0 .. W - 1 do
        if maze.[y, x] = '#' then r <- x
    for x in r - 1 .. -1 .. 0 do
        if maze.[y + 1, x] = '#' then ok <- false

if ok then "Possible" else "Impossible"
|> puts

writer.Flush()


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

using namespace std;
using ll = long long;

#define gc getchar
int getint() { unsigned int c; int x = 0; while (((c = gc()) - '0') >= 10) { if (c == '-') return -getint(); if (!~c) exit(0); } do { x = (x << 3) + (x << 1) + (c - '0'); } while (((c = gc()) - '0') < 10); return x; }
int getstr(char *s) { int c, n = 0; while ((c = gc()) <= ' ') { if (!~c) exit(0); } do { s[n++] = c; } while ((c = gc()) > ' ' ); s[n] = 0; return n; }
template<class T> inline bool chmin(T &a, T b) { return a > b ? a = b, 1 : 0; }
template<class T> inline bool chmax(T &a, T b) { return a < b ? a = b, 1 : 0; }

int n;

int main () {
    n = getint();
    vector<int> as, bs, cs;
    for (auto i = 0; i < n; ++i) as.push_back(getint());
    for (auto i = 0; i < n; ++i) bs.push_back(getint());
    for (auto i = 0; i < n; ++i) cs.push_back(getint());

    sort(begin(as), end(as));
    sort(begin(bs), end(bs));
    sort(begin(cs), end(cs));

    ll res = 0;
    for (auto i = 0; i < bs.size(); ++i) {
        const auto b = bs[i];
        auto pos1 = lower_bound(as.begin(), as.end(), b) - as.begin();
        auto pos2 = upper_bound(cs.begin(), cs.end(), b) - cs.begin();
        res += (ll)pos1 * (cs.size() - pos2);
    }
    cout << res << endl;

    return 0;
}




Measured memory_bytes: 1912
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int main(){

	int N,M;
	scanf("%d %d",&N,&M);

	int ans = 0,ret,tmp;

	for(int i = 0; i < N; i++){
		printf("lst %d\n",i);fflush(stdout);
		scanf("%d",&ret);
		for(int k = 0; k < ret; k++)scanf("%d",&tmp);
		ans += ret*(ret-1);
	}

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

	return 0;
}

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

int main()
{

	int	   n, temp, sum;
	int	   top, front, back, left, right, under;
	string order;

	while( 1 ) {

		top   = 1;
		front = 2;
		back  = 5;
		left  = 4;
		right = 3;
		under = 6;
		sum   = 1;
	
		cin >> n;
		if( n == 0 ) break;

		for( int i = 0; i < n; i++ ) {
		
			cin >> order;

			if( order == "North" ) {
			
				temp  = top;
				top   = front;
				front = under;
				under = back;
				back  = temp;

			}
			else if( order == "South" ) {
			
				temp  = top;
				top   = back;
				back  = under;
				under = front;
				front = temp;
			
			}
			else if( order == "West" ) {
			
				temp  = top;
				top   = right;
				right = under;
				under = left;
				left  = temp;
			
			}
			else if( order == "East" ) {
			
				temp  = top;
				top   = left;
				left  = under;
				under = right;
				right = temp;
			
			}
			else if( order == "Right" ) {
			
				temp  = front;
				front = right;
				right = back;
				back  = left;
				left  = temp;
			
			}
			else if( order == "Left" ) {
			
				temp  = front;
				front = left;
				left  = back;
				back  = right;
				right = temp;

			}

			sum += top;
		
		}

		cout << sum << endl;
	
	}

	return 0;

}

Measured memory_bytes: 1208
# -*- coding: utf-8 -*-
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN


nums = list(map(int, input().rstrip().split()))

#----------
average = (nums[0] + nums[1]) / 2
print( Decimal(str(average)).quantize(Decimal('0'), rounding=ROUND_HALF_UP))


Measured memory_bytes: 5076
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
    int N, Q;
    cin >> N >> Q;

    UnionFind tree(N);

    for(int i = 0; i < Q; i++) {
        int p, x, y;
        cin >> p >> x >> y;
        if(p==0){
            tree.unite(x, y); // xの木とyの木を併合する
        }else{
            if(tree.same(x, y)){
                cout << "1" << endl;
            }else{
                cout << "0" << endl;
            }
        }
    }

    return 0;
}



Measured memory_bytes: 3216
#Grid Repainting
from collections import deque
import sys
h,w=map(int,input().split())
field=[list(input()) for _ in range(h)]
white=0
for i in range(h):
    for j in range(w):
        if field[i][j]==".":
            white+=1
start=[0,0]
goal=[h-1,w-1]
dx=[1,0,-1,0]
dy=[0,1,0,-1]
count=0
que=deque([[[0,0]]])
field[0][0]="#"
while que:
    q=que.popleft()
    count+=1
    k=[]
    while q:
        p=q.pop()
        x=p[0]
        y=p[1]
        if x==h-1 and y==w-1:
            break
        for i in range(4):
            nx=x+dx[i]
            ny=y+dy[i]
            if 0<=nx and nx<h and 0<=ny and ny<w:
                if field[nx][ny]!="#":
                    k.append([nx,ny])
                    field[nx][ny]="#"
    else:
        if k:
            que.append(k)
        continue
    break
else:
    print(-1)
    sys.exit()
print(white-count)

Measured memory_bytes: 40560
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define MAX_V 100005



int main(void){
	ll n,m;
	cin>>n>>m;
	vector<ll> yaku;
	int p = 1;
	while(pow(p,2) <= m){
		if(m%p == 0){
			yaku.push_back(p);
			yaku.push_back(m/p);
		}
		p++;
	}
	sort(yaku.begin(),yaku.end());
	REP(i, yaku.size()){
		if(yaku[i] * n <= m){
			cout<<yaku[i]<<endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
from itertools import permutations
N = int(input())
P = "".join(list(map(str,input().split())))
Q = "".join(list(map(str,input().split())))
ls = permutations(list(range(1,N+1)))
ans = []
for i in list(ls):
    ans.append("".join(list(map(str,i))))
ans = sorted(ans)
a,b = 0,0
for i in range(len(ans)):
    if ans[i] == P:
        a = i+1
    if ans[i] == Q:
        b = i+1
print(abs(int(a)-int(b)))

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

int main() {
  int N;
  cin >> N;
  
  vector<int> H(N);
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }
  
  int record = 0;
  int best = 0;
  
  if (N > 1) {
    for (int i = 0; i < N-1; i++) {
      if (H[i] >= H[i+1]) {
        record++;
        best = max(best, record);
      }
      else {
        record = 0;
      }
    }
  }
  
  cout << best << endl;
  
}

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

int main() {
  string s;
  cin>>s;
  int count=0;
  for(int i=0;i<s.size();i++){
    if(s.at(i)=='+'){
      count ++;
    }
  }
  if(count==0){
    cout<<-4<<endl;
  }
  else if(count==1){
    cout<<-2<<endl;
  }
  else if(count==2){
    cout<<0<<endl;
  }
  else if(count==3){
    cout<<2<<endl;
  }
  else{
    cout<<4<<endl;
  }
  
}

Measured memory_bytes: 764
#include <iostream>
 using namespace std;
 int main(){
   int a,b;
   cin >> a >> b;
   if(a>b){
   cout << "a > b" << endl;
   }
   if(a==b){
   cout << "a == b" << endl;
   }
   if(a<b){
   cout << "a < b" << endl;
   }
    }
    


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#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(){
  int N, D, X;
  cin >> N >> D >> X;
  vector<int> A(N);
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
  }
  int result = X;
  for(int i = 0; i < N; i++){
    int sum = 0;
    for(int j = 1; j <= D; j++){
      if((j-1) % A.at(i) == 0) sum++;
    }
    result += sum;
  }
  cout << result << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll          long long int
#define uu          first
#define vv          second
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define INF         1e9
#define fastRead    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;

const int MAX = 1e6 + 6;
int mark[MAX] , ara[MAX];

int main()
{
    fastRead;
    
    int n;
    cin>>n;
    
    for(int i =0 ; i < n ; i++ ) {
        int tmp ;
        cin>>tmp;
        ara[tmp]++;
    }
    
    if(ara[1]) {
        if(ara[1] ==1 ) cout<<1<<'\n';
        else cout<<0<<'\n';
        return 0;
    }
    int ans = 0;
    for(int i =2 ; i < MAX ; i++ ) {
        if(ara[i] ==0 || mark[i] ) continue;
        
        for(int j = i*2 ; j < MAX ; j +=i ) mark[j] = 1;
        
        if(ara[i] == 1) ans++;
    }
    
    cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 11424
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on 2019/3/16
Solved on 2019/3/
@author: shinjisu
"""


# ABC 095 C Half and Half
#import math
#import numpy as np

def getInt(): return int(input())

def getIntList(): return [int(x) for x in input().split()]
# def getIntList(): return np.array(input().split(), dtype=np.longlong)

def zeros(n): return [0]*n
# def zeros(n): return np.zeros(n, dtype=np.longlong)

def getIntLines(n): return [int(input()) for i in range(n)]
"""
def getIntLines(n):
    data = zeros(n)
    for i in range(n):
        data[i] = getInt()
    return data
"""

def zeros2(n, m): return [zeros(m)]*n # obsoleted zeros((n, m))で代替

def getIntMat(n, m):  # n行に渡って、1行にm個の整数
    #mat = zeros((n, m))
    mat = zeros2(n, m)
    for i in range(n):
        mat[i] = getIntList()
    return mat

ALPHABET = [chr(i+ord('a')) for i in range(26)]
DIGIT = [chr(i+ord('0')) for i in range(10)]
N1097 = 10**9 + 7
INF = 10**18

class Debug():
    def __init__(self):
        self.debug = True
 
    def off(self):
        self.debug = False
 
    def dmp(self, x, cmt=''):
        if self.debug:
            if cmt != '':
                print(cmt, ':  ', end='')
            print(x)
        return x


def prob():
    d = Debug()
    d.off()
    A, B, C, X, Y = getIntList()
    d.dmp((A, B, C, X, Y),'A, B, C, X, Y')
    pt1 = A*X + B*Y
    pt2 = A*X + C*2*Y
    pt3 = C*2*X + B*Y
    pt4 = C*2*min(X, Y)+ C*2*(max(X, Y)-min(X, Y))
    if X > Y:
        pt5 = C*2*min(X, Y)+ A*(X-min(X, Y))
    else:
        pt5 = C*2*min(X, Y)+ B*(Y-min(X, Y))

    yen = min(pt1, pt2, pt3, pt4, pt5)
    d.dmp((pt1, pt2, pt3, pt4, pt5), 'pt1, pt2, pt3, pt4, p5')
    d.dmp(yen, 'yen')
    return yen


ans = prob()
if ans is None:
    pass
elif type(ans) == tuple and ans[0] == 1:  # 1,ans
    for elm in ans[1]:
        print(elm)
else:
    print(ans)


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

signed main(){
	int n;
	int p[50];
	int q[50];
	cin >> n;
	LOOP(i,n){
		cin >> p[i];
		q[i] = p[i];
	}
	sort(q,q+n);

	int diff = 0;
	LOOP(i,n){
		if(p[i]!=q[i])diff++;
	}
	if(diff<=2){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}

}


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

int main(){
  int N;
  cin>>N;
  int s;
  s=N%10;
  
  if(s==3){
    cout<<"bon"<<endl;
  }
  else if(s==0||s==1||s==6||s==8){
    cout<<"pon"<<endl;
  }
  else {
    cout<<"hon"<<endl;
  }
}

Measured memory_bytes: 3616
import sys, math, collections, heapq, itertools
F = sys.stdin
def single_input(): return F.readline().strip("\n")
def line_input(): return F.readline().strip("\n").split()
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while a % b > 0: a, b = b, a % b
    return b
  
def solve():
    N = int(single_input())
    point = dict()
    city = []
    for i in range(N):
        s, p = map(str, line_input())
        if s in point:
            point[s].append((int(p), i+1))
        else:
            point[s] = [(int(p), i+1)]
            city.append(s)
    city.sort()
    for s in city:
        l = point[s]
        l.sort(reverse = True)
        for p, i in l:
            print(i)
    return 0
  
if __name__ == "__main__":
    solve()

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

#define ll long long
#define print(x) cout << "[" << #x << ":" << x << "] "; 
#define println(x) cout << "[" << #x << ":" << x << "]\n";

int main(){
    int n; cin >> n;
    int ans;
    if(n >= 400 && n < 600)
	ans = 8;
    else if(n >= 600 && n < 800)
	ans = 7;
    else if(n >= 800 && n < 1000)
	ans = 6;
    else if(n >= 1000 && n < 1200)
	ans = 5;
    else if(n >= 1200 && n < 1400)
	ans = 4;
    else if(n >= 1400 && n < 1600)
	ans = 3;
    else if(n >= 1600 && n < 1800)
	ans = 2;
    else if(n >= 1800 && n < 2000)
	ans = 1;
    cout << ans << "\n";
    return 0;
}


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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

const ll MOD = 1000000007;
const ll INF = (1LL << 62);

int main() {
  // std::cout << std::fixed << std::setprecision(10);

  ll N, M;
  scanf("%lld %lld", &N, &M);

  ll sum = 0;

  for (ll i = 0; i < M; i++) {
    ll v;
    scanf("%lld", &v);
    sum += v;
  }

  if (sum > N) {
    cout << -1 << endl;
  } else {
    cout << (N - sum) << endl;
  }
}


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

int main(){
  int N;
  cin >> N;
  int count=0;
  for(int i=0;i<N;i++){
    int A;
    cin >> A;
    if(A%2!=0){
      count++;
    }
  }
  if(count%2==0){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}


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

bool cmp(int a, int b)
{ 
    return a > b;
}

int main()
{
    int n, k, x; cin >> n >> k;

    int a[200000+5]={0};

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

    sort(a+1, a+200000+1, cmp);
    int count = 0;

    for (int i=k+1; i<=200000; i++) count += a[i];

    cout << count << endl; 
	return 0;
}

Measured memory_bytes: 1152
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f3f3f3f3fLL
#define SIZE 8080
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD=1e9+7;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
int N,X,Y,Z;
ll dp[50][(1<<17)+1]={0};
bool check(ll hoge){
	bool flag=true;
	int cnt=0;
	hoge = hoge >> (Z-1);
	//cout<<hoge<<" ";
	if(hoge%2==1)cnt++;
	hoge = hoge >> Y;
	//cout<<hoge<<" ";
	if(hoge%2==1)cnt++;
	hoge = hoge >> X;
	//cout<<hoge<<" "<<endl;
	if(hoge%2==1)cnt++;
	if(cnt==3)flag=false;
	return flag;
}

int NN=17;
int main(){
	cin>>N>>X>>Y>>Z;
	dp[0][0]=1;
	ll ans=1;
	for(int i=1;i<=N;i++){
		for(int j=1;j<=10;j++){
			ll che=(1<<(j-1));
			for(ll k=0;k<(1<<NN);k++){
				ll nex=((k<<j)+che)%(1<<NN);
				if(check(nex))dp[i][nex]=(dp[i][nex]+dp[i-1][k])%MOD;
			}
		}
		ans=(ans*(ll)10)%MOD;
	}
	for(int k=0;k<(1<<NN);k++){
		ans=(ans-dp[N][k]+MOD)%MOD;
	}
	cout<<ans<<endl;
	/*for(int i=0;i<(1<<4);i++){
		if(check(i))cout<<"True"<<endl;
		else cout<<"False"<<endl;
	}*/
	
	
	/*for(int i=0;i<=N;i++){
		for(int j=0;j<(1<<4);j++){
			cout<<dp[i][j]<<" ";
		}
		cout<<endl;
	}*/
	
	
	
}

Measured memory_bytes: 42240
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
#define pb push_back
#define all(v) v.begin(),v.end()
const ll mod=1000000007;
ll cnt[200005];
 
 
using namespace std;
 
 
ll fib(ll n) { 
  double phi = (1 + sqrt(5)) / 2; 
  return round(pow(phi, n) / sqrt(5)); 
} 
 
int main() {
		 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
	ll N, K, x, i;
	
	cin >> N >> K;
	ll ans = 0;
	
	vector<ll>h;
	for(i=0; i<N; i++){
		cin >> x;
	
		if(x>=K)
		ans++;
		
	}
	
	cout << ans << endl;	
	
	
}


Measured memory_bytes: 256
a = input()
b = input()
c = len(a)
a_list = list(a)
b_list = list(b)
for i in range(101):
  tmp = a_list[0]
  for j in range(c-1):
    a_list[j] = a_list[j+1]
  a_list[c-1] = tmp
  if a_list == b_list:
    print("Yes")
    exit()
print("No")


Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

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

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  m /= 1000;
  // 9x + 4y = n - m;
  int target = m - n;
  for (int i = 0; i * 9 <= target; ++i) {
    if ((target - i * 9) % 4) continue;
    int j = (target - i * 9) / 4;
    int k = n - i - j;
    if (k >= 0) {
      printf("%d %d %d\n", i, j, k);
      return 0;
    }
  }
  puts("-1 -1 -1");
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

int main() {
    int n; std::cin >> n;
    std::vector<int> d(n);
    for (int i = 0; i < n; i++) std::cin >> d[i];

    std::sort(d.begin(), d.end());

    int diff = d[n/2 - 1] - d[n/2];
    if (diff < 0) diff = -diff;

    std::cout << diff << std::endl;

    return 0;
}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main{

    public static final int FIRST_NUMBER = 0;
    public static final int SECOND_NUMBER = 1;

    public static void main(String[] args) throws NumberFormatException, IOException {

	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	// ???????????°
	int vertical = Integer.parseInt(br.readLine());
	// ?¨?????????°
	int horizontal = Integer.parseInt(br.readLine());

	// ???????????????????´?????????°??????????????????
	List<int[]> changeRequests = new ArrayList<>();
	for (int i = 0; i < horizontal; i++) {
	    String[] changeRequestStr = br.readLine().split(",");
	    int[] changeRequest = new int[2];
	    changeRequest[FIRST_NUMBER] = Integer.parseInt(changeRequestStr[FIRST_NUMBER]);
	    changeRequest[SECOND_NUMBER] = Integer.parseInt(changeRequestStr[SECOND_NUMBER]);
	    changeRequests.add(changeRequest);
	}

	// ?????\???????????????????´???????????????????????????????
	int[] outputArray = getDrawedArray(changeRequests, vertical, horizontal);

	// ???????????????????????????????????¨????????????????????????????????????1??????????????????
	for (int i = 1; i < outputArray.length; i++) {
	    System.out.println(outputArray[i]);
	}

    }

    /**
     * ?????? ???????????????????????????????????\??????????????????
     * 
     * @param changeRequests
     * @param vertical
     * @param horizontal
     * @return ?????\?????????
     */
    private static int[] getDrawedArray(List<int[]> changeRequests, int vertical, int horizontal) {
	// ?????\?????????????????????????????????????????????
	// ?????????????????????????????¨?????\????????????????????´???????????????outputArray[0]????????¨?????????
	int[] outputArray = new int[vertical + 1];
	for (int i = 1; i < outputArray.length; i++) {
	    outputArray[i] = i;
	}

	// ?????????????????????????£????????????\????????????
	for (int[] changeRequest : changeRequests) {
	    int mediator = 0;
	    mediator = outputArray[changeRequest[FIRST_NUMBER]];
	    outputArray[changeRequest[FIRST_NUMBER]] = outputArray[changeRequest[SECOND_NUMBER]];
	    outputArray[changeRequest[SECOND_NUMBER]] = mediator;

	}

	return outputArray;

    }

}

Measured memory_bytes: 24392
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <sstream>
using namespace std;

#define REP(i,a,n) for(i=a; i<n; i++)
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define foreach(it,x) for(typeof(x.begin()) it=x.begin(); it!=x.end(); it++)

const char *keitai[] = {
    "",
    ".,!? ",
    "abc",
    "def",
    "ghi",
    "jkl",
    "mno",
    "pqrs",
    "tuv",
    "wxyz"
};

int main(){
    int T,i;
    string in;

    cin >> T;
    while( T-- ){
        cin >> in;

        int cnt = 0, num = -1;
        rep(i,in.length()){
            if( in[i] == '0' ){
                if( num != -1 ){
                    putchar(keitai[num][(cnt-1)%strlen(keitai[num])]);
                }
                cnt = 0, num = -1;
            }
            else{
                num = in[i] - '0';
                cnt++;
            }
        }
        puts("");
    }
    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <map>
#include <string>

using namespace std;

int main(int argc, char const *argv[])
{
	int n,q;
	int ey,wy;
	string en;
	map<pair<int,int>, string>::iterator it;

	while(1){
		cin>>n>>q;
		if(n+q==0) break;

		map<pair<int,int>, string> mp;
		for(int i1=0;i1<n;i1++){
			cin>>en>>ey>>wy;
			mp[make_pair(wy-ey+1,wy)]=en;
		}

		for(int i1=0;i1<q;i1++){
			cin>>ey;
			for(it=mp.begin();it!=mp.end();it++){
				if((*it).first.first <= ey && (*it).first.second >= ey) {
					cout<<(*it).second<<" "<<ey-(*it).first.first+1<<endl;
					break;
				}
			}
			if(it==mp.end()) cout<<"Unknown"<<endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1332
# coding: utf-8
K = int(input())
st_lib = '0123456789'

memory = []
def search(s):
    if len(s) == 11:
        memory.append(int(s))
        return
    last_s = int(s[-1])
    if s == '0' * len(s):
        patterns = st_lib
    else:
        patterns = st_lib[max([last_s-1, 0]):last_s+2]
    for next in patterns:
        search(s+next)

if __name__ == '__main__':
    search('0')
    memory = sorted(memory)
    print(memory[K])

Measured memory_bytes: 12532
<?php
list($s) = strs();
$n = strlen($s);
for ($i = 0; $i < $n; ++$i) {
    if ($s[$i] === 'A' && !isset($a)) $a = $i;
    if ($s[$i] === 'Z') $z = $i;
}
echo $z - $a + 1;
function strs()
{
    return explode(' ', trim(fgets(STDIN)));
}


Measured memory_bytes: 4604
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
using namespace std;

typedef long long ll;
ll MOD = 1e9+7;

int main()
{
	int n,k;
	int ans=0;
	cin>>n>>k;
	if((n+1)/2>=k)
	{
		cout<<"YES"<<endl;
	}else
		cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
class UnionFind():
    def __init__(self,N):
        self.par=[-1]*N
    
    def unite(self,x,y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return False
        if self.par[x] > self.par[y]:
            x,y = y,x
        self.par[x] += self.par[y]
        self.par[y] = x
        return True
    
    def root(self,x):
        if self.par[x]<0:
            return x
        self.par[x] = self.root(self.par[x])
        return self.par[x]
    
    def size(self,x):
        return -self.par[self.root(x)]

N,M = map(int,input().split())
Edge = []
for _ in range(M):
    u,v = map(int,input().split())
    Edge.append((u-1,v-1))

ans = 0

for e in Edge:
    uf = UnionFind(N)
    for _e in Edge:
        if e == _e:
            continue
        uf.unite(_e[0],_e[1])
    if uf.size(0) != N:
        ans += 1

print(ans)

Measured memory_bytes: 9224
/**
 * File    : C.cpp
 * Author  : Kazune Takahashi
 * Created : 2/3/2019, 9:04:54 PM
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

ll N, M;
ll X[100010];
ll Y[100010];

int main()
{
  cin >> N >> M;
  for (auto i = 0; i < M; i++)
  {
    cin >> X[i];
  }
  if (N >= M)
  {
    cout << 0 << endl;
    return 0;
  }
  sort(X, X + M);
  for (auto i = 0; i < M - 1; i++)
  {
    Y[i] = X[i + 1] - X[i];
  }
  sort(Y, Y + M - 1);
  ll sum = 0;
  for (auto i = 0; i < M - N; i++)
  {
    sum += Y[i];
  }
  cout << sum << endl;
}

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

using namespace std;

#define ll long long

int main(){
    string O, E;

    cin >> O >> E;

    for(int i=0; i < O.length(); ++i){
        cout << O[i];
        if(i < E.length()){
            cout << E[i];
        }
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long long LL;
const long long M=1000000007;
#define ri register int 
#define rl register long long
int n,m,a,b,i,j;
int main()
{
	scanf("%d %d %d %d",&n,&m,&a,&b);
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=a;j++)
			if(i<=b)
				printf("1");
			else
				printf("0");
		for(j=a+1;j<=m;j++)
			if(i<=b)
				printf("0");
			else
				printf("1");
		printf("\n");
	}
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
using namespace std;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n,a,b,c;
    cin>>n;
    int dp[n+1][3];
    dp[0][0]=0;dp[0][1]=0;dp[0][2]=0;
    for (int i=1;i<=n;++i)
    {
        cin>>a>>b>>c;
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a;
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b;
        dp[i][2]=max(dp[i-1][1],dp[i-1][0])+c;
    }
    cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes                \
    cout << "Yes" << endl; \
    return 0;
#define No                \
    cout << "No" << endl; \
    return 0;
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int MOD = 1000000007;
typedef long long ll;

template <typename T>
void print(const T &v);

int main()
{
    ll X;
    cin >> X;
    vector<ll> vec;
    for (ll i = 0; i <= 27000; i++)
    {
        ll tmp = pow(i, 5);
        vec.push_back(tmp);
    }
    int n = vec.size();
    // A - Bの場合
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (vec[i] - vec[j] == X)
            {
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }

    // A + Bの場合
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (vec[i] + vec[j] == X)
            {
                cout << i << " -" << j << endl;
                return 0;
            }
        }
    }
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 4392
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

const int MAX = 200000;

bool graph[2][MAX + 5];

int main() {
    int n, m;
    cin >> n >> m;
    for (int i = 0, a, b; i < m; i++) {
        cin >> a >> b;
        if (a == 1) {
            graph[0][b] = true;
        } else if (b == n) {
            graph[1][a] = true;
        }
    }
    bool flag = false;
    for (int i = 2; i < MAX+5; i++) {
        if (graph[0][i] && graph[1][i]) flag = true;
    }
    if (flag) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(type, x, y) do { type tmp = x; x = y; y = tmp; } while (0)

#define MOD 1000000007 

//昇順
int asc(const void* a, const void* b){
    return *(int*)a-*(int*)b;
}

int main(void){
    int N;
    scanf("%d",&N);

    //A[0]~A[N-1]に格納する
    int* A;
    NEW(A,N);
    int a=0;
    int b=0;
    int c=0;
    for(int i=0;i<N;i++){
        scanf("%d",&A[i]);
        if(A[i]%2==1){
            A[i]=1;
            a++;
        }
        else{
            if(A[i]%4==0){
                A[i]=4;
                c++;
            }
            else{
                A[i]=2;
                b++;
            }
        }
    }

    int flg=1;
    if(a>c+1) flg=0;
    else if(a==c+1){
        if(a+c!=N) flg=0;
    }

    if(flg) printf("Yes\n");
    else printf("No\n");

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define fastt ios_base::sync_with_stdio(false);cin.tie(NULL);
#define enl "\n"
#define ll long long
#define pb push_back
#define fi first
#define se second
#define vvi vector<vector<ll>> 
#define vi vector<ll> 
#define vpii vector<pair<ll,ll>>
#define all(x) x.begin(),x.end()
#define ffor(i,n) for(ll i = 0; i < n; ++i)
 
int main() {
    fastt;
    ll a,b,n;
    cin>>n;
    ll i,j,k;
    for(i=1;i*i<=n;i++){
        if(n%i==0){
            a=i;
            b=n/i;
        }
    }
    cout<<a+b-2<<enl;
    return 0;
}

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

#define INF 100100100
#define MOD 1000000007

using namespace std;
using ll = long long;
using ull = unsigned long long ;

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

   int N;
   cin>>N;
   vector<int>A(N);
   double ave = 0;
   for(int i=0;i<N;i++){
      cin>>A[i];
      ave += A[i];
   }
   ave /= 1.*N;

   double MIN = INF;
   int ans = 0;
   for(int i=0;i<N;i++){
      if(abs(A[i]-ave) < MIN){
         MIN = abs(A[i]-ave);
         ans = i;
      }
   }

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


Measured memory_bytes: 256
package main

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

var scan *bufio.Scanner
var writer io.Writer

func init() {
	scan = bufio.NewScanner(os.Stdin)
	writer = os.Stdout
	scan.Split(bufio.ScanWords)
}

func main() {
	solve()
}

func solve() {
	n := nextInt()
	// a := make([]int, n)
	b := make([]int, n)
	for i := 0; i < n-1; i++ {
		b[i] = nextInt()
	}
	b[n-1] = 100001
	res := 0
	for i := 0; i < n-1; i++ {
		res += int(math.Min(float64(b[n-2-i]), float64(b[n-1-i])))
	}
	res += b[0]

	fmt.Fprint(writer, res)
}

func nextWord() string {
	scan.Scan()
	str := scan.Text()
	return str
}

func nextInt() int {
	i, e := strconv.Atoi(nextWord())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = 1; i <= n; i++)
#define drep(i, n) for(int i = n-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define vi vector<int>
#define P pair<ll, ll>
int mod = 1'000'000'000 + 7;
struct edge {
    int to;
    ll cost;
};

void COME_LET_THE_GAMES_BEGIN() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(20);
}

int main() {
    COME_LET_THE_GAMES_BEGIN();
    int N, M;
    cin >> N >> M;
    vector<string> A(N), B(M);
    rep(i, N) {
        cin >> A[i];
    }
    rep(i, M) {
        cin >> B[i];
    }
    for (int i = 0; i + M - 1 < N; i++) {
        for (int j = 0; j + M - 1 < N; j++) {
            bool f = 1;
            for (int p = 0; p < M; p++) {
                for (int q = 0; q < M; q++) {
                    if (A[i + p][j + q] != B[p][q]) {
                        f = 0;
                    }
                }
            }
            if (f) {
                puts("Yes");
                return 0;
            }
        }
    }
    puts("No");
}

Measured memory_bytes: 256
import Data.List

main = do
  n <- readLn :: IO Integer
  let p = [(a, div n a) | a <- [1..10^5], mod n a == 0]
  putStrLn . show . minimum . map f $ p

f :: (Integer, Integer) -> Int
f (a, b) = max (length . show $ a) $ length . show $ b


Measured memory_bytes: 1020
using System;
using System.Globalization;
using System.Linq;

namespace AOJ0027
{
    class Program
    {
        static void Main()
        {
            string line;
            while ((line = Console.ReadLine()) != null && line != "0 0")
            {
                var values = line.Split(' ').Select(int.Parse).ToArray();
                var date = new DateTime(2004, values[0], values[1]);
                Console.WriteLine(date.ToString("dddd", CultureInfo.CreateSpecificCulture("en-US")));
            }
        }
    }
}

Measured memory_bytes: 6308
#include<stdio.h>
#define INFTY (1 << 21)
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n;
int M[100][100];

void Dijkstra();

int main(){
  int i, j, u, k, v, w;

  scanf("%d",&n);
for(i=0;i<n;i++)

  for(i = 0 ; i < n ; i++){
    for(j = 0 ; j < n ; j++){
      M[i][j] = INFTY;
    }
  }

  for(i = 0 ; i < n ; i++){
    scanf("%d%d",&u,&k);

    for(j = 0 ; j < k ; j++){
      scanf("%d%d",&v,&w);
      M[u][v] = w;
    }
  }

  Dijkstra();

  return 0;
}

void Dijkstra(){
  int i;
  int min, u, v;
  int d[100], color[100];

  for(i = 0 ; i < n ; i++){
    d[i] = INFTY;
    color[i] = WHITE;
  }

  d[0] = 0;
  color[0] = GRAY;

  while(1){
    min = INFTY;
    u = -1;
    for(i = 0 ; i < n ; i++){
      if(min > d[i] && color[i] != BLACK){
 u = i;
 min = d[i];
      }
    }

    if(u == -1) break;

    color[u] = BLACK;
    for(v = 0 ; v < n ; v++){
      if(color[v] != BLACK && M[u][v] != INFTY){
 if(d[v] > d[u] + M[u][v]){
   d[v] = d[u] + M[u][v];
   color[v] = GRAY;
 }
      }
    }
  }

  for(i = 0 ; i < n ; i++){
    printf("%d ",i);

    if(d[i] == INFTY) printf("-1\n");
    else printf("%d\n",d[i]);
  }
}



Measured memory_bytes: 2112
#include <stdio.h>

int main(void){
int x,y,i;

while(1){
scanf("%d",&x);
scanf("%d",&y);
if(x==0&&y==0){
break;
}
if(x<y){
printf("%d %d\n",x,y);
}
else{
printf("%d %d\n",y,x);
}
}
return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

void Main()
{
    int n, m;
    cin >> n >> m;
    priority_queue<int> a;
    for (int i = 0; i < n; ++i)
    {
        int v;
        cin >> v;
        a.push(v);
    }
    while (m != 0)
    {
        int t = a.top();
        t = t / 2;
        a.pop();
        a.push(t);
        m--;
    }
    ll total = 0;
    while (!a.empty())
    {
        total += a.top();
        a.pop();
    }
    cout << total << endl;
}

int main()
{
    std::cout << std::fixed << std::setprecision(15);
    Main();
}

Measured memory_bytes: 892