akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

void solve(long long X, long long A){
    cout<<(X<A?0:10)<<endl;
}

int main(){
    long long X;
    scanf("%lld",&X);
    long long A;
    scanf("%lld",&A);
    solve(X, A);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
#define PIL pair<int,LL>
#define PLI pair<LL,int>
#define PIII pair<int,PII>
#define PLL pair<LL,LL>
#define PLII pair<LL,PII>
#define VI vector<int>
#define VVI vector<VI>
#define VL vector<LL>
#define VVL vector<VL>
#define VPII vector<PII>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define all(x) x.begin(),x.end()
#define watch(x) cout<<(#x)<<" = "<<(x)<<'\n'
#define mset(a,v) memset(a,v,sizeof(a))
#define setp(x) cout<<fixed<<setprecision(x)
#define EPS 0.00000000001
#define PI acos(-1)
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
using namespace std;

const int MOD = 1e9 + 7;
const LL MX = 1e9;
const LL INF = 1e9;

int main()
{
    //ofstream out("output.txt");
    //ifstream in("input.txt");
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    LL d,t,s;
    cin>>d>>t>>s;
    LL d1 = t*s;
    if(d1 >= d) cout<<"Yes\n";
    else cout<<"No\n";

    /*
    int t,n;
    cin>>t;
    while(t--)
    {
        cin>>n;
        int a[n];
        loop(i,0,n)
        {
            cin>>a[i];
        }
    }
    */

    /*
    int n;
    cin>>n;
    int a[n];
    loop(i,0,n)
    {
        cin>>a[i];
    }
    */

    /*
    cout<<ans<<'\n';

    if(f) cout<<"YES\n";
    else cout<<"NO\n";

    if(f) cout<<"Yes\n";
    else cout<<"No\n";
    */

    return 0;
}


Measured memory_bytes: 3636
// 24/01/20 // 9:53 PM //

#include <bits/stdc++.h>

using namespace std;

const int MAXN = (int)(3e2) + 10;

int n;
double memo[MAXN][MAXN][MAXN];

double solve(int a, int b, int c){
    if(memo[a][b][c]!=-1) return memo[a][b][c];

    if(a==0 && b==0 && c==0) return 0.0;

    double dn=n, da = a, db = b, dc = c;

    memo[a][b][c] = dn/(da+db+dc);
    if(a>0) memo[a][b][c] += da/(da+db+dc) * solve(a-1, b, c);
    if(b>0) memo[a][b][c] += db/(da+db+dc) * solve(a+1, b-1, c);
    if(c>0) memo[a][b][c] += dc/(da+db+dc) * solve(a, b+1, c-1);

    return memo[a][b][c];
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n;

    int a=0, b=0, c=0;
    for(int i=0; i<n; i++){
        int temp;
        cin >> temp;

        a += (temp==1);
        b += (temp==2);
        c += (temp==3);
    }

    for(int x=0; x<=a+b+c; x++)
        for(int y=0; y<=b+c; y++)
            for(int z=0; z<=c; z++)
                memo[x][y][z] = -1;

    cout.precision(10);
    cout.setf(ios::fixed);
    cout << solve(a, b, c) << endl;

    return 0;
}


Measured memory_bytes: 227584
#include <bits/stdc++.h>
using namespace std;
int main () {
	int K,N;
	cin >> N >> K;
	std::vector<int> A(N);
	for (int i = 0; i < N; ++i)
	{
		A[i] = 0;
	}
	for (int i = 0; i < N; ++i)
	{
		int tmp = 0;
		cin >> tmp;
		A[tmp-1]++;
	}
	sort(A.begin(), A.end());
	int sum = 0;
	for (int i = 0; i < N-K; ++i)
	{
		sum += A[i];
	}
	cout << sum << endl;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mem(a) memset(a,0,sizeof(a))
typedef long long ll;
typedef pair<ll,ll> pll;
 
const int mn=1e5+5;
 
int n;
ll c;
pll p[mn];
ll pre[mn],suf[mn];
 
priority_queue<ll> qp,qs;
 
int main() {
	scanf("%d%lld",&n,&c);
	for(int i=1; i<=n; i++)
		scanf("%lld%lld",&p[i].first,&p[i].second);
	ll ans=0;
	for(int i=1; i<=n; i++) {
		pre[i]=pre[i-1]+(p[i-1].first-p[i].first)+p[i].second;
		ans=max(ans,pre[i]);
	}
	p[n+1]=make_pair(c,0);
	for(int i=n; i; i--) {
		suf[i]=suf[i+1]+(p[i].first-p[i+1].first)+p[i].second;
		ans=max(suf[i],ans);
	}
	for(int i=1; i<=n; i++) {
		if(!qs.empty()) {
            ans=max(suf[i]+p[i].first-c+qs.top(),ans);
		}
		qs.push(pre[i]);
	}
	for(int i=n; i; i--) {
		if(!qp.empty()) {
            ans=max(pre[i]-p[i].first+qp.top(),ans);
		}
		qp.push(suf[i]);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 5748
using System;

namespace ABC104_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] array = Console.ReadLine().Split(' ');
            int a = int.Parse(array[0]);
            if (a < 1200)
            {
                Console.WriteLine("ABC");
            }else if((1200 <= a) && (a < 2800))
            {
                Console.WriteLine("ARC");
            }else
            {
                Console.WriteLine("AGC");
            }
        }
    }
}


Measured memory_bytes: 13140
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> pint;
#define foreach(i,n) for(i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
int dx[]={1,-1,0,0},dy[]={0,0,1,-1};

int main(){
	pair<int,int> a[101];
	rep(i,101){
		a[i].second=-i;
	}
	for(int k;cin>>k;){
		a[k].first++;
	}
	sort(a,a+101,greater<pair<int,int> >());
	for(int i=0;cout<<-a[i].second<<endl,a[i].F==a[i+1].F;i++);
	return 0;
}

