akhauriyash/Code-Regression huggingface dataset:
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
#include <numeric>
#include <random>
#include <climits>  // A/Bを計算するときA==LLONG_MIN && B==-1のみ(1ull<<63)で代用
using namespace std;

typedef long long LL;
typedef pair<LL, LL> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef vector<VL> VVL;				// VVL v(100,VL(100,0));
typedef vector<pair<LL, LL> > VP;
typedef vector<string> VS;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<LL, pair<P, P> > PP;

#define INF 999999999999999997		// 少し加算したらオーバーフローする
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
#define O(s) cout<<s<<endl;
#define SORTVL(v) sort(v.begin(), v.end());
#define SORTVL_GR(v) sort(v.begin(), v.end(), greater<LL>());

#define DUMP_VVI(b) if(dbgF){FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}

template<class T>T IN() { T d; cin >> d; return d; }

LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a % b) : a; } // 最大公約数（Greatest Common Divisor）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; } // 最小公倍数（Least Common Multiple）
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); } // うるう年判定
string Replace(string S, string from, string to) { auto p = S.find(from); while (p != string::npos) { S.replace(p, from.size(), to); p = S.find(from, p + to.size()); }return S; }
// 桁和
LL Ketawa_s(string s) { LL a = 0; FOR(i, 0, s.length())a += s[i] - '0'; return a; }
// 末尾数字で切り上げ
LL CeilLastNumber(LL n) { return ((n + (10 - 1)) / 10) * 10; }
//二項係数 nCk mod pを求める
const LL MAX = 510000, p = 998244353; LL fac[MAX], finv[MAX], inv[MAX];
/* 前処理 */void COM_init() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; FOR(i, 2, MAX) { fac[i] = fac[i - 1] * i % p; inv[i] = p - inv[p % i] * (p / i) % p; finv[i] = finv[i - 1] * inv[i] % p; } }
/* 主処理 */LL COM(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % p) % p; }

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

// -------------------------------------------------------------------------------

int main() {
	FAST_IO;
	bool dbgF = true; // for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;

	LL K, X;
	cin >> K >> X;

	if (500 * K >= X) {
		O("Yes");
	}
	else {
		O("No");
	}


	return 0;
}

Measured memory_bytes: 256
// package com.patra.cp.atcoder.practice.dp;

// https://atcoder.jp/contests/dp/tasks/dp_a

import java.util.Arrays;
import java.util.Scanner;

public class Main {

    private static int solve(int[] arr, int[] dp, int currPos) {
        if(currPos >= arr.length) {
            return Integer.MAX_VALUE;
        }
        if(dp[currPos] != -1) {
            return dp[currPos];
        }
        int count = 0;
        int res = Integer.MAX_VALUE;
        if(currPos == arr.length - 1) {
            res = 0;
        }
        for(int i = currPos + 1; i < arr.length; i++) {
            if(count == 2) {
                break;
            }
            count++;
            int temp = solve(arr, dp, i);
            res = Math.min(res, temp + Math.abs(arr[currPos] - arr[i]));
        }
        dp[currPos] = res;
        return dp[currPos];
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        int N = Integer.parseInt(line);
        int[] arr = new int[N];
        int[] dp = new int[N];
        Arrays.fill(dp, -1);
        line = sc.nextLine();
        String[] splits = line.split(" ");
        for(int i=0; i<N; i++) {
            arr[i] = Integer.parseInt(splits[i]);
        }
        System.out.println(solve(arr, dp, 0));
    }
}

Measured memory_bytes: 50224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define pb push_back
const int INF = 1e9 + 7;

void test_case() {
    int n, w;
    cin >> n >> w;
    vector<int> weight(n);
    vector<int> value(n);
    int value_sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> weight[i];
        cin >> value[i];
        value_sum += value[i];
    }
    vector<ll> dp(value_sum + 1, INF);
	dp[0] = 0;
    for (int item = 0; item < n; item++) {
        vector<ll> new_dp(value_sum + 1);
        for (int val = 1; val <= value_sum; val++) {
            ll chosen = weight[item] +
                     (val - value[item] >= 0 ? dp[val - value[item]] : INF);
            ll not_chosen = dp[val];
            new_dp[val] = min(chosen, not_chosen);
        }
        dp = new_dp;
    }

	ll ans=0;
	for(int i=0;i<=value_sum;i++)
		if(dp[i]<=w)
			ans = max(ans, (ll)i);
    cout <<ans<< endl;
}

int main() {
    int t = 1;
    // cin >> t;
    while (t--) test_case();
    return 0;
}

Measured memory_bytes: 4812
using System;
class Program
{
	static void Main(string[] args)
	{
		string[] input = Console.ReadLine().Split(' ');
		int a = int.Parse(input[0]);
		int b = int.Parse(input[1]);
      	string s = "No";
      	if(a == b) s = "Yes";
      	Console.WriteLine(s);
      	
	}
}

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

int insertionSort(vector<int>& a, int n, int g) {
    int cnt = 0;
    for (int i=g; i<n; i++) {
        int v = a[i];
        int j = i - g;
        while (j >= 0 && a[j] > v) {
            a[j+g] = a[j];
            j = j - g;
            cnt++;
        }
        a[j+g] = v;
    }
    return cnt;
}

