akhauriyash/Code-Regression huggingface dataset:
n=gets.to_i;
a=Array.new(n){Array.new(n,0)}
m=Array.new
n.times do |i|
  m.clear
  m=gets.split.map{|i|i.to_i}
  m[1].times do |j|
    a[m[0]-1][m[j+2]-1]=1
  end
end
n.times do |i|
  (2*n-1).times do|j|
    if j%2==0 then
      print a[i][j/2]
    else
      print " "
    end
  end
  print "\n"
end


Measured memory_bytes: 6960
#include <bits/stdc++.h>
#define rep(__i, l, r) for(int __i = (int)(l);__i <= (int)(r);++__i)
#define M 26
#define fi first
#define se second
#define PB push_back
#define MP make_pair
#define ls (rt<<1)
#define rs (rt<<1|1)
using namespace std;
typedef long long ll;
//#define double long double
typedef unsigned long long ull;
//typedef __int128 LLL;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll inf = 1e9 + 10;
const int maxn = 1e6 + 200;
const int mod = 1e9 + 7;
const double eps = 1e-9;
int dcmp(double x) {
	if (fabs(x) < eps) return 0;
	return x < 0 ? -1 : 1;
}
ll powmod(ll x, ll n) {
	ll ret = 1;
	for (; n > 0; n >>= 1, x = x * x % mod)if (n & 1) ret = ret * x % mod;
	return ret;
}
//head
int sz;
struct SegTree {
		int lazy[maxn << 2], mx[maxn << 2];
		void push(int rt) {
			if (lazy[rt] == 0) return;
			lazy[ls] += lazy[rt], lazy[rs] += lazy[rt];
			mx[ls] += lazy[rt], mx[rs] += lazy[rt];
			lazy[rt] = 0;
		}
		void maintain(int rt) {
			mx[rt] = max(mx[ls], mx[rs]);
		}
		void build(int l, int r, int rt) {
			lazy[rt] = 0;
			if (l == r) mx[rt] = -(sz - l);
			else {
				int mid = l + r >> 1;
				build(l, mid, ls);
				build(mid + 1, r, rs);
				maintain(rt);
			}
		}
		void update(int l, int r, int rt, int ql, int qr, int v) {
			if (ql <= l && qr >= r) {
				lazy[rt] += v;
				mx[rt] += v;
			} else {
				push(rt);
				int mid = l + r >> 1;
				if (ql <= mid) update(l, mid, ls, ql, qr, v);
				if (qr > mid) update(mid + 1, r, rs, ql, qr, v);
				maintain(rt);
			}
		}
		int query(int l, int r, int rt, int ql, int qr) {
			if (ql <= l && qr >= r) return mx[rt];
			int mid = l + r >> 1, mx = (int) -1e9;
			push(rt);
			if (ql <= mid) mx = query(l, mid, ls, ql, qr);
			if (qr > mid) mx = max(mx, query(mid + 1, r, rs, ql, qr));
			return mx;
		}
} Tree;
pii seg[maxn];
int n, m;

bool work() {
	if (!(cin >> n >> m)) return 0;
	swap(n, m);
	int res = 0;
	rep(i, 1, m) {
		cin >> seg[i].fi >> seg[i].se;
	}
	sort(seg + 1, seg + m + 1, [](const pii &a, const pii &b) {
			return a.fi < b.fi;
	});
	sz = n + 1;
	Tree.build(1, sz, 1);
	int mx = 0;
	for (int i = 0, p = 1; i < sz; ++i) {
		while (p <= m && seg[p].fi <= i) {
			Tree.update(1, sz, 1, 1, seg[p].se, 1);
			++p;
		}
		int now = Tree.query(1, sz, 1, i + 1, sz) - i;
		mx = max(mx, now);
	}
	mx = max(mx, m - n);
	cout << mx << '\n';
	return 1;
}

int main() {
//	freopen("1.in", "r", stdin);
//	freopen("2.out", "w", stdout);
	srand(time(NULL));
//	ios::sync_with_stdio(0), cin.tie(0);
	double c = clock();
	int T = 2e6;
	while (T--) {
		if (!work()) break;
	}
	// cout << (clock() - c) / CLOCKS_PER_SEC << '\n';
	return 0;
}

Measured memory_bytes: 9984
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string a;
	getline(cin,a);
	int l=a.length();
	if(a[0]==a[l-1])
	{
		if(l%2==0) cout<<"First"<<endl;
		else cout<<"Second"<<endl;
	}
	else
	{
		if(l%2==0) cout<<"Second"<<endl;
		else cout<<"First"<<endl;
	}
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

ll a[110];
int main(){
	ll n;
	scanf("%lld",&n);
	rep(i,0,n)scanf("%lld",a+i);
	sortdown(a,n);
	ll ans=0;
	repp(i,0,n,2)ans+=a[i]-a[i+1];
	printf("%lld",ans);
}

Measured memory_bytes: 128
n = int(input())
h = list(map(int,input().split()))
s = []
ph = 0
for i in range(n-1):
    if not(h[i+1]==h[i]):
        s.append(h[i+1]-h[i])