Measured memory_bytes: 0
"""Boot-camp-for-Beginners_Easy006_B_Bishop_25-August-2020.py"""

H, W = (map(int, input().split()))
if(H == 1 or W == 1):
    print(1)
else:
    if (H*W) % 2 == 0:
        print(int(H*W/2))
    else:
        print(int(H*W/2)+1)


Measured memory_bytes: 9136
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int i,j,k,prt[1005],cnt,num;
long long n;
int main()
{
	scanf("%lld",&n);
	++n;
	for(k=60;!(n>>k&1);--k);
	--k;
	while(k>=0)
	{
		++num;
		for(i=cnt;i>cnt/2;--i)
			prt[i+1]=prt[i];
		prt[cnt/2+1]=num;
		++cnt;
		for(i=cnt;i>=1;--i)
			prt[i+1]=prt[i];
		++cnt;
		prt[1]=num;
		if(n>>k&1)
		{
			for(i=cnt;i>=1;--i)
				prt[i+1]=prt[i];
			++cnt;
			prt[1]=prt[++cnt]=++num;
		}
		--k;
	}
	printf("%d\n",cnt);
	for(i=1;i<=cnt;++i)
		printf("%d ",prt[i]);
	return 0;
}


Measured memory_bytes: 128
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
-- import System.IO.Unsafe
 
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f
-- end of templete


main = (+) <$> (minimum <$> replicateM 3 getInt) <*> (minimum <$> replicateM 2 getInt) >>= print . (subtract 50)

Measured memory_bytes: 3632
n, m = map(int, input().split())
A = [list(input()) for _ in range(n)]
B = [list(input()) for _ in range(m)]
BB = sum(B,[])
for i in range(n-m+1):
  for k in range(n-m+1):
    AA = []
    for v in range(m):
      AA += A[i+v][k:k+m]
    if BB == AA:
      print("Yes")
      quit()
print("No")

Measured memory_bytes: 3064
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
i=N-1
ans=0
while i>=0:
  if A[i+1]>B[i]:
    ans+=B[i]
  else:
    B[i]-=A[i+1]
    ans+=A[i+1]
    ans+=min(A[i],B[i])
    A[i]-=min(A[i],B[i])
  i-=1
print(ans)

Measured memory_bytes: 18624
#include<bits/stdc++.h>
using namespace std;
#define int long long
map<string,int>mp;
signed main()
{
	int n;
	string s;
	cin>>n;
	while(n--)
	{
		cin>>s;
		mp[s]++;
	}
	cout<<"AC x "<<mp["AC"]<<endl;
	cout<<"WA x "<<mp["WA"]<<endl;
	cout<<"TLE x "<<mp["TLE"]<<endl;
	cout<<"RE x "<<mp["RE"];
	return 0;
}

Measured memory_bytes: 3636
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    static Scanner scan = new Scanner(System.in);

    public static void main(String[] args) {
        String[] ab1 = getLine().split(" ");
        String[] ab2 = getLine().split(" ");
        String[] ab3 = getLine().split(" ");

        Map<Integer, Integer> map = new HashMap<>();

        for(int i=0; i<2; i++ ) {
            Integer count;
            count = map.getOrDefault(toInt(ab1[i]), 0) + 1;
            map.put(toInt(ab1[i]), count++);
            count = map.getOrDefault(toInt(ab2[i]), 0) + 1;
            map.put(toInt(ab2[i]), count++);

            count = map.getOrDefault(toInt(ab3[i]), 0) + 1;
            map.put(toInt(ab3[i]), count++);
        }

        int count1 = 0;
        int count2 = 0;
        for(Map.Entry<Integer, Integer> e: map.entrySet()) {
            int count = e.getValue();
            if(count == 1) {
                count1++;
            }
            if(count == 2) {
                count2++;
            }
        }

        if(count1 == 2 && count2 == 2) {
            print("YES");
        } else {
            print("NO");
        }
    }

    public static int getInt() {
        return scan.nextInt();
    }

    public static String getLine() {
        return scan.nextLine();
    }

    public static int toInt(String str) {
        return Integer.parseInt(str);
    }

    public static long toLong(String str) {
        return Long.parseLong(str);
    }

    public static void print(String str) {
        System.out.println(str);
    }
}


Measured memory_bytes: 21716
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using vi = vector<int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define eb(val) emplace_back(val)
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
#define int ll
int MAX = 1e5+1;
vector<int> sorted,indegree(MAX,0);//入次数
vector<vector<int>> graph(MAX);
int n;//ノード数
void tpsort(){
  REP(i,n){
    REP(j,(ll)graph[i].size()){//入次数の計算
      indegree[graph[i][j]]++;
    }
  }
  stack<int> st;
  REP(i,n){//入次数0のものをstackに入れる
    if(!indegree[i]) st.push(i);
  }
  while(!st.empty()){
    int tmp = st.top();
    st.pop();
    sorted.emplace_back(tmp);//sortedに入れる
    REP(i,(ll)graph[tmp].size()){
      indegree[graph[tmp][i]]--;//消滅したノードの入次数を再計算
      if(!indegree[graph[tmp][i]]) st.push(graph[tmp][i]);//入次数0のものをstackに入れる
    }
  }
}
struct union_find{//rank,経路圧縮で高速化
  vector<int> par;//parは添字の親（または自分が根の時自身）を示す。
  vector<int> rank;//rankは木の高さ（根についてのみ実装,0-indexed）
  union_find(int size){//コンストラクタ,size個のノードを作成し、自分を親につける
    par.assign(size,0);
    rank.assign(size,0);
    //for(int i = 0;i < size;++i) par[i]=i;
  }
  void ad(ll a,ll b){//a→bに辺を貼る
    if(rank[a] + 1>rank[b]){
      rank[b] = rank[a]+1;
      par[b] = a;
    }
  }
};
signed main(){
  ll m;
  cin >> n >> m;
  union_find uf(n+1);
  vl a(n+m,0),b(n+m,0);
  REP(i,n+m-1){
    ll tmp1,tmp2;
    cin >> tmp1 >> tmp2;
    a[i] = tmp1; b[i] = tmp2;
    graph[tmp1-1].eb(tmp2-1);
  }
  tpsort();
  REP(i,n){
    REP(j,graph[sorted[i]].size()){
      uf.ad(sorted[i]+1,graph[sorted[i]][j]+1);
    }
  }
  REP(i,n){
    // cout << (uf.par[i]!=i?uf.par[i]:0) << endl;
    cout << uf.par[i+1] << endl;
  }
}

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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)


