akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <math.h>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll INF = 1000000000000000000LL;
using namespace std;

const int MOD = 1000000007;
//biscuit
int main(){
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    string S;
    cin >> S;

    int res = MOD;

    for(int i = 0; i < 26; ++i)
    {
        char c = 'a' + i;
        string s = S;
        int cnt = 0;
        while(true)
        {
            if(s.size() == 0 || string(s.size(), c) == s)
            {
                break;
            }
            string tmp_s = "";
            for(int j = 0; j < s.size() - 1; ++j)
            {
                if(s[j] == c || s[j+1] == c)
                {
                    tmp_s += c;
                }
                else
                {
                    //a~z以外のなんでもよい
                    tmp_s += "*";
                }
            } 
            s = tmp_s;
            ++cnt;
        }

        res = min(res, cnt);
    }
    
    cout << res << endl;

    return 0;    
}



Measured memory_bytes: 256
n = input()
op_cnt = len(n) - 1
for i in range(2 ** op_cnt):
    op = ["+"] * op_cnt
    for j in range(op_cnt):
        if ((i>>j)&1):
            op[op_cnt - j - 1] = "-"
    formula = ""
    for p_n, p_o in zip(n, op + [""]):
        formula += (p_n+p_o)
    if eval(formula) == 7:
        break

print(formula + "=7")

Measured memory_bytes: 3060
#coding: UTF-8

import sys
import math

class Algo:
  @staticmethod
  def is_prime(n):
    if n == 2:
      return True
    elif n<2 or n%2 == 0:
      return False
    else:
      for i in range(3,int(math.sqrt(n))+2, 2):
        if n%i == 0:
          return False
    return True

N = int(input())
ans = 0
for i in range(0,N):
  if Algo.is_prime(int(input())):
    ans += 1
print(ans)

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

using namespace std;
using ll = long long;

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

  int n;
  cin >> n;
  const ll inf = 1e18;
  ll zmax = -inf;
  ll zmin = inf;
  ll wmax = -inf;
  ll wmin = inf;
  for (int i = 0; i < n; i++) {
    ll x, y;
    cin >> x >> y;
    zmax = max(zmax, x + y);
    zmin = min(zmin, x + y);
    wmax = max(wmax, x - y);
    wmin = min(wmin, x - y);
  }
  cout << max(zmax - zmin, wmax - wmin) << endl;

  return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
using P = pair<int,int>;
using ivec = vector<int>;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }


const int MOD=1000000007;
int INF=100100100100100;

signed main(){
  char c;cin>>c;
  if(c=='A')cout<<'T'<<endl;
  if(c=='T')cout<<'A'<<endl;
  if(c=='G')cout<<'C'<<endl;
  if(c=='C')cout<<'G'<<endl;
  
  return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/detail/standard_policies.hpp>
// using namespace __gnu_pbds;

#pragma GCC optimize("O3")
#ifdef LOCAL
#include "/Users/lbjlc/Desktop/coding/debug_utils.h"
#else
#define print(...) ;
#define printn(...) ;
#define fprint(...) ;
#define fprintn(...) ;
#endif

#define rep(i, a, b) for(auto i = (a); i < (b); i++)
#define rrep(i, a, b) for(auto i = (a); i > (b); i--)
#define all(v) (v).begin(), (v).end()
#define pb push_back
// #define mp make_pair
#define fi first
#define se second
#define maxi(x, y) x = max(x, y)
#define mini(x, y) x = min(x, y)
// long long fact(long long n) { if(!n) return 1; return n*fact(n-1); }
// #define endl '\n'
#define solve_testcase int T;cin>>T;for(int t=1;t<=T;t++){solve(t);}

// long long gcd(long long x, long long y) { return y ? gcd(y, x % y) : x; }

typedef unsigned long long ull;
typedef long long ll;
 
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pdd> vpdd;
typedef vector<long long> vll;
#define bd(type,op,val) bind(op<type>(), std::placeholders::_1, val)

const int MAXN = 1e6+10;

ll a,b,c,d;
map<ll,ll> dp;
vi xs({2,3,5});
vi vs(6);
ll dp_cal(ll n) {
    if(dp.count(n)) return dp[n];
    if(n==0) return dp[n]=0;
    dp[n]=LLONG_MAX;
    if(n<=LLONG_MAX/d) dp[n]=n*d;
    for(auto x:xs) {
        ll nn=n/x*x;
        ll tmp;
        if(nn>0) {
            tmp=abs(n-nn)*d+vs[x]+dp_cal(nn/x);
            mini(dp[n],tmp);
        }
        if(nn!=n) {
            nn+=x;
            tmp=abs(n-nn)*d+vs[x]+dp_cal(nn/x);
            mini(dp[n],tmp);
        }
    }
    return dp[n];
}

void solve(int tt) {
    // cout<<"Case #"<<tt<<": ";
    ll n,m=LLONG_MAX;
    cin>>n>>a>>b>>c>>d;
    dp.clear();  
    vs[2]=a;
    vs[3]=b;
    vs[5]=c;
    cout<<dp_cal(n)<<endl;

}

int main(int argc, char * argv[]) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    solve_testcase;



    return 0;
}




















Measured memory_bytes: 4480
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <list>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
typedef pair<int,int> PI;
typedef vector<int> vi;
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define F first
#define S second


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

