akhauriyash/Code-Regression huggingface dataset:
// abc.cpp :
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

#define MOD 1000000007
#define rp(i,n) for(int i=0;i<(n);i++)
#define irp(i,n) for(int i=(n);i>=0;i--)
#define up(i,s,e,d) for(int i=(s);i<(e);i+=(d))
#define dw(i,s,e,d) for(int i=(s);i>(e);i-=(d))
#define in(x) cin>>(x)
#define ot(x) cout<<(x)
#define ote(x) cout<<(x)<<endl
void bye(auto x, int code=0){cout<<(x)<<endl;exit(code);}

void p1(vi v){
  for(auto a: v){ot(a);ot(",");}
}
void p2(vvi &x){
  for(auto v: x){ot("[");p1(v);ot("]\n");}
}

int main(){
	int k,x;cin>>k>>x;

	up(i,x-k+1,x+k,1){
		cout<<i<<" ";
	}
	ote("");

}


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

#define f first
#define s second

using namespace std;

int main(){
  vector<pair<double, int> > t1(8), t2(8), t3(8), t4;
  
  for(int i = 0 ; i < 8 ; i++) cin >> t1[i].s >> t1[i].f;
  for(int i = 0 ; i < 8 ; i++) cin >> t2[i].s >> t2[i].f;
  for(int i = 0 ; i < 8 ; i++) cin >> t3[i].s >> t3[i].f;
  
  sort(t1.begin(), t1.end());
  sort(t2.begin(), t2.end());
  sort(t3.begin(), t3.end());
  
  for(int i = 2 ; i < 4 ; i++){
    t4.push_back(t1[i]);
    t4.push_back(t2[i]);
    t4.push_back(t3[i]);
  }
  
  sort(t4.begin(), t4.end());
  cout.precision(4);
  cout.setf(ios::showpoint);
  for(int i = 0 ; i < 2 ; i++) cout << t1[i].s << ' ' << t1[i].f << endl;
  for(int i = 0 ; i < 2 ; i++) cout << t2[i].s << ' ' << t2[i].f << endl;
  for(int i = 0 ; i < 2 ; i++) cout << t3[i].s << ' ' << t3[i].f << endl;
  for(int i = 0 ; i < 2 ; i++) cout << t4[i].s << ' ' << t4[i].f << endl;
  return 0;
}

Measured memory_bytes: 1300
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

# https://atcoder.jp/contests/abc069/submissions/3276445

N = int(input())
A = list(map(int, input().split()))

x4 = odd = 0
for a in A:
    if a%4 == 0:
        x4 += 1
    elif a%2:
        odd += 1

if odd <= x4:
    print('Yes')
elif odd == x4+1:
    print('Yes' if x4+odd == N else 'No')
else:
    print('No')

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007;
int dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};
ll dp[100100][13];

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    int ans = 0,now = 0,next,cnt = 0;
    while(1){
        if(now != 1){
            next = a[now];
            now = next-1;
            cnt++;
            if(cnt >= n+1){
                cout << -1 << endl;
                return 0;
            }
        }else if(now == 1){
            cout << cnt << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 640
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();

    int d = b + c;

    if(d<=a){
      c = 0;
    }
    if(d>a){
      c = c - (a- b);
    }
    System.out.println(c);
  }
}


Measured memory_bytes: 21844
n,w=map(int,input().split())
#dp=[[0,0] for i in range(w+1)]
dp=[]
for i in range(w+1):
    dp.append([0,0])
dp[0][0]=1
it=[]
val=[]
for i in range(n):
    a,b=input().split()
    it.append(int(a))
    val.append(int(b))
for i in range(n):
    x=it[i]
   # dp2=dp[:]
    ac=[]
    for j in range(w-x,-1,-1):
        if dp[j][0]==1:
           # print(i,j)
            ac.append(j+x)
            dp[j+x][1]=max(dp[j+x][1],val[i]+dp[j][1])
   # print(dp)
    for i in ac:
        dp[i][0]=1
  #  print(dp,dp2)
print(max([i[1] for i in dp]))


Measured memory_bytes: 93532
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#define ll long long
#define db double

using namespace std;

const int MAXN = 300010;
const ll INF = 10000000000000000ll;

