akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

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

    cout << "Christmas";
    if (N < 25) cout << " Eve";
    if (N < 24) cout << " Eve";
    if (N < 23) cout << " Eve";
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#B - Some Sums
#30min
N, A, B = map(int, input().split())
sumn = 0
sumans = 0
for n in range(1,N+1):
    Ns = str(n)
    sumn = 0
    for i in range(len(Ns)):
        sumn = sumn + int(Ns[i])
    if A <= sumn and sumn <= B:
        sumans = sumans + n
print(sumans)

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

int n,cnt=0,ans=0;
int num[30005];

int main()
{
	string s;
	cin>>n>>s;
	for (int i=1;i<=n;i++)  num[i]=s[i-1]-'0';
	while (cnt<=999)
	{
		int a=cnt/100,b=(cnt%100)/10,c=cnt%10;
		int pos=0;
		for (int i=1;i<=n;i++)
		{
			if (pos==0&&num[i]==a)  pos++;
			else if (pos==1&&num[i]==b)  pos++;
			else if (pos==2&&num[i]==c)  pos++;
			if (pos==3)
			{
				ans++;
				break;
			}
		}
		cnt++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
num = gets.to_i
while num>0 do
	a,b,c = gets.split.map(&:to_i)
	if a**2+b**2==c**2||a**2+c**2==b**2||b**2+c**2==a**2 then
		puts("YES")
	 else 
	 	puts("NO")
	 end
	 num-=1
	 end

Measured memory_bytes: 8752
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int main() {
  string S, T, U;
  int A, B;
  cin >> S >> T >> A >> B >> U;
  if(S == U) cout << A-1 << ' ' << B << endl;
  else cout << A << ' ' << B-1 << endl;
  return 0;
}


Measured memory_bytes: 256
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 2018-12-22 21:02:04
**/

#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
using pii = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define fi first
#define se second

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(__null);
    
    int n, h, w; cin >> n >> h >> w;
    int a[n], b[n];
    rep(i, n) cin >> a[i] >> b[i];

    int cnt = 0;

    rep(i, n){
        if (a[i] >= h && b[i] >= w) ++cnt;
    }
    print(cnt);
    
    return 0;
}

Measured memory_bytes: 256
#include<vector>
#include<map>
#include<climits>
#include<set>
#include<queue>
#include<algorithm>
#include<functional>
#include<numeric>
#include<utility>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cctype>
#include<string>
#include<bitset>
#include<cstring>
#include<list>
using namespace std;
typedef vector<string>vs;
typedef vector<int>vi;
typedef vector<vi>vvi;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll>pll;
typedef vector<ll>vl;
typedef map<string,int>msi;
#define REP(i,x,n) for(int i=(x);i<(n);++i)
#define rep(i,x) REP(i,0,(x))
#define fi first
#define se second
#define each(i,c) for(typeof(c)::iterator i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back



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

    int n;cin>>n;
    msi M;
    rep(i,n){
        string str;int val;cin>>str>>val;
        M[str]=val;
    }
    int m;cin>>m;
    vs a(m),b(m);
    rep(i,m)cin>>a[i]>>b[i];
    rep(i,n-1){
        bool flag=false;
        rep(j,m){
            if(M[a[j]]!=M[b[j]])flag=true;
            int val=min(M[a[j]],M[b[j]]);
            M[a[j]]=val;
            M[b[j]]=val;
        }
        if(flag==false)break;
    }
    ll ans=0;
    msi::iterator it;
    for(it=M.begin();it!=M.end();it++){
        ans+=it->se;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 1856
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>

//using namespace __gnu_pbds;
using namespace std;

#define sz(x)                 x.size()
#define all(x)                x.begin(), x.end()
#define tr(x, it)             for(auto it = x.begin();it != x.end();it++)
#define fo(i, k, n)           for(int i = k;i < n;i++)
#define Fo(i, k, n)           for(int i = k;i >= n;i--)
#define el                    "\n"
#define ff                    first
#define ss                    second
#define ll                    long long
#define pb                    push_back
#define mp                    make_pair
#define pii                   pair<int, int>
#define vi                    vector<int>
#define mii                   map<int, int>
//#define pqb                   priority_queue<int>
//#define pqs                   priority_queue<int, vi, greater<int>>
//#define pc(x)                 putchar(x);
//#define setbits(x)            __builtin_popcountll(x)
//#define zrobits(x)            __builtin_ctzll(x)
#define mod                   1000000007
#define inf                   1e18
#define deb(x)                cout<<#x<< " = "<< x<<"\n";
//#define ps(x, y)              fixed<<setprecision(y)<<x
//#define mk(arr, n, type)      type *arr = new type[n];
//#define w(x)                  int x; cin>>x; while(x--)

void solve(){
	int n; cin>>n;
	if(n%1000 == 0) cout<<"0";
	else cout<<1000 - (n%1000);
}

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


Measured memory_bytes: 3604
n = gets.chomp.to_i
ary = gets.chomp.split.map(&:to_i)
avg1 = (ary.inject(&:+)/(n.to_f)).ceil
avg2 = (ary.inject(&:+)/(n.to_f)).floor

ans1 = ary.inject(0) do |sum, i|
  sum + (i - avg1) ** 2
end
ans2 = ary.inject(0) do |sum, i|
  sum + (i - avg2) ** 2
end

puts [ans1, ans2].min

Measured memory_bytes: 14280
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long;
using llint = long long;
using namespace std;

int main() {
    fastIO;
    string s;
    rep(i, 4) {
        string t;
        cin >> t;
        s += t;
    }
    sort(s.begin(), s.end());
    if (s == "1479")
        cout << "YES";
    else
        cout << "NO";
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define pr pair<int,int>
#define mod 1000000007
#define endl "\n"

int power(int a,int b,int m=mod)
{
	if(b==0)	return 1;
	if(b==1)	return a;
	int res=power(a,b/2,m);
	res=(res*res)%m;
	if(b&1)	res=(res*a)%m;
	return res;
}

int modinv(int a){ return power(a,mod-2);}

void solve()
{
	int n,ans=2,i;
	cin>>n;
	if(n==2){	cout<<"1"<<endl;return;}
	int m=n-1;
	for(i=2;i*i<=n;i++)
	{
		if(m%i==0)
		{
			ans++;
			ans+=1-(i*i==m);
		}
		if(n%i==0)
		{
			int x=n;
			while(x%i==0)
				x/=i;
			if(x%i==1)	ans++;
		}
	}
	cout<<ans<<endl;
}

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <cmath>
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    ll cnt = 0;
    while(true) {
        if(a % 2 || b % 2 || c % 2) break;
        if(a == b && b == c && c == a) {
            cout << -1 << endl;
            return 0;
        }
        ll _a = a, _b = b, _c = c;
        a = (_b + _c) / 2;
        b = (_c + _a) / 2;
        c = (_a + _b) / 2;
        cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
	long long int a;
	long long int b;
	long long int x;
	scanf("%lld%lld%lld", &a, &b, &x);
	long long int cnt = b / x;
	long long int cnt2 = max(0LL,a-1LL) / x;
	if (a == 0){
		cnt++;
	}
	cnt -= cnt2;
	printf("%lld\n", cnt);
	return 0;
}

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

int main() {
 int n;
 cin >> n;
 vector<int> v(n);
 for(int i= 0;i<n;i++){
   cin >> v[i];
 }
  bool flag = true;
  int a = 1;
  for(int i= 0;i<n-1;i++){
    if(v[i] == v[i+1]) a++;
  }
  if(a == n) flag = false;
  if(flag){
  vector<int> v0(n/2);//vの偶数番目の項の列
  vector<int> v1(n/2);//vの奇数番目の項の列
  for(int i= 0;i<n;i++){
   if(i%2 == 0){
     v0[i/2] = v[i];
   }
    if(i%2 == 1){
      v1[i/2] = v[i];
    }
  }
  
  sort(v0.begin(),v0.end());
  sort(v1.begin(),v1.end());
  v0.push_back(0);
  v1.push_back(0);
  vector<pair<int,int>> p0;
  vector<pair<int,int>> p1;
  
  int c = 1;
  for(int i= 0;i<n/2;i++){
   if(v0[i] == v0[i+1]){
      c++;
      }
    else if(v0[i] != v0[i+1]){
      p0.push_back(make_pair(c,v0[i]));
      c = 1;
    }
  }

  int d = 1;
  for(int i= 0;i<n/2;i++){
   if(v1[i] == v1[i+1]){
      d++;
      }
    else if(v1[i] != v1[i+1]){
     p1.push_back(make_pair(d,v1[i]));
      d = 1;
    }
  }

  sort(p0.begin(),p0.end());
  reverse(p0.begin(),p0.end());
  sort(p1.begin(),p1.end());
  reverse(p1.begin(),p1.end());

  
  v0.pop_back();
  v1.pop_back();
  int ans = 0;
  
  if(p0[0].second != p1[0].second){
    ans += v0.size()-p0[0].first;
    ans += v1.size()-p1[0].first;
  }
  
  else if(p0[0].second == p1[0].second){/*v0とv1の最頻値が等しい場合、v0の最頻値を
  採用するとき、v0の最頻値以外を最頻値に変え、v1の二番目の最頻値以外をそれに置き換える。
  v1の最頻値を採用する場合も同様。両者の場合の操作回数の小さい方を出力*/
    int ans1 = n/2 - p0[0].first +n/2 -p1[1].first;
    int ans2 = n/2 - p0[1].first + n/2 -p1[0].first;
    ans = min(ans1,ans2);
   
    }
    cout << ans << endl;
  }
  
  else cout << n/2 << endl;
}


Measured memory_bytes: 2164
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  ll i;
  vector<ll> fib;
  fib.push_back(1);
  fib.push_back(2);
  for(i=2;i<60;i++){
    fib.push_back(fib[i-2]+fib[i-1]);
  }
  ll x,y,a=0,b=0,c=0,d=0;
  cin >> x >> y;
  for(i=0;i<60;i++){
    if(x>=a && x<=c && y>=b && y<=d){
      cout << i%3+1 << endl;
      return 0;
    }
    if(i%4==0){
      c+=fib[i];
    }
    else if(i%4==1){
      d+=fib[i];
    }
    else if(i%4==2){
      a-=fib[i];
    }
    else{
      b-=fib[i];
    }
  }
}


Measured memory_bytes: 3148
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;

void main()
{
	auto N = readln.chomp.to!int;
	auto a = readln.split.to!(int[]);
	int count;

	foreach(i; a)
	{
		while(i % 2 == 0)
		{
			i /= 2;
			count++;
		}
	}
	writeln(count);
}

//writeln("滲み出す混濁の紋章　不遜なる狂気の器　湧き上がり　否定し　痺れ　瞬き　眠りを妨げる　爬行する鉄の王女　絶えず自壊する泥の人形　結合せよ　反発せよ　地に満ち己の無力を知れ　破道の九十　黒棺")

Measured memory_bytes: 2428
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
#define pb push_back
const int MOD=1e9+7;
const int INF=1e15;

signed main(){
    int X,T;cin>>X>>T;
    cout<<max(0ll,X-T)<<endl;
}

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

int main(){
  
  int x,y,Y;

  scanf("%d %d",&x,&y);

  //if((x<1) || (y>(10^9))) exit(8);

  while(y != 0){
    Y = y;
    y = x % y;
    x = Y;
}

  printf("%d\n",x);

  return 0;
  }

Measured memory_bytes: 592
import java.util.Scanner;

public class Main {

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

        int l = 1;
        for (int i = s.length()-1; i > 1; i--) {
            if (i % 2 == 0) {
                continue;
            }
            l = i/2;
            if (s.substring(0, l).equals(s.substring(l, i-1))) {
                break;
            }
        }

        System.out.println(l*2);
    }

}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()

ll N;
 
int main(){
  int n, l;
  cin >> n >> l;
  int sum = (l + l + n - 1) * n / 2;
  if(l>=0) cout << sum - l;
  else if(abs(l) < n) cout << sum;
  else cout << sum - (l + n - 1);
}

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

int main(){
  int A,B,X;
  cin >> X >> A >> B;
  if(A >= B){
    cout << "delicious" << endl;
  }else if(X+A < B){
    cout << "dangerous" <<endl;
  }else{
    cout << "safe" <<endl;
  }
}

Measured memory_bytes: 256
using System;
class Program
{
	static void Main(string[] args){
    	string yosoku = Console.ReadLine();
      	string real = Console.ReadLine();
      
      	int a = 0;	
      
      	for(int i= 0;i<3;i++){
        	 if(yosoku.Substring(i,1) == real.Substring(i,1)){
              a++;
             }
        }
      	Console.WriteLine(a);
    }  
}

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

int main() {
  long long n,m;
  cin>>n>>m;
  vector<long long>a(n,1);
  vector<bool>hantei(n,0);
  hantei[0]=true;
  for(long long i=0;i<m;i++){
    long long x,y;
    cin>>x>>y;
    x--;y--;
    if(hantei[x]==1){
      a[x]--;
      a[y]++;
      hantei[y]=true;
      if(a[x]==0)hantei[x]=0;
    }else{
      a[x]--;
      a[y]++;
    }
  }
  long long  kotae=0;
  for(long long i=0;i<n;i++){
    if(hantei[i]==true)kotae++;
  }
  cout<<kotae<<endl;
  return 0;
}
    
    
  

Measured memory_bytes: 4056
#include <bits/stdc++.h>
using namespace std;
#define oo 666666666
#define ll long long
#define ld long double

ll DP[100001];

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n,k;
    cin>>n>>k;
    vector<int>A(n);
    for(int&x:A)cin>>x;

    DP[A[0]]=1;
    for(int i=A[0]+1; i<=k; i++)
        for(int j=0; j<n && i-A[j]>=0; j++)
        DP[i]|=!DP[i-A[j]];

    cout<<(DP[k] ? "First" : "Second");
}