typedef struct{
  int x,y,c;
}state;

main(){
  int w,h;
  while(cin>>w>>h,w|h){
    int kabe[w][2*h-1];
    rep(i,2*h-1){
      rep(j,w+i%2-1){
        cin>>kabe[j][i];
      }
    }

    bool heya[w][h];
    memset(heya,0,sizeof(heya));

    queue<state> Q;
    Q.push((state){0,0,1});
    int ans=INT_MAX/2;

    while(!Q.empty()){
      int cx=Q.front().x,cy=Q.front().y,cc=Q.front().c;
      Q.pop();
      if(heya[cx][cy])continue;
      heya[cx][cy]=1;

      if(cx==w-1 && cy==h-1){
        ans=cc;
        break;
      }

      rep(i,4){
        int nx=cx+dx[i],ny=cy+dy[i];
        if(nx<0 || w<=nx || ny<0 || h<=ny)continue;

        if(nx==cx && kabe[nx][cy*2+dy[i]]==0){
          Q.push((state){nx,ny,cc+1});
        }else if(ny==cy && kabe[(cx+nx)/2][ny*2]==0){
          Q.push((state){nx,ny,cc+1});
        }
      }
    }
    if(ans==INT_MAX/2)cout<<0<<endl;
    else cout<<ans<<endl;
  }
}

Measured memory_bytes: 916
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

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

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

    int res = 0;
    for (int i = 0; i < K; ++i) {
        res += p[i];
    }
    cout << res << endl;
}


