akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a,b,e;
    e = 0;
    scanf("%d %d",&a,&b);
    while(a != 0 && b != 0){
        for(int c = 0 ; a > c ; c ++){
            for(int d = 0 ; b > d ; d++){
                if(c % 2 == 0){
                    if(e % 2 == 0){
                        printf("#");
                        e++;
                    }else{
                        printf(".");
                        e++;
                    }
                }else{
                    if(e % 2 == 0){
                        printf(".");
                        e++;
                    }else{
                        printf("#");
                        e++;
                    }
                }
            }
            printf("\n");
            e = 0;
        }
        printf("\n");
        scanf("%d %d",&a,&b);
    }
    return 0;
}



Measured memory_bytes: 2040
#include <bits/stdc++.h>
using namespace std;
#define INF 0x7fffffff
#define PI acos(-1.0)
#define MOD 2520
#define E 1e-12
using namespace std;
typedef long long ll;
const int MAXN=500000+5;//最大元素个数
char ans[MAXN]; 
 string s;
   int n;
int solve(char ch1,char ch2)
{
  ans[0]=ch1;
  ans[1]=ch2;
  for(int i=1;i<n;i++)
  {
  	if(s[i]=='o')
	{
		if(ans[i]=='S')
		ans[i+1]=ans[i-1];
		else
		{
			if(ans[i-1]=='W')
		    ans[i+1]='S';
		    else
			ans[i+1]='W';
		}
	}
	else  if(s[i]=='x')
	{
		if(ans[i]=='W')
		ans[i+1]=ans[i-1];
		else
		{
			if(ans[i-1]=='W')
		    ans[i+1]='S';
		    else
			ans[i+1]='W';
		}
	}
  }
  char temp;
    if(s[0]=='o')
    {
    	if(ans[0]=='S')
    		temp=ans[1];
		else
		{
			if(ans[1]=='W')
		    temp='S';
		    else
			temp='W';
		}
    }
    else
	{
		if(ans[0]=='W')
    		temp=ans[1];
		else
		{
			if(ans[1]=='W')
		    temp='S';
		    else
			temp='W';
		}
	}
    if(ans[n]==ans[0]&&temp==ans[n-1]) return 1;
    else return 0;
  	
}
int main()
{
  
    scanf("%d",&n);
   
    cin>>s;
    if(solve('S','S')==1)
	{
		
		for(int i=0;i<n;i++)
			cout<<ans[i];
		//cout<<ans<<endl;
	}
	else if(solve('S','W')==1)
	{
		for(int i=0;i<n;i++)
			cout<<ans[i];
		//cout<<ans<<endl;
	}
	else if(solve('W','S')==1)
	{
		for(int i=0;i<n;i++)
			cout<<ans[i];
		//cout<<ans<<endl;
	}
	else if(solve('W','W')==1)
	{
		for(int i=0;i<n;i++)
			cout<<ans[i];
		//cout<<ans<<endl;
	}
	else
	{
		cout<<-1<<endl;
	}
    return 0;
}


Measured memory_bytes: 640
a,b,c,d = map(int, input().split())
if b<=c or d <= a :
    print(0)
    
elif c<=b:
    if c <= a and b<=d:
        print(b-a)
    elif a<= c and b<=d:
        print(b-c)
    elif a<=c and d<=b:
        print(d-c)
    elif c<=a and d<=b:
        print(d-a)

Measured memory_bytes: 3060
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
from decimal import Decimal
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,l = inpl()
s = [input() for _ in range(n)]
s.sort()
L = ''
for i in s:
    L += i
print(L)

Measured memory_bytes: 63980
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ld = long double;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.precision(10);
	cout << fixed;
	int m1, d1;
	int m2, d2;
	cin >> m1 >> d1 >> m2 >> d2;
	cout << (m1 != m2) << '\n';
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace         std;
#define                 int long long
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<endl
#define                 real signed
#define                 endl '\n'              
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;
#define forn(i,a,b)     for(int i=a;i<=b;i++)
#define rfor(i,a,b)     for(int i=a;i>=b;i--)
#define all(x)          x.begin() , x.end()
#define pi pair<int,int>
#define X first
#define Y second
#define N 314159
#define  vi vector<int>
#define  v  vector

signed main() 
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
     string s;
     int k;
     cin>>s>>k;
     int n=s.size();
     set<string>dc;
     forn(i,1,k)
     {
         forn(j,0,n-i)
            dc.insert(s.substr(j,i));
     }
     
     int d=1;
     
     for(auto i : dc)
     {
         if(d==k)cout<<i;
         d++;
     }




     return 0;

}

//       g++ -g c.cpp ; ./a.exe

Measured memory_bytes: 1664
N ,X, Y = map(int, input().split())
 
X -= 1
Y -= 1
k = [0]*N
 
for i in range(N-1):
    for j in range(i+1, N):
        a = j-i
        b = abs(i-X)+1+abs(Y-j)
        m =  min(a, b)
        k[m] += 1
 
for i in range(1, N):
    print(k[i])

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

