akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

main(){
  int da[2][11][3], n[2], cn[10];
  while(cin >> n[0] >> n[1] && (n[0]|n[1])){
    fill(da[0][0], da[2][0], 0);
    fill(cn, cn+11, 0);
    for(int k=0;k<2;k++){
      for(int i=1;i<=n[k];i++){
        string in;
        cin >> in;
        if(!k) for(;in[cn[i-1]]=='.';cn[i-1]++);
        for(int j=0;j<3;j++) da[k][i][j] = da[k][i-1][j];
        for(int j=0;j<in.size();j++){
          if(in[j] == '(') da[k][i][0]++;
          if(in[j] == '{') da[k][i][1]++;
          if(in[j] == '[') da[k][i][2]++;
          if(in[j] == ')') da[k][i][0]--;
          if(in[j] == '}') da[k][i][1]--;
          if(in[j] == ']') da[k][i][2]--;
        }
      }
    }
    int ans[10];
    fill(ans, ans+10, -2);
    ans[0] = 0;
    for(int r=1;r<21;r++){
      for(int c=1;c<21;c++){
        for(int s=1;s<21;s++){
          bool f = true;
          for(int i=0;i<n[0];i++){
            if(r*da[0][i][0] + c * da[0][i][1] + s * da[0][i][2] != cn[i]) f = false;
          }
          if(!f) continue;
          for(int i=0;i<n[1];i++){
            int t = r * da[1][i][0] + c * da[1][i][1] + s * da[1][i][2];
            if(ans[i] == -2) ans[i] = t;
            else if(ans[i] != t) ans[i] = -1;
          }
        }
      }
    }
    cout << ans[0];
    for(int i=1;i<n[1];i++) cout << ' ' << ans[i];
    cout << endl;
  }
}

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

int main(){
    string s;cin >> s;
    rep(i,3){
        if(s[i]==s[i+1]){
          cout << "Bad" << endl;
          return 0;
        }
    }
  cout << "Good" << endl;
    return 0;
}


Measured memory_bytes: 256
import math
from functools import reduce
def gcd(*numbers):
  return reduce(math.gcd, numbers)

K = int(input())
ans = 0

for a in range(1, K+1):
  for b in range(1, K+1):
    for c in range(1, K+1):
      ans += gcd(a, b, c)
print(ans)

  
  

Measured memory_bytes: 74820
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vector<int>>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define vpli vector<pair<long long, int>>
#define deb(x) cout << "deb " << #x << " " << x << endl;
#define all(x) x.begin(), x.end()
ll MOD = 1e9 + 7;
const int INF = 2e9 + 10;
int n;
int k;
vi s;
vector<vvi> dp(2, vvi(105, vi(5, -1)));

int f(bool fill, int curr, int count)
{
    if(count > k) return 0;
    if (curr == n && count != k)
        return 0;
    if (curr == n && count == k)
        return dp[fill][curr][count] = 1;
    if (dp[fill][curr][count] != -1)
        return dp[fill][curr][count];
    int last = (fill ? s[curr] : 9);
    int ans = 0;
    for (int i = 0; i <= last; i++)
    {
        if(i == 1 && curr == 0)
        {
            //deb((fill && (i == last)));
            //deb((curr + 1));
            //deb((count + (i > 0)))
        }
        ans += f(fill && (i == last), curr + 1, count + (i > 0));
    }
    //cout << fill << " " << curr << " " << count << " " << ans << " \n";
    return dp[fill][curr][count] = ans;
}

void solve()
{
    string t;
    cin >> t >> k;
    for (char c : t)
    {
        s.pb(c - '0');
    }
    n = s.size();
    cout << f(1, 0, 0);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    //cin >> t;
    while (t--)
        solve();
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int K;
  cin >> K;
  int ans=0;
  vector<int> h(N);
  for (int i=0; i<N; i++){
     cin >> h.at(i);
  }
  for (int i=0; i<N; i++){
     if (h.at(i)>=K) ans++;
  }
  cout << ans << endl;
}

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

int main()
{
	int n, rm = 1001, lm = 1001;
	int a[10], w;

	cin >> n;

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

		if (a[i] == 0 && rm > w)
			rm = w;
		else if (a[i] == 1 && lm > w)
			lm = w;
	}

	if (rm == 1001 || lm == 1001)
		cout << 0 << endl;
	else
		cout << rm + lm << endl;
	
	return 0;
}


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

int field[50][50];
int w, h;
vector<int> di_x = {1,0,-1,0,1,-1,1,-1};
vector<int> di_y = {0,1,0,-1,1,1,-1,-1};

void dfs(int x, int y) {
   field[x][y] = 0;
   rep(i,8) {
      int n_x = x + di_x[i];
      int n_y = y + di_y[i];
      if (n_x < 0 || h <= n_x || n_y < 0 || w <= n_y) continue;
      else if (field[n_x][n_y] == 0) continue;
      else dfs(n_x,n_y);
   }
}

int main () {
   while (true) {
      cin >> w >> h;
      if (w == 0 && h == 0) break;
      int ct = 0;
      rep(i,h)rep(j,w) cin >> field[i][j];
      rep(i,h)rep(j,w) {
         if (field[i][j] == 1) {
            dfs(i,j);
            ct++;
         }
      }
      cout << ct << endl;
      rep(i,h)rep(j,w) field[i][j] = 0;
   }
}
   


Measured memory_bytes: 3136
#include<iostream>

using namespace std;

