akhauriyash/Code-Regression huggingface dataset:
import collections
import sys

S1 = collections.deque()
S2 = collections.deque()

for i, j in enumerate(sys.stdin.readline()):
    if j == '\\':
        S1.append(i)
    elif j == '/':
        if S1:
            left_edge = S1.pop()
            new_puddle = i - left_edge
            while S2 and (S2[-1][0] > left_edge):
                new_puddle += S2[-1][1]
                S2.pop()
            S2.append((left_edge, new_puddle))
        else:
            pass


print(sum(j for i, j in S2))

print(len(S2), *(j for i, j in S2))

Measured memory_bytes: 8472
n=int(input())
A=list(map(int,input().split()))

c=0
flag=1
while flag:
    flag=0
    for i in range(n-1,0,-1):
        if A[i]<A[i-1]:
            A[i],A[i-1]=A[i-1],A[i]
            c+=1
            flag=1
print(' '.join(map(str, A)))
print(c)


Measured memory_bytes: 5600
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
const int maxStore = 2e5 + 5;
int nbStore, sj, totNeg, totZer;
ll sum[maxStore];
struct STORE {
	ll slope, add;
	STORE operator = (const STORE &d) {
		slope = d.slope;
		add = d.add;
		return (*this);
	}
} store[maxStore], zero[maxStore];
ll dp[maxStore][35];
bool cmp1(STORE fir, STORE sec) {
	return (1ll * sec.slope * (fir.add + 1) < 1ll * fir.slope * (sec.add + 1));
}
bool cmp2(STORE fir, STORE sec) {
	return fir.add < sec.add;
}
int main() {
	scanf("%d%d", &nbStore, &sj);
	for (int i = 1; i <= nbStore; ++i) {
		STORE tmp;
		scanf("%lld%lld", &tmp.slope, &tmp.add);
		if (tmp.slope != 0)
			store[++totNeg] = tmp;
		else zero[++totZer] = tmp;
	}
	sort(store + 1, store + totNeg + 1, cmp1);
	sort(zero + 1, zero + totZer + 1, cmp2);
	for (int i = 1; i <= totZer; ++i)
		sum[i] = sum[i - 1] + zero[i].add + 1;
	memset(dp, 0x3f, sizeof(dp));
	dp[0][0] = 0;
	for (int pre = 1; pre <= totNeg; ++pre) {
		dp[pre][0] = 0;
		//前几个取0个应该都是0 
		for (int chos = 1; chos <= 30; ++chos) {
			dp[pre][chos] = dp[pre - 1][chos];
			if (dp[pre - 1][chos - 1] > 1e9)
				continue ;
			ll tmp = (dp[pre - 1][chos - 1] + 1) * (store[pre].slope + 1) + store[pre].add;
			if (tmp > 1e9) break ;
			else dp[pre][chos] = min(dp[pre][chos], tmp);
		}
	}
	int ans = 0;
	for (int chos = 0; chos <= 30; ++chos) {
		ll spare = sj - dp[totNeg][chos];
		if (spare < 0) break ;
		int pos = upper_bound(sum + 1, sum + totZer + 1, spare) - sum;
		ans = max(chos + pos - 1, ans);
	}
	printf("%d\n", ans);
	return 0;
}

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

string divide[4] = {"dream","dreamer","erase","eraser"};

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

    reverse(s.begin(),s.end());
    for(int i=0;i<4;i++){
        reverse(divide[i].begin(),divide[i].end());
    }
    bool can = true;
    for(int i=0;i<s.size();){
        bool can2 = false; //分割出来たらtureにする
        for(int j=0;j<4;j++){
            string d = divide[j];
            if(s.substr(i,d.size())==d){
                can2 = true;
                i+=d.size();
            }
        }
        if(!can2){
            can = false;
            break;
        }
    }
    if(can) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 512
package main

import "fmt"

func main() {
	var days, homeWorks, cost int

	fmt.Scan(&days, &homeWorks)

	for i := 0; i < homeWorks; i++ {
		var c int
		fmt.Scan(&c)
		cost += c
	}

	if days >= cost {
		fmt.Println(days - cost)
	} else {
		fmt.Println(-1)
	}
}


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

using namespace std;

int main() {
  int n; cin >> n;
  for(int i = 1 ; i <= 9 ; ++i) {
    for(int j = 1 ; j <= 9 ; ++j) {
      if(i * j == n) {
        cout << "Yes\n";
        return 0;
      }
    }
  }
  cout << "No\n";
}


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

int main()
{
    string s;
    cin >> s;
    for (int i = 0; i < 19; i++)
    {
        if (s.at(i) == ',')
        {
            s.at(i) = ' ';
        }
    }
    cout << s << endl;
}

Measured memory_bytes: 256
solve :: Char -> String
solve '0' = "pon"
solve '1' = "pon"
solve '2' = "hon"
solve '3' = "bon"
solve '4' = "hon"
solve '5' = "hon"
solve '6' = "pon"
solve '7' = "hon"
solve '8' = "pon"
solve '9' = "hon"

main :: IO ()
main = do
 n <- getLine :: IO String
 putStr $ solve (last n)

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

using namespace std;

typedef long long ll;
const int INF = 1000000000;

struct para
{
    int m, M;
};

vector<para> T;
int l, size;

void Stworz(int n)
{
    int p = 1;
    while (p < n)
        p *= 2;
    l = p;
    size = 2 * p - 1;
    for (int i = 0; i <= size; ++i)
        T.push_back({INF, -INF});
}

void Dodaj(int a, int x)
{
    a += l;
    T[a] = {x, x};
    a /= 2;
    while (a != 0)
    {
        T[a].m = min(T[2 * a].m, T[2 * a + 1].m);
        T[a].M = max(T[2 * a].M, T[2 * a + 1].M);
        a /= 2;
    }
}

