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++)
using ll = long long;
const long long INF = 1LL << 60;
const int MOD = 1e9 + 7;

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

int main(){
	int N;
	cin >> N;
	std::vector<std::vector<ll>> vecA(N,std::vector<ll>(2));
	rep(i,N){
		cin >> vecA.at(i).at(1);
		vecA.at(i).at(0) = i;
	}


	sort(vecA.begin(),vecA.end(),
		[](const std::vector<ll> &x,const std::vector<ll> &y){
			return x.at(1) > y.at(1);
		});

	//DP table
	std::vector<std::vector<ll>> dp(N+1,std::vector<ll>(N+1));

	ll ans = 0;
	rep(i,N+1){
		rep(j,N+1){

			if(i+j-1 >= N || i+j == 0){
				continue;
			}
			ll active = vecA.at(i+j-1).at(1);
			ll index = vecA.at(i+j-1).at(0);

			dp.at(i).at(j) = max((i>0)?dp.at(i-1).at(j)+active*abs(index-(i-1)):-1,
								(j>0)?dp.at(i).at(j-1)+active*abs(index-(N-1-(j-1))):-1);
			chmax(ans,dp.at(i).at(j));
		}
	}


	cout << ans << endl;
	return 0;

}

Measured memory_bytes: 34672
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

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

class Data
{
public:
    int p, q, y, x, d;
    Data(int p0, int q0, int y0, int x0, int d0){
        p = p0;
        q = q0;
        y = y0;
        x = x0;
        d = d0;
    }
    int toInt(){
        return (((p * 11 + q) * 102 + y) * 102 + x) * 4 + d;
    }
};

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

    vector<string> s(h+2, string(w+2, '#'));
    int sy, sx, gy, gx;
    for(int i=1; i<=h; ++i){
        for(int j=1; j<=w; ++j){
            cin >> s[i][j];
            if(s[i][j] == 'S'){
                sy = i;
                sx = j;
            }
            if(s[i][j] == 'G'){
                gy = i;
                gx = j;
            }
        }
    }

    vector<bool> check(11*11*102*102*4, false);
    queue<Data> q;
    Data d0(n, n, sy, sx, 1);
    check[d0.toInt()] = true;
    q.push(d0);

    int ret = INT_MAX;
    while(!q.empty()){
        Data d = q.front();
        q.pop();

        if(d.y == gy && d.x == gx){
            ret = min(ret, 2 * n - d.p - d.q);
            continue;
        }

        for(int i=0; i<4; ++i){
            Data d2 = d;
            d2.y += dy[i];
            d2.x += dx[i];
            d2.d = i;
            if(s[d2.y][d2.x] == '#')               // 進行方向に壁
                continue;
            if(d.y == sy && d.x == sx && d.d != i) // generator の上に鏡を置くことは出来ない
                continue;
            if(d.y == sy && d.x == sx && d.d == 3) // どのように鏡をおいても、generator を上向きに通過することは出来ない
                continue;

            if(d.d == i){                                               // そのまま直進
                ;
            }else if(abs(d.d - i) == 2){                                // 逆向きには戻れない
                continue;
            }else if((dy[d2.d] + dx[d2.d]) * (dy[d.d] + dx[d.d]) == 1){ // Pの鏡を使用
                if(-- d2.p < 0)
                    continue;
            }else{                                                      // Qの鏡を使用
                if(-- d2.q < 0)
                    continue;
            }

            if(!check[d2.toInt()]){
                check[d2.toInt()] = true;
                q.push(d2);
            }
        }
    }

    if(ret == INT_MAX)
        cout << -1 << endl;
    else
        cout << ret << endl;

    return 0;
}

Measured memory_bytes: 1636
//k_k_dubey_
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define inf 999999999999
#define mx 200005
#define gcd __gcd
#define pb push_back
#define mk make_pair
#define bs binary_search
#define ub upper_bound
#define lb lower_bound
#define endl "\n"
#define vl vector<ll>
#define vs vector<string>
#define non __builtin_popcount
#define ml map<ll, ll> 
#define ms map<string , ll> 
using namespace std;

bool isp[mx];

void sv(){

	ll i,j;
	memset(isp, true, sizeof(isp));
	
	isp[1]= false;
	for(i=2;i*i<mx;i++){
		if(isp[i]){
			for(j=i*i;j<mx;j+=i)
			isp[j]= false;
		}
	}
}

ll powr(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1)res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	//sv();
	
	ll x,a;
	cin>>x>>a;
	if(x<a)
	cout<<"0";
	else
	cout<<"10";
    return 0;
}























Measured memory_bytes: 256
#!/usr/bin/env python3
import math

(n, ), *p = [[*map(int, i.split())] for i in open(0)]
m = 0.0
f = math.factorial(n - 1)*2
for i in range(n):
    for j in range(i + 1, n):
        m += ((p[i][0] - p[j][0])**2 + (p[i][1] - p[j][1])**2)**0.5*f
print(m / math.factorial(n))


Measured memory_bytes: 62544
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n,arr[100009][3],dp[100009][3];

ll rec(ll cur, ll knot){
    if(dp[cur][knot]==-1){
        if(cur==0){
            ll temp=0;
            for(int i=0;i<3;i++){
                if(i!=knot){
                    temp=max(temp,arr[cur][i]);
                }
            }
            dp[cur][knot]=temp;
        }
        else{
            ll ans=0;
            for(int i=0;i<3;i++){
                if(i!=knot){
                    ll ya=rec(cur-1,i)+arr[cur][i];
                    ans=max(ans,ya);
                }
            }
            dp[cur][knot]=ans;
        }
    }
    return dp[cur][knot];
}

void init(){
    for(int i=0;i<=100000;i++){
        for(int j=0;j<3;j++){
            dp[i][j]=-1;
        }
    }
}

int main()
{
    init();
    cin>>n;
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            cin>>arr[i][j];
        }
    }
    cout<<rec(n-1,4);
    return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)x.size()

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
  string s;
  cin >> s;
  if(s[2] == s[3] && s[4] == s[5]) cout << "Yes";
  else cout << "No";
}


