akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll k,n;
    cin>>k>>n;
    ll a[n];
    for(ll i=0;i<n;i++)
        cin>>a[i];
    ll maxi=-1;
    for(ll i=1;i<n;i++)
        maxi=max(maxi,a[i]-a[i-1]);
    maxi=max(maxi,a[0]+k-a[n-1]);
    cout<<k-maxi;
}

Measured memory_bytes: 1792
S = input().strip()
p, g = "pg"

score = sum(1 if c==g else 0 for c in S)
G, P = 0, 0

hands = []
lastp = None
for c in S:
    if P == G:
        if c == g:
            hand = g
            score -= 1
        else:
            hand = p
            hands[lastp] = g
            # c == p
            # 過去のP vs G を G vs G : +1 -> 0 = -1
            # 過去のP vs P を G vs P :  0 -> -1 = -1
            score -= 1
            P-=1
            G+=1
    else:
        hand = p
    if hand == g:
        G += 1
    else:
        P += 1
        lastp = len(hands)
    hands.append(hand)
    #print(score, hand, "vs", c, P, G)
#print(S)
#print("".join(hands))
print(score)



Measured memory_bytes: 3956
#include<stdio.h>

int main(){
   int a, b, c;
   scanf("%d %d %d", &a, &b, &c);

   int tmp = a;
   a = b;
   b = tmp;
   tmp = a;
   a = c;
   c = tmp;

   printf("%d %d %d", a, b, c);

   return 0;
}



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

namespace ProblemB
{
    class Program
    {
        static void Main(string[] args)
        {
            var read = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var H = read[0];
            var W = read[1];
            var N = read[2];
            read = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var firstI = read[0];
            var firstJ = read[1];

            var S = Console.ReadLine().ToCharArray();
            var T = Console.ReadLine().ToCharArray();
            var outFromLeft = 0;
            var outFromRight = W + 1;
            var outFromUp = 0;
            var outFromDown = H + 1;
            for(int i = N-1;i>=0;i--)
            {
                if (S[i] == 'L') outFromLeft++;
                if (S[i] == 'R') outFromRight--;
                if (S[i] == 'U') outFromUp++;
                if (S[i] == 'D') outFromDown--;
                if (outFromLeft == W || outFromRight == 1 || outFromUp == H || outFromDown == 1)
                    break;

                if(i>0)
                {
                    if (T[i - 1] == 'L' && outFromRight < W+1) outFromRight++;
                    if (T[i - 1] == 'R' && outFromLeft > 0) outFromLeft--;
                    if (T[i - 1] == 'U' && outFromDown < H+1) outFromDown++;
                    if (T[i - 1] == 'D' && outFromUp>0) outFromUp--;
                }
            }

            if (outFromLeft >= firstJ || outFromRight <= firstJ || outFromUp >= firstI || outFromDown <= firstI)
                Console.WriteLine("NO");
            else
                Console.WriteLine("YES");
        }
    }
}


Measured memory_bytes: 15456
def prime_factor(n):
    factors = []
    for i in range(2,int(n**0.5)+1):
        while n%i==0:
            factors.append(i)
            n = n//i
    if n!=1:
        factors.append(n)
    return factors

A,B = map(int,input().split())
li = list(set([1] + prime_factor(A) + prime_factor(B)))
count = 0
for i in li:
    if A%i==0 and B%i==0:
        count += 1
print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

ll cnt[200010];

int main(){
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cnt[i%k]++;
    }

    ll ans=0;
    int x,y,z;
    for(int a=1;a<=n;a++){
        x=a%k;
        if(x==0) y=0;
        else y=k-x;
        if(y==0) z=0;
        else z=k-y;
        //cout<<x<<" "<<y<<" "<<z<<endl;
        if((z+x)%k!=0) continue;
        ans+=cnt[y]*cnt[z];
    }

    cout<<ans<<endl;

}


Measured memory_bytes: 4360
#include<bits/stdc++.h>
using namespace std;
#define min(a,b) ((a>b)? b:a)
int main()
{
  int n,m;
  cin>>n>>m;
  vector<pair<int,int>> student;
  for(int i=0;i<n;i++){
    int a,b;
    cin>>a>>b;
    student.push_back(make_pair(a,b));
  }
  vector<pair<int,int>> point;
  for(int i=0;i<m;i++){
    int c,d;
    cin>>c>>d;
    point.push_back(make_pair(c,d));
  }
  
  for(int i=0;i<n;i++){
    vector<int> diff={};
    for(int j=0;j<m;j++){
      int tmp=abs(student[i].first-point[j].first)+abs(student[i].second-point[j].second);
      diff.push_back(tmp);
    }
    int p=min_element(diff.begin(),diff.end())-diff.begin();
    cout<<p+1<<endl;
  }
}

Measured memory_bytes: 256
/*
    NEVER GIVE UP!
    THE EXPERT IN ANYTHING WAS ONCE A BEGINNER
*/

#pragma GCC optimize("unroll-loops", "omit-frame-pointer","inline")
#pragma GCC option("arch=native","tune=native","no-zero-upper")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define f(i,a,b) for(ll i=a; i<=b; i++)
#define fi(i,a,b) for(ll i=a; i>=b; i--)
#define fa(x,b) for(auto x:b)
#define TC ll test_case; cin>>test_case; for(ll number=1 ; number <= test_case ; number ++ )
#define vll vector<ll>
#define pb push_back
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (ll)(a).size()
#define sp(x) cout << fixed << setprecision(x);
#define ReadFile freopen("input.txt","r",stdin)
#define WriteFile freopen("output.txt","w",stdout)
#define endl "\n"