inline int read()
{
    char ch;
    for (ch = getchar(); ch < '0' || ch > '9'; ch = getchar()) 1;
    int x = ch - '0';
    for (ch = getchar(); ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
    return x;
}

int n, m;
int stk[MAXN], top = 0;
ll a[MAXN], sum[MAXN], dp[MAXN], h[MAXN], tmp[MAXN];
ll fo[MAXN], ba[MAXN], chose_ans[MAXN];//fo forward; ba backward

inline db getK(int a, int b)
{
	return 1.0 * (dp[a] + sum[a] + 1ll * a * (a - 1) / 2 - dp[b] - sum[b] - 1ll * b * (b - 1) / 2) / (a - b);
}

void getsum()
{
	sum[0] = 0;
	for (int i = 1; i <= n; i++)
		sum[i] = a[i] + sum[i - 1];
}

void getdp()
{
	getsum();
	stk[top = 1] = 0;
	for (int i = 1; i <= n; i++)
	{
		while (top > 1 && getK(stk[top], stk[top - 1]) <= i) top--;
		int now = stk[top];
		dp[i] = max(dp[i - 1], dp[now] + 1ll * (i - now) * (i - now + 1) / 2 + sum[now] - sum[i]);
		while (top > 1 && getK(stk[top], stk[top - 1]) < getK(i, stk[top])) top--;
		stk[++top] = i;
	}
}

void rev()
{
	for (int i = 1; i <= n / 2; i++)
		swap(a[i], a[n - i + 1]);
}

void solve(int l, int r)
{
	if (l == r)
	{
		h[l] = max(h[l], fo[l - 1] + 1 + ba[l + 1] - a[l]);
		return;
	}
	int mid = (l + r) >> 1;
	stk[top = 1] = l - 1;
	for (int i = l; i <= mid - 1; i++)
	{
		while (top > 1 && getK(stk[top], stk[top - 1]) < getK(i, stk[top])) top--;
		stk[++top] = i;
	}
	for (int i = mid; i <= r; i++)
	{
		while (top > 1 && getK(stk[top], stk[top - 1]) <= i) top--;
		int now = stk[top];
		tmp[i] = dp[now] + (i - now) * (i - now + 1) / 2 + sum[now] - sum[i] + ba[i + 1];
	}
	for (int i = r - 1; i >= mid; i--) tmp[i] = max(tmp[i], tmp[i + 1]);
	for (int i = mid; i <= r; i++) h[i] = max(h[i], tmp[i]);
	solve(l, mid); solve(mid + 1, r);
}

int main()
{
	ios::sync_with_stdio(false);
	n = read();
	for (int i = 1; i <= n; i++)
		a[i] = read();
	getdp();
	for (int i = 1; i <= n; i++) fo[i] = dp[i];
	rev();
	getdp();
	for (int i = 1; i <= n; i++) ba[n - i + 1] = dp[i];
	rev();
	
	for (int i = 1; i <= n; i++) chose_ans[i] = -INF;
	
	for (int i = 1; i <= n; i++) dp[i] = fo[i];
	getsum();
	for (int i = 1; i <= n; i++) h[i] = -INF;
	solve(1, n);
	for (int i = 1; i <= n; i++)
		chose_ans[i] = max(chose_ans[i], h[i]);
	
	rev();
	for (int i = 1; i <= n; i++) swap(fo[i], ba[i]);
	for (int i = 1; i <= n / 2; i++)
	{
		swap(fo[i], fo[n - i + 1]);
		swap(ba[i], ba[n - i + 1]);
	}
	for (int i = 1; i <= n; i++) dp[i] = fo[i];
	getsum();
	for (int i = 1; i <= n; i++) h[i] = -INF;
	solve(1, n);
	for (int i = 1; i <= n; i++)
		chose_ans[i] = max(chose_ans[i], h[n - i + 1]);
	
	rev();
	for (int i = 1; i <= n; i++) swap(fo[i], ba[i]);
	for (int i = 1; i <= n / 2; i++)
	{
		swap(fo[i], fo[n - i + 1]);
		swap(ba[i], ba[n - i + 1]);
	}
	
	m = read();
	while (m--)
	{
		int p, x;
		p = read(), x = read();
		cout << max(fo[p - 1] + ba[p + 1], chose_ans[p] + a[p] - x) << endl;
	}
	return 0;
}


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N; ll K;
int A[int(2e5+5)], Table[100][int(2e5+5)];

int main(){
  cin >> N >> K;
  for (int i = 1; i <= N; i++) {
    cin >> A[i];
    Table[0][i] = A[i];
  }

  for (int i = 1; i < 100; i++){
    for (int j = 1; j <= N; j++){
      Table[i][j] = Table[i-1][Table[i-1][j]];
    }
  }

  int ans = 1;
  while (K > 0){
    for (ll i = 1; i < 100; i++){
      ll now = (ll)1 << i;
      if (K < now){
        ans = Table[i-1][ans];
        K -= now / 2;
        break;
      }
    }
  }
  cout << ans << endl;

  return 0;
}


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

int main() {
	int n,max=-1000000,min=1000000,a;
	long sum=0;
	scanf("%d",&n);
	for(int i=0;i<n;++i) {
		scanf("%d",&a);
		if (a>max) max = a;
		if (a<min) min = a;
		sum += a;
	}
	printf("%d %d %ld\n",min, max, sum);
	return 0;
}

Measured memory_bytes: 2744
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(void) {
	int a, b; cin >> a >> b;
	cout << (a <= 9 && b <= 9 ? a * b : -1) << endl;

	return 0;
}


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

using namespace std;
#define ll long long int

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);


	ll n1,n2,n3;
	cin>>n1>>n2>>n3;
	cout<<n3<<" "<<n1<<" "<<n2;


	return 0;
}


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

int main() {
    int n;
    std::cin >> n;
    std::vector<int> ds(n);
    for (auto& d : ds) std::cin >> d;

    int ans = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < i; ++j) {
            ans += ds[i] * ds[j];
        }
    }

    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 256
# coding: utf-8

import sys
import math
import collections
import itertools
from inspect import currentframe
INF = 10 ** 10
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def MI() : return map(int, input().split())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def chkprint(*args) : names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}; print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

N = I()
X = LI()

p = sum(X) // N
ret = INF

for pp in range(p - 1, p + 2):
    ans = 0
    for x in X:
        ans += (x - pp)**2
    ret = min(ret, ans)

print(ret)


Measured memory_bytes: 43376
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) throws Exception
	{
		new Main().run();
	}
	
	public void run() throws Exception
	{
		Scanner file = new Scanner(System.in);
		int N = file.nextInt();
		double[] ints = new double[N];
		for(int i = 0;i<N;i++)
			ints[i] = file.nextDouble();
		PriorityQueue<Double> que = new PriorityQueue<Double>();
		for(double x:ints)
			que.add(x);
		while(que.size() != 1)
		{
			double x= que.poll();
			double y = que.poll();
			que.offer((x+y)/2);
		}
		System.out.println(que.peek());
	}
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n);
	REP(i,n) {
		cin >> a[i];
		a[i]--;
	}
	int ct = 0;
	REP(i,n){
		if(a[i] != (int)1e8 && a[a[i]] == i){
			a[a[i]] = (int)1e8;
			ct++;
		}
	}
	cout << ct << endl;
  return 0;
}


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