int main()
{
  ll n, k, a, b;
  cin >> n >> k;
  map <ll, ll> m;
  forll(i, 0, n){
	cin >> a >> b;
	m[a] += b;
  }
  for (auto i=m.begin(); i!=m.end(); i++){
	k -= i->second;
	if (k <= 0){
	  cout << i->first << endl;
	  return 0;
	}
  }
}



Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
typedef unsigned int uint;
typedef vector<int> VI;
typedef vector<double> VD;
typedef vector<vector<int> > VV;
 
const int INF = 1 << 28;
const double EPS = 1e-9;
 
int n;
VV par;
VD x, y, r;
VI c;
map<int,int> m;
 
string toString (int era) {
    string str;
    for (int i = 0; i < n; i++) {
        str = (era % 2 ? "1" : "0") + str;
    }
 
    return str;
}
 
int dfs (int era) {
    if (era == ((1 << n) - 1)) return 0;
    int cera = ((1 << n) - 1) ^ era;
    if (m.find(cera) != m.end()) {
        return m[cera];
    }
     
    VV count(5);
    rep (i,n) {
        bool flag = true;
        if (era & (1 << i)) continue; 
        rep(j,par[i].size()) {
            if (cera & (1 << par[i][j])) {
                flag = false;
                break;
            }
        }
        if (flag) {
            count[c[i]].push_back(i);
        }
    }
 
    int ret = 0;
    REP(i,1,5) {
        if (count[i].size() >= 2) {
            rep(j,count[i].size()-1) REP(k,j+1,count[i].size()) {
                int tera = era;
                tera |= (1 << count[i][j]);
                tera |= (1 << count[i][k]);
                ret = max(ret, dfs(tera) + 2);
            }
        }
    }
 
    return m[cera] = ret;
}
 
int main()
{
    while (cin >> n, n) {
        x.resize(n), y.resize(n), r.resize(n), c.resize(n);
        m.clear();
         
        rep(i, n) {
            cin >> x[i] >> y[i] >> r[i] >> c[i];
        }
         
        par.clear();
        par.resize(n);
        rep(i,n) rep(j,i) {
            double dis = pow(x[i] - x[j], 2.) + pow(y[i] - y[j], 2.);
            if (sqrt(dis) < r[i] + r[j]) {
                par[i].push_back(j);
            }
        }
 
        cout << dfs(0) << endl;
    }
                 
    return 0;
}

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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

// template <typename T>
// struct edge {
//     int to;
//     T cost;
//     edge(){}
//     edge(int _to, T _cost) : to(_to), cost(_cost) {}
//     bool operator< (const edge& e) const {
//         return cost == e.cost ? to < e.to : cost < e.cost;
//     }
// };

template <typename T>
struct edge {
    int from, to;
    T cost;
    edge(){}
    edge(int _from, int _to, T _cost) : from(_from), to(_to), cost(_cost) {}
    bool operator< (const edge& e) const {
        return cost == e.cost ? (from == e.from ? to < e.to : from < e.from) : cost < e.cost;
    }
    bool operator> (const edge& e) const {
        return cost == e.cost ? (from == e.from ? to > e.to : from > e.from) : cost > e.cost;
    }
};

template <typename T>
class Prim {
private:
    int n;
    vector<vector<edge<T>>> G;
public:
    Prim(int _n) : n(_n) {
        G.resize(n);
    }
    // undirected
    void addEdge(int u, int v, T c) {
        G[u].emplace_back(u, v, c);
        G[v].emplace_back(v, u, c);
    }
    T calc(int s = 0) {
        T total_weight = 0;
        vector<bool> visited(n);
        priority_queue<edge<T>, vector<edge<T>>, greater<edge<T>>> pq;
        pq.push(edge<T>(-1, s, 0));
        while (!pq.empty()) {
            auto e = pq.top(); pq.pop();
            if (visited[e.to]) continue;
            total_weight += e.cost;
            visited[e.to] = true;
            for (const auto& ne: G[e.to]) {
                if (!visited[ne.to]) pq.push(ne);
            }
        }
        return total_weight;
    }
};
/* !!!!! T: ?????????????????????(int, double) !!!!! */

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int n, m;
    cin >> n >> m;
    Prim<int> prim(n);
    rep(i, m) {
        int a, b, c;
        cin >> a >> b >> c;
        prim.addEdge(a, b, c);
    }

    cout << prim.calc() << endl;
}

Measured memory_bytes: 8644
#include <stdio.h>
int main(void){
	int a,b,i;
	char s[101];
	while(1){
		scanf("%s",s);
		if(s[0]=='0')break;
		a=b=0;
		for(i=1;s[i]!='\0';i++){
			if(s[i]=='A')a++;
			else b++;
		}
		if(a>b)a++;
		else b++;
		printf("%d %d\n",a,b);
	}
	return 0;
}

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