Measured memory_bytes: 256
// Created by Davidia on 2018-12-17.
//

// copyright@ Dr. Davidia


#include <bits/stdc++.h>

using namespace std;

#define MAXN 200000
#define INF 999999999 // watch it
#define int long long
typedef pair<int,int> hb;

vector<int> tree(4*MAXN,0);

void update(int ind, int v, int node = 1, int i = 1, int j = MAXN){
    if (ind < i || ind > j) return;
    if ( i==j ){
        tree.at(node) = max(tree[node], v);
    }
    else{
        update(ind,v,node*2,i,(i+j)/2);
        update(ind,v,node*2+1,(i+j)/2+1,j);
        tree.at(node) = max(tree.at(node*2), tree.at(node*2+1)); 
    }
}

int queries(int a, int b, int node = 1, int i = 1, int j = MAXN){
    if (a > j || b < i) return INT_MIN;
    if (a <= i && b >= j){
        return tree.at(node);
    }
    return max(queries(a,b,node*2,i,(i+j)/2)  ,  queries(a,b,node*2+1, (i+j)/2+1, j));
}

#undef int
int main(){
#define int long long
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n; cin >> n;
    vector<hb> flowers(n);
    for (int i = 0; i < n; i++){
        cin >> flowers.at(i).first;
    }
    for (int i = 0; i < n; i++){
        cin >> flowers.at(i).second;
    }

    for (auto &p : flowers){
        update(p.first, p.second+queries(1,p.first));
    }
    cout << queries(1, n) << '\n';


}





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

int main() {
  
  long long N,K;
  cin >> N;
  cin >> K;

  long long dam =0;
  vector <long long>H(N);
  
  for( long long i = 0;i<N;i++){
    cin >> H.at(i);
  }

  sort(H.begin(), H.end());
  reverse(H.begin(), H.end());
  
  long long res = 0;

  for ( long long i = K;i < N;i++){
//    cout << H.at(i) << endl;
     res += H.at(i);
  }
   
  cout << res << endl;
}





Measured memory_bytes: 1792
score = list(map(int,input().split()))
if score[0] == 1:
    evennum = 0
else:
    evennum = score[0]*(score[0]-1)/2
if score[1] == 1:
    oddnum = 0
else:
    oddnum = score[1]*(score[1]-1)/2
print(int(evennum+oddnum))

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

using namespace std;

#define pii pair<ll, ll>
#define ll long long
#define PRIME 1000000007
#define sq(x) ((x)*(x))
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mset(x,v) memset(x,v,sizeof(x))

int main() {

  ios_base::sync_with_stdio(false); cin.tie(0);

  ll n,k,arr[100005]={0},i,j,dp[100005]={0};
  cin >> n >> k;
  for(i=0;i<n;i++){
    cin >> arr[i];
    if(!i)
      dp[i]=0;
    // else
    // if(i==1)
    //   dp[i]=abs(arr[i]-arr[i-1]);
    else if(i){
      dp[i]=PRIME;
      ll maxi = max(i-k,(ll)0);
      for(j=i-1;j>=maxi;j--)
        dp[i]=min(dp[i],dp[j]+abs(arr[i]-arr[j]));
    }
  }
  cout << dp[n-1] << endl;
}


Measured memory_bytes: 1792
#!/usr/bin/perl
#= CPAN mocules =====================================================#
use strict;				# strictモード
use warnings;			# 警告有効
use utf8;				# UTF8モード ON

#= Global values ====================================================#
#= Local routines ===================================================#
sub main(){
	my $input = <>;
	chomp $input;

	my @in = split(/ /, $input);
	if ($in[0] eq "H"){
		print $in[1]."\n";
	}else{
		if ($in[1] eq "H"){
			print "D\n";
		}else{
			print "H\n";
		}
	}

	return 0;
}

#----- 実行 -----#
exit( main() );




Measured memory_bytes: 640
line = readlines.map(&:chomp)

n = line[0].to_i
s = line[1]

r_num = []
g_num = []
b_num = []

for i in 0..n-1
  if s[i] == "R" then
    r_num.push(i)
  elsif s[i] == "G" then
    g_num.push(i)
  elsif s[i] == "B" then
    b_num.push(i)
  end
end

result = r_num.length * g_num.length * b_num.length

for i in r_num
  for j in g_num
    c1 = [i,j].sort[0]
    c2 = [i,j].sort[1]
    d = c2 - c1
    c3 = c2 + d
    c0 = c1 - d
    cm = (c2 + c1) / 2
    if c0 >= 0 and s[c0] == "B"
      result = result - 1
    end
    if c3 <= n - 1 and s[c3] == "B"
      result = result - 1
    end
    if (c2 + c1) % 2 == 0 and s[cm] == "B"
      result = result - 1
    end
  end
end

print result

Measured memory_bytes: 14384
#include<iostream>
#include<vector>
#include<cmath>

using namespace std;

vector<long long int> cumsum(vector<long long int> A)
{
    vector<long long int> res;
    res.push_back(A[0]);
    for (int i=1; i<A.size(); ++i)
    {
        res.push_back(res[i-1] + A[i]);
    }
    return res;
}