Measured memory_bytes: 3196
a = list(map(int, input().split()))
a.sort()
if abs(a[0] - a[1]) % 2 == 1:
    print(abs(a[2] - a[1]) + (abs(a[0] - a[1]) + 1) // 2 + 1)
else:
    print(abs(a[2] - a[1]) + abs(a[0] - a[1]) // 2)


Measured memory_bytes: 3060
#include <iostream>
#include <cstring>
#include <algorithm>
#include <functional>

using namespace std;
string s, t;
const int MAX_S = 100;
char s1[MAX_S], t1[MAX_S];

int main() {

	cin >> s >> t;

	for (int i = 0; i < s.length(); i++) {
		s1[i] = s[i];
	}
	for (int i = 0; i < t.length(); i++) {
		t1[i] = t[i];
	}

	sort(s1, s1 + s.length());
	sort(t1, t1 + t.length(), greater<char>());

	if (strcmp(s1, t1) < 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

margin = 0 # b側で加算可能な回数
for a,b in zip(a_list, b_list):
    if a == b:
        continue
    elif a < b:
        margin -= (b-a)//2
    else:
        margin += a-b

if margin <= 0:
    print('Yes')
else:
    print('No')

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

void getAC() {	
	ios_base :: sync_with_stdio(false); cin.tie(0);
	int a, b;
	cin >> a >> b;
	if(a <= b) {
		while(b--) cout << a;
	} else {
		while(a--) cout << b;
	}
}
 
int main() {	
	getAC();
	return 0;
}

Measured memory_bytes: 256
INF=10**6
f=lambda:map(int,input().split())
h,w=f()
ch,cw=f()
dh,dw=f()
g=[input() for _ in range(h)]
d=[[INF]*w for _ in range(h)]
from collections import *
q=deque([(0,ch-1,cw-1)])
while q:
  c,x,y=q.popleft()
  if d[x][y]<=c: continue
  d[x][y]=c
  for dx in range(-2,3):
    for dy in range(-2,3):
      j=abs(dx)+abs(dy)
      nx,ny=x+dx,y+dy
      if 0<=nx<h and 0<=ny<w and g[nx][ny]=='.' and j:
        if j>1: q.append((c+1,nx,ny))
        else: q.appendleft((c,nx,ny))
a=d[dh-1][dw-1]
print([-1,a][a<INF])

Measured memory_bytes: 254024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;
ll MOD = 1000000000 + 7;

int main() {
    int x;
    cin >> x;
    int ans = 0, sum = 0;
    while (sum < x) {
        ans++;
        sum += ans;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
 
#define loop(n, i) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()

using namespace std;

int main(int argc, char const* argv[])
{
    while (1) {
        int N; cin >> N;
        if (!N) break;
        int ans = 0;
        loop (1001, i) loop (1001, j) if (i < j) {
            if (!i || !j) continue;
            if ((i + j) * (j - i + 1) == N * 2) ans++;
        }
        cout << ans << endl;
    }
    return 0;
}

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
typedef pair<int,int> P;

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

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

    int n,w;

    while(cin>>n>>w,n)
    {   
        int a[11]={0},c=0,M=0; //度数、区間の数、度数の最大値
        REP(i,n){
            int b; cin>>b;
            a[b/w]++;
            c=max(c,b/w+1);
        }
        REP(i,c) M=max(M,a[i]);
        
        double ret=0.01;
        REP(i,c){
            ret+=(double)(c-1-i)/(c-1)*a[i]/M;
        }
        cout<<ret<<endl;
    }

}



Measured memory_bytes: 3260
from sys import stdin
import numpy as np


# noinspection PyShadowingBuiltinsInspection

def main():
    n = int(input())
    if n % 2 == 0:
        print(0.5)
    else:
        m = (n + 1) / 2
        print(m / n)
    return


if __name__ == "__main__":
    main()

Measured memory_bytes: 21504
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x;
    int n;
    cin>>x>>n;
    vector<int> p(n,0);
    for(int i=0;i<n;i++){
        cin>>p[i];
    }
    int ans,min=100;
    for(int i=0;i<=101;i++){
        if(min>abs(x-i)){
            bool flag=true;
            for(int j=0;j<n;j++){
                if(p[j]==i)flag=false;
            }
            if(flag){
            ans=i;
            min=abs(x-i);
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

int main()
{
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	int maxn=a[0];
	int sum=1;
	for(int i=1;i<n;i++)
	{
		if(a[i]>=maxn)
		{
			sum++;
			maxn=a[i];
		}
	}
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 256
using System;

public class Program
{
  private static void Main()
  {
    int a, b;
    string[] input = Console.ReadLine().Split(' ');
    
    a = int.Parse(input[0]);
    b = int.Parse(input[1]);
    
    int ans = a - b * 2;
    
    Console.WriteLine((ans > 0 ? ans : 0).ToString());
  }
}


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

count = 0

if K == 0:
    count = N ** 2
else:
    for i in range(K + 1, N + 1):
        count += (N // i) * (i - K) if N % i < K else (N // i) * (i - K) + (N % i) - K + 1

print(count)

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

public class Main {

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

		int n = Integer.parseInt(br.readLine());

		int a[] = new int[n];
		boolean flag[] = new boolean[n];
		String str[] = br.readLine().split(" ");

		int min = Integer.MAX_VALUE;
		int minI = 0;

		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(str[i]);

			if (a[i] < min) {
				min = a[i];
				minI = i;
			}
		}

		int count = 0;

		while (count + 1 != n) {
			int min2 = Integer.MAX_VALUE;
			int min2I = 0;

			for (int i = 0; i < n; i++) {
				if (minI == i)
					continue;

				a[i] = a[i] % min;

				if (a[i] < min2 && a[i] != 0) {
					min2 = a[i];
					min2I = i;
				}

				if (a[i] == 0 && !flag[i]) {
					flag[i] = true;
					count++;
				}

			}
			if (min > min2) {
				min = min2;
				minI = min2I;
			}
		}

		System.out.println(min);
	}
}


Measured memory_bytes: 37716
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 100000000
#define INFLL 100000000000
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};



string N;

int main () {
  cin >> N;

  cout << "ABC" + N << "\n";

}

Measured memory_bytes: 256
#include <stdio.h>
long long lucas(int, long long[]);

int main(){
  int input;
  long long lu[86];
  for(int i = 0; i < 86; i++) lu[i] = 0;
  scanf("%d", &input);
  printf("%lld", lucas(input, lu));
  return 0;
}

long long lucas(int input, long long lu[]){

  if(lu[input] != 0)return lu[input];
	if(input == 0)return 2;
	if(input == 1)return 1;
  lu[input] = lucas(input - 2, lu) + lucas(input - 1, lu);
  return lu[input];
}


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,k,ans = 0,sum = 0;
  while(cin >> n >> k && n && k){
    if(cin.eof()) break;
    ans = 0,sum =0;
    vary(ll,v,n,0);
    vary(ll,imos,n+1,0);
    rep(i,n){
      cin >> v[i];
      sum += v[i];
      imos[i] += sum;
    }
    ans = -inf;
    REP(i,k,n){
      ans = max(ans,imos[i]-imos[i-k]);
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 4400
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=1e5+10;
int a[N],b[N],c[N],d[N],stk[N];
int n,m,q,ans;
void dfs(int pre,int dep){
    if(dep>n){
        int tmp=0;
        for(int i=1;i<=q;i++){
            if(stk[b[i]]-stk[a[i]]==c[i]){
                tmp+=d[i];
            }
        }
        ans=max(ans,tmp);
        return;
    }
    for(int i=pre;i<=m;i++){
        stk[dep]=i;
        dfs(i,dep+1);
    }
}
int main(){
    cin>>n>>m>>q;
    for(int i=1;i<=q;i++){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
    }
    dfs(1,1);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
using namespace std;
typedef long long ll;
int main() {
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	if (a[0] == 5 && a[1] == 5 && a[2] == 7)cout << "YES" << endl;
	else cout << "NO" << endl;
	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <bitset>
#include <time.h>
#include <set>
#include <algorithm>
#define ll long long
#define MAXN 111111
#define ll long long
using namespace std;

int main() {
    int n;
    cin>>n;
    
    
    int min_counts[26];
    for(int i=1;i<=n;i++) {
        string S;
        cin>>S;
        int counts[26];
        for(int j=0;j<26;j++)
            counts[j]=0;
        for(int j=0;j<S.size();j++) {
            counts[S[j]-'a']++;
        }
        
        for(int c=0;c<26;c++) {
            if (i==1) {
                min_counts[c]=counts[c];
            } else {
                min_counts[c]=min(min_counts[c],counts[c]);
            }
        }
    }
    
    for(int c=0;c<26;c++) {
        for(int j=0;j<min_counts[c];j++)
            printf("%c",'a'+c);
    }
    printf("\n");
    
}

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


using namespace std;


using ll = long long;


int main()
{
    vector<ll> cnt;
    ll N, Q;
    cin >> N >> Q;
    string S;
    cin >> S;
    cnt.push_back(0);
    for (ll i = 1; i < S.length(); i++) {
        if (S[i - 1] == 'A' && S[i] == 'C') {
            cnt.push_back(cnt.back() + 1);
        } else {
            cnt.push_back(cnt.back());
        }
    }

    for (ll i = 0; i < Q; i++) {
        ll l, r;
        cin >> l >> r;
        cout << cnt[r - 1] - cnt[l - 1] << endl;
    }
}


Measured memory_bytes: 1908
#include <iostream>

using namespace std;


int main(){
    char a,b;
    cin >> a >> b;
    if((a == 'H' && b == 'H')||(a == 'D' && b == 'D')) {//AtCoDeerは正直で正直者という。
        cout << "H" << endl;
    }else{//AtcoDeerはうそつきで正直者
        cout << "D" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
// #include<map>
#include<unordered_map>
#include<iostream>
#include<vector>
void stupid(){
    int N;
    std::unordered_map<long long,long long>cnts;
    int Q;
    std::vector<std::vector<int> >converts;
    long long sum;
    std::cin>>N;
    for(int i=0;i<N;++i){
        int buf;
        std::cin>>buf;
        cnts[buf]++;
    }
    std::cin>>Q;
    converts=std::vector<std::vector<int> >(Q,std::vector<int>(2));
    for(int i=0;i<Q;++i){
        std::cin>>converts[i][0]>>converts[i][1];
    }
    sum=0;
    for(auto itr=cnts.begin();itr!=cnts.end();++itr){
        sum+=itr->first * itr->second;
    }
    for(int i=0;i<Q;++i){
        auto itr1=cnts.find(converts[i][0]);
        if(itr1!=cnts.end()){
            cnts[converts[i][1]]+=itr1->second;
            sum+=(converts[i][1]-itr1->first)*itr1->second;
            std::cout<<sum<<std::endl;
            cnts.erase(itr1);
        }else{
            std::cout<<sum<<std::endl;
        }
    }
}
int main(){
    stupid();
    return 0;
}

Measured memory_bytes: 11476
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(ll i = (ll)a; i <= (ll)b; i++)
#define DEC(i, a, b) for(ll i = (ll)a; i >= (ll)b; i--)
typedef pair<ll, ll> pi;
typedef pair<pi, ll> pii;
typedef pair<pi, pi> pipi;
#define f first
#define s second
typedef vector<ll> vi;
typedef vector<pi> vpi;
typedef vector<pii> vpii;
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define disc(v) sort(all(v)); v.resize(unique(all(v)) - v.begin());
#define INF (ll) 1e9 + 100
#define LLINF (ll) 1e18
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sandybridge __attribute__((optimize("Ofast"), target("arch=sandybridge")))
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss

ll n, q, a, b, pre[200005], pos[200005], coun = 1;
vi adj[200005];
ll ft[200005];              // 1-index
ll ls(ll x){
	return (x & (-x));
}
// N means the largest possible index you need for the fenwick!! Refer to flowering for more.
void update(ll l, ll r, ll v){ // Updates from l to r inclusive
	r++;           // Update the difference at r+1 not r
	for(; l <= n; l += ls(l)) ft[l] += v;// Add v to the diff at l
	for(; r <= n; r += ls(r)) ft[r] -= v;// Minus v from diff at r+1
}
ll query(ll p){                     // Returns the element at p
	ll sum = 0;
	for(; p; p -= ls(p)) sum += ft[p];
	return sum; 
}

void dfs(ll x, ll p) {
	pre[x] = coun++;
	for (auto it:adj[x]) if (it != p) dfs(it, x);
	pos[x] = coun - 1;
}

int main() {
	fastio; cin >> n >> q;
	FOR(i, 1, n-1) {
		cin >> a >> b;
		adj[a].pb(b);
		adj[b].pb(a);
	}
	dfs(1, -1);
	while (q--) {
		cin >> a >> b;
		update(pre[a], pos[a], b);
	}
	FOR(i, 1, n) cout << query(pre[i]) << " ";
}


Measured memory_bytes: 28624
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;

int main(){
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  int x,n; cin >>x >>n;
  if(!n){cout <<x; return 0;}
  set<int>s; int rec;
  for(int i=0; i<102; i++) s.insert(i);
  for(int i=0; i<n; i++){
    int a; cin >>a;
    s.erase(a);
  }
  for(int i=0; i<51; i++){
    bool shit=0;
    if(s.count(x+i)){rec=x+i; shit=1;}
    if(s.count(x-i)){rec=x-i; shit=1;}
    if(shit) break;
  }
  cout <<rec;
return 0;}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int ans=n;
    for(int i=1;i<n;i++)
    {
        if(s[i]==s[i-1])
            ans--;
    }
    cout<<ans<<'\n';
}


Measured memory_bytes: 512
import kotlin.math.*
import java.util.*

const val mod = 1000000007L

fun readI() = readLine()!!.toInt()
fun readL() = readLine()!!.toLong()
fun readD() = readLine()!!.toDouble()
fun readIs() = readLine()!!.split(' ').map(String::toInt)
fun readLs() = readLine()!!.split(' ').map(String::toLong)
fun readDs() = readLine()!!.split(' ').map(String::toDouble)

fun main(args: Array<String>) {
  val (a, b) = readIs()
  println(a * b)
}


Measured memory_bytes: 36340
N, M =map(int,input().split())
AB = [list(map(int,input().split())) for i in range(N)]
AB.sort()
#print(AB)
sum = 0
ans = 0
i = 0
while sum < M:
    ans += AB[i][0]*min(AB[i][1],M-sum)
    sum = sum+AB[i][1]
    i +=1
print(ans)

Measured memory_bytes: 27756
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
    long long int a,b,c;
    cin >>a>>b>>c;
    rep(i,10){
        c = a*c-b;
        cout << c << endl; 
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define Mod 1000000007
#define Max 1000001
 
 
 

 
 
void func(){
    ll n;
    cin>>n; 
    if(n%1000 == 0){
        cout<<0<<endl;
    }
    else{
        ll ans=(n+1000-1)/1000;
        ll rem=ans*1000 - n;
        cout<<rem<<endl;
    }
}
int main(){
 
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
 
 
//int t;
//cin >> t;
//for(ll i=1; i<=t; i++)
//{
    
    func();
//    cout<<endl;
//cout<<func()<<endl;
 
//if(func())
//    cout<<"Yes"<< endl;
//else
//    cout <<"No"<<endl; 
//cout<<"Case:"<<i<<" "<<     <<endl;
//}
 
 
return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <vector>
#define N 100005
using namespace std;

int n, mx, ans[N];
bool v[N];
vector<int> gr[N], gi[N];

void f(int p, int q) {
	int i, nt, c=0;
	for(i=0; i<gr[p].size(); i++) {
		nt = gr[p][i];
		if(v[nt]) continue;
		v[nt] = 1;
		c++;
		if(c==q) c++;
		ans[gi[p][i]] = c;
		f(nt, c);
	}
}

int main() {
	int i, t1, t2;
	cin >> n;
	for(i=1; i<n; i++) {
		scanf("%d%d", &t1, &t2);
		gr[t1].push_back(t2); gi[t1].push_back(i);
		gr[t2].push_back(t1); gi[t2].push_back(i);
	}
	v[1] = 1;
	f(1, 0);
	for(i=1; i<n; i++) mx = max(mx, ans[i]);
	cout << mx <<endl;
	for(i=1; i<n; i++) printf("%d\n", ans[i]);
	return 0;
}

Measured memory_bytes: 12672
#include <iostream>
using namespace std;
bool f(int x){
    int s[5];
    for(int i=0;i<5;i++){
        s[i]=x%10;
        x/=10;
    }
    if(s[0]==s[4] && s[1]==s[3])return true;
    else return false;
}
int main(void){
    // Your code here!
    int n,m;
    cin>>n>>m;
    int ans=0;
    for(int i=n;i<=m;i++){
        if(f(i)) ans++;
    }
    cout<<ans<<endl;
}


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

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

   map<string, int> weeks;

   weeks["SUN"] = 7;
   weeks["MON"] = 6;
   weeks["TUE"] = 5;
   weeks["WED"] = 4;
   weeks["THU"] = 3;
   weeks["FRI"] = 2;
   weeks["SAT"] = 1;

   cout << weeks[s] << endl;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, math.MaxInt64)
}

func readFloat64() float64 {
	sc.Scan()
	r, _ := strconv.ParseFloat(sc.Text(), 6)
	return r
}

func main() {
	n := readFloat64()
	var ans int = 1
	var v float64
	for i := 1; i <= 6; i++ {
		v = math.Pow(2, float64(i))
		if n >= v {
			ans = int(v)
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#define T 1001
#define M 1000000007
#define E e[x][i]
#define S e[x].size()
using namespace std;
typedef long long ll;
ll func(int);
int N,s,t;
string n[T];
vector<int> e[T];
 
main(){
  cin>>N;
  for(int i=0;i<N;i++) cin>>n[i];
  for(int i=0;i<N-1;i++) cin>>s>>t,e[s-1].push_back(t-1);
  cout<<func(0)%M<<endl;
}

ll func(int x){
  ll res=0;
  if(!e[x].size()){
    if(n[x]=="E") return 1;
    if(n[x]=="E?") return 2;
    return 0;
  }
  if(n[x][0]=='E'){
    res++;
    for(int i=0;i<S;i++) res*=func(E);
    if(n[x]=="E?") res++;
  }
  if(n[x][0]=='A'){
    for(int i=0;i<S;i++) res+=func(E);
    if(n[x]=="A?") res++;
  }
  if(n[x][0]=='R'){
    res++;
    for(int i=0;i<S;i++) res*=(1+func(E));
    if(n[x]=="R") res--;
  }
  return res%M;
}

Measured memory_bytes: 1372
#include <stdio.h>
#include <string.h>

int main(void){
   char cards[201],sub[200];
   int i,m,h,len;
   
   while(scanf("%s",cards),strcmp(cards,"-")){
       scanf("%d",&m);
       len=strlen(cards);
       for(i=0;i<m;i++) {
           scanf("%d",&h);
           strcpy(sub,&cards[h]);
           strcat(sub,cards);
           sub[len]='\0';
           strcpy(cards,sub);
       }
       printf("%s\n",cards);
   }
   
    return 0;
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  int ans =0;
  rep(i, n) {
    if((i+1) % 2 == 1 && a[i] % 2 == 1) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3620
using System;

namespace A___Christmas_Eve_Eve_Eve
{
    class Program
    {
        static void Main()
        {
            var D = int.Parse(Console.ReadLine());

            if(D ==25)
            {
                Console.WriteLine("Christmas");
            }

            if (D == 24)
            {
                Console.WriteLine("Christmas Eve");
            }

            if (D == 23)
            {
                Console.WriteLine("Christmas Eve Eve");
            }


            if (D == 22)
            {
                Console.WriteLine("Christmas Eve Eve Eve");
            }



        }
    }
}


Measured memory_bytes: 11092
#!/usr/bin/env python3
import sys


def z_algorithm(S):
    """Zアルゴリズム
    """
    N = len(S)
    Z = [0]*N

    c = 0
    for i in range(1, N):
        if i+Z[i-c] < c+Z[c]:
            Z[i] = Z[i-c]
        else:
            j = max(0, c+Z[c]-i)
            while i+j < N and S[j] == S[i+j]:
                j += 1
            Z[i] = j
            c = i
    Z[0] = N
    return Z


def solve(N: int, a: "List[int]", b: "List[int]"):

    a1 = [0]*(2*N)
    b1 = [0]*N
    b2 = [0]*N
    k_cand = [True]*N
    for keta in range(30):
        for i, aa in enumerate(a):
            a1[i] = a1[i+N] = (aa >> keta) & 1
        for i, bb in enumerate(b):
            b1[i] = v = (bb >> keta) & 1
            b2[i] = 1-v
        Z1 = z_algorithm(b1 + [-1] + a1)
        Z2 = z_algorithm(b2 + [-1] + a1)
        # print(a1+[-1]+b1)
        # print(a1+[-1]+b2)
        # print("Z1", Z1)
        # print("Z2", Z2)
        for i in range(N):
            if k_cand[i]:
                k_cand[i] = Z2[i+N+1] == N or Z1[i+N+1] == N
        # print(k_cand)

    for i in range(N):
        if k_cand[i]:
            print(i, b[0] ^ a[i])
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N - 1 - 0 + 1)]  # type: "List[int]"
    b = [int(next(tokens)) for _ in range(N - 1 - 0 + 1)]  # type: "List[int]"
    solve(N, a, b)


if __name__ == '__main__':
    main()


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

int a[50];

int main(void){
    int n,mn=INF,mn_idx,mx=-INF,mx_idx;
    cin>>n;
    rep(i,n){
        cin>>a[i];
        if(mn>a[i]){
            mn = a[i];
            mn_idx = i;
        }
        if(mx<a[i]){
            mx = a[i];
            mx_idx = i;
        }
    }
    cout<<2*n-1<<endl;
    if(abs(mn)<abs(mx)){
        rep(i,n){
            cout<<mx_idx+1<<" "<<i+1<<endl;
        }
        rep(i,n-1){
            cout<<i+1<<" "<<i+2<<endl;
        }
    }else{
        rep(i,n){
            cout<<mn_idx+1<<" "<<i+1<<endl;
        }
        rep(i,n-1){
            cout<<n-i<<" "<<n-i-1<<endl;
        }
    }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long mod2 = 998244353;
const long long INF = 1LL << 60;
const int inf = pow(10, 9) + 7;
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int main()
{
  int N;
  cin >> N;
  vector<int> buc(100100, 0);
  for (int i = 0; i < N; i++)
  {
    int A;
    cin >> A;
    buc.at(A)++;
  }
  
  int k = 0;
  for (int i = 0; i < 100100; i++)
  {
    if (buc.at(i) > 0) k++;
  }
  
  int ans = k;
  if (k % 2 == 0) ans--;
  
  cout << ans<< endl;
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

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

	ll n;cin >> n;
	vector<ll> v(n);
	REP(i, n)cin >> v[i];

	ll ans = 0;
	REP(i, n){
		REP(j, i){
			ans += v[i] * v[j];
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env pypy3
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    p = [0] + list(map(int, input().split()))
    ans = 0
    for i in range(1,N+1):
        if p[i] == i:
            ans += 1
            if i == 1 or p[i] == i-1 or (i < N and p[i+1] == i+1):
                p[i], p[i+1] = p[i+1], p[i]
            else:
                p[i], p[i-1] = p[i-1], p[i]
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 52316
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin >> N;
    N = N%10;
    if (N==3){
        cout << "bon" << endl;
    }else if((N==0) || (N==1) || (N==6) || (N==8)){
        cout << "pon" << endl;    
    }else{
        cout << "hon" << endl;
    }
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define ll long long
#define ld long double
#define ft first
#define sd second
using namespace std;

const int N = 3e3 + 9;
ll a[N];
ll dp[N][N][2];

ll solve(int l, int r, bool turn) {
    if(l > r) return 0;
    ll &ret = dp[l][r][turn];
    if(ret != -1) return ret;
    if(turn) {
        ret = min(solve(l+1, r, turn^1)-a[l], solve(l, r-1, turn^1)-a[r]);

    } else {    
        ret = max(solve(l+1, r, turn^1)+a[l], solve(l, r-1, turn^1)+a[r]);
        
    }
    return ret;
}

signed main() {

    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    memset(dp, -1, sizeof dp);
    int n; cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    cout << solve(1, n, 0);
    
    return 0;
}

Measured memory_bytes: 141952
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	h, w := getInt(), getInt()
	a := make([][]int, h)
	b := make([][]int, h)
	for i := 0; i < h; i++ {
		a[i] = make([]int, w)
		for j := 0; j < w; j++ {
			a[i][j] = getInt()
		}
	}
	for i := 0; i < h; i++ {
		b[i] = make([]int, w)
		for j := 0; j < w; j++ {
			b[i][j] = getInt()
		}
	}
	var dp [81][81][20000]bool

	dp[0][0][abs(a[0][0]-b[0][0])] = true
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			for k := 0; k < 20000; k++ {
				if dp[i][j][k] == true {
					if j+1 < w {
						d := abs(a[i][j+1] - b[i][j+1])
						dp[i][j+1][abs(k-d)] = true
						dp[i][j+1][abs(k+d)] = true
					}
					if i+1 < h {
						d := abs(a[i+1][j] - b[i+1][j])
						dp[i+1][j][abs(k-d)] = true
						dp[i+1][j][abs(k+d)] = true
					}
				}
			}
		}
	}

	// out(dp[h-1][w-1][:10])
	//ans := math.MaxInt32
	for i := 0; i < 20000; i++ {
		if dp[h-1][w-1][i] == true {
			out(i)
			return
		}
	}
}


Measured memory_bytes: 134400
n = int(input())
a = list(map(int, input().split()))
current = [-1]*3
MOD = 1000000007
res = 1
for c in a:
    cnt = 0
    for can in current:
        if can == c-1:
            cnt += 1
    for i, v in enumerate(current):
        if v == c-1:
            current[i] = c
            break

    res *= cnt
    res %= MOD

res %= MOD
print(res)

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

#define forsn(i,s,n) for(tint i=(s);i<(tint)(n); i++)
#define forn(i,n) forsn(i,0,n)
#define dforn(i,n) for(tint i = tint(n)-1; i >= 0; i--)
#define debug(x) cout << #x << " = "  << x << endl

using namespace std;

typedef long long tint;

void imprimirVector (vector<tint> v)
{
	if (!v.empty())
	{ 
		tint p = tint(v.size());
		cout << "[";
		forn(i,p-1)
			cout << v[i] << ",";
		cout << v[p-1] << "]" << endl;
	}
	else
		cout << "[]" << endl;
}

const tint INF = 1000000000000000000;
tint N;

pair<tint,tint> bfs (tint start, const vector<vector<tint> > &ladj)
{
	
	vector<tint> neigh = {start}, new_neigh;
	vector<tint> distance (N,INF);
	distance[start] = 1;
	tint last = start;
	while (!neigh.empty())
	{
		tint actual = neigh.back();
		neigh.pop_back();
		for (const auto &v : ladj[actual])
		{
			if (distance[v] == INF)
			{
				distance[v] = distance[actual]+1;
				new_neigh.push_back(v);
				last = v;
			}
		}
		
		if (neigh.empty())
			neigh.swap(new_neigh);
	}

	return {distance[last],last};
}


int main()
{
	#ifdef ACMTUYO
		assert(freopen("entrada.in", "r", stdin));
	#endif
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	
	while (cin >> N)
	{
		vector<vector<tint> > ladj (N);
		forn(i,N-1)
		{
			tint a,b;
			cin >> a >> b;
			ladj[a-1].push_back(b-1);
			ladj[b-1].push_back(a-1);
		}
		if (bfs(bfs(0,ladj).second,ladj).first % 3 == 2)
			cout << "Second\n";
		else
			cout << "First\n";
		
		
		
		
	}
	
	
	return 0;
}






Measured memory_bytes: 17976
'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const A = parseInt(args[0][0], 10)
	const B = parseInt(args[0][1], 10)
	if (A % 3 === 0 || B % 3 === 0 || (A + B) % 3 === 0) console.log('Possible')
	else console.log('Impossible')
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


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

using ll = long long;
const int mod = 1e9 + 7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    map<string, int> cnt;
    for (int i = 0; i < N; i++) {
        string S;
        cin >> S;
        cnt[S]++;
    }
    int ma = 0;
    for (auto p : cnt) {
        ma = max(ma, p.second);
    }
    vector<string> ans;
    for (auto p : cnt) {
        if (p.second == ma)
            ans.push_back(p.first);
    }
    sort(begin(ans), end(ans));
    for (string &s : ans)
        cout << s << endl;
}

Measured memory_bytes: 25584
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
const int maxn=1e5+7;

priority_queue<int> q;

int main()
{
//    freopen("input.txt","r",stdin);
    
    ll n,m;
    cin>>n>>m;
    for(ll i=0;i<n;i++) 
    {
    	int x;
    	cin>>x;
    	q.push(x);
	}
    for(ll i=0;i<m;i++)
    {
    	int temp=q.top();
    	q.pop();
    	temp/=2;
    	q.push(temp);
	}
	ll ans=0;
	for(ll i=0;i<n;i++) 
	{
		int temp=q.top();
		q.pop();
		ans+=temp;
	}
	cout<<ans<<endl; 

    return 0;
}
//想着稍微改一改思路来做这道题也不错 
//考虑一下我为什么会把G题的思路想起来 














Measured memory_bytes: 892
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    string s;
    cin >> s;
    int sum = 0;
    rep(i, s.size()){
        sum += s[i] - '0';
    }
    if(sum % 9 == 0)cout << "Yes" << endl;
    else cout << "No" << endl;
    
}

Measured memory_bytes: 3748
#include<iostream>
#include<math.h>
using namespace std;
int main()
{

    typedef  long long int ll;
    ll n,m;
    cin>>n>>m;
    ll c = 0;

    while(n--)
    {
        ll x,y;
        cin>>x>>y;

        if(sqrt((x*x)+(y*y))<=m)
        {

            c++;
        }
    }
    cout<<c;
}


Measured memory_bytes: 3648
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <iomanip>
#include <typeinfo>
#include <iterator>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <set>
using namespace std;


typedef long long       ll;
struct edge { ll to; ll cost; };
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<string>  vs;
typedef vector<char>    vc;
typedef vector<edge>    ve;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;
typedef vector<ve>      vve;

// マクロ
#define repr(itr, bgn, end) for (ll itr = (ll)bgn; itr < (ll)end; ++itr)
#define rep(itr, end) repr(itr, 0, end)
#define reprrev(itr, bgn, end) for (ll itr = (ll)end - 1; itr >= (ll)bgn; --i)
#define reprev(itr, end) reprrev(itr, 0, end)
#define all(container) container.begin(), container.end()
#define sortall(container) sort(all(container))
#define yn(cond) cond ? (cout << "Yes" << endl) : (cout << "No" << endl)
#define YN(cond) cond ? (cout << "YES" << endl) : (cout << "NO" << endl)

// 定数
#define LLONG_MAX 9223372036854775807
constexpr double PI = 3.14159265358979323846;
constexpr ll INF = 1 << 15;
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-7;

// よく使うもの
constexpr int dy[4] = { 0, 1, 0, -1 };
constexpr int dx[4] = { 1, 0, -1, 0 };


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec) {
	for (T& x : vec) os << x << " ";
	return os;
}

// ***<ここから>****************************************************************

int main(void) {

	vi A(3);
	cin >> A;

	sortall(A);

	cout << A[2] - A[0] << endl;




	
	return 0;
}

Measured memory_bytes: 256
;; -*- coding: utf-8 -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(defmacro dbg (&rest forms)
  #+swank
  (if (= (length forms) 1)
      `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
      `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 (princ obj stream) (terpri stream))))

(defconstant +mod+ 1000000007)

;; Body

(defun main ()
  (declare #.OPT)
  (let* ((n (read))
         (s (make-array n :element-type 'bit :initial-element 0)))
    (declare (uint32 n))
    (dotimes (i n)
      (when (= #.(char-code #\o)
               #+swank (char-code (read-char *standard-input* nil #\Nul))
               #-swank (sb-impl::ansi-stream-read-byte *standard-input* nil #.(char-code #\Nul) nil))
        (setf (sbit s i) 1)))
    (dotimes (bits 4 (println -1))
      (let ((res (make-array n :element-type 'bit :initial-element 0)))
        (setf (aref res 0) (ldb (byte 1 0) bits))
        (setf (aref res 1) (ldb (byte 1 1) bits))
        (loop for pos from 2 below n
              do (setf (sbit res pos)
                       (logxor (sbit res (mod (- pos 1) n))
                               (sbit res (mod (- pos 2) n))
                               (sbit s (mod (- pos 1) n)))))
        (when (loop for pos below n
                    always (= (sbit s pos)
                              (logxor (sbit res (mod (- pos 1) n))
                                      (sbit res (mod pos n))
                                      (sbit res (mod (+ pos 1) n)))))
          (loop for b across res
                do (write-char (if (zerop b) #\W #\S)))
          (terpri)
          (return-from main))))))

#-swank(main)



Measured memory_bytes: 22756
using System;

namespace ManyFormulas
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputNumber = Console.ReadLine();
            var ans = CalcManyFormulas(inputNumber);
            Console.WriteLine(ans);
            //Console.ReadKey();
        }

        static private long CalcManyFormulas(string inputNumber)
        {
            long ans = 0;
            int plusNum = inputNumber.Length - 1;
            long loop = (long)Math.Pow(2, plusNum);
            for (var i = loop - 1; i >= 0; i--)
            {
                var temp = inputNumber;
                for (var j = 0; j < plusNum; j++)
                {
                    if ((i >> j) % 2 != 0)
                    {
                        ans += long.Parse(temp.Substring(plusNum - j));
                        temp = temp.Substring(0, plusNum - j);
                    }
                }
                if (!string.IsNullOrWhiteSpace(temp))
                {
                    ans += long.Parse(temp);
                }
            }

            return ans;
        }
    }
}


Measured memory_bytes: 2776
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);
 
    int n, tmp1, tmp2;
    cin >> n;
    string ans="No";
    tmp1 = n % 10;
    tmp2 = n % 100;

    if (n / 100 == 7){
      ans = "Yes";
    }

    if (tmp2 / 10 == 7){
      ans = "Yes";
    }

    if (tmp1 == 7){
      ans = "Yes";
    }

    cout << ans;    

}


Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

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

int main(){
    int N;
    cin >> N;
    ll inp;
    set<ll> a;
    ll num = 0;
    REP(i,N){
        cin >> inp;
        if(a.find(inp) == a.end()){
            a.insert(inp);
            num++;
        }else{
            a.erase(inp);
            num--;
        }
    }
    cout << num << endl;
    return 0;
}


Measured memory_bytes: 4864