akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) throws Exception	{
		// TODO ?????????????????????????????????????????????
           Scanner sc = new Scanner(System.in);
           int a,b,c,d,e;
           a=1;b=1;e=1;
           while(a!=0||b!=0){
        	   a = sc.nextInt();
        	   b = sc.nextInt();
        	   c=1;d=1;
        	   if(e!=1){
        		   System.out.println();
        	   }
        	   while(c<=a){
        		   while(d<=b){
        			   if((d+c)%2==0){
        				   if(d!=b){
        					   System.out.print("#");
        				   }else{
        					   System.out.println("#");
        				   }
        			   }
        			   if((d+c)%2==1){
        				   if(d!=b){
        					   System.out.print(".");
        				   }else{
        					   System.out.println(".");
        				   }
        			   }
        			   d=d+1;
        		   }
        		   d=1;
        		   c=c+1;
        	   }
        	   c=1;
        	   e=e+1;
           }
	}

}

Measured memory_bytes: 34976
import java.util.*;
import java.math.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		long n = sc.nextLong();
		long a = 1;	
		
		for(int i=1; i<=Math.sqrt(n); i++) {
			if(n%i == 0) {
				a = n/i;
			}
		}
		
		
		
		System.out.println((int)Math.log10(a)+1);
		
		
		

	}

}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
//ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
//ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve() {
  int n,k;
  cin>>n>>k;
  set<int> s;
  rep(i,k){
    int d; cin>>d;
    vi a(d);
    rep(i,d) cin>>a[i];
    rep(i,d){
      s.insert(a[i]);
    }
  }
  ll ans=0;
  rep(i,n){
    if(!s.count(i+1)) ans++;
  }
  out(ans);
}

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


Measured memory_bytes: 3668
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

typedef long long ll;
ll a, b;

int main() {
	cin >> a >> b;
	ll ans = a;
	a = a - b;
	if (a < b) swap(a, b);
	while (a % b) {
		ans += (a / b * 2 ) * b;
		a = a % b;
		swap(a, b);
	}
	ans += (a / b * 2 - 1) * b;
	cout << ans << endl;

}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
#define FS              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll              long long int
#define ld              long double
#define pb              push_back
#define bp              __builtin_popcount
#define sz              size()
#define ff              first
#define ss              second
#define vll             vector<ll>
#define vbool           vector<bool>
#define vpll            vector<pair<ll,ll>>
#define pll             pair<ll,ll>
#define vllv            vector<vector<ll>>
#define setpri(x)       cout<<setprecision(x)<<fixed;
#define all(v)          v.begin(),v.end()
#define allr(v)         v.rbegin(),v.rend()
#define yesr {cout<<"YES"<<endl;return;}
#define nor {cout<<"NO"<<endl;return;}
// getline (std::cin,name);
ll MOD=1e9+7;
ll ceil1(ll n,ll x){return (n-1)/x+(n>0);}

ll gcd(ll a,ll b){return __gcd(a,b);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}

ll pow1(ll n,ll m ,ll mod=MOD );
ll pow2(ll n,ll k);

ll modinv(ll n,ll mod=MOD){  return pow1(n,mod-2,mod);}

bool func(pair<ll,ll> &a,pair<ll,ll> &b ){
        if(a.ff != b.ff)return a.ff < b.ff;
        return a.ss > b.ss;
}
ll const N=(ll)3e2+11;
ll const LG=(ll)log2(N)+1;


void solve(){
        ll i,j,k,l,n,m,x,y,z,r;
        
        cin>>n;
        cin>>m;
        vll a(n+1);
        for(i=0;i<m;i++)
        {
                cin>>x;
                a[x]=1;
        }
        vll dp(n+11,0);
        dp[0]=1;
        if(a[1]!=1){
                dp[1]=1;
        }
        for(i=2;i<=n;i++){
                if(a[i]!=1){
                        dp[i]=dp[i-1]+dp[i-2];
                        dp[i]%=MOD;
                }else{
                        dp[i]=0;
                }
        }
        // for(i=0;i<=n;i++){
        //         cout<<dp[i]<<" ";
        // }cout<<endl;
        cout<<dp[n]<<endl;
        
        
        
        
}       
int main(){
        FS;
        
        ll i,j,k,n,m,x,y,z,q;
        q=1;
        // cin>>q;
        while(q--){
                solve();
        }
        return 0;
}


ll pow1(ll n,ll m,ll mod){
        if(m==0)return 1;
        
        if(m%2==0)return pow1((n*n)%mod,m/2,mod);
    	
    	return (pow1((n*n)%mod,m/2,mod)*n)%mod;
}

ll pow2(ll n,ll k){
        ll ans=1;
            while(k>0){
                if(k%2==1)ans=ans*n;
                n=n*n;
                k/=2;
            }
            return ans;
}

