akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace NotFounds
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve();
        }

        public void Solve()
        {
            var cin = new MyInputStream();
            var N = cin.ri();
            var A = cin.ri();
            var B = cin.ri();
            var h = new int[N];
            for (int i = 0; i < N; ++i)
                h[i] = cin.ri();

            var diff = A - B;
            Func<long, bool> check = (K) =>
            {
                var k = K;
                for (int i = 0; i < N; ++i)
                {
                    var t = h[i] - B * K;
                    if (t > 0)
                        k -= (long)Math.Ceiling((double)t / diff);
                }
                return k >= 0;
            };

            var r = (long)0;
            var l = (long)1e9;
            for (int i = 0; i < 40; ++i)
            {
                var mid = (l + r) >> 1;
                if (check(mid))
                {
                    l = mid;
                }
                else
                {
                    r = mid;
                }
                //WriteLine($"{r} {l}");
            }
            WriteLine(l);
        }
    }

    public class MyInputStream
    {
        private char separator = ' ';
        private Queue<string> inputStream;
        public MyInputStream(char separator = ' ')
        {
            this.separator = separator;
            inputStream = new Queue<string>();
        }

        public string Read()
        {
            if (inputStream.Count != 0) return inputStream.Dequeue();
            string[] tmp = Console.ReadLine().Trim().Split(separator);
            for (int i = 0; i < tmp.Length; i++)
            {
                inputStream.Enqueue(tmp[i]);
            }
            return inputStream.Dequeue();
        }
        public string ReadLine() => Console.ReadLine();
        public int ReadInt() => int.Parse(Read());
        public long ReadLong() => long.Parse(Read());
        public double ReadDouble() => double.Parse(Read());
        public string r() => Read();
        public int ri() => ReadInt();
        public long rl() => ReadLong();
        public double rd() => ReadDouble();
    }
}


Measured memory_bytes: 15568
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <stdio.h>
#include <fstream>
#include <cmath>
#include <stdlib.h>
#include <iomanip>
#include <algorithm>
#include <limits.h>
using namespace std;
#define FAST_IO ios::sync_with_stdio(false);
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef pair<double,double> pdd;
const int maxn = 1e6 + 10;
int N;
char str[maxn];
int sum_est[maxn],sum_west[maxn];