int main(){

  while(1){
    int n;
    cin >> n;
    if(n==0)break;
    n = 1000 - n;
    int ans=0;
    if(n >= 500){
      n -= 500;
      ans++;
    }
    while(n >= 100){
      n-=100;
      ans++;
    }
    if(n >= 50){
      n-=50;
      ans++;
    }
    while(n >= 10){
      n-=10;
      ans++;
    }
    if(n >= 5){
      n-=5;
      ans++;
    }
    ans += n;
 
  cout << ans <<endl;
  }


}

Measured memory_bytes: 1160
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define int         long long   
#define double      long double
#define endl        "\n"
#define pb          push_back
#define PI          3.1415926535897932384626433832795l
#define F           first
#define S           second
#define mp          make_pair
#define f(i,n)      for(int i=0;i<n;i++)
#define fastio      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v)      (v).begin(),(v).end()
#define sort(v)     sort((v).begin(),(v).end())
#define rall(v)     (v).rbegin(),(v).rend()
#define rsort(v)     sort((v).rbegin(),(v).rend())
#define gcd(a,b)    __gcd((a),(b))
#define minn(v)     *min_element(v.begin(), v.end());
#define maxx(v)     *max_element(v.begin(), v.end());
#define print(x)    cout<<(x)<<endl;
typedef pair<int,int> pii;  
typedef vector<int> vi;
struct type{
    int i, j, k;
};
bool isPrime(int n) 
{ 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
}

signed main() 
{
    
    fastio;
    int n;
    cin>>n;
    vi a(n);
    map<string,int> m;
    f(i,n)
    {
        string s;
        cin>>s;
        m[s]++;
    }
    int maxx=-1;
    for(auto x:m)
    {
        maxx=max(maxx,x.S);
    }
    for(auto x:m)
    {
        if(x.S==maxx)cout<<x.F<<endl;
    }
}


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

LL r, c, mod = 1000000007, dp[1010][1010];
string s[1010];
int dy[4] = {1, 0};
int dx[4] = {0, 1};

LL solve(int y, int x) {
	if(y == r-1 && x == c-1) return 1;
	LL &ret = dp[y][x];
	if(ret != -1) return ret;
	ret = 0;
	for(int i = 0; i < 2; i++) {
		int ny = y + dy[i];
		int nx = x + dx[i];
		if(ny < 0 || nx < 0 || ny >= r || nx >= c || s[ny][nx] == '#') continue;
		ret = (ret + solve(ny, nx)) % mod;
	}
	return ret;
}

int main() {
	memset(dp, -1, sizeof(dp));
	cin>>r>>c;
	for(int i = 0; i < r; i++) {
		cin>>s[i];
	}
	cout<<solve(0, 0)<<endl;
	return 0;
}


Measured memory_bytes: 9472
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
vector<int> vec(5);
for (int i = 0; i < 5; i++) {
  cin >> vec.at(i);
}
      
     if (vec.at(0)==0) {
  cout << "1" << endl;
}
else if (vec.at(1)==0) {
  cout << "2" << endl;
}
else if (vec.at(2)==0) {
  cout << "3" << endl;
}
else if (vec.at(3)==0) {
  cout << "4" << endl;
} 
else if (vec.at(4)==0) {
  cout << "5" << endl;
}
      
      
      
  }

Measured memory_bytes: 3588
#include <stdio.h>
#include <string.h>
int main()
{
    int n,k,d,a[100],i,j,l,cnt=0;
    scanf("%d %d", &n,&k);
    for(i=0;i<=n;i++)
    {
        a[i]=i+1;
    }
    for(i=0;i<k;i++)
    {
        scanf("%d", &d);
        for(j=0;j<d;j++)
        {
            scanf("%d",&l);
            a[l-1]=0;
        }
    }
    for(i=0;i<n;i++)
    {
        if(a[i]!=0)cnt++;
    }
    printf("%d\n", cnt);

    return 0;
}


Measured memory_bytes: 1724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() {
int a,b,c;
  cin>>a>>b>>c;
  
  if(a==b){
  if(b==c){
    cout<<"Yes"<<endl;
  }
    else{
          cout<<"No"<<endl;
  }
  }
    else{
          cout<<"No"<<endl;
}
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    long long N;
    cin >>N;
    vector<long long> A(N,0);
    map<int,long long> mp;
    long long ans = 0;
    for(int i = 0; i < N;i++){
        cin >> A[i];
        mp[A[i]]++;
        ans += A[i];
    }
    long long Q;
    cin >> Q;
    vector<long long> B(Q);
    vector<long long> C(Q);
    for(int i = 0; i < Q ; i++){
        cin >> B[i] >> C[i];
        long long cont = mp[B[i]];
        mp[C[i]] += mp[B[i]];
        mp[B[i]] = 0;
        ans += (C[i] - B[i]) * cont;
        cout << ans << endl;
    }

}

Measured memory_bytes: 11232
#include<iostream>
#include<vector>
#include<string>
#include<queue>
using namespace std;

