akhauriyash/Code-Regression huggingface dataset:
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 07/23/20 23:55:06
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int n,ma,mb; cin>>n>>ma>>mb;
  constexpr int MAX = 400;
  constexpr int INF = 1e9;
  array<array<int,MAX+1>,MAX+1> dp{};
  for (auto& v:dp) for (auto& vv:v) vv=INF;
  dp[0][0] = 0;
  for (int i = 0; i < n; i++) {
    int a,b,c; cin>>a>>b>>c;
    for (int j = MAX; j >= 0; j--) {
      for (int k = MAX; k >= 0; k--) {
        if (j-a<0 or k-b<0)
          continue;
        dp[j][k] = min(dp[j][k], dp[j-a][k-b]+c);
      }
    }
  }
  int mma = ma, mmb = mb;
  int ans = INF;
  while (max(mma,mmb) <= MAX) {
    ans = min(ans, dp[mma][mmb]);
    mma+=ma;
    mmb+=mb;
  }
  cout << (ans != INF ? ans : -1) << endl;

  return 0;
}


Measured memory_bytes: 4244
//package AtCoder.ABC157;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) {
        int[][] q = new int[3][3];
        for (int i=0;i<3;i++) for (int j=0;j<3;j++) q[i][j] = in.NI();
        int cou = in.NI();
        while (cou-->0) {
            int te = in.NI();
            for (int i=0;i<3;i++) for (int j=0;j<3;j++) {
                if (q[i][j]==te) q[i][j] = -1;
            }
        }

        int fl = 0;
        for (int i=0;i<3;i++) {
            if (q[i][0]==-1 && q[i][1]==-1 && q[i][2]==-1) fl = 1;
        }
        for (int j=0;j<3;j++) {
            if (q[0][j]==-1 && q[1][j]==-1 && q[2][j]==-1) fl = 1;
        }
        if (q[0][0]==-1 && q[1][1]==-1 && q[2][2]==-1) fl = 1;
        if (q[2][0]==-1 && q[1][1]==-1 && q[0][2]==-1) fl = 1;
        if (fl==1) {
            out.println("Yes");
        } else {
            out.println("No");
        }
        out.close();
    }

    static InputStream inputStream = System.in;
    static OutputStream outputStream = System.out;
    static InputReader in = new InputReader(inputStream);
    static PrintWriter out = new PrintWriter(outputStream);

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int NI() {
            return Integer.parseInt(next());
        }

        public long NL() {
            return Long.parseLong(next());
        }

    }
}

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

vector<string> s(20);
ll h,w;

int main() {
    
    std::cin >> h>>w;
    

    
    for (int i = 0; i < h; i++) {
        std::cin >> s[i];
    }
    
    ll ans = 0;
    
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if(s[i][j]=='#')continue;
            
            vector<vector<ll>> done(h,vector<ll>(w,-1));
            done[i][j]=0;
            
            queue<pair<pair<ll,ll>,ll>> q;
            
            q.push({{i,j},0});
            
            while(q.size()){
                auto now = q.front();q.pop();
                
                auto hh = now.first.first;
                auto ww = now.first.second;
                auto dis = now.second;
                
                for (int ii = hh-1; ii < hh+2; ii++) {
                    for (int jj = ww-1; jj < ww+2; jj++) {
                        if(abs(ii+jj-hh-ww)!=1)continue;
                        if(ii<0 || jj<0 || ii>=h || jj>=w)continue;
                        if(s[ii][jj]=='#')continue;
                        if(done[ii][jj]!=-1)continue;
                        done[ii][jj] = dis+1;
                        q.push({{ii,jj},dis+1});
                        ans = max(ans,dis+1);
                    }
                }
            }
        }
    }
    
    std::cout << ans << std::endl;
}

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

long long cnt;
vector<int> G;
int A[1000000];

void insertionSort(int A[],int n,int x)
{
    int t;
    for(int i=0; i<x; i++)
    {

        for(int j=i+x; j<n; j=j+x)
        {
            int k=j;
            while(k-x>=0&&A[k]<A[k-x])
            {
                t=A[k];
                A[k]=A[k-x];
                A[k-x]=t;
                k=k-x;
                cnt++;
            }
        }

    }
}
void shellSort(int A[],int n)
{

    for(int h=1; h<=n; h=3*h+1)
    {
        G.push_back(h);
    }
    for(int i=G.size()-1; i>=0; i--)
    {
        insertionSort(A,n,G[i]);
    }
}

void print(int A[],int n)
{
    for(int i=0; i<n; i++)
        cout<<A[i]<<endl;
}



int main()
{
    cnt=0;
    int n;
    cin>>n;
    for(int i=0; i<n; i++)
        cin>>A[i];
    shellSort(A,n);

    cout<<G.size()<<endl;
    for(int i=G.size()-1; i>0; i--)
        cout<<G[i]<<" ";
    cout<<G[0]<<endl;
    cout<<cnt<<endl;
    print(A,n);
    return 0;

}



Measured memory_bytes: 7072
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;

#define rep(i, n) for(ll i = 0; i < (int)(n); i++)
#define reps(i,x) for(ll i=1;i<=(int)(x);i++)
#define rrep(i,x) for(ll i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=((int)(x) - 1 * 100);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define mp make_pair
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
using namespace std;
ll n, m;