int main(){
    cin>>N;
    scanf("%s", str + 1);
    int n = strlen(str + 1);
    for(int i = 1;i <= n; i++){
        if(str[i] == 'W') sum_west[i] = 1;
        else sum_est[i] = 1;
    }
    for(int i = 1; i <= n; i++) {
        sum_west[i] += sum_west[i - 1];
        sum_est[i] += sum_est[i - 1];
    }
    int ans = INT_MAX;
    for(int i = 1; i <= n; i++){
        ans = min(ans,sum_west[i - 1] + sum_est[n] - sum_est[i]);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 7552
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N,ans=0;
  cin>>N;
  ll P[N*N],BLACK[N*N],COST[N*N];
  REP(i,N*N){
    cin>>P[i];
    P[i]--;
    BLACK[i]=1;
    COST[i]=N;
    chmin(COST[i],i/N);
    chmin(COST[i],N-1-i/N);
    chmin(COST[i],i%N);
    chmin(COST[i],N-1-i%N);
  }
  
  REP(i,N*N){
    ans+=COST[P[i]];
    BLACK[P[i]]=0;
    
    queue<ll> Q;
    Q.push(P[i]);
    while(!Q.empty()){
      ll v=Q.front();
      Q.pop();
      REP(j,4){
        ll X=v/N+dx[j],Y=v%N+dy[j];
        ll nv=X*N+Y;
        if(X<0 || N<=X || Y<0 || N<=Y) continue;
        if(COST[nv]>COST[v]+BLACK[v]){
          COST[nv]=COST[v]+BLACK[v];
          Q.push(nv);
        }
      }
    }
  }
  
  co(ans);
  return 0;
}

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

int main()
{
  // エラトステネスのふるい
  // 総数を見つけたらそれ以降のその倍数全てをふるい落す
  int MAX = 101010;
  vector<int> is_prime(MAX, 1);
  is_prime[0] = 0, is_prime[1] = 0;
  for (int i = 2; i < MAX; ++i)
  {
    if (!is_prime[i])
      continue;
    for (int j = i * 2; j < MAX; j += i)
      is_prime[j] = 0;
  }

  // 2017-like 数かどうか
  vector<int> a(MAX, 0);
  for (int i = 0; i < MAX; ++i)
  {
    if (i % 2 == 0)
      continue;
    if (is_prime[i] && is_prime[(i + 1) / 2])
      a[i] = 1;
  }

  // 累積和
  vector<int> s(MAX + 1, 0);
  for (int i = 0; i < MAX; ++i)
    // ただの漸化式
    // s[i+1]はi番目までの和なので最後のクエリで+1
    s[i + 1] = s[i] + a[i];

  // クエリ処理
  int Q;
  cin >> Q;
  for (int q = 0; q < Q; ++q)
  {
    int l, r;
    cin >> l >> r;
    cout << s[r + 1] - s[l] << endl;
  }
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n;
vi a;
vvi g;

bool dfs(int v,int p){
	int S=g[v].size();
	if(S>2){
		a[v]++;
		return 0;
	}
	if(S==1&&p>=0) return 1;
	for(auto u:g[v]) if(u!=p) return dfs(u,v);
}

int main(){
	cin>>n;
	a=vi(n);
	g=vvi(n);
	for(int i=0;i<n-1;i++){
		int u,v;
		cin>>u>>v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	for(int i=0;i<n;i++) if(g[i].size()==1) if(dfs(i,-1)){
		cout<<1<<endl;
		return 0;
	}
	int res=0;
	for(int i=0;i<n;i++) if(a[i]) res+=a[i]-1;
	cout<<res<<endl;
}

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

int main(){
  int n;cin >> n;
  int hantei = 0;
  for(int i=1; i<=n; i+=2){
    int count = 0;
    for(int j=1; j<=i; j++){
      if(i % j == 0) count++;
    }
    if(count == 8) hantei++;
  }
  cout << hantei << endl;
}


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

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

	for (int i = 0; i <= N - M; i++) {
		for (int j = 0; j <= N - M; j++) {
			bool match = true;
			for (int k = 0; k < M; k++) {
				if (A[i+k].substr(j, M) != B[k]) {
					match = false;
					break;
				}
			}
			if (match) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
static int a = 0;


void re(int n, int t) {
    if(t == 0){
        if(n == 0) {
            a++;
            return;
        } else return;
    }

    for(int i = 0; i <= 9; i++) {
        re(n - i, t - 1);
    }

    return;
}

int main() {
    int n;
    while(cin >> n) {
        re(n, 4);
        cout << a << endl;
        a = 0;
    }

    return 0;
}

Measured memory_bytes: 1160
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char[] c = s.toCharArray();
        int l = s.length();
        int [] num = new int[l];
        for(int i=0; i<l; i++) {
            num[i] = c[i] - '0';
        }
        int k = sc.nextInt();
        long res = comb(l-1, k) * pow(9, k);

        if(k == 1) {
            res += num[0];
        } else if (k==2 && l >= 2) {
            res += find(num, l, 1, 1) + (num[0]-1) * (l-1) * 9;
        } else if (k==3 && l >=3 ) {
            res += find(num, l, 2, 1) + (num[0]-1) * comb(l-1, 2) * 81;

        }
        System.out.println(res);
    }

    static long find(int[] num, int l, int k, int pos) {
        if(k==0) return 1;
        if(pos + k > l) return 0;
        if(num[pos] == 0) {
            return find(num, l, k, pos+1);
        } else {
            if(k==1) {
                return num[pos] + (l-pos-1) * 9;
            } else {
                return comb(l-pos-1, 2) * 81 + find(num, l, k-1, pos+1) + (num[pos]-1) * comb(l-pos-1, k-1) * pow(9, k-1) ;
            }
        }
    }

    static long comb(int n, int k) {
        if(k == 1) {
            return n;
        }
        if(k == 2) {
            return n * (n-1) / 2;
        }
        return n * (n-1) * (n-2) / 6;
     }

     static long pow(int n, int k) {
        long res = 1;
        for(int i=0; i<k; i++) {
            res *= n;
        }
        return res;
     }

}




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

int main() {
  int n, k, q;
  cin >> n >> k >> q;

  int sum = 0;
  map<int, int> mp;
  for(int i = 0; i < q; i++){
    int a;
    cin >> a;

    mp[a]++;
  }

  int num = n;
  for(int i = 1; i <= n; i++){
    if(q - mp[i] >= k){
      cout << "No" << endl;
    }
    else{
      cout << "Yes" << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 5376
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int gcd(int a,int b){return b?gcd(b,a%b):a;}

ll modpow(ll n,ll k){
  if(k == 1){
    return n;
  }else if(k == 0){
    return 1;
  }else if(k%2==0){
    ll memo = modpow(n,k/2)%MOD;
    return memo*memo%MOD;
  }else{
    return n * modpow(n,k-1)%MOD;
  }
}

int main(){

  int n,k;
  cin>>n>>k;
  cout<<n-k+1<<endl;

 

  return 0;
}

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

int main(){
  long long N;
  cin>>N;
  long long ans=1;
  for(int i=1;i<=N;i++){
    ans*=i;
    ans%=m;
  }
  cout<<ans<<endl;
}
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define rbg rbegin()
#define red rend()
#define all(x) x.bg,x.ed
#define rall(x) x.rbg,x.red
#define pb push_back
#define pf push_front
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> bool chmax(t&a,u b){if(a<b){a=b; return true;} return false;}
template<class t,class u> bool chmin(t&a,u b){if(a>b){a=b; return true;} return false;}
template<class t,class u> t MAX(t a,u b){if(a>=b) return a; return b;}
template<class t,class u> t MIN(t a,u b){if(a<=b) return a; return b;}
template<class t> int SIZE(t s){return (int)s.size();}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using vvi=vc<vc<int>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
const long long INF = 1LL << 60;

int main(){
    cout << fixed << setprecision(20);
    string s; cin >> s;
    int si = SIZE(s);
    rep(i,si){
        if(i % 2 == 0){
            if(s[i] != 'R' && s[i] != 'U' && s[i] != 'D'){
                no();
                return 0;
            }
        } else {
            if(s[i] != 'L' && s[i] != 'U' && s[i] != 'D'){
                no();
                return 0;
            }
        }
    }
    yes();
    return 0;
}


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

li = [0 for i in range(40)]

for i in range(N):
    j = 0
    while((A[i]>>j) > 0):
        if (A[i]>>j)&1:
            li[j] += 1
        j += 1

mm = 0
for j in range(39,-1,-1):
    if li[j] <= N-li[j]:
        if (mm + (1<<j)) <= K:
            mm += 1<<j

ans = 0
for n in range(N):
    ans += mm^A[n]

print(ans)



Measured memory_bytes: 14620
import java.io.*;
public class Main {
	/**
	 * 公舎の入居者数を出力する
	 * @param args
	 * @throws IOException
	 */
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//校舎の件数
		int n = Integer.parseInt(br.readLine());
		//トランプ全てのの配列
		int[][][] count = new int[4][3][10]; 
		//全ての部屋の人数を0人にする
		for(int i = 0; i < 4; i++){
			for(int l = 0; l < 3; l++){
				for(int k = 0; k < 10; k++){
					count[i][l][k] = 0;
				}//for
			}//for
		}//for
		//各棟、各部屋の人数を配列に入れる
		for(int i = 0; i < n; i++){
			String str  = br.readLine();
			String[] strs = str.split(" ");
			int b = Integer.parseInt(strs[0]) - 1;	//各棟
			int f = Integer.parseInt(strs[1]) - 1;	//階
			int r = Integer.parseInt(strs[2]) - 1;	//何番目
			int v = Integer.parseInt(strs[3]);
			count[b][f][r] += v;
			if(count[b][f][r] > 9){
				count[b][f][r] = 9;
			}else if(count[b][f][r] < 0){
				count[b][f][r] = 0;
			}
		}//for
		//出力
		for(int i = 0; i < 4; i++){
			if(i != 0){
				System.out.println("####################");
			}
			for(int l = 0; l < 3; l++){
				for(int k = 0; k < 10; k++){
					System.out.print(" ");
					System.out.print(count[i][l][k]);
				}//for
				System.out.println();
			}//for
		}//for
	}
}

Measured memory_bytes: 19328
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    Set<Integer> set = new HashSet<>();
    for(int i = 0; i < N; i++){
      set.add(Integer.parseInt(sc.next()));
    }
    System.out.println(N == set.size() ? "YES" : "NO");
  }
}

Measured memory_bytes: 68152
#include<stdio.h>
#define SLOPE_STACK_MAX 20000
#define SECTION_STACK_MAX  10000
typedef struct slope_stack_tag{
	int size;
	int (*push)(struct slope_stack_tag *, int);
	int (*pop )(struct slope_stack_tag *);
	int (*top )(struct slope_stack_tag *);
	int slope[SLOPE_STACK_MAX];
} slope_stack;
typedef struct{
	int start;
	int area ;
} section_t;
typedef struct section_stack_tag{
	int size;
	int        (*push)(struct section_stack_tag *, section_t *);
	int        (*pop )(struct section_stack_tag *);
	section_t* (*top )(struct section_stack_tag *);
	section_t section[SECTION_STACK_MAX];
} section_stack;

int slope_pop(slope_stack* ps){
	if(ps->size == 0)
		return -1;
	--ps->size;
	return ps->size;
}
int slope_top(slope_stack* ps){
	return ps->slope[ps->size-1];
}
int slope_push(slope_stack* ps, int slope){
	if(ps->size >= SLOPE_STACK_MAX)
		return -1;
	ps->slope[ps->size] = slope;
	++ps->size;
	return 0;
}
void slope_init(slope_stack* ps){
	ps->size = 0;
	ps->pop = slope_pop;
	ps->top = slope_top;
	ps->push = slope_push;
	return;
}

int section_pop(section_stack* ps){
	if(ps->size == 0)
		return -1;
	--ps->size;
	return ps->size;
}
section_t* section_top(section_stack* ps){
	return &ps->section[ps->size-1];
}
int section_push(section_stack* pss, section_t *pst){
	if(pss->size >= SECTION_STACK_MAX)
		return -1;
	pss->section[pss->size].start = pst->start;
	pss->section[pss->size].area  = pst->area ;
	++pss->size;
	return 0;
}
void section_init(section_stack* ps){
	ps->size = 0;
	ps->pop = section_pop;
	ps->top = section_top;
	ps->push = section_push;
	return;
}
// -------------------------------------------------------------
void add_section(section_stack* pss, section_t* pst){
	if(pss->size == 0 || pss->top(pss)->start < pst->start){
		pss->push(pss, pst);
	}else{
		pst->area += pss->top(pss)->area;
		pss->pop(pss);
		add_section(pss, pst);
	}
	return;
}

int main(void){
	slope_stack   slope_s  ;
	section_stack section_s;
	section_t     section  ;
	char          c        ;
	int           i    = -1,
		      area = 0 ;

	slope_init(&slope_s);
	section_init(&section_s);

	while(EOF != scanf("%c", &c)){
		++i;
		if(c == '\\'){
			slope_s.push(&slope_s, i);
		}else if(c == '/'){
			if(slope_s.size != 0){
				section.start = slope_s.top(&slope_s);
				section.area  = i - slope_s.top(&slope_s);
				slope_s.pop(&slope_s);
				area         += section.area;
				add_section(&section_s, &section);
			}
		}else if(c == '_'){
			continue;
		}else{
			break;
		}
	}
	printf("%d\n%d", area, section_s.size);
	for(i=0; i<section_s.size; ++i){
		printf(" %d", section_s.section[i].area);
	}
	printf("\n");

	return 0;
}

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

public class Main {
	int run() {
		int n = in.nextInt();
		boolean[][] a = new boolean[n][n];
		int[] row = new int[n];
		int[] col = new int[n];
		int sum = 0;
		for (int i = 0; i < n; i++) {
			String s = in.next();
			for (int j = 0; j < n; j++) {
				if (s.charAt(j) == '#') {
					a[i][j] = true;
					row[i]++;
					col[j]++;
					sum++;
				}
			}
		}
		if (sum == 0) {
			return -1;
		}
		for (int i = 0; i < n; i++) {
			if (row[i] < n) {
				continue;
			}
			int ans = 0;
			for (int j = 0; j < n; j++) {
				if (col[j] < n) {
					ans++;
				}
			}
			return ans;
		}
		int ans = 3 * n;
		for (int r = 0; r < n; r++) {
			int cur = (col[r] == 0) ? 1 : 0;
			for (int j = 0; j < n; j++) {
				if (!a[r][j]) {
					cur += 2;
				} else if (col[j] < n) {
					cur++;
				}
			}
			ans = Math.min(ans, cur);
		}
		return ans;
	}

	static MyScanner in;
	static PrintWriter out;

	public static void main(String[] args) throws IOException {
		boolean stdStreams = true;
		String fileName = Main.class.getSimpleName().replaceFirst("_.*", "").toLowerCase();
		String inputFileName = fileName + ".in";
		String outputFileName = fileName + ".out";
		
		Locale.setDefault(Locale.US);
		BufferedReader br;
		if (stdStreams) {
			br = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
		} else {
			br = new BufferedReader(new FileReader(inputFileName));
			out = new PrintWriter(outputFileName);
		}
		in = new MyScanner(br);
		int tests = 1;//in.nextInt();
		for (int test = 0; test < tests; test++) {
			out.println(new Main().run());
		}
		br.close();
		out.close();
	}
	
	static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		MyScanner(BufferedReader br) {
			this.br = br;
		}
		
		void findToken() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
		}
		
		String next() {
			findToken();
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		
		long nextLong() {
			return Long.parseLong(next());
		}
		
		double nextDouble() {
			return Double.parseDouble(next());
		}
	}
}


Measured memory_bytes: 24504
_ = input()
a = [int(x) for x in input().split()]

odd, m4, m2 = 0, 0, 0
for i in a:
    if i % 2 != 0:
        odd += 1
    elif i % 4 == 0:
        m4 += 1
    else:
        m2 = 1
else:
    if odd + m2 - 1 <= m4:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 20040
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int x=0;
  int y=0;
  vector<int>vec(n);
  for(int i=0;i<n;i++){
    cin>>vec.at(i);
  }
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  for(int i=0;i<n;i+=2){
    x+=vec.at(i);
  }
  for(int i=1;i<n;i+=2){
    y+=vec.at(i);
  }
  cout<<x-y<<endl;
}
  


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

int main () {
  int a,b,c;
  cin >> a >> b >> c;
  if(a!=b && b!=c && a!=c){
    cout << 3 << endl;
  }
  else if(a==b && b==c){
    cout << 1 << endl;
  }
  else{
    cout << 2 << endl;
  }
}

Measured memory_bytes: 256
import sys
from collections import defaultdict, deque, Counter
import math
 
# import copy
from bisect import bisect_left, bisect_right
# import heapq
 
# sys.setrecursionlimit(1000000)
 
# input aliases
input = sys.stdin.readline
 
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]
 
