akhauriyash/Code-Regression huggingface dataset:
//Dragan Andrei Gabriel
//    (-_-)


#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>

using namespace std;

int n;
char s[101];

int main()
{
    scanf("%d\n", &n);
    scanf("%s", s + 1);

    if (n % 2 == 1)
        {
            printf("No\n");
            return 0;
        }

    for (int i = 1; i <= n / 2; i++)
    if (s[i] != s[n / 2 + i])
    {
        printf("No\n");
        return 0;
    }

    printf("Yes\n");

    return 0;
}


Measured memory_bytes: 128
n,x,y = map(int,input().split())


dic = {}
x = x-1
y = y-1
for i in range(n):
    for j in range(n):
        if(i == j):
            break

        nm = abs(j - i)
        if(abs(x-i) > abs(y-i)):
            lp = abs(y-i) + abs(x-j) + 1
        else:
            lp = abs(x-i) + abs(y-j) + 1
        
        k = min(nm,lp)
        if(k in dic):
            dic[k] += 1
        else:
            dic[k] = 1



for i in range(1,n):
    if not (i in dic):
        print(0)
    else:
        print(dic[i])


Measured memory_bytes: 49884
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
int main()
{
    int N;
    cin >> N;
    vector<int> C(N);
    vector<int> S(N);
    vector<int> F(N);
    REP(i, N - 1)
    {
        cin >> C[i] >> S[i] >> F[i];
    }

    REP(i, N)
    {
        int time = 0;
        for(int j = i; j < N -1 ; j ++) 
        {
            if (time < S[j])
            {
                time = S[j];
            }
            else
            {
                time += (F[j] - time % F[j]) % F[j];
            }
            time += C[j];
        }
        cout << time << endl;
    }
    return 0;
}

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl


int main(){
    int n,m,t;
    cin >> n >> m;
    map<ll,ll,greater<ll>>map1;
    REP(i,n){
        cin >> t;
        map1[t]++;
    }
    int b,c;
    REP(i,m){
        cin >> b >> c;
        map1[c]+=b;
    }
    ll ans = 0;
    ll count=n;
    for(const auto &x:map1){
        ll y = x.first;
        ll z = x.second;
        if(count>=z){
            ans+=y*z;
            count-=z;
        }
        else{
            ans += y*count;
            break;
        }
    }
    COUT(ans);
    return 0;
}

Measured memory_bytes: 12800
def examA():
    N = I(); K = I(); X = I(); Y = I()
    sum = 0
    sum += min(N,K)*X
    sum += max(N-K,0)*Y
    ans = sum
    print(ans)
   
import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examA()


Measured memory_bytes: 38256
n = int(input())
a = list(map(int, input().split()))
ai = [[a_, i] for i, a_ in enumerate(a)]
ai.sort(reverse=True)

# dp[i][j] 左端からi個、右端からj個を入れた場合の最適
dp = [[0]*(n+1) for _ in range(n+1)]

for i in range(n):
    for j in range(n-i):
        dp[i+1][j] = max(dp[i+1][j], dp[i][j] + ai[i+j][0] * (ai[i+j][1] - i))
        dp[i][j+1] = max(dp[i][j+1], dp[i][j] + ai[i+j][0] * ((n-1-j) - ai[i+j][1]))
ans = 0    
for i in range(n):
    ans = max(ans, dp[i][n-i])
print(ans)

Measured memory_bytes: 100180
import sys
#果物の種類Nと，購入数K
N, K = map(int, input().split())

#果物値段A
A = list(map(int, input().split()))
A = sorted(A, reverse = False)
#print(N, K)
#print(A)
ans=0
#C = 0
#i = 0
ans = (A[:K])
#print(ans)
print(sum(ans))



Measured memory_bytes: 9252
#!/usr/bin/env python3
import sys, math, fractions, itertools, collections, copy, heapq


def solve(N: int, A: int, B: int):
    print(max(B*(N-1)+A-A*(N-1)-B+1, 0))
    return


# Generated by 1.1.4 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
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(N, A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5692
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<string>
#include<queue>
#include<map>
#include<vector>
#include<ctime>

#define int long long
#define R register
#define IL inline
#define Rf(a,b,c) for(R int (a)=(b);(a)<=(c);++(a))
#define Tf(a,b,c) for(R int (a)=(b);(a)>=(c);--(a))
#define MP make_pair
#define PA pair<int,int>
#define MES(a,b) memset((a),(b),sizeof((a)))
#define MEC(a,b) memcpy((a),(b),sizeof((b)))
#define D double

using namespace std;

const int N=1e6+5;

int A,B,ans,cnt,prim[N],vis[N];
  
IL int read() {
    int x=0,f=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x*=10;x+=(ch-'0');ch=getchar();}
    return x*f;
}
IL void write(int x) {
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}

