akhauriyash/Code-Regression huggingface dataset:
using System;

class Program {
  static void Main(string[] args) {
    int N = int.Parse(Console.ReadLine());
    if(N == 1)
      Console.WriteLine("Hello World");
    else if(N == 2) {
      int a = int.Parse(Console.ReadLine());
      int b = int.Parse(Console.ReadLine());
      Console.WriteLine(a + b);
    }
  }
}

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

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


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

    if( N%500 > A ) cout << "No" << endl;
    else cout << "Yes" << endl;
}


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

//まだ終わっていない途中がけ

int main() {
    int N;
    cin>>N;
    ll m=0,a=0,r=0,c=0,h=0;
    rep(i,N){
        string S;
        cin>>S;
        if(S[0]=='M')m++;
         else if(S[0]=='A')a++;
         else if(S[0]=='R')r++;
           else if(S[0]=='C')c++;
            else if(S[0]=='H')h++;
            else continue;
    }
    ll ans =m*a*r;
    ans +=m*a*c;
     ans +=m*a*h;
      ans +=m*r*c;
       ans +=m*r*h;
        ans +=m*c*h;
         ans +=r*a*c;
          ans +=r*a*h;
           ans +=r*c*h;
            ans +=a*c*h;
    cout<<ans<<endl; 
}

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

#define int long long

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

/*
#define cin ifs
#define cout ofs
ifstream ifs("in.txt");
ofstream ofs("out.txt");
//*/

int N;
int x[200], y[200];
int mod = 998244353;
bool used[200][200];

signed main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> x[i] >> y[i];
    }
    int ans = 1;
    for (int i = 0; i < N; i++) {
        ans *= 2;
        ans %= mod;
    }
    ans -= 1 + N;
    ans += mod;
    ans %= mod;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (i == j)
                continue;
            int cur = 0;
            int diff = 1;
            for (int k = 0; k < N; k++) {
                if (used[i][k] && used[j][k] &&
                    (x[i] - x[j]) * (y[i] - y[k]) ==
                        (x[i] - x[k]) * (y[i] - y[j])) {
                    goto check;
                }
            }
            for (int k = 0; k < N; k++) {
                if ((x[i] - x[j]) * (y[i] - y[k]) ==
                    (x[i] - x[k]) * (y[i] - y[j])) {
                    cur++;
                    used[i][k] = used[k][i] = true;
                }
            }
            for (int k = 0; k < cur; k++) {
                diff *= 2;
                diff %= mod;
            }
            diff -= 1 + cur;
            diff += mod;
            diff %= mod;
            ans -= diff;
            ans += mod;
            ans %= mod;
        check:;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int a,h,t,m,r,s;
  scanf("%d",&a);
  h=a/3600;
  t=a-3600*h;
  m=t/60;
  r=t-60*m;
  s=r;
  printf("%d:%d:%d\n",h,m,s);
  return 0;
}

Measured memory_bytes: 2680
/*

宣告——
汝身听吾号令，托付吾之命运于汝之剑，
应圣杯之召，若汝遵从此意志此理，回应吧。
在此起誓，吾愿成就世间一切之善行，吾愿诛尽世间一切之恶行。
汝为身缠三大言灵之七天，从抑止之轮显现吧，天秤之守护者！

*/
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<queue>
#define ll long long
#define MOD 1000000007
using namespace std;
inline int read(){
	int re=0,flag=1;char ch=getchar();
	while(!isdigit(ch)){
		if(ch=='-') flag=-1;
		ch=getchar();
	}
	while(isdigit(ch)) re=(re<<1)+(re<<3)+ch-'0',ch=getchar();
	return re*flag;
}
ll n,a[100010],inv[100010],sum[100010],f[1000010];
int main(){
	n=read();ll i,ans=0;inv[1]=1;f[0]=1;
	for(i=1;i<=n;i++){
		a[i]=read();
		f[i]=f[i-1]*i%MOD;
		if(i>1) inv[i]=(MOD-MOD/i)*inv[MOD%i]%MOD;
		sum[i]=(sum[i-1]+inv[i])%MOD;
	}
	for(i=1;i<=n;i++){
		ans=(ans+(sum[i]+sum[n-i+1]-sum[1])*a[i])%MOD;
	}
	ans=ans*f[n]%MOD;
	printf("%lld\n",ans);
}

Measured memory_bytes: 4992
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
public class Main {
	public static void main(String[] args){
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
				PrintWriter pw = new PrintWriter(System.out);) {
			int m = Integer.parseInt(br.readLine());
			pw.println(48 - m);
		} catch (Exception e) {
		}
	}
}

