akhauriyash/Code-Regression huggingface dataset:
import javax.print.DocFlavor;
import java.awt.*;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
import java.util.List;

public class Main {

    static String br = System.getProperty("line.separator");
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        if(nextInt() + nextInt() + nextInt() <= 21){
            println("win");
        }else{
            println("bust");
        }
    }

    static long a(long n){
        return n < 2L ? 1L : n*a(n-2);
    }

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

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

    static String next() {
        return sc.next();
    }

    static String nextLine(){
        return sc.nextLine();
    }

    static void println(Object o) {
        out.println(o);
        out.flush();
    }

    static void print(Object o) {
        PrintWriter out = new PrintWriter(System.out);
        out.print(o);
        out.flush();
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b) {a = b; return true;}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b) {a = b; return true;}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

int main(){
    string s; cin >> s;
    ll n = s.size();
    vvl dp(n+1,vl(2,0));
    dp[0][0] = 1;
    rep(i,n){
        dp[i+1][1] += dp[i][1] * 3;
        if(s[i]=='1'){
            dp[i+1][0] += dp[i][0] * 2;
            dp[i+1][1] += dp[i][0]; 
        }else{
            dp[i+1][0] += dp[i][0];
        }
        rep(j,2) dp[i+1][j] %= mod;
    }
    cout << (dp[n][0] + dp[n][1]) % mod << endl;
}

Measured memory_bytes: 5888
#include<stdio.h>