int main(){
  int n,i,j,k=0,r=0;
  cin>>n;
  for(i=1;i<1000000;i=i*10){
    if(i<=n) k++;
    else break;
  }//k桁

  j=1;
  for(i=1;i<=k;i++){
    if(i%2){
      if(i==k) r+=n-j+1;
      else r+=j*9;
    }

    j=j*10;
  }

  cout<<r<<endl;
  return 0;
}

Measured memory_bytes: 256
data=[]
while(True):
  a,b=map(int,input().split(' '))
  if a==0 and b==0:
    break
  data.append((a,b))

  

for a,b in data:
  line='#'*b
  line2='#'+'.'*(b-2)+'#'
  for i in range(a):
    if i==0:
      print(line)
    elif i==a-1:
      print(line)
    else:
      print(line2)
  print('')



Measured memory_bytes: 5620
import sys
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

a,b,c,d = na()

if (a-1)//d >= (c-1)//b:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9060
#include<iostream>
#include<algorithm>

using namespace std;

typedef long long ll;

int N, M;
const ll INF = 1145141919810893;
int open[1000 + 10];
ll cost[1000 + 10];
ll dp[1 << 12 + 10];

int main(){
	for (int i = 0; i < (1 << 12); i++)dp[i] = INF;
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int b;
		cin >> cost[i] >> b;
		for (int j = 0; j < b; j++) {
			int c;
			cin >> c;
			open[i] |= 1 << (c - 1);
		}
	}

	dp[0] = 0;
	for (int i = 0; i < M; i++) {
		for (int bit = 0; bit < (1 << N); bit++) {
			dp[bit | open[i]] = min(dp[bit | open[i]], dp[bit] + cost[i]);
		}
	}
	if (dp[(1 << N) - 1] == INF) {
		cout << -1 << endl;
	}
	else {
		cout << dp[(1 << N) - 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include<cmath>
using namespace std;
int main(void){
    
    // 定義:円の半径を「 r 」 と置く
    double r;
    cin >> r;
    
    // 定義・計算:面積を「 r * r * M_PI 」 と演習を「 2 * M_PI * r 」 置く
    double face = r * r * M_PI;
    double week =2 * M_PI * r;
    
    // 出力：C言語の出力の仕方 ➡  一番左の % .7f に face の値が入る  一番左からの % .7f に week 値が入る  
    // 書き方：printf("　文字列・〇％ が入る", 変数名１,　変数名２);
    printf("%.7f %.7f\n", face, week);
    
    return 0;
}



Measured memory_bytes: 3200
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
    int n, l;
    vector<string> S;
    cin >> n >> l ;
    for( int i = 0 ; i < n ; i++){
        string str;
        cin >> str;
        S.push_back(str);
    }
    
    sort(S.begin(), S.end());
    
    for_each(S.begin(), S.end(), [](const string& str){
        cout << str;
    });
    return 0;
}

// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://cppreference.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   https://www.boost.org/doc/


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

#define pb push_back
#define mp make_pair
#define inside sl<=l&&r<=sr
#define outside r<sl||sr<l
#define INF 1000000009
using namespace std;
typedef long long ll;

ll dp[102][100005];

int main(){
	//freopen("stl.gir", "r", stdin);
	
	ll n, W;
	cin >> n >> W;
	vector<ll> w(n), v(n);
	for (int i = 0; i < n; i++) cin >> w[i] >> v[i];
	
	// dp[i][j] = dp[i+1][j+w[i]]
	// dp[i][j] = dp[i+1][j];
	
	for (int i = 0; i < n; i++){
		for (int j = 0; j <= W; j++){
			if (i == 0){
				if (j >= w[i]) dp[i][j] = v[i];
				else dp[i][j] = 0;
			} else {
				dp[i][j] = dp[i-1][j];
				if (j-w[i] >= 0) dp[i][j] = max(dp[i][j], dp[i-1][j-w[i]]+v[i]); 
			}
		}
	}
	
	cout << dp[n-1][W] << endl;
}

Measured memory_bytes: 78464
N = input()
l = input().split()


result = 0

for i in range(len(l)):
    flg = 0

    if i == 0:
        result = 1
    else:
        for j in range(0, i):
            if int(l[i]) < int(l[j]):
                flg = 1

        if flg == 0:
            result = result + 1

if len(l) <= 20:
    print(result)


Measured memory_bytes: 3060
N = int(input())
As = sorted(list(map(int, input().split())))

sieve = [True] * 1000001

prev = 0

for i in range(N):
    if As[i] == prev:
        sieve[As[i]] = False
        continue
    else:
        prev = As[i]
        try:
            for j in range(2, 1000000 // prev + 1):
                sieve[prev * j] = False
        except:
            continue

count = 0
As = list(set(As))
for i in range(len(As)):
    if sieve[As[i]] is True:
        count += 1
        
print(count)

Measured memory_bytes: 132708
#include <stdio.h>
#include <stdlib.h>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1'000'000'000ll + 7;
//const i64 smod = 998244353ll;
//const i64 inf = 1'000'000'000'000'000'000ll + 7;
const i64 inf = 1'000'000'007;

const long double eps = 1e-8;

const i64 MAXN = 5'000 + 5;

i64 T;

i64 n, k;
i64 a[MAXN];

vector<i64> pos;
vector<i64> neg;
i64 zero = 0;

i64 calc_pos() {
    i64 R = 1;

    sort(pos.begin(), pos.end());
    sort(neg.begin(), neg.end());

    i64 i = pos.size() - 1;
    i64 j = 0;

    if (k % 2) {
        k -= 1;
        R *= pos[i];
        R %= mod;
        i--;
    }

    while (k > 0 && i > 0 && j < (i64)neg.size() - 1) {
        i64 pn = neg[j] * neg[j + 1];
        i64 pp = pos[i] * pos[i - 1];
        if (pn > pp) {
            R *= pn % mod;
            j += 2;
        }
        else {
            R *= pp % mod;
            i -= 2;
        }
        k -= 2;
        R %= mod;
    }

    while (k > 0 && i > 0) {
        i64 pp = pos[i] * pos[i - 1];
        R *= pp % mod;
        R %= mod;
        k -= 2;
        i -= 2;
    }

    while (k > 0 && j < (i64)neg.size() - 1) {
        i64 pn = neg[j] * neg[j + 1];
        R *= pn % mod;
        R %= mod;
        k -= 2;
        j += 2;
    }

    return R;
}

i64 calc_neg() {
    i64 R = 1;

    sort(pos.begin(), pos.end());
    sort(neg.begin(), neg.end());

    i64 i = 0;
    i64 j = neg.size() - 1;

    k -= 1;
    j -= 1;
    /*
    R *= neg.back();
    R %= mod;
    */

    while (k > 0 && i < (i64)pos.size() - 1 && j > 0) {
        i64 pn = neg[j] * neg[j - 1];
        i64 pp = pos[i] * pos[i + 1];
        if (pn > pp) {
            R *= pn % mod;
            j -= 2;
        }
        else {
            R *= pp % mod;
            i += 2;
        }
        k -= 2;
        R %= mod;
    }

    while (k > 0 && i < (i64)pos.size() - 1) {
        i64 pp = pos[i] * pos[i + 1];
        R *= pp % mod;
        R %= mod;
        k -= 2;
        i += 2;
    }

    while (k > 0 && j > 0) {
        i64 pn = neg[j] * neg[j - 1];
        R *= pn % mod;
        R %= mod;
        k -= 2;
        j -= 2;
    }

    R *= (mod + neg.back()) % mod;
    R %= mod;

    return R;
}


int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed); cerr.precision(15); cerr.setf(ios::fixed);

    i64 n;
    cin >> n;

    i64 R = (1000 - n % 1000) % 1000;
    cout << R << endl;


    return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
 int a, b;
  cin >> a >> b;
 if(a * b % 2)
  cout << "Odd" << endl;
  else
    cout << "Even" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long X = Math.abs(sc.nextLong());
		long K = sc.nextLong();
		long D = sc.nextLong();

		long minX;
		long maxX;
		long minK = X / D;

		if(X % D > Math.abs((X % D) - D)) {
			minX = Math.abs((X % D) - D);
			maxX = X % D;
			minK++;
		}else {
			minX = X % D;
			maxX = Math.abs((X % D) - D);
		}

		if(minK >= K) {
			System.out.println(Math.abs(X- (D * K)));
			return;
		}

		if((K-minK)%2 == 0) {
			System.out.println(minX);
		}else {
			System.out.println(maxX);
		}

	}

}

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