Measured memory_bytes: 20820
#include<iostream>
#include<cstdio>
using namespace std;
int a[52][52]={0};
int main()
{
	int m,n,i,j;
	cin>>n>>m;
	for(i=1;i<=n;i++)
	{
		getchar();
		for(j=1;j<=m;j++)
		{
			char c;
			scanf("%c",&c);
			if(c=='#')
				a[i][j]=1;
		}
	}
	for(i=2;i<n;i++)
	{
		for(j=2;j<m;j++)
		{
			if(a[i][j]==1&&a[i-1][j]==0&&a[i+1][j]==0&&a[i][j-1]==0&&a[i][j+1]==0)
			{
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	cout<<"Yes"<<endl;
	return 0;
} 

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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(t, x) t ipt; cin >> ipt; x.push_back(ipt);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
ll n, cnt, ans, tmp, sum, a, b, c, d, k, m, h, w, q, x, y;
string s, t;

ll f(ll n) {
    if (n >= 0) return n / x + 1;
    else return 0;
}

int main() {
    cin >> a >> b >> x;
    MSG(f(b) - f(a - 1));
}


Measured memory_bytes: 256
n= int(input())
lista=[]
ac= 0
wa=0
tle=0
re=0
for x in range(n):
    palavra= input()
    lista.append(palavra)
for x in range(n):
    if lista[x]== 'AC':
        ac+=1
    if lista[x]== 'WA':
        wa+=1
    if lista[x]== 'TLE':
        tle+=1
    if lista[x]== 'RE':
        re+=1
print("AC x", ac)
print("WA x", wa)
print("TLE x",tle )
print("RE x", re)

Measured memory_bytes: 16024
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
#define Max(a) (*max_element(ALL(a)))
#define Min(a) (*min_element(ALL(a)))
using namespace std;
ll imos[444444];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,k;cin>>n>>k;
  vi A(n);
  for(ll i=0;i<n;i++){
    cin>>A[i];
    imos[max(0LL,(i-A[i]))]++;
    imos[min(210000LL,(i+A[i])+1)]--;
  }
  for(int i=0;i<222220;i++)
    imos[i+1] += imos[i];
  for(int i=0;i<min(k-1,500LL);i++){
    // cout<<"!"<<endl;
    for(int j=0;j<n;j++){
      A[j] = imos[j];
      imos[j] = 0;
    };
    for(int j=0;j<n;j++){
      imos[max(0LL,(j-A[j]))]++;
      imos[min(210000LL,(j+A[j])+1)]--;
    }
    for(int j=0;j<222220;j++)
      imos[j+1] += imos[j];
  }
  for(int i=0;i<n;i++){
    cout<<imos[i]<<" ";
  }
  cout<<endl;

  return 0;
}

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

using namespace std;

bool palindrome(string s) {
    for (int i=0; i<=s.size()/2; i++) {
        if (s[i]!=s[s.size()-1-i])
            return false;
    }
    return true;
}

int main()
{
    string s;
    cin >> s;

    if (palindrome(s) && palindrome(s.substr(0, (s.size()-1)/2)) && palindrome(s.substr((s.size()-1)/2 + 1)))
        puts("Yes");
    else
        puts("No");

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
using namespace std;
int a[100010]={0};
int main()
{
	int n,m,i;
	cin>>n>>m;
	int x=0,y=0;
	for(i=0;i<m;i++)
	{
		int s;string ss;
		cin>>s>>ss;
		if(a[s]>=0)
		{
			if(ss=="WA")
			{
				a[s]++;
			}
			else
			{
				x+=a[s];
				a[s]=-1;
				y++;
				
			}
		}
	}
	printf("%d %d\n",y,x);
}

Measured memory_bytes: 640
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using Graph = std::vector<std::vector<int>>;
using WGraph = std::vector<std::vector<std::pair<int, long long>>>;
using ll = long long;
using namespace std;

int main() {
    int n = 0; cin >> n;
    vector<int> p(n);
    for (int i=0; i<n; i++) {
        cin >> p.at(i);
        p.at(i)--;
    }

    vector<int> pla(n);
    for (int i=0; i<n; i++) {
        pla.at(p.at(i)) = i;
    }
    vector<int> dp(n);
    int maxi = 1;
    dp.at(0) = 1;
    for (int i=1; i<n; i++) {
        if (pla.at(i) > pla.at(i-1)) {
            dp.at(i) = dp.at(i-1) + 1;
        } else {
            dp.at(i) = 1;
        }
        maxi = max(maxi, dp.at(i));
    }

    cout << n - maxi << endl;
    return 0;
}
 

Measured memory_bytes: 2560
#include <iostream>
#include <cmath>
#include <functional>
#include <algorithm>

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

using namespace std;

int main() {
    int N, H, a[100000], b[100000];
    cin >> N >> H;
    REP(i, N) cin >> a[i] >> b[i];

    int a_max = *max_element(a, a + N);
    sort(b, b + N, greater<int>());

    int ans = 0, i = 0;
    while (H > 0) {
        if (b[i] > a_max) {
            H -= b[i++];
            ans++;
        }
        else break;
    }
    if (H <= 0) {
        cout << ans << endl;
        return 0;
    }
    ans += ceil((double)H / a_max);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 405;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
int H, W;
vector<vector<int> > m(MAX, vector<int>(MAX, 0));
vector<vector<int>> visited(MAX, vector<int>(MAX, 0));
vector<int> dx{0, 0, 1, -1}, dy{1, -1, 0, 0};
/* function */
ll bfs(int sx, int sy) {
    visited[sx][sy] = 1;
    queue<pii> q;
    q.push(pii(sx, sy));
    vector<ll> cnt(2);
    while (!q.empty()) {
        pii p = q.front(); q.pop();
        int x = p.first, y = p.second;
        cnt[m[x][y]]++;
        for (int i = 0; i < 4; i++) {
            int nx = x + dx[i], ny = y + dy[i];
            if (nx < 0 || H <= nx || ny < 0 || W <= ny) continue;
            if (visited[nx][ny]) continue;
            if (m[x][y] == m[nx][ny]) continue;
            visited[nx][ny] = 1;
            q.push(pii(nx, ny));
        }
    }
    return cnt[0] * cnt[1];
}
/* main */
int main(){
    cin >> H >> W;
    for (int i = 0; i < H; i++) {
        string S;
        cin >> S;
        for (int j = 0; j < W; j++) m[i][j] = (S[j] == '#' ? 1 : 0);
    }

    ll ans = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (!visited[i][j]) {
                ans += bfs(i, j);
            }
        }
    }
    cout << ans << '\n';
}


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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
//#define debug(x)  cerr << #x << " = " << (x) << endl;
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 coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
const ll INF = 1LL << 60;

//Write From this Line

const int mod = 1e9+7;
int main()
{
	int n;
	cin >> n;
	vector<vector<int>> a(2,vector<int> (n));
	rep(i,2) rep(j,n) cin >> a[i][j];
	int under = a[0][0]; //下段の飴の数と、スタート升の飴の数を足したもの。
	rep(i,n) under += a[1][i] ; 
	//debug(under);
	//どこで下の段に行くかで、n-1通りを試す
	int ans = under ; 
	for(int i = 1 ; i < n ; i ++) {
		under -= a[1][i-1] ;
		under += a[0][i] ;
		//debug(under);
		chmax(ans,under);
	}
	cout << ans << endl;
}


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

int main(){
  int X,Y;
  int ashi;
  int ans=-1;
  cin>>X>>Y;
  //iは鶴，X-iはかめ
  for(int i=0;i<=X;i++){
      ashi=i*2+(X-i)*4;
      if(Y == ashi){
      		ans=ashi;
      }
  }
  
  if(ans==-1)	cout<<"No"<<endl;
  else	cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int s[6],t[6];
int a[3]={-1,-1,-1};
int main(void){
	int n,m; cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>s[i]>>t[i];
		if(a[s[i]-1]!=-1&&a[s[i]-1]!=t[i]){
			cout<<-1<<endl;
			return 0;
		}else{
			a[s[i]-1]=t[i];
		}
	}
	if(a[0]==0&&n!=1){
		cout<<-1<<endl;
		return 0;
	}
	if(n==1&&m==0){
		cout<<0<<endl;
		return 0;
	}
	for(int i=0;i<n;i++){
		if(a[i]!=-1){
			cout<<a[i];
		}else if(i==0){
			cout<<1;
		}else{
			cout<<0;
		}
	}
	cout<<endl;
	    
}


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

int main(){
    string s;
    cin >> s;

    int n = s.length();

    int che[26];
    for(int i = 0; i < 26; i++){
        che[i] = 0;
    }
    for(int i = 0; i < n; i++){
        che[s[i] - 97]++;
    }

    string ans;
    if(n == 26){
        int flag = -1;
        for(int i = 25; i > 0; i--){
            if(s[i] > s[i - 1]){
                flag = i - 1;
                che[s[i] - 97]++;
                break;
            }else{
                che[s[i] - 97]++;
            }
        }


        if(flag == -1){
            cout << -1 << endl;
        }else{
            for(int i = 0; i < flag; i++){
                ans += s[i];
            }
            
            for(int i = 0; i < 26; i++){
                if(che[i] == 2 && s[flag] < char(97 + i)){
                    ans += char(97 + i);
                    break;
                }
            }
            cout << ans << endl;
        }
    }else{
        ans = s;
        for(int i = 0; i < 26; i++){
            if(che[i] == 0){
                ans += (char)(97 + i);
                break;
            }
        }   

        cout << ans << endl;
    }
}

Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = readline().strip()
    if N[0] == N[2]:
        print('Yes')
    else:
        print('No')

    return


if __name__ == '__main__':
    main()


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

int n;
vector<int> a;
vector<vector<int>> e;
vector<int> dp;
vector<int> ans;

void dfs(int pre, int crt)
{
  auto ud = lower_bound(dp.begin(), dp.end(), a[crt]);
  int tmp = *ud;
  *ud = a[crt];
  if (crt != 0)
    if (tmp == INT_MAX)
      ans[crt] = ans[pre] + 1;
    else
      ans[crt] = ans[pre];
  for (int i : e[crt])
    if (i != pre)
      dfs(crt, i);
  *ud = tmp;
}

int main()
{
  cin >> n;
  a.resize(n);
  rep(i, n)
    cin >> a[i];
  e.resize(n);
  rep(i, n - 1)
  {
    int u, v;
    cin >> u >> v;
    e[u-1].push_back(v - 1);
    e[v-1].push_back(u - 1);
  }
  ans.resize(n);
  dp.resize(n);
  fill(dp.begin(), dp.end(), INT_MAX);
  ans[0] = 1;
  dfs(-1, 0);
  rep(i, n)
    printf("%d\n", ans[i]);
  return 0;
}

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

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

const main = (input: string[][]) => {
  const A = input[0].map(Number);

  A.sort((a, b) => b - a);

  return Math.abs(A[1] - A[0]) + Math.abs(A[2] - A[1]);
};

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


Measured memory_bytes: 29476
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
using namespace std;
using pll = pair<long long, long long>;
 
int main() {
    int N, M; cin >> N >> M;
    vector<pll> v;
    for (int i = 0; i < N; ++i) {
        int a; cin >> a;
        v.push_back({a, 1});
    }
    for (int i = 0; i < M; ++i) {
        int b, c; cin >> b >> c;
        v.push_back({c, b});
    }
    sort(v.begin(), v.end(), greater<pll>());
 
    long long num = 0;
    long long res = 0;
    for (auto p : v) {
        if (num + p.second <= N) {
            res += p.first * p.second;
            num += p.second;
        }
        else {
            res += p.first * (N - num);
            num = N;
            break;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 6256
#include<stdio.h>

int main(){
	int N,i,ac = 0,wa = 0,tle = 0,re = 0;
	scanf("%d",&N);
	char frag[N];
	for(i = 0; i < N; i++){
		scanf("%s",&frag[i]);
		/*if(frag[i] == 'A' || frag[i] == 'W' || frag[i] == 'R'){
			i++;
		} else {
			i += 2;
		}*/
	}
	for(i = 0; i < N; i++){
		if(frag[i] == 'A'){
			ac++;
		} else if(frag[i] == 'W'){
			wa++;
		} else if(frag[i] == 'T'){
			tle++;
		} else if(frag[i] == 'R'){
			re++;
		}
	}
	printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n",ac,wa,tle,re);

	return 0;
}

Measured memory_bytes: 1828
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
int a[105]={0};
int main(){
	int n,m=1e9,t=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=100;i++){
		t=0;
		for(int j=1;j<=n;j++){
			t+=(a[j]-i)*(a[j]-i);
		}
		if(t<m) m=t;
	}
	printf("%d",m);



	return 0;
}

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

int main(){
  vector<int> s(5);
  int k;
  for(int i=0;i<5;i++){
    cin>>s.at(i);
  }
  cin >> k;
  string ans="";
  for(int i=0;i<5;i++){
    for(int j=0;j<5;j++){
      if(s.at(i)-s.at(j)>k){
        ans = ":(";
        break;
      }
      ans ="Yay!";
    }
  }
  cout << ans << endl;
}

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

#define NIL NULL

struct node{
  struct node *l, *r, *p;
  int key;
};

typedef struct node * Node;
Node root;

void Preorder(Node t){
  printf(" %d", t->key);
  if(t!=NIL){
    if(t->l != NIL)   Preorder(t->l);
    if(t->r != NIL)   Preorder(t->r);
  }
}

void Inorder(Node t){
  if(t != NIL)
    if(t->l != NIL) Inorder(t->l);

    printf(" %d",t->key);
    
    if(t->r!=NIL)   Inorder(t->r);

}

void insert(int k){
  Node y = NIL, x = root, z;

  z = malloc(sizeof(struct node));
  z->key=k;
  z->l=NIL;
  z->r=NIL;

    for( ; x!=NIL ; ){
    y = x;

    if(z->key < x->key) x = x->l;
    else                x = x->r;
  }
  z->p = y;
  
  if(y==NIL)                root = z;
  else if(z->key<y->key)    y->l = z;
  else                      y->r = z;

  //free(z);
}

main(){
  int n, x;
  char str[20];
  
  scanf("%d",&n);

  for (int  i = 0; i < n; i++ ){
    scanf("%s",str);

    if (str[0] == 'i'){
      scanf("%d",&x);
      insert(x);
    } 
    else if (str[0] == 'p'){
      Inorder(root);
      printf("\n");
      
      Preorder(root);
      printf("\n");
    }
  }
  return 0;
}



Measured memory_bytes: 25204
#include<iostream>
#include<vector>
#include<utility>
#include<map>
#include<deque>
#include<numeric>
#include<algorithm>
#include<unordered_map>

using namespace std;
using ll = long long int;
constexpr int INF = 1 << 29;
constexpr ll MOD = ll(1e9 + 7);

string s, t;

int main(void) {
	cin >> s >> t;
	int ret = 0;
	for (int i = 0; i < 3; i++) {
		if (s[i] == t[i])
			ret++;
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    string s;
    cin >> s;
    string ans;
    
    if (s == "Sunny")ans = "Cloudy";
    else if (s == "Cloudy")ans = "Rainy";
    else if (s == "Rainy")ans = "Sunny";
        
   
    cout << ans << endl;
    
    
    return 0;
}



Measured memory_bytes: 256
extern crate core;

use std::io::{self, Read};

#[macro_export]
macro_rules! input {
  ($s:expr=>$($t:tt)*) => {
    let mut lines=$s.split("\n");
    $(
        line_parse!(lines,$t);
    )*
  };
}

macro_rules! line_parse {
  ($lines:expr,($($name:ident:$t:tt)*)) => {
    let mut line=$lines.next().unwrap().split_whitespace();
    $(value_def!(line,$name,$t);)*
  };

  //複数行
  ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
    values_def!($lines,$n,$name,$t);
  };
}

macro_rules! value_def {
    ($line:expr, $name:ident, $t:tt) => {
        let $name = value!($line, $t);
    };
}

macro_rules! values_def {
    ($lines:expr, $n:expr, $name:ident, $t:tt) => {
        let $name = {
            let mut vec = Vec::new();
            for i in 0..$n {
                let mut next = $lines.next().unwrap().split_whitespace();
                vec.push(value!(next, $t));
            }
            vec
        };
    };
}

macro_rules! value {
  //配列
  ($line:expr,[$t:tt]) => {
    $line.map(|x|{
      let mut iter=::std::iter::once(x);
      value!(iter,$t)
    }).collect::<Vec<_>>()
  };
  //タプル
  ($line:expr,($($t:tt),*)) => {
    ($(value!($line,$t),)*)
  };
  //文字列
  ($line:expr,#) => {
    $line.next().unwrap()
  };
  //インデックス(-1)
  ($line:expr,@) => {
    $line.next().unwrap().parse::<usize>().unwrap()-1
  };
  //単一値
  ($line:expr,$t:ty) => {
    $line.next().unwrap().parse::<$t>().unwrap()
  };
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(n:usize)(list:[usize]));
    let x = list[0];
    if list.clone().into_iter().all(|y| x == y) {
        return (n / 2).to_string();
    }
    let a = {
        let mut vec = Vec::new();
        vec.resize(100001, 0);
        for (i, x) in list.clone().into_iter().enumerate() {
            if i % 2 == 0 {
                vec[x] += 1;
            }
        }
        let mut vec = vec.into_iter().enumerate().collect::<Vec<_>>();
        vec.sort_by_key(|&(_, x)| x);
        vec.reverse();
        vec
    };

    let b = {
        let mut vec = Vec::new();
        vec.resize(100001, 0);
        for (i, x) in list.clone().into_iter().enumerate() {
            if i % 2 == 1 {
                vec[x] += 1;
            }
        }
        let mut vec = vec.into_iter().enumerate().collect::<Vec<_>>();
        vec.sort_by_key(|&(_, x)| x);
        vec.reverse();
        vec
    };

    if a[0].0 == b[0].0 {
        std::cmp::min(n - a[0].1 - b[1].1, n - a[1].1 - b[0].1)
    } else {
        n - a[0].1 - b[0].1
    }.to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "4\n3 1 3 2" => "1",
    test2: "6\n105 119 105 119 105 119" => "0",
    test3: "4\n1 1 1 1" => "2",
}


Measured memory_bytes: 13940
#include <bits/stdc++.h>
#define int long long
using namespace std;

int a[200005];
vector <int> cnt(200005, -1);
int32_t main() {
 int n;
 //freopen("input.txt","r",stdin);
 long long k;
 cin >> n >> k;
 for (int i = 1; i <= n; i++) {
    cin >> a[i];
 }
 int v = 1, curr = 1, len;
 cnt[1] = 0;
 while(k > 0) {
    v = a[v];
    if (cnt[v] != -1) {
        len = cnt[v] - curr;
        break;
    }
    cnt[v] = curr;
    curr++;
    k--;
 }
 k--;
 if (k != 0) {
    if (k > len)
        k %= len;
    while(k > 0) {
        v = a[v];
        k--;
    }
 }
 cout << v;
 return 0;
}


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

int main(void){
    int ct = 0;
    char a[5] = {'\0'};
    int i;

    scanf("%s", a);

    for( i =0 ; a[i] != '\0'; i++){
        if(a[i] == '+'){
            ct++;
        }else{
            ct--;
        }
    }

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


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
	int s,i=1,m;
    cin>>s;
    m=s;
	while(s!=4){
		if(m==2 || m==1) break;
		if(s%2==0){
			s/=2;
		}else s=3*s+1;
		i++;
	}
	cout <<i+3<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  vint d(n);
  rep(i,n){
    cin>>d[i];
  }
  int m;
  cin>>m;
  vint t(m);
  rep(i,m){
    cin>>t[i];
  }
  sort(all(d));
  sort(all(t));
  int fg=0;
  rep(i,m){
    REP(j,fg,n){
      // cout<<t[i]<<' '<<d[j]<<'\n';
      if(j==n-1 && t[i]!=d[j]){
        cout<<"NO"<<'\n';
        return(0);
      }
      if(t[i]==d[j]){
        fg=j+1;
        break;
      }
      if(t[i]<d[j]){
        cout<<"NO"<<'\n';
        return(0);
      }
    }
  }
  cout<<"YES"<<'\n';
  return(0);
}


Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define reps(i, n) for (int i = 1; i <= (n); ++i)
#define repd(i, n) for (int i = (n)-1; i >= 0; --i)
#define repds(i, n) for (int i = (n); i > 0; --i)
#define loop(i, x, n) for (int i = (x); i < (n); ++i)
#define loops(i, x, n) for (int i = (x); i <= (n); ++i)
#define loopd(i, x, n) for (int i = (x); i > (n); --i)
#define loopds(i, x, n) for (int i = (x); i >= (n); --i)
#define itrep(i, a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i, a) for (auto i = rbegin(a); i != rend(a); ++i)
#define each(i, x) for (auto &i : x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
template <class T>
using priority_queuel = priority_queue<T, vector<T>, greater<T>>;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
constexpr double eps = 1e-9;
ll mod = static_cast<ll>(1e9 + 7);
template <class T>
constexpr int sz(const T &a) { return (int)a.size(); }
template <class T>
constexpr T pow2(const T a) { return a * a; }
template <class T, class... Args>
constexpr void mins(T &a, Args... args) { a = min<T>({a, args...}); }
template <class T, class... Args>
constexpr void maxs(T &a, Args... args) { a = max<T>({a, args...}); }
template <class A, int N, class T>
void fillArray(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }

ll x;
void solve() {
    cin >> x;
    ll res = 100;
    ll ans = 0;
    while (res < x) {
        res += res / 100;
        ++ans;
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout.flush();
    return 0;
}


Measured memory_bytes: 3648
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE BangPatterns          #-}
{-# LANGUAGE CPP                   #-}
{-# LANGUAGE LambdaCase            #-}
{-# LANGUAGE MagicHash             #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE MultiWayIf            #-}
{-# LANGUAGE OverloadedStrings     #-}
{-# LANGUAGE TupleSections         #-}
{-# LANGUAGE TypeFamilies          #-}
{-# LANGUAGE ViewPatterns          #-}

import           Control.Applicative
import           Control.Exception
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString             as B
import qualified Data.ByteString.Builder     as B
import qualified Data.ByteString.Char8       as C
import qualified Data.ByteString.Internal    as B
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import qualified Data.Foldable               as F
import           Data.Function
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import qualified Data.List                   as L
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           GHC.Exts
import qualified System.IO                   as IO
import           Unsafe.Coerce

main :: IO ()
main = do
    n <- readLn :: IO Int
    xs <- U.unfoldrN n parseInt <$> C.getLine
    putStrLn.unwords.map show $ solve n xs

solve :: Int -> U.Vector Int -> [Int]
solve n xs = map (succ.snd)
    . L.sort
    . U.toList
    $ U.imap (flip (,)) xs


-------------------------------------------------------------------------------
type Parser a = C.ByteString -> Maybe (a, C.ByteString)

parseInt :: Parser Int
parseInt = C.readInt . C.dropWhile isSpace

parseInt2 :: Parser (Int, Int)
parseInt2 = runStateT $
    (,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)

parseInt3 :: Parser (Int, Int, Int)
parseInt3 = runStateT $
    (,,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)

parseInt4 :: Parser (Int, Int, Int, Int)
parseInt4 = runStateT $
    (,,,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)

Measured memory_bytes: 28284
package main

import (
	"fmt"
)

func main() {
	n, m := ScanInt(), ScanInt()
	a, b := oddCount(n, m), oddCount(m, n)
	fmt.Println(a * b)
}

func oddCount(a, b int) int {
	if a == 2 {
		return 0
	}
	if b == 1 {
		return 1
	}
	return b - 2
}

func ScanInt() (i int) {
	fmt.Scan(&i)
	return
}


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

int main()
{
  string s;
  cin >> s;
  int c0 = 0, c1 = 0, ans = 0; // c0: 0の個数, c1: 1の個数
  for (int i = 0; i < s.size(); i++)
  {
    if (s[i] == '0')
      c0++;
    else if (s[i] == '1')
      c1++;
  }
  ans = min(c0, c1) * 2;
  cout << ans << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double lld;
ll MOD = (1e9)+7;
void fastIO(){
  ios_base::sync_with_stdio(0); cin.tie(0);
}
int main(){
  fastIO();
  ll n,c,x;
  cin>>n>>c;
  int par=0,impar=0;
  for(int i=0;i<n;i++){
  	cin>>x;
  	x%2==0?par++:impar++;
  }
  ll ans = 1;
  if((impar==0&&c==1)){
  	cout<<0<<endl;
  	return 0;
  }
  if(impar!=0){
  	for(int i=0;i<impar+par-1;i++){
  		ans*=2;
  	}
  }else{
  	for(int i=0;i<n;i++){
  		ans*=2;
  	}
  }
  cout<<ans<<endl;
}  





Measured memory_bytes: 256
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
int main(void){
	double a,b,c,deg,rad,S,L,h;
	scanf("%lf %lf %lf",&b,&c,&deg);
	rad = deg/180.0*M_PI;
	a = sqrt(b*b+c*c-2*b*c*cos(rad));
	S = (b*c*sin(rad))/2;
	L = a+b+c;
	h = (b*c*sin(rad))/b;
	printf("%f\n%f\n%f\n",S,L,h);
	return 0;
}
	
	
	

Measured memory_bytes: 648
n, t = map(int,input().split())
time = list(map(int,input().split()))

ans = 0
wait = 0
for i in range(n):
    if i == 0:
        ans += t
        wait += t
    if wait <= time[i]:
        ans += t
        wait = time[i] + t
    else:
        c = (wait - time[i])
        ans -= c
        ans += t
        wait = time[i] + t

print(ans)

Measured memory_bytes: 26708
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		if(N%10==3) {
			System.out.println("bon");
			}
		if(N%10==0||N%10==1||N%10==6||N%10==8){
			System.out.println("pon");
			}
		if(N%10==2||N%10==4||N%10==5||N%10==7||N%10==9){
			System.out.println("hon");
		}
	}

}

Measured memory_bytes: 35584
#include "bits/stdc++.h"

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<long long>L(86 + 1);
	L[0] = 2;
	L[1] = 1;
	for (int i = 2; i <= N; ++i) {
		L[i] = L[i - 1] + L[i - 2];
	}
	cout << L[N];
	return 0;
}


Measured memory_bytes: 3620
import sys
import itertools
input = sys.stdin.readline
sys.setrecursionlimit(100000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if self.v is None:
            self.v = n
        else:
            self.v = self.f(self.v, n) 


def main():
    N = int(input())
    S = read_list()

    res = V(max, 0)
    for c in range(1, N):
        r = 0
        t1 = 0
        t2 = N - 1
        while True:
            t1 += c
            t2 -= c
            if t2 < c:
                break
            
            if (N - 1) % c == 0 and 2 * t2 <= N - 1:
                break

            r += S[t1] + S[t2]
            res.ud(r)

    print(res)


if __name__ == "__main__":
    main()


Measured memory_bytes: 14988
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dunk(n) cout << n << endl
#define all(v) v.begin(), v.end()
typedef long long ll;



int main() {
    rep(i,5){
        int x;
        cin >> x;
        if(x == 0){
            dunk(i+1);
            break;
        }
    }
    return 0;
}



Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(void) {
  int a, b, c, k;
  cin >> a >> b >> c >> k;

  int count = 0;
  while (a >= b) {
    b *= 2; count++;
  }
  while (b >= c) {
    c *= 2; count++;
  }
  if (count > k)
  cout << "No" << endl;
  else
  {
    cout << "Yes" << endl;
  }
  
}

Measured memory_bytes: 3628
package main
import (
        "fmt"
        "sort"
)

func main() {
        var n, ans int
        ans = 0
        fmt.Scan(&n)
        d := make([]int, n)
        for i:=0; i < n; i++ {
                fmt.Scan(&d[i])
                ans += d[i]
        }
        sort.Ints(d)
        fmt.Printf("%d\n", ans - d[n-1]/2)
}


Measured memory_bytes: 512
use std::collections::HashMap;

use proconio::input;

fn main() {
    input! {
        n: usize, k: usize,
        a: [usize; n],
    }
    let mut map = HashMap::new();
    for i in 0..n {
        *map.entry(a[i]).or_insert(0) += 1;
    }
    let mut v = map.into_iter().map(|(_, value)| value).collect::<Vec<_>>();
    v.sort();
    let mut i = 0;
    let mut ret = 0;
    while k < v.len() - i {
        ret += v[i];
        i += 1;
    }
    println!("{}", ret);
}


Measured memory_bytes: 11352
#include<stdio.h>
int main(void)
{
  int t,h,m,s=0;
  scanf("%d",&t);
  h=t/3600;
  m=(t%3600)/60;
  s=t-(h*3600+m*60);
  printf("%d:%d:%d\n",h,m,s);
    return 0;
    }



Measured memory_bytes: 2080
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    public static void Main(string[] args) {
        char[] s = Console.ReadLine().ToCharArray();
        List<Char> list = new List<char>();
        list.AddRange(s);
        for (int i = 0; i < list.Count()-1;) {
            if ((list[i+1].ToString() == "1" && list[i].ToString() == "0") || (list[i+1].ToString() == "0" && list[i].ToString() == "1")) {
                list.RemoveRange(i, 2);
                i --;
                if (i < 0) i = 0;
            }
            else i ++;
        }
        Console.WriteLine(s.Count()-list.Count());
    }
}

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

int main()
{
    int n;
    cin >> n;
    int a[100002];
    int largest = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        largest = max(largest, a[i]);
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        if((abs(largest / 2 - a[i]) < abs(largest / 2 - ans) ||
           (abs(largest / 2 - a[i]) == abs(largest / 2 - ans) && a[i] > ans)) && a[i] != largest){
            ans = a[i];
        }
    }
    cout << largest << " " << ans << endl;
}

Measured memory_bytes: 640
#ifdef LOCAL111
#else
	#define NDEBUG
#endif
#include <bits/stdc++.h>
const int INF = 1e8;
using namespace std;

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RBP(i,a) for(auto& i : a)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
#else
	#define DEBUG(x) true
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
#define rangej(a,b,c) ((a) <= (c) and (c) < (b))
#define rrangej(b,c) rangej(0,b,c)
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef pair<int,int> P;
typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<LL,LL> LP;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);	
}

int main()
{
	ios_init();
	int n;
	cin >> n;
	int k;
	cin >> k;
	vector<int> d(k);
	REP(i,k) cin >> d[i];
	set<int> ds;
	REP(i,k) ds.insert(d[i]);
	int mo = n;
	while(true){
		set<int> s;
		int cmo = mo;
		while(cmo != 0){
			s.insert(cmo%10);
			cmo /= 10;
		}
		bool f = true;
		RBP(e, s){
			if(ds.count(e)) f = false;
		}
		if(f){
			cout << mo << endl;
			return 0;
		}
		mo++;
	}
	return 0;
}


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

namespace ITP1
{
    class ITP1_7_B
    {
        static void Main(string[] args)
        {
            int n, x;
            int[] readLine;
            int count;

            while (true)
            {
                count = 0;
                readLine = Console.ReadLine().Split().Select(int.Parse).ToArray();
                n = readLine[0];
                x = readLine[1];

                if (n == 0 && x == 0)
                {
                    break;
                }

                for (int i = 1; i < n; i++)
                {
                    for (int j = i + 1; j < n; j++)
                    {
                        for (int k = x - i - j; k > j; k--)
                        {

                            if (x == i + j + k && k <= n)
                            {
                                count++;
                            }
                        }
                    }

                }
                Console.WriteLine(count);
            }
        }
    }
}



Measured memory_bytes: 18380
use num::pow;
use proconio::{fastout, input};
#[allow(unused_mut)]
#[fastout]
fn main() {
    input! {
        n: usize,
        a: [u128; n]
    }
    if a.contains(&0u128) {
        println!("0");
        return;
    }
    let mut res = 1u128;
    for i in 0..n {
        res *= a[i];
        if pow(10, 18) < res {
            println!("-1");
            return;
        }
    }
    println!("{}", res);
}


Measured memory_bytes: 5316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)

bool compare(pair<ll, int> a, pair<ll, int> b) {
    if (a.first != b.first) return a.first > b.first;
    else return a.second > b.second;
}

int main() {
    int X, Y, A, B, C; 
    vector<pair<ll, int>> apples(300005);
    cin >> X >> Y >> A >> B >> C;
    
    ll a;
    rep(i, A) cin >> a, apples[i] = make_pair(a, 0);
    rep(i, B) cin >> a, apples[i + A] = make_pair(a, 1);
    rep(i, C) cin >> a, apples[i + A + B] = make_pair(a, 2);

    sort(apples.begin(), apples.end(), compare);
    a = 0;
    int cntA = 0, cntB = 0, cntC = 0, i = 0;
    while ((cntA + cntB + cntC) < (X + Y)) {
        if (apples[i].second == 0 && cntA < X) {
            cntA++;
            a += apples[i].first;
        }
        if (apples[i].second == 1 && cntB < Y) {
            cntB++;
            a += apples[i].first;
        }
        if (apples[i].second == 2) {
            cntC++;
            a += apples[i].first;
        }
        i++;
    }
    cout << a << endl;
}

Measured memory_bytes: 4992
N=int(input())
div=1000000007

primedict= {i:True for i in range(2,N+1)}

for i in range(2,N+1):
        if primedict[i]==True:
                j=2
                while i*j<=N:
                        primedict[i*j]=False
                        j+=1

primelist = [i for i in  range(2,N+1) if primedict[i]==True]

primecntdict={p:0 for p in primelist}

for n in range(2,N+1):
        for p in [p for p in primelist if p <= n]:
                while n%p==0:
                        n/=p
                        primecntdict[p]+=1

res=1
for p in primelist:
        res*=primecntdict[p]+1
        res%=div

print(res)


Measured memory_bytes: 3192
#![allow(unused_imports, unused_variables, dead_code)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

trait InputValue {
    fn parse(s: &str) -> Self;
}

fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

const MOD: i32 = 1000000007;

fn main() {
    let (n, m): (usize, usize) = read();
    let q: Vec<(usize, usize, usize)> = readn(m);
    let mut vec: Vec<Vec<(usize, usize)>> = vec![vec![]; n+1];
    for (l, r, c) in q {
        vec[r].push((l, c));
    }

    let mut dp: Vec<Vec<Vec<i32>>> = vec![vec![vec![0; n+1]; n+1]; n+1];
    dp[0][0][0] = 1;

    for x in 0..n {
        for p in 0..n {
            for q in 0..n {
                let base = dp[x][p][q];
                if base == 0 {
                    continue
                }

                let r = x + 1;
                for (tp, tq) in vec![(p, q), (x, q), (p, x)] {
                    let mut ok = true;
                    for &(l, c) in &vec[x+1] {
                        if color(tp, tq, l, r) != c {
                            ok = false;
                            break;
                        }
                    }
                    if ok {
                        dp[x+1][tp][tq] += base;
                        if dp[x+1][tp][tq] >= MOD {
                            dp[x+1][tp][tq] -= MOD;
                        }
                    }
                }
            }
        }
    }

    let mut sum: i64 = 0;
    for p in 0..n {
        for q in 0..n {
            sum += dp[n][p][q] as i64;
        }
    }
    sum %= MOD as i64;

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

fn color(a: usize, b: usize, l: usize, r: usize) -> usize {
    let mut ret = 1;
    if l <= a && a <= r {
        ret += 1;
    }
    if l <= b && b <= r {
        ret += 1;
    }
    ret
}

Measured memory_bytes: 121212
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<algorithm>
#include<cmath>
using namespace std;

typedef long long int llint;

int main(){
	int N,W;
	cin >> N >> W;
	llint w[N],v[N];

	for(int i=0;i<N;i++){
		cin >> w[i] >> v[i];
	}

	llint dp[N][W+1];
	for(int i=0;i<N;i++){
		for(int k=0;k<=W;k++){
			if(i==0){
				if(k>=w[i]){
					dp[i][k]=v[i];
				}else{
					dp[i][k]=0;
				}
			}else{
				if(k>=w[i]){
					llint valueA=dp[i-1][k];
					llint valueB=dp[i-1][k-w[i]]+v[i];
					if(valueA>valueB){
						dp[i][k]=valueA;
					}else{
						dp[i][k]=valueB;
					}
				}else{
					dp[i][k]=dp[i-1][k];
				}
			}
		}
	}

	cout << dp[N-1][W] << endl;
	return 0;
}


Measured memory_bytes: 78336
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        sc.close();
        char[] c = s.toCharArray();
        System.out.println(c[2] == c[3] && c[4] == c[5] ? "Yes" : "No");

    }

}


Measured memory_bytes: 21844