INF = 10 ** 20
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)

class Segtree_op():
     # 単位元及び操作を設定して使うこと
     # queryでは、区間の(l, r)を指定する ex: (0, 5) => [0, 1, 2, 3, 4]
     # 特定の1点は (i, i+1)
     def __init__(self, n):
         self.size = 1
         while(n >= 1):
             self.size = self.size << 1
             n = n//2
 
         self.arr = [self.unit() for i in range(self.size*2)]
 
     def op(self, lch, rch):
         # update min with holding index
         return max(rch, lch)
     def unit(self):
         return 0
 
     def update(self, k, val):
         k += self.size - 1
         self.arr[k] = val
         while(k):
             k = (k - 1) // 2
             self.arr[k] = self.op(self.arr[k*2 + 1], self.arr[k*2 + 2])
 
     def query(self, l, r):
         L = l + self.size
         R = r + self.size
         s = self.unit()
         while L < R:
             if R & 1:
                 R -= 1
                 s = self.op(s, self.arr[R - 1])
 
             if L & 1:
                 s = self.op(s, self.arr[L - 1])
                 L += 1
             L >>= 1
             R >>= 1
         return s
 
 
     def show(self):
         idx = 1
         while(idx <= self.size):
             print(self.arr[idx - 1:idx * 2 - 1])
             idx *= 2
 