int main(){
    int N;
    int L[10002];
    long long ans = 0;

    cin >> N;
    for(int i=0;i<N;i++) cin >> L[i];
    sort(L, L+N);
    // for(int i=0;i<N;i++) cout << L[i] << " ";
    // cout << endl;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            auto k = lower_bound(L+j+1, L+N, L[i]+L[j]);
            long long temp = (k-L) - (j+1);
            ans += temp;
            // cout << L[i] << " " <<  L[j] << " " << temp << endl;
            // cout << max(0LL, temp) << endl;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N;
vector<int> x, y;
double const eps = 1e-10;

double g(double X, double Y) {
    double ret = 0;
    for(int i=0; i<N; ++i) {
        ret = max(ret, sqrt((x[i] - X) * (x[i] - X) + (y[i] - Y) * (y[i] - Y)));
    }
    return ret;
}

double f(double X) {
    double yl = 0, yr = 1000;
    while(yr - yl > eps) {
        double left = (2 * yl + yr) / 3;
        double right = (2 * yr + yl) / 3;
        if(g(X, left) > g(X, right) + eps) yl = left;
        else yr = right;
    }
    return yl;
}

double solve() {
    double xl = 0, xr = 1000;
    while(xr - xl > eps) {
        double left = (2 * xl + xr) / 3;
        double right = (2 * xr + xl) / 3;
        if(g(left, f(left)) > g(right, f(right)) + eps) xl = left;
        else xr = right;
    }
    return g(xl, f(xl));
}

int main() {
    cin >> N;
    x.resize(N); y.resize(N);
    for(int i=0; i<N; ++i) cin >> x[i] >> y[i];
    cout << fixed << setprecision(10) << solve() << endl;
}

Measured memory_bytes: 256
import sys
n=int(input())
a=list(map(int,input().split()))
sum=1
for i in range(n):
    if a[i]==0:
        print(0)
        sys.exit()
for i in a:
    sum*=i
    if sum>1000000000000000000:
        print(-1)
        sys.exit()
else:
    print(sum)

Measured memory_bytes: 21632
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

 
int main(){
  int h,w; cin >> h >> w;
  vector<vector<char>> data(60, vector<char>(60,'.'));
  for(int i=1; i<=h; i++){for(int j=1; j<=w; j++){
    cin >> data[i][j];
  }}
  for(int i=1; i<=h; i++){for(int j=1; j<=w; j++){
    if(data[i][j]=='#'){
      if(data[i+1][j]!='#'&&data[i-1][j]!='#'&&data[i][j+1]!='#'&&data[i][j-1]!='#'){
        cout << "No" << endl; return 0;
      }
    }
  }}
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

long int inv(long int x){
  long int j[30],y,k;
  j[0]=x%1000000007;
  for(k=1;k<=29;k++){
    j[k]=(j[k-1]*j[k-1])%1000000007;
  }
  y=(j[0]*j[2])%1000000007;
  y=(y*j[9])%1000000007;
  y=(y*j[11])%1000000007;
  y=(y*j[14])%1000000007;
  y=(y*j[15])%1000000007;
  y=(y*j[17])%1000000007;
  y=(y*j[19])%1000000007;
  y=(y*j[20])%1000000007;
  y=(y*j[23])%1000000007;
  y=(y*j[24])%1000000007;
  y=(y*j[25])%1000000007;
  y=(y*j[27])%1000000007;
  y=(y*j[28])%1000000007;
  y=(y*j[29])%1000000007;
  
  if(y<0){
    y=1000000007+y;
  }
  return y;
}

long int power(long int X,long int Y){
  int digit2[100];
  long int XX[100];
  int I,N;
  long int mod;
  I=0;
  
  while(Y!=0){
    digit2[I]=Y%2;
    Y=Y/2;
    I++;
  }
  N=I;
  
  XX[0]=X%1000000007;
  for(I=1;I<N;I++){
    XX[I]=(XX[I-1]*XX[I-1])%1000000007;
  }
  
  mod=1;
  for(I=0;I<N;I++){
    if(digit2[I]==1){
      mod=(mod*XX[I])%1000000007;
    }
  }
  
  if(mod<0){
    mod=mod+1000000007;
  }
  
  return mod;
}

int main(void){
  long int n,a,b;
  scanf("%ld%ld%ld",&n,&a,&b);
  
  long int p,ca,cb;
  long int i;
  p=1;
  ca=1;
  
  p=power(2,n);
  
  for(i=1;i<=a;i++){
    ca=(((ca*(n-i+1))%1000000007)*inv(i))%1000000007;
  }
  cb=ca;
  for(i=a+1;i<=b;i++){
    cb=(((cb*(n-i+1))%1000000007)*inv(i))%1000000007;
  }
  
  long int ans;
  ans=(p-ca-cb-1)%1000000007;
  if(ans<0){
    ans=ans+1000000007;
  }
  
  printf("%ld",ans);
  
  return 0;
}


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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  if (A > B) {
    if (A > C && C > B) {
      cout << "Yes";
    }
    else {
      cout << "No";
    }
  }
  else {
    if (B > C && C > A) {
      cout << "Yes";
    }
    else {
      cout << "No";
    }
  }
}


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

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

  if (x <= 599) cout << 8 << endl;
  else if (x <= 799) cout << 7 << endl;
  else if (x <= 999) cout << 6 << endl;
  else if (x <= 1199) cout << 5 << endl;
  else if (x <= 1399) cout << 4 << endl;
  else if (x <= 1599) cout << 3 << endl;
  else if (x <= 1799) cout << 2 << endl;
  else if (x <= 1999) cout << 1 << endl;

}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define rep(i,a,n) for (int i = a; i < n; i++)
#define per(i,n,a) for (int i = n - 1; i >= a; i--)
using namespace std;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define dbg(x) cout<<#x<<" = "<<x<<endl
#define dbg2(x,y) cout<<#x<<" = "<<x<<", "<<#y<<" = "<<y<<endl
#define dbg3(x,y,z) cout<<#x<<" = "<<x<<", "<<#y<<" = "<<y<<", "<<#z<<" = "<<z<<endl
#define dbg4(x,y,z,q) cout<<#x<<" = "<<x<<", "<<#y<<" = "<<y<<", "<<#z<<" = "<<z<<", "<<#q<<" = "<<q<<endl
#define dbg_array(x,sz) for (int i = 0; i < sz; ++i) cout << x[i] << " \n"[i==sz-1]
using namespace std;

const ll N = 100 + 9, M = 400 - 9, Max_ans = 1LL * (1e16);
int a[N];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
#ifdef ECLIPSE
	freopen("input.in", "rt", stdin);
	//freopen("output.out", "wt", stdout);
#endif
	int n, cnt = 0;
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		if (i % 2 && a[i] % 2)
			++cnt;
	}
	printf("%d\n", cnt);
	return 0;
}



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

