akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  const double PI = acos(-1);
  int n;
  cin >> n;
  vector<int> x(n), y(n);
  for (int i = 0; i < n; ++i)
    cin >> x[i] >> y[i];
  for (int i = 0; i < n; ++i) {
    vector<double> angle;
    for (int j = 0; j < n; ++j)
      if (i != j)
        angle.push_back(atan2(x[j] - x[i], y[j] - y[i]));
    sort(angle.begin(), angle.end());
    double ans = 0;
    for (int j = 0; j < n - 2; ++j)
      ans = max(ans, angle[j + 1] - angle[j] - PI);
    ans = max(ans, angle.front() + PI - angle.back());
    printf("%.15f\n", ans / PI / 2);
  }

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
r, g, b, n = map(int, input().split())
c = 0
for i in range(n // r + 1):
    for j in range((n - i * r) // g + 1):
        if (n - i * r - j * g) % b == 0:
            c += 1
print(c)


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

using namespace std;

vector<vector<int>> a(200000);
vector<long long> ans(200000);

void dfs(int n, int p);

int main()
{
	int n, q;
	cin >> n >> q;
	for (int i = 0; i < n - 1; i++) {
		int p, q;
		cin >> p >> q;
		p--;
		q--;

		a[p].emplace_back(q);
		a[q].emplace_back(p);
	}
	for (int i = 0; i < q; i++) {
		int p, x;
		cin >> p >> x;
		ans[p - 1] += x;
	}

	dfs(0, 0);

	for (int i = 0; i < n; i++) {
		cout << ans[i] << (n == i + 1 ? "\n" : " ");
	}

	return 0;
}

void dfs(int n, int p)
{
	for (auto & i : a[n]) {
		if (p == i) continue;

		ans[i] += ans[n];
		dfs(i, n);
	}
}

Measured memory_bytes: 24320
#include<bits/stdc++.h>
#include<string>
#include<cmath>

using namespace std;

#define ll long long int
#define ld long double
#define loop(i, n) for (int i = 0; i < n; i++)
#define loops(i, s, n) for (int i = s; i < n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
#define deb(x) cout<< #x << '=' << x <<endl
#define MOD 1000000007
const int N = 1e6 + 5;
int vis[N];
int cnt[N];
ll a[N];
void go(){
    for(ll i = 1; i<N; i++){
        if(cnt[i]){
            if(cnt[i] > 1){
                vis[i] = 1;
            }
            for(ll j = 2; i*j<N; j++){
                vis[i*j] = 1;
            }
        }
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin>>n;
    for(int i = 0; i<n; i++){
        cin>>a[i];
        cnt[a[i]]++;       
    }
    go();
    ll ans = 0;
    for(int i = 0; i<n; i++){
        ans += !vis[a[i]];
    }
    cout<<ans;
}

Measured memory_bytes: 12920
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
const ll INF = 100000000000000000;

int main(){
    int n,m;
    cin>>n>>m;
    if(n==m) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

int main() {
  char a,b,c,d;
  cin >> a >> b >> c >> d;
  int A = a-'0';
  int B = b-'0';
  int C = c-'0';
  int D = d-'0';
  if(A+B+C+D == 7){
    cout << A << "+" << B << "+" << C << "+" << D << "=7" << endl;
  }
  else if(A+B+C-D == 7){
    cout << A << "+" << B << "+" << C << "-" << D << "=7" << endl;
  }
  else if(A+B-C+D == 7){
    cout << A << "+" << B << "-" << C << "+" << D << "=7" << endl;
  }
  else if(A-B+C+D == 7){
    cout << A << "-" << B << "+" << C << "+" << D << "=7" << endl;
  }
  else if(A+B-C-D == 7){
    cout << A << "+" << B << "-" << C << "-" << D << "=7" << endl;
  }
  else if(A-B+C-D == 7){
    cout << A << "-" << B << "+" << C << "-" << D << "=7" << endl;
  }
  else if(A-B-C+D == 7){
    cout << A << "-" << B << "-" << C << "+" << D << "=7" << endl;
  }
  else{
    cout << A << "-" << B << "-" << C << "-" << D << "=7" << endl;
  }
}


Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
    int n;
    int add=0,ans=0;
    scanf("%d",&n);
    for(register int i=1;i<=n;i++)
    {
        int a;
        scanf("%d",&a);
        ans+=a*add;
        add+=a;
    }
    printf("%d",ans);
    return 0;
}

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

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

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

  int total=0;
  for(int i=0; i<n; i++){
    if(i==n-1) total += p[i] / 2;
    else total += p[i];
  }

  cout << total << endl;
}


Measured memory_bytes: 256
#include<stdio.h>


int main(void){

	int n, day[101];
	scanf("%d\n", &n);

	for (int i = 0; i < n; i++) {
		scanf("%d", &day[i]);
	}
    for (int i = n - 1; i >= 0; i--) {
    	printf("%d", day[i]);
		if(i) printf(" ");
    }
	printf("\n");

    return 0;
}


Measured memory_bytes: 2080
#include <bits/stdc++.h>   
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
     
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
using Graph = vector<vector<int>>;
Graph G;

int main(){
    int n, m, q; cin >> n >> m >> q;

    int a, b;
    vector<vector<int>> count(501, vector<int>(501, 0));
    rep(i, m){
        cin >> a >> b;
        count[a][b]++;
    }
    vector<vector<int>> sum(501, vector<int>(501, 0));
    _rep(i, 1, n + 1)_rep(j, 1, n + 1){
        sum[i][j] = sum[i][j - 1] + sum[i - 1][j] - sum[i - 1][j - 1] + count[i][j]; 
    }
    rep(i, q){
        cin >> a >> b;
        cout << sum[b][b] - sum[b][a - 1]- sum[a - 1][b] + sum[a - 1][a - 1] << endl;
    }
}

Measured memory_bytes: 5640
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long 
#define M 1000000007
#define P pair<int,int>

char s[1000000];
int n;
int a,b;

int main(){
  cin>>s;
  n = strlen(s);

  for(int i=0;i<n;i++)
    if(s[i]=='p') b++;

  cout<<n/2-b<<endl;

  return 0;
}


Measured memory_bytes: 384
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
 
class Program{
    static void Main(){
        char[] s = Console.ReadLine().ToCharArray();
        long k = long.Parse(Console.ReadLine());
        long remain = k;
        for(int i = 0; i < s.Length; i++){
            if(s[i] == 'a') continue;
            int gap = 'z' - s[i] + 1;
            if(gap <= remain){
                s[i] = 'a';
                remain -= gap;
            }
            if(remain == 0) break;
        }
        s[s.Length - 1] = (char)(s[s.Length - 1] + remain % 26);
        for(int i = 0; i < s.Length; i++){
            Console.Write(s[i]);
        }
        Console.WriteLine();
    }
}

Measured memory_bytes: 3288
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <set>
#include <vector>
using namespace std;
#define int long long

int n, ans, c00, c11;
int a[100005], b[100005];
bool visa[100005], visb[100005];

signed main() {
	scanf("%lld", &n);
	vector <int> all;
	for (int i = 1; i <= n; ++ i) {
		scanf("%lld %lld", a + i, b + i);
		all.push_back(a[i]);
		all.push_back(b[i]);
	}
	sort(all.begin(), all.end());
	multiset <int> st(all.begin(), all.begin() + n);
	multiset <int> ts(all.begin() + n, all.begin() + n + n);
	multiset <int> mst = st;
	for (int i = 1; i <= n; ++ i) {
		if (mst.count(a[i])) {
			visa[i] = 1;
			mst.erase(mst.find(a[i]));
		}
		if (mst.count(b[i])) {
			visb[i] = 1;
			mst.erase(mst.find(b[i]));
		}
		if (!visa[i] && !visb[i]) c00 ++;
		if (visa[i] && visb[i]) c11 ++;
	}
	for (auto x: st) ans += x;
	if (c00 || c11)
		return printf("%lld\n", ans) & 0;
	set <int> gans;
	for (int i = 1; i <= n; ++ i)
		if (visa[i]) gans.insert(1);
		else gans.insert(0);
	if ((int)gans.size() == 1)
		return printf("%lld\n", ans) & 0;
	int res = 0x3f3f3f3f3f3f3f3f;
	for (int i = 1; i <= n; ++ i)
		if (visa[i]) {
			auto it = ts.begin();
			if (b[i] == *it) ++ it;
			res = min(res, ans + (*it - a[i]));
		}
		else {
			auto it = ts.begin();
			if (a[i] == *it) ++ it;
			res = min(res, ans + (*it - b[i]));
		}
	printf("%lld\n", res);
	return 0;
}


Measured memory_bytes: 17648
N=int(input())
Ws=[]
for n in range(N):
    W=input()
    Ws.append(W)

for w in range(len(Ws)):
    if Ws.count(Ws[w])>=2:
        print("No")
        exit()
        
for x in range (1,len(Ws)):
    if Ws[x][0] != Ws[x-1][-1]:
        print("No")
        exit()

print("Yes")

Measured memory_bytes: 3064
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N = int(input())

# dp[i+100000] : i 円を引き出すのに必要な最小回数 
dp = [0]*(N+100010)
# dp[99999] までを大きな数で初期化しておく
for i in range(100000):
    dp[i] = 10**10

# dp[100000] : 0円を引き出すのに必要な最小回数 = 0 で初期化済み
# dp[100001] : 1円を引き出すのに必要な最小回数 から処理していく
for i in range(100001,N+100010):
    dp[i] = min(dp[i-1] + 1,
                dp[i-6] + 1,
                dp[i-9] + 1,
                dp[i-36] +1,
                dp[i-81] + 1,
                dp[i-216] + 1,
                dp[i-729] + 1,
                dp[i-1296] + 1,
                dp[i-6561] + 1,
                dp[i-7776] + 1,
                dp[i-46656] + 1,
                dp[i-59049] + 1)
 
print(dp[N+100000])

Measured memory_bytes: 4596
/*** akshaykumar99 ***/
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using id_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update> ;
  
const long long MOD = 1e9+7;
const long double PI = acos(-1);
const long long N = 1e5+1;
 
typedef long long ll;
typedef long double ld;

void test_case()
{
    ll n,k,i,j,zz = 0;
    cin >> n >> k;
    vector<pair<ll,ll>> v;
    for(i = 0; i < n; i++)
    {
        ll x, y = 1;
        cin >> x;
        if(x < 0)
        {
            zz++;
            y = -1;
        }
        v.push_back({abs(x), y}); 
    }
    ll ans = 1;
    if(n == k)
    {
        for(i = 0; i < n; i++)
        {
            ans = ans * v[i].first * v[i].second % MOD;
        }
        cout << (ans + MOD) % MOD << '\n';
        return ;
    }
    sort(v.rbegin(), v.rend());
    ll tot = 0;
    if(zz == n && k&1)
    {
        for(i = n-1; i >= n-k; i--)
        {
            ans = ans * v[i].first * v[i].second % MOD;
        }
        cout << (ans + MOD) % MOD << '\n';
        return ;
    }
    vector<ll> neg, pos;
    for(i = 0; i < n; i++)
    {
        if(v[i].second == -1)
            neg.push_back(-v[i].first);
        else
            pos.push_back(v[i].first);
    }
    sort(neg.begin(), neg.end());
    sort(pos.rbegin(),pos.rend());
    ll n1 = neg.size(), n2 = pos.size();
    if(k&1)
    {
        ll s1 = 0, s2 = 0, w = 0;
        while(tot < k-1)
        {
            ll tot1 = -INT_MAX, tot2 = -INT_MAX;
            if(s1 < n1-1)
                tot1 = neg[s1] * neg[s1+1];   
            if(s2 < n2-2)
                tot2 = pos[s2] * pos[s2+1];
            if(tot1 > tot2)
            {
                tot1 %= MOD;
                ans  = ans * tot1 % MOD;
                s1 += 2;
            }
            else
            {
                tot2 %= MOD;
                ans = ans * tot2 % MOD;
                s2 += 2;
            }
            tot+=2;
        }
        ans = ans * pos[s2] % MOD;
    }
    else
    {   
        ll s1 = 0, s2 = 0;
        while(tot < k)
        {
            ll tot1 = -INT_MAX, tot2 = -INT_MAX;
            if(s1 < n1-1)
                tot1 = neg[s1] * neg[s1+1];   
            if(s2 < n2-1)
                tot2 = pos[s2] * pos[s2+1];
            if(tot1 > tot2)
            {
                tot1 %= MOD;
                ans  = ans * tot1 % MOD;
                s1 += 2;
            }
            else
            {
                tot2 %= MOD;
                ans = ans * tot2 % MOD;
                s2 += 2;
            }
            tot+=2;
        }
    }   
    cout << (ans + MOD) % MOD<< '\n';
    
}

 
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL); 
    int tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}

