akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
int main()
{
   int n,x,l,i,count=0;
   scanf("%d %d",&n,&x);
   for(i=0;i<n;i++){
    scanf("%d",&l);
    x=x-l;
    if(x>=0){
         count++;
    }
   }
   printf("%d",count+1);
    return 0;
}


Measured memory_bytes: 128
// VSCF.cpp : Defines the entry point for the console application.
//
#include <cassert>
#include <functional>
#include <cmath>
#include <list>
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <string>
#include <vector>
#include <set>
#include <deque>
#include <map>
#include <iomanip>
#include <sstream>
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
#define MP make_pair
#define FOR(v,p,k) for(int v=p;v<=k;++v)
#define FORD(v,p,k) for(int v=p;v>=k;--v)
#define REP(i,n) for(int i=0;i<(n);++i)
#define VAR(v,i) __typeof(i) v=(i)
#define FOREACH(i,c) for(VAR(i,(c).begin());i!=(c).end();++i)
#define PB push_back
#define ST first
#define ND second
#define SIZE(x) (int)x.size()
#define ALL(c) c.begin(),c.end()
#define int long long
#define MAXN 1000010
typedef long double LD;


vector<string> inp2;


struct Trie {
	Trie* sons[26];
	Trie* father;
	int fatherPos;
	int isWord;
	int sonsCo = 0;
	int size;
	static int getSize(Trie * t) {
		if (t) {
			return t->size;
		} else {
			return 0;
		}
	}
	Trie() {
		REP(i, 26) {
			sons[i] = 0;
		}
		father = 0;
		isWord = 0;
		size = 0;
	}
	Trie* addWord(int idx, const string & s, int no) {
		if (idx == s.size()) {
			isWord = no;
			return this;
		}
		int letter = s[idx] - 'a';
		if (sons[letter]) {
			sons[letter]->addWord(idx + 1, s, no);
		} else {
			sons[letter] = new Trie();
			sonsCo++;
			sons[letter]->addWord(idx + 1, s, no);
		}
	}
	Trie* compress() {
		if (!isWord && sonsCo == 1) {
			int i = 0;
			while (!sons[i]) {
				i++;
			}
			return sons[i]->compress();
		}
		if (sonsCo) {
			REP(i, 26) {
				if (sons[i]) {
					sons[i] = sons[i]->compress();
				}
			}
		}
		return this;
	}
	int findSize() {
		size = 0;
		if (isWord) {
			size++;
		}
		REP(i, 26) {
			if (sons[i]) {
				size += sons[i]->findSize();
			}
		}
		REP(i, 26) {
			if (sons[i]) {
				sons[i]->father = this;
				sons[i]->fatherPos = i;
			}
		}
		return size;
	}
	int findWord(int idx, const string & s) {
		if (idx == 1 && isWord) {
			return isWord;
		}
		if (isWord) {
			idx--;
		}
		int i = 0;
		while (getSize(sons[s[i] - 'a']) < idx) {
			idx -= getSize(sons[s[i] - 'a']);
			i++;
		}
		return sons[s[i] - 'a']->findWord(idx, s);
	}
	int findBefore(int sonIdx, const string & s) {
		int i = 0;
		int res = 0;
		if (isWord) {
			res++;
		}
		while (s[i] - 'a' != sonIdx) {
			res += getSize(sons[s[i] - 'a']);
			i++;
		}
		if (father) {
			res += father->findBefore(fatherPos, s);
		}
		//cerr << size << " " << getSize(sons[0]) << " " << getSize(sons[1]) << " "<< res << endl;
		return res;
	}
	int findPos(const string & s) {
		int res = 1;
		if (father) {
			res += father->findBefore(fatherPos, s);
		}
		return res;
	}
};

#undef int
int main() {
#define int long long
	int n;
	cin >> n;
	Trie * t = new Trie();
	vector<Trie*> inp(n);
	REP(i, n) {
		string s;
		cin >> s;
		inp[i] = t->addWord(0, s, i + 1);
		inp2.push_back(s);
	}
	t = t->compress();
	t->findSize();
	int q;
	cin >> q;
	REP(i, q) {
		int k;
		string s;
		cin >> k >> s;
		cout << inp[k - 1]->findPos(s) << "\n";
	}
	return 0;
}



Measured memory_bytes: 101120
def solve():
    N = int(input())
    A = list(map(int, input().split()))
    B = []
    for a, b in enumerate(A):
        B.append((b, a+1))
    B.sort()
    l = []
    for (a, b) in B:
        l.append(b)
    print(*l)

# print(solve())

# def solve()が@return voidのとき
solve()

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

int main() {
  vector<vector<int>> c(4, vector<int>(4));
  for (int i = 1; i <= 3; i++) {
    for (int j = 1; j <= 3; j++) cin >> c[i][j];
  }

  for (int a1 = 0; a1 <= 100; a1++) {
    for (int a2 = 0; a2 <= 100; a2++) {
      for (int a3 = 0; a3 <= 100; a3++) {
        int b1 = c[1][1] - a1;
        int b2 = c[2][2] - a2;
        int b3 = c[3][3] - a3;

        if (a2 + b1 == c[2][1] && a3 + b1 == c[3][1] && a1 + b2 == c[1][2] &&
            a3 + b2 == c[3][2] && a1 + b3 == c[1][3] && a2 + b3 == c[2][3]) {
          cout << "Yes" << endl;
          return 0;
        }
      }
    }
  }

  cout << "No" << endl;
}


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