int gcd(int x,int y) {return x%y?gcd(y,x%y):y;}
void getp(int n)
{
    Rf(i,2,n) {
        if(!vis[i]) prim[++cnt]=i;
        for(int j=1;j<=cnt&&prim[j]*i<=n;j++)
        {
            vis[prim[j]*i]=1;
            if(i%prim[j]==0)break;
        }
    }
}

signed main()
{
	A=read();B=read();
	int g=gcd(A,B);
	getp(N-5);
	for(R int i=1;i<=cnt&&prim[i]<=g;++i) {
		if(g%prim[i]==0) {
			ans++;
			while(g%prim[i]==0) g/=prim[i];
		}
	}
	if(g!=1) ans++;
	write(ans+1);
	
	
    return 0;
}


Measured memory_bytes: 12060
#include <iostream>
#include <cstring>
#include <cstdio>
#include<cstdint>
#include <utility>
#include <algorithm>
#include<map>
#include<cmath>
#include<vector>
#include<string>
#include<list>
#include<deque>
#include<stack>
#include<queue>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
typedef pair<double,double>P_D;
#define rep(i, n) for (int i = 0; i < n; i++)
#define reprev(i, n) for (int i = n - 1; i >= 0; i--)
#define MAX 100100
#define MAX_N 200100
#define SENTINEL 2000000000
const int MOD = 1e9+7;
#define NIL -1
const int INF = 1 << 29;
int n,m;
bool matrix[50][50];
int a,b;
bool visited[50];


int dfs(int v){
    bool all_visited=true;
    rep(i,n){
        if(visited[i]==false)all_visited=false;
        }
        if(all_visited){
            return 1;
        }
        int ret=0;
        rep(i,n){
            if(matrix[v][i]==false)continue;
            if(visited[i]==1)continue;
            visited[i]=true;
            ret+=dfs(i);
            visited[i]=false;
        }
        return ret;
    }

int main(){
    memset(visited,0,sizeof(visited));
visited[0]=1;
    cin>>n>>m;
    rep(i,m){
        cin>>a>>b;
        matrix[a-1][b-1]=matrix[b-1][a-1]=true;
    }
    cout<<dfs(0)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
int main(){int s[9000],n,m,t,f,i;while(std::cin>>n>>m&&n){for(i=t=f=1;i<=n+m;i++){std::cin>>s[i];if(i>n){t+=s[i];t+=s[t];if(t>=n&f==1){std::cout<<i-n<<std::endl;f=0;}}}}}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

struct UnionFind {
  const int n;
  V<> t, x, y; // root ? -sz : par
  UnionFind(int n) : n(n), t(n, -1), x(n), y(n) {}
  int find(int v) { return t[v] < 0 ? v : t[v] = find(t[v]); }
  void unite(int u, int v) {
    if ((u = find(u)) == (v = find(v))) return;
    if (-t[u] < -t[v]) swap(u, v);
    t[u] += t[v];
    t[v] = u;
    x[u] += x[v];
    y[u] += y[v];
  }
  bool same(int u, int v) { return find(u) == find(v); }
  int size(int v) { return -t[find(v)]; }
};

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  V<> x(n), y(n);
  UnionFind uf(2e5);
  fill(begin(uf.x), begin(uf.x) + 1e5, 1);
  fill(begin(uf.y) + 1e5, end(uf.y), 1);
  for (int i = 0; i < n; ++i) {
    cin >> x[i] >> y[i], --x[i], --y[i];
    uf.unite(x[i], 1e5 + y[i]);
  }
  V<> a(2e5);
  for (int i = 0; i < n; ++i) ++a[uf.find(x[i])];
  set<int> se;
  for (int v = 0; v < 2e5; ++v) se.insert(uf.find(v));
  lint res = 0;
  for (int e : se) {
    res += (lint)uf.x[e] * uf.y[e] - a[e];
  }
  cout << res << '\n';
}

Measured memory_bytes: 13568
K, N = map(int, input().split())
A = list(map(int, input().split()))

# 隣り合う二つの配列の差を計算する
max_len = 0
A.append(A[0] + K)

for i in range(N) :
  if (A[i+1] - A[i]) > max_len :
    max_len = (A[i+1] - A[i])

# 円周Kから最長の距離を引くと答え
print(K - max_len)

Measured memory_bytes: 26420
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

int gcd(int a, int b) {return b == 0 ? a : gcd(b, a % b);}

#define ll long long
#define pb push_back
#define ld long double
#define mp make_pair
#define F first
#define S second
#define pii pair<ll,ll> 

using namespace :: std;

const ll maxn=1e5+500;
const ll inf=1e9+800;
const ll mod=1e9+7;

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);	
	ll n;
	cin>>n;
	ll ans=0;
	ll res=0;
	for(ll i=1;i<=n;i++){
		ll p;
		cin>>p;
		if(p==i){
			res++;
		}else{
			ans+=(res+1)/2;
			res=0;
		}
	}
	ans+=(res+1)/2;
	cout<<ans;
}




















Measured memory_bytes: 256
n=input()
a=[int(i) for i in input().split()]

def cl(n):
    return n//400