def getind(c):
    return ord(c) - ord("a")

def main():
    N = getN()
    S = list(getS())
    Q = getN()
    segs = [Segtree_op(N) for i in range(26)]
    for i, c in enumerate(S):
        segs[getind(c)].update(i, 1)

    for _ in range(Q):
        query = getS().split()
        if query[0] == "1":
            k, i, c = query
            i = int(i) - 1
            segs[getind(S[i])].update(i, 0)
            segs[getind(c)].update(i, 1)
            S[i] = c
        else:
            k, l, r = list(map(int, query))
            ans = 0
            for se in segs:
                if se.query(l-1, r) == 1:
                    ans += 1

            print(ans)


if __name__ == "__main__":
    main()
   

Measured memory_bytes: 440536
S = input()

if S == 'SUN':
    print('7')
elif S == 'MON':
    print('6')
elif S == 'TUE':
    print('5')
elif S == 'WED':
    print('4')
elif S == 'THU':
    print('3')
elif S == 'FRI':
    print('2')
elif S == 'SAT':
    print('1')

Measured memory_bytes: 8872
#include <iostream>


using namespace std;


bool k_judge(int n, int m, int k)
{
  for (int i=0; i<n+1; i++){
    for (int j=0; j<m+1; j++){
      if (i*(m-j)+j*(n-i) == k){
	return true;
      }
    }
  }
  return false;
}


int main()
{
  int n, m, k;

  cin >> n >> m >> k;
  if (k_judge(n, m, k)){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int t,n,s,f,i,j,sum;
	while(1){
		scanf("%d",&t);
		sum=0;
		if(t==0) break;
		scanf("%d",&n);
		for(i=0;i<n;i++){
			scanf("%d %d",&s,&f);
			sum+=f-s;
		}
		if(t<=sum) printf("OK\n");
		else printf("%d\n",t-sum);
	}
	return 0;
}

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

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b&&a!=c){
        cout<<"Yes\n";
    }else if(a==c&&a!=b){
        cout<<"Yes\n";
    }else if(b==c&&b!=a){
        cout<<"Yes\n";
    }else{
        cout<<"No\n";
    }
    return 0;
}


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

a = [int(input()) for i in range(n)]

a = sorted(a)


temp = a[0]
c = 0

cnts = [0]*n

for i in a:
    if temp == i:
        cnts[c] += 1
    
    else:
        temp = i
        c += 1
        cnts[c] += 1

ans = 0

for i in cnts:
    if i%2 == 1:
        ans += 1

print(ans)
        

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

int		atcg(char c)
{
	if (c == 'A' || c == 'T' || c == 'C' || c == 'G')
		return (1);
	else
		return (0);
}

int		atcg_len(char *str,int i, int n)
{
	int count = 0;
	while (i < n)
	{
		if (atcg(str[i]) == 1)
			count++;
		else
			break ;
		i++;
	}
	return (count);
}

int		main(void)
{
	char str[10];
	scanf("%s", str);
	int n = strlen(str);
	int max = 0;
	int i = 0;
	while (i < n)
	{
		if (max < atcg_len(str, i , n))
			max = atcg_len(str, i , n);
		i++;
	}
	printf("%d", max);
	return (0);
}

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <math.h>
#include <algorithm>
#define rep(i,n) for(int i=0; i < (n); i++)
#define INF 1001001
using namespace std;
 
int main(){
  int x;
  cin >> x;
  int a=1;
  for(int t=360; t%x!=0; t+=360) a++;
  
  //cout << a << endl;
  cout << a*360/x << endl;
 
  
}

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