int main(){
  int N; string s; cin >> s; N = s.size();
  int ans = 0;
  if(N == 1) ans = 0;
  else {
    int zero = 0;
    for(int i = 0; i < N; i++){
      if(s[i] == '0') zero++;
    }
    
    ans = min(zero, N - zero);
    ans *= 2;
  }
  
  cout << ans << endl;
  
}

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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define P3(a, b, c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

double euclid(double x1,double y1,double x2,double y2){
    return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}

//nの階乗
double factorial(double n){
    double result=1;
    if(n==0)return 1;
    REP(i,1,n+1){
        result*=i;
    }
    return result;
}

int main(){
    double N;
    double x, y, sum=0;
    cin >> N;
    vector<pair<double, double>> vp;
    REP(i,0,N){
        cin >> x >> y;
        vp.push_back(make_pair(x, y));
    }
    REP(i,0,N){
        REP(j,i+1,N){
            sum+=euclid(vp[i].first, vp[i].second, vp[j].first, vp[j].second);
        }
    }

    sum*=2*factorial(N-2)*(N-1);

    std::cout << std::setprecision(10) << sum/factorial(N) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n,a=0,w=0,t=0,r=0;
	char s[4];

	scanf("%d",&n);
	while(scanf("%s",s)==1){
		if(s[0]=='A')
			a++;
		else if(s[0]=='W')
			w++;
		else if(s[0]=='T')
			t++;
		else
			r++;
	}
	printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n",a,w,t,r);
	return 0;
}

Measured memory_bytes: 1732
using System;

class Program
{
    static public void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);

        if((a*b)%2==0)
            Console.WriteLine("Even");
        else
            Console.WriteLine("Odd");
    }
}


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

using namespace std;
typedef pair<int,int> pii;
typedef long long int ll;

#define INF 1 << 30
#define REP(i,n) for(ll i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(ll i=(k);i<(int)(n);i++)



vector<bool> gen_sosuu(vector<bool> sosuu){
  int size = sosuu.size();
  REP(i,size){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(size)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<size;j++){
      sosuu[i*j] =false;
    }
  }
  return sosuu;
}

ll a,b,c,k;