buff=[0]*9

for i in a:
    color=cl(i)
    if color>8:
        color=8
    buff[color]+=1


min=0
for i in range(len(buff)-1):
    if buff[i]>=1:
        min+=1

max=min+buff[8]

if min==0:
    min=1

print(str(min)+" "+str(max))



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

using ll = long long;

int main() {
	int n; cin >> n;
	unordered_map<string, ll> map;

	while (n--) {
		string s; cin >> s;
		sort(s.begin(), s.end());
		map[s]++;
	}

	ll ans = 0;
	for (auto a : map) {
		ll x = a.second;
		ans += (x * (x - 1) / 2);
	}
	cout << ans << "\n";
}

Measured memory_bytes: 10660
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MOD 1000000007
typedef long long  ll;

using namespace std;

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

	string s;
    cin >> s;
    int len = s.size();
    string ke = "keyence";
    for(int i = 0; i <= 7; i++){
        // cout << s.substr(0, i) << " = " <<  s.substr(len-7+i) << endl;
        if(s.substr(0, i) + s.substr(len-7+i) == ke){
           cout << "YES" << endl;
           return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#include<array>
using namespace std;
const int mx = 1e5+5;
int a[mx];
array<int,100005>dp;
void memo(int i,int n,int k)
{
     if(i>n) return;
     for(int m=1;m<=k;m++)
     {
     	dp[i+m] = min(dp[i+m],dp[i]+abs(a[i+m]-a[i]));
     }
     memo(i+1,n,k);
}
int main()
{
	int n,k;cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	dp.fill(INT_MAX);
	dp[0] = 0;
	dp[1] = 0;
	memo(1,n,k);
	cout<<dp[n]<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int d,n;
  cin>> d>>n;
  int D;
  if( d==0){
    D =1;
  }
  else if(d==1){
    D=100;
  }
  else{
    D=10000;
  }
  if(n!=100){
    cout << D*n;
  }
  else{
    cout << D*101;
  }
  
}

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

int main(void) {
    int n, a[114514] = {};
		long long sum[114514] = {};
    cin >> n;
    a[0] = 0;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    for (int i = 1; i <= n; i++)
        sum[i] = sum[i - 1] + abs(a[i] - a[i - 1]);
    sum[n + 1] = sum[n] + abs(a[0] - a[n]);
    for (int i = 1; i <= n; i++) {
        cout << sum[n + 1] - (abs(a[i] - a[i - 1]) + abs(a[i + 1] - a[i])) + abs(a[i + 1] - a[i - 1]) << endl;
    }
}


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

int main() {
    ll n;
    cin >> n;

    ll ans = 0;
    if (n % 2 == 0) {
        for (ll i = 10; i <= n; i *= 5) {
            ans += n / i;
        }
    }

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


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

n_c = n - 1
w_dict = {0: "a", 1: "b", 2: "c", 3: "d", 4: "e", 5:"f", 6:"g" , 7:"h", 8:"i", 9:"j", 10:"k"
        , 11:"l", 12:"m", 13:"n", 14:"o" , 15:"p", 16:"q", 17:"r", 18:"s", 19:"t", 20:"u"
        , 21:"v", 22:"w", 23:"x", 24:"y", 25:"z"}
out = ""
while n_c > 25:
    out = out + w_dict[n_c % 26]
    n_c = n_c // 26 - 1

out = out + w_dict[n_c]
print(out[::-1])

Measured memory_bytes: 9172
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
using namespace std;

int main() {
    int t,x;
    cin >> t >> x;

    cout << fixed;
    cout << setprecision(10) << double(t) / double(x) << endl;

    return 0;
}


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

int main() 
{
    int a, b;
    cin >> a >> b;
    string s = to_string(a) + to_string(b);
    int n = stoi(s);
    cout << (sqrt(n)==(int)sqrt(n)?"Yes":"No");
    return 0;
}

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

typedef pair<double,int> P;

const double INF = 1e10;

int main ()
{
    int n;
    while (cin >> n, n) {
        vector<double> x(n), y(n), z(n), r(n);
        for (int i = 0; i < n; i++) {
            cin >> x[i] >> y[i] >> z[i] >> r[i];
        }

        vector<vector<double> > dis(n, vector<double>(n, INF));
        for (int i = 0; i < n - 1; i++) {
            for (int j = i + 1; j < n; j++) {
                double tdis = pow(x[i] - x[j], 2.0) + pow(y[i] - y[j], 2.0) + pow(z[i] - z[j], 2.0);
                tdis = sqrt(tdis) - r[i] - r[j];
                if (tdis < 0.0) tdis = 0.0;
                dis[i][j] = dis[j][i] = tdis;
            }
        }

        priority_queue<P, vector<P>, greater<P> > que;
        vector<bool> used(n, false);
        double res = 0.0;
        for (int i = 0; i < n; i++) {
            que.push(P(dis[0][i], i));
        }
        used[0] = true;
        while (que.size()) {
            P p = que.top(); que.pop();

            if (used[p.second]) continue;
            res += p.first;
            used[p.second] = true;
            for (int i = 0; i < n; i++) {
                que.push(P(dis[p.second][i], i));
            }
        }

        printf("%.3f\n", res);
    }

    return 0;
}

Measured memory_bytes: 1732
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] S = new int[n]; 
		for (int i = 0; i < n; i++) {
			S[i] = sc.nextInt();
		}
		
		int q = sc.nextInt();
		int[] T = new int[q];
		for (int i = 0; i < q; i++) {
			T[i] = sc.nextInt();
		}
		
		int count = 0;
		for (int i = 0; i < T.length; i++) {
			int t = T[i];
			
			int l = -1;
			int u = S.length;
			while(u - l > 1) {
				int m = (u + l) / 2;	
				if(t == S[m]) { 
					count++;
					break;
				} else if (t < S[m]) {
					u = m;
				} else {
					l = m;
				}
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 76380
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<cmath>
#include<string>

#define ls (t<<1)
#define rs ((t<<1)+1)
#define mid ((l+r)>>1)
#define fi first
#define se second
#define mk make_pair
#define pb push_back

#define N 100005
#define M 200005
#define seed 23333

using namespace std;
int i,j,m,n,p,k,A,B,x;
set<int>st;
int main()
{
		scanf("%d%d%d",&n,&A,&B);
		for (i=1;i<=n;++i)
		{
				scanf("%d",&x);
				if (x<A||x>=B) st.insert(x);
		}
		printf("%d\n",(int)st.size());
}


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

ans = 0

BA = 0
XA = 0
BX = 0

for i in range(n):
    s = input()
    ans += s.count('AB')

    if s[0] == 'B' and s[-1] == 'A':
        BA += 1
    elif s[-1] == 'A':
        XA += 1
    elif s[0] == 'B':
        BX += 1

if BA > 0:
    ans += BA-1
    BA = 1
    if BX > 0:
        ans += 1
        BA = 0
    else:
        BX = 1
        BA = 0

ans += min(XA, BX)

print(ans)


Measured memory_bytes: 44008
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>

#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)

typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;

using namespace std;


void solve(){
    int n;
    cin >> n;
    int cnt = 0;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        while(x % 2 == 0){
            cnt++;
            x /= 2;
        }
    }
    cout << cnt;
}

int main(){
    barsik;
    int q = 1;
    //cin >> q;
    while(q--) solve();
}



Measured memory_bytes: 256
/*input
314159265 358979323846264338
*/
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
int main()
{
	ll x,y;
	cin>>x>>y;
	ll mn=1;
	ll xx=log2(x);
	ll foo=x;
	ll ans=0;
	while(foo<=y)
	{
		if(x<=foo&&foo<=y)
			ans++;
		foo*=2;
	}
	ans=max(ans,mn);
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdbool.h>
#include<string>
#include<iostream>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<utility>
#include<list>
#define N (1000000000+7)
typedef long long ll;
using namespace std;

ll kaijo(ll n) {
	ll sum = 1;
	for (ll i = 1;i <= n;i++) {
		sum = (sum*(i%N)) % N;
	}
	return sum;
}

int main() {
	ll n, m;
	cin >> n >> m;
	if (abs(n - m) >= 2) {
		cout << 0 << endl;
	}
	else {
		ll sum1 = 1, sum2 = 1, ans = 0;
		if (n == m) {
			sum1 = kaijo(n);
			ans = (2 * (((sum1%N)*(sum1%N)) % N)) % N;
			cout << ans << endl;
		}
		else {
			sum1 = kaijo(n);
			sum2 = kaijo(m);
			ans = ((sum1%N)*(sum2%N)) % N;
			cout << ans << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int i=in.nextInt(),j=in.nextInt(),max=0;
		for(int v=0;v<i;v++) {
			int cnt=0;
			for(int w=0;w<j;w++)cnt+=in.nextInt();
			max=Math.max(max,cnt);
		}
		System.out.println(max);
	}

}



Measured memory_bytes: 27012
# coding: utf-8

s = list(input())
n = len(s) - 1

for bit in range(2 ** n):
    tmp = s[:]
    total = 0
    for i in range(n):
        if (bit & (1 << i)):
            tmp[i] += '+'
        else:
            tmp[i] += '-'
    total = eval(''.join(tmp))
    if total == 7:
      print(''.join(tmp) + '=7')
      break

Measured memory_bytes: 3064
//
// Created on 2020/04/26.
//


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


int main() {
    string ans;
    int s;
    int w;
    cin>>s>>w;
    if(s <= w){
        ans = "unsafe";
    }else{
        ans = "safe";
    }

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


Measured memory_bytes: 3624
N, X, Y = list(map(int, input().split()))
result = {N-i:0 for i in range(1, N)}

for i in range(1, N):
  for j in range(i + 1, N + 1):
    dis = min([j - i, abs(j - Y) + abs(i - X) + 1, abs(j - X) + abs(i - Y) + 1])
    result[dis] += 1
print("\n".join(list(map(str, result.values()))))


Measured memory_bytes: 46172
n = gets.to_i
s = gets.split.map(&:to_i)
q = gets.to_i
t = gets.split.map(&:to_i).sort

count = 0
i = j = 0
while i < n and j < q
  if s[i] == t[j]
    count += 1
    i += 1
    j += 1
  elsif s[i] < t[j]
    i += 1
  else
    j += 1
  end
end
puts count


Measured memory_bytes: 16132
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
    cin >> first;
    IN(rest...);
    return;
}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
/*--Output/////////////////////////////////////////////////*/
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
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; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }

const int MOD = 1000000007;

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

int main() {
    SS(ll,n)
    vl a(n);
    rep(i,n){
        cin>>a[i];
    }
    ll next=1;
    rep(i,n){
       ll temp=a[next-1];
        next=temp;
        if(next==2){
            cout<<i+1<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
}


Measured memory_bytes: 1024
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);


    int R, G;

    cin >> R >> G;

    cout << (G * 2 - R) << '\n';

    return 0;
}

Measured memory_bytes: 3624
///بِسْمِ الّٰلهِ الرَّحْمٰنِ الرَحِيْمِ
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi acos(-1.0)
int main()
{
     ios_base::sync_with_stdio(false);cin.tie(NULL);
     ll int i,n,t,j=0,p,x,a=0,b,l=0,r=0,y,k,c,sum=0,m,d;
     cin>>n>>k;
     int ara[n];
     for(i=0;i<n;i++){
        cin>>ara[i];
     }
     sort(ara,ara+n);
     for(i=0;i<k;i++){
        sum+=ara[i];
     }
     cout<<sum<<endl;

     return EXIT_SUCCESS;
}


Measured memory_bytes: 3660
//02-03-2020

#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n,k,cnt=0;
    cin>>n>>k;

    while(n>0)
    {
        n=n/k;
        cnt++;
    }
    cout<<cnt<<"\n";	//:D
    return 0;

}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
#include <queue>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
using namespace std;
#define sL(i) i << 1
#define sR(i) i << 1 | 1
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<int, pair<int,int>> ppi;
const int MOD = 1e9 + 7;
const int INF = 2e9 + 5;

int x, y;
int main() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin >> x >> y;
    for (int i = 0; i <= x; i++) {
        int legs = i * 2 + (x - i) * 4;
        if (legs == y) {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
}

Measured memory_bytes: 3116
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("4 10");
            //3
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("8 9");
            //2
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("8 8");
            //1
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        int[] wkArr = InputList[0].Split(' ').Select(X => int.Parse(X)).ToArray();
        int A = wkArr[0];
        int B = wkArr[1];

        int cnt = 1;
        int Answer = 0;
        while(cnt < B){
            Answer++;
            cnt--;
            cnt += A;
            if (cnt >= B) break;
        };
        Console.WriteLine(Answer);
    }
}


Measured memory_bytes: 13396
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let r: i32 = read(&mut stdin_lock, &mut buf, b'\n');

    println!("{}", r * r);
}


Measured memory_bytes: 4476
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define P 1000000007
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;

void solve() {
	int h, w, k;
	cin >> h >> w >> k;
	
	char a[6][6];
	for(int i = 0; i < h; i++) {
		for(int j = 0; j < w; j++) {
			cin >> a[i][j];
		}
	} 
	
	int ans = 0;
	for(int bi = 0; bi < (1 << h); bi++) {
		for(int bj = 0; bj < (1 << w); bj++) {
			int sum = 0;
			for(int i = 0; i < h; i++) {
				for(int j = 0; j < w; j++) {
					if(a[i][j] == '#' && !((1 << i) & bi) && !((1 << j) & bj)) sum++;
				}
			} 
			if(sum == k) ans++;	
		}
	}
	
	cout << ans << endl;
}

int main(){
#define MULTITEST 0
#if MULTITEST   
 
    CASET {
        solve();
    }
    
#else

    solve();
    
#endif

    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int P, Q, R; cin >> P >> Q >> R;
    cout << min({P + Q, Q + R, R + P}) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
#define N 1001000
typedef long long ll; 
template<typename T> inline void read(T &x) {
  x = 0; char c = getchar(); bool flag = false;
  while (!isdigit(c)) { if (c == '-') flag = true; c = getchar(); }
  while (isdigit(c)) { x = (x << 1) + (x << 3) + (c ^ 48); c = getchar(); }
  if (flag) x = -x; 
}
using namespace std;
const int P = 998244353;
inline ll quickpow(ll x, int k) {
  ll res = 1;
  while (k) {
    if (k & 1)  res = res * x % P;
    x = x * x % P;
    k >>= 1;
  }
  return res;
}
int n, m;
ll jie[N], jieni[N];
inline void init() {
  int up = n + m;
  jie[0] = jieni[0] = 1;
  for (int i = 1; i <= up; ++i) jie[i] = jie[i - 1] * i % P;
  jieni[up] = quickpow(jie[up], P - 2); 
  for (int i = up - 1; i; --i)  jieni[i] = jieni[i + 1] * (i + 1) % P;
}
inline ll get_c(int n, int m) {
  ll res = jie[n] * jieni[m] % P * jieni[n - m] % P;
  return res;
}
inline void work() {
  ll res = 0;
  if (n < m)  swap(n, m); 
  for (int i = 1; i <= m; ++i) {
    res = (res + get_c(i + i - 1, i) * get_c(n - i + m - i, n - i)) % P;
  }
  res = (res + n * get_c(n + m, n)) % P;
  res = res * quickpow(get_c(n + m, n), P - 2) % P;
  printf("%lld\n", (res % P + P) % P); 
}
int main() {
  read(n), read(m); init();
  work();
  return 0;
}


Measured memory_bytes: 18852
import java.util.Scanner;

/**
 * @author author
 *
 */
public class Main {

  /**
   * @param args
   */
  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    long a = Long.parseLong(sc.next());
    long b = Long.parseLong(sc.next());
    long c = Long.parseLong(sc.next());
    long d = Long.parseLong(sc.next());

 //   System.out
 //       .println(
 //           LongStream.range(a, b + 1).filter(i -> i % c != 0 && i % d != 0).count());
 // }

    long cMulti = (b / c) - ((a - 1) / c);
    long dMulti = (b / d) - ((a - 1) / d);
    long lcm = lcm(c, d);
    System.out.println(b - a + 1 - cMulti - dMulti + b / lcm - ((a - 1) / lcm));
  }
    
  static long gcd(long a, long b) {
    
    long c = 0;
    do {
      c = a % b;
      a = b;
      b = c;
    } while (c != 0);
    return a;
  }

  static long lcm(long a, long b) {
    
    return a * b / gcd(a, b);
  }
}


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

person = set(range(1,n+1))
for i in range(k):
    d = int(input())
    a = list(map(int,input().split()))
    for j in range(d):
        if a[j] in person:
            person.discard(a[j])

print(len(person))

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

int main(){
	long long int N, M, ans;
	cin >> N >> M;
	if (M == 0||M==1){
		ans = 0;
	}
	else{
		M = (M - (M % 2)) / 2;
		if (N > M){ ans = M; }
		else{ ans =( (N+M)-((N+M)%2))/2; }
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import functools
import operator

n = functools.partial(functools.reduce, operator.mul)
N,K = map(int,input().split())
A = list(map(int,input().split()))
# print(n(A))
for i in range(K,N):
    if A[i-K] < A[i]:
        print("Yes")
    else:
        print("No")
        






Measured memory_bytes: 32192
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>
#include <cassert>
#include <bitset>
#include <list>
#include <iomanip>
#include <cctype>
#include<chrono>
#include<random>

#define for0(i, N)    for (long long i = 0  ; i <  (N); ++i)
#define for1n(i, N)   for (long long i = 1  ; i <= (N); ++i)
#define for1(i, N)    for (long long i = 1  ; i <  (N); ++i)
#define forn(i, N)    for (long long i = 0  ; i <= (N); ++i)
#define forx(i, N, x) for (long long i = (x); i <  (N); ++i)
#define forl(i, N, x, a) for (long long i = (x), a = 0; a < (N);    \
                              i = (i + 1) % (N), ++a)
#define int long long

long double constexpr pi = 3.141592653589793;

template<class T>
constexpr T sigma1(T i, T n){
    return (n - i + 1) * (i + n) / 2;
}

template<class T>
constexpr T sigma2(T i, T n){
    return (i == 1 ? n * (n + 1) * (2 * n + 1) / 6 :
            sigma2(1, n) - sigma2(1, i - 1));
}

template<class T>
constexpr T sigma3(T i, T n){
    if (i == 1) {
        auto temp = sigma1(i, n);
        return temp * temp;
    }
    return sigma2(1, n) - sigma2(1, i - 1);
}

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b, signed){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b + 1;
}

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b++;
    return temp;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b, signed){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b - 1;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b--;
    return temp;
}