Measured memory_bytes: 9948
import sys
L, R = map(int, input().split())

if R-L >= 2018:
    print(0)
    sys.exit()

min_mod = 2019
for i in range(L, R+1):
    for j in range(i+1, R+1):
        mod = (i*j)%2019
        min_mod = mod if min_mod > mod else min_mod
print(min_mod)

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

vector<vector<int>> G;

int main() {
    int N; cin >> N;
    vector<pair<int, int>> E(N - 1);
    G.resize(N + 1);
    REP(i, 0, N - 1) {
        cin >> E[i].first >> E[i].second;
        G[E[i].first].push_back(E[i].second);
    }

    int C[N + 1];
    C[1] = 0;
    int colors = G[1].size();
    REP(i, 1, N + 1) {
        if (i != 1 && G[i].size() >= colors) colors = G[i].size() + 1;

        int color = 1;
        REP(j, 0, G[i].size()) {
            if (C[i] == color) color++;
            C[G[i][j]] = color;
            color++;
        }
    }

    cout << colors << endl;
    REP(i, 0, N - 1) cout << C[E[i].second] << endl;
    
    return 0;
}

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

S = A[0]
T = sum(A) - S
cnt = abs(S - T)
for i in range(1, N - 1):
    S += A[i]
    T -= A[i]
    cnt = min(cnt, abs(S - T))