int main(){
  cin >> a>>b>>c>>k;
  if(k%2==1) cout << b-a<<endl;
  else cout << a-b<<endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n,k = map(int,input().split())

sum = 0
x = 0
for i in range(n,0,-1):
    while i * (2 ** x) < k:
        x += 1
    if (i * (2 ** x) > k * 2) and x >= 1:
        x -= 1
    sum += (1/2)**x / n

print(sum)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
 
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
 
/*------------------------------------------------------------------*/
 
int main(){
    ll n, T; cin >> n >> T;
    vector<ll> t(n);
    rep(i, n) cin >> t[i];
    ll t_sum = 0;
    ll time = 0;
    rep(i, n){
        if(i == 0){
            t_sum += T;
        }else{
            if(t[i] < time){
                t_sum += (t[i] + T) - time;
            }else{
                t_sum += T;
            }
        }
        time = T + t[i];
    }
    cout << t_sum << endl;
}

Measured memory_bytes: 1792
package main

import (
	"fmt"
	"sort"
)

// 命名に特に意味はないよ
type YO struct {
	Index int
	Diff  float64
}

type YOS []YO

func (yos YOS) Len() int {
	return len(yos)
}
func (yos YOS) Swap(i, j int) {
	yos[i], yos[j] = yos[j], yos[i]
}

func (yos YOS) Less(i, j int) bool {
	return yos[i].Diff < yos[j].Diff
}

func main() {
	var N int
	var T, A float64
	fmt.Scan(&N, &T, &A)
	HS := make(YOS, N)
	for i := 0; i < N; i++ {
		var H float64
		fmt.Scan(&H)
		dif := abs(A - (T - H*0.006))
		HS[i] = YO{Index: i + 1, Diff: dif}
	}
	sort.Sort(HS)
	fmt.Println(HS[0].Index)
}

func abs(a float64) float64 {
	if a < 0 {
		a *= -1.0
	}
	return a
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>

#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

int main()
{
  string S;
  cin >> S;
  
  if(S == "ABC") cout << "ARC";
  else cout << "ABC";
}
  

Measured memory_bytes: 3604
a,b,c,d,e,f=map(int,input().split())

A=sorted(list(set([a*i+b*j for j in range(f//(100*b)+1) for i in range(f//(100*a)+1) if 100*(a*i+b*j)<=f])))
B=sorted(list(set([c*i+d*j for j in range(f//d+1) for i in range(f//c+1) if c*i+d*j<=f])))

r=w=s=0
for x in A[1:]:
    for y in B:
        if 100*x+y<=f and y<=x*e and r<=y/(100*x+y):
            r=y/(100*x+y)
            w=100*x+y
            s=y
print(w,s)

Measured memory_bytes: 12544
W, H, N = map(int, input().split())
lis = []
xi = 0
yi = 0
xj = W
yj = H
for i in range(N):
    #lis.append(list(map(int, input().split())))
    x, y, a = map(int, input().split())
    if (a==1) and (x>xi):
        xi = x
    elif (a==2) and (x<xj):
        xj = x
    elif (a==3) and (y>yi):
        yi = y
    elif (a==4) and (y<yj):
        yj = y

x = W-xi-(W-xj)
if x<0:
    x = 0
y = H-(H-yj)-yi
if y<0:
    y = 0

print(x*y)

Measured memory_bytes: 3064
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

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

typedef pair<int, int> pint;
typedef long long ll;

int main()
{
    int a, b;
    cin >> a >> b;
    if (a * b % 2)
    {
        cout << "Odd" << endl;
    }
    else
    {
        cout << "Even" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while(true) {
			int H = scan.nextInt();
			int W = scan.nextInt();
			if (H == 0 && W == 0) break;
			for (int i = 0; i < H; i++) {
				for(int k = 0; k < W; k++) {
					System.out.print("#");
				}
				System.out.println();
			}
			System.out.println();
		}
	}
}


Measured memory_bytes: 34912
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll kabe[400010];
ll h,w,n;

int nibutan(ll x){
	//xより大きな最小の要素を探す(必ず存在する)
	if(kabe[0]>x)return 0;
	int l=0,r=n-1;//lはng,rはok;
	while(r-l>1){
		int m=(l+r)/2;
		if(kabe[m]>x)r=m;
		else l=m;
	}
	return r;
}

ll ans=INF;
int main(){
	scanf("%lld%lld%lld",&w,&h,&n);
	rep(i,0,n){
		ll x,y;
		scanf("%lld%lld",&x,&y);
		kabe[i]=y<<32|x;
	}
	rep(y,1,h+1)kabe[n+(y-1)]=y<<32|(w+1);
	n+=h;
	sortup(kabe,n);
	
	ll crry=1;
	rep(x,1,w+1){
		//コマは(x,crry)にあり高橋の手番
		int idx=nibutan(crry<<32|x);
		ll kabex=kabe[idx]&0xFFFFFFFF;
		ll kabey=kabe[idx]>>32;
		//青木がなにもしない
		ans=min(ans,kabex-1);
		//高橋は右に動かすので、青木は上に動かせるなら動かす
		idx=nibutan((crry+1)<<32|x);
		kabex=kabe[idx]&0xFFFFFFFF;
		kabey=kabe[idx]>>32;
		if(!(kabey==crry+1&&kabex==x+1))crry++;
		if(crry>h)break;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 6396
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;

char a[1000];

int main()
{
 int n;
 scanf("%d",&n);
 scanf("%s",a);
 int t=n/2;
 int f=0;
 if(n%2!=0)
 f=1;
 else
 {
 for(int i=0;i<n/2;i++)
 {
 if(a[i]!=a[t])
 {
 f=1;
 break;
 }
 t++;
 }
 }
 
 if(f==0)
 printf("Yes\n");
 else
 printf("No\n");
}


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

int main(){
 int n=0, k=0;
  cin >> n >> k;
  vector<int> ll(n);
  for(int i =0; i < n ; i++){
  cin >> ll.at(i);
  }
 
  for(int i =0; i < n-k; i++){
    if (ll.at(i+k) > ll.at(i)) cout << "Yes" << endl;
    else cout << "No" << endl;
  }

  return 0;
  
}


Measured memory_bytes: 3964
// atcoder/agc041/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  std::ios_base::sync_with_stdio(0);
  std::cin.tie(0);
  std::cout.setf(std::ios_base::fixed);
  std::cout.precision(15);

  lli n, a, b;
  while (cin >> n >> a >> b) {
    lli diff = abs(a - b);
    if (diff % 2 == 0) {
      cout << diff / 2 << endl;
    } else {
      unless (a < b) swap(a, b);
      lli x = a + (b - a) / 2;
      a = n - a + 1;
      b = n - b + 1;
      swap(a, b);
      lli y = a + (b - a) / 2;
      cout << min(x, y) << endl;
    }
  }

  return 0;
}


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

using namespace std;

const int N = 1005;

struct Que {
	int time;
	int val;
}q[N];

int n , t;

bool cmp ( Que x , Que y ) {
	return x.val < y.val;
}

int main ( void ) {
	cin >> n >> t;
	for ( int i = 1 ; i <= n ; i++ ) 
		cin >> q[i].val >> q[i].time;
	sort ( q + 1 , q + 1 + n , cmp );
	for ( int i = 1 ; i <= n ; i++ ) {	
		if ( q[i].time > t ) continue;
		printf ( "%d\n" , q[i].val );
		return 0;
	}
	puts ( "TLE" );
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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 (a>b) { a=b; return 1; } return 0; }



int main() {
  int n, k;
  string s;
  cin >> n >> s >> k;

  char c = s[k - 1];
  rep(i, s.length()) cout << (s[i] == c ? c : '*');
  cout << endl;


  
  return 0;
}

Measured memory_bytes: 256
//To debug :  g++ -g file.cpp -o code
//to flush output : fflush(stdout) or cout.flush()
//cout<<setprecision(p)<<fixed<<var
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a,n) for(i=a;i<n;++i)
#define irep(i,n,a) for(i=n;i>a;--i)
#define mod 1000000007
#define pb push_back
#define big 9223372036854775807
#define big1 LONG_MAX
#define big2 INT_MAX
#define big3 1000000000
#define sma1 LONG_MIN
#define sma2 INT_MIN
#define sma3 -1000000000
#define mp make_pair
#define dub double
#define ivec vector<int>
#define lvec vector<long long>
#define cvec vector<char>
#define svec vector<string>
#define mt make_tuple
#define PI acos(-1)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 

ll n,m,c,i,v,j,k,s;

bool bs(ll mid,ll *a)
{	
	j=n-1,c=0;

	for(i=0;i<n;++i)
	{
		v = mid - a[i];
		k = 0;
		for(j;j>=0;--j)
		{
			if(a[j]<v)
			{
				k=j+1;
				break;
			}
		}
		c += n-k;

	}

	return (m<=c);
}

int main()
{
	IOS

	ll i;
	cin>>n>>m;
	ll a[n];

	rep(i,0,n)
		cin>>a[i];

	sort(a,a+n);

	//Find the maximum value such number of pairs that give that value
	//is greater than or equal to m
	ll lef = 0 , rig = 200002 , mid = (lef+rig)/2;

	//till wherever lef goes means it works

	while(lef<rig)
	{
		if(rig == (lef+1))
			mid = rig;

		if(bs(mid,a))
		{
			lef = mid;
			mid = (lef + rig)/2;
		}
		else
		{
			rig = mid-1;
			mid = ((lef + rig))/2;
		}
	}

	ll ans=0,t = m,s=lef+1,j=n-1,sum[n+1]={0};

	for(i=n-1;i>=0;--i)
		sum[i]+=sum[i+1]+a[i];

	for(i=0;i<n;++i)
	{
		v = s - a[i];
		k = 0;
		for(j;j>=0;--j)
		{
			if(a[j]<v)
			{
				k=j+1;
				break;
			}
		}

		ans += sum[k] + a[i]*(n-k);

		t = t - (n-k); 
	}

	ans += t*lef;

	cout<<ans<<"\n";

	return 0;
}

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

int main(){
	string d("");
	int m;
	int h;
	int l;
	while(true) {
		cin >> d;
		if ( d == "-" ) break;
		cin >> m;
		l = d.size();
		for (int i = 0 ;i<m ;i++ ) {
			cin >> h;
			d = d.substr(h) + d.substr(0,h);
		}
		cout << d << endl;
	}
	return 0;
}

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

using namespace std;

int main(){
  string s;
  int a[4];
  cin >> s;
  int num = stoi(s);
  for(int i = 3; i >= 0; i--){
    a[i] = num %10;
    num /= 10;
  }
  if(a[0] + a[1] + a[2] + a[3] == 7) {
    cout << s[0] << '+' << s[1] << '+' << s[2] << '+' << s[3] << "=7" << endl;
    return 0;
  }
  if(a[0] + a[1] + a[2] - a[3] == 7) {
    cout << s[0] << '+' << s[1] << '+' << s[2] << '-' << s[3] << "=7" << endl;
    return 0;
  }
  if(a[0] + a[1] - a[2] + a[3] == 7) {
    cout << s[0] << '+' << s[1] << '-' << s[2] << '+' << s[3] << "=7" << endl;
    return 0;
  }
  if(a[0] + a[1] - a[2] - a[3] == 7) {
    cout << s[0] << '+' << s[1] << '-' << s[2] << '-' << s[3] << "=7" << endl;
    return 0;
  }
  if(a[0] - a[1] + a[2] + a[3] == 7) {
    cout << s[0] << '-' << s[1] << '+' << s[2] << '+' << s[3] << "=7" << endl;
    return 0;
  }
  if(a[0] - a[1] - a[2] + a[3] == 7) {
    cout << s[0] << '-' << s[1] << '-' << s[2] << '+' << s[3] << "=7" << endl;
    return 0;
  }
  if(a[0] - a[1] + a[2] - a[3] == 7) {
    cout << s[0] << '-' << s[1] << '+' << s[2] << '-' << s[3] << "=7" << endl;
    return 0;
  }
  if(a[0] - a[1] - a[2] - a[3] == 7) {
    cout << s[0] << '-' << s[1] << '-' << s[2] << '-' << s[3] << "=7" << endl;
    return 0;
  }
}


Measured memory_bytes: 256
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let abx: Vec<u64> = read_vec();
    let a = abx[0];
    let b = abx[1];
    let x = abx[2];
    let mut ans = b / x + 1 - a / x - 1;
    if a % x == 0 {
        ans += 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<iostream>
#include<cctype>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cctype>
#include<cstring>
#include<utility>
#include<cmath>
using namespace std;

int main() {
    int num[7] = { 0 }, question, q1[25] = { 0 }, q2[25] = { 0 }, ans[25] = { 0 }, i;

    for (i = 0; i < 6; i++) {
        scanf("%d", &num[i]);
    }
    scanf("%d", &question);
    for (i = 0; i < question; i++) {
        scanf("%d%d", &q1[i], &q2[i]);
    }

    for (i = 0; i < question; i++) {
        if (q1[i] == num[0] && q2[i] == num[1]) ans[i] = 3;
        else if (q1[i] == num[0] && q2[i] == num[2]) ans[i] = 5;
        else if (q1[i] == num[0] && q2[i] == num[3]) ans[i] = 2;
        else if (q1[i] == num[0] && q2[i] == num[4]) ans[i] = 4;
        else if (q1[i] == num[1] && q2[i] == num[0]) ans[i] = 4;
        else if (q1[i] == num[1] && q2[i] == num[2]) ans[i] = 1;
        else if (q1[i] == num[1] && q2[i] == num[3]) ans[i] = 6;
        else if (q1[i] == num[1] && q2[i] == num[5]) ans[i] = 3;
        else if (q1[i] == num[2] && q2[i] == num[1]) ans[i] = 6;
        else if (q1[i] == num[2] && q2[i] == num[4]) ans[i] = 1;
        else if (q1[i] == num[2] && q2[i] == num[5]) ans[i] = 5;
        else if (q1[i] == num[2] && q2[i] == num[0]) ans[i] = 2;
        else if (q1[i] == num[3] && q2[i] == num[0]) ans[i] = 5;
        else if (q1[i] == num[3] && q2[i] == num[1]) ans[i] = 1;
        else if (q1[i] == num[3] && q2[i] == num[4]) ans[i] = 6;
        else if (q1[i] == num[3] && q2[i] == num[5]) ans[i] = 2;
        else if (q1[i] == num[4] && q2[i] == num[0]) ans[i] = 3;
        else if (q1[i] == num[4] && q2[i] == num[2]) ans[i] = 6;
        else if (q1[i] == num[4] && q2[i] == num[3]) ans[i] = 1;
        else if (q1[i] == num[4] && q2[i] == num[5]) ans[i] = 4;
        else if (q1[i] == num[5] && q2[i] == num[1]) ans[i] = 4;
        else if (q1[i] == num[5] && q2[i] == num[2]) ans[i] = 2;
        else if (q1[i] == num[5] && q2[i] == num[3]) ans[i] = 5;
        else if (q1[i] == num[5] && q2[i] == num[4]) ans[i] = 3;
    }

    for (i = 0; i < question; i++) {
        printf("%d\n", num[ans[i]-1]);
    }

    return 0;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
 
const int INF = 1e9;
int dp[100000+1][2];

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

    //dp[i][0] - Who wins when game is played with i number of stones and game starts with Taro
    //dp[i][1] - Who wins when game is played with i number of stones and game starts with Jiro
    //dp[k][0] - Who wins when game is played with k number of stones and game starts with Taro
    
    //initialize
    for (int i=0; i <=a[0]-1; i++){
        dp[i][0] = 1;
        dp[i][1] = 0;
    }
    dp[a[0]][0] = 0;
    dp[a[0]][1] = 1;

    //cout<<a[0]<<"- "<<dp[0][0]<<" "<<dp[0][1]<<endl;
    for (int i=a[0]+1; i<=k; i++){
        //Taro wants to win
        int flag = 1;
        for (int j=0; j <n; j++){
            if (i>=a[j] && dp[i-a[j]][1]==0) {
                flag = 0;
                break;
            }
        }
        dp[i][0] = flag;
        //Jiro wants to win
        flag = 0;
        for (int j=0; j <n; j++){
            if (i>=a[j] && dp[i-a[j]][0]==1) {
                flag = 1;
                break;
            }
        }
        dp[i][1] = flag;
        //cout<<i<<"- "<<dp[i][0]<<" "<<dp[i][1]<<endl;
    }
    if(dp[k][0]==0) cout<<"First";
    else if (dp[k][0]==1) cout<<"Second";
    
    return 0;
}




Measured memory_bytes: 1024
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static int N = 3;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int a = parseInt(sc.next());
		int b = parseInt(sc.next());
		int c = parseInt(sc.next());
		int d = parseInt(sc.next());
		sc.close();
		out.println(a*b>c*d?a*b:c*d);
	}
}


Measured memory_bytes: 21328
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

signed main() {
	for (int m; cin >> m&&m;) {
		int dp[1001] = { 1 };
		//????????°???????????????????????\
		//rep(i, 0, m) {
		//	int a, b; cin >> a >> b;
		//	rep(k, 0, b) {
		//		rrep(j, 0, 1001 - a) {
		//			dp[j + a] += dp[j];
		//		}
		//	}
		//	dumpc(dp);
		//}
		//????????°???????????????????????\?????????
		rep(i, 0, m) {
			int a, b; cin >> a >> b;
			rrep(j, 0, 1001) {
				if (dp[j] == 0)continue;
				rep(k, 1, b + 1) {
					if (j + a*k > 1000)break;
					dp[j + a*k] += dp[j];
				}
			}
		}
		int g; cin >> g;
		rep(i, 0, g) {
			int n; cin >> n;
			cout << dp[n] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3108
n = int(input())
a = list(map(int, input().split()))

t = 0
for i in range(1, n):
    t ^= a[i]

ans = [0 for _ in range(n)]
ans[0] = t
for i in range(1, n):
    ans[i] = ans[i-1]^a[i-1]^a[i]

print(*ans)

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<vector<int>> data(K * 2);
  int d;
  int ans = 0;
  for (int i = 0; i < K; i++) {
    cin >> d;
    data[i * 2].push_back(d);
    for (int j = 0; j < d; j++) {
      data[i * 2 + 1].push_back(0);
      cin >> data.at(i * 2 + 1).at(j);
    }
  }
  for (int h = 1; h < N + 1; h++) {
    bool finished = false;
    for (int i = 0; i < K; i++) {
      for (int j = 0; j < data.at(i * 2).at(0); j++) {
        if (data.at(i * 2 + 1).at(j) == h) {
          finished = true;
          break;
        }
      }
      if (finished) {
        break;
      }
    }
    if (finished) {
      continue;
    }
    ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
using lint         = long long;
constexpr lint inf = 1LL << 60;
constexpr lint mod = 1000000007;

template <lint mod>
struct modint {
    lint v;
    constexpr modint(lint t = 0) noexcept {
        v = t % mod;
        if (v < 0)
            v += mod;
    }
    constexpr modint pow(lint k) noexcept {
        modint res(1), tmp(v);
        while (k) {
            if (k & 1)
                res *= tmp;
            tmp *= tmp;
            k >>= 1;
        }
        return res;
    }
    static modint add_identity() { return modint(0); }
    static modint mul_identity() { return modint(1); }
    constexpr modint inv() { return pow(mod - 2); }

    constexpr modint &operator+=(const modint a) noexcept {
        v += a.v;
        if (v >= mod)
            v -= mod;
        return *this;
    }
    constexpr modint &operator-=(const modint a) noexcept {
        v += mod - a.v;
        if (v >= mod)
            v -= mod;
        return *this;
    }
    constexpr modint &operator*=(const modint a) noexcept {
        v = v * a.v % mod;
        return *this;
    }
    constexpr modint &operator/=(const modint a) noexcept { return (*this) *= a.inv(); }

    constexpr modint operator+(const modint a) const noexcept { return modint(v) += a; };
    constexpr modint operator-(const modint a) const noexcept { return modint(v) -= a; };
    constexpr modint operator*(const modint a) const noexcept { return modint(v) *= a; };
    constexpr modint operator/(const modint a) const noexcept { return modint(v) /= a; };
    constexpr modint operator-() const noexcept { return v ? modint(mod - v) : modint(v); }

    constexpr bool operator==(const modint a) const noexcept { return v == a.v; }
    constexpr bool operator!=(const modint a) const noexcept { return v != a.v; }
    constexpr bool operator<(const modint a) const noexcept { return v < a.v; }
};
using mint = modint<mod>;
ostream &operator<<(ostream &os, mint m) { return os << m.v; }

struct Combination {
    vector<lint> fac, finv, inv;
    Combination(lint maxN) : fac(maxN + 100), finv(maxN + 100), inv(maxN + 100) {
        maxN += 100; // for safety
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1]            = 1;
        for (lint i = 2; i <= maxN; ++i) {
            fac[i]  = fac[i - 1] * i % mod;
            inv[i]  = mod - inv[mod % i] * (mod / i) % mod;
            finv[i] = finv[i - 1] * inv[i] % mod;
        }
    }
    lint operator()(lint n, lint k) {
        if (n < k)
            return 0;
        if (n < 0 || k < 0)
            return 0;
        return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
    }
};

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint k;
    cin >> k;
    string s;
    cin >> s;
    lint ns = s.size();
    Combination nCk(ns + k);
    mint ret = 0;
    for (int i = 1; i <= k; ++i) {
        ret += mint(25).pow(i) * nCk(ns + k, i);
    }
    cout << ret + 1 << "\n";
    // cout << mint(26).pow(ns + k) - ret << "\n";
    return 0;
}

Measured memory_bytes: 51184
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k,i,sum=0;
  cin>>n>>k;
  int a[n];
  for(i=0;i<n;i++)
    cin>>a[i];
  sort(a,a+n);
  for(i=0;i<k;i++)
  sum+=a[i];
  cout<<sum;
  return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <bitset>
#include <cstring>
#include <map>
#include <math.h>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
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 int INF = 1<<30;
const ll LINF = 1LL<<58;
const ll mod = 1000000007;

int main(){
    int a;
    string s;
    cin >> a >> s;
    if (a >= 3200) cout << s << endl;
    else cout << "red" << endl;
    return 0;
}


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

int main() {
	long double a, b, c, d;
	cin >> a >> b >> c;
	d = 1.0e-14;
	if (sqrt(a) + sqrt(b) + d < sqrt(c))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

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

int main(){
    int n;
    scanf("%d",&n);
    int A[n];
    for(int i = 0; i < n; i++){
        scanf("%d",&A[i]);
    }
    int min = A[0],mp=A[1]-min;
    for(int i = 1; i < n; i++){
        if(A[i] - min > mp){
            mp = A[i] - min;
        }
        if(A[i] < min){
            min = A[i];
        }
    }
    printf("%d\n",mp);
}

Measured memory_bytes: 3368
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int nPr(int n, int r) {
	r = n - r;
	int sum = 1;
	int i;
	for (i = n; i >= r + 1; i--)sum *= i;
	return sum;
}
//int nCr1(int n, int r)
//int nCr2(int n, int r) 
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}

using namespace std;
#pragma endregion
signed main() {
	string s, a = "No";
	cin >> s;
	rep(i, s.size() - 1) {
		if (s[i] == 'A' && s[i + 1] == 'C')
			a = "Yes";
	}
	cout << a << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<long long, long long>;
const int INF = numeric_limits<int>::max();
const ll INFL = numeric_limits<ll>::max();
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

bool fn_is_prime(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return n != 1;
}

bool isOK(int index, int key, vector<ll>& a) {
    if (a[index] >= key) return true;
    else return false;
}

int binary_search(int key, vector<ll>& a) {
    int ng = -1;
    int ok = a.size();

    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key, a)) ok = mid;
        else ng = mid;
    }
    return ok;
}

struct UnionFind {
    vector<int> r;

    UnionFind(int N) {
        r = vector<int>(N, -1);
    }

    int root(int x) {
        if (r[x] < 0) return x;
        return r[x] = root(r[x]);
    }

    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (r[x] > r[y]) swap(x, y);
        r[x] += r[y];
        r[y] = x;
        return true;
    }

    int size(int x) {
        return -r[root(x)];
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }
};

int main()
{
    string s; cin >> s;
    s[3] = '8';
    cout << s << endl;
}


Measured memory_bytes: 3600
import java.util.*;
public class Main {
    
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int[] h = new int[N];
        for (int i = 0; i < h.length; i++) {
            h[i] = scanner.nextInt();
        }
        int[] hc = new int[N];
        int ans = 0;
        while(true){
            int count = 0;
            boolean section = false;
            for (int i = 0; i < h.length; i++) {
                if(hc[i] < h[i]){
                    if(!section) count++;
                    section = true;
                    hc[i] ++;
                }else{
                    section = false;
                }
            }
            ans += count;
            if(count == 0) break;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
import sys
from collections import defaultdict

N = input()
F = defaultdict(int)

def factorization(n):
    f=defaultdict(int)
    a = n
    for k in range(2, n+1):
        while a%k==0:
            f[k]+=1
            a/=k
    return f


def solve():
    A = F.values()
    B = F.keys()
    # (24, 2)
    n = len(A)
    s1 = set()
    for i in range(n):
        a = A[i]
        if a >= 24:
            for j in range(n):
                if i == j: continue
                if A[j] >= 2:
                    a = B[i]
                    b = B[j]
                    s1.add(a**24 + b**2)
    # (14, 4)
    n = len(A)
    s2 = set()
    for i in range(n):
        a = A[i]
        if a >= 14:
            for j in range(n):
                if i == j: continue
                if A[j] >= 4:
                    a = B[i]
                    b = B[j]
                    s2.add(a**14 + b**4)

    # (4, 4, 2)
    n = len(A)
    s3 = set()
    for i in range(n):
        a = A[i]
        if a >= 4:
            for j in range(n):
                if i == j: continue
                if A[j] >= 4:
                    for k in range(n):
                        if k == i or k == j: continue
                        if A[k] >= 2:
                            a = B[i]
                            b = B[j]
                            c = B[k]
                            s3.add(a**4 + b**4+c**2)

    # (74)    
    n = len(A)
    s4 = set()
    for i in range(n):
        a = A[i]
        if a >= 74:
            s4.add(a**74)                    

    return len(s1) + len(s2) + len(s3) + len(s4)

    




for n in range(2, N+1):
    f = factorization(n)
    for k, v in f.iteritems():
        F[k] += v

print(solve())


Measured memory_bytes: 2936
#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>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
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)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
typedef pair<int, int> PII;
typedef long long ll;
template<typename T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;


int n, cnt;
map<string, int> mp;
vector <string> s;
map<string, int>::iterator ite;

int main() {

	cin >> n;
	rep(i, n) {
		string tmp;
		cin >> tmp;
		mp[tmp]++;
		cnt = max(cnt, mp[tmp]);
	}

	for (ite = mp.begin(); ite != mp.end(); ite++) {
		if (ite->se == cnt)s.push_back(ite->fi);
	}

	sort(s.begin(), s.end());

	rep(i, s.size()) {
		cout << s[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 26868
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
//B - 文字列大好きいろはちゃんイージー / Iroha Loves Strings (ABC Edition)

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();

		List <String> ans = new ArrayList<String>();

		for (int i = 0; i < s.length();i++ ) {
			if(s.charAt(i) == '0') {
				ans.add("0");
			} else if (s.charAt(i) == '1') {
				ans.add("1");
			} else {
				if ( ans.size() != 0) {
					ans.remove(ans.size() -1);
			}
			}
		}
		for (int i = 0; i < ans.size(); i++) {
			System.out.print(ans.get(i));
		}
	}
}


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

#define int long long

#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define ALL(v) (v).begin(), (v).end()

#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;

using pi = pair<int, int>;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vpi = vector<pi>;
using vvi = vector<vi>;
using vvb = vector<vb>;

const int INF = 1e16;
//const int MOD = 1e9+7;
const int MOD = 998244353;

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

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int N; cin >> N;
    vi D(N); REP(i, N) cin >> D[i];
    if(D[0] != 0)
    {
        cout << 0 << endl;
        return 0;
    }
    vi c(1e5); REPS(i, N-1) c[D[i]]++;
    int ans = 1;
    REPS(i, N-1)
    {
        if(D[i] == 0)
        {
            cout << 0 << endl;
            return 0;
        }
        if(D[i] >= 2) ans *= c[D[i]-1], ans %= MOD;
    }
    cout << ans % MOD << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <limits.h>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <string>
#define ll long long
#define ull unsigned long long
#define ms(a) memset(a,0,sizeof(a))
#define pi acos(-1.0)
#define INF 0x7f7f7f7f
#define lson o<<1
#define rson o<<1|1
const double E=exp(1);
const int maxn=1e6+10;
const int mod=1e9+7;
using namespace std;
char ch[maxn];
int a[maxn];
int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(false);
	cin>>ch;
	int l=strlen(ch);
	int k=0;
	for(int i=0;i<l;i++)
	{
		if(ch[i]=='B')
		{
			if(k)
				k--;
		}
		else
			a[k++]=ch[i]-'0';
			// a[i]='\0';
	}
	for(int i=0;i<k;i++)
		cout<<a[i];
	cout<<endl;
	// cout<<a<<endl;
	return 0;
}

Measured memory_bytes: 2304
#pragma GCC optimize "O3"

#include<bits/stdc++.h>

using namespace std;

constexpr int N = 20;

int n, ans;
string tmp, ans_rev;
vector<string> words[N+1], cands[N+1];

inline bool valid(string &tar, string &s, string &rev) {
  for(size_t i = 0; i<s.size(); ++i) {
    if(rev[s[i]] != -1 && rev[s[i]] != tar[i])
      return false;
    if(rev[tar[i]] != -1 && rev[tar[i]] != s[i])
      return false;
  }
  return true;
}
void dfs(int l, size_t x, string &rev) {
  if(ans > 1)
    return;
  while(l && x >= words[l].size()) {
    x = 0;
    --l;
  }
  if(l == 0) {
    ans_rev = rev;
    ++ans;
    return;
  }
  string &tar = words[l][x];
  for(size_t j = 0; j<cands[l].size(); ++j) {
    string &s = cands[l][j];
    if(valid(tar, s, rev)) {
      string nrev = rev;
      size_t i = 0;
      for(; i<s.size(); ++i)
        if(nrev[s[i]] == -1) {
          if(nrev[tar[i]] != -1)
            break;
          nrev[s[i]] = tar[i];
          nrev[tar[i]] = s[i];
        }
      if(i != s.size())
        continue;
      dfs(l, x+1, nrev);
    }
  }
}
void cleanup(vector<string>& v) {
  sort(v.begin(), v.end());
  v.resize(unique(v.begin(), v.end()) - v.begin());
}
void init() {
  for(int i = 0; i<=N; ++i)
    words[i].clear(), cands[i].clear();
  ans = 0;
}
void solve() {
  init();
  for(int i = 0; i<n; ++i) {
    cin >> tmp;
    for_each(tmp.begin(), tmp.end(), [](char &c) { c -= 'A'; });
    cands[tmp.size()].push_back(tmp);
  }
  vector<string> sent;
  bool cont = true;
  while(cont) {
    cin >> tmp;
    if(tmp.back() == '.') {
      tmp.pop_back();
      cont = false;
    }
    sent.push_back(tmp);
    for_each(tmp.begin(), tmp.end(), [](char &c) { c -= 'A'; });
    words[tmp.size()].push_back(tmp);
  }
  for(int i = 1; i<=N; ++i)
    cleanup(words[i]);
  string rev(26, -1);
  dfs(N, 0, rev);
  if(ans == 1) {
    for(size_t i = 0; i<sent.size(); ++i) {
      for(auto c : sent[i]) 
        putchar(ans_rev[c - 'A'] == -1 ? c : ans_rev[c - 'A'] + 'A');
      putchar(i+1 == sent.size() ? '.' : ' ');
    }
    puts("");
  } else
    puts("-.");
}
int main() {
  while(scanf("%d", &n) == 1 && n)
    solve();
}

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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
vector<vector<int>>vec;
int n;
vector<int>color;
void bsf(int s,int c) {
	queue<int>q;
	q.push(s);
	color[s] = c;
	while (!q.empty()) {
		int u = q.front(); q.pop();
		rep(v, 0, vec[u].size()) {
			if (color[vec[u][v]] != -1)continue;
			color[vec[u][v]] = c;
			q.push(vec[u][v]);
		}
	}
}
void solve() {
	rep(i, 0, n) {
		if (color[i] == -1)bsf(i, i);
	}
}
signed main() {
	cin >> n; vec = vector<vector<int>>(n); color = vector<int>(n, -1);
	int m; cin >> m;
	rep(i, 0, m) {
		int s, t; cin >> s >> t;
		vec[s].push_back(t);
		vec[t].push_back(s);
	}
	solve();
	int q; cin >> q;
	rep(i, 0, q) {
		int s, t; cin >> s >> t;
		if (color[s] == color[t])cout << "yes" << endl;
		else cout << "no" << endl;
	}
	return 0;
}

Measured memory_bytes: 8584