mt1 = True
yes = True
for i in range(len(s)):
    if s[i]<-1:
        print("No")
        yes = False
        break
    else:
        if (not mt1) and s[i]<0:
            print("No")
            yes = False
            break
        if s[i]<0:
            mt1 = False
        else:
            mt1 = True
if yes:
    print("Yes")


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

int main(){
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    cout << (h2-h1)*60+(m2-m1)-k << endl;
}

Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var SA = Console.ReadLine();
            var SB = Console.ReadLine();
            var SC = Console.ReadLine();
            var a = 0;
            var b = 0;
            var c = 0;
            var turn = 'a';
            while (true)
            {
                switch (turn)
                {
                    case 'a':
                        if (a == SA.Length) { Console.WriteLine("A");return;}
                        turn = SA[a];
                        a++;
                        break;
                    case 'b':
                        if (b == SB.Length) { Console.WriteLine("B"); return; }
                        turn = SB[b];
                        b++;
                        break;
                    case 'c':
                        if (c == SC.Length) { Console.WriteLine("C"); return; }
                        turn = SC[c];
                        c++;
                        break;
                }
            }
        }
    }
}


Measured memory_bytes: 2648
#include <bits/stdc++.h>
    using namespace std;
    int main()
    {
    string s;
    cin>>s;
    int cnta=0;
    int cntb=0;
    for(int i=0; i<s.size(); i++)
    {
        if(i%2==0&&s[i]!='1') {++cnta;}
        else if(i%2!=0&&s[i]!='0'){++cnta;}
 
        else if(i%2==0&&s[i]!='0') {++cntb;}
        else if(i%2!=0&&s[i]!='1'){++cntb;}
    }
    cout<<min(cnta,cntb)<<endl;
    }

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define boost ios_base::sync_with_stdio(0); cin.tie(); cout.tie()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define endl '\n'
#define len(a) a.length()
#define TIME cout << endl << "Time execute: " << clock() / (double)CLOCKS_PER_SEC << " sec" << endl;
#define f first
#define s second

#pragma GCC optimize("-O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;

typedef long long ll;

const long long inf = 1e18;
const double eps = 1e-6;
const long long mod = 1e9 + 7;

vector <vector <char>> a;
int n, m, k;
ll ans = 0;
map <pair <vector <int>, vector <int>>, bool> used;

void brute (vector <int> h, vector <int> w) {
    if (used[{h, w}])
        return;
    int q = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            auto it1 = lower_bound(all(h), i);
            auto it2 = lower_bound(all(w), j);
            bool ok1, ok2;
            ok1 = ok2 = true;
            if (it1 != h.end() && *it1 == i) {
                ok1 = false;
            }
            if (it2 != w.end() && *it2 == j) {
                ok2 = false;
            }
            if (ok1 && ok2 && a[i][j] == '#') {
                q++;
            }
        }
    }
    if (q == k) {
        ans++;
        used[{h, w}] = true;
    }

    int st_h, st_w;
    if (h.size() > 0) {
        st_h = h.back() + 1;
    }
    else {
        st_h = 0;
    }

    if (w.size() > 0) {
        st_w = w.back() + 1;
    }
    else {
        st_w = 0;
    }


    for (int i = st_h; i < n; i++) {
        h.push_back(i);
        brute(h, w);
        h.pop_back();
    }

    for (int i = st_w; i < m; i++) {
        w.push_back(i);
        brute(h, w);
        w.pop_back();
    }
}

int32_t main()
{
    boost;
    cin >> n >> m >> k;
    a.resize(n);
    for (int i = 0; i < n; i++) {
        a[i].resize(m);
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    vector <int> h, w;
    brute(h, w);
    cout << ans;
    return 0;
}



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

using namespace std;
int n,i,a,c,nr,ok,v[200005],b[200005],poz,d,maxim,maxim2;
long long sum;
int main()
{
    cin>>n;
    for (i=1;i<=n;i++)
    {
        cin>>v[i];
        if (v[i]>maxim)
        {
            maxim2=maxim;
            maxim=v[i];
        }
        else
        {
             if (v[i]>maxim2)
             {
                 maxim2=v[i];
             }
        }
    }
    for (i=1;i<=n;i++)
    {
        if (v[i]==maxim)
        {
            cout<<maxim2;
        }
        else
        {
            cout<<maxim;
        }
        cout<<'\n';
    }
}


Measured memory_bytes: 2432
#include <iostream>

using namespace std;
 
int main(){
    int W,a,b;
 
    cin >> W >> a >> b;

    int aw = a + W;
    int bw = b + W;

    if(bw < a){
        cout << a - bw << endl;
        exit(0);
    }

    if(aw < b){
        cout << b - aw << endl;
        exit(0);
    }

    if((a <= bw && bw <= aw) || (a <= b && b <= aw)){
        cout << 0 << endl;
        exit(0);
    }

    return 0;
}

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

int main() {
	int a, b;
	char op;
	
	while (1) {
		cin >> a >> op >> b;
		if (op == '?' )break;

		if (op == '+')cout << a + b << endl;
		else if (op == '-')cout << a - b << endl;
		else if (op == '*')cout << a * b << endl;
		else if (op == '/')cout << a / b << endl;
	}
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lb;
#define REP(i,j,n) for (int i=j;i<(n);i++)
#define RREP(i,n) for (int i = n; 0<i;i--)
#define print(out) cout<< out  << "\n";
#define mod 1000000007
const int INF = 1e9;

int main(){
  string S;cin>>S;
  string s1="",s2="";
  int ans0=0,ans1=0;
  REP(i,0,S.size()){
    if(i%2==0){
      if(S.at(i)!='0'){ans0++;}
      if(S.at(i)!='1'){ans1++;}
    }
    if(i%2==1){
      if(S.at(i)!='1'){ans0++;}
      if(S.at(i)!='0'){ans1++;}
    }
  }
  print(min(ans0,ans1))
  

}


Measured memory_bytes: 512
N = int(input())
D, X = [int(n) for n in input().split()]
A = [int(input()) for _ in range(N)]

s = 0

for a in A:
    if a == 1:
        s += D // a
    else:
        s += sum([1 for d in list(range(1, D+1)) if d % a == 1])

print(s + X)


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

int main()
{
  int a, b;
  cin >> a >> b;
  if(a % 2 && b % 2) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3524
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace A
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var ab = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            Console.WriteLine(ab[0] > 9 || ab[1] > 9 ? -1 : ab[0] * ab[1]);
        }
    }
}


