akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    int N; cin >> N;
    LLONG t = 1, a = 1;
    // ti : ai を満たすなるべく小さな値に更新していく : O(N)
    for (int i = 0; i < N; ++i)
    {
        LLONG ti, ai; cin >> ti >> ai;    // ti:ai 互いに素
        // これまでの t, a を超えるような比を計算し，大きい側の比に合わせる
        LLONG tr = t % ti == 0 ? t / ti : t / ti + 1;
        LLONG ar = a % ai == 0 ? a / ai : a / ai + 1;
        LLONG r = max(tr, ar);
        t = r * ti;
        a = r * ai;
    }
    cout << t + a << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template<typename T1, typename T2> istream& operator>>(istream& is, pair<T1, T2>& a){ return is >> a.first >> a.second; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, pair<T1, T2>& a){ return os << a.first << " "<<a.second; }
template<typename T> istream& operator>>(istream& is, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) is >> vc[i]; return is; }
template<typename T> ostream& operator<<(ostream& os, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) os << vc[i] << endl; return os; }

main()
{
  for(int n; cin >> n, n; ) {
    vector< int > h(n + 1);
    int ret;

    cin >> h;
    for(int i = 0; i < h.size(); i++) {
      vector< int > buffer;
      set< int > del;
      for(int j = 0; j < h.size(); j++) {
        if(i != j) buffer.push_back(h[j]);
      }
      for(int j = 1; j < buffer.size(); j++) {
        del.insert(buffer[j] - buffer[j - 1]);
      }
      if(del.size() == 1) ret = i;
    }
    cout << h[ret] << endl;
  }
}

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

int main(){
	int N; cin >> N;
	
	vector<int> A(N);
	vector<int> B(N);
	vector<int> C(N - 1);

	for(int i = 0; i < N; i++){
		int a; cin >> a;
		A[i] = a - 1;
	}
	for(int i = 0; i < N; i++){
		cin >> B[i];
	}
	for(int i = 0; i < N - 1; i++){
		cin >> C[i];
	}

	int ans = 0;
	for(int i = 0; i < N; i++){
		int cooking = A[i];
		ans += B[cooking];
		
		if(i != N - 1){
			int nextCooking = A[i + 1];
			
			if(cooking + 1 == nextCooking){
				ans += C[cooking];
			}
		}
	}

	std::cout << ans;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))



