akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
//typedef boost::multiprecision::cpp_int bigint;

ll N, A, B;

int main() {
	cin >> N >> A >> B;
	cout << min(A, B) << " " << max((ll)0, A + B - N) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
int memo[50];
int fib(int n){
  if(~memo[n]) return memo[n];
  if(n<=1) return 1;
  return memo[n]=(fib(n-1)+fib(n-2));
}
signed main(){
  int n;
  cin>>n;
  memset(memo,-1,sizeof(memo));
  cout<<fib(n)<<endl;
  return 0;
}

Measured memory_bytes: 3120
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <iomanip>
#include <functional>
#include <cassert>

using namespace std;

typedef long long ll;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  int n, x;
  cin >> n >> x;
  vector <int> b(n), l(n), r(n);
  ll score = 0;
  for (int i = 0; i < n; ++i) {
    cin >> b[i] >> l[i] >> r[i];
    score += (ll)b[i] * l[i];
  }
  vector <pair <ll, int>> gs;
  for (int i = 0; i < n; ++i) {
    ll delta = (ll)r[i] * x - (ll)(r[i] - l[i]) * b[i];
    gs.push_back({delta, i});
  }

  sort(gs.rbegin(), gs.rend());
  vector <int> pos(n);
  for (int i = 0; i < n; ++i) {
    pos[gs[i].second] = i;
  }
  vector <ll> pref(n + 1);
  for (int i = 0; i < n; ++i) {
    pref[i + 1] = pref[i] + gs[i].first;
  }
  
  ll L = -1, R = (ll)n * x;
  while (R - L > 1) {
    ll M = (L + R) >> 1;
    int cnt_full = M / x;
    int rem = M % x;
    bool ok = false;
    for (int who = 0; who < n; ++who) {
      ll have = pref[cnt_full];
      if (pos[who] < cnt_full) {
        have = pref[cnt_full + 1] - gs[pos[who]].first;
      }
      if (rem >= b[who]) {
        have += (ll)rem * r[who] - (ll)(r[who] - l[who]) * b[who];
      } else {
        have += (ll)rem * l[who];
      }
      if (have >= score) {
        ok = true;
      }
    }
    if (ok) R = M;
    else L = M;
  }
  cout << R << '\n';
}



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