Measured memory_bytes: 13396
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
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; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール
constexpr ll pdiv = 1000000007LL;

// 処理内容
int main() {
    
    ll n; cin >> n;
    string s; cin >> s;

    // dp[i][j] := i+1個置いて、前に置いたのが小さい順で(0-indexed)j番目の組み合わせの数
    vector<vector<ll>> dp(n, vector<ll>(n, 0));
    REP(i, n) {
        dp[0][i] = 1;
    }
    REP(i, n-1) {
        vector<ll> imos(n+1, 0);
        REP(j, n) imos[j+1] = (imos[j] + dp[i][j]) % pdiv;
        if (s[i] == '>') {
            RANGE(j, 0, n-i-2) {
                (dp[i+1][j] += (pdiv + imos[n] - imos[j+1]) % pdiv) %= pdiv;
            }
        } else {
            RANGE(j, 0, n-i-2) {
                (dp[i+1][j] += (pdiv + imos[j+1] - imos[0]) % pdiv) %= pdiv;
            }
        }
    }

    cout << accumulate(ALL_OF(dp.back()), 0LL) << endl;
    
}

Measured memory_bytes: 70656
''' Hey stalker :) '''
INF = 10**10
def main():
    #print = out.append
    ''' Cook your dish here! '''
    n, d, a = get_list()
    monsters = [get_list() for _ in range(n)]
    monsters.sort()
    sm = 0
    updates = []
    ptr = 0
    res = 0
    for x, helth in monsters:
        while ptr<len(updates) and updates[ptr][0]<=x:
            sm += updates[ptr][1]
            ptr += 1
        if helth>sm:
            times = (helth-sm+a-1)//a
            k = times*a
            res += times
            sm += k
            updates.append([x+2*d+1, -k])
    print(res)

''' Pythonista fLite 1.1 '''
import sys
#from collections import defaultdict, Counter
#from bisect import bisect_left, bisect_right
#from functools import reduce
#import math
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
out = []
get_int = lambda: int(input())
get_list = lambda: list(map(int, input().split()))
main()
#[main() for _ in range(int(input()))]
print(*out, sep='\n')


Measured memory_bytes: 124228
#include <iostream>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>
#include <utility>
#include <bitset>
#include <queue>

using namespace std;

using ll = long long;

int main()
{
	int n, a, b;
	cin >> n >> a >> b;

	ll cost = 0;
	ll current;
	cin >> current;

	for (int i = 1; i < n; i++)
	{
		ll next;
		cin >> next;
		cost += min((ll)b, (next - current) * a);
		current = next;
	}

	cout << cost << endl;
}

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