print(cnt)


Measured memory_bytes: 23800
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const ll INF = (1 << 28);
const ll dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const ll Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
ll n, m;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m;
    map<ll, ll> modm;
    ll sum = 0;
    for (ll i = 0; i < n; i++)
    {
        ll a;
        cin >> a;
        a = a % m;
        sum += a;
        sum %= m;
        modm[sum]++;
    }
    ll ans = 0;
        for (auto itr = modm.begin(); itr != modm.end(); ++itr)
        {
            ll k = itr->first;
            ll v = itr->second;
            if (k == 0){
                ans+=modm[0];
                ans += ll(modm[k]*(modm[k]-1)/2);
            }
            else{
                ans+=ll(modm[k]*(modm[k]-1)/2);
            }
        }
    
    cout << ans << "\n";
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=1<<17,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int N,M;cin>>N>>M;
        
        if(N==0&&M==0) return 0;
        
        vector<int> A(N),B(M);
        int Asum=0,Bsum=0;
        for(int i=0;i<N;i++){
            cin>>A[i];
            Asum+=A[i];
        }
        
        for(int i=0;i<M;i++){
            cin>>B[i];
            Bsum+=B[i];
        }
        
        int maxi=INF,a=INF,b=INF;
        
        for(int i=0;i<N;i++){
            for(int j=0;j<M;j++){
                if(Asum-A[i]+B[j]==Bsum+A[i]-B[j]){
                    if(A[i]+B[j]<maxi){
                        maxi=A[i]+B[j];
                        a=A[i];
                        b=B[j];
                    }
                }
            }
        }
        
        if(maxi==INF) cout<<-1<<endl;
        else cout<<a<<" "<<b<<endl;
    }
}