void shellSort(vector<int>& a, int n) {
    vector<int> G; // 3g+1: 1, 4, 13, 40, ...
    for (int val=1; val<=n; val=val*3+1) {
        G.push_back(val);
    }
    cout << G.size() << endl;

    for (int i=G.size()-1; i>0; i--) cout << G[i] << " ";
    cout << G[0] << endl;

    int cnt = 0;
    for (int i=G.size()-1; i>=0; i--) {
        cnt += insertionSort(a, n, G[i]);
    }
    cout << cnt << endl;
}

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i=0; i<N; i++) cin >> A[i];

    shellSort(A, N);
    for (int i=0; i<N; i++) cout << A[i] << endl;

    return 0;
}



Measured memory_bytes: 6720
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//using ll = long long;
using P = pair<int,int>;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n,k,a[200010],sum[200010] = {},b[200010],ans = 0;
	cin >> n >> k;
	if(k == 1){
		cout << 0 << endl;
		return 0;
	}
	b[0] = 0;
	map<int,int> cnt;
	cnt[0]++;
	for(int i = 0;i < n;i++){
		cin >> a[i];
		sum[i + 1] = sum[i] + a[i];
		b[i + 1] = (sum[i + 1] - (i + 1) + k) % k;
		ans += cnt[b[i + 1]];
		cnt[b[i + 1]]++;
		if(i - k + 2 >= 0) cnt[b[i - k + 2]]--;
		//cout << b[i] << endl;
	}
	cout << ans << endl;
}

Measured memory_bytes: 17408
#include <stdio.h>

int main()
{
    int a_0, b_0, c_0;
    int a_1, b_1, c_1;
    int a_2, b_2, c_2;
    int a_3, b_3, c_3;

    scanf("%d %d %d", &a_0, &b_0, &c_0);
    if (a_0 <= b_0){
        a_1 = a_0;
        b_1 = b_0;
        c_1 = c_0;
    }else{
        a_1 = b_0;
        b_1 = a_0;
        c_1 = c_0;
    }

    if (b_1 <= c_1){
        a_2 = a_1;
        b_2 = b_1;
        c_2 = c_1;
    }else{
        a_2 = a_1;
        b_2 = c_1;
        c_2 = b_1;
    }

    if (a_2 <= b_2){
        a_3 = a_2;
        b_3 = b_2;
        c_3 = c_2;
    }else{
        a_3 = b_2;
        b_3 = a_2;
        c_3 = c_2;
    }

    printf("%d %d %d\n", a_3, b_3, c_3);

    return 0;
}

Measured memory_bytes: 596
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define INF (1LL<<60)

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	map<int,int> m;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		m[A[i]]++;
	}

	for (auto itr = m.begin(); itr != m.end(); itr++) {
		//cout << itr->first <<" "<< itr->second << endl;
		if (itr->second >= 3) {
			if (itr->second % 2 == 0)
				itr->second = 2;
			else
				itr->second = 1;
		}
	}

	int cnt=0;
	for (auto itr = m.begin(); itr != m.end(); itr++) {
		if(itr->second==2) cnt++;
	}

	if(cnt%2==0) cout << m.size() << endl;
	else cout << m.size()-1 << endl;

}



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

using namespace std ;

const int MAX = 3010 ;

vector< pair<int , int> >vp ;

int dp[MAX][MAX] ;
int n , t;

int solve(int idx , int rem)
{
	if(rem <= 0)
		return 0 ;
	if(idx == n)
		return 0 ;
	int &ret = dp[idx][rem] ;
	if(ret != -1)
		return ret ;
	ret = solve(idx+1 , rem) ;
	ret = max(ret , solve(idx+1 , rem - vp[idx].first) + vp[idx].second) ;
	return ret ;
}

int main()
{
	memset(dp , -1 , sizeof(dp)) ;
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n>>t ;
	for(int i = 0 ; i < n ; ++i)
	{
		int x , y ;
		cin>>x>>y ;
		vp.push_back({x , y}) ;
	}
	sort(vp.begin() , vp.end()) ;
	return cout<<solve(0 , t)<<"\n" , 0;
}		

Measured memory_bytes: 35840
import java.util.Scanner;

public class Main{
    public static Scanner scan  = new Scanner(System.in);
    public static void main(String[]args){
        int n,tmp;
        boolean flag;
        flag=false;
        n=nextInt();
        tmp=1;
        while(tmp<10){
            if(n%tmp==0){
                if(n/tmp<10){
                    flag=true;
                    break;
                }
            }
            tmp+=1;
        }
        yesNo(flag);
    }



    public static int nextInt(){
        return Integer.parseInt(scan.next());
    }
    public static long nextLong(){
        return Long.parseLong(scan.next());
    }
    public static String next(){
        return scan.next();
    }
    public static double nextDouble(){
        return Double.parseDouble(scan.next());
    }
    public static float nextFloat(){
        return Float.parseFloat(scan.next());
    }

    //Yes or No
    public static void yesNo(boolean flag){
        if(flag) System.out.println("Yes");
        else System.out.println("No");
    }
    public static void print(Object a){
        System.out.println(a);
    }
}

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

