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

#define ll          long long
#define pb          push_back
#define endl        '\n'
#define mii         map<ll,ll>
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (ll)x.size()
#define hell        1000000000000000007ll
#define INF         (1ll<<60)
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define rrep(i,a,b)  for(ll i=a;i>=b;i--)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
const int N=100005;
void solve(){
    ll n;
    cin>>n;
    vi v(n+1);
    rep(i,0,n) cin>>v[i];
    if(n==0){
        if(v[0]==1) cout<<1<<endl;
        else cout<<-1<<endl;
        return;
    }
    else{
        if(v[0]!=0){
            cout<<-1<<endl;
            return;
        }
        ll maxx=2;
        vi vmaxx(n+1);
        vmaxx[0]=1;
        // vmaxx[1]=maxx;
        ll ans=0;
        rep(i,1,n){
            vmaxx[i]=maxx;
            if(v[i]>maxx){
                cout<<-1<<endl;
                return;
            }
            maxx=min(hell,2*(maxx-v[i]));
        }
        ll curr=0;
        rrep(i,n,0){
            curr+=v[i];
            ans+=min(curr,vmaxx[i]);
        }
        cout<<ans<<endl;
    }
}
signed main()
{
    ios
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
        solve();
    }
    // time
    return 0;
}

Measured memory_bytes: 4784
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
ll n;
cin>>n;
ll a[n],sum=0,cusum=0;
// pre[0] = 0;
for(ll i=0;i<n;i++){
cin>>a[i];
sum += a[i];
}
ll final=0,mod = 1000000007;
for(ll i=n-1;i>=0;i--){
final = ((final%mod) + ((a[i]*cusum)%mod))%mod;
cusum = (cusum%mod + a[i]%mod)%mod;
}
cout<<final<<endl;
}

Measured memory_bytes: 5156
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <iostream>
#include <vector>
#include <set>
#include <map>

#define PB push_back
#define MP make_pair
#define X first
#define Y second

using namespace std;

typedef long long ll;
typedef pair < int, int> pii;
typedef vector < int > vi;

const int N = 2e5 + 500;
const int M = 1e6 + 500;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int LOG = 20;
const int OFF = (1 << LOG);
const double EPS = 1e-9;

ll a,b,c,k;