int main(){
  int a,b;
  cin >> a >> b;
  if(a==2||b==2)cout << "No";
  else if(a==4||a==6||a==9||a==11){
    if(b==4||b==6||b==9||b==11){
      cout << "Yes";
    }
    else cout << "No";
  }
  else{
    if(b==4||b==6||b==9||b==11){
      cout << "No";
    }
    else cout << "Yes";
  }
}


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

const int Mod = 1e9 + 7;
int f[100003], N, M; 
bool isdanger[100003];

inline int Rd() {
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') { if(ch == '-') f = -1; ch = getchar(); }
	while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
	return x * f;
}

int main() {
	int last;
	N = Rd(), M = Rd();
	for(register int i = 1; i <= M; ++i)
		last = Rd(), isdanger[last] = true;
	f[0] = 1;
	for(register int i = 1; i <= N; ++i) {
		last = i - 1;
		if(last >= 0) {
			if(!isdanger[last])
				f[i] += f[last];
		}
		last = i - 2;
		if(last >= 0) {
			if(!isdanger[last])
				f[i] += f[last];
		}
		f[i] %= Mod;
	}
	cout << f[N] << endl;
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define LLINF 1000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
template<class T>
void dump(vector<T> &vec){
	for(int i=0;i<vec.size();i++){
		cout << vec[i];
		if(i+1<vec.size())cout << ' ';
		else cout << endl;
	}
	return;
}
int main(){
	ll N;
	cin >> N;
	cout << (N-1)*N/2ll << endl;
	return 0;
}


Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let mut g: Vec<Vec<u8>> = vec![vec![0; n]; n];
    for _ in 0..n {
        let u: usize = iterator.next().unwrap().parse().unwrap();
        let k: usize = iterator.next().unwrap().parse().unwrap();
        for _ in 0..k {
            let v: usize = iterator.next().unwrap().parse().unwrap();
            g[u - 1][v - 1] = 1;
        }
    }

    let mut result = String::new();
    for row in g {
        let mut line = String::new();
        for col in row {
            line.push_str(&format!("{} ", col));
        }
        result.push_str(&format!("{}\n", line.trim()));
    }
    return result.trim().to_string();
}



Measured memory_bytes: 5048
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  int n;
  int a;
  int c[8]={0};
  int ans=0;
  int yaba=0;
  cin>>n;
  rep(i,n){
    cin>>a;
    if(a<3200) c[a/400]=1;
    else yaba++;
  }

  rep(i,8) ans+=c[i];
  if(ans==0) cout<<"1 "<<yaba<<endl;
  else cout<<ans<<" "<<ans+yaba<<endl;
  return 0;
}





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

using namespace std;

string lcs(string a,string b)
{
    int n = a.size();
    int m = b.size();
    vector<vector<int>> dp(n+1);
    for (int i=0;i<=n;++i)
    {
        dp[i].resize(m+1);
    }

    for (int ai=1;ai<=n;++ai)
    {
        for (int bi=1;bi<=m;++bi)
        {
            if (a[ai-1]==b[bi-1]) dp[ai][bi] = dp[ai-1][bi-1] + 1;
            else
            {
                dp[ai][bi] = max(max(dp[ai-1][bi],dp[ai][bi-1]),dp[ai-1][bi-1]);
            }
        }
    }

    string ans;

    int i=n;
    int j=m;

    while (i>0  && j>0)
    {
        if (a[i-1]==b[j-1])
        {
            ans += string(1,a[i-1]);
            --i;
            --j;
        }
        else
        {
            if (dp[i-1][j] > dp[i][j-1])
            {
                --i;
            }
            else
            {
                --j;
            }
        }
    }

    reverse(ans.begin(),ans.end());

    return ans;

}

int main()
{
    string s,t;
    cin>>s>>t;
    cout<<lcs(s,t)<<endl;


    return 0;
}


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

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

  int A[n][m], b[m];

  for ( int i = 0; i < n; i++ ){
    for ( int j = 0; j < m; j++ ){
      cin >> A[i][j];
    }
  }

  for ( int j = 0; j < m; j++ ) cin >> b[j];

  for ( int i = 0; i < n; i++ ){
    int c = 0;
    for ( int j = 0; j < m; j++ ){
      c += A[i][j]*b[j];
    }
    cout << c << endl;
  }

  return 0;
}


Measured memory_bytes: 3096
#include <stdio.h>
int main(){

 int x, y;
 while(1) {
 scanf("%d%d",&x,&y);
 if(x == 0 && y == 0) break;
 if(x < y) {
 printf("%d %d\n", x, y);
 } else {
 printf("%d %d\n", y, x);
 }
 }

 return 0;
}

Measured memory_bytes: 596
import sys
for s in sys.stdin:
    s=s[:-1]
    while 1:
        idx=s.find("@")
        if idx==-1:break
        s=s.replace(s[idx:idx+3],
                    "".join([s[idx+2] for _ in range(int(s[idx+1]))]))
    print(s)


Measured memory_bytes: 5612
#include <bits/stdc++.h>
 
using namespace std;
 
#define mp make_pair
#define endl '\n'
using ll=long long;

const int INF=1e9+5;
const int N=2e5+5;
const int mod=1e9+7;
const ll oo=1e18+5;

int n;

void max_self(ll& a,ll b){
	a=max(a,b);
}

int main(){
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
	cin>>n;
	int base=1;
	while(base<=n) base*=2;
	vector<ll> tree(2*base);
	vector<int> h(n);
	vector<int> a(n);
	for(int& x:h) cin>>x;
	for(int& x:a) cin>>x;
	vector<ll> dp(n+1); // dp[i] is max total beauty if last flower height i
	for(int flower=0;flower<n;++flower){
		int x=h[flower]+base;
		ll best=0;
		while(x>1){
			if(x%2==1){
				max_self(best,tree[x-1]);
			}
			x/=2;
		}
		dp[h[flower]]=best+a[flower];
		for(int i=base+h[flower];i>=1;i/=2){
			max_self(tree[i],dp[h[flower]]);
		}
	}
	ll ans=0;
	// for(ll x:dp) cout<<x<<endl;
	for(ll x:dp) max_self(ans,x);
	cout<<ans;	
	return 0;
}