typedef long long ll;

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

    string n; cin >> n;
    int ans = (n[0] - '0') - 1;
    ans += 9 * (n.size()-1);
    int uku = 0;
    for(int i=0;i<n.size();i++){
        uku += (n[i]-'0');
    }
    ans = max(ans,uku);
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main() {
		string S;

		cin >> S;	

		vector<int> cnt(2, 0);

		for ( int i = 0; i < S.size(); i++ ) {
				cnt[S[i] - '0']++;
		}

		int ans = min(cnt[0], cnt[1]) * 2;	

		cout << ans << endl;

		return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i, n) for (long long i = 0; i < (int)(n); i++)
#define put(i) cout<<fixed<<i<<endl
using namespace std;
using ll = long long;

char a[10][10];
ll h, w;
ll cnt = 0;

ll dfs(ll x, ll y){
    if(a[x+1][y] == '#'){
        cnt++;
        dfs(x+1, y);
    }else if(a[x][y+1] == '#'){
        cnt++;
        dfs(x, y+1);
    }
    return 0;
}

int main(){
    cin >> h >> w;
    ll charp = 0;

    fill(a[0] ,a[10], '.');

    for(long long y = 1; y <= h; y++){
        for(long long x = 1; x <= w; x++){
            cin >> a[x][y];
            if(a[x][y] == '#') charp++;
        }
    }

    dfs(1, 1);
    
    if(charp-1 == cnt) put("Possible");
    else put("Impossible");
    
    //rep(y,h) {rep(x,w) {cout << a[x][y];}cout << endl;}
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define fo(a,b,c) for (a=b; a<=c; a++)
#define fd(a,b,c) for (a=b; a>=c; a--)
#define add(a,b) a=((a)+(b))%mod
#define ll long long
//#define file
using namespace std;

ll f[151][151][151][2][2],g[151][151],ans;
int n,m,mod,i,j,k,l,p1,p2,I,J,K,L,P1,P2,s;

ll qpower(ll a,int b) {ll ans=1;while (b) {if (b&1) ans=ans*a%mod;a=a*a%mod;b>>=1;} return ans;}

int main()
{
	#ifdef file
	freopen("agc035E.in","r",stdin);
	#endif
	
	scanf("%d%d%d",&n,&m,&mod);
	if (m==n) {printf("%lld\n",qpower(2,n));return 0;}
	
	if (!(m&1))
	{
		g[0][0]=1;
		fo(i,1,n)
		{
			fo(j,0,m/2)
			{
				if (j<m/2) add(g[i][j+1],g[i-1][j]);
				add(g[i][0],g[i-1][j]);
			}
		}
		
		j=k=0;
		fo(i,0,m/2) add(j,g[(n+1)/2][i]),add(k,g[n/2][i]);
		printf("%lld\n",1ll*j*k%mod);
	}
	else
	{
		f[0][0][0][0][0]=1;
		fo(i,1,n)
		{
			fo(j,0,i-1)
			{
				fo(k,0,i-1)
				{
					fo(p1,0,1)
					{
						fo(p2,0,1)
						if (f[i-1][j][k][p1][p2])
						{
							fo(s,0,1)
							{
								if (s) //yes
								{
									if (i&1)
									{
										K=k,P2=p2;
										if (!p1) J=j+1;
										else
										{if (j==1) continue; else J=j-1,P1=1;};
									}
									else
									{
										J=j,P1=p1;
										if (!p2) K=k+1;
										else
										{if (k==1) continue; else K=k-1,P2=1;};
									}
								}
								else //no
								{
									if (i&1)
									{
										if (p1 || p2 || k<m/2+2 || !j)
										J=0,P1=0,K=k,P2=p2;
										else
										{
											if (j>=m/2+1) continue;
											J=0,P1=0,K=m/2+1-j,P2=1;
										}
									}
									else
									{
										if (p2 || p1 || j<m/2+2 || !k)
										K=0,P2=0,J=j,P1=p1;
										else
										{
											if (k>=m/2+1) continue;
											K=0,P2=0,J=m/2+1-k,P1=1;
										}
									}
								}
								add(f[i][J][K][P1][P2],f[i-1][j][k][p1][p2]);
							}
						}
					}
				}
			}
		}
		
		fo(j,0,n)
		{
			fo(k,0,n)
			{
				fo(p1,0,1)
				{
					fo(p2,0,1)
					if (f[n][j][k][p1][p2] && !((!p1 && !p2 && ((n&1) && j>m/2+1 || !(n&1) && j>m/2)) && (!(n&1) && k>m/2+1 || (n&1) && k>m/2)))
					add(ans,f[n][j][k][p1][p2]);
				}
			}
		}
		printf("%lld\n",ans);
	}
}

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

#define ff first
#define ss second
#define maxn 2000006
#define pb push_back
#define ll long long
#define vll vector<ll>
#define mll map<ll,ll>
#define MOD 1000000007
#define pll pair<ll,ll>
#define ull unsigned long long
#define f(i,x,n) for(int i=x;i<=n;i++)

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

using namespace std;

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

	ll a; cin>>a;
	string s;
	 cin>>s;

	if(a< 3200) cout<<"red";
	else cout<<s;

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
long long floorsqrt(long long n) {
	if (n < 4)return (long long)1;
	long long a = n / 2, b = 2;
	while (std::abs(a - b) > 1) {
		b = (a + b) / 2;
		a = n / b;
	}
	return a < b ? a : b;
}
int main() {
	long long q, a, b, i, c, ans;
	scanf("%lld", &q);
	for (i = 0; i < q; i++) {
		scanf("%lld%lld", &a, &b);
		if (a < b) {
			c = a;
			a = b;
			b = c;
		}
		if (a == b || a==b+1)ans = 2 * b - 2;
		else {
			c = floorsqrt(a*b);
			if (c*c == a*b)c--;
			if (c*(c + 1) >= a*b)ans = 2 * c - 2;
			else ans = 2 * c - 1;
		}
		printf("%lld\n", ans);
	}
}

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

using namespace std;
typedef long long ll;

const ll MAX_N = 3005;
ll dp[MAX_N][MAX_N][4];
ll items[MAX_N][MAX_N];

int main() {
    ll R, C, K;
    cin >> R >> C >> K;

    ll r, c, v;

    for (ll i = 0; i < K; ++i) {
        cin >> r >> c >> v;
        items[r][c] = v;
    }

    ll value;
    ll h;
    ll b;

    for (ll row = 1; row <= R; ++row) {
        for (ll col = 1; col <= C; ++col) {
            value = items[row][col];
            b = 0;
            for (ll i = 0; i < 4; ++i) {
                b = max(b, dp[row - 1][col][i]);
            }
            b = max(b, dp[row][col - 1][0]);
            dp[row][col][0] = b;
            dp[row][col][1] = max(dp[row][col - 1][1], b + value);
            for (ll i = 2; i < 4; ++i) {
                dp[row][col][i] = max(dp[row][col - 1][i], dp[row][col - 1][i - 1] + value);
            }
        }
    }

    ll ans = 0;

    for (ll i = 0; i < 4; ++i) {
        ans = max(ans, dp[R][C][i]);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 355696
list1 = list(map(int, input().split()))
list2 = list(map(int, input().split()))
list3 = list(map(int, input().split()))
n = int(input())
num_list = []
for i in range(n):
    b = int(input())
    num_list.append(b)
for num in num_list:
    if num in list1:
        x = list1.index(num)
        list1.pop(x)
        list1.insert(x, 'bingo')
    if num in list2:
        x = list2.index(num)
        list2.pop(x)
        list2.insert(x, 'bingo')
    if num in list3:
        x = list3.index(num)
        list3.pop(x)
        list3.insert(x, 'bingo')
result = 'No'
if list1[0] == list1[1] == list1[2] == 'bingo':
    result = 'Yes'
if list2[0] == list2[1] == list2[2] == 'bingo':
    result = 'Yes'
if list3[0] == list3[1] == list3[2] == 'bingo':
    result = 'Yes'
if list1[0] == list2[0] == list3[0] == 'bingo':
    result = 'Yes'
if list1[1] == list2[1] == list3[1] == 'bingo':
    result = 'Yes'
if list1[2] == list2[2] == list3[2] == 'bingo':
    result = 'Yes'
if list1[0] == list2[1] == list3[2] == 'bingo':
    result = 'Yes'
if list1[2] == list2[1] == list3[0] == 'bingo':
    result = 'Yes'

print(result)

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iterator>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

typedef   signed long long int slli;
typedef unsigned long long int ulli;
const slli MAX_SLLI = 0x7FFFFFFFFFFFFFFF;
const slli MIN_SLLI = 0x8000000000000000;
const ulli MAX_ULLI = 0xFFFFFFFFFFFFFFFF;
const ulli MIN_ULLI = 0x0000000000000000;

#define N_TIMES(i, n)     for (ulli i = 0;     i <  n; ++i)
#define N_TIMES_REV(i, n) for (slli i = n - 1; i >= 0; --i)

#ifdef __DEBUG__
template<typename T>
std::ostream& operator<<(std::ostream &os, const std::list<T> &list)
{
  const std::string delim = ", ";
  typename std::list<T>::const_iterator itr = list.begin();
  while (itr != list.end()) {
    os << *itr;
    ++itr;
    if(itr != list.end()) os << delim;
  }
  return os;
}

template<typename T>
std::ostream& operator<<(std::ostream &os, const std::vector<T> &v)
{
  const std::string delim = ", ";
  for (unsigned n = 0; n < v.size(); ++n) {
    os << v[n];
    if((n + 1) < v.size()) os << delim;
  }
  return os;
}
#endif /* __DEBUG__ */

int main(int argc, char **argv)
{
  std::string S;
  std::cin >> S;
  
  auto C = std::count_if(S.begin(), S.end(), [](char c){return c == 'o';});
  
  std::cout << (700 + (C * 100)) << std::endl;
  
  return 0;
}

Measured memory_bytes: 256
def btn(n, l)
  a = [".", ",", "!", "?", " "] + [*"a".."z"]
  return case n
  when 1
    a[0 + (l - 1) % 5]
  when 2
    a[5 + (l - 1) % 3]
  when 3
    a[8 + (l - 1) % 3]
  when 4
    a[11 + (l - 1) % 3]
  when 5
    a[14 + (l - 1) % 3]
  when 6
    a[17 + (l - 1) % 3]
  when 7
    a[20 + (l - 1) % 4]
  when 8
    a[24 + (l - 1) % 3]
  when 9
    a[27 + (l - 1) % 4]
  end
end

gets.to_i.times do
  arr, ans = gets.chomp.split(/0+/), ""
  
  arr.each do |str|
    ans += btn(str[0].to_i, str.length) if str[0]
  end
  
  puts ans
end

Measured memory_bytes: 9124
#include <stdio.h>

int main(void)
{
	int i;
	int n;
	int m;
	scanf("%d", &n);
	m = 100000;
	for (i = 0; i < n; i++){
		m *= 1.05;
	    m = (m + 999)/1000 * 1000;
	}
	printf("%d\n", m);
	return (0);
}

Measured memory_bytes: 0
function Main(input) {
  input = input.split("\n");
  var S = input[0].split("");
  var T = input[1].split("");
  var ans = 0;
  for(var i = 0;i<S.length;i++){
    if(S[i]!=T[i]){
      ans++;
    }
  }

  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 36524
//Resting_Prince
#include<bits/stdc++.h>
#define mod 1000000007
#define inf 1e18
#define PI 3.141592653589
#define fi first
#define se second 
#define sv(v) sort(all(v));reverse(all(v))
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mk make_pair
#define en '\n'
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double ld;

int main()
{
    ll n,a[200005],i,j,k,l,b[200005];
    cin>>n;
    rep(i,0,n-1)cin>>a[i];
    k=0;
    rep(i,0,n-1)
    {
        if((i+1)%2==1)k+=a[i];
        else k-=a[i];
    }b[1]=k;
    rep(i,2,n)
    {
        b[i]=2*(a[i-2]-(b[i-1]/2));
    }
    rep(i,1,n)cout<<b[i]<<" ";
    return 0;
}


Measured memory_bytes: 3584
#include<iostream>
#include<vector>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repn(i, n) for(int i = 1; i <= n; i++) 

template <typename A, size_t N, typename T> void array_fill(A(&array)[N], const T &val){
    fill((T*)array, (T*)(array + N), val);
}

int main(){
    int n,m,q; cin>>n>>m>>q;
    int T[501][501]; array_fill(T,0);
    int S[501][501]; array_fill(S,0);
    rep(i, m){
        int l,r; cin>>l>>r;
        T[l][r]++;
    }
    repn(i, n)repn(j, n){
        S[i][j] = S[i-1][j]+S[i][j-1]-S[i-1][j-1]+T[i][j];
    }
    rep(i,q){
        int p,q; cin>>p>>q;
        int ans = S[q][q]-S[q][p-1]-S[p-1][q]+S[p-1][p-1];
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) obj.begin(),obj.end()
#define pb(obj) push_back(obj)
#define REP(i,N) for(ll i=0;i<N;i++)
typedef long long ll;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin>>S;
    bool YYMM=false;
    bool MMYY=false;
    int a=(S[0]-'0')*10+(S[1]-'0');
    int b=(S[2]-'0')*10+(S[3]-'0');
    if(1<=a&&a<=12){MMYY=true;}
    if(1<=b&&b<=12){YYMM=true;}
    if(MMYY&&YYMM)cout<<"AMBIGUOUS"<<endl;
    else if(MMYY)cout<<"MMYY"<<endl;
    else if(YYMM)cout<<"YYMM"<<endl;
    else cout<<"NA"<<endl;
}

Measured memory_bytes: 256
import sys

table = [0]*26
alf = "abcdefghijklmnopqrstuvwxyz"

s = sys.stdin.read().lower()

for i in s:
    index = 0
    for j in alf:
        if j == i:
            table[index] += 1
            break
        index += 1

for i in range(26):
    print("%s : %d" %(alf[i], table[i]))


Measured memory_bytes: 5560
/*
我的心脏怦怦跳，监管者就在附近
*/
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#include<string>
#include<iostream>
#include<cmath>
#include<set>
#include<stack>
#include<queue>
#include<unistd.h>
#include<stdio.h>
#include<cstring>
#define random(a,b) (rand()%(b-a+1)+a)
using namespace std;
bool prime(int x){
	 int i;
	 if(x<2) return 0;
	 for(i=2;i*i<=x;i++){
		if(x%i==0){return 0;}
	 }
	 return 1;
}
int main()
{
	string st;
	int n;
	cin>>n;
	cin>>st;
	int i;
	string s,c;
	s=st.substr(0,st.size()/2);
	c=st.substr(st.size()/2,st.size()/2);
	if(st.size()%2!=0) cout<<"No"<<endl;
	else if(s==c) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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 ll;
using namespace std;
int main(void){
    string s;cin>>s;
    map<char,int> mp;
    ll k;cin>>k;
    ll buf1=0,buf2=0;
    bool b=false;
    mp[s[0]]++;
    rep(i,s.size()-1){
        mp[s[i+1]]++;
        if(s[i]==s[i+1]){
            if(b)b=false;
            else{
                b=true;
                buf1++;
            }
        }else b=false;
    }
    if(mp.size()==1){
        cout<<(s.size()*k)/2<<endl;
      	return 0;
    }
    if(s[0]!=s[s.size()-1]){
        cout<<buf1*k<<endl;
        return 0;
    }
    ll A=1,B=1;
    rep(i,s.size()-1){
        if(s[i]!=s[i+1])break;
        else A++;
    }
    reverse(s.begin(),s.end());
    rep(i,s.size()-1){
        if(s[i]!=s[i+1])break;
        else B++;
    }
    buf2=A/2+B/2-(A+B)/2;
    ll res=buf1*k-buf2*(k-1);
    cout<<res<<endl;
}

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

using namespace std;

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

	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());

	cout << ((s < t) ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N, X;
    cin >> N >> X;
    vector<int> m(N);
    rep(i, 0, N) cin >> m[i];
    sort(m.begin(), m.end());
    rep(i, 0, N) X -= m[i];
    int ans = N;
    while (X >= m[0])
    {
        X -= m[0];
        ++ans;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

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

int main(){
    double a, b;
    cin >> a >> b;
    int amin, amax, bmin, bmax;
    if((int)a%2==0){
        amin = (int)(a * 12.5);
        amax = amin + 13;
    }
    else{
        amin = (int)(a * 12.5) + 1;
        amax = amin+ 12;
    }
    bmin = b * 10;
    bmax = bmin + 10;
    int ans = max(amin, bmin);
    if(ans>=amax||ans>=bmax){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
s = list(input())
k = int(input())
s.append('-1')
ran = []
counter = 0
while counter < len(s)-1:
    j = counter +1
    while s[counter] == s[j]:
        j += 1
    ran.append([s[counter], j - counter])
    counter = j
counter = 0
result = 0
if k >= 2:
    if len(ran) >= 2:
        if ran[0][0] == ran[-1][0]:
            result += ((ran[0][1]+ran[-1][1])//2)*(k-1)
            if ran[-1][1] != 1:
                result += ran[-1][1]//2
            if ran[0][1] != 1:
                result += ran[0][1]//2
        else:
            result += (ran[0][1]//2 + ran[-1][1]//2)*k
    else:
        result += (ran[0][1]*k)//2
    for  i in range(1, len(ran)-1):
        result += ((ran[i][1])//2)*k
    print(result)
else:
    for i in range(len(ran)):
        result += (ran[i][1])//2
    print(result)

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647;
const long long int llINF = 9223372036854775807;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
struct multi {
  ll first;
  ll second;
  ll third;
  multi(ll first, ll second, ll third)
      : first(first), second(second), third(third) {}
};
bool multicomp(const multi &a, const multi &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll A, P;
  cin >> A >> P;
  cout << ((A * 3) + P) / 2 << endl;

  return 0;
}


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

int main()
{
	int k, a, b;
	cin >> k;
	cin >> a >> b;
	for(int i = a; i <= b; i++)
	{
		if(i%k == 0)
		{
			cout << "OK" << endl;
			return 0;
		}
	}
	cout << "NG" << endl;
}


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

#define rep(i, n) for(int i = 0; i < n; i++)

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll H, W; cin >> H >> W;
    ll x;
    if(H == 1 || W == 1){
        cout << 1 << endl;
        return 0;
    }
    if(W % 2){
        x = W/2 + 1;
        if(H % 2 == 0) cout << (x + x-1)*(H/2) << endl;
        else cout << (x + x-1)*(H/2) + x << endl;
    }
    else{
        x = W/2;
        cout << x*H << endl;
    }
    return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=sorted(a)
c=0
for i in range(n):
 x=a.index(b[i])
 j=0
 while x>i:
  j+=1
  y=a.index(b[x])
  c+=a[y]
  a[x],a[y]=a[y],a[x]
  x=y
 c+=min(b[i]*j,b[i]*2+b[0]*(j+2))
print(c)


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

using namespace std;

int main()
{
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif // LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    for (int i = 0; i < (int)s.size() - 1; i++) {
        if (s[i] == s[i + 1]) {
            cout << "Bad";
            return 0;
        }
    }
    cout << "Good";
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>

int main()
{
    /* input */
    int H1, H2, M1, M2, K;
    scanf( "%d %d %d %d %d", &H1, &M1, &H2, &M2, &K );

    /* process */
    int total = ( 60 * H2 + M2 ) - ( 60 * H1 + M1 );

    /* output */
    printf( "%d\n", total - K );

    return 0;
}


Measured memory_bytes: 1728
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
using P = pair<int,int>;
const int MOD = 1000000007;
#define inf 1e9

int main() {
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if (a+b>c+d) cout<<"Left"<<endl;
    else if(a+b==c+d) cout<<"Balanced"<<endl;
    else cout<<"Right"<<endl;
} 


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <map>
#include <iostream>
using namespace std;

int main() {
  long N,W;
  cin >> N >> W;
  vector<pair<int,int>> wv(N);
  for (int i=0; i<N; i++) {
    cin >> wv[i].first >> wv[i].second;
  }
  int smallw = wv[0].first;
  //cerr << smallw << endl;
  
  sort(wv.begin(),wv.end());
  
  /*for (int i=0; i<N; i++) {
    cerr << wv[i].first << " " << wv[i].second << endl;
  }*/
  
  int cc0 = 0;
  int cc1 = 0;
  int cc2 = 0;
  int cc3 = 0;
  for (int i=0; i<N; i++) {
    if (wv[i].first == smallw) {
      cc0++;
      continue;
    }
    if (wv[i].first == smallw+1) {
      cc1++;
      continue;
    }
    if (wv[i].first == smallw+2) {
      cc2++;
      continue;
    }
    cc3++;
  }
  
  vector<long> vv0(cc0+1,0);
  vector<long> vv1(cc1+1,0);
  vector<long> vv2(cc2+1,0);
  vector<long> vv3(cc3+1,0);
  for (int i=cc0-1; i>=0; i--) {
    vv0[cc0-i] = vv0[cc0-1-i] + wv[i].second;
    cerr << vv0[cc0-i] << ' ';
  }
  cerr << endl;
  for (int i=cc1-1; i>=0; i--) {
    vv1[cc1-i] = vv1[cc1-1-i] + wv[i+cc0].second;
    cerr << vv1[cc1-i] << ' ';
  }
  cerr << endl;
  for (int i=cc2-1; i>=0; i--) {
    vv2[cc2-i] = vv2[cc2-1-i] + wv[i+cc0+cc1].second;
    cerr << vv2[cc2-i] << ' ';
  }
  cerr << endl;
  for (int i=cc3-1; i>=0; i--) {
    vv3[cc3-i] = vv3[cc3-1-i] + wv[i+cc0+cc1+cc2].second;
    cerr << vv3[cc3-i] << ' ';
  }
  cerr << endl;
  long ans = 0;
  long term = 0;
  for(int i=0; i<cc0+1; i++) {
    for(int j=0; j<cc1+1; j++) {
      for(int k=0; k<cc2+1; k++) {
        for(int l=0; l<cc3+1; l++) {
          if ((i+j+k+l)*smallw+j+k*2+l*3 > W) {
            continue;
          }
          term = vv0[i] + vv1[j] + vv2[k] + vv3[l];
          ans = max(term,ans);
          term = 0;
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] len = new long[n];
		long allLen = 0;
		for (int i = 0; i < n; i++) {
			len[i] = sc.nextLong();
			allLen = allLen + len[i];
		}
		long before = 0;
		long after = 0;
		int num = 0;
		while (after < allLen) {
			before = after;
			after = before + len[num] * 2;
			num++;
		}
		long ans = Math.min(after - allLen, allLen - before);
		System.out.println(ans);
	}
}

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

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

using ll = long long;

ll mod = 1e9+7;

ll modinv(ll a){
    ll b = mod, p = 1, q = 0;
    ll temp;
    while(b>0){
        temp = a/b;
        a -= temp * b; swap(a, b);
        p -= temp * q; swap(p, q);
    }
    p %= mod; if(p<0) p += mod;
    return p;
}

ll modpow(ll a, ll n){
    ll ret = 1;
    while(n>0){
        if(n&1) ret = (ret*a) % mod;
        a = (a*a) % mod;
        n >>= 1;
    }
    return ret;
}

ll modfact(int n){
    ll a = 1;
    rep(i,n) a = a * (i+1) % mod;
    return a;
}

ll modinvfact(int n){
    ll a = 1;
    rep(i,n) a = a * modinv(i+1) % mod;
    return a;
}

ll modfallfact(int a,int n){
    ll t = 1;
    for(ll i=a; i>a-n; i--) t = t * i % mod;
    return t;
}

int main(){
    int n,a,b;
    cin >> n >> a >> b;
    ll result = modpow(2, n)-1;
    if(result<0) result += mod;
    
    ll nCa = modfallfact(n,a)*modinvfact(a);
    ll nCb = modfallfact(n,b)*modinvfact(b);

    result = (result-nCa-nCb)%mod;
    if(result<0) result += mod;

    cout << result << endl;
    return 0;
}

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

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

#define pb                                        push_back
#define all(v)                                    v.begin(),v.end()

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

const int N = 3e6 + 7, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;

int n, Q;
int arr[N + 2];


void solve()
{
	lop(i, 1, 6) cin >> arr[i];

	lop(i, 1, 6)
	{
		if (!arr[i])
		{
			cout << i << endl;
			return;
		}
	}

}

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

	int test = 1;
	// cin >> test;
	while (test--)solve();


}
































Measured memory_bytes: 3608
nx=list(map(int,input().split()))
X=list(map(int,input().split()))
from fractions import gcd
for i in range(nx[0]):
  if i==0:
    d=abs(X[0]-nx[1])
  else:
    d=gcd(d,abs(X[i]-X[i-1]))
print(d)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }


int main(void){
    // Your code here!
    int n,k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i,n) cin >> h.at(i);
    vector<int> dp(n);
    rep(i,n) dp.at(i) = INF;
    dp.at(0) = 0;
    FOR(i,1,n-1) {
        for ( int j = max(i-k,0); j < i; j++) {
            chmin(dp.at(i),dp.at(j) + abs(h.at(i)-h.at(j)));
        }
    }
    cout << dp.at(n-1) << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>
#include <set>
#include <map>
using namespace std;

const double PI=acos(-1);

int main(){
    int n, cnt = 0;
    cin >> n;

    map<string, int> l;
    string s;
    for(int i = 0; i < n; i++){
        cin >> s;
        l[s]++;
        cnt = max(cnt, l[s]);
    }
    for(auto a : l){
        if(a.second == cnt)
            cout << a.first << endl;
    }
    return 0;
}

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

struct Point
{
  int i;
  int j;
};

class Orchard
{
  public:
    Orchard(int height, int width);
    
    int section_num();

  private:
    bool CheckIndex(const Point& p) const;
    void Passed(const Point& p, char tree);

  private:
    const int m_height;
    const int m_width;
    vector<vector<char>> m_orchard;
};

Orchard::Orchard(int height, int width) :
  m_height(height), m_width(width), m_orchard(height, vector<char>(width))
{
  for (auto& line : m_orchard)
  {
    for (auto& tree : line)
    {
      cin >> tree;
    }
  }
}

int Orchard::section_num()
{
  int result = 0;
  for (int i = 0; i < m_height; ++i)
  {
    for (int j = 0; j < m_width; ++j)
    {
      if (m_orchard[i][j] == 'x') continue;
      ++result;
      Passed({ i, j }, m_orchard[i][j]);
    }
  }
  return result;
}

inline bool Orchard::CheckIndex(const Point& p) const
{
  return (0 <= p.i and p.i < m_height) and (0 <= p.j and p.j < m_width);
}

void Orchard::Passed(const Point& p, char tree)
{
  if (m_orchard[p.i][p.j] != tree) return;

  m_orchard[p.i][p.j] = 'x';

  vector<Point> buf_ps;
  buf_ps.push_back( { p.i, p.j + 1} );
  buf_ps.push_back( { p.i, p.j - 1} );
  buf_ps.push_back( { p.i + 1, p.j} );
  buf_ps.push_back( { p.i - 1, p.j} );
  for (auto buf_p : buf_ps)
  {
    if (CheckIndex(buf_p))
    {
      Passed(buf_p, tree);
    }
  }
}

int main(void)
{
  while (true)
  {
    int height, width;
    cin >> height >> width;
    if (height == 0 and width == 0) break;

    Orchard orchard(height, width);
    cout << orchard.section_num() << endl;
  }
  return 0;
}

Measured memory_bytes: 3256
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs

const int MAXN = 2 * 105000;

class SegmentTree {
private: 
  const long long INF = 1e18;
  vector<long long> tree;
  int n;
public:
  void init(int sz) {
    n = 1;
    while (n < sz) {
      n *= 2;
    }
    tree.assign(2 * n, -INF);
  }

  // l, r are in [0, n - 1]
  long long getMax(int l, int r) {
    l = n + l; r = n + r;
    long long res = -INF;
    
    while (l <= r) {
      if (l & 1) {
        res = max(res, tree[l]);
        l++;
      }
      if (r % 2 == 0) {
        res = max(res, tree[r]);
        r--;
      }
      l /= 2; r /= 2;
    }

    return res;
  }

  // pos is in [0, n - 1]
  void update(int pos, long long val) {
    pos = n + pos;
    tree[pos] = val;
    pos /= 2;
    while (pos >= 1) {
      tree[pos] = max(tree[pos * 2], tree[pos * 2 + 1]);
      pos /= 2;
    }
  }
};

int n;
int h[MAXN];
int a[MAXN];
long long ans;
SegmentTree tree;

int main() { 

  scanf("%d", &n);

  for (int i = 0; i < n; i++) {
    scanf("%d", &h[i]);
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }

  tree.init(n);

  for (int i = 0; i < n; i++) {
    long long cur = a[i];
    if (h[i] > 1) {
      long long mx = tree.getMax(0, h[i] - 2);
      if (mx >= 0) {
        cur += mx;
      }
    }
    ans = max(ans, cur);
    tree.update(h[i] - 1, cur);
  }

  cout << ans << endl;

  return 0;
}


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

int main() {
  int N;
  int K;
  int x;
  int sum = 0;
  
  cin >> N >> K;
  for (int i = 0; i < N; i++)
  {
    cin >> x;
    if (x > K - x)
    {
      sum = sum + (K - x) * 2;
    }
    else
    {
      sum = sum + x * 2;
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 256