akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;

public class Main {
    static long [] basis; static int sz; static boolean ok;
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
        int t = sc.nextInt();
        for (int tt = 0; tt < t; tt++) {
            int n = sc.nextInt();
            long [] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = sc.nextLong();
            }
            String s = sc.next();
            basis = new long[62]; sz = 0;
            ok = true;
            for (int i = n - 1; i >= 0; i--) {
                if (s.charAt(i) == '0') {
                    insertVector(a[i], false);
                } else {
                    insertVector(a[i], true);
                }
            }
            out.println(ok ? 0 : 1);
        }
        out.close();
    }

    static void insertVector(long x, boolean represent) {
        for (int bit = 0; bit < 62; bit++) {
            if (((x >> bit) & 1) == 0) continue;
            if (basis[bit] == 0) {
                if (represent) {
                    ok = false;
                    return;
                }
                basis[bit] = x;
                ++sz;
                return;
            }
            x ^= basis[bit];
        }
    }



    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

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

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

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

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

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

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


    }

}

Measured memory_bytes: 38840
#include <bits/stdc++.h>
using namespace std;
#define MOD_NUMBER 1000000007
template <class T> void vector_print(vector<T> vec) {
  for (unsigned int i = 0; i < vec.size(); i++) {
    cout << vec.at(i);
    if (i < vec.size()-1) {
      cout << " ";
    } else if (i == vec.size()-1) {
      cout << endl;
    }
  }
}
// 226732710
int main() {
  long long n, k, sum = 0;
  cin >> n >> k;
  for (long long i = k; i < n+2; i++) {
    sum += (n+1-i)*i+1;
    sum %= MOD_NUMBER;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int n,m,mod=1e9+7;
vector <string> grid;
int dp[1005][1005];
int rec(int x,int y){
	if(dp[x][y]==-1){
		if(x>=n || y>=m || grid[x][y]=='#'){
			dp[x][y]=0;
		}
		else if(x==n-1 && y==m-1){
			dp[x][y]=1;
		}
		else dp[x][y]=(rec(x+1,y)+rec(x,y+1))%mod;
	}
	return dp[x][y];
}
int main(){
	string s;
	cin>>n>>m;
	memset(dp,-1,sizeof(dp));
	for(int i=0;i<n;i++){
		cin>>s;
		grid.push_back(s);
	}
	cout<<rec(0,0)<<endl;
	return 0;
}

Measured memory_bytes: 5376
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;


int main() {
  ll n, a, b;
  cin >> n >> a >> b;

  ll ans = a * (n / (a+b));
  ans += min(n % (a+b), a);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import itertools
N = int(input())
dic = {}
cnt = 0
ok = []
for i in range(N):
  A = int(input())
  for j in range(A):
    x,y = (int(t) for t in input().split())
    dic[(i,x)] = y
for i in itertools.product([0,1],repeat=N):
  for k in dic.keys():
    if i[k[0]] == 0:
      continue
    if dic[k] != i[k[1]-1]:
      break
  else:
    ok += [i]
mm = 0
for i in ok:
  mm = max(mm,sum(i))
print(mm)

Measured memory_bytes: 8820
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

int change(int x, int y) {
    if(x > y) {
        return x-1;
    }
    return x;
}

int max(int a, int b) {
    if(a > b) return a;
    return b;
}

int min(int a, int b) {
    return -max(-a, -b);
}

int main() {
    char C;
    scanf("%c", &C);
    printf("%c\n", C+1);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#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>;
 
// mt19937 gen_rand_int(chrono::steady_clock::now().time_since_epoch().count());
// mt19937_64 gen_rand_ll(chrono::steady_clock::now().time_since_epoch().count());
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
long long power(long long a, long long b,long long m) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a %m;
        a = a * a %m;
        b >>= 1;
    }
    return res;
}


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

    int mm[2005];
    int cnt=0;
    for(int i=1800;i>=400;i-=200)
    {
        mm[i]=++cnt;
        for(int j=i;j<=i+199;j++)
            mm[j]=cnt;
    }
    int n;
    cin>>n;
    cout<<mm[n];

}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <string>
#include <cmath>

using namespace std;

int main(){

	int cnt=0, sz;
	string s;

	cin>> s;

	sz=s.size();

	for(int i=0;i<sz;i++){
		if(i%2==0){
			if(s.substr(i, 1)=="0") cnt++;
		}else{
			if(s.substr(i, 1)=="1") cnt++;
		}
	//cout<< s.substr(i, 1) <<endl;
	}

	//cout<< cnt << " " << sz << " " << sz-cnt << endl;

	cnt=min(sz-cnt, cnt);

	cout<< cnt << endl;


}

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int n;
int a[200010];
deque<int> b;

int main(){
	scanf("%d" , &n);
	repp(i,0,n){
		scanf("%d" , a+i);
	}
	b.push_back(a[0]);
	repp(i,1,n){
		if(i%2==1){
			b.push_back(a[i]);
		} else {
			b.push_front(a[i]);
		}
	}
	while(!b.empty()){
		if(n%2==0){
			printf("%d" , b.back());
			b.pop_back();
		} else {
			printf("%d" , b.front());
			b.pop_front();
		}
		if(!b.empty()){
			printf(" ");
		}
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(t) (t).begin(),(t).end()
typedef long long ll;

int main() {
	int Ans=0;
	int N; cin >> N;
	vector<int> L(N); REP(i,N) cin >> L.at(i);
	sort(ALL(L));
	REP(i,N){
		for(int j=0;L.at(j)<L.at(i);j++){
			for(int k=0;L.at(k)<L.at(j);k++){
				if (L.at(k)+L.at(j)>L.at(i)) Ans++;
			}
		}
	}
	cout << Ans << '\n';
	return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e6;
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);

  int n;cin>>n;multiset<int>st;
  for(int i=1;i<=n;i++)
  {
    int x;cin>>x;st.insert(x);
  }
  int ans=0;
  while(st.size())
  {
    int x=*st.rbegin();
    st.erase(st.find(x));

    for(int i=30;i>=0;i--)
    {
      int z=(1<<i)-x;
      if(z<0)break;
      if(st.find(z)!=st.end())
      {
        ans++;st.erase(st.find(z));
        break;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 13012
#include <stdio.h>

int main(void){
	int input1[9],i,j,N;
	for(i = 0; i < 9; i++){
		scanf("%d",&input1[i]);
	}
	scanf("%d",&N);
	int input2;
	for(i = 0; i < N; i++){
		scanf("%d",&input2);
		for(j = 0;j < 9;j++){
			if(input2 == input1[j]){
				input1[j] = 1;
			}
		}
	} 
	
	if( (input1[0] == input1[1] && input1[0] == input1[2]) || (input1[0] == input1[4] && input1[0] == input1[8]  ) || (input1[0] == input1[3] && input1[0] == input1[6] ) || (input1[1] == input1[4] && input1[1] == input1[7] ) || (input1[2] == input1[5] && input1[2] == input1[8]) || (input1[3] == input1[4] && input1[3] == input1[5] ) || (input1[6] == input1[7] && input1[6] == input1[8]) || (input1[2] == input1[4] && input1[2] == input1[6]) ){
		puts("Yes");
	}else{
		puts("No");
	}
	
	
	return 0;
}

Measured memory_bytes: 128
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import itertools

N = int(readline())
S = [x - ord('0') for x in read().rstrip()]

left_index = [[-1] * (N+1) for _ in range(10)]

for i,x in enumerate(S,1):
    for j in range(10):
        left_index[j][i] = left_index[j][i-1]
    left_index[x][i] = i

answer = 0
for a,b,c in itertools.product(range(10),repeat=3):
    i = N
    bl = True
    for x in [a,b,c]:
        i = left_index[x][i] - 1
        if i < -1:
            bl = False
            break
    if bl:
        answer += 1

print(answer)

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

int main(){
    ll n, t;
    cin >> n >> t;
    vector<ll> a(n);
    rep(i, 0, n) cin >> a[i];
    ll ans = 0, mx = 0;
    set<ll> st;
    st.insert(a[0]);
    rep(i, 1, n){
        if(mx == a[i] - *st.begin()){
            ans++;
        }else if(mx < a[i] - *st.begin()){
            ans = 1;
            mx = a[i] - *st.begin();
        }
        st.insert(a[i]);
    }
    cout << ans << endl;
    return 0;
}

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

bool checkPrime(int a) {
	if (a <= 1) return 0;
	if (a == 2) return 1;
	if (a % 2 == 0) return 0;
	for (int i = 2;i*i <= a;i++) {
		if (a%i == 0) {
			return 0;
		}
	}
	return 1;
}

int main(void) {
	int x, counter = 0;

	while (cin >> x) {
		if (checkPrime(x)) counter++;
	}

	cout << counter << endl;

	return 0;
}

Measured memory_bytes: 3056
import itertools

n, m, k = map(int, input().split())
A = [0] + list(map(int, input().split()))
B = [0] + list(map(int, input().split()))

A = list(itertools.accumulate(A))
B = list(itertools.accumulate(B))

count = 0
j = m
for i in range(n+1):
    if A[i] > k:
        break
    
    while A[i]+B[j] > k:
        j -= 1
        
    count = max(count, i+j)
    
print(count)


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

public static partial class Program
{
    public static void Main()
    {
        var n = CRL().ToInt();
        var s = CRL();

        var x = 0;
        var max = 0;
        for (int i = 0; i < n; i++)
        {
            if (s[i] == 'I')
            {
                x++;
            }
            else
            {
                x--;
            }

            max = Math.Max(max, x);
        }

        CWL(max);
    }
}

public static partial class Program
{
    //テンプレここから
    public static int ToInt(this double d) => (int) d;
    public static long ToLong(this double d) => (long) d;
    public static int ToInt(this string str) => int.Parse(str);
    public static long ToLong(this string str) => long.Parse(str);
    public static long[] ToLong(this IEnumerable<string> strs) => strs.Select(x => x.ToLong()).ToArray();
    public static int[] ToInt(this IEnumerable<string> strs) => strs.Select(x => x.ToInt()).ToArray();
    public static long[] ArrayLongs(this string str, char opr = ' ') => str.Split(opr).ToLong();
    public static int[] ArrayInts(this string str, char opr = ' ') => str.Split(opr).ToInt();
    public static string CRL() => Console.ReadLine();
    public static void CWL(object obj) => Console.WriteLine(obj);
    public static long Diff(long a, long b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static int Diff(int a, int b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static long Sign(this long i) => Math.Sign(i);
    public static bool IsEven(this long i) => i % 2 == 0;
    public static bool IsEven(this int i) => i % 2 == 0;
    public static long[] dx = new long[] {0, -1, 0, 1};
    public static long[] dy = new long[] {-1, 0, 1, 0};
    public static long mod = 1000000007;
    public static string alphabet = "abcdefghijklmnopqrstuvwxyz";
    public static long ToLong(this char c) => c.ToString().ToInt();
    public static long[] Sort(this long[] array) => array.OrderBy(x => x).ToArray();
    public static int[] Sort(this int[] array) => array.OrderBy(x => x).ToArray();
    public static long[] DSort(this long[] array) => array.OrderByDescending(x => x).ToArray();
    public static int[] DSort(this int[] array) => array.OrderByDescending(x => x).ToArray();
    public static string Join(this IEnumerable<string> array, string sep = "") => string.Join(sep, array);
    public static string Join(this IEnumerable<char> array, string sep = "") => string.Join(sep, array);
    public static long GCD(long a, long b) => b == 0 ? a : GCD(b, a % b);

    public static long LCM(long a, long b) => a * b / GCD(a, b);

    //テンプレここまで
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
 
signed main(){
 
    int N;
    cin >> N;
    vector<int> t(N), v(N);
    readv(t);
    readv(v);

    vec T(N + 1, 0);
    REP(i, N) T[i + 1] = T[i] + t[i];
    
    vec maxv(2 * T[N] + 1, INF);
    REP(i, N){
        FOR(j, 0, 2 * T[i]) maxv[j] = min(maxv[j], 2 * v[i] + llabs(2 * T[i] - j));
        FOR(j, 2 * T[i], 2 * T[i + 1] + 1) maxv[j] = min(maxv[j], 2 * v[i]);
        FOR(j, 2 * T[i + 1] + 1, 2 * T[N] + 1) maxv[j] = min(maxv[j], 2 * v[i] + llabs(2 * T[i + 1] - j));
    }
    FOR(j, 0, 2 * T[N] + 1) maxv[j] = min(maxv[j], min(j, 2 * T[N] - j));

    double ans = 0;
    REP(i, 2 * T[N]) ans += (maxv[i] + maxv[i + 1]) * 0.125;
 
    cout << setprecision(10) << ans;
    
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define fo(i,a,b) for(int i=a;i<=b;++i)
#define fod(i,a,b) for(int i=a;i>=b;--i)
#define efo(i,q) for(int i=A[q];i;i=B[i][0])
#define min(q,w) ((q)>(w)?(w):(q))
#define max(q,w) ((q)<(w)?(w):(q))
#define PR(...) printf(__VA_ARGS__)
#define EPR(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef long long LL;
const int N=100500;
int read(int &n)
{
	char ch=' ';int q=0,w=1;
	for(;(ch!='-')&&((ch<'0')||(ch>'9'));ch=getchar());
	if(ch=='-')w=-1,ch=getchar();
	for(;ch>='0' && ch<='9';ch=getchar())q=q*10+ch-48;n=q*w;return n;
}
int m,n,ans;
int c1,c2,c0;
int main()
{
	int q,w;
	read(n);
	fo(i,1,n)
	{
		char ch=' ';
		for(;ch<'A'||ch>'Z';ch=getchar());
		int la=ch,fr=la;ch=getchar();
		for(;ch<='Z'&&ch>='A';la=ch,ch=getchar())
		{
			if(la=='A'&&ch=='B')++ans;
		}
		if(fr=='B'&&la=='A')++c0;
		else if(fr=='B')++c2;
		else if(la=='A')++c1;
	}
	ans+=max(0,c0-1);
	q=min(c1,c2);
	ans+=q;
	w=max(c1,c2)-q;
	if((w||q)&&c0)++ans;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    map<string,ll> mp;
    int n;
    cin>>n;
    ll ans = 0;
    rep(i,n){
        string s;
        cin>>s;
        sort(s.begin(),s.end());
        ans += mp[s];
        mp[s]++;
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
  int n,r;
  cin >> n >> r;
  if(n>=10){
    cout << r << endl;
    return 0;
  }
  else{
    cout << r + 100*(10-n) << endl;
    return 0;
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

using namespace std;
typedef vector<int> veci;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define foreach(i, n) for (typeof(n) i = 0; i < (n); ++i)
#define foreach_eq(i, n) for (typeof(n) i = 0; i <= (n); ++i)
#define foreach_from(i, m, n) for (typeof(n) i = m; i < (n); ++i)
#define foreach_eq_from(i, m, n) for (typeof(n) i = m; i <= (n); ++i)

inline bool between(int lower, int upper, int x) { return lower <= x && x < upper; }
inline bool between(pii lower, pii upper, pii x) {
    return between(lower.first, upper.first, x.first)
        && between(lower.second, upper.second, x.second);
}
pii dirctions[4] = { pii(0,-1), pii(0,1), pii(-1,0), pii(1,0) };
template <typename S, typename T> inline
pair<S,T> pair_plus(const pair<S,T> & p, const pair<S,T> & q) {
    return pair<S,T>(p.first + q.first, p.second + q.second);
}

#define MAX_H 1000
#define MAX_W 1000
#define MAX_N 9

int H, W, N;
bool orig_map[MAX_H][MAX_W];
pii factories[MAX_N + 1];
queue<pair<pii, int> > que;

int main() {
    cin >> H >> W >> N;
    foreach (i, H) foreach (j, W) {
        char c;
        cin >> c;
        orig_map[i][j] = true;
        if (c == '.') {
        } else if ('0' <= c && c <= '9') {
            factories[(int)c - (int)'0'] = pii(i,j);
        } else if (c == 'S') {
            factories[0] = pii(i,j);
        } else {
            assert(c == 'X');
            orig_map[i][j] = false;
        }
    }

    int result = 0;
    foreach (n, N) {
        bool data[MAX_H][MAX_W];
        foreach (i, MAX_H) foreach (j, MAX_W) data[i][j] = orig_map[i][j];
        data[factories[n].first][factories[n].second] = false;
        que.push(pair<pii,int>(factories[n], 0));
        int found = 0;
        while (not found) {
            pii pos = que.front().first;
            int cnt = que.front().second;
            que.pop();
            foreach (d, 4) {
                pii nxt = pair_plus(pos, dirctions[d]);
                if (not between(pii(0,0), pii(H,W), nxt)) continue;
                if (nxt == factories[n+1]) {
                    found = cnt + 1;
                } else if (data[nxt.first][nxt.second]) {
                    data[nxt.first][nxt.second] = false;
                    que.push(pair<pii,int>(nxt, cnt + 1));
                }
            }
        }
        result += found;
        que = queue<pair<pii,int> >();
    }

    cout << result << endl;
}

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

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

  bool a = false;
  bool b = false;
  bool c = false;

  for (int i = 0; i < S.size(); i++){
    if (S.at(i) == 'a') a = true;
    if (S.at(i) == 'b') b = true;
    if (S.at(i) == 'c') c = true;
  }

  if (a && b && c){
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 3632
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll a, b, c;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> a >> b >> c;
    if(a%2||b%2||c%2)return cout<<0<<"\n",0;
    if(a==b&&b==c)return cout<<-1<<"\n",0;
    int i=0;
    while(true){
        i++;
        int an=(b+c)/2;
        int bn=(a+c)/2;
        int cn=(a+b)/2;
        if(an%2||bn%2||cn%2)return cout<<i<<"\n",0;
        a=an;
        b=bn;
        c=cn;
    }
}


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

namespace ConsoleApp18
{
    class Program
    {
        static void Main(string[] args)
        {
            string a = Console.ReadLine();
            if(a[2]==a[3]&&a[4]==a[5])
            {
                Console.Write("Yes");
            }
            else
            {
                Console.Write("No");
            }
            Console.Read();
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
//#include <assert.h>
#include <vector>
#include <map>
//#include <algorithm>
//#include <functional>
#include <cmath>
#include <iomanip>

using cities_type = std::vector<std::pair<int32_t, int32_t>>;

int main(){
    int32_t N;
    std::cin >> N;
    cities_type cities(N);
    for(int32_t i = 0; i < N; i++){
        std::cin >> cities[i].first >> cities[i].second;
    }

    //int64_t num_route = 1;
    //for(int32_t i = 1; i <= N; i++){
    //    num_route *= i;
    //}
    double res = 0;
    for(int32_t i = 0; i < N; i++){
        for(int32_t j = 0; j < N; j++){
            if(i == j) continue;
            int32_t x_diff = cities[i].first - cities[j].first;
            int32_t y_diff = cities[i].second - cities[j].second;
            double dist_pow = x_diff * x_diff + y_diff * y_diff;
            res += std::sqrt(dist_pow);
        }
    }
    std::cout << std::setprecision(11) << res / N << std::endl;

    return 0;
}


Measured memory_bytes: 256
main=map read.words<$>getLine>>=print.minimum.f
 where f [h,w] =map(\l->(maximum l)-(minimum l))[((quot h 3)*w):(g (h-(quot h 3)) w),((quot h 3)*w+w):(g (h-(quot h 3)-1) w),((quot w 3)*h):(g h (w-(quot w 3))),((quot w 3)*h+h):(g h (w-(quot w 3)-1))]
       g h w =if(even(h*w))then[quot(h*w)2,quot(h*w)2]else[(quot(max h w)2)*(min h w),h*w-(quot(max h w)2)*(min h w)]

Measured memory_bytes: 508
#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> 
  
const int N=2e+5 + 5;
long long int h[N];

int main()
{
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>h[i];
    sort(h+1,h+n+1);
    long long int a=0;
    for(int i=1;i<=n-k;i++)
        a+=h[i];
    cout<<a;
    
}

Measured memory_bytes: 1792
/*
[ ( ^ _ ^ ) ]
*/

import java.io.*;
import java.util.*;


public class Main {
    int INF = (int)1e9;
    long MOD = 1000000007;

    int abs(int x) {
        return Math.abs(x);
    }

    void solve(InputReader in, PrintWriter out) throws IOException {
        int n = in.nextInt();
        int[] h = new int[n];
        int[] dp = new int[n];
        for(int i=0; i<n; i++) {
            h[i] = in.nextInt();
        }
        dp[0] = 0;
        dp[1] = abs(h[0]-h[1]);
        for(int i=2; i<n; i++) {
            dp[i] = dp[i-2] + abs(h[i-2] - h[i]);
            dp[i] = Math.min(dp[i], dp[i-1] + abs(h[i-1] - h[i]));
        }
        out.println(dp[n-1]);
    }
    

    public static void main(String[] args) throws IOException {
        if(args.length>0 && args[0].equalsIgnoreCase("d")) {
            DEBUG_FLAG = true;
        }
        InputReader in = new InputReader();
        PrintWriter out = new PrintWriter(System.out);
        int t = 1;//in.nextInt();
        long start = System.nanoTime();
        while(t-- >0) {
            new Main().solve(in, out);
        }
        long end = System.nanoTime();
        debug("\nTime: " + (end-start)/1e6 + " \n\n");
        out.close();
    }
    
    static boolean DEBUG_FLAG = false;
    static void debug(String s) {
        if(DEBUG_FLAG) System.out.print(s);
    }
    
    public static void show(Object... o) {
        System.out.println(Arrays.deepToString(o));
    }
    
    static class InputReader {
        static BufferedReader br;
        static StringTokenizer st;
    
        public InputReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        
        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        int nextInt() {
            return Integer.parseInt(next());
        }
        
        long nextLong() {
            return Long.parseLong(next());
        }
        
        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

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

#define MOD_1_000_000_007 (1000000007LL)
#define LINF (1LL<<60)
#define rep(i, n)   for (long long i = 0; i <  (long long)(n); i++)
#define rep1(i, n)  for (long long i = 1; i <  (long long)(n); i++)
#define rep2(i, n)  for (long long i = 2; i <  (long long)(n); i++)
#define rep0c(i, n) for (long long i = 0; i <= (long long)(n); i++)
#define rep1c(i, n) for (long long i = 1; i <= (long long)(n); i++)
#define rep2c(i, n) for (long long i = 2; i <= (long long)(n); i++)
#define repc0(n, i) for (long long i = (long long)(n); i >= 0; i--)
#define repc1(n, i) for (long long i = (long long)(n); i >= 1; i--)
#define repc2(n, i) for (long long i = (long long)(n); i >= 2; i--)

namespace solver {
  using namespace std;
  typedef long long ll;

  ll M, D[200020], C[200020];

  void init() {
    scanf("%lld", &M);
    rep(i, M) scanf("%lld %lld", &D[i], &C[i]);
  }

  ll fold(ll n) {
    if (n < 10) return n;
    return (n/10)+(n%10);
  }

  void solve() {
    ll past = 0, ans = 0;
    rep(i, M) {
      ans += (C[i]-1) + (D[i]*C[i]/10);
      past *= 10;
      past += fold(D[i]*C[i]);
      while(past >= 10) {
        ans++;
        past = (past/10)+(past%10);
      }
    }
    printf("%lld\n", ans);
  }

  void solve2() {
    ll acc = 0, ans = 0;
    rep(i, M) {
      ans += C[i];
      acc += D[i]*C[i];
    }
    ans--;
    acc--;
    ans += acc/9;
    printf("%lld\n", ans);
  }
}

int main() {
  solver::init();
  solver::solve2();
  return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()

int main(){
  int X,Y;
  cin>>X>>Y;
  int ans=0;
  if(X==3) ans+=100000;
  else if(X==2) ans+=200000;
  else if(X==1) ans+=300000;
  if(Y==3) ans+=100000;
  else if(Y==2) ans+=200000;
  else if(Y==1) ans+=300000;
  if(X*Y==1) ans+=400000;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))
#define PRECISION(x) std::fixed << std::setprecision(x)

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

bool is_connected(VI2D edges) {
	int n = edges.size();
	vector<bool> is_used(n, false);
	queue<int> q;
	q.push(0);
	while(!q.empty()) {
		int node = q.front();
		q.pop();
		if(is_used[node]) {
			continue;
		}
		is_used[node] = true;
		REP(i, n) {
			if(edges[node][i] != 0) {
				q.push(i);
			}
		}
	}
	return all_of(ALL(is_used), [](bool x) { return x; });
}

int main() {
	int n, m;
	cin >> n >> m;
	VI2D edges(n, VI(n, 0));
	REP(i, m) {
		int a, b;
		cin >> a >> b;
		edges[a - 1][b - 1] = edges[b - 1][a - 1] = 1;
	}

	int result = 0;
	REP(i, n) {
		REP(j, i) {
			if(edges[i][j] == 1) {
				VI2D copy_edges = edges;
				copy_edges[i][j] = 0;
				copy_edges[j][i] = 0;
				result += is_connected(copy_edges) ? 0 : 1;
			}
		}
	}
	cout << result << endl;
	return 0;
}


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

using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  int index = k - 1;
  if (s[index] == 'A') {
    s[index] = 'a';
  } else if (s[index] == 'B') {
    s[index] = 'b';
  } else if (s[index] == 'C') {
    s[index] = 'c';
  }
  cout << s << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define INF 1145141919
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
int ny, nx;
typedef long long int ll;
using namespace std;

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

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}

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;
}

int N, i, res6, res9;
ll dp[1000000];

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

    REP(i,1000000) dp[i]=INF;
    dp[0]=0;

    FOR(i,1,N+1){

        chmin(dp[i], dp[i-1]+1);

        res6=1;
        while(i-res6*6>=0) res6*=6;
        chmin(dp[i], dp[i-res6]+1);

        res9=1;
        while(i-res9*9>=0) res9*=9;
        chmin(dp[i], dp[i-res9]+1);

    }

    cout << dp[N] << endl;

    return 0;
}


Measured memory_bytes: 8064
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <algorithm>



using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main()
{
	int n, m, x;
	cin >> n >> m >> x;
	vector<int> c;
	vector<vector<int>> a;
	rep(i, n) {
		int temp; cin >> temp;
		c.push_back(temp);
		vector<int> atemp;
		rep(j, m) {
			int temp2; cin >> temp2;
			atemp.push_back(temp2);
		}
		a.push_back(atemp);
	}

	int nmax = 1;
	rep(i, n)
		nmax *= 2;


	int res = 1000000000;

	rep(i, nmax) {
		bitset<12> bs(i);
		bool flag = true;
		int cost = 0;

		rep(i, n) {
			if (bs[i])
				cost += c[i];
		}

		rep(j, m) {
			int und = 0;
			rep(k, n) {
				if (bs[k]) {
					und += a[k][j];
				}
			}
			if (und < x)
				flag = false;
		}
		if (flag)
			res = min(res, cost);
	}

	if (res == 1000000000)
		cout << -1 << endl;
	else
		cout << res << endl;


}


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

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

    ll n,k;
    cin >> n >> k;
    vector<ll> a(n);
    for (ll i = 0;i < n;i++){
        cin >> a[i];
    }

    cout << (n+k-3)/(k-1) << "\n";
}

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

using namespace std;
typedef long long ll;
const int N = 105;

ll n, w, Ws[N], Vs[N];
ll dp[N][100005];

ll solve(ll i, ll v) {
    if(i == n) {
        if(v == 0) return 0;
        else return 1e12;
    }
    if(v == 0) return 0;
    ll& res = dp[i][v];
    if(~res) return res;
    res = solve(i+1, v);
    if(v - Vs[i] >= 0)
        res = min(res, solve(i+1, v - Vs[i]) + Ws[i]);
    return res;
}

int main() {
    ios_base::sync_with_stdio(false);
    memset(dp, -1, sizeof(dp));
    cin >> n >> w;
    for(int i=0; i<n; i++)
        cin >> Ws[i] >> Vs[i];
    solve(0, 17);
    ll res, tmp;
    for(ll i=100005; i>0; i--) {
        tmp = solve(0, i);
        if(tmp <= w) { res = i; break; }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 82304
#include <iostream>

using namespace std;

int main() {
    int a, b, c, d, left, right;
    cin >> a >> b >> c >> d;
    left = a + b;
    right = c + d;

    if (left == right) {
        cout << "Balanced";
    } else if (left > right) {
        cout << "Left";
    } else {
        cout << "Right";
    }
}



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

int main(){
    int n;
    cin>>n;
    set<int> kuku;
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            kuku.insert(i*j);
        }
    }
    decltype(kuku)::iterator ans=kuku.find(n);
    if(ans != kuku.end()) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3616
let sort a n = 
  let rec selection_sort a c =
    let rec selection j acc =
      if j < n then selection (j+1) (if a.(j) < a.(acc) then j else acc)
      else acc
    in
    function
      i when i = n -> a,c
    | i ->
      selection_sort
        a
        (match selection (i+1) i with
         | j when i != j ->
           let ai = a.(i) in
           a.(i) <- a.(j);
           a.(j) <- ai;
           c+1
         | _ -> c)
        (i+1)
  in
  selection_sort a 0 0

let () =
  let n = read_int () in
  let a = read_line () |> Str.split (Str.regexp " ")
          |> List.map int_of_string |> Array.of_list in
  let sorted,c = sort a n in
  Array.iteri
    (fun i x -> Printf.printf (if i=n-1 then "%d\n" else "%d ") x) sorted;
  Printf.printf "%d\n" c

Measured memory_bytes: 2300
import java.util.*

class Scanner(`in`: java.io.InputStream) {
    private val reader = java.io.BufferedReader(java.io.InputStreamReader(`in`))
    private var tokenizer: StringTokenizer? = null

    fun next(): String {
        if (tokenizer?.hasMoreTokens() != true) {
            tokenizer = StringTokenizer(reader.readLine())
        }
        return tokenizer!!.nextToken()
    }

    fun nextLine(): String {
        return if (tokenizer?.hasMoreTokens() != true) {
            reader.readLine()
        } else tokenizer!!.nextToken("\n")
    }
}

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

////////////////////////////////////////////////////////////////////////

object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val A = sc.next().toInt()
        val B = sc.next().toInt()
        val ans = Array(100) { CharArray(100) { '.' } }
        for (i in 0 until 50) for (j in 0 until 100) ans[i][j] = '#'
        for (i in 0 until A - 1) ans[(i / 50) * 2][(i % 50) * 2] = '.'
        for (i in 0 until B - 1) ans[(i / 50) * 2 + 51][(i % 50) * 2] = '#'
        pw.println("100 100")
        ans.forEach { pw.println(it.joinToString("")) }
    }
}


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

using namespace std;

int main(int argc, char const *argv[])
{
    int X;
    cin >> X;
    int num = 0;
    int max = 1;
    for (int i = 2; i <= 1000; i++)
    {
        if (i > X) break;
        for (int j = 2; j <= 10; j++)
        {
            num = (int)pow((double)i, (double)j);
            if (num <= X)
            {
                if (num > max) max = num;
            }else
            {
                break;
            }
            
        }
        
    }
    
    cout << max << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val s = sc.nextLine()
    val n = s.length
    var l = 1
    var r = n + 1
    while (r - l > 1) {
        val k = (l + r) / 2
        var ok = true
        if (n - k <= k - 1) {
            if (s.substring(n - k, k).toCharArray().distinct().count() == 2) {
                ok = false
            }
        }
        if (ok) {
            l = k
        } else {
            r = k
        }
    }
    println(l)
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


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

using namespace std;
typedef long long ll;

void solve()
{

}

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

    /*int t;
    cin>>t;
    while(t--)
        solve();
    */
    int N,L;
    cin>>N>>L;
    vector<string> vi(N);
    for(int i=0;i<N;++i){
        cin>>vi[i];
    }
    sort(vi.begin(),vi.end());
    for(auto u:vi){
        cout<<u;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e9;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
struct edge{
	int to,cost;
};
class DIA{//diameter of tree
	public:
	vector<vector<edge> >G;
	vi d;
	vector<bool>vis;
	int n;
	DIA(int size){
		n=size;
		G=vector<vector<edge> >(n);
		d=vi(n);
		vector<bool>vis(n);
	}
	void add_edge(int a,int b,int c){
		edge e={b,c},ee={a,c};
		G[a].pb(e);G[b].pb(ee);
	}
	void bfs(int s){
		d=vi(n,inf);
		queue<int>q;
		q.push(s);
		d[s]=0;
		int u;
		while(!q.empty()){
			u=q.front();q.pop();
			rep(i,G[u].size()){
				edge e=G[u][i];
				if(d[e.to]==inf){
					d[e.to]=d[u]+e.cost;
					q.push(e.to);
				}
			}
		}
	}
	void dia(){
		bfs(0);
		int maxv=0,tgt=0;
		rep(i,n)if(d[i]!=inf&&maxv<d[i]){
			maxv=d[i];
			tgt=i;
		}
		bfs(tgt);
		maxv=0;
		rep(i,n)if(d[i]!=inf)maxv=max(maxv,d[i]);
		cout<<maxv<<endl;
	}
};
int main(){
	int n;
	cin>>n;
	DIA dia(n);
	rep(i,n-1){
		int s,t,w;
		cin>>s>>t>>w;
		dia.add_edge(s,t,w);
	}
	dia.dia();
}

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

int main(){
	int hi,hy,ki,ky,a,b,c,d,hsum,ksum;
	cin>>hi>>hy>>ki>>ky>>a>>b>>c>>d;
	hsum = hi*a+hy*b+hi/10*c+hy/20*d;
	ksum = ki*a+ky*b+ki/10*c+ky/20*d;
	if(hsum>ksum) cout<<"hiroshi"<<endl;
	else if(hsum<ksum) cout<<"kenjiro"<<endl;
	else cout<<"even"<<endl;
	return 0;
}


Measured memory_bytes: 3088
n = int(input())
 
difs = {}
points = []
 
for i in range(n):
    x, y = list(map(int, input().split()))
 
    for j in range(len(points)):
        dif1 = (points[j][0] - x, points[j][1] - y)
        dif2 = (-dif1[0], -dif1[1])
 
        difs[dif1] = 1 if dif1 not in difs else difs[dif1] + 1
        difs[dif2] = 1 if dif2 not in difs else difs[dif2] + 1
 
    points.append((x, y))
 
if n == 1:
    print(1)
else:
    print(n-max(difs.values()))

Measured memory_bytes: 68300
#include <iostream>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL<<60;

int N;
long long W, weight[110], value[110];

long long dp[110][100100] = {0};

int main() {
    cin >> N >> W;
    for (int i = 0; i < N; ++i) cin >> weight[i] >> value[i];

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

            if (sum_w - weight[i] >= 0) {
                chmax(dp[i+1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
            }

            chmax(dp[i+1][sum_w], dp[i][sum_w]);
        }
    }

    cout << dp[N][W] << endl;
}

Measured memory_bytes: 79360
#include<cstdio>
int main()
{
    double w,h,x,y;
    scanf("%lf%lf%lf%lf",&w,&h,&x,&y);
    printf("%lf ",w*h/2);
    if  (w/2==x&&h/2==y)    puts("1");
    else    puts("0");
    return 0;
}

Measured memory_bytes: 128
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
    
    
N,M = map(int,input().split())
uf = UnionFind(N+1)
for m in range(M):
	i,j = map(int,input().split())
	uf.union(i,j)
print(-min(uf.parents))

Measured memory_bytes: 14504
#include <bits/stdc++.h>
using namespace std;
int main(){
	int A = 0, N = 10;
	cin >> N;
	vector<int> P(N);
	for(int i = 0; i < N; i++){
		cin >> P.at(i);
		A = A + P.at(i);
    }
	for(int i = 1; i < N; i++){
		for(int j = 1; j < N; j++){
			if(P.at(j - 1)  < P.at(j)){
				int S;
				S = P.at(j - 1);
				P.at(j - 1) = P.at(j);
				P.at(j) = S;
            }
        }
    }
	A = A - P.at(0) / 2;
	cout << A;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl enjoy_codeforces
using lint=long long;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    int n,k;std::cin>>n>>k;
    std::vector<std::vector<int>>a(n);
    for(int i=0;i<n;i++){
        int t,d;std::cin>>t>>d;t--;
        a.at(t).push_back(d);
    }
    std::vector<lint>b,c;
    for(auto&&v:a){
        if(v.empty())continue;
        std::sort(v.begin(),v.end(),std::greater<>{});
        b.push_back(v.front());
        c.insert(c.end(),v.begin()+1,v.end());
    }
    std::sort(b.begin(),b.end(),std::greater<>{});
    std::sort(c.begin(),c.end(),std::greater<>{});
    for(int i=0;i<(int)b.size();i++)b.at(i)+=2*i+1;
    b.resize(k);
    c.resize(k);
    lint now=std::accumulate(c.begin(),c.end(),0ll);
    lint ans=0;
    for(lint i=0,j=k;i<k;){
        now+=b.at(i++)-c.at(--j);
        if(ans<now)ans=now;
    }
    std::cout<<ans<<'\n';
}


Measured memory_bytes: 6904
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i<(n);i++)
#define fore(i,a) for(auto &i:a)
#define debug(a,b) cout << "debug : " << a << " , "<< b << endl
using ll=long long;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
const ll INF=1LL<<60;
const ll mod=1E9+7;

int main(){
  string s,t;
  cin >> s >> t;
  bool f=true;
  rep(i,s.length()){
    if(s[i]!=t[i])f=false;
  }
  if(s.length()==t.length()-1&&f)cout << "Yes";
  else cout << "No";
}



Measured memory_bytes: 3576
N = list(map(int,input()))
def minus(x,y):
    if y == 0:
        return x
    else:
        return -1*x
def plmi(x):
    if x == 0:
        return '+'
    else:
        return '-'

for i in range(2):
    for j in range(2):
        for k in range(2):
            if 7 == N[0] + minus(N[1],i) + minus(N[2],j) + minus(N[3],k):
                print(str(N[0])+plmi(i)+str(N[1])+plmi(j)+str(N[2])+plmi(k)+str(N[3])+"=7")
                quit()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define int long long
using namespace std;


signed main(){
	fast
	
	int t; cin>>t;
	if(t>=30) cout<<"Yes\n";
	else cout<<"No\n";
return 0; 
}

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

int main() {
    string S, T, U;
	int A , B;
    cin >> S >> T >> A >> B >> U;
    if (U == S) {
        cout << A - 1 << ' ' << B << endl;
    }
    else if (U == T) {
        cout << A << ' ' << B - 1 << endl;
    }

return 0;
}

Measured memory_bytes: 256