Measured memory_bytes: 7552
dp = [None] * 31
dp[0] = 1
dp[1] = 1
dp[2] = 2
def func(n):
  for i in range(3, n + 1):
    dp[i] = dp[i - 3] + dp[i - 2] + dp[i - 1]

func(30)

while True:
  n = int(input())
  if n == 0:
    break
  p = dp[n]
  p = p // 10 + bool(p % 10)
  print(p // 365 + bool(p % 365))



Measured memory_bytes: 5596
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<algorithm>
using namespace std;
typedef vector<string>VS;
struct S{string p;VS v;};
map<string,S>m;
int A(string a,string n)
{
	if(m[n].p.empty())return 0;
	if(m[n].p==a)return 1;
	return A(a,m[n].p);
}
int main()
{
	int N,M,i,c,f;
	string s,t,x,y;
	while(cin>>N>>M,N)
	{
		VS v;
		m.clear();
		getline(cin,s);
		getline(cin,s);
		m[s].p="";
		v.push_back(s);
		for(i=1;i<N;++i)
		{
			getline(cin,s);
			c=count(s.begin(),s.end(),' ');
			s=s.substr(c);
			while(v.size()>c)v.pop_back();
			m[s].p=v.back();
			m[v.back()].v.push_back(s);
			v.push_back(s);
		}
		for(i=0;i<M;++i)
		{
			getline(cin,s);
			v.clear();
			for(;;)
			{
				c=s.find(' ');
				if(c==string::npos)break;
				v.push_back(s.substr(0,c));
				s=s.substr(c+1);
			}
			x=v[0];
			y=s;
			y.erase(y.size()-1);
			t=v[3];
			if(t=="child")f=(m[x].p==y);
			if(t=="parent")f=(m[y].p==x);
			if(t=="sibling")
			{
				v=m[m[x].p].v;
				f=(find(v.begin(),v.end(),y)!=v.end());
			}
			if(t=="descendant")f=A(y,x);
			if(t=="ancestor")f=A(x,y);
			cout<<(f?"True\n":"False\n");
		}cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define all(a) (a).begin(),(a).end()
#define lb(s,x) lower_bound(all(s),x)-s.begin()
#define ub(s,x) upper_bound(all(s),x)-s.begin()
#define uniq(a) a.erase(unique(all(a)),a.end())
const int INF = 1e9;

#define debug(x) cerr<<(#x)<<": "<<(x)<<endl
template<class T,class U>
ostream& operator<<(ostream& o, const pair<T,U> &p){
    o<<"("<<p.first<<", "<<p.second<<")";
    return o;
}
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }


int main(void){
    string s;
    cin>>s;
    int n = s.size();
    int d = INF;
    rep(i,n-2){
        string sub = s.substr(i,3);
        int x = stoi(sub);
        d = min(d, abs(x-753));
    }
    cout << d <<endl;
    return 0;
}


Measured memory_bytes: 256
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
A = sorted(Counter(A).items(), key=lambda x:x[0])
cnt = 0
for k, v in A:
  if k != v:
    if k < v:
      cnt += (v-k)
    else:
      cnt += v
print(cnt)      

Measured memory_bytes: 21744
#include<bits/stdc++.h>
using namespace std;
int main(){
  int count1=0,count2=0;
  string s;cin>>s;
  sort(s.begin(),s.end());
  cout<<(s[0]==s[1]&&s[2]==s[3]&&s[0]!=s[2]?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
int n,m,c;
cin>>n>>m>>c;
int b[m+1];
int a[n+1][m+1];
int abc=0,bcd=c;
for(int i=1;i<=m;i++)
	cin>>b[i];
for(int i=1;i<=n;i++){
	for(int j=1;j<=m;j++){
		cin>>a[i][j];
	}
}
for(int i=1;i<=n;i++){
	bcd=c;
	for(int j=1;j<=m;j++){
		bcd+=a[i][j]*b[j];
	}
	if(bcd>0)
	abc++;
}
cout<<abc;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <bits/stdc++.h>


using namespace std;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(long long i=(a),i##Len_=(b);i<i##Len_;i++)
typedef long ll;

//abc120
//i番目の橋をとったときに、いくつの島が行き来できなくなるか
//強固さ、みたいなのを保持しておく?
//1-2 が切れても　1-3 3-1があればよい
//unionfind

struct UnionFind {

    vector <ll> par;
    
    // new
    UnionFind(ll n):par(n, -1){}

    //初期化
    void init(ll n){par.assign(n, -1); } 


    ll root(ll x)
    {
        if(par[x] < 0)return x;
        else return par[x] = root(par[x]);//親の番号を返す(親が子になっていたら困るので取り込まれてたら代入も行う)
    }

    //同じグループに属するか
    bool issame(ll x, ll y)
    {
        //rootが同じであるか
        return root(x) == root(y);
    }

    //併合
    bool merge(ll x, ll y)
    {

        x = root(x);
        y = root(y);
        if(x == y)return false;
        if(par[x] > par[y])swap(x, y);
        //多い方に足し合わせる
        par[x] += par[y];
        //従属(ここで0以上となる)
        par[y] = x;
        return true;
    }

    ll size(ll x)
    {
        return -par[root(x)];
    }

};

int main() {


    ll N,M;
    cin >> N >> M;
    //橋の左をA 右をB
    vector <ll> A(M),B(M);
    REP(i,M)
    {
        cin >> A[i] >> B[i];
        //0-based
        --A[i];--B[i];
    }

    UnionFind uf(N);

    //橋の連結
    //はじめ、どの 2つの島についてもいくつかの橋を渡って互いに行き来できます。
    //はじめの連結数 N * (N-1) / 2  nC2
    ll cur = N * (N - 1)  / 2;
    vector <ll> res;

    for(ll i = 0; i < M; ++i)
    {
        res.push_back(cur);

        //後ろから調べる
        ll a = A[M-1-i];
        ll b = B[M-1-i];
        
        //同じグループに属するか
        if(uf.issame(a,b))continue;

        //サイズ取得
        ll sa = uf.size(a);
        ll sb = uf.size(b);
        //最初に外すのは、最後の橋→必ず(1*1)減る

        //連結成分sa と 連結成分sb がここで初めて併合された
        cur -= sa * sb;
        uf.merge(a,b);
    }

    //後ろからとってたので
    reverse(res.begin(),res.end());

    for(auto r:res)
    {
        cout << r << endl;
    }

    return 0;

}

Measured memory_bytes: 4596
#include <iostream>
#include <algorithm>
#define rng(x1, y1, x2, y2) (sum[y2][x2] + sum[y1][x1] - sum[y2][x1] - sum[y1][x2])
using namespace std;
int H, W, ra, o, a[40][40], sum[40][40], dp[40][40][40][40];
int solve(int x1, int y1, int x2, int y2) {
	if (dp[y1][x1][y2][x2] != -1) return dp[y1][x1][y2][x2];
	int rng_ = rng(x1, y1, x2, y2);
	int ret = 1000000 + rng_;
	for (int i = x1 + 1; i < x2; i++) {
		int petl = rng(x1, y1, i, y2);
		int petr = rng(i, y1, x2, y2);
		if (min(petl, petr) >= o) {
			int resl = solve(x1, y1, i, y2);
			int resr = solve(i, y1, x2, y2);
			int res = (resl / 1000000 + resr / 1000000) * 1000000 + min(resl % 1000000, resr % 1000000);
			ret = max(ret, res);
		}
	}
	for (int i = y1 + 1; i < y2; i++) {
		int petl = rng(x1, y1, x2, i);
		int petr = rng(x1, i, x2, y2);
		if (min(petl, petr) >= o) {
			int resl = solve(x1, y1, x2, i);
			int resr = solve(x1, i, x2, y2);
			int res = (resl / 1000000 + resr / 1000000) * 1000000 + min(resl % 1000000, resr % 1000000);
			ret = max(ret, res);
		}
	}
	return dp[y1][x1][y2][x2] = ret;
}
int main() {
	while (cin >> H >> W >> ra, H) {
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) cin >> a[i][j];
		}
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) sum[i + 1][j + 1] = sum[i + 1][j] + sum[i][j + 1] - sum[i][j] + a[i][j];
		}
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				for (int k = i + 1; k <= H; k++) {
					for (int l = j + 1; l <= W; l++) dp[i][j][k][l] = -1;
				}
			}
		}
		o = sum[H][W] - ra;
		int ret = solve(0, 0, W, H);
		cout << ret / 1000000 << ' ' << ret % 1000000 - o << endl;
	}
}