Measured memory_bytes: 1024
def prime_checker_range(n): #n未満の数の中で素数のものを全て出力(リスト型)
    ls = [i for i in range(2,n)]
    p = 0
    while True:
        new_ls = [j for j in ls if (j % ls[p] != 0) or (j <= ls[p])]
        ls = new_ls
        if ls[p]**2 >= max(ls):
            return ls
        else:
            p += 1
    return ls
def prime_checker(i): #素数かどうか判定
    if i == 1:
        return False
    else:
        for j in range(2,(int(i**0.5))+1):
            if i % j == 0:
                return False
            else:
                continue
        return True
q = int(input())
ls = [i for i in prime_checker_range(10**5+1) if prime_checker((i+1)//2)]
di = [0]*(10**5+1)
c = 1
for p in range(len(ls)):
    if p != len(ls)-1:
        for m in range(ls[p],ls[p+1]):
            di[m] = c
    else:
        for m in range(ls[p],10**5+1):
            di[m] = c
    c += 1
for k in range(q):
    l,r = map(int,input().split())
    print(di[r]-di[l-1])





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

using namespace std;
#define int long long int

constexpr int MOD = 1000000007; // 10 ** 9 + 7
constexpr int SIZE = 2010;

int dp[SIZE][SIZE];
int sum[SIZE][SIZE];

void solve() {
    int N, M;
    cin >> N >> M;

    vector<int>s(N); for (auto &x : s) {cin >> x;}
    vector<int>t(M); for (auto &x : t) {cin >> x;}

    for (int i = 0; i <= N; i++) {

        sum[i][0] = 1;
    }

    for (int i = 0; i <= M; i++) {

        sum[0][i] = 1;
    }

    int ret = 1;

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            if (s[i] == t[j]) {
                dp[i + 1][j + 1] = sum[i][j];
                ret += dp[i + 1][j + 1];
            }
            sum[i + 1][j + 1] = (sum[i+1][j] + sum[i][j+1] - sum[i][j] + dp[i + 1][j + 1] + MOD)%MOD;
        }
    }
    cout << ret % MOD << endl;
}