int main(){
	int r,g,b,n;
	int ri,gi,bi,c;
	int ans=0;
	scanf("%d %d %d %d",&r,&g,&b,&n);
	
	for(ri=0;ri*r<=n;ri++){
		for(gi=0;ri*r+gi*g<=n;gi++){
			if((n-(ri*r+gi*g))%b==0){
				ans++;
				continue;
			}
		}
	}
	printf("%d\n",ans);
					
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N;
    vector<ll> a;
    cin >> N;
    
    ld ave = 0;
    rep(i,N){
      ll inp;
      cin >> inp;
      a.pb(inp);
      ave += inp;
    }
    ave /= (ld) N;

    ll ans = 0;
    ld ans_diff = 100.0; 
    rep(i,N){
      if(abs(a[i] - ave) < ans_diff){
	ans = i;
	ans_diff = abs(a[i]-ave);
      }
    }


    cout << ans << endl;
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextInt64() int64 {
	sc.Scan()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

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

func main() {
	sc.Buffer(make([]byte, 0), 1000006)
	sc.Split(bufio.ScanWords)

	var n int
	var s string
	var ans int64

	mp := map[string]int{}

	n = nextInt()

	for i := 0; i < n; i++ {
		s = nextStr()
		slice := strings.Split(s, "")
		sort.Strings(slice)
		s = strings.Join(slice, "")
		ans += int64(mp[s])
		mp[s]++
	}

	fmt.Println(ans)
}


Measured memory_bytes: 11776
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
string s,ans;
int n;

P getNum(string str,int x){
  int r=0;
  while('0'<=str[x]&&str[x]<='9')
    r=r*10+str[x]-'0',x++;
  return P(x,r);
}

void dfs(int b,int e){
  int p=b;
  while(p<=e&&ans.size()<=n){
    while('0'<=s[p]&&s[p]<='9'){
      P r=getNum(s,p);
      int ss=r.first,num=r.second;
      int idx=r.first,z=r.first;
      if(s[ss]=='('){
	int c=1;
	idx=ss+1;
	for(z=idx;z<=e&&c;z++){
	  if(s[z]=='(')c++;
	  if(s[z]==')')c--;
	}
	p=z;
	z-=2;
	for(int i=0;i<num;i++)dfs(idx,z);
      }else{
	for(int i=0;i<num;i++)ans+=s[ss];
	p=ss+1;
      }
    }
    while('A'<=s[p]&&s[p]<='Z')ans+=s[p],p++;
  }
}

int main(){
  while(1){
    cin>>s>>n;
    if(s=="0"&&!n)break;
    dfs(0,s.size()-1);
    if(ans.size()>=n+1)cout<<ans[n]<<endl;
    else cout<<0<<endl;
    ans.clear();
  }
  return 0;
}

Measured memory_bytes: 2120
#include<iostream>
#include <bits/stdc++.h>
#include<algorithm>
#define endl "\n"
#define START ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int main()
{
    int t;
    cin >> t;
    cout<<(1000-(t%1000))%1000<<"\n";
    return 0;
}


Measured memory_bytes: 3556
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=a;i--)
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
#define de(x) cout << #x << "=" << x << endl
#define dd(x) cout << #x << "=" << x << " "
#define pw(x) (1ll<<(x))
#define pq priority_queue
#define endl "\n"
const int maxn=1e6;
int prime[maxn+1];
void getprime(){
	memset(prime,0,sizeof(prime));
	for(int i=2;i<=maxn;i++){
		if(!prime[i]) prime[++prime[0]]=i;
		for(int j=1;j<=prime[0]&&prime[j]<=maxn/i;j++){
			prime[prime[j]*i]=1;
			if(i%prime[j]==0) break;
		}
	}
} 
map<ll,ll> vis;
int main()
{
    ios::sync_with_stdio(false);
    ll n,ans=0,flag=0;
    cin >> n;
//    if(n==1){
//    	cout << 0 << endl;
//    	return 0;
//	}
    getprime();
    for(int i=1;i<=prime[0];i++){
    	ll now=1;
  //  	cout << prime[i] << endl;
		for(int j=1;j<=40;j++){
			now*=prime[i];
			if(now>n) break;
			if(n%now==0){
				vis[now]=1;
				n/=now;
				ans++;
			}
		} 
		while(n%prime[i]==0){
			n/=prime[i];
		}
	}
	if(vis[n]!=1 && n!=1) ans++;
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7564
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <climits>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>
#include <set>

using namespace std;

template<typename T>inline T get(){T x;cin>>x;return x;}

int main()
{
    int n = get<int>(), k = get<int>();
    map<int,int> buck;
    for (int i = 0; i < n; i++)
        buck[get<int>()]++;

    vector<int> freqs;
    for (auto p = buck.begin(); p != buck.end(); p++)
        freqs.push_back(p->second);

    sort(freqs.begin(), freqs.end());
    int count = 0;
    for (int i = 0; i < (int)freqs.size() - k; i++) {
        count += freqs[i];
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 10748
N, M, K = map(int, input().split())
par = [i for i in range(N)]
rank = [0 for _ in range(N)]

def root(x):
  if par[x] == x:
    return x
  else:
    par[x] = root(par[x])
    return par[x]
def unite(x, y):
  x, y = root(x), root(y)
  if x != y:
    if rank[x] < rank[y]:
      par[x] = y
    else:
      par[y] = x
      if rank[x] == rank[y]:
        rank[x] += 1
F, B = [], []
for i in range(M):
  a, b = map(int, input().split())
  F.append([a-1, b-1])
  unite(a-1, b-1)
for i in range(N):
  par[i] = root(i)
for i in range(K):
  a, b = map(int, input().split())
  B.append([a-1, b-1])
D = {}
for i in par:
  if i in D:
    D[i] += 1
  else:
    D[i] = 1
p = [0 for _ in range(N)]
for i in range(N):
  p[i] = D[par[i]]
for i in range(M):
  p[F[i][0]] -= 1
  p[F[i][1]] -= 1
for i in range(K):
  l = B[i][:]
  if par[l[0]] == par[l[1]]:
    p[l[0]] -= 1
    p[l[1]] -= 1
for i in range(N):
  if i != N - 1:
    print(p[i] - 1, end = ' ')
  else:
    print(p[i] - 1)

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

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

const int INF=1e9;
const int MOD=1e9+7;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

int Signum(double x){
	return x<-EPS?-1:x>EPS?1:0;
}

struct Point{
	double x,y;
	Point(){}
	Point(double x,double y):x(x),y(y){}
	Point& operator+=(Point p){
		x+=p.x,y+=p.y;
		return *this;
	}
	Point& operator-=(Point p){
		x-=p.x,y-=p.y;
		return *this;
	}
	Point& operator*=(double c){
		x*=c,y*=c;
		return *this;
	}
	Point& operator/=(double c){
		x/=c,y/=c;
		return *this;
	}
};
Point operator+(Point a,Point b){
	return a+=b;
}
Point operator-(Point a,Point b){
	return a-=b;
}
Point operator*(Point a,double c){
	return a*=c;
}
Point operator*(double c,Point a){
	return a*=c;
}
Point operator/(Point a,double c){
	return a/=c;
}
bool operator==(Point a,Point b){
	return abs(a.x-b.x)<EPS && abs(a.y-b.y)<EPS;
}
bool operator!=(Point a,Point b){
	return !(a==b);
}

double Abs2(Point p){
	return p.x*p.x+p.y*p.y;
}
double Dot(Point a,Point b){
	return a.x*b.x+a.y*b.y;
}
double Cross(Point a,Point b){
	return a.x*b.y-a.y*b.x;
}

int CCW(Point a,Point b,Point c){
	b-=a,c-=a;
	if(int sign=Signum(Cross(b,c)))
		return sign; // 1:ccw,-1:cw
	if(Dot(b,c)<-EPS)
		return -2;   // c-a-b
	if(Abs2(b)<Abs2(c)-EPS)
		return 2;    // a-b-c
	return 0;        // a-c-b
}

int main()
{
	Point a,b; cin>>a.x>>a.y>>b.x>>b.y;
	int q; cin>>q;
	rep(_,q){
		Point c; cin>>c.x>>c.y;
		int ccw=CCW(a,b,c);
		if(ccw==1)  cout<<"COUNTER_CLOCKWISE"<<endl;
		if(ccw==-1) cout<<"CLOCKWISE"<<endl;
		if(ccw==-2) cout<<"ONLINE_BACK"<<endl;
		if(ccw==2)  cout<<"ONLINE_FRONT"<<endl;
		if(ccw==0)  cout<<"ON_SEGMENT"<<endl;
	}
}

Measured memory_bytes: 1228
#define SUBMIT

#include <bits/stdc++.h>

using namespace std;

int main() {
#ifdef SUBMIT
    auto& in = cin;
#else
    stringstream in(R"(D D
)");
#endif
    string a, b;
    in >> a >> b;
    if ((a == "H" && b == "H") || (a == "D" && b == "D")) cout << "H" << endl;
    else cout << "D" <<endl;
    return 0;
}

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

int main(){
    ll N,M;cin >> N >> M;
    vector<ll> k(M),p(M);
    vector<vector<ll> > s(M);
    rep(i,M){
        cin >> k[i];
        rep(j,k[i]){
            ll s_;cin >> s_;
            s[i].push_back(s_);
        }
    }
    rep(i,M)cin >> p[i];

    ll ans=0;
    for(ll bit=0;bit<(1<<N);++bit){
        vector<ll> v;
        for(int j=0;j<=10;++j){
            if(bit & (1<<j))v.push_back(j);
        }
        bool ok=true;
        rep(i,M){
            ll sum=0;
            for(auto it1: s[i]){
                for(auto it2: v){
                    if(it1==(it2+1))sum++;
                }
            }
            if(p[i]!=(sum%2))ok=false;
        }
        if(ok)ans++;
    }

    cout << ans << endl;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

struct mint {
    long long x;
    mint(long long x=0):x(x % MOD + (0 <= x ? 0 : MOD)) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint& a) { if ((x += a.x) >= MOD) x -= MOD; return *this; }
    mint& operator-=(const mint& a) { if ((x -= a.x) < 0) x += MOD; return *this; }
    mint& operator*=(const mint& a) { (x *= a.x) %= MOD; return *this; }
    mint operator+(const mint& a) const { return mint(x) += a; }
    mint operator-(const mint& a) const { return mint(x) -= a; }
    mint operator*(const mint& a) const { return mint(x) *= a; }

    // for prime mod
    mint inv() const {
        long long a = x, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        return mint(u);
    }
    mint& operator/=(const mint& a) { return *this *= a.inv(); }
    mint operator/(const mint& a) const { return mint(x) /= a; }
};
istream& operator>>(istream& is, const mint& a){ return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a){ return os << a.x; }

struct Combination{
    vector<long long> fac, finv, inv;
    Combination(int n=1001001):fac(n+1), finv(n+1), inv(n+1) {
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i <= 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 operator()(int n, int k) const {
        if (n < k || n < 0 || k < 0) return 0;
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
    }
};

long long mod_pow(long long x, long long n, int M=1000000007) {
    long long ret = 1;
    while(n) {
        if(n & 1) (ret *= x) %= M;
        (x *= x) %= M;
        n >>= 1;
    }
    return ret;
}

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

    Combination C;

    mint ans = 0;
    for (int i = 1; i <= N; ++i) {
        ans += (mint)C(N, i) * mod_pow(9, N - i);
    }
    ans *= 2;
    ans += mod_pow(8, N);
    ans -= mod_pow(10, N);

    cout << ans << endl;
}

Measured memory_bytes: 26756
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.Test(process, "../TextFile2.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var s = input.ReadLine();

        var dic = new int[2019];
        for (int i = 0; i < 2019; i++) {
            var x = (i * 10) % 2019;
            //if (dic[x] != 0)
            //    throw new Exception();
            dic[i] = x;
        }
        //for (int i = 0; i < 2019; i++) {
        //    Debug.WriteLine(i + ":" + dic[i]);
        //}

        var tbl = new long[2019];
        var tbl2 = new long[2019];
        var tbl3 = new long[2019];

        var len = s.Length;

        for (int i = 0; i < len; i++) {
            int c = s[i] - '0';

            for (int j = 0; j < tbl.Length; j++) {
                var par = (dic[j] + c) % 2019;
                tbl3[par] = tbl2[j];
            }
            for (int j = 0; j < tbl.Length; j++) {
                tbl[j] += tbl3[j];
                tbl2[j] = tbl3[j];
                tbl3[j] = 0;
            }
            if (c != 0) {
                tbl2[c % 2019] += 1;
            }
        }

        return tbl[0];
    }
}


Measured memory_bytes: 26628
import fractions
A, B, C, D = (int(x) for x in input().split())

C_ = int(B//C) - int((A-1)//C)
D_ = int(B//D) - int((A-1)//D)

E = int(C * D // int(fractions.gcd(C, D)))
E_ = int(B//E) - int((A-1)//E)

ans = B - A + 1 - C_ - D_ + E_
print(ans)


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

using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  int penalty[N];
  bool cleared[N];
  // init
  for (int i = 0;i < N;i++) {
    penalty[i] = 0;
    cleared[i] = false;
  }

  for (int i = 0;i < M;i++) {
    int problem_number;
    string result;
    cin >> problem_number >> result;
    problem_number--;
    if (result.compare("AC") == 0) {
      cleared[problem_number] = true;
    } else {
      if (!cleared[problem_number])
        penalty[problem_number]++;
    }
  }

  int num_of_clear = 0;
  int num_of_penalty = 0;
  for (int i = 0;i < N;i++) {
    if (cleared[i]) {
      num_of_clear++;
      num_of_penalty += penalty[i];
    }
  }
  cout << num_of_clear << " " << num_of_penalty << endl;

  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/
constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vl a(n);
	cin>>a;
	ll ans=a[0];
	rep(i,n){
		ans=gcd(ans,a[i]);
	}
	puta(ans);
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main{
    public static void main(String[] args){
            int a, b, aLen, bLen,i;
            String A,B,sumA="",sumB="";
            Scanner scan = new Scanner(System.in);

            a = scan.nextInt();
            b = scan.nextInt();
            aLen = a;
            bLen = b;
            A = Integer.toString(a);
            B = Integer.toString(b);

            for(i=1;i<=bLen;i++){
                sumA += A;
            }

            for(i=1;i<=aLen;i++){
                sumB += B;
            }

            if(sumA.length() > sumB.length()){
                System.out.println(sumA);
            }
            if(sumA.length() < sumB.length()){
                System.out.println(sumB);
            }
            if(sumA.length() == sumB.length()){
                System.out.println(sumA);
            }


    }
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
int func(int n){
	int ans=0;
	for(int i=1;i<=n;i++){
		if(n%i==0)ans++;
	}
	return ans;
}
int main() {
	int n;cin>>n;
	int ans=0;
	for(int i=1;i<=n;i+=2){
		if(func(i)==8)ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
n,a,b=map(int,input().split())

def comb(n,a,mod):
  x,y=1,1
  for i in range(a):
    x=(x*(n-i))%mod
    y=(y*(i+1))%mod
  return x*pow(y,mod-2,mod)%mod

mod=10**9+7
ans=pow(2,n,mod)-1-comb(n,a,mod)-comb(n,b,mod)
print(ans%mod)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
int main() {
	int a, b, v, w, t;
	scanf("%d%d%d%d%d", &a, &v, &b, &w, &t);
	int d = abs(a - b);
	if (v <= w) {
		printf("NO\n");
	} else printf((ll)(v - w) * t >= d ? "YES\n" : "NO\n");
}


Measured memory_bytes: 3752
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <array>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

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

    constexpr int P = 37, K = P + 1, N = P * P + K;

    vector<array<int, K>> x(N);
    for (int a = 0; a < P; a++) {
        for (int b = 0; b < P; b++) {
            int i = P * a + b;
            int t = b;
            for (int j = 0; j < P; j++) {
                x[i][j] = P * j + t;
                t += a; if (t >= P) t -= P;
            }
            x[i][P] = P * P + a;
        }
    }
    for (int a = 0; a <= P; a++) {
        int i = P * P + a;
        for (int j = 0; j < P; j++) {
            x[i][j] = P * a + j;
        }
        x[i][P] = N - 1;
    }

    cout << N << ' ' << K << '\n';
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < K; j++) {
            cout << x[i][j] + 1 << " \n"[j == K - 1];
        }
    }

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN=1e6+5;

int main(){
    ios::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);
    int a,b,n;
    cin >> n;
    if (n==1)
		cout << "Hello World";
	else 
	{
		cin >> a >> b;
		cout << a+b;
	}
}


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

int main(){
	int a,b;
	cin>>a>>b;
	if(a>b){
		cout<<"a > b"<<endl;
	}
	else if(a<b){
		cout<<"a < b"<<endl;
	}
	else{
		cout<<"a == b"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3084
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

#define debug(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(int i=0;i<(n);i++)
#define fori(a,b,i) for(int i=(a);i<=(b);i++)
#define ford(a,b,i) for(int i=(a);i>=(b);i--)
#define fast_io ios_base::sync_with_stdio(false) , cin.tie(NULL);


#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007

#define fir first
#define sec second
#define pb push_back
#define mp make_pair

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MII;
typedef set<int> SI;
typedef long long int llint;

llint n, e;
llint height[500000];

bool bfs(llint root, vector <llint> v[]){
	bool vis[n+1];
	memset(vis, 0, sizeof(vis));
	vis[root] = 1;
	queue <llint> q;
	q.push(root);
	while(!q.empty()){
		llint x = q.front();
		q.pop();
		for(auto i : v[x]){
			if(!vis[i]){
				vis[i] = 1;
				q.push(i);
				height[i] = 1 + height[x];
			}
		}
	}
	for(int i = 1; i <= n; ++i) if(!vis[i]) return false;
	return true;
}



int main(){
	cin>>n>>e;
	vector <llint> v[n+1];
	loop(i, e){
		llint a, b;
		cin>>a>>b;
		v[a].pb(b);
		v[b].pb(a);
	}
	if(!bfs(1, v)) { cout<<"No"; return 0; }
	cout<<"Yes"<<endl;
	for(int i = 2; i < n+1; ++i){
		llint mdis = INF, ans = -1;
		for(auto j : v[i]){
			if(height[j] < mdis){
				mdis = height[j];
				ans = j;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 12948
//In The Name of ALLAH//

/*      ______     _    _______
       |  ___ \   | |  |  ____/   /\
       | |   \ \  | |  | |       /  \
       | |___/ /  | |  | |___   / /\ \
       |     _/   | |  |  __/  / /__\ \
       | |\ \     | |  | |    / ______ \
       | | \ \    | |  | |   / /      \ \
       |_|  \_\   |_|  |_|  /_/        \_\
*/

#include<bits/stdc++.h>

//#define FILEIO
#define ll long long

using namespace std;

const int SZ = 105;
const int LIM = 1000000000;
const double EPS = 1e-9;
const int MOD = 100000008;
const int INF = ( 1 << 30 ) - 1;
const double PI = 2 * acos( 0.0 );

template <class T> T MIN(T a, T b) { return (a < b) ? a : b; }
template <class T> T MAX(T a, T b) { return (a > b) ? a : b; }
template <class T> void SWAP(T &a, T &b) { T c; c = a; a = b; b = c; }
template <class T> T GCD(T a, T b) { T c; while(b > 0) { c = a % b; a = b; b = c; } return a; }

bool CMP(int a, int b)
{
    return (a > b);
}

ll ans, mn, mx, n, m, t, k, len, sum = 0, i, cnt, j, a[SZ][SZ], b[SZ][SZ];

void read()
{
    cin >> n >> m;
}

void solve()
{
    for(i = 0; i < n; i++)
    {
        for(j = 0; j < m; j++)
        {
            cin >> a[i][j];
            a[i][m] += a[i][j];
            a[n][j] += a[i][j];
            a[n][m] += a[i][j];
        }
    }
    for(i = 0; i <= n; i++)
    {
        for(j = 0; j < m; j++)
        {
            cout << a[i][j] << " ";
        }
        cout << a[i][m] << endl;
    }
}

int main()
{
    #ifdef FILEIO
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    //ll tc, t = 0;

    //while(tc--)
    //{
        read();
        solve();
    //}

    return 0;
}



Measured memory_bytes: 3140
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    #divisors.sort()
    return divisors

N = int(input())
list =  make_divisors(N)
ans = 10**9
if len(list)%2==1:
    list.append(list[-1])
for i in range(0,len(list),2):
    tmp1 = len(str(list[i]))
    tmp2 = len(str(list[i+1]))
    ans = min(ans,max(tmp1,tmp2))
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;

int main(){ 
  int n;
  cin >> n;
  
  queue<string> que;
  
  for (int i = 1; i <= 9; i++) {
    que.push(to_string(i));
  }
  vector<string> res;
  while (res.size() <= n) {
    auto now = que.front();
    que.pop();
    res.emplace_back(now);
    for (int i = 0; i <= 9; i++) {
      int d = now.back() - '0';
      auto tmp = now;
      tmp += char(i + '0');
      if (abs(d - i) <= 1) que.push(tmp);
    }
  }
  //for (auto e : res) cout << e << " ";
  cout << res[n-1] << endl;
  return 0;
} 

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

using namespace std;

#define INF 1ll << 62
#define pb push_back
#define ii pair<int,int>
#define OK cout<<"OK"<<endl
#define debug(x) cout << #x " = " << (x) << endl
#define ff first
#define ss second
#define int long long

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

	int n,k;

	cin >> n>> k;

	cout << (n%k != 0) << endl;
	
}

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

using namespace std;

//DEFINE---{{{
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b); i > (a); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
//end.DEFINE---}}}

//end.template ---}}}

int main() {

  int a, b, c, d;

  cin >> a >> b >> c >> d;

  int ac_len = c - a;
  int ab_len = b - a;
  int bc_len = c - b;

  if (ac_len < 0) ac_len *= -1;
  if (ab_len < 0) ab_len *= -1;
  if (bc_len < 0) bc_len *= -1;

  if (ac_len <= d) {
    cout << "Yes" << endl;
  }
  else {
    if (ab_len <= d && bc_len <= d) cout << "Yes" << endl;
    else cout << "No" << endl;
  }

  return (0);
}

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

#define fir first
#define sec second
#define MP make_pair
#define PB push_back

using namespace std;
typedef long long LL;
typedef unsigned long long u64;

template <typename T> inline bool cmin(T & a, const T & b) { return a > b ? a = b, 1 : 0;}
template <typename T> inline bool cmax(T & a, const T & b) { return a < b ? a = b, 1 : 0;}
int read() {
	int x = 0, f = 1;char ch;
	for(ch = getchar(); !isdigit(ch); ch = getchar())
		if(ch == '-') f = -1;
	for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
	return x * f;
}

const int MaxN = 301234;

int n, m, l[MaxN], r[MaxN], x[MaxN], bit[MaxN];
void add(int p, int d) {
	for(; p <= m; p += p & -p) bit[p] += d;
}

int query(int p) {
	int ans = 0;
	for(; p; p -= p & -p) ans += bit[p]; return ans;
}

bool cmp(int x, int y) {
	return r[y] - l[y] > r[x] - l[x];
}

int main() {
	int i, j, k, p; 
	n = read(); m = read();
	for(i = 1; i <= n; i++) {
		l[i] = read(); r[i] = read(); x[i] = i;
	}
	sort(x + 1, x + n + 1, cmp);
	for(i = k = 1; i <= m; i++) {
		while(k <= n && r[p = x[k]] - l[p] + 1 < i) add(l[p], 1), add(r[p] + 1, -1), ++k;
		int ans = 0;
		for(j = i; j <= m; j += i)
			ans += query(j);
		printf("%d\n", ans + n - k + 1);
	}
	return 0;
}


Measured memory_bytes: 4864
n,m = map(int,input().split())
L = []
R = []
for i in range(m):
    l,r = map(int,input().split())
    L.append(l)
    R.append(r)
L = sorted(L,reverse = True)
R = sorted(R)
x = R[0]-L[0]
if x<0:
    print(0)
else:
    print(x+1)



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

typedef pair<int,int> pint;

vector<pint> A;
bool cmp(pint a, pint b) { return a.second < b.second; }

int main() {
    int N, M;
    cin >> N >> M;
    A.resize(M);
    for ( int i = 0; i < M; ++i){
        cin >> A[i].first >> A[i].second;
    }
    
    // 2つ目の昇順で並び替え
    sort(A.begin(),A.end(),cmp);
    int res = 0;
    int endtime = 0;
    for ( int i = 0; i < M; ++i){
        if ( A[i].first >= endtime ){
            endtime = A[i].second;
            ++res;
        }
    }
    
    cout << res << endl;
    
    return 0;
}

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

double angle(int h, int m){
    return M_PI*h/6 + M_PI*m/360 - M_PI*m/30;
}

int main()
{
    int a, b, h, m; cin >> a >> b >> h >> m;
    double c2 = a*a + b*b - 2*a*b*cos(angle(h,m));
    // cout << angle(h,m) << endl;
    printf("%.10lf\n", sqrt(c2));
}

Measured memory_bytes: 4264
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>
#define _USE_CMATH_DEFINES

const long INF = (1l << 30);
const long LINF = (1l << 60); //1.15*10^18

double a, b, h, m;

int main(){
    scanf("%lf%lf%lf%lf", &a, &b, &h, &m);
    double t = 30 * h - 11.0 / 2.0 * m;
    t *= 2 * M_PI / 360.0;
    printf("%.15lf\n", std::sqrt(a * a + b * b - 2 * a * b * std::cos(t)));
}


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

#define rep(i,n) for(int i = 0; i < n; ++i)
#define reps(i,a,n) for(int i = (a); i < n; ++i)
using namespace std;


using ll = long long;
using ull = unsigned long long;

int main(){
    ll n;
    while(cin >> n, n){
        string s;
        cin >> s;
        int a = 0;
        ll b = 1;
        rep(i, 52){
            b = b*2 + (s[i]-'0');
        }
        ll B = b;
        const ll Z = (1LL << 53)-1;
        while(n > 0){
            //cout << "$";rep(i, 12){cout << ((a>>(11-i))&1);}cout << "|";rep(i, 52){cout << ((b>>(51-i))&1);} cout << endl;

            if(B == 0) break;

            ll d = (Z - b)/B;
            //printf("# %llx %llx %llx %d\n", b, B, Z, d);
            if(d == 0 ){
                //puts("#");
                ++a;
                b += B;
                b >>= 1;
                B >>= 1;
                --n;
                continue;
            }
            d = min(d, n);

            //puts("$");
            b += B * d;
            n -= d;
        }
        //puts("FIN");

        rep(i, 12){
            cout << ((a>>(11-i))&1);
        }
        //cout << "|";
        rep(i, 52){
            cout << ((b>>(51-i))&1);
        }
        cout << endl;

    }
}

/*
0000000000000000000000000000000000000000000000000000

0000000000010000000000000000000000010000000000000000000000000000
0000000000010000000000000000000000000000000000000000000000000000

# 10000000000000 10000000000000 20000000000000

# 
10000000000000
10000000000000
20000000000000

*/


Measured memory_bytes: 3108
from collections import deque
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
to = [[] for _ in range(n)]

for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    to[a].append(b)
    to[b].append(a)

que = deque([])
que.append(0)

f_inf = float("inf")
dist = [f_inf for _ in range(n)]
dist[0] = 0

pre = [-1 for _ in range(n)]

while que:
    v = que.popleft()
    for u in to[v]:
        if dist[u] != f_inf: continue
        dist[u] = dist[v] + 1
        pre[u] = v
        que.append(u)

print("Yes")
for i in range(n):
    if i == 0: continue
    ans = pre[i]
    ans += 1
    print(ans)

Measured memory_bytes: 34784
#include<stdio.h>
int main() {
 long long int h,n;
 long long int i,sum=0;
 scanf("%lld %lld",&h,&n);
 for(i=0;i<n;i++) 
 { 
   long long int m;
   scanf("%lld",&m);
   sum = sum + m;     
 }
    if(sum>=h)
   { printf("Yes\n"); }  
    else {printf("No\n"); } 
        
  
    
    
    return 0;
}

Measured memory_bytes: 1640
def solve(N, AB):
    def getMedian(A):
        if N % 2 == 0:
            m1 = A[N // 2 - 1]
            m2 = A[N // 2]
            m = (m1 + m2) / 2
        else:
            m = A[N // 2]
        return m

    A = sorted(a for a, b in AB)
    B = sorted(b for a, b in AB)
    if N % 2 == 0:
        return int(2 * (getMedian(B) - getMedian(A))) + 1
    else:
        return getMedian(B) - getMedian(A) + 1


(N,) = [int(x) for x in input().split()]
AB = [[int(x) for x in input().split()] for i in range(N)]
print(solve(N, AB))


Measured memory_bytes: 125676
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    long long sum=0,m=0;
    cin >> n >>k;
    int x=abs(n-k);
    int arr[n];
    for (int i=0; i<n; i++)
    {
        cin >> arr[i];
        m+=arr[i];
    
   // cout << m;
        
    }
    if (n==k||k>n)
    cout << 0<< "\n";
    else if (k==0)
    cout << m <<"\n";
    else
    {
    sort(arr,arr+n);
    for(int i=n-1;i>=x;i--)
    {
        //cout << i << " " <<arr[i] <<"\n";
        sum+=arr[i];
    }
   cout <<abs(sum-m)<<"\n";

}


    /*
    int t;
    cin >> t;
    vector<int>r;
    vector<int>l;
    map<int,int>mp;
    map<int,int>li;
    map<int,int>rt;
    for (int i=0; i<t; i++)
    {
        char c;
        int id;
        cin >> c >> id;
        mp[id]++;
        if (c=='R')
        {
            if (mp[id]==1)
            {
                r.push_back(id);
                rt[id]++;

            }
            else if (c=='L')
            {
                if (mp[id]==1)
                {
                    l.push_back(id);
                    li[id]++;
                }
                else if (c=='?')
                {


                }
            }*/

    return 0;
}


Measured memory_bytes: 4356
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <climits>
typedef long long ll;
using namespace std;

struct Node{
  int f;
  int k;
  vector<int> e;
};

struct Edge{
  int a,b,c;
};

static Edge edge[100010];
static Node node[100010];
int x=0;

void color(int prev,int i,int c){
  if(c>x){
    x=c;
  }
  node[i].f=c;
  int t=1,to,edgeid;
  for(int j=0;j<node[i].e.size();j++){
    edgeid=node[i].e[j];
    if(edge[edgeid].a==i){
      to=edge[edgeid].b;
    }
    else{
      to=edge[edgeid].a;
    }

    if(to==prev){
      continue;
    }
    else{
      if(t==c){
        t++;
      }
      edge[edgeid].c=t;
      color(i,to,t);
      t++;
    }
  }
  return;
}

int main(void){
  int n,i,a,b;

  cin>>n;
  for(i=0;i<n-1;i++){
    cin>>edge[i].a>>edge[i].b;
    node[edge[i].a].e.push_back(i);
    node[edge[i].b].e.push_back(i);
  }

  color(-1,1,0);

  printf("%d\n",x);
  for(i=0;i<n-1;i++){
    printf("%d\n",edge[i].c);
  }

  return 0;
}



Measured memory_bytes: 10880
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int inf = 1001001001;
 
int main(){

    ll N,waka=0;
    cin >> N;
    vector<string> data(N);
    map<string,ll> masa;
    rep(i,N){
        cin >> data.at(i);
        masa[data.at(i)]++;
        chmax(waka,masa[data.at(i)]);
    }

    vector<string> ans;
    for(auto x: masa){
        if(x.second==waka){
            ans.push_back(x.first);
        }
    }

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

    rep(i,ans.size()){
        cout << ans.at(i) << endl;
    }
   
    
}

Measured memory_bytes: 28404
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N,P;
    cin >> N >> P;
    while(N){
        int num = P,turn = 0;
        vector<int> V(N);
        while(1){
            if(num){
                V[turn]++;
                num--;
            }else{
                num = V[turn];
                V[turn] = 0;
            }
            if(!num){
                int cnt = 0,ans;
                rep(i,0,N){
                    cnt += V[i] != 0;
                    if(V[i] != 0)ans = i;
                }
                if(cnt == 1){
                    cout << ans << endl;
                    break;
                }
            }
            turn = (turn + 1) % N;
        }
        cin >> N >> P;
    }
}


Measured memory_bytes: 3080
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <complex>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

typedef complex<double> C;
typedef vector<double> vd;
void fft(vector<C>& a) {
    int n = sz(a), L = 31 - __builtin_clz(n);
    static vector<complex<long double>> R(2, 1);
    static vector<C> rt(2, 1);  // (^ 10% faster if double)
    for (static int k = 2; k < n; k *= 2) {
        R.resize(n); rt.resize(n);
        auto x = polar(1.0L, acos(-1.0L) / k);
        rep(i,k,2*k) rt[i] = R[i] = i&1 ? R[i/2] * x : R[i/2];
    }
    vi rev(n);
    rep(i,0,n) rev[i] = (rev[i / 2] | (i & 1) << L) / 2;
    rep(i,0,n) if (i < rev[i]) swap(a[i], a[rev[i]]);
    for (int k = 1; k < n; k *= 2)
        for (int i = 0; i < n; i += 2 * k) rep(j,0,k) {
            // C z = rt[j+k] * a[i+j+k]; // (25% faster if hand-rolled)  /// include-line
            auto x = (double *)&rt[j+k], y = (double *)&a[i+j+k];        /// exclude-line
            C z(x[0]*y[0] - x[1]*y[1], x[0]*y[1] + x[1]*y[0]);           /// exclude-line
            a[i + j + k] = a[i + j] - z;
            a[i + j] += z;
        }
}
vd conv(const vd& a, const vd& b) {
    if (a.empty() || b.empty()) return {};
    vd res(sz(a) + sz(b) - 1);
    int L = 32 - __builtin_clz(sz(res)), n = 1 << L;
    vector<C> in(n), out(n);
    copy(all(a), begin(in));
    rep(i,0,sz(b)) in[i].imag(b[i]);
    fft(in);
    for (C& x : in) x *= x;
    rep(i,0,n) out[i] = in[-i & (n - 1)] - conj(in[i]);
    fft(out);
    rep(i,0,sz(res)) res[i] = imag(out[i]) / (4 * n);
    return res;
}

typedef vector<ll> vl;
template<int M> vl convMod(const vl &a, const vl &b) {
    if (a.empty() || b.empty()) return {};
    vl res(sz(a) + sz(b) - 1);
    int B=32-__builtin_clz(sz(res)), n=1<<B, cut=int(sqrt(M));
    vector<C> L(n), R(n), outs(n), outl(n);
    rep(i,0,sz(a)) L[i] = C((int)a[i] / cut, (int)a[i] % cut);
    rep(i,0,sz(b)) R[i] = C((int)b[i] / cut, (int)b[i] % cut);
    fft(L), fft(R);
    rep(i,0,n) {
        int j = -i & (n - 1);
        outl[j] = (L[i] + conj(L[j])) * R[i] / (2.0 * n);
        outs[j] = (L[i] - conj(L[j])) * R[i] / (2.0 * n) / 1i;
    }
    fft(outl), fft(outs);
    rep(i,0,sz(res)) {
        ll av = ll(real(outl[i])+.5), cv = ll(imag(outs[i])+.5);
        ll bv = ll(imag(outl[i])+.5) + ll(real(outs[i])+.5);
        res[i] = ((av % M * cut + bv) % M * cut + cv) % M;
    }
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<ll> a(n), b(m), c;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < m; i++) cin >> b[i];
    c = convMod<998244353>(a, b);
    for (ll i : c) cout << i << ' ';
}


Measured memory_bytes: 138816
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			while (true)
			{
				int[] abcd = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
				if (abcd.Sum() == 0) break;
				f(abcd);
			}
		}

		// ((a ? b) ? (c ? d))
		// (((a ? b) ? c) ? d)
		// ((a ? (b ? c)) ? d)

		static void f(int[] abcd)
		{
			string op = "+-*";
			bool flg = false;
			foreach (var p in GetPermutations(new[] { 0, 1, 2, 3 }))
			{
				for (int i = 0; i < 3; i++)
				{
					for (int j = 0; j < 3; j++)
					{
						for (int k = 0; k < 3; k++)
						{
							if (c(c(abcd[p[0]], abcd[p[1]], op[i]), c(abcd[p[2]], abcd[p[3]], op[j]), op[k]) == 10)
							{
								Console.WriteLine("(({0} {4} {1}) {6} ({2} {5} {3}))",
									abcd[p[0]], abcd[p[1]], abcd[p[2]], abcd[p[3]],
									op[i], op[j], op[k]);
								flg = true;
								return;
							}
							if (c(c(c(abcd[p[0]], abcd[p[1]], op[i]), abcd[p[2]], op[j]), abcd[p[3]], op[k]) == 10)
							{
								Console.WriteLine("((({0} {4} {1}) {5} {2}) {6} {3})",
									abcd[p[0]], abcd[p[1]], abcd[p[2]], abcd[p[3]],
									op[i], op[j], op[k]);
								flg = true;
								return;
							}
							if (c(c(abcd[p[0]], c(abcd[p[1]], abcd[p[2]], op[i]), op[j]), abcd[p[3]], op[k]) == 10)
							{
								Console.WriteLine("(({0} {5} ({1} {4} {2})) {6} {3})",
									abcd[p[0]], abcd[p[1]], abcd[p[2]], abcd[p[3]],
									op[i], op[j], op[k]);
								flg = true;
								return;
							}
						}
					}
				}
			}
			if (!flg)
				Console.WriteLine(0);
		}

		static int c(int n1, int n2, char op)
		{
			if (op == '+')
				return n1 + n2;
			else if (op == '-')
				return n1 - n2;
			else if (op == '*')
				return n1 * n2;
			return 0;
		}

		static IEnumerable<int[]> GetPermutations(int[] nums)
		{
			if (nums.Count() == 1)
			{
				yield return new int[1] { nums.First() };
			}
			else
			{
				foreach (var s in GetPermutations(nums.Skip(1).ToArray()))
				{
					for (int i = 0; i <= s.Count(); i++)
					{
						var tmp = s.ToList();
						tmp.Insert(i, nums.First());
						yield return tmp.ToArray();
					}
				}
			}
		}
	}
}

Measured memory_bytes: 6096
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int n;
  cin >> n;
  VEC<LL> a(n), b(n), mi(n);
  REP(i, 0, n) {
    cin >> a[i] >> b[i];
    if (a[i] % b[i] == 0)
      mi[i] = 0;
    else
      mi[i] = b[i] - a[i] % b[i];
  }
  // DUMP(mi);
  LL minus = 0;
  for (int i = n - 1; i >= 0; --i) {
    mi[i] -= minus;
    if (mi[i] < 0) {
      mi[i] = mi[i] + (LL)(ceil((double)abs(mi[i]) / b[i]) * b[i]);
    }
    minus += mi[i];
  }
  cout << minus << endl;

  return 0;
}


Measured memory_bytes: 2560