Measured memory_bytes: 3072
n = int(input())
A = [int(x) for x in input().split()]
LIM = 10**5
freq = [0 for i in range(LIM+1)]

for x in A:
    freq[x] += 1

unique = sum([1 if ct > 0 else 0 for ct in freq])
evens = sum([1 if ct > 0 and ct%2==0 else 0 for ct in freq])
print(unique-(1 if evens%2==1 else 0))

Measured memory_bytes: 14396
N = gets.to_i
S = gets.to_s
black = []
white = []
if S[0] == '.'
  black << 0
  white << 1
else
  black << 1
  white << 0
end
(1...N).each do |i|
  if S[i] == '#'
    black << black[i-1] + 1
    white << white[i-1]
  else
    black << black[i-1]
    white << white[i-1] + 1
  end
end
mem1 = [black[N-1], white[N-1]].min
(1...N).each do |i|
  mem2 = black[i-1] + white [N-1] - white [i-1]
  mem1 = [mem1, mem2].min
end
p mem1

Measured memory_bytes: 7240
#include <stdio.h>
int main(void){
    
    int a, b, d, r;
    double f;
    scanf("%d %d", &a, &b);
    
    d = a / b;
    r = a % b;
    f = a / (double)b;
    
    printf("%d %d %.7f\n", d,r,f);
    
    return 0;
}



Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
     
#define ll long long
#define loop(i,a,n) for(ll i=a;i<n;++i)
#define revloop(i,a,b) for(ll i=a;i>=b;--i)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 1000000000000000000
#define MOD 1000000007 

void func()
{
    ll n;
    cin>>n;
    ll a[n];
    loop(i,0,n){
        cin>>a[i];
    }
    sort(a,a+n);
    vector<ll> v;
    v.pb(a[n-1]);
    ll i=n-2;
    while(v.size()<n-1){
        v.pb(a[i]);
        if(v.size()==n-1) break;
        v.pb(a[i]);
        i--;
    }
    ll sum=0;
    loop(i,0,v.size()){
        sum+=v[i];
    }
    cout<<sum<<"\n";
}
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w" , stdout);
    #endif
 
    ll t=1;
    //cin>>t;
    while(t--)
    {
        func();
    }
}

Measured memory_bytes: 6896
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl;
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define RE return 0;
#define int ll