int Min(int a, int b)
{
    if (a > b)
        return INF;
    a += l;
    b += l;
    int odp = min(T[a].m, T[b].m);
    while (a / 2 != b / 2)
    {
        if (a % 2 == 0)
            odp = min(odp, T[a + 1].m);
        if (b % 2 == 1)
            odp = min(odp, T[b - 1].m);
        a /= 2;
        b /= 2;
    }
    return odp;
}

int Max(int a, int b)
{
    if (a > b)
        return -INF;
    a += l;
    b += l;
    int odp = max(T[a].M, T[b].M);
    while (a / 2 != b / 2)
    {
        if (a % 2 == 0)
            odp = max(odp, T[a + 1].M);
        if (b % 2 == 1)
            odp = max(odp, T[b - 1].M);
        a /= 2;
        b /= 2;
    }
    return odp;
}

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
        --a[i];
    }
    Stworz(n);
    vector<int> L(n);
    for (int i = 0; i < n; ++i)
    {
        L[i] = Max(0, a[i] - 1);
        if (L[i] == -1e9)
            L[i] = 0;
        else
            ++L[i];
        Dodaj(a[i], i);
    }
    T.clear();
    Stworz(n);
    vector<int> P(n);
    for (int i = n - 1; i >= 0; --i)
    {
        P[i] = Min(0, a[i] - 1);
        if (P[i] == 1e9)
            P[i] = n - 1;
        else
            --P[i];
        Dodaj(a[i], i);
    }
    ll odp = 0;
    for (int i = 0; i < n; ++i)
    {
        ll l = i - L[i] + 1;
        ll p = P[i] - i + 1;
        odp += l * p * (a[i] + 1);
    }
    cout << odp;
    return 0;
}


Measured memory_bytes: 7920
#include <bits/stdc++.h> 
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<int>>;

