akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};
ll H, W;
vector<string> s;

int main(){
    cin >> H >> W;
    s.resize(H);
    rep(i, 0, H) cin >> s[i];
    rep(i, 0, H){
        rep(j, 0, W){
            if(s[i][j] == '#'){
                ll c = 1;
                rep(k, 0, 4){
                    ll nh = i + d1[k];
                    ll nw = j + d2[k];
                    if(nh >= H || nw >= W || nh < 0 || nw < 0) continue;
                    if(s[nh][nw] == '#') c++;
                }
                if(c < 2){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }

    cout << "Yes" << endl;
    return 0;
}

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

int main(){
  int n,m,i;
  cin >> n >> m;
  if(n%2==1){
    for(i=1;i<=m;i++){
      cout << i << " " << 2*m+1-i << endl;
    }
  }else{
    for(i=1;i<=m;i++){
      if(i<=n/4){
        cout << i << " " << n+1-i << endl;
      }else{
        cout << i << " " << n-i << endl;
      }
    }
  }
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>

#define INF 2e9

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

using namespace std;

int main(void) {

	string S;
	long long K;

	cin >> S >> K;
	int size = S.size();
	char c1, c2; // 現在の文字、一つ前に調べた文字
	int index1 = 0, index2 = size; // 頭から数えて2種類目の文字の位置、末尾版
	int len = 1;
	long long ans = 0;

	c1 = S[0];
	c2 = S.back();
	if (c1 == c2) { // 先頭と末尾の文字が同じ
		index1++;
		index2--;
		REPA(i, 1, size) { // 先頭何文字続いてる？
			if (c1 != S[i]) {
				break;
			}
			index1++;
		}
		
		for (int i = size - 2; i >= 0; i--) { // 末尾何文字続いてる？
			c1 = S[i];
			if (c1 != c2) {
				break;
			}
			index2--;
		}
	}

	// 文字が全て同じ時index1は末尾を越え、index2は先頭を指している
	if (index1 > index2) {
		cout << (size * K) / (long long)2 << endl;
		return 0;
	}

	// 先頭末尾に関係なく置換しなければいけない数を数える
	c2 = S[index1];
	REPA(i, index1 + 1, index2 + 1) {
		c1 = S[i];
		if (c1 == c2) {
			REPA(j, i, index2 + 1) { // 何文字続いてる？
				c2 = S[j];
				if (c1 == c2) {
					len++;
				}
				else {
					break;
				}
				i++;
			}
			ans += len / (long long)2; // 置換回数は[連続した文字列長/2]回(切り捨て)
			len = 1;
		}
		else c2 = c1;
	}
	ans *= K;

	// 境界の数 = K-1
	len = index1 + (size - index2);
	ans += (K - 1) * (long long)(len / 2);

	// 先頭
	ans += index1 / 2;

	// 末尾
	ans += (size - index2) / 2;

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

Measured memory_bytes: 256
// ITP1_5-C Print a Chessboard
import java.util.Scanner;

class Main {
   public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      while (true) {
         int H = Integer.parseInt(sc.next());
         int W = Integer.parseInt(sc.next());
         if (H > 300 || W > 300) break;
         if (H == 0 && W == 0)   break;
         for (int i = 1; i <= H; i++) {
            for (int j = 1; j <= W; j++) {
               if ((i + j) % 2 == 0) {
                  System.out.print("#");
               } else if ((i + j) % 2 == 1) {
                  System.out.print(".");
               }
            }
            System.out.println();
         }
         System.out.println();
      }
   }
}

Measured memory_bytes: 27180
N = int(input())
A = list(map(int,input().split()))
ascend = True
for j in range(1,N):
    if A[j-1] < A[j]:
        break
    if A[j-1] > A[j]:
        ascend = False
        break
ans = 1
for i in range(1,N):
    if ascend:
        if A[i-1] > A[i]:
            ans += 1
            ascend = True
            for j in range(i+1,N):
                if A[j-1] < A[j]:
                    break
                if A[j-1] > A[j]:
                    ascend = False
                    break
    else:
        if A[i-1] < A[i]:
            ans += 1
            ascend = True
            for j in range(i+1,N):
                if A[j-1] < A[j]:
                    break
                if A[j-1] > A[j]:
                    ascend = False
                    break
print(ans)

Measured memory_bytes: 14480
// AOJ ALDS1_4_D Allocation
// 2018.4.30 bal4u

#include <stdio.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

int n, k;
int w[100002];

int check(int x)
{
	int i, f, s;

	f = 0, s = 0;
	for (i = 0; i < n; i++) {
		if (s + w[i] > x) {
			s = 0;
			if (++f >= k) break;
		}
		s += w[i];
	}
	return ++f <= k;
}

int main()
{
	int i, a, lo, hi, mi;
	
	n = in(), k = in();
	lo = 0, hi = 0;
	for (i = 0; i < n; i++) {
		w[i] = a = in();
		if (a > lo) lo = a;
		hi += a;
	}
	if (k == 1)    { printf("%d\n", hi); return 0; }
	if (check(lo)) { printf("%d\n", lo); return 0; }
	while (lo+1 < hi) {
		mi = (lo + hi) >> 1;
		if (check(mi)) hi = mi; else lo = mi;
	}
	printf("%d\n", hi);
	return 0;
}


Measured memory_bytes: 2228
//50
#include<iostream>
#include<algorithm>
#include<queue>

using namespace std;

char g[2][50][50];
bool p[50][50][50][50];
int w,h;

struct S{
  int x[2],y[2];
};

int main(){
  while(cin>>w>>h,w|h){
    int px[2],py[2];
    for(int y=0;y<h;y++){
      for(int i=0;i<2;i++){
	for(int x=0;x<w;x++){
	  cin>>g[i][y][x];
	  if(g[i][y][x]=='R'||g[i][y][x]=='L'){
	    px[i]=x;
	    py[i]=y;
	  }
	}
      }
    }
    fill(p[0][0][0],p[50][0][0],false);
    queue<S> que;
    S is={{px[0],px[1]},{py[0],py[1]}};
    que.push(is);
    while(!que.empty()){
      S c=que.front();
      int x=c.x[0],y=c.y[0],xx=c.x[1],yy=c.y[1];
      if(g[0][y][x]=='%'&&g[1][yy][xx]=='%')break;
      que.pop();
      if(p[x][y][xx][yy]++||(g[0][y][x]=='%'^g[1][yy][xx]=='%'))continue;
      for(int i=0;i<4;i++){
	int dy[]={0,1,0,-1};
	int dx[][4]={{1,0,-1,0},{-1,0,1,0}};
	int nx[2],ny[2];
	nx[0]=x+dx[0][i];
	ny[0]=y+dy[i];
	nx[1]=xx+dx[1][i];
	ny[1]=yy+dy[i];
	for(int j=0;j<2;j++){
	  if(nx[j]<0||w<=nx[j]||ny[j]<0||h<=ny[j]||g[j][ny[j]][nx[j]]=='#'){
	    nx[j]-=dx[j][i];
	    ny[j]-=dy[i];
	  }
	}
	S n={{nx[0],nx[1]},{ny[0],ny[1]}};
	que.push(n);
      }
    }
    cout<<(!que.empty()?"Yes":"No")<<endl;
  }
  return 0;
}

Measured memory_bytes: 10940
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <map>
#include <cstring>
using namespace std;
typedef long long ll;
const ll maxn = 1e6+10;
const ll inf = 1e16;
const ll mod = 998244353;

int N;
int gcd(int a,int b){
    return !b? a:gcd(b,a%b);
}
int main(){
//    freopen("in.txt", "r", stdin);
    
    cin>>N;
    int res = 0,t;
    for(int i = 0;i<N;i++){
        scanf("%d",&t);
        res = gcd(res,t);
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
using VVI = vector<vector<long long int> >;

int main(void) {
    Int r;
    cin >> r;
    cout << r * r << endl;
    return 0;
}


Measured memory_bytes: 3636
#include<cstdio>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
#include<map>
#include<cmath>
#include<iostream>
#define MAXN 200005
#define LL long long
#define ULL unsigned LL
#define rg register
#define lowbit(x) (-(x) & (x))
#define ENDL putchar('\n')
#define DB double
//#pragma GCC optimize(2)
//#pragma G++ optimize(3) 
//#define int LL
using namespace std;
inline int read() {
	int f = 1,x = 0;char s = getchar();
	while(s < '0' || s > '9') {if(s == '-') f = -1;s = getchar();}
	while(s >= '0' && s <= '9') {x = x * 10 - '0' + s;s = getchar();}
	return x * f;
}
int n,m,i,j,s,o,k;
map<int,int> b;
signed main() {
	n = read();
	LL ans = 0;
	for(int i = 1;i <= n;i ++) {
		k = read();
		int B = i - k,C = i + k;
		ans += (LL)b[B];
		b[C] ++;
	}
	printf("%lld\n",ans);
	return 0;
}  

Measured memory_bytes: 20756
#include<bits/stdc++.h>
using namespace std;int N,i,v,k;char c;main(){for(cin>>N,N--;i<=N;cin>>c,v+=((N&i)==i)*(c-1),k+=c&1,i++);v&=3;cout<<(v&1?1:k<N?0:v);}

Measured memory_bytes: 256
import bisect
import sys
readline = sys.stdin.buffer.readline


def main():
    A, B, Q = map(int, readline().split())
    inf = 10 ** 18
    s = [-inf] + [int(readline()) for _ in range(A)] + [inf]
    t = [-inf] + [int(readline()) for _ in range(B)] + [inf]
    for q in range(Q):
        x = int(readline())
        b, d = bisect.bisect_right(s, x), bisect.bisect_left(t, x)
        res = inf
        for S in [s[b - 1], s[b]]:
            for T in [t[d - 1], t[d]]:
                d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
                res = min(res, d1, d2)
        print(res)

if __name__ == '__main__':
    main()


Measured memory_bytes: 12792
# AOJ 1106: Factorization of Quadratic Formula
# Python3 2018.7.15 bal4u

def gcd(a, b):
	while b != 0:
		r = a % b
		a, b = b, r
	return a

while True:
	a, b, c = map(int, input().split())
	if a == 0: break
	d = b**2-4*a*c
	if d < 0: print("Impossible"); continue
	d = d**0.5
	if not d.is_integer(): print("Impossible"); continue
	d = int(d)
	d1, d2, a2 = -b+d, -b-d, a<<1
	g1, g2 = gcd(d1, a2), gcd(d2, a2)
	p, q = a2//g1, -d1//g1
	if p < 0: p, q = -p, -q
	r, s = a2//g2, -d2//g2
	if r < 0: r, s = -r, -s
	if (p < r) or (p == r and q < s): p, q, r, s = r, s, p, q
	print(p, q, r, s)



Measured memory_bytes: 5680
#include <cstdio>
#include<iostream>
#include<algorithm>

using namespace std;
 
int main(void){

	int cup[3]={0};
	char inp,gav,inp2;

	cup[0]=1;
	while(cin>>inp>>gav>>inp2){
		swap(cup[inp-'A'],cup[inp2-'A']);
	}

	for(int i=0;i<3;i++){
		if(cup[i]==1) cout<<(char)(i+'A')<<endl;
	}

    return 0;
}

Measured memory_bytes: 1132
# https://atcoder.jp/contests/caddi2018/tasks/caddi2018_b

n = int(input())
odd = even = 0
for _ in range(n):
    apple = int(input())
    if apple % 2 == 0:
        even += 1
    else:
        odd += 1

if odd:
    print('first')
else:
    print('second')

Measured memory_bytes: 79764
import math

N, K = map(int, input().split())
A = list(map(int, input().split()))

log_A = [math.log(a) for a in A]

evaluations = [0]*(N-K+1)
evaluations[0] = sum(log_A[:K])

for i in range(N-K):
    evaluations[i+1] = evaluations[i] - log_A[i] + log_A[K+i]
    
for i in range(N-K):
    if evaluations[i] < evaluations[i+1]:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 105720
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

signed main(void)
{
	ll n, k, a[20];
	cin >> n >> k;
	REP(i, n) cin >> a[i];

	ll ans = LLINF;
	REP(i, 1<<n) {
		ll ma = a[0], ret = 0, cnt = 0;
		REP(j, n) {
			if(i>>j&1) {
				cnt++;
				if(j == 0) continue;
				if(ma >= a[j]) ret += ma-a[j]+1, ma++;
				else ma = a[j];
			} else {
				ma = max(ma, a[j]);
			}
		}
		//cout << i << " " << cnt << " " << ret << endl;
		if(cnt == k) {
			ans = min(ans, ret);
		}
	}
	cout << ans << endl;
	return 0;
}


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

vector<pair<int, int> > graph[100010];

pair<int, int> p[100010];
pair<int, int> q[100010];

long long ans[100010] = {};

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

  int tmp;

  for(int i = 0;i < n;i++){
    cin >> tmp;
    p[i] = make_pair(tmp, i);
  }

  for(int i = 0;i < n;i++){
    cin >> tmp;
    q[i] = make_pair(tmp, i);
  }

  sort(p,p+n);
  sort(q,q+n);

  for(int i = 1;i < n;i++){
    graph[p[i].second].push_back(make_pair(p[i-1].second, p[i].first-p[i-1].first));
    graph[p[i-1].second].push_back(make_pair(p[i].second, p[i].first-p[i-1].first));
  }

  for(int i = 1;i < n;i++){
    graph[q[i].second].push_back(make_pair(q[i-1].second, q[i].first-q[i-1].first));
    graph[q[i-1].second].push_back(make_pair(q[i].second, q[i].first-q[i-1].first));
  }

  priority_queue<pair<long long, int>, vector<pair<long long, int> >, greater<pair<long long, int> > > que;

  ans[0] = 0;

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

  que.push(make_pair(0, 0));

  while(!que.empty()){
    long long cost = que.top().first;
    int idx = que.top().second;
    que.pop();

    for(int i = 0;i < graph[idx].size();i++){
      int next = graph[idx][i].first;
      long long ncost = cost + graph[idx][i].second;
      if(ans[next] > ncost){
        ans[next] = ncost;
        que.push(make_pair(ncost, next));
      }
    }
  }

  for(int i = 0;i < n;i++){
    cout << ans[i] << endl;
  }

  return 0;
}



Measured memory_bytes: 14192
#include <cstdio>
#include <set>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;

int v[3010][3010];
long long f[3010][3010][4];

int main() {
    int n, m, k;
    scanf("%d%d%d", &n, &m, &k);
    for(int i = 0; i < k; i++) {
        int x, y, z;
        scanf("%d%d%d", &x, &y, &z);
        v[x][y] = z;
    }
    f[1][1][1] = v[1][1];
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) {
            if(v[i][j] == 0) {
                for(int t = 0; t < 4; t++) {
                    if(j > 1) f[i][j][t] = max(f[i][j][t], f[i][j - 1][t]);
                    if(i > 1) f[i][j][0] = max(f[i][j][0], f[i - 1][j][t]);
                }
                continue;
            }
            f[i][j][0] = max(f[i][j][0], f[i][j - 1][0]);
            for(int t = 1; t < 4; t++) {
                if(j == 1) break;
                f[i][j][t] = max(f[i][j][t], f[i][j - 1][t - 1] + v[i][j]);
                f[i][j][t] = max(f[i][j][t], f[i][j - 1][t]);
            }
            for(int t = 0; t < 4; t++) {
                if(i == 1) break;
                f[i][j][0] = max(f[i][j][0], f[i - 1][j][t]);
                f[i][j][1] = max(f[i][j][1], f[i - 1][j][t] + v[i][j]);
            }
        }
    }
    long long ans = 0;
    for(int i = 0; i < 4; i++) ans = max(ans, f[n][m][i]);
    printf("%lld\n", ans);

    return 0;
}


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

int main(){
  int N;
  cin >> N;
  if (N == 19 ||
      N == 29 ||
      N == 39 ||
      N == 49 ||
      N == 59 ||
      N == 69 ||
      N == 79 ||
      N == 89 ||
      N == 90 ||
      N == 91 ||
      N == 92 ||
      N == 93 ||
      N == 94 ||
      N == 95 ||
      N == 96 ||
      N == 97 ||
      N == 98 ||
      N == 99 )
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
    int n;
    long long sum = 0;
    cin>>n;
    int A[n];
    for(int i=0;i<n;i++){
        cin>>A[i];
    }
    for(int i=1;i<n;i++){
        int d = A[i-1]-A[i];
        if(d>0){
            A[i] = A[i] + d;
            sum += d;
        }
    }
    printf("%lld\n",sum);
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    const int m = 1000000000;
    int n, k, s;
    cin >> n >> k >> s;
    vector<int> a;
    for (int i = 0; i < k; ++i) {
        a.push_back(s);
    }
    for (int i = 0; i < n - k; ++i) {
        if (s != m) a.push_back(m);
        else a.push_back(1);
    }
    for (int i = 0; i < n; ++i) cout << a[i] << " ";
    cout << endl;
    return 0;
}



Measured memory_bytes: 1912
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <ctype.h>
#include <stdlib.h>
#include <map>
using namespace std;

int main()
{
	int N, K;
	cin >> N >> K;
	int d = 0;
	vector<bool> KA(N,false);
	for (int i = 0; i < K; i++)
	{
		cin >> d;
		int A = 0;
		for (int i = 0; i < d; i++)
		{
			cin >> A;
			KA[A - 1] = true;
		}
	}

	int ans = 0;
	for (int i = 0; i < N; i++)
	{
		if (KA[i] == true) {
			ans++;
		}
	}
	ans = N - ans;
	cout << ans << endl;

}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)

const long long  int INF = 1e18;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
#define COUT(x) cout<<x<<"\n"

void Main()
{
	ll N;
	ll result=0;
	cin>>N;
	ll cnt=N/11;
	ll mod=N%11;
	if(mod>6) result+=2;
	else if(mod==0) result+=0;
	else result+=1;
	result+=cnt*2;
	cout << result << "\n";
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int H, N, O = 0;
  cin >> H >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {cin >> A.at(i);}
  for (int i = 0; i < N; i++) {O += A.at(i);}
  if (O >= H) {cout << "Yes" << endl;}
  else {cout << "No" << endl;}
}

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

int main(){
  vector<string> S(3);
  for (int i = 0; i < 3; i++){
    cin >> S.at(i);
  }
  cout << S.at(0).at(0) << S.at(1).at(1) << S.at(2).at(2) << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;

#define INF INT_MAX
#define MOD 1000000007
#define all(x) x.begin(), x.end()

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

    int G[3][3] = {};
    for(int r  = 0; r < 3; r++)
        for(int c = 0; c < 3; c++)
            cin >> G[r][c];
    
    int N; cin >> N;
    while(N--){
        int b; cin >> b;
        for(int r = 0; r < 3; r++)
            for(int c = 0; c < 3; c++)
                if(G[r][c] == b) G[r][c] = 0;
    }
    bool flag = false;
    for(int r = 0; r < 3; r++)
        if(!G[r][0] and !G[r][1] and !G[r][2])
            flag = true;
    for(int c = 0; c < 3; c++)
        if(!G[0][c] and !G[1][c] and !G[2][c])
            flag = true;
    if(!G[0][0] and !G[1][1] and !G[2][2]) flag = true;
    if(!G[0][2] and !G[1][1] and !G[2][0]) flag = true;
    

    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
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 LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


class UnionFind:
    def __init__(self, n):
        # 負  : 根であることを示す。絶対値はランクを示す
        # 非負: 根でないことを示す。値は親を示す
        self.table = [-1] * n
        self.size = [1] * n

    def root(self, x):
        if self.table[x] < 0:
            return x
        else:
            self.table[x] = self.root(self.table[x])
            return self.table[x]


    def get_size(self, x):
        r = self.root(x)
        return self.size[r]


    def is_same(self, x, y):
        if self.root(x) == self.root(y):
            return True
        else:
            return False

    def union(self, x, y):
        r1 = self.root(x)
        r2 = self.root(y)
        if r1 == r2:
            return
        # ランクの取得
        d1 = self.table[r1]
        d2 = self.table[r2]
        if d1 <= d2:
            self.table[r2] = r1
            self.size[r1] += self.size[r2]
            if d1 == d2:
                self.table[r1] -= 1
        else:
            self.table[r1] = r2
            self.size[r2] += self.size[r1]


def comb(n, r):
    if r > n:
        return 0
    fact = 1
    for i in range(n-r+1, n+1):
        fact = fact * i
    divisor = 1
    for j in range(1, r+1):
        divisor = divisor * j
    return fact//divisor



n, m = LI()
U = UnionFind(n)
ret = 0
L = LIR(m)
ans = [0] * m
ans[m - 1] = comb(n, 2)
for i in range(m - 1, 0, -1):
    u, v = L[i]
    ans[i - 1] = ans[i]
    if not U.is_same(u - 1, v - 1):
        ans[i - 1] -= U.get_size(u - 1) * U.get_size(v - 1)
        U.union(u - 1, v - 1)



for i in ans:
    print(i)

Measured memory_bytes: 107996
#include<bits/stdc++.h>
using namespace std;
int dp[100001]; int n,a[100001];
int main()
{
    int i,x,y;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    dp[0]=0;
    for(i=1;i<n;i++)
    {
        if(i==1)
            y=dp[i]=dp[i-1]+abs(a[i-1]-a[i]);
        else
        {
            y=dp[i]=dp[i-1]+abs(a[i-1]-a[i]);
            x=dp[i-2]+abs(a[i-2]-a[i]);
            dp[i]=min(y,x);
        }
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;

ll n, a, s1, s2, c1, c2;

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a;
        s1 += a;
        s2 += a;
        if (i % 2) {
            if (s1 <= 0) c1 += 1 - s1, s1 = 1;
            if (s2 >= 0) c2 += 1 + s2, s2 = -1;
        }
        else {
            if (s1 >= 0) c1 += 1 + s1, s1 = -1;
            if (s2 <= 0) c2 += 1 - s2, s2 = 1;
        }
    }

    cout << min(c1, c2) << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a,int b){return a*b/gcd(a,b);}
//priority_queue<int, vector<int>, greater<int> > que; //昇順

using namespace std;

const int mod=1e9+7;

void run();

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

signed main(){
    init();
    run();
    return 0;
}

void run(){
    string n;
    cin >> n;
    for(int i=0;i<n.size();++i)
    {
        if(n[i]=='1')cout << "9";
        else cout << "1";
    }
    cout << endl;
}

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

#define ll long long
#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define forn(i,n) for(ll i=0; i<(n); i++)
#define fori(i,k,n) for(ll i=k; i<(n); i++) 
#define all(x) (x).begin(),(x).end()
#define en '\n'
#define FILL(x,v) memset(x,v,sizeof(x))
#define pb push_back

template<typename T> void print(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}
 
template<typename T> void print(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}
 
template<typename T> void print(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < a[i].size(); j++)
			cout << a[i][j] << ' ';
		cout << en;
	}
}

void solve(){
	int n;
	cin >> n;
	vi a(n, 0);
	forn(i,n-1) {
		int k;
		cin >> k;
		k--;
		a[k]++;
	}
	forn(i, n)
		cout << a[i] << en;
}

int main(){
    ios::sync_with_stdio(0);
	cin.tie(0);
    cout.tie(0);
 
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
    int t =1;
    while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 4000
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
int rdn()
{
  int ret=0;bool fx=1;char ch=getchar();
  while(ch>'9'||ch<'0'){if(ch=='-')fx=0;ch=getchar();}
  while(ch>='0'&&ch<='9')ret=ret*10+ch-'0',ch=getchar();
  return fx?ret:-ret;
}
ll Mx(ll a,ll b){return a>b?a:b;}
const int N=1e5+5;
int n,X,nw; ll sf[N],val;
bool vis[N];
struct Node{
  int l,r,b; ll s1,sm;
  bool operator< (const Node &b)const
  { return sm>b.sm;}
}a[N];
ll cal(int i)
{
  if(nw<=a[i].b)return (ll)nw*a[i].l;
  return a[i].s1+(ll)(nw-a[i].b)*a[i].r;
}
bool chk(ll mid)
{
  if(mid%X==0)return sf[mid/X]>=val;
  ll lj=0; int k=mid/X; nw=mid%X;
  for(int i=1;i<=k;i++)
    lj=Mx(lj,sf[k]-a[i].sm+a[k+1].sm+cal(i));
  for(int i=k+1;i<=n;i++)
    lj=Mx(lj,sf[k]+cal(i));
  return lj>=val;
}
int main()
{
  n=rdn();X=rdn(); ll l=0,r=0,ans;
  for(int i=1;i<=n;i++)
    {
      a[i].b=rdn(); a[i].l=rdn(); a[i].r=rdn();
      a[i].s1=(ll)a[i].b*a[i].l;
      a[i].sm=a[i].s1+(ll)(X-a[i].b)*a[i].r;
      val+=a[i].s1; r+=a[i].b;
    }
  sort(a+1,a+n+1);
  for(int i=1;i<=n;i++)
    sf[i]=sf[i-1]+a[i].sm;
  while(l<=r)
    {
      ll mid=l+r>>1;
      if(chk(mid))ans=mid,r=mid-1;
      else l=mid+1;
    }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 4096
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  string s;
  cin >> s;
  int day = s.size(), win = 0;
  for (auto e : s) {
    if (e == 'o')
      win++;
  }
  if (win+15-day >= 8)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
//#include <boost/multiprecision/cpp_int.hpp>
//using boost::multiprecision::cpp_int;
//typedef cpp_int c_i;
#include<bits/stdc++.h>
typedef long long ll;
#define MOD 1000000007
#define p0(x) cout <<x <<" "
#define p1(x) cout <<x <<endl
#define p2(x,y) cout <<x <<" " <<y <<endl
#define p3(x,y,z) cout <<x <<" " <<y <<" " <<z <<endl
#define p4(w,x,y,z) cout <<w <<" " <<x <<" " <<y <<" " <<z <<endl
#define nl cout<<endl
# define pb push_back
#define mp make_pair
#define mp make_pair
# define vi vector<int>
# define vll vector<ll>
# define vvi vector< vector <int> >
#define ff first
#define ss second
# define vvll vector<vector <ll> >
# define srt(a) sort(a.begin(),a.end())
# define f(i,a,b) for(int i=a;i<b;i++)
# define frev(i,a,b) for(int i=a;i>=b;i--)
# define srtrev(a) sort(a.begin(),a.end(),cmp)
#define gcd(a,b) __gcd(a,b);
#define lcm(a,b)   (a/gcd(a,b))*b;
using namespace std;
#define Map map<int,int>
#define Umap unordered_map<int,int> 
ll limit = 1000000007;
#define fast  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);  
 
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool cmp(ll a,ll b)
{
	return a>b;
}
ll Pow(ll a,ll b )  //for modulus power
{
	ll ans=1,mul=a;
	while(b)
	{
		if(b&1)ans=(ans*mul)%limit;
		mul=(mul*mul)%limit;
		b/=2;
	}
	return ans;
}
 
 
void solve()
{
	int a,b;
	cin>>a>>b;
	b=2*b+1;
	if(a%b)
	cout<<a/b+1;
	else
	cout<<a/b;
}
//driver function
    int main()
    {
		//fast
		int t=1;
		//cin>>t;
		f(T,1,t+1)
		{
			//cout<<"Case #"<<T<<": ";
			solve();
		}
    }


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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
	ll N, K; cin >> N >> K;
	ll ans = K;
	for(int i = 0; i < N - 1; i++) ans *= K - 1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

int main(){
	int N;
	cin >> N;
//	vector<vll> A(N,vll(N+1,0));
	vll A(N+1,0);
	for(int i=0; i<N; i++){
		ll a;
		cin >> a;
		A[i]=a*2;
	}

	for(int i=0; i<N-1; i++){
		if(i%2==1){
//			A[N-1][i]+=A[i][i];
//			A[N-1][i+1]+=A[i][i+1];
//			A[N-1][N]+=A[i][N];
	A[N-1]+=A[i];
		}else{
//			A[N-1][i]-=A[i][i];
//			A[N-1][i+1]-=A[i][i+1];
//			A[N-1][N]-=A[i][N];
	A[N-1]-=A[i];
		}
	}
//	A[N-1][N-1]/=2;
//	A[N-1][N]/=2;
	A[N-1]/=2;
	for(int i=N-1; i>0; i--){
//		A[i-1][i]-=A[i][i];
//		A[i-1][N]-=A[i][N];
		A[i-1]-=A[i];
	}

	for(int i=0; i<N; i++){
//		cout << A[i][N] << " ";	
		cout << A[i] << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 2048
from operator import itemgetter
from collections import defaultdict
n = int(input())
if n == 1:
  print(1)
  exit()
xy = sorted([list(map(int, input().split())) for i in range(n)], key = itemgetter(0,1))
a = defaultdict(int)
for key,(x1,y1) in enumerate(xy):
  for x2,y2 in xy[key+1:]:
    p,q = x2-x1, y2-y1
    if p != 0 or q != 0:
      a[(p,q)] += 1
ans = n - max(a.values())
print(ans)

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

using namespace std;

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

typedef long long int ll;
typedef unsigned long long int ull;

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

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

    ll A, B, C, D, count = 0;
    cin >> A >> B >> C >> D;
    ll lcmcd = (C * D) / gcd(C, D);
    ll bdiv = 0, adiv = 0;
    bdiv = B / C + B / D - B / lcmcd;
    adiv = (A - 1) / C + (A - 1) / D - (A - 1) / lcmcd;
    cout << B - (A - 1) -(bdiv - adiv) << endl;
}

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

int main(){
	int N; cin>>N;
	int n = 0, r = 0;
	vector<int> A(N);
	rep(i, N){ cin>>A[i]; n = max(n, A[i]); }
	rep(i, N) if(abs((n+1)/2 - r) > abs((n+1)/2 - A[i])) r = A[i];
	cout<< n <<" "<< r <<endl;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

// {{{
template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar[0].size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}

template<typename T>
T digitsum(T x){
    T y=0;
    while(x){
        y += x % 10;
        x /= 10;
    }

    return y;
}
// }}}
/* vim:set foldmethod=marker: */

int main(int argc, char const* argv[])
{
    int w,a,b;
    cin >> w >> a >> b;

    if (a+w < b) {
        cout << b-(a+w) << endl;
    }else if (b+w < a){
        cout << a - (b+w) << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}

// sortの仕方
// int a[N];
// array<int,N> ar;
// vector<int> v;
//
// sort(a, a+N); // 配列
// sort(ar.begin(), ar.end()); // array
// sort(v.begin(), v.end()); // vector 昇順
// sort(v.begin(), v.end(), greater<int>()); // 降順

// Template
// template <class T>
// T foomax(T x, T y){
//   if (x > y){
//     return x;
//   }else{
//     return y;
//   }
// }

// string を int に変換 stoi("1010")
// int を string に変換 to_string(1010)


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define Max 100005
#define Mod 1e9+7
const LL mod=1e9+7;
const LL inf=0x3f3f3f3f;
using namespace std;
int main()
{
	int maxx=0,n,x,sum=0;
	scanf("%d",&n);
	while(n--)
	{
		scanf("%d",&x);
		maxx=max(maxx,x);
		sum+=x;
	}
	if(maxx<(sum-maxx))
		printf("Yes\n");
	else
		printf("No\n");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
 
using namespace std;
 
vector<int> calc(string &s) {
  vector<int> ret(256, 0);
  for(int i = 0; i < s.size(); i++) {
  	ret[s[i]] = 1;
  }
  return ret;
}
 
int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  int ret = 0;
  for(int i = 0; i < N; i++) {
  	string s1 = S.substr(0, i);
    string s2 = S.substr(i, N - i);
    vector<int> b1 = calc(s1);
    vector<int> b2 = calc(s2);
    int k = 0;
    for(int j = 0; j < 256; j++) {
    	k += b1[j] * b2[j];
    }
    ret = max(ret, k);
  }
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 256
K,S=[int(x) for x in input().split()]
ans=0
for x in range(min(K,S),-1,-1):
  for y in range(min(K,S-x),-1,-1):
    z=S-x-y
    if z >= 0 and z <= K:
      ans+=1
    else:
      break
print(ans)

Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <array>
#include <deque>
#include <bitset>
typedef long long ll;
using namespace std;
#define trace(x) cerr << #x << " is " << x << endl;

const ll INF = 1e18L + 5;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, w;
    cin >> n >> w;
    int weight[n + 1];
    int value[n + 1];
    int value_sum = 0;
    for (int i = 1; i <= n; i++) {
        cin >> weight[i] >> value[i];
        value_sum += value[i];
    }
    vector<ll> dp(value_sum + 1, INF);
    dp[0] = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = value_sum; j >= value[i]; j--) {
            dp[j] = min(dp[j - value[i]] + weight[i], dp[j]);
        }
    }
    ll res = 0L;
    for (int i = 1; i <= value_sum; i++) {
        if (dp[i] <= w) {
            res = max((ll)i, res);
        }
    }
    cout << res <<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

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

/*==================================================*/
/*variable*/
int N, a, b, c;
int Q, K, x[100010], y[100010];

/*==================================================*/
/*function*/
vector<pair<int, ll>> edge[100010];   //<ノード, 距離>
ll d[100010];   //始点ノードからノードiへの最短距離
int start;  //開始ノード番号

void dijkstra() {
    REP(i,0,N){
        d[i] = LLINF;
    }

    priority_queue< pair<ll, int> > PQ;  //<(-1)*最短距離, ノード番号>

    PQ.push(make_pair(0,start));  //開始ノードを0とする。

    while(!PQ.empty()){
        ll curCost = -PQ.top().first;
        int curNode = PQ.top().second;
        PQ.pop();

        d[curNode] = curCost;

        REP(i,0,edge[curNode].size()){
            int nextNode = edge[curNode][i].first;
            ll addCost = edge[curNode][i].second;

            if(d[nextNode] > d[curNode] + addCost){
                d[nextNode] = d[curNode] + addCost;
                PQ.push(make_pair(-d[nextNode], nextNode));
            }
        }
    }
}
/*==================================================*/

int main() {
    cin>>N;
    REP(i,0,N-1){
        cin>>a>>b>>c;
        edge[a-1].emplace_back(b-1, c);
        edge[b-1].emplace_back(a-1, c);
    }

    cin>>Q>>K;
    REP(i,0,Q){
        cin>>x[i]>>y[i];
    }

    start = K-1;
    dijkstra(); //Kを起点にすべてのノードへの最短距離を計算

    REP(i,0,Q){
        cout<<d[x[i]-1]+d[y[i]-1]<<endl;
    }

    return 0;
}


Measured memory_bytes: 11888
#include <iostream>

using namespace std;

int main() {
 int n, m, x, a, minL=0, minR=0;
 cin>>n>>m>>x;
 for(int i=0;i<m;i++) {
  cin>>a;
  if(a<x) minL++;
  else if(a>x) minR++;
 }
 if(minL<minR) cout<<minL;
 else cout<<minR;
}

Measured memory_bytes: 256
/* ----------------------- reclone_rk --------------------------------------------*/ 
#include<bits/stdc++.h>
using namespace std;
#define int long long int
const int mod=1e9+7;

#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define prq priority_queue<int>
#define prqp priority_queue<pair<int,int>>
#define vtr vector<int>
#define INF INT_MAX
#define NINF INT_MIN
#define endl "\n"
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define pvtr vector<pair<int,int>>
#define FOR(i,a,n) for (int i=(a);i<=(n);++i)

int gcd(int a, int b){ if(a == 0) return b; return gcd(b%a, a);}
int MOD(int n){ return ((n%mod)+mod)%mod;}
int power(int a,int b){ if(b==0)return 1LL;int s=power(a,b/2LL);s*=s;s%=mod;if(b&1LL)return (s*a)%mod;return s;}
int inv(int a){return power(a,mod-2);}
int nCr(int n,int r){if(r>n)return 0LL;if(n-r<r)r=n-r;int ans=1;for(int i=0;i<r;i++){ans*=(n-i);ans=MOD(ans);ans*=inv(i+1);ans=MOD(ans);}return ans;}

signed main()
{   
    int k;
    cin>>k;
    string s;
    cin>>s;
    int n = s.length();
    // cout<<n<<endl;
    if(n<=k)
        cout<<s<<endl;
    else
    {
        for(int i=0; i<k; i++)
            cout<<s[i];
        cout<<"..."<<endl;
    }
    
	return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;

typedef long long ll;

int main(void)
{
    int ans = 0;
    int a, b;
    
    cin >> a >> b;
    
    ans = a - b * 2;
    if (ans < 0) ans = 0;
    
    cout << ans << endl;
    return 0;
}

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

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,b) FOR(i, 0, b)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

// N人をKグループに分ける、それはスターリング数
ll S[1050][1050];
ll starling_number_2nd(ll N, ll K){
    // k=0 0個の箱に入れる
    // 0
    // ただし
    S[0][0] = 1;

    // k=1 1個の箱に入れる
    FOR(n, 1, 1050){
        S[n][1] = 1;
    }

    FOR(n, 1, 1050){
        FOR(k, 2, n+1){
            S[n][k] = S[n-1][k-1] + k * S[n-1][k];
            S[n][k] %= mod;
        }
    }
    return S[N][K];
}

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

    // input
    ll N, K;
    cin >> N >> K;

    ll ans = starling_number_2nd(N, K);
    p(ans);
    
    return 0;
}


Measured memory_bytes: 10676
n, x = map(int, input().split())
X = list(map(int, input().split()))

def gcd(a, b):
    if b == 0:
        return a

    else:
        return gcd(b, a % b)

if n == 1:
    output = abs(X[0] - x)
    print(output)
    exit()

else:
    output = gcd(abs(x - X[0]), abs(X[0] - X[1]))

for i in range(1, n - 1):
    tmp = abs(X[i] - X[i + 1])
    output = gcd(output, tmp)

print(output)


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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 (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N;
	cin >> N;
	
	int ans = INF;
	rep(i, 1, sqrt(N) + 1)
	{
		if (N%i == 0)
		{
			chmin(ans, ((int)log10(max(i, N / i)) + 1));
		}
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    ll a, b, c, k; cin >> a >> b >> c >> k;

    if (k <= a) {
        cout << k << endl;
        return 0;
    } else if (a < k && k <= a + b) {
        cout << a << endl;
        return 0;
    } else {
        cout << a - (k - a - b) << endl;
        return 0;
    }
}

Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2147483647
#define int long long
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
signed main(){
	
	double t,x;
	cin>>t>>x;
	cout<<t/x<<endl;

}

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

using namespace std;

typedef long long ll;

int main()
{
    string s,t;
    cin>>s>>t;
    ll ans=t.size();
    ll dif=0;
    for(ll i=0;i<=s.size()-t.size();i++)
    {
        dif=0;
        for(ll j=0;j<t.size();j++)
        {
            if(t[j]!=s[j+i])
            {
                dif++;
            }
        }
        ans=min(ans,dif);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3616
#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;
template <typename T> using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int SET(int N, int pos)  {return N=N | (1<<pos);}
int RSET(int N,int pos)  {return N= N & ~(1<<pos);}
bool CHK(int N,int pos)  {return (bool)(N & (1<<pos));}

#define ll             long long
#define pll            pair<ll,ll>
#define unique(a)      a.resize(unique(a.begin(), a.end()) - a.begin())
#define fill(v, p)     memset(v,p,sizeof v)
#define all(x)         x.begin(), x.end()
#define index(x,i)     x.find_by_order(i)
#define lesscount(x,i) x.order_of_key(i)
#define PI             acos(-1.0)
#define EPS            0.000000001
#define INF            1e18+10
#define MAX            300005
#define MOD            1000000007


signed int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(0);
	
	ll n, m;
	cin >> n >> m;
	
	if(n==m)
	{
		cout << "Yes\n";
	}
	else cout << "No\n";
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, l, r) for(int i = (int)l; i <= (int)r; ++i)
#define REP(i, n) for(int i = (int)0; i < (int)r; ++i)

using namespace std;
typedef long long ll;
const int Nmax = 5e5 + 112;
    
int n, cur, res[Nmax];
ll ans;
string s;

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> s;
    n = s.size();
    s = '#' + s;
    FOR(i, 1, n) {
        if (s[i] == '>') {
            int j = i;
            while(j + 1 <= n && s[j + 1] == '>') {
                ++j;
            }
            cur = max(cur, j - i + 1);
            ans += cur;
            FOR(k, 1, j - i) {
                 ans += k;
            }
            cur = 0;
            i = j;
        } else {
            int j = i;
            while(j + 1 <= n && s[j + 1] == '<') {
                ++j; 
            }
            FOR(k, i, j) {
                ans += cur;
                ++cur;
            }
            if (j == n) ans += cur;
            i = j;
        }
    }
    cout << ans;
}


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

int main() {
    int n, k, pos, mid;
    int sum = 0;
    cin >> n >> k;
    mid = k/2 + k%2;
    for (int i = 0; i < n; i++) {
        cin >> pos;
        if (pos < mid) sum += pos * 2;
        else sum += (k - pos) * 2;
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <math.h>
using namespace std;
int main()
{
int n,k;
int a[100005];
scanf("%d %d",&n,&k);
for(int i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
sort(a,a+n);
int min=1000000005;
for(int i=0;i<n-k+1;i++)
{
if(a[i+k-1]-a[i]<min){min=a[i+k-1]-a[i];}
}
printf("%d\n",min);
}

Measured memory_bytes: 512
x1, x2, x3, x4, x5 = list(map(int, input().split()))

if x1 == 0:
    print("1")
elif x2 == 0:
    print("2")
elif x3 == 0:
    print("3")
elif x4 == 0:
    print("4")
else:
    print("5")


Measured memory_bytes: 61548