int main(){
    scanf("%lld%lld%lld%lld",&a, &b, &c, &k);
    if(k % 2 == 0){
        printf("%lld\n", a - b);
    }
    else{
        printf("%lld\n", b - a);
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    ll x, y;
    cin >> x >> y;
    ll tmp = x;
    int ans = 0;
    while(true) {
        if (x <= tmp && tmp <= y) {
            ans++;
            tmp *= 2;
        }
        else {
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())

cnt = 0
for i in range(1,n+1):
    cnt += i
    if cnt >= n:
        idx = i
        break


sum = 0
for i in range(1,idx+1)[::-1]:
    if sum+i < n:
       print(i)
       sum += i
    
    else:
        print(n-sum)
        break


Measured memory_bytes: 3316
#ABC161,D_LunLun Number

import queue
q = queue.Queue()

#[1~9]
for i in range(1,10):
    q.put(i)
K = int(input())


for k in range(K):
    #queueの最初を取り出す
    x =q.get()

    #last=1桁目の数字
    last = x % 10

    #1桁目が0ではないなら
    if last != 0:
        #1桁目-1の数字を末尾に加える
        q.put(10*x + last - 1)
    #末尾に1桁目と同じ数字を足す
    q.put(10*x + last)
    #もし1桁目が9ではないなら
    if last != 9:
        #末尾に1桁目+1の数字を加える
        q.put(10*x + last + 1)
print (x)

Measured memory_bytes: 12480
#include <stdio.h>
#define INF 200001
int p[100];
 int m[100][100];
void matrixChainOrder(int);
int min(int,int);

int main(){
  int i,n;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d",&p[i],&p[i+1]);
  }
  matrixChainOrder(n);
  return 0;
}

void matrixChainOrder(int n){
    int i,j,k,l,q;
    for(i=i;i<=n;i++){
      m[i][i]=0;
    }
    for(l=2;l<=n;l++){
      for(i=1;i<=n-l+1;i++){
	j=i+l-1;
	m[i][j]=INF;
	for(k=i;k<=j-1;k++){
	  q=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
	  m[i][j]=min(m[i][j],q);
	}
      }
    }
    printf("%d\n",m[i-1][n]);
  }

  int min(int x,int y){
    if(x>y) return y;
    else return x;
	   }
	  

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

int main(){
    int count = 0;
    string W;
    string H;
    cin >> W;
    while(cin >> H){
        if (H == "END_OF_TEXT") break;
        else {
            for (int i = 0; i < W.size(); i++){
                W[i] = tolower(W[i]);
            }
            for ( int j = 0; j < H.size(); j++){
                H[j] = tolower(H[j]);
            }
            if (W == H){
                count += 1;
            }
        }
    }
    cout << count << '\n';
    return 0;
}



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

using namespace std;

long long gcd(long long a, long long b){
    if(b > a){
        swap(a, b);
    }
    if(b == 0){
        return a;
    }
    return gcd(b, a % b);
}

int main(){
    long long n, m;
    string s, t;
    cin >> n >> m;
    cin >> s >> t;
    bool b = 1;
    for(int i = 0; i < n; i++){
        if(m * i % n == 0){
            if(s[i] != t[m * i / n]){
                b = 0;
            }
        }
    }
    if(b == 0){
        cout << -1; return 0;
    }
    cout << m * n / gcd(n, m);
}


Measured memory_bytes: 512
x=int(input())
if 400<=x<=599:
  print(8)
elif 600<=x<=799:
  print(7)
elif 800<=x<=999:
  print(6)
elif 1000<=x<=1199:
  print(5)
elif 1200<=x<=1399:
  print(4)
elif 1400<=x<=1599:
  print(3)
elif 1600<=x<=1799:
  print(2)
elif 1800<=x<=1999:
  print(1)

Measured memory_bytes: 61936
#include <bits/stdc++.h>
#include <string>
#include <sstream>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vint;
#define MSG(a) cout << #a << " " << a << "\n";

int main(){
    string n,s; cin >> n >> s;
    istringstream ss;
    ss = istringstream(n);
            int a;
        ss>>a;
    if(a>=3200){

        cout << s <<endl;


    }else{
        cout << "red" <<endl;
    }


}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	char a[55][55],b[55][55];
	int i,j;
	int k;
	for(i=0;i<n;i++)
	  scanf("%s",a[i]);
	for(i=0;i<m;i++)
	  scanf("%s",b[i]);
	int x,y;
	for(x=0;x<=n-m;x++)
	{
		for(y=0;y<=n-m;y++)
		{
			k=0;
			for(i=0;i<m;i++)
			{
				for(j=0;j<m;j++)
				{
					if(b[i][j]!=a[x+i][y+j])
					{
						k++;
						break;
					}
				}
				if(k>0)
				  break;
			}
			if(k==0)
			{
				printf("Yes\n");
				return 0;
			}
		}
	}
	printf("No\n");
	return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

const int NUM_=2200001;
static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];
ll mo=1000000007;
int X[6],Y[6];


ll comb(int x,int y) {
	return fact[x+y]*factr[x]%mo*factr[y]%mo;
}

ll hoge(int L,int U,int R,int B) {
	ll ret=0;
	int x,y;
	
	for(x=X[2];x<=X[3];x++) {
		ll in=comb(x-L,Y[3]-U)*comb(R-x,B-(Y[3]+1))%mo*(x+Y[3])%mo;
		ll out=comb(x-L,(Y[2]-1)-U)*comb(R-x,B-(Y[2]-1+1))%mo*(x+(Y[2]-1))%mo;
		ret += in - out;
	}
	for(y=Y[2];y<=Y[3];y++) {
		ll in=comb(X[3]-L,y-U)*comb(R-(X[3]+1),B-y)%mo*(X[3]+y)%mo;
		ll out=comb((X[2]-1)-L,y-U)*comb(R-(X[2]-1+1),B-y)%mo*((X[2]-1)+y)%mo;
		ret += in - out;
	}
	return (ret%mo+mo)%mo;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	inv[1]=fact[0]=factr[0]=1;
	for (int i=2;i<=NUM_;++i) inv[i] = inv[mo % i] * (mo - mo / i) % mo;
	for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%mo, factr[i]=factr[i-1]*inv[i]%mo;
	
	FOR(i,6) cin>>X[i];
	FOR(i,6) cin>>Y[i];
	int L[2]={X[0]-1,X[1]};
	int U[2]={Y[0]-1,Y[1]};
	int R[2]={X[5]+1,X[4]};
	int B[2]={Y[5]+1,Y[4]};
	
	ll ret=0;
	FOR(i,16) {
		ll tmp=hoge(L[i/8],U[i/4%2],R[i/2%2],B[i%2]);
		if(__builtin_popcount(i)&1) ret-=tmp;
		else ret+=tmp;
	}
	
	cout<<(ret+8*mo)%mo<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 51840
#include<iostream>
#include<string.h>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> P;

string str;

int main()
{
  int n,k,x,y;

  cin>>n;
  cin>>k;
  cin>>x;
  cin>>y;

  if(n<=k)
    cout<<x*n<<endl;
  else
    cout<<x*k+y*(n-k)<<endl;

}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FScanner sc = new FScanner();
		int r = sc.nextInt();
		System.out.println((int) Math.pow(r, 2) * 3);
	}

}

class FScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 23252
n = int(input())
h = list(map(int, input().split()))

dp = [10**18] * n
dp[0] = 0
for i in range(n-1):
    if i == n-2:
        dp[i+1] = min(dp[i] + abs(h[i+1] - h[i]), dp[i+1])
    else:
        dp[i+1] = min(dp[i] + abs(h[i+1] - h[i]), dp[i+1])
        dp[i+2] = min(dp[i] + abs(h[i+2] - h[i]), dp[i+2])
        
print(dp[-1])

Measured memory_bytes: 20432
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC113A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] b = Console.ReadLine().Split();
            int A = int.Parse(b[0]); int B = int.Parse(b[1]);
            int an;
            an = A + B / 2;
            Console.Write(an);
        }
    }
}


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

int main()
{
  int x, a, b;
  cin >> x >> a >> b;
  int aa, bb;
  aa = x - a;
  if(aa < 0) aa *= -1;
  bb = x - b;
  if(bb < 0) bb *= -1;
  if(aa < bb)
  {
    cout << "A" << endl;
  }
  else
  {
    cout << "B" << endl;
  }
}

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

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
    
  