signed main() {
    solve();
    return 0;
}


Measured memory_bytes: 63104
#include<iostream>
#include<string>

using namespace std;

int main(){
int N; cin >> N; string S; cin >> S;
  int max_cnt = 0; int x = 0;
  for(int i = 0; i < N; i++){ 
    if(S[i] == 'I'){ x++;}
    else{x--;}
                                    max_cnt = max(max_cnt,x);}
  cout << max_cnt << endl;
  
  return 0;}
              

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline

    S = input().rstrip('\n')
    N = len(S)
    ok = 1
    for i in range(N):
        if S[i] != S[-i-1]:
            ok = 0
        if i < N // 2:
            if S[i] != S[N//2 - i - 1]:
                ok = 0
        if i > N // 2:
            if S[i] != S[-(i - N//2 - 1) - 1]:
                ok = 0
    if ok:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

// ABC098 C - Attention
// 2020.06.18

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  string S; cin >> S;
  vector<int> LW(N), RE(N);
  REP(i, N){
    if(i != 0){
      LW[i] = LW[i-1];
      RE[N-i-1] = RE[N-i]; 
    }
    if(S[i] == 'W') LW[i]++;
    if(S[N-i-1] == 'E') RE[N-i-1]++;
  }

  int ans = N;
  REP(i, N){
    int res;
    if(i == 0){
      res = RE[+1];
    }else if(i == N-1){
      res = LW[i-1];
    }else{
      res = LW[i-1] + RE[i+1];
    }
    ans = min(ans, res);
  } 
  cout << ans << endl;
}

Measured memory_bytes: 6088
n = int(input())
ls = []
for i in range(n):
    a = int(input())
    p = []
    for i in range(a):
        x,y = map(int,input().split())
        p.append([x-1,y])
    ls.append(p)

ans = 0

for i in range(2**n):
    flag = 0
    for j in range(n):
        if (i >> j)&1:#もし正直者だったら
            for k in ls[j]:#証言の確認
                if (i >> k[0])&1 != k[1]:#もし証言がおかしかったら
                    flag = 1
                    break
    if flag == 0:
        ans = max(ans, bin(i)[2:].count('1'))#2進数表記の'1'の数が正直者の数
print(ans)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var num = Input.num;
        //TAGC
        var dp = new long[num + 1, 4, 4, 4];
        dp[0, 0, 0, 0] = 1;
        for (var i = 0; i < num; i++)
            for (var j = 0; j < 4; j++)
                for (var k = 0; k < 4; k++)
                    for (var h = 0; h < 4; h++)
                        for (var l = 0; l < 4; l++)
                            if (isOk(j, k, h, l))
                                dp[i + 1, k, h, l] = (dp[i + 1, k, h, l] + dp[i, j, k, h]) % Input.MOD;
        var res = 0L;
        for (var i = 0; i < 4; i++)
            for (var j = 0; j < 4; j++)
                for (var h = 0; h < 4; h++)
                    res = (res + dp[num, i, j, h])%Input.MOD;
        WriteLine(res);
    }
    private static bool isOk(params int[] last)
    {
        for(var i = 0; i < 4; i++)
        {
            var li = new int[4];
            Array.Copy(last, li, 4);
            if (i > 0)
                Manipulation.Swap(li, i - 1, i);
            var str = string.Join("", li);
            if (str.StartsWith("123") || str.EndsWith("123"))
                return false;
        }
        return true;
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static int[][] twodim(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] twodimL(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public static Tuple<int, int, long> MakeEdge(int num1, int num2, long weight=Inf)
        => new Tuple<int, int, long>(num1, num2, weight);
    public const long Inf = (long)1e18;
    public const double eps = 1e-11;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}

public class Manipulation
{
    public static void Swap<T>(T[] array, int index1, int index2)
    {
        var tmp = array[index1];
        array[index1] = array[index2];
        array[index2] = tmp;
    }

    public static void Swap<T>(ref T obj1, ref T obj2)
    {
        var tmp = obj1;
        obj1 = obj2;
        obj2 = tmp;
    }

    public static void Insert<T>(T[] array,int index,T val,int last)
    {
        for (var i = last; i > index; i--)
            array[i] = array[i - 1];
        array[index] = val;
    }
}


Measured memory_bytes: 15584
#include <cstdio>
using namespace std;

int p[102];

int main(){
  int N; scanf("%d", &N);

  for(int i = 1, s = 0; i <= N; i++){
    int x; scanf("%d", &x);
    s += x; p[i] = s;
  }

  int ans = 0;

  for(int i = 1; i <= N; i++){
    int x; scanf("%d", &x);
    ans = (p[i] > ans ? p[i] : ans) + x;
  }

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

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <math.h>
#include<algorithm>
using namespace std;
typedef long long ll;
int main()
{
    ll N, n, b, ans(0),min(1000000000),ans1(0),ans2(0),b1,b2;
    double num;
    vector<int> v;
    cin >> N;
    for (int i = 0; i < N; i++){
        cin >> n;
        v.push_back(n - i - 1);
    }
    sort(v.begin(), v.end());
    if(N%2==1){
        b=v[(N-1)/2];
        min=0;
        for (int i = 0; i < N; i++){
            min += abs(v[i] - b);
        }
    }else{
        b1=v[N/2-1];
        b2=v[N/2];
        for (int i = 0; i < N; i++){
                ans1 += abs(v[i] - b1);
                ans2 += abs(v[i]-b2);
        }
            if(b2>b1){
                min=ans1;
            }else{
                min=ans2;
            }
        }

    cout << min;
}

Measured memory_bytes: 1400
N = int(input())
A = list(map(int, input().split()))
A.sort()
B = []
ans='APPROVED'

for i in A:
    if (i % 2 == 0):
        B.append(i)

for i in B:
    if (i % 3 != 0 and i % 5 != 0):
        ans = 'DENIED'
        break

print(ans)

Measured memory_bytes: 3060
a, b, c = map(int, input().split())
k = int(input())
cnt = 0
while b <= a:
    b *= 2
    cnt -= -1
# print(cnt)
while c <= b:
    c *= 2
    cnt -= -1
# print(cnt)
if cnt <= k: print('Yes')
else: print('No')

Measured memory_bytes: 61616
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

struct Sushi {
    long long x;
    long long v;
};

int main() {
    
    int N;
    long long C;
    cin >> N >> C;


    long long ans = 0;
    vector<Sushi> V(N);
    for ( int i = 0; i < N; i++ ) {
        long long x,v;
        cin >> x >> v;
        V[i].x = x;
        V[i].v = v;        
    }

    long long vs = 0;
    for ( int i = 0; i < N; i++ ) {
        vs += V[i].v;
        ans = max( ans, vs-V[i].x );
    }
    vs = 0;
    for ( int i = N-1; i >= 0; i-- ) {
        vs += V[i].v;
        ans = max( ans, vs-(C-V[i].x) );
    }

    vector<long long> BR(N), BL(N);
    long long v = V[0].v;
    BR[0] = V[0].v-V[0].x;
    for ( int i = 1; i < N; i++ ) {
        v += V[i].v;
        BR[i] = max( BR[i-1], v-V[i].x );
    }
    v = V[N-1].v;
    BL[N-1] = v-(C-V[N-1].x);
    for ( int i = N-2; i >= 0; i-- ) {
        v += V[i].v;
        BL[i] = max( BL[i+1], v-(C-V[i].x) );
    }

    v = 0;
    for ( int i = 0; i < N-1; i++ ) {
        v += V[i].v;
        ans = max( ans, v - V[i].x*2 + BL[i+1] );
    }
    v = 0;

    for ( int i = N-1; i >= 1; i-- ) {
        v += V[i].v;
        ans = max( ans, v - ( (C-V[i].x)*2 ) + BR[i-1] );
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 3328
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2 * 10**6)


def inpl():
    return list(map(int, input().split()))


def main():
    N = int(input())
    A = inpl()
    lx = 30
    tmp = [0] * lx

    for a in A:
        for i in range(lx):
            if (a >> i) % 2 == 1:
                tmp[i] = (tmp[i] + 1) % 2

    ans = []
    for a in A:
        b = 0
        for i in range(lx):
            if tmp[i] == 0 and (a >> i) % 2 == 1:
                b += 2**i
            elif tmp[i] == 1 and (a >> i) % 2 == 0:
                b += 2**i
        ans.append(b)
    print(*ans)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 99028
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>

using namespace std;

int main()
{
	int n, d, ans;

	scanf("%d", &n);

	set<int> ds;
	
	for(int i=0; i<n; i++){
		scanf("%d", &d);
		ds.insert(d);
	}

	ans=ds.size();

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

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#define max 10000
#define NIL -1

struct Node { int pt, L, R; };

Node t[max];
int n,d[max],h[max];

void setd(int u,int d2){
  if(u == NIL) return;
  d[u] = d2;
  setd(t[u].L, d2+1);
  setd(t[u].R, d2+1);
}

int seth(int u){
  int h1 = 0, h2 = 0;
  if(t[u].L != NIL)
    h1 = seth(t[u].L) + 1;
  if(t[u].R != NIL)
    h2 = seth(t[u].R) + 1;
  return h[u] = (h1 > h2 ? h1 : h2);
}

int gets(int u){
  if(t[u].pt == NIL) return NIL;
  if(t[t[u].pt].L != u && t[t[u].pt].L != NIL){
    return t[t[u].pt].L;}
  if(t[t[u].pt].R != u && t[t[u].pt].R != NIL){
    return t[t[u].pt].R;}
  return NIL;
}

void print(int u) {
  printf("node %d: ", u);
  printf("parent = %d, ",t[u].pt);
  printf("sibling = %d, ",gets(u));
  int dg = 0;
  if(t[u].L != NIL) dg++;
  if(t[u].R != NIL) dg++;
  printf("degree = %d, ", dg);
  printf("depth = %d, ", d[u]);
  printf("height = %d, ", h[u]);

  if(t[u].pt == NIL){
    printf("root\n");
  }else if(t[u].L == NIL && t[u].R == NIL){
    printf("leaf\n");
  }else {
    printf("internal node\n");
  }
}

int main(){
  int v,l,r,rt=0;
  scanf("%d",&n);

  for(int i=0;i < n;i++) t[i].pt = NIL;

  for(int i=0;i < n;i++){
    scanf("%d %d %d",&v,&l,&r);
    t[v].L = l;
    t[v].R = r;
    if(l != NIL) t[l].pt=v;
    if(r != NIL) t[r].pt=v;
  }

  for(int i=0;i<n;i++) if(t[i].pt == NIL) rt = i;

  setd(rt,0);
  seth(rt);

  for(int i = 0;i < n;i++) print(i);

  return 0;
}
  



Measured memory_bytes: 2768
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using vs = vector<string>;
using vb = vector<bool>;
#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 REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    string s;
    cin >> n >> s;
    int red = 0;
    bool st = false;
    REP(i, n) {
        if (!st and s[i] == 'W') {
            st = true;
        } else if (st and s[i] == 'R') {
            red++;
        }
    }
    st = false;
    int w = 0;
    REPR(i, n) {
        if (!st and s[i] == 'R') {
            st = true;
        } else if (st and s[i] == 'W') {
            w++;
        }
    }

    int l = 0;
    int r = n - 1;
    int ans = 0;
    while (l < r) {
        if (s[l] == 'W') {
            if (s[r] == 'R') {
                ans++;
                l++;
                r--;
            } else {
                r--;
            }
        } else {
            l++;
        }
    }
    cout << min({red, w, ans}) << endl;
}


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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>(ll)m; i--)
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
	ll N;
	cin>>N;
	ll res=1e9;
	ll i6=0,i9=0;
	int a;
	FOR(i,0,N+1){
		a=i;
		i6=0;
		i9=0;
		while(a!=0){
			i6+=a%6;
			a = a/6;
		}

		a=N-i;
		while(a!=0){
			i9+=a%9;
			a = a/9;
		}
		if(i6+i9<res) res=i6+i9;
	}
	cout<<res<<endl;
}


Measured memory_bytes: 256
//package atcoder;
 
import java.util.*;
import java.math.BigDecimal;
 
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int R = sc.nextInt();
		if(N>=10) {
			System.out.println(R);
		}
		if(N<10) {
			System.out.println(R+100*(10-N));
		}
	}
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector<pi> vpi;
typedef long double ld;
#define pb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll)x.size()
#define f first
#define s second
#define MAXN 501010

ll T,N,M;
ll A[MAXN];
vi V[MAXN];
ld a = 0.08;
ld b = 0.10;

int main(){
	cin>>N>>M;
	for (ll x = 1;x<=10000;++x){
		if ((ll)(x*a) == N && (ll)(x*b) == M){
			cout<<x;
			return 0;
		}
	}
	cout<<-1;
}


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

int main(){
  int N,D,sum;
  cin >> N >> D >> sum;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<D;j+=A.at(i)){
      sum++;
    }
  }
  cout << sum << endl;
}

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