int main()
{
	int n,a,s,g;
	while(cin>>n>>a>>s>>g && n!=0){
		int LIMIT=0;
		vector<string> ans(n);
		vector<vector<vector<string> > > edge(n,vector<vector<string> >(n));//edge[i][j][k]  i->j :k番目のラベル
		for(int i=0;i<a;i++){
			int x,y; string r;
			cin>>x>>y>>r;
			edge[x][y].push_back(r);
			LIMIT+=r.size()*4;
		}

		queue<int> que;
		que.push(g);
		int count=0;

		while(!que.empty()){//無限ループするよ！
			count++;
			int to=que.front(); que.pop();
			for(int from=0;from<n;from++){
				for(int k=0;k<edge[from][to].size();k++){
					if(from==g) continue;
					string rabel=edge[from][to][k];
					if(ans[from]=="" || ans[from]>rabel+ans[to]){
						ans[from]=rabel+ans[to];que.push(from);
					}
				}
			}
			bool b=false;
			for(int i=0;i<n;i++){
				if(ans[i].size()>=LIMIT){b=true;break;}
			}
			if(b)  break;
		}
		if(ans[s].size()>=LIMIT/4 || ans[s]=="") cout<<"NO"<<endl;
		else cout<<ans[s]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1388
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string.h>
#include<queue>
#include<map>
#define maxn 10005
#define mod 1000000007
#define INF 0x3f3f3f3f
#define PI 3.1415926
using namespace std;
typedef long long ll;

int main(){
    //freopen("Test.txt", "r", stdin);
    char s[11];
    scanf("%s", s);
    int len = strlen(s);
    int ans = 1000;
    for(int i = 0 ; i <= len - 3; i++){
    	int x = 0;
    	for(int j = i ; j < i + 3 ; j++){
    		x = x * 10 + s[j] - '0';
    	}
    	x = fabs(753 - x);
    	ans = min(x, ans);
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
long long int  fact(long long int);
int main(){
	int n;
	cin>>n;
	cout<<fact(n)%1000000007<<endl;
}
long long int fact(long long int M){
	int some;
	some=M;
	for(int i=1;i<some;i++){
		M=M*i%1000000007;
	}
	return M;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
int a,b,c;
 
int main(void){
	scanf("%d%d%d",&a,&b,&c);
	printf("%d\n",max(0,c-(a-b)));
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define MAX 50

int main(void){
    int input[MAX];
    int i,j;
    double x1,x2;
    
    for(i=0;i<50;i++){
        scanf("%d",&input[i]);
        if(input[i]==-1){
            break;
        }
    }

    for(j=0;j<i;j++){
        x1=(double)input[j]/2;
        x2=x1-(pow(x1,3)-input[j])/(3*pow(x1,2));
        if(fabs(pow(x2,3)-input[j])<0.00001*input[j]){
            
        }
        else{
            do{
                x1=x2;
                x2=x1-(pow(x1,3)-input[j])/(3*pow(x1,2));
            } while(fabs(pow(x2,3)-input[j])>0.00001*input[j]);
        }
        printf("%lf\n",x2);
    }
    return 0;
}


Measured memory_bytes: 1980
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
typedef long long ll;

string S;
int N;
// pos
vector<set<int>> v;

// j - i \ne k-j を満たす数を負数として返す。
ll go() {
    ll ans = 0;
    for(const auto &i:v[0]) {
        // find start
        auto sj = upper_bound(ALL(v[1]),i);
        for(auto j = sj; j != v[1].end(); j ++) {
            int nk = 2*(*j) - i;
            if (   *j < nk && v[2].count(nk) == 1)  ans--;
        }
    }
    return ans;
}



void solve() {
    v.resize(3);
    cin >> N;
    cin >> S;
    REP(i,N) {
        if (S[i]== 'R') v[0].insert(i);
        if (S[i]=='G') v[1].insert(i);
        if (S[i]=='B') v[2].insert(i);
    }
    ll ans = v[0].size()*v[1].size()*v[2].size();
    // iter_swapでi,j,kとR,G,Bの袋の割り当て方を全部だしている。
    REP(i,3) {
        ans += go();
        iter_swap(v.begin()+1,v.begin()+2);
        ans += go();
        iter_swap(v.begin(),v.begin()+1);
    }
    cout << ans << endl;

}

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


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

int main()
{
	int n,k;
	cin>>n>>k;
	int a[n];
	for (int i=0;i<n;i++) cin>>a[i];
	vector <bool> dp(k+1);
	for (int i=0;i<=k;i++)
	for (int j=0;j<n;j++)
	{
		if (i>=a[j] && !dp[i-a[j]]) dp[i]=true;
	}
	puts(dp[k]? "First" : "Second");
}

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

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
import java.util.*;
 
public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        sc.close();

        if(a > b){
            int t = b;
            b = a;
            a = t;
        }
        for(int i = 0; i < b; i++){
            System.out.print(a);
        }
        System.out.println();
    }
}

Measured memory_bytes: 21844
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  string n; cin >> n;
  int sn = 0;
  for (char c : n) sn += c - '0';
  cout << (stoi(n) % sn == 0? "Yes" : "No") << '\n';
  return 0;
}


Measured memory_bytes: 384
// 見せてやるぜ、奇跡ってやつをよぉ……
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m; cin >> n >> m;
    string s; cin >> s;
    vll jump(n + 1, -1);
    ll l = 0;
    rep(i, 1, n + 1) {
        if (s[i] == '0') {
            while (i - l > m || s[l] == '1') l++;
            jump[i] = i - l;
        }
    }

    vll ans;
    ll tmp = n;
    while (tmp > 0) {
        if (jump[tmp] == -1 || jump[tmp] == 0) {
            ans.clear();
            ans.emplace_back(-1);
            break;
        }
        ans.emplace_back(jump[tmp]);
        tmp -= jump[tmp];
    }

    reverse(ALL(ans));
    REP(i, ans.size()) cout << ans[i] << (i == ans.size() - 1 ? '\n' : ' ');
    return 0;
}


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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >
# define PQ priority_queue

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvs vector < vs >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

# define fr(a,b) for(int i = a; i < b; i++)
# define rep(i,a,b) for(int i = a; i < b; i++)

string vow = "aeiou";
int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.1415926535897932384626 ;
const ll mod = 1e9 + 7 ;

void solve(){

    ll n,x;
    cin >> n >> x;
    vll a(n);
    ll sum = 0;
    fr(0,n) {
        cin >> a[i];
        sum+=a[i];
    }
    ll c = 0;
    rep(i,1,n){
        if(a[i]+a[i-1] > x){
            ll t =  a[i]+a[i-1] - x;
            c+=t;
            if(a[i]>=t){
                a[i] -= t;
            }
            else a[i] =0;
        }
    }
    cout << c;
    line;
    return;

}

int main(){
	fast
	int tc=1;
	//cin >> tc;
	while(tc--){
             solve();
    }

	R 0;
}


Measured memory_bytes: 3996
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
const ll mod = 1000000007;
const int inf = 0x3f3f3f3f;
const ll inff = 0x7ffffffffff;
ll read()
{
	ll x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
//head
char s[5];
int main() {
	scanf("%s", s + 1);
	if(s[1] == 'R' && s[2] == 'R' && s[3] == 'R') cout << 3;
	else if(s[1] == 'R' && s[2] == 'R') cout << 2;
	else if(s[2] == 'R' && s[3] == 'R') cout << 2;
	else if(s[1] == 'R' || s[2] == 'R' || s[3] == 'R') cout << 1;
	else cout << 0;
	return 0;
}

Measured memory_bytes: 3644
#include<stdio.h>
int main()
{
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	if(a+b>c+d)
		printf("Left\n");
	else if(a+b==c+d)
		printf("Balanced\n");
	else
		printf("Right\n");
}

Measured memory_bytes: 128
#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 INF 1e9

using namespace std;

int N;

int main(void)
{
    cin >> N;
    vector<long long> A(N, 0);
    rep(i, N)
    {
        cin >> A[i];
    }

    long long sum_diff = 0;

    rep(i, N - 1)
    {
        if (A[i] > A[i + 1])
        {
            sum_diff += A[i] - A[i + 1];
            A[i + 1] = A[i];
        }
    }

    cout << sum_diff << endl;
}

Measured memory_bytes: 4780
n = int(input())
ans = [0] * n
for x in range(1, int(n ** 0.5) + 1):
    for y in range(1, int(n ** 0.5) + 1):
        for z in range(1, int(n ** 0.5) + 1):
            res = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
            if res <= n:
                ans[res - 1] += 1
            elif res > n:
                break

for x in ans:
    print(x)

Measured memory_bytes: 9572
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
int N;
int main() {
	cin >> N;
	long long maxV = 0; //最後尾の番号
	long long minV = 1000000000; //先頭の番号
	long long subscore = 0;
	for (int i = 0; i < N; ++i) {
		long long a, b; cin >> a >> b;
		if (a > maxV) {
			maxV = a;
			subscore = b;
		}
	}
	cout << maxV + subscore << endl;
	
	return 0;
}


Measured memory_bytes: 384
n = int(input())
a = list(map(int,input().split()))
q = int(input())
bc = [list(map(int,input().split())) for i in range(q)]

dic = {}
ans = sum(a)


for i in a:
    if i in dic:
        dic[i] += 1
    else:
        dic[i] = 1


for b,c in bc:
    try:
        before = dic[b]
    except:
        before = 0

    ans = ans + before * (c-b)
    print(ans)
    try:
        dic.pop(b)
    except:
        pass

    if c in dic:
        dic[c] += before
    else:
        dic[c] = before


Measured memory_bytes: 40008
Q, *AB = map(int, open(0).read().split())

for a, b in zip(*[iter(AB)] * 2):
    if a == b or a + 1 == b:
        print(2 * a - 2)
    else:
        c = int((a * b) ** 0.5)
        if c * c == a * b:
            c -= 1

        if c * (c + 1) >= a * b:
            print(2 * c - 2)
        else:
            print(2 * c - 1)


Measured memory_bytes: 3316
fun main(args: Array<String>) {
    val (N, D) = readLine()!!.split(" ").map { it.toInt() }
    val points = mutableListOf<List<Int>>()
    var integerDistanceCount = 0
    for (i in 0 until N) {
        points.add(readLine()!!.split(" ").map { it.toInt() })
    }

    for (i in 0 until points.size) {
        for (j in 0 until points.size) {
            if (i < j) {
                val diff = pointsDistance(points[i], points[j], D)
                if (diff == Math.floor(diff)) {
                    integerDistanceCount += 1
                }
            }
        }
    }

    println(integerDistanceCount)
}

fun pointsDistance(p1: List<Int>, p2: List<Int>, dimensions: Int): Double {
    var distance = 0.0
    for (i in 0 until dimensions){
        distance += ((p1[i] - p2[i]) * (p1[i] - p2[i]))
    }

     return Math.sqrt(distance)
}

Measured memory_bytes: 37896
#include <stdio.h>

int main() {
  char c;
  int count[26] = {};
  while (scanf("%c", &c) != EOF) {
    if ('a' <= c && c <= 'z') {
      count[c - 'a']++;
    } else if ('A' <= c && c <= 'Z') {
      count[c - 'A']++;
    }
  }
  for (int i = 0; i < 26; i++) {
    printf("%c : %d\n", 'a' + i, count[i]);
  }
  return 0;
}


Measured memory_bytes: 2100
#include<map>
int64_t k,t=1,n,p;int S(int64_t x){return x?x%10+S(x/10):0;}main(){scanf("%d",&k);while(printf("%ld\n",n+=t),--k)t+=t*9*(S(p=n+t+t)*(n+t)>S(n+t)*p);}

Measured memory_bytes: 128
// luogu-judger-enable-o2
/*
Problem : luogu AT2134
Algorithm : MST
Status :
*/
#include <bits/stdc++.h>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
typedef long long ll;

const int INF = 0x3f3f3f3f;
const int MAXN = 2e5 + 5;

int n,m,tot,cnt;
ll ans;
int d[MAXN],f[MAXN];

struct Edge{
	int u,v,w;
} e[MAXN * 2];

bool cmp(const Edge &x,const Edge &y){
	return x.w < y.w;
}

void add(int u,int v,int w){
	e[++tot].u = u;
	e[tot].v = v;
	e[tot].w = w;
}

int find(int x){
	if(x == f[x])
	    return x;
	else
	    return f[x] = find(f[x]);
}

int main(){
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
	scanf("%d%d",&n,&m);
	for(int i = 0;i <= n;i++){
		f[i] = i;
		d[i] = INF;
	}
	for(int i = 1;i <= m;i++){
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		add(a,b,c);
		d[a] = min(d[a],c + 1);
		d[b] = min(d[b],c + 2);
	}
	for(int i = 0;i < n;i++)
	    d[i] = min(d[i],d[(i - 1 + n) % n] + 2);
	for(int i = 0;i < n;i++)
	    d[i] = min(d[i],d[(i - 1 + n) % n] + 2);
	for(int i = 0;i < n;i++)
	    add(i,(i + 1) % n,d[i]);
	sort(e + 1,e + 1 + tot,cmp);
	for(int i = 1;i <= tot;i++){
		int x = e[i].u;
		int y = e[i].v;
		if(find(x) != find(y)){
			f[find(x)] = find(y);
			ans += e[i].w;
			cnt++;
			if(cnt == n - 1)
			    break;
		}
	}
	printf("%lld\n",ans);
	return 0;
}


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

int main(){
  int N;
  cin >>N;
  int d[N];
  for(int i=0;i<N;i++)
    cin >>d[i];
  
  sort(d,d+N);

  int count=0;
  for(int i=d[N/2-1]+1;i<=d[N/2];i++)
    count++;
 

  cout<<count<<endl;

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int N=1050;
const int M=2*N;
const ll inf=9e18;
struct Edge
{
	int u,v,c;ll w;
	Edge(){}
	Edge(int a, int b, int d, ll e):u(a),v(b),c(d),w(e){}
};
vector<Edge> edges;
vector<int> G[M];
void AddEdge(int u, int v, int c, ll w)
{
	G[u].pb(edges.size());
	edges.pb(Edge(u,v,c,w));
	G[v].pb(edges.size());
	edges.pb(Edge(v,u,0,-w));
}
int s,t;
ll dist[M];
int go[M];
bool in[M];
bool BFS()
{
	for(int i=s;i<=t;i++) dist[i]=-inf;
	dist[s]=0;
	queue<int> q;
	q.push(s);
	in[s]=1;
	while(q.size())
	{
		int u=q.front();
		q.pop();
		in[u]=0;
		//printf("u:%i dist[u]:%i\n",u,dist[u]);
		for(int e:G[u])
		{
			int v=edges[e].v;
			int c=edges[e].c;
			ll w=edges[e].w;
			//if(c>0) printf("Edge:%i %i %i %lld\n",u,v,c,w);
			if(c>0 && dist[v]<dist[u]+w)
			{
				dist[v]=dist[u]+w;
				go[v]=e;
				if(!in[v]) q.push(v),in[v]=1;
			}
		}
	}
	return dist[t]!=-inf;
}
ll MaxCostMaxFlow()
{
	ll ans=0;
	while(BFS())
	{
		int MaxCut=1e9+7;
		for(int i=t;i!=s;i=edges[go[i]].u) MaxCut=min(MaxCut,edges[go[i]].c);
		for(int i=t;i!=s;i=edges[go[i]].u) edges[go[i]].c-=MaxCut,edges[go[i]^1].c+=MaxCut;
		ans+=dist[t]*MaxCut;
	}
	return ans;
}
int main()
{
	int n,i,x,y,cnt;
	scanf("%i",&n);
	s=0;t=2*n+5;
	for(i=1;i<=n;i++)
	{
		scanf("%i %i %i",&x,&y,&cnt);
		AddEdge(s,i,cnt,0);
		AddEdge(i,2*n+1,cnt,x+y);
		AddEdge(i,2*n+2,cnt,x-y);
		AddEdge(i,2*n+3,cnt,-x+y);
		AddEdge(i,2*n+4,cnt,-x-y);
	}
	for(i=n+1;i<=2*n;i++)
	{
		scanf("%i %i %i",&x,&y,&cnt);
		AddEdge(i,t,cnt,0);
		AddEdge(2*n+1,i,cnt,-x-y);
		AddEdge(2*n+2,i,cnt,-x+y);
		AddEdge(2*n+3,i,cnt,x-y);
		AddEdge(2*n+4,i,cnt,x+y);
	}
	printf("%lld\n",MaxCostMaxFlow());
	return 0;
}

Measured memory_bytes: 1180
#include<stdio.h>
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}
int main(){
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	swap(&a,&b);
	swap(&a,&c);
	printf("%d %d %d",a,b,c);
	return 0;
} 

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

int main(){
    long W,H,x,y;
    cin >> W >> H >> x >> y;

    // case 1 div x
    long minX = min(x,W-x);
    long area1 = minX * H;

    // case 2 div y
    long minY = min(y,H-y);
    long area2 = minY * W;
    
    // case 3 div x/y
    cout << double(W)*double(H)/2;

    if(x+x == W && y+y == H) cout << " 1" << endl;
    else cout << " 0" << endl;
}

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

using namespace std;
using ll = long long;

using Field = vector<vector<int>>;
using Graph = vector<vector<int>>;
using VI = vector<int>;
using VC = vector<char>;
using PI = pair<int, int>;

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

const long long INF = 1LL<<60;
const int mod = 1000000007;

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

string s, t;
vector<vector<int>> dp(3010, vector<int>(3010, 0));
vector<vector<pair<int, int>>> prev_ij(3010, vector<pair<int,int>>(3010, pair<int, int>()));


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

    cin >> s >> t;
    int lens = s.size();
    int lent = t.size();

    dp.at(0).at(0) = 0;

    for (int i = 0; i < lens; i++) {
        for (int j = 0; j < lent; j++) {
            if (s.at(i) == t.at(j)) {
                chmax(dp.at(i + 1).at(j + 1), dp.at(i).at(j) + 1);
                prev_ij.at(i + 1).at(j + 1) = make_pair(i,j);
            }
            if (dp.at(i + 1).at(j + 1) < dp.at(i + 1).at(j)) {
                chmax(dp.at(i + 1).at(j + 1), dp.at(i + 1).at(j));
                prev_ij.at(i + 1).at(j + 1) = make_pair(i + 1, j);
            }
            if (dp.at(i + 1).at(j + 1) < dp.at(i).at(j + 1)) {
                chmax(dp.at(i + 1).at(j + 1), dp.at(i).at(j + 1));
                prev_ij.at(i + 1).at(j + 1) = make_pair(i, j + 1);
            }
        }
    }


    int i = lens;
    int j = lent;
    string ans;
    while(i > 0 && j > 0) {
        if (dp.at(i).at(j) == dp.at(i - 1).at(j)) i--;
        else if (dp.at(i).at(j) == dp.at(i).at(j - 1)) j--;
        else {
            i--; j--;
            ans = s.at(i) + ans;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 106752
N,Y = map(int,input().split())

for i in range(N+1):
  for s in range(N+1):
    k = N-i-s
    if k>=0 and 1000*i+5000*s+10000*k==Y:
      print(k,s,i)
      exit()

print(-1,-1,-1)

Measured memory_bytes: 9144
n, t = map(int, input().split())
time = list(map(int, input().split()))
ans, pre = 0, 0

if n == 1:
    print(t)
    exit()

pre = time[0]

for i in range(n):
    if i == 0:
        pass
    else:
        dist = time[i] - pre
        if dist > t:
            ans += t
        else:
            ans += dist
        if i == n-1:
            ans += t
        pre = time[i]

print(ans)        

Measured memory_bytes: 25200
/*Made by Shivam Solanki*/
#include<bits/stdc++.h> 
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define ll long long int
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<pii> vp;
typedef vector<pll> vpll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef set<int> sii;
typedef set<ll> sll;
typedef priority_queue<int> pq;
typedef unordered_map<int,int> umii;
typedef unordered_map<ll,ll> umll;
typedef queue<int> qii;
#define rep(i,k,n) for (int i = k; i < n; ++i) 
#define repr(i,k,n) for (int i = n; i>=k; --i)
#define repll(i,k,n) for (ll i = k; i < n; ++i) 
#define repllr(i,k,n) for (ll i = n; i >= k; --i) 
#define pb push_back
#define mp make_pair
#define gcd __gcd
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int INF = 1e9+5;
const int MOD = 1e9+7;
 
void solve(){
	int n;
	cin>>n;
	map<string,int>m;
	rep(i,0,n){
		string s;
		cin>>s;
		m[s]++;
	}
	int x=0;
	for(pair<string,int>p:m){
		x=max(p.S,x);
	}
	vector<string>ans;
	for(pair<string,int>p:m){
		if(p.S==x){
			ans.pb(p.F);
		}
	}
	sort(all(ans));
	for(string s:ans){
		cout<<s<<'\n';
	}
}
    
int main(){
    // #ifndef ONLINE_JUDGE  
        // freopen("input.txt", "r", stdin); 
        // freopen("output.txt", "w", stdout); 
    // #endif 
    // fastio;
    int t=1;
    // cin>>t;
    while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 26868
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<limits.h>
#include<utility>
#include<vector>
#include<tuple>
#include <map>
#include<algorithm>
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(A) A.begin(),A.end()


int main() {
	double a, b;
	double h, m;
	cin >> a >> b >> h >> m;
	double xa = a * cos(2 * M_PI * m / 60);
	double ya = -a * sin(2 * M_PI * m / 60);
	double xb = b * cos(2 * M_PI * (h / 12 + m / (12 * 60)));
	double yb = -b * sin(2 * M_PI * (h / 12 + m / (12 * 60)));
	printf("%.20f\n", sqrt((xa - xb) * (xa - xb) + (ya - yb) * (ya - yb)));
	//cout << sqrt((xa-xb)* (xa - xb)+(ya-yb)* (ya - yb)) << endl;
}


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

const int INF = 1001001001;

int main(void){
  ll n;
  cin >> n;

  string ans;
  while(n != 0){
    int r = ((n%2)+2)%2;
    ans += (char)r + '0';
    n = -0.5*(n-r);
  }
  reverse(ALL(ans));
  if(ans == "") ans = "0";
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

import static java.lang.Math.PI;

public class Main{
    public static void main(String[] args) {
	try {
	    BufferedReader stdReader = new BufferedReader(new InputStreamReader(System.in));
	    String line;
	    while ((line = stdReader.readLine()) != null) {
		Double r = Double.parseDouble(line);
		System.out.println( String.format("%f %f", PI*r*r, 2*PI*r) );
	    }
	    stdReader.close();
	} catch (Exception e) {
	    System.out.println(Arrays.toString(e.getStackTrace()));
	    System.exit(0);
	}
    }
}

Measured memory_bytes: 24692
#include <iostream>
#include <algorithm>
#include <stdio.h>
using namespace std;
typedef long long ll;
int p = 998244353, dp[3010], n, s, ans, x[3010];
int main()
{
    int n, s;
    scanf("%d%d", &n, &s);
    ll ans = 0;
    for (int i = 1; i <= n; ++i)
    {
        scanf("%d", &x[i]);
        dp[0] = i;
        for (int j = s; j >= x[i]; --j)
            dp[j] = (dp[j] + dp[j - x[i]]) % p;
        ans = (ans + dp[s]) % p;
    }
    cout << ans << endl;
    return 0;
}
// #include <cstdio>
// int p = 998244353, dp[3010], n, s, ans, x[3010];
// int main()
// {
//     scanf("%d%d", &n, &s);
//     for (int i = 1; i <= n; ++i)
//     {
//         scanf("%d", &x[i]);
//         dp[0] = i;
//         for (int j = s; j >= x[i]; --j)
//             dp[j] += dp[j - x[i]];
//         ans = (ans + dp[s]);
//     }
//     printf("%d", ans);
//     return 0;
// }

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
using namespace std;
#define MOD 1000000007
using lint = long long;

lint nPr(lint n, lint r){
    lint sum = 1;
    for(lint i = 0; i < r; i++){
        sum *= (n-i) % MOD;
        sum %= MOD;
    }
    return sum % MOD;
}

lint dfs(const vector<vector<lint>> &nodes, lint v, lint p, lint K)
{
    if(nodes.size() == 1){
        return 1;
    }
    lint sum = nPr(K-2, nodes[v].size()-1);
    sum %= MOD;
    for(int i = 0; i < nodes[v].size(); i++){
        if(nodes[v][i] == p) continue;
        sum *= dfs(nodes, nodes[v][i], v, K);
        sum %= MOD;
    }
    return sum % MOD;
}

int main(void)
{
    lint N, K;
    cin >> N >> K;
    vector<vector<lint>> nodes(N, vector<lint>());
    for(int i = 0; i < N-1; i++){
        lint a, b;
        cin >> a >> b;
        a--;
        b--;
        nodes[a].push_back(b);
        nodes[b].push_back(a);
    }
    lint sum = nPr(K, nodes[0].size()+1) % MOD;
    for(int i = 0; i < nodes[0].size(); i++){
        sum *= dfs(nodes, nodes[0][i], 0, K) % MOD;
        sum %= MOD;
    }
    cout << (sum % MOD) << endl;

    return 0;
}

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

using namespace std;

typedef long long ll;

int N;
int A[100];

void show() {
  for (int i = 0; i < N; i++) {
    printf("%d%c", A[i], i == N-1 ? '\n' : ' ');
  }
}

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

  int cnt = 0;
  for (int i = 0; i < N; i++) {
    int mini = i;
    for (int j = i; j < N; j++) {
      if(A[mini] > A[j]) mini = j;
    }
    if(mini != i) {
      swap(A[mini], A[i]);
      cnt++;
    }
  }

  show();
  printf("%d\n", cnt);
}

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

int main(){
    int n;
    while(cin >> n,n){
        long long sum = 0;
        vector <long long> wait(n);
        for(int i=0;i<n;i++) cin >> wait[i];
        sort(wait.begin(),wait.end());
        for(int i=0;i<n-1;i++) sum += wait[i],wait[i+1] += wait[i];
        cout << sum << endl;
    }
}

Measured memory_bytes: 1296
#include<bits/stdc++.h>
 
#define INF 1000000007
#define LINF 1000000000000000007
 
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> P;


int a[3];

int main(){
	for(int i = 0; i < 3; i++){
		cin >> a[i];
	}
	sort(a, a+3);
	if(a[2] == a[0] + a[1]) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	var a int
	var b int
	var c int
	var d int
	var s string
	fmt.Scan(&n)
	fmt.Scan(&a)
	fmt.Scan(&b)
	fmt.Scan(&c)
	fmt.Scan(&d)
	fmt.Scan(&s)

	ret := "No"
	if c < d {
		sharpTwoFlg := false
		sharpCount := 0
		for i := a; i < c; i++ {
			if s[i] == '#' {
				sharpCount++
				if sharpCount >= 2 {
					sharpTwoFlg = true
					break
				}
			} else {
				sharpCount = 0
			}
		}

		sharpCount = 0
		for i := b; i < d; i++ {
			if s[i] == '#' {
				sharpCount++
				if sharpCount >= 2 {
					sharpTwoFlg = true
					break
				}
			} else {
				sharpCount = 0
			}
		}

		if sharpTwoFlg {
			ret = "No"
		} else {
			ret = "Yes"
		}

	} else {

		dotThreeFlg := false
		sharpTwoFlg := false

		dotCount := 0
		sharpCount := 0
		for i := b - 2; i <= d; i++ {
			if s[i] == '.' {
				dotCount++
				if dotCount >= 3 {
					dotThreeFlg = true
				}
				sharpCount = 0
			} else {
				sharpCount++
				if sharpCount >= 2 {
					sharpTwoFlg = true
					break
				}
				dotCount = 0
			}
		}

		sharpCount = 0
		for i := a; i < c; i++ {
			if s[i] == '#' {
				sharpCount++
				if sharpCount >= 2 {
					sharpTwoFlg = true
					break
				}
			} else {
				sharpCount = 0
			}
		}

		if !sharpTwoFlg && dotThreeFlg {
			ret = "Yes"
		}
	}

	fmt.Println(ret)
}


Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <limits.h>
 
#define YesNo(b) ((b) ? "Yes" : "No")
#define YESNO(b) ((b) ? "YES" : "NO")

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;



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

    int ans = 0;
    for (size_t i = 0; i < S.size() / 2; i++)
    {
        if (S[i] != S[S.size() - 1 - i])
            ++ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
readlines.each{|line|
  yyyy,mm,dd = line.split.map(&:to_i)
  date = "%04d%02d%02d" % [yyyy,mm,dd]
  date = date.to_i
  if date < 18680908
    puts "pre-meiji"
  elsif date < 19120730
    puts "meiji #{yyyy-1867} #{mm} #{dd}"
  elsif date < 19261225
    puts "taisho #{yyyy-1911} #{mm} #{dd}"
  elsif date < 19890108
    puts "showa #{yyyy-1925} #{mm} #{dd}"
  else
    puts "heisei #{yyyy-1988} #{mm} #{dd}"
  end
}

Measured memory_bytes: 8580