n,k = LI()
dp = [0]*(k+1)
ans = 0
for i in range(1,k+1)[::-1]:
    tmp = pow(k//i,n,mod)
    for j in range(2*i,k+1,i):
        tmp -= dp[j]
    dp[i] = tmp
    ans += tmp*i
    ans %= mod
print(ans)


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

using namespace std;
typedef long long ll;

ll a, b, c, x, y;

ll res = 1000000000000000005;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> a >> b >> c >> x >> y;
	res = min(res, a*x+b*y);
	if (x >= y) res = min(res, 2*y*c+(x-y)*a);
	else res = min(res, 2*x*c+(y-x)*b);
	if (x >= y) res = min(res, 2*x*c);
	else res = min(res, 2*y*c);
	cout << res << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (long i=0;i<(n);i++)
#define FOR(i,a,b) for (long i=(a);i<(b);i++)
#define RREP(i,n) for(long i=n;i>=0;i--)
#define RFOR(i,a,b) for(long i=(a);i>(b);i--)
#define dump1d_arr(array) REP(i,array.size()) cerr << #array << "[" << (i) << "] ==> " << (array[i]) << endl;
#define dump2d_arr(array) REP(i,array.size()) REP(j,array[i].size()) cerr << #array << "[" << (i) << "]" << "[" << (j) << "] ==> " << (array[i][j]) << endl;
#define dump(x)  cerr << #x << " => " << (x) << endl;
#define CLR(vec) { REP(i,vec.size()) vec[i] = 0; } 
#define llINF (long long) 9223372036854775807
#define loINF (long) 2147483647
#define shINF (short) 32767
#define SORT(c) sort((c).begin(),(c).end())
#define MIN(vec) *min_element(vec.begin(), vec.end());
#define MAX(vec) *max_element(vec.begin(), vec.end());
#define UNIQ(vec) vec.erase(unique(vec.begin(), vec.end()),vec.end());
#define IN(n,m)  (!(m.find(n) == m.end()))
#define TO_INT(vec,s) REP(i,s.length()){vec.push_back(s[i] - ‘0’);}
#define ENUM_v(vec) for (auto e : vec)
#define dump_MAP(m) for(auto itr = m.begin(); itr != m.end(); ++itr) { cerr << itr->first << " --> "  << itr->second << endl; }
#define FINDL(vec,x) (lower_bound(vec.begin(),vec.end(),x) - vec.begin())
#define FINDU(vec,x) (upper_bound(vec.begin(),vec.end(),x) - vec.begin())
#define ROUND(N) setprecision(N)

using namespace std;
typedef long long LL;
typedef vector<LL> VI;
typedef vector<VI> VVI;
typedef pair<long long,long long> pr;
typedef vector<pr> VP;
struct Order {
	bool operator() (pr const& a,pr const& b) const {
		return a.first < b.first;
	}
};


int main(void) {
	long N;
	LL C,x,v;
	cin >> N >> C;	
	VP xv(N);
	VI acc(N),accr(N);
	VI acc2(N),accr2(N);
	REP(i,N) {
		cin >> x >> v;
		xv[i] = pr(x,v);
	}
	sort(xv.begin(),xv.end(),Order());

	acc[0] = xv[0].second - xv[0].first;
	accr[0] = xv[N-1].second - (C - xv[N-1].first);
	FOR(i,1,N) {
		acc[i] = acc[i-1] + (xv[i].second - (xv[i].first-xv[i-1].first));
		accr[i] = accr[i-1] + (xv[N-i-1].second + (xv[N-i-1].first-xv[N-i].first));
	}
	acc2 = acc;
	accr2 = accr;

	FOR(i,1,N) {
		acc[i] = max(acc[i-1],acc[i]);
		accr[i] = max(accr[i-1],accr[i]);
	}

	//dump1d_arr(acc);
	//dump1d_arr(accr);
	long long ans = max(accr[N-1],acc[N-1]);
	long long sumv;
	REP(i,N-1) {
		sumv = max(acc2[i] + accr[N-i-2] - xv[i].first,acc2[i]);
		if (sumv > ans) ans = sumv;
		sumv = max(accr2[i] + acc[N-i-2] - (C - xv[N-i-1].first),accr2[i]);
		if (sumv > ans) ans = sumv;
	}
	if (ans < 0) ans = 0;
	cout << ans << endl;
}

Measured memory_bytes: 4992
import sys
readlines = sys.stdin.readlines
write = sys.stdout.write
def solve():
    mp = {}
    for line in readlines():
        v = int(line)
        mp[v] = mp.get(v, 0) + 1
    ma = max(mp.values())
    ans = [k for k, v in mp.items() if v == ma]
    ans.sort()
    write("\n".join(map(str, ans)))
    write("\n")
solve()



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

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

    int n=false;
    int s=false;
    int e=false;
    int w=false;
    
    for (char c : S)
    {
        if (c == 'N') n = true;
        if (c == 'S') s = true;
        if (c == 'E') e = true;
        if (c == 'W') w = true;
    }

    if (n ^ s or e ^ w)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n, m;
  cin >> n >> m;
  vector<ll> a(n);
  vector<ll> b(n);
  vector<ll> c(m);
  vector<ll> d(m);
  rep(i, 0, n)
    cin >> a[i] >> b[i];
  rep(i, 0, m)
    cin >> c[i] >> d[i];
  
  rep(i, 0, n) {
    ll ans = 0;
    ll mini = 1000000000;
    rep(j, 0, m) {
      ll dist = abs(a[i]-c[j]) + abs(b[i]-d[j]);
      if(mini > dist) {
        ans = j+1;
        mini = dist;
      }
    }
    cout << ans << "\n";
  }
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a.at(i);
  sort(a.rbegin(), a.rend());

  ll ans = 0;
  for (int i = 1; i < n; i++) {
    ans += a.at(i / 2);
  }

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

Measured memory_bytes: 4032
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
#include<iomanip>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()

using namespace std;

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

/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*/
int main() {
	int A,B; cin >> A>>B;
	string S; cin >> S;
	bool ok = true;
		for (int i = 0;i < A+B;i++) {
			if (i != A) {
				if ('0' > S[i] || S[i] > '9') {
					ok = false;
				}
			}
		}
		if (S[A] != '-') ok = false;
		if (ok) cout << "Yes" << endl;
		else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
using namespace std;
const int INF=2<<20;
typedef long long int llf;
int main() {
	// your code goes here
	
	int num[5];
	while(cin >> num[0] && num[0] != 0){
	for(int i=1;i<5;i++)
	cin >> num[i];
	int taked[4]={};
	for(int i=0;i<5;i++)
	taked[num[i]%3]=1;
	for(int i=0;i<5;i++)
	if(taked[(num[i]+1)%3])
		if(taked[(num[i]+2)%3])
			cout <<3<<endl;
		else
			cout <<1<< endl;
	else
		if(taked[(num[i]+2)%3])
			cout <<2<<endl;
		else
			cout <<3<< endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#include<functional>
//#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define rep(i, x) for(ll i = 0; i < x; i++)
#define rep2(i, x) for(ll i = 1; i <= x; i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
const ld pi = 3.141592653589793238;

/*bool IsPrime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) { // 素数ではない
			return false;
		}
	}
	// 素数である
	return true;
}*/
/*ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}*/
/*ll keta(ll n) {
	ll res = 0;
	while (n >= 1) {
		res += n % 10; n /= 10;
	}
	return res;
}*/
/*ll modpow(ll x, ll y, ll mod) {
	ll res = 1;
	while (y) {
		if (y % 2) { res *= x; res %= mod; }
		x = x * x % mod; y /= 2;
	}
	return res;
}*/
/*ll nCk(ll n, ll k) {
	ll a = 1, b = 1;
	for (int h = n - k + 1; h <= n; h++) { a *= h; a %= mod; }
	for (int h = 1; h <= k; h++) { b *= h; b %= mod; }
	return a * modpow(b, mod - 2) % mod;
}*/
//printf("%.10f\n", n);

ll test[123456];
signed main() {
	string s, t;
	ll n, m, k, a, b, c, cnt = 0, ans = 0;
	cin >> n >> m >> k;
	if (n <= m * k) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }

	return 0;
}

Measured memory_bytes: 3620
use strict;
my $x = <>;
if(399<$x&&$x<600){
print "8";}
elsif(599<$x&&$x<800){
print "7";}
elsif(799<$x&&$x<1000){
print "6";}
elsif(999<$x&&$x<1200){
print"5";}
elsif(1199<$x&&$x<1400){
print"4";}
elsif(1399<$x&&$x<1600){
print"3";}
elsif(1599<$x&&$x<1800){
print"2";}
elsif(1799<$x&&$x<2000){
print"1";}

Measured memory_bytes: 4924
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
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 (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
ll n;
int main(){
  cin >> n;
  vector<ll> vec(n),vec_sorted(n),move(10000,0);
  ll minnum = INFLONG;
  rep(i,n){
    cin >> vec[i];
    chmin(minnum,vec[i]);
  }
  vec_sorted = vec;
  sort(all(vec_sorted));
  rep(i,n){
    move[vec_sorted[i]] = i;
  }

  ll ans = 0;
  vector<ll> rem;
  rep(i,n){
    if(i != move[vec[i]]){
      //cout << i << endl;
      ll piv = i;
      ll sum = 0;
      ll cou = 0;
      ll mini = INFLONG;
      while(piv != move[vec[piv]]){
        chmin(mini,vec[piv]);
        //cout << piv << endl;
        sum += vec[piv];
        cou++;
        ll tmp = piv;
        piv = move[vec[piv]];
        move[vec[tmp]] = tmp;
      }
      ll t1 = 0;
      //cout << mini << " " << sum << endl;
      t1 = (cou-2) *  mini + sum;
      //chmin(t1,(cou-2) * minnum + sum + (mini + minnum) * 2);
      chmin(t1,mini + sum + (cou+1) * minnum);
      ans += t1;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3268
#include <stdio.h>
int main()
{
    double ans;
    double h, w, x ,y;
    int j=0;
    scanf("%lf%lf%lf%lf", &w, &h, &x, &y);
    ans=(w*h)/2.0;
    if(x+x==w && y+y==h) j=1;
    printf("%.9f %d\n", ans, j);
    return 0;
}


Measured memory_bytes: 128
n=int(input())
s=input()

def sheep(a,b):
    l=[0]*(n+1)
    l[0]=a
    l[1]=b
    m=[]
    for i in range(1,n):
        if s[i]=="o":
            if l[i]==0:
                l[i+1]=l[i-1]
            else:
                l[i+1]=(l[i-1]+1)%2
        else:
            if l[i]==0:
                l[i+1]=(l[i-1]+1)%2
            else:
                l[i+1]=l[i-1]
    x=0
    if s[0]=="o":
        if l[0]==0:
            x=l[1]
        else:
            x=(l[1]+1)%2
    else:
        if l[0]==0:
            x=(l[1]+1)%2
        else:
            x=l[1]
    if l[n]==l[0] and x==l[n-1]:
        for i in range(n):
            if l[i]==0:
                m.append("S")
            else:
                m.append("W")
        print("".join(m))
        exit()

sheep(0,0)
sheep(0,1)
sheep(1,0)
sheep(1,1)
print("-1")

Measured memory_bytes: 10880
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <map>
#include<stack>
#define INF 100000000
#define rep(i,a) for(int i=0;i<(a);i++)

using namespace std;
typedef long long ll;


int main(){
    stack<int> box;
    int n;
    while(cin>>n){
        if(n==0){
            cout<<box.top()<<endl;
            box.pop();
        }
        else{
            box.push(n);
        }
    }
    return 0;
}

Measured memory_bytes: 1200
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect
from fractions import gcd

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

N, X = reads()
xs = reads()
ans = abs(reduce(lambda x, y: gcd(x, y), [y-X for y in xs], 0))
print(ans)


Measured memory_bytes: 88736
import heapq


class PriorityQueue:
    def __init__(self):
        self.__heap = []
        self.__count = 0

    def empty(self) -> bool:
        return self.__count == 0

    def dequeue(self):
        if self.empty():
            raise Exception('empty')
        self.__count -= 1
        return heapq.heappop(self.__heap)

    def enqueue(self, v):
        self.__count += 1
        heapq.heappush(self.__heap, v)

    def __len__(self):
        return self.__count


def cake123(X: int, Y: int, Z: int, K: int, A: list, B: list, C: list)->list:
    ret = [0] * K

    sA = sorted(-a for a in A)
    sB = sorted(-b for b in B)
    sC = sorted(-c for c in C)

    q = PriorityQueue()
    q.enqueue((sA[0] + sB[0] + sC[0], 0, 0, 0))

    used = {}

    k = 0
    while k < K:
        delicious, ai, bi, ci = q.dequeue()
        if -delicious in used and (ai, bi, ci) in used[-delicious]:
            continue

        used.setdefault(-delicious, set())
        used[-delicious].add((ai, bi, ci))

        ret[k] = -delicious
        k += 1

        if ai+1 < X:
            q.enqueue((sA[ai+1] + sB[bi] + sC[ci], ai+1, bi, ci))
        if bi+1 < Y:
            q.enqueue((sA[ai] + sB[bi+1] + sC[ci], ai, bi+1, ci))
        if ci+1 < Z:
            q.enqueue((sA[ai] + sB[bi] + sC[ci+1], ai, bi, ci+1))
        if ai+1 < X and bi+1 < Y:
            q.enqueue((sA[ai+1] + sB[bi+1] + sC[ci], ai+1, bi+1, ci))
        if ai+1 < X and ci+1 < Z:
            q.enqueue((sA[ai+1] + sB[bi] + sC[ci+1], ai+1, bi, ci+1))
        if bi+1 < Y and ci+1 < Z:
            q.enqueue((sA[ai] + sB[bi+1] + sC[ci+1], ai, bi+1, ci+1))
        if ai+1 < X and bi+1 < Y and ci+1 < Z:
            q.enqueue((sA[ai+1] + sB[bi+1] + sC[ci+1], ai+1, bi+1, ci+1))

    return ret


if __name__ == "__main__":
    X, Y, Z, K = map(int, input().split())
    A = [int(s) for s in input().split()]
    B = [int(s) for s in input().split()]
    C = [int(s) for s in input().split()]
    ans = cake123(X, Y, Z, K, A, B, C)
    for a in ans:
        print(a)


Measured memory_bytes: 6744
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF=1e18;

vector<int> cost(1000000);
vector<vector<int>> data(1000000);


int main(){
    int n, i = 0;
    cin >> n;
    int a = n % 1000;
    if (a == 0) cout << 0 << endl;
    else cout << 1000 - a << endl;
}

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

string s, t;
vector<int> pos[26];
int ptr[26], numS;

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

    for (int i = 0; i < s.length(); i++) {
        pos[s[i] - 'a'].push_back(i);
    }

    numS = 0;
    int lastIndex = -1;
    LL answer;
    for (int i = 0; i < t.length(); i++) {
        int charIndex = (t[i] - 'a');

        if (pos[charIndex].size() == 0) {
            cout << "-1\n";
            return 0;
        }

        int p = lower_bound(pos[charIndex].begin(), pos[charIndex].end(), lastIndex + 1) - pos[charIndex].begin();
        if (p == pos[charIndex].size()) {
            numS += 1;
            lastIndex = pos[charIndex][0];
        } else {
            lastIndex = pos[charIndex][p];
        }

        answer = (LL) numS * (LL) s.length() + lastIndex + 1;
    }

    cout << answer << endl;
}


Measured memory_bytes: 1216
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt(), B = sc.nextInt(), C = sc.nextInt(), D = sc.nextInt();
		sc.close();
		if (B > D) {
			B = D;
		}
		if (A > C) {
			C = A;
		}
		if (B - C > 0) {
			System.out.println(B - C);
		} else {
			System.out.println(0);
		}
	}
}


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

#define rep(i,n) for(int i=0; i<n ; ++i)
#define REP(i,a,b) for(int i=a; i<b; ++i)
#define all(v) (v).begin() , (v).end()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using pii = pair<int , int>;
using pll = pair<long long , long long>;

//プロトタイプ宣言
void faster(void);
template <class T>
T gcd(T , T);
template <class T>
T get_digent(T);
template <class T>
T POW(T , T);


int main(){
  faster();
  int n;
  cin >> n;
  string s;
  map<string , int> mp;
  rep(i,n){
    cin >> s;
    mp[s]++;
  }
  int _max=0;
  for(auto itr=mp.begin();itr!=mp.end();itr++){
    _max = max(_max , itr->second);
  }
  for(auto itr=mp.begin();itr!=mp.end();itr++){
    if(_max == itr->second) cout << itr->first << endl;
  }
}


























//同期解除
void faster(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

//ユークリッドの互除法
template <class T>
T gcd(T a, T b) {
  return (b ? gcd(b, a%b) : a);
} 

//桁数取得
template <class T>
T get_digent(auto x){
  string s;
  s = to_string(x);
  ll digent = s.size();
  return digent;
} 

//べき乗計算
template <class T>
T POW(T x, T y){
  if(y==0) return 1;
  if(y%2 == 1){
    ll temp = POW(x,y-1);
    return (temp*x);
  }
  else{
    ll temp = POW(x,y/2);
    return temp*temp;
  }
} 



Measured memory_bytes: 23808
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    while(sc.hasNext()) {
      int a = sc.nextInt();
      int b = sc.nextInt();
      String c = String.valueOf(a + b);
      System.out.println(c.length()); 
    }  
  }
}

Measured memory_bytes: 26324
N,M = map(int,input().split())
XY = [list(map(int,input().split())) for _ in [0]*M]
R = [False]*N
R[0] = True
B = [1]*N
for x,y in XY:
    x-=1;y-=1
    B[y] += 1
    B[x] -= 1
    R[y] = R[y] or R[x]
    R[x] = R[x] and B[x]>0
print(sum(R))

Measured memory_bytes: 28948
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007
int main(){
	fast;
	string s;
	cin>>s;
	ll len=s.length();
	ll rock_count=0,paper_count=0,ans=0;
	for(int i=0;i<len;i++)
	{
		if(s[i]=='g')
		{
			if(paper_count<rock_count)
				ans++,paper_count++;
			else
				rock_count++;
		}
		else
		{
			if(paper_count<rock_count)
				paper_count++;
			else
				ans--,rock_count++;
		}
	}
	cout<<ans;
	return 0;
}



Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
string s;
set<char> a;
cin >> s;
for(ll i = 0; i < 3; i++){
    a.insert(s[i]);
}
cout << (a.size() == 1 ? "No" : "Yes") << endl;
}

Measured memory_bytes: 256
import sys

def max_heapify(A, H, i):
  target = A[i]

  m = i
  l = i * 2
  while l <= H:
    largest = target
    if A[l] > target:
      m = l
      largest = A[m]

    r = l + 1
    if r <= H and A[r] > largest:
      m = r
      largest = A[m]

    if m != i:
      A[i] = largest
      i = m
      l = i * 2
    else:
      break

  A[m] = target

def build_max_heap(A, i):
  if i < 2: return
  last = A[i]
  p = i // 2
  while p > 0 and A[p] < last:
    A[i] = A[p]
    i = p
    p = i // 2
  A[i] = last

A = [0]

for line in sys.stdin.readlines():
  if line[0] == 'i':
    A.append(int(line[7:]))
    build_max_heap(A, len(A) - 1)
  elif line[1] == 'x':
    if len(A) <= 1:
      pass
    elif len(A) <= 2:
      print(A.pop())
    else:
      print(A[1])
      A[1] = A.pop()
      max_heapify(A, len(A) -1, 1)
  else:
    exit()

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

char c[128];

void change(){
  c['('] = ')';
  c[')'] = '(';
  c['i'] = 'i';
  c['w'] = 'w';
  c[' '] = ' ';
}

int main(){
  string str;
  int cnt = 0;

  change();
  cin >> str;

  if(str.size()%2==1)
    if(str[str.size()/2] != 'w' && str[str.size()/2] != 'i') 
      cnt++;

  for(int i = 0 ; i < str.size()/2 ; i++){
     if(str[i] != c[str[str.size()-i-1]]) cnt++;
  }

  cout << cnt << endl;

  return 0;
}

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

using namespace std;

const int maxn = 100002;

int a[maxn];

int main() {
    int n;
    while (cin >> n) {
        int a4 = 0, a2 = 0, a1 = 0;
        for (int i = 0; i < n; i++) {
            cin >> a[i];
            if (a[i] % 4 == 0) {
                a4++;
            } else if (a[i] % 2 == 0) {
                a2++;
            } else {
                a1++;
            }
        }
        if (a4 >= a1) {
            cout << "Yes" << endl;
        } else if (a4 + 1 == a1 && a2 == 0) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
long long n,k,ans,a[200005],b[200005],c[200005],bit[200005];
void upd(long long x){for(;x<200005;x+=(x&(-x)))bit[x]++;}
long long qry(long long x){long long res=0;for(;x;x-=(x&(-x)))res+=bit[x];return res;}
int main()
{
	cin>>n>>k;
	b[0]=c[0]=0;
	for(long long i=0;i<n;i++)cin>>a[i];
	for(long long i=0;i<n;i++)b[i+1]=b[i]+a[i]-k;
	for(long long i=0;i<n;i++)c[i+1]=b[i+1];
	sort(c,c+n+1);
	for(long long i=0;i<=n;i++)
	{
		long long x=lower_bound(c,c+n+1,b[i])-c+1;
		ans+=qry(x);
		upd(x);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6528
from collections import deque

S = deque(list(input()))
Q = int(input())
count = 0
for q in range(Q):
    Query = input().split()
    if Query == ['1']:
        count += 1
    else:
        if count % 2 == 0:
            if Query[1] == "1":
                S.appendleft(Query[2])
            else:
                S.append(Query[2])
        else:
            if Query[1] == "1":
                S.append(Query[2])
            else:
                S.appendleft(Query[2])
if count % 2 == 1:
    print(''.join(list(S)[::-1]))
else:
    print(''.join(S))


Measured memory_bytes: 10084
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

int main(){
  int N;
  cin >> N;
  stack<int> s;
  if(N == 0){
    cout << 0 << endl;
    return 0;
  }
  while(N != 0){
    if(N < 0){
      s.push(N - (N-1)/(-2) * (-2));
      N = (N-1)/(-2);
    }
    else{
      s.push(N - N/(-2) * (-2));
      N /= (-2);
    }
  }
  while(!s.empty()){
    int x;
    x = s.top(); s.pop();
    cout << x;
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <stdio.h>


void checkA(char masu[8][9],int i,int j){
    //printf("%c%c%c%c\n",masu[i][j],masu[i+1][j],masu[i][j+1],masu[i+1][j+1]);
    if(masu[i][j+1]=='1'&&masu[i+1][j]=='1'&&masu[i+1][j+1]=='1'){
        printf("A\n");
    }
}
void checkB(char masu[8][9],int i,int j){
    if(masu[i+1][j]=='1'&&masu[i+2][j]=='1'&&masu[i+3][j]=='1'){
        printf("B\n");
    }
}
void checkC(char masu[8][9],int i,int j){
    if(masu[i][j+1]=='1'&&masu[i][j+2]=='1'&&masu[i][j+3]=='1'){
        printf("C\n");
    }
}
void checkD(char masu[8][9],int i,int j){
    if(masu[i+1][j]=='1'&&masu[i+1][j-1]=='1'&&masu[i+2][j-1]=='1'){
        printf("D\n");
    }
}

void checkE(char masu[8][9],int i,int j){
    if(masu[i][j+1]=='1'&&masu[i+1][j+1]=='1'&&masu[i+1][j+2]=='1'){
        printf("E\n");
    }
}
void checkF(char masu[8][9],int i,int j){
    if(masu[i+1][j]=='1'&&masu[i+1][j+1]=='1'&&masu[i+2][j+1]=='1'){
        printf("F\n");
    }
}
void checkG(char masu[8][9],int i,int j){
    if(masu[i][j+1]=='1'&&masu[i+1][j-1]=='1'&&masu[i+1][j]=='1'){
        printf("G\n");
    }
}

int main(int argc, const char * argv[]) {
    int i=0,j=0,flag=0;
    char masu[8][9];
    
    while(1){
        for(i=0;i<8;i++){
                if(scanf("%s",masu[i])==EOF){
                    flag=1;
                    break;
                }
        }
        
        
        if(flag==1){
            //printf("b\n");
            break;
        }
        for(i=0;i<8;i++){
            for(j=0;j<8;j++){
                if(masu[i][j]=='1'){
                    //printf("a\n");
                    if(i<=6&&j<=6){
                        //printf("checkA\n");
                        checkA(masu,i,j);
                    }
                    if(i<=4){
                        //printf("checkB\n");
                        checkB(masu,i,j);
                    }
                    if(j<=4){
                        //printf("checkC\n");
                        checkC(masu,i,j);
                    }
                    if(j>=1&&i<=5){
                        //printf("checkD\n");
                        checkD(masu,i,j);
                    }
                    if(j<=5&&i<=6){
                        //printf("checkE\n");
                        checkE(masu,i,j);
                    }
                    if(j<=6&&i<=5){
                        //printf("checkF\n");
                        checkF(masu,i,j);
                    }
                    if(j>=1&&i<=6){
                        //printf("checkG\n");
                        checkG(masu,i,j);
                    }
                }
            }
        }
       
    }
    
    
    return 0;
}

Measured memory_bytes: 524
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(ll i=(x);i<(y);i++)
#define RREP(i,x,y) for(ll i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#define dump(x)  cout << #x << " = " << (x) << endl
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

class FSilverFoxVsMonster {
public:
    void solve(std::istream& in, std::ostream& out) {
        int N;
        ll D, A;
        in >> N >> D >> A;
        vector<pair<ll, ll>> XH(N+1);
        REP(i,1,N+1) in >> XH[i].first >> XH[i].second;
        sort(all(XH));
        vector<ll> damage(N+2);

        int left = 0, right; // [left, right)
        ll answer = 0;
        ll damageTotal = 0;
        while(left <= N) {
            while (left <= N && XH[left].second - damageTotal <= 0) {
                left++;
                damageTotal += damage[left];
            }
            if (left > N) break;
            auto itr = upper_bound(all(XH),pair<ll, ll>(XH[left].first + 2 * D, 1e10), [&](const pair<ll, ll>& a, const pair<ll, ll>& b) {
                return a.first < b.first;
            });
            right = min((int)distance(XH.begin(), itr), N+1);
            ll attack = (XH[left].second - damageTotal - 1) / A + 1;
            answer += attack;
            damage[left] += attack * A;
            damage[right] -= attack * A;
            damageTotal += attack * A;
        }
        out << answer << "\n";
    }
};


signed main() {
    FSilverFoxVsMonster solver;
    std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 4992
N, L = map(int, input().split())
A = []
for i in range(N):
  A.append(L+i)
i = 0
ans = False
while ans == False:
    x, y = abs(i), -abs(i)
    for k in A:
      if k == x or k == y:
        ans = True
        A.remove(k)
    i += 1
print(sum(A))

Measured memory_bytes: 9092
A, B, K = list(map(int, input().split()))

for k in range(K):
  if k % 2 == 0:
    if A % 2 == 1:
      A = A - 1
    A = A // 2
    B = B + A
  else:
    if B % 2 == 1:
      B = B - 1
    B = B // 2
    A = A + B

print(A, B)

Measured memory_bytes: 3060
#include <stdio.h>

int main(){

  int N,i,max=0;
  scanf("%d", &N);

  int V[N];
  for(i=0;i<N;i++){
    scanf("%d", &V[i]);
  }

  int C[N];
  for(i=0;i<N;i++){
    scanf("%d", &C[i]);
  }

  for(i=0;i<N;i++){
    if(V[i]>C[i]){
      max+=V[i]-C[i];
    }
  }
  printf("%d",max);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
#define double long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define pii pair<int,int>
#define ff first
#define ss second
#define frr(i,n) for(int i=0;i<n;i++)
#define td(v) v.begin(),v.end()
#define inf 1000000000 // 1e9
#define M   1000000007 // 1e9 + 7
using namespace std;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int exp(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}
struct SegmentTree{
    struct node{
        int val=0;
        int lazy=0;
        node(){}
        node(int val,int lazy) : val(val), lazy(lazy){}
    };
    std::vector<node> stree;
    SegmentTree(){}
    SegmentTree(int size){
        stree.resize(4*size);
    }
    node merge(node a,node b){
        return node(max(a.val,b.val),0);
    }
    // root = 1;
    void propagate(int cur,int l,int r){
        if(stree[cur].lazy==0) return;
        stree[cur].val += stree[cur].lazy*(r-l+1); // r-l+1 quantidade de elementos
        if(l!=r){
            stree[2*cur].lazy += stree[cur].lazy;
            stree[2*cur+1].lazy += stree[cur].lazy;
        }
        stree[cur].lazy = 0;
    }
    void updaterange(int cur,int l,int r,int a,int b,int x){ // l r ->posiçoes atuais
        propagate(cur,l,r);
        if(r<a || l>b){
            return;
        }
        if(a <= l && r <= b){
            stree[cur].lazy += x;
            propagate(cur,l,r);
            return;
        }
        int m = (l+r)>>1;
        updaterange(2*cur,l,m,a,b,x);
        updaterange(2*cur+1,m+1,r,a,b,x);
        propagate(cur,l,r);
        stree[cur] = merge(stree[2*cur],stree[2*cur+1]);
        return;
    }
    node query(int cur,int l,int r,int a,int b){ // l r ->posiçoes atuais
        propagate(cur,l,r);
        if(r<a || l>b){
            return node(0,0);
        }
        if(a <= l && r <= b) return stree[cur];
        int m = (l+r)>>1;
        node x = query(2*cur,l,m,a,b);
        node y = query(2*cur+1,m+1,r,a,b);
        propagate(cur,l,r);
        return merge(x,y);
    }
};
int32_t main(){
    fastio;
    int n;
    cin >> n;
    vector<int> h(n),a(n);
    SegmentTree Tree(n+200);
    frr(i,n) cin >> h[i];
    frr(i,n) cin >> a[i];
    for(int i=0;i<n;i++){
        int best = (h[i] == 1 ? 0 : Tree.query(1,1,n,1,h[i]-1).val);
        Tree.updaterange(1,1,n,h[i],h[i],best+a[i]);
    }
    cout << Tree.query(1,1,n,1,n).val << endl;
}

Measured memory_bytes: 15872
//g++ -std=c++11 -Wall test.cpp -o test -lm -g -O2
#include <bits/stdc++.h>
using namespace std;
#define sws                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define endl '\n'
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define qi queue<int>
#define si stack<int>
#define s string
#define ll long long;

int main()
{
    sws;
    int A, B;
    bool ans = false;
    cin >> A >> B;
    for (int i = 1; i <= B; i++)
    {
        if ((A * B * i) % 2 != 0)
        {
            ans = true;
            break;
        }
    }
    if (ans)
        puts("Yes");
    else
    {
        puts("No");
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mh(s, g) abs(start.at(i).first - goal.at(j).first) + abs(start.at(i).second - goal.at(j).second)

int main()
{
    int n, m, i, j;
    cin >> n >> m;
    vector<pair<long, long>> start(n + 1);
    vector<pair<long, long>> goal(m + 1);
    for (i = 1; i <= n; i++)
    {
        cin >> start.at(i).first >> start.at(i).second;
    }
    for (i = 1; i <= m; i++)
    {
        cin >> goal.at(i).first >> goal.at(i).second;
    }
    for (i = 1; i <= n; i++)
    {
        int ans = 1;
        long min = abs(start.at(i).first - goal.at(1).first) + abs(start.at(i).second - goal.at(1).second);
        for (j = 2; j <= m; j++)
        {
            long kouho = abs(start.at(i).first - goal.at(j).first) + abs(start.at(i).second - goal.at(j).second);
            if (min > kouho)
            {
                min = kouho;
                ans = j;
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3576
# coding:utf-8
def main():
    n,a,b = map(int, input().split())

    #総和
    count = 0

    for number in range(1,n+1):
        #各桁の合計値
        score = sum(list(map(int, list(str(number))))) 
        if  b >= score >= a:
            count += int(number)
    print(count)


if __name__ == '__main__' :
    main()

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

using namespace std;

class D3
{
public:
	long double x;
	long double y;
	long double z;
	long double EPS;

	//?????????????????????
	D3 ( long double x_ = 0.0 , long double y_ = 0.0 , long double z_ = 0.0 )
	{
		EPS = 1e-9;
		x = x_;
		y = y_;
		z = z_;
	}

	//??????
	D3 Cross_product ( D3 partner )
	{
		D3 ret ( y*partner.z - z*partner.y , z*partner.x - x*partner.z , x*partner.y - y*partner.x );
		return ret;
	}

	//??????
	double Inner_product ( D3 partner )
	{
		return x*partner.x + y*partner.y + z*partner.z;
	}

	//?????????????????????????????????
	D3 Make_vector ( D3 partner )
	{
		D3 ret ( partner.x - x , partner.y - y , partner.z - z );
		return ret;
	}

	//???????§????2????????????????????¢???????±???????
	double S_vec ( D3 A , D3 B )
	{
		D3 G;
		G = A.Cross_product ( B );
		return sqrt ( G.Inner_product ( G ) ) / 2;
	}

	//??????????????¢???????±???????
	double S_point ( D3 A , D3 B , D3 C )
	{
		return S_vec ( A.Make_vector ( B ) , A.Make_vector ( C ) );
	}

	//???????§????3????????????????????????????±???????
	double V_vec ( D3 A , D3 B , D3 C )
	{
		D3 G;
		G = A.Cross_product ( B );
		return G.Inner_product ( C ) / 6;
	}

	//4???????????????????±???????
	double V_point ( D3 A , D3 B , D3 C , D3 D )
	{
		return V_vec ( A.Make_vector ( B ) , A.Make_vector ( C ) , A.Make_vector ( D ) );
	}

	D3 operator+( D3 partner )
	{
		return D3 ( x + partner.x , y + partner.y , z + partner.z );
	}

	D3 operator-( D3 partner )
	{
		return D3 ( x - partner.x , y - partner.y , z - partner.z );
	}

	D3 operator*( D3 partner )
	{
		return D3 ( x * partner.x , y * partner.y , z * partner.z );
	}

	D3 operator/( D3 partner )
	{
		return D3 ( x / partner.x , y / partner.y , z / partner.z );
	}

	D3 operator*( double d )
	{
		return D3 ( x * d , y * d , z * d );
	}

	D3 operator/( double d )
	{
		return D3 ( x / d , y / d , z / d );
	}

	bool operator==( D3 partner )
	{
		return abs ( x - partner.x ) < EPS&&abs ( y == partner.y ) < EPS&&abs ( z == partner.z ) < EPS;
	}

	double length ()
	{
		return sqrt ( x*x + y*y + z*z );
	}

	//???????????????????????????
	//????????¨???
	D3 Unit_vec ()
	{
		return D3 ( *this ) / ( *this ).length ();
	}

	//????????????????????????
	D3 Inverse_vec ()
	{
		return D3 ( *this )*-1.;
	}

	//?????´????????????
	bool Vertical ( D3 partner )
	{
		return ( *this ).Inner_product ( partner ) == 0;
	}

	//??????????????????
	bool Parallel ( D3 partner )
	{
		return ( *this ).Unit_vec () == partner.Unit_vec () || ( *this ).Unit_vec ().Inverse_vec () == partner.Unit_vec ();
	}

};

int main ()
{
	long double xa , ya , xb , yb , xc , yc , xd , yd;
	char c;
	while( cin >> xa >> c >> ya >> c >> xb >> c >> yb >> c >> xc >> c >> yc >> c >> xd >> c >> yd )
	{
		D3 A ( xa , ya ) , B ( xb , yb ) , C ( xc , yc ) , D ( xd , yd );
		D3 calc;
		if( calc.S_point ( A , B , C ) + calc.S_point ( A , D , C ) == calc.S_point ( B , A , D ) + calc.S_point ( B , C , D ) )
		{
			cout << "YES" << endl;
		} else
		{
			cout << "NO" << endl;
		}
	}
}

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

int main() {
	int sx, sy, tx, ty, dx, dy;
	cin >> sx >> sy >> tx >> ty;
	dx = tx - sx;
	dy = ty - sy;
	rep(i,dy) cout << "U";
	rep(i,dx) cout << "R";
	rep(i,dy) cout << "D";
	rep(i,dx+1) cout << "L";
	rep(i,dy+1) cout << "U";
	rep(i,dx+1) cout << "R";
	cout << "D";
	cout << "R";
	rep(i,dy+1) cout << "D";
	rep(i,dx+1) cout << "L";
	cout << "U";
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<vector>
#include<set>
#include<cmath>
#include<iomanip>
#include<algorithm>
#define int long long int
#define mod 1000000007
int memo[101][101];
void function()
{
	int i=0,j=0;
	for(i=0;i<=100;i++)
	{
		for(j=0;j<=100;j++)
		{
			if(j>i)
			{
				memo[i][j]=0;
			}
		}
	}
	memo[1][1]=1;
	for(i=2;i<=100;i++)
	{
		memo[i][1]=i;
	}
	for(i=2;i<=100;i++)
	{
		for(j=2;j<=100;j++)
		{
			memo[i][j]=(memo[i-1][j]+memo[i-1][j-1]);
		}
	}
}
int ncr(int n,int r)
{
	if(r>n)
	   return 0;
	return memo[n][r];
}
int32_t main()
{
	int n;
	cin>>n;
	int count[n][26]={0};
	int j;
	for(j=0;j<n;j++)
	{
		string str;
		cin>>str;
		for(char x:str)
		{
			count[j][x-97]++;
	    }
	}
	for(int i=0;i<26;i++)
	{
		int val=100000;
		for(j=0;j<n;j++)
		{
			val=min(val,count[j][i]);
		}
		char x=char(i+97);
		for(j=0;j<val;j++)
		  cout<<x;
	}
	cout<<endl;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

#include <bits/stdc++.h>
using namespace std;



int main() {
    int N;
    cin >> N;
    int value = N%10;
    if(value == 0 | value == 1 | value == 6 | value == 8){
        cout << "pon" << endl;
    }else if(value == 2 | value == 4 | value == 5 | value == 7 | value == 9){
        cout << "hon" << endl;
    }else{
        cout << "bon" << endl;
    }
}


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

#define rep(i, n) for (int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;

const int WHITE = 0;
const int GRAY = 1;
const int BLACK = 2;
const int MAX = 103;
const int INF = -1;
int G[MAX][MAX];
int n;
int color[MAX], dist[MAX];

void bfs(int s) {
  memset(color, WHITE, sizeof(color));
  memset(dist, INF, sizeof(dist));

  queue<int> Q;

  color[s] = GRAY;
  dist[s] = 0;
  Q.push(s);

  while (!Q.empty()) {
    int u = Q.front(); Q.pop();
    rep(v,n) {
      if (G[u][v] && color[v] == WHITE) {
	color[v] = GRAY;
	dist[v] = dist[u] + 1;
	Q.push(v);
      }
    }
    color[u] = BLACK;
  }
}

int main() {
  cin >> n;
  rep(i,n) memset(G[i], 0, sizeof(G[i])); // init
  int u, k;
  rep(i,n) {
    cin >> u >> k;
    rep(j,k) {
      int t;
      cin >> t;
      G[i][t-1] = 1;
    }
  }

  bfs(0);

  rep(i,n) {
    cout << i+1 << ' ' << (dist[i]==INF ? -1 : dist[i]) << endl;
  }
  return 0;
}



Measured memory_bytes: 3144
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
long long d[2000][2000], N, A, B, C, D, mod = 1000000007, fact[2000], dp[2000][2000], DV[2000];
long long ncr(long long n, long long r) {
	return d[n - r][r];
}
long long modpow(long long a, long long b, long long m) {
	long long p = 1, q = a;
	for (int i = 0; i < 62; i++) {
		if ((b / (1LL << i)) % 2 == 1) { p *= q; p %= m; }q *= q; q %= m;
	}
	return p;
}
long long Div(long long a, long long b, long long m) {
	return (a*modpow(b, m - 2, m)) % m;
}
long long Div2(long long a, long long b, long long m) {
	return (a*DV[b]) % m;
}
int main() {
	fact[1] = 1; for (int i = 2; i < 1999; i++) { fact[i] = fact[i - 1] * i; fact[i] %= mod; }
	for (int i = 0; i < 1999; i++) {
		for (int j = 0; j < 1999; j++) {
			if (i == 0 || j == 0)d[i][j] = 1;
			else d[i][j] = d[i - 1][j] + d[i][j - 1];
			d[i][j] %= mod;
		}
	}
	for (int i = 1; i <= 1999; i++)DV[i] = Div(1, i, mod);
	cin >> N >> A >> B >> C >> D; dp[A - 1][0] = 1;
	for (int i = A; i <= B; i++) {
		for (int j = 0; j <= N; j++) {
			//dp[i-1][j],dp[i-1][j-k],dp[i-1][j-k*2]...
			long long ret = 1, cnt = 0;
			for (int k = j; k >= 0; k -= i) {
				if (k == j)ret = 1;
				else { cnt++; ret *= ncr(k + i, i); ret %= mod; ret = Div2(ret, cnt, mod); }
				if (cnt != 0 && (cnt < C || cnt > D))continue;
				dp[i][j] += ret*dp[i - 1][k]; dp[i][j] %= mod;
			}
		}
	}
	cout << dp[B][N] << endl;
	return 0;
}

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

int main()
{
    int n;
    cin>>n;
    vector<string>arr(n);
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        sort(arr[i].begin(),arr[i].end());
    }
    sort(arr.begin(),arr.end());
    long long int k=1,sum=0;
    for(int i=0;i<n-1;i++)
    {
        if(arr[i]==arr[i+1])
        {
            k++;
            if(i==n-2)
            {
                sum+=(k*(k-1))/2;
            }
        }
        else
        {
            sum+=(k*(k-1))/2;
            k=1;
        }
    }
    cout<<sum<<endl;
}


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

int main() {
    int N;
    cin >> N;
    if (N <= 999) {
        cout << "ABC" << endl;
    }
    else {
        cout << "ABD" << endl;
    }
}


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

int32_t main() {
    int n;
    cin>>n;
    int a[n];
    long double ans =1;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    for(int i=0;i<n;i++){
        ans = ans*a[i];
        if(ans-1000000000000000000 > 0){
			cout << "-1";
			return 0;
		}
    }
    cout<< (long long)ans;
}


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,a,b,c,d;
    cin >> n >> a >> b >> c >> d;
    int q=0,w=0;
    if(n%a>0){q=1;}
    if(n%c>0){w=1;}
    cout << min((b*((n/a)+q)),(d*((n/c)+w))) << endl;

    return 0;
}


Measured memory_bytes: 3232
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
vector<int>graph[1000005];
bool vis[1000005];
int connection[1000005];
bool BPM(int node)
{
    int sz=graph[node].size();
    for(int i=0; i<sz; i++)
    {
        int child=graph[node][i];
        if(vis[child]==0)
        {
            vis[child]=1;
            if(connection[child]<0 || BPM(connection[child]))
            {
                connection[child]=node;
                return true;
            }
        }
    }
    return false;
}
int maxBPM(int n)
{
    memset(connection,-1,sizeof(connection));
    int res=0;
    for(int i=0; i<n; i++)
    {

        memset(vis,0,sizeof(vis));
        if(BPM(i))
            res++;

    }
    return res;
}
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n;
    cin>>n;
    vector<pair<int,int> >R,B;
    for(int i=0; i<n; i++)
    {
        int x,y;
        cin>>x>>y;
        R.push_back({x,y});
    }
    for(int i=0; i<n; i++)
    {
        int x,y;
        cin>>x>>y;
        B.push_back({x,y});
    }
  /*  sort(R.begin(),R.end(),cmp);
    sort(B.begin(),B.end(),cmp);
    for(auto x:R)
        cout<<x.first<<"      "<<x.second<<endl;
    bug
    bug
    for(auto x:B)
        cout<<x.first<<"      "<<x.second<<endl;
    int cnt=0;*/
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<n; j++)
        {
            if(R[i].first<B[j].first && R[i].second<B[j].second)
            {

               graph[i].push_back(j);

            }
        }
    }
    cout<<maxBPM(n)<<endl;
    return 0;
}


Measured memory_bytes: 31912
#include<bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back

using namespace std;

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

ll f(ll t , ll a){
	
	ll ans = t/a*2*a;

	if(t%a == 0)
	   return ans - a;

	ans += f(a , t%a);

	return ans;

}
int main(){
     
    ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0); 
	
	ll n , x;
	cin >> n >> x;
	
	cout << n + f(n-x , x) << endl; 

	return 0;
}

Measured memory_bytes: 256