akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
// #define int ll
using namespace std;
const int INF (1 << 30);
const ll LLINF (1LL << 55LL);
const int MOD = 1000000007;
const int MAX = 510000;
const double pi=3.14159265358979;

ll fac[MAX], finv[MAX], inv[MAX];
ll POW[MAX];

ll extgcd(ll a, ll b, ll& x, ll& y){
    ll d=a;
    if(b != 0){
        d = extgcd(b, a%b, y, x);
        y -= (a/b) * x;
    }
    else{
        x=1;y=0;
    }
    return d;
}

void POWinit(){
    POW[0]=0;
    POW[1]=1;
    for(ll i=2;i<MAX;i++){
        POW[i]=POW[i-1]*i;
        POW[i]%=MOD;
    }
}


// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll 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;
    }
}

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

ll mod_inverse(ll a,ll mod){
    ll x,y;
    extgcd(a,mod,x,y);
    return (mod+x%mod)%mod;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k,ans[1010]={},res=0;
    cin>>n>>k;
    COMinit();
    POWinit();
    if(n>k){
        cout<<0<<endl;
        return 0;
    }
    else{
        cout<<1<<endl;
        return 0;
    }
    return 0;
}


Measured memory_bytes: 19052
import sys;input=sys.stdin.readline

P = 2019
S=input().strip()
N = len(S)
if P in {2, 5}:
    r=0
    for i in range(N):
        if not int(S[i])%P:
            r+=i+1
    print(r)
else:
    S = S[::-1]
    r=0
    from collections import defaultdict
    d=defaultdict(int)
    d[0] += 1
    R=0
    X=1
    for i in range(N):
        r += int(S[i])*X
        R += d[r%P]
        X = (X*10)%P
        d[r%P]+=1
    print(R)


Measured memory_bytes: 69140
// acdart
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <string>
#include <queue>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <cstdlib>
#include <list>
#include <limits.h>
#include <utility>
#include <functional>
#include <deque>
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define X first
#define Y second
#define F first
#define S second
#define MOD9 1000000009ll
#define MOD7 1000000007ll
#define MOD
#define INF  1023456789ll
#define INF16 10000000000000000ll
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define SZ(x) ((int)(x).size())
#define MAXN 10010
#define MAXM
#define ALL(x) ((x).begin()),((x).end())
#define RESET(a,b) memset(a,b, sizeof a)
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define LEN(X) strlen(X)
#define FI(a,b,c) for(int a=b; a<c; a++)
#define FD(a,b,c) for(int a=b; a>c; a--)
using namespace std;
typedef long long ll;
typedef long long LL;
typedef double db;
typedef double D;
typedef long double ld;
typedef long double LD;
/*********default*********/
int n, k, v[5010], a[5010], d[5010];