using namespace std;

typedef long double ld;
typedef long long ll;

#define sz(x) (int)(x).size()
#define pb push_back
#define mp make_pair
#define f first
#define s second

template<typename T, typename U> bool ckmin(T &a, U b){ return b < a ? a = b, true : false; }
template<typename T, typename U> bool ckmax(T &a, U b){ return b > a ? a = b, true : false; }

const ll MOD = 1e9 + 7;

ll k, res = 0;
string s;
vector<ll> fac;

ll exp(ll a, ll n){
    if(n == 0) return 1;
    ll tmp = exp(a, n/2);
    tmp *= tmp;
    tmp %= MOD;
    if(n%2) tmp *= a;
    tmp %= MOD;
    return tmp;
}

ll inv(ll x){
    return exp(x, MOD - 2);
}

ll cmb(ll c, ll k){
    if(k > c) return 0;
    ll t = inv(fac[c - k]) * inv(fac[k]);
    t %= MOD;
    t *= fac[c];
    t %= MOD;
    return t;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> k >> s;
    fac.assign(3e6 + 5, 1);
    for(int i = 1; i < sz(fac); ++i){
        fac[i] = fac[i - 1] * i;
        fac[i] %= MOD;
    }
    // characters at very end
    for(int i = 0; i <= k; ++i){
        ll tmp = exp(26, i);
        tmp *= cmb(k - i + sz(s) - 1, sz(s) - 1);
        tmp %= MOD;
        tmp *= exp(25, k - i);
        tmp %= MOD;
        res += tmp;
        res %= MOD;
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 27708
n = gets.to_i
arr = gets.chomp.split('')
stack = []
result = ''
(0...n).each do |i|
  if arr[i] == '('
    stack << arr[i]
  else
    if stack.count > 0
      stack.pop
    else
      result = '(' + result
    end
  end
  result += arr[i]
end
while stack.count > 0
  stack.pop
  result = result + ')'
end
puts result

Measured memory_bytes: 1788
inf = 10**9+7
mod = 10**9+7
n, k = map(int, input().split())
a = list(map(int, input().split()))
rep = len(bin(k)) - 2
ans = 0
totala = 0
if k != 0:
    for i in range(rep):
        count1 = 0
        count0 = 0
        for j in range(n):
            if ((a[j] >> (rep-1-i)) & 1): # 最大でrep-1回シフト
                count0+=1
            else:
                count1+=1
        if count1 > count0:
            ans += (2**(rep-1-i))
    anslist = []
    for i in range(rep):
        tmp = 0
        if (k >> (rep-1-i) & 1):
            for j in range(rep):
                if j > i:
                    tmp+=(ans>>(rep-1-j) & 1)*(2**(rep-1-j))
                if j < i:
                    tmp+=(k>>(rep-1-j) & 1)*(2**(rep-1-j))
            anslist.append(tmp)
    anslist.append(k)
    for num in anslist:
        total = 0
        for i in range(n):
            total += (num ^ a[i])
        totala = max(totala, total)
else:
    for i in range(n):
        totala += (ans ^ a[i])

print(totala)

Measured memory_bytes: 68696
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e4+5;
inline int read(){
	char c=getchar();int t=0,f=1;
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){t=(t<<3)+(t<<1)+(c^48);c=getchar();}
	return t*f;
}
int n;
struct node{
	string s;
	int id1,id2,len;
}a[maxn];
int s[5][maxn],cnt[5];
string ans;
int main(){
	n=read();
	for(int i=1;i<=n;i++){
		cin>>a[i].s;
		a[i].len=a[i].s.length();
		if(a[i].s[a[i].len-1]=='A')a[i].id1=1;
		if(a[i].s[0]=='B')a[i].id2=1;
		if(a[i].id1&&a[i].id2)s[3][++cnt[3]]=i;
		else if(a[i].id1) s[1][++cnt[1]]=i;
		else if(a[i].id2) s[2][++cnt[2]]=i;
		else s[4][++cnt[4]]=i;
	}
	ans+=a[s[1][1]].s;
	for(int i=1;i<=cnt[3];i++)ans+=a[s[3][i]].s;
	ans+=a[s[2][1]].s;
	int i;
	for(i=2;i<=min(cnt[2],cnt[1]);i++){
		ans+=a[s[1][i]].s;
		ans+=a[s[2][i]].s;
	}
	if(cnt[2]>cnt[1]){
		for(;i<=cnt[2];i++)
		ans+=a[s[2][i]].s;
		for(i=1;i<=cnt[4];i++)
		ans+=a[s[4][i]].s;
	}
	else{
		for(;i<=cnt[1];i++)
		ans+=a[s[1][i]].s;
		for(i=1;i<=cnt[4];i++)
		ans+=a[s[4][i]].s;
	}
	int l=ans.length();
	int att=0;
	for(int i=1;i<l;i++)
	{
		if(ans[i-1]=='A'&&ans[i]=='B')att++;
	}
	printf("%d\n",att);
	return 0;
}


Measured memory_bytes: 1152
package main

import (
	"fmt"
	"strconv"
)

var queue = [][]int{}

func add(p []int) {
	n := p[len(p)-1]
	if n == 9 {
		np1 := make([]int, len(p))
		copy(np1, p)
		np2 := make([]int, len(p))
		copy(np2, p)

		np1 = append(np1, 8)
		np2 = append(np2, 9)

		queue = append(queue, np1, np2)
	} else if n == 0 {
		np1 := make([]int, len(p))
		copy(np1, p)
		np2 := make([]int, len(p))
		copy(np2, p)
		np1 = append(np1, 0)
		np2 = append(np2, 1)
		queue = append(queue, np1, np2)
	} else {
		np1 := make([]int, len(p))
		copy(np1, p)
		np2 := make([]int, len(p))
		copy(np2, p)
		np3 := make([]int, len(p))
		copy(np3, p)

		np1 = append(np1, n - 1)
		np2 = append(np2, n)
		np3 = append(np3, n + 1)
		queue = append(queue, np1, np2, np3)
	}
}

func show(p []int) {
	str := ""
	for _, e := range p {
		str += strconv.Itoa(e)
	}
	fmt.Println(str)
}

func main() {
	// Code for D - Lunlun Number
	var k int
	fmt.Scanf("%d", &k)

	for i := 1; i <= 9; i++ {
		queue = append(queue, []int{i})
	}

	for i := 1; i <= k; i++ {
		p := queue[0]
		queue = queue[1:]
		add(p)

		if i == k {
			show(p)
		}
	}
}


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

int main()
{
	int n, m, sum = 0;
	cin >> n >> m;
	double x;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin >> a[i];
		sum += a[i];
	}
	int z = 4*m;
	x = sum / (z*1.0);
	sort(a, a+n);
	bool flag = true;
	for(int i=n-1;i>=n-m;i--)
	{
		if(a[i]<x)
		{
			flag = false;
			break;
		}
	}
	if(flag)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<algorithm>
#include<queue>
#define int long long
using namespace std;

int b[300000];
signed main() {
	int a; cin >> a; a *= 3;
	for (int c = 0; c < a; c++) {
		scanf("%lld", &b[c]);
	}
	sort(b, b + a, greater<int>());
	int ans = 0;
	for (int i = 1; i < a / 3*2; i+=2) {
		ans += b[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  int tower = 0;
  for (int i = 1; i <= 999; i++) {
    tower += i;
    if (tower - a == tower + i + 1 - b) {
      cout << tower - a << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
	Scanner sc;
	public void run(){
		sc = new Scanner(System.in);
		s = sc.next();
		calc();
	}
	String s;
	public void calc(){
		boolean ans;
		ans = boolMEW();
		
		if(ans && s.equals("")) System.out.println("Cat");
		else System.out.println("Rabbit");
	}
	
	public boolean boolMEW(){
		if(s.equals("")) 
			return true;
		else{
			if(!s.substring(0, 1).equals("m")){
				return false;
			}
			s = s.substring(1);
			
			boolean a;
			if(s.substring(0,1).equals("m")){
				a = boolMEW();
				if(a && s.substring(0,1).equals("e")){
					s = s.substring(1);
				}
				else a = false;
			}
			else if(s.substring(0,1).equals("e")){
				a = true;
				s = s.substring(1);
			}
			else a = false;
			if(!a) return false;
			
			boolean b;
			if(s.substring(0,1).equals("m")){
				b = boolMEW();
				if(b && s.substring(0,1).equals("w")){
					s = s.substring(1);
				}
				else b = false;
			}
			else if(s.substring(0,1).equals("w")){
				b = true;
				s = s.substring(1);
			}
			else b = false;
			
			if(b) return true;
			else return false;
		}
	}
	public static void main(String[] args){
		new Main().run();
	}
}

Measured memory_bytes: 17304
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>

static const int N = 101;

using namespace std;

int main () {
  int n, v, v2, k;
  int d[N], visited[N];
  vector<vector<int> > V;
  queue<int> Q;
  int maxNumber = 1 << 21;

  for (int i = 0; i <= N; i++) {
    vector<int> A;
    V.push_back(A);
  }
  for (int i = 0; i <= N; i++) {
    d[i] = maxNumber;
    visited[i] = 0;
  }

  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> v >> k;

    for (int j = 0; j < k; j++) {
      cin >> v2;
      V[v].push_back(v2);
    }
  }

  Q.push(1);
  d[1] = 0;

  while (Q.size()) {
    for (vector<int>::iterator it = V[Q.front()].begin(); it != V[Q.front()].end(); it++) {
      if (!visited[*it]) {
        Q.push(*it);
        //printf("d[%d] = d[%d] + 1\n", *it, Q.front());
        d[*it] = min(d[*it], d[Q.front()] + 1);
        visited[*it] = 1;
      }
    }

    Q.pop();
  }

  for (int i = 1; i <= n; i++)
    cout << i << " " << (d[i] == maxNumber ? -1 : d[i]) << endl;

  return 0;
}


Measured memory_bytes: 3164
#include <iostream>
#include <algorithm>
#include <string>
#include <functional> 
#include <vector>
#include <numeric>
#include <stack>
#include <queue>
#include <utility>
//#include <cmath>
#include <cstdlib>

using namespace std;

int main(){

    int n;
    cin >> n ;
    long long a[n];
    for(int i=0;i<n;i++) cin >> a[i];

    long long minmum = 100000000000000000;
    long long sum = 0LL,sub =0LL;
    for(int i=0;i<n;i++) sum += a[i];
    for(int i=0 ; i < n-1 ;i++){
        sub += a[i];
        minmum = min(minmum,abs(sum-sub*2));
    }
    cout << minmum;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>

using namespace std;

double getProb (vector<double>& p, int k, int maxK) {
    if(k >= maxK) return 1.0;
    double& memo = p[k];
    if(memo != -1) return memo;
    return memo = 0.5 * getProb(p, 2*k, maxK);
}

int main() {
    int N, K;scanf("%d %d", &N, &K);
    vector<double> p(K, -1.0);
    double pSum = 0.0;
    for(int i = 1; i <= N; i++) {
        pSum += getProb(p, i, K);
    }
    printf("%.12lf", pSum/N);
    return 0;
}


Measured memory_bytes: 4064
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, ans = 0;
    cin >> n;
    int a[n], b[100005];
    for (int i = 0 ; i < n ; i++) cin >> a[i];
    sort(a, a + n);
    for (int i = 1 ; i <= min(n, a[n - 1]) ; i++) b[i] = 0;
    for (int i = 0 ; i < n ; i++) {
    	if (a[i] > n) ans++;
    	else b[a[i]]++;
	}
    for (int i = 1 ; i <= min(n, a[n - 1]) ; i++) {
    	if (b[i] > 0) {
            if (i != b[i]) {
                if (b[i] > i) ans += b[i] - i;
                else ans += b[i];
            }
        }
	}
	cout << ans;
}

Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
//#pragma GCC optimize("Ofast")
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
//#define int ll
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX / 2;
const ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  string S, T;
  cin >> S >> T;
  rep(i, S.size()) {
    if(S == T) {
      fin("Yes");
      return 0;
    }
    
    char ls = S.back();
    for(int j=S.size()-1; j>=0; j--) {
      S[j + 1] = S[j];
    }
    S[0] = ls;
    
    if(S == T) {
      fin("Yes");
      return 0;
    }
  }
  
  fin("No");
}

Measured memory_bytes: 256
N,Y = map(int,input().split())
x = y = z = 0
for i in range(N,-1,-1):
    if i*10000 <= Y:
        charge = Y - i*10000
        rest = N - i
        for j in range(rest,-1,-1):
            if j*5000 <= charge:
                if charge - j*5000 - (rest-j)*1000 == 0:
                    print('{0} {1} {2}'.format(i, j ,rest-j))
                    exit(0)
print('-1 -1 -1')


Measured memory_bytes: 3060
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import copy
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)

N = getN()
dist = [[] for i in range(N + 1)]
for i in range(N - 1):
    a, b, c = getNM()
    dist[a].append([b, c])
    dist[b].append([a, c])
ignore = [-1] * (N + 1)

# Kからの最短距離をbfsで測る
def distance(sta):
    # 木をKから順にたどる（戻るの禁止）
    pos = deque([sta])

    while len(pos) > 0:
        u = pos.popleft()
        for i in dist[u]:
            if ignore[i[0]] == -1:
                ignore[i[0]] = ignore[u] + i[1]
                pos.append(i[0])

Q, K = getNM()
ignore[K] = 0
distance(K)
# 答えはK~xまでの距離+K~yまでの距離
ans = []
for i in range(Q):
    x, y = getNM()
    ans.append(ignore[x] + ignore[y])
for i in ans:
    print(i)

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }



int main() {
    vector<set<ll>> alph(26);
    ll n; cin >> n;
    string s; cin >> s;
    rep(i, s.size()) {
        alph[s[i]-'a'].insert(i);
    }
    ll q; cin >> q;
    rep(Q, q) {
        int t; cin >> t;
        if(t == 1) {
            ll i; cin >> i; i--;
            char c; cin >> c;
            rep(j, 26) {
                if(alph[j].find(i) != alph[j].end()) {
                    alph[j].erase(i);
                    alph[c-'a'].insert(i);
                    break;
                }
            }
        } else {
            ll l,r; cin >> l >> r; l--; r--;
            int ans = 0;
            rep(i, 26) {
                auto it = alph[i].lower_bound(l);
                if (it != alph[i].end() && *it <= r) ans++;
            }
            cout << ans << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 24196
//yukicoder@cpp14
//author:luckYrat(twitter:@luckYrat_)
//競技プログラミングから逃げるな
//https://www.youtube.com/watch?v=z_B9iJ8r4ic

//せんげん！
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <bitset>

#include <cctype>
#include <utility>
#include <climits>


//なまえくーかん！
using namespace std;
using ll = long long;
using P = pair<ll,ll>;

//てーすう！
const int mod = 1000000007;
const int inf = (1<<30)-1;
const ll linf = (1LL<<62LL)-1;
const double EPS = (1e-10);

//でふぁいん！
#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)

//みじかく！
#define pb push_back
#define fir first
#define scn second
#define ednl endl

//いぇすのー！
#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")

//きんぼーnほーこー！！
P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる

計算量は変わらないが楽できるシリーズ
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる
*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
  int n;cin>>n;
  vector<int> A(n);
  for(int i = 0; n > i; i++){
    cin>>A[i];
  }
  map<int,int> B;
  B[-A[0]]++;
  long long ans = 0;
  for(int i = 1; n > i; i++){
    ans += B[A[i]-i];
    B[-A[i]-i]++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 21068
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> G;
vector<bool> used;
vector<int> topo;
void dfs(int i)
{
    if (used[i]) return;
    used[i] = true;
    for (int j : G[i]) dfs(j);
    topo.push_back(i);
}
int main()
{
    int N, M; cin >> N >> M;
    G.resize(N);
    used.resize(N);
    for (int i = 0; i < M; i++) {
        int x, y; cin >> x >> y; x--, y--;
        G[x].push_back(y);
    }
    for (int i = 0; i < N; i++) {
        dfs(i);
    }
    vector<int> dist(N);
    for (int i : topo) for (int j : G[i]) {
        if (dist[i] < dist[j] + 1) dist[i] = dist[j] + 1;
    }
    cout << *max_element(begin(dist), end(dist)) << endl;
    return 0;
}

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

using namespace std;

int main() {
    long long n, m;
    cin >> n >> m;
    long long s[m]; 
    long long c[m]; 
    long long ans[n];

    for (int i = 0; i < n; i++){
        ans[i] = 0xff;
    }
    for (int  i = 0; i < m; i++){ 
        cin >> s[i] >> c[i];
        if ((s[i] == 1) && (c[i] == 0)){
            if (n == 1){
                cout << 0;
            }
            else{ 
                cout << -1;
            }
            return 0;
        }
        
        if ((ans[s[i]-1] != 0xff) && (ans[s[i]-1] != c[i])){
            cout << -1;
            return 0;
        }
        else {
            ans[s[i]-1] = c[i];
        }
    }
    for (int i = 0; i < n; i++){
        if (ans[i] == 0xff){
            if (i != 0){ 
                ans[i] = 0;
            }
            else{
                if (n == 1){
                    ans[i] = 0;
                }
                else{ 
                    ans[i] = 1;
                }
            }
        }
        cout << ans[i];
    }
                

    
    return 0;
}


Measured memory_bytes: 256
a = gets.to_i
a += 1
c = 0
a.times do |i|
  count = 0
  i.times do |j|
    if i % (j+1) == 0 then
      count += 1
    end
  end
  if count == 8 && i % 2 == 1 then
    c += 1
  end
end
puts c

Measured memory_bytes: 1788
#include<stdio.h>
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	if(a < b)
	{
		printf("a < b\n");
	}
	else if(a > b)
	{
		printf("a > b\n");
	}
	else
	{printf("a == b\n");}
	return 0;
}




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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll n=5;
ll a[5],b[5];

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

  rep(i,n)cin>>a[i];
  ll sum=0;
  rep(i,n){
    b[i]=((a[i]+9)/10)*10;
    sum+=b[i];
  }
  ll res=INF;
  rep(i,n){
    minch(res,sum-b[i]+a[i]);
  }
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int D;
    cin >> D;

    vi c(26);
    REP(i, 26) cin >> c[i];

    vector<vector<ll>> s(D, vector<ll>(26));

    REP(i, D) REP(j, 26) cin >> s[i][j];

    vi last(26, 0);

    ll score = 0;
    REP(i, D) {
        int t; cin >> t;
        --t;

        score += s[i][t];
        last[t] = i + 1;

        REP(j, 26) {
            score -= c[j] * (i + 1 - last[j]);
        }

        print(score);
    }

    
}


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

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;



ll N = 0;
ll tmp;
ll ret = 0;

void input() {
  IN(N);
}

void solve() {
  PRINT(N * (N-1) / 2);
}

int main(void){
  input();
  solve();
}


Measured memory_bytes: 256
import java.awt.Point;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.io.IOException;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int n = Integer.parseInt(br.readLine());
        Point[] points = new Point[n];
        for(int i = 0; i < n; i++) {
            String[] in = br.readLine().split(" ");
            int x = Integer.parseInt(in[0]);
            int y = Integer.parseInt(in[1]);
            points[i] = new Point(x, y);
        }

        Map<Point, Integer> map = new HashMap<>();
        for(int i = 0; i < n; i++) {
            for(int j = i + 1; j < n; j++) {
                Point tmp;
                if(points[i].x > points[j].x || points[i].x == points[j].x && points[i].y > points[j].y) {
                    tmp = new Point(points[i].x - points[j].x, points[i].y - points[j].y);
                }else {
                    tmp = new Point(points[j].x - points[i].x, points[j].y - points[i].y);
                }
                if(map.containsKey(tmp)) map.put(tmp, map.get(tmp) + 1);
                else map.put(tmp, 1);
            }
        }

        int max = map.size() > 0? map.values().stream().max(Comparator.naturalOrder()).get() : 0;
        System.out.println(n - max);
    }
}

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

namespace CompetitiveProgramming
{
    class Program
    {
        static void Main(string[] args)
        {
            MainStream();
        }

        static void MainStream()
        {
            string[] n_i = Console.ReadLine().Split();
            Console.WriteLine(int.Parse(n_i[0]) - int.Parse(n_i[1]) + 1);
        }



    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <cassert>
#include <algorithm>
#define N int(1e5+10)
typedef long long ll;
using namespace std;
ll f[N],h[N];
int main(int argc,char ** argv)
{
    ll n;
    cin>>n;
    for(ll i=0;i<n;++i){
        cin>>h[i+1];
    }
    f[1]=0,f[2]=abs(h[2]-h[1]);
    for(ll i=3;i<=n;++i){
        f[i]=min(f[i-1]+abs(h[i]-h[i-1]),f[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<f[n]<<endl;
    return 0;
}

Measured memory_bytes: 5184
#include<bits/stdc++.h>
using namespace std;
int a[100005],b[100005];
int main()
{
    int n,i,j,k,sum,tmp,x,y,z;
    int h,c,d,e;
    cin>>n>>h;
    for(i=0;i<n;i++)
    {
        scanf("%d%d",&a[i],&b[i]);
    }
    sort(a,a+n);
    sort(b,b+n);
    for(i=n-1,sum=0;i>=0;i--){
        if(b[i]<a[n-1]){
            break;
        }
        if(h<=0){
            break;
        }
        h-=b[i];
        sum++;
    }
    if(h>0){
        //cout<<"sum="<<sum<<endl;
        tmp=h/a[n-1];
        if(h%a[n-1]!=0)
            tmp++;
        sum+=tmp;
    }
    printf("%d\n",sum);
}


Measured memory_bytes: 1024
import java.io.*;
import java.util.*;

class Main {
    static Scanner scanner = new Scanner();
    static long mod = 1000000007;
    static int inf = 0x7ffffff;

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int[][] s = new int[n][n];
        for (int i = 0; i < n; i++) {
            char[] t = scanner.next().toCharArray();
            for (int j = 0; j < n; j++) {
                s[i][j] = t[j] == '1' ? 1 : inf;
                if (t[j] == '1') {
                    s[i][j] = 1;
                }
            }
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                for (int k = 0; k < n; k++) {
                    s[j][k] = Math.min(s[j][k], s[j][i] + s[i][k]);
                }
            }
        }
        int max = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (i != j) {
                    max = Math.max(max, s[i][j]);
                }
                for (int k = 0; k < n; k++) {
                    if ((s[i][j] + s[j][k] + s[k][i]) % 2 == 1) {
                        System.out.println(-1);
                        return;
                    }
                }
            }
        }
        System.out.println(max + 1);
    }

    static class Scanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

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

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


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

int64_t solution(int64_t a, int64_t b) {
  int64_t key, target = a * b;
  for (int64_t i = sqrt(static_cast<long double>(target -1)); i < std::max({a, b}); ++i) {
    if (target > i * i)
      key = i;
    else
      break;
  }
  int64_t ans = 2 * key;
  if (a <= key)
    ans -= 1;
  if (b <= key)
    ans -= 1;
  if (key * (key + 1) >= target)
    ans -= 1;
  return ans;
}

int main() {
  int q;
  std::cin >> q;
  for (int i = 0; i < q; ++i) {
    int64_t a, b;
    std::cin >> a >> b;
    std::cout << solution(a, b) << std::endl;
  }
}


Measured memory_bytes: 384
N = int(raw_input())
L = []
for i in range(N):
  L.append(raw_input())
result = []
sumA = 0
sumB = 0
for i in range(N):
    L[i] = L[i].split()
    result.append([int(L[i][0]) + int(L[i][1]), i])
result.sort()
for i in range(N-1, -1, -2):
    index = result[i][1]
    sumA += int(L[index][0])
for i in range(N-2, -1, -2):
    index = result[i][1]
    sumB += int(L[index][1])
result_K = sumA - sumB
print(result_K)

Measured memory_bytes: 48380
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  map<string, int> m;
  rep(i, n) {
    string s;
    cin >> s;
    m[s]++;
  }
  vector<pair<int, string>> tmp;
  for (auto& x : m) {
    tmp.emplace_back(x.second, x.first);
  }
  sort(tmp.begin(), tmp.end(), greater<pair<int, string>>());
  int cur = tmp[0].first;
  vector<string> ans;
  for (auto& x : tmp) {
    if (x.first < cur) break;
    ans.push_back(x.second);
  }
  sort(ALL(ans));
  for (auto& x : ans) cout << x << endl;
  return 0;
}


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

using namespace std;
using ll = long long;


long long GCD(long long x, long long y){
  if(y==0) return x;
  return GCD(y, x%y); 
}


long long solve(int N, long long M, vector<long long> &a) {
    bool same = true;
    while (a[0] % 2 == 0) {
        for (int i = 0; i < N; ++i) {
            if (a[i] % 2 != 0) return 0;
            a[i] /= 2;
        }
        M /= 2;
    }
    for (int i = 0; i < N; ++i) if (a[i] % 2 == 0) return 0;

    long long lcm = 1;
    for (int i = 0; i < N; ++i) {
        long long g = GCD(lcm, a[i]);
        lcm = lcm / g * a[i];
        if (lcm > M) return 0;
    }
    return (M / lcm + 1) / 2;
}

int main(){
  ll n, m;
  cin >> n >> m;
  vector<ll> a(n);
  for(int i=0; i<n; i++) cin >> a[i], a[i] /= 2;
  
  
  cout << solve(n, m, a) << endl;

  return 0;
}

Measured memory_bytes: 4020
n=int(input())
A=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]
C=[int(i) for i in input().split()]
sum=0
prev=-1
for i in A:
  sum+=B[i-1]
  if(i==prev+1):
    sum+=C[prev-1]
  prev=i
print(sum)

  

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

int N;
int A[100010];
int ans = 0;

int main()
{
    scanf("%d",&N);
    for(int i = 0; i < N; i++)scanf("%d",A + i);
    sort(A,A + N);

    int cnt = 1;
    for(int i = 0; i < N; i++)
    {
        if(i == N - 1 || A[i] != A[i + 1])
        {
            if(cnt < A[i])ans += cnt;
            else ans += cnt - A[i];
            cnt = 0;
        }
        cnt++;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main()
{
	int n,a,b,s=0;
	cin>>n>>a>>b;
	if(n*a>b) s+=b;
	else if(n*a<b) s+=n*a;
	else s+=b;
	cout<<s;
	return 0;
	
}

Measured memory_bytes: 256
#ABC110

n,m,x,y = list(map(int,input().split()))
a = list(map(int,input().split()))
b = list(map(int,input().split()))
l = []
if max(a)<= min(b):
    l = [i for i in range(max(a)+1,min(b)+1)]
    #print(l)
for i in l:
    if x < i <= y:
        print("No War")
        break
        
else:
    print("War")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

int main(void) {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("in.txt", "r", stdin);
	int n;
	cin >> n;
	vl a(n), b(n);
	ll total = 0;
	rep(i,0,n) {
		cin >> a[i] >> b[i];
		total += a[i];
	}
	bool flag = true;
	rep(i,0,n) {
		if(a[i] != b[i]) {
			flag = false;
			break;
		}
	}
	if(flag) {
		cout << 0 << '\n';
		return 0;
	}
	ll mn = 1e18;
	rep(i,0,n) {
		if(a[i] > b[i]) {
			mn = min(mn, b[i]);
		}
	}
	cout << total - mn << '\n';
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
#include<set>
#include<queue>

typedef long long ll;


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

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

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<int, int> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h, w, n,m,x; string s,t;
char maze[60][60];
int dis[101][101]; int graph[52][52]; bool vis[52];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);

}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <long long int> >& v) {
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
vector<ll> vi(200010);
ll a, b, c, d; bool flg = true; bool af = false; bool bf = false;
bool dfs(ll x,ll y) {
	if (x == c) { af = true; }
	if (y == d) { bf = true; }
	if (a>c||b>d) return false;
	else if (af&&bf) return true;
	for (int i = 1; i <= 2; i++) {
		if (flg) {
			if (vi[x + i] == 0) {
				x += i;
				vi[x] = 2;
				dfs(x, y);
			}
			else if (vi[x + i] == 2) {
				vi[x] = 2;
				flg = false;
				dfs(x, y);
			}
		}
		else if (!flg) {
			if (vi[y + i] == 0) {
				y += i;
				vi[y] = 2;
				dfs(x, y);
			}
			else if (vi[y + i] == 2) {
				vi[y] = 2;
				flg = true;
				dfs(x, y);
			}
		}
		else return false;
	}
}

int main() {
	cin >> n;
	vector<ll> ww(n);
	ll res = INF;
	ll sum = 0;
	rep(i, n) {
		cin >> ww[i];
		sum += ww[i];
	}
	ll ss = 0;
	rep(i, n) {
		ss += ww[i];
		ll s2 = sum - ss;
		chmin(res, abs(s2 - ss));
	}
	cout << res << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N; cin>>N;
    set<int> st;
    int x,y=0;
    REP(i,N){
        int a; cin>>a;
        if(a<3200) st.insert(a/400);
        else y++;
    }
    x=st.size();
    cout<<max(1LL,x)<<' '<<x+y<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxN = 2e5 + 13;
int n, m, a[maxN], ans, cnt[maxN], val[maxN];
void add (int x) {
    cnt[x]++;
    if (x - cnt[x] >= 0) {
	if (!val[x - cnt[x]])
	    ans--;
	val[x - cnt[x]]++;
    }
}

void del (int x) {
    if (x - cnt[x] >= 0) {
	val[x - cnt[x]]--;
	if (!val[x - cnt[x]])
	    ans++;
    }
    cnt[x]--;
}

int main () {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    ans = n;
    for (int i = 0; i < n; i++) {
	cin >> a[i];
	add(a[i]);
    }

    for (int i = 0; i < m; i++) {
	int x, y;
	cin >> x >> y;
	add(y);
	del(a[x - 1]);
	a[x - 1] = y;
	cout << ans << '\n';
    }
}
	

    


Measured memory_bytes: 3840