long long constexpr inf = std::numeric_limits<long long>::max();

using namespace std;

typedef long long ll;
typedef long double ld;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll>, greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;
typedef pair<ll, ll> pll;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef set<ll> sll;
typedef unordered_set<ll> usll;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<vector<ll>> vvll;


signed main(void){
    cin.tie(0); ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);
    ll k, a, b;
    cin >> k >> a >> b;
    cout << (a % k == 0 || a % k - k + b - a >= 0 ? "OK" : "NG");

    return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;

int h,w,grid[1002][1002],dp[1002][1002];
char x;

int main() {
    scanf("%d%d\n",&h,&w);
    for(int i=0;i<h;++i) {
        for(int j=0;j<w;++j) {
            scanf("%c",&x);
            if(x=='.')  grid[i][j] = 1;
            else grid[i][j] = 0;
        }
        scanf("\n");
    }

    dp[0][0] = 1;
    for(int i=1;i<w;++i)
        if(grid[0][i])  dp[0][i] = dp[0][i-1];

    for(int i=1;i<h;++i)
        if(grid[i][0])    dp[i][0] = dp[i-1][0];

    for(int i=1;i<h;++i)
        for(int j=1;j<w;++j)
            if(grid[i][j])  dp[i][j] = (dp[i-1][j]+dp[i][j-1]) % mod;

    printf("%d",dp[h-1][w-1]);
    return 0;
}


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