const ld pi = acos(-1);
const ll M=1e9+7,N=1e7+5,INF=1e18;


void solve()
{
    ll h,n,s=0;
    cin >> h >> n;
    vll a(n);

    f(i,0,n-1)
        cin >> a[i],
        s+=a[i];
    if(s>=h)
        cout << "Yes";
    else 
        cout << "No";

}

int32_t main()
{
    FIO
    solve();
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#define H 2000000

void insert(int);
int extract();
void heapIncreaseKey(int i, int);
void buildMaxHeap(int *);
void maxHeapify(int *, int);
int parent(int);
int left(int);
int right(int);

int size = 1;
int S[H];

int main(){

  int i = 0;
  char com[10];
  int key = 0, dkey = 0;
  
 
  while(1){
    scanf("%s",com);
    //printf("%c\n",com[0]);
    if(com[0] == 'e' && com[1] == 'n')break;
    if(com[0] == 'i'){
      scanf("%d",&key);
      insert(key);
      //printf("fds\n");
    }
    if(com[0] == 'e' && com[1] == 'x'){
      dkey = extract();
      printf("%d\n",dkey);
      //printf("hgf\n");
    }
  }
  
  return 0;
}

void insert(int k){
  size++;
  S[size] = -1;
  heapIncreaseKey(size,k);
}

int extract(){
  int max = 0;
  
  if(size < 1){
    printf("heap underflow\n");
  }
  max = S[1];
  S[1] = S[size--];
  maxHeapify(S, 1);
  return max;
}

void heapIncreaseKey(int i,int key){
  int keep = 0;
  
  if(key < S[i]){
    printf("new key is smaller than current key\n");
  }
  S[i] = key;
  while(i > 1 && S[parent(i)] < S[i]){
    keep = S[i];
    S[i] = S[parent(i)];
    S[parent(i)] = keep;
    i = parent(i);
  }
}

void buildMaxHeap(int *A){
  int i = 0;
  
  for(i = size/2; i >= 1; i--){
    maxHeapify(A,i);
  }
}

void maxHeapify(int *A, int i){
  int l = left(i), r = right(i), largest = 0;
  int keep = 0;

  //left, right and me top of the world
  if(l <= size && A[l] > A[i]){
    largest = l;
  }
  else{
    largest = i;
  }

  if(r <= size && A[r] > A[largest]){
    largest = r;
  }

  if(largest != i){
    //A[i] koukan A[largest]
    keep = A[i];
    A[i] = A[largest];
    A[largest] = keep;
    maxHeapify(A, largest);
  }
}

int parent(int i){
  return i/2;
}

int left(int i){
  return i*2;
}

int right(int i){
  return i*2+1;
}



Measured memory_bytes: 5600
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"

using namespace std;

typedef long int li;
typedef long double ld;
typedef long long ll;
typedef pair<ll, ll> pt;

#define fi first
#define se second
#define lson (p<<1)+1
#define rson (p<<1)+2
#define dump(x) cout << #x << " = " << x << endl
#define comb(x) ((x * (x + 1)) >> 1)
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

ll n, res;
string s;

int main () {
    fastIO
    cin >> n >> s;
    for(li i = 1; i < n; i ++) {
        if(s[i] != s[i - 1]) res ++;
    }
    cout << res + 1;
}


Measured memory_bytes: 512
def solve():
    N = int(input())
    
    A = []
    
    for i in range(1,N+1):
        s, p = input().split()

        A.append((s, -int(p), i))

    A.sort()
    
    for i in range(N):
        print (A[i][2])
    
if __name__ == "__main__":  
    solve() 

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

using namespace std;

int main(void) {
  int N, M;
  cin >> N >> M;

  int temp;
  int total = 0;
  for (int i = 0;i < M;i++) {
    cin >> temp;
    total += temp;
  }

  if (N >= total) {
    cout << N - total << endl;
  } else {
    cout << -1 << endl;
  }

  return 0;
}

Measured memory_bytes: 3636
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
#import bisect# lower_bound etc
#import numpy as np
#from copy import deepcopy
#from collections import deque



def run():
    N, *A = map(int, read().split())
    ans = 0
    for i in range(0, N, 2):
        if A[i] % 2:
            ans += 1

    print(ans)



if __name__ == "__main__":
    run()


Measured memory_bytes: 9040
#include<iostream>
#include<deque>

using namespace std;

int main(){
  int n;
  cin>>n;
  deque<int> d;
  int c1,c2,c3;
  for(int i=0;i<n;i++){
    cin>>c1;
    cin>>c2;
    if(c1==0){
      cin>>c3;
      if(c2==0){
        d.push_front(c3);
      }else{
        d.push_back(c3);
      }
    }else if(c1==1){
      cout<<d[c2]<<endl;
    }else{
      if(c2==0){
        d.pop_front();
      }else{
        d.pop_back();
      }
    }
  }
}



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

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, n, m) for (int i = n; i < m; i++)
#define ll long long int

using namespace std;