int main() {
	cin >> n;
	ll ans;
	ans = n / 11 * 2;
	n %= 11;
	if (n > 6)
		ans += 2;
	else if (n % 6 || n == 6)
		ans += 1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//Author: Fuadul Hasan(fuadul202@gmail.com)
//BSMRSTU,Gopalganj
#include<bits/stdc++.h>
using namespace std;int tc = 1;
#define happy ios::sync_with_stdio(false);
#define coding  cin.tie(0);
#define mp make_pair
#define ll long long
#define Pi atan(1)*4
#define pb  push_back
#define vpr vector<pr> 
#define pr pair<int, int> 
#define vi std::vector<int>
#define vll std::vector<ll>
#define YES printf("YES\n");
#define NO printf("NO\n");
#define Yes printf("Yes\n");
#define No printf("No\n");
#define all(n) n.begin(),n.end()
#define point(x) setprecision(x)
#define Test printf("Case %d: ",tc++);
#define Unique(c) (c).resize(unique(all(c))-(c).begin())

const int M = 1e9 + 7;
const ll  Inf = (ll)2e18 + 5;
const int N   = 2e5 + 5;
int dp[N];
int solve() 
{
	//happy coding

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

	dp[1] = 0;
	dp[2] = abs(a[2]-a[1]);
	///cout<<dp[2]<<endl;
	for(int i=3;i<=n;i++){
		//cout<<dp[i-1]+(abs(a[i-1]))<<" "<<dp[i-2]+(abs(a[i-2]-a[i]))<<endl;
		dp[i] = min(dp[i-1]+(abs(a[i-1]-a[i])),dp[i-2]+(abs(a[i-2]-a[i])));
		//cout<<dp[i]<<" ";
	}

	cout<<dp[n]<<endl;

	
	return 0;
}
int main(){
	int test = 1;
	//scanf("%d", &test);
	while (test--)solve();return 0;
}

Measured memory_bytes: 1024
// B - 1 Dimensional World's Tale
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int main(){
	int N,M,X,Y; cin>>N>>M>>X>>Y;
	vi XX(N+1); rp(i, 0, N) cin>>XX[i]; XX[N]=X;
	vi YY(M+1); rp(i, 0, M) cin>>YY[i]; YY[M]=Y;
	sort(all(XX)); sort(all(YY));
	puts(XX[N]<YY[0]? "No War":"War");
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
int main(){
	int a,b,i,keta,waru;
	while(cin>>a>>b){
		keta=0;
		waru=1;
		while(1){
			if((a+b)/waru*10!=0){
				keta++;
				waru=waru*10;
				}
			else break;
			}
		cout<<keta<<endl;
		}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 2e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    string s;
    cin >> s;
    int len = s.size();
    if (len <= 4 || 10 <= len ){
        cout << "NO" << endl;
        return 0;
    }

    for (int i = 0; i < (1 << (len + 1)); i++) {
        string ans;
        for (int j = 0; j < len + 1; j++) {
            if (i & (1 << j)) {
                ans += 'A';
            }
            if (j != len) ans += s[j];
        }
        if (ans == "AKIHABARA") {
            cout << "YES" << endl;
            return 0;
        }
    }

    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using std::cin;
using std::cout;
using std::endl;
using std::ceil;
using std::max;

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

    long long t = 1, a = 1;
    for (int i = 0; i < n; ++i) {
        long long T, A;
        cin >> T;
        cin >> A;
        // 投票数がt:aとなる最小の自然数kを探す
        // 投票数T, Aは T:A = k * t : k * a
        // 　　　　　　　→ k =

        long long k = max((t + T - 1) / T, (a + A - 1) / A);
        t = k * T;
        a = k * A;
    }

    cout << t + a << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(void){
    int N,X,m[110],i;
    cin>>N>>X;
    int remain=X,count=0;
    for(i=0;i<N;i++){
        cin>>m[i];
        remain-=m[i];
        count++;
    }
    int min=m[0];
    for(i=1;i<N;i++){
        if(min>m[i])min=m[i];
    }
    while(remain>=0){
        remain-=min;
        count++;
    }
    cout<<count-1;
    return 0;
}

Measured memory_bytes: 256
//Author: Fuadul Hasan(fuadul202@gmail.com)
//BSMRSTU,Gopalganj
#include<bits/stdc++.h>
using namespace std;int tc = 1;
#define happy ios::sync_with_stdio(false);
#define coding  cin.tie(0);
#define F first
#define S second
#define mp make_pair
#define ll long long
#define Pi atan(1)*4
#define pb  push_back
#define vpr vector<pr> 
#define pr pair<int, int> 
#define vi std::vector<int>
#define vll std::vector<ll>
#define YES printf("YES\n");
#define NO printf("NO\n");
#define Yes printf("Yes\n");
#define No printf("No\n");
#define all(n) n.begin(),n.end()
#define point(x) setprecision(x)
#define Test printf("Case %d: ",tc++);
#define Unique(c) (c).resize(unique(all(c))-(c).begin())
#define vout(v) for (auto z: v) cout << z << " "; cout << endl;

#define error(args...) {vector<string>_v=split(#args,',');err(_v.begin(),args);cout<<endl;}
vector<string> split(const string &s, char c) {vector<string>v; stringstream ss(s); string x;
while (getline(ss, x, c))v.emplace_back(x); return move(v);} void err(vector<string>::iterator it) {}
template<typename T, typename... Args>void err(vector<string>::iterator it, T a, Args...args) {
cout << it->substr((*it)[0] == ' ', it->length()) << " = " << a << " "; err(++it, args...);}

const int M = 1e9 + 7;
const ll  Inf = (ll)2e18 + 5;
const int N   = 2e5 + 5;
ll vis[N],res[N];

int solve() 
{
	//happy coding

	int n;
	cin>>n;
	int a[n],b[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
		b[i] = a[i];
	}
	sort(a,a+n);

	int cnt = 0;
	for(int i=0;i<n;i++){
		if(b[i]!=a[i]){
			cnt++;
		}
	}

	if(cnt==2||cnt==0){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}


	
	return 0;
}
int main(){
	int test = 1;
  	//scanf("%d", &test);
  	while (test--)solve();return 0;
}

Measured memory_bytes: 256
def calc():
  n,ma,mb=map(int,input().split())
  dp=[[0]*401 for _ in range(401)]
  for _ in range(n):
    a,b,c=map(int,input().split())
    for i in range(400,-1,-1):
      for j in range(400,-1,-1):
        if i-a<0 or j-b<0:
          continue
        else:
          if dp[i-a][j-b]==0:
            continue
          else:
            if dp[i][j]==0:
              dp[i][j]=dp[i-a][j-b]+c
            else:
              dp[i][j]=min(dp[i][j],dp[i-a][j-b]+c)
    if dp[a][b]==0:
      dp[a][b]=c
    else:
      dp[a][b]=min(dp[a][b],c)
  ans=10**10
  for i in range(401):
    if i*ma>400 or i*mb>400:
      break
    if dp[i*ma][i*mb]==0:
      continue
    else:
      ans=min(ans,dp[i*ma][i*mb])
  if ans==10**10:
    print(-1)
  else:
    print(ans)
    
calc()

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

int main(){
	int n,m;
	int a[100][100]={0},b[100]={0},c[100]={0};
	cin>>n>>m;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
		cin>>a[i][j];	
			}
	}
	for(int i=0;i<m;i++){
		cin>>b[i];
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			c[i]+=a[i][j]*b[j];
		}
	}
	for(int i=0;i<n;i++){
		cout<<c[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 3156
def power_socket(a, b)
  return 0 if b == 1
  return 1 if b <= a
  ans = 1
  sum = a
  while sum < b
    sum += a - 1
    ans += 1
  end

  ans
end

a, b = gets.split.map(&:to_i)
puts power_socket(a, b)

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

public class Solution
{
    static long Search(long ok, long ng)
    {
        while (Math.Abs(ok - ng) > 1)
        {
            var mid = (ok + ng) / 2;
            if (Solve(mid))
            {
                ok = mid;
            }
            else
            {
                ng = mid;
            }
        }
        return ok;
    }

    static bool Solve(long score)
    {
        var k = K;
        for (int i = 0; i < N; i++)
        {
            if (A[i] * F[i] > score)
            {
                var need = A[i] - (int)Math.Floor(score / (double)F[i]);
                if (need > 0)
                {
                    k -= need;
                    if (k < 0)
                    {
                        return true;
                    }
                }
            }
        }

        return false;
    }

    static int N;
    static long K;
    static long[] A;
    static long[] F;

    public static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        N = (int)vals[0];
        K = vals[1];
        A = Console.ReadLine().Split(' ').Select(long.Parse).OrderBy(x => x).ToArray();
        F = Console.ReadLine().Split(' ').Select(long.Parse).OrderByDescending(x => x).ToArray();

        var max = Enumerable.Range(0, N).Max(i => A[i] * F[i]);
        var min = Search(-1, max + 1) + 1;

        Console.WriteLine(min);
    }
}

Measured memory_bytes: 49912
from sys import stdin

input = stdin.readline
mi = lambda: map(int, input().split())
lmi = lambda: list(mi())
si = lambda: input().strip('\n')
ii = lambda: int(input())


n = int(input())
arr = [0 for i in range(n+1)]
nums = lmi()
for i in range(n):
    arr[nums[i]] = i+1
print(*arr[1:])

Measured memory_bytes: 14676
import sys
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
N, M = [int(x) for x in input().strip().split()]
A = [int(x) for x in input().strip().split()]
S = sum(A)
C = len([a for a in A if a >= S / (4*M)])
if C >= M:
    print('Yes')
else:
    print('No')

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

// Problem https://atcoder.jp/contests/abc086/tasks/arc089_a

bool solver(long int visitTime,vector<long int> t,vector<long int> x,vector<long int> y){
    bool result;
    result=true;
    for(long int j=1;j<visitTime+1;j++){
        // 移動時間より距離が短いかを調べる
        long int  dist,movetime;
        dist = abs(x.at(j)-x.at(j-1))+abs(y.at(j)-y.at(j-1));
        movetime = t.at(j)-t.at(j-1);
        if(movetime < dist){
            result=false;
            break;
        } // 移動時間の割には距離が長い場合はNG

        // 移動時間の偶奇が移動距離の偶奇が一致しているか確認
        // -> 1秒で1マス移動,2秒で2マス移動を考慮すると
        // 偶奇がそれぞれ異なる事は無い
        if((movetime%2) != (dist%2)){
            result=false;
            break;
        }

    }
    // 全部の移動に対して2つのポイントを満たしていれば最初に設定したtrueになる
    return result;
}

int main(void){
    bool answerside;
    answerside=false;
    long int N;
    cin >> N;
    vector<long int> t(N+1,0);
    vector<long int> x(N+1,0);
    vector<long int> y(N+1,0);
    for(int long j=1;j<N+1;j++){
        cin >> t.at(j) >> x.at(j) >> y.at(j);
    }
    answerside = solver(N,t,x,y);
    if(answerside){
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 4992
N = int(input())
H = list(map(int, input().split()))

max_H = H[0]
L = [1 for i in range(N)]
for i in range(1, N):
    if H[i] >= max_H:
        L[i] = 1
    else:
        L[i] = 0
    max_H = max(H[i], max_H)

print(sum(L))


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<queue>
#include<iomanip>
#include<math.h>
#include<bitset>
#include<cassert>
#include<random>
#include<time.h>
#include<functional>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

class BIT {
private:
	ll N;
	ll bit[303030];
public:
	BIT(ll N) : N(N) {
		REP(i, 303030) bit[i] = 0;
	}

	void add(ll a, ll w) {
		a++;
		for (ll x = a; x <= N; x += x & -x) bit[x] += w;
	}

	ll sum(ll a) {
		a++;
		ll ret = 0;
		for (ll x = a; x > 0; x -= x & -x) ret += bit[x];
		return ret;
	}

	ll sum(ll a, ll b) {
		ll ret = sum(b - 1);
		if(a) ret -= sum(a - 1);
		return ret;
	}
};

ll _pow(ll a, ll n) {
	if(n==0) return 1;
	else {
		ll res = 1;
		ll buf = a;
		while(n>0) {
			if(n%2==1) {
				res *= buf;
				res %= MOD;
			}
			buf *= buf;
			buf %= MOD;
			n/=2;
		}
		return res;
	}
}

/* --------------------------------------- */

ll n, d, x;
// return dCk
ll comb(ll k) {
	ll ret = 1;
	REP(i, k) {
		ret *= (d - i) % MOD; ret %= MOD;
	}
	REP(i, k) {
		ret *= _pow(k - i, MOD - 2); ret %= MOD;
	}
	return ret;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	while(1) {
		cin >> n >> d >> x;
		if(n == 0 && d == 0 && x == 0) break;
		BIT bit(n + 10);
		vector<ll> cnt(n + 1, 0);
		bit.add(0, 1);
		REP(i, n) {
			for(ll j = n; j >= 0; j--) {
				bit.add(j, -bit.sum(j, j + 1));
				bit.add(j, (bit.sum(max(j - x + 1, 0ll), j) % MOD));
			}
			cnt[i + 1] = bit.sum(n, n + 1);
		}
		ll ans = 0;
		for(ll i = 1; i <= n; i++) {
			ans += comb(i) * cnt[i]; ans %= MOD;
		}
		cout << ans << endl;
	}
 	return 0;
}

/* --------------------------------------- */




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

using namespace std;

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

    vector<int> vt(N);
    for (int i = 0; i < N; ++i) {
        cin >> vt[i];
    }

    int ans = 0;
    for (int left = 0; left <= N; ++left) {// 左からleft個取る
        for (int right = 0; left + right <= min(N, K); ++right) {// 右からright個とる
            vector<int> w;
            w.reserve(left + right);
            for (int i = 0; i < left; ++i) w.push_back(vt[i]);
            for (int i = 0; i < right; ++i) w.push_back(vt[N - 1 - i]);
            sort(w.begin(), w.end());

            for (int i = 0; i < min<int>(w.size(), K - left - right); ++i)
                if (w[i] < 0) w[i] = 0;
            ans = max(ans, accumulate(w.begin(), w.end(), 0));
        }
    }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) 				for(int i=0; i<(n); ++i)
#define all(c) 					(c).begin(),(c).end()
#define sortall(x)              sort(all(x))
#define tr(c,i) 				for( typeof( (c).begin() ) i = (c).begin();  i != (c).end(); ++i)
#define pb 						push_back
#define sz(a) 					int((a).size())
#define mp                      make_pair
#define ll                      long long
#define F                       first
#define S                       second
#define PI                      3.1415926535897932384626
// Input macros
#define s(n)                    scanf("%d",&n)
#define sc(n)                   scanf("%c",&n)
#define sl(n)                   scanf("%lld",&n)
#define sf(n)                   scanf("%lf",&n)
#define ss(n)                   scanf("%s",n)

// Others
#define test(t) 				int t; cin>>t; while(t--)
#define endl 					"\n"

using namespace std;

typedef pair<int, int> 			pii;
typedef pair<ll, ll> 	        pll;
typedef vector<int> 			vi;
typedef vector<ll>              vl;

// const int mod = 1000000007;
// const int INF = 1e9+5;

int main(){
	
     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

     ll n;
     cin>>n;
     
     vector<ll> heights(n,0);
     
     for( int i=0 ; i<n ; i++ ){
		 cin >> heights[i];
	 }
	 
	 ll ans=0;
	 ll m_height = heights[0];
	 
	 // 4 4 5 6 2
	 
	 for(int i=1 ; i<n ; i++){
		  if(m_height > heights[i]){
			ans+=m_height - heights[i];
			heights[i] = m_height;
		  }else{
			  m_height = heights[i];
		  }
		}
	
	cout<<ans<<endl;
}


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

int n,m,q;
vector<int> a,b,c,d;
int ans = 0;

void dfs(vector<int> A){
  if(A.size()==n+1){
    int sum = 0;
    for (int i = 0; i < q; i++)
    {
      if(A[b[i]]-A[a[i]] == c[i]) sum+=d[i];
    }
    ans = max(ans,sum);
    return;
  }
  A.push_back(A.back());
  while(A.back()<=m){
    dfs(A);
    A.back()++;
  }
}

int main(){
  cin >> n >> m >> q;
  a = b = c = d = vector<int>(q);
  for (int i = 0; i < q; i++) cin >> a[i] >> b[i] >> c[i] >> d[i];

  dfs(vector<int>(1,1));
  cout << ans << endl;    
}

Measured memory_bytes: 3612
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let D: usize = sc.get();
    let c: Vec<i64> = sc.vec(26);
    let s: Vec<Vec<i64>> = sc.mat(D, 26);
    let mut last = vec![0; 26];
    let mut ans = Vec::new();
    for d in 0..D {
        let mut max_score_d = 0;
        let mut max_t = 0;
        for t in 0..26 {
            let mut score_d = 0;
            score_d += s[d][t];
            last[t] = d as i64 + 1;
            for i in 0..26 {
                score_d -= c[i] * (d as i64 + 1 - last[i]);
            }
            if max_score_d < score_d {
                max_score_d = score_d;
                max_t = t;
            }
        }
        ans.push(max_t);
    }
    for d in 0..D {
        println!("{}", ans[d] + 1);
    }
}


Measured memory_bytes: 2224
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;

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

int main(){
    //freopen("in.txt", "r", stdin);
    int K; cin>>K;
    string ans;
    for(int i=0; i<K; i++){
        ans += "ACL";
    }
    cout<<ans<<endl;

    return 0;
}





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

int main() {
  int n;
  string c;
  cin >> n >> c;
  int red = 0;
  for (char r : c) {
    if (r == 'R') red++;
  }
  int ans = 0;
  for (int i = 0; i < red; i++) {
    if (c[i] == 'W') ans++;
  }

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

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

n = int(input())
h = list(map(int, input().split()))
dp = [10001 for _ in range(n)]

dp[0] = 0 
dp[1] = abs(h[1]-h[0])

for i in range(2,n):
    dp[i] = min(dp[i-2] + abs(h[i]-h[i-2]), dp[i-1] + abs(h[i]-h[i-1]))

print(dp[n-1])


Measured memory_bytes: 13976
#include <cstdio>
using namespace std;
int N, M, cnt[2][100001], AC, WA;
int main() {
  scanf("%d %d", &N, &M);
  int p; char S[2];
  for(int i = 0; i < M; ++i) {
    scanf("%d %s", &p, &S);
    if(S[0] == 'A') ++cnt[0][p];
    else if(cnt[0][p] == 0) ++cnt[1][p];
  }
  for(int i = 1; i <= N; ++i) {
    if(cnt[0][i] > 0) ++AC, WA+=cnt[1][i];
  }
  printf("%d %d\n", AC, WA);
}

Measured memory_bytes: 896
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
import cmath
pi = cmath.pi
exp = cmath.exp

def fft(a, inverse=False):
    n = len(a)
    h = n.bit_length() - 1

    # Swap
    for i in range(n):
        j = 0
        for k in range(h):
            j |= (i >> k & 1) << (h - 1 - k)
        if i < j:
            a[i], a[j] = a[j], a[i]

    # Butterfly calculation
    if inverse:
        sign = 1.0
    else:
        sign = -1.0
    b = 1
    while b < n:
        for j in range(b):
            w = exp(sign * 2.0j * pi / (2.0 * b) * j)
            for k in range(0, n, b*2):
                s = a[j + k]
                t = a[j + k + b] * w
                a[j + k] = s + t
                a[j + k + b] = s - t
        b *= 2

    if inverse:
        for i in range(n):
            a[i] /= n

    return a

def ifft(a):
    return fft(a, inverse=True)

def convolve(f, g):
    n = 2**((len(f) + len(g) - 1).bit_length())
    f += [0] * (n - len(f))
    g += [0] * (n - len(g))
    F = fft(f)
    G = fft(g)
    FG = [Fi * Gi for Fi, Gi in zip(F, G)]
    fg = [int(item.real + 0.5) for item in ifft(FG)]
    return fg

if __name__ == "__main__":
    n, m = map(int, input().split())
    a = [int(item) for item in input().split()]
    max_a = max(a)
    freq = [0] * (max_a + 1)
    for item in a:
        freq[item] += 1
    f = freq[:]; g = freq[:]
    fg = convolve(f, g)
    total = sum(a) * n * 2
    cnt = n * n - m
    for i, item in enumerate(fg):
        use = min(cnt, item)
        total -= i * use
        cnt -= use
        if cnt == 0:
            break
    print(total)

Measured memory_bytes: 130616
import java.util.*;

public class Main {

	static final int INF = Integer.MAX_VALUE/2;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		
		long min = Long.MAX_VALUE/2;
		for(int i=0;i<5;i++) {
			long t = sc.nextLong();
			min = Math.min(min, t);
		}
		sc.close();
		
		long ans = (n+min-1)/min;
		System.out.println(ans - 1 + 5);
	}
}

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

using namespace std;

int main() {
    multimap<string, int> mmp;

    int q;
    cin >> q;
    while (q--) {
        int op;
        string key;
        cin >> op;
        if (op == 0) {
            int x;
            cin >> key >> x;
            mmp.insert(make_pair(key, x));
        } else if (op == 1) {
            cin >> key;
            for (auto it = mmp.lower_bound(key); it != mmp.upper_bound(key); ++it) {
                cout << it->second << endl;
            }
        } else if (op == 2) {
            cin >> key;
            mmp.erase(key);
        } else {
            string l, r;
            cin >> l >> r;
            for (auto it = mmp.lower_bound(l); it != mmp.upper_bound(r); ++it) {
                cout << it->first << " " << it->second << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 24892
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		double r = 0;

		Scanner in = new Scanner(System.in);

		r = in.nextDouble();

		double a =  r * r * Math.PI;
		double b =  2 * r * Math.PI;

		String A =  String.format("%f", a);
		String B =  String.format("%f", b);

		System.out.println(A + " " + B);

	}

}

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

int main() {
    string S, T;
    bool a;
    a = false;
    cin >> S >> T;
    for (int i = 0; i < S.size(); i++){
        if(S.at(i) != T.at(i))a = true;
    }
    if(a) cout << "No" << endl;
    else  cout << "Yes" << endl;
}


Measured memory_bytes: 3584
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        int n = 0;
        char[] s = null;
        boolean scansucceed = false;
        try (Scanner scanner = new Scanner(System.in)) {
            n = Integer.parseInt(scanner.nextLine());
            s = scanner.nextLine().toCharArray();
            scansucceed = true;
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (!scansucceed)
            System.exit(0);
        int result = 0;
        int src = 0;
        for (int length = 1;; length++) {
            boolean found = false;
            outerloop: for (; src <= s.length - length; src++) {
                for (int dst = src + length; dst <= s.length - length; dst++) {
                    if (submatch(s, src, dst, length)) {
                        found = true;
                        break outerloop;
                    }
                }
            }
            if (!found) {
                break;
            }else{
                result++;
            }
        }
        System.out.println(result);
    }

    private static boolean submatch(char[] str, int src, int dst, int length) {
        boolean result = true;
        for (int i = 0; i < length; i++) {
            result &= str[src + i] == str[dst + i];
            if (!result)
                break;
        }
        return result;
    }
}

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

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

  vector<int> p(n);
  vector<int> q(n);
  for (int i = 0; i < n; i++) { cin >> p.at(i); }
  for (int i = 0; i < n; i++) { cin >> q.at(i); }

  vector<int> order(n);
  for (int i = 0; i < n; i++) { order.at(i) = i+1; }

  map<vector<int>, int> mp;
  do {
    mp[order] = mp.size();
  } while (next_permutation(order.begin(), order.end()));

  cout << abs(mp.at(p) - mp.at(q)) << endl;
  return 0;
}


Measured memory_bytes: 8676
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i ++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i ++)
#define MP make_pair

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int INF = 1e9 + 7;

multiset<int> S;

int main()
{
	int n, x;
	scanf("%d", &n);
	rep(i, n) {
		scanf("%d", &x);
		S.insert(x);
	}
	int ans = 0;
	while(!S.empty()) {
		multiset<int>::iterator it = S.end();
		int cur = *(--it);
		S.erase(it);
		if(S.empty()) continue;
		int sum = 1;
		for(; sum <= cur; sum <<= 1); 
		it = S.find(sum - cur);
		if(it != S.end()) {
			S.erase(it);
			ans ++;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 9600
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
typedef pair<LL, LL> P;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQ(c)     (c).erase(unique(ALL((c))),(c).end())
# define mp          make_pair
# define eb          emplace_back
# define FOR(i,a,b)  for(int i=(a);i<(b);i++)
# define RFOR(i,a,b) for(int i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

int n;
LL x[101], y[101];

int main() {
	cin >> n;
	REP(i, n)cin >> x[i] >> y[i];
	REP(i, n) {
		vector<double>angle;
		REP(j, n)if (i != j)angle.emplace_back(atan2(y[j] - y[i], x[j] - x[i]));
		sort(ALL(angle));
		double maxl = 0;
		REP(j, angle.size()-1)maxl = max(maxl, angle[j + 1] - angle[j]);
		maxl = max(maxl, angle[0] - angle[angle.size() - 1] + 2 * PI);
		double ans = (maxl > PI ? (maxl - PI) / (2 * PI) : 0.0);
		cout << fixed << setprecision(15) << ans<<endl;
	}
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <cmath>
using namespace std;
using ll = long long;
#define REP(i, n) for(int i = 0; i < n; ++i)
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1LL << 60;
constexpr int MAX = 22;


vector<int> e;
int main() {
	long double a, b;
	cin >> a >> b;
	cout << (long long)floor(a * b) << endl;
	return 0;
}

Measured memory_bytes: 3720
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int q = sc.nextInt();
    int[] a = new int[n];
    Arrays.fill(a, 1000000);
    int index = 0;
    String s = sc.next();
    int[] l = new int[q];
    int[] r = new int[q];
    for(int i = 0; i < q; i++){
      l[i] = sc.nextInt();
      r[i] = sc.nextInt();
    }
    for(int i = 0; i < n-1; i++){
      char c = s.charAt(i);
      if(c == 'A' && s.charAt(i + 1) == 'C'){
        a[index] = i; 
        index++;
        i++;
      }
    }
    Arrays.sort(a);
    for(int i = 0; i < q; i++){
      int start = Arrays.binarySearch(a, l[i] - 1);
      int end = Arrays.binarySearch(a, r[i] - 1);
      if(start < 0){
        start = ~start;
      }
      if(end < 0){
        end = ~end;
      }
      System.out.println(end - start);
    }
  }
}

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

using namespace std;

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    long long n,m;
    cin>>n>>m;
    if(n==m)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    
    return 0;
}


Measured memory_bytes: 256
require 'set'; require 'prime'
INF=Float::INFINITY; MOD=10**9+7
n = gets.chomp.to_i
a = []
n.times do |i|
  city, num = gets.chomp.split
  a.push [i+1, city, num.to_i]
end

j = 0
a.sort_by{|i,x,y| -y}.sort_by{|i,x,y| [x, j+=1]}.each do |i,x,y|
  puts i
end


Measured memory_bytes: 2300
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define print(x) cout<<(x)<<endl
#define INF10 1001001001 
#define INF5 100000
#define EPS 1e-10


int main() {
	int n; cin >> n;
	string s; cin >> s;
	if (n >= 3200) cout << s << endl;
	else cout << "red" << endl;


	return 0;
}


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

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			//[summary]C - Back and Forth
			var line = ReadLine();
			int sx = line[0];
			int sy = line[1];
			int tx = line[2];
			int ty = line[3];

			string forward = new String('U', ty - sy) + new String('R', tx - sx);
			string back = GetWayBack(forward);
			string route = forward + back;
			
			forward = "L" + new String('U', ty - sy + 1) + new String('R', tx - sx + 1) + "D";
			back = GetWayBack(forward);
			route += forward + back;
			
			Console.WriteLine(route);
		}
		
		static string GetWayBack(string forward)
		{
		    string s = "";
		    
		    foreach(var c in forward)
		    {
		        switch(c)
		        {
		            case 'U':
		                s += "D";
		                break;
		            case 'D':
		                s += "U";
		                break;
		            case 'R':
		                s += "L";
		                break;
		            case 'L':
		                s += "R";
		                break;
		        }    
		    }
		    
		    return s;
		}

		static List<int> ReadLine()
		{
			var line = Console.ReadLine();
			var array = line.Split(' ');

			return array.Select(x => int.Parse(x)).ToList();
		}
	}
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}
int h,w;
char fld[25][25];
int mvx[] = {-1,0,0,1};
int mvy[] = {0,-1,1,0};
int bfs(int sy, int sx, int gy, int gx){
  if(fld[sy][sx] == '#' ||
     fld[gy][gx] == '#') return -1;
  int cnt[25][25];
  bool visit[25][25]={};
  cnt[sy][sx] = 0;
  visit[sy][sx] = 1;
  queue<P<int,int>> que;
  que.push({sy,sx});
  while(!que.empty()){
    int ny = que.front().first;
    int nx = que.front().second;
    if(ny == gy && nx == gx) return cnt[gy][gx];
    que.pop();
    visit[ny][nx] = 1;
    for(int i = 0; i < 4; ++i){
      int y = ny + mvy[i];
      int x = nx + mvx[i];
      if(y < 0 || y >= h)continue;
      if(x < 0 || x >= w)continue;
      if(fld[y][x] == '#')continue;
      if(visit[y][x])continue;
      visit[y][x] = 1;
      cnt[y][x] = cnt[ny][nx] + 1;
      que.push({y,x});
    }
  }
  return -1;
}
int main(){
  cin >> h >> w;
  for(int i = 0; i < h; ++i){
    for(int j = 0; j < w; ++j){
      cin >> fld[i][j];
    }
  }
  int ans = 0;
  for(int i = 0; i < h; ++i){
    for(int j = 0; j < w; ++j){
      for(int k = 0; k < h; ++k){
	for(int l = 0; l < w; ++l){
	  ChangeMax(ans,bfs(i,j,k,l));
	}
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();scan.nextLine();
		String[] s = new String[n];
		for (int i = 0; i < n; i++) {
			s[i] = scan.nextLine();
		}
		for (int i = 0; i < n-1; i++) {
			char c = s[i].charAt(s[i].length()-1);
			if (c != s[i+1].charAt(0)) {
				//System.out.println(c + "" + s[i+1].charAt(0));
				System.out.println("No");
				return;
			}
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (s[i].equals(s[j]) && i != j) {
					System.out.println("No");
					return;
				}
			}
		}
		System.out.println("Yes");
	}
}


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

int main() {
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	ll ans = 0;
	ans += b / c - (a - 1) / c;
	ans += b / d - (a - 1) / d;
	ll e = c * d / __gcd(c, d);
	ans -= b / e - (a - 1) / e;
	cout << b - a + 1 - ans;
}

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


int main()
{
    int n;
    double m=0.0,b,a;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a;
        b=1/a;
        m+=b;
    }
    cout << fixed << setprecision(8) << 1/m << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
    
int main(){
    int n;
    cin >> n;
    int ac=0, wa=0, tle=0,re=0;
    rep(i,n){
        string s;
        cin >> s;
        if(s == "AC") ac ++;
        else if(s == "WA") wa ++;
        else if(s == "TLE") tle ++;
        else re ++;
    }

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

}

Measured memory_bytes: 3640
n=int(input())
abc_li=[0]*26
S=input()
for i in range(len(S)):
    abc_li[ord(S[i])-97]+=1

for i in range(n-1):
    S=input()
    tmp_abc_li=[0]*26
    for j in range(len(S)):
        tmp_abc_li[ord(S[j])-97]+=1
    for k in range(26):
        abc_li[k]=min(abc_li[k],tmp_abc_li[k])

ans=''
for i in range(26):
    if abc_li[i]>0:
        ans=ans+(chr(i+97)*abc_li[i])
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  double a, b, c;
  int d;
  string s, t;
  cin >> a;
  d=(a+1)/2;
  c=d/a;
  co(c);
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using  namespace std;
int n,a,b,c;
string s[100005];
char ans[100005];

bool ok;
void dfs(int ind,int a,int b,int c){
	if(a<0 || b<0 || c<0) return;
	if(ind==n){
		puts("Yes");
		for(int i = 0;i < n;i++){
			cout<<ans[i]<<endl;
		}
		exit(0);
	}
	else{
		if(s[ind]=="AB"){
			ans[ind]='A';
			dfs(ind+1,a+1,b-1,c);
			ans[ind]='B';
			dfs(ind+1,a-1,b+1,c);
		}
		else if(s[ind]=="AC"){
			ans[ind]='A';
			dfs(ind+1,a+1,b,c-1);
			ans[ind]='C';
			dfs(ind+1,a-1,b,c+1);
		}
		else{
			ans[ind]='B';
			dfs(ind+1,a,b+1,c-1);
			ans[ind]='C';
			dfs(ind+1,a,b-1,c+1);
		}
	}
	
}
int main(){
	cin>>n>>a>>b>>c;
	
	for(int i = 0;i<n;i++) cin>>s[i];
	dfs(0,a,b,c);
	
		puts("No");
	
	return 0;
}

Measured memory_bytes: 14648
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;

public class Main {



    private static final Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
       String s = sc.next();
       if (s.equals("ABC") )
       System.out.println("ARC");
       else 
       System.out.println("ABC");

        //scanner.close();
    }
}