const int MAX = 10010;
int V, E;
vector<int> G[MAX];
int dig[MAX];

void init(int V, int E) {
    for (int i = 0; i < V; i++) {
        G[i].clear();
        dig[i] = 0;
    }

    for (int i = 0; i < E; i++) {
        int from, to;
        scanf("%d %d", &from, &to);
        G[from].push_back(to);
        dig[to]++;
    }
}

void topSort(vector<int> &ans) {
    queue<int> Q;
    for (int i = 0; i < V; i++) {
        if (dig[i] == 0) {
            Q.push(i);
        }
    }
    while (!Q.empty()) {
        int t = Q.front();
        Q.pop();
        ans.push_back(t);
        for (int i = 0; i < G[t].size(); i++) {
            int to = G[t][i];
            dig[to]--;
            if (dig[to] == 0) {
                Q.push(to);
            }
        }
    }
}


int main() {
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    scanf("%d %d", &V, &E);
    init(V, E);
    vector<int> ans;
    topSort(ans);
    for (int i = 0; i < ans.size(); i++) {
        printf("%d\n", ans[i]);
    }
    return 0;
}

Measured memory_bytes: 3988
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 1000000000
#define InfLL 1000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=(n-1);(i)>=(0);(i)--)
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	ll A;
	string B;
	cin >> A >> B;
	string b;
	b += B[0];
	b += B[2];
	b += B[3];
	ll bb = stoll(b);

	ll ans = A * bb;
	ans /= 100;

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

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