int main() {
  ll x,y,z,k;
  cin >> x >> y >> z >> k;
  ll a[1005], b[1005], c[1005];
  unordered_set<ll> list{};
  REP(i,x) {
    cin >> a[i];
  }
  REP(i,y) {
    cin >> b[i];
  }
  REP(i,z) {
    cin >> c[i];
  }

  // sort
  sort(a, a + x, greater<ll>());
  sort(b, b + y, greater<ll>());
  sort(c, c + z, greater<ll>());

  priority_queue<pair<ll, ll> > q;
  ll in[3] = {};
  q.push(make_pair(a[0] + b[0] + c[0], (in[0] << 20) + (in[1] << 10) + in[2]));
  list.insert((in[0] << 20) + (in[1] << 10) + in[2]);

  REP(i,k) {
    pair<ll,ll> top = q.top();
    cout << top.first << endl;
    q.pop();

    in[0] = (top.second >> 20);
    in[1] = (top.second >> 10)%1024;
    in[2] = top.second%1024;

    REP(j,3) {
      ll ix = in[0];
      ll iy = in[1];
      ll iz = in[2];
      if(j == 0 && ix < x-1) {
        ix++;
      }
      if(j == 1 && iy < y-1) {
        iy++;
      }
      if(j == 2 && iz < z-1) {
        iz++;
      }

      if(list.count((ix << 20) + (iy << 10) + iz) == 0) {
        q.push(make_pair(a[ix] + b[iy] + c[iz], (ix << 20) + (iy << 10) + iz));
        list.insert((ix << 20) + (iy << 10) + iz);
      }
    }
  }
}


Measured memory_bytes: 768
# https://atcoder.jp/contests/abc098/tasks/arc098_a
# C - Attention
import collections

N = int(input().split()[0])
S = input().split()[0]
min_c = float('inf')
count_dict = {}
now_w = 0
w_count_list = []

for i in range(N):
    w_count_list.append(now_w)
    if S[i] == 'W':
        now_w += 1

now_e = 0
e_count_list = []
r_S = list(reversed(S))
for i in range(N):
    e_count_list.append(now_e)
    if r_S[i] == 'E':
        now_e += 1

e_count_list = list(reversed(e_count_list))

ans = min([w + e for w, e in zip(w_count_list, e_count_list)])
print(ans)


Measured memory_bytes: 33784
#include<iostream>
#include<cstdio>
using namespace std;
int main(void){
	int in[31];
	int a;

	for(int i=1;i<31;i++)in[i]=0;
	in[0]=1;
	while(cin>>a)in[a]=1;
	for(int i=1;i<31;i++){
		if(in[i]==0){
			cout<<i<<endl;
		}
	}
	return 0;

}