signed main(){
  int a,b;
  cin>>a>>b;
  if(a+b==15) cout<<'+'<<en
    else if(a*b==15) cout<<'*'<<en
      else cout<<'x'<<en
        RE
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define mp make_pair
#define fi first
#define se second
#define pb push_back

int a,b,c;
set < string > S;
map < string ,int > C;
string s;

int main(){
	
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int ans = 0;
	cin >> a;
	for ( int i = 0; i < a; i++ ){
		cin >> s;
		C[s]++;
		ans = max( ans, C[s] );
	}
	
	for ( auto it : C ){
		if ( it.second == ans ) cout << it.first << endl;
	}
	return 0;
}

Measured memory_bytes: 23808
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")



n,k = map(int, input().split())
a = list(map(int, input().split()))

# 累積和
def cumsum(l):
    """a[i] = sum(l[:i]) なるaを返す
    """
    c = 0
    a = [None] * (len(l)+1)
    for i,num in enumerate(l):
        a[i] = c
        c += num
    a[-1] = c
    return a
c = cumsum(a)
l = 50
s = set()
for j in range(n+1):
    for i in range(j):
        s.add(bin(c[j]-c[i])[2:].rjust(l, "0"))
        
ans = 0
for i in range(l):
    count = 0
    tmp = set()
    for item in s:
        if item[i]=="0":
            pass
        else:
            count += 1
            tmp.add(item)
    if count>=k:
        ans+= 2**(l-i-1)
        s = tmp
print(ans)

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

using ll = long long;

#define mod 1000000007
#define init ios::sync_with_stdio(0);cin.tie(0);

typedef vector<int> vi;
typedef pair<int, int> pi;
#define MS(x,y) memset(x,y,sizeof(x))
#define F first
#define S second
#define PB push_back
#define MP make_pair






int main()
{
   init;

   int x[5];

   cin >> x[0] >> x[1] >> x[2] >> x[3] >> x[4];

   for (int i = 0; i < 5; ++i)
   {
      if (x[i] == 0) {
         cout << i + 1 << endl;
         break;
      }

   }

}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount _builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace __gnu_pbds;
using namespace std;
//typedef
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
//constants
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
//
#define forn(i, n)for(ll i=0;i<n;i++)
// gcd of a and b
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
// distance between (a,b) and (c,d)
long double dis(long long a,long long b,long long c,long long d){return sqrt( ((a)-(c))*((a)-(c))+((b)-(d))*((b)-(d)) );}
// simple prime check
bool isprime(long long a){
if(a==2)return 1;
if(!(a&1))return 0;
for(ll i=3;i*i<=a;i+=2){
	if(a%i==0)return 0;
}
return 1;
}
// fast expo
long long mpow(long long base,long long exponent,long long modulus){
if(modulus==1)return 0;
long long result = 1;
base=base%modulus;
while(exponent){
		if(exponent%2 == 1)
			result=(result*base)%modulus;
		exponent=exponent>>1;
		base=(base*base)%modulus;
	}
return result;
}
// modular inverse
ll minv(ll a,ll mod){
	ll _gcd=gcd(a,mod);
	assert(_gcd==1);
	return mpow(a,mod-2,mod);
}

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

/*
ll dx[]={1,0,-1,0,1,1,-1,-1};
ll dy[]={0,-1,0,1,1,-1,-1,1};
*/

/*
void sieve(int N){
	for(int i=0;i<=N;i++){
		spf[i]=i;
	}
	for(int i=2;i*i<=N;i++){
		if(spf[i]==i){
			for(ll j=i*i;j<=N;j+=i){
				spf[j]=min(spf[j],i);
			}
		}
	}
	return;
}
*/

/*
void nCr(ll n,ll k){
	ll i,j;
	for(i=0;i<=n;i++){
		for(j=0;j<=min(i,k);j++){

			if(j==0 or j==i)C[i][j]=1LL;
			else  C[i][j]=(C[i-1][j-1]+C[i-1][j])%MOD;

		}
	}
	return;
}
*/
/*
ll ncr(ll N,ll K){
	if(N<K)return 0;
	if(K==0)return 1;
	if(N==0)return 0;

	ll den=1;
	for(ll i=1;i<=K;i++)den*=i;
	ll num=1;
	while(K--){
		num*=N;
		if(num%den==0){
			num/=den;
			den=1;
		}
		N--;
	}

	return num;
}
*/

ll n;
ll a[25],b[25];
int main(){FAST;
cin>>n;
for(ll i=0;i<n;i++){
	cin>>a[i];
}
for(ll i=0;i<n;i++){
	cin>>b[i];
}
vl dif;
for(ll i=0;i<n;i++){
	dif.pb(a[i]-b[i]);
}
sort(rall(dif));
ll ans=0;
for(auto it:dif){
	if(it>=0)ans+=it;
}
cout<<ans;
return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int cnt[27];
int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  int ans = INF;
  // ll n;
  // cin >> n;
  // ll n, m;
  // cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  string ss;
  cin >> ss;
  // for(char c: s) {
  //   cnt[c - 'a']++;
  // }
  // int* i = MAX(cnt, cnt + 27);
  // char maxc = i - cnt + 'a';
  // cout << maxc << endl;
  fk(0, 26) {
    int cnt = 0;
    int run = 1;
    char c = 'a' + k;
    string s(ss);
    while(run) {
      run = 0;
      string ns;
      fi(0, s.size() - 1) {
        if(s[i] != c || s[i + 1] != c)
          run = 1;

        if(s[i] == c || s[i + 1] == c) {
          ns += c;
        }
        else
          ns += s[i];
      }
      s = ns;
      if(run)
        cnt++;
    }
    chmin(ans, cnt);
  }
  cout << ans << endl;
  return 0;
}



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

bool num[107] = {};
int main()
{
	int x, n;
	cin >> x >> n;

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

	for (int i = 0;; ++i)
	{
		if (x-i < 0 || num[x-i] == false)
		{
			cout << x-i << '\n';
			break;
		}
		else if (num[x+i] == false)
		{
			cout << x+i << '\n';
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3624
#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 all(x) (x).begin(),(x).end()
#define m0(x) memset(x,-1,sizeof(x))
const int INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793;
const int MAX_N = 2e5;

int main(){
  int k;
  cin >> k;
  ll ta[10000010];
  fill(ta, ta + 10000001, 1);
  for(int i = 2; i < 10000001; i++){
    int j = 1;
    while(i * j < 10000001){
      ta[i*j]++;
      j++;
    }
  }
  for(int i = 1; i < 10000001; i++){
    ta[i] *= i;
  }
  for(int i = 1; i < 10000001; i++){
    ta[i+1] += ta[i];
  }
  cout << ta[k] <<endl;
}

Measured memory_bytes: 81724
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"


int main() {
	while(1){
		int a, b, c, d, e, f; cin >> a >> b >> c >> d >> e >> f;
		int x = a + d, y = b + e, z = c+ f;
		if (!x&&!y&&!z)break;
		int ans = 0;
		int amin = min(min(x, y), z);
		for (int i = 0; i <= min(2,amin); ++i) {
			int sum = i;
			sum += (x - i) / 3 + (y - i) / 3 + (z - i) / 3;
			ans = max(ans, sum);
		}
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;  
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define Rep(i, a, b) for(ll i = a; i <= b; i++)
#define repr(i, a, b) for(ll i = b-1; i >= a; i--)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
// const ll INF = 1LL << 60;
const ll INF = 100000000000;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second
 
// rep(i, 0, sz(v)) cout << v[i] << " \n"[i==sz(v)-1];
 
////////////////////////////////////////////////////////

const int MAX = 5100000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    COMinit();
    ll n, k; cin >> n >> k;
    if(k >= n){
        co(COM(2*n-1, n-1));
        return 0;
    }
    ll ans = 0;
    Rep(i, 0, k){
        ans += COM(n, i) * COM(n-1, i);
        ans %= MOD;
    }
    co(ans);

    return 0;
}
 

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;
struct Edge {
	ll to;
	ll cost;
};
using Graph = vector<vector<Edge>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define RES(a, n) (a).resize(n)
#define VLCIN(a, n) REP(i,n){cin >> a[i];}
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 2.0 * asin(1.0);
const ll INF = 1L<<60;
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MAX = (ll)pow(10,7);
/****** define constant end ********/
/****** define variable start ******/
ll a;
/******* define variable end *******/
int solve() {
	cin >> a;
	cout << a + a * a + a * a * a << endl;
	return 0;
}
int main() {
	// clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define dump(x) cout << #x << " = " << (x) << endl;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

#define int long long

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> A(N);
  REP(i, N) cin >> A[i];
  vector<int> v;
  map<int, int> cnt;
  REP(i, N) {
    cnt[A[i]]++;
    if(cnt[A[i]] == 2) {
      cnt[A[i]] = 0;
      v.push_back(A[i]);
    }
  }
  if(v.size() >= 2) {
    sort(rall(v));
    cout << 1 * v[0] * v[1] << endl;
  } else {
    cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
#define pb push_back
#define long long long
#define pll pair < long , long >
#define vll vector < pll >
#define ml map < long , long >
#define mll map < pll , long >
#define x first
#define y second
#define vl vector < long >
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
long n,i,a[11],c=0;
vl v(11);
void solve(long x)
{
    if(x==n)
    {
        long i,f=0;
        for(i=0;i<n;++i)
        if(v[i]%2==0) f=1;
        if(f) c++;
        return ;
    }
    v[x]=a[x]-1;
    solve(x+1);
    v[x]=a[x];
    solve(x+1);
    v[x]=a[x]+1;
    solve(x+1);
}
int main()
{
    io
    cin>>n;
    for(i=0;i<n;++i)
    cin>>a[i];
    solve(0);
    cout<<c;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
 
int main(void)
{
    long long N, x, a[101], i, num=0, ans, judge=0;

    cin >> N >> x;

    for(i=1; i<=N; i++){
        cin >> a[i];
    }

    sort(a+1, a+N+1);

    for(i=1; i<=N; i++){
        num += a[i];

        if(num > x){
            ans = i-1;

            judge = 1;

            break;
        }
    }

    if(judge == 0){
        if(num == x){
            ans = N;
        }
        
        else{
            ans = N-1;
        }
    }
    
    cout << ans << endl;

    return 0;
}


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

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

	int sz = S.size();
	string s;
	for( int i = 0; i < sz; i++ ) {
		if( S[i] != 'x' ) s += S[i];
	}
	int sz2 = s.size();
	for( int i = 0; i < sz2 / 2; i++ ) {
		if( s[i] != s[sz2 - 1 - i] ) {
			cout << -1 << endl;
			return 0;
		}
	}
	vector<int> x( sz2 + 1 );
	int j = 0;
	for( int i = 0; i < sz; i++ ) {
		if( S[i] == 'x' ) {
			x[j]++;
		}
		else {
			j++;
		}
	}
	int sz4 = x.size();
	int ans = 0;
	for( int i = 0; i < sz4; i ++ ) {
		int l = x[i];
		int r = x[sz4 - 1 - i];
		x[i] = 0;
		x[sz4 - 1 - i] = 0;
		ans += abs( l - r );
	}

	cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;
 
#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
	#define eprintf(...) 42
#endif

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
	return (ull)rng() % B;
}
 
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mk(arr,n,type)  type *arr=new type[n];
 
clock_t startTime;
double getCurrentTime() {
	return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}
int main(){
	int n;
	cin >> n;
	vector<string>s(10);
	s[0] = "pon";
	s[1] = "pon";
	s[2] = "hon";
	s[3] = "bon";
	s[4] = "hon";
	s[5] = "hon";
	s[6] =	"pon";
	s[7] = "hon";
	s[8] = "pon";
	s[9] = "hon";
	cout << s[n % 10]<< "\n";

	return 0;
}


Measured memory_bytes: 3128
from operator import itemgetter

N, M = map(int, raw_input().split())
drinklist = []
for i in range(0, N):
	drinklist.append(map(int, raw_input().split()))
drinklist = sorted(drinklist, key=itemgetter(0))
sum = 0
drink = M
for i in range(0, N):
	if drink < drinklist[i][1]:
		sum += drink * drinklist[i][0]
		break
	else:
		sum += drinklist[i][1] * drinklist[i][0]
		drink -= drinklist[i][1]

print sum


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

#define int long long
#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define mp make_pair
#define mt make_tuple
#define DESYNC                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector<ii>
#define all(x) x.begin(), x.end()
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define M 1000000007
#define curtime chrono::steady_clock::now().time_since_epoch().count
#define rep(i, beg, n, s) for (int i = beg; i < n; i += s)
const double PI = acos(-1);

using namespace std;

inline int mod(int n, int m = M) {
  int ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}

int exp(int n, int k) {
  if (k == 0) return 1;
  if (k == 1) return n;
  int ax = exp(n, k / 2);
  ax = mod(ax * ax);
  if (k % 2) ax = mod(ax * n);
  return ax;
}

int gcd(int a, int b) {
  if (a == 0)
    return b;
  else
    return gcd(b % a, a);
}

namespace NT {

const int MAX_N = 1123456;

bitset<MAX_N> prime;
vector<int> primes;
int lf[MAX_N];
int totient[MAX_N];

void Sieve(int n) {
  for (int i = 0; i <= n; i++) lf[i] = i;
  prime.set();
  prime[0] = false;
  prime[1] = false;
  for (int p = 2; p * p <= n; p++) {
    if (prime[p]) {
      for (int i = p * p; i <= n; i += p) {
        prime[i] = false;
        lf[i] = min(lf[i], p);
      }
    }
  }
  for (int i = 2; i <= n; i++)
    if (prime[i]) primes.pb(i);
}

void EulerTotient(int n) {
  for (int i = 0; i <= n; i++) totient[i] = i;
  for (int p = 2; p <= n; p++) {
    if (totient[p] == p) {
      totient[p] = p - 1;
      for (int i = p + p; i <= n; i += p) {
        totient[i] = (totient[i] / p) * (p - 1);
      }
    }
  }
}

};  // namespace NT

//#define MULTIPLE_TEST_CASE
void solution() {
  int n;
  cin >> n;
  NT::Sieve(1000000);
  int v[n];
  rep(i, 0, n, 1) cin >> v[i];
  int all_g = v[0];
  set<int> s;
  bool pair = true;
  rep(i, 0, n, 1) {
    all_g = gcd(all_g, v[i]);
    int x = v[i];

    vector<int> fac;
    while (x != 1) {
      if (pair == false) break;
      if (s.count(NT::lf[x])) pair = false;
      fac.pb(NT::lf[x]);
      x /= NT::lf[x];
    }
    for (int x : fac) s.insert(x);
  }
  if (pair)
    cout << "pairwise coprime" << endl;
  else if (all_g == 1)
    cout << "setwise coprime" << endl;
  else
    cout << "not coprime" << endl;
}

int32_t main() {
  DESYNC;
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  int t = 1;
#ifdef MULTIPLE_TEST_CASE
  cin >> t;
#endif
  while (t--) solution();
}


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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> data(n);

    int min = -1;
    int max = 1 << 30;
    for(int i = 0; i < m; i++){
        int l, r;
        cin >> l >> r;
        if (min < l){
            min = l;
        }
        if (max > r){
            max = r;
        }
    }

    cout << (max >= min ? (max - min + 1) : (0)) << endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	private void solve() {
		Scanner in = new Scanner(System.in);
		int A = in.nextInt();
		int B = in.nextInt();
		int C = in.nextInt();
		
		int ans = C - (A - B) ;
		System.out.println((ans<0)?0:ans);
	}

	public static void main(String[] args) {
		new Main().solve();
	}
}

Measured memory_bytes: 22996
/**
 * Author: PraveenKumarRana
**/

#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
using namespace std;

void solve(){
    int n; cin>>n; 
    vector<int> dp(3,0);
    for(int day=0; day<n; day++){
        vector<int> new_dp(3,0);
        vector<int> c(3);
        for(int i=0; i<3; i++) cin>>c[i];
        for(int i=0; i<3; i++){
            for(int j=0; j<3; j++){
                if(i!=j){
                    new_dp[j]=max(new_dp[j],dp[i]+c[j]);
                }
            }
        }
        dp=new_dp;
    }
    cout<<max(dp[0],max(dp[1],dp[2]))<<"\n";
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}



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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1000000000

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const long double EPS = 0.0000000001;

int n,m;

bool check(int x, vector<vector<int>> s, vector<int>p){
	vector<int> state(n);
	for(int i = 0; i < n; i++){
		if(x % 2 == 1)state[i] = 1;
		x /= 2;
	}
	// for(int i = 0; i < n; i++)cout << state[i] << " ";
	// cout << endl;
	for(int i = 0; i < m; i++){
		int tmp = 0;
		for(int j = 0; j < s[i].size(); j++){
			// cout << s[i][j] <<"\t" << state[s[i][j]]<< endl;
			tmp += state[s[i][j]];
		}
		if(tmp % 2 != p[i])return 0;
	}
	return 1;
}


int main(){
	cin >> n >> m;
	vector<vector<int>> s(m);
	for(int i = 0; i < m; i++){
		int k; cin >> k;
		vector<int>v(k);
		for(int j = 0; j < k; j++){
			cin >> v[j];
			v[j]--;
		}
		s[i] = v;
	}


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

	// cout << check(3,s,p) << endl;

	int ans = 0;
	for(int i = 0; i < (1<< n); i++){
		// cout << i << endl;
		ans += check(i, s, p);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main()
{
	long K, ans, dist, A0, N;
	cin >> K >> N;
	vector<long> A(N), Sum(N);
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
		//Sum[i] += A[i];
	}
	dist = (A[N - 1] - A[0]);
	for (int i = 1; i < N; i++)
	{
		dist = min(dist,K-(A[i] - A[i - 1]));
	}
	cout << dist;
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    vector<ll> sum(N);
    sum[0] = A[0];
    for (int i = 1; i < N; i++) sum[i] = sum[i-1]+A[i];
    vector<vector<ll>> dp(N, vector<ll>(N, (ll)1e18));
    for (int i = 0; i < N; i++) dp[i][i] = 0;
    for (int l = 2; l <= N; l++) {
        for (int i = 0; i+l-1 <= N-1; i++) {
            ll all = sum[i+l-1];
            if (i > 0) all -= sum[i-1];
            for (int j = i+1; j <= i+l-1; j++) {
                dp[i][i+l-1] = min(dp[i][i+l-1], all+dp[i][j-1]+dp[j][i+l-1]);
            }
        }
    }
    cout << dp[0][N-1] << endl;
    return 0;
}

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

int main(){
    string n;
    cin >> n;
    if (n[0] == '7' || n[1] == '7' || n[2] == '7'){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

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

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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; }



i64 n, a[202020];
i64 d[202020];
void solve(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		d[a[i]]++;
	}
	
	i64 cnt = 0;
	for(int i = 0; i <= n; i++){
		cnt += d[i]*(d[i]-1)/2;
	}
	for(int i = 0; i < n; i++){
		cout << cnt-d[a[i]]+1 << endl;
	}
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 4736
import numpy as np
N, K ,Q = map(int, input().split())
participant = np.full(N, K)
As = []
for i in range(Q):
    answer = int(input())
    participant[answer-1] +=1
participant -= Q
for surviver in np.where(participant>0, "Yes", "No"):
    print(surviver)

Measured memory_bytes: 16984
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int N;
  cin >> N;
  vector <string> S(N);
  rep(i,N) cin >> S[i];

  int ac = 0;
  int wa = 0;
  int tle = 0;
  int re = 0;

  rep(i,N){
    if (S[i] == "AC") ac++;
    if (S[i] == "WA") wa++;
    if (S[i] == "TLE") tle++;
    if (S[i] == "RE") re++;
  }

  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
}


Measured memory_bytes: 6412
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx2,tune=native")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("trapv")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using pi = pair<ll, ll>;
const ll mod = 7 * 17 * (1 << 23) + 1;
const ll inf = 1e18 + 69;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() { //DINIC ORZ
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n;
	vi p;
	cin >> n;
	p.resize(n);
	for(int t, i = 0; i < n; i++) {
		cin >> t;
		--t;
		p[t] = i;
	}
	ll ans = 0, cur = 0;
	for(int r = -1, i = 0; i < n; i++) {
		if(p[i]<r) {
			cur = 0;
		}
		cur++;
		r = p[i];
		ans = max(ans, cur);
	}
	cout << n-ans;
}


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


void solve(long long N, std::vector<long long> H){
    int cnt = 1;
    for(long long i = 1; i < N; i++){
        bool flag = true;
        //cout << "i: " << i << endl;
        for(long long j = 0; j <= i-1; j ++){
            //cout << "j: " << j << endl;
            //cout << "H[j]: " << H[j] << endl;
            //cout << "H[i]: " << H[i] << endl;
            if(H[j] <= H[i]) continue;
            else{
                flag = false;
                break;
            };
        }
        if(flag) cnt++;
    }
    cout << cnt << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> H(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&H[i]);
    }
    solve(N, std::move(H));
    return 0;
}


Measured memory_bytes: 256