Measured memory_bytes: 4744
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    int n; cin>>n;
    vector<ll> ch(5,0);
    rep(i,n){
        string s; cin>>s;
        if(s[0]=='M') ch[0]++;
        if(s[0]=='A') ch[1]++;
        if(s[0]=='R') ch[2]++;
        if(s[0]=='C') ch[3]++;
        if(s[0]=='H') ch[4]++;
    }
    ll ans=0;
    for(int i=0;i<3;i++){
        for(int j=i+1;j<4;j++){
            for(int k=j+1;k<5;k++){
                ans=ans+ch[i]*ch[j]*ch[k];
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <tuple>
#include <unordered_map>
#include <map>
#include <cmath>

#define endl "\n"
#define eb emplace_back
#define ll long long

using namespace std;

int main() {

    cin.tie(nullptr); cout.tie(nullptr);
    ios_base::sync_with_stdio(false);

    string s, t;
    cin >> s >> t;

    int dp[s.size()+1][t.size()+1];
    for (int i = 0; i < s.size()+1; i++)
        dp[i][0] = 0;
    for (int i = 0; i < t.size()+1; i++)
        dp[0][i] = 0;

    for (int i = 1; i < s.size()+1; i++) {
        for (int j = 1; j < t.size()+1; j++) {
            if (s[i-1] == t[j-1])
                dp[i][j] = dp[i-1][j-1]+1;
            else
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
        }
    }

    string ans("");
    int i = s.size(), j = t.size();
    while (dp[i][j] != 0) {
        if (dp[i][j] == dp[i-1][j])
            i--;
        else if (dp[i][j] == dp[i][j-1])
            j--;
        else {
            ans = t[j-1] + ans;
            i--; j--;
        }
    }

    cout << ans;

    return 0;

}

Measured memory_bytes: 38900
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int r, g, b, n;
    cin >> r >> g >> b;
    n = g * 10 + b;
    if(n % 4 == 0)
        cout << "YES\n";
    else
        cout << "NO\n";
    return 0;
}

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

vector<int> vl,ans;
vector<char> c;

int a[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
int main(){

    int m1,d1,m2,d2;

    cin >> m1 >> d1 >> m2 >> d2;
    if(d1==a[m1-1]) cout << 1;
    else cout << 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define ASSERT(c, m) if(!(c)){cerr << (m) << endl;exit(1);}

int count_spaces(string s) {
    int ret = 0;
    rep(i, 0, s.size()) {
        if (s[i] != ' ') break;
        ret++;
    }
    return ret;
}

pair<string, string> read_line(string line) {
    string key, cont;
    int st = 0;
    while (line[st] == ' ') {
        ASSERT(st < line.size(), "error1");
        st++;
    }
    bool f = false;
    rep(i, st, line.size()) {
        if (line[i] == ':') {
            f = true;
            i++;
            continue;
        }
        if (!f) {
            key += line[i];
        } else {
            cont += line[i];
        }
    }
    return make_pair(key, cont);
}

signed main() {
    string line;
    getline(cin, line);
    deque<string> keys;
    rep(i, 0, line.size()) {
        if (line[i] == '.') {
            keys.push_back("");
        } else {
            keys.back() += line[i];
        }
    }
    assert(!keys.empty());

    bool found = false;
    string ans;
    int indent = -1;
    while (getline(cin, line)) {
        int tmp = count_spaces(line);
        if (indent == -1) indent = tmp;
        if (indent != tmp) {
            continue;
        }

        string key, cont;
        tie(key, cont) = read_line(line);   
        ASSERT(!keys.empty(), "error2");
        if (key != keys.front()) {
            continue;
        }
        keys.pop_front();
      
        indent = -1;
        if (keys.empty()) {
            ans = cont;
            found = true;
            break;
        }
    }
    if (!found) {
        cout << "no such property" << endl;
    } else {
        if (ans == "") cout << "object" << endl;
        else cout << "string \"" << ans << "\"" << endl;
    }
    return 0;
}



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

int main(int argc, const char * argv[]) {
    int N;
    cin >> N;
    
    int *d = new int[N];
    for (int i = 0; i < N; i++) {
        cin >> d[i];
    }
    
    uint64_t ans = 0;
    for (int i = 0; i < N - 1; i++) {
        for (int j = (i+1); j < N; j++) {
            ans += (d[i] * d[j]);
        }
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド
		Scanner sc = new Scanner(System.in);
		while(true) {
		String str = sc.next();
		if(str.equals("-")) {
			break;
		}
		int a = sc.nextInt();
		for(int i=0;i<a;i++) {
			int b = sc.nextInt();
			str = str.substring(b) + str.substring(0,b);
		}
		System.out.println(str);

	}
	}
}



Measured memory_bytes: 26240
def counting_sort(A, k):
    n = len(A)
    B = [0 for i in range(n)]
    C = [0 for i in range(k+1)]

    for j in range(n):
        C[A[j]] += 1

    for i in range(1, k):
        C[i] = C[i] + C[i-1]

    for j in range(n-1, -1, -1):
        B[C[A[j]]-1] = A[j]
        C[A[j]] -= 1

    return B

n = int(input())
A = list(map(int, input().split(' ')))
B = counting_sort(A, 10000)
print(' '.join(map(str, B)))


Measured memory_bytes: 241920
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  cout << n / 3 << endl;
}

Measured memory_bytes: 3608
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>

double x,y,a;
long n;
long save;
double min = 99999;

int main()
{
	scanf("%ld", &n);
	scanf("%lf %lf", &x, &y);
	for (long i = 1; i <= n; i++) {
		scanf("%lf", &a);
		a = x - a*0.006;
		a = fabs(y - a);
		if (a <= min) {
			min = a;
			save = i;
		}
	}
	printf("%ld", save);
}

Measured memory_bytes: 128
def gcd(a: int, b: int) -> int:
    """a, bの最大公約数(greatest common divisor: GCD)を求める
    計算量: O(log(min(a, b)))
    """
    if b == 0:
        return a
    return gcd(b, a%b)


def lcm(a: int, b: int) -> int:
    """a, bの最小公倍数(least common multiple: LCM)を求める
    計算量: O(log(min(a, b)))
    """
    return (a * b) // gcd(a, b)


def multi_gcd(array: list) -> int:
    """arrayのGCDを求める"""
    n = len(array)
    ans = array[0]
    for i in range(1, n):
        ans = gcd(ans, array[i])
    return ans



n, y = list(map(int, input().split()))
x = list(map(int, input().split()))

li = []
for i in range(n):
    li.append(abs(x[i] - y))
print(multi_gcd(li))

Measured memory_bytes: 63768
////////////////////////
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
namespace my {
char itoc(int i) { return i + '0'; }
int ctoi(char c) { return c - '0'; }
ll gcd(ll a, ll b) {
  a = abs(a);
  b = abs(b);
  if (a < b) swap(a, b);
  while (b != 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
ll lcm(ll a, ll b) { return a * b / my::gcd(a, b); }
vector<pair<ll, ll>> primeFac(ll n) {
  vector<pair<ll, ll>> ret;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i != 0) continue;
    ll exp = 0;
    while (n % i == 0) {
      n /= i;
      exp++;
    }
    ret.push_back(make_pair(i, exp));
  }
  if (n != 1) ret.push_back(make_pair(n, 1));
  return ret;
}
}  // namespace my
////////////////////////

int main() {
  int l, r, d;
  cin >> l >> r >> d;
  int ans = 0;
  for (int i = l; i <= r; i++) {
    if (i % d == 0) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
   
 #ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
 #endif

// -------------------------------------Code starts here---------------------------------------------------------------------     

   string s;
   cin>>s;
   int n=s.length();
   if(n%2)
      cout<<"No";
   else
   {
      for(int i=0;i<n;i++)
      {
         if(i%2==0)
         {
            if(s[i]!='h')
            {
               cout<<"No";
               return 0;
            }
         }
         else 
         {
            if(s[i]!='i')
            {
               cout<<"No";
               return 0;
            }
         }
      }
   cout<<"Yes";
   }
   

// -------------------------------------Code ends here------------------------------------------------------------------
     clock_t clk;
 	clk = clock();
 
    clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            long[] A = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            long[] B = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            long[] C = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            long result = 0;
            result += B.Sum();
            for(int p= 0; p < N; p++)
            {
                //1つ前に追加したのと比較したい→料理番号を保持してきたい
                if (p + 1 < N)
                {
                    if (A[p] + 1 == A[p + 1])
                    {
                        result += C[A[p] - 1];
                    }
                }
            }
            Console.WriteLine(result);
        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

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

int main() {
    string s; cin >> s;
    if (s[0] == s[1] && s[1] == s[2] || s[1] == s[2] &&  s[2] == s[3]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
#define ll long long int
#define pb push_back
int main(){
	ll x, k, d;
	cin>>x>>k>>d;
	ll i, j;
	if(x<0)
		x = -x;
	ll n = x/d;
	if( n >= k)
		cout<<x-k*d;
	else
	{
		k = k - n;
		ll curr = x - n*d;
		if(k%2)
			cout<<abs(curr-d);
		else
			cout<<abs(curr);
	}
}
  

Measured memory_bytes: 3632
#include <iostream>
#include <set>

using namespace std;

int main() {
	int s;
	cin >> s;
	
	set<int> set;
	int count = 0;
	while (1) {
		++count;

		if (set.find(s) != set.end())
			break;
		
		set.insert(s);
		
		if (s % 2 == 0)
			s /= 2;
		else
			s = s * 3 + 1;
	}
	
	cout << count << endl;
}

Measured memory_bytes: 384
import itertools

N = int(input())

def div(n):
    divs = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divs.append(i)
            if i != n // i:
                divs.append(n//i)
    return divs

def F(a, b):
  fi = max(len(str(a)), len(str(b)))
  return fi

D = div(N)
ans = len(str(N))
for i in D:
  a = i
  b = N//a
  #print(a, b)
  ans_i = F(a, b)
  if ans > ans_i:
    #print(a, b)
    ans = ans_i

print(ans)

Measured memory_bytes: 3064
//
//  main.cpp
//  at
//
//  Created by 黄道煜 on 2018/8/18.
//  Copyright © 2018年 黄道煜. All rights reserved.
//

#include <iostream>
#include <cstdio>
using namespace std;

long long k;
char s[10000];

int main()
{
    scanf("%s%lld", s, &k);
    for(int i=0; i<k; i++)
    {
        if(s[i]!='1') {printf("%c\n", s[i]); return 0;}
    }
    printf("1\n");
}


Measured memory_bytes: 256
// Copyright (C) 2017 __debug.

// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; version 3

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; If not, see <http://www.gnu.org/licenses/>.


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/priority_queue.hpp>

#define x first
#define y second
#define MP std::make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif

using std::pair;
using std::vector;
using std::string;

typedef long long LL;
typedef pair<int, int> Pii;

const int oo = 0x3f3f3f3f;

template<typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, true : false; }
template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, true : false; }
string procStatus()
{
    std::ifstream t("/proc/self/status");
    return string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
}
template<typename T> T read(T &x)
{
    int f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar())
        f = (ch == '-' ? -1 : 1);
    for (x = 0; isdigit(ch); ch = getchar())
        x = 10 * x + ch - '0';
    return x *= f;
}
template<typename T> void write(T x)
{
    if (x == 0) {
        putchar('0');
        return;
    }
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    static char s[20];
    int top = 0;
    for (; x; x /= 10)
        s[++top] = x % 10 + '0';
    while (top)
        putchar(s[top--]);
}
// EOT

const int MAXN = 3e3 + 5;

struct Edge {
    int v, next;
    Edge() { }
    Edge(int v_, int next_): v(v_), next(next_) { }
};

int N;
LL A[MAXN];
int tote, head[MAXN];
Edge edge[MAXN * 2 + 5];

inline void addEdge(int u, int v)
{
    edge[++tote] = Edge(v, head[u]);
    head[u] = tote;
}

void input()
{
    read(N);
    for (int i = 1; i <= N; ++i) {
        read(A[i]);
    }
    for (int i = 1; i < N; ++i) {
        int u, v;
        read(u); read(v);
        addEdge(u, v);
        addEdge(v, u);
    }
}

int dp[MAXN];

void calc(int u, int f)
{
    for (int i = head[u]; i; i = edge[i].next) {
        int v = edge[i].v;
        if (v == f)
            continue;
        calc(v, u);
        if (!dp[v] && A[v] < A[u])
            dp[u] = 1;
    }
}

void solve()
{
    for (int i = 1; i <= N; ++i) {
        memset(dp, 0, sizeof(dp));
        calc(i, 0);
        if (dp[i])
            printf("%d ", i);
    }
    puts("");
}

int main()
{
#ifdef __DEBUG
    freopen("F.in", "r", stdin);
    freopen("F.out", "w", stdout);
#endif

    input();
    solve();

    return 0;
}

// 群芳过后西湖好，狼籍残红。
//     -- 欧阳修《采桑子·群芳过后西湖好》


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORe(i, k, n) for(int i = (k); i <= (n); i++)
#define FORr(i, k, n) for(int i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(int i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

const int INF = 1001001001;

int main(void){
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  REP(i, n) cin >> v[i];
  int m = min(n, k);
  int ans = 0;
  FORe(l, 0, m){
    FORe(r, 0, m-l){
      int d = k-l-r;
      int now = 0;
      vector<int> s;
      REP(i, l){
        now += v[i];
        s.emplace_back(v[i]);
      }
      REP(i, r){
        now += v[n-1-i];
        s.emplace_back(v[n-1-i]);
      }
      sort(ALL(s));
      int ns = s.size();
      for(int i = 0; i < d && i < ns && s[i] < 0; i++){
        now -= s[i];
      }
      chmax(ans, now);
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a<=c && b>=c){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define F first
#define S second
#define ll long long
using namespace std;
string s;
ll dp[110][5][2],k;
int main(){
	ll i,j,l,p;
	cin>>s>>k;
	reverse(s.begin(),s.end());
	s='#'+s;
	memset(dp,0,sizeof(dp));
	for(i=0;i<s.size();i++)
	{
		dp[i][0][0]=1;
	}
	for(i=1;i<s.size();i++)
	{
		p=s[i]-'0';
		for(l=1;l<=k;l++)
		{
			if(p==0)
			{
				dp[i][l][0]=dp[i-1][l][0];
				dp[i][l][1]=9*(dp[i-1][l-1][0]+dp[i-1][l-1][1])+dp[i-1][l][1];
			}
			else
			{
				dp[i][l][0]=(p-1)*(dp[i-1][l-1][0]+dp[i-1][l-1][1])+dp[i-1][l-1][0]+dp[i-1][l][0]+dp[i-1][l][1];
				dp[i][l][1]=(9-p)*(dp[i-1][l-1][0]+dp[i-1][l-1][1])+dp[i-1][l-1][1];
			}
		}
	}
	cout<<dp[s.size()-1][k][0]<<endl;
	return 0;
}

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

using namespace std;
using pii = pair<int, int>;

const int NMAX = 1e3 + 11;
const int MOD  = 1e9 + 7;

int  h, w;
bool wall[NMAX][NMAX];
int  mem[NMAX][NMAX];

vector<pii> moves(int row, int col)
{
    vector<pii> ans;
    if (row < h)
        ans.push_back({1, 0});
    if (col < w)
        ans.push_back({0, 1});
    return ans;
}

// int paths(int row, int col)
// {
//     int &ans = mem[row][col];
//     if (wall[row][col])
//         return (ans = 0);
//     if (vis[row][col])
//         return ans;
//
//     vis[row][col] = true;
//     if (row == h - 1 and col == w - 1)
//         return (ans = 1);
//
//     for (auto drdc : moves(row, col))
//         ans = (ans + (paths(row + drdc.first, col + drdc.second) % MOD) %
//         MOD);
//
//     return ans;
// }

int paths(void)
{
    // mem[h][w] = 0;
    // for (int row = h - 1; row >= 0; --row)
    //     mem[row][w] = 0;
    // for (int col = w - 1; col >= 0; --col)
    //     mem[h][col] = 0;

    for (int row = h - 1; row >= 0; --row)
    {
        for (int col = w - 1; col >= 0; --col)
        {
            if (wall[row][col])
                continue;
            if (row == h - 1 and col == w - 1)
                mem[row][col] = 1;
            else
                mem[row][col] = (mem[row + 1][col] + mem[row][col + 1]) % MOD;
        }
    }

    return mem[0][0];
}

int main(void)
{
    char c;
    cin >> h >> w;

    for (int row = 0; row < h; ++row)
    {
        for (int col = 0; col < w; ++col)
        {
            cin >> c;
            wall[row][col] = (c == '#');
        }
    }

    cout << paths() << endl;

    return 0;
}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
 #define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  string S;
  cin>>S;
  if(S.at(2)==S.at(3)&&S.at(4)==S.at(5)){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  
}

Measured memory_bytes: 256
# import numpy as np
# import math
import sys
input = sys.stdin.readline

S = input()

M = len(S)
N = 2 ** (M-1)

res = 0

for i in range(N):
    T = S[:]
    for j in range(M-1,-1,-1):
        if ((i >> j) & 1):
            temp = T[j:]
            T = T[:j]
            # print(temp)
            if temp != '':
                res += int(temp)
    if T != '':
        # print(T)
        res += int(T)

print(res//2)

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    string S; cin >> S;
    int Q; cin >> Q;
    int reverseNum = 0;
    // Q = 10^5 なので、各クエリをO(1)で終える必要がある
    // 前後に付く文字を覚えておく
    string front, back;
    for (int i = 0; i < Q; ++i)
    {
        int Ti; cin >> Ti;
        if (Ti == 1)
        {
            ++reverseNum;
        }
        else
        {
            int Fi; char Ci; cin >> Fi >> Ci;
            if (reverseNum % 2 == 0)
            {
                // 反転していなければ問題文通りに処理
                if (Fi == 1) front += Ci;
                else back += Ci;
            }
            else
            {
                // 反転していれば逆に処理
                if (Fi == 1) back += Ci;
                else front += Ci;
            }
        }
    }
    reverse(front.begin(), front.end());
    S = front + S + back;
    if (reverseNum % 2 == 1)
    {
        reverse(S.begin(), S.end());
    }
    cout << S << endl;
}


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

#define int long long

//最初から一緒になってるのはダメ　だけど最初から奇数なのは大丈夫
main()
{
  int A, B, C;

  cin >> A >> B >> C;

  if(A & 1 || B & 1 || C & 1) cout << 0 << endl;
  else if(A == B && B == C && C == A) cout << -1 << endl;
  else {
    //シミュでも間に合うだろ(安直)

    int cnt = 0;
    while(!(A & 1) && !(B & 1) && !(C & 1)) {
      cnt++;
      int ta = A, tb = B, tc = C;
      A = (tb + tc) / 2, B = (tc + ta) / 2, C = (ta + tb) / 2;
    }

    cout << cnt << endl;
  }

  return 0;
}


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

int main() {
    int x;  cin >> x;
    if (x == 3 || x == 5 || x == 7)  cout << "YES" << endl;
    else  cout << "NO" << endl;
}

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

int main() {
  int A, B, K;
  
  cin >> A >> B >> K;
  
  vector<int> divisors;
  for (int n = 1; n <= max(A, B); n++) {
    if (A % n == 0 && B % n == 0) {
      divisors.push_back(n);
    }
  }
  cout << divisors[divisors.size() - K] << endl;
  
  return 0;
}

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

using namespace std;
int main(){
  int x;
  cin>>x;

  cout<<x+x*x+x*x*x;


  return 0;
}

/*---------
 double n,m,a;
    cin>>n>>m>>a;
    cout<<(ceil(n/a)*ceil(m/a));

*/




/* int n;
  cin >> n;_.-
  for (int y=0; y<2*n+1; y++) {
    int c = 0;
    for (int x=0; x<2*n+1; x++) {
      int nx = x;
      int ny = y;
      if (nx>n) {
        nx -= (nx-n)*2;
      }
      if (ny>n) {
        ny -= (ny-n)*2;
      }
      int p = nx+ny-n;
      if (p>=0) {
        cout << p;
        c++;
        if (c >= 2*ny+1) {
          break;
        } else {
          cout << " ";
        }
      } else {
        cout << "  ";
      }
    }
    cout << endl;
  }
  return 0;
}*/
 /*----------my code--------------
  int n,a,b,c,d,space,i,j,apply;
    cin>>n;
    b=2*n+1;
    for(i=0;i<b;i++){
        space=2(n-1);
        for(j=0;j<b;j++){
            if(space>0){
                apply=space/2;
                for()
            }
        }

        int n,a,b,c,d,space,i,j,k,apply,index;
    cin>>n;
    b=2*n+1;
    for(i=0;i<b;i++){
        space=2(n-i);
        apply=space/2;
        for(j=0,k=0;j<b;j++,k++){
            if(space>1){
                    if(k<i){
                            index=apply+1;
                a[index]=k;
            index++;
            }
            if(k>=i){
                a[]
            }
            }
            }
        }
    }

   for
    }*/
    /*--------------------

    int main() {
	int n;
	cin>>n;
	int x[n],y[n];
	for(int i=0;i<n;i++)
	{
		cin>>x[i]>>y[i];
	}
	int u=0,d=0,l=0,r=0,ans=0;
	for(int i=0;i<n;i++)
	{
		u=0;d=0;l=0;r=0;
		for(int j=0;j<n;j++)
		{
			if(x[i]==x[j]&&y[i]>y[j])d=1;
			if(x[i]==x[j]&&y[i]<y[j])u=1;
			if(y[i]==y[j]&&x[i]>x[j])l=1;
			if(y[i]==y[j]&&x[i]<x[j])r=1;
		}
		if(d&&u&&l&&r)ans++;
	}
	cout<<ans<<endl;
}-----------*/


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

// n円引き出すには何回操作が必要か
int solve(int n, vector<int> &memo) {
  if (memo[n] != -1) {
    return memo[n];
  }

  if (n == 0) {
    return 0;
  }

  vector<int> bases{6, 9};
  int min_op = n + 1;
  for (auto base : bases) {
    int exp = 1;
    while(n >= exp) {
      min_op = min(solve(n - exp, memo) + 1, min_op);
      exp *= base;
    }
  }

  return memo[n] = min_op;
}

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

  vector<int> memo(n + 1, -1);
  cout << solve(n, memo) << "\n";
  return 0;
}

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

const int maxn = 1e5 + 10;
int n, m, deg[maxn];

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

	int a, b;
	for(int i = 0; i < m; i++){
		cin >> a >> b;
		deg[a]++;
		deg[b]++;
	}

	for(int i = 1; i <= n; i++){
		if(deg[i] & 1){
			cout << "NO" << endl;
			return 0;
		}
	}

	cout << "YES" << endl;

	return 0;
}


Measured memory_bytes: 640
//Author rahuliitkgp

/*A thing of beauty is a joy forever,
Its loveliness increases,
it will never pass into nothingness.*/
//Men at Work :)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;

#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void cpp() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int main(){
    cpp();
    ll n;
    cin>>n;
    vector<ll> v(n);
    for(auto& ele: v) cin>>ele;
    vector<ll> dp(n);
    dp[0] = 0;
    dp[1] = llabs(v[1]-v[0]);
    for(ll i=2; i<n; i++){
        dp[i] = min(dp[i-1]+llabs(v[i]-v[i-1]), dp[i-2]+llabs(v[i]-v[i-2]));
    }
    cout<<dp[n-1]<<endl;
    return 0;
}






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

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

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

int main() {
    char x, y;
    cin >> x >> y;
    if (x < y) cout << "<" << endl;
    else if (x > y) cout << ">" << endl;
    else cout << "=" << endl;

    return 0;
}


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

#define int long long int
const int N=1e5;
int A[3][N],B[3][N];

int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
  
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>A[0][i]>>A[1][i]>>A[2][i];
	B[0][0] = A[0][0];
	B[1][0] = A[1][0];
	B[2][0] = A[2][0];
	for(int i=1;i<n;i++){
		B[0][i] = max(B[1][i-1],B[2][i-1])+A[0][i];
		B[1][i] = max(B[0][i-1],B[2][i-1])+A[1][i];
		B[2][i] = max(B[0][i-1],B[1][i-1])+A[2][i];
	}
	cout<<max(max(B[0][n-1],B[1][n-1]),B[2][n-1]);

	return 0;
}

Measured memory_bytes: 4992
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<sstream>
#include<iomanip>

using namespace std;
int _;


struct city {
	int year;
	int index;

	bool operator<(const city& right) const {
		return year < right.year;
	}
};

int main() {
	int n,m;
	_ = scanf("%d%d", &n, &m);

	vector<vector<city>> pref_having_cities(n);

	for (int i = 0; i < m; i++) {
		int p, y;
		_ = scanf("%d%d", &p, &y);
		city tmp_city = { y, i };

		pref_having_cities[p-1].push_back(tmp_city);
	}

	vector<string> answer(m);
	
	for (int i = 0; i < n; i++) {
		auto pref = pref_having_cities[i];
		sort(pref.begin(), pref.end());
		int pref_index = 1;
		for (auto it = pref.begin(); it != pref.end(); ++it) {
			ostringstream sout;
			sout << setw(6) << setfill('0') << i+1 << setw(6) << setfill('0') << pref_index;
			string out = sout.str();			
			answer[it->index] = out;
			pref_index++;
		}
	}

	for (auto it = answer.begin(); it != answer.end(); ++it) {
		cout << *it << endl;
	}

	return 0;
}

Measured memory_bytes: 12416
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep_1(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define rep_2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
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; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

vector<ll> h,dp;

ll rec(int i){
    // DPの値が更新されていたらそのままリターン
    if(dp[i] < LINF) return dp[i];
    // 足場0のコストは0
    if( i == 0 ) return 0;
    
    //i-1,i-2　それぞれ試す
    ll res = LINF;

    chmin(res,rec(i-1) + abs( h[i] - h[i-1] ));//足場i-1からきた場合
    if(i > 1) chmin(res, rec(i-2) + abs( h[i] - h[i-2] ));//足場i-2からきた場合

    //結果をメモしながら、返す
    return dp[i] = res;
}

int main(){
    int n;cin >>n;
    h.resize(n);
    dp.resize(n+1,LINF);
    rep(i,n)cin>>h[i];

    cout<<rec(n-1)<<endl;
}



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

const int N = 2e6 + 10, mod = 1e9 + 7;
typedef long long ll;
ll r1, c1, r2, c2, n;
ll a1, a2, a3, a4;
ll fac[N], inv[N];

ll quick_pow(ll a, ll b) {
    ll ret = 1;
    for (; b; b >>= 1) {
        if (b & 1) ret = ret * a % mod;
        a = a * a % mod;
    } return ret;
}

ll C(ll n, ll m) {
    return fac[n] * inv[m] % mod * inv[n - m] % mod;
}

ll calc(ll r, ll c) {
    ll ret = 0;
    rep(i, 0, r) ret = (ret + C(i + c + 1, c)) % mod;
    return ret;
}

int main() {
    cin >> r1 >> c1 >> r2 >> c2;

    n = r2 + c2 + 2;
    fac[0] = inv[0] = 1;
    rep(i, 1, n) fac[i] = (fac[i - 1] * i) % mod;
    inv[n] = quick_pow(fac[n], mod - 2);
    for (int i = n; i >= 1; i--) inv[i - 1] = inv[i] * i % mod;

    a1 = calc(r2, c2);
    a2 = calc(r1 - 1, c2);
    a3 = calc(r2, c1 - 1);
    a4 = calc(r1 - 1, c1 - 1);
    printf("%lld\n", (a1 - a2 - a3 + a4 + mod) % mod);
    return 0;
}


Measured memory_bytes: 31488
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <cassert>
 
#pragma comment(linker, "/STACK:336777216")  
 
using namespace std;

const int MAXN = 200000 + 10;
const int Z = 26;

int N;
int Cnt[Z];
char S[MAXN];
vector <int> Pos[Z];
int Tree[MAXN * 2];

int GetSum(int i)
{
	i ++;
	int Ret = 0;
	for (; i; i -= (i & (-i)))
		Ret += Tree[i];
	return Ret;
}

void Add(int i, int x)
{
	i ++;
	for (; i <= N; i += i & (-i))
		Tree[i] += x;
}

int Used[MAXN];

void Work()
{
	scanf("%s", S);
	N = strlen(S);
	for (int i = 0; i < N; i ++)
	{
		S[i] -= 'a';
		Cnt[S[i]] ++;
		Pos[S[i]].push_back(i);
	}
	
	int nOdd = 0, whoodd = -1;
	for (int i = 0; i < Z; i ++)
		if (Cnt[i] % 2 == 1)
		{
			nOdd ++;
			whoodd = i;
		}

	if (nOdd > 1)
	{
		printf("-1\n");
		return;
	}

	long long Ans = 0;
	for (int i = 0; i < N; i ++)
		Add(i, 1);
	
	int Remain = N;
	for (int i = 0; i < N; i ++)
	{
		if (Used[i]) continue; // processed

		int j = Pos[S[i]][Cnt[S[i]] - 1];
		if (i == j)
			Ans += (Remain - GetSum(j)) / 2;
		else
			Ans += Remain - GetSum(j);

		Remain --;
		Add(i, -1);

		if (i != j)
		{
			Remain --;
			Add(j, -1);
		}

		Used[i] = Used[j] = 1;
		Cnt[S[i]] --;
	}
	printf("%lld\n", Ans);
}

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

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;

void print_ans(bool flag, string y, string n){
    if(flag){
        cout << y << endl;
    } else {
        cout << n << endl;
    }   
}

int main(){
    string s, t;
    cin >> s >> t;
    bool ans = (s[0] == t[2]) && (s[1] == t[1]) && (s[2] == t[0]);
    print_ans(ans, "YES", "NO");  
    return 0;
}


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

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

int main(){

	int n;
	cin>>n;
	int k=n%10;
	if(k==3)cout<<"bon";
	else if(k==0||k==1||k==6||k==8)cout<<"pon";
	else cout<<"hon";
	cout<<endl;
	
	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <utility>
#include <unordered_map>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    unordered_map <int, int> odd;
    unordered_map <int, int> even;
    int max_odd = 0, max_even = 0, sec_odd = 0, sec_even = 0;
    int odd_num, even_num;
    for (int i;i<n;i++){
        cin >> v[i];
        if (i % 2){
            if (odd.find(v[i]) == odd.end()){
                odd.insert(make_pair(v[i], 1));
            }

            else{
                odd[v[i]]++;
            }

        }
        else{
            if (even.find(v[i]) == even.end()){
                even.insert(make_pair(v[i], 1));
            }

            else{
                even[v[i]]++;
            }
        }
    }
    
    for (auto it=odd.begin();it!=odd.end();it++){
        if (it->second > max_odd){
            sec_odd = max_odd;
            max_odd = it->second;
            odd_num = it->first;
        }
        else if (it->second > sec_odd)
            sec_odd = it->second;
    }
    for (auto it=even.begin();it!=even.end();it++){
        if (it->second > max_even){
            sec_even = max_even;
            max_even = it->second;
            even_num = it->first;
        }
        else if (it->second > sec_even)
            sec_even = it->second;
    }
    
    int ret = n - max_odd - max_even;
    if (odd_num == even_num){
        if ((max_even + sec_odd) > (max_odd + sec_even))
            ret = n - max_even - sec_odd;
        else
            ret = n - max_odd - sec_even;
    }

    cout << ret;
    return 0;

}


Measured memory_bytes: 4760
n, _ = map(int, input().split(' '))
no_likes = list(map(int, input().split(' ')))

numbers = sorted([i for i in range(10) if i not in no_likes])

for i in range(n, 100000):
    for b in str(i):
        if int(b) not in numbers:
            break
    else:
        print(i)
        break


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int N, C;
int d[505][505], c[505][505];
int cnt[5], num[5][505], change[5][505];
int main(){
    scanf("%d%d", &N, &C);
    for(int i = 1; i <= C; ++i){
        for(int j = 1; j <= C; ++j){
            scanf("%d", &d[i][j]);
        }
    }
    for(int i = 1; i <= N; ++i){
        for(int j = 1; j <= N; ++j){
            scanf("%d", &c[i][j]);
            cnt[(i+j)%3]++;
            num[(i+j)%3][c[i][j]]++;
        }
    }
    for(int t = 0; t <= 2; ++t){
        for(int k = 1; k <= C; ++k){
            int res = 0;
            for(int i = 1; i <= N; ++i){
                for(int j = 1; j <= N; ++j){
                    if((i+j)%3 == t){
                        if(c[i][j] != k) res += d[c[i][j]][k];
                    }
                }
            }
            change[t][k] = res;
        }
    }
    int ans = 0x3f3f3f3f;
    for(int i = 1; i <= C; ++i){
        for(int j = 1; j <= C; ++j){
            for(int k = 1; k <= C; ++k){
                if((i==j) || (j==k) || (i==k)) continue;
                int res = 0;
                res += change[0][i] + change[1][j] + change[2][k];
    /*
                for(int l = 1; l <= N; ++l){
                    if(res >= ans) break;
                    for(int x = 1; x <= N; ++x){
                        if((l+x) % 3 == 0){
                            if(c[l][x] != i){
                                res += d[c[l][x]][i];
                            }
                        }else if((l+x) % 3 == 1){
                            if(c[l][x] != j){
                                res += d[c[l][x]][j];
                            }
                        }else{
                            if(c[l][x] != k){
                                res += d[c[l][x]][k];
                            }
                        }
                        if(res >= ans) break;
                    }j
                }
            */
                ans = min(ans, res);
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 1280
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<class T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<class T,class Size=typename vector<T>::size_type>inline auto vector_2d(Size h,Size w,T v){return vector<vector<T>>(h,vector<T>(w,v));}
template<class RandomAccessIterator,class Pair=typename iterator_traits<RandomAccessIterator>::value_type>inline void sort_pairs_by_second(RandomAccessIterator first,RandomAccessIterator last){sort(first,last,[](const Pair&p1,const Pair&p2){return p1.second<p2.second||(p1.second==p2.second&&p1.first<p2.first);});}

int main()
{
    ll n=in();
    vector<ll>l(n);for(ll i=0;i<n;++i)l[i]=in();
    ll ans=0;
    for(ll i=0;i<n;++i){
        for(ll j=i+1;j<n;++j){
            for(ll k=j+1;k<n;++k){
                if(l[i]!=l[j]&&l[j]!=l[k]&&l[k]!=l[i]&&l[i]+l[j]>l[k]&&l[j]+l[k]>l[i]&&l[k]+l[i]>l[j]){
                    ++ans;
                }
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#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)
template<typename T> istream& operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream& operator<<(ostream &os, vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream& operator<<(ostream &os, set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream& operator<<(ostream &os, pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream& operator<<(ostream &os, map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

int N;
vector<int> A, B, C;

// 1-indexed BIT (i : [1, len])
template<typename T, int len>
struct BIT
{
    array<T, len + 1> val;
    BIT() { val.fill(0); }
    void add(int pos, T v)
    {
        while (pos > 0 && pos <= len)
        {
            val[pos] += v;
            pos += pos & -pos;
        }
    }
    T sum(int pos)
    {
        T res = 0;
        while (pos > 0)
        {
            res += val[pos];
            pos -= pos & -pos;
        }
        return res;
    }
};


int cnt(const vector<double> &vec)
{
    vector<double> vec_sorted = vec;
    sort(vec_sorted.begin(), vec_sorted.end());
    
    map<double, int> ma;
    REP(i, vec_sorted.size()) ma[vec_sorted[i]] = i + 1;
    
    BIT<int, 40001> bit;
    int ans = 0;
    for (auto v : vec)
    {
        ans += bit.sum(ma[v]);
        bit.add(ma[v], 1);
    }
    return ans;
}

double solve(const vector<int> &A, const vector<int> &B, const vector<int> &C)
{
    using p = pair<double, double>;
    vector<p> info(N);
    REP(i, N) info[i] = p((double)A[i] / B[i], (double)C[i] / B[i]);
    sort(info.begin(), info.end());

    double l = -2E8, r = 2E8;
    while (r - l > 1E-10 and (r - l) > (abs(l) + abs(r)) * 1E-10)
    {
        double c = (l + r) / 2;
        vector<double> vec(N);
        REP(i, N) vec[i] = info[i].second - info[i].first * c;
        if (cnt(vec) > N * (N - 1) / 2 / 2) l = c;
        else r = c;
    }
    return l;
}

int main()
{
    cin >> N;
    A.resize(N);
    B.resize(N);
    C.resize(N);
    REP(i, N) cin >> A[i] >> B[i] >> C[i];

    cout << solve(A, B, C) << " " << solve(B, A, C) << endl;
}


Measured memory_bytes: 6740