Measured memory_bytes: 9008
#include<stdio.h>
int main(void)
{
	int i,j;
	int n,s,r[20000];
	int wa,cnt;
	
	while(1)	{
		scanf("%d %d",&n,&s);
		if(n==0 && s==0)	break;
		for(i=0;i<n;i++)	{
			scanf("%d",&r[i]);
		}
		cnt=0;
		for(i=0;i<n-1;i++)	{
			for(j=i+1;j<n;j++)	{	
				if(r[i]+r[j]>s)	cnt++;
			}
		}
		printf("%d\n",cnt);
	}
	return 0;
}


Measured memory_bytes: 648
#include <bits/stdc++.h>
using namespace std;
int main() {
  int y, m, d;
  scanf("%d/%d/%d", &y, &m, &d);
  if (y > 2019 || m > 4) {
    cout << "TBD" << endl;
  } else {
    cout << "Heisei" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <queue>

using namespace std;
#define N 100
#define INF 2000000

int n, M[N][N];
int d[N];

void bfs(int s){
	int i,u,v;

	queue<int> q;
	q.push(s);
	for(i=0;i<n;i++){
		d[i] = INF;
	}

	d[s] = 0;

	while(!q.empty()){
		u = q.front();
		q.pop();
		for(v=0;v<n;v++){
			if(M[u][v] == 0) continue;
			if(d[v] != INF) continue;
			d[v] = d[u] + 1;
			q.push(v);
		}
	}
	for(i=0;i<n;i++){
		if(d[i] == INF){
			printf("%d -1\n",i+1);
		}else{
			printf("%d %d\n",i+1,d[i]);
		}
	}
}


int main(void){
	int i,j,u,k,v;

	scanf("%d",&n);

	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			M[i][j] = 0;
		}
	}

	for(i=0;i<n;i++){
		scanf("%d%d",&u,&k);
		u--;
		for(j=0;j<k;j++){
			scanf("%d",&v);
			v--;
			M[u][v] = 1;
		}
	}

	bfs(0);

	return 0;
}








Measured memory_bytes: 3184
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(n,v) cout<<#v<<":";for(int i=0;i<n;i++)cout<<v[i]<<" ";cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    int n;
    cin>>n;
    int N=n;
    vector<pair<int,int>> pa;
    //奇数
    if(n%2){
        pa.push_back(make_pair(-1,n));
        n--;
    }
    int l=1,r=n;
    while(l<r){
        pa.push_back(make_pair(l,r));
        l++,r--;
    }
    vector<pair<int,int>> ans;
    for(int i=0;i<pa.size();i++){
        int u=pa[i].first,v=pa[i].second;
        
        if(u!=-1)for(int j=i+1;j<pa.size();j++){
            ans.push_back(make_pair(u,pa[j].first));
            ans.push_back(make_pair(u,pa[j].second));
        }
        if(v!=-1)for(int j=i+1;j<pa.size();j++){
            ans.push_back(make_pair(v,pa[j].first));
            ans.push_back(make_pair(v,pa[j].second));
        }
    }
    cout<<ans.size()<<endl;
    
    for(auto x:ans){
        cout<<x.first<<' '<<x.second<<endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
    int s;
    scanf("%d",&s);
    if (s == 25) printf("Christmas");
    else if (s == 24) printf("Christmas Eve");
    else if (s == 23) printf("Christmas Eve Eve");
    else if (s == 22) printf("Christmas Eve Eve Eve");
    return 0;
}

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

typedef long long ll;
using namespace std;
int main()
{
  ll k;
  cin>>k;
  ll start=7;
  ll ans=1;
  if(k%2==0){
    puts("-1");
    return 0;
  }

  rep(i,1000000){
    if(start%k==0){
      cout<<ans<<endl;
      return 0;
    }
    start=(start*10)%k;
    start+=7;
    ans++;
  }
  puts("-1");
}


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

