akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<bits/stdc++.h>
#define ll long long
#define   ull unsigned long long 
const int MAX=3e5;
const int mod=1e9+7;
using namespace std;

int main(){
	int n , m, a, b, c;
	cin>>n;
	int arr[n+1];

	for(int i=1;i<=n;i++){
		cin>>arr[i];
	}
	int cnt=0;
	for(int i=2;i<=n-1;i++){
		vector<int>v;
		v.push_back(arr[i-1]);
		v.push_back(arr[i+1]);
		v.push_back(arr[i]);
		sort(v.begin(), v.end());
		if(v[1]==arr[i])
			cnt++;
	}
	cout<<cnt;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
typedef long long ll;

#define MOD 1000000007
int counts[1001] = { 0 };

void countFactor(int num)
{
	int limit = num;

	while (limit % 2 == 0) {
		counts[2]++;
		limit /= 2;
	}

	for (int i = 3; i <= limit; i += 2) {
		while (limit % i == 0) {
			counts[i]++;
			limit /= i;
		}
	}
}

ll getResult(int N)
{
	ll ans = 1;
	rep1(i, 1, N) ans = (ans * (ll)(counts[i] + 1)) % MOD;
	return ans;
}

int main()
{
	int N;
	cin >> N;
	rep1(i, 1, N) countFactor(i);
	cout << getResult(N) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
int N;

int main(){
	cin >> N;
	vector<ll> v(N+1,0),u(N+1,0);
	for(int i=1;i<=N;i++){
		cin >> v[i];
		u[i] = v[i];
	}
	sort(v.begin()+1,v.end());
	sort(u.begin()+1,u.end());
	for(int i=1;i<=N;i++){
		u[i] += u[i-1];
	}
	ll ans = 1;
	ll j = N;
	while(j>1){
		if(v[j] <= 2*u[j-1]){// j-1 is OK?
			ans++;
			j--;
		}else break;
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>

int b(void);
int c(void);

int main(void) {
	c();
	return 0;
}

int c(void) {
	long long int N;
	std::cin >> N;
	long long int up_b = static_cast<long long int>(std::sqrt(N));
	long long int max_i = 0;
	for (int i = up_b; i > 0; i--) {
		if (N % i == 0) {
			max_i = i;
			break;
		}
	
	}
	
	std::cout << max_i + (N / max_i) -2;
	return 0;
}

int b(void) {
	int N;
	std::cin >> N;
	if (N > 81) {
		std::cout << "No";
		return 0;
	}
	else {
		for (int i = 1; i < 10; i++) {
			if (N % i == 0 && N / i < 10) {
				
				std::cout << "Yes";
				return 0;
			}
		}
	}
	std::cout << "No";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
using namespace std;
typedef long long int ll;
using ull = unsigned long long;

constexpr ll mod=1e9+7;

struct UnionFind{
    vector<int> par,num;
    vector<bool> done;
    UnionFind(int n):par(n),num(n,1),done(n,false){
        iota(par.begin(),par.end(),0);  //include<numeric>
    }
    int find(int v){
        return (par[v]==v)?v:(par[v]=find(par[v]));
    }
    void unite(int u,int v){
        u=find(u),v=find(v);
        if(u==v)return;
        if(num[u]<num[v])swap(u,v);
        num[u]+=num[v];
        par[v]=u;
        done[u]=done[u]|done[v];
    }
    bool same(int u,int v){
        return find(u) == find(v);
    }
    bool ispar(int v){
        return v=find(v);
    }
    int size(int v){
        return num[find(v)];
    }
};

vector<int> g[200200];
ll dp[200200];

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll res=0;
    int n; cin >> n;
    for(int i=1;i<n;i++){
        int a,b; cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    for(int i=0;i<n;i++){
        if(i==0){
            int cnt=0;
            for(int j=0;j<n;j++){
                int ok=0;
                for(int t:g[j]){
                    if(t<j)ok++;
                }
                if(!ok){
                    cnt++;
                }
                else{
                    cnt-=(ok-1);
                }
                dp[0]+=cnt;
            }
        }
        else{
            dp[i]=dp[i-1];
            vector<int> v;
            for(int t:g[i-1]){
                if(t>i-1){
                    v.push_back(t);
                }
            }
            sort(v.begin(), v.end());
            for(int j=1;j<v.size();j++){
                dp[i]+=(n-v[j]);
            }
            if(v.size())dp[i]-=(v[0]+1-i);
            else dp[i]-=(n-(i)+1);
        }
        res+=dp[i];
    }
    cout << res << endl;
}


Measured memory_bytes: 16820
import Control.Monad

main = do
    n <- read <$> getLine
    putStrLn $ if solve n == "" then "0" else solve n

solve :: Int -> String
solve n | n == 0          = ""
        | n `mod` 2 == 1  = solve ((n - 1) `div` (-2)) ++ "1"
        | otherwise       = solve ( n      `div` (-2)) ++ "0"

Measured memory_bytes: 508
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int n;
	string S, ans = "";
	map<char, int> tmp, cnt;

	for (char c = 'a'; c <= 'z'; c++) cnt[c] = 50;

	cin >> n;
	rep(i, n) {
		cin >> S;

		for (char c = 'a'; c <= 'z'; c++) tmp[c] = 0;
		rep(j, (int)S.length()) tmp[S[j]]++;
		for (char c = 'a'; c <= 'z'; c++) cnt[c] = min(cnt[c], tmp[c]);
	}

	for (char c = 'a'; c <= 'z'; c++) {
		rep(j, cnt[c]) ans.push_back(c);
	}

	sort(ans.begin(), ans.end());
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
)

func main() {
	for {
		var x, y int
		fmt.Scan(&x)
		fmt.Scan(&y)
		if x == 0 && y == 0 { break }
		if x < y {
			fmt.Println(strconv.Itoa(x) + " " + strconv.Itoa(y))
		} else {
			fmt.Println(strconv.Itoa(y) + " " + strconv.Itoa(x))
		}
	}
}

Measured memory_bytes: 1400
a, b, ab, x, y = map(int, input().split())
ave = (a + b) / 2
ans = 0

if ab >= ave:
    ans += a * x + b * y
else:
    if x > y:
        ans += ab * y * 2
        if a > ab * 2:
            ans += ab * (x - y) * 2
        else:
            ans += a * (x - y)
    else:
        ans += ab * x * 2
        if b > ab * 2:
            ans += ab * (y - x) * 2
        else:
            ans += b * (y - x)
        
print(ans)

Measured memory_bytes: 3064
/**
 * Title:
 * Url:
 */
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<numeric>
#include<functional>
#include<sstream>
#include<iomanip>

using namespace std;

#define ll long long

int main() {
    int n, m; cin >> n >> m;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin >> a[i];
    vector<pair<int, int>> bc(m);
    for(int i=0; i<m; i++) {
        int bi, ci; cin >> bi >> ci;
        bc.push_back(make_pair(ci, bi));
    }
    // O(MlogM) 
    sort(bc.begin(), bc.end(), std::greater<pair<int, int>>());
    vector<int> d(n, 0);
    int counter = 0;
    for(auto bci:bc) {
        // O(max(M, N))
        if(counter>=n) break;
        for(int i=0; i<bci.second; i++) {
            if(counter>=n) break;
            d[counter] = bci.first;
            counter++;
        }
    }
    // O(NlogN)
    sort(a.begin(), a.end());
    ll sum = 0;
    // O(N)
    for(int i=0; i<n; i++) {
        if(a[i]>=d[i]) {
            sum += a[i];
        } else {
            sum += d[i];
        }
    }
    // O(NlogN+MlogM)
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 2544
from collections import deque
import sys
input = sys.stdin.readline

n = int(input())

edge = [[] for i in range(n)]
for i in range(n-1):
    u,v,w = map(int,input().split())
    edge[u-1].append((v-1,w))
    edge[v-1].append((u-1,w))
#p:ne
p = -1
cnt = -1
for i in range(n):
    if len(edge[i]) > cnt:
        p = i
        cnt = len(edge[i])

res = [-1]*n
res[p] = 0

tank = deque([p])
while len(tank):
    new = deque.pop(tank)
    for e in edge[new]:

        if res[e[0]] == -1:
            if  e[1] %2 == 0:
                if res[new] == 1:
                    res[e[0]] =1
                else:
                    res[e[0]] = 0                
            else:
                if res[new] == 1:
                    res[e[0]] =0
                else:
                    res[e[0]] = 1
            tank.append(e[0])
for e in res:
    print(e)

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

int main(){
  int n,m,ans=0;cin>>n>>m;
  vector<int> k(m,0),p(m,0);
  vector<vector<int>> s(m,vector<int>(n,0));
  REP(i,m){
    cin>>k[i];
    for(int j=0;j<k[i];j++) cin>>s[i][j];
  }
  REP(i,m) cin>>p[i];
  
  for(int i=0;i<pow(2,n);i++){
    bool flag=1;
    for(int j=0;j<m;j++){
      int on=0;
      for(int l=0;l<k[j];l++) if(i&(1<<(s[j][l]-1))) on++;
      if(on%2!=p[j]) flag=0;
    }
    if(flag) ans++;
  }
  cout<<ans;
}

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

int main() {
    string S, T;
    cin >> S >> T;
    int cnt = 0;
    for (int i=0; i<S.length(); i++)
        if (S[i] != T[i]) cnt++;
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3836
#include<iostream>
 #include<stdio.h>
 #include<cstdlib>
 #include<cstdio>
 #include<string>
 #include<math.h>
 #include<time.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<fstream> 
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<deque>
 #include<functional>
 #include<utility>
 #include<list>
 #include<memory>
 
 using namespace std;

 int main()
 {
   string a,b;
   while(cin>>a>>b)
   {
     if(a[0]==b[2]&&(a[1]==b[1])&&(a[2]==b[0])) cout<<"YES"<<endl;
     else cout<<"NO"<<endl;         
   }
   return 0;
 }
 

        


Measured memory_bytes: 256
/*author  ADITYA BANSAL
                 //~ MNNIT ALLAHABAD     */
        #include<bits/stdc++.h>
        using namespace std;
        #define ll long long
        #define ull unsigned long long
        ll power(ll,ll);
        ll ncr(ll,ll);
        ll add(ll a,ll b);
        void fact();
        ll mul(ll a,ll b);
        #define watch(x) cerr<<(#x)<<"is"<<x<<nl;
        #define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
        #define fi(a,b) for(ll i=a; i<b; i++)
        #define fk(a,b) for(ll k=a; k<b; k++)
        #define fri(a,b) for(ll i=a; i>=b; i--)
        #define fj(a,b) for(ll j=a; j<b; j++)
        #define ffi(a,b) for(ll i=a;i*i<=b;i++)
        #define mp make_pair
        #define ff first 
        #define  tc ll t; cin>>t; while(t--)
        #define all(v) (v).begin(),(v).end()
        #define ss second
        #define pb push_back
        #define mem(v,a) memset((v),a,sizeof(v));
        #define pll pair<ll,ll>
        #define mll map<ll,ll>
        #define sll set<ll>
        #define vll vector<ll>
        #define max3(a,b,c) max(a,max(b,c))
        #define min3(a,b,c) min(a,min(b,c))
        #define nl endl
         int mod=1e9+7;
        const ll  N=100002LL;
        ll fac[N+2];
        ll inv[N+2];
        double dis(ll x1,ll x2,ll y1,ll y2){
			return sqrt(1.0*(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
		} 
    
        signed main(){  
    	fast
    	fact();
    	 //~ tc
        {
		     ll n;
		     cin>>n;
		  ll x[n],y[n];
		  fi(0,n) cin>>x[i]>>y[i];
		double s=0;
		 fi(0,n) {
			 fj(i,n){ 
				 s+=dis(x[i],x[j],y[i],y[j]);
			 }
			
		 }		
		s/=fac[n];
		s*=fac[n-1]*2;
		printf("%.10lf",s);	
	     }
            return 0;
        }
         
         
        /******************************************************************************/
         
        ll add(ll a,ll b){
			a+=b+mod;
		   if(a>=mod) a-=mod;
		   
		   return a;
		} 
         
        ll mul(ll a,ll b){
            return ((a)*(b))%mod;
        }
         
        ll power(ll a,ll n){
          ll res=1;
          while(n){
              if(n&1) res= mul(res,a);
             n>>=1; 
             a= mul(a,a);
          }
            return res;
        }
        void fact(){
        	inv[0]=fac[0]=1;
        	fi(1,N){
        	 fac[i]=mul(fac[i-1],i);
        	inv[i]=power(fac[i],mod-2);
        }
        }
         
        ll ncr(ll n,ll r){
        	
        	if(r>n) return 0;
        	ll e=fac[n];
        	e=mul(e,inv[r]);
        	e=mul(e,inv[n-r]);
        	return e;
        }


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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define int ll
#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair
using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using vs  = vector<string>;
using pii = pair<int,int>;
constexpr ll inf = 1ll<<61;
constexpr ll mod = 1e9+7;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>void add(T &a, const T &b){a += b; a %= mod;}

signed main(){
  int a, b; cin >> a >> b;
  int fa, fb;
  if(a % 4 == 0) fa = a;
  else if(a % 4 == 1) fa = 1;
  else if(a % 4 == 2) fa = a+1;
  else fa = 0;
  if(b % 4 == 0) fb = b;
  else if(b % 4 == 1) fb = 1;
  else if(b % 4 == 2) fb = b+1;
  else fb = 0;
  cout << (fa ^ fb ^ a) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

void shownum(int a, int b){

  for (int i = 0; i < b; i++) {
    printf("%d", a);
  }
  printf("\n");
}

int main(int argc, char const *argv[]) {

  int a, b;
  scanf("%d", &a);
  scanf("%d", &b);

  if (a <= b) {
    shownum(a, b);
  }else if(b < a){
    shownum(b, a);
  }

  return 0;

}


Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
    int i,q,cnt1=0,cnt2=0;char a[60]; scanf("%s",&a);
    q=strlen(a);
    for(i=2;i<q;i++)
    {
        if(a[i]=='C')
        {
            cnt1++;
        }
        if(a[i]>='a'&&a[i]<='z')
        {
            cnt2++;
        }
    }
    
    if(a[1]>='a'&&a[1]<='z')
    {
        cnt2+=1;
    }
    if(a[q-1]=='C')
    {
        cnt1=cnt1-1;
    }
    if(a[0]=='A'&&cnt1==1&&cnt2==q-2)
    {
        printf("AC\n");
    }
    else
    {
        printf("WA\n");
    }

    return 0;
}


Measured memory_bytes: 128
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    n, k = map(int, input().split())
    k2 = k * 2
    t = [[0] * k2 for _ in range(k2)]
    for _ in range(n):
        x, y, c = input().split()
        x, y = int(x), int(y)
        if c == "W": x += k
        x %= k2
        y %= k2
        t[x][y] += 1
        x = (x + k) % k2
        y = (y + k) % k2
        t[x][y] += 1
    # p2D(t)
    # print()
    for i in range(k2):
        ti = t[i]
        for j in range(1, k2):
            ti[j] += ti[j - 1]
    for j in range(k2):
        for i in range(1, k2):
            t[i][j] += t[i - 1][j]
    # p2D(t)
    ans = 0
    for i in range(k - 1, k2):
        for j in range(k - 1, k2):
            cur = t[i][j]
            if i - k >= 0: cur -= t[i - k][j]
            if j - k >= 0: cur -= t[i][j - k]
            if i >= k and j >= k: cur += t[i - k][j - k]
            ans=max(ans,cur,n-cur)
    print(ans)

main()


Measured memory_bytes: 74204
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>

using namespace std;

int main() {
	map<string, string> enki;
	enki["T"] = "A";
	enki["A"] = "T";
	
	enki["C"] = "G";
	enki["G"] = "C";

	string b;
	cin >> b;
	cout << enki[b] << endl;

	return 0;
}

Measured memory_bytes: 768
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const K = Number(input[0][0]);
  const S = input[1][0];

  if (S.length <= K) {
    return S;
  }

  return `${S.slice(0, K)}...`;
};

console.log(main(read()));


Measured memory_bytes: 29632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A;
  cin >> N >> A;
 
  if (N % 500 <= A) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  // ここにプログラムを追記
}


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

int a,b;

signed main()
{
	cin>>a>>b;
	for (int i=1;i<=a*100;i++)
	{
		if ((int(i*0.08)==a)&&(int(i*0.10)==b))
		{
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

int main(){ _;
  string s;cin>>s;
  int sz=s.size();
  int cnt[4]={};
  REP(i,sz){
    if(s[i]=='N')cnt[0]++;
    else if(s[i]=='W')cnt[1]++;
    else if(s[i]=='S')cnt[2]++;
    else if(s[i]=='E')cnt[3]++;
  }
  if((cnt[0]>0&&cnt[2]==0)||
     (cnt[2]>0&&cnt[0]==0)||
     (cnt[1]>0&&cnt[3]==0)||
     (cnt[3]>0&&cnt[1]==0)){
    cout<<"No"<<endl;
  }else{
    cout<<"Yes"<<endl;
  }
}


Measured memory_bytes: 256
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n,k = readInts()
print(min(n%k,k - (n%k)))


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

int H;
int A[500001];

int p(int u) {
	return u / 2;
}

int l(int u) {
	return (2 * u <= H ? 2 * u : 0);
}

int r(int u) {
	return (2 * u + 1 <= H ? 2 * u + 1 : 0);
}

void maxheapify(int u) {
	int max = u;
	if (l(u) && A[l(u)] > A[u])
		max = l(u);
	if (r(u) && A[r(u)] > A[max])
		max = r(u);
	if (max != u) {
		swap(A[max], A[u]);
		maxheapify(max);
	}
}

void buildmaxheap() {
	for (int i = H / 2; i > 0; i--)
		maxheapify(i);
}

int main() {
	cin >> H;
	for (int i = 1; i <= H; i++)
		cin >> A[i];
	buildmaxheap();
	for (int i = 1; i <= H; i++)
		cout << " " << A[i];
	cout << endl;
	return 0;
}



Measured memory_bytes: 4956
import java.util.*;
public class Main
{
    public static void main(String[] args) throws Exception
    {
        Scanner scanner = new Scanner(System.in);
        int[][][] house = new int[5][4][11];
        int n = scanner.nextInt();
        int b, f, r, v;
        String sharp = "####################";
        
        for(int i = 0; i < n; i++)
        {
            b = scanner.nextInt();
            f = scanner.nextInt();
            r = scanner.nextInt();
            v = scanner.nextInt();
            
            house[b][f][r] += v;
        }
        
        for(int i = 1; i <= 4; i++)
        {
            for(int j = 1; j <= 3; j++)
            {
                for(int k = 1; k <= 10; k++)
                {
                    System.out.print(" ");
                    System.out.print(house[i][j][k]);
                }
                System.out.println();
            }
            if (i != 4)
            {
                System.out.println(sharp);
            }
        }
    }
}



Measured memory_bytes: 29152
#include <iostream>
#include <cmath>
#include <algorithm>
#include <deque>
using namespace std;

long long memo[87];


long long ryuka(int n){
  long long ret;
  if(n == 0){
    return 2;
  } else if (n == 1){
    return 1;
  } else if(memo[n] != -1){
    ret = memo[n];
  } else {
    ret = ryuka(n-1) + ryuka(n-2);
    memo[n] = ret;
  }
  return ret;
}


int main(){
  int n;
  cin >> n;
  int i;
  for(int i = 0; i < 87;i++){
    memo[i] = -1;
  }
  memo[0] = 2;
  memo[1] = 1;

  cout << ryuka(n) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    string s;
    cin >> s;
    ll L = s.size();

    ll w;
    cin >> w;

    ll i = 0;
    stringstream ss;
    while(i<L){
        ss << s[i];
        i += w;
    }
    p(ss.str());

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
 
using namespace std;
 
int min_prime(int n);
int isprime(int n);
 
int main()
{
    int n, p;
    while(1){
        cin >> n >> p;
        if(n == -1 && p == -1) break;
        int prime_array[1000] = {0}, sum_array[50000] = {0};
        prime_array[0] = min_prime(n);
        for(int i = 0; i < (2 * p); i++){
            prime_array[i + 1] = min_prime(prime_array[i]);
        }
        int k = 0;
        for(int i = 0; i < (2 * p) + 1; i++){
            for(int j = i; j < (2 * p) + 1; j++){
                sum_array[k] = prime_array[i] + prime_array[j];
                k++;
            }
        }
        sort(sum_array, sum_array+k);
        cout << sum_array[p - 1] << endl;
    }
    return 0;
}
 
int min_prime(int n)
{
    while(++n){
        if(isprime(n)) break;
    }
    return n;
}
 
int isprime(int n)
{
    int ans = 0;
    if(n == 0 || n == 1) ans = 0;
    else if(n == 2) ans = 1;
    else {
        for(int i = 2; i < n; i++){
            if(i * i > n) ans = 1;
            else if(n % i == 0){
                ans = 0;
                break;
            }
        }
    }
    return ans;
}

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

typedef long long ll;
typedef vector<ll> vl;      typedef vector<int> vi;
typedef vector<vl> vvl;     typedef vector<vi> vvi;
typedef pair<ll, ll> pll;   typedef pair<int, int> pii;
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define MOD 1000000007
#define F first
#define S second
#define INF ll(1e18)
#ifdef SHUBHAM107
#include "../trace.h"
#else
#define trace(args...)
#endif
void solve() {
    string s;
    cin >> s;
    int cnt = 0;

    for (char c : s) {
        cnt += (c - '0');
    }

    if (cnt % 9) 
        cout << "No";
    else
        cout << "Yes";
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifdef SHUBHAM107
    freopen("inp.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("err.txt", "w", stderr);
#endif
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}


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

int f[] = {400, 800, 1200, 1600, 2000, 2400, 2800, 3200, 100000};
int a[100], r[10];
int main(){
	int n;
	scanf("%d", &n);
	for(int i = 0;i < n;i++)scanf("%d", &a[i]);
	for(int i = 0;i < n;i++){
		for(int j = 0;j < 9;j++){
			if(a[i] < f[j]){
				r[j]++;
				break;
			}
		}
	}
	int ans = 0;
	for(int i = 0;i < 8;i++)ans += (r[i] >= 1);
	printf("%d %d\n", max(1, ans), ans+r[8]);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <algorithm>
#include <iomanip> //cout << fixed << setprecision(12) << ans << endl;
using namespace std;
 
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define loop(i, l, r) for(int i = l; i < r; i++)
#define rloop(i, l, r) for(int i = l; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vec_i;
typedef pair<int,int> pair_ii;
typedef pair<ull,ull> pair_ull;

const int dx[4] = {0, 0, 1, -1};
const int dy[4] = {1, -1, 0, 0};
const int INF = 1e9;
const int MOD = 1e9+7;

int main()
{
	int n,m;
	cin >> n >> m;
	vector<pair_ull> ps;
	rep(i, n){
		ull a;
		cin >> a;
		ps.push_back(make_pair(a, 1ULL));
	}

	rep(i, m){
		ull b,c;
		cin >> b >> c;
		ps.push_back(make_pair(c,b));
	}
	sort(all(ps), greater<pair<ull,ull>>());

	ull k = 0;
	ull ans = 0;
	for(auto x: ps){
		ull t = min(x.second, n-k);
		ans += t*x.first;
		k += t;
		if(k==n)
			break;
	}
	cout << ans << endl;
}

Measured memory_bytes: 6512
#include<stdio.h>
long long int dp[1001][1001];
int main(void)
{
	long long int N,a[1001],i,j;
	scanf("%lld",&N);
	for(i=1;i<=N;i++){
		scanf("%lld",&a[i]);
	}
	for(i=1;i<N;i++){
		for(j=0;j<=20;j++){
			dp[i][j]=0;
		}
	}
	dp[1][a[1]]=1;
	for(i=1;i<N;i++){
		for(j=0;j<=20;j++){
			if(j+a[i+1]<=20){
				dp[i+1][j+a[i+1]]+=dp[i][j];
			}
			if(j-a[i+1]>=0){
				dp[i+1][j-a[i+1]]+=dp[i][j];
			}
		}
	}
	/*for(i=1;i<N;i++){
		for(j=0;j<=20;j++){
			printf("%d ",dp[i][j]);
		}
		printf("\n");
	}*/
	for(i=0;i<=20;i++){
		if(i==a[N]){
			printf("%lld\n",dp[N-1][i]);
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3092
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastReader s = new FastReader();
        long N = s.nextLong();
        long K= s.nextLong();
        N=N%K;
        System.out.println(Math.min(N,(K-N)));

    }
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

}

Measured memory_bytes: 21076
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,h;cin>>n>>h;
  vector<pair<ll,ll> >pa,pb;
  for(ll i=0;i<n;i++){
    ll a,b;cin>>a>>b;
    pa.push_back(make_pair(a,i));
    pb.push_back(make_pair(b,i));
  }
  sort(pa.begin(),pa.end());
  sort(pb.begin(),pb.end());
  ll af=pa[n-1].first;
  ll as=pa[n-1].second;
  ll sum=0;
  ll hor=0;
  ll th;
  for(ll i=n-1;i>=0;i--){
    if(pb[i].second==as){
      th=i;
    }
    if(pb[i].first>=af){
      hor++;
      sum+=pb[i].first;
    }
    if(sum>=h){
      cout<<hor<<endl;
      return 0;
    }
    if(pb[i].first<af){
      break;
    }
  }
  ll bf=pb[th].first;
  sum-=bf;hor--;
  for(;;){
    hor++;
    if(sum+bf>=h){
      cout<<hor<<endl;
      return 0;
    }
    sum+=af;
  }
}
    
      


Measured memory_bytes: 3564
#include<stdio.h>
int main(void)
{
    char s[6][10001];
    int i = 0,j,k,joi[6] = {0},ioi[6] = {0};
    while(scanf("%s",s[i]) != EOF){
        i++;
    }
    //printf("%d",i);
    for(j = 0;j < i;j++){
        for(k = 0;;k++){
            if(k + 2 <= 10000){
                if(s[j][k] == 'J' && s[j][k + 1] == 'O' && s[j][k + 2] == 'I'){
                    joi[j]++;
                }
                else if(s[j][k] == 'I' && s[j][k + 1] == 'O' && s[j][k + 2] == 'I'){
                    ioi[j]++;
                }
                else if(s[j][k] == '\0'){
                    break;
                }
            }
        }
        printf("%d\n%d\n",joi[j],ioi[j]);
    }


    return 0;
}

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

using namespace std;

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

#define PB push_back
#define F first
#define S second
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(x) (int)x.size()

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007
// #define harmonic(n) 0.57721566490153286l+log(n)

#define mem(a,b) memset( a, b, sizeof(a) )
#define gcd(a,b) __gcd(a,b)
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

inline bool checkBit(ll n, int i) { return n & (1LL << i); }
inline ll setBit(ll n, int i) { return n | (1LL << i); }
inline ll resetBit(ll n, int i) { return n & (~(1LL << i)); }

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

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

const int MAX = 100123;

int dp[MAX];

int main() {
    optimize();
    mem(dp, 0);
    dp[100] = dp[101] = dp[102] = dp[103] = dp[104] = dp[105] = 1;
    for (int i = 106; i < MAX; ++i) {
        dp[i] |= dp[i - 100];
        dp[i] |= dp[i - 101];
        dp[i] |= dp[i - 102];
        dp[i] |= dp[i - 103];
        dp[i] |= dp[i - 104];
        dp[i] |= dp[i - 105];
    }
    int x;
    cin >> x;
    cout << dp[x] << endl;
    return 0;
}


Measured memory_bytes: 640
// unolight {{{
#include <bits/stdc++.h>
#include <unistd.h>
#define SZ(x) ((int)(x).size())
#define ALL(c) begin(c),end(c)
#define REP(i,n) for ( int i=0; i<(int)(n); i++ )
#define REP1(i,a,b) for ( int i=(int)(a); i<=(int)(b); i++ )
#define FOR(it,c) for ( auto it=(c).begin(); it!=(c).end(); it++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long LL;

void RI() {}

template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}

template<typename T>
void _dump( const char* s, T&& head ) { cerr<<s<<"="<<head<<endl; }

template<typename T, typename... Args>
void _dump( const char* s, T&& head, Args&&... tail ) {
    int c=0;
    while ( *s!=',' || c!=0 ) {
        if ( *s=='(' || *s=='[' || *s=='{' ) c++;
        if ( *s==')' || *s==']' || *s=='}' ) c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1,tail...);
}

#define dump(...) _dump(#__VA_ARGS__, __VA_ARGS__);

template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.first<<","<<p.second<<")"; }

template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}

template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }

// }}}
const int MAX_N = 200005;
int n;
vector<PII> jobs;
void input() {
    RI(n);
    REP(i, n) {
    	int a,b;
    	RI(a,b);
    	jobs.PB({b, a});
    }
}

void solve() {
	sort(ALL(jobs));
	int time = 0;
	for(auto j:jobs) {
		int b = j.first, a = j.second;
		if(a + time > b) {
			printf("No\n");
			return;
		}
		time += a;
	}
	printf("Yes\n");
}

int main( int argc, char *argv[] ) {
	input();
	solve();
    return 0;
}


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

int main(void)
{
  int a,b,d,r;
  double f;

  cin >> a >> b;

  d = a / b;
  r = a % b;
  f = (double)a / (double)b;
  
  printf("%d %d %.6lf\n",d,r,f);
  
  return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) \
    for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) \
    for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(), v.end()
#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e15 + 7LL;
constexpr ll MOD = 1e9 + 7LL;
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (int i = 0; i < v.size(); ++i) {
        is >> v[i];
    }
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    if (v.size() == 0) return os;
    for (int i = 0; i < v.size() - 1; ++i) {
        os << v[i] << " ";
    }
    os << v[v.size() - 1];
    return os;
}

void solve() {
    ll n;
    cin >> n;
    if (n == 1) {
        cout << 0 << endl;
        return;
    }
    ll ans = 1;
    REP(i, n) {
        ans = (ans * 8) % MOD;
    }
    ll tmp = 1;
    REP(i,n) {
        tmp = (tmp * 10) % MOD;
    }
    ans = (tmp + MOD - ans) % MOD;
    ll tmp2 = 1;
    REP(i, n) {
        tmp2 = (tmp2 * 9) % MOD;
    }
    ll tmp3 = (tmp + MOD - tmp2) % MOD;
    tmp3 = (tmp3*2) % MOD;
    ans = (tmp3 + MOD - ans) % MOD;
    cout << ans << endl;
}

int main() {
    solve();
    char tmp;
    while (cin >> tmp) {
        cin.putback(tmp);
        solve();
    }
}



Measured memory_bytes: 3628
using namespace std;
#include<iostream>
 
int main()
{
    int a,b;
         cin>>a>>b;
         char arr[a][b];
         for(int i=0;i<a;i++)
         {
             for(int j=0;j<b;j++)
             cin>>arr[i][j];
         }
         for(int x=0;x<b+2;x++)
         cout<<"#";
         cout<<endl;
         for(int y=0;y<a;y++)
         {
             cout<<"#";
             for(int z=0;z<b;z++)
             cout<<arr[y][z];
             cout<<"#"<<endl;
         }
         for(int s=0;s<b+2;s++)
         cout<<"#";
         return 0;
}
 

Measured memory_bytes: 256
import math
a,b,n = map(int,input().split())
Max = 0
if b != 1:
    x = min(n, b-1)
    while x <= n:
        Max = max(math.floor(a*x/b) - a * math.floor(x/b),Max)
        x += b
else:
    Max = 0
print(Max)


Measured memory_bytes: 9120
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author KharYusuf
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ATakahashiCalendar solver = new ATakahashiCalendar();
        solver.solve(1, in, out);
        out.close();
    }

    static class ATakahashiCalendar {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            int m = s.nextInt(), d = s.nextInt();
            int ans = 0;
            for (int i = 1; i <= m; i++) {
                for (int j = 11; j <= d; j++) {
                    if (check(i, j)) ans++;
                }
            }
            w.println(ans);
        }

        boolean check(int i, int j) {
            if ((j % 10) >= 2 && (j / 10) >= 2 && (j % 10) * (j / 10) == i) return true;
            return false;
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public int nextInt() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();

                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);

const int N = 105;

int cnt[N];

int main() {

	FAST;

	int n, k;
	cin >> n >> k;
	while (k -- ) {
		int x;
		cin >> x;
		while (x -- ) {
			int m;
			cin >> m;
			cnt[m] ++;
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; i ++) {
		if (!cnt[i]) {
			ans ++;
		}
	}
	cout << ans << '\n';
	return 0;
}

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int n,m; cin>>n>>m;
    vector<int> s(m),c(m);
    rep(i,m)cin>>s[i]>>c[i];
    string res;
    if(n==1)res="0";
    else if(n==2)res="10";
    else res="100";
    //同じけたで違う数字があれば-1
    rep(i,m){
        for(int j=i+1;j<m;j++){
            if(s[i] == s[j] && c[i] != c[j]){
                cout << -1 << endl;
                return 0;
            }
        }
    }
    //s[i]==1のとき0だったら
    rep(i,m){
        if(s[i] == 1 && c[i] == 0 && n!=1){
            cout << -1 << endl;
            return 0;
        }
    }
    rep(i,m){
        res[s[i]-1] = '0'+c[i];
        //cout << res << endl;
    }
    cout << res << endl;
}


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

ans = set()

for i in range(N-1,-1,-1):
    a = A[i]
    for j in range(i+1,N+1,i+1):
        if j in ans:
            a += 1
    if a%2:
        ans.add(i+1)

print(len(ans))
print(*ans)

Measured memory_bytes: 70364
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

N = INT()
S = input()

tmp_W = 0
tmp_E = 0

cnt = [0]*len(S)
for i in range(len(S)):
	if S[i] == "W":
		tmp_W += 1
	cnt[i] += tmp_W

for i in range(len(S)-1, -1, -1):
	if S[i] == "E":
		tmp_E += 1
	cnt[i] += tmp_E

print(min(cnt)-1)
	


Measured memory_bytes: 17580
S = input()
N = len(S)
sum = 0
count = 0
flg = False
S = S[::-1]

for i in range(N):
  if S[i] == 'W':
    count += 1
    flg = True
  elif S[i] == 'B' and flg:
    sum += count
print(sum)

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

using ll = long long;

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

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

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

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

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int n; std::cin >> n;
  set<string> m;
  rep(i, n) {
    string s; std::cin >> s;
    m.insert(s);
  }
  std::cout << m.size() << "\n";
}


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

using namespace std;

int main(){
   //~ freopen("input.txt", "r", stdin);
   //~ freopen("output.txt", "w", stdout);
   long long a, b, c, d;
   scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
   long long xx = max(a * c, a * d);
   long long yy = max(b * c, b * d);
   printf("%lld\n", max(xx, yy));
   return 0;
}


Measured memory_bytes: 3808
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	string s;
	cin >> s;
	int ans = 700;
	for(int i=0; i<3; i++){
		if(s[i] == 'o'){
			ans += 100;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
s = input()[::-1]
words = ["dream", "dreamer", "erase", "eraser"]
while True:
    match = False
    for w in words:
        if s.startswith(w[::-1]):
            s = s[len(w)::]
            match = True
    if match == False:
        break
print("NO" if len(s) else "YES")

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main (){
  int a,b,c;
  cin >> a >> b >> c ;
  if (b>=(c-1))	cout << b+c <<endl;
  else if((a+b)<=(c-1)) cout << a+2*b+1 <<endl;
  else cout << b+c << endl;
  }

Measured memory_bytes: 256
n=int(input())
c=list(int(input()) for i in range(n))
dp=[0]*n
rec=[0]*(2*10**5+1)
dp[0]=1
rec[c[0]]=1
for i in range(1,n):
	if c[i]==c[i-1]:
		dp[i]=dp[i-1]
		continue
	dp[i]=(dp[i-1]+rec[c[i]])%(10**9+7)
	rec[c[i]]=dp[i]
print(dp[-1])

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

#define MAX_N 20001
int N;
int p[MAX_N] = {0};
int a[MAX_N] = {0};
int b[MAX_N] = {0};
int r[MAX_N] = {0};

void solve(){
    for(int i = 1; i <= N; i++){
        r[p[i]] = i;
    }

    for(int i = 1; i <= N; i++){
        a[i] = 30000 * i;
        b[i] = 30000 * (N - i) +  r[i];
    }

    for(int i = 1; i <= N; i++){
        cout << a[i] << " ";
    }cout << endl;

    for(int i = 1; i <= N; i++){
        cout << b[i] << " ";
    }cout << endl;

    return ;
}

int main(){
    cin >> N;
    for(int i = 1; i <= N; i++){
        cin >> p[i];
    }
    solve();
    return 0;
}

Measured memory_bytes: 896
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define MOD 1000000007
ll powll(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)
#define swapd(a,b) do{double w=(a);(a)=(b);(b)=w}while(0)
#define in(a) scanf("%lld", &(a))
#define in2(a,b) scanf("%lld %lld",&(a),&(b))
#define in3(a,b,c) scanf("%lld %lld %lld",&(a),&(b),&(c))
#define ind(a) scanf("%lf", &(a))
#define ins(a) scanf("%s", (a))
#define put(a) printf("%lld\n", (a))
#define putd(a) printf("%.15f\n", (a))
//      puts(a) printf("%s\n", a) 文字はこっち
//your code here!
int main(void){
    ll N, A, ans=1e15;
    in(N);
    rep(i,N){
        in(A);
        if(A%2){  //奇数だった。
            puts("0");
            return 0;
        }
        ll cnt=0;
        while(!(A%2)){//偶数の時続ける
            A /= 2;
            cnt++;
        }
        chmin(ans, cnt);
    }
    put(ans);
    return 0;
}


Measured memory_bytes: 128