akhauriyash/Code-Regression huggingface dataset:
import java.util.Map.Entry;
import java.io.*;
import java.util.*;

public class Main {
	
	static double[] dp;
	static int[] pow;
	
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		
		int N = sc.nextInt();
		boolean winFirst = false;
		for(int i = 0; i < N; i++){
			int a = sc.nextInt();
			if(a % 2 == 1) winFirst = true;
		}
		System.out.println((winFirst) ? "first" : "second");
	}
}

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    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: 22612
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

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

int f(string s, ll a)
{
  int ans = 0;
  for(char c = 'a'; c <= 'z'; c++) {
    bool ok1 = false, ok2 = false;
    for(ll i = 0; i < s.size(); i++) {
      if(s[i] == c) {
	if(i < a) {
	  ok1 = true;
	} else {
	  ok2 = true;
	}
      }
    }
    if(ok1 == true && ok2 == true) ans++;
  }
  return ans;
}


int main(void)
{
  ll n; cin >> n;
  string s; cin >> s;
  ll ans = 0;

  REP(i, s.size()) {
    ll cnt = f(s, i);
    if(cnt > ans) ans = cnt;
  }
  
  cout << ans << endl;
}


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

typedef long long int ll;
typedef long double ld;

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pll pair<ll,ll>
#define MP make_pair
#define ff first
#define ss second
#define PB push_back
#define mod 1000000007
#define lp(i,start,end) for(ll i=start;i<=end;i++) 
#define deb1(a) cout<<#a<<" = "<<(a)<<endl;
#define deb2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define deb3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;


ll modu(ll a, ll b)
{
	ll ans =1;
	while(b>0)
	{
		if(b&1)
		ans = (ans*a)%mod;
		b/=2;
		a = (a*a)%mod;
	}
	return ans;
}

int main()
{
	fastio
	string s;
	cin>>s;
	if(s[s.size()-1]!='s')
		s+='s';
	else{
		s+='e';
		s+='s';
	}
	cout<<s<<endl;
	return 0;	
}


Measured memory_bytes: 3652
// Crt. 2020-01-10  08:56:59
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
typedef long long ll;
const int Mod = 1e9 + 7;
const int lim = 90;

ll n, m, fib[200];

inline ll calc(ll a, ll b) {
    ll res; res = (m - a) / b + 1, res %= Mod;
    if (a <= n) res += (n - a) / b + 1, res %= Mod;
    return res;
}

void work(int K) {
    ll res = 0; res += calc(fib[K + 1], fib[K]), res %= Mod;
    for (int i = 2; i < K; ++i) {
        ll x = fib[i + 2], y = fib[i];
        ll a = x * fib[K - i + 1] + y * fib[K - i];
        ll b = x * fib[K - i] + y * fib[K - i - 1];
        if (a > m || b > n || !a || !b) continue;
        res += calc(a, b), res %= Mod;
    }
    printf("%d %lld\n", K - 1, res);
}

int main(){
    fib[0] = 0, fib[1] = 1;
    for (int i = 2; i <= lim; ++i)
        fib[i] = fib[i - 1] + fib[i - 2];

    int Q; cin >> Q;
    while (Q--) {
        scanf("%lld%lld", &n, &m);
        if (n > m) swap(n, m); int K = 0;
        if (n == 1) { printf("1 %lld\n", (m) % Mod); continue;}
        if (n + m == 4) { puts("1 4"); continue;}
        for (int i = 1; i < lim; ++i)
            if (fib[i + 1] <= m && fib[i] <= n)
                K = i;
        work(K);
    }
    return 0;
}

Measured memory_bytes: 3968
import sys
import math
from itertools import combinations

stdin = sys.stdin


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


def ns(): return stdin.readline().rstrip()  # ignore trailing spaces


def circumcircle(ax, ay, bx, by, cx, cy):
    if (bx - ax) * (cy - ay) - (by - ay) * (cx - ax) == 0:
        return None
    D = 2 * (ax * (by - cy) + bx * (cy - ay) + cx * (ay - by))
    X = ((ax * ax + ay * ay) * (by - cy) + (bx * bx + by * by)
         * (cy - ay) + (cx * cx + cy * cy) * (ay - by)) / D
    Y = ((ax * ax + ay * ay) * (cx - bx) + (bx * bx + by * by)
         * (ax - cx) + (cx * cx + cy * cy) * (bx - ax)) / D
    R = math.sqrt((X - ax) * (X - ax) + (Y - ay) * (Y - ay))
    return X, Y, R


def diametercircle(ax, ay, bx, by):
    X = (ax + bx) / 2
    Y = (ay + by) / 2
    R = math.sqrt((X - ax) * (X - ax) + (Y - ay) * (Y - ay))
    return X, Y, R


def distance(ax, ay, bx, by):
    return math.sqrt((ax - bx) ** 2 + (ay - by) ** 2)


N = ni()
XY_array = [na() for _ in range(N)]
ans = 10 ** 10
for p in combinations(range(N), 2):
    ax, ay = XY_array[p[0]]
    bx, by = XY_array[p[1]]
    x, y, r = diametercircle(ax, ay, bx, by)
    for xy in XY_array:
        cx, cy = xy
        rr = distance(x, y, cx, cy)
        if rr > r:
            break
    else:
        ans = min(ans, r)

for p in combinations(range(N), 3):
    ax, ay = XY_array[p[0]]
    bx, by = XY_array[p[1]]
    cx, cy = XY_array[p[2]]
    if circumcircle(ax, ay, bx, by, cx, cy):
        x, y, r = circumcircle(ax, ay, bx, by, cx, cy)
        for xy in XY_array:
            dx, dy = xy
            rr = distance(x, y, dx, dy)
            if rr > r:
                break
        else:
            ans = min(ans, r)