int main()
{
    int N;
    cin >> N;
    vector<long long int> A;

    int tmp = 0;
    for (int i=0; i<N; ++i)
    {
        cin >> tmp;
        A.push_back(tmp);
    }

    vector<long long int> cumA = cumsum(A);
    long long int ans = 2020202020;
    for (int i=0; i<N; ++i)
    {
        long long left = cumA[i];
        long long right = cumA[N-1] - cumA[i];
        long long dif = abs(left-right);
        if(dif<ans) ans = dif;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6384
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>

using namespace std;

#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 REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 999999999
#define MINF -999999999

int main() {
	int a;
	cin >> a;
	if (a / 10 == 9 || a % 10 == 9) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
N = gets.to_i
a = gets.split.map(&:to_i)
max = a.map(&:abs).each.with_index.max[1]

puts 2 * N - 2
N.times{|i| puts [max+1, i+1] * " " if i != max}
puts (N-1).times.map{|i| [i+1, i+2] * " "} if a[max] >= 0
puts (N-1).times.map{|i| [i+2, i+1] * " "}.reverse if a[max] < 0

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    int n;cin>>n;
    ll ans=0;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n);
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++) cin>>b[i];
    for(int i=0;i<n;i++) cin>>c[i];
    sort(a.begin(),a.end());
    sort(c.begin(),c.end());
    for(int i=0;i<n;i++){
        auto iter=lower_bound(a.begin(),a.end(),b[i]);
        ll index1=iter-a.begin();
        auto it=upper_bound(c.begin(),c.end(),b[i]);
        ll index2=it-c.begin();
        ans+=index1*(n-index2);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1408
N,K=map(int,input().split())
a=[1]
p=[1]
for i in range(N):
  a.append(a[i]*2+3)
  p.append(p[i]*2+1)
def find(N,K):
  if N==0:
    return 0 if K<=0 else 1
  elif K<=a[N-1]+1:
    return find(N-1,K-1)
  else:
    return p[N-1]+1+find(N-1,K-2-a[N-1])
print(find(N,K))

Measured memory_bytes: 3064
import numpy as np
x, y, z, k = map(int, input().split())
k = min(x * y * z, k)
a = np.array(list(map(int, input().split())))
b = np.array(list(map(int, input().split())))
c = np.array(list(map(int, input().split())))

ab = np.ravel(a + b[:, None])
ab.sort()
abc = np.ravel(c + ab[-k:, None])
abc.sort()
print(np.sum(abc[-k:][::-1].astype(str).astype(object) + "\n"), end="")


Measured memory_bytes: 44100
#include<stdio.h>
#include<string.h>
#include<utility>
#include<iostream>
#include<queue>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<bitset>

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

#define MAX_BIN 17
bitset<MAX_BIN> crop(bitset<MAX_BIN> num, int a){
    for(int i=a;i<MAX_BIN-1;i++){
        num[i]=num[i+1];
    }
    num[MAX_BIN-1]=0;
    return num;
}
bitset<MAX_BIN> insert(bitset<MAX_BIN> num, int bit,int a){
    for(int i=MAX_BIN-1;i>=a+1;i--){
        num[i]=num[i-1];
    }
    num[a]=bit;
    return num;
}

vector<bitset<MAX_BIN>> GrayCodeGenerator(bitset<MAX_BIN> a,bitset<MAX_BIN> b,int binary_digit){
    //printf("###hoge [%ld:%ld]\n",a.to_ulong(),b.to_ulong());
    if(binary_digit==1){
        vector<bitset<MAX_BIN>> ans;
        ans.push_back(a);
        ans.push_back(b);
        return ans;
    }
    int dig;
    for(int i=binary_digit-1;i>=0;i--){
        if(a[i]!=b[i])dig=i;
    }
    //printf("%d\n",dig);
    bitset<MAX_BIN> adash=crop(a,dig);
    bitset<MAX_BIN> bdash=crop(b,dig);
    //printf("%lld %lld\n",a.to_ullong(),adash.to_ullong());
    bitset<MAX_BIN> c=adash;
    c=c.flip(binary_digit-2);
    vector<bitset<MAX_BIN>> p=GrayCodeGenerator(adash,c,binary_digit-1);
    vector<bitset<MAX_BIN>> q=GrayCodeGenerator(c,bdash,binary_digit-1);
    REP(i,p.size())p[i]=insert(p[i],a[dig],dig);
    REP(i,q.size())q[i]=insert(q[i],b[dig],dig);
    std::copy(q.begin(),q.end(),std::back_inserter(p));
    return p;
}

int main()
{
    int n,a,b;
    scanf("%d %d %d",&n,&a,&b);
    std::bitset<17> aa(a);
    std::bitset<17> bb(b);
    std::bitset<17> dif=aa^bb;
    if(dif.count()%2==0){
        printf("NO\n");
        return 0;
    }
    printf("YES\n");
    vector<bitset<MAX_BIN>> ans=GrayCodeGenerator(aa,bb,n);
    for(bitset<MAX_BIN> i : ans){
        printf("%lld\n",i.to_ullong());
    }
    return 0;
}

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

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

    int x[N], y[N], h[N];
    for (int i = 0; i < N; i++){
        cin >> x[i] >> y[i] >> h[i];
    }

    for (int i = 0; i <= 100; i++){
        for (int j = 0; j <= 100; j++){
            bool isDefined = false;
            bool isAns = true;
            int H;
            for (int k = 0; k < N; k++){
                if (h[k] > 0){
                    if (isDefined){
                        if ((H - abs(x[k] - i) - abs(y[k] - j)) != h[k]){
                            isAns = false;
                        }
                    }else{
                        isDefined = true;
                        H = abs(x[k] - i) + abs(y[k] - j) + h[k];
                    }
                }
            }
            for (int k = 0; k < N; k++){
                if (h[k] == 0){
                    if ((H - abs(x[k] - i) - abs(y[k] - j)) > 0){
                        isAns = false;
                    }
                }
            }
            if (isAns){
                cout << i << " " << j << " " << H << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
S=input()
import itertools
A=[]
for key,g in itertools.groupby(S):
  A.append([key,len(list(g))])
ans=0
open=True
cur=0
for i in range(len(A)):
  key=A[i][0]
  n=A[i][1]
  if (i==0 and key==">") or (i==len(A)-1 and key=="<"):
    ans+=n*(n+1)//2
  else:
    if open:
      cur=n
      open=False
    else:
      if n>cur:
        cur-=1
      else:
        n-=1
      ans+=cur*(cur+1)//2+n*(n+1)//2
      open=True
print(ans)


Measured memory_bytes: 30108
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
typedef long long ll;
const int N=1e6+8;
ll n,x,y,k,val[N],ans,dp[N],mx=0,a[N],b[N];
vector<ll>g[N];
inline void dfs(ll v,ll fa)
{
	for(int i=0;i<g[v].size();i++)
	{
		//cout<<v<<endl;
		ll u=g[v][i];
		if(u==fa)continue;
		dfs(u,v);
		dp[v]++;
		dp[v]+=dp[u];
		mx=max(dp[v],mx);
	}
}
int main()
{
	ios::sync_with_stdio(0);
   	cin>>n;
   	for(int i=1;i<n;i++)
   	{
   		for(int j=1;j*i<n;j++)
   		{
   			//if(i*j==n)continue;
   		//	cout<<i<<" "<<j<<endl;
   			ans++;
		}
	}
	cout<<ans<<endl;
}

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

int main(){
    int n,x;
    cin >> n >> x;
    int m[200];
    int res,a=0;
    int min_m=10000;
    for(int i=1;i<n+1;i++){
        cin >> m[i];
        if(m[i]<min_m)min_m=m[i];
        a+=m[i];
    }
    res=n+(x-a)/min_m;
    cout << res << endl;
}

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

int main()
{
	bool aster[10][7]={0};
	for(int i=0; i<10; i++)
	{
		if(i<=4) aster[i][0]=1;
		else aster[i][1]=1;
	}
	
	for(int i=0; i<5; i++)
	for(int j=0; j<10; j++)
		if(i!=(j%5)) aster[j][i+2]=1;
	
	bool f=false;
	char buf[9];
	while(scanf("%s", buf) != EOF)
	{
		if(f) puts("");
		f=true;
		
		char str[9];
		int len=strlen(buf);
		for(int i=0; i<5; i++)
		{
			if(5-len<=i) str[i]=buf[i-(5-len)];
			else str[i]='0';
		}
		str[5]='\0';
		
		for(int i=0; i<7; i++)
		{
			for(int j=0; j<5; j++)
			{				
				if(aster[str[j]-'0'][i]) printf("*");
				else printf(" ");
			}
			puts("");
			if(i==1) puts("=====");
		}
	}
}

Measured memory_bytes: 0
#include<iostream>

using namespace std;

int main(){
  int m,f,r;
  string LNK;
  while(cin >> m >> f >> r){
    if(m==-1 && f==-1 && r==-1) break;
    if(m==-1 || f==-1) LNK = "F";
    else if(m+f>=80) LNK = "A";
    else if(m+f>=65) LNK = "B";
    else if(m+f>=50) LNK = "C";
    else if(m+f>=30){ LNK = "D";
      if(r>=50) LNK = "C";}
    else if(m+f<30) LNK = "F";
    cout << LNK << endl;
  }
}

Measured memory_bytes: 1192
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
const int wx[4]={0,0,1,-1},wy[4]={1,-1,0,0};
int n,m;
bool map[21][21];
bool walk[21][21];
int max(int a,int b)
{
    if(a>b) return a;
    return b;
}
struct Node {
    int x,y,deep;
}q[100000];
int bfs(int x,int y)
{
    memset(walk,0,sizeof(walk));
    q[1].x=x,q[1].y=y,q[1].deep=0;
    walk[x][y]=1;
    int l=1,r=1;
    while(l<=r)
    {
        for(int i=0;i<4;++i)
        {
            int tx=q[l].x+wx[i],ty=q[l].y+wy[i];
            if(map[tx][ty]==1||walk[tx][ty]==1||tx<=0||ty<=0||tx>n||ty>m) continue;
            q[++r].x=tx,q[r].y=ty;
            q[r].deep=q[l].deep+1;
            walk[tx][ty]=1;
        }
        ++l;
    }
    /*for(int i=1;i<=n;++i,putchar('\n'))
    {
        for(int j=1;j<=m;++j)
        {
            printf("%d",walk[i][j]);
        }
    }*/
    return q[r].deep;
}
int main()
{
    scanf("%d%d",&n,&m);
    char ch;
    for(int i=1;i<=n;++i)
    {
        for(int j=1;j<=m;++j)
        {
            cin>>ch;
            if(ch=='#') map[i][j]=1;
        }
    }
    int ans=0;
    for(int i=1;i<=n;++i)
    {
        for(int j=1;j<=m;++j)
        {
            if(map[i][j]==0) ans=max(ans,bfs(i,j));
        }
    }
    printf("%d",ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
#include <vector>
#include <chrono>
#include <cstdlib>
#include <bitset>
using namespace std;
int main(){
   string s;
   cin >> s;
   if(s == "ABC") cout << "ARC" << endl;
   else cout << "ABC" << endl;
}


Measured memory_bytes: 3596
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;

class Procon {
    static void Main (string[] agrs) {
        int N = Int();
        int K = Int();
        int[] h = Ints();

        int ret = 0;
        for (int i = 0; i<N; i++) {
            if (h[i] >= K) {
                ret ++;
            }
        }

        Console.WriteLine(ret);
    }

    static string String () => Scanner.nextString ();
    static int Int () => int.Parse (Scanner.nextString ());
    static long Long () => long.Parse (Scanner.nextString ());
    static double Double () => double.Parse (Scanner.nextString ());
    static char[] Chars () => String ().ToCharArray ();
    static string[] Strings () => Console.ReadLine ().Split (' ');
    static int[] Ints () => Strings ().Select (v => int.Parse (v)).ToArray ();
    static long[] Longs () => Strings ().Select (v => long.Parse (v)).ToArray ();
    static double[] Doubles () => Strings ().Select (v => double.Parse (v)).ToArray ();
    const int M = 1000000007;
}

class PriorityQueue<T> where T : IComparable<T> {
    public T[] heap;
    public int size;
    public int sign;
    public PriorityQueue (int N, bool descend = false) {
        heap = new T[N];
        sign = 1;
        if (descend) sign = -1;
    }
    public int Compare (T x, T y) {
        return x.CompareTo (y) * sign;
    }
    public void Push (T x) {
        int i = size++;
        while (i > 0) {
            int p = (i - 1) / 2;
            if (Compare (x, heap[p]) >= 0) {
                break;
            }
            heap[i] = heap[p];
            i = p;
        }
        heap[i] = x;
    }
    public T Pop () {
        T ret = heap[0];
        T x = heap[--size];
        int i = 0;
        while (i * 2 + 1 < size) {
            int a = i * 2 + 1;
            int b = i * 2 + 2;
            if (b < size && Compare (heap[a], heap[b]) > 0) {
                a = b;
            }
            if (Compare (heap[a], x) >= 0) {
                break;
            }
            heap[i] = heap[a];
            i = a;
        }
        heap[i] = x;
        return ret;
    }
    public int Count () {
        return size;
    }
}

class Scanner {
    static string[] s = new string[0];
    static int i = 0;
    static int max_i = 0;
    static public string nextString () {
        if (i >= s.Length) {
            s = Console.ReadLine ().Split (' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0) {
                return "";
            }
            return s[i++];
        }
        return s[i++];
    }
}

Measured memory_bytes: 17248
#!/usr/bin/env python
# coding: utf-8

# In[4]:


N = int(input())
S = input()


# In[5]:


ans = 0
x = 0
for i in range(N):
    if S[i] == "I":
        x += 1
    else:
        x -= 1
    ans = max(ans, x)
print(ans)


# In[ ]:






Measured memory_bytes: 2940
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

class Main
{
    long dp[][];
    int max[];
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int child=sc.nextInt();
        int candles=sc.nextInt();
        sc.nextLine();
        Main object=new Main();
        object.dp=new long[child+1][candles+1];
        object.max=new int[child];
        object.dp[0][0]=1;
        for(int i=1;i<=child;i++)
        {
          object.max[i-1]=sc.nextInt();
          for(int j=0;j<=candles;j++)
          {
              if(j-object.max[i-1]<=0)
                 object.dp[i][j]=object.dp[i-1][j]%1000000007;
              else
                 object.dp[i][j]=(object.dp[i-1][j]-object.dp[i-1][j-object.max[i-1]-1])%1000000007;
              if(j!=0)
                object.dp[i][j]=(object.dp[i][j]+object.dp[i][j-1]+1000000007)%1000000007;
          }
        }
        System.out.println(object.dp[child][candles]);
        sc.close();
     }
}

Measured memory_bytes: 140824
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <functional>
using namespace std;
using ll = long long;

int main() {
	double R, G;
	cin >> R;
	cin >> G;
	cout << 2 * G - R << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define int ll

int n,k;
int a[1000000];
int dp[1000000];

signed main(){
  cin>>n>>k;
  rep(i,n){
    cin>>a[i];
    dp[i]=inf;
  }

  dp[0]=0;
  rep(i,n){
    for(int j=1;j<=k&&i+j<n;j++){
      dp[i+j]=min(dp[i+j],dp[i]+abs(a[i]-a[i+j]));
    }
  }


  cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 5120
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
 
using namespace std;
 
int main(){
    string in;
    int ansj=0,ansi = 0,n=0;
    while(cin>>in){
        ansj=ansi=0;
        //if(cin.eof())break;
        for(int i=0;i<in.size()-2;i++){
            if(in[i]=='J' && in[i+1]=='O' && in[i+2]=='I')ansj++;
            if(in[i]=='I' && in[i+1]=='O' && in[i+2]=='I')ansi++;
        }
        cout <<ansj<<"\n"<<ansi<<endl;
    }
    return 0;
}

Measured memory_bytes: 1192
#include <stdio.h>
#define H 250

int main()
{
  int i,A[H],n;
  int pk,lk,rk;

  scanf("%d",&n);

  for(i=0;i<n;i++) scanf("%d",&A[i]);
  
  for(i=1;i<=n;i++){
    pk = i/2;
    lk = i*2;
    rk = lk + 1;
    printf("node %d: key = %d, ",i,A[i-1]);

    if(pk == 0); 

    else printf("parent key = %d, ",A[pk-1]);

    if(lk > n) printf("\n");

    else if(lk == n) printf("left key = %d, \n",A[lk-1]);

    else printf("left key = %d, right key = %d, \n",A[lk-1],A[rk-1]);
  }

  return 0;
}
  

  



Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
int main(){
   int n;
   cin>>n;
   int a[n];
   for(int i=0;i<n;i++){
     cin>>a[i];
   }
   int b[n];
   for(int i=0;i<n;i++){
       b[i]=a[i];


   }
   sort(b,b+n);
   int c1=0;
   for(int i=0;i<n;i++){
    if(a[i]!=b[i]){
      c1++;
    }

   }
   if(c1==2||c1==0){
    cout<<"YES"<<endl;


   }
   else
   cout<<"NO"<<endl;



}


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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long

int main() {
  int n ;
  cin >> n ;
  vector<int> v(n) , c(n) ;
  int ans1 , ans2 ;
  
  rep(i,n){
    cin >> v.at(i) ;
    c.at(i) = v.at(i) ;
  }
  sort(all(v)) ;
  ans1 = v.at((n-1)/2);
  ans2 = v.at((n+1)/2);

  
 rep(i,n){
   if(c.at(i) <= ans1)
     cout << ans2 << endl;
   
   else 
     cout << ans1 << endl;
 }
  
  
   


}


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

using namespace std;

int main() {
  string s, t;
  cin >> s >> t;

  bool flag = true;
  for (int i = 0; i < static_cast<int>(min(s.length(), t.length())); ++i)
    if (s[i] != t[i])
      flag = false;

  cout << ((flag && s.length() + 1 == t.length()) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3636
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10**9)
INF = 10**19
MOD = 10**9 + 7
EPS = 10**-10

def SCC(N, edges):
    """ 強連結成分分解 """

    nodes1 = [[] for i in range(N)]
    nodes2 = [[] for i in range(N)]
    for u, v in edges:
        nodes1[u].append(v)
        nodes2[v].append(u)

    T = []
    visited = [False] * N
    def rec1(cur):
        visited[cur] = True
        for nxt in nodes1[cur]:
            if not visited[nxt]:
                rec1(nxt)
        T.append(cur)

    for u in range(N):
        if not visited[u]:
            rec1(u)

    visited = [False] * N
    group = [0] * N
    grpnum = 0
    def rec2(cur):
        group[cur] = grpnum
        visited[cur] = True
        for nxt in nodes2[cur]:
            if not visited[nxt]:
                rec2(nxt)

    for u in reversed(T):
        if not visited[u]:
            rec2(u)
            grpnum += 1
    return grpnum, group

N, M = MAP()
edges = []
for i in range(M):
    a, b = MAP()
    edges.append((a, b))

grpnum, group = SCC(N, edges)
ans = [[] for i in range(grpnum)]
for i in range(N):
    ans[group[i]].append(i)

print(grpnum)
for i in range(grpnum):
    ans[i].insert(0, len(ans[i]))
    print(*ans[i])


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

int main() {
    string ABCD;
    cin >> ABCD;
    int num[4];
    for (int i=0; i<4; ++i) num[i] = stoi(ABCD.substr(i,1));
    char op[3];
    int ans;
    for (int i=0; i<(1<<3); ++i) {
        ans = num[0];
        for (int j=0; j<3; ++j) {
            if (i >> j & 1) {
                ans += num[j+1];
                op[j] = '+';
            } else {
                ans -= num[j+1];
                op[j] = '-';
            }
        }
        if (ans == 7) break;
    }

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

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
char str[110];
int b[110];
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<a;i++)scanf("%d",b+i);
		scanf("%s",str);
		for(int i=0;str[i];i++){
			int p=0;
			if('a'<=str[i]&&str[i]<='z')p=str[i]-'a';
			else p=str[i]-'A'+26;
			p-=b[i%a];
			if(p<0)p+=52;
			if(p<26)str[i]='a'+p;
			else str[i]='A'+p-26;
		}
		printf("%s\n",str);
	}
}

Measured memory_bytes: 1020
k=int(input())
from collections import deque
d=deque()
e=deque()

d.append(1)


d.append(2)


d.append(3)


d.append(4)


d.append(5)


d.append(6)



d.append(7)

d.append(8)


d.append(9)

cnt=0

while cnt<10**5+100:
    x=d.popleft()
    st=str(x)
    last=int(st[-1])
    if last==0:      
        e.append(x)
        d.append(10*x)
        cnt+=1
        d.append(10*x+1)
        cnt+=1

    elif last==9:
        e.append(x)
        d.append(10*x+8)
        cnt+=1
        d.append(10*x+9)
        cnt+=1

    else:
        e.append(x)
        d.append(10*x+last-1)
        cnt+=1
        d.append(10*x+last)
        cnt+=1
        d.append(10*x+last+1)
        cnt+=1
f=list(e)+list(d)
print(f[k-1])
        
        

Measured memory_bytes: 9060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  int N, K;
  cin >> N >> K;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    int tmp;
    cin >> tmp;
    if (K <= tmp) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3588
#include<stdio.h>

void maxHeapify(int i);
int n,A[2000000+1];
int main(){
  int i;
  scanf("%d",&n);
  for(i=1;i<=n;i++) scanf("%d",&A[i]);
  for(i=n/2;i>=1;i--) maxHeapify(i);
  for(i=1;i<=n;i++) printf(" %d",A[i]);
  printf("\n");
  return 0;
}

void maxHeapify(int i){
  int l,r,largest,B;
  l = 2 * i;
  r = 2 * i+1;
  if(l <= n && A[l] > A[i]) largest = l;
  else largest = i;
  
  if(r <=n && A[r] > A[largest]) largest = r;
  
  if (largest != i){
    B = A[i];
    A[i] = A[largest];
    A[largest] = B;
    maxHeapify(largest); 
  }
  
}




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

using namespace std;
typedef long long ll;

#define  input freopen("in.txt","r",stdin)
#define  output freopen("out.txt","w",stdout)

const int mxn = 1e5+5;
int arr[4][mxn];
int dp[4][mxn];

int main()
{
	//input;
	//output;

	int n;
	cin >> n;

	for(int i = 1; i <= n; i++) cin >> arr[0][i] >> arr[1][i] >> arr[2][i];

	for(int i = 1; i <= n; i++)
	{
		dp[0][i] = max(dp[1][i-1]+arr[0][i], dp[2][i-1]+arr[0][i]);
		dp[1][i] = max(dp[0][i-1]+arr[1][i], dp[2][i-1]+arr[1][i]);
		dp[2][i] = max(dp[1][i-1]+arr[2][i], dp[0][i-1]+arr[2][i]);
	}
	int ans = max(dp[0][n], max(dp[1][n], dp[2][n]));
	cout << ans << '\n';
	return 0;

}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() {
  string S;
  cin >> S;
  ll ans = 0;
  char c = S[0];
  REP(i,S.size()){
    if(c!=S[i]){
      ans++;
      c = S[i];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for(ll i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(ll i=0;i<(n);i++)
#define RREP(i,n) for(ll i=n-1;i>=0;i--)

#define PB push_back
#define INF (1<<29)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int d[5001];
int n,k;
vector< int > v[5000];
int t[5001];
int r[5001];
int dp[5000][5000];
ll c = 0;

int main(){
    memset(d,100000001,sizeof(d));
    memset(dp,d[0],sizeof(dp));
    cin >> n >> k;
    REP(i,n){
	cin >> t[i];
	cin >> r[i];
    }
    REP(i,k){
	ll a,b;
	cin >> a >> b;
	a--;
	b--;
	v[a].PB(b);
	v[b].PB(a);
    }
    queue<int> qx;
    queue<int> qr;
    dp[r[0]][0] = t[0];
    qx.push(0);
    qr.push(r[0]);
    while(!qx.empty()){
	int x = qx.front();
	int tr = qr.front();
	qx.pop();
	qr.pop();
	if(tr == 0) continue;
	REP(i,v[x].size()){
	    int nx = v[x][i];
	    if(dp[tr-1][nx] > dp[tr][x]){
		dp[tr-1][nx] = dp[tr][x];
		qx.push(nx);
		qr.push(tr-1);
	    }
	    if(dp[r[nx]][nx] > dp[tr][x] + t[nx]){
		dp[r[nx]][nx] = dp[tr][x]+t[nx];
		qx.push(nx);
		qr.push(r[nx]);
	    }
	}
    }
    int ans = d[0];
    REP(i,5000) ans = min(ans,dp[i][n-1]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 99764
<?php
$N = (int)trim(fgets(STDIN));
//$S = trim(fgets(STDIN));
//list($A,$B) = array_map('intval',explode(" ",trim(fgets(STDIN))));
//list($A,$B) = explode(" ",trim(fgets(STDIN)));
//$A = array_map('intval',explode(" ",trim(fgets(STDIN))));
//$lcnt=array(1,2,4,8,16,32,64,128);
$lcnt=array(1,3,6,10,15,21,28,36);
$p = prime_factors($N);
$pn = array_count_values($p);
$sonota=0;
$used=array();
foreach($pn as $k=>$v) {
  if ($v == 1) {
    $used[]=$v;
  }
  else {
    for($i=7;$i>=0;$i--) {
      if ($v >= $lcnt[$i]) {
         $sonota += $i+1;
         break;
      }
    }
  }
}
printf("%d\n",count($used)+$sonota);

function gcd($a,$b) {
  if ($b == 0) return $a;
  return gcd($b,$a%$b);
}
function lcm($a,$b) {
  $l = gcd($a,$b);
  return $a / $l * $b;
}

function prime_factors(int $n) {
    $i = 2;
    $factors = [];
    while ($i * $i <= $n) {
        if ($n % $i) $i += 1;
        else {
            $n /= $i;
            $factors[] = $i;
        }
    }
    if ($n > 1) $factors[] = $n;
    return $factors;
}
function is_prime(int $n) : bool {
    $r = true;
    if ($n < 2) $r = false;
    elseif ($n == 2 || $n == 3 || $n == 5) $r = true;
    elseif ($n & 1 == 0) $r = false;
    elseif ($n % 2 == 0 || $n % 3 == 0 || $n % 5 == 0) $r = false;
    else {
        $f = true;
        $v = 7;
        $m = intval($n ** 0.5) + 1;
        while ($v < $m) {
            if ($n % $v == 0) {
                $r = false;
                break;
            }
            $v += $f ? 4 : 2;
            $f = !$f;
        }
    }
    return $r;
}


Measured memory_bytes: 16300
s = list(str(input()))
t = list(str(input()))
flag = 0
for i in range(len(s)):
    sippo = s[-1]
    del s[-1]
    s.insert(0,sippo)
    #print(s)
    if s == t:
        flag = 1
        break
    else:
        continue
        
if flag:
    print("Yes")
else:
    print("No")

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

int main() {
 
  int N;
  cin >> N;
  int l[N], r[N];
  for(int i = 0; i < N; i++) {
    cin >> l[i];
    cin >> r[i];
  }
  
  int count = 0;
  for(int i = 0; i < N; i++) {
    count += r[i] - l[i] + 1;
  }
  
  cout << count << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;
//const long long int MOD = 998244353;
const double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

class UnionFind {
	vector<int>parent;
	vector<int>rank;
public:
	UnionFind(int num) {
		num++;
		parent.resize(num);
		rank.resize(num);
		for (int i = 0; i < num; i++) {
			parent[i] = i;
			rank[i] = 0;
		}
	}
	int Find(int node) {
		if (parent[node] == node)return node;
		else return parent[node] = Find(parent[node]);
	}
	void Unite(int u, int v) {
		u = Find(u);
		v = Find(v);
		if (u == v)return;
		if (rank[u] < rank[v])parent[u] = v;
		else {
			parent[v] = u;
			if (rank[u] == rank[v])rank[u]++;
		}
	}
	bool Check_Same(int u, int v) {
		return Find(u) == Find(v);
	}
};

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

	cin >> N;
	vector<int>x(N);
	vector<int>y(N);
	vector<vector<int>>h(100001);
	vector<vector<int>>w(100001);
	for (int i = 0; i < N; i++) {
		cin >> x[i] >> y[i];
		x[i]--;
		y[i]--;
		h[y[i]].push_back(x[i]);
		w[x[i]].push_back(y[i]);
	}
	UnionFind uf(200000);
	for (int i = 0; i < N; i++) {
		uf.Unite(y[i], x[i] + 100000);
	}
	for (int i = 0; i < 100000; i++) {
		for (int j = 1; j < h[i].size(); j++)uf.Unite(h[i][j] + 100000, h[i][j - 1] + 100000);
		for (int j = 1; j < w[i].size(); j++)uf.Unite(w[i][j], w[i][j - 1]);
	}
	vector<long long int>hnum(200000);
	vector<long long int>wnum(200000);
	for (int i = 0; i < 100000; i++) {
		hnum[uf.Find(i)]++;
		wnum[uf.Find(i + 100000)]++;
	}
	long long int ans = 0;
	for (int i = 0; i < 200000; i++)ans += hnum[i] * wnum[i];
	ans -= N;
	cout << ans << endl;
}

Measured memory_bytes: 13568
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>
#include<numeric>

#define PB push_back
#define all(a)  (a).begin(),(a).end()
#define ALL(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define V vector<int>
#define VV vector<V>
#define VVV vector<VV>

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int inf = (int)1e9;
const ll INF = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;

int main() {
	int n;
	cin >> n;
	int odd = 0, even = 0;
	vector<int> a(n);
	rep(i, n) {
		cin >> a[i];
		if (a[i] % 2 == 0) {
			even++;
		}
		else {
			odd++;
		}
	}
	even += odd / 2;
	odd %= 2;
	while (even / 2 > 0) {
		even = even % 2 + even / 2;
	}
	if (even + odd == 1) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

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

int main(){
   int N;
   int d[110];
   cin >> N;
   for(int i=0;i < N; i++) cin >> d[i];
   int num[110] = {0};
   for(int i=0;i<N;i++){
       num[d[i]]++;
   } 
   int res=0;
   for(int i = 1; i <= 100; i++){
       if(num[i]){
           ++res;
       }
   }
   cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(...) out(__VA_ARGS__);cout<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void out(){} template<class T,class... U> void out(T t,U ...u){cout<<t<<" ";out(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, N);
  VEC(int, a, N);

  vl v(N);
  vi ans;
  rrep(i, N, 0) {
    int c = 0;
    for (int j = i + 1; j <= N; j += i + 1) {
      c += v[j - 1];
    }
    if (a[i] ^ (c % 2)) {
      v[i] = 1;
      ans.push_back(i + 1);
    }
  }
  print(ans.size());
  each(x, ans) {
    cout << x << " ";
  }
}


Measured memory_bytes: 3832
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define n_l '\n'

#ifndef ONLINE_JUDGE
#define dbg(...) cout << "[" << #__VA_ARGS__ << "]: "; cout << to_string(__VA_ARGS__) << endl
template <typename T, size_t N> int SIZE(const T (&t)[N]){ return N; } template<typename T> int SIZE(const T &t){ return t.size(); } string to_string(const string s, int x1=0, int x2=1e9){ return '"' + ((x1 < s.size()) ? s.substr(x1, x2-x1+1) : "") + '"'; } string to_string(const char* s) { return to_string((string) s); } string to_string(const bool b) { return (b ? "true" : "false"); } string to_string(const char c){ return string({c}); } template<size_t N> string to_string(const bitset<N> &b, int x1=0, int x2=1e9){ string t = ""; for(int __iii__ = min(x1,SIZE(b)),  __jjj__ = min(x2, SIZE(b)-1); __iii__ <= __jjj__; ++__iii__){ t += b[__iii__] + '0'; } return '"' + t + '"'; } template <typename A, typename... C> string to_string(const A (&v), int x1=0, int x2=1e9, C... coords); int l_v_l_v_l = 0, t_a_b_s = 0; template <typename A, typename B> string to_string(const pair<A, B> &p) { l_v_l_v_l++; string res = "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; l_v_l_v_l--; return res; } template <typename A, typename... C> string to_string(const A (&v), int x1, int x2, C... coords) { int rnk = rank<A>::value; string tab(t_a_b_s, ' '); string res = ""; bool first = true; if(l_v_l_v_l == 0) res += n_l; res += tab + "["; x1 = min(x1, SIZE(v)), x2 = min(x2, SIZE(v)); auto l = begin(v); advance(l, x1); auto r = l; advance(r, (x2-x1) + (x2 < SIZE(v))); for (auto e = l; e != r; e = next(e)) { if (!first) { res += ", "; } first = false; l_v_l_v_l++; if(e != l){ if(rnk > 1) { res += n_l; t_a_b_s = l_v_l_v_l; }; } else{ t_a_b_s = 0; } res += to_string(*e, coords...); l_v_l_v_l--; } res += "]"; if(l_v_l_v_l == 0) res += n_l; return res; } void dbgm(){;} template<typename Heads, typename... Tails> void dbgm(Heads H, Tails... T){ cout << to_string(H) << " | "; dbgm(T...); } 
#define dbgm(...) cout << "[" << #__VA_ARGS__ << "]: "; dbgm(__VA_ARGS__); cout << endl
#endif

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define forn(i,n) for(int i=0;i<n;i++)
#define for1(i,n) for(int i=1;i<=n;i++)
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef double db;
typedef vector<vi> vvi;
const ll mod=1000000007;
const ll N=200005; //check this
int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};

ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll powb(ll a,ll b) {ll res=1;a ; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a;a=a*a;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    #ifndef ONLINE_JUDGE
    freopen("inputf.in", "r", stdin);
    freopen("outputf.in", "w", stdout);
    #endif

    int t=1;
    // cin>>t;
    while(t--){
    	ll n;cin>>n;
    	cout<<((powmod(10,n)-2*powmod(9,n)%mod +powmod(8,n))%mod+mod)%mod;
    }
}


Measured memory_bytes: 3648
N,M,K = map(int,input().split())
m = 998244353
ans = (M*pow(M-1,N-1,m))%m
alpha = 1
for k in range(1,K+1):
    alpha = (alpha*(N-k)*pow(k,m-2,m))%m
    ans = (ans + M*alpha*pow(M-1,N-k-1,m))%m
print(ans)


Measured memory_bytes: 68116
#include <iostream>

using namespace std;

int main() {
	long long h, w;
	cin >> h >> w;
	if (h == 1 || w == 1) {
		cout << 1 << endl;
	} else {
		cout << (h / 2) * w + (h % 2)* ((w / 2) + (w % 2)) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2,147,483,647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int main() {
    int n;cin>>n;
    ll sum=0;
    vector<int> A(n);
    rep(i,n){
        cin>>A[i];
        sum+=A[i];
    }
    ll lsum=0;
    ll ans=INF;
    rep(i,n-1){
        lsum+=A[i];
        ans=min(ans,abs(sum-lsum-lsum));
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
    int a,b;
    int k;
    int c = -1;
    
    scanf("%d %d",&a,&b);
    
    for (k = b*10;k <= b*10+9;k++){
        if (k*8/100 == a){
            c = k;
            break;
        }
    }
    printf("%d\n",c);
    return 0;
}


Measured memory_bytes: 128
#from copy import copy
N = int(input())
A = [int(i) for i in input().split()]
for i in range(N):
    A[i] -= i+1
A.sort()
#sum_A = copy(A)
# for i in range(1, N):
#    sum_A[i] += sum_A[i-1]
right = max(abs(max(A)), abs(min(A)))
left = -right
right += 1
ans = 0
while right-left > 2:
    middle = (right+left)//2
    m0 = 0
    m1 = 0
    for a in A:
        m0 += abs(a-middle)
        m1 += abs(a-middle-1)
    if m0 < m1:
        right = middle+1
    elif m0 == m1:
        ans = m0
        break
    else:
        left = middle+1
else:
    s1 = 0
    s2 = 0
    for a in A:
        s1 += abs(a-left)
        s2 += abs(a-left-1)
    ans = min(s1, s2)
print(ans)


Measured memory_bytes: 86868