int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int cnt=1;
    rep(i,n-1){
        if(s[i]!=s[i+1]){
            cnt++;
        }
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 3696
#include<iostream>
#include<algorithm>

using namespace std;

#define REP(s,e) for(int i=(s);i<(e);i++)

int main(){
    //2 46911
    int x,y;
    int g[]={0,0,1,0,2,0,2,0,0,2,0,2,0,0,0};
    
    cin>>x>>y;
    
    if(g[x]==g[y]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
// #pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vii = vector<int>;
using pii = pair<int, int>;
template <typename T = vii> 
using vec = vector<T>;

const ll INF = numeric_limits<ll>::max(),
         MOD = 1e9 + 7;

const int INF_i = numeric_limits<int>::max(),
          MAX = 1e6;

int main() {
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    // freopen("in.in", "r", stdin);
    
    int m, k;
    cin >> m >> k;
    int n = 1 << m;
    if (k >= n or k == 1 and m == 1) {
        cout << "-1\n";
        return 0;
    }
    
    if (m == 1) {
        cout << "1 1 0 0\n";
        return 0;
    }
    
    vii x, y;
    if (k == 0) {
        x.resize(n - 1);
        iota(x.begin(), x.end(), 1);
    }
    else {
        x.resize(2);
        if (k == n - 1) {
            x[0] = k - 1;
            x[1] = 1;
        }
        else {
            x[0] = n - 1;
            x[1] = x[0] ^ k;
        }
        for (int i = 0; i < n; i++) {
            if (i == k or i == x[0] or i == x[1]) continue;
            y.push_back(i);
        }
    }


    for (int e : y) { cout << e << ' '; }
    cout << k << ' ';
    for (int i = y.size() - 1; i >= 0; i--) { cout << y[i] << ' '; }
    for (int e : x) { cout << e << ' '; }
    cout << k << ' ';
    for (int i = x.size() - 1; i >= 0; i--) { cout << x[i] << ' '; }
    cout << '\n';
}


Measured memory_bytes: 2424
// Try Educational DP Contest
// author: Leonardone @ NEETSDKASU

fn main() {
	let mut stdin = String::new();
	std::io::Read::read_to_string(
		&mut std::io::stdin(),
		&mut stdin).unwrap();
	let mut stdin = stdin.split_whitespace();
	let mut get = || stdin.next().unwrap();
	macro_rules! get {
		($t:ty) => (get().parse::<$t>().unwrap());
		() => (get!(i64));
	}
	
	let n = get!(usize);
    let k = get!(usize);
	let mut hs = vec![];
	for _ in 0..n {
		hs.push(get!());
	}
	let mut dp = vec![std::i64::MAX; n];
	dp[0] = 0;
	use std::cmp::min;
	for i in 0..n-1 {
    	for j in i+1..min(i+k+1,n) {
        	dp[j] = min(dp[j], dp[i]+
            	(hs[i]-hs[j]).abs());
        }
	}
	println!("{}", dp[n-1]);
}

Measured memory_bytes: 8444
//
// Created by yamunaku on 2019/10/15.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> mti;
typedef vector<ll> vl;
typedef vector<vector<ll>> mtl;

struct edge{
    int to;
    int w;
};

struct vertex{
    int x;
    int w;
};

int main(){
    int n, m;
    cin >> n >> m;
    int u, v;
    vector<vector<edge>> e(n);
    rep(i, m){
        cin >> u >> v;
        u--, v--;
        e[u].push_back({v, 1});
        e[v].push_back({u, 2});
    }
    mti flag(n, vi(3, false));
    vi flag2(n, false);
    ll ans = 0;
    rep(i, n){
        if(flag2[i]) continue;
        queue<vertex> q;
        vector<set<int>> st(3);
        q.push({i, 0});
        st[0].insert(i);
        flag[i][0] = true;
        flag2[i] = true;
        int count = 0;
        while(!q.empty()){
            auto now = q.front();
            q.pop();
            for(auto nx:e[now.x]){
                int w = (now.w+nx.w)%3;
                count++;
                if(flag[nx.to][w]) continue;
                flag[nx.to][w] = true;
                flag2[nx.to] = true;
                q.push({nx.to,w});
                st[w].insert(nx.to);
            }
        }
        if(st[0].empty() || st[1].empty() || st[2].empty()){
            ans += count/2;
        }else if(st[0].find(i)!=st[0].end()&&st[1].find(i)!=st[1].end()){
            ans += (ll)st[0].size()*st[0].size();
        }else{
            ans += (ll)st[0].size()*st[1].size();
            ans += (ll)st[1].size()*st[2].size();
            ans += (ll)st[2].size()*st[0].size();
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 25600
#include <bits/stdc++.h>
#include<math.h>
#include<queue>
#include<cstdio>
#include<set>
#include<map>
using namespace std;
using ll = long long;

int main(){
    ll N,K;
    cin >> N >> K;
    vector<ll> A(N+1);
    for(ll i=1; i<N+1; i++){
        cin >> A.at(i);
    }
    for(ll i=K+1; i<N+1; i++){
        if(A.at(i)>A.at(i-K)) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 4836
n,k=map(int,input().split())

td=[]

for i in range(n):
    a=[]
    a=[int(j) for j in input().split()]
    td.append(a)

from operator import itemgetter
td.sort(key=itemgetter(1))  
td.reverse()
td.sort(key=itemgetter(0))

s=0
l=[]
for i in range(n):
    if s!=td[i][0]:
        s=td[i][0]
        l.append([td[i][1],1])
    else:
        l.append([td[i][1],0])

l.sort(key=itemgetter(0))
l.reverse()

op=0
sp=0
ans=[]
sl=[]
l1=[]

for i in range(n):
    if i<k:
        op+=l[i][0]
        sp+=l[i][1]
        if l[i][1]==0:
            sl.append(l[i][0])
    else:
        if l[i][1]==1:
            l1.append(l[i][0])


ans=[op+sp**2]
sl.sort()
l1.sort()
l1.reverse()

for i in range(min(len(sl),len(l1))):
    ans.append(ans[-1]-sl[i]+l1[i]+sp*2+1)
    sp+=1

print(max(ans))





    



Measured memory_bytes: 33468
#include <iostream>
#include <string>
using namespace std;
int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b, a%b);
}
int main(){
    int n;
    cin >> n;
    long long sum=0;
    int i,j,k;
    for(i=1;i<=n;i++){
        for(j=1;j<=i;j++){
            for(k=1;k<=j;k++){
                int gcd1 = gcd(i,j);
                int gcd2 = gcd(gcd1,k);
                int mt = 1;
                if((j==i)&&(k==j)){
                    mt=1;
                }else if((j==i)||(k==j)){
                    mt=3;
                }else{
                    mt=6;
                }
                sum += mt * gcd2;
            }
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll get(ll x)
{
    return x*x*x*x*x;
}
int main()
{
    ll x;
    cin >>x;
    for(ll i=-500;i<=500;i++)
    {
        int flag=0;
        for(ll j=-500;j<=500;j++)
        {
            if(get(i)-get(j)==x)
            {
                flag=1;
                cout <<i<<" "<<j<<endl;
                break;
            }
        }
        if(flag) break;
    }
}

Measured memory_bytes: 3580
fn main() {
    let n = read::<u64>();
    println!("{}", solve(n));
}

fn solve(n: u64) -> u64 {
    if n % 2 == 1 {
        return 0
    }

    let mut n = n / 2;
    let mut cnt = 0;
    while n > 0 {
        cnt += n / 5;
        n /= 5;
    }

    cnt
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;


int main() {
   
    ll a,b,k;
    cin >> a >> b >> k;
    if(k <= a){
        cout << a-k << " " << b << endl;
    }else if(a <= k and k <= a+b){
        cout << 0 << " " << b - (k-a) << endl;
    }else{
        cout << 0 << " " << 0 << endl;
    }
}

Measured memory_bytes: 256
<?php
// Your code here!
    $N_M = explode(" ",trim(fgets(STDIN)));
    $N = intval($N_M[0]);
    $M = intval($N_M[1]);
    
    $S = fgets(STDIN);
    $T = fgets(STDIN);
    
    $NX = $N;
    $MX = $M;
    while($NX != $MX){
        if ($NX > $MX) {
            $MX = $MX + $M;
        } else {
            $NX = $NX + $N;
        }
    }
    $L = $NX;
    
    $Sword = array();
    $Tword = array();
    if ($S[0] == $T[0]){
        //$Sの条件でwordを作る
       for ($i = 0; $i < $N; $i++) {
           //一文字目
            if ($i == 0) {
                $Sword[1] = $S[0];
            } else {
            //二文字目以降
                $range = $i * $L / $N + 1;
                $Sword[$range] = $S[$i];
            }
        }
        //$Tの条件でwordを作る
        for ($i = 0; $i < $M; $i++) {
           //一文字目
            if ($i == 0) {
                $Tword[1] = $T[0];
            } else {
            //二文字目以降
                $range = $i * $L / $M + 1;
                $Tword[$range] = $T[$i];
            }
        }
        
        $word = $Sword + $Tword;
        $miss = 0;
        foreach ($Tword as $key => $val) {
            if ($word[$key] != $val) {
                $miss++;
            }
        }
        
        if ($miss > 0) {
            $output = -1;
        } else {
            $output = $L;
        }
        
    } else {
        //一文字目が違ってたら-1
        $output = -1;
    }
    
    echo $output;
?>


Measured memory_bytes: 27640
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
  int A,B,C; cin>>A>>B>>C;
  int D=gcd(A,B);
  int ans=0;
  rev(i,D+1){
    if(D%i==0)ans++;
    if(ans==C){
      cout<<i<<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3640
#include<stdio.h>
int main()
{
    int a,b,c,f=0;
    scanf("%d %d %d",&a,&b,&c);
    if(a==b && b==c && c==a) f++;
    if(a!=b && b!=c && c!=a) f++;
    if(f==0){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python3
import sys
from collections import deque

def solve(N: int, S: str):
    r = []
    g = []
    b = []
    rp = 0
    gp = 0
    bp = 0

    rsum = [0]*(N+1)
    bsum = [0]*(N+1)
    gsum = [0]*(N+1)

    for i, x in enumerate(S[::-1]):
        if x ==  "R":
            r.append(i)
            rp = 1
        elif x =="G":
            g.append(i)
            gp = 1
        else:
            b.append(i)
            bp = 1
        rsum[N-1-i] = rsum[N-1-i+1] + rp
        gsum[N-1-i] = gsum[N-1-i+1] + gp
        bsum[N-1-i] = bsum[N-1-i+1] + bp
        rp = 0
        gp = 0
        bp = 0
    ans = 0
    for i in range(N):
        for j in range(i+1, N):
            if S[i] != S[j]:
                if j+j-i<N: k = S[j+j-i]
                else: k = ""
                if (S[i] == "R" and S[j] == "B") or (S[j] == "R" and S[i] == "B"):
                    ans += gsum[j] - (k=="G")*1
                elif (S[i] == "R" and S[j] == "G") or (S[j] == "R" and S[i] == "G"):
                    ans += bsum[j] - (k=="B")*1
                elif (S[i] == "G" and S[j] == "B") or (S[j] == "G" and S[i] == "B"):
                    ans += rsum[j] - (k=="R")*1
    

    print(ans)
  
    return
 
 
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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
    S = next(tokens)  # type: str
    solve(N, S)
 
if __name__ == '__main__':
    main()


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

int main() {
	long long K;
	long long p;
	long long r;

	cin >> K;

	if (K%2==0) {
		cout << -1 << endl;
		return 0;
	}
	if (K%5==0) {
		cout << -1 << endl;
		return 0;
	}
	p=0;
	r=7;
	rep(i, K) {
		p++;
        r%=K;
		if (r==0) {
			cout << p << endl;
			return 0;
		}
		r*=10;
		r+=7;
	}
}


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

int main(void) {
	int w, h, x, y, r;
	cin >> w >> h >> x >> y >> r;
	if ((x - r >= 0 && x + r <= w) && (y - r >= 0 && y + r <= h))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 1160
class Main{
    public static void main(String[] a){
        int i=1,n;
        while(true){
        	if(i<=9){
        		for(int j=1;j<=9;j++){
        			n=i*j;
        			System.out.println(i+"x"+j+"="+n);
        		}
        		i++;
        	}else{
        		break;
        	}
        	
        }
    }
}

Measured memory_bytes: 16920
using System;

public class Hello
{
    public static void Main()
    {
        var t = 100;
        var rmin = 0;
        var asum = 0;
        for (int i = 0; i < 5; i++)
        {
            var w = int.Parse(Console.ReadLine().Trim());
            var ww = ((w + 9) / 10) * 10;
            asum += ww;
            var tw = w % 10;
            if (tw != 0 && tw < t) { t = tw; rmin = ww - w; }
        }
        Console.WriteLine(t == 100 ? asum : asum - rmin);
    }
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;

int dice[6][4]={{1,2,4,3},{0,3,5,2},{0,1,5,4},{0,4,5,1},{0,2,5,3},{1,3,4,2}};
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

void solve(int x,int y,VVI& v,VVI& w,int top,int face){
    //cout<<x<<" "<<y<<" "<<top<<" "<<face<<endl;
    vector<P> vec;
    int var=-1;
    for(int i=0;i<4;i++) if(dice[top][i]==face)var=i;
    for(int i=0;i<4;i++){
        int nx=x+dx[i],ny=y+dy[i];
        if(v[nx][ny]<v[x][y] && dice[top][(i+var)%4]>=3){
            vec.push_back(P(dice[top][(i+var)%4],i*11+var));
        }
    }
    if(vec.size()==0){
        v[x][y]++;
        w[x][y]=top;
        return ;
    }
    sort(vec.rbegin(),vec.rend());
    int i=vec[0].second/11,va=vec[0].second%11;
    if(i==0)solve(x+dx[i],y+dy[i],v,w,dice[top][(2+va)%4],top);
    if(i==1)solve(x+dx[i],y+dy[i],v,w,dice[top][(3+va)%4],dice[top][(0+va)%4]);
    if(i==2)solve(x+dx[i],y+dy[i],v,w,dice[top][(0+va)%4],5-top);
    if(i==3)solve(x+dx[i],y+dy[i],v,w,dice[top][(1+va)%4],dice[top][(0+va)%4]);
    return ;
}

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

  int n;
  while(true){
      cin>>n;if(n==0)break;
      std::vector<int> res(6,0);
      VVI top(200,vector<int>(200,-1)),num(200,vector<int>(200,0));
      for(int i=0;i<n;i++){
          int t,f;cin>>t>>f;t--;f--;
          solve(100,100,num,top,t,f);
      }
     for(int i=0;i<200;i++)for(int j=0;j<200;j++) if(top[i][j]!=-1)res[top[i][j]]++;
      for(int i=0;i<6;i++){cout<<res[i];
      if(i==5)cout<<endl;
      else cout<<" ";}
  }
}

Measured memory_bytes: 3296
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

#ifndef _DEBUG
#define main_ main
#endif
#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<bool> vb;
typedef vector<string> vs;

template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
	return left.second > right.second;
}

void init_global() {}

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

	ll N;  cin >> N;
	ll R = sqrt(N);
	ll ans = INF;
	FOR(i, 1, R + 1) {
		if (N%i == 0) {
			ll b = N / i;
			ll d = to_string(b).size();
			ans = min(ans, d);
		}
	}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int INF = 1 << 30 ;
struct edge{
  int pos, strong ;
  int dp[77];

  edge(int pos, int strong): pos(pos), strong(strong){
    fill_n( dp, 77, INF);
  };
  edge(){};
};

int main(){
  int n; //行数 
  int m; //ジャンプの数

  edge node[152][10];
  int size[152] = {};

  while(scanf("%d %d", &n, &m), n){
    for(int i = 0; i < n; i++){
      int k;
      scanf("%d", size + i);
      for(int j = 0; j < size[i]; j++){
        int x, d;
        scanf("%d %d", &x, &d);
        node[i][j] = edge( x, d);
      }
    }

    for(int i = 0; i < size[0]; i++){ //最初は普通にジャンプ
      node[0][i].dp[0] = 0;
    }
    for(int i = 0; i < size[1]; i++){ //最初はジャンプする
      node[1][i].dp[1] = 0 ;
    }
    for(int i = 0; i < n; i++){
      for(int j = 0; j < size[i]; j++){
        for(int k = 0; k <= m; k++){
          if(node[i][j].dp[k] != INF){
            if(k != m){
              for(int l = 0; l < size[i + 2]; l++){
                node[i + 2][l].dp[k + 1] = min( node[i + 2][l].dp[k + 1], node[i][j].dp[k] + (node[i + 2][l].strong + node[i][j].strong) * abs(node[i + 2][l].pos - node[i][j].pos));
              }
            }
            for(int l = 0; l < size[i + 1]; l++){
              node[i + 1][l].dp[k] = min( node[i + 1][l].dp[k], node[i][j].dp[k] + (node[i + 1][l].strong + node[i][j].strong) * abs(node[i + 1][l].pos - node[i][j].pos));
            }
          }
        }
      }
    }
    int ret = INF ;
    for(int i = 0; i < size[n - 1]; i++){
      for(int j = 0; j <= m; j++){
        ret = min( ret, node[n - 1][i].dp[j]);
      }
    }
    for(int i = 0; i < size[n - 2]; i++){
      for(int j = 0; j < m; j++){
        ret = min( ret, node[n - 2][i].dp[j]);
      }
    }
    printf("%d\n", ret);
  }
}

Measured memory_bytes: 1656
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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 INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int k;
	int ans=0;
	cin >>k;
	int sum=7;
	vector<int> mod(1000010, 7);
	rep(i, 1000000) {
	    if (i != 0) { mod[i] =+ mod[i - 1] * 10+7 ; }
	    mod[i] %= k;
		if(i<10){
			//clog<<mod[i]<<endl;
		}
		if(mod[i]==0){
			cout<<i+1<<endl;
			//clog<<mod[i]<<endl;
			return 0;
		}
	}

	cout<<-1<<endl;
	//部分的にとる
}//素数が課題->素因数分解で可能？

Measured memory_bytes: 7216
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<numeric>
#include<climits>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

int dy[] = {1,0,-1,0};//次に行くところ
int dx[] = {0,1,0,-1};//上に同じ


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

  int x,ans = 8;
  cin >> x;
  for (int i = 400; i < 2000; i += 200){
    if (x >= i && x < i+200){
      cout << ans << '\n';
      return 0;
    }
    ans--;
  }
  
  
  return 0;
}

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

using namespace std;

using a_t = std::bitset<30>;

int solve(const std::vector<a_t>& as) {
  a_t retBits;
  retBits.set();
  for (const auto& a : as) {
    retBits &= a;
  }
  return retBits.count();
}

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int n, m;
  std::cin >> n >> m;
  std::vector<a_t> as(n, a_t(0));
  for (auto& a : as) {
    int k;
    std::cin >> k;
    for (int i = 0; i < k; ++i) {
      int v;
      std::cin >> v;
      a.set(v - 1);
    }
  }
  std::cout << solve(as) << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int n;
    cin>>n;
    int tm = n%10;
    if(tm==3)
    {
        cout<<"bon"<<endl;
    }
    else if(tm==0 || tm==1 || tm==6 || tm==8)
    {
        cout<<"pon"<<endl;
    }
    else
    {
        cout<<"hon"<<endl;
    }
}


Measured memory_bytes: 3604
#include <iostream>

using namespace std;

int main() {
	int A, B, K;

	cin >> A >> B >> K;

	int count = 0;
	for (int i = 100; i >= 1; i--) {
		if (A %i == 0 && B % i == 0) {
			count++;
			if (count == K) {
				cout << i << endl;
				break;
			}
		}
	}

	return 0;
}

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

A,B = map(int,input().split())
C,D = map(int,input().split())

if (A == 1 or A == 3 or A == 5 or A == 7 or A == 8 or A == 10 or A == 12):
  if B == 31:
    print(1)
  else:
    print(0)
elif (A == 4 or A == 6 or A== 9 or A == 11):
  if B == 30:
    print(1)
  else:
    print(0)
elif A == 2:
  if B == 28:
    print(1)
  else:
    print(0)

Measured memory_bytes: 3064
#include <stdio.h>
#define N 100
#define WHITE 0
#define BLACK 1
#define GRAY 2

int represent[N][N],u,color[N],f[N],d[N],tt;

void dfs_cal(int n)
{
  int v;
  color[n]=GRAY;
  d[n]=++tt;
  for(v=0;v<u;v++)
    {
      if(represent[n][v]==0)continue;
      if(color[v]==WHITE)
	{
	  dfs_cal(v);
	}
    }
  color[n]=BLACK;
  f[n]=++tt;
}

void dfs(void)
{
  int i,j,k;
  for(i=0;i<u;i++)
    color[i]=WHITE;
  tt=0;
  for(i=0;i<u;i++)
    {
      if(color[i]==WHITE)dfs_cal(i);
    }
  for(i=0;i<u;i++)
    {
      printf("%d %d %d\n",i+1,d[i],f[i]);
    }
}

int main()
{
  int i,j,k,ade,retu;
 while(1)
    {
      scanf("%d",&u);
      if(u>=1 && u<=N)
	break;
    }
  for(i=0;i<u;i++)
    {
      for(j=0;j<u;j++)
	{
	  represent[i][j]=0;
	}
    }
  for(i=0;i<u;i++)
    {
      scanf("%d",&ade);
      scanf("%d",&k);
      for(j=0;j<k;j++)
	{
	  scanf("%d",&retu);	  
	  represent[ade-1][retu-1]=1;
	}
    }
  dfs();
  return 0;
}



Measured memory_bytes: 2056
#include<stdio.h>
#pragma GCC optimize("O2")
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#define rep(i,N) for(int i=0;i<(int)N;i++)
#define swap(a,b) (a+=b,b=a-b,a-=b)
const int MOD=1e9+7;
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline void Radix32(int *a,const int sz)
{
  int temp[sz],shift=0;
  while(shift<32)
  {
    int u[256]={},v[256]={};
    rep(i,sz)u[(a[i]>>shift)&255]++;
    rep(i,255)u[i+1]+=u[i];
    rep(i,sz){temp[--u[(a[sz-1-i]>>shift)&255]]=a[sz-1-i];}shift+=8;
    rep(i,sz)v[(temp[i]>>shift)&255]++;
    rep(i,255)v[i+1]+=v[i];
    rep(i,sz)a[--v[(temp[sz-1-i]>>shift)&255]]=temp[sz-1-i];
    shift+=8;
  }
}
int main()
{
  int N=IN(),K=IN(),l,m=0,r,accum=1,sign=1,A[N];long x,y;
  rep(i,N)A[i]=IN(),m+=A[i]<0?1:0;
  Radix32(A,N);
  rep(i,m/2)swap(A[N-m+i],A[N-1-i]);
  rep(i,(N-m)/2)swap(A[i],A[N-m-1-i]);
  rep(i,N/2)swap(A[i],A[N-1-i]);
  if(K&1)accum=A[N-1],sign=(A[N-1]<0?-1:1),N--,K--;
  l=0,r=N-1;
  while(K)
  {
    x=1l*A[l]*A[l+1],y=1l*A[r]*A[r-1];
    if(x*sign>y*sign)x%=MOD,accum=1l*accum*x%MOD,l+=2;
    else y%=MOD,accum=1l*accum*y%MOD,r-=2;
    K-=2;
  }
  return printf("%ld\n",(1l*accum%MOD+MOD)%MOD),0;
}

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

int main(){
    string s;
    cin>>s;
    int x,y;
    cin>>x>>y;
    int xs=0,ys=0;
    int state=-1;
    vector<int> xv,yv;
    for(auto c:s){
        if(c=='T'){
            if(xs) xv.push_back(xs);
            if(ys) yv.push_back(ys);
            xs=ys=0;
            state=(state+1)%2;
        }
        else{
            switch(state){
                case -1:{
                    x--; break;
                }
                case 0:{
                    ys++; break;
                }
                case 1:{
                    xs++; break;
                }
            }
        }
    }
    if(xs) xv.push_back(xs);
    if(ys) yv.push_back(ys);
    
    auto knapsack=[](const vector<int>& v,int tar){
        int n=v.size();
        const int OFFSET=8000+5;
        const int SIZE=OFFSET*2+5;;
        vector<vector<int>> dp(2,vector<int>(SIZE,0));
        dp[0][OFFSET]=true;
        for(int i=0;i<n;i++){
            fill(dp[(i+1)&1].begin(),dp[(i+1)&1].end(),0);
            for(int j=0;j<SIZE;j++){
                if(j+v[i]<SIZE) dp[(i+1)&1][j+v[i]]|=dp[i&1][j];
                if(j-v[i]>=0) dp[(i+1)&1][j-v[i]]|=dp[i&1][j];
            }
        }
        return dp[n&1][OFFSET+tar];
    };
    cout<<(knapsack(xv,x) && knapsack(yv,y) ? "Yes" : "No")<<endl;
    
    return 0;
}

Measured memory_bytes: 580
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n = f()[0]
    a = f()

    b = [0] * n

    if n%2 ==0:
        k = n//2
        for i in range(k):
            b[i] = a[n - i * 2-1]
        for i in range(k):
            b[k+i] = a[ i*2]

        for i in b:
            print(i, end=' ')
    else:
        k = n//2+1
        for i in range(k):
            b[i] = a[n - i * 2-1]

        for i in range(k-1):
            b[k+i] = a[(i+1)*2-1]

        for i in b:
            print(i, end=' ')


solve()


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

int main(){
  int N; cin >> N;
  int C[500],S[500],F[500];
  for(int i=0;i<N-1;i++){
    cin >> C[i] >> S[i] >> F[i];
  }
  for(int i=0;i<N;i++){
    int t=0;
    for(int j=i;j<N-1;j++){
      if(t<S[j])t=S[j];
      else if(t%F[j] != 0)
        {t=t+(F[j]-t%F[j]);}
      t += C[j];
    }
    cout << t << endl;
  }
}
      
      
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int ans = 0, i = 0;
  while (i < n) {
    int num = a[i], c = 0;
    while (i < n && num == a[i]) i++, c++;
    ans += c % 2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.solve(in, out);
        out.close();
    }

    static class Solver {
        public void solve(Scanner in, PrintWriter out) {
            long H = in.nextLong();
            long count = 0;
            long loop = 0;

            do {
                count += Math.pow(2, loop);
                loop++;
                H /= 2;
            }
            while (H >= 1);

            out.println(count);
        }
    }
}

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

int main(){
	
	int i, sum=0;
	char number[1000];
	
	while(1){
		scanf("%s",number);
		if(number[0]=='0')break;
		for(i=0;number[i]!='\0';i++){
			sum+=(number[i]-'0');
		}
		printf("%d\n",sum);
		sum=0;
	}
	return 0;
}

Measured memory_bytes: 536
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);

static const int MAX = 50;
vector<bool> used(MAX);
vector<vector<int> > vec(MAX);
int n, m;

void dfs(int v, int x, int y){
    used[v] = true;
    for (const auto & u : vec[v]){
        if ((v == x && u == y) || (v == y && u == x)) continue;
        if (used[u] == true) continue;
        dfs(u, x, y);
    }
}

bool solve(int x, int y){
    bool res = false;
    fill(used.begin(), used.end(), false);
    dfs(0, x, y);
    for (int i = 0; i < n; i++){
        if (!used[i]) res = true;
    }
    return res;
}

int main(){
    int x, y, ans = 0;
    sc(n) sc(m)
    vector<P> edge;
    for (int i = 0; i < m; i++){
        sc(x) sc(y)
        x--; y--;
        vec[x].push_back(y);
        vec[y].push_back(x);
        edge.push_back(P(x, y));
    }
    for (int i = 0; i < edge.size(); i++){
        if (solve(edge[i].first, edge[i].second)) ans += 1;
    }
    cout << ans << endl;
    return 0;
}

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

template<typename T> void drop(const T &x){cout<<x<<'\n';exit(0);}

void solve() {
  int n, w;
  cin >> n >> w;
  const int max_v = 1e5+1;
  const long long INF = 1LL<<60;
  vector<int> x(n), y(n);
  for(int i=0; i<n; ++i) cin >> x[i] >> y[i];

  vector<vector<long long>> dp(n+1, vector<long long>(max_v, INF));
  dp[0][0] = 0;
  for(int i=0; i<n; ++i) {
    for(int j=0; j<max_v; ++j) {
      if(j >= y[i]) dp[i+1][j] = min(dp[i][j], dp[i][j-y[i]] + x[i]);
      else dp[i+1][j] = dp[i][j];
    }
  }
  long long ans = 0;
  for(int i=0; i<max_v; ++i) {
    if(dp[n][i] <= w) ans = i;
  }
  cout << ans << '\n';
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T=1;
  //cin >> T;
  while(T--) solve();

  return 0;
}


Measured memory_bytes: 83196
#include <iostream>
#include <string.h>
using namespace std;

int main() {
	long long int a, b, k;

	cin >> a >> b >> k;

	long long int c = a;
	a = a - k;
	if (a < 0) {
		a = 0;
	}

	long long int t = k - c;
	if (t > 0) {
		b -= t;
	}
	if (b < 0) {
		b = 0;
	}

	cout << a << ' ' << b << "\n";

	return 0;
	
}



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

typedef pair<int, int> iPair;
vector<iPair> AdjList[200005];
int n, m, a, b;

void Dijkstra(int src)
{
    priority_queue< iPair, vector <iPair> , greater<iPair> > PQ;
    long long dist[200005];
    fill(dist, dist+200000, LONG_LONG_MAX);

    PQ.push(make_pair(0, src));
    dist[src] = 0;

    while(!PQ.empty()) {
        iPair P = PQ.top();
        int u = P.second;
        PQ.pop();

        if(dist[u] < P.first) continue;

        for(int i=0; i<AdjList[u].size(); i++) {
            int v = AdjList[u][i].first; //vertex
            int w = AdjList[u][i].second; //weight

            if (dist[v] > dist[u] + w) {
                dist[v] = dist[u] + w;
                PQ.push(make_pair(dist[v], v));
            }
        }
    }

    if(dist[n]<=2) cout << "POSSIBLE" << '\n';
    else cout << "IMPOSSIBLE" << '\n';
}


int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> m;
    for(int i=1; i<=m; i++) {
        cin >> a >> b;
        AdjList[a].push_back(make_pair(b, 1));
    }
    Dijkstra(1);

    return 0;
}

Measured memory_bytes: 12020
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,a,b;
cin>>n>>a>>b;
int ans=0;
for(int i=1;i<=n;i++)
{
    int x=i;
    int tm=0;
    while(x>0)
    {
        tm+=x%10;
        x/=10;
    }
    if(tm>=a&&tm<=b)
    ans+=i;
}
cout<<ans;
return 0;
}
 


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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}

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

  int count = 0;
  map<string, int> m;
  rep(i, N) {
    string S; cin >> S;
    ++m[S];
    chmax(count, m[S]);
  }
  vector<string> ans;
  for (const auto& e : m) {
    if (e.second == count)
      ans.push_back(e.first);
  }
  all(sort, ans);
  for (const auto& e : ans) {
    cout << e << endl;
  }

  return 0;
}


Measured memory_bytes: 26868
#include<iostream>
#include<stdlib.h>
#include<math.h>
#include<algorithm>
#include<string.h>
using namespace std;

int main()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(0);
	string s; cin >> s; int n = s.length(); bool x = true;
	for (int i = 97; i <=122; i++)
	{
		 x = true;
		for (int j = 0; j < n; j++)
		{

			if (char(i) == s[j])
			{
				x = false;
				continue;

			}

		}
	
		if (x== true)
		{
			cout<<char(i)<<endl;
			return 0;
		}
	}
	if (x == false) {
		cout << "None" << endl;
		return 0;
	}
}


Measured memory_bytes: 3740
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ll long long 
#define PB push_back
#define lc 2 * v
#define rc 2 * v + 1
#define mid (s + e) / 2
#define pii pair <int,  int>
#define pll pair <long long , long long>  
#define FAST ios::sync_with_stdio(false);cin.tie(0);
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

const int maxn = 2e5 + 10 , INF = 1e9;

ll a[maxn] , p26[maxn] , cnt[maxn];

int main() {
    FAST
    ll n , q , sum = 0;
    cin >> n;
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
        cnt[a[i]]++;
        sum += a[i];
    }
    cin >> q;
    for (int i = 0; i < q; ++i) {
        ll x , y;
        cin >> x >> y;
        sum -= cnt[x] * x;
        sum += cnt[x] * y;
        cnt[y] += cnt[x];
        cnt[x] = 0;
        cout << sum << endl;
    }
}

Measured memory_bytes: 5140
import std.stdio, std.math, std.algorithm, std.array, std.string, std.conv, std.container, std.range;
pragma(inline, true) T[] Reads(T)() { return readln.split.to!(T[]); }
alias reads = Reads!int;
pragma(inline, true) void scan(Args...)(ref Args args) {
    string[] ss = readln.split;
    foreach (i, ref arg ; args) arg = ss[i].parse!int;
}

void main() {
    int n; scan(n);
    auto a = new int[n];
    foreach (ref i ; a) scan(i);

    auto b = a.dup;
    b.sort();
    int m1 = b[$-1], m2 = b[$-2];
    foreach (i; a) {
        writeln(i == m1 ? m2 : m1);
    } 
}

Measured memory_bytes: 6268
#include <stdio.h>

int solve(int N)
{
    int ans = 0;
    do
    {
        ans += (N % 10);
        N /= 10;

    } while (N);
    return ans;
}

int main()
{
    int N, ans;

    scanf("%d", &N);
    ans = solve(N);
    if (N % ans == 0)
        printf("Yes");
    else
    {
        printf("No");
    }

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int n;
    cin >> n;
    long long a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a,a+n);
    unsigned long long  p = 0,q = 0;
    for(int i = 1;i < n; i++ ){
        if(a[i-1] == a[i]){
            p = q;
            q = a[i];
            a[i-1] = 0;
            a[i] = 0;
        }
    }
    cout << p*q << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
    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: 3624
#include<iostream>
#include<string>
#include<cmath>
#include<vector>

using namespace std;

#define ll long long

int main(){

    int H, W;
    int h, w;

    cin >> H >> W;
    cin >> h >> w;

    cout << H * W - (H * w + W * h) + h * w << endl;

    return 0;


}


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

int main(){
    int n;
    std::cin >> n;
    std::vector<int> h(n);
    for (int i = 0; i < n; i++)
    {
        std::cin >> h[i];
    }
    
    int tmp = *std::max_element(h.begin(), h.end());
    std::vector<int> flag(0);
    for (int i = 0; i < tmp; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (h[j] > 0)
            {
                flag.push_back(1);
            }
            else
            {
                flag.push_back(0);
            }
            h[j]--;
        }
        flag.push_back(0);
    }
    
    int count = 0;
    for (int i = 0; i < (int)flag.size() - 1; i++)
    {
        if (flag[i] == 1 && flag[i + 1] == 0)
        {
            count++;
        }
    }
    
    std::cout << count << std::endl;

    return 0;
}

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


int main()
{
	string s, t;
	cin >> s >> t;
	if (s[0] == t[2] && s[1] == t[1] && s[2] == t[0]) { cout << "YES"; }
	else { cout << "NO"; }

    return 0;
}



Measured memory_bytes: 256
//Anik_Modak
#include<iostream>
using namespace std;

int main()
{
    int a,b,c,x,y;

    cin>>a>>b>>c>>x>>y;

    long long ans=0, mx;

    if(a+b>=2*c){
        if(x>y){
            ans=2*y*c;
            ans+=(x-y)*a;
        }
        else{
            ans=2*x*c;
            ans+=(y-x)*b;
        }
    }
    else ans=x*a+y*b;

    mx=2*max(x,y)*c;
    ans=min(mx,ans);

    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int N, X, T;
    scanf("%d %d %d", &N, &X, &T);
    
    int X2 = X;
    int T2 = T;
    while(X2 < N){
        X2 = X2 + X;
        T2 = T2 + T;
    }

    printf("%d\n", T2);
    return 0;
}

Measured memory_bytes: 1728
using System;
using System.Linq;
using System.Text;

namespace ALDS1_6_A {
    class Program {
        static void Main(string[] args) {
            int n = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');

            int[] A = new int[n + 1];
            int[] B = new int[n + 1];
            int[] C = new int[10001];

            for(int i = 1; i <= n; i++) {
                int temp = int.Parse(input[i - 1]);
                A[i] = temp;
                C[temp]++;
            }

            for(int i = 1; i < 10001; i++) {
                C[i] += C[i - 1];
            }

            for(int i = n; i > 0; i--) {
                int temp = A[i];
                B[C[temp]] = temp;
                C[temp]--;
            }

            StringBuilder sb = new StringBuilder();
            foreach (int b in B.Skip(1))
                sb.AppendFormat(" {0}", b);
            Console.WriteLine(sb.ToString().TrimStart());
        }
    }
}

Measured memory_bytes: 274580
#include <iostream>
#include <vector>
int main(){
  int H, N;
  std::cin >> H >> N;
  int sum = 0;
  for (int i=0; i<N; i++){
    int x;
    std::cin >> x;
    sum += x;
  }
  if (sum>=H) {std::cout << "Yes" << std::endl;}
  else {std::cout << "No" << std::endl;}
  return 0;
}

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

#define MAX (10010)

class UnionFind {
  
 private:
  int par[MAX];
  int rank[MAX];
  
 public:
  void init() {
    for(int i=0; i<MAX; i++) {
      par[i] = i;
      rank[i] = 0;
    }
  }
  
  int find(int x) {
    if(par[x] == x) { return x; }
    return par[x] = find(par[x]);
  }
  
  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    
    if(x == y) return;
    
    if(rank[x] < rank[y]) {
      par[x] = y;
    } else {
      par[y] = x;
      if(rank[x] == rank[y]) rank[x] ++;
    }
  }
  
  bool same(int x, int y) { return find(x) == find(y); }

  UnionFind() { init(); }
};

struct Edge {
  int from, to, cost;
  Edge(int f=-1, int t=-1, int c=-1)
    : from(f), to(t), cost(c) {}
};

bool comp(const Edge& a, const Edge& b) {
  return a.cost < b.cost;
}

int kruskal(vector<Edge>& edges) {

  sort(edges.begin(), edges.end(), comp);
  UnionFind uf;
  vector<int> vec;
  for(int i=0; i<edges.size(); i++) {
    Edge e = edges[i];
    if(!uf.same(e.from, e.to)) {
      uf.unite(e.from, e.to);
      vec.push_back(edges[i].cost);
    }
  }
  sort(vec.begin(), vec.end());
  
  return vec[vec.size()/2];
}

int main() {
  
  int n, m;
  while(cin >> n >> m && (n|m)) {
    vector<Edge> es;
    for(int i=0; i<m; i++) {
      int s, t, c;
      cin >> s >> t >> c; s--, t--;
      es.push_back(Edge(s, t, c));
    }
    cout << kruskal(es) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1532