akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
const int MAX = 1e5+5;
int mp[30], ok = 1;
char s[MAX];

int main(int argc, char ** argv) {
	scanf(" %s", s);
	rep(i, 0, strlen(s))
	    mp[s[i]-'a']++;
	rep(i, 0, 30) if(mp[i]&1) ok = 0;
	printf("%s\n", ok ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<string>
using namespace std;
int main() {
	//<<<ここにプログラムを書く>>>
	int x,y,z;
	cin >> x >> y >> z;
	if (x < y && y< z)
	{
		cout <<"Yes" << endl;
	}
	else 
	{
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
int main()
{
    // freopen("in.txt", "r", stdin);
    string s;
    while (cin >> s)
    {
        int n = s.length();
        int l = 0, r = n - 1, res = 0;
        while (l < r)
        {
            if (s[l] != s[r]) res++;
            l++; r--;
        }
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)


ll p10[20];
ll temp[20];
ll ans;
void f(ll rest,ll keta,ll c){
	
	if(c>(keta-1)/2){
		//終わり
		ll t=1;
		rep(i,0,c)t*=10-temp[i]-!i;
		ans+=t;
		return;
	}
	int t=(10-rest%10)%10;
	
	//正のとき
	if(llabs(rest-(p10[keta-1-c*2]-1)*t)<p10[keta-1-c*2]){
		temp[c]=t;
		f((rest-(p10[keta-1-c*2]-1)*t)/10,keta,c+1);
	}
	//負のとき
	if(t!=0&&llabs(rest-(p10[keta-1-c*2]-1)*(t-10))<p10[keta-1-c*2]){
		temp[c]=10-t;
		f((rest-(p10[keta-1-c*2]-1)*(t-10))/10,keta,c+1);
	}
}

int main(){
	ll d;
	scanf("%lld",&d);
		
	p10[0]=1;
	rep(i,1,20)p10[i]=p10[i-1]*10;
	
	rep(i,1,19)f(d,i,0);
	printf("%lld",ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
using Graph = vector<vector<int>>;
int main(int argc, const char * argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int a,b;
    cin>>a>>b;
    if((a+b)%2==0)cout<<(a+b)/2<<endl;
    else cout<<(a+b)/2+1<<endl;

    return 0;
}


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

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORTASC(c) sort((c).begin(),(c).end())
#define SORTDESC(c,t) sort((c).begin(),(c).end(), std::greater<t>());
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define VMAX(a) *max_element(ALL(a))
#define VMIN(a) *min_element(ALL(a))
#define OUT(a) cout << (a) << endl;
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double PI  = acos(-1.0);

template <class T, class S>
using umap = std::unordered_map<T, S>;
using ll = long long;
using namespace std;

int main() {
    ll n, m, c, a, ct = 0;
    ll b[200010];

    cin >> n >> m >> c;

    REP(i, m){
      cin >> b[i];
    }

    REP(i, n){
      ll total = 0;
      REP(j, m){
        cin >> a;
        total += a*b[j];
      }

      if (total > -c){
        ct++;
      }
    }

    cout << ct << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cctype>

#include<cmath>
#include<iostream>
#include<fstream>

#include<string>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<sstream>
#include<stack>

using namespace std;


int main()
{

    long long int n,i=0,j,a,b,c,ln,my=0,ck=0;
    int arr[10];

    for(i=0; i<10; i++){
       cin>>arr[i];
    }
    sort(arr, arr+10);

    cout<<arr[9]<<endl;
    cout<<arr[8]<<endl;
    cout<<arr[7]<<endl;
}



Measured memory_bytes: 3116
#include <iostream>
#include <cstdio>
 
using namespace std;
 
int a;
int b;
int k;
 
int main() {
    cin >> a >> b >> k;
    if(b - a < k * 2) {
        for(int j = 0; j < (b - a + 1); ++j){
           printf("%d\n", a + j);
        }
    }
    else {
        for(int m = 0; m < k; ++m) {
            printf("%d\n", a + m);
        }
        for(int n = 0; n < k; ++n){
            printf("%d\n", b - k + n + 1);
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=400005;
struct Gragh{
	int cnt,y[N],z[N],nxt[N],fst[N];
	void clear(){
		cnt=0;
		memset(fst,0,sizeof fst);
	}
	void add(int a,int b,int c){
		y[++cnt]=b,z[cnt]=c,nxt[cnt]=fst[a],fst[a]=cnt;
	}
}g;
int n,m;
int q[N],head,tail;
LL dis[N];
LL INF=10000000000000000LL;
void out0(){
	puts("0");
	exit(0);
}
void SPFA(int S){
	for (int i=1;i<=n*2;i++)
		dis[i]=INF;
	head=tail=0;
	q[++tail]=S;
	dis[S]=0;
	while (head!=tail){
		int x=q[++head],y;
		for (int i=g.fst[x];i;i=g.nxt[i]){
			int y=g.y[i];
			if (dis[y]!=dis[x]+g.z[i]){
				if (dis[y]!=INF)
					out0();
				dis[y]=dis[x]+g.z[i];
				q[++tail]=y;
			}
		}
	}
}
int main(){
	scanf("%d%d",&n,&m);
	g.clear();
	for (int i=1;i<=m;i++){
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		g.add(a,b+n,-c);
		g.add(b+n,a,c);
		g.add(b,a+n,-c);
		g.add(a+n,b,c);
	}
	SPFA(1);
	LL v=INF;
	for (int i=1;i<=n;i++)
		if (dis[i]!=INF&&dis[i+n]!=INF){
			LL A=dis[i],B=dis[i+n];
			if ((A+B)%2LL)
				out0();
			LL x=-(A+B)/2LL;
			if (x!=v)
				if (v==INF)
					v=x;
				else
					out0();
		}
	if (v!=INF){
		int f=1;
		for (int i=1;i<=n;i++){
			if (dis[i]!=INF)
				if (v+dis[i]<=0)
					f=0;
			if (dis[i+n]!=INF)
				if (v+dis[i+n]>=0)
					f=0;
		}
		printf("%d",f);
		return 0;
	}
	LL MIN=1,MAX=INF;
	for (int i=1;i<=n;i++)
		if (dis[i]!=INF)
			MIN=max(MIN,-dis[i]+1);
		else
			MAX=min(MAX,-dis[i+n]-1);
	printf("%lld",max(MAX-MIN+1,0LL));
	return 0;
}

Measured memory_bytes: 10752
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

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

int main(){
	int N;
	vi arr;
	arr.reserve(101);
	cin>>N;
	int sum = 0;

	REP(i,N){
		int a;
		cin>>a;
		arr.push_back(a);
		sum += a;
	}

	int mu = sum/N;
	int kai_2 = mu + 1;
	int cost1 = 0,cost2 = 0;
	REP(i,N){
		cost1 += (arr[i] - mu)*(arr[i] - mu); 
	}
	REP(i,N){
		cost2 += (arr[i] - kai_2)*(arr[i] - kai_2); 
	}
	cout<<min(cost1,cost2)<<endl;
	return 0;
}



Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
public class Main {
    static boolean[][] used;
    static int[] ans;
    public static void main(String[] args) throws Exception {
        long max = 100000 * 20000000000L;
        FastScanner sc = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int n = sc.nextInt();
        int k = sc.nextInt();
        long[] a = sc.nextLongArray(n);
        long ans = 0;
        for(int i = 0; i <= k; i++){
            for(int j = 0; j <= k-i; j++){
                if(i+j > n) continue;
                long now = 0;
                int d = k-i-j;
                ArrayList<Long> li = new ArrayList<>();
                for(int l = 1; l <= i; l++){
                    now += a[l-1];
                    li.add(a[l-1]);
                }
                for(int r = 1; r <= j; r++){
                    now += a[n-r];
                    li.add(a[n-r]);
                }
                Collections.sort(li);
                for(int v = 0; v < d; v++){
                    if(v >= li.size()) break;
                    if(li.get(v) >= 0) break;
                    now -= li.get(v);
                }
                ans = Math.max(ans,now);
            }
        }
        System.out.println(ans);
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

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

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

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

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}




Measured memory_bytes: 22740
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath> // 変数名にy1が使えなくなるかも…。
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <string>

typedef __int128_t int128_t;
std::istream &operator>>(std::istream& input, int128_t& value) { // int128_tの入力。入力が64bitに収まる前提。
    long long tmp; input >> tmp; value = tmp;
    return input;
}
std::ostream &operator<<(std::ostream& output, const int128_t value) { // int128_tの出力。出力が64bitに収まる前提。
    output << (long long)value;
    return output;
}

int grundy(int X, int K) {
    //std::cout << X << " " << K << std::endl;
    if (X < K) { return 0; }

    int r = X % K;
    int q = X / K;    
    if (r % (q + 1) == 0) { return q; }

    X = q * K + r % (q + 1);
    return grundy(X - (q+1), K);
}

const int MAX_N = 210;
int N;
int A[MAX_N], K[MAX_N];

int main(int argc, char **argv) {
    std::cin >> N;
    
    for (int i = 1; i <= N; i++) {
        std::cin >> A[i] >> K[i];
    }

    int g = 0;

    for (int i = 1; i <= N; i++) {
        //std::cout << "---" << std::endl;
        //std::cout << grundy(A[i], K[i]) << std::endl;
        g ^= grundy(A[i], K[i]);
    }

    if (g == 0) {
        std::cout << "Aoki" << std::endl;
    } else {
        std::cout << "Takahashi" << std::endl;
    }
    
    return 0;
}


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

#define N_MAX 110000

void dump(vector<int>& v,int n){

	  for(int i=0; i<min(n,(int)v.size()); i++)
			cout << v[i] <<  " ";
	  cout << endl;
}

int main(){
	  
	  bool is_pri[N_MAX] = {false};
	  vector<int> pri; 

	  for(int i=2; i<N_MAX; i++) is_pri[i] = true;

	  for(int i=2; i<N_MAX; i++){
			if( is_pri[i] ) {
				  for(int j=2; j*i<N_MAX; j++)
						is_pri[i*j] = false;
				  pri.push_back(i);
			}
	  }

	  

	  int N,P;
	  while(cin >> N >> P){
			if(N==-1) break;

			int first = upper_bound(pri.begin(),pri.end(),N) - pri.begin();

			vector<int> ans(P,INT_MAX);
			for(int i=first; i<min(first+P,(int)pri.size()); i++){
				  for(int j=i; j<min(first+P,(int)pri.size()); j++){

						ans.push_back(pri[i]+pri[j]);
						sort(ans.begin(),ans.end());
						ans.pop_back();

						
				  }
			}
			cout << ans[P-1] << endl;
	  }

}

Measured memory_bytes: 1440
N = int(input())
F = []
for _ in range(N):
    F.append(input().split())
P = []
for _ in range(N):
    P.append(list(map(int,input().split())))

def return_C(i, List):
    j = ''.join(List)
    j = int(j, 2)
    AND = i & j
    return bin(AND).count('1')

ans = - 10 ** 10
for i in range(1, 2 ** 10):
    temp = 0
    for j in range(N):
        c = return_C(i, F[j])
        temp += P[j][c]
    ans = max(ans, temp)

print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<cstring>
using namespace std;
string s;
int l;
int main()
{
	cin>>s;
	l=s.size();
	if(s[0]==s[l-1])
	{
		if(l%2==0) cout<<"First";
		else cout<<"Second";
		return 0;
	}
	else
	{
		if(l%2==0) cout<<"Second";
		else cout<<"First";
		return 0;
	}
}

Measured memory_bytes: 512
from collections import deque

H,W = map(int, input().split())
Ch, Cw = map(int, input().split())
Dh, Dw = map(int, input().split())
Ch -= 1
Cw -= 1
Dh -= 1
Dw -= 1

squares = []
for i in range(H):
    squares.append([None]*(W))

for i in range(H):
    s = input()
    for j in range(W):
        if s[j] == '#':
            squares[i][j] = -1  # Wall

squares[Ch][Cw]=0

d1 = deque()
d2 = deque()
d1.append([Ch, Cw])

warps = 0

def visit(i1, j1, i2, j2, with_warp = False):  # (i1,j1) to (i2,j2)
    if i2 < 0 or i2 >= H or j2 < 0 or j2 >= W:
        return
    sq2 = squares[i2][j2]
    if sq2 == None:
        if with_warp:
            squares[i2][j2] = warps + 1  # sq2 = warps + 1 <- doesn't work
        else:
            squares[i2][j2] = warps  # sq2 = warps <- doesn't work
        d1.append([i2, j2])
        if i2 == Dh and j2 == Dw:
            print(squares[i2][j2])
            exit()

while (len(d1)>0):
    while (len(d1)>0):
        src = d1.popleft()
        visit(src[0], src[1], src[0] - 1, src[1])
        visit(src[0], src[1], src[0] + 1, src[1])
        visit(src[0], src[1], src[0], src[1] - 1)
        visit(src[0], src[1], src[0], src[1] + 1)
        d2.append(src)

    while (len(d2)>0):
        src = d2.popleft()
        for i in range(-2,3):
            for j in range(-2,3):
                visit(src[0], src[1], src[0]+i, src[1]+j, True)

    warps += 1

print(-1)


Measured memory_bytes: 104036
package main

import "fmt"

func Otoshidama(N, Y int) (int, int, int) {
	var x, y, z, tmp int

	for i := 0; i <= N; i++ {
		tmp = Y - 10000 * i
		rest := N - i
		for j := 0; j <=rest; j++ {
			if tmp == 5000 * j + 1000 * (rest -j){
				x, y, z = i, j, rest-j
				return x, y, z
			}
		}
	}
	return -1, -1, -1
}

func main() {
  	var N, Y int
	fmt.Scan(&N, &Y)
	x, y, z := Otoshidama(N, Y)
	fmt.Println(x, y, z)
}

Measured memory_bytes: 512
#include<iostream>
#include<queue>
#include<utility>
#define F first
#define S second
using namespace std;
typedef pair< int, int >p;//first = node , second = time

bool g[101][101];
int t[101];

main()
{
  int n, u, k, v;
  queue<p>que;

  cin >> n;

  for ( int i = 0; i < n ; ++i) {
    t[i] = -1;
    for(int j = 0; j < n ; ++j) {
      g[i][j] = false;
    }
  }
  
  for (int i = 0; i < n ; ++i) {
    cin >> u >> k; --u;
    
    for (int j = 0; j < k ; ++j) {
      cin >> v; --v;
      g[u][v] = true;
    }
  }

  que.push(p(0,0));
  t[0] = 0;
  while ( !que.empty() ) {
    p now = que.front(); que.pop();
    
    int pos = now.F;
    int time = now.S;
    
    for ( int i = 0; i < n ; ++i) {
      if ( g[pos][i] && t[i] == -1 ) {
	t[i] = time + 1;
	que.push(p(i,time+1));
      }
    }
  }

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



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

int N, R;

int main()
{
	scanf("%d%d", &N, &R);
	if(N < 10)
		printf("%d\n", R + 100 * (10 - N));
	else
		printf("%d\n", R);

	return 0;
}

Measured memory_bytes: 256
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n,m = readInts()
box = [1] * n
In = [False] * n
In[0] = True
for i in range(m):
    x,y = readInts()
    if In[x-1]:
        box[x-1] -= 1
        if box[x-1] == 0:
            In[x-1] = False
        box[y-1] += 1
        In[y-1] = True
    else:
        box[x-1] -= 1
        box[y-1] += 1
cnt = 0
for i in range(n):
    if In[i]:
        cnt += 1
print(cnt)


Measured memory_bytes: 11656
#include <iostream>

using namespace std;

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

    int ans = -1;
    if (a > 0 && a <= 9 && b > 0 && b <= 9)
    {
        ans = a * b;
    }

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

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

int main()
{
    int x, n; cin >> x >> n;
    set<int> s;
    int tmp;
    rep(i,n) {
        cin >> tmp;
        s.insert(tmp);
    }

    int ans_p = 0,ans_m = 0;

    for(int i = x; i <= 101; i++) {
        if(s.count(i)) {
            continue;
        } else {
            ans_p = i;
            break;
        }
    }
    for(int i = x; i >= 0; i--) {
        if(s.count(i)) {
            continue;
        } else {
            ans_m = i;
            break;
        }
    }

    if( abs(x - ans_p) < abs(x - ans_m) ) {
        cout << ans_p << endl;
    } else {
        cout << ans_m << endl;
    } 
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<long long,int> P;

int main(){
    int n, m;
    cin >> n >> m;
    int array[n];
    rep(i, n) array[i] = i;

    bool g[n][n];
    rep(i,n) rep(j,n) g[i][j] = false;

    rep(i, m){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a][b] = true;
        g[b][a] = true;
    }

    int cnt = 0;
    do{
        bool flag = false;
        for(int i=0; i<n-1; i++){
            if (array[0] != 0 || !g[array[i]][array[i+1]]) flag = true;
        }
        if (!flag) cnt ++;
    }while(next_permutation(array,array+n));

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
N=int(input())
nums=list(map(int,input().split()))

over=False
all_su=sum(nums)
su=0
for i in range(N):
  nsu=su+nums[i]
  if nsu>all_su/2:
    break
  else:
    su=nsu
if all_su/2-su > nsu-all_su/2:
  print(2*nsu-all_su)
else:
  print(all_su-2*su)

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

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> adj(n);
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  } 
  queue<int> q;
  q.push(0);
  vector<bool> vis(n);
  vector<int> res(n);
  vis[0] = true;
  while (!q.empty()) {
    int cur = q.front();
    q.pop();
    for (int node : adj[cur]) {
      if (!vis[node]) {
        res[node] = cur + 1;
        vis[node] = true;
        q.push(node);
      }
    }
  }
  cout << "Yes\n";
  for (int i = 1; i < n; i++)
    cout << res[i] << "\n"[i == n - 1];
  return 0;
}

Measured memory_bytes: 10312
N = int(input())
t = [int(Ti) for Ti in input().split()]
v = [int(Vi) for Vi in input().split()]

v_max = [0]
for ti, vi in zip(t, v):
    v_max[-1] = min(v_max[-1], vi)
    for _ in range(2*ti):
        v_max.append(vi)

for i in range(len(v_max)-1):
    v_max[i+1] = min(v_max[i] + 0.5, v_max[i+1])

v_max[-1] = 0
for i in range(len(v_max)-2, -1, -1):
    v_max[i] = min(v_max[i], v_max[i+1] + 0.5)

area = 0
for i in range(len(v_max) - 1):
    area += 0.5 * 0.5 * (v_max[i] + v_max[i+1])

print(area)


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

using namespace std;

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

	int n;
	string s;
	string t;

	cin >> n;
	cin >> s;

	if(n%2==1)
	{
		cout << "No" << '\n';
	}
	else
	{
		t = s.substr(0,n/2);
		t = t + t;
		if(s==t)
		{
			cout << "Yes" << '\n';
		}
		else
		{
			cout << "No" << '\n';
		}
	}
	return 0;
}


Measured memory_bytes: 3600
import math
def py():
    print("Yes")
def pn():
    print("No")
def iin():
    x = int(input())
    return x

neko = 0
nya = 0
nuko = 0
a,b = input().split()
neko = int(a + b)
for i in range(1000):
    if i*i == neko:
        py()
        nya = 1
        break

if(nya == 0):
    pn()

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

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

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
	int n, k, q;
	cin >> n >> k >> q;
	int count[N];
	rep1(i, n) count[i] = 0;
	rep(i, q) {
		int a;
		cin >> a;
		count[a]++;
	}
	rep1(i, n) {
		cout << (k - q + count[i] > 0 ? "Yes" : "No") << endl;
	}
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(){
    int H,W;
    while(true){
        scanf("%d %d",&H,&W);
        if(H==0 && W==0)break;
        
        for(int y=0;y<H;y++){
            for(int x=0;x<W;x++){
                if((x+y)%2==0)printf("#");
                else if((x+y)%2==1)printf(".");
            }
            printf("\n");
        }
        printf("\n");
    }
}


Measured memory_bytes: 2696
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define krep(i,k,n,m) for(int i=k;i<n;i+=m)
#define erep(i,k,n) for(int i=k;i<n;i++)
#define mod 1000000007;
//最大公約数
int gcd(int s,int b){
    if(b==0)return s;
    return gcd(b,s%b);
}
signed main() {
    int n;
    cin>>n;
    if(n%2==0){
        cout<<0.5<<endl;
    }
    else{
        cout<<(n+1.0)/2.0/n<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)


int main(){
    int n, m, X, Y;
    cin >> n >> m >> X >> Y;
    vector<int> x(n+1);
    vector<int> y(m+1);
    for(int i = 0; i < n; i++){
        cin >> x[i];
    }
    for(int i = 0; i < m; i++){
        cin >> y[i];
    }
    x[n] = X;
    y[m] = Y;
    sort(x.begin(),x.end());
    sort(y.begin(),y.end());
    if(x[x.size()-1]<y[0]){
        cout << "No War" << endl;
    }else{
        cout << "War" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int maxn = (int) 1e5 + 5, mod = (int) 1e9 + 7;
int n;
int a[maxn], b[maxn];

int read() {
  if (scanf("%d", &n) < 1) {
    return false;
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &b[i]);
  }
  return true;
}

void solve() {
  sort(a, a + n);
  sort(b, b + n);
  int cnta = 0, cntb = 0;
  int res = 1;
  for (int ia = 0, ib = 0; ia < n || ib < n;) {
    if (ia < n && (ib == n || a[ia] < b[ib])) {
      if (cntb) {
        res = ((long long) res * cntb) % mod;
        cntb--;
      } else {
        cnta++;
      }
      ia++;
    } else {
      if (cnta) {
        res = ((long long) res * cnta) % mod;
        cnta--;
      } else {
        cntb++;
      }
      ib++;
    }
  }
  printf("%d\n", res);
}

int main() {
  precalc();
#ifdef LOCAL
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (true) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<string> S(N);
  for (int i = 0; i < N; i++) {
    cin >> S.at(i);
  }
  vector<int> C(4);
  for (int i = 0; i < N; i++) {
    string Sn = S.at(i);
    if (Sn == "AC") {
      C.at(0)++;
    }
    else if (Sn == "WA") {
      C.at(1)++;
    }
    else if (Sn == "TLE") {
      C.at(2)++;
    }
    else {
      C.at(3)++;
    }
  }
  cout << "AC x " << C.at(0) << endl;
  cout << "WA x " << C.at(1) << endl;
  cout << "TLE x " << C.at(2) << endl;
  cout << "RE x " << C.at(3) << endl;

  return 0;
}

Measured memory_bytes: 6392
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <string>
#include <cmath>
#include <map>
#include <iomanip>
#include <utility>
#define INF 1000000009
#define LINF 1000000000000000009
#define double long double
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;
typedef pair<ll, double> PD;
//ll mod = 1000000007;
//ll mod = 998244353;

int main() {
	int h, w, a, b;
	cin >> h >> w >> a >> b;
	vector<vector<int>> ans(h, vector<int>(w));
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < a; j++) {
			ans[i][j] = 1;
		}
	}
	for (int j = 0; j < w; j++) {
		for (int i = 0; i < b; i++) {
			ans[i][j] = 1 - ans[i][j];
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cout << ans[i][j];
		}
		cout << endl;
	}
}

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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define REPR(i,a,b) for(ll i=b;i>=a;i--)
#define repr(i,n) REPR(i,0,n)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define fi first
#define se second
#define m_p make_pair

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

    char a,b;
    cin >> a >> b;
    if(a=='H'){
        if(b=='H') cout << 'H' << "\n";
        else cout << 'D' << "\n";
    }else{
        if(b=='H') cout << 'D' << "\n";
        else cout << 'H' << "\n";
    }
    return 0;
}

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

int main(){
  int n;
  cin>>n;
  int a[10000];

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

  int mn = a[0], mx =a[0];

  long long sum = 0;

  for (int i=0; i<n; i++){
    mn = min(mn, a[i]);
    mx = max(mx, a[i]);
    sum += a[i];
  }

  cout<<mn<<" "<<mx<<" "<<sum<<endl;
  

  return 0;
  
}
	


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (ll i=0;i<(n);++i)
const ll MOD=1e9+7;

template<typename T,bool directed>
struct FordFulkerson{
    struct edge{
        int to,rev; T cap;
        edge(int to,T cap,int rev):to(to),cap(cap),rev(rev){}
    };
    vector<vector<edge>> G;
    vector<int> used;
    FordFulkerson(int n):G(n),used(n){}
    int add_edge(int from,int to,T cap){
        G[from].emplace_back(to,cap,G[to].size());
        G[to].emplace_back(from,directed?0:cap,G[from].size()-1);
        return G[to].back().rev;
    }
    T dfs(int v,int t,T f){
        if (v==t) return f;
        used[v]=true;
        for (auto &e:G[v]){
            if (!used[e.to]&&e.cap>0){
                T d=dfs(e.to,t,min(f,e.cap));
                if (d==0) continue;
                e.cap-=d;
                G[e.to][e.rev].cap+=d;
                return d;
            }
        }
        return 0;
    }
    T max_flow(int s,int t,T lim){
        T flow=0;
        while(1){
            fill(used.begin(),used.end(),0);
            T f=dfs(s,t,lim);
            if (f==0) break;
            flow+=f;
            lim-=f;
        }
        return flow;
    }
    T max_flow(int s,int t){
        return max_flow(s,t,numeric_limits<T>::max()/2);
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int V,E; cin >> V >> E;
    FordFulkerson<int,true> ff(V);
    rep(i,E){
        int u,v,c; cin >> u >> v >> c;
        ff.add_edge(u,v,c);
    }
    cout << ff.max_flow(0,V-1) << endl;
}


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


class Main{
    public long luca(int n){
        long l = 2;
        long ln = 1;
        for(int i = 1; i < n;i++){
            long tmp = l;
            l = ln;
            ln = tmp + ln;
            // System.out.println(ln);
        }
        return ln;
    }

    public void run() throws Exception{
        Scanner cin = new Scanner(System.in);
        int arg = cin.nextInt();
        System.out.println(luca(arg));
    }

    public static void main(String[] args) throws Exception{
        new Main().run();
    }
}


Measured memory_bytes: 22996
#  Copyright: this code was written at Dec 30th, 2019. for AtCoder, by Silviase
import math


def is_prime(x):
    if x == 1:
        return False
    for i in range(2, int(math.sqrt(x) + 1)):
        if x % i == 0:
            return False
    return True


n = int(input())
while not is_prime(n):
    n += 1
print(n)


Measured memory_bytes: 38512
def bitsearch(n, a, x):
  mincost = 10**10
  for b in range(2**n):
    bit = format(b, f"0{n}b")
    total = [sum([int(bit[i])*a[i][j] for i in range(n)]) for j in range(m+1)]
    # print(total)
    if min(total[1:]) >= x:
      # print(min(total[1:]), x)
      mincost = min(mincost, total[0])
  if mincost == 10**10:
    return -1
  return mincost

n, m, x = map(int, input().split())
a = []
for i in range(n):
  line = list(map(int, input().split()))
  a.append(line)
print(bitsearch(n, a, x))

Measured memory_bytes: 9168
H,W = map(int, input().split())
c = [ [int(j) for j in input().split()] for _ in range(10)]


from collections import defaultdict
d = defaultdict(int)

dist = [ [float("inf")] * 10 for _ in range(10)]
for i in range(10):
    for j in range(10):
        dist[i][j] = c[i][j]
for k in range(10):
    for i in range(10):
        for j in range(10):
            dist[i][j] = min(dist[i][j], 
                    dist[i][k] + dist[k][j] )


A = [ [int(j) for j in input().split()] for _ in range(H)]
for ai in A:
    for aij in ai:
        d[aij] += 1
ans = 0
for i in range(0,10):
    if i == 1: continue
    ans += d[i]* dist[i][1]
print(ans)





Measured memory_bytes: 40412
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<utility>

using namespace std;

#define SPEEDY cin.tie(0);ios::sync_with_stdio(false);

#define REP(i,n) for(int i=0;i<(n);i++)
#define ARREP(i,n,X) for(int i=0;i<(n);i++)cin>>X[i]
#define FOR(i,X,n) for(int i=(X);i<(n);i++)
#define EREP(i,n) for(int i=1;i<=n;i++)

#define DEB(X) if(mode==1)cout<< #X <<": "<<X<<" ";
#define DEB2(X) if(mode==1)cout<< X <<" ";
#define ARDEB(i,X) if(mode==1)cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define FORDEB(n,X) if(mode==1)for(int i=0;i<(n);i++)ARDEB(i,X)
#define END if(mode==1)cout<<endl;

typedef long long int ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
#define ALL(X) X.begin(),X.end()
struct edge{int to,cost;};
//struct edge{int from,cost,to;};

const int INF=100000000;
int mode=1;

int main(){
	int n,t;
	cin>>n>>t;
	cout<<((n-t>0)? n-t:0)<<endl;
	return 0;
}

Measured memory_bytes: 256
S=str(input())

f=1
s1=S[:int((len(S)-1)/2)]
s2=S[int((len(S)+3)/2-1):]
s2=s2[::-1]

if S!=S[::-1]:
    f=0
if s1!=s1[::-1]:
    f=0
if s2!=s2[::-1]:
    f=0

if f==1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);++i)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int MOD=1e9+7;
const long long INF = 1LL << 60;
int gcd(int a,int b) { return b ? gcd(b,a%b) : a;}
int lcm(int a,int b) { return a/gcd(a,b)*b;}
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
void printb(unsigned int v) {
  unsigned int mask = (int)1 << (sizeof(v) * CHAR_BIT - 1);
  do putchar(mask & v ? '1' : '0');
  while (mask >>= 1);
}
void putb(unsigned int v) {putchar('0'), putchar('b'), printb(v), putchar('\n');}
#define ALL(W) (W).begin(),(W).end()

signed main(){
  int sum,res=0;
  while(cin >> sum && sum!=0){
    res=0;
    rep(i,9){
      int tmp;
      cin >> tmp;
      res+=tmp;
    }
    cout << sum-res << endl;
  }

  return 0;
}



Measured memory_bytes: 3072
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <map>
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int c[3][3],a[2],b[2];
	bool bo = true;
	FOR(i, 0, 3) {
		FOR(j, 0, 3) {
			cin >> c[i][j];
		}
	}
	a[0] = c[1][0] - c[0][0];
	a[1] = c[2][0] - c[1][0];
	b[0] = c[0][1] - c[0][0];
	b[1] = c[0][2] - c[0][1];
	FOR(i, 1, 3) {
		FOR(j, 0, 3) {
			if (j != 0) {
				if (c[i][j] - c[i-1][j] != a[i - 1]) {
					bo = false;
				}
			}
		}
	}
	FOR(i, 0, 3) {
		FOR(j, 1, 3) {
			if (j != 0) {
				if (c[i][j] - c[i][j - 1] != b[j - 1]) {
					bo = false;
				}
			}
		}
	}
	cout << (bo ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>

std::vector<int> primes(const int upper_limit) {
	std::vector<bool> is_prime(upper_limit + 1, true);
	for (auto i = 2; i * i <= upper_limit; ++i) {
		if (is_prime[i]) {
			for (auto j = i * i; j <= upper_limit; j += i) {
				is_prime[j] = false;
			}
		}
	}
	std::vector<int> result;
	for (auto i = 2; i <= upper_limit; ++i) {
		if (is_prime[i]) result.push_back(i);
	}
	return result;
}
std::vector<int> prime_factors(int number, const std::vector<int>& prime) {
	std::vector<int> result;
	for (const auto p : prime) {
		if (number % p == 0) {
			while (number % p == 0) {
				number /= p;
			}
			result.push_back(p);
		}
		if (p * p > number) {
			if (number != 1) result.push_back(number);
			return result;
		}
	}
	if (number != 1) result.push_back(number);
	return result;
}
long long int sum_if_friend_with(const int k, const std::vector<int>& number) {
	long long int result = 0;
	for (const auto n : number) if (n % k == 0) result += n;
	return result;
}
int main() {
	auto prime = primes(static_cast<int>(std::ceil(std::sqrt(1001000000))));
	int n; std::cin >> n;
	std::vector<int> number(n); for (auto& a : number) std::cin >> a;
	std::vector<std::vector<int>> factors(n); for (auto i = 0; i < n; ++i) factors[i] = prime_factors(number[i], prime);
	std::set<int> all_factors;
	for (const auto& factor : factors) 
		for (const auto f : factor)
			all_factors.insert(f);
	long long int max = 0LL;
	for (const auto f : all_factors) {
		max = std::max(max, sum_if_friend_with(f, number));
	}
	std::cout << max << std::endl;
}




Measured memory_bytes: 3228
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	a, b := nextInt(), nextInt()

	if b % a == 0 {
		fmt.Println(a + b)
	} else {
		fmt.Println(b - a)
	}
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
int main(void) {
	char s[200];
	int i, j;
	scanf("%s", s);
	for (i = 0; s[i] != '\0'; i++) {
	}
	i--;
	while (1) {
		if(j==i/2)break;
		i--;
		if (i % 2 == 0) continue;

		for (j = 0; j < i / 2 + 1; j++) {
			if (s[j] != s[i / 2 + 1 + j]) break;
			else if (j == i / 2) {
				printf("%d\n", (j + 1) * 2);
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 128
/*..................................
manojeet24
....................................*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fl(i,a,b) for(int i=a;i<b;i++)
#define flr(i,a,b) for(int i=a;i>b;i--)
#define INF INT_MAX
int dp[100005],h[100005];
int solve(int n)
{
    if(dp[n]!=INF)
        return dp[n];
    if(n==0)
    {
        dp[n]=0;return dp[n];
    }
    if(n==1)
    {
        dp[n]=abs(h[1]-h[0]);
        return dp[n];
    }
    return dp[n]=min(abs(h[n]-h[n-1])+solve(n-1),abs(h[n]-h[n-2])+solve(n-2));

}
int main()
{
    int n;
    cin>>n;
   //a int h[n];
    fl(i,0,n)
    {
        cin>>h[i];
    }
    fl(i,0,n)
        dp[i]=INF;
    solve(n-1);
    cout<<dp[n-1];
}



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

int main() {
    int X, f_X, N;
    cin >> X;
    
    N = X;

    f_X = 0;

    while (X >= 10) {
        f_X += X % 10;
        X /= 10;
    }

    f_X += X;

    if (N % f_X == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>

using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
const ll MOD = 1000000007;
const int MAX = 100000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }


int main(){
    int N; cin>>N;
    map<string,int> m;
	vector<string> S(N);
    int max=-1;
    for(int i=0;i<N;i++){
        string tmp;
        cin >> tmp;
      	S[i] = tmp;
        int c=m[tmp];
        //cerr << tmp << " " << m[tmp]  << endl;
        m[tmp] = c+1;
        if(max<c+1) max = c+1;

    }
  	sort(S.begin(),S.end());
    //cerr << max << "\n";
    for(auto i=m.begin();i!=m.end();i++){
        //cerr << i->first << "\t" << i->second << endl;
        if(i->second == max) cout << i->first << "\n";
    }

    return 0;
}


Measured memory_bytes: 22272
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node {
	int key;
	Node* next, * prev;
};

Node* nil;

Node* listSearch(int key){
	Node* cur = nil->next;
	while (cur != nil&&cur->key!=key) {
		cur = cur->next;
	}
	return cur;
}

void init() {
	nil = (Node*)malloc(sizeof(Node));
	nil->next = nil;
	nil->prev = nil;
}

void printList() {
	Node* cur = nil->next;
	int isf = 0;
	while (1) {
		if (cur == nil) {
			break;
		}
		if (isf++ > 0) {
			printf(" ");
		}
		printf("%d", cur->key);
		cur = cur->next;
	}
	printf("\n");
}

void deleteNode(Node* t) {
	if (t == nil) {
		return;
	}
	t->prev->next = t->next;
	t->next->prev = t->prev;
	free(t);
}

void deleteFirst() {
	deleteNode(nil->next);
}

void deleteLast() {
	deleteNode(nil->prev);
}

void deleteKey(int key) {
	deleteNode(listSearch(key));
}

void insert(int key) {
	Node* x = (Node*)malloc(sizeof(Node));
	x->key = key;
	x->next = nil->next;
	nil->next->prev = x;
	nil->next = x;
	x->prev = nil;
}

int main() {
	int key, n, i;
	int size = 0;
	char com[20];
	int np = 0, nd = 0;
	scanf("%d", &n);
	init();
	for ( i = 0; i < n; i++){
		scanf("%s%d", com, &key);
		if (com[0] == 'i') {
			insert(key);
			np++;
			size++;
		}
		else if (com[0]=='d') {
			if (strlen(com) > 6) {
				if (com[6] == 'F') {
					deleteFirst();
				}
				else if (com[6] == 'L') {
					deleteLast();
				}
			}
			else {
				deleteKey(key);
				nd++;
			}
				size--;
		}
	}
	printList();
	return 0;
}


Measured memory_bytes: 33824
n = int(input())

C = [[0]*10 for i in range(10)]

for i in range(1, n+1):
    a = int(str(i)[0])
    b = int(str(i)[-1])
    
    C[a][b] += 1
        
answer = sum([C[i][j]*C[j][i] for i in range(10) for j in range(10)])

print(answer)

Measured memory_bytes: 3064
#include <iostream>
#include <map>
#include <ctime>
#include <vector>
#include <climits>
#include <algorithm>
#include <random>
#include <cstring>
#include <cstdio>
#include <map>
#include <set>
#include <bitset> 
#include <queue>
#define inf 0x3f3f3f3f
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define rep(i, a, n) for(register int i = a; i <= n; ++ i)
#define per(i, a, n) for(register int i = n; i >= a; -- i)
#define ONLINE_JUDGE
using namespace std;
typedef long long ll;
const int mod=1e9+7;
template<typename T>void write(T x)
{
    if(x<0)
    {
        putchar('-');
        x=-x;
    }
    if(x>9)
    {
        write(x/10);
    }
    putchar(x%10+'0');
}
 
template<typename T> void read(T &x)
{
    x = 0;char ch = getchar();ll f = 1;
    while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
    while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;};
ll ksm(ll a,ll n){//看是否要mod 
	ll ans=1;
	while(n){
		if(n&1) ans=(ans*a)%mod;
		a=a*a%mod;
		n>>=1;
	}
	return ans%mod;
}
//==============================================================
const int maxn=105;
map<int,int> cnt;


int main()
{
	#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	//===========================================================
	int n,x;
    read(x),read(n);
    rep(i,1,n){
        int t;
        read(t);
        cnt[t]++;
    }
    int pos=inf,ans=-100;
    rep(i,-5,110){
        if(abs(i-x)<pos&&cnt[i]==0){
            ans=i;
            pos=abs(i-x);
        }
    }
    write(ans);
	//===========================================================
	return 0;
}

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

int main() {
    string s;
    cin >> s;
    int n = s.size();
    reverse(s.begin(), s.end());
    int i = 0;
    while (i < n) {
        if (s.substr(i, 5) == "maerd") i += 5;
        else if (s.substr(i, 5) == "esare") i += 5;
        else if (s.substr(i, 6) == "resare") i += 6;
        else if (s.substr(i, 7) == "remaerd") i += 7;
        else break;
    }
    if (i == n) printf("YES\n");
    else printf("NO\n");
    return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		long dp[] = new long[n * n];
		for ( int i = 0; i < n; i++ ) {
			dp[ i*n + i] = in.nextInt();
		}
		in.close();

		for ( int col = 1; col < n; col++ ) {
			int r = 0, c = col;
			while ( c < n ) {
				dp[ r*n + c] = Math.max(dp[ r*n + r] - dp[ (r + 1)*n + c], dp[ c*n + c] - dp[ r*n + c - 1]);
				r++;
				c++;
			}
		}
		System.out.println(dp[n - 1]);
	}
}

Measured memory_bytes: 98028
n = int(input())

s = input()


white = s.count('.')

lb = 0
rw = white


ans = rw + lb;

for c in s:

    if c == '.':
        rw -= 1
    else:
        lb += 1

#    print((lb,rw))
    t = rw + lb 

    ans = min(t, ans)

print(ans)

Measured memory_bytes: 3500
from heapq import heappush,heappop


def int_raw():
    return int(input())

def ss_raw():
    return input().split()

def ints_raw():
    return list(map(int, ss_raw()))


def runLength(in_str):
    kukan = 1
    start = 0
    ret = []
    for i in range(1,len(in_str)):
        if in_str[i-1]!=in_str[i]:
            ret.append([in_str[i-1],kukan,start])
            start = i
            kukan=0
        kukan+=1
    ret.append([in_str[-1],kukan,start])
    return ret

N = int_raw()
S= input()
K = int_raw()

def main():
    ans =""
    for c in S:
        if c==S[K-1]:
            ans+=c
        else:
            ans+="*"
    return ans


print(main())



Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

public final class Main {

    public static void main(String[] args) {
        final FastScanner fs = new FastScanner();
        final String s = fs.next();
        final StringBuilder res = new StringBuilder();
        for (char c : s.toCharArray()) {
            if (c == '9') {
                res.append('1');
            } else {
                res.append('9');
            }
        }
        System.out.println(res);
    }

    static final class Utils {
        public static void shuffleSort(int[] arr) {
            shuffle(arr);
            Arrays.sort(arr);
        }

        public static void shuffleSort(long[] arr) {
            shuffle(arr);
            Arrays.sort(arr);
        }

        public static void shuffle(int[] arr) {
            final Random r = new Random();

            for (int i = 0; i <= arr.length - 2; i++) {
                final int j = i + r.nextInt(arr.length - i);
                swap(arr, i, j);
            }
        }

        public static void shuffle(long[] arr) {
            final Random r = new Random();

            for (int i = 0; i <= arr.length - 2; i++) {
                final int j = i + r.nextInt(arr.length - i);
                swap(arr, i, j);
            }
        }

        public static void swap(int[] arr, int i, int j) {
            final int t = arr[i];
            arr[i] = arr[j];
            arr[j] = t;
        }

        public static void swap(long[] arr, int i, int j) {
            final long t = arr[i];
            arr[i] = arr[j];
            arr[j] = t;
        }

        private Utils() {}
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        private String next() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    //noinspection CallToPrintStackTrace
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

        int[] nextIntArray(int n) {
            final int[] a = new int[n];
            for (int i = 0; i < n; i++) { a[i] = nextInt(); }
            return a;
        }

        long[] nextLongArray(int n) {
            final long[] a = new long[n];
            for (int i = 0; i < n; i++) { a[i] = nextLong(); }
            return a;
        }
    }
}


Measured memory_bytes: 32824