Measured memory_bytes: 35436
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder.ABC112.B
{
    class Program
    {
        static void Main()
        {
            var sc = new Scanner();
            var n = sc.Nextint();
            var T = sc.Nextint();
            var c = new int[n];
            var t = new int[n];
            for (int i = 0; i < n; i++)
            {
                c[i] = sc.Nextint();
                t[i] = sc.Nextint();
            }
            try
            {
                var minCost = Enumerable.Range(0, n).Where(i => t[i] <= T).Select(i => c[i]).OrderBy(val => val).First();
                Console.WriteLine(minCost);
            }
            catch (System.Exception)
            {
                Console.WriteLine("TLE");
            }

        }
    }
    class Scanner
    {
        string[] s;
        long i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string Next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return Next();
            i = 0;
            return s[i++];
        }

        public int Nextint()
        {
            return int.Parse(Next());
        }
        public int[] Arrayint(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = Nextint() + add;
            }
            return Array;
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextLong() + add;
            }
            return Array;
        }

        public double NextDouble()
        {
            return double.Parse(Next());
        }

        public double[] ArrayDouble(long N, double add = 0)
        {
            double[] Array = new double[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextDouble() + add;
            }
            return Array;
        }

        public decimal NextDecimal()
        {
            return decimal.Parse(Next());
        }

        public decimal[] ArrayDecimal(long N, decimal add = 0)
        {
            decimal[] Array = new decimal[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextDecimal();
            }
            return Array;
        }
    }
}

Measured memory_bytes: 13524
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, a, b) for(int i = a, i##_len = (b); i < i##_len; ++i)

int main()
{
    int N;
    scanf("%d", &N);
    pair<int, int> List[N];
    int sm = 0;
    for(int i = 0; i < N; ++i) {
        scanf("%d", &List[i].first);
        List[i].second = i;
        sm += List[i].first;
    }

    //for(int i = 0; i < N; ++i) printf("%d : %d\n", List[i].first, List[i].second);
    int res = 0, val = 1000000;
    for(int i = 0; i < N; ++i) {
        int dist = abs(sm - N*List[i].first);
        if(dist < val) res = List[i].second, val = dist;
    }
    printf("%d\n",res);
    return 0;
}

Measured memory_bytes: 256