int main(){

    int n, m, i, sum=0;
    cin >> n >> m;
    int a[m];

    for(i=0;i<m;i++){
        cin >> a[i];
        sum += a[i];
    }

    if(sum <= n){
        cout << n-sum << endl;
    }else{
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define F first
#define S second
#define pi acos(-1)
using ll = long long;
using namespace std;
using namespace __gnu_pbds;
using vl = vector<ll>;
using pll =  pair<ll,ll>;
const ll mod = 1000000007;
const ll infi = 1000000000000000;
const ll md = 998244353;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;


ll power(ll x,ll y){
    ll res = 1;
    while(y){
        if(y&1)
            res = (res*x)%md;
        x = (x*x)%md;
        y = y/2;
    }
    return res;
}


void solve(){
    ll a,b,v,w,t,f = 1;
    cin>>a>>v>>b>>w>>t;
    ll al1 = a + t*v;
    ll bl1 = b + t*w;
    ll al2 = a - t*v;
    ll bl2 = b - t*w;
    if(a >= b && al2 <= bl2)
        cout<<"YES";
    else if(b >= a && al1 >= bl1)
        cout<<"YES";
    else
        cout<<"NO";
}
 
int main()
{
    
   
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //int n; cin>>n; for (int i = 0; i < n; ++i)
    solve();
    return 0;
}


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

#define RAD2DEG(rad) (((rad)/2/M_PI)*360)

void solve(double a, double b, double x){
    x /= a;
    if(x >= a * b / 2){
        const double y = 2 * (b - x / a);
        const double t = atan2(y, a);
        printf("%.8f\n", RAD2DEG(t));
    }else{
        const double y = 2 * x / b;
        const double t = atan2(y, b);
        printf("%.8f\n", RAD2DEG(M_PI / 2 - t));
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    long long x;
    scanf("%lld",&x);
    solve(a, b, x);
    return 0;
}


Measured memory_bytes: 896
from operator import itemgetter
import heapq

N, M = map(int, input().split())
pairs = [tuple(map(int, input().split())) for _ in range(N)]
pairs.sort(key = itemgetter(0))

heap = []
reward = 0
index_of_pairs = 0   
for i in range(1, M+1):
    while index_of_pairs < N and pairs[index_of_pairs][0] <= i:
        heapq.heappush(heap, -pairs[index_of_pairs][1])
        index_of_pairs += 1
    if heap:
        reward -= heapq.heappop(heap)

print(reward)            


Measured memory_bytes: 20464
#include<bits/stdc++.h>
using namespace std;
struct Node{
	   int key,id;
	   Node *parent,*left,*right;
};
Node *root,*NIL;
bool f;
vector<int> r;
void find(int k){
	 Node *x;
	 x=root;
	 while (x!=NIL && k!=x->key){
	 	if (k<x->key)
	 	   x=x->left;
	 	else
	 	   x=x->right;
	 }
	 if (x!=NIL)
	    cout<<"yes"<<endl;
	 else
	    cout<<"no"<<endl;
}
void insert(int k){
	 Node *y,*x,*z;
	 y=NIL;
	 x=root;
	 z=(Node *)malloc(sizeof(Node));
	 z->key=k;
	 z->left=NIL;
	 z->right=NIL;
	 while (x!=NIL){
	 	   y=x;
	 	   if (z->key<x->key)
	 	     x=x->left;
	 	   else
	 	     x=x->right;
	 }
	 if (y==NIL){
	 	root=z;
	 }
	 else
	    if (z->key<y->key)
	       y->left=z;
	    else
	       y->right=z;
}
void pre(Node *u){
	 if (u==NIL) return;
	 //r.push_back(u->key);
	 cout<<' '<<u->key;
	 pre(u->left);
	 pre(u->right);
}
void in(Node *u){
	 if (u==NIL) return;
	 in(u->left);
	 cout<<' '<<u->key;
	 //r.push_back(u->key);
	 in(u->right);
}
int n,x;
string s;
int main(){
	cin>>n;
	for (int i=0; i<n; i++){
		cin>>s;
		if (s[0]=='i'){
			cin>>x;
			insert(x);
		}
		else{
			if (s[0]=='p'){
			   in(root);
		       cout<<'\n';
		       pre(root);
			   cout<<'\n';
			}
			else{
				cin>>x;
				f=false;
				find(x);
			}
		}
		   
	}
	
	return 0;
} 


Measured memory_bytes: 21800
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()
	N := sc.NextInt()

	d := 100 * N / 108
	if 100*N%108 != 0 {
		d++
	}
	//fmt.Println(d)
	if d+8*d/100 == N {
		fmt.Println(d)
	} else {
		fmt.Println(":(")
	}

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


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

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

const int maxn = 4000 + 5;
const int mod = 924844033;
const int oo = 0x3f3f3f3f;

template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }

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

template<typename T> T read() {
	T n(0), f(1);
	char ch = getchar();
	for( ;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
	for( ; isdigit(ch); ch = getchar()) n = n * 10 + ch - 48;
	return n * f;
}

int fac[maxn];
int f[maxn][maxn][2];
bool vis[maxn][2], a[maxn];

int main() {
#ifndef ONLINE_JUDGE
    //freopen("data.txt", "r", stdin);
    //freopen("ans.txt", "w", stdout);
#endif

    int n, k, s = 0;
    n = read<int>(), k = read<int>();

    fac[0] = 1;
    for(int i = 1; i <= n; i++) fac[i] = 1LL*fac[i-1]*i % mod;

    for(int i = 1; i <= n; i++) {
        for(int j = 0; j < 2; j++) if(!vis[i][j]) {
            int u = i, v = j, len = 0;
            while(u <= n) {
                vis[u][v] = 1;
                ++ len;
                u += k, v ^= 1;
            }
            a[s += len] = 1;
        }
    }

    f[1][0][0] = 1;

    for(int i = 2; i <= s; i++) {
        for(int j = 0; j <= n; j++) {
            (f[i][j][0] += f[i-1][j][0] + f[i-1][j][1]) %= mod;
            if(!a[i-1]) (f[i][j][1] += f[i-1][j-1][0]) %= mod;
        }
    }

    static int M[maxn];
    for(int i = 0; i <= n; i++) 
        M[i] = (f[s][i][0]+f[s][i][1]) % mod;

    long long ans = 0;
    for(int i = 0; i <= n; i++) ans = (ans + (i&1 ? -1LL : 1LL)*fac[n-i]*M[i] % mod + mod) % mod;
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 124544
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import Data.List (group)

main :: IO ()
main = do
  (_ : _) <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  cs <- getLine :: IO String
  print . length . group $ cs

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 6524
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int l ,r ,d ,a ,L ,R;
  cin >> l >> r>> d;
  
  R = r - r % d;
    
  if (l % d == 0) {
   L = l;
    }
  else {
   L = l + d - l % d;
  }
  
  a = ( R - L ) / d + 1;
 
  cout << a << endl;
}

Measured memory_bytes: 3616
#include <cstdio>
int main() {
	int n;
	scanf("%d", &n);
	long long sum_power = 1;
	for (int i = 1; i <= n; i++) {
		sum_power = (sum_power*i) % 1000000007;
	}
	printf("%lld", sum_power);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include <algorithm>
#include<string>
#include <numeric>
#include<math.h>
#include <bits/stdc++.h>
using namespace std;

int main(void) {
    int a,b;
    cin>>a>>b;
    if(a+b>=10)cout<<"error"<<endl;
    else cout<<a+b<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}


int d[3] = {-1,0,1};
int main(){
   string s;cin>>s;
   cout<<(s[0]=='9'||s[1]=='9'?"Yes":"No");
}



Measured memory_bytes: 256
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

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

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")



/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main() { 
  int n,m;cin>>n>>m;

  cout << (n==m ? "Yes" : "No") << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int MAXN = 1010;
const int MAXV = MAXN*MAXN/2;
int id[MAXN][MAXN];
vector<int> to[MAXV];
bool visited[MAXV];
bool calculated[MAXV];

int dp[MAXV];

int toId(int i, int j) {
  if(j < i) swap(i, j);
  return id[i][j];
}

int dfs(int v) {
  if(visited[v]) {
    if(!calculated[v]) return -1;
    return dp[v];
  }

  visited[v] = true;
  dp[v] = 1;
  for(int u: to[v]) {
    int res = dfs(u);
    if(res == -1) return -1;
    dp[v] = max(dp[v], res+1);
  }
  calculated[v] = true;
  return dp[v];
}

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int N; cin >> N;
  vector<vector<int>> A(N, vector<int>(N-1));
  for(int i = 0; i < N; i++) {
    for(int j = 0; j < N-1; j++) {
      cin >> A[i][j];
      A[i][j]--;
    }
  }

  int V = 0;
  for(int i = 0; i < N; i++) {
    for(int j = 0; j < N; j++) {
      if(i < j) id[i][j] = V++;
    }
  }

  for(int i = 0; i < N; i++) {
    for(int j = 0; j < N-1; j++) {
      A[i][j] = toId(i, A[i][j]);
    }

    for(int j = 0; j < N-2; j++) {
      to[A[i][j+1]].push_back(A[i][j]);
    }
  }

  int ans = 0;
  for(int i = 0; i < V; i++) {
    int res = dfs(i);
    if(res == -1) {
      cout << -1 << endl;
      return 0;
    }
    ans = max(ans, res);
  }
  cout << ans << endl;

  return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n + 1);
    vector<int> b(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        b[a[i]] = i;
    }
    for (int i = 1; i <= n; i++) {
        cout << b[i] << " ";
    }

    cout << endl;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

const int mod = 998244353;

struct mint{
  ll x;
  mint(ll x = 0):x((x % mod + mod) % mod){};
  mint pow(ll y) const {
    mint res(1);
    mint a(x);
    while(y>0){
      if(y&1) res *= a;
      a *= a;
      y >>= 1;
    }
    return res;
  }
  mint inv() const{ return pow(mod-2); }
  mint& operator+= (const mint a) noexcept {
    if((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-= (const mint a) noexcept {
    if((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*= (const mint a) noexcept {
    (x *= a.x) %= mod;
    return *this;
  }
  mint& operator/= (const mint a) noexcept {
    return (*this) *= a.inv();
  }
  mint operator+ (const mint a) const noexcept {
    mint res(*this);
    return res += a;
  }
  mint operator- (const mint a) const noexcept {
    mint res(*this);
    return res -= a;
  }
  mint operator* (const mint a) const noexcept {
    mint res(*this);
    return res *= a;
  }
  mint operator/ (const mint a) const noexcept{
    mint res(*this);
    return res /= a;
  }
};

ostream& operator<<(ostream& stream, const mint& n){
  stream << n.x;
  return stream;
};

struct comb{
  vector<mint> fact, ifact;
  comb(int n): fact(n+1), ifact(n+1){
    fact[0] = 1;
    for(int i = 1; i <= n; i++) fact[i] = fact[i-1] * i;
    ifact[n] = fact[n].inv();
    for(int i = n; i >= 1; i--) ifact[i-1] = ifact[i] * i;
  }
  mint operator()(int n, int k) const noexcept{
    if(k < 0 || n < k) return 0;
    return fact[n] * ifact[k] * ifact[n-k];
  }
};

using P = pair<ll, ll>;

mint dp[200005];

int main(void){
  ll n, k;
  cin >> n >> k;
  vector<P> s;
  REP(i, k){
    ll l, r;
    cin >> l >> r;
    s.emplace_back(l, ++r);
  }
  dp[0] = 1;
  dp[1] = -1;
  REP(i, n){
    dp[i+1] += dp[i];
    REP(j, k){
      ll l = s[j].first;
      ll r = s[j].second;
      if(i+l <= n) dp[i+l] += dp[i];
      if(i+r <= n) dp[i+r] -= dp[i];
    }
  }
  cout << dp[n-1] << endl;
  return 0;
}

Measured memory_bytes: 5188
/*
 *Author - Abhas Jain
 */
 
#include <bits/stdc++.h>
 
#define F first
#define S second
#define all(c) c.begin(), c.end()
#define endl '\n'
#define pb push_back
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
 
typedef long long ll;
typedef long double ld;
 
using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;
mt19937 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
 
const ld PI = 3.141592653589793;
const ll INF = 9223372036854775807ll;
const ll mod = 1e9 + 7;
 
void solve() 
{
    int n;
    cin >> n;
    vector<int> temp;
    for (int i = 0; i < n; ++i) {
    	int cur;
    	cin >> cur;
    	temp.pb(cur);
    }
    temp[0]--;
    for (int i = 1; i < n; ++i) {
    	if (temp[i] < temp[i - 1]) {
    		cout << "No" << endl;
    		exit(0);
    	}
    	if (temp[i] > temp[i-1]) temp[i]--;
    }
    cout << "Yes" << endl;
}
 
int main( )
{   
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    solve();
    return 0;
}

Measured memory_bytes: 892
#include <stdio.h>
#include <array>
#include <bitset>


#define FOR(i, a, b) for(int (i) = (a); (i) < (b); ++(i))
#define REP(i, n) FOR(i, 0, n)

constexpr int N = 80;
constexpr int MAX_V = (2 * N) * N;
using datum = std::bitset<2 * MAX_V + 1>;
std::array<std::array<int, N>, N> A;
std::array<std::array<datum, N>, N> P;


int main(void){
    int H, W; scanf("%d%d", &H, &W);
    REP(i, H) REP(j, W) scanf("%d", &A[i][j]);
    REP(i, H) REP(j, W){
        int a; scanf("%d", &a); A[i][j] -= a;
        if(A[i][j] < 0) A[i][j] = -A[i][j];
    }

    P[0][0][MAX_V + A[0][0]] = true;
    P[0][0][MAX_V - A[0][0]] = true;
    REP(i, H) REP(j, W){
        if(i+1 < H){
            P[i+1][j] |= (P[i][j] << A[i+1][j]);
            P[i+1][j] |= (P[i][j] >> A[i+1][j]);
        }
        if(j+1 < W){
            P[i][j+1] |= (P[i][j] << A[i][j+1]);
            P[i][j+1] |= (P[i][j] >> A[i][j+1]);
        }
    }
    int res = 2e9;
    REP(i, 2 * MAX_V + 1) if(P[H-1][W-1][i]){
        int v = (i >= MAX_V) ? i - MAX_V : MAX_V - i;
        if(res > v) res = v;
    }
    printf("%d\n", res);
    return 0;
}

Measured memory_bytes: 20224
sq = set()

i, ii= 0,0
while ii <= 160000:
    sq.add(ii)
    i+=1
    ii = i*i

n, d = map(int,input().split())

X = []
for _ in range(n):
    X.append(tuple(map(int,input().split())))

def d2(x,y):
    ret = 0
    for i in range(len(x)):
        ret += (x[i]-y[i])**2
    return ret

ans = 0
for i in range(n):
    for j in range(i+1,n):
        if d2(X[i],X[j]) in sq:
            ans += 1
    
print(ans)

Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int ans = 0;
    int n = s.size();
    int star = -1;
    REP(i, 0, n) {
        if (s[i] == '*') {
            star = i;
        }
    }
    {
        int depth = 0;
        for (int i = star; i >= 0; i--) {
            if (s[i] == '(') {
                depth++;
            }
            if (s[i] == ')') {
                depth--;
            }
            ans = max(ans, depth);
        }
    }
    {
        int depth = 0;
        for (int i = star; i < n; i++) {
            if (s[i] == ')') {
                depth++;
            }
            if (s[i] == '(') {
                depth--;
            }
            ans = max(ans, depth);
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
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;
}

constexpr int INF = 1e9;

int memo[20][20];
void init_memo() {
    rep(i, 0, 20) rep(j, 0, 20) memo[i][j] = INF;
}
int distance(string &s, string &t, int i, int j) {
    auto &MEMO = memo[i][j];
    if (MEMO != INF) return MEMO;

    if (i >= s.size() && j >= t.size()) return MEMO = 0;
    if (i >= s.size()) return MEMO = (int)t.size() - j;
    if (j >= t.size()) return MEMO = (int)s.size() - i;
    
    int ret = INF;

    if (s[i] == t[j]) {
        chmin(ret, distance(s, t, i + 1, j + 1));
    } else {
        chmin(ret, distance(s, t, i + 1, j    ) + 1);
        chmin(ret, distance(s, t, i    , j + 1) + 1);
        chmin(ret, distance(s, t, i + 1, j + 1) + 1);
    }

    rep(k, j + 1, t.size()) {
        if (s[i] == t[k] && s[i + 1] == t[j]) {
            chmin(ret, distance(s, t, i + 2, k + 1) + 1 + abs(k - (j + 1)));
        }
    }
    rep(k, i + 1, s.size()) {
        if (s[i] == t[j + 1] && s[k] == t[j]) {
            chmin(ret, distance(s, t, k + 1, j + 2) + 1 + abs(k - (i + 1)));
        }
    }

    return MEMO = ret;
}

signed main_() {
    string s, t;
    cin >> s >> t;
    init_memo();
    cout << distance(s, t, 0, 0) << endl;
}
signed main() {
    while (1) {
        int n, d;
        cin >> n;
        if (n == 0) break;
        cin >> d;
        vector<string> S(n);
        rep(i, 0, n) {
            cin >> S[i];
        }
        sort(S.begin(), S.end());
        vector<pair<string, string>> ans;
        rep(i, 0, n) {
            rep(j, i + 1, n) {
                init_memo();
                // cerr << i << ", " << j << " = " << distance(S[i], S[j], 0, 0) << endl;
                if (distance(S[i], S[j], 0, 0) <= d) {
                    ans.push_back({S[i], S[j]});
                }
            }
        }
        sort(ans.begin(), ans.end());
        for (auto &x : ans) {
            cout << x.first << "," << x.second << endl;
        }
        cout << ans.size() << endl;
    }
}


Measured memory_bytes: 3200
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main{
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int count = sc.nextInt();
		long[] a = new long[count];
		for(int i=0;i<count;i++) {
			a[i] = sc.nextLong();
		}
		
		for(int i=1;i<=count;i++) {
			System.out.print("node "+i+": key = "+a[i-1]+", ");
			if(i!=1) {
				System.out.print("parent key = "+a[i/2-1]+", ");
			}
			if(2*i<=a.length) {
				System.out.print("left key = "+a[2*i-1]+", ");
			}
			if(2*i<=a.length-1) {
				System.out.print("right key = "+a[2*i]+", ");
			}
			System.out.println();
		}
}}


Measured memory_bytes: 27572
package main

import "fmt"

func score(v int) int {
	if v == 1 {
		return 14
	}
	return v
}

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	if sa, sb := score(a), score(b); sa > sb {
		fmt.Println("Alice")
	} else if sa == sb {
		fmt.Println("Draw")
	} else {
		fmt.Println("Bob")
	}
}


Measured memory_bytes: 512
def main():
    x,y = map(int,input().split())
    if 2*x > y:
        print('No')
        return 0
    if 4*x < y:
        print('No')
        return 0
    if (4*x-y)%2 == 0:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()


Measured memory_bytes: 61668
#include<stdio.h>

int main(void)
{
  int size,reps;
  scanf("%d",&size);
  scanf("%d",&reps);
  int i=0;
  int arr[size];
  
  while(i<size)
  {
    scanf("%d",&arr[i]);
    i++;
  }
  
 int sum=0,min[reps],j=0,l;
 printf("\n");
  
  
   for(i=0;i<size;i++)
   {
    for(l=0;l<size;l++)
    {
      if(arr[i]<arr[l])
      {
        int tmp=arr[i];
        arr[i]=arr[l];
        arr[l]=tmp;
      }
    }
}

   
j=0;
     
 while(j!=reps)
 {
  sum=arr[j]+sum;     
  j++; 	
 }
     printf("%d",sum);
 }
   
  

Measured memory_bytes: 1736
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
#define all(v) v.begin(), v.end()

int main(){
  ll N;
  cin >> N;
  vector<tuple<string,ll,ll>> A(N);
  rep(i,N){
    cin >> get<0>(A.at(i)) >> get<1>(A.at(i));
    get<1>(A.at(i))=100-get<1>(A.at(i));
    get<2>(A.at(i))=i+1;
  }
  sort(all(A));
  rep(i,N){
    cout << get<2>(A.at(i)) << endl;
  }
}
      
    

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

// 毎回appendするとTLEになってしまうのでappendの回数を減らすようにする

func main() {
	n := nextInt()
	if n == 1 {
		fmt.Println(nextInt())
		return
	}
	length := n / 2
	bfront := make([]int, length)
	bback := make([]int, length)
	for i := 0; i < n/2; i++ {
		switch n % 2 {
		case 0:
			bback[i] = nextInt()
			bfront[len(bfront)-1-i] = nextInt()
		case 1:
			bfront[len(bback)-1-i] = nextInt()
			bback[i] = nextInt()
		}

	}
	// fmt.Println(bfront, bback)
	if n%2 == 1 {
		bfront = append([]int{nextInt()}, bfront...)
	}
	b := append(bfront, bback...)
	fmt.Println(strings.Trim(fmt.Sprint(b), "[]"))
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func abs(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}


Measured memory_bytes: 19168
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
        char a[] = sc.next().toCharArray();
        int end[] = new int[28];
        for(int i = 0; i< 28;i++){
          end[i] = 0;
        }
        for(int i = 0; i < a.length;i++){
          end[a[i] - 97] = end[a[i] - 97] + 1;
        }
        for(int i = 0; i< 28;i++){
          if(end[i] % 2 == 1){
            System.out.println("No");
            System.exit(0);
          }
        }
        System.out.println("Yes");
    }
}

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

int main(void){
    int i,j,n,tmp,cnt=0;
    int a[100];
    cin>>n;
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    
    for(i=0;i<n;i++){
        for(j=0;j<n-i-1;j++){
            if(a[j]>a[j+1]){
                tmp=a[j];
                a[j]=a[j+1];
                a[j+1]=tmp;
                cnt++;
            }
        }
    }
    
    for(i=0;i<n-1;i++){
        cout<<a[i]<<" ";
    }
    cout<<a[n-1]<<endl<<cnt<<endl;
    
    return 0;
}
    


Measured memory_bytes: 3100
#include<stdio.h>

int main(){

  int A[22][22];
  int n,m,xc,yc,zc;
  int cnt;
  int i,j;
  int px,py;
  char ch;

  while(1){
    px=10;
    py=10;
    cnt=0;

    for(i=0;i<21;i++){
      for(j=0;j<21;j++){
	A[i][j]=0;
      }
    }
    
    scanf("%d",&n);
    if(n==0)break;
    for(i=0;i<n;i++){
      scanf("%d%d",&xc,&yc);
      A[xc][yc]=1;
    }
    
    scanf("%d",&m);
    for(i=0;i<m;i++){
      scanf(" %c %d",&ch,&zc);
      for(j=0;j<zc;j++){
      if(ch=='N'){
	py++;
	if(A[px][py]==1){
	  A[px][py]=5;
	}else if(A[px][py]==0){
	  A[px][py]=3;
	}
      }
      if(ch=='W'){
	px--;
	if(A[px][py]==1){
	  A[px][py]=5;
	}else if(A[px][py]==0){
	  A[px][py]=3;
	}
      }
      if(ch=='S'){
	py--;
	if(A[px][py]==1){
	  A[px][py]=5;
	}else if(A[px][py]==0){
	  A[px][py]=3;
	}
      }
      if(ch=='E'){
	px++;
	if(A[px][py]==1){
	  A[px][py]=5;
	}else if(A[px][py]==0){
	  A[px][py]=3;
	}
      }
      }
    }
    
    for(i=0;i<21;i++){
      for(j=0;j<21;j++){
	if(A[i][j]==5)cnt++;
      }
    }
    
    if(cnt==n){
      printf("Yes\n");
    }else{
      printf("No\n");
    }
  }
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))

#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s))
#define repiins(x, y, z, s) for ((x) = (z); (x) <= (y); (x) += (s))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define repit2(x) for (__typeof((x).begin()) it2 = (x).begin(); it2 != (x).end(); it2++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)

#define All(x) (x).begin(),(x).end()

#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))

// can be applied to string type
#define Unique(v) v.resize(unique(All(v)) - v.begin())

#define peq(p0, p1)(p0.first == p1.first && p0.second == p1.second)

#define End '\n'
#define Out(x) cout<<(x)<<End
template<typename T>
void Debug(const T &val) { cerr << val << End; }
template<typename T, typename... Args>
void Debug(const T &val, Args... args) {
    cerr << val << ' ';
	Debug(std::forward<Args>(args)...);
}

template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

// can be applied to string type
#define Sort(v) sort(All(v))
#define SortR(v) sort(All(v), std::greater<__typeof(v[0])>())
// array sorters
#define Sart(a) sort(a, a + sizeof(a) / sizeof(__typeof(a[0])));
#define SartR(a) sort(a, a + sizeof(a) / sizeof(__typeof(a[0])), std::greater<__typeof(a[0])>())

#define pb push_back
#define mp make_pair
#define a first
#define b second
#define lb std::lower_bound
#define ub std::upper_bound

#define lbi(v, x) lb(All(v), (x))-v.begin()
#define ubi(v, x) ub(All(v), (x))-v.begin()

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);
	//std::cout.precision(18);

    long n, q;
	string s;

	cin >> n >> q;
	cin >> s;

	long cumSum[n];
	long l, r;

	cumSum[0] = 0;

	long i;

	repi(i, n, 1) {
		if (s[i - 1] == 'A' && s[i] == 'C') cumSum[i] = cumSum[i - 1] + 1;
		else cumSum[i] = cumSum[i - 1];
	}

	while (q--) {
		cin >> l >> r;

		l--;
		r--;

		if (l == 0) Out(cumSum[r]);
		else if (s[l] == 'C' && s[l - 1] == 'A') Out(cumSum[r] - cumSum[l - 1] - 1);
		else Out(cumSum[r] - cumSum[l - 1]);
	}
	
	return 0;
}


Measured memory_bytes: 1872
#include<bits/stdc++.h>
using namespace std;
#define        fast        ios_base::sync_with_stdio(false);cin.tie(NULL)
#define        ll          long long int
#define        End         return 0
#define        st          string
#define        sz(x)       (int)x.size()
#define        nl          '\n'
int main()
{
    fast;
    st s;
    cin>>s;
    if(s.back()=='s')
        cout<<s<<"es";
    else
        cout<<s<<'s';
    End;
}



Measured memory_bytes: 3636