print(ans)


Measured memory_bytes: 76340
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

int main(){
    int N;
    cin >> N;
    vector<int> A(N,0);
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    int ans=0;
    for(int i=0; i<N; i++){
        int B;
        cin >> B;
        ans+=B;
    }

    vector<int> C(N,0);
    for(int i=1; i<N; i++){
        cin >> C[i];
    }

    int tmp=-1;
    for(int i=0; i<N; i++){
        if(A[i]==tmp+1){
            ans+=C[tmp];
        }
        tmp=A[i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cassert>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<vector>
#include<time.h>
#include<algorithm>
using namespace std;
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define rep(i,n) REP(i,1,n)
#define rep0(i,n) REP(i,0,n-1)
#define repG(i,x) for(ll i=pos[x];~i;i=e[i].next)
#define ll long long
#define db double
const ll N=5007;
const ll mod=1e9+7;
ll Pow(ll x,ll y){
	ll ans=1,now=x;
	while(y){
		if(y&1)ans=ans*now%mod;
		now=now*now%mod;
		y>>=1;
	}
	return ans;
}
ll n,m,v1=0,v2=0,v3=0,X;
struct Edge{ll u,v,c;}E[N];
ll f[N],g[N];
ll ff(ll x){return (f[x]==x)?x:f[x]=ff(f[x]);}
bool cmp(Edge a,Edge b){return a.c<b.c;}

int main(){
	scanf("%lld%lld%lld",&n,&m,&X);
	rep(i,m)scanf("%lld%lld%lld",&E[i].u,&E[i].v,&E[i].c);
	sort(E+1,E+m+1,cmp);
	rep(i,m){
		rep(j,n)f[j]=j;
		f[E[i].u]=E[i].v;
		g[i]=E[i].c;
		rep(j,m){
			if(i!=j){
				ll x=ff(E[j].u),y=ff(E[j].v);
				if(x!=y){
					f[x]=y;
					g[i]+=E[j].c;
				}
			}
		}
		if(g[i]<X)v1++;
		else if(g[i]==X)v2++;
		else v3++;
	}
	if(!v2){puts("0"); return 0;}
	if(!v1)printf("%lld\n",(Pow(2,v2)-2+mod)*Pow(2,v3)%mod);
	else printf("%lld\n",2*(Pow(2,v2)-1+mod)%mod*Pow(2,v3)%mod);
	return 0;
}


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

int main() {
	int A, B;
	cin >> A >> B;
	if(A > B){
	cout << A + A -1 << endl;
	}else if(A < B){
	cout << B + B -1<< endl;	
	}else if(A == B){
	cout << A + B << endl;	
}
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>
#include <stack>
#include <bitset>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

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

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

  int n, k;
  cin >> n >> k;
  cout << (k == 1 ? 0 : (n-k)) << endl;    
  
  return 0;
}


Measured memory_bytes: 256
A,B,K = map (int, input ().split ())
c = 0
if A < B:
  R = A
else:
  R = B
for i in range (R):
  I = R-i
  if A%I==0 and B%I==0:
    c += 1
    if c == K:
      print (I)
      break

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

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<bits/stdc++.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
int mod = 1000000000+7;

int main(){

	int d;
	cin>>d;
	int c[26];
	rep(i,26)cin>>c[i];
	int lastd[26]={};
	int s[d][26];
	rep(i,d){
		rep(j,26){
			cin>>s[i][j];
		}
	}

	ll ans=0,maxi=0,maxid=0;
	ll ans2=0;
	int t[d]={};
	rep(i,d){
		maxi=0;
		rep(j,26){
			ans=s[i][j];
			rep(k,26){
				if(k==j)continue;
				ans-=c[k]*(i+1-lastd[k]);
			}
			if(ans>maxi){
				maxi=ans;
				maxid=j;
			}
		}
		ans2+=maxi;
		lastd[maxid]=i+1;
		t[i]=maxid;
	}

	rep(i,d){
		cout<<t[i]+1;
		if(i!=d-1)cout<<endl;
	}

	return 0;
}


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

int main(){
    int N,X;
    cin>>N>>X;
    vector<int> L(N);
    for(int i=0;i<N;i++){
        cin>>L[i];
    }
    vector<int> D(N+1);
    D[0]=0;
    int cnt=1;
    for(int i=1;i<N+1;i++){
        D[i]=D[i-1]+L[i-1];
        if(D[i]<=X){
            cnt++;
        }
        else{
            break;
        }
    }
    cout<<cnt<<endl;

}

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

const int dx[4] = {0,0,-1,1};
const int dy[4] = {-1,1,0,0};
int W, H;
char c[101][101];

void dfs(int x, int y, char ch){
	c[y][x] = 0;
	for(int i = 0 ; i < 4 ; i++ ){
		int mx = x + dx[i], my = y + dy[i];
		if( mx < 0 || my < 0 || W <= mx || H <= my ) continue;
		if( c[my][mx] == ch){
			dfs(mx, my, ch);
		}
	}
}

int main(){
	while( cin >> H >> W , W || H ){
		for(int y = 0 ; y < H ; y++ ) cin >> c[y];
		int ans = 0;
		for(int y = 0 ; y < H ; y++ ){
			for(int x = 0 ; x < W ; x++ ){
				if( c[y][x] != 0 ){
					ans++;
					dfs(x, y, c[y][x]);
				}
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1640
using System;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = Int32.Parse(Console.ReadLine());
            var b = Int32.Parse(Console.ReadLine());
            var c = Int32.Parse(Console.ReadLine());
            var x = Int32.Parse(Console.ReadLine());

            var result = 0;
            for (int i = 0; i < a + 1; i++)
            {
                for (int j = 0; j < b + 1; j++)
                {
                    for (int k = 0; k < c + 1; k++)
                    {
                        if (500 * i + 100 * j + 50 * k == x) result++;
                    }
                }
            }

            Console.WriteLine(result);
        }
    }
}


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

#define MAXN (300010)
#define MAXM (100010)
#define lowbit(x) ((x) & (-(x)))

int n, m;
std::pair<int, int> seg[MAXN];
int cnt[MAXM];

bool cmp(const std::pair<int, int> &A, const std::pair<int, int> &B){
	return A.second - A.first < B.second - B.first;
}

void insert(int loc, int d){
	for(int i = loc; i <= m; i += lowbit(i)){
		cnt[i] += d;
	}
}

int getsum(int loc){
	int ret = 0;
	for(int i = loc; i; i -= lowbit(i)){
		ret += cnt[i];
	}
	return ret;
}

int main(){
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= n; ++ i){
		scanf("%d%d", &seg[i].first, &seg[i].second);
	}
	std::sort(seg + 1, n + seg + 1, cmp);
	for(int d = 1, i = 1; d <= m; ++ d){
		while(i <= n && seg[i].second - seg[i].first + 1 <= d){
			insert(seg[i].first, 1);
			insert(seg[i].second + 1, -1);
			++ i;
		}
		int ans = n - i + 1;
		for(int j = 1; j * d <= m; ++ j){
			ans += getsum(j * d);
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 3712
// ACM-ICPCà\I2010 F. Ã¢L¯

#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <string.h>

using namespace std;

const int INF = 100000000;

int d;
string mes, cur;
vector<string> piece;
vector<int> connect[30][20];
vector<string> ans;
set<string> mem[43];
int dp[43][43];
int cost[30][20];
int curdist;

int getMinedit(string s, string t){
	int n = s.size(), m = t.size();
	int cost[43], newcost[43];
	for(int i=0;i<=n;i++) cost[i] = 0;
	for(int j=1;j<=m;j++){
		newcost[0] = j;
		for(int i=1;i<=n;i++){
			newcost[i] = 1+min(newcost[i-1],cost[i]);
			newcost[i] = min(newcost[i],cost[i-1]+(s[i-1]!=t[j-1]));
		}
		memcpy(cost, newcost, sizeof(cost));
	}
	return *min_element(cost, cost+n+1);
}

bool editDist(int s, int e){
	for(int i=s+1;i<=e;i++){
		curdist = INF;
		for(int j=max(1,i-d);j<=min((int)mes.size(),i+d);j++){
			if(cur[i-1]==mes[j-1]) dp[i][j] = dp[i-1][j-1];
			else {
				dp[i][j] = dp[i-1][j-1]+1;
				dp[i][j] = min(dp[i][j], dp[i-1][j]+1);
				dp[i][j] = min(dp[i][j], dp[i][j-1]+1);
			}
			curdist = min(curdist, dp[i][j]);
		}
		if(curdist > d) return false;
	}
	return true;
}

void dfs(int pIdx, int p1, int p2){
	int len = piece[0].size();
	int csize = cur.size();
	if(dp[csize][mes.size()] <= d) ans.push_back(cur);
	int start = min(len-1, csize-p2-1);
	cur += string(len-1-start, ' ');
	int ccost = curdist;
	for(int i=start;i>=0;i--){
		int nsize = csize+len-i;
		if(nsize > mes.size() + d) break;
		cur += ' ';
		for(int j=0;j<connect[pIdx][i].size();j++){
			if(ccost + cost[connect[pIdx][i][j]][i] > d) continue;
			bool flag = true;
			for(int k=i;k<len;k++){
				cur[csize+k-i] = piece[connect[pIdx][i][j]][k];
				if(!editDist(csize+k-i, csize+k-i+1)){
					flag = false;
					break;
				}
			}
			if(!flag) continue;
			if(mem[nsize].count(cur)) continue;
			mem[nsize].insert(cur);
			dfs(connect[pIdx][i][j], nsize, p1);
		}
	}
	cur = cur.substr(0, csize);
}

int main(){
	int n, len;
	for(int i=0;i<=42;i++) dp[i][0] = dp[0][i] = i;
	while(cin >> d >> n, n){
		cin >> mes;
		piece.clear();
		for(int i=0;i<n;i++){
			string str; cin >> str;
			if(getMinedit(mes, str) > d) continue;
			piece.push_back(str);
		}
		sort(piece.begin(), piece.end());
		piece.erase(unique(piece.begin(), piece.end()), piece.end());
		len = piece[0].size();
		for(int i=1;i<=mes.size()+d;i++)
			for(int j=1;j<=mes.size()+d;j++)
				if(abs(i-j) > d) dp[i][j] = INF;
		for(int i=0;i<piece.size();i++){
			for(int j=0;j<len;j++){
				connect[i][j].clear();
				for(int k=0;k<piece.size();k++){
					if(piece[i].substr(len-j) == piece[k].substr(0,j)){
						connect[i][j].push_back(k);
						cost[k][j] = getMinedit(mes, piece[k].substr(j));
					}
				}
			}
		}
		for(int i=0;i<=mes.size()+d;i++)
			mem[i].clear();
		ans.clear();
		for(int i=0;i<piece.size();i++){
			cur = piece[i];
			if(!editDist(0, len)) continue;
			dfs(i, len, 0);
		}
		sort(ans.begin(), ans.end());
		cout << ans.size() << endl;
		if(ans.size() <= 5){
			for(int i=0;i<ans.size();i++)
				cout << ans[i] << endl;
		}
	}
}

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

typedef long long ll;
int main(){
  int N;
  cin >> N;
  map<string, bool> m;
  string now;
  cin >> now;
  
  m[now] = true;
  string next;
  
  bool flg = true;
  for(int i = 0; i < N-1; i++){
    cin >> next;
    if(now[now.size()-1] == next[0]){

    } else {
      flg = false;
      break;
    }
    if(m.count(next) != 0){
      flg = false;
      break;
    } else { 
      m[next] = true;
    }
    
    now = next;
  }
  
  cout << (flg ? "Yes" : "No" ) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    char str[1000] = {}, tmp_str[1000] = {};
    int count;
    char order[10];
    int a, b;
    char p[1000];
    scanf("%s %d", str, &count);
    
    for(int i=0; i<count; i++){
        scanf("%s %d %d", order, &a, &b);
        
        strcpy(tmp_str, str);
        
        if(strcmp(order, "print") == 0){
            for(int j=a; j<=b; j++){
                printf("%c", str[j]);
            }
            printf("\n");
        }else if(strcmp(order, "reverse") == 0){
            for(int j=a; j<=b; j++){
                str[j] = tmp_str[a+b-j];
            }
        }else{
            scanf("%s", p);
            strncpy(str+a, p, b-a+1);
        }
    }
    return 0;
}


Measured memory_bytes: 2100
# -*- coding:utf-8 -*-

n = int(input())
h = input().split()
h_int = [int(i) for i in h]
count = 0
flag = 0

for i in range(n):
    #print(i)
    for j in range(i):
        if h_int[i] < h_int[i-1-j]:
            #print("{} {}".format(h[i-j], h[i]))
            flag = 1
            break
    if flag == 0:
        count += 1
    else:
        flag = 0

print(count)

Measured memory_bytes: 3064
(defun get-input-array (n)
  (let ((rst (make-array n)))
    (dotimes (i n)
      (setf (aref rst i) (read)))
    rst))

(defun main (n)
  (let* ((input (get-input-array n))
        (rst "APPROVED"))
    (loop for x across input
          if (equal 0 (mod x 2))
          do (if (and (not (equal 0 (mod x 3)))
                      (not (equal 0 (mod x 5))))
                 (progn (setf  rst "DENIED")
                   (return)))
          )
    rst))

(format t "~A~%" (main (read)))


Measured memory_bytes: 16864
n = int(input())
arr = list(map(int, input().split()))

colors = [0] * 8
over = 0

for i in arr:
    if i >= 3200:
        over += 1
    else:
        colors[i // 400] += 1

res = 8 - colors.count(0)
if res:
    print(res, res+over)
else:
    print(1, over)

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

using Vi = vector<int>;
using VVi = vector<Vi>;
const int INF = 1e9;

void solve() {
  int N, M, X;
  cin >> N >> M >> X;
  M++;
  VVi v(N, Vi(M));
  for (auto &e1 : v)
    for (auto &e2 : e1) cin >> e2;

  int ans = INF;
  for (int bit = 0; bit < (1 << N); bit++) {
    Vi t(M, 0);
    int sum = 0;
    rep(i, 0, N) {
      if (bit & (1 << i)) {
        sum += v[i][0];
        rep(j, 1, M) t[j] += v[i][j];
      }
    }
    bool ok = true;
    rep(k, 1, M) if (t[k] < X) ok = false;
    if (ok) ans = min(ans, sum);
  }
  cout << ((ans == INF) ? -1 : ans) << endl;
}

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

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

using namespace std;

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

  vector<pair<int, int>> vp1(n), vp2(n);
  for (auto &p : vp1) {
    cin >> p.first >> p.second;
  }

  for (auto &p : vp2) {
    cin >> p.first >> p.second;
  }

  vector<vector<int>> indeces(n);
  vector<int> ref_cnts(n, 0);
  for (int i = 0; i < n; i++) {
    auto [x1, y1] = vp1[i];
    for (int j = 0; j < n; j++) {
      auto [x2, y2] = vp2[j];
      if (x1 < x2 && y1 < y2) {
        ref_cnts[j]++;
        indeces[i].push_back(j);
      }
    }
  }

  for (int i = 0; i < indeces.size(); ++i) {
    sort(indeces[i].begin(), indeces[i].end(),
         [&](auto &a, auto &b) { return ref_cnts[a] < ref_cnts[b]; });
  }

  sort(indeces.begin(), indeces.end(),
       [](auto &a, auto &b) { return a.size() < b.size(); });

  vector<int> used(n, false);
  int ans = 0;
  for (int i = 0; i < indeces.size(); ++i) {
    for (int j = 0; j < indeces[i].size(); ++j) {
      if (!used[indeces[i][j]]) {
        used[indeces[i][j]] = true;
        ans++;
        break;
      }
    }
  }

  cout << ans << '\n';
}

Measured memory_bytes: 3600
import java.util.*;

public class Main{
    static int[][] field;
    static int[] x,y;
    static int arrange;
    static int setX,setY;

    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);

	x = new int[4];
	y = new int[4];

	x[0] = sc.nextInt();

	while(x[0]<5){
	    field = new int[8][8];
	    arrange = 0;
	    int count = 0;

	    y[0] = sc.nextInt();
	    for(int i=1; i<4; i++){
		x[i] = sc.nextInt();
		y[i] = sc.nextInt();
	    }

	    solve(count);

	    System.out.println(arrange);

	    x[0] = sc.nextInt();
	}
    }

    public static void solve(int count){
	if(count==8){arrange++; return;}

	for(int i=0; i<4; i++){
	    set();
	    if(setX!=-1){
		int xx = setX;
		int yy = setY;
		if(setPair(i,xx,yy)){
		    field[yy+y[i]][xx+x[i]] = 1;
		    solve(count+1);
		    field[yy+y[i]][xx+x[i]] = 0;
		}
		field[yy][xx] = 0;
	    }
	}
    }

    public static void set(){
	for(int i=0; i<4; i++){
	    for(int j=0 ;j<4; j++){
		if(field[i][j]==0){
		    field[i][j] = 1;
		    setX = j;
		    setY = i;
		    return;
		}
	    }
	}
	setX = -1;
    }

    public static boolean setPair(int num, int xx, int yy){
	if(yy+y[num]<0 || xx+x[num]<0 || yy+y[num]>3 || xx+x[num]>3){return false;}
	if(field[yy+y[num]][xx+x[num]]==0){return true;}
	return false;
    }
}

Measured memory_bytes: 11000
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>

using namespace std;
#define ll long long
#define repX(i,j,n) for (ll i = j; i < n; i++)
#define rep(i, n) repX(i,0,n)
#define BIG 100000000

int main()
{
    ll n,l,sum = 0,pos_min=BIG;
    cin >> n>> l;
    
    for(int i=1;i<=n;i++)
    {
        ll t = l+i-1;
        sum +=t;
        
        if(t >=0 && pos_min >= t )
        {
            pos_min = t;
        }
    }
    
    if(pos_min!=BIG)
    cout << sum - pos_min << endl;
    else
        cout << sum - (l+n-1) << endl;
    
    return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;

int main() {
  int N;
  cin >> N;
  vector<P> ans;
  for (int i = 1; i <= N; i++) {
    for (int j = i+1; j <= N; j++) {
      if (i == j || i + j == ((N/2) * 2) + 1) {
        continue;
      } else {
        ans.push_back(make_pair(i,j));
      }
    }
  }
  cout << (int)ans.size() << endl;
  for (int i = 0; i < (int)ans.size(); i++) {
    cout << ans[i].first << " " << ans[i].second << endl;
  }
  return 0;
}

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

int main() {
  string s;
  cin >> s;
  vector<string> ans = {"Sunny", "Cloudy", "Rainy"};
  if (s[0] == 'S') cout << ans[1] << '\n';
  else if (s[0] == 'C') cout << ans[2] << '\n';
  else cout << ans[0] << '\n';
  return 0;
}

Measured memory_bytes: 3532
#include<stdio.h>
int main()
{
	int n,i;
	int a[1000];
	scanf("%d",&n);
	for(i=0;i<4;i++)
	{
		a[i]=n%10;
		n=n/10;
	}
	if((a[0]==a[1]&&a[1]==a[2])||(a[1]==a[2]&&a[2]==a[3])||(a[0]==a[1]&&a[1]==a[2]&&a[2]==a[3]))
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main()
{
    int a,b;cin>>a>>b;

    if(a<b)
    {
        for(int i=0;i<b;i++)
        {
            cout<<a;
        }
    }else{
        for(int i=0;i<a;i++)
        {
            cout<<b;
        }

    }

   return 0;
}


Measured memory_bytes: 256
def power(n, m):
    ret = 1
    for i in range(m):
        ret *= n
    return ret

M, K = map(int, input().split())
if K >= power(2, M):
    print(-1)
else:
    if M == 0:
        print(0, 0)
    elif M == 1:
        if K == 1:
            print(-1)
        else:
            print(0, 0, 1, 1)
    else:
        ans = []
        N = power(2, M)
        if K % 2 == 1:
            ans.append(K)
            ans.append(K - 1)
            for i in range(0, N):
                if i == K or i == K - 1:
                    continue
                ans.append(i)
            ans.append(K)
            for i in range(N - 1, -1, -1):
                if i == K or i == K - 1:
                    continue
                ans.append(i)
            ans.append(K - 1)
        else:
            ans.append(K)
            ans.append(K + 1)
            for i in range(0, N):
                if i == K or i == K + 1:
                    continue
                ans.append(i)
            ans.append(K)
            for i in range(N - 1, -1, -1):
                if i == K or i == K + 1:
                    continue
                ans.append(i)
            ans.append(K + 1)
        print(" ".join(map(str, ans)))

Measured memory_bytes: 31668
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    int N; cin >> N;
    vector<int> A(N);
    for (int i = 1; i < N; ++i) {
        cin >> A[i];
        --A[i];
    }

    vector< vector<int> > parts(N);
    vector<int> seen(N, 0), depth(N, 0);
    for (int i = 1; i < N; ++i)
        seen[A[i]]++;
    queue<int> Q;
    for (int i = 0; i < N; ++i)
        if (seen[i] == 0) {
            Q.push(i);
        }
    while (!Q.empty()) {
        int top = Q.front();
        Q.pop();

        sort(parts[top].begin(), parts[top].end(), [&](int x, int y) {
            return depth[x] < depth[y];
        });
        for (auto &lost : parts[top])
            depth[top] = max(depth[top], depth[lost]) + 1;
        if (top == 0)
            continue;
        parts[A[top]].push_back(top);
        if (--seen[A[top]] == 0)
            Q.push(A[top]);
    }
    cout << depth[0] << "\n";
}



Measured memory_bytes: 6912
import java.util.*;

public class Main {
	
	void run() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		
		int maxDiff = Integer.MIN_VALUE;
		int minVal = scan.nextInt();
		
		for (int i = 1; i < n; i++) {
			int val = scan.nextInt();
			int diff = val - minVal;
			if (maxDiff < diff) {
				maxDiff = diff;
			}
			if (minVal > val) {
				minVal = val;
			}
		}
		
		System.out.println(maxDiff);
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().run();
	}

}



Measured memory_bytes: 68580
S = (input())
ue=int(S[0]+S[1])
shita=int(S[2]+S[3])

if 1 <= ue <= 12:
    if 1 <= shita <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 1 <= shita <= 12:
        print('YYMM')
    else:
        print('NA')

Measured memory_bytes: 2940
fun main( args : Array<String> ) {
  val bbb   = 1000000007L
  val (a,b) = readLine()!!.split(" ").map { it.toInt() }
  val A     = listOf(1L, (1L..a).map { it.toLong() }. reduce {y,x -> 
                    (y%bbb*x%bbb)%bbb
                  } ).max()!!
  val B     = listOf(1L, (1L..b).map { it.toLong() }.reduce {y,x -> 
                    (y%bbb*x%bbb)%bbb
                  } ).max()!!
  when {
    a == b -> (A%bbb*B%bbb)%bbb*2%bbb
    a+1 == b || a == b+1 -> (A%bbb*B%bbb)%bbb
    else -> 0
  }.let { println(it) }
}

Measured memory_bytes: 49152
#ABC119 D - Lazy Faith
from bisect import bisect_left,bisect_right
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

a,b,q = map(int, input().split())
INF = 10**11
S = [-INF]+[int(input()) for _ in range(a)]+[INF]
T = [-INF]+[int(input()) for _ in range(b)]+[INF]
X = [int(input()) for _ in range(q)]

for i in range(q):
    idx_s = bisect_right(S,X[i])
    idx_t = bisect_right(T,X[i])
    ans = INF
    for s in [S[idx_s-1],S[idx_s]]:
        for t in [T[idx_t-1],T[idx_t]]:
            d1,d2 = abs(s-X[i])+abs(s-t),abs(t-X[i])+abs(t-s)
            ans = min(ans,d1,d2)
    print(ans)


Measured memory_bytes: 18048
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <locale>
#include <random>
#include <cassert>
#include <sstream>
using namespace std;
#define F first
#define S second
#define pb push_back
#define MP make_pair
#define ALL(x) begin(x), end(x)
#define SZ(x) (int)(x).size()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rep1(i, a, b) for(int i = a; i < b; ++i)
#define per1(i, a, b) for(int i = a; i >= b; --i)
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ln(i, n) " \n"[i == n]
typedef long long LL;
typedef long double LDB;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
//////////////////////
const long double eps = 1e-13;
const long double PI = acos(-1);
const int INF = (int)1e9;
const LL  INFF = (LL)1e18;
const int mod = 998244353;
const int MXN = (int)2e5 + 7;
int main(void){
	int a, b, c; cin >> a >> b >> c;
	int ans = 0;
	if(c > b){
		ans += b + 1 + b;
		c -= b + 1;
		ans += min(a, c);
	} else{
		ans = b + c;
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

int N;
int A[214514];
LL ans;

int main(){
  scanf("%d", &N);
  rep(i, N) {
    scanf("%d", &A[i]);
  }

  int bound = 0;
  rrep(i, N) {
    if (A[i] < bound) {
      puts("-1");
      return 0;
    }

    if (A[i] > bound) {
      ans += A[i];
      bound = A[i];
    }
    
    if (i == 0 && bound > 0) {
      puts("-1");
      return 0;
    }

    if (bound > 0) bound--;
  }

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


Measured memory_bytes: 1152
#pragma GCC optimize ("Ofast","unroll-loops")
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define MP make_pair
#define F first
#define S second
#define MEM(a,b) memset(a,b,sizeof a)
#define Tie ios::sync_with_stdio(0),cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

ll n,a[410],dp[410][410];
const ll INF=1LL<<62;

int main()
{Tie
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i],a[i]+=a[i-1];
	for(int i=1;i<n;i++)
		for(int j=1;j+i<=n;j++)
		{
			dp[j][j+i]=dp[j+1][i+j];
			for(int k=j;k<j+i;k++)
				dp[j][j+i]=min(dp[j][j+i],dp[j][k]+dp[k+1][i+j]);
			dp[j][j+i]+=a[j+i]-a[j-1];
		}
		
	cout << dp[1][n]<<'\n';
}

Measured memory_bytes: 1536
#include<iostream>
#include<vector>
#include<tuple>
using namespace std;
int main(){
    int h,w,n=0;
    vector<tuple<int,int,int,int>>ans;
    cin>>h>>w;
    int a[h][w];
    for(int i=0;i<h;i++)for(int j=0;j<w;j++){cin>>a[i][j];a[i][j]%=2;}
    for(int i=0;i<h;i++){
        if(i%2){
            for(int j=w-1;j>0;j--){
                if(a[i][j]){
                    a[i][j-1]=(a[i][j-1]+1)%2;
                    ans.push_back(make_tuple(i+1,j+1,i+1,j-1+1));
                    n++;
                }
            }
            if(i!=h-1&&a[i][0]){
                a[i+1][0]=(a[i+1][0]+1)%2;
                ans.push_back(make_tuple(i+1,0+1,i+1+1,0+1));
                n++;
            }
        }
        else{
            for(int j=0;j<w-1;j++){
                if(a[i][j]){
                    a[i][j+1]=(a[i][j+1]+1)%2;
                    ans.push_back(make_tuple(i+1,j+1,i+1,j+1+1));
                    n++;
                }
            }
            if(i!=h-1&&a[i][w-1]){
                a[i+1][w-1]=(a[i+1][w-1]+1)%2;
                ans.push_back(make_tuple(i+1,w-1+1,i+1+1,w-1+1));
                n++;
            }
        }
    }
    cout<<n<<endl;
    for(auto x:ans)cout<<get<0>(x)<<" "<<get<1>(x)<<" "<<get<2>(x)<<" "<<get<3>(x)<<endl;
    return 0;
}

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

constexpr int64_t MOD = 1e9 + 7;

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

    map<int64_t, int64_t> factors;
    for (int64_t i = 2; i <= n; i++) {
        for (int64_t j = 2, d = i; d != 1; j++) {
            while (d % j == 0) {
                d /= j;
                factors[j]++;
            }
        }
    }

    int64_t ans = 1;
    for (auto& e : factors) ans = ans * (e.second + 1) % MOD;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
//cout << "Yes" << endl;
//cout << "No" << endl;
int seiyaku_check(long i,int Min,long Max){
	if(Min <= i && i <= Max){
		return 1;
	}else{
		exit(1);
	}
}

int main(){
	
	int a,b,c;
	
	cin >> a >> b >> c;
	
	seiyaku_check(a,1,13);
	seiyaku_check(b,1,13);
	seiyaku_check(c,1,13);
	
	if( a+b+c >= 22)cout << "bust" << endl;
    if( a+b+c < 22)cout << "win" << endl;
	
return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<vector>

using namespace std;

int main(){
    long long n, k, d[109], mx=0;
    cin >> n >> k;
    for(int i=0;i<n;i++){
        cin >> d[i];
    }
    for(int i=1;i<=min(n, k);i++){
        for(int j=0;j<=i;j++){
            long long sm=0;
            priority_queue<long long, vector<long long>, greater<long long> > q;
            while(!q.empty())q.pop();
            for(int l=0;l<j;l++){
                sm += d[l];         
                q.push(d[l]);
            }
            for(int l=0;l<i-j;l++){
                sm += d[n-1-l];
                q.push(d[n-1-l]);
            }
            for(int l=0;l<k-i;l++){
                if(q.top()>0 || q.empty())break;
                sm -= q.top();q.pop();
            }
            mx = max(sm, mx);
        }
    }
    cout << mx << endl;
}

Measured memory_bytes: 256
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

x = int(input())
print(a[x-1])

Measured memory_bytes: 9012
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      n: usize,
      k: usize,
      hs: [isize; n],
    }
    const INF: isize = 1 << 32;
    let mut dp = vec![INF; n];

    dp[0] = 0;
    dp[1] = (hs[1]-hs[0]).abs();

    for i in 2..n {
        for j in 1..k+1 {
            if i < j { break; }
            dp[i] = min(dp[i], (hs[i]-hs[i-j]).abs() + dp[i-j]);
        }
    }
    println!("{}", dp[n-1]);
}


Measured memory_bytes: 6396
import java.util.*;
import java.io.*;

public class Main {

	static void solve (Scanner in, PrintWriter out, Methods ms) {

		while (true) {

			double[] a = {in.nextDouble(), in.nextDouble(), in.nextDouble()};
			if (a[0] == 0 && a[1] == 0 && a[2] == 0) return;
			
			Arrays.sort(a);
			double len = Math.sqrt(a[0] * a[0] + a[1] * a[1]);

			int n = in.nextInt();
			for (int i = 0; i < n; i++) {
				String ans = "NA";
				if (len < in.nextDouble() * 2) {
					ans = "OK";
				}
				out.println(ans);
			}


		}

	}



	public static void main (String[] args) {

		Scanner in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		Methods ms = new Methods();
		solve(in, out, ms);
		in.close();
		out.close();

	}

	static class Methods {

		public void print (Object... ar) {System.out.println(Arrays.deepToString(ar));}

		public int max (int... ar) {Arrays.sort(ar); return ar[ar.length-1];}

		public int min (int... ar) {Arrays.sort(ar); return ar[0];}

		public long gcd (long a, long b) {return b > 0 ? gcd(b,a%b) : a;}

		public long lcm (long a, long b) {return a / gcd(a,b) * b;}

		public long factorial (int i) {
			if (i == 1) return 1;
			else return i * factorial(i-1);
		}

		public int manhat (int x1, int y1, int x2, int y2) {
			return Math.abs(x1 - x2) + Math.abs(y1 - y2);
		}

		public double euclid (double x1, double y1, double x2, double y2) {
			return Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
		}

		public boolean isPrime (int n) {
			if (n == 2) return true;
			if (n < 2 || n % 2 == 0) return false;
			for (int i = 3; i <= Math.sqrt(n); i += 2) if(n % i == 0) return false;
			return true;
		}

	}

}


Measured memory_bytes: 28300
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int x, a, b; cin >> x >> a >> b;
    bool judge = 0;
    if(x > b) judge = 1;
    else if(x + a < b) judge = 1;
    cout << (judge ? "NO" : "YES") << endl;
}

Measured memory_bytes: 256
N = int(input())
L = list(map(int, input().split()))

def two_counter(i):
    if i == 0:
        # 10 ** 100 == inf
        return 10 ** 100
    cnt = 0
    while i%2 == 0:
        cnt += 1
        i /= 2
    return cnt
ans = 10 ** 100

visual = [two_counter( L[i] ) for i in range(N)]
print(min(visual))

Measured memory_bytes: 38768
#include <cstdlib>
#include <iostream>
#include <string>
#include <time.h>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <vector>
//#include "bits/stdc++.h"
using namespace std;
//using namespace std::vector;
#define rep(i,a,b) for(int i=(a);i<(b);++i)


#define huge 1000000007
typedef long long ll;

int main(void) {

	ll N = 0;
	ll A = 0;
	ll B = 0;
	ll C = 0;
	ll K = 0;
	ll W = 0;
	ll X = 0;
	//ll m[100000] = {};
	ll w[3] = {};
	ll v[100] = {};
	ll *x, *c, *d;
	string S,T,U;
	ll count = 0;
	ll sum = 0;
	ll min = 1;
	ll max = 0;
	int flag = 0;
	char temp,head;
	//char p;
	cin >>S >> T;
	
	rep(i, 0, S.length()) {


		if (S == T) {
			sum++;
			break;
		}
		else {

			head = S[0];
			rep(j, 0, S.length()-1) {
				
				S[j] = S[j + 1];

			}
			
			S[S.length() - 1] = head;
		}

	}

	if (sum == 1)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;

}



Measured memory_bytes: 256
from collections import Counter

N = int(input())
S = input()
index = Counter(S)
ans = index["R"]*index["G"]*index["B"]

for diff in range(1, N//2 +1):
    for i in range(N):
        j = i +diff
        k = j +diff
        if k >= N:
            break
        if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
            ans -= 1
print(ans)

Measured memory_bytes: 68924
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

int main(){
	ll x,y,z;
	scanf("%lld%lld%lld",&x,&y,&z);
	puts(llabs(y-x)<llabs(z-x)?"A":"B");
}

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

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;

int main(){
  int N,M;
  vector<int> G[100000];
  int s,t;
  vector<vector<ll>> dp(100000,vector<ll>(3,INFll));
  cin>>N>>M;
  for(int i(0);i<M;i++){
    int u,v;
    cin>>u>>v;
    u--;v--;
    G[u].push_back(v);
  }
  cin>>s>>t;
  s--;t--;
  dp[s][0] = 0;
  queue<pair<int,int>> q;
  q.push({s,0});
  while(!q.empty()){
    pair<int,int> now = q.front();q.pop();
    for(auto next:G[now.first]){
      if(dp[next][(now.second+1)%3] == INFll){
        dp[next][(now.second+1)%3] = now.second + 1;
        q.push({next,now.second+1});
      }
    }
  }
  if(dp[t][0] != INFll){
    cout << dp[t][0]/3 << endl;
  }else{
    cout << -1 << endl;
  }
  return 0;
}


Measured memory_bytes: 14024
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
const ll MAX = 1000000;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for(int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
ll COM(int n, int k) {
  if(n < k) return 0;
  if(n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	ll x,y;
	cin >> x >> y;

	if((x+y)%3>0){
		puts("0");
		return 0;
	}
	ll m = (2*x-y)/3;
	ll n = (2*y-x)/3;
	if(m<0 || n<0){
		puts("0");
		return 0;
	}
	COMinit();
	cout << COM(m+n, n) << '\n';

	return 0;
}



Measured memory_bytes: 23680
#include <iostream>
using namespace std;
typedef long long ll;

int main() {
  ll a, b, x;
  cin >> a >> b >> x;
  ll l = a % x ? a + (x - a % x) : a;
  ll r = b - (b % x);
  ll ans;
  if (l > r) ans = 0;
  else if (l == r) ans = 1;
  else ans = (r - l) / x + 1;
  cout << ans << endl;
}

Measured memory_bytes: 256
// vim: set fdm=marker:
// {{{
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <utility>

using namespace std ;

typedef long long ll ;

// }}}

ll sol(const vector<int>& xs, int K) {
  assert(xs.size() >= K);
  ll ans = 2*(xs.back() - xs[0]);
  for (int i = 0 ; i + K <= xs.size() ; i++) {
    ll leftLoc = xs[i];
    ll rightLoc = xs[i+K-1];
    if (leftLoc >= 0) // both location are >= 0
      ans = min(ans, rightLoc);
    else if (rightLoc <= 0) // both location are <= 0
      ans = min(ans, -leftLoc);
    else // leftLoc <= 0, rightLoc >= 0
      ans = min(ans, min(2*(-leftLoc)+rightLoc, 2*rightLoc+(-leftLoc)));
  }
  return ans;
}


int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> x;
    for (int i = 0 ; i != N ; i++)
    {
        int now;
        cin >> now;
        x.push_back(now);
    }
    cout << sol(x, K) << endl;
    return 0;
}



Measured memory_bytes: 892
#include<cstdio>
#include<iostream>
#include<queue>
#include<stack>
#define MAX_N 100000000

using namespace std;

int main(){
    int num[31]={0};
    int i;
    int a;
    for(int i=1;i<=28;i++){
        scanf("%d",&a);
        num[a]=1;
    }
    for(int i=1;i<=30;i++){
        if(num[i]==0){
            printf("%d\n",i);
        }
    }
}

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

using lli = long long int;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

int main(void){
    int n;
    cin >> n;
    vector<lli> h(n);
    for(auto& i : h) cin >> i;
    bool can = true;
    for(int i = n-1; i > 0; i--){
        if(h.at(i-1) - h.at(i) >= 2){
            can = false;
            break;
        }else if(h.at(i-1) - h.at(i) == 1){
            h.at(i-1)--;
        }else{
            continue;
        }
    }
    if(can == true) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

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

	if (x == 0) {
		cout << 1 << endl;
	}
	else {
		cout << 0 << endl;
	}

}


Measured memory_bytes: 3672
#include <stdio.h>
int main(void){
  int a,b,c,d=0;
  int i;
  scanf("%d%d%d",&a,&b,&c);
 for(i=0;i<=100;i++){
     if((i*b+c)%a==0){
       printf("YES\n");
       d=1;
       break;
     }
 }
  if(d==0){
 printf("NO\n");
  }
      return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<math.h>

using namespace std;

void write(int , int);
int main()
{
  int H, W;
  cin >> H >> W;
  while(H!=0 || W!=0){
    write(H, W);
    cin >> H >> W;
  }
  return 0;
}

void write(int H, int W){
  for(int y=0; y<H; y++){
    for(int x=0; x<W; x++){
      if(x==0 || y==0 || x==(W-1) || y==(H-1))cout << '#';
      else cout << '.';
    }
    cout << endl;
  }
  cout << endl;
}



Measured memory_bytes: 3088