int main(){
    int N;
    ll K;
    cin >> N >> K;
    vector<int> A(N),B(N);

    for(int i = 0; i < N; i++){
        cin >> A[i] >> B[i];
    }
    
    //C++ int2つの型
    vector<pair<int,int>> AB(N);
    for(int i = 0; i < N; i++){
        AB[i] = make_pair(A[i],B[i]);
    }
    sort(AB.begin(),AB.end());

    ll sum = 0;
    for(int i = 0; i < N; i++){
        sum += AB[i].second;
        if(sum >= K){
            cout << AB[i].first << endl;
            return 0;
        }
    }

    return 1;
}

Measured memory_bytes: 1792
# -coding: utf-8 -

n = int(input())
d, x = map (int, input().split())
a = ["" for _ in range(n)]
for i in range(n):
    a[i] = int(input())

def countit(a):
    c = 1
    n = 1
    while(True):
        if (n*a+1) <= d:
            c += 1
            n += 1
        else:
            break
    return c

ans = []
for i in a:
    ans.append(countit(i))

print(x + sum(ans))

    


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
using namespace std;
typedef pair<int,int> pii;
#define mp(a,b)	make_pair(a,b)
#define fst first
#define scn second


bool edge[50][50][4];
int dist[50][50];
const int dx[]={1,0,-1,0};
const int dy[]={0,1,0,-1};
const int inf=1e9;
int main(){
	while(true){
		int w,h;	cin>>w>>h;
		if(w==0)	break;
		for(int i=0;i<50;i++)	for(int j=0;j<50;j++){
			for(int k=0;k<4;k++)	edge[i][j][k]=false;
			dist[i][j]=inf;
		}
		for(int i=1;i<w;i++){
			int c;	cin>>c;
			if(c==0)	edge[0][i-1][0]=edge[0][i][2]=true;
		}
		for(int i=1;i<h;i++){
			for(int j=0;j<w;j++){
				int c;	cin>>c;
				if(c==0)	edge[i-1][j][1]=edge[i][j][3]=true;
			}
			for(int j=1;j<w;j++){
				int c;	cin>>c;
				if(c==0)	edge[i][j-1][0]=edge[i][j][2]=true;
			}
		}
		dist[0][0]=1;
		priority_queue<pair<int,pii> > pq;
		pq.push(mp(-1,mp(0,0)));
		while(!pq.empty()){
			auto it=pq.top();	pq.pop();
			int d=-it.fst;
			int y=it.scn.fst;
			int x=it.scn.scn;
			if(dist[y][x]<d)	continue;
			d++;
			for(int i=0;i<4;i++){
				if(!edge[y][x][i])	continue;
				if(dist[y+dy[i]][x+dx[i]]>d){
					dist[y+dy[i]][x+dx[i]]=d;
					pq.push(mp(-d,mp(y+dy[i],x+dx[i])));
				}
			}
		}
		if(dist[h-1][w-1]==inf)	dist[h-1][w-1]=0;
		cout<<dist[h-1][w-1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3124
import sys
def input():
	return sys.stdin.readline().strip()

S = input()

S_list = ["AKIHABARA", "AKIHABAR", "AKIHABRA", "AKIHABR", "AKIHBARA", "AKIHBAR", "AKIHBRA", "AKIHBR",
		  "KIHABARA", "KIHABAR", "KIHABRA", "KIHABR", "KIHBARA", "KIHBAR", "KIHBRA", "KIHBR"]

if S in S_list:
	print("YES")
else:
	print("NO")

Measured memory_bytes: 38384
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

int main()
{
	int n;
	cin >> n;
	int p[30];
	for(int i = 0; i < n; i++){
		cin >> p[i];
	}
	int ans = 0;
	for(int i = 1; i < n - 1; i++){
		if((p[i - 1] < p[i] && p[i] < p[i + 1]) || (p[i - 1] > p[i] && p[i] > p[i + 1])) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import sys
def input():
	return sys.stdin.readline()[:-1]

n, m = map(int, input().split())
adj = [[] for _ in range(n)]
for _ in range(m):
	u, v = map(int, input().split())
	adj[u-1].append(v-1)
	adj[v-1].append(u-1)

visited = [-1 for _ in range(n)]
even, odd = 0, 0

def dfs(start):
	global even, odd
	odd_loop = False
	stack = [(start, -1)]
	while stack:
		x, p = stack.pop()
		for v in adj[x]:
			if v == p:
				continue
			elif visited[v] == -1:
				visited[v] = 1^visited[x]
				stack.append((v, x))
			elif visited[v] != 1^visited[x]:
				odd_loop = True

	if odd_loop:
		odd += 1
	else:
		even += 1
	return

alone = 0
for i in range(n):
	if not adj[i]:
		alone += 1
	elif visited[i] == -1:
		visited[i] = 0
		dfs(i)

ans = 2*even + odd + 2*even*(even-1) + 2*even*odd + odd*(odd-1)
ans += alone*(2*n-alone)

print(ans)

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

int main(){
    string s[3];
    cin >> s[0] >> s[1] >> s[2];

    int base = 0;
    char ans, c;
    while(1){
        if(s[base].size()==0){
            ans = c;
            break;
        }
        c = s[base][0];
        s[base].erase(s[base].begin());
        base = c - 'a';
    }

    cout << (char)(ans - ('a' - 'A')) << endl;

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int com(int n) {
    if(n <= 1) {
        return 0;
    }
    return n * (n - 1) / 2;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    cout << com(n) + com(m) << endl;
}

Measured memory_bytes: 256
from math import ceil
N = int(input())
b = []
c = []

for i in range(N):
    A,B = map(int,input().split())
    b.append(B)
    c.append(-1*(A+B))

c.sort()
ans = 0 
for i in range(ceil(N/2)):
    ans -= c[2*i]

ans -= sum(b)
print(ans)

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

int main(){
  
  int n,k;
  cin>>n>>k;
  vector<int> cnt(n+1);
  for(int i=0;i<k;i++){
   int d;
    cin>>d;
    for(int j=0;j<d;j++){
     int x;
      cin>>x;
      cnt[x] += 1;
    }
  }
  int ans = 0;
  for(int i=1;i<n+1;i++){
   if(cnt[i] < 1)
     ans += 1;
  }
  cout<<ans<<endl;
  
  
  
 return 0; 
  
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;bool flag=1;
	cin>>n;
	for(int i=1;i<=n;i++){
		int t,x,y;
		cin>>t>>x>>y;
		if(t<x+y) flag=0;
		if((t-x-y)%2) flag=0;
	}
	if(flag) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


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

int main(){
	long long x;
	cin >> x;
	long long a=100;
	long long count=0;
	while(a<x){
		a*=1.01;
		count++;
      if(a>=x)break;
	}
	cout<<count<<endl;
	return 0;
}

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



vector<int> dfs(string nish,int n)
{
    int siz=nish.size();
    vector<int>res(siz);
    for(int i=0;i<siz;i++)
    {
        if(nish[i]!='x')
            res[i]=(i-n-1>=0?res[i-n-1]:0)+1;
        if(i>0)
            res[i]=max(res[i],res[i-1]);
    }
    return res;
}

int main()
{


    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   
    int t,m,n;
    cin>>t>>m>>n;
    string nish;
    cin>>nish;
    vector<int>stra=dfs(nish,n);
    reverse(nish.begin(),nish.end());
    vector<int>back=dfs(nish,n);
    reverse(back.begin(),back.end());



    for(int i=0;i<t;i++)
    {
        int l=i>0?stra[i-1]:0;
        int r=i+1<t?back[i+1]:0;
        if(l+r+1==m)
            cout<<i+1<<endl;
    }
    

return 0;

}

Measured memory_bytes: 3536
N = int(input())
NK = list(map(int, input().split()))
Key = N
for i in range(N):
    if N != Key:
            break
    elif NK[i] % 2 == 0:
        if NK[i] % 3 == 0 or NK[i] % 5 == 0:
            continue
        else:
            N -= 1
            break
    else:
        continue
    
if N == Key:
    print("APPROVED")
elif N != Key:
    print("DENIED")


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

int main () {
  int N;	cin >> N;
  int a[110000], odd =0;
  for (int i=0; i<N; i++)
  {
    cin >>a [i];
    odd = odd + a[i] % 2;
  }
    
    if (odd %2 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
#define f first
#define s second
#define pb push_back
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int h, w, k, ans = 100000, sec[11], tosec[11];
int grid[11][1005];

int main() {
	fastio; cin >> h >> w >> k;
	FOR(i, 1, h) FOR(j, 1, w) {
		char x; cin >> x;
		if (x == '1') grid[i][j] = 1;
		else grid[i][j] = 0;
	}
	FOR(i, 0, (1<<h)-1) {
		memset(sec, 0, sizeof sec);
		memset(tosec, 0, sizeof tosec);
		tosec[1] = 1; int c = 1;
		FOR(j, 2, h) {
			if (i & (1<<(j-2))) c++;
			tosec[j] = c;
		}
		int cuts = c - 1;
		FOR(j, 1, w) {
			int sum[11]; memset(sum, 0, sizeof sum);
			FOR(l, 1, h) {
				sec[tosec[l]] += grid[l][j];
				sum[tosec[l]] += grid[l][j];
			}
			bool okok = true;
			FOR(l, 1, h) if (sum[tosec[l]] > k) {cuts = 100000; okok = false;}
			if (!okok) break;
			bool ok = true;
			FOR(l, 1, h) if (sec[tosec[l]] > k) ok = false;
			if (!ok) {
				memset(sec, 0, sizeof sec);
				cuts++; j--;
			}
		}
		ans = min(ans, cuts);
	}
	cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MN 100100
#define MOD 1000000007
typedef long long int ll;
#define pb push_back
#define mp make_pair
using namespace std;
struct Edge{
    int u,v;
   ll d;
    Edge(int u,int v,ll d):u(u),v(v),d(d){}
};
int n,m,s,t;
const ll INF = 1e17;
vector<pair<int,ll> > adj[MN];
vector<Edge> edges;
ll d1[MN],d2[MN],dp1[MN],dp2[MN];
bool check[MN];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m >> s >> t;
    for(int i=0;i<m;i++){
        int u,v;
        ll d;
        cin >> u >> v >> d;
        adj[u].pb(mp(v,d));
        adj[v].pb(mp(u,d));
        edges.pb(Edge(u,v,d));
    }
    for(int i=1;i<=n;i++) d1[i] = INF;
    for(int i=1;i<=n;i++) d2[i] = INF;
    priority_queue<pair<ll,int> > q;
    d1[s] = 0;
    q.push(mp(0,s));
    while(!q.empty()){
        pair<ll,int> p = q.top();
        q.pop();
        int x = p.second;
        if(check[x]) continue;
        check[x] = true;
        for(int i=0;i<adj[x].size();i++){
            int nxt = adj[x][i].first;
            if(d1[nxt]>(d1[x]+adj[x][i].second)){
                d1[nxt] = d1[x]+adj[x][i].second;
                q.push(mp(-d1[nxt],nxt));
            }
        }
    }
    d2[t] = 0;
    for(int i=1;i<=n;i++) check[i] = false;
    q.push(mp(0,t));
     while(!q.empty()){
        pair<ll,int> p = q.top();
        q.pop();
        int x = p.second;
        if(check[x]) continue;
        check[x] = true;
        for(int i=0;i<adj[x].size();i++){
            int nxt = adj[x][i].first;
            if(d2[nxt]>(d2[x]+adj[x][i].second)){
                d2[nxt] = d2[x]+adj[x][i].second;
                q.push(mp(-d2[nxt],nxt));
            }
        }
    }
    dp1[s] = 1;
    for(int i=1;i<=n;i++) q.push(mp(-d1[i],i));
    while(!q.empty()){
        pair<ll,int> p = q.top();
        q.pop();
        int x = p.second;
        for(int i=0;i<adj[x].size();i++){
            int nxt = adj[x][i].first;
            if((d1[x]+adj[x][i].second)==d1[nxt]) dp1[nxt] = (dp1[x]+dp1[nxt])%MOD;
        }
    }
    dp2[t] = 1;
    for(int i=1;i<=n;i++) q.push(mp(-d2[i],i));
    while(!q.empty()){
        pair<ll,int> p = q.top();
        q.pop();
        int x = p.second;
        for(int i=0;i<adj[x].size();i++){
            int nxt = adj[x][i].first;
            if((d2[x]+adj[x][i].second)==d2[nxt]) dp2[nxt] = (dp2[x]+dp2[nxt])%MOD;
        }
    }
    ll ans = (dp1[t]*dp1[t])%MOD;
    for(int i=1;i<=n;i++){
        if((2*d1[i])==d1[t] && d1[i]==d2[i]){
            ans = (ans+MOD-((((((dp1[i]*dp1[i])%MOD)*dp2[i])%MOD)*dp2[i])%MOD))%MOD;
        }
    }
    for(int i=0;i<m;i++){
            int x = edges[i].u;
            int y = edges[i].v;
        if((2*d1[x])<(d1[t]) && (2*d2[y])<d1[t] && (d1[x]+d2[y]+edges[i].d)==d1[t]){
                ans = (ans+MOD-((((((dp1[x]*dp1[x])%MOD)*dp2[y])%MOD)*dp2[y])%MOD))%MOD;

        }
        if((2*d1[y])<(d1[t]) && (2*d2[x])<d1[t] && (d1[y]+d2[x]+edges[i].d)==d1[t]){
                ans = (ans+MOD-((((((dp1[y]*dp1[y])%MOD)*dp2[x])%MOD)*dp2[x])%MOD))%MOD;
        }
    }
    cout << ans << '\n';
    return 0;
}
    

Measured memory_bytes: 23916
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <cstring>
#include <queue>
#include <iomanip>
#include <numeric>
#include <cmath>

using namespace std;

//#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

typedef long long ll;

//static const ll MOD = 1000000007;

int main() {
    ll N, K, Q;
    vector<ll> A;

    // input
    cin >> N >> K >> Q;
    for (ll i = 0; i < Q; i++) {
        ll input;
        cin >> input;
        A.emplace_back(input - 1);
    }

    // process
    ll point[N];
    memset(point, 0, sizeof(point));

    for (ll i = 0; i < Q; i++) {
        point[A[i]]++;
    }

    for (ll i = 0; i < N; i++) {
        if (K - Q + point[i] > 0) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 2292
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
#define debug puts("wzpakking")
#define y1 ysghysgsygsh
using namespace std;
const int N=200005;
struct edge{
	int to,next,v;
}e[N*2];
struct Edge{
	int x,y; ll v;
	bool operator <(const Edge &a)const{
		return v<a.v;
	}
}E[N*2];
int n,tot,top,fav[N];
int a[N],head[N],fa[N];
pll f[N];
void add(int x,int y,int v){
	e[++tot]=(edge){y,head[x],v};
	head[x]=tot;
}
void dfs1(int x){
	//cout<<x<<endl;
	f[x]=pll(a[x],x);
	for (int i=head[x];i;i=e[i].next)
		if (e[i].to!=fa[x]){
			fa[e[i].to]=x;
			fav[e[i].to]=e[i].v;
			dfs1(e[i].to);
			if (f[e[i].to].fi+e[i].v<f[x].fi)
				f[x]=f[e[i].to],f[x].fi+=e[i].v;
		}
}
void dfs2(int x){
	for (int i=head[x];i;i=e[i].next)
		if (e[i].to!=fa[x]){
			if (f[x].fi+e[i].v<f[e[i].to].fi)
				f[e[i].to]=f[x],f[e[i].to].fi+=e[i].v;
			dfs2(e[i].to);
		}
}
int get(int x){
	return x==fa[x]?x:fa[x]=get(fa[x]);
}
int main(){
	scanf("%d",&n);
	For(i,1,n) scanf("%d",&a[i]);
	For(i,1,n-1){
		int x,y,v;
		scanf("%d%d%d",&x,&y,&v);
		add(x,y,v); add(y,x,v);
	}
	dfs1(1); dfs2(1);
	For(i,1,n) E[++top]=(Edge){i,f[i].se,f[i].fi+a[i]};
	For(i,2,n) E[++top]=(Edge){f[i].se,f[fa[i]].se,f[i].fi+f[fa[i]].fi+fav[i]};
	sort(E+1,E+top+1);
	For(i,1,n) fa[i]=i;
	ll ans=0;
	For(i,1,top){
		//cout<<E[i].x<<' '<<E[i].y<<' '<<E[i].v<<endl;
		int x=get(E[i].x);
		int y=get(E[i].y);
		if (x!=y){
			fa[x]=y;
			ans+=E[i].v;
		}
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 29952
def a_thumbnail(N, A):
    ave_x_n = sum(A)
    a = [abs(i * N - ave_x_n) for i in A]  # 小数の計算をしたくない
    ans = a.index(min(a))
    return ans

N = int(input())
A = [int(i) for i in input().split()]
print(a_thumbnail(N, A))

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
 
#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

int main(int argc, char **argv){
	std::string str;
	std::string buf;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
#endif

#if INPUT_FROM_FILE
	while(std::getline(ifs, buf)){
#else
	while(std::getline(std::cin, buf)){
#endif
		str = buf;


		for(int i = 1; i <= 26; i++){
			for(int j = 0; j < str.size(); j++){
				unsigned char c = str[j];

				if(c >= 'a' && c <= 'z'){
					if(c == 'z'){
						c = 'a';
					}
					else{
						c++;
					}
				}
				str[j] = c;
			}

			std::istringstream stream(str);
			while(stream >> buf){
				if(buf == "the" || buf == "this" || buf == "that"){
					i = 27;
					break;
				}
			}
		}
		std::cout << str << std::endl;
	}
	return 0;
}


Measured memory_bytes: 2980
#include<stdio.h>
int main() {
	int n, m,t,a;
	int num;
	int h[100003] = {};
	scanf("%d%d%d", &n,&t,&a);
	t *= 1000;
	a *= 1000;
	int min = 200000000;
	for (int i = 1; i <= n; i++) {
		scanf("%d", &h[i]);
		if (t - 6 * h[i]-a >= 0) {
			m = t - 6 * h[i] - a;
		}
		else {
			m = -(t - 6 * h[i] - a);
		}
		if (m <= min) {
			min = m;
			num = i;
		}
	}
	printf("%d", num);
}

Measured memory_bytes: 512
import string
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


def n_to_alp(n):
    if n <= 26:
        return chr(64 + n)
    elif n % 26 == 0:
        return n_to_alp(n // 26-1) + chr(90)
    else:
        return n_to_alp(n // 26) + chr(64 + n % 26)


n = I()
m = 1
i = 0

print(n_to_alp(n).lower())


Measured memory_bytes: 9908
#include <iostream>
#include <cmath>

using namespace std;

int memo[4096];
int C[12];
int A[12][12];

int main () {
  int N, M, X;
  int ans = -1;

  cin >> N >> M >> X;
  for (int i=0; i<N; i++) {
    cin >> C[i];
    for (int j=0; j<M; j++) {
      cin >> A[i][j];
    }
  }
  for (int i=0; i<4096; i++) {
    memo[i]=0;
  }

  for (int i=0; i < (int)pow(2,N); i++) {
    int check[12];
    int cost=0;

    for (int j=0; j<M; j++) {
      check[j] = 0;
    }

    for (int j=0; j<N; j++) {
      if (i & (1 << j)) {
        cost += C[j];
        for (int k=0; k<M; k++)
          check[k] += A[j][k];
      }
    }

    bool flag = true;
    for (int k=0; k<M; k++){
      if(check[k] < X) {
        flag = false;
        break;
      }
    }
    if (flag && (ans < 0 || ans > cost)) {
      ans = cost;
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4080
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    cin >> N;
    int H[100000];
    for(int i=0;i<N;i++)
        cin >> H[i];

    int ans = 0, count = 0;
    for(int i=1;i<N;i++){
        if(H[i] > H[i-1]){
            if(count > ans)
                ans = count;
            count = 0;
        }else{
            count++;
        }
    }
    if(count > ans)
        ans = count;
    
    cout << ans << endl;

}

Measured memory_bytes: 640
import Data.List

main :: IO ()
main = do
  ss <- getParams
  print $ solve ss

getParams :: IO [String]
getParams = tail . lines <$> getContents

solve :: [String] -> Int
solve ss = sum $ map numIJs groups
  where numIJs g = sum [1..length g - 1]
        groups   = group $ sort sorteds
        sorteds  = map sort ss


Measured memory_bytes: 112892
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

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

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

    int ans = a[0];

    for(int i = 1; i < n; i++){
        ans = ans ^ a[i];
    }

    if(ans == 0){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


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

int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	printf(a==b&&b!=c||b==c&&c!=a||c==a&&a!=b?"Yes\n":"No\n");
	return 0;
}

Measured memory_bytes: 256
#pragma region

#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define _rep3(i, begin, end) for (register int i = (begin), i##_end = (end); i < i##_end; i++)
#define _irep3(i, begin, end) for (register int i = (end)-1, i##_begin = (begin); i >= i##_begin; i--)
#define _rep2(i, n) _rep3(i, 0, n)
#define _irep2(i, n) _irep3(i, 0, n)
#define _overload3(_1, _2, _3, name, ...) name
#define rep(...) _overload3(__VA_ARGS__, _rep3, _rep2, )(__VA_ARGS__)
#define irep(...) _overload3(__VA_ARGS__, _irep3, _irep2, )(__VA_ARGS__)
#define out(x) cout << (x) << '\n';
#define debug(x) cerr << #x << " = " << (x) << " (line: " << __LINE__ << ") " << endl;

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<long long>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<long long>>;
using vvb = vector<vector<bool>>;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &pair) {
  cin >> pair.first >> pair.second;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[ ";
  rep(i, vec.size()) i == 0 ? os << vec[i] : os << ", " << vec[i];
  os << " ]";
  return os;
}

template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

void init() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(16) << boolalpha;
}

#pragma endregion

#define MOD 1000000007
#define INF 2147483647

class UnionFind {
 private:
  vector<int> _par, _size;

 public:
  UnionFind(int N) : _par(N), _size(N, 1) {
    for (int i = 0; i < N; i++) _par[i] = i;
  }

  int root(int x) {
    return _par[x] == x ? x : _par[x] = root(_par[x]);
  }

  bool unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return false;
    if (_size[x] < _size[y]) swap(x, y);
    _size[x] += _size[y];
    _par[y] = x;
    return true;
  }

  bool is_same(int x, int y) {
    return root(x) == root(y);
  }

  int size(int x) {
    return _size[root(x)];
  }
};

int main() {
  init();

  int N, M, K;
  cin >> N >> M >> K;

  UnionFind uf(N);
  vvi friends(N), blocks(N, vi(0));
  int A, B;
  rep(i, M) {
    cin >> A >> B;
    uf.unite(A - 1, B - 1);
    friends[A - 1].push_back(B - 1);
    friends[B - 1].push_back(A- 1);
  }
  rep(i, K) {
    cin >> A >> B;
    blocks[A - 1].push_back(B - 1);
    blocks[B - 1].push_back(A - 1);
  }

  rep(i, N) {
    int ans = uf.size(i) - friends[i].size() - 1;
    rep(j, blocks[i].size()) {
      if (uf.is_same(blocks[i][j], i)) ans--;
    }
    if (i != 0) cout << ' ';
    cout << ans;
  }
  cout << endl;
}


Measured memory_bytes: 12664
#include<stdio.h>
int main(void)
{
    int a,b;
    scanf("%d",&a);
    scanf("%d",&b);
    if(a < b)
    {
    printf("a < b\n");
    }
    else if(a == b)
    {
    printf("a == b\n");
    }
    else
    {
    printf("a > b\n");
    }
    return 0;
}



Measured memory_bytes: 2680
N,M=map(int,input().split())
Islands=[[10**9]*N for i in range(N)]
Edge=[]
S=0
for i in range(M):
  a,b,c=map(int,input().split())
  Islands[a-1][b-1]=c
  Islands[b-1][a-1]=c
  Edge.append([a-1,b-1,c])
for k in range(N):
  for i in range(N):
    for j in range(N):
      Islands[i][j]=min(Islands[i][j],Islands[i][k]+Islands[k][j])

ans=0
for a,b,c in Edge:
  if Islands[a][b]!=c:
    ans+=1
print(ans)

Measured memory_bytes: 3444
D,G = map(int,input().split())

p = [0] * (D+1)
c = [0] * (D+1)

for i in range(1,D+1):
    p[i],c[i] = map(int,input().split())

#print(p,c)
can = []
for k in range(2 ** D):
    x = [0] * (D+1)
    kk = k
    score = [0] * (D+1)
    count = 0
    for j in range(1,D+1):
        x[j] = kk % 2
        kk //= 2
        score[j] = x[j] * (j * p[j] + c[j]//100)
        count += x[j] * p[j]
    s = sum(score)
    deffer = G//100 - s
    num = D
    left = p[:]
    while deffer > 0 and num > 0:
        if x[num] == 1 or left[num] == 1:
            num -= 1
        else:
            deffer -= num
            left[num] -= 1
            count += 1
    if deffer <= 0:
        #print(x,count,score)
        can.append(count)

print(min(can))  

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
int main()
{
    int x,i,j,flag=1;
    scanf("%d\n",&x);
    char s[x];
    gets(s);
    for(i=0,j=i+1;i<x,j<x;i++,j++)
    {

        if(s[i]!=s[j])
          {
            flag++;
          }

    }
    printf("%d",flag);
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <bitset>

using namespace std;
typedef long long ll;

#define PI 3.141592653589793236

int main() {
	double a, b, x; cin >> a >> b >> x;
	double c = a * a;

	if (x * 2 > c * b) {
		double y = (b * c - x) / c * 2;
		cout << setprecision(15) << atan2(y, a) * 180 / PI << endl;
	}
	else {
		double y = x * 2 / b / a;
		cout << setprecision(15) << 90 - atan2(y, b) * 180 / PI << endl;
	}
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>
#include <unordered_map>
#include <bitset>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

LL mod = 998244353;

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

  LL hoge[] = {2,5,5,4,5,6,3,7,6};

  LL N, M;
  cin >> N >> M;

  vector<bool> b(9, false);
  REP(i, M)
  {
    LL a;
    cin >> a;
    b[a - 1] = true;
  }

  LL min = 10;
  LL minn = 0;

  REP(i,9){
    if(b[i]){
      if(hoge[i]<=min){
        min = hoge[i];
        minn = i + 1;
      }
    }
  }

  REP(i,9){
    hoge[i] -= min;
  }

  bool flag = true;
  LL keta = (N - 1) / min + 1;
  while (flag)
  {
    LL num = N-keta * min;

    for (LL i = 999999; i >= 111111;--i){
      LL n = i;
      LL c = 0;
      while (n > 0)
      {
        if(n%10==0){
          c = -999999;
        }else{
          if(b[n%10-1]){
            c += hoge[n % 10 - 1];
          }
          else
          {
            c = -999999;
          }
        }
        n /= 10;
      }
      if(c==num){
        flag = false;

        LL m = i;
        LL mm = 0;
        while (m % 10 < minn&&m>0)
        {
          mm++;
          m /= 10;
        }

        LL l = i;
        LL ll = 0;
        while (l % 10 <= minn &&l>0)
        {
          ll++;
          l /= 10;
        }

        if(l!=0)
        {
          cout << l;
        }
        REP(i,keta-(6-ll)-mm){
          cout << minn;
        }
        LL k = i;
        LL kk = 1;
        REP(i,mm){
          kk *= 10;
        }
        if(kk!=1){
          cout << k % kk;
        }
        cout << endl;
        break;
      }
    }

    keta--;
  }
}


Measured memory_bytes: 256
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>

static bool binary_search(int32_t data[], size_t size, int32_t f)
{
  if (size == 0) {
    return false;
  } else if (size == 1) {
    return data[0] == f;
  } else {
    int32_t mid = size / 2;
    int32_t pivot = data[mid];
    if (f < pivot) {
      return binary_search(data, mid, f);
    } else if (pivot < f) {
      return binary_search(&data[mid], size - mid, f);
    } else {
      return true;
    }
  }

  return false;
}
size_t binary_search_find(int32_t data[], size_t data_size, int32_t find[], size_t find_size)
{
  if ((data == NULL) || (find == NULL)) {
    return 0;
  }

  size_t found = 0;
  int32_t i;
  for (i = 0; i < find_size; i++) {
    int32_t f = find[i];
    if (binary_search(data, data_size, f)) {
      found++;
    }
  }

  return found;
}

#if !defined(TEST)

#include <stdio.h>
static int32_t data[100000];
static int32_t find[50000];

int32_t main(void)
{
  int32_t num1;
  scanf("%d", &num1);
  int32_t i;
  for (i = 0; i < num1; i++) {
    scanf("%d", &data[i]);
  }

  int32_t num2;
  scanf("%d", &num2);

  for (i = 0; i < num2; i++) {
    scanf("%d", &find[i]);
  }

  size_t n = binary_search_find(data, num1, find, num2);

  printf("%lu\n", n);

  return 0;
}
#endif

Measured memory_bytes: 1188
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;
 
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)
 
int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};
 
typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;
 
const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;
// << fixed << setprecision
// --------------------------------------
int n, m;
int prime2(int x) {
  int c = 0;
  while(x % 2 == 0) {
    x /= 2;
    c++;
  }
 
  return c;
}
 
ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}
 
ll lcm(ll a, ll b) {
  if(a < b) swap(a, b);
  return a * b / gcd(a, b);
}
 
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
 
  cin >> n >> m;
 
  vector<int> a(n);
  REP(i, n) cin >> a[i];
 
  int t = prime2(a[0]);
 
  REP(i, n) if(t != prime2(a[i])) {
    cout << 0 << endl;
    return 0;
  }
 
  ll lc = a[0] / 2;
  REP(i, n) {
    lc = lcm(lc, a[i] / 2);
    if(lc > m) {
      cout << 0 << endl;
      return 0;
    }
  }
 
  cout << ((m / lc + 1) / 2) << endl;
}

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

using namespace std;

int dp[234567];

int main(){
  memset(dp, 9999999, sizeof(dp));
  int N, K;
  cin >> N >> K;
  int h[N+2];
  for(int i=1; i<=N; ++i) cin >> h[i];
  
  dp[1] = 0;
  dp[2] = abs(h[1]-h[2]);

  for(int i=2; i<=N; ++i)
    for(int k=1; i > k && k<=K; ++k)
     dp[i] = min(dp[i-k] + abs(h[i]-h[i-k]), dp[i]);
  
  cout << dp[N] << "\n";
  return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef int ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vpll> vvpll;
typedef unordered_map<ll, ll> um;
typedef unordered_set<ll> us;

#define fastio ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define ts ll t; in(t) while (t--) solve();
#define ks ll t; in(t) FOR(i, 1, t+1) out("Case #" << i << ": " << solve());
#define endl '\n'
#define ln cout << endl;
#define in(x) cin >> x;
#define out(x) cout << x << endl;
#define flush cout << flush;
#define reset(a, b) memset(a, b, sizeof(a));
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define FORI(i, a, b, c) for (ll i = a; i < b; i += c)
#define FORD(i, a, b) for (ll i = a; i > b; --i)
#define FOREACH(it, v, r) for (auto it = v.begin() + r; it != v.end(); it++)
#define FORALL(it, v) for (auto it : v)
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define vin(v, x) vll v(x); FOR(i, 0, x) in(v[i])
#define all(v) v.begin(), v.end()
#define allr(v, r) v.begin(), v.begin() + r
#define showv(v) FORALL(it, v) cout << it << ' '; ln
#define printv(v) FORALL(it, v) out(it)
#define show2d(v) FORALL(it, v) { FORALL(j, it) cout << j << ' '; ln}
#define showm(v) FORALL(it, v) cout << it.F << ": " << it.S << ' '; ln
#define sortv(v) sort(all(v));
#define revv(v) reverse(all(v));
#define maxv(v) *max_element(all(v))
#define minv(v) *min_element(all(v))
#define gcd __gcd
#define checkbit(n, i) (n >> i) & 1               // check ith bit
#define bitcount __builtin_popcount               // count set bits
#define firstbitindex __builtin_ctz               // count trailing zeros
#define lastbitindex __builtin_clz                // count leading zeros
#define bitparity __builtin_parity                // check set bits are even or odd
#define findv(v, x) (find(all(v), x) != v.end())  // find in a vector
#define findsm(u, x) (u.find(x) != u.end())       // find in a set / map
#define findstr(s, x) (s.find(x) != string::npos) // find in a string
#define sz(a) a.size()
#define precise(x) cout << fixed << setprecision(x);

const ll MAXN = 1e5, MOD = 998244353, SIZE = 2e7;//, INF = 0x7f7f7f7f7f7f7f7f;
const double EPS = 1e-9, PI = acos(-1);
const int INFi = 0x7f7f7f7f;

//<<------Declare Variables Here----->>//
ll n, k, t;

//<<-----Implement Functions Here---->>//
void solve()
{
    in(n >> k)
    vin(p, n)
	sortv(p)
    t = 0;
    FOR(i, 0, k)
        t += p[i];
    out(t)
}

//<<----------Start of Main---------->>//
int main()
{
    fastio
    //ts
    solve();
    return 0;
}

Measured memory_bytes: 3612
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
using ull = unsigned long long;
using P = pair<int, int>;

static constexpr ull MOD = 1000000007;
static constexpr double pi = 3.14159265359;

int main() {
    string S;
    cin >> S;
    string y = string("") + S[0] + S[1] + S[2] + S[3];
    string m = string("") + S[5] + S[6];
    string d = string("") + S[8] + S[9];
    if ((y >= "2019" && m >= "05") || y >= "2020") {
        cout << "TBD" << endl;
    } else {
        cout << "Heisei" << endl;
    }
}


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

int main() {
  int n;
  cin >> n;
  long double x[n];
  string u[n];
  long double sum = 0;
  int i;
  for (i = 0; i < n; i++) {
    cin >> x[i] >> u[i];
    if (u[i] == "BTC") {
      sum += x[i] * 380000.0;
    } else {
      sum += x[i];
    }
  }
  cout << sum << endl;
  return 0;
}


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

using i64 = long long;

vector<int> v;
i64 sum(0);
int n;

int main() {
#ifdef HOME
	freopen("agc12a.in", "r", stdin);
	freopen("agc12a.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);

	cin >> n;
	v.resize(n * 3);
	for (auto &i: v)
		cin >> i;

	sort(begin(v), end(v));
	for (int i = 1; i <= n; ++i)
		sum+= v[3 * n - 2 * i];


	cout << sum << endl;

	return 0; }


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

using namespace std;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    int x, a, b;
    cin >> x >> a >> b;
    if(abs(a - x) < abs(b - x))
        cout <<"A";
    else
        cout <<"B";

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=120,V=2e5;

int w[N],v[N];
ll d[V];

int main(){
	ios::sync_with_stdio(0);
	int n,W,ans=0;
	cin>>n>>W;
	memset(d,63,sizeof d);
	d[0]=0;
	for(int i=0;i<n;i++){
		cin>>w[i]>>v[i];
		for(int j=V-1;j>=v[i];j--){
			d[j]=min(d[j],d[j-v[i]]+w[i]);
			if(d[j]<=W)ans=max(ans,j);
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1792