int dfs(int n, vector<vector<int> >& adj){
	if((int)adj[n].size() == 0) return n;
	int ret=0;
	for(int i=0; i<(int)adj[n].size(); i++){
		ret = max(ret, dfs(adj[n][i], adj));
	}
	adj[n].clear();
	return ret;
}

int main(){
	int n,m;
	cin >> n >> m;
	
	vector<vector<int> > need(n+1);
	for(int i=0; i<m; i++){
		int c,d;
		cin >> c >> d;
		need[c].push_back(d);
	}
	vector<int> c,d;
	for(int i=1; i<=n; i++){
		int top = dfs(i, need);
		if(top != i){
			c.push_back(i);
			d.push_back(top);
		}
	}
	c.push_back(n+1);
	d.push_back(n+1);
	
	int ans = 0;
	int s=c[0], e=d[0];
	for(int i=1; i<(int)c.size(); i++){
		if(c[i] <= e){
			e = max(e, d[i]);
		}else{
			ans += e-s;
			s = c[i];
			e = d[i];
		}
	}
	ans = n +1 +ans*2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3228
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long 
#define mp make_pair
#define pb push_back
#define gcd(a, b)   __gcd(a, b)
#define lcm(a, b)  ((a)*((b)/gcd(a,b)))
#define pi 3.14159265358979323846
#define reus ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int32_t main()
{
	reus;

//	#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//	#endif
    
    int n;
    cin>>n;
    map<string,int>mp;
    set<string>sts;
    string s;
    for(int i=0;i<n;i++)
    {
    	cin>>s;
    	mp[s]++;
	}
	int maxi=INT_MIN;
    for(auto i=mp.begin();i!=mp.end();i++)
    {
    	maxi=max(maxi,i->second);
	}
	for(auto i=mp.begin();i!=mp.end();i++)
	{
		if(i->second==maxi)
		{
			sts.insert(i->first);
		}
	}
	for(auto it=sts.begin();it!=sts.end();it++)
	{
		cout<<*it<<endl;
	}

	return 0;
}

Measured memory_bytes: 34876
(* unihernandez22
 * https://atcoder.jp/contests/abc066/tasks/abc066_a
 * sorting, implementation
 * *)

Printf.printf "%d\n" @@
Scanf.scanf "%d %d %d\n" @@ fun a b c ->
    [a; b; c]
    |> List.sort compare
    |> fun l -> List.nth l 0 + List.nth l 1


Measured memory_bytes: 3812
N=int(input())

if 1<=N<=9:
  print("Yes")
elif (N%2==0) and N<=18:
  print("Yes")
elif (N%3==0) and N<=27:
  print("Yes")
elif (N%4==0) and N<=36:
  print("Yes")
elif (N%5==0) and N<=45:
  print("Yes")
elif (N%6==0) and N<=54:
  print("Yes")
elif (N%7==0) and N<=63:
  print("Yes")
elif (N%8==0) and N<=72:
  print("Yes")
elif (N%9==0) and N<=81:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds; 
  
#define ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

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

const int mod = (int)1e9 + 7;
const int MX = (int)1e5 + 10;

void add_self(int &x, int y){x += y; if(x >= mod) x -= mod;}
void sub_self(int &x, int y){x -= y; if(x < 0) x += mod;}
void mul(int &x, int y){x = x * 1LL * y % mod;}

int main(){

	cin.tie(0); cout.tie(0);
	ios_base::sync_with_stdio(0);
	
	int a, b;
	cin >> a >> b;

	cout << (a + b - 1) / b << endl;

	return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>

#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>

#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <ctime>

// namespace
using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

// constant
static const ll MOD = 1000000007LL;
static const double PI = 3.14159265358979323846;

// conversion
inline ll toint(string s) { ll v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

// print
#define RET(x) return cout << x << endl, 0;

// for loop
#define REP(i, a, b) for ((i) = (ll)(a);(i) < (ll)(b);(i)++)
#define REPD(i, a, b) for (ll i = (ll)(a);(i) < (ll)(b);(i)++)
#define REPI(v, vs) for (auto& v : vs)

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __LINE__ << ")" << " " << __FILE__ << endl

#define MAX_VALUE 9223372036854775807

int solve() {
	//ll n, k;
	//cin >> n >> k;

	//vector<ll> as(n);
	//REPD(i, 0, n) cin >> as[i];

	ll k;
	cin >> k;

	if (k % 2 == 0 || k % 5 == 0) RET(-1);

	ll residual_7 = 7 % k;
	ll residual_sum = 0;
	REPD(i, 0, k) {
		residual_sum = (residual_sum + residual_7) % k;
		if (residual_sum == 0) RET(i + 1);
		residual_7 = (residual_7 * 10) % k;
	}

	return 0;
}

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

	solve();

	return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>
#include <stdlib.h>

int main(){
  int i,j,N,minj,a,b;
  char tmp;
  char tmp2;
  int flag=0;
  scanf("%d",&N);
 
  char A[N][2];
  char B[N][2];
  char C[N][2];
  for(i=0;i<N;i++){
    scanf("%s",C[i]); 
    A[i][0]=C[i][0];
    A[i][1]=C[i][1];
    B[i][0]=C[i][0];
    B[i][1]=C[i][1];

  }
  
   for(i=0;i<N;i++){
    for(j=N-1;j>i;j--){
      if((int)A[j][1]<(int) A[j-1][1]){
	tmp=A[j][0];
	A[j][0]=A[j-1][0];
	A[j-1][0]=tmp;
	tmp2=A[j][1];
	A[j][1]=A[j-1][1];
	A[j-1][1]=tmp2;
      }
    }
    }

   for(i=0;i<N-1;i++)printf("%c%c ",A[i][0],A[i][1]);
   printf("%c%c\n",A[N-1][0],A[N-1][1]);


   for(i=0;i<N;i++){
     for(j=i+1;j<N;j++){
       for(a=0;a<N;a++){
	 for(b=a+1;b<N;b++){
	   if(C[i]==C[j] && C[i]==A[b] && C[j]==A[a]){
	     flag=1;
	   }
	 }
       }
     }
   }
   if(flag==0)printf("Stable\n");
   else printf("Not stable\n");

   flag=0;

   for(i=0;i<N;i++){
     minj=i;
     for(j=i;j<N;j++){
       if((int)B[j][1]<(int)B[minj][1]){
	 minj=j;
       }
     }
     tmp=B[i][0];
     B[i][0]=B[minj][0];
     B[minj][0]=tmp;
     tmp2=B[i][1];
     B[i][1]=B[minj][1];
     B[minj][1]=tmp2;
   }


   for(i=0;i<N-1;i++)printf("%c%c ",B[i][0],B[i][1]);
   printf("%c%c\n",B[N-1][0],B[N-1][1]);

   for(i=0;i<N;i++){
     for(j=i+1;j<N;j++){
       for(a=0;a<N;a++){
	 for(b=a+1;b<N;b++){
	   if(C[i][1]==C[j][1] && C[i][0]==B[b][0] && C[i][1]==B[b][1] && C[j][0]==B[a][0] && C[j][1]==B[a][1] ){
	     flag=1;
	   }
	 }
       }
     }
   }
   if(flag==0)printf("Stable\n");
   else printf("Not stable\n");



   return 0;
}

Measured memory_bytes: 608
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

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

  ll num = 1;

  while(num < N) num *= 2;  

  if(num == N)
    cout << N << endl;
  else
    cout << num / 2 << endl;
  
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int a = in.nextInt();
		int b = in.nextInt();
		int c = in.nextInt();
		
		if(a-b >= c)System.out.println(0);
		else System.out.println(c-(a-b));

		in.close();

	}

}

Measured memory_bytes: 22996