int main()
{
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	sort(a, a + n);
	n = lower_bound(a, a + n, k) - a;
	int l = 0, r = n - 1;
	while (l <= r) {
		int i = (l + r) / 2;
		memset(d, 0, sizeof d);
		d[0] = 1;
		for (int j = 0; j < n; j++) {
			if (j != i) {
				for (int l = k - 1; l >= a[j]; l--) {
					if (d[l - a[j]]) {
						d[l] |= d[l - a[j]];
					}
				}
			}
		}
		int fg = 0;
		for (int j = k - 1; j >= k - a[i]; j--) {
			if (d[j]) {
				fg = 1;
				break;
			}
		}
		if (!fg) {
			l = i + 1;
		} else {
			r = i - 1;
		}
	}
	printf("%d\n", r + 1);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
		#include <bitset>
		using namespace std;
		#define ll long long 
		#define ld long double
		#define MOD 1000000007
		#define mod9 1000000009
		#define mod 1000003
		#define fast ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
		#define mp make_pair
		#define pb push_back
		#define ct ll t;cin>>t;while(t--)
		#define bi begin()
		#define ei end()
		#define fi first 
		#define se second   	
		bool isPrime(ll n) 
		{ 
			// Corner case 
			if (n <= 1) 
				return false; 
			
			// Check from 2 to n-1 
			for (ll i = 2; i*i <= n; i++) 
				if (n % i == 0) 
					return false; 
			
			return true; 
		}
		long long binpow(long long a, long long b) {
			long long res = 1;
			while (b > 0) {
				if (b & 1)
					res = (res%mod) * (a%mod);
				a = (a%mod) * (a%mod);
				b >>= 1;
			}
			return res%mod;
		}

		bool compare(const pair<ll,ll>&a,const pair<ll,ll>&b)
		{
			return (a.se<b.se);
		}
		ll lcm(ll a,ll b)
		{
			return(a*b)/__gcd(a,b);
		}
		vector<ll>s[2005];
		void SieveOfEratosthenes() 
		{  
			ll n=2005;
			bool prime[1000005]; 
			memset(prime, true, sizeof(prime)); 
			// s[0]=1;
			// s[1]=1;
			for (int p=2; p*p<=n; p++) 
			{ 
				s[p].pb(1);
				if (prime[p] == true) 
				{   
					for (int i=p+p; i<=n; i += p) {
						prime[i] = false; 
						s[i].pb(p);
						}
				} 
			} 
			// for(ll i=2;i<10005;i++)
			// {
			// 	if(prime[i])
			// 	{
			// 		// s.pb(i);
			// 	}
			// }
		} 
		void eea(ll a, ll b, ll & x, ll & y) {
		if (a == 0) {
			x = 0;
			y = 1;
			return ;
		}
		ll x1, y1;
		eea(b % a, a, x1, y1);
		x = y1 - (b / a) * x1;
		y = x1;
		return ;
	}
	ll modinverse(ll a,ll m)
	{
		ll x, y;
		eea(a, m, x, y);
		if (__gcd(a,m) != 1) {
		return -1;
		}
	else {
		x = (x % m + m) % m;
		cout << x << endl;
		return x;
	}
	}
		ll fact[1000007]={0};
		ll expo(ll x, ll y) {ll res=1;x=x%MOD;while(y>0){if(y&1)res=(1ll*res*x)%MOD;
		y=y>>1;x=(1ll*x*x)%MOD;} return res;}
		void facto() {fact[0]=1;fact[1]=1;for(ll i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%MOD;}
		ll npr(ll n,ll r) {facto(); ll res=1; res=fact[n]; res=(res*(expo(fact[n-r],MOD-2)))%MOD; return res; }
		ll ncr(ll n,ll r){ ll res=1; if(r>n-r)r=n-r; for(ll i=0;i<r;i++) {  res*=n-i;  res/=i+1; } return res;}
			ll C(ll n, ll k) {
    ll res = 1;
    for (ll i = 1; i <= k; ++i)
        res = ((res) * (n - k + i) / i)%MOD;
    return (ll)(res + 0.01)%MOD;
}
				
		int main()
		{
			fast
			
			ll n,a,b;
			cin>>n>>a>>b;
			ll k=n/(a+b);
			k*=a;
			k+=min(a,n%(a+b));
			cout<<k<<"\n";
		}

 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
//#define pw (ll)pow 
#define MAX 10000001
#define MOD (ll)1e9+7
using namespace std;

vector<ll> dv(MAX,0);

void nd(ll n) {
  for(int i=1; i<=n; i++) {
    for(int j=i; j<=n; j+=i)  dv[j]++;
  }
}

int main()  {
  ll n;
  cin >> n;
  nd(n);
  ll c=0;
  for(ll i=1; i<=n; i++) {
    c+=i*dv[i];
  }
  cout << c << endl;
}


Measured memory_bytes: 81220
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
#define INF LLONG_MAX
#define mod 1000000007
typedef long long ll;
int main(void)
{
	ll A, B, K;
	cin >> A >> B >> K;
	if(A>K)
	{
	    A -= K;
	    K = 0;
	}
	else
	{
	    K -= A;
	    A = 0;
	}
	if(B>K) B -= K;
	else B = 0;
	cout << A << " " << B << endl;
	return 0;
}


Measured memory_bytes: 256
# coding: utf-8
import math

anagramed = []

def main():
    # n = map(int, input().split(" "))
    n = int(input())
    m = []
    r = {}
    count = 0

    for _ in range(n):
        m.append(input())
        anagramed.append(False)

    for i in range(n):
        s = "".join(sorted(m[i]))
        if r.get(s) is None :
            r[s] = 1
        else:
            count += r[s]
            r[s] += 1
    print(count)


main()

Measured memory_bytes: 25812
#include<cstdio>
#include<cstring>
#include<cctype>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<vector>
#include<algorithm>
#define ll long long
#define lowbit(x) x&-x
using namespace std;
int read(){
    char c;int s=0,t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
int min(int a,int b){return a<b?a:b;}
int max(int a,int b){return a<b?b:a;}
int ab(int x){return x>0?x:-x;}
//int MO(int x){return x>=MOD?x-MOD:x;}
//void insert(int u,int v){tot++;e[tot].v=v;e[tot].from=first[u];first[u]=tot;}
/*------------------------------------------------------------*/
const int inf=0x3f3f3f3f,maxn=100;

int n,A[maxn],a[maxn];
char s[maxn];
int main(){
    scanf("%s",s+1);n=strlen(s+1);
    for(int i=1;i<=n;i++)A[i]=s[i]-'a';
    int ok=0,oki;
    for(int i=1;i<=n;i++){
    	for(int j=A[i]+1;j<=25;j++)if(!a[j]){ok=i,oki=j;break;}
    	a[A[i]]++;
    }
    for(int i=0;i<=25;i++)if(!a[i]){printf("%s%c",s+1,i+'a');return 0;}
    if(ok==0){printf("-1");return 0;}
	for(int i=1;i<ok;i++)printf("%c",s[i]);printf("%c",oki+'a');
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

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

const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

template<class TYPE>
struct edge{
    TYPE to,cost; 
    edge(TYPE t,TYPE c){
        to = t;
        cost = c;
    }
};

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    int right = 0;
    int left = 0;
    for(int i = 1; i < s.length(); i++){
        if(s[i] == 'E') right++;
    }
    ans = left + right;
    for(int i = 0; i < s.length() - 1; i++){
        if(s[i] == 'W') left++; 
        if(s[i+1] == 'E') right--;
        ans = min(ans,left + right);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 900
#include <iostream>
#include <stdio.h>
using namespace std;

int n,a,b;

int main(void)
{
    cin >> n >> a >> b;
    if(n*a>b)
        cout << b;
    else if(n*a<b)
        cout << n*a;
    else
        cout << n*a;
    return 0;
}


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

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

using ll = long long;
using ull = unsigned long long;
using P = pair<ll,ll>;
using grid = vector<vector<int>>;

const int dx[2] = {1, 0};
const int dy[2] = {0, 1};
const int INF = 1<<30;
const ll mod = 998244353LL;
const ull B = 1000000007;

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

ull pow(ull a, ull n) {
	ull ret = 1LL;
	for (; n > 0LL; n >>= 1LL, a = a * a) {
		if (n % 2LL == 1LL) {
			ret = ret * a;
		}
	}
	return ret;
}

int main() {
    ull N;
    string S;
    cin>>N>>S;
    int ans = 0;
    rep(i,N/2+1){
        if(i==0) continue;
        bool done = false;
        vector<ull> v(N-i+1,0);
        rep(j,N-i+1){
            if(j==0){
                rep(k,i){
                    ull s = S[k] - 'a';
                    v[j] = (v[j]*B+s);
                }
            }
            else {
                ull t = S[j-1]-'a', s = S[j+i-1]-'a';
                v[j] = (v[j-1]*B-pow(B,(ull)i)*t+s);
            }
        }
        map<ull,vector<ull>> m;
        rep(j,N-i+1){
            m[v[j]].push_back(j);
        }
        for(auto x:m){
            if(*x.second.rbegin()-*x.second.begin()>=i) {
                ans = i;
                done = true;
            }
        }
        if(!done) break;
    }
    cout<<ans<<endl;
}

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

int main() {
	int N;
	string W[100];
	bool check = true;
	cin >> N >> W[0];
	for (int i = 1; i < N; i++) {
		cin >> W[i];
		if (W[i - 1][W[i - 1].size() - 1] != W[i][0]) check = false;
		for (int j = 0; j < i; j++) {
			if (W[i] == W[j]) check = false;
		}
	}
	if (check) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define MOD (long long)1000000007
#define INF (long long)998244353
using namespace std;

int main(void){
    string s;
    cin >> s;
    if((s[0]==s[1]&&s[2]==s[3]&&s[0]!=s[2])||(s[0]==s[2]&&s[1]==s[3]&&s[0]!=s[1])||(s[0]==s[3]&&s[1]==s[2]&&s[0]!=s[1])){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}


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

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

long long a[100010][3];
long long dp[100010][3];

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

  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < 3; j++)
    {
      cin >> a[i][j];
    }
  }

  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < 3; j++)
    {
      for (int k = 0; k < 3; k++)
      {
        if (j == k)
          continue;
        chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
      }
    }
  }

  long long res = 0;
  for (int j = 0; j < 3; j++)
    chmax(res, dp[N][j]);
  cout << res << endl;
}


Measured memory_bytes: 4992
import Foundation

let input1 = readLine()!.components(separatedBy: " ")
let x = Int(input1[0])!
let n = Int(input1[1])!

if n == 0 {
    print(x)
    exit(0)
}

var p = readLine()!.components(separatedBy: " ").map {Int($0)!}

var counter = 0
while(true) {
    
    if p.first(where: {$0 == x - counter}) == nil {
        print(x - counter)
        exit(0)
    }
    
    if p.first(where: {$0 == x + counter}) == nil {
        print(x + counter)
        exit(0)
    }
    
    counter += 1

}


Measured memory_bytes: 14164
#include <stdio.h>

int main(void)
{
	int solved, sum;
	int max;
	int m, n;
	int i, j;
	
	scanf("%d%d", &m, &n);
	
	max = 0;
	for (i = 0; i < m; i++){
		sum = 0;
		for (j = 0; j < n; j++){
			scanf("%d", &solved);
			sum += solved;
		}
		if (sum > max){
			max = sum;
		}
	}
	
	printf("%d\n", max);
	
	return (0);
}

Measured memory_bytes: 0
# BIT使ってC問題ちゃんとやろうとしたけど1時間かけて無を生成したので諦める。ぷえwwwww
from random import randint
d=int(input())
c=list(map(int,input().split()))
s=[list(map(int,input().split()))for _ in range(d)]
for i in range(d):s.append(s[i][:])
for i in range(d):s.append(s[i][:])
def xyz(start):
  ans=[0]*d
  score=0
  for i in range(start,start+d,26):
    dd=set()
    uu=set()
    h=[]
    for j in range(i,min(i+26,start+d)):
      for k in range(26):
        h.append([s[j][k],j,k])
    h.sort(reverse=1)
    for t,j,k in h:
      if j in dd or k in uu:continue
      score+=t
      ans[j%d]=k
      dd.add(j)
      uu.add(k)
  return [score,ans]
score,ans=xyz(0)
for i in range(1,d):
  ss,aa=xyz(i)
  if ss>score:
    score,ans=ss,aa
for i in ans:print(i+1)

Measured memory_bytes: 10168
//By Vasu Agrawal
#include<iostream>
#include<bits/stdc++.h>
typedef long long int ll;
#define pb push_back
#define pob pop_back
#define mk make_pair
#define fr first
#define sc second
#define pu push
#define ins insert
#define mod 1000000007
#define mem(a,val) memset(a,val,sizeof(a))
#define V(a) vector<a> 
#define pp pair<ll,ll>
#define lb(a,n) lower_bound(a.begin(),a.end(),n)-a.begin()
#define ub(a,n) upper_bound(a.begin(),a.end(),n)-a.begin()
#define F(i,n) for(ll i=0;i<n;i++)
#define in(a,n) F(i,n) cin>>a[i]
#define in1(a,n) f(i,n) cin>>a[i]
#define out1(a,n); f(i,n) cout<<a[i]<<" ";cout<<endl;
#define out(a,n); F(i,n) cout<<a[i]<<" ";cout<<endl;
#define f(i,n) for(ll i=1;i<=n;i++)
#define all(a) a.begin(),a.end()
#define vasu2907 ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
using namespace std;
bool isprime(ll n) //Time Complexity--->sqrt(n)
{   if (n <= 1)  return false; if (n <= 3)  return true; 
  	if (n%2 == 0 || n%3 == 0) return false; 
    for (int i=5; i*i<=n; i=i+6) if (n%i == 0 || n%(i+2) == 0) return false; 
    return true; 
} 

V(ll) merge(V(ll) v1,V(ll) v2)
{	V(ll) temp;
	ll i=0,j=0;
	while(i<v1.size() && j<v2.size())
	{	if(v1[i]<v2[j])
			temp.pb(v1[i]),i++;
		else
			temp.pb(v2[j]),j++;
	}
	while(i<v1.size())	
		temp.pb(v1[i]),i++;
	while(j<v2.size())	
		temp.pb(v2[j]),j++;
	return temp;
}
//id=(id&(id+1))-1
//ll fetch(ll id)
//{		
//}
//id=(id|(id+1))
//void update(ll id)
//{	
//}

//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
// Code Starts Here
ll power(ll a,ll b,ll p)
{	if(b==0)	return 1;
	if(b==1)	return a;
	ll x=power(a,b/2,p);
	if(b%2==1)	return (((x*x)%mod)*a)%mod;
	else return (x*x)%mod;
}
int main()
{	vasu2907;
	ll n;
	cin>>n;
	if(n==1)	return cout<<0<<endl,0;
//	ll ans=(n*(n-1));
//	ans=(ans*power(10,n-2,mod))%mod;
	ll ans=(power(10,n,mod)-(2*power(9,n,mod)-power(8,n,mod)+mod)+mod+mod+mod)%mod;
	cout<<ans<<endl;
}

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

const int Max=100010;
int n,m,num[Max],pre,ans;
map<int,int>sum;

signed main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%d",&num[i]);
	sum[0]=1;
	for(int i=1;i<=n;i++)
	{
	  int x=num[i]+pre;
	  pre=x;
	  ans+=sum[x%m];
	  sum[x%m]++;
	}
	cout<<ans<<"\n";

	return 0;
}

Measured memory_bytes: 4992
#include <iostream>

using namespace std;

int main(){
        long long int N,i,j,k,ans=1,hiki=1;
        cin >> N;
        for(i=0;i<N;i++){
                cin >> j;
                ans*=3;
                if(j%2==0)hiki*=2;
        }
        cout << ans - hiki << endl;

        return 0;
}

Measured memory_bytes: 256
Program Main

    Implicit None
    Character            :: S*10,T*10,U*10
    Integer              :: A,B

    Read(*,*) S,T
    Read(*,*) A,B
    Read(*,*) U

    If(S==U) A=A-1
    If(T==U) B=B-1

    Write(*,"(I0,x,I0)") A,B

  End Program


Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <limits.h>

using namespace std;

int main() {
  int32_t i;
//  int32_t j;
//  int32_t answer;
  cin >> i;
//  cin >> j;

  switch(i) {
    case 22:
    case 23:
    case 24:
    case 25:
      cout << "Christmas";
      for (int32_t k = 0; k < 25 - i; ++k) {
        cout << " Eve";
      }
      break;
    default:
      break;
  }

//  answer = (i + j) % 24;

//cout << answer;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<tuple>
#include<vector>
#include<map>
using namespace std;

int main(void){
  //入力
  int x1, y1, x2, y2;
  int x3, y3, x4, y4;
  int dx, dy;
  cin >> x1 >> y1 >> x2 >> y2;
  //正方形を求める。
  dx = x2 - x1;
  dy = y2 - y1;
  x3 = x2 - dy;
  y3 = y2 + dx;
  x4 = x3 - dx;
  y4 = y3 - dy;
  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000000

int h=0, A[MAX+1], num;
char input[8];

void heapIncreaseKey(key)
{
    int current;
    int i = h;
    if (key < A[i]) printf("new key is smaller than current key\n");
    A[i] = key;
    while (i > 1 && A[i/2] < A[i])
    {
        current = A[i];
        A[i] = A[i/2];
        A[i/2] = current;
        i = i/2;
    }
}

void maxHeapInsert(key)
{
    h++;
    A[h] = -MAX;
    heapIncreaseKey(key);
}

void maxHeapify(i)
{
    int l = 2*i;
    int r = 2*i+1;
    int largest;
    int swap;
    if (l <= h && A[l] > A[i]) largest = l;
    else largest = i;
    if (r <= h && A[r] > A[largest]) largest = r;
    if (largest != i)
    {
        swap = A[i];
        A[i] = A[largest];
        A[largest] = swap;
        maxHeapify(largest);
    }
}

int heapExtractMax()
{
    if (h < 1) printf("heap underflow\n");
    int max = A[1];
    A[1] = A[h];
    h--;
    maxHeapify(1);
    return max;
}

int main()
{
    while(1)
    {
        scanf("%s", input);
        if(input[2] == 'd') break;
        else if(input[0] == 'i')
        {
            scanf("%d", &num);
            maxHeapInsert(num);
        }
        else
        {
            printf("%d\n", heapExtractMax());
        }
    }
    return 0;
}


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

#define rep(idx, max)	for(int idx = 0, idx##Max = max; idx < idx##Max; idx ++)
#define rrep(idx, min, max)	for(int idx = min, idx##Max = max; idx <= idx##Max; idx ++)
#define MAX_W	32
#define MAX_H	32

typedef std::vector<int>	VEC;

int	g_map[MAX_W * MAX_H];
int	g_step;

typedef struct _POINT
{
	int x, y;
	_POINT() {}
	_POINT(int _x, int _y) : x(_x), y(_y) {}
} POINT;

enum
{
	RED_BLOCK = -1,
	BLACK_BLOCK = 0,
};

void PrintMap()
{
	rep(y, MAX_H)
	{
		rep(x, MAX_W)
		{
			::printf("%2d|", g_map[MAX_W * y + x]);
		}
		::putchar('\n');
	}
	::putchar('\n');
}

void Solve(POINT &pt, int step)
{
	static int dx[] = { +1, 0, -1, 0};
	static int dy[] = { 0, +1, 0, -1};

	//PrintMap();

	g_map[MAX_W * pt.y + pt.x] = step + 1;
	g_step++;

	rep(i, 4)
	{
		POINT ptn(pt.x + dx[i], pt.y + dy[i]);
		if (g_map[MAX_W * ptn.y + ptn.x] == BLACK_BLOCK)
		{
			Solve(ptn, step + 1);
		}
	}
}

int main(int nArgs, char **lplpszArgs)
{
	int	width, height;
	int	map[MAX_W * MAX_H];

	while (std::cin >> width >> height, width)
	{
		POINT start;

		// Init map info
		rep(y, MAX_H)
		{
			rep(x, MAX_W)
			{
				map[MAX_W * y + x] = RED_BLOCK;
			}
		}

		// Input map info
		rrep(y, 1, height)
		{
			char szLine[0x100];
			::scanf("%s", szLine + 1);
			rrep(x, 1, width)
			{
				switch(szLine[x])
				{
				case '.':	map[MAX_W * y + x] = BLACK_BLOCK;	break;
				case '#':	map[MAX_W * y + x] = RED_BLOCK;	break;
				case '@':
					map[MAX_W * y + x] = BLACK_BLOCK; 
					start = POINT(x, y);
					break;
				}
			}
		}
		//::printf("Start: (%d, %d)\n", start.x, start.y);
		g_step = 0;
		::memcpy(g_map, map, sizeof(map));
		::Solve(start, 0);
		std::cout << g_step << std::endl;
	}
}

Measured memory_bytes: 1212
#include<iostream>
using namespace std;
typedef long long ll;

int main(){
    int n; cin >> n;
    ll ar[n];
    ll ans = 0;
    for(int i = 0; i < n; ++i) cin >> ar[i];
    while(1){
        bool jud = 1;
        ll inc = 0;
        ll dec[n] = {0};
        for(int i = 0; i < n; ++i){
            if(ar[i] > n - 1){
                ll tim = ar[i] - (n - 1);
                tim = tim / n + (tim % n > 0);
                ar[i] -= n * tim;
                inc += tim;
                dec[i] = tim;
            }
        }
        ans += inc;
        for(int i = 0; i < n; ++i){
            ar[i] += (inc - dec[i]);
            if(ar[i] > n - 1) jud = 0;
        }
        if(jud) break;
    }
    cout << ans << endl;
    return 0;
}

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

N,K = map(int,readline().split())
A = sorted(list(map(int,readline().split())))
F = sorted(list(map(int,readline().split())),reverse = True)

ok = A[-1] * F[0]
ng = -1

def isOk(x):
  # 時間がxになるためには、A_iをx/F_i以下まで減らす必要がある
  diff = 0
  for i in range(len(A)):
    diff += max(A[i] - x // F[i], 0)
  return diff <= K
  
while (ok - ng)>1:
  mid = (ok + ng) // 2
  if isOk(mid):
    ok = mid
  else:
    ng = mid
print(ok)

Measured memory_bytes: 108492
#include <cstdio>
#include <cstring>

using namespace std;

#define MAX 100000

int main(){
  int n;
  char str[MAX+1];

  scanf("%d" ,&n);
  while(n--){
    bool ok = true;
    scanf("%s" ,str);
    int len = (int)strlen(str);
    for(int i = 1 ; i < len ; i++){
      if(str[i] == str[i-1]){
	ok = false;
	break;
      }
    }
    printf("%s\n" , ok ? "Yes" : "No");
  }

  return 0;
}

Measured memory_bytes: 1108
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main()
{
	int r[MAX], n;
	cin >> n;
	for (int i = 0; i < n; i++) cin >> r[i];
	int maxv = -2000000000;
	int minv = r[0];
	for (int i = 1; i < n; i++)
	{
		maxv = max(maxv, r[i] - minv);
		minv = min(minv, r[i]);
	}
	cout << maxv << endl;
	return 0;

}








Measured memory_bytes: 3888
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <ctype.h>

int main(void) {
    int k, n;

    if(scanf("%d %d", &k, &n) == 1);

    if (k % n == 0) {
        printf("0");
    } else {
        printf("1");
    }
    

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using P = pair<int, int>;

signed main() {

    int n;
    cin >> n;
    vector<int> a(3*n);
    rep(i, 3*n){
        cin >> a[i];
    }
    sort(a.rbegin(), a.rend());

    int ans = 0;
    for(int i=1; i<2*n; i+=2){
        ans += a[i];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
bool cmp(int a, int b)
{
 return a>b;
	
}long long n,a[1001],second,frist,k;
int main()
{
	
	cin>>n>>k;
	for(int i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+1+n,cmp);
	for(int i=1;i<=k;i++){
		frist+=a[i];
	}
	cout<<frist<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
 
using namespace std;
 
typedef long long ll;
 
int main(void)
{
    const int N_MAX = 1000;
    int N, K;
    int a[N_MAX];
    cin >> N >> K;
    REP(i, N) cin >> a[i];
    ll s[N_MAX + 1];
    s[0] = 0;
    REP(i, N) s[i + 1] = s[i] + a[i];
    vector<ll> v;
    REP(i, N) FOR(j, i + 1, N + 1) {
        v.push_back(s[j] - s[i]);
    }
    ll mask = (1L << 61);
    ll result = ((1L << 62) - 1);
    while (true) {
        if (mask == 0) {
            for (ll x: v) {
                if (x != -1) {
                    result &= x;
                }
            }
            break;
        }
        int count = 0;
        for (ll x: v) {
            if (x == -1) {
                continue;
            } else if (x & mask) {
                count++;
            }
        }
        if (count > K) {
            REP(i, v.size()) {
                if (v[i] == -1) {
                    continue;
                } else if ((v[i] & mask) == 0) {
                    v[i] = -1;
                }
            }
        } else if (count == K) {
            REP(i, v.size()) {
                if (v[i] == -1) {
                    continue;
                } else if (v[i] & mask) {
                    result &= v[i];
                }
            }
            break;
        }
        mask >>= 1;
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 6256
import java.math.BigInteger;
import java.util.*;


public class Main{

    static double PI = Math.acos(-1);

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        BigInteger sum = BigInteger.ONE;
        BigInteger out = new BigInteger("1000000000000000000");
        long a[] = new long[n];
        boolean ok = true;
        for (int i = 0;i < n;i ++) {
            a[i] = scanner.nextLong();
        }
        Arrays.sort(a);
        for (int i = 0;i < n;i ++) {
            sum = sum.multiply(new BigInteger(a[i]+""));
            if (sum.compareTo(out) > 0) {
                ok = false;
                break;
            }
        }
        if (ok) println(sum);
        else println("-1");


    }

    static void print(Object a){System.out.print(a);}
    static void println(Object a){System.out.println(a);}
}

Measured memory_bytes: 62320
#include <cstdio>
#include <iostream>
#include <queue>
using namespace std;

struct task{
	char name[11];
	int time;
};
int main()
{
	queue<task> que;
	int n,limit_t;
	scanf("%d%d",&n,&limit_t);
	struct task t;
	for(int i=0;i<n;i++)
	{
		scanf("%s%d",&t.name,&t.time);
		que.push(t);
	}
	
	
	int dispose_t=0;
	while(!que.empty())
	{
		t=que.front();
		if(t.time<=limit_t)
		{
			dispose_t+=t.time;
			printf("%s %d\n",t.name,dispose_t);
			
			que.pop();	
		} else
		{
			dispose_t+=limit_t;
			t.time-=limit_t;
			que.pop();
			que.push(t);
		}
	}
	return 0;
}


Measured memory_bytes: 3744
import sys
lines = []
for line in sys.stdin:
  col = line.strip().split(' ')
  lines.append((int(col[0]), int(col[1])))
min = 1001
for cand in lines[1:]:
  if cand[1] <= lines[0][1] and cand[0] < min:
    min = cand[0]
print(min if min < 1001 else 'TLE')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll n,k;
  cin >> n >> k;
  ll ans=0;
  FOR(i,k,n+2){
    ans=(ans+(i*n+1)-i*(i-1))%MOD;
  }
  cout << (MOD+ans)%MOD << endl;
}

Measured memory_bytes: 3632
#include<cstdio>
#include<vector>
#include<bitset>
#include<cstdlib>
#include<iostream>
#define nc getchar
#define pb push_back
using namespace std;
const int N = 100005;
inline void read(int &x) {
	char b = nc(); x = 0;
	for (; !isdigit(b); b = nc());
	for (; isdigit(b); b = nc()) x = x * 10 + b - '0';
}
int n, m, a[N], tt, p[N], L[N], R[N];
bitset < N > tag;
vector < int > g[N];
inline void ae(int u, int v) {
	g[u].pb(v); g[v].pb(u);
}
bool dfs1(int u, int f) {
	if (tag[u] && (a[u] & 1) != p[u]) return false;
	for (int v, i = 0; i < g[u].size(); ++i) if ((v = g[u][i]) != f) {
		p[v] = p[u] ^ 1; if (!dfs1(v, u)) return false;
	} return true;
}
bool dfs2(int u, int f) {
	if (tag[u]) L[u] = R[u] = a[u];
	else L[u] = -2e8, R[u] = 2e8;
	for (int v, i = 0; i < g[u].size(); ++i) if ((v = g[u][i]) != f) {
		if (!dfs2(v, u)) return false;
		L[u] = max(L[u], L[v] - 1);
		R[u] = min(R[u], R[v] + 1);
	} return L[u] <= R[u];
}
void dfs3(int u, int f) {
	for (int v, i = 0; i < g[u].size(); ++i) if ((v = g[u][i]) != f) {
		a[v] = a[u] + (L[v] < a[u] ? -1 : 1); dfs3(v, u);
	}
}
int main() {
	read(n);
	for (int u, v, i = 1; i < n; ++i)
		read(u), read(v), ae(u, v);
	read(m);
	for (int y, i = 0; i < m; ++i)
		read(tt), read(y), tag[tt] = 1, a[tt] = y;
	p[tt] = a[tt] & 1; 
	if (!dfs1(tt, tt)) return puts("No"), 0;
	if (!dfs2(tt, tt)) return puts("No"), 0; 
	dfs3(tt, tt);
	puts("Yes");
	for (int i = 1; i <= n; ++i) printf("%d\n", a[i]);
	return 0;
}

Measured memory_bytes: 15744
#include<bits/stdc++.h>
using namespace std;
const int maxn=10000;
char ch[maxn];
int len;
int main(){
	scanf("%s",ch+1);
	len=strlen(ch+1);
	for(int i=1;i<=len;i++){
		if(i&1){
			if(ch[i]=='L')puts("No"),exit(0);

		}
		else if(ch[i]=='R'){
			puts("No");
			exit(0);
	    }
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=200100;
int n,k,a[maxn],fv[maxn],Log2[maxn];
int mnv[maxn][20],mxv[maxn][20];
inline int Qmnv(int l,int r){int t=Log2[r-l+1];return min(mnv[l][t],mnv[r-(1<<t)+1][t]);}
inline int Qmxv(int l,int r){int t=Log2[r-l+1];return max(mxv[l][t],mxv[r-(1<<t)+1][t]);}
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++) scanf("%d",a+i);
	for(int i=2;i<=n;i++) Log2[i]=Log2[i>>1]+1;
	for(int i=2;i<=n;i++) fv[i]=fv[i-1]+(a[i-1]>a[i]),mnv[i][0]=mxv[i][0]=a[i];
	for(int j=1;j<20;j++) for(int i=1;i+(1<<j)-1<=n;i++)
	{
		mnv[i][j]=min(mnv[i][j-1],mnv[i+(1<<(j-1))][j-1]);
		mxv[i][j]=max(mxv[i][j-1],mxv[i+(1<<(j-1))][j-1]);
	}
	int ans=0;
	for(int i=k;i<=n;i++) if(fv[i]-fv[i-k+1]==0){ans=1;break;}
	int lstv=0;
	for(int i=k;i<=n;i++) if(fv[i]-fv[i-k+1])
	{
		if(lstv==i-1&&a[i-k]<Qmnv(i-k+1,i-1)&&Qmxv(i-k+1,i-1)<a[i]) ans--;
		lstv=i;ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 37348
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <deque>

using namespace std;
using ll = long long;

int main() {
    int N;
    cin >> N;
    deque<int> pos, neg;
    vector<int> A(N);
    for (int i=0;i<N;++i) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    for (int i=0;i<N;++i){
        if (A[i] > 0) {
            pos.push_back(A[i]);
        } else {
            neg.push_back(A[i]);
        }
    }
    vector<int> ax, ay;
    while (pos.size() + neg.size() > 2) {
        int x, y;
        if (pos.size() == 0) {
            x = neg.back();
            y = neg.front();
            ax.push_back(x);
            ay.push_back(y);
            neg.pop_back();neg.pop_front();
            pos.push_back(x - y);
        }
        if (neg.size() == 0) {
            x = pos.front();
            y = pos.back();
            ax.push_back(x);
            ay.push_back(y);
            pos.pop_back();pos.pop_front();
            neg.push_back(x - y);
        }
        if (pos.size() > 1) {
            x = neg.front();
            y = pos.back();
            ax.push_back(x);
            ay.push_back(y);
            neg.pop_front();
            pos.pop_back();
            neg.push_front(x-y);
        }
        if (neg.size() > 1) {
            x = pos.back();
            y = neg.front();
            ax.push_back(x);
            ay.push_back(y);
            neg.pop_front();
            pos.pop_back();
            pos.push_back(x-y);
        }
    }
    int M = 0;
    if (N == 2) {
        M = A[1] - A[0];
        ax.push_back(A[1]);
        ay.push_back(A[0]);
    } else {
        ax.push_back(pos.back());
        ay.push_back(neg.front());
        M = pos.back() - neg.front();
    }
    
    cout << M << endl;
    for (int i=0; i<ax.size(); ++i) {
        cout << ax[i] << " " << ay[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define inf LLONG_MAX
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n; cin >> n;
    ll s = 0;
    for (int i = 1; i <= n; i++) {
        if (i % 3 != 0 && i % 5 != 0) s += i;
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    string s; cin>>s;
    int len=s.size();
    int ans=0;
    char c=s[0];
    rep(i,len){
        if(s[i]!=c){
            ans++;
            if(c=='W')c='B';
            else c='W';
        }
        }
        cout<<ans<<endl;
    }


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <cstring> 
using namespace std;
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define int long long int
#define mpp make_pair
#define F first
#define mem(a,b) memset(a,b,sizeof(a))
#define F first
#define S second
#define MOD 100000007
#define in_range(x, y, r, c) (x < r && y < c && x >= 0 && y >= 0)
const int MAXN = 1e5+5;
#define MAXI 2e18+3
#define all(v) v.begin(), v.end()
#define endl "\n"
# define PI 3.14159265358979323846



signed main(){
 
    fast;
    
    #ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    
    int a, b, c, k;
    cin>>a>>b>>c>>k;
    if(k<=a){
    	cout<<k<<endl;
    }
    else if(k<=a+b){
    	cout<<a<<endl;
    }
    else{
    	cout<<a-(k-a-b)<<endl;
    }
}

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

int dp[1002][1002][16];

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

int main() {
	int H, W; cin >> H >> W;
	for (int i = 0; i < 1002; ++i)for (int j = 0; j < 1002; ++j)for (int k = 0; k < 16; ++k){
		dp[i][j][k] = 1e9;
	}
	dp[1][1][0] = 0;
	vector<vector<int>>field(H + 3, vector<int>(W + 3));
	for (int i = 0; i < H; ++i) {
		string st; cin >> st;
		for (int j = 0; j < W; ++j) {
			if (st[j] != '.') {
				field[i + 1][j + 1] = st[j] - '0';
			}
		}
	}
	for (int nowy = 1; nowy < H + 1; ++nowy) {
		for (int nowx = 1; nowx < W +1; ++nowx) {
			for (int n = 0; n < 16; ++n) {
				const int eat_ld = n & 1;
				const int eat_d = (n & 2) >> 1;
				const int eat_r = (n & 4) >> 2;
				const int eat_ru = (n & 8) >> 3;
				if (1e9 <= dp[nowy][nowx][n])continue;
				vector<vector<char>>eats(4, vector<char>(4));
				eats[2][0] = eat_ld;
				eats[2][1] = eat_d;
				eats[1][2] = eat_r;
				eats[0][2] = eat_ru;
				eats[1][1] = true;
				for (int way = 0; way < 2; ++way) {
					const int  nextx = nowx + dx[way];
					const int nexty = nowy + dy[way];
					const int ax = 1 + dx[way];
					const int ay = 1 + dy[way];
					for (int w = 0; w < 4; ++w) {
						int nexteat_ld = eats[2 + dy[way]][0 + dx[way]];
						int nexteat_d = eats[2 + dy[way]][1 + dx[way]];
						int nexteat_r = eats[1 + dy[way]][2 + dx[way]];
						int nexteat_ru = eats[0 + dy[way]][2 + dx[way]];
						int eat_sum = 0;
						if (!eats[ay][ax]) {
							if (ay == 2 + dy[way] && ax == 0 + dx[way])nexteat_ld = true;
							if (ay == 2 + dy[way] && ax == 1 + dx[way])nexteat_d = true;
							if (ay == 1 + dy[way] && ax == 2 + dx[way])nexteat_r = true;
							if (ay == 0 + dy[way] && ax == 2 + dx[way])nexteat_ru = true;
							eat_sum += field[nexty][nextx];
						}
						for (int v = 0; v < 4; ++v) {
							if (v == w)continue;
							else {
								if (!eats[ay + dy[v]][ax + dx[v]]) {
									if (ay + dy[v]== 2 + dy[way] && ax + dx[v] == 0 + dx[way])nexteat_ld = true;
									if (ay + dy[v]== 2 + dy[way] && ax + dx[v] == 1 + dx[way])nexteat_d = true;
									if (ay + dy[v]== 1 + dy[way] && ax + dx[v] == 2 + dx[way])nexteat_r = true;
									if (ay + dy[v]== 0 + dy[way] && ax + dx[v] == 2 + dx[way])nexteat_ru = true;
									eat_sum += field[nexty + dy[v]][nextx + dx[v]];
								}
							}
						}
						int n = dp[nowy][nowx][eat_ld+2*eat_d+4*eat_r+8*eat_ru] + eat_sum;
						dp[nexty][nextx][nexteat_ld+2*nexteat_d+4*nexteat_r+8*nexteat_ru] = min(dp[nexty][nextx][nexteat_ld + 2 * nexteat_d + 4 * nexteat_r + 8 * nexteat_ru], n);
					}
				}
			}
		}
	}
	int ans = 1e9;
	for (int l = 0; l < 16; ++l) {
		ans = min(ans, dp[H][W][l]);	
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 69608
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mt make_tuple
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<string,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e9;
const ll INF=2e18;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int n;
vi used;
bool H=false;
vvi G;
int dfs(int a){
	used[a]=true;
//	int t=0;
	vi t;
	rep(i,G[a].size())if(used[G[a][i]]==0)
		t.pb(dfs(G[a][i]));
	
	int co=0;
	rep(i,t.size())if(t[i]%2)co++;
	if(co>=2){
		H=true;
		return 0;
	}else if(co==1)return 0;
	else return 1;
}
int main(){
	cin>>n;
	G=vvi(n);
	rep(i,n-1){
		int a,b;
		cin>>a>>b;
		a--;b--;
		G[a].pb(b);
		G[b].pb(a);
	}
	vi co(n);
	rep(i,n)if(G[i].size()==1)co[G[i][0]]++;
	bool h=false;
	rep(i,n)if(co[i]>1)h=true;
	rep(i,n)if(co[i]==0){
		int c=0;
		rep(j,G[i].size())if(co[G[i][j]])c++;
		if(c>1&&c==G[i].size())h=true;
	}
	if(h)cout<<"First"<<endl;
	else{
		rep(i,n)if(G[i].size()>1&&co[i]==0){
			used=vi(n);
			int t=dfs(i);
			if(t)H=true;
			break;
		}
		if(H)cout<<"First"<<endl;
		else cout<<"Second"<<endl;
//		assert(0);//cout<<"Second"<<endl;
	}
}
/*/
int main(){
	int n,m,k;
	cin>>n>>m>>k;
	vs in(n);
	rep(i,n)cin>>in[i];
	int sx,sy;
	rep(i,n)rep(j,m)if(in[i][j]=='S'){
		sx=i,sy=j;
		in[i][j]='.';
	}
	int dp[
}
//*/






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

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int K,N;cin>>K>>N;
    vector<int> A(N+N);
    for(int i=0;i<N;i++){
        cin>>A[i];
        A[N+i]=A[i]+K;
    }
    
    int ans=0;
    
    for(int i=1;i<N+N;i++) ans=max(ans,A[i]-A[i-1]);
    
    cout<<K-ans<<endl;
}


Measured memory_bytes: 1792
#include <stdio.h>

void swap(int *x, int *y){
    int temp = *x;
    *x = *y;
    *y = temp;
}

int main(void)
{

    int n, i, j, h = 0;

    int a[1000][3];

    scanf("%d", &n);

    for(i = 0; i < n; i++)
        scanf("%d %d %d", &a[i][0], &a[i][1], &a[i][2]);

    for(i = 0; i < n; i++) {
        if(a[i][0] > a[i][1]) swap(&a[i][0], &a[i][1]);
        if(a[i][0] > a[i][2]) swap(&a[i][0], &a[i][2]);
        if(a[i][1] > a[i][2]) swap(&a[i][1], &a[i][2]);
    }

    for(i = 0; i < n; i++) {
        for(j = 0; j < n; j++) {
            if(i != j) {
                if(a[i][0] == a[j][0] && a[i][1] == a[j][1] && a[i][2] == a[j][2]) {
                    if(a[i][0] == 0)
                        h--;
                    h++;
                    a[j][0] = 0;
                    a[j][1] = 0;
                    a[j][2] = 0;
                }
            }
        }
    }

    printf("%d\n", h);

    return 0;
}
    

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

/////////////////////////////////////////////////////////

void Main(){
  int N; cin >> N;
  cout << N * N * N << endl;
}

/////////////////////////////////////////////////////////

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  //cout << std::fixed << std::setprecision(15);

  Main();
}


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

vector<int> hi(100000);
vector<int> cost(100000);

void cost_fn(int n)
{
	// if(n == 0) return 0;
	// if(n == 1) return abs(hi[1]-hi[0]);

	// int onestep = abs(hi[n]-hi[n-1]) + cost_fn(n-1);
	// int twostep = abs(hi[n]-hi[n-2]) + cost_fn(n-2);

	// return min(onestep, twostep);

	cost[1] = abs(hi[1]-hi[0]);

	for(int i = 2; i <= n; i++)
	{
		int onestep = abs(hi[i]-hi[i-1]) + cost[i-1];
		int twostep = abs(hi[i]-hi[i-2]) + cost[i-2];
		cost[i] = min(onestep, twostep);
	}

	cout << cost[n] << endl;
}

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

	for(int i = 0; i < n; i++)
		cin >> hi[i];
	cost_fn(n-1);
	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
    int main() {
    int a[100001]={};
    int n,t,ans;
    scanf("%d", &n);
    ans=n;
    for (int i = 0; i < n; i++)
    {
    scanf("%d", &t);
    if(t <= n)
    {
    a[t]++;
    if(a[t] == t)
    {
    ans -= t;
    }
    }
    }
    printf("%d", ans);
    return 0;
    }

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

int main(){
    string a,b;
    int n,c=0,d=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a>>b;
        if(a>b)c+=3;
        else if(a<b)d+=3;
        else{
            c++;
            d++;
        }
    }
    cout<<c<<' '<<d<<endl;
    return 0;
}


Measured memory_bytes: 3104
//Dragon_warrior7(IITK)
#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 pb emplace_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 1000000000000000000
#define pll pair<ll, ll> 
#define vll vector<ll> 
#define rub cout << "\n------------------------------------\n"
#define deb(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) 
{
	cout << *it << " = " << a;
	nl;
	err(++it, args...);
}
typedef  tree < int ,  null_type ,  greater<int> ,  rb_tree_tag ,  tree_order_statistics_node_update > oset;
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
		cin >> v[i];
}
const int mod=1e9+7;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
ll binpow(ll a, ll b, ll m) 
{a %= m;b%=(m-1);ll res = 1;while (b > 0) {if (b & 1)res = res * a % m;a = a * a % m;b >>= 1; }return res;}
void print(vector<ll> v)
{
	for (int i = 0; i < v.size(); i++)
		cout << v[i] << " ";
}
ll n,m,a,b,c,temp,x,y;
string str;
void solveforthiscase(const int & test)
{//deb(test);
cin>>n;
string s[n];
map<string,ll> count;
ll mx=0;
for(int i=0;i<n;i++)
{
   cin>>s[i];
   count[s[i]]++;
   mx=max(mx,count[s[i]]);
}
set<string> ans;
for(int i=0;i<n;i++)
{
    if(count[s[i]]==mx)
    ans.insert(s[i]);
}
for(auto x:ans)
{
    cout<<x<<'\n';
}







return ;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
// 	cin>>test;
    for(int i=1;i<=test;i++)
    {
        solveforthiscase(i);
    }
}

Measured memory_bytes: 34816
# https://note.nkmk.me/python-union-find/
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# print('input >>')
N, M, K = map(int,(input().split()))
friend_numbers = [0] * N
block_numbers = [0] * N # ただし同じUnionFind木内のみ
unionFind = UnionFind(N)
for _ in range(M):
    friend = list(map(int,(input().split())))
    i = friend[0]-1
    j = friend[1]-1
    unionFind.union(i, j)
    friend_numbers[i] += 1
    friend_numbers[j] += 1
for _ in range(K):
    block = list(map(int,(input().split())))
    i = block[0]-1
    j = block[1]-1
    if unionFind.same(i, j):
        block_numbers[i] += 1
        block_numbers[j] += 1

# print(friend_numbers)
# print(block_numbers)
# print(unionFind)

for i in range(N):
    print(unionFind.size(i) - friend_numbers[i] - block_numbers[i] - 1, end=' ')    

# print('-----output-----')

Measured memory_bytes: 9500
k = int(input())
if k % 2 == 0 & k % 5 == 0:
    print(-1)
    exit()

x = 7 % k
s = set()
i = 1
ans = -1
while x not in s:
    if x == 0:
        ans = i
        break
    s.add(x)
    x = (10 * x + 7) % k
    i += 1
    
print(ans)

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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

const int N = 100000;
int n;
vector<int> graph[N*2+1];
int seen[N*2+1];

void dfs(int cur, int& l, int& r) {
    seen[cur] = true;
    if(cur <= N) l++;
    else r++;
    for(auto child : graph[cur]) {
        if(!seen[child]) {
            dfs(child, l, r);
        }
    }
}

int32_t main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n;
    for(int i = 0; i < n; ++i) {
        int x, y; cin >> x >> y;
        graph[x].push_back(y+N);
        graph[y+N].push_back(x);
    }

    int ans = 0;
    for(int i = 1; i <= N; ++i) {
        if(!seen[i]) {
            int l = 0, r = 0;
            dfs(i, l, r);
            ans += l*r;
        }
    }
    ans -= n;

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


Measured memory_bytes: 12672