Measured memory_bytes: 0
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <string>
#include <iostream>
using namespace std;
const int N = 55;
string s[N];
int n,m;
int dx[]= {1,-1,0,0},dy[] = {0,0,1,-1};
bool ju(int x,int y)
{
	for (int i = 0;i < 4;i++)
	{
		int nx = x + dx[i],ny = y + dy[i];
		if (nx >= 0 && ny >= 0 && nx < n && ny < m)
		{
			if (s[nx][ny] == '#') return 1;
		}
	}
	return 0;
}
int main()
{
	
	scanf("%d%d",&n,&m);
	for (int i = 0;i < n;i++)
	{
		cin >> s[i];
	}
	bool f = 0;
	for (int i = 0;i < n;i++)
	{
		for (int j = 0;j < m;j++)
		{
			if (s[i][j] == '#')
			{
				if (!ju(i,j)) f = 1;
			}
		}
	}
	puts(f?"No":"Yes");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<queue>

using namespace std;

long long n;

int main(){
  cin >> n;
  if(n==0){
    cout<<"0"<<endl;
    return 0;
  }
  int k = 1;
  long long p = 1;
  long long pt = 1;
  long long m = -2;
  long long mt = -2;
  while(1){
    if((mt <= n) && (n <= pt))break;
    p *= 4LL;
    pt += p;
    m *= 4LL;
    mt += m;
    k++;

    //cout<<k<<" "<<p<<" "<<pt<<" "<<m<<" "<<mt<<endl;
  }

  string s="";

  while(k--){
    long long diffp = ((p-1LL)/3LL);
    long long diffm = ((p-1LL)/3LL)*2LL;
    string tmpstr = "";

    //cout<<n<<" "<<p<<" "<<m<<" "<<diffp<<" "<<diffm<<endl;

    if(((p+m-diffm) <= n) && (n <= (p+m+diffp))){
      tmpstr = "11";
    } else if(((p-diffm) <= n) && (n <= (p+diffp))){
      tmpstr = "01";
    } else if(((m-diffm) <= n) && (n <= (m+diffp))){
      tmpstr = "10";
    } else {
      tmpstr = "00";
    }
    if(tmpstr[0] == '1') n-=m;
    if(tmpstr[1] == '1') n-=p;

    s += tmpstr;
    p/=4LL;
    m/=4LL;
  }

  for(int i=0;i<(int)s.length();i++){
    if((i==0) && (s[i] == '0'))continue;
    cout<<s[i];
  }cout<<endl;

  return 0;
}

Measured memory_bytes: 256
n = int( input() )
h = list( map( int, input().split() ) )

possible = True
for i in range(1,n):
    if h[-i] < h[-i-1]:
        h[-i-1] -= 1
        if h[-i] < h[-i-1]:
            possible = False
            break

if possible:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 63856
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"

using ll = long long;
using P = pair<int, int>;

const long long MOD = 1e9+7;

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

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter) { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

int main() {
    int n;
    cin >> n;
    vector<string> ss(n);
    vector<int> ts(n);
    rep(i, n) cin >> ss.at(i) >> ts.at(i);
    string x;
    cin >> x;
    
    bool flag = false;
    int sum = 0;
    rep(i, n) {
        if (flag) sum += ts.at(i);
        else if (ss.at(i) == x) flag = true;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
x=input().split()
X=[int(a) for a in x]

new_X=sorted(X)


if M<=N:
    print(0)

elif N==1:
    print(new_X[-1]-new_X[0])

else:
    numbers=[]
    for m in range(M-1):
        number=new_X[m+1]-new_X[m]
        numbers.append(number)
    new_numbers=sorted(numbers)
    for _ in range(N-1):
        del new_numbers[-1]
    print(sum(new_numbers))
    

Measured memory_bytes: 83668
#include<cstdio>

int main() {
  int a, v;
  scanf("%d %d", &a, &v);
  int b, w;
  scanf("%d %d", &b, &w);
  int t;
  scanf("%d", &t);
  long long la, ra;
  la = a - 1ll * v * t;
  ra = a + 1ll * v * t;
  long long lb, rb;
  lb = b - 1ll * w * t;
  rb = b + 1ll * w * t;
  printf("%s\n", la <= lb && rb <= ra ? "YES" : "NO");
}


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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    a=LI()
    b=[0]*N
    
    
    for i in range(N-1,-1,-1):
        temp=0
        for j in range(i+1,N+1,i+1):
            jj=j-1
            if b[jj]:
                temp+=1
        temp=temp%2
        if temp!=a[i]:
            b[i]=1
            
    M=sum(b)
    ans=[]
    for i in range(N):
        if b[i]:
            ans.append(i+1)
            
    print(M)
    print(' '.join(map(str, ans)))
        

main()


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

using namespace std;

int main(){
    int H, W;
    cin >> H >> W;

    vector<string> S(H);
    for(int i = 0; i < H; i++){
        cin >> S[i];
    }

    /*
    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            cout << S[i][j];
        }
        cout << endl;
    }
    */
    const int dx[8] = {1, 0, -1, 1, -1, 1, 0, -1};
    const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            if(S[i][j] == '#')
                continue;
            else{
                int num = 0;
                for (int d = 0; d < 8; d++){
                    const int ni = i + dy[d];
                    const int nj = j + dx[d];
                    if(ni < 0 or H <= ni)
                        continue;
                    if(nj < 0 or W <= nj)
                        continue;
                    if(S[ni][nj] == '#')
                        num++;
                }
                S[i][j] = char(num + '0');
            }
        }
    }

    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            cout << S[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Queue;

public class Main {

	static String matrix[][];
	static int dist[][];
	static boolean used[][];

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

	static int w;
	static int h;

	static int min = Integer.MAX_VALUE;

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

		int a = Integer.parseInt(br.readLine());
		int b = Integer.parseInt(br.readLine());

		if (a + b == 3) {
			System.out.println(3);
		} else if (a + b == 4) {
			System.out.println(2);
		} else {
			System.out.println(1);
		}
	}
}

Measured memory_bytes: 20948
#include<bits/stdc++.h>
using namespace std;
 //bool check[100007];
bool checks(int n){
  for(int i=3;i*i<=n;i+=2){
    if(n%i==0) return false;
  }
  return true;
}
int numberOfPrime(int n){
  if(n<=2) return 2;
  if(n%2==0)n++;
  for(int i=n;;i+=2){
     if(checks(i)){
       return i;
     }
  }
  return n;
}
int main(){
    int n;
  	cin>>n;
  	cout<<numberOfPrime(n)<<"\n";
	return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

const int N = 100001;
int n, a[N], b[N];
pair<int, int> pa[N], pb[N];

vector<int> v[N];
int id[N];
int unit, cn;
void init() {
	inc(i, n) { v[i].PB(i); id[i] = i; }
	unit = n;
	cn = n;
}
void unite(int xx, int yy) {
	int x = id[xx], y = id[yy];
	if(x == y) { return; }
	cn--;
	if(v[x].size() > v[y].size()) { swap(x, y); }
	if(v[x].size() == 1) { unit--; }
	if(v[y].size() == 1) { unit--; }
	
	dec(i, v[x].size()) {
		id[ v[x][i] ] = y;
		v[y].PB(v[x][i]);
		v[x].pop_back();
	}
}

int main() {
	cin >> n;
	inc(i, n) { cin >> a[i]; }
	inc(i, n) { cin >> b[i]; }
	
	int x = 0, y = 0;
	inc(i, n) { x ^= a[i]; y ^= b[i]; }
	a[n] = x;
	b[n] = y;
	n++;
	
	inc(i, n) {
		if(i < n - 1 && a[i] == b[i]) { a[i] = b[i] = -(i + 1); }
		pa[i] = MP(a[i], i);
		pb[i] = MP(b[i], i);
	}
	sort(pa, pa + n);
	sort(pb, pb + n);
	
	inc(i, n) {
		if(pa[i].FI != pb[i].FI) {
			cout << -1 << endl;
			return 0;
		}
	}
	
	init();
	inc(i, n) { unite(pa[i].SE, pb[i].SE); }
	inc(i, n - 1) {
		if(pa[i].FI == pa[i + 1].FI) { unite(pa[i].SE, pa[i + 1].SE); }
	}
	
	cout << (cn - unit) + (n - unit) + (v[ id[n - 1] ].size() != 1 ? -2 : 0) << endl;
	
	return 0;
}


Measured memory_bytes: 12160
def examB():
    N = I()
    max_N = 50001
    origin = [None]*int(max_N*1.08+10)
    for i in range(max_N):
        origin[int(i*1.08)] = i
    if origin[N]:
        ans = origin[N]
    else:
        ans = ":("
    print(ans)
    return

def examC():
    return

def examD():
    return
def examE():
    return

def examF():
    return

import sys,copy,bisect,itertools,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()


Measured memory_bytes: 39280
#include <bits/stdc++.h>
using namespace std;
#define what_is(x) cerr << #x << " is " << x << endl;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;
const int N = 1e5+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int a, b, c;
int main()
{
	IOS
	//freopen("input.txt", "r", stdin);
	cin >> a >> b >> c;
	cout << max(0, c - (a-b)) << endl;

	return 0;
}


Measured memory_bytes: 256
// Reading stuff 
// check the modulus 
// for tree case n=1


#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")
 
#include <bits/stdc++.h>
#include <vector> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;

#define int         long long
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define mp          make_pair
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define rep(i,a,b)  for(int i=a;i<b;i++)
const ll hell=1000000007;


int solve(){    
 
int n;
cin>>n;
mi m;
rep(i,2,n+1)
{
  int x;
  cin>>x;
  m[x]++;
}

rep(i,1,n+1)
{
  if(m.count(i))cout<<m[i]<<" ";
  else cout<<0<<" ";
}


return 0;
}

 
signed main()
{    


   ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);


int t=1;                                                                                                                  
//cin>>t;
int k=1;

    while(t--)
     {
      //cout<<"Case #"<<k<<": ";
      k++;
      solve();
     }
    return 0;
  }

Measured memory_bytes: 16112
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>
#include<list>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

ll mypow(ll x,ll n,ll mod = MOD){
    ll ret = 1;
    while(n > 0){
        if(n&1){
            ret = (ret*x)%mod;
        }
        x = (x*x)%mod;
        n >>= 1;
    }
    return ret;
}

ll mygcd(ll a,ll b){
    if(b == 0)return a;
    return mygcd(b,a%b);
}

ll twoPow(ll shiftNum){
    return (1LL << (shiftNum - 1));
}

bool solve(ll r,ll n,ll k,vector<ll> &a){
    vector<ll> rest(n);

    for(int i = 0; i < n; i++){
        rest[i] = a[i]%r;
    }

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

    ll t = 0;

    for(int i = 0; i < n; i++){
        ll d = rest[i];
        t += rest[i];
        rest[i] = 0;
        while(true){
            if((r - rest[n-1])%r < d){
                d -= (r - rest[n-1])%r;
                rest[n-1] = 0;
                n--;
            }else{
                rest[n-1] += d;
                rest[n-1] %= r;
                break;
            }
        }
    }

    if(t <= k){
        return true;
    }
    return false;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    ll n,k;
    cin >> n >> k;

    vector<ll> a(n);

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

    ll s = 0;
    for(int i = 0; i < n; i++){
        s += a[i];
    }

    ll ans = 0;

    for(int i = 1; i*i <= s; i++){
        if(s%i == 0){
            if(solve(i,n,k,a)){
                ans = max(ans,(ll)i);
            }
            if(solve(s/i,n,k,a)){
                ans = max(ans,(ll)(s/i));
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
  int N,K;
  int min=1;
  int tmp1=1,tmp2=1;
  cin >> N >> K ;
  for(int i=0;i<N;i++){
    tmp1 += K;
    tmp2 *= 2;
    if(tmp1 <= tmp2) min=tmp1;
    if(tmp2 < tmp1) min=tmp2;
    tmp1 = min;
    tmp2 = min;
  }
  cout << min << endl;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
    int H,W;
    cin >> H >> W;
    bool M[H+2][W+2];
    queue<pair<int,int>> que;
    rep(i,W+2) M[0][i] = 1;
    rep(i,W+2) M[H+1][i] = 1;
    rep(i,H+2) M[i][0] = 1;
    rep(i,H+2) M[i][W+1] = 1;
    for(int i=1;i<=H;i++){
        string str;
        cin >> str;
        int j = 1;
        for(char c : str){
            if(c == '#'){
                M[i][j] = true;
                que.push(make_pair(i,j));
            }else{
                M[i][j] = false;
            }
            j++;
        }
    }

    int res = 0;
    int quecount = que.size();
    while(true){
        int count = 0;
        rep(k,quecount){
            auto e = que.front();
            que.pop();
            int i = e.first,j = e.second;
            //if(!M[i][j]){que.push(make_pair(i,j));count++;} 
            if(!M[i][j-1]){M[i][j-1]=1;que.push(make_pair(i,j-1));count++;} 
            if(!M[i][j+1]){M[i][j+1]=1;que.push(make_pair(i,j+1));count++;} 
            if(!M[i+1][j]){M[i+1][j]=1;que.push(make_pair(i+1,j));count++;} 
            if(!M[i-1][j]){M[i-1][j]=1;que.push(make_pair(i-1,j));count++;} 
        }
        if(count == 0)break;
        res++;
        quecount = count;
    }
    /*
    rep(i,H+2){
        rep(j,W+2){
            cout << M[i][j] << " ";
        }
        cout << endl;
    }
    */

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 9488
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <vector>

using namespace std;

#define debug(x) (cout << # x ": " << x << endl)
#define int long long int
#define repeat(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()

signed main() {
    double l;
    cin >> l; 

    printf("%.12f", pow(l / 3, 3));
    
    return 0;
}


Measured memory_bytes: 3468
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
#define repl(i, l, r) for (int i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
const int MAX = 1000005;
int n, a[200000], P[MAX];
int main() {
	scanf("%d", &n);
	rep(i, n) {
		scanf("%d", a + i);
		P[a[i]]++;
	}
	int ans = 0;
	rep(i, MAX) {
		if (P[i] == 1) ans++;
		if (P[i])
			for (int j = 2; j * i < MAX; j++) P[j * i] = 0;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 8332
#include <stdio.h>


int main(void)
{
	int n, i, j,v;
	int A[100];

	/*???°?????\???*/
	 scanf("%d", &n);
	 for (i = 0; i < n; i++)
	 {
		 scanf("%d", &A[i]);
	 }

	 /**/
	 for (i = 0; i < n; i++)
	 {
		 v = A[i];
		 j = i - 1;

		 while (j >= 0 && A[j] > v)
		 {
			 A[j + 1] = A[j];
			 j--;
		 }
		 A[j + 1] = v;

		 for (j = 0; j < n; j++)
		 {
			 if (j != 0)
			 {
				 printf(" ");
			 }

			 printf("%d", A[j]);
		 }

		 printf("\n");
	 }
			

		
		return 0;
}

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

int gcd(int a, int b) {
    int n = (a < b) ? a : b;
    
    if(a % n == 0 && b % n == 0) {
        return n;
    }
    for(int i = n / 2 ; i > 0; --i) {
        if(a % i == 0 && b % i == 0) {
            return i;
        }
    }
}
int main(void) {
    int a, b;
    
    cin >> a >> b;
    
    cout << gcd(a, b) << endl;
    
    return 0;
    
}



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

using namespace std;

int main(){
    int N, M;
    cin >> N >> M;


    vector <int> k(M);
    vector <vector <int> > s(M);
    for (int i = 0; i < M; i++){
        cin >> k[i];
        for (int j = 0; j < k[i]; j++){
            int S;
            cin >> S;
            s[i].push_back(S);
        }
    }
    vector <int> p(M);
    for (int i = 0; i < M; i++){
        cin >> p[i];
    }

    vector <int> Switch(N);
    int count = 0;

    for (int i = 0; i < pow(2, N); i++){
        int num = i;
        for (int j = 0; j < N; j++){
            Switch[j] = num % 2;
            num = num / 2;
        }

        bool f = true;
        for (int j = 0; j < M; j++){
            int sum = 0;
            for (int k = 0; k < s[j].size(); k++){
                sum += Switch[s[j][k] - 1];
            }
            if(sum % 2 != p[j]){
                f = false;
            }    
        }

        if(f == true){
            count ++;
        }
    }
    
    cout << count << endl;




    return 0;
}

Measured memory_bytes: 512
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

const COST: [usize; 10] = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6];

fn calc(n: usize, usable: &Vec<usize>, memo: &mut Vec<String>) -> String {
    if n == 0 {
        return "".to_string();
    }
    if memo[n] != "" {
        return memo[n].clone();
    }
    let mut ret = "NG".to_string();
    for &v in usable.iter() {
        if COST[v] > n {
            continue;
        }
        let nn = n - COST[v];
        let nret = calc(nn, usable, memo);
        if nret == "NG" {
            continue;
        }
        let nret = format!("{}{}", v, nret);
        if ret == "NG" || nret.len() > ret.len() || (nret.len() == ret.len() && nret > ret) {
            ret = nret;
        }
    }
    memo[n] = ret.clone();
    return ret;
}

fn main() {
    let n = read::<usize>();
    let m = read::<usize>();
    let mut usable = vec![0; m];
    for i in 0..m {
        usable[i] = read::<usize>();
    }
    let mut memo = vec!["".to_string(); n + 1];
    for i in 1..n {
        calc(i, &usable, &mut memo);
    }
    let ans = calc(n, &usable, &mut memo);
    println!("{}", ans);
}


Measured memory_bytes: 30972
import sys


input = sys.stdin.readline


def main():
    A, B = map(int, input().split())

    c = []
    n = 1
    m = min(A, B)
    k = max(A, B)
    while n*n <= m:
        if m % n == 0:
            if k % n == 0:
                c.append(n)
            if k % (m//n) == 0 and n*n != m:
                c.append(m//n)
        n += 1
    c.sort()
    ary = []
    for i in range(1, len(c)):
        for n in ary:
            if c[i] % n == 0:
                break
        else:
            ary.append(c[i])
    # print(c, ary)
    print(len(ary)+1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 39664
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define rrep(i,a,b) for(int i = (b); i --> (a);)
#define trav(x, v) for(auto &x : v)
#define all(v) v.begin(),v.end()
#define sz(v) int(v.size())
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

int main(){
	cin.tie(0);
	cin.sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	string s;
	cin >> s;

	int n = sz(s)+1;

	vi a(n,-1), deg(n);
	rep(i,0,sz(s)){
		if(s[i]=='>') ++deg[i];
		else ++deg[i+1];
	}
	queue<int> ko;
	rep(i,0,n) if(deg[i]==0){
		a[i] = 0;
		ko.push(i);
	}
	while(!ko.empty()){
		int i = ko.front(); ko.pop();
		if(i && s[i-1]=='>' && --deg[i-1] == 0){
			a[i-1] = a[i]+1;
			ko.push(i-1);
		}
		if(i < n-1 && s[i]=='<' && --deg[i+1] == 0){
			a[i+1] = a[i]+1;
			ko.push(i+1);
		}
	}
	ll ans = 0;
	trav(x, a) ans += x;
	cout << ans << endl;
}


Measured memory_bytes: 5276
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<float.h>


using namespace std;
#define ll long long


int main(void){
    int A,P;
    cin>>A>>P;
    cout<<(3*A+P)/2<<endl;
    return 0;
}


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

using ull = unsigned long long int;
using ll = long long int;
using du = double;
using ld = long du;
using vi = vector<int>;
using vll = vector<ll>;
using vld = vector<ld>;
using vdu = vector<du>;
using vs = vector<string>;
using vc = vector<char>;
using si = set<int>;
using sll = set<ll>;
using sdu = set<du>;
using sld = set<ld>;
using pii = pair<int, int>;
using pll = pair<ll,ll>;
using pdu = pair<du,du>;
using pld = pair<ld,ld>;
using pis = pair<int,string>;

#define FASTIO ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define sp(x) setprecision(x)<<fixed
#define loop(i,n) for(int i=0;i<n;i++)
#define ff first
#define ss second
#define pi acos(-1)
#define meme(a,x) memset(a,x,sizeof(a))
#define fout() cout.flush()
//King's Move
vi f={0,0,1,-1};
vi g={-1,1,0,0};
//debugger

#ifdef KAIZER
#include "debug.h"
#else
#define debug(x...)
#endif
//debugger

//functions
bool check_pow(ll a)
{
    if((a&(a-1))==0) return true;
    else return false;
}
ld my_pow(ld a,int b)
{
    ld ans=1;
    for(int i=0;i<b;i++) ans*=a;
    return ans;
}
ll digits(ll a)
{
    string line=to_string(a);
    return line.size();
}
bool prime_check(ll a)
{
    bool flag=true;
    for(ll i=2;i<=sqrt(a);i++)
    {
        if(a%i==0) {flag=false; break;}
    }
    return flag;
}
bool comp(const pair<int,int> &a , pair<int,int> &b)
{
    if(a.ff!=b.ff) return a.ff>b.ff;
    else return a.ss<b.ss;
}
//functions

int main()
{
    FASTIO;
    string line;
    cin>>line;
    if(line[line.size()-1]=='s') line+="es";
    else line+="s";
    cout<<line<<endl;
}

Measured memory_bytes: 3668
from collections import defaultdict
 
 
N, M = map(int, input().split())
PY = [list(map(int, input().split())) for _ in range(M)]
 
di = defaultdict(list)
 
for i, py in enumerate(PY):
    di[py[0]].append([py[1], i])
 
ans = ["" for _ in range(M)]
 
for k, v in di.items():
    v.sort()
 
    for j, yi in enumerate(v):
        s = str(k).zfill(6)
        t = str(j + 1).zfill(6)
        ans[yi[1]] = s + t
 
print("\n".join(ans))

Measured memory_bytes: 62716
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <cstring>
using namespace std;

const int up = 30000;
const int maxn = up + 7;
int d[maxn];
void output(int *d, int n) {
	sort(d, d + n);
	for (int i = 0; i < n; i++) printf("%d ", d[i]);
	puts("");
	exit(0);
}

int main() {
	int n, tail = 0;
	scanf("%d", &n);
	
	if (n == 3) {
		printf("2 5 63\n");
		return 0;
	}
	
	d[tail++] = 2;
	d[tail++] = 4;
	d[tail++] = 3;
	d[tail++] = 9;
	if (tail >= n) output(d, n);
	
	for (int i = 1; 6 * i + 4 <= up && tail + 2 <= n; i++) {
		d[tail++] = 6 * i + 2;
		d[tail++] = 6 * i + 4;
	}
	if (tail >= n) output(d, n);
	
	for (int i = 2; 6 * (i + 1) + 3 <= up && tail + 2 <= n; i += 2) {
		d[tail++] = 6 * i + 3;
		d[tail++] = 6 * i + 9;
	}
	if (tail >= n) output(d, n);
	
	for (int i = 1; 6 * i <= up; i++) d[tail++] = 6 * i;
	output(d, n);
	return 0;
}


Measured memory_bytes: 384
n,a,b=map(int,input().split())
cab,cb=0,0
S=input()
for i in range(n):
  s=S[i]
  if s=='c':
    print('No')
  if s=='a':
    if cab<a+b:
      print('Yes')
      cab+=1
    else:
      print('No')
  if s=='b':
    if cab<a+b and cb<b:
      print('Yes')
      cab+=1
      cb+=1
    else:
      print('No')


Measured memory_bytes: 4040
s = input() #efabdd
t = input() #abcd
sl = len(s) #6
tl = len(t) #4
ans = tl #4
for i in range(sl-tl+1): #6-4+1 => 0, 1, 2
    c = 0
    for j in range(min(tl, sl)): #min(4, 6) => 4
        if (s[i+j] != t[j]): #s[0] != t[0]..t[3]
            c += 1
    ans = min(c, ans) #min(0..4, 4)
print(ans)


Measured memory_bytes: 9072
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

ll f(ll a){
  return (1+a)*a/2;
}

int main(){
  string S;
  cin >> S;
  int N = (int)S.size();
  vector<int> A(N+1, -1);
  ll ans = 0;
  if(S[0] == '<') A[0] = 0;
  if(S[N-1] == '>') A[N] = 0;
  rep(i,N-1){
    if(S[i] == '>' && S[i+1] == '<'){
      A[i+1] = 0;
    }
  }
  //rep(i,N+1) cout << A[i] << endl;
  rep(i,N){
    if(S[i] == '<'){
      A[i+1] = max(A[i]+1, A[i+1]);
    }
  }
  //rep(i,N+1) cout << A[i] << endl;
  for(int i=N-1; i >= 0; i--){
    if(S[i] == '>'){
      A[i] = max(A[i+1]+1, A[i]);
    }
  }
  //rep(i,N+1) cout << A[i] << endl;
  rep(i,N+1){
    //cout << A[i] << endl;
    ans += A[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2820
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
typedef pair<int,string> i_s;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int n; cin >> n;
  map<string,int> mp;
  int mx=0;
  rep(i,n){
    string s; cin >> s;
    mp[s]++;
    chmax(mx,mp[s]);
  }
  //cout << "---" << endl;
  vector<string> ans(0);
  for(auto c:mp){
    if(c.second==mx) ans.push_back(c.first);
  }
  int l=ans.size();
  //cout << "-" << endl;
  rep(i,l){
    cout << ans[i] << endl;
  }
  
}

Measured memory_bytes: 26868
from collections import defaultdict
 
n, k = map(int, input().split())
x = [int(i) for i in input().split()]
x = [i-k for i in x]
dic = defaultdict(int)

dic[0]=1
for i in x:
    for k,v in list(dic.items()):
        dic[k+i]+=v
print(dic[0]-1)



Measured memory_bytes: 3564
import sys
input = sys.stdin.readline
from collections import *
 
n = int(input())
h = list(map(int, input().split()))+[0]
ans = 0

while True:
    for i in range(n):
        if h[i]>0 and h[i+1]==0:
            ans +=1
            
    able=True
    
    for j in range(n):
        if h[j]>0:
            h[j]-=1
            able=False
            
    if able:
        break
        
print(ans)

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

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

    int N; cin >> N;

    int sum = 0;
    if (N < 10) sum += N;
    if (10 <= N && N < 100) sum += 9;
    if (100 <= N && N <= 999) sum += N - 99 + 9;
    if (1000 <= N && N <= 9999) sum += 909;
    if (10000 <= N && N <= 99999) sum += N - 9999 + 909;
    if (100000 == N) sum += 90000 + 909;

    cout << sum << endl;

    return 0;
}


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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

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;
}
vector<bool> seen;
void dfs(const Graph &G, int v){
    seen[v] = true; // vを訪問済みにする
    
    for(auto next_v: G[v]){
        if(seen[next_v]) continue; // next_vが探索済みならスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

void lunlun(int pos, ll val, vector<ll> &V){
    V.push_back(val);

    if(pos == 10) return;

    for(int i = -1; i <= 1; i++){
        int add = (val%10) + i;
        if((add >= 0) && (add <= 9)){
            lunlun(pos+1, val*10 + add, V);
        }
    }
}
int main(){

    int k;
    cin >> k;
    vector<ll> L;
    for(int i = 1; i <10; i++){
        lunlun(1, i, L);
    }
    sort(L.begin(), L.end());
    cout << L[k-1] << endl;
    return 0;
}

Measured memory_bytes: 5376
N,K = map(int,input().split())

ans_sum=0#確率合計

for i in range(1,N+1):
    num=i#現在の数字格納用
    ans=1/N #Nの目が出る確率
    while num<K:
        num*=2
        ans/=2
    #print(ans)
    ans_sum+=ans
print(ans_sum)

Measured memory_bytes: 66428
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 1010;

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

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

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; 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(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
ll dp[101010];
ll a[1010][1010];

//long longしか使わない
//素数は1より大きい
int main() {
	ll h, w;
	cin >> h >> w;
	vector<pair<ll, ll>>odd;
	rep(i, h) {
		rep(j, w) {
			cin >> a[i][j];
		}
	}
	vector<tuple<ll, ll, ll, ll>>motion;
	ll ans = 0;
	for (ll i = 0;i < h;i++) {
		for (ll j = 0;j < w-1;++j) {
			if (a[i][j] % 2 != 0) {
				motion.push_back(make_tuple(i, j, i, j + 1));
				a[i][j]--;
				a[i][j + 1]++;
				ans++;
			}
		}
	}
	for (ll i = 0;i < h - 1;++i) {
		if (a[i][w - 1] % 2 == 1) {
			a[i][w - 1]--;
			a[i + 1][w - 1]++;
			motion.push_back(make_tuple(i, w - 1, i + 1, w - 1));
			ans++;
		}
	}
	cout << ans << endl;
	for (ll i = 0;i < motion.size();i++) {
		cout << get<0>(motion[i]) + 1 << " " << get<1>(motion[i]) + 1 << " " << get<2>(motion[i]) + 1 << " " << get<3>(motion[i]) + 1 << endl;
	}
	return 0;
}


Measured memory_bytes: 10480
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
const int nax=1000*1007;
const ll mod=998244353;

int n;
ll A, B, k;

ll sil[nax];
ll odw[nax];

ll wyn;

ll dziel(ll a, ll b)
{
	ll wyk=mod-2;
	while(wyk)
	{
		if (wyk&1)
			a=(a*b)%mod;
		b=(b*b)%mod;
		wyk>>=1;
	}
	return a;
}

ll komb(ll a, ll b)
{
	if (b<0 || b>a)
		return 0;
	return (sil[a]*((odw[b]*odw[a-b])%mod))%mod;
}

int main()
{
	scanf("%d%lld%lld%lld", &n, &A, &B, &k);
	sil[0]=1;
	for (int i=1; i<=n; i++)
		sil[i]=(sil[i-1]*i)%mod;
	odw[n]=dziel(1, sil[n]);
	for (int i=n-1; i>=0; i--)
		odw[i]=(odw[i+1]*(i+1))%mod;
	for (int i=0; i<=n; i++)
	{
		ll jesz=k-i*A;
		if (jesz<0 || (jesz%B))
			continue;
		jesz/=B;
		wyn=(wyn+komb(n, i)*komb(n, jesz))%mod;
	}
	printf("%lld\n", wyn);
	return 0;
}


Measured memory_bytes: 8448
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
main()
{
	char a[1005],b[1005];
	scanf("%s %s",a,b);
	int len1 = strlen(a);
	int len2 = strlen(b);
	if(len1 > len2) printf("GREATER\n");
	if(len1 < len2) printf("LESS\n");
	if(len1 == len2) 
	{
		if(strcmp(a,b) > 0) printf("GREATER\n");
		if(strcmp(a,b) < 0) printf("LESS\n");
		if(strcmp(a,b) == 0) printf("EQUAL\n");
	}
}


Measured memory_bytes: 256