#define rep(i,a,b) for(i=(a);i<=(b);++i)
#define rev(i,a,b) for(i=(a);i>=(b);--i)
#define max2(a,b)  ((a)>(b)?(a):(b))
#define min2(a,b)  ((a)<(b)?(a):(b))
#define all(x) x.begin(),x.end()
#define sz(x) (long long)x.size()
#define fi first
#define se second
#define pb emplace_back // push_back
#define mp make_pair
#define endl '\n'

#ifdef Wild4Stone
template<typename T>
void __p(T a) { cout << a << " "; }
template<typename T, typename F>
void __p(pair<T, F> a) { cout << "{ "; __p(a.fi); __p(a.se); cout << "}"; }
template<typename T>
void __f(const char* s, T t) { cout << s << " : "; __p(t); }
template<typename T>
void __t(const char* s, const T &x) { cout << s << " : { "; for (auto it : x) __p(it); cout << "} ";}
template<typename T, typename ... F>
void __f(const char* s, T t, F ... f) {
	int i = 0; for (;; ++i) if (s[i] == ',') break;
	cout.write(s, i) << " : "; __p(t); cout << " | "; __f(s + i + 1, f...);
}
#define trace(...) { cout<<"LINE: "<<__LINE__<<" || "; __f(#__VA_ARGS__,__VA_ARGS__); cout<<"\n\n"; }
#define autra(...) { cout<<"LINE: "<<__LINE__<<" || "; __t(#__VA_ARGS__,__VA_ARGS__); cout<<"\n\n"; }
#else
#define trace(...) {}
#define autra(...) {}
#endif

typedef long long int ll;
typedef pair<ll, ll> pll;

const ll mod = 1000000007;  //998244353;
const ll inf = 0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-9;
const double PI = acos(-1);

ll i, j, k;
void solve(void);
inline bool equal(double a, double b) { return fabs(a - b) < eps; }
// inline ll gcd(ll a, ll b) { a=abs(a); b=abs(b); while(a>0 && b>0) (a>b?a%=b:b%=a); return (a==0?b:a); }
// inline ll power(ll x, ll n, ll m = LLONG_MAX)
//        {  ll res=1; x = (x%m + m)%m;
//             while(n) { if(n&1) res=(res*x)%m;  x=(x*x)%m;  n >>= 1; }  return res;
//        }

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

//***************** Code Starts Here *******************//

void solve()
{
	ll n, k; cin >> n >> k;
	ll a[n + 1] = {0}; rep(i, 1, n) cin >> a[i];

	ll dp[n + 1][k + 1], pre[n + 1][k + 1];
	memset(dp, 0, sizeof(dp));
	memset(pre, 0, sizeof(pre));

	rep(i, 0, a[n]) dp[n][i] = 1;
	pre[n][0] = dp[n][0];
	rep(i, 1, k) pre[n][i] = pre[n][i - 1] + dp[n][i];

	rev(i, n - 1, 1)
	rep(j, 0, k)
	{
		int l = j - min2(j, a[i]), r = j;
		if (l == 0)
		{
			dp[i][j] += pre[i + 1][r];
			dp[i][j] %= mod;
		}
		else
		{
			dp[i][j] += (pre[i + 1][r] - pre[i + 1][l - 1] + mod) % mod;
			dp[i][j] %= mod;
		}

		if (j == 0)
			pre[i][j] = dp[i][j];
		else
		{
			pre[i][j] = pre[i][j - 1] + dp[i][j];
			pre[i][j] %= mod;
		}
	}

	cout << dp[1][k] << endl;
}

Measured memory_bytes: 158080
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

from functools import lru_cache

MOD = 10 ** 9 + 7

"""
桁数が異なると矛盾
したがって商が1であることが必要
すると、xがyのsubsetであることが必要
一番上の桁を含むsubsetがx
"""

@lru_cache()
def F_naive(L,R):
    # 
    ret = 0
    ret += F((L+1)//2,(R+1)//2) # 2x,2y
    answer = 0
    for x in range(L,R+1):
        for y in range(x,R+1):
            if x.bit_length() == y.bit_length() and (x^y)+x == y:
                answer += 1
    return answer

@lru_cache()
def F(L,R):
    # x subset y かつ 2x > y
    if L < 0:
        L = 0
    if R < L:
        return 0
    if R == 0:
        return 0
    ret = 0
    # 下一桁が0,0ととる場合
    ret += F((L+1)//2, R//2)
    # 下一桁が0,1ととる場合
    # 2(2x) > (2y+1) iff 2x > y
    ret += F((L+1)//2,(R-1)//2)
    # 下一桁が1,0ととる場合
    # これはsubsetにならない

    # 下一桁が1,1ととる場合
    # 2(2x+1) > 2y+1 iff 2x >= y
    ret += G(L//2,(R-1)//2)
    return ret

@lru_cache()
def G(L,R):
    # x subset y かつ 2x >= y
    if L < 0:
        L = 0
    if R < L:
        return 0
    if R == 0:
        return 1
    ret = 0
    # 下一桁が0,0ととる場合
    ret += G((L+1)//2, R//2)
    # 下一桁が0,1ととる場合
    # 2(2x) >= (2y+1) iff 2x > y
    ret += F((L+1)//2,(R-1)//2)
    # 下一桁が1,0ととる場合
    # これはsubsetにならない

    # 下一桁が1,1ととる場合
    # 2(2x+1) >= 2y+1 iff 2x >= y
    ret += G(L//2,(R-1)//2)
    return ret

L,R = map(int,input().split())
answer = F(L,R) % MOD
print(answer)

Measured memory_bytes: 3796
#include<iostream>
#include<string.h>
using namespace std;
 
int main()
{
  int k;
  string s;
  cin>>k;
  cin>>s;
  if(s.size()<=k)
    cout<<s;
  else
    cout<<s.substr(0,k)+"...";
  return 0;
}


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int t=100,i=0,n,k,c,s1,s2,s,e,o,j,a,b,x;
   cin>>x;
   while(1)
   {
       t=t+t/100;
       i++;
       if(t>=x) break;
   }
    cout<<i<<endl;
}









Measured memory_bytes: 3624