int main(){
	int a,b;
	while(cin >> a >> b && (a || b) ){
		long long ans = 1e15;
		for(int i = 1 ; i*i <= a ; i++){
			if( a % i == 0 ){
				for(int j = 1 ; j*j <= b ; j++){
					if( b % j == 0 ){
						int T[] = {i,j,a/i,b/j};
						sort(T,T+4);
						long long sub = 0;
						for(int k = 0 ; k < 3 ; k++)
							sub += (T[k+1]-T[k]) * (T[k+1]-T[k]);
						ans = min( ans , sub );
					}
				}
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
#define MAXN 1000001
void solve(){
ll s,w;
cin>>s>>w;
if(w>=s)
{
	cout<<"unsafe"<<endl;
	return;
}
cout<<"safe"<<endl;	
}
int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
} 


Measured memory_bytes: 3652
#include <vector>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <map>
#include <set>
#include <chrono>
#include <queue>
#include <string>
#include <cassert>
#include <bitset>
#include <stack> 

#define INFLL 2000000000000000000
#define INF 2000000000
#define MOD 1000000007
#define BASE 77747
#define PI acos(-1.0)
#define MAXLEN 29

using namespace std;

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

int n;
int k;
int arr[100];
ll dp[100][100001];
ll sum[100001];

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	scanf("%d %d", &n, &k);
	for (int i = 0; i < n; i++) scanf("%d", arr + i);
	for (int i = 0; i <= arr[0]; i++) {
		dp[0][k - i] = 1;
	}
	sum[0] = dp[0][0];
	for (int i = 1; i <= k; i++) sum[i] = sum[i - 1] + dp[0][i];
	for (int i = 1; i < n; i++) {
		for (int j = 0; j <= k; j++) {
			dp[i][j] = sum[min(k, j + arr[i])] - (j - 1 >= 0 ? sum[j - 1] : 0);
			dp[i][j] %= MOD;
		}
		sum[0] = dp[i][0];
		for (int j = 1; j <= k; j++) {
			sum[j] = sum[j - 1] + dp[i][j];
			sum[j] %= MOD;
		}
	}
	cout << (dp[n - 1][0] + MOD) % MOD << endl;
	return 0;
}

Measured memory_bytes: 79104
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
const int MR=1e5+10;
typedef long long LL;

vector<int> d[MR];

int h[MR],f[MR];

int main() {
	int n,m,a,b;
	cin>>n>>m;
	for(int i=1;i<=n;i++) cin>>h[i];
	for(int i=1;i<=m;i++){
		cin>>a>>b;
		d[a].push_back(b);
		d[b].push_back(a);
	}
	memset(f,0,sizeof(f));
	for(int i=1;i<=n;i++){
		if(f[i]) continue;
		int len=d[i].size();
		bool flag=true;
		for(int j=0;j<len;j++){
			if(h[d[i][j]]>=h[i]){
				flag=false;break;
			}
			else{
				f[d[i][j]]=-1;
			}
		}
		if(flag){
			f[i]=1;
		}
		else{
			f[i]=-1;
		}
	}
	int cnt=0;
	for(int i=1;i<=n;i++){
		if(f[i]==1) cnt++;
	}
	printf("%d\n",cnt);
    return 0;
}

Measured memory_bytes: 9608
# -*- coding: utf-8 -*-

N, M, X = map(int, input().split())
A = list(map(int, input().split()))

ans_l = 0 # 左に進んだ場合の答え
ans_r = 0 # 右に進んだ場合の答え

# 左に進んだ場合のコストの算出
for i in range(X, 0, -1):
    if i in A:
        ans_l += 1

# 右に進んだ場合のコストの算出
for i in range(X, N, 1):
    if i in A:
        ans_r += 1

# 最小値の算出
min_cost = min(ans_l, ans_r)

print(min_cost)

Measured memory_bytes: 9136
N = int(input())
alist = list(map(int, input().split()))
m1, m2 = 0, 0
for i in range(N):
  if i == 0:
    m1+=alist[i]
    m2+=alist[i]
  elif i%2 == 0:
    m1+=alist[i]
    m2+=-1*alist[i]
  else:
    m1+=-1*alist[i]
    m2+=alist[i]

ans = [m1, m2]
for i in range(2, N-1, 2):
  # index=i
  ans.append(ans[i-2] -2*alist[i-2] + 2*alist[i-1])
  # index=i+1
  ans.append(ans[i-1] - 2*alist[i-1] + 2*alist[i])

ans.append(ans[N-3] - 2*alist[N-3] + 2*alist[N-2])

print(*ans)

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

int main(){
    string a;
    cin >> a;
    int s;
    int res=753;
    for(int i=0;i<a.size()-2;i++){
        string b="";
        for(int j=0;j<3;j++){
            b+=a[i+j];
        }
        int intb=stoi(b);
        s=abs(753-intb);
        if(s<res)res=s;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
hand = [input() for _ in range(3)]
pos = [0 for i in range(3)]

turn = 0
d = {c:i for i,c in enumerate('abc')}
while pos[turn] < len(hand[turn]):
    pos[turn], turn = pos[turn] + 1, d[hand[turn][pos[turn]]]
print('ABC'[turn])


Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
int n,m,q;
int main(int argc,int **argv){
    std::ios::sync_with_stdio(false);
    std::cin >> n >> m;
    q=m/n;
    for(int i=q;i>=1;i--){
        if(m%i==0){
            std::cout << i << std::endl;
            break;
        }
    }
return 0;
}


Measured memory_bytes: 256
using System;

namespace Atcoder
{
    class Program
    //ABC127 A - Ferris Wheel
    {
        private static void Main(string[] args)
        {
            var ab = Console.ReadLine().Split(' ');
            var a = int.Parse(ab[0]);
            var b = int.Parse(ab[1]);
            var ans = 0;
            if (a < 6)
            {
                ans = 0;
            }
            else if (6 <= a && a <= 12)
            {
                ans = b / 2;

            }
            else
            {
                ans = b;

            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11092
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iterator>
#include<sstream>
#include<iomanip>
#include<map>
#include<queue>
#include<deque>
#include<fstream>
#include<random>

#define rep(i, n) for (ll i = 0; i < n; i++) 
#define rrep(i, n) for(ll i = n-1; i>=0; i--)
#define range(i, n, m) for (ll i = n; i < m; i++) 
#define rrange(i, n, m) for (ll i = n - 1; i => m; i--) 
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vp vector<pair<ll, ll> >
#define vvp vector<vector<pair<ll, ll> > >
#define First first
#define Second second.first
#define Third second.second
#define Sort(X) sort(X.begin(), X.end())
#define RSort(X, T) sort(X.begin(), X.end(), greater<T>())
//#define MOD 998244353
#define MAX 100000

typedef long long int ll;
typedef unsigned long long int ull;

using namespace std;

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

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

	ll N;
	cin >> N;

	vvl A(N, vl(N-1));
	rep(i, N) {
		rep(k, N-1) {
			cin >> A[i][k];
		}
	}

	vl C(N);
	vector<bool> end(N, false);
	vvl S(N, vl(N - 1, 0));
	bool flg = false;
	ll cend = 0;
	ll mx = 0;
	while(true){
		flg = false;
		rep(k, N) {
			if (end[k]) continue;
			ll r = A[k][C[k]] - 1;
			if (A[r][C[r]] - 1 != k) continue;

			flg = true;
			ll i1, i2;
			i1 = C[k];
			i2 = C[r];

			if (i1 != 0 && i2 != 0) S[k][i1] = S[r][i2] = max(S[k][i1 - 1], S[r][i2 - 1]) + 1;
			else if (i1 != 0) S[k][i1] = S[r][i2] = S[k][i1 - 1] + 1;
			else if (i2 != 0) S[k][i1] = S[r][i2] = S[r][i2 - 1] + 1;
			else S[k][i1] = S[r][i2] = 1;

			chmax(mx, S[r][i2]);

			C[r]++;
			C[k]++;

			if (C[k] >= (N - 1)) {
				end[k] = true;
				cend++;
			}
			if (C[r] >= (N - 1)) {
				end[r] = true;
				cend++;
			}
		}
		if (!flg) {
			cout << -1 << endl;
			return 0;
		}
		if (cend == N) {
			break;
		}
	}


	cout << mx << endl;

	return 0;
}



Measured memory_bytes: 16000
#include <bits/stdc++.h>
using namespace std;
using sint = int64_t;

template<class T> T read() {
	T t;
	cin >> t;
	return t;
}

template<class T> vector<T> read_vector(sint const n) {
	vector<T> vs;
	for (sint i = 0; i < n; ++i) {
		vs.push_back(read<T>());
	}
	return vs;
}

inline void write() {
}

template<class T> void write(T const& t) {
	cout << t;
}

template<class T> void write(vector<T> const& ts) {
	if (ts.size() > 0) {
		cout << ts[0];
	}
	for (size_t i = 1; i < ts.size(); ++i) {
		cout << ' ' << ts[i];
	}
}

template<class T, class... Args> void write(T const& t, Args const&... args) {
	cout << t << ' ';
	write(args...);
}

template<class... Args> void writeln(Args const&... args) {
	write(args...);
	cout << '\n';
}

inline sint gcd(sint y, sint x) {
	while (x != 0) {
		sint const t = y % x;
		y = x;
		x = t;
	}
	return y;
}

inline sint pow_mod(sint const a, sint const n, sint const p) {
	if (n == 0) {
		return 1;
	}
	sint const h = pow_mod(a, n / 2, p);
	sint const f = (h * h) % p;
	if (n % 2 == 1) {
		return (a * f) % p;
	}
	else {
		return f;
	}
}

inline sint rcp_mod(sint const a, sint const p) {
	assert(a % p != 0);
	return pow_mod(a, p - 2, p);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin .exceptions(ios_base::badbit | ios_base::failbit);
	cout.exceptions(ios_base::badbit | ios_base::failbit);
	cin .tie(nullptr);
	cout.tie(nullptr);
	cout.precision(16);
	void run();
	run();
	return 0;
}

void run() {
	auto const C = read<char>();
	writeln(char(C + 1));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N;
    cin >> N;
    vector<int> P(N);
    vector<int> Q(N);
    REP(i,N)cin >> P[i];
    REP(i,N)cin >> Q[i];
    vector<int> R(N);
    REP(i,N)R[i] = i+1;
    int when = 0;
    bool poi = 0;
    do{
        when++;
        if(poi){
            if(R == P||R == Q){
                break;
            }
        }else{
            if(R == P||R == Q){
                poi = 1;
                when = 0;
            }
        }
    }while(next_permutation(ALL(R)));
    if(Q == P)when = 0;
    cout << when << "\n";
}

Measured memory_bytes: 256
// In The Name Of Allah
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e12;
typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pii;
const ll mod = 1e9 + 7;
 
 
void faster()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
 
const ll M = 10 + 10;
const ll N = 200 * 1000 + 10;

vector <pii> adj[N];
vector <pair <int, pii> > edge;
bool ok = true, vis[N];
ll dist[N];


void dfs(int v)
{
	vis[v] = 1;
	for (auto e : adj[v])
	{
		int u = e.second, w = e.first;
		if(vis[u])
			continue;
		dist[u] = dist[v] + w;
		dfs(u);
	}
}

int main()
{
	faster();
	int n, m;
	cin >> n >> m;
//	cout << "DEBUG\n";
	for (int i = 0; i < m; i++)
	{
		int v, u, w;
		cin >> v >> u >> w;
		v--, u--;
		adj[v].push_back({w, u});
		adj[u].push_back({-w, v});
		edge.push_back({w, {v, u}});
	}
	for (int i = 0; i < n; i++)
	{
		if(!vis[i])
		{
			dfs(i);
		}
	}
//	cout << "DEBUG\n";
	for (auto e : edge)
	{
		int v = e.second.first, u = e.second.second, w = e.first;
		if(dist[v] - dist[u] != -w)
			ok = false;
	}
	if(ok)
		cout << "Yes\n";
	else
		cout << "No\n";
}

Measured memory_bytes: 23980
import sys
input = sys.stdin.readline

N = int(input())

s = [[] for _ in range(N)]
a_ord = ord("a")

for i in range(N):
    if i == 0:
        s[0].append("a")
        continue
    for j in s[i - 1]:
        j_max_ord = max([ord(x) for x in j])
        for k in range(a_ord, j_max_ord + 2):
            s[i].append(j + chr(k))

ans = s[-1]
ans.sort()

for i in ans:
    print(i)

Measured memory_bytes: 57308
var
 n:int64;
 i,j,s:longint;
begin
 read(n);
 for i:=trunc(sqrt(n)) downto 1 do
  if n mod i=0 then
   begin
    j:=n div i;
    break;
   end;
   while j>0 do
    begin
     inc(s);
     j:=j div 10;
    end;
    writeln(s);
end.

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

using namespace std;

#define LL long long int
#define FASTIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

// const int oo = 1e9;
const LL oo = 1e18;
// const int MOD = 1e9 + 7;
const int MOD = 998244353;
const int N = 1e5 + 5;
// const long double PI = acos(-1);

vector<pair<int, int>> in[N];
vector<LL> out[N];
LL ans[N];

void solve() {
    int n, m, i;
    cin >> n >> m;
    for (i=0;i<=n;i++) {
        out[i].clear();
        in[i].clear();
    }
    for (i=0;i<m;i++) {
        int l, r, c;
        cin >> l >> r >> c;
        in[l].push_back({c, r});
    }
    multiset<LL> st;
    st.insert(0);
    out[1].push_back(0);
    for (i=1;i<=n;i++) ans[i] = oo;
    for (i=1;i<=n;i++) {
        if (st.empty()) break;
        ans[i] = *st.begin();
        for (auto it : in[i]) {
            st.insert(ans[i] + it.first);
            out[it.second].push_back(ans[i] + it.first);
        }
        for (auto it : out[i]) {
            auto jt = st.find(it);
            st.erase(jt);
        }
    }
    if (ans[i] >= oo) cout << "-1\n";
    else cout << ans[n] << '\n';
}

int main() {
    FASTIO; 
    int t = 1; 
    // cin >> t;
    for (int tc = 1; tc <= t; ++tc) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 11776
def main():
    n = int(input())
    a = list(map(int, input().split()))
    j = 1
    for i in range(n):
        if a[i] == j:
            j += 1
    if n-j+1 == n:
        print(-1)
    else:
        print(n-j+1)


main()


Measured memory_bytes: 26268
class Dice():

    def __init__(self):
        self.number = [i for i in range(6)]
        self.work = [i for i in range(6)]
        self.order = 'NNNNWNNNWNNNENNNENNNWNNN'

    def setNumber(self,n0,n1,n2,n3,n4,n5):
        self.number[0] = n0
        self.number[1] = n1
        self.number[2] = n2
        self.number[3] = n3
        self.number[4] = n4
        self.number[5] = n5


    def roll(self,loc):
        for i in range(6):
            self.work[i] = self.number[i]

        if loc == 'E':
            self.setNumber(self.work[3],self.work[1],self.work[0],self.work[5],self.work[4],self.work[2])
        elif loc == 'N':
            self.setNumber(self.work[1],self.work[5],self.work[2],self.work[3],self.work[0],self.work[4])
        elif loc == 'S':
            self.setNumber(self.work[4],self.work[0],self.work[2],self.work[3],self.work[5],self.work[1])
        elif loc == 'W':
            self.setNumber(self.work[2],self.work[1],self.work[5],self.work[0],self.work[4],self.work[3])


    def equals(self,another):

        ret = False;

        for i in range(len(self.order)):
            self.roll(self.order[i])
            FLG = True
            for k in range(6):
                if self.number[k] != another.number[k]:
                    FLG = False
                    break
            if FLG == True:
                return True

        return ret

diceA = Dice()
diceB = Dice()

table = list(map(int,input().split()))
diceA.setNumber(table[0], table[1], table[2], table[3], table[4], table[5])

table = list(map(int,input().split()))
diceB.setNumber(table[0], table[1], table[2], table[3], table[4], table[5])

if diceA.equals(diceB):
    print("Yes")
else:
    print("No")



Measured memory_bytes: 5624
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>

ll n, a[210000], b[210000], s[210000];
int main() {
	cin >> n;
	REP(i, n)cin >> s[i];
	REP(i, n) {
		a[i + 1] = max(a[i], s[i]);
	}
	REPR(i, n - 1) {
		b[i] = max(b[i + 1], s[i]);
	}
	REP(i, n) {
		cout << max(a[i], b[i + 1]) << endl;
	}
}





Measured memory_bytes: 6400
#include<iostream>
#include<algorithm>
#include<string>
#include <vector>

using namespace std;

int main(){

	int x,y,s,taxx,taxy,ans;

	while(cin>>x>>y>>s,x||y||s){
		ans=0;
		for(int i=1;i<s-1;i++){
			for(int j=s-1;j>=i;j--){
				taxx=(i*(100+x))/100+(j*(100+x))/100;
				if(s==taxx){
					taxy=(i*(100+y))/100+(j*(100+y))/100;
					ans=max(ans,taxy);
				}
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
bool comp(pair<int,int> &p1,pair<int,int> &p2){
return p1.first<p2.first;
}
int main(){
int N,W;
  cin>>N>>W;
  vector<pair<int,int>> weight;
  
  for(int i=0;i<N;i++){
  int t,u;
    cin>>u>>t;
    weight.push_back(make_pair(u,t));
  }
  sort(weight.begin(),weight.end(),comp);
  long long dp[N][W+1]={0};
  for(int i=0;i<N;i++){
  for(int j=1;j<=W;j++){
  if(j<(weight[i].first)&&i>0)
    dp[i][j]=dp[i-1][j];
    if(j<(weight[i].first)&&i==0)
    dp[i][j]=0;
    if(j>=(weight[i].first)&&i==0)
    dp[i][j]=(long long)(weight[i].second);
    if(j>=(weight[i].first)&&i>0){
    if(dp[i-1][j-(weight[i].first)]+(long long)(weight[i].second)>dp[i-1][j])
       dp[i][j]=dp[i-1][j-(weight[i].first)]+(long long)(weight[i].second);
      else
        dp[i][j]=dp[i-1][j];
    }
  }
  }
  cout<<dp[N-1][W];
  return 0;
}

Measured memory_bytes: 78336
import sys
sys.setrecursionlimit(10**7)



def tansaku(i,j):
	for di in range(-1,2):
		for dj in range(-1,2):
			if 0<=i+di<h and 0<=j+dj<w:
					if visited[i+di][j+dj]:
						continue
					else:
						visited[i][j]=1
						if c[i][j]==0:continue
						tansaku(i+di,j+dj)
			else:continue
			
			
	return

			
def dfs(i,j):
	global count
	if visited[i][j]:return
	visited[i][j]=1
	# print(visited)
	if c[i][j]==0:return
	count+=1
	tansaku(i,j)

while True:
	# print('スタート')
	w,h =list(map(int,input().split()))
	if w==0 and h==0:break
	c=[list(map(int,input().split())) for i in range(h)]
	visited=[[0]*w for i in range(h)]
	count=0
	for s in range(w):
		for t in range(h):
			dfs(t,s)

	print(count)









Measured memory_bytes: 9208
#include<bits/stdc++.h>
using namespace std;
int main(){
	int k;
	string s;
	cin >> k >> s;
	if(s.length() > k){
		for(int i = 0;i < k;i++) cout << s[i];
		cout << "...";
	}else {
		cout << s;
	}
	return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector <int> a(n);
    vector <int> b(n);//int b(n)とすると19行目の配列の代入がうまく行かなかった。
    REP(i,n) {
        cin >> a[i];
        if (a[i]%2 ==0){
        b.at(i)=a[i];
        }
    }
    REP(i,n){
        //cout << b[i] << endl;
        if(b[i]%3!=0 && b[i]%5 !=0){
            cout << "DENIED" << endl;
            return 0;
        }
    }
    cout << "APPROVED" << endl;
    return 0;



}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<queue>
#include<set>
#include<vector>
#include<stack>
#include<map>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;

#define mod 998244353
#define inf 0x7f7f7f7f
#define maxn 500005
#define N 300005
typedef long long ll;

inline int read()
{
    int x = 0;
    int f = 1;
    char c = getchar();
    while (c<'0' || c>'9')
    {    
        if (c == '-')
            f = -1;
        c = getchar();
    }
    while (c >= '0'&&c <= '9')
    {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x*f;
}

//_scc[u]存u点所在强连通分量的标号,out[x]存标号为x的强连通分量的出度,
//cot[x]存标号为x的连通量的点的数目
int n;
struct people{
    int num, i;
    bool operator<(const people & a)const {
        return a.num > num;
    }
} p[100005];
int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> p[i].num;
        p[i].i = i;
    }
    sort(p + 1, p + 1 + n);
    for (int i = 1; i <= n; i++)
        cout << p[i].i <<" ";

}   

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

template <typename T, T F(T, T), T ZERO>
struct SegmentTree {
    T n;
    vector<T> v;

    SegmentTree(T n_){
        n = 1;
        while(n < n_){ n *= 2; }
        v.resize(2 * n - 1);
        fill(v.begin(), v.end(), ZERO);
    }

    // zero-indexed
    void update(ll k, T a){
        k += n - 1;
        v[k] = a;
        while(k > 0){
            k = (k - 1) / 2;
            v[k] = F(v[k * 2 + 1], v[k * 2 + 2]);
        }
    }

    // [a, b), zero-indexed
    T query(ll a, ll b) const {
        return query_internal(a, b, 0, 0, n);
    }

    T get(ll a) const {
        return query(a, a + 1);
    }

    T query_internal(ll a, ll b, ll k, ll l, ll r) const {
        if(r <= a || b <= l){ return ZERO; }
        if(a <= l && r <= b){
            return v[k];
        }else{
            T v1 = query_internal(a, b, k * 2 + 1, l, (l + r) / 2);
            T v2 = query_internal(a, b, k * 2 + 2, (l + r) / 2, r);
            return F(v1, v2);
        }
    }
};


ll or_func(ll x, ll y){
    return x | y;
}

int main(){
    ll n;
    cin >> n;
    string s;
    cin >> s;

    SegmentTree<ll, or_func, 0> st(n);
    REP(i, n){
        ll x = static_cast<ll>(s.at(i) - 'a');
        ll y = 1LL << x;
        st.update(i, y);
    }

    ll q;
    cin >> q;
    REP(i, q){
        ll ti;
        cin >> ti;
        if(ti == 1){
            ll j;
            cin >> j;
            j--;
            char c;
            cin >> c;
            ll x = static_cast<ll>(c - 'a');
            ll y = 1LL << x;
            st.update(j, y);
        }else{
            assert(ti == 2);
            ll li, ri;
            cin >> li >> ri;
            li--; ri--;
            ll tmp = st.query(li, ri + 1);
            ll ans = 0;
            REP(i, 30){
                if((tmp >> i) & 1){
                    ans++;
                }
            }
            cout << ans << endl;
        } 
    }
    return 0;
}


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

int main(){
	ll a,v;	cin>>a>>v;
 	ll b,w;	cin>>b>>w;
  	ll t;	cin>>t;
  if(v>w){
  	double temp=abs(b-a)*(1.0);
    int tm=v-w;
   	double p=(temp/tm);
    if(p<=t){
    	cout<<"YES"<<endl;
    }
    else{
    	cout<<"NO"<<endl;
    }
  }
  else{
  	cout<<"NO"<<endl;
  }
  return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  vector<int> C(N);
  for(int i = 0; i < N; i++) cin >> A[i];
  for(int j = 0; j < N; j++) cin >> B[j];
  for(int k = 0; k < N; k++) cin >> C[k];
  
  int ans = 0;
  for(int l = 0; l < N; l++){
    int eat_index = A[l] - 1;
    ans += B[eat_index];
    if(A[l+1] == A[l] + 1){
      ans += C[eat_index];
    }
  }
  cout << ans;
}

Measured memory_bytes: 256
import java.util.Scanner;

fun main (args : Array<String>) {
  val input = Scanner(System.`in`)
  
  while (input.hasNext()) {
    val N = input.nextInt()
    var isApproved = true;
    
    for (i in 1..N) {
      val A = input.nextInt()
      
      if (A % 2 == 0) {
        if (A % 3 != 0 && A % 5 != 0) {
          isApproved = false
        }
      }
    }
    
    if (isApproved) {
      println("APPROVED")
    } else {
      println("DENIED")
    }
  }
}

Measured memory_bytes: 36740
def ceil(src, range):
    k = src / 1000
    if k == int(k):
        return int(src)
    else:
        return ((int)(src / range) + 1 ) * range

debt = 100000
for x in range (0, int(input())):
    debt = ceil(debt * 1.05, 1000)
    
print(int(debt))

Measured memory_bytes: 7600
#include <bits/stdc++.h>
using namespace std;
int p[100005],pre[100005];
long long cum[100005];
long long get(int a,int b,int c,int dir)
{
	int mx=0,smx=0,pos=a-dir,pos2=a-dir;
	pre[a]=0;
	cum[a]=0;
	for (int i=pos;i!=c-dir;i-=dir)
	{
		pre[i]=max(pre[i+dir],p[i]);
		cum[i]=cum[i+dir]+pre[i];
	}
	long long ret=0;
	for (int i=a;i!=b+dir;i+=dir)
	{
		if (p[i]>mx)
		{
			smx=mx;
			mx=p[i];
		}
		else if (p[i]>smx)
		smx=p[i];
		while (pos!=c-dir && p[pos]<smx)
		pos-=dir;
		ret+=(abs(pos-a)-1LL)*smx;
		while (pos2!=c-dir && p[pos2]<mx)
		pos2-=dir;
		ret+=cum[pos2+dir]-cum[pos+dir];
	}
	return ret;
}
long long solve(int l,int r)
{
	if (l==r)
	return 0;
	int mid=(l+r)/2;
	return solve(l,mid)+solve(mid+1,r)+get(mid+1,r,l,1)+get(mid,l,r,-1);
}
int main()
{
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	scanf("%d",&p[i]);
	printf("%lld",solve(1,n));
}

Measured memory_bytes: 1792
n=int(input())
b=[[int(i) for i in input().split()] for j in range(n)]
a=[[int(i) for i in input().split()] for j in range(n)]
a=sorted(a,key=lambda x:x[0])
b=sorted(b,key=lambda x:x[1],reverse=True)
ans=0

for ai in range(n):
  for bi in range(len(b)):
    if b[bi][0]<a[ai][0] and b[bi][1]<a[ai][1]:
      ans+=1
      del b[bi]
      break
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#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 all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = 1'000'000'007;
// const ll MOD = 998244353;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll H, W, M;
    cin >> H >> W >> M;
    vvec<int> vx(H);
    vec<int> cntx(H,0), cnty(W,0);
    map<l_l, int> mp;
    vector<l_l> cnt_y(1, {-1,-1});
    rep(i,M){
        int h, w;
        cin >> h >> w;
        h--; w--;
        cntx[h]++;
        cnty[w]++;
        mp[{h,w}]++;
    }
    rep(j,W)cnt_y.emplace_back(cnty[j], j);
    sort(all(cnt_y));
    vector<int> kouho_y;
    for(int i = W; i >= 0; i--){
        kouho_y.emplace_back(cnt_y[i].second);
        if(cnt_y[i].first != cnt_y[i-1].first)break;
    }
    ll maxxy = cnt_y.back().first;
    ll ans = 0;
    rep(i,H){
        ll tmp = cntx[i];
        if(ans >= tmp + maxxy)continue;
        for(auto y: kouho_y){
            chmax(ans, tmp + maxxy - (mp[{i,y}] > 0));
            if(ans >= tmp + maxxy)break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 39708
#include<stdio.h>
#include<iostream>
#include<string>
#include<complex>
#include<algorithm>
#include<vector>

int main()
{
	int n;
	long long a[200000], sum{};

	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
	{
		scanf("%lld", a + i);
		a[i] -= i + 1;
	}

	std::sort(a, a + n);

	for (int i = 0; i < n; ++i)
	{
		sum += std::abs(a[i] - a[n / 2]);
	}

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

	return 0;
}

Measured memory_bytes: 1792
program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int64):: n,i,ans=1000
    integer(int64), allocatable:: a(:)

    read*, n
    allocate(a(n))
    read*, a(:)

    do i=1,n-1
        if (a(i+1) > a(i)) then
            ans = ans + (ans/a(i))*(a(i+1)-a(i))
        end if
    end do
    print'(i0)', ans
end program main

Measured memory_bytes: 2868
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
int main(){
  int n;cin>>n;
  vector<ll>num(n);
  for(int i=0;i<n;i++){
    cin>>num[i];
    num[i]--;
  }
  vector<pair<ll,ll> >pii(n);
  vector<ll>A(n);
  vector<ll>B(n);
  for(int i=0;i<n;i++){
    A[i]=i*20001+1;
    B[i]=(20000*20001)+1-(i*20001);
  }
  pii[0]=mp(A[num[0]],B[num[0]]);
  ll now=A[num[0]]+B[num[0]];
  for(int i=1;i<n;i++){
    if(now<A[num[i]]+B[num[i]]){
      //pii[i]=mp(A[num[i]],B[num[i]]);
      now=A[num[i]]+B[num[i]];
    }else{
      B[num[i]]+=(now-(A[num[i]]+B[num[i]]))+1;
      now=A[num[i]]+B[num[i]];
      //pii[i]=mp(A[num[i]],B[num[i]]);
    }
  }
  for(int i=0;i<n;i++){
    cout<<A[i];
    if(i!=n-1)cout<<" ";
  }
  cout<<endl;
  for(int i=0;i<n;i++){
    cout<<B[i];
    if(i!=n-1)cout<<" ";
  }
  cout<<endl;
  // for(int i=0;i<n;i++){
  //   cout<<pii[i].F+pii[i].S;
  //   if(i!=n-1)cout<<" ";
  // }
  // cout<<endl;
  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;} return false;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;} return false;}

int main(){
    ll x, y;
    cin >> x >> y;
    int ans = 0;
    while(x <= y){
        x *= 2;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/**
 🍪 the_hyp0cr1t3
 🍪 29.08.2020 12:17:21
**/
#ifdef W
#include "k_II.h"
#else
#include <bits/stdc++.h>
using namespace std;
#define aylmao cin.tie(nullptr)->sync_with_stdio(false);
#endif
#define endl '\n'
#define pb emplace_back
// #define int long long
#define sz(x) (int)((x).size())
#define all(x) x.begin(), x.end()
#define Luv(...) [&](auto&& u, auto&& v) { return __VA_ARGS__; }
auto chmax = [](auto& A, auto&& B) { return B > A? A = B, true : false; };
auto chmin = [](auto& A, auto&& B) { return B < A? A = B, true : false; };

using ll = long long;
using pii = pair<int,int>;
const ll DESPACITO = 2e18;
const int INF = 2e9, MOD = 1e9+7;

template<class T> class Y {
    T f;
public:
    template<class U> explicit Y(U&& f): f(forward<U>(f)) {}
    template<class... Args> decltype(auto) operator()(Args&&... args) {
        return f(ref(*this), forward<Args>(args)...);
    }
}; template<class T> Y(T) -> Y<T>;

const int N = 300 + 5;
double cache[N][N][N];

int32_t main() {
    aylmao
    int i, j, k, n, cnt[4] = {};
    cin >> n;
    for(i = 0; i < n; i++) {
        int a; cin >> a; cnt[a]++;
    }
    memset(cache, -1, sizeof(cache));

    cout << fixed << setprecision(10) << Y([&](auto dp, int i, int j, int k) -> double {
        if(min({i, j, k}) < 0 or max({i, j, k}) == 0) return 0.0;
        auto& ans = cache[i][j][k];
        if(ans > 0) return ans;
        return ans = (n + dp(i-1, j, k)*i + dp(i+1, j-1, k)*j + dp(i, j+1, k-1)*k) / (i+j+k);
    })(cnt[1], cnt[2], cnt[3]);
    
    return 0;
}

Measured memory_bytes: 225432
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;

int main() {
	int n,sum=0;
	cin>> n;
	int S[10000];
	for (int i = 0;i < n;i++) cin >> S[i];
	int q;
	cin >> q;
	int T[500];
	for (int i = 0;i < q;i++) {
		cin >> T[i];
		S[n] = T[i];
		int j = 0;
		while (S[j] != T[i]) j++;
		if(j!=n) sum++;
	}

	cout << sum << endl;
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<ll,pll> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n;
vvp g;
vi a;

void dfs(int v,int pre,int x){
	a[v]=x;
	for(auto p:g[v]){
		int u=p.first,c=p.second;
		if(u!=pre) dfs(u,v,(x+c)%2);
	}
}

int main(){
	cin>>n;
	g=vvp(n);
	a=vi(n);
	for(int i=0;i<n-1;i++){
		int u,v,c;
		cin>>u>>v>>c;
		u--;v--;
		g[u].push_back({v,c});
		g[v].push_back({u,c});
	}
	dfs(0,-1,0);
	for(auto i:a) cout<<i<<endl;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = (ll)a;i < (ll)b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = (ll)b-1LL;i >= (ll)a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

const ll INF=(1LL<<50);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif
template<class T>
bool chmax(T& a,const T& b){
  if(a<b){
    a=b;
    return true;
  }
  return false;
}
template<class T>
bool chmin(T& a,const T& b){
  if(a>b){
    a=b;
    return true;
  }
  return false;
}
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}

const string YES = "Yes";
const string NO = "No";

void solve(long long N, long long M, std::vector<long long> A){
  ll sum=accumulate(A.begin(),A.end(),0LL);
  ll cnt=0;
  REP(N){
    if(4*M*A[i]<sum){
      ;
    }else{
      ++cnt;
    }
  }
  if(cnt>=M){
    cout<<YES<<endl;
  }else{
    cout<<NO<<endl;
  }
}

int main(){
  cout<<setprecision(1000);
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, M, std::move(A));
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
#define mod 1e9
//int a[100005],b[i][30];
int32_t main() {
	/*int t;
	cin>>t;
	while(t--)
	{
		int n,i,j,k;
		cin>>n;
		for(i=1;i<=n;i++)
		{
			cin>>a[i];
			for(j=0;j<=26;j++)
				b[i][j]=b[i][j-1];
			b[i][a[i]]++;
		}*/
	string s;
	cin>>s;
	int i;
	map<char ,int> mp;
	for(auto c:s)
		mp[c]++;
	if(mp.size()==26)
		cout<<"None\n";
	else 
	{
		for(i=0;i<26;i++)
		{
			char k=(char)('a'+i);
	
			if(!mp[k])
			{	cout<<k;
				break;
			}
		}
		
	}
		
		
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <queue>


using namespace std;


int main() {
	int N, score, No;
	string city;
	pair<pair<string, int>, int> rest[110];

	cin >> N;

	for (int i = 0; i < N; i++) {
		cin >> city >> score;
		rest[i] = make_pair(make_pair(city, -score), i);
	}

	sort(rest, rest + N);

	for (int i = 0; i < N; i++) {
		cout << rest[i].second + 1 << "\n";
		
	}
	
	return 0;
}


Measured memory_bytes: 504
#include<bits/stdc++.h>
const int N=2e5+10;
int a[N],n;
using namespace std;
typedef pair<int,int> pi;
set<pi> s;
int check(int lim){
	s.clear();
	s.insert(make_pair(-1,0));
	for (int i=1;i<=n;i++){
		if (a[i]>a[i-1])continue;
		while (s.size()&&s.rbegin()->first>a[i])s.erase(*s.rbegin());
		for (int j=a[i];j>=0;j--){
			if (j==0)return 0;
			if (s.rbegin()->first!=j){
				s.insert(make_pair(j,2));
				break;
			}
			int k=s.rbegin()->second;
			s.erase(*s.rbegin());
			if (k<lim){
				s.insert(make_pair(j,k+1));
				break;
			}
		}
	}
	return 1;
}
int main(){
	cin>>n;
	int ans=0;
	for (int i=1;i<=n;i++)scanf("%d",&a[i]),ans|=a[i]<=a[i-1];
	if (!ans){
		cout<<1<<endl;
		return 0;
	}
	for (int u=1<<18;u;u>>=1){
		if (check(ans+u));
		else ans+=u;
	}
	cout<<ans+1<<endl;
}

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

using ll = long long;
const ll INF = 1e18;

// ダイクストラ法 O(ElogV)
vector<ll> d; // 最短距離

void dijkstra(const vector<vector<pair<int, ll>>> &G, int s) {
  priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> pq; // first:最短距離 second:頂点の番号
  d.resize(G.size(), INF); // 初期化
  d[s] = 0;
  pq.push(make_pair(0, s));
  while (!pq.empty()) {
    pair<ll, int> p = pq.top();
    pq.pop();
    int v = p.second;
    if (d[v] < p.first) continue;
    for (int i = 0; i < G[v].size(); i++) {
      pair<int, ll> p2 = G[v][i];
      if (d[p2.first] > d[v] + p2.second) {
        d[p2.first] = d[v] + p2.second;
        pq.push(make_pair(d[p2.first], p2.first));
      }
    }
  }
  return;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  // 重み付き無向(有向)グラフの隣接リスト
  int n, m; // n:頂点数 m:辺数
  cin >> n >> m;
  
  vector<vector<pair<int, ll>>> G(n); // G:頂点数nのグラフの隣接リスト
  
  vector<int> imos(n);
  for (int i = 0; i < m; i++) {
    int l, r;
    ll c;
    cin >> l >> r >> c;
    l--;
    r--;
    G[l].emplace_back(make_pair(r, c));
    imos.at(l)++;
    imos.at(r)--;
  }
  
  for (int i = 0; i < n; i++) {
    if (i) imos.at(i) += imos.at(i - 1);
    if (imos.at(i) > 0) G[i + 1].emplace_back(make_pair(i, 0));
  }
  
  dijkstra(G, 0);
  
  if (d[n - 1] == INF) cout << "-1\n";
  else cout << d[n - 1] << '\n';
}

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

int main(){

 int r, c, t[101][101] = {};

 cin >> r >> c;

 for (int i = 0; i < r; i++) {
  for (int j = 0; j < c; j++) {
   cin >> t[i][j];
   t[r][j] += t[i][j];
   t[i][c] += t[i][j];
  }
  t[r][c] += t[i][c];
 }

 for (int i = 0; i <= r; i++) {
  for (int j = 0; j < c; j++) {
   cout << t[i][j] << " ";
  }
  cout << t[i][c] << endl;
 }
 
 return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
const int INF=0x3f3f3f3f;

int main(){
	int n,t;
	int a,b,ans=INF;
	scanf("%d%d",&n,&t);
	while(n--){
		scanf("%d%d",&a,&b);
		if(b<=t) ans=min(ans,a);
	}
	if(ans==INF) printf("TLE\n");
	else printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    var n = readLine()!!.toInt()

    var o = false
    for (i in 1 .. 9){
        for (j in 1 .. 9){
            if (i * j == n) {
                o = true
            }
        }
    }
    println(if (o) "Yes" else "No")
}

Measured memory_bytes: 31788
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll n;
    cin>>n;
    ll a[n][3];
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<3;j++)
        {
            cin>>a[i][j];
        }
    }
    ll mi = max(a[0][0],max(a[0][1],a[0][2]));
    for(ll i=1;i<n;i++)
    {
        for(ll j=0;j<3;j++)
        {
            if(j==0)
            a[i][j]=a[i][j]+max(a[i-1][1],a[i-1][2]);
            if(j==1)
            a[i][j]=a[i][j]+max(a[i-1][0],a[i-1][2]);
            if(j==2)
            a[i][j]=a[i][j]+max(a[i-1][0],a[i-1][1]);
            mi=max(mi,a[i][j]);
        }
    }
    cout<<mi;
    return 0;
}

Measured memory_bytes: 2560
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n,k = readInts()
print(n-k+1)


Measured memory_bytes: 5128
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <bitset>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <chrono>
#include <random>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

template<typename T> T gcd(T a, T b) {
    if (a < b) return gcd(b, a);
    T r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

template<typename T> T lcm(const T a, const T b) {
    return a / gcd(a, b) * b;
}

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

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

// End of template.

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

    int n;
    cin >> n;

    print((n + 999) / 1000 * 1000 - n);

    return 0;
}

/*
  __ _   ___ _ __  _ __
 / _` | / __| '_ \| '_ \
| (_| || (__| |_) | |_) |
 \__,_(_)___| .__/| .__/
            |_|   |_|
*/


Measured memory_bytes: 3632
#include<stdio.h>

int main(){
    int an[6];
    for(int i=0; i<5; i++){
        scanf("%d", &an[i]);
    }

    int k;
    scanf("%d", &k);

    for(int i=0; i<5; i++){
        for(int j=i; j<5; j++){
            if(i==j)
                continue;
            if(an[j] - an[i] > k){
                printf(":(\n");
                return 0;
            }
        }
    }

    printf("Yay!\n");
    return 0;


    return 0;
}

Measured memory_bytes: 128
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

int main(int argc, char const *argv[])
{
	int n;
	scanf("%d",&n);
	printf("%d\n", 600 * (n / 15) + 800 * (n - n / 15));
	return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
#define N_ 10010000
using namespace std;
int H, W, K;
long long Mod = 1000000007;
long long F[N_ * 2], InvF[N_ * 2];
long long Pow(long long a, long long b) {
	long long r = 1;
	while (b) {
		if (b & 1)r = r*a%Mod;
		a = a*a%Mod; b >>= 1;
	}
	return r;
}
long long Comb(int a, int b) {
	if (a < b || b < 0)return 0;
	return F[a] * InvF[b] % Mod*InvF[a - b] % Mod;
}
long long res;
int main() {
	int i;
	F[0] = 1;
	for (i = 1; i < N_ * 2; i++)F[i] = F[i - 1] * i%Mod;
	InvF[i - 1] = Pow(F[i - 1], Mod - 2);
	for (i = i - 1; i >= 1; i--)InvF[i - 1] = InvF[i] * i%Mod;
	scanf("%d%d%d", &H, &W, &K);
	long long ttt = Comb(K, 3) + Comb(K, 2);
	for (i = 0; i <= H; i++) {
		int a = i, b = K - i;
		if (0 > b || b > W)continue;
		long long t = Comb(a + b - 2, a - 1) * ttt * 2 % Mod;
		t += (1ll * K*(K + 1) / 2 + K) % Mod*Comb(a + b, a) % Mod;
		long long tt = F[H] * InvF[H - a] % Mod*F[W] % Mod*InvF[W - b] % Mod;
		res = (res + t*tt) % Mod;
	}
	printf("%lld\n", res);
}

Measured memory_bytes: 312960