int main(){
  int n, l;
  string s2;
  vector<string> s;

  cin >> n;
  cin >> l;
  for(int i=0; i<n; i++){
    cin >> s2;
    s.push_back(s2);
  }

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

  for(int i=0; i<n; i++){
    cout << s[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
class box {
public:
	int min;
	int large;
	box() {

	}
};
int main() {
	int n, k;
	while (cin >> n >> k&&n != 0) {
		int *line;
		line = new int[k];
		for (int i = 0; i < k; ++i) {
			cin >> line[i];
		}
		sort(line, line + k);
		bool zero = false;
		if (line[0] == 0)zero = true;
		vector<box> set;
		set.push_back(box());
		set[0].min = (zero) ? line[1] - 1 : line[0] - 1;
		set[0].large = 1;
		for (int i = (zero) ? 2 : 1; i < k; ++i) {
			if (line[i] == set.back().min + set.back().large) {
				++set.back().large;
			}
			else {
				set.push_back(box());
				set.back().min = line[i];
				set.back().large = 1;
			}
		}
		if (zero == false) {
			int answer = 0;
			for (int i = 0; i < set.size(); ++i) {
				answer = max(answer, set[i].large);
			}
			cout << answer << endl;
		}
		else {
			if (set.size() == 1) {
				cout << set[0].large + 1 << endl;
			}
			else {
				int answer = 0;
				for (int i = 0; i < set.size() - 1; ++i) {
					if (set[i + 1].min - set[i].min - set[i].large == 1) {
						answer = max(answer,set[i + 1].large + 1 + set[i].large);
					}
					else {
						answer = max(answer, set[i].large);
					}
				}
				cout << answer << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fordec(a,b,c) for(int a=b;a>=c;--a)
#define forinc(a,b,c) for(int a=b;a<=c;++a)
const int N=500005;
int n,a[N];
string s;
main(){
    cin>>s;
    n=s.size()+1;
    forinc(i,0,n-2){
        if(s[i]=='<') a[i+1]=max(a[i+1],a[i]+1);
    }
    fordec(i,n-2,0){
        if(s[i]=='>') a[i]=max(a[i],a[i+1]+1);
    }
    int ans=0;
    forinc(i,0,n-1) ans+=a[i];
    cout<<ans;
}


Measured memory_bytes: 4740
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            long[] march = new long[5];

            for (int i = 0; i < n; i++) {
                String s = in.next();
                if (s.charAt(0) == 'M') march[0]++;
                if (s.charAt(0) == 'A') march[1]++;
                if (s.charAt(0) == 'R') march[2]++;
                if (s.charAt(0) == 'C') march[3]++;
                if (s.charAt(0) == 'H') march[4]++;
            }

            ArrayList<Long> count = new ArrayList<>();
            for (long i : march) {
                if (i != 0) {
                    count.add(i);
                }
            }

            long ans = 0;
            if (count.size() >= 3) {
                for (int i = 0; i < count.size(); i++) {
                    for (int j = i + 1; j < count.size(); j++) {
                        for (int k = j + 1; k < count.size(); k++) {
                            ans += count.get(i) * count.get(j) * count.get(k);
                        }
                    }
                }
            }


            out.print(ans);
        }

    }
}



Measured memory_bytes: 46636
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int main(){
    string S;
    cin >> S;
    long long cnt = 0;
    long long flag = 0;
    for(int i = 0; i < S.size(); i++){
        if(S[i] == 'A') flag++;
        else if(i + 1 < S.size() && S[i] == 'B' && S[i + 1] == 'C') {
            cnt += flag;
            i++;
        }
        else flag = 0;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String  s = sc.next();
        char[] rgb = s.toCharArray();
        long countR = 0;
        long countB = 0;
        long countG = 0;
        for (int i = 0; i < rgb.length; i++){
            if('R' == rgb[i])
                countR++;
            if ('B' == rgb[i])
                countB++;
            if ('G' == rgb[i])
                countG++;
        }
        long result = countB * countG * countR;
        long ng = 0;
        for (int i = 0; i < n - 2; i++){
            for (int j = i + 1; j < n - 1; j++){
                if (rgb[i] == rgb[j]){
                    continue;
                }
                int diff = j - i;
                if (j + diff < n && rgb[j + diff] != rgb[i] && rgb[j + diff] != rgb[j])
                    ng++;
            }
        }
        System.out.println(result - ng);

    }
}


Measured memory_bytes: 36096
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;

vector<int> es[101];
vector<int> dia;
P dfs(int r,int p){
	P ret=P(0,r);
	for(auto e:es[r]){
		if(e==p)continue;
		auto v=dfs(e,r);
		v.first++;
		ret=max(ret,v);
	}
	return ret;
}

bool dfs2(int r,int p,int t){
	dia.push_back(r);
	if(r==t)return true;
	for(auto e:es[r]){
		if(e==p)continue;
		if (dfs2(e,r,t)){
			return true;
		}
	}
	dia.pop_back();
	return false;
}

vector<LL> ds;
void dfs3(int r,int p,int d){
	if(ds.size()==d){
		ds.push_back(1);
	}
	LL c=0;
	for(auto e:es[r]){
		if(e==p)continue;
		dfs3(e,r,d+1);
		c++;
	}
	cerr << r << ", " << c << endl;
	ds[d]=max(ds[d],c);
}
void solve(long long N, std::vector<long long> a, std::vector<long long> b){
	for(int i=0;i<N-1;i++){
		es[a[i]].push_back(b[i]);
		es[b[i]].push_back(a[i]);
	}

	auto v=dfs(1,0);
	auto w=dfs(v.second,0);
	cerr << v.second << ", " << w.second << endl;
	dfs2(v.second,0,w.second);
	cerr << "aaa" << endl;
	for(auto k:dia){
		cerr << k << " ";
	}
	cerr << endl;
	if(dia.size()%2==0){
		dfs3(dia[dia.size()/2],dia[dia.size()/2-1],0);
		dfs3(dia[dia.size()/2-1],dia[dia.size()/2],0);
		LL v=2;
		for(auto d:ds){
			v*=d;
		}
		cout << dia.size()/2 << " " << v << endl;
		return;
	}


	LL ret=1;
	int c=dia[dia.size()/2];
	dfs3(c,0,0);
	for(auto d:ds){
		ret*=d;
	}
	//cerr << "aaa " << ret << endl;
	for(auto e:es[c]){
		ds.clear();
		//cerr << c << ", " << e << ", " << endl;
		dfs3(c,e,0);
		dfs3(e,c,0);
		LL v=2;
		for(auto d:ds){
			v*=d;
			cerr << d << " ";
		}
		cerr << endl;
		ret=min(ret,v);
	}
	cout << (dia.size()+1)/2 << " " << ret << endl;
}

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


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

int main() {
	// your code goes here
	int n, m, j=0;

	cin >> n >> m;
	string a[n], b[m];
	
	for(int i=0; i<n; i++) cin >> a[i];
	
	for(int i=0; i<m; i++) cin >> b[i];
	
		while(a[j].find(b[j]) != -1){
			j++;
			if(j == m) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "queue"
#include "utility"
#include "math.h"

using namespace std;
int H, W;
char status[1002][1002];
int field[1002][1002];
pair<int, int> dir[8] = {make_pair(0,1),make_pair(1,1),make_pair(1,0),make_pair(1,-1),make_pair(0,-1),make_pair(-1,-1),make_pair(-1,0),make_pair(-1,1)};
queue<pair<int,int> > Q;
queue<pair<int, int> >del;
bool flag[1002][1002];
int ans = 0;
int box = 0;
int num = 0;
int x, y;

int main() {
	cin >> H >> W;
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			cin >> status[i][j];
			if (status[i][j] == '.') {
				field[i][j] = 0;
			}
			else {
				field[i][j] = status[i][j] - '0';
				flag[i][j] = true;
			}
		}
	}
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			if (field[i][j] != 0) {
				box = 0;
				for (int k = 0; k < 8; k++) {
					if (field[i + dir[k].first][j + dir[k].second] == 0)box++;
				}
				if (box >= field[i][j]&&flag[i][j]) {
					Q.push(make_pair(i, j));
					flag[i][j] = false;
					ans = 1;
				}
			}
		}
	}
	del = Q;
	
	while (!del.empty()) {
		y = del.front().first;
		x = del.front().second;
		field[y][x] = 0;
		del.pop();
	}
	while (1) {
		num = Q.size();
		//cout << num <<" ";
		for (int i = 0; i < num; i++) {
			y = Q.front().first;
			x = Q.front().second;
			for (int j = 0; j < 8; j++) {
				if (field[y + dir[j].first][x + dir[j].second] != 0&&y+dir[j].first>=1&&y+dir[j].first<=H&&x+dir[j].second>=1&&x+dir[j].second<=W) {
					box = 0;
					for (int k = 0; k < 8; k++) {
						if (field[y + dir[j].first + dir[k].first][x + dir[j].second + dir[k].second] == 0)box++;
					}
					if (box >= field[y + dir[j].first][x + dir[j].second]&& flag[y + dir[j].first][x + dir[j].second]) {
						Q.push(make_pair(y + dir[j].first, x + dir[j].second));
						flag[y + dir[j].first][x + dir[j].second] = false;
					}
				}
			}
			Q.pop();
		}
		//cout << Q.size() << "\n";
		if (Q.empty())break;
		del = Q;
		ans++;
		//cout << del.size() << "\n";
		while (!del.empty()) {
			y = del.front().first;
			x = del.front().second;
			field[y][x] = 0;
			del.pop();
		}
		
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 8992
#include <stdio.h>
int c[27];

int main(void) {
    char ch;
    while( scanf( "%c", &ch ) != EOF ) {
        if( 'a' <= ch && ch <= 'z' ){
            c[ ch - 'a' ]++;
        } else if( 'A' <= ch && ch <= 'Z' ) {
            c[ ch - 'A' ]++;
        }
    }
    for( int i = 0; i < 26; i++ ){
        printf( "%c : %d\n", 'a' + i, c[i] );
    }
    return 0;
}


Measured memory_bytes: 2700
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define x first
#define y second
#define mod 1e9+7
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rof(i,a,b) for(ll i=a;i>b;i--)

//int a[1001][1001] //aise global me hi

ll lcm(ll a, ll b){
    return a / __gcd(a, b) * b;
}
//memset can initialize to 0 or -1 ONLY
// memset(a,0,sizeof(a[0][0])*n*n); //2D array
//memset(a, 0, sizeof(a));  //1D array
//memset(str, 't', sizeof(str)); // string
void solve()
{
	long long int n;cin>>n;long long int ans=2;
	
for(long long int i=2;i<=sqrt(n);i++)
{
	if(n%i==0)
	{	

		long long int tmp=n;
		while(tmp%i==0) tmp=tmp/i;
		if(tmp%i==1) ans++;
		if(i*i!=n)
		{
			tmp=n;
			while(tmp%(n/i)==0) tmp=tmp/(n/i);
			if(tmp%(n/i)==1) ans++;
		}
	}
}

for(long long int i=2;i<=sqrt(n-1);i++)
{
if((n-1)%i==0)
{
	ans++;
	if(i*i!=(n-1))
		 ans++;
}
    
}

if(n==2) ans--;
cout<<ans;


}


int main()
{

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

    ll t=1;
   // cin>>t;
    while(t--)
    {
    
    solve();
    
    }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (ll)(1E9+7)
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}


int main() {
	ll num = 100;
	int d, n;
	cin >> d >> n;
	if (n == 100) n++;
	num = pow(num, d)*n;
	printf("%lld\n", num);
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  int cnt = 0;
  cnt += max(a,b);
  if(a>b) a--;
  else b--;
  cnt += max(a,b);
  cout << cnt << "\n";
  return 0;
}

Measured memory_bytes: 3604
#include<stdio.h>
#include<stdlib.h>

int main(void){
    int N;

    scanf("%d", &N);

    int *H;
    H = (int*)malloc(N * sizeof(int));

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

Measured memory_bytes: 128
using System;

public class Hello
{
    public static void Main()
    {
        var s = Console.ReadLine().Trim();
        Console.WriteLine(check(s) ? "Yes" : "No");
    }
    static bool check(string s)
    {
        var sL = s.Length;
        for (int i = 0; i < sL; i++)
        {
            var a = s[i];
            if (a == 'U' | a == 'D') continue;
            if (a == 'R' && i % 2 == 0) continue;
            if (a == 'L' && i % 2 == 1) continue;
            return false;
        }
        return true;
    }
}

Measured memory_bytes: 13140
#atcoderstock
#https://atcoder.jp/contests/agc008/tasks/agc008_a
if ARGV[0]=="LOCAL_DEV"
    define_method("debug") do |var|
        p var
    end
else
    define_method("debug") do |var|
    end
end

x,y=STDIN.gets.strip.split.map(&:to_i)
if x==y
    puts 0
    exit
elsif -x==y
    puts 1
    exit
end

ans=0
if x*y>=0
  if x<y
     ans=(y-x).abs
  else
    ans=2+(x-y).abs
    ans-=1 if x*y==0
  end
else
  ans=(x+y).abs+1
end
puts ans


Measured memory_bytes: 1788
# coding: utf-8
xp0,yp0,xp1,yp1 = map(float,raw_input().split())
q = int(raw_input())
for i in range(q):
    xp2,yp2 = map(float,raw_input().split())
    p0p2 = (xp2-xp0,yp2-yp0)
    p0p1 = (xp1-xp0,yp1-yp0)
    k = ((p0p2[0]*p0p1[0]+p0p2[1]*p0p1[1])/(p0p1[0]**2 + p0p1[1]**2))
    p0T = (k*p0p1[0],k*p0p1[1])
    OT = (xp0+p0T[0],yp0+p0T[1])
    print "%.10f %.10f" % (OT[0],OT[1])

Measured memory_bytes: 4292
import java.lang.StringBuilder
import java.util.*
import kotlin.collections.ArrayList

val sc = Scanner(System.`in`)
fun nextIntArray() = sc.nextLine().split(" ").map(String::toInt).toTypedArray()

const val INF = 10000000




fun main(args: Array<String>) {

    val N = sc.nextLine().toInt()
    val a = nextIntArray()
    val map = Array(N+1){ArrayList<Int>()}
    val dp = IntArray(N){INF}
    var cnt = 0
    val ans = IntArray(N){0}

    for(i in 0..N-2){
        val u = sc.nextInt()
        val v = sc.nextInt()
        map[u].add(v)
        map[v].add(u)
    }

    val back_idx = IntArray(N+1){-1}
    val back_val = IntArray(N+1){-1}

    val stack = ArrayDeque<Int>(N)
    stack.push(1)
    while(stack.isNotEmpty()){

        var i = stack.pop()

        if(i < 0){
            i = -i
            dp[back_idx[i]] = back_val[i]
            if(back_val[i] == INF) cnt--
            continue
        }

        val s = dp.binarySearch(a[i-1], 0, cnt)
        val idx = if(s < 0) -s-1 else s

        val pre = dp[idx]
        if(pre == INF) cnt++
        dp[idx] = a[i-1]
        ans[i-1] = cnt

        stack.push(-i)
        back_idx[i] = idx
        back_val[i] = pre

        for(j in map[i]){
            if(ans[j-1] == 0) {
                stack.push(j)
            }
        }
    }

    val sb = StringBuilder()
    for(t in ans) sb.appendln(t)
    println(sb.toString())
}




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

int main() {
	int A, B;
	int counter = 0;
	cin >> A >> B;
	
	for (int i = A; i <= B; i++) {
		int c, d;
			c = i;
			d = 0;
		for (int j = 0; j < 5; j++) {
			d *= 10;
			d += c % 10;
			c /= 10;
		}
		//cout << i << d << endl;
		if (i == d) {
			counter++;
		}
	}
	
	cout << counter << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define maxn 200001
#define maxa 1000005
#define MOD 1000000007
#define INF 1000000000000000000

using namespace std;

#define ll long long
#define pii pair<ll, ll>
#define piii pair<pii, ll>
#define ft first
#define sd second

void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}

ll power(ll a, ll b = MOD-2){
    if(b == 0) return 1;
    ll r = power(a, b/2);
    r = (r*r)%MOD;
    if(b%2 == 1) r = (r*a)%MOD;
    return r;
}

vector<ll> vec[55];
ll par[55], dep[55], X[21], Y[21], lca[21], n, m, dp[1<<21];

void  dfs(ll u, ll p){
    par[u] = p;
    dep[u] = dep[p]+1;
    for(auto x: vec[u]){
        if(p != x){
            dfs(x, u);
        }
    }
}

void solve(){
    ll x, n;
    cin >> x >> n;
    if(x*500 >= n) cout << "Yes\n";
    else cout << "No\n";
}

int main()
{
    fast();
    ll t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
#define llint long long int
const int mod=1e9+7;
const int ele=1e6+9;
llint fact[ele],revfact[ele];
llint powmod(llint a,llint k,int m)
{
	if(k==0)return 1;
	if(k%2==0)return powmod((a*a)%m,k/2,m);
	else return (a*powmod(a,k-1,m))%m;
}
void setfact(int n)
{
	fact[0]=1;
	for(int i=1;i<n;i++)fact[i]=(fact[i-1]*i)%mod;
	revfact[n-1]=powmod(fact[n-1],mod-2,mod);
	for(int i=n-2;i>=0;i--)revfact[i]=(revfact[i+1]*(i+1))%mod;
}
llint getcmod(int n,int r)
{
	return (((fact[n]*revfact[r])%mod)*revfact[n-r])%mod;
}
llint gethmod(int n,int r)
{
	return getcmod(n+r-1,r);
}
int main()
{
	setfact(ele-9);
	int n,m;
	cin>>n>>m;
	llint ans=1;
	for(int i=2;i*i<=m;i++)
	{
		if(m%i==0)
		{
			llint p=0;
			while(m%i==0)
			{
				p++;
				m/=i;
			}
			ans=ans*gethmod(n,p)%mod;
		}
	}
	if(m>1)ans=ans*n%mod;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 16504
x, n = list(map(int, input().split()))
p_list = list(map(int, input().split()))

candidates= {}
for i in range(203):
    a = x-101+i
    candidates[a] = abs(x-a)

for p in p_list:
    del candidates[p]
    
min_diff = None
ans = []
for k, v in sorted(candidates.items(), key=lambda x:x[1]):
    if min_diff is None:
        min_diff = v
        ans.append(k)
    elif min_diff == v:
        ans.append(k)
    else:
        break
print(min(ans))

Measured memory_bytes: 9152
import sys
input=sys.stdin.readline
n,k=map(int,input().split())
INF=10**9+7
p=[0]*n
p[0]=1
def modinv(a,m):
    b=m
    (x,lastx)=(0,1)
    (y,lasty)=(1,0)
    while not b==0:
        q=a//b
        (a,b)=(b,a%b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return lastx%m
x=n-1
y=n
for i in range(1,n):
    p[i]=(x*y)%INF
    a=n-1-i
    b=modinv(i+1,INF)
    x=(x*a*b)%INF
    a = n - i
    b = modinv(i+1, INF)
    y = (y * a * b) % INF
ans=0
if k>=n:
    for i in range(n):
        ans=(ans+p[i])%INF
else:
    for i in range(k+1):
        ans=(ans+p[i])%INF
print(ans)






Measured memory_bytes: 60368
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<i32> = procon_read();
	let a = v[0];
	let b = v[1];
	if (a*b) % 2 == 0 {
		println!("No");
	}else{
		println!("Yes");
	}
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, n, c=0;
  vector<int> a(9),b(9,0);
  for (int i=0;i<9;i++){
    cin>>a.at(i);
  }
  cin>>N;
  for (int i=0;i<N;i++){
    cin>>n;
    for (int i=0;i<9;i++){
      if(a.at(i)==n){
        b.at(i)=1;
      }
    }
  }
  c+=b[0]*b[1]*b[2]+b[3]*b[4]*b[5]+b[6]*b[7]*b[8];
  c+=b[0]*b[3]*b[6]+b[1]*b[4]*b[7]+b[2]*b[5]*b[8];
  c+=b[0]*b[4]*b[8]+b[2]*b[4]*b[6];
  string s;
  if(c==0){s="No";}
  else{s="Yes";}
  cout<<s<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int m[9],N;
int main(){
    cin>>N;
    while(N--){
      int z;
      cin>>z;
      m[min(8,z/400)]++;
    }
    N=0;
    for(int i=0;i<8;i++)if(m[i])N++;
    cout<<max(N,1)<<' '<<m[8]+N;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
sList = list(input())
total = 0
for i in range(1, n):
    if sList[i] == "E":
        total+= 1
minNum = total
for i in range(1, n):
    if sList[i-1] == "W":
        total += 1
    if sList[i] == "E":
        total -= 1
    if total < minNum:
        minNum = total
print(minNum)

Measured memory_bytes: 5792
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#define lout cout
#else
stringstream devnull;
#define lout devnull
#endif
template <class C>
inline void vcin(C &a);
template <class C>
inline void vcout(const C a, const string separate = "\n");

struct restaurant
{
  int index;
  string s;
  int p;
};

bool cmp(const restaurant a, const restaurant b)
{
  if (a.s != b.s)
  {
    return a.s < b.s;
  }
  return a.p > b.p;
}

int main()
{
  int n;
  cin >> n;
  vector<restaurant> r(n);
  for (auto &e : r)
  {
    static int i = 1;
    cin >> e.s >> e.p;
    e.index = i;
    i++;
  }
  sort(r.begin(), r.end(), cmp);

  for (auto e : r)
  {
    cout << e.index << endl;
  }

  return 0;
}

template <class C>
inline void vcin(C &c)
{
  for (auto &a : c)
  {
    cin >> a;
  }
}
template <class C>
inline void vcout(const C c, const string separate)
{
  for (auto it = c.begin(); it != c.end(); it++)
  {
    if (it != c.begin())
      cout << separate;
    cout << *it;
  }
}


Measured memory_bytes: 384
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void debug(String str) {
        System.out.println(str);
    }

    public static void main(String[] args) {

        int N;
        int[][] A;

        try (Scanner sc = new Scanner(System.in)) {
            N = sc.nextInt();
            A = new int[N][N - 1];
            for (int i = 0; i < N; i++) {
                for (int j = 0; j < N - 1; j++) {
                    A[i][j] = sc.nextInt();
                }
            }
        }
        long result = 0;
        Deque<Integer>[] list = new Deque[N];
        for (int i = 0; i < N; i++) {
            Deque<Integer> target = new ArrayDeque<>(N);
            list[i] = target;
            for (int j = 0; j < N - 1; j++) {
                target.add(A[i][j]);
            }
        }
        Integer[] nextCallenge = new Integer[N];
        for (int i = 0; i < N; i++) {
            nextCallenge[i] = list[i].poll();
        }

        long game = 0;
        long maxGame = (N * (N - 1)) / 2;

        long days = 1;

        Deque<Integer> gamePeple = new ArrayDeque<>(N);
        for (int j = 0; j < N; j++) {
            gamePeple.add(j + 1);
        }

        while (true) {
            Set<Integer> set = new HashSet<>();
            Integer p1;
            while ((p1 = gamePeple.poll()) != null) {
                //対戦相手を調査.
                if (nextCallenge[p1 - 1] == null) {
                    continue;
                }

                int p2 = nextCallenge[p1 - 1];
                int temp = nextCallenge[p2 - 1];
                if (p1 == temp) {
                    boolean b1 = set.add(p1);
                    boolean b2 = set.add(p2);
                    //System.out.println(p1 + ":" + p2);
                    if (b1 && b2) {
                        game++;
                    }
                }
            }
            if (maxGame == game) {
                System.out.println(days);
                break;
            }
            //もう入れらんない
            if (set.isEmpty()) {
                System.out.println(-1);
                break;
            }
            for (Integer i : set) {
                nextCallenge[i - 1] = list[i - 1].poll();
                gamePeple.add(i);
            }

            days++;

        }

    }

}


Measured memory_bytes: 294612
#include<iostream>
using namespace std;
int main(){
    int n,m,l;
    cin>>n>>m>>l;
    int x[100][100]={{}};
    int y[100][100]={{}};
    long long int z[100][100]={{}};
    
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>x[i][j];
        }
    }
    for(int j=0;j<m;j++){
        for(int k=0;k<l;k++){
            cin>>y[j][k];
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            for(int k=0;k<m;k++){
                z[i][j]+=x[i][k]*y[k][j];
                }
            cout<<z[i][j];
            if(j==l-1){
                cout<<endl;
            }
            else{
                cout<<" ";
            }
                
            
            
        }
    }
    return 0;
}


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

using namespace std;
typedef long long ll;
const ll mx = 10000007;
const ll mod = 1e9 + 7;
const double pi = acos(-1);
#define    ss   second
#define    ff   first
#define    pb   push_back
#define gcd(a, b) __gcd((a), (b))
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
#define FIO ios_base::sync_with_stdio(false);  cin.tie(NULL);


int main() {
    FIO;
    ll n;
    cin >> n;
    vector<ll>v, u;
    for (ll i = 0; i < n; i++) {
        ll x;
        cin >> x;
        v.push_back(x);
        u.push_back(x);
    }
    sort(u.begin(), u.end());
    ll l = u[(n/2) - 1];
    ll r = u[n/2];

    for (ll i = 0; i < n; i++) {
        if(v[i] <= l) {
            cout << r << endl;
        }
        else {
            cout << l << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 6604
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー

int main(int argc,char* argv[]){
    int n,x,t;
    cin >> n >> x >> t;

    int ans=0;
    if(n%x==0) ans=t*(n/x);
    else ans=t*((n/x)+1);

    cout << ans << endl;

    return 0;
}


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

string s;
int l;

int main(){
    cin>>s;
    l=s.size();
    for(int i=0;i<l;i++){
        if(s[i]=='C'){
            for(register int j=i+1;j<l;j++){
                if(s[j]=='F'){
                    cout<<"Yes";
                    return 0;
                }
            }
        }
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N;
long long A,B;
long long h[100000];

bool C(long long T) {
    long long cnt = 0;
    for(int i=0; i<N; ++i) {
        if(h[i] - B*T >= 0) {
            cnt += (h[i] - B * T) / (A - B);
            if((h[i] - B * T) % (A - B)) ++cnt;
        }
    }
    return cnt <= T;
}

int main() {
    cin >> N >> A >> B;
    long long hmax = 0;
    for(int i=0; i<N; ++i) {
        cin >> h[i];
        hmax = max(hmax, h[i]);
    }

    long long l = 0;
    long long r = hmax / B + 1;
    while(r - l > 1) {
        long long mid = (l+r)/2;
        if(C(mid)) r = mid;
        else l = mid;
    }
    cout << r << endl;
    return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

vector<pair<char, int> > runLengthEncode(string s) {
  vector<pair<char, int> > res;
  rep (i, s.size()) {
	int j = i + 1;
	while (s[i] == s[j]) j++;
	res.emplace_back(s[i], j - i);
	i = j - 1;
  }

  return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	int n, k;
	string s;
	cin >> n >> k >> s;
	vector<pair<char, int> > v = runLengthEncode(s);
	int res = 0, l = v.size();
	if (l == 1) {
	  cout << n - 1 << endl;
	  return 0;
	} else if (l <= 2) {
	  res += 1;
	} else if (l % 2) {
	  int mid = l / 2;
	  if (mid >= k) {
		res += 2 * k;
	  } else {
		res += 2 * mid;
	  }
	} else {
	  int mid = (l - 1) / 2;
	  if (mid >= k) {
		res += 2 * k;
	  } else {
		res += 2 * mid;
		res++;
	  }
	}
	rep (i, v.size()) res += v[i].second - 1;
	cout << res << endl;
    
    return 0;
}



Measured memory_bytes: 4480
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define lli long long int
#define llu long long unsigned int
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define FOR(i,s,e) for(i=s; i<e; i++)
#define mod 1000000007
#define F first
#define S second
#define plli pair<lli,lli>
#define pqlli priority_queue<lli>
#define test(t) cin>>t; while(t--)
using namespace std;
int main()
{
	int n;
	cin>>n;
	char a[26];
	for(int i = 0; i<26; i++)
	a[i] = (char)('a' + i);
	string s;
	cin>>s;
	for(int i = 0; i<s.length(); i++)
	cout<<(char)((s[i]-'A' + n)%26 + 'A');
	

}



Measured memory_bytes: 256