int main() {
  int n = 5;
  vector<int> a(n);
  rep(i, n) {
    cin >> a[i];
    if (a[i] == 0) {
      cout << i + 1 << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N = in()-1,K = in()-1;
    vector<int> A(N+1);
    REP(i,N+1)A[i] = in();
    cout <<  (K+N-1)/K<< "\n";
}

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

int main(){
    string S;cin >> S;
    reverse(S.begin(),S.end());
    int index = 0;
    int N = S.size();
    vector<string> memo = {"dream","dreamer","erase","eraser"};
    for(int i = 0; i < memo.size(); i++){
        reverse(memo[i].begin(),memo[i].end());
    }
    
    
    while(index < N){
        bool flag = true;
        for(int i = 0; i < memo.size(); i++){
            if(S.substr(index,memo[i].size()) == memo[i]){
                index += memo[i].size();
                flag = false;
            }
        }
        //cout << index << " " << N << endl;;
        if(flag){cout << "NO" << endl;return 0;}
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 3728
n,p = map(int,input().split())
def factorization(n): 
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
ls = factorization(p)
di = []
for i in range(len(ls)):
    if ls[i][1] >= n:
        di.append(ls[i][0]**(ls[i][1]//n))
if di == []:
    print(1)
else:
    a = 1
    for j in di:
        a *= j
    print(a)

Measured memory_bytes: 9452
#include <cstdio>
#include <map>
#include <set>

using namespace std;

int main() {
  char s[32];
  int i, d;
  bool f(false);
  map<int, int> csa, csb;
  set<int> is;
  while (fgets(s, 32, stdin)) {
    if (s[0] == '\n' && !s[1]) {
      f = true;
      continue;
    }
    sscanf(s, "%d,%d\n", &i, &d);
    if (f) {
      if (csa[i])
        is.insert(i);
      csb[i]++;
    } else
      csa[i]++;
  }
  for (set<int>::iterator it = is.begin(); it != is.end(); ++it)
    printf("%d %d\n", *it, csa[*it] + csb[*it]);
  return 0;
}

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

int check(char str[],unsigned len);

int main(void){
  char str[16],part[16];
  unsigned i,j,k,l,end,max=3;
  scanf("%s",str);
  l=strlen(str);
  end=(1<<l);

  for(i=0;i<end;i++){
    memset(part,0,sizeof(part));
    for(j=k=0;j<l;j++){
      if((i>>j&1)==0) continue;
      part[k++]=str[j];
    }
    if(k<=max) continue;
    if(check(part,k)==0) continue;
    max=k;     
  }
  printf("%u\n",max);
  return 0;
}

int check(char str[],unsigned len){
  unsigned mid,i,j,k;
  const char check[2][7]={"(){}[]",")(}{]["};
  if(len%2==0) return 0;
  mid=len/2;
  if(str[mid-1]!='i' || str[mid]!='w' || str[mid+1]!='i') return 0;
  for(i=0;i<mid-1;i++){
    for(j=0;j<6;j++){
      if(str[i]==check[0][j] && str[len-i-1]!=check[1][j]) return 0;
    }
  }
  return 1;
}

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

int main(void){
  int n, *s, q, *t, c = 0;
  int i, mid, right, left;

  scanf("%d", &n);
  s = (int *)malloc(sizeof(int) * n);
  for(i = 0; i < n; i++){
    scanf("%d", &s[i]);
  }
  scanf("%d", &q);
  t = (int *)malloc(sizeof(int) * q);
  for(i = 0; i < q; i++){
    scanf("%d", &t[i]);
  }

  for(i = 0; i < q; i++){
    right = n;
    left = 0;
    while(left < right){
      mid = (left + right) / 2;
      if(s[mid] == t[i]){
	c++;
	break;
      }else if(s[mid] > t[i]){
	right = mid;
      }else{
	left = mid+1;
      }
    }
  }
  printf("%d\n", c);
  free(s);
  free(t);
  return 0;
}

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

#define REPI(i, n) for(int i = 0; i < n; i++)
#define REPJ(j, n) for(int j = 0; j < n; j++)

using ll = long long;
using namespace std;

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

    int a; cin >> a;
    string s; cin >> s;
    a >= 3200 ? cout << s : cout << "red";
}


Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())


void solve() {
  int n;
  int l;
  cin >> n >> l;
  int res = 0;
  FOR(i, l, l+n) {
    if (i == l && i > 0 ) continue;
    if (i == l+n-1 && i < 0) continue;
    res += i;
    // cout << res << endl;
  }
  cout << res << endl;

}

int main() {
	solve();
	return 0;
}


Measured memory_bytes: 256
/*
* Desciption:  union find	
* Created:    2016-02-21
* Author:      JIngwei Xu [mail:xu_jingwei@outlook.com]
*
*/
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cstring>
using namespace std;
char s[5];
const int maxn=100000+7;
int n,q,v;
long ans;
int f[maxn];
void init(){
	for (int i = 1; i < n+7; i += 1)f[i]=i;
	ans=0;
}
int find(int x){
	int r=x;
	while (f[r]!=r)r=f[r];
	return r;
}
bool same(int x,int y){
	return find(x)==find(y);
}
int main()
{
	while (scanf("%d%d",&n,&q)&&n)
	{
		init();
		for (int i = 2; i <=n; i += 1)scanf("%d",&f[i]);
		while (q--)
		{
			scanf("%s",s);
			scanf("%d",&v);
			if(s[0]=='M')f[v]=v;
			if(s[0]=='Q')ans+=find(v);
		}
		printf("%ld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1580
#include <bits/stdc++.h>
using namespace std;
#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 print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;
typedef long long ll;

const int MOD = 1e9+7;
const int INF = 1e9;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int N;
    cin>>N;
    string ans = "No";
    rep1(a,10)rep1(b,10){
        if(N == a*b){
            ans = "Yes";
        }
    }
    cout<<ans<<endl;
}

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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
int main(){
  int n,m,i,j;
  while(1){
    scanf("%d %d",&m,&n);
    if(m+n==0)break;
    bool flag[7380000];
    int counter=0;
    for(i=0;i<7380000;i++)
      flag[i]=false;
    for(i=m;i<7380000;i++){
      if(flag[i]==false){
	if(counter==n){
	  printf("%d\n",i);
	  break;
	}
	counter++;
	for(j=i;j<7380000;j+=i){
	  flag[j]=true;
	}
      }
    }
  }
  return 0;
}



Measured memory_bytes: 10412
#include <iostream>

using namespace std;

int main()
{
	int x, a, b;
	
	cin >> x >> a >> b;
	
	if (b - a <= 0) {
		cout << "delicious" << endl;
	}
	else if (b - a <= x) {
		cout << "safe" << endl;
	}
	else {
		cout << "dangerous" << endl;
	}
	
	return (0);
}

Measured memory_bytes: 256
#include<stdio.h>

void print(int A[], int N) {
	int i;
	for (i = 0; i < N; i++) {
		if (i == 0)
			printf("%d", A[i]);
		else
			printf(" %d", A[i]);
	}
	printf("\n");
}

void insertionSort(int A[], int N) {
	int i, j;
	int v;
	for (i = 1; i < N; i++) {
		v = A[i];
		j = i - 1;
		while (j >= 0 && A[j] > v) {
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = v;
		print(A, N);
	}
}

int main() {
	int A[1000];
	int N;
	int i;
	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}
	print(A, N);
	insertionSort(A, N);
//	print(A, N);
	return 0;
}



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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

signed main(){
	int A=read(),B=read();
	if(A+B>=10) cout << "error";
	else cout << A+B;
}

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

int main()
{
    int N;
    std::cin >> N;

    int count = 0;
    for(int i=1; i<=N; i++){
        int log = floor(log10(i)) + 1;
        if(log%2 == 1) count++;
    }

    std::cout << count << std::endl;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        n: usize, x: usize
    }

    if x == 1 || x == 2 * n - 1 {
        println!("No");
        return;
    }

    if n == 2 && x == 2 {
        println!("Yes\n1\n2\n3");
        return;
    }

    let mut ans = vec![0; 2 * n - 1];
    let mut used = HashSet::new();
    let mid = n - 1;
    ans[mid] = x;
    used.insert(x);
    ans[mid - 1] = x - 1;
    used.insert(x - 1);
    ans[mid + 1] = x + 1;
    used.insert(x + 1);
    if x + 2 <= 2 * n - 1 {
        ans[mid - 2] = x + 2;
        used.insert(x + 2);
    } else {
        ans[mid + 2] = x - 2;
        used.insert(x - 2); 
    }
    
    let mut pos = 0;
    for i in 1..=2 * n - 1 {
        if used.contains(&i) {
            continue;
        }
        while pos < 2 * n - 1 && ans[pos] != 0{
            pos += 1;
        }
        if pos == 2 * n - 1 {
            break;
        }
        ans[pos] = i;
    }

    println!("Yes");
    for v in ans {
        println!("{}", v);
    }
}


Measured memory_bytes: 3640
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().execute();
	}

	private void execute() {
		Scanner sc = new Scanner(System.in);
		final int N = sc.nextInt();

		int[] keyX = new int[N];
		int[] keyY = new int[N];
		int[] keyH = new int[N];
		Key[] keys = new Key[N];
		for (int i = 0; i < N; i++) {
			keys[i] = new Key(sc.nextInt(), sc.nextInt(), sc.nextInt());
		}
		Arrays.sort(keys, new Comparator<Key>() {
			@Override
			public int compare(Key o1, Key o2) {
				// TODO Auto-generated method stub
				return o2.h - o1.h;
			}
		});

		for (int cx = 0; cx <= 100; cx++) {
			for (int cy = 0; cy <= 100; cy++) {
				int H = estimateH(cx, cy, keys[0].x, keys[0].y, keys[0].h);
				boolean allKeyOk = true;
				for (int i = 1; i < N; i++) {
					Key k = keys[i];
					if(heightAt(cx, cy, H, k.x, k.y) != k.h) {
						allKeyOk = false;
						break;
					}
				}
				if (allKeyOk) {
					System.out.printf("%d %d %d\n", cx, cy, H);
					return;
				}
			}
		}

	}

	private int heightAt(int cx, int cy, int h, int x, int y) {
		return Math.max(0, h - Math.abs(cx - x) - Math.abs(cy - y));
	}

	private int estimateH(int cx, int cy, int x, int y, int h) {
		return h + Math.abs(cx - x) + Math.abs(cy - y);
	}

	class Key {
		int x;
		int y;
		int h;

		public Key(int x, int y, int h) {
			this.x = x;
			this.y = y;
			this.h = h;
		}
	}

}


Measured memory_bytes: 23636
"use strict";

// read lines from stdin
const input = require("fs")
  .readFileSync("/dev/stdin", "utf8")
  .split(" ").map((v) => parseInt(v, 10));

const N = input[0];
const K = input[1];

let borders = [];

if (K === 1) {
  console.log(1);
  return;
}

for (let i = 1; ; i++) {
  const border = K / Math.pow(2, i);
  borders.push(Math.ceil(border));

  if (border < 1) { break; }
}

let ans = (K < N) ? (N - K + 1) / N : 0;

for (let i = 0; i < borders.length; i++) {
  if (borders[i] > N) {
    borders[i] = N + 1;
    continue;
  }

  ans += ((borders[i - 1] || K) - borders[i]) / (N * Math.pow(2, i + 1));
}

console.log(ans);


Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<ll> &v) {
    std::for_each(v.begin(), v.end(), [](ll x) { std::cout << x << " "; });
    std::cout << std::endl;
}
// http://drken1215.hatenablog.com/entry/2018/09/09/015414
int main() {
    ll x, y;
    cin >> x >> y;
    ll res = 1LL << 60;
    if(x <= y) {
        res = min(res, y - x);
    }
    if(-x <= y) {
        // xを最初に反転
        res = min(res, y + x + 1);
    }
    if(x <= -y) {
        // xを最後に反転
        res = min(res, -y - x + 1);
    }
    if(-x <= -y) {
        // xを最初にxを最後に反転
        res = min(res, -y + x + 2);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> p = {2, 5, 5, 4, 5, 6, 3, 7, 6};
  vector<pair<int, char>> vp;
  rep(i, m){
    int in;
    cin >> in;
    vp.push_back(make_pair(p.at(in-1), in + '0'));
  }
  vector<string> dp(n+10, "x");
  dp.at(0) = "";
  rep(i, n){
    if(dp.at(i) == "x") continue;
    rep(j, vp.size()){
      int pf; char ps;
      tie(pf, ps) = vp.at(j);
      int nxi = i + pf;
      string nxs = dp.at(i);
      nxs.push_back(ps);
      sort(nxs.rbegin(), nxs.rend());
      bool f = false;
      if(dp.at(nxi) == "x") f = true;
      else if(dp.at(nxi).size() < nxs.size()) f = true;
      else if(dp.at(nxi).size() == nxs.size() && dp.at(nxi) < nxs) f = true;
      if(f == true) dp.at(nxi) = nxs;
    }
  }
  cout << dp.at(n) << endl;
  return 0;
}

Measured memory_bytes: 54632
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;

#include <assert.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 FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    string s;
    cin >> s;
    cout << count(ALL(s), '1') << endl;


    return 0;
}





Measured memory_bytes: 256