akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int n;
string s;
set<int> r, g, b;
int suffR[4001], suffG[4001], suffB[4001];

void input(){
    scanf("%d", &n);
    cin >> s;
}

void prepare(){
    for (int i = s.length() - 1; i >= 0; i--){
        if (s[i] == 'R'){
            suffR[i] = suffR[i+1] + 1;
            suffG[i] = suffG[i+1];
            suffB[i] = suffB[i+1];
        } else if (s[i] == 'G'){
            suffR[i] = suffR[i+1];
            suffG[i] = suffG[i+1] + 1;
            suffB[i] = suffB[i+1];
        } else if (s[i] == 'B'){
            suffR[i] = suffR[i+1];
            suffG[i] = suffG[i+1];
            suffB[i] = suffB[i+1] + 1;
        }
    }
}

void solve(){
    long long int ans = 0;
    for (int i = 0; i < s.length(); i++){
        if (s[i] == 'R'){
            for (int j = i+1; j < s.length(); j++){
                if (s[j] == 'G'){
                    ans += suffB[j];
                    if (2*j-i < s.length() && s[2*j-i] == 'B'){
                        ans--;
                    }
                }
            }
        }
    }
    for (int i = 0; i < s.length(); i++){
        if (s[i] == 'R'){
            for (int j = i+1; j < s.length(); j++){
                if (s[j] == 'B'){
                    ans += suffG[j];
                    if (2*j-i < s.length() && s[2*j-i] == 'G'){
                        ans--;
                    }
                }
            }
        }
    }
    for (int i = 0; i < s.length(); i++){
        if (s[i] == 'G'){
            for (int j = i+1; j < s.length(); j++){
                if (s[j] == 'R'){
                    ans += suffB[j];
                    if (2*j-i < s.length() && s[2*j-i] == 'B'){
                        ans--;
                    }
                }
            }
        }
    }

    for (int i = 0; i < s.length(); i++){
        if (s[i] == 'G'){
            for (int j = i+1; j < s.length(); j++){
                if (s[j] == 'B'){
                    ans += suffR[j];
                    if (2*j-i < s.length() && s[2*j-i] == 'R'){
                        ans--;
                    }
                }
            }
        }
    }

    for (int i = 0; i < s.length(); i++){
        if (s[i] == 'B'){
            for (int j = i+1; j < s.length(); j++){
                if (s[j] == 'R'){
                    ans += suffG[j];
                    if (2*j-i < s.length() && s[2*j-i] == 'G'){
                        ans--;
                    }
                }
            }
        }
    }

    for (int i = 0; i < s.length(); i++){
        if (s[i] == 'B'){
            for (int j = i+1; j < s.length(); j++){
                if (s[j] == 'G'){
                    ans += suffR[j];
                    if (2*j-i < s.length() && s[2*j-i] == 'R'){
                        ans--;
                    }
                }
            }
        }
    }

    cout << ans << endl;
}