int main(){
  int N;
  ll X;
  cin >> N >> X;
  vector<ll> A(N);
  rep(i, N){
    cin >> A[i];
  }
  
  ll max_g = abs(X - A[0]);
  rep(i, N){
    max_g = GCD(max_g, abs(X - A[i]));
  }
  
  cout << max_g << endl;
  
 
    
    
    
}


Measured memory_bytes: 1024
#include <algorithm>
#include <array>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;

int main(int argc, char** argv) {
	int n;
	cin >> n;
	if (n == 1) {
		cout << 1.0 << endl;
		return 0;
	}
	switch (n % 2) {
	case 0:
		cout << 0.5 << endl;
		break;
	case 1:
		cout << (n / 2 + 1) / static_cast<double>(n) << endl;
		break;
	}

	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

long int M = 1e+9+7;
int main(void){
    ll x;
    cin >> x;
    ll tyokin=100;
    int ans=0;
    while(tyokin<x){
        tyokin*=1.01;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
	int H, W;
	
	while(true){
		cin >> H >> W;

		if(H == 0 && W == 0) break;

		for(int i = 0; i < H; i++){
			for(int ii = 0; ii < W; ii++){
				if(i % 2 == 1){
					cout << (ii % 2 == 0 ? "." : "#");
				}else{
					cout << (ii % 2 == 0 ? "#" : ".");
				}
			}
			cout << endl;
			
		}

		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1152
using System;

class Program
{
	static void Main()
	{
		Console.ReadLine();
		var n = Array.ConvertAll(Console.ReadLine().Split(new[] { ' ' }), number => int.Parse(number));

		var approved = true;
		for (var i = 0; i < n.Length && approved; ++i) {
			if ((n[i] & 0x01) == 0x00) {
				if (n[i] % 3 != 0 && n[i] % 5 != 0) {
					approved = false;
				}
			}
		}

		Console.WriteLine(approved ? "APPROVED" : "DENIED");
	}
}


Measured memory_bytes: 13140
def sqDist(x, y):
    d = 0
    for i in range(len(x)):
        d += (x[i] - y[i])**2
    return d


def isSq(n):
    i = 0
    while i*i <= n:
        if i*i == n:
            return True
        i+=1


n, d = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(n)]

c = 0
for i in range(n-1):
    for j in range(i+1, n):
        d = sqDist(x[i], x[j])
        if isSq(d):
            c += 1

print(c)

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

int main() {
	int a;
	int b;
	while (1) {
		cin >> a >> b;
		if ((a == 0) && (b == 0)) {
			break;
		}
		if (a < b) {
			cout << a << ' ' << b << endl;
		} else {
			cout << b << ' ' << a << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;

namespace FastFourierTransform
{
	using C = complex< double >;

	void DiscreteFourierTransform(vector< C > &F, bool rev)
	{
		const int N = (int)F.size();
		const double PI = (rev ? -1 : 1) * acos(-1);
		for (int i = 0, j = 1; j + 1 < N; j++) {
			int k=N>>1;
			for (; k > (i ^= k); k >>= 1);
			if (i > j) {
				swap(F[i], F[j]);
			}
		}
		C w, s, t;
		for (int i = 1; i < N; i <<= 1) {
			for (int k = 0; k < i; k++) {
				w = polar(1.0, PI / i * k);
				for (int j = 0; j < N; j += i * 2) {
					s = F[j + k];
					t = C(F[j + k + i].real() * w.real() - F[j + k + i].imag() * w.imag(),
						F[j + k + i].real() * w.imag() + F[j + k + i].imag() * w.real());
					F[j + k] = s + t, F[j + k + i] = s - t;
				}
			}
		}
		if (rev) for (int i = 0; i < N; i++) F[i] /= N;
	}

	vector< long long > Multiply(const vector<long long int > &A, const vector<long long int > &B)
	{
		int sz = 1;
		while (sz <= A.size() + B.size()) sz <<= 1;
		vector< C > F(sz), G(sz);
		for (int i = 0; i < A.size(); i++) F[i] = A[i];
		for (int i = 0; i < B.size(); i++) G[i] = B[i];
		DiscreteFourierTransform(F, false);
		DiscreteFourierTransform(G, false);
		for (int i = 0; i < sz; i++) F[i] *= G[i];
		DiscreteFourierTransform(F, true);
		vector< long long > X(A.size() + B.size() - 1);
		for (int i = 0; i < A.size() + B.size() - 1; i++) X[i] = F[i].real() + 0.5;
		return (X);
	}
};

int main()
{
	long long	int A,B,C;cin>>A>>B>>C;

	vector<long long int>lens{ A,B,C };
	int Q;cin>>Q;
	long long int ans=0;
	vector<tuple<int,int,int>>vs;
	for (int i = 0; i < Q; ++i) {
		int a,b,c;cin>>a>>b>>c;
		vs.emplace_back(a,b,c);
	}
	 ans=2*(A*B+B*C+C*A);

	for (int i = 0; i < Q; ++i) {
		ans+=6;

		auto t1=vs[i];
		vector<int>z1{ get<0>(t1),get<1>(t1),get<2>(t1) };

		for (int k = 0; k < 3; ++k) {
			if(z1[k]==0)ans-=2;
			if(z1[k]+1==lens[k])ans-=2;
		}
		for (int j = i+1; j < Q; ++j) {
			auto t2=vs[j];

			vector<int>z2{ get<0>(t2),get<1>(t2),get<2>(t2) };

			int num1=0,num0=0;
			for (int k = 0; k < 3; ++k) {
				int x=abs(z1[k]-z2[k]);
				if(x==0)num0++;
				if(x==1)num1++;
			}
			if (num1 == 1 && num0 == 2) {
				ans-=2;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 3140
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define FOR(i,a,b) for (int i=(a),for_##i##_max=(b);i<=(for_##i##_max);++i)
#define RFOR(i,a,b) for (int i=(a),rfor_##i##_min=(b);i>=(rfor_##i##_min);--i)
#define REP(i,n) for (int i=0,rep_##i##_len=(n);i<(rep_##i##_len);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

namespace { // Basics

template<typename T>
void chmin(T &x, T y) {
  x = std::min(x, y);
}

template<typename T>
void chmax(T &x, T y) {
  x = std::max(x, y);
}

template<typename T>
__attribute__((unused))
const auto minimum = static_cast<T const &(*)(T const &, T const &)>(std::min);

template<typename T>
__attribute__((unused))
const auto maximum = static_cast<T const &(*)(T const &, T const &)>(std::max);

template<typename T>
int cmp3(T lhs, T rhs) { return (lhs == rhs) ? 0 : (lhs > rhs) ? 1 : -1; }

template<typename T>
__attribute__((unused))
T constexpr infty = std::numeric_limits<T>::max / 3;
template<>
__attribute__((unused))
auto constexpr infty<int> = 1'100'100'100;
template<>
__attribute__((unused))
auto constexpr infty<long long int> = 100'500'400'300'200'100LL;

using lli = long long int;
using ld = long double;

} // namespace

using namespace std;

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

  int K, A, B;
  cin >> K >> A >> B;
  int x = (A - 1) / K * K + K;
  cout << (x <= B ? "OK":"NG") << "\n";
  return 0;
}


Measured memory_bytes: 3620
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
from pprint import pprint
from copy import deepcopy
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
from pprint import pprint


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
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


n, k = LI()


l = n + k
fac = [1] * (l + 1)
inv = [1] * (l + 1)


for j in range(1, l + 1):
    fac[j] = fac[j - 1] * j % mod

inv[l] = pow(fac[l], mod - 2, mod)
for j in range(l - 1, -1, -1):
    inv[j] = inv[j + 1] * (j + 1) % mod



def comb(n, r):
    if r > n or n < 0 or r < 0:
        return 0
    return fac[n] * inv[n - r] * inv[r] % mod



for i in range(1, k + 1):
    print(comb(n - k + 1, i) * comb(k - 1, i - 1) % mod)

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

ll kai(ll i){
    if(i==0){
        return 1;
    }
    else{
        return i*kai(i-1)%MOD;
    }
}

int main(){
    ll n,m;
    cin>>n>>m;
    if(abs(n-m)>1){
        cout<<0;return 0;
    }
    if(n==m)cout<<(((kai(n)*kai(m))%MOD)*2)%MOD;
    if(n!=m)cout<<kai(n)*kai(m)%MOD;
}

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

int n;
double dp[301][301][301];

double f(int o, int t, int th){
    if(o==0 and t==0 and th==0) return 0;
    int k = o+t+th;
    double &ans = dp[o][t][th];
    if(ans>0.0) return ans;
    
    ans = 1.0*n/k;
    if(o>0) ans = ans + (1.0*o/k)*f(o-1,t,th);
    if(t>0) ans = ans + (1.0*t/k)*f(o+1,t-1,th);
    if(th>0) ans = ans +(1.0*th/k)*f(o,t+1,th-1);
    return ans;
}

int main(){
    memset(dp,-1,sizeof(dp));
    cin>>n;
    
    int arr[n];int o=0,t=0,th=0;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        if(arr[i]==1)o++;
        if(arr[i]==2)t++;
        if(arr[i]==3)th++;
    }
    
    cout<<setprecision(15)<<f(o,t,th);
}

Measured memory_bytes: 213376
#include<bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define lint long long
#define ll long long
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define vl vector<long long>
#define pii pair<long long,long long>
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mod 1000000007
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
long long INF = 1e10;
/************************  DEFINE  ****************************/

/************************ FUNCTION ****************************/

/************************   MAIN   ****************************/
int main(void){
    
    string s; cin >> s;
    int n = s.size();
    if(s[0]==s[n-1]){
        if(n%2==0)cout << "First" << endl;
        else cout << "Second" << endl;
    }else{
        if(n%2==0) cout << "Second" << endl;
        else cout << "First" << endl;
    }
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	int n;
	cin>>n;
	int m;
	cin>>m;
	for(int i=1;i<=1000;i++){
		if(floor(i*0.08)==n&&floor(i*0.1)==m){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<"-1"<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[]args) throws Throwable {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		HashMap<Integer,Integer> dp = new HashMap();
		int res = 0;
		for (int i = 0 ; i < n ; ++i) {
			int x = sc.nextInt();
			dp.put(x, dp.getOrDefault(x - 1, 0) + 1);
			res = Math.max(res, dp.get(x));
		}
		System.out.println(n - res);
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(String s) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(new File(s)));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public boolean ready() throws IOException {
			return br.ready();
		}
	}
}


Measured memory_bytes: 54536
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

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

#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection)  (collection).begin(), (collection).end()		// begin to end
#define rep(i, begin, end) for (ll i = begin; i < end; i++)					// repeat
#define repr(i, begin, end) for (ll i = begin - 1; end <= i; i--)		// repeat reverse

std::chrono::system_clock::time_point  start;

void TimeStart(void)
{
	start = std::chrono::system_clock::now();
}

void TimeEnd(void)
{
	auto time = std::chrono::system_clock::now() - start;
	auto msec = std::chrono::duration_cast<std::chrono::milliseconds>(time).count();
	cerr << endl << msec << " msec " << endl;
}

#endif



struct Edge
{
	ll length;
	ll vertex;
	Edge(ll v, ll l)
	{
		length = l;
		vertex = v;
	}
};

using Graph = vector<vector<Edge>>;


class ABC126D
{
public:
	ABC126D()
	{
		cin >> n;
		g.resize(n);

		ll u, v, w;
		rep(ei, 0, n - 1)
		{
			cin >> u >> v >> w;
			--u;
			--v;
			g[u].push_back(Edge(v, w));
			g[v].push_back(Edge(u, w));
		}

	}
	void Run(void)
	{
		vector<ll> ans(n);
		DFS(0, -1, 0, ans);

		for (const auto& e : ans)
			cout << e << endl;
	}
private:
	ll n;
	Graph g;
	void DFS(ll v, ll r, ll c, vector<ll>& ans)
	{
		ans[v] = c;
		for (const auto& e : g[v])
		{
			if (e.vertex == r)
				continue;
			if (e.length % 2 == 1)
				DFS(e.vertex, v, 1-c, ans);
			else
				DFS(e.vertex, v, c, ans);
		}
	}
};



int main(void)
{
	ABC126D abc125d;
	abc125d.Run();

	return 0;
}


Measured memory_bytes: 13312
from collections import deque
K = int(input())

q = deque()
for i in range(1, 10):
    q.append(i)

for i in range(K):
    x = q.popleft()
    if x % 10 != 0:
        q.append(10 * x - 1 + x % 10)
    q.append(10 * x + x % 10)
    if x % 10 != 9:
        q.append(10 * x + 1 + x % 10)

print(x)


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

using namespace std;

using ll=int64_t;

ll lis(vector<ll>a)
{
    int n=a.size();
    const ll INF=1e10;
    vector<ll>d((n+1),INF);
    d[0]=-1*INF;

    for(int i=0;i<n;i++)
    {
        ll j=upper_bound(d.begin(),d.end(),a[i])-d.begin();
        if(d[j-1]<=a[i]&&a[i]<=d[j])
            d[j]=a[i];
    }
    ll ans=0;
    for(int i=0;i<=n;i++)
    {
        if(d[i]<INF)
            ans=i;
    }
    return ans;
}
int main()
{
    int n;
    cin>>n;
    vector<ll>v(n);

    for(int i=0;i<n;i++)
    {
        cin>>v[i];
        v[i]*=-1;
    }

    cout<<lis(v)<<endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cctype>
using namespace std;

int n, idx; //ãÀ, ¶ñÌY
int max_ptr, mem; //gpÏÝÌAhXl+1, »ÝmÛµÄ¢éÌTCY
char s[1000002]; //¶ñ

int var[256]; //eÏÉüÁÄ¢élði[
bool mem_flg[1000002]; //ãÉmÛµ½ÌæªcÁÄ¢é©Ç¤©
int mem_size[1000002]; //mÛµ½ÌæÌTCY

int Number();
int Expr();
int Assign();
int Malloc();
bool Free();
int Clone();
bool Line();

int Number(){
  int res = 0;

  while(isdigit(s[idx])){
    res *= 10;
    res += s[idx] - '0';
    idx++;
  }

  return res;
}

int Malloc(){
  idx += 7; //"malloc("Ì¶

  int tmp = Number();

  idx++; //")"Ì¶

  if(n < mem + tmp){
    return 0;
  }

  mem_flg[max_ptr] = true;
  mem_size[max_ptr] = tmp;
  mem += tmp;
  max_ptr++;

  return max_ptr - 1;
}

int Assign(){
  int alpha = s[idx];

  idx += 2; //Ï¼Æ"="Ì¶

  int ptr = Expr();

  return var[alpha] = ptr;
}

int Clone(){
  idx += 6; //"clone("Ì¶

  int ptr = Expr();
  if(ptr == 0){
    return 0;
  }
  if(ptr == -2 || ptr == -1 || !mem_flg[ptr]){
    return -2;
  }

  idx++; //")"Ì¶

  if(n < mem + mem_size[ptr]){
    return 0;
  }

  mem_flg[max_ptr] = true;
  mem_size[max_ptr] = mem_size[ptr];
  mem += mem_size[ptr];
  max_ptr++;

  return max_ptr - 1;
}

int Expr(){
  if(s[idx] == '('){
    idx++; //"("Ì¶
    int tmp = Expr();
    idx++; //")"Ì¶

    return tmp;
  }
  else if(s[idx] == 'N' && s[idx + 1] == 'U'){
    idx += 4; //"NULL"Ì¶
    return 0;
  }
  else if(s[idx + 1] == '='){
    return Assign();
  }
  else if(s[idx] == 'm'){
    return Malloc();
  }
  else if(s[idx] == 'c'){
    return Clone();
  }
  else{
    return var[(int)s[idx++]];
  }
}

bool Free(){
  idx += 5; //"free("Ì¶

  int ptr = Expr();
  if(ptr == -2 || ptr == -1){
    return false;
  }

  idx++; //")"Ì¶

  if(ptr == 0){ //NULLÌê, ³
    return true;
  }
  else{
    if(!mem_flg[ptr]){ //·ÅÉmÛÌæÅÈ¢ÈçError
      return false;
    }
    mem -= mem_size[ptr];
    mem_flg[ptr] = false;
    mem_size[ptr] = 0;
    return true;
  }
}

bool Line(){
  if(s[idx] == 'f'){
    return Free();
  }
  else{
    int tmp = Expr();
    if(tmp == -2){
      return false;
    }
    return true;
  }
}

int main(){
  bool error_flg = false;

  mem = 0;
  max_ptr = 1;
  memset(var, -1, sizeof(var));
  memset(mem_flg, 0, sizeof(mem_flg));
  memset(mem_size, 0, sizeof(mem_size));

  scanf("%d", &n);

  while(scanf("%s", s) != EOF){
    if(error_flg) continue;

    idx = 0;
    error_flg = !Line();
  }

  if(error_flg){
    printf("Error\n");
  }
  else{
    int ans = 0;

    for(int i = 'A'; i <= 'Z'; i++){
      if(0 < var[i]){
	mem_flg[var[i]] = false;
      }
    }

    for(int i = 1; i < max_ptr; i++){
      if(mem_flg[i]){
	ans += mem_size[i];
      }
    }

    printf("%d\n", ans);
  }
}

Measured memory_bytes: 0
# 1 2 4 8 16 32
# SE

=begin
        1
    4   2   3   5
        6

        0
    3   1   2   4
        5
=end

a = gets.split(" ").map(&:to_i)
s = gets.chomp

s.each_char do |i|
    if i.eql?("N") then
        a[0], a[1], a[5], a[4] = a[1], a[5], a[4], a[0]
    elsif i.eql?("S") then
        a[0], a[1], a[5], a[4] = a[4], a[0], a[1], a[5]
    elsif i.eql?("E") then
        a[0], a[2], a[5], a[3] = a[3], a[0], a[2], a[5]
    elsif i.eql?("W") then
        a[0], a[2], a[5], a[3] = a[2], a[5], a[3], a[0]
    end
end

print a[0], "\n"



Measured memory_bytes: 6880
#include<stdio.h>
#include<string.h>

int main(void)
{
  char O[52];
  char E[52];
  scanf("%s", O);
  scanf("%s", E);
  for(int i = 0; i < strlen(E); i++) {
    printf("%c%c", O[i], E[i]);
  }
  if (strlen(O) > strlen(E)) {
    printf("%c", O[strlen(O) - 1]);
  }
  printf("\n");
  return 0;
}



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

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

    int N, K; cin >> N >> K;
    vector<int> x(N);
    for (int i = 0; i < N; i++) cin >> x[i];

    int ans = 1 << 30;
    for (int i = 0; i < N-K+1; i++) {
        int l = abs(x[i+K-1] - x[i]) + abs(x[i]);
        int r = abs(x[i+K-1] - x[i]) + abs(x[i+K-1]);
        ans = min(ans, min(l, r));
    }
    cout << ans << "\n";
}

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

int A[100001];

void Add(int i, int x) {
	A[i] += x;
}

void GetSum(int x, int y) {
	int s, t, sum = 0;
	if (x < y) { s = x; t = y; }
	else { s = y; t = x; }
	for (int i = s; i <= t; i++) {
		sum += A[i];
	}
	cout << sum << endl;
}

int main() {
	int n, q, com, x, y;
	cin >> n >> q;
	for (int i = 0; i < n; i++) A[i] = 0;
	for (int j = 0; j < q; j++) {
		cin >> com >> x >> y;
		if (com == 0) {
			Add(x, y);
		}
		else if (com == 1) {
			GetSum(x, y);
		}
	}
}


Measured memory_bytes: 3468
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

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

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int r;

    cin >> r;

    cout << r * r << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9+5
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n],dp[n];
	for(int i=0;i<n;i++)cin>>a[i],dp[i]=INF;
	dp[0]=0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<=i+2&&j<n;j++)
		dp[j]=min(dp[j],abs(a[i]-a[j])+dp[i]);
	}
	cout<<dp[n-1];
}

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

int main()
{
  char c;
  cin >> c;

  if (c == 'a' || c == 'e' || c == 'i' ||
     	c == 'o' || c == 'u')
  	cout << "vowel" << endl;
  else
  	cout << "consonant" << endl;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


string A[3];
int X,Y,Z;

int ok[3][4020];




void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>A[0]>>A[1]>>A[2];
	
	int mi=1<<30;
	sort(A,A+3);
	do {
		int X=A[0].size();
		int Y=A[1].size();
		int Z=A[2].size();
		
		FOR(i,4010+1) {
			ok[0][i]=1;
			FOR(x,X) if(x>=i && x-i<Y && A[0][x]!='?' && A[1][x-i]!='?' && A[1][x-i]!=A[0][x]) ok[0][i]=0;
			ok[1][i]=1;
			FOR(x,X) if(x>=i && x-i<Z && A[0][x]!='?' && A[2][x-i]!='?' && A[2][x-i]!=A[0][x]) ok[1][i]=0;
			ok[2][i]=1;
			FOR(x,Y) if(x>=i && x-i<Z && A[1][x]!='?' && A[2][x-i]!='?' && A[2][x-i]!=A[1][x]) ok[2][i]=0;
		}
		FOR(x,2001) FOR(y,2001) {
			if(ok[0][x] && ok[1][x+y] && ok[2][y]) {
				mi=min(mi,max({X,x+Y,x+y+Z}));
			}
		}
		
		
		
		
	} while(next_permutation(A,A+3));
	
	cout<<mi<<endl;
	
	
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<int> vec(9);

  for (int i = 0;i < 9;i++) {
    cin >> vec.at(i);
  }
  int N;
  cin >> N;
 for (int j = 0;j < N;j++) {
int A;
    cin >> A;
  for (int i = 0;i < 9;i++) {
    
    if (A == vec.at(i)) {
      vec.at(i) = 0;
    }
  }
 }
if (vec.at(0) ==0 && vec.at(1) ==0 && vec.at(2) == 0) {
  cout << "Yes" << endl;
} else if (vec.at(3) ==0 && vec.at(4) ==0 && vec.at(5) == 0) {
  cout << "Yes" << endl;
} else if (vec.at(6) ==0 && vec.at(7) ==0 && vec.at(8) == 0) {
  cout << "Yes" << endl;
} else if (vec.at(0) ==0 && vec.at(3) ==0 && vec.at(6) == 0) {
  cout << "Yes" << endl;
} else if (vec.at(1) ==0 && vec.at(4) ==0 && vec.at(7) == 0) {
  cout << "Yes" << endl;
} else if (vec.at(2) ==0 && vec.at(5) ==0 && vec.at(8) == 0) {
  cout << "Yes" << endl;
} else if (vec.at(0) ==0 && vec.at(4) ==0 && vec.at(8) == 0) {
  cout << "Yes" << endl;
} else if (vec.at(2) ==0 && vec.at(4) ==0 && vec.at(6) == 0) {
  cout << "Yes" << endl;
}  else {
  cout << "No" << endl;

}

}



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

typedef long long ll;

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

int gcd(int x, int y) {
    if (x % y == 0) return y;
    return gcd(y, x % y);
}

int main () {
   ll n, x; std::cin >> n >> x;

   std::vector<ll> y (n);
   std::vector<ll> dif (n);
   rep(i, n) {
      std::cin >> y[i];
   }

   int ans = abs(x - y[0]);
   rep(i, n) {
      ans = gcd(ans, abs(x-y[i]));
   }
   
   std::cout << ans << std::endl;
}

   

   
   

   


Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int a;
    cin >> a;
    cout << a / 100 + a / 10 % 10 + a % 10;
}


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

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

    string S; cin >> S;
    string S1 = ""; string S2 = "";

    int counter1 = 0; int counter2 = 0;

    for(int i=0;i<S.length();i++){
        if(i%2==0){
            S1.push_back('1');
            S2.push_back('0');
        }else {
            S1.push_back('0');
            S2.push_back('1');
        }
        int currChar = S[i];
        if(currChar != S1[i]) counter1++;
        if(currChar != S2[i]) counter2++;
    }

    cout << min(counter1, counter2);

    return 0;
}


Measured memory_bytes: 720
//https://onlinejudge.u-aizu.ac.jp/challenges/sources/VPC/UTPC/2204?year=2010

#include <bits/stdc++.h>

using namespace std;

int main() {
    int n;
    while (cin >> n, n) {
        int ans_max = 0, ans_min = 500;
        for (int i = 0; i < n; ++i) {
            int tmp = 0;
            for (int j = 0; j < 5; ++j) {
                int a;
                cin >> a;
                tmp += a;
            }
            ans_max = max(tmp, ans_max);
            ans_min = min(tmp, ans_min);
        }

        cout << ans_max << " " << ans_min << endl;
    }
    return 0;
}

/*
 *
 */


Measured memory_bytes: 2984
import os

def main():
        num = int(input())
        dict_list = {}
        for i in range(num):
                strings = input()
                if strings in dict_list.keys():
                        dict_list[strings] += 1
                else:
                        dict_list[strings] = 1 

        max_num = max(dict_list.values())
        result = []
        
        for k,v in dict_list.items():
                if v == max_num:
                        result.append(k)
        result.sort()
        for i in result:
                print(i)

if __name__ == "__main__":
        main()



Measured memory_bytes: 32216
import java.util.Scanner;
//http://www.ipsj.or.jp/07editj/promenade/4304.pdf
//http://algorithms.blog55.fc2.com/blog-entry-131.html
//http://algorithms.blog55.fc2.com/blog-entry-132.html
//http://algorithms.blog55.fc2.com/blog-entry-133.html
//最大正方形の問題はDPだったけど最大長方形は累積和とスタックを組み合わせてる
public class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		//while(true) {
			int N=sc.nextInt();
			//if(N==0) {
			//	break;
			//}
			long[] stacks=new long[N+1];
			int counter=0;
			long mltp=100000000000L;
			long now_h=0;
			long max=0;		//最大長方形の面積
			stacks[0]=0;
			counter++;
			for(int i=0; i<N; i++) {		//スタックに入れる
				long h=sc.nextLong();
				if(i==0) {	//スタックが空なら追加
					stacks[counter]=((long)i)*mltp+h;
					counter++;
				}
				else {
					if(now_h<h) {		//今のほうが高いならスタックに追加
						stacks[counter]=((long)i)*mltp+h;
						counter++;
					}
					else if(now_h==h) {	//同じなら何もしない
						//
					}
					else if(now_h>h) {
						while(counter-1>=0 && stacks[counter-1]%mltp>=h) {//例えば今高さが2,3,5,8とはいっていて、いま3が入った時、長方形が維持できるのはさいしょの2,3のみ
							max=Math.max(max,(i-stacks[counter-1]/mltp)*(stacks[counter-1]%mltp));
							//pl(max);
							counter--;
						}
						stacks[counter]=(stacks[counter]/mltp)*mltp+h;
						//pl(stacks[counter]);
						counter++;
					}
				}
				now_h=h;
			}
			//スタック取り出し
			for(int i=counter-1; i>=0; i--) {
				max=Math.max(max, (N-stacks[i]/mltp)*(stacks[i]%mltp));
			}
			pl(max);
		//}
		sc.close();
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
}


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


int money(int a, int b){
	int i;
	switch (a){
	case 1:
		i = b * 6000;
		break;
	
	case 2:
		i = b * 4000;
		break;

	case 3:
		i = b * 3000;
		break;

	case 4:
		i = b * 2000;
		break;
	}
	return i;
}


int main(){
	int t[4];
	int n[4];
	int a[4];
	for (int i = 0; i < 4; i++){
		cin >> t[i];
		cin >> n[i];
	}
	for (int i = 0; i < 4; i++){
		a[i] = money(t[i], n[i]);
		cout << a[i] << endl;
	}
	return 0;
}


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

int n, m, x, c;
std::vector<int> vec;
std::map<int, int> ma;

int main() {
    std::cin >> n >> m;
    vec.assign(n+1, 0);
    for (int i = 0; i < m; i++) {
        std::cin >> x;
        ma[x] = 1;
        vec[x] = -1;
    }
    if (ma[1] == 1 && ma[2] == 1) {
        std::cout << 0 << std::endl;
        return 0;
    }
    if (ma[1] == 1 && ma[2] == 0) {
        vec[1] = -1;
        vec[2] = 1;
    }
    else if (ma[1] == 0 && ma[2] == 1) {
        vec[1] = 1;
        vec[2] = -1;
    }
    else {
        vec[1] = 1;
        vec[2] = 2;
    }
    for (int i = 3; i <= n; i++) {
        if (vec[i] == -1) {
            continue;
        }
        c = 0;
        if (vec[i-1] != -1) {
            c += vec[i-1];
        }
        if (vec[i-2] != -1) {
            c += vec[i-2];
        }
        if (c == 0) {
            std::cout << 0 << std::endl;
            return 0;
        }
        vec[i] = c % 1000000007;
    }
    std::cout << vec[n] << std::endl;
}


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


int main() {
int N, M, C;
cin >> N >> M >> C;
int hensu[110];
for(int i = 0; i < M; i++) cin >> hensu[i];

int sous[110][110];
for(int i = 0; i < N; i++){
    for(int j = 0; j < M; j++){
cin >> sous[i][j];
    }
}
int count = 0;
for(int i = 0; i < N; ++i){
    int sousans = 0;
    for(int j = 0; j < M; ++j){
sousans += sous[i][j] * hensu[j];
    }
    if(sousans + C > 0) ++count;
}

cout << count << endl;
}

Measured memory_bytes: 256
//header{{{
#include<bits/stdc++.h>
  
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define setout(n,x) setw(n+1) << setfill(x)
#define Fixed fixed << setprecision(10)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 
constexpr int MOD = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}

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

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

    int n;
    cin >> n;
    max_heap<pii> pq;
    vector<int> a(n),b(n);
    rep(i,n){
        cin >> a[i] >> b[i];
        pq.emplace(a[i]+b[i],i);
    }

    int t_sum = 0,a_sum = 0;

    rep(i,n){
        int num,val;
        tie(val,num) = pq.top();
        pq.pop();
        if(i % 2 == 0){
            t_sum += a[num];
        }else{
            a_sum += b[num];
        }
    }

    cout << t_sum - a_sum << '\n';

    return 0;
}


Measured memory_bytes: 3956
#include <stdio.h>

int main(void){
	char a[1201];
	int i,c[26];
	for(i=0;i<26;i++){
		c[i]=0;
	}
	while(1){
		if(scanf("%s",a)==EOF) break;

		for(i=0;i<1201;i++){
			if(a[i]=='\0') break;
			if(a[i]>='A' && a[i]<='Z'){
				a[i]=a[i]+('a'-'A');
			}
			if(a[i]>='a' && a[i]<='z'){
				c[a[i]-'a']++;
			}
		}
	}
	for(i=0;i<26;i++){
		printf("%c : %d\n",'a'+i,c[i]);
	}
	return 0;
}

Measured memory_bytes: 540