int main(){
    input();
    prepare();
    solve();
}


Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef pair<l_l,ll> lll;
typedef vector<string> vs;
const ll dx[4]={1,-1,0,0};
const ll dy[4]={0,0,1,-1};
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
int main(){
    ld x,y;cin>>x>>y;
    ll yy=y*100+0.5;
    ll ans=x*yy;
    ans/=100;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3732
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>

using namespace std;


#define all(c) ((c).begin()), ((c).end())
#define debug(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back


const double EPS = 1e-10;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;


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

Measured memory_bytes: 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("-Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef int in;
#define int long long
#define f first
#define s second
#define pb push_back
#define pp push
#define RETURN exit(0)
#define pow(x,y) (int)(pow(x,y))
#define ceil(x) (int)(ceil(x))
#ifndef ONLINE_JUDGE
#define debug(x) cout<<x<<endl;
#else
#define debug(x) 42
#endif
const int MAX=1e4;
const int MOD=1e9+7;
const int MAAX=1e15;
const long double EPS=1e-6;
const int N=1e6;
int power(int x,int y)
{
    if (y == 0)
        return 1;
    int a=power(x,y/2);
    if (y % 2 == 0)
        return a * a % MOD;
    else
        return x * a * a % MOD;
}
long double sq(int x){
    long double s=0,e=x,mid;
    while(e-s>=EPS){
        mid=(s+e)/2;
        if(mid*mid<=x){
            s=mid;
        }
        else{
            e=mid-EPS;
        }
    }
    return s;
}
bool check(int x){

}
int binary(int x,int y){
    int s=x,e=y,mid;
    while(s<e){
        mid=ceil((s+e)/2.0);
        if(check(mid))
            s=mid;
        else
            e=mid-1;
    }
    return s;
}
vector<int> primes;
bool visted[N+5];
void sieve(){
    visted[0]=visted[1]=1;
    for(int i=2;i*i<=N;i++){
        if(visted[i]==0){
            primes.pb(i);
            for(int j=i*i;j<=N;j+=i){
                visted[j]=1;
            }
        }
    }
    for(int i=sqrt(N)+1;i<=N;i++){
        if(visted[i]==0)
            primes.pb(i);
    }
    return;
}

int p[10],q[10],arr[10];

in main()
{
    //freopen("in.in","r",stdin);
    //freopen("out.out","w",stdout);
    int tc=1;
    //sieve();
    //scanf("%lld",&tc);
    while(tc--)
    {
        int n;
        cin>>n;
        for(int i=0;i<n;i++){
            cin>>p[i];
            arr[i]=i+1;
        }
        for(int i=0;i<n;i++)
            cin>>q[i];
        int x,y,idx=0;
        do{
            bool bol=1,bol2=1;
            for(int i=0;i<n;i++){
                if(arr[i]!=p[i])
                    bol=0;
                if(arr[i]!=q[i])
                    bol2=0;
            }
            if(bol)
                x=idx;
            if(bol2)
                y=idx;
            idx++;
        }while(next_permutation(arr,arr+n));
        cout<<abs(y-x)<<endl;
    }
    RETURN;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	string s;
	map<string, int> cnt;
	ll ans = 0;
	rep(i,n){
		cin >> s;
		sort(s.begin(), s.end());
		ans += cnt[s];
		cnt[s]++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 11264
import java.util.LinkedList;
import java.util.Scanner;

class NumTh{
	static long mod=1000000007; // 10e9 + 7
	static long GCD(long x, long y) {
		if(Math.max(x, y) % Math.min(x, y) == 0) return Math.min(x, y);
		return GCD(Math.min(x, y), Math.max(x, y) % Math.min(x, y));
	}
	static int GCD(int x, int y) {
		return (int)GCD((long)x, (long)y);
	}
	static long LCM(long x, long y){
		return (x / GCD(x,y)) * y;
	}
	static int LCM(int x, int y) {
		return (int)LCM((long)x, (long)y);
	}
    // $a^x$ mod m
	static long pow(long a, long x, long m){
		if(x == 1) return a % m;
		else if(x % 2 == 0) return pow((a * a) % m, x / 2, m) % m;
		else return (a * pow((a * a) % m, x / 2, m)) % m;
	}
	static boolean ip(long x) {
		if(x == 1) return false;
		for(long i = 2; i * i <= x; i++) if(x % i == 0) return false;
		return true;
	}
	static long Perm(long n, long k) {
		if(n == 0) return 1;
		if(n < k) return 0;
		long ans = 1;
		for(long i = 0; i < k; i++) {
			ans *= (n - i);
			ans %= mod;
		}
		return ans;
	}
	static long Choose(long n, long k) {
		long res = 1;
		for(long i = n; i >= n - k + 1; i--) {
			res *= i; res %= mod;
			res *= inv(k - n + i, mod); res %= mod;
		}
		return res % mod;
	}
	static long inv(long a, long mod) {
		if(GCD(a, mod) != 1) return -1; // there is no inverse
		x = 0; y = 0;
		extGCD(a, mod, 0);
		return (x + mod) % mod;
	}
	/* Calculate the solution of ax + by = gcd(a, b) */
	// Usage: extgcd(a, b, 0)
	static long x = 0, y = 0;
	static long extGCD(long a, long b, int c) {
		long d = a;
		if(b != 0) {
			d = extGCD(b, a % b, (c + 1) % 2);
			if(c == 0) y -= (a / b) * x;
			else x -= (a / b) * y;
		}else {
			x = (c == 0) ? 1 : 0;
			y = (c == 0) ? 0 : 1;
		}
		return d;
	}
}
// if id == -1, the Node is root.
class Node{
	int id = -1;
	long occ_num = 1, can_choose = 0;
	LinkedList<Integer> child;
	public Node(int x) {
		id = x;
		child = new LinkedList<Integer>();
	}
}
class Edge{
	int s, t;
	public Edge(int _a, int _b) {
		s = _a; t = _b;
	}
}
public class Main{
	static LinkedList<Integer>[] tree;
	static long dfs(int K, int now, int from) {
		long can_color = (from == -1) ? K - 1 : K - 2;
		if(K < tree[now].size()) return 0; // ぬれない
		long ans = 1;
		for(int e : tree[now]) {
			if(e == from) continue;
			ans *= can_color;
			can_color--;
			ans %= NumTh.mod;
		}
		for(int e : tree[now]) {
			if(e == from) continue;
			ans *= dfs(K, e, now);
			ans %= NumTh.mod;
		}
		return ans;
	}
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), K = sc.nextInt();
		tree = new LinkedList[N];
		for(int i = 0; i < N; i++) tree[i] = new LinkedList<Integer>();
		for(int i = 0; i < N - 1; i++) {
			int a = sc.nextInt() - 1, b = sc.nextInt() - 1;
			tree[a].add(b);
			tree[b].add(a);
		}
		long ans = dfs(K, 0, -1);
		ans *= K;
		System.out.println((ans) % NumTh.mod);
	}
}


Measured memory_bytes: 125828
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define sortr(v) sort((v).rbegin(), (v).rend())
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
*/

int main() {
	lint N;
	cin >> N;
	vector<lint>n(5);
	rep(i, 5) {
		cin >> n[i];
	}
	sort(n);
	cout << 4 + N / n[0] + bool(N% n[0]) << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

long dp[100][100001];

int main(){
    int N, W;
    cin >> N >> W;
    for(int i = 0; i < N; i++){
        for(int j = 1; j <= 100000; j++){
            dp[i][j] = INT32_MAX;
        }
    }
    int w, v;
    cin >> w >> v;
    dp[0][v] = w;
    for(int i = 1; i < N; i++){    
        cin >> w >> v;
        dp[i][v] = w;
        for(int j = 0; j <= 100000; j++){
            dp[i][j] = min(dp[i][j], dp[i-1][j]);
            if(j >= v){
                if(dp[i-1][j-v]+w <= W) dp[i][j] = min(dp[i][j], dp[i-1][j-v]+w);
            }
        }
    }
    for(int i = 100000; i >= 0; i--){
        if(dp[N-1][i] != INT32_MAX){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 78336
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x) cout << #x << " = " << (x) << endl;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define P pair<int, int>
#define V vector<int>
#define M map<int, int>
#define S set<int>
#define itn int
#define tin int
#define tni int
bool dbg = false;
int N, A[100010], B[100010];
void solve()
{
    int ans = 0;
    ;
    FOR(i, 0, N)
    {
        if (B[i] > A[i]) {
            ans += A[i];
            int t = B[i] - A[i];
            if (t >= A[i + 1]) {
                ans += A[i + 1];
                A[i + 1] = 0;
            } else {
                ans += t;
                A[i + 1] -= t;
            }
        } else {
            ans += B[i];
        }
    }
    cout << ans << endl;
}

signed main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> N;
    FORR(i, 0, N)
    {
        cin >> A[i];
    }
    FOR(i, 0, N)
    {
        cin >> B[i];
    }
    solve();
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <climits>

#define F first
#define S second
#define vsort(v) sort((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())


//INT_MAX
//INT_MIN
//LLONG_MAX
//LLONG_MIN
//DBL_MIN
//DBL_MAX
//LDBL_MIN
//LDBL_MAX

using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    int a, b, h;
    cin >> a >> b >> h;
    cout << (a + b) * h / 2 << endl;
}


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

using namespace std;

long long dp[100005];

int main(){
    int N, W;
    cin >> N >> W;
    for(int i = 1; i<=N; i++){
        int wt, v;
        cin >> wt >> v;
        for(int j = W; j>=wt; j--){
            dp[j] = max(dp[j], dp[j-wt]+v);
        }
    }
    cout << dp[W] << endl;
}


Measured memory_bytes: 1024
from collections import deque
import numpy as np

N,K = (int(x) for x in input().split())
S = input()
count = []
d = deque(list(S))
now = d.popleft()
cum = 1
for i in range(len(S)-1):
    popped = d.popleft()
    if popped == now:
        cum += 1
    else:
        count.append(cum)
        now = popped
        cum = 1
count.append(cum)
cs = np.array(count).cumsum()
block = len(count)
if S[0] == '0':
    zeros = int(np.ceil(block/2))
    if K >= zeros:
        print(len(S))
    else:
        m = cs[K*2-1]
        if S[-1] == '1':
            for i in range(1,zeros-K+1):
                m = max(m,cs[2*i+2*K-1]-cs[2*(i-1)])
        else:
            for i in range(1,zeros-K):
                m = max(m,cs[2*i+2*K-1]-cs[2*(i-1)])
            m = max(m,cs[-1]-cs[-2*K-1])
        print(m)
else:
    zeros = int(np.floor(block/2))
    if K >= zeros:
        print(len(S))
    else:
        m = cs[2*K]
        if S[-1] == '1':
            for i in range(1,zeros-K+1):
                m = max(m,cs[2*i+2*K]-cs[2*i-1])
        else:
            for i in range(1,zeros-K):
                m = max(m,cs[2*i+2*K]-cs[2*i-1])
            m = max(m,cs[-1]-cs[-2*K-1])
        print(m)

Measured memory_bytes: 15584
/*Author : Harsh AKA Codula*/

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inp freopen("input.txt","r",stdin)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
 
//main class

class Solution
{
	public:
		void run()
		{
			ll t=1;//cin>>t;
			while(t--)
			{
				ll n;                 
				cin>>n;
				vector<ll> a(n,0);
				for(ll i=0;i<n;++i)cin>>a[i];
				sort(a.begin(),a.end());
				ll c=0;
				if(n<3)
				{
					cout<<0;
				}
				else
				{
				for(ll i=0;i<(n-2);++i)
				{
					for(ll j=(i+1);j<(n-1);++j)
					{
						for(ll k=(j+1);k<n;++k)
						{
							if(a[i]+a[j]>a[k] && a[i]!=a[j] && a[j]!=a[k] && a[k]!=a[i])
							{
								c++;
							}	
						}
					}
				
				}
				cout<<c;
				}
				
				cout<<"\n";
			}
		}	
};
//driver func

int main()
{
	//fast;
	//inp;
	Solution MAIN1;
	MAIN1.run();
	return 0;
}


Measured memory_bytes: 3612
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
char s[16];
char t[16];
int main(){
	scanf("%s",s);
	int p=strlen(s);
	int ret=0;
	for(int i=0;i<(1<<p);i++){
		int now=0;
		for(int j=0;j<p;j++)if(i&(1<<j))t[now++]=s[j];
		int I=0;
		int W=0;
		for(int j=0;j<now;j++){
			if(t[j]=='i')I++;
			if(t[j]=='w')W++;
		}
		if(I!=2||W!=1)continue;
		bool ok=false;
		for(int j=0;j<now-2;j++){
			if(t[j]=='i'&&t[j+1]=='w'&&t[j+2]=='i')ok=true;
		}
		if(!ok)continue;
		bool dame=false;
		if(now%2==1&&t[now/2]!='w')continue;
		for(int j=0;j<now/2;j++){
			if(t[j]=='i'&&t[now-1-j]!='i')dame=true;
			if(t[j]=='['&&t[now-1-j]!=']')dame=true;
			if(t[j]=='{'&&t[now-1-j]!='}')dame=true;
			if(t[j]=='('&&t[now-1-j]!=')')dame=true;
			if(t[j]==']'&&t[now-1-j]!='[')dame=true;
			if(t[j]=='}'&&t[now-1-j]!='{')dame=true;
			if(t[j]==')'&&t[now-1-j]!='(')dame=true;
		}
		if(dame)continue;
		ret=max(ret,now);
	}
	printf("%d\n",ret);
}

Measured memory_bytes: 0
#include<iostream>
#include<iomanip>
#include<string>
#include<set>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<functional>
using namespace std;
#define LL long long
#define MOD 100000
#define inf 1999999999
#define ALL(x) (x).begin(), (x).end()
#define Pi pair<int, int>
#define Vi vector<int>

#define rep(i, n) for(LL i = 0; i < n; i++)
#define repr(i, x, n) for(int i = x; i < n; i++)
#define repd(n) for(int i = n - 1; i >= 0; i--)

LL n, a[100002], b[100002] ,ans = 0;

int main() {
	cin >> n;
	rep(i, n + 1) cin >> a[i];
	rep(i, n) cin >> b[i];
	rep(i, n) {
		if (b[i] <= a[i]) {
			ans += b[i];
			a[i] -= b[i];
			b[i] = 0;
		}
		else {
			ans += a[i];
			b[i] -= a[i];
			a[i] = 0;
			if (b[i] <= a[i + 1]) {
				ans += b[i];
				a[i + 1] -= b[i];
				b[i] = 0;
			}
			else {
				ans += a[i + 1];
				b[i] -= a[i + 1];
				a[i + 1] = 0;
			}
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pi = pair<int, int>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<pi>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m); (i) > (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define R cin>>
#define repr(i, n) REPR(i, n, 0)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define in(a) insert(a)
#define P(p) cout<<(p)<<endl;
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SORT(a) sort((a).begin(), (a).end())
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long int> vll;
typedef vector<string> vs;
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename T> void co(T e){cout << e << "\n";}
template<typename T> void co(const vector<T>& v){for(const auto& e : v)
    { cout << e << " "; } cout << "\n";}
ll gcd(ll a, ll b) {
    if (a < b)swap(a, b);
    if (b == 0) return a;
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}
ll lcm(ll a, ll b) {
    ll g = gcd(a, b);
    return a * b / g;
}
bool prime(ll n) {
    for (ll i = 2; i <= sqrt(n); i++) {
        if (n%i == 0)return false;
    }
    return n != 1;
}

Vec fac, finv;

ll PowMod(ll a, ll n){
    if(n == 1) return a;
    if(n%2 == 0) return PowMod(a*a%MOD, n/2);
    return a*PowMod(a*a%MOD, n/2)%MOD;
}

ll combi(ll n, ll k){
    if(k>n) return 0;
    return fac[n]*finv[k]%MOD*finv[n-k]%MOD;
}


double memo[301][301][301];
double f(int i, int j, int k, int n) {
    if(i + j + k == 0) return 0;
    if(memo[i][j][k] != 0) return memo[i][j][k];
    int s = i + j + k;
    double ret = n - s;
    if(i) ret += (f(i - 1, j, k, n) + 1) * i;
    if(j) ret += (f(i + 1, j - 1, k, n) + 1) * j;
    if(k) ret += (f(i, j + 1, k - 1, n) + 1) * k;
    memo[i][j][k] = ret/s;
    return ret/s;
}



int main(){
    int n, r, a = 0, b = 0, c = 0;
    setp(12);
    cin >> n;
    rep(i, n) {
        cin >> r;
        if (r == 1) a ++;
        else if (r == 2) b ++;
        else c ++;
    }
    co(f(a, b, c, n));
}



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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N,C;

vpint lis[33];

vpint latte(vpint v){
    sort(all(v));
    vpint ret;
    for(auto &p:v){
        if(ret.size()&&ret.back().se==p.fi)ret.back().se=p.se;
        else ret.pb(p);
    }
    return ret;
}

int sum[222222];

signed main(){
    cin>>N>>C;
    rep(i,N){
        int l,r,c;
        cin>>l>>r>>c;
        c--;
        lis[c].pb({l,r});
    }

    rep(i,C)lis[i]=latte(lis[i]);
    rep(i,C)rep(j,lis[i].size()){
        pint p=lis[i][j];
        p.fi*=2;p.se*=2;
        p.fi--;
        sum[p.fi]++;
        sum[p.se]--;
    }

    rep(i,222222-1)sum[i+1]+=sum[i];

    cout<<*max_element(sum,sum+222222)<<endl;
    return 0;
}


Measured memory_bytes: 4560
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

 class Main{

	public static void main(String[] args) throws IOException {
		 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));		

		int n = Integer.parseInt(br.readLine());
		int[] in = new int[n];
		int max = Integer.MIN_VALUE;
		int mini = 0;
		int maxj=0;
		boolean con=false;
		
		for (int i = 0; i < n; i++)
			in[i] = Integer.parseInt(br.readLine());
		
		for (int i = 0; i < n - 1; i++) {
			if (in[i] > in[mini])continue;
			for (int j = i + 1; j < n; j++){
				
				if(max+in[i]<in[j]){
					max=in[j]-in[i];
					mini=i;
					maxj=j;
					con=false;
				}
			}con=true;
		}
		System.out.println(max);
	}}

Measured memory_bytes: 37684
#include "bits/stdc++.h"

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i,n) for(ll i=1;i<=(ll)(n);i++)
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(ll)(n);i>0;i--)
#define REP(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(v) v.begin(),v.end()
#define UNIQUE(v) v.erase(unique(all(v)), v.end())
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; }
const ll inf = 1000000001;
const ll INF = 2e18;
const ll MOD = 1000000007;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);


int main() {
	int n, m;
	cin >> n >> m;
	vl _x(n), _y(n), _z(n);
	rep(i, n) {
		cin >> _x[i] >> _y[i] >> _z[i];
	}
	ll ans = -INF;
	rep(mask, 8) {
		vl x = _x, y = _y, z = _z;
		rep(i, n) {
			if (mask & (1 << 0)) {
				x[i] *= -1;
			}
			if (mask & (1 << 1)) {
				y[i] *= -1;
			}
			if (mask & (1 << 2)) {
				z[i] *= -1;
			}
		}
		vll dp(n + 1, vl(m + 1, -INF));
		dp[0][0] = 0;
		rep(i, n) {
			rep(j, m + 1) {
				chmax(dp[i + 1][j], dp[i][j]);
				if (j != m) {
					chmax(dp[i + 1][j + 1], dp[i][j] + x[i] + y[i] + z[i]);
				}
			}
		}
		chmax(ans, dp[n][m]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 8200
#include <bits/stdc++.h>
  
#define INF 2000000010
#define mod7 1000000007
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL_MAX 9223372036854775807
#define INF_LL 9223372036854775
#define EPS 1e-10
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double 
 
using namespace std;

int main(){

  int a, b;
  cin >> a >> b;
  if(a <= 0 && 0 <= b){
    cout << "Zero" << endl;
    return 0;
  }

  if(0 < a){
    cout << "Positive" << endl;
  }

  else{
    if(abs((b-a))%2 == 0){
      cout << "Negative" << endl;
    }
    else{
      cout << "Positive" << endl;
    }
  }

  return 0;

}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int N;
  cin >> N;
  vi32 A(N);
  cin >> A;

  i64 ans = 0;
  ans += A[0] - 1;
  int p = 1;
  reps(i, N - 1) {
    if (A[i] == p + 1) {
      p++;
      continue;
    } else if (A[i] < p + 1) {
      continue;
    } else {
      int d = p + 1;
      int c = (A[i] + d - 1) / d - 2;
      ans += c + 1;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
 
#define sl(x) scanf("%ld", &x)
#define ss(x) scanf("%s", x)
#define pl(x) printf("%ld\n", x)
#define ps(x) printf("%s\n", x)
 
#define INF 100000000000
#define MOD 1000000007
 
#define MIN(a,b) (((a)<(b))?(a):(b))
#define MAX(a,b) (((a)>(b))?(a):(b))
 
int main() {
	long K, S;
	long X, Y, Z;
	long i, j;
	long tmp;
	long ans = 0;
	long min_i, max_i;
	
	sl(K); sl(S);
	
	for(X=0;X<=K;X++) {
		for(Y=0;Y<=K;Y++) {
			if(0 <= S-X-Y && S-X-Y <= K) {
				ans++;
			}
		}
	}
	
	pl(ans);
	
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int gcd(int x, int y) {
	if (x < y) gcd(y, x);
	if (y == 0) return x;
	return gcd(y, x % y);
}

int main()
{
	int A, B, C;
	cin >> A >> B >> C;
	if (C % gcd(A, B) == 0) cout << "YES" << endl;
	else cout << "NO" << endl;
}


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

int main(){
    ios_base::sync_with_stdio(false);
    int n,l,r;
    int ans = 0;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> l >> r;
        int x = r-l+1;
        ans = ans+x;
    }
    cout << ans << endl;
  return 0;
}

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

#define LL long long
#define reep(i,n,m) for(int i = n;i < m;i++)
#define rep(i,m) for(int i = 0;i < m;i++)
#define MAX_N 100000

using namespace std;

typedef struct node{
	int par;
	bool mark;
	node(){
		par = 0;
		mark = false;
	}
	node(int _par,int _mark){
		par = _par;
		mark = _mark;
	}
}node;

node field[MAX_N + 1];

int N,Q;

LL ans;

void init(){
	reep(i,0,MAX_N + 1){
		field[i].par = i;
		field[i].mark = false;
	}
	field[1].mark = true;

	return ;
}

int query(int n){
	//printf("###query to %d\n",n);
	if(field[n].mark) return n;
	return query(field[n].par);	
}

int main(){

	while(true){

	init();

	scanf("%d%d",&N,&Q);
	if(N == 0 && Q == 0) break;
	int _par;
	for(int i = 2;i <= N;i++){
		scanf("%d",&_par);
		field[i].par = _par;
	}
	ans = 0;
	char q;
	int node;
	rep(i,Q){
		scanf(" %c%d",&q,&node);
		//printf("###%c###%d\n",q,node);
		switch(q){
		case 'M':
			field[node].mark = true;
			break;
		case 'Q':
			ans += query(node);
			break;
		}
	}

	printf("%lld\n",ans);

	}

	return 0;
}

Measured memory_bytes: 1968
var i,n,min,max,x:longint;
begin
readln(n);
max:=-maxlongint;
min:=maxlongint;
for i:=1 to n do
        begin
        read(x);
        if x>max then max:=x;
        if x<min then min:=x;
        end;
writeln(max-min);
end.

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

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
    int n, m; cin >> n >> m;
    vector<int> pe(n + 1, 0);
    vector<bool> f(n + 1, false);
    int ac_count = 0, wa_count = 0;
    int p; string s;
    REP(i, m) {
        cin >> p >> s;
        if (s == "WA" && !f[p]) pe[p]++;
        else if (s == "AC" && !f[p]) { 
            ac_count++;
            f[p] = true;
        }
    }
    REP(i, n) if (f[i + 1]) wa_count += pe[i + 1];
    cout << ac_count << " " << wa_count << endl;
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <cctype>
#include <algorithm>
typedef long long LL;
const int N = 10000100,MOD = 998244353;
inline void up(int &x,int y){if((x += y) >= MOD) x -= MOD;}
inline int qpow(int a,int b)
{
    int r = 1;for(;b;b >>= 1)
    {
        if(b & 1) r = 1LL * r * a % MOD;
        a = 1LL * a * a % MOD;
    }
    return r;
}
int n,a,b;LL k;
int frc[N],inv[N];
inline int C(int m,int n)
{
    return 1LL * frc[n] * (1LL * inv[m] * inv[n - m] % MOD) % MOD;
}
int main()
{
    frc[0] = 1;for(int i = 1;i < N;i++) frc[i] = 1LL * frc[i - 1] * i % MOD;
    inv[N - 1] = qpow(frc[N - 1],MOD - 2);for(int i = N - 1;i;i--) inv[i - 1] = 1LL * inv[i] * i % MOD;
    scanf("%d%d%d%lld",&n,&a,&b,&k);
    int ans = 0;
    if(!b) std::swap(a,b);
    if(!b)
    {
        printf("%d\n",k ? 0 : qpow(4,n));
        return 0;
    }
    for(int i = 0,j;i <= n;i++)
    {
        LL re = k - 1LL * a * i;
        if(re < 0) break;
        if((re % b)) continue;
        j = re / b;
        if(j > n) continue;
        up(ans,1LL * C(i,n) * C(j,n) % MOD);
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 78336
#include<bits/stdc++.h>
using namespace std;
long long n,k,a[200001],ans=0;
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+n+1);
	for(int i=1;i<=n-k;i++)
		ans+=a[i];
	cout<<ans<<endl; 
	return 0;
} 

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

using namespace std;
const long long int maxx = 1e15L;
const int sz = 444;

long long dp[sz][sz], sum[sz][sz];
vector<long long > v;

long long f(int a, int b) {
    if (a == b) {
        return 0;
    }
    if (dp[a][b] != maxx) {
        return dp[a][b];
    }
    long long ans = maxx;
    for (int i = a; i < b; ++i) {
        ans = min(ans, f(a, i) + f(i+1, b) + sum[a][b]);
    }

    dp[a][b] = ans;
    return ans;
}


int main(void) {
    int n;
    cin>>n;
    for(int i = 0; i < n; ++i) {
        int x;
        cin>>x;
        v.push_back(x);
    }

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            dp[i][j] = maxx;
        }
    }

    for (int i = 0; i <= n-1; ++i) {
        for (int j = i; j <= n-1; ++j) {
            if (j == i) {
                sum[i][j] = v[i];
                continue;
            }
            sum[i][j] = sum[i][j-1] + v[j];
        }
    }

    cout<<f(0, n-1);

    // cout<<" table "<<endl;
    // for (int i = 0; i < n; ++i) {
    //     for (int j = 0; j < n; ++j) {
    //         cout<<dp[i][j]<< " ";
    //     }
    //     cout<<endl;
    // }

    return 0;
}



Measured memory_bytes: 3072
#include <iostream>
#include <vector>
#define INFTY 10000000
using namespace std;
int n,G[100][100];
int d[100],flag[100];
vector<int>path;
void dijkstra(){
    path.push_back(0);
    //int distance=0;
    int mini,min;
    while(path.size()<n){
        min=INFTY;
        int index=path.size()-1;
        //distance+=path[path.size()-1];
        for(int i=1;i<n;i++)
        {
            int temp=d[path[index]]+G[path[index]][i];
            if(d[i]>temp)
                d[i]=temp;
        }
        for(int i=1;i<n;i++)
        {
            if(flag[i])continue;
            if(d[i]<min)
            {
                min=d[i];
                mini=i;
            }
        }
        path.push_back(mini);
        flag[mini]=1;
        //distance+=path[path.size()-1];
    }
}
int main()
{
    int u,k,v,c;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        d[i]=INFTY;
        flag[i]=0;
        for(int j=0;j<n;j++)
            G[i][j]=INFTY;
    }
    for(int i=0;i<n;i++)
    {
        cin>>u>>k;
        for(int j=0;j<k;j++)
        {
            cin>>v>>c;
            G[u][v]=c;
        }
    }
    d[0]=0;
    dijkstra();
    for(int i=0;i<n;i++)
        cout<<i<<' '<<d[i]<<endl;
    return 0; 
}


Measured memory_bytes: 3132
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();


        System.out.println(c+ " " + a + " " + b);
    }
}

Measured memory_bytes: 21844
# python3.4.2用
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def lprint(l): print(*l, sep='\n')


X,Y = imn()

# 一回の移動でx座標とy座標の値は3増える。X+Yが3の倍数でないときは0
if (X+Y)%3 != 0:
    print(0)
    exit()
# M + 2N = X, 2M + N = Yの連立方程式が得られるので、M,Nを求める 
M = (2*Y-X)//3
N = (-2*M)+Y

# nCrをやる前に前準備を行う
MAX = 10**6
fact = [1,1]
factinv = [1,1]
inv = [0,1]
for i in range(2, MAX+1):
    fact.append((fact[-1]*i) % MOD)
    inv.append((-inv[MOD%i]*(MOD//i))%MOD)
    factinv.append((factinv[-1]*inv[-1])%MOD)

# nCrを求める
def cmb(n,r):
    if r < 0 or n < r:
        return 0
    r = min(r, n-r)
    return fact[n] * factinv[r] * factinv[n-r] % MOD 

print(cmb(M+N, M))



Measured memory_bytes: 124232
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
/*  
    int n; cin >> n;
      
    vector<string> s(n);
    rep(i,n){
        string a; cin >> a;
        s.push_back(a);
    }
    
    sort(all(s));
    vector<string> copy;
    copy = s;

    copy.erase(unique(all(copy)), copy.end());

    vector<int> cnt(copy.size());
    rep(i,copy.size()){
        cnt[i] = count(s.begin(), s.end(), copy[i]);
    }

    cnt.erase(cnt.begin());
    copy.erase(copy.begin());

    int max = (int)*max_element(all(cnt));

    rep(i,n){
        if(max == cnt[i]) cout << copy[i] << ln; 
    }

    return 0;
*/
    int n; cin >> n;
    map<string, int> mp;
    rep(i,n){
        string s; cin >> s;
        mp[s]++;
    }

    int mx = 0;
    for(auto p: mp) mx = max(mx, p.second);
    for(auto p: mp){
        if(p.second != mx) continue;
        cout << p.first << ln;
    }
}

Measured memory_bytes: 23808
n = int(input())
ans=0
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
b4 = 100000000
cn = 0
for i in range(n):
    ans+=b[i]
    #print(b4, a[i])
    if(b4==a[i]-1):
        ans+=c[b4-1]
        cn += 1

    b4 = a[i]
print(ans)


Measured memory_bytes: 3064
S = list(input())
N = len(S)
x,y = list(map(int,input().split()))

now = 1
YOKO = []
TATE = []
cnt=0
for i in range(N):
    if now==1:
        if S[i]=="F":
            cnt+=1
        elif S[i]=="T":
            if cnt!=0:
                YOKO.append(cnt)
            cnt=0
            now=-1*now
    elif now==-1:
        if S[i]=="F":
            cnt+=1
        elif S[i]=="T":
            if cnt!=0:
                TATE.append(cnt)
            cnt=0
            now=-1*now
if cnt>0:
    if now==1:
        YOKO.append(cnt)
    if now==-1:
        TATE.append(cnt)

NYOKO = len(YOKO)
NTATE = len(TATE)

dpYOKO = [0]*16001
dpTATE = [0]*16001
dpYOKO[0+8000]=1
dpTATE[0+8000]=1
if S[0]=="F":
    YOKOd = YOKO[1-1]
    newdp1 = [0]*16001
    for j in range(0,16001):
        if 0<=j-YOKOd:
            newdp1[j] = dpYOKO[j-YOKOd]
    dpYOKO = newdp1

    for i in range(2,NYOKO+1):
        YOKOd = YOKO[i-1]
        newdp1 = [0]*16001
        for j in range(0,16001):
            if (0<=j-YOKOd)and(j+YOKOd<=16000):
                newdp1[j] = max(dpYOKO[j-YOKOd],dpYOKO[j+YOKOd])
            elif (0<=j-YOKOd):
                newdp1[j] = dpYOKO[j-YOKOd]
            elif (j+YOKOd<=16000):
                newdp1[j] = dpYOKO[j+YOKOd]
        dpYOKO = newdp1
else:
    for i in range(1,NYOKO+1):
        YOKOd = YOKO[i-1]
        newdp1 = [0]*16001
        for j in range(0,16001):
            if (0<=j-YOKOd)and(j+YOKOd<=16000):
                newdp1[j] = max(dpYOKO[j-YOKOd],dpYOKO[j+YOKOd])
            elif (0<=j-YOKOd):
                newdp1[j] = dpYOKO[j-YOKOd]
            elif (j+YOKOd<=16000):
                newdp1[j] = dpYOKO[j+YOKOd]
        dpYOKO = newdp1

for i in range(1,NTATE+1):
    TATEd = TATE[i-1]
    newdp2 = [0]*16001
    for j in range(0,16001):
        if (0<=j-TATEd)and(j+TATEd<=16000):
            newdp2[j] = max(dpTATE[j-TATEd],dpTATE[j+TATEd])
        elif (0<=j-TATEd):
            newdp2[j] = dpTATE[j-TATEd]
        elif (j+TATEd<=16000):
            newdp2[j] = dpTATE[j+TATEd]
    dpTATE = newdp2

if dpYOKO[x+8000]==1 and dpTATE[y+8000]==1:
    print("Yes")
else:
    print("No")

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

int main()
{
    string S;
    while (cin >> S)
    {
        if (S == ".")
            return 0;
        int n = S.size();
        string T = "";
        int cnt = 0;
        for (int i = 0; i < n; i++)
        {
            if ('A' <= S[i] && S[i] <= 'Z')
            {
                if (cnt < 0)
                    cnt = (104 + cnt) % 26;
                S[i] = (S[i] - 'A' + cnt) % 26 + 'A';

                T += S[i];
                cnt = 0;
            }
            else if (S[i] == '+')
                cnt++;
            else if (S[i] == '-')
                cnt--;
            else if (S[i] == '?')
            {
                T += 'A';
                cnt = 0;
            }
            else
            {
                T += S[i];
                cnt = 0;
            }
        }
        n = T.size();
        stack<int> st;
        vector<pair<int, int>> v;
        for (int i = 0; i < n; i++)
        {
            if (T[i] == '[')
                st.push(i);
            else if (T[i] == ']')
            {
                v.push_back({st.top(), i});
                st.pop();
            }
        }
        for (auto p : v)
        {
            reverse(T.begin() + p.first + 1, T.begin() + p.second);
        }
        S = "";
        for (char c : T)
        {
            if (c == '[' || c == ']')
                continue;
            S += c;
        }
        cout << S << endl;
    }
}


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

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

int main() {

    int N;
    cin >> N;

    vector<int> A(N);

    rep(i,N){
        cin >> A[i];
    }

    double sum  = 0.0;
    
    rep(i,N){
        sum+=(1.0/(double)A[i]);
    }

    printf("%lf",1.0/sum);

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll h,n;
    cin>>h>>n;
    ll a,sum=0;
    rep(i,n){
        cin>>a;
        sum+=a;
    }
    cout<<(sum>=h?"Yes":"No")<<endl;
    return 0;
}

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

P_NUM = 1000000007


def solv(n, m, a):
    comb = [1] * (n+1)
    for i in a:
        comb[i] = 0

    for i in range(2, n+1):
        if comb[i] != 0:
            comb[i] = comb[i-1] + comb[i-2]

    return comb[-1]


if __name__ == '__main__':

    n, m = map(int, input().split())
    a = [int(input()) for _ in range(m)]

    ans = solv(n, m, a)

    print(ans % P_NUM)


Measured memory_bytes: 460020
//----------------------------------------------------------------------
// ITP1_2_B   Range
//----------------------------------------------------------------------

//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include <iostream>

//----------------------------------------------------------------------
// Definitions
//----------------------------------------------------------------------

//----------------------------------------------------------------------
// Entry point
//----------------------------------------------------------------------
int main()
{
    int a = 0, b = 0, c = 0;

    std::cin >> a >> b >> c;

    if( a < b && b < c )
    {
        std::cout << "Yes" << std::endl;
    }
    else
    {
        std::cout << "No" << std::endl;
    }

    return 0;
}

Measured memory_bytes: 3124