akhauriyash/Code-Regression huggingface dataset:
/**
 * C - Sentou
 * https://atcoder.jp/contests/abc060/tasks/arc073_a
 **/
#include<iostream>
#include<vector>

#define ll long long

using namespace std;

int main() {
    int N;
    ll T;
    cin >> N >> T;
    vector<ll> t(N+1, 0);
    ll X=0;
    for(int i=1; i<N+1; i++) cin >> t[i];
    ll ans=0;
    for(int i=1; i<N+1; i++) {
        if(t[i]-t[i-1]>T) {
            ans += T;
        } else {
            ans += t[i]-t[i-1];
        }
    }
    ans += T;
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int main() {
    long long int N, A, B;
    cin >> N >> A >> B;
    long long int shou;
    long long int amari;
    shou = N / (A + B);
    amari = N % (A + B);
    cout << shou * A + min(A, amari) << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <stack>
#include <limits>
#include <array>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <numeric>
#include <tuple>

constexpr long long mod = static_cast<long long>(1e9 + 7);


int main() {
    std::string str;
    std::cin >> str;
    if(str.size() == 1) {
        std::cout << std::stoi(str) << std::endl;
    } else {
        if(std::find_if(begin(str) + 1, end(str), [](auto c){return c != '9';}) != end(str)) {
            std::cout << 9 * (str.size() - 1) + (int)(str[0] - '0') - 1 << std::endl;
        } else {
            std::cout << 9 * (str.size() - 1) + (int)(str[0] - '0') << std::endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int a,b,sum;
	scanf("%d %d",&a,&b);
	sum=a+b;
	if(a%3==0){
		printf("Possible\n");
	}
	else if(b%3==0){
		printf("Possible\n");
	}	
	else if(sum%3==0){
		printf("Possible\n");
	}
	else{
		printf("Impossible\n");
	}
	return 0;
}


Measured memory_bytes: 128
#include"bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds; 
using namespace std;

#define double long double
#define int long long
#define pb push_back 
#define eb emplace_back
#define Z(c) (int)(c).size()
#define L(c) c[Z(c)-1]
#define F first
#define S second
#define nl "\n"
#define mii map<int,int> 
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define rep(i,iv,n) for(int (i)=(iv);(i)<(n);++(i))
#define FO fflush(stdout) 
#define D1(x) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<nl
#define D2(x,y) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<nl
#define D3(x,y,z) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<nl
#define tr(it,ct) for(auto &(it) : (ct))
#define pi acos(-1)
#define prt(ct) for(auto &(it) : (ct)) cerr<<it<<" "; cerr<<nl
#define prtp(ct) for(auto &(it) : (ct)) cerr<<it.F<<" "<<it.S<<nl; cerr<<nl

typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;
typedef pair<pii,pii> ppp;
typedef vector< pii > vp;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, 
             tree_order_statistics_node_update> baap;

void swap(char &a,char &b)
{ auto tm=a; a=b; b=tm; }

void mina(int &a,int b)
{ a=(a<b?a:b); }

void maxa(int &a,int b)
{ a=(a>b?a:b); }

  const int mod=1000000007;
  const int mod2=998244353;
  const int INF=1e18;
  const int N=1e5+15;
  const int M=2001+21;
  

 void doit()         
 { 
   int s,w; cin>>s>>w;

   if(w>=s) cout<<"unsafe";
   else cout<<"safe";
 }


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

 
  
   int tc=1;                         
//  cin>>tc;

  rep(i,1,tc+1)
  { // cout<<"Case #"<<i<<": ";
    
   doit();
   if(i<tc)
   cout<<nl;
  }
  
 
 return 0; 
}

Measured memory_bytes: 3608
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { -1,0,1,0 }, dy[4] = { 0,-1,0,1 };
const char dir[4] = { 'u','l','d','r' };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        (wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)
# pragma warning(disable:4996)

LL n, k;

int main() {
	cin >> n >> k;
	LL ans = 0;
	ans += (n / k)*(n / k)*(n / k);
	if (k % 2 == 0) {
		LL num = n / k + (n%k >= (k / 2) ? 1 : 0);
		ans += num*num*num;
	}
	cout << ans << endl;
}

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

int main(){
 
  double A, B, H, M, x1, x2, y1, y2, L;
  double PI = 3.141592653589793238;
  cin >> A >> B >> H >> M;
  
  x1 = A * sin(H * 2 * PI / 12 + M * 2 * PI / 60 / 12);
  y1 = A * cos(H * 2 * PI / 12 + M * 2 * PI / 60 / 12);
  x2 = B * sin(M * 2 * PI / 60);
  y2 = B * cos(M * 2 * PI / 60);
  
  L = pow(pow((x1 - x2), 2) + pow((y1 - y2), 2), 0.5);
  printf("%.11f\n", L);
  
  return 0;
}

Measured memory_bytes: 4356
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  double sum = 0;
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    sum += 1.0 / A;
  }
  cout << 1 / sum << endl;
}

Measured memory_bytes: 384
matrix = []
for i in range(3):
    line = []
    line = input().split(" ")
    matrix.append(line)

n = int(input())
chosen = 0

for i in range(n):
    b = input()
    for i in range(3):
        for j in range(3):
            if matrix[i][j] == b:
                chosen += 1
                matrix[i][j] = 0
bingo = False
for i in range(3):
    if(matrix[i][0] == 0 and matrix[i][1] == 0 and matrix[i][2] == 0):
        bingo = True
        break
    elif(matrix[0][i] == 0 and matrix[1][i] == 0 and matrix[2][i] == 0):
        bingo = True
        break

if(matrix[1][1] == 0 and matrix[0][0] == 0 and matrix[2][2] == 0):
    bingo = True
if(matrix[1][1] == 0 and matrix[2][0] == 0 and matrix[0][2] == 0):
    bingo = True
if bingo:
    print("Yes")
else:
    print("No")


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

int main(){
    int n;
    cin >> n;
    int cnt = 0;
    int ans = 0;
    for(int i = 1; i <= n; i += 2){
        for(int j = 1; j <= i; j++){
            if(i%j == 0){
                cnt++;
            }
        }
        if(cnt == 8){
            ans++;
        }
        cnt = 0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define forn(i,n)            for(int i=0; i<n; i++)
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void zeus()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
	//zeus();

	int n; cin >> n;

	vector<int> dp(3);

	forn(day, n) {
		vector<int> new_dp(3, 0);
		vector<int> c(3);
		forn(i, 3) {
			cin >> c[i];
		}
		forn(i, 3) {
			forn(j, 3) {
				if (i != j) {
					new_dp[j] = max(new_dp[j], dp[i] + c[j]);
				}
			}
		}
		dp = new_dp;
	}

	cout << max({dp[0], dp[1], dp[2]});



	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.lang.*;

public class Main {
    public static MyScanner scan;
    public static PrintWriter out;
    public static void main(String[] args) {
        scan=new MyScanner();
        out=new PrintWriter(new BufferedOutputStream(System.out));

        int t=1;
//        int t=scan.nextInt();
        while(t-->0) {

            String s=scan.nextLine(),st=scan.nextLine();
            int min=Integer.MAX_VALUE;
            for(int i=0;i<s.length()-st.length()+1;i++) {
                int cur=0;
                for(int j=i;j<i+st.length();j++) if(s.charAt(j)!=st.charAt(j-i)) cur++;
                min=Math.min(min,cur);
            } out.println(min);
        }
        out.close();
    }

    //scanner
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 26224
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define all(x) x.begin(),x.end()
#define endl '\n'
#define read(FILE)  freopen(FILE, "r", stdin);
#define out(FILE) freopen(FILE, "w", stdout);
#define all(x) x.begin(),x.end()
#define clr(v,val) memset(v,val,sizeof(v))
#define rep(i,m,n) for(int i=m ; i<n ; i++)
#define forr(i,m,n) for(int i=m ; i<=n ; i++)
#define pb push_back
#define pff push_front
#define re return
#define bit __builtin_popcountll
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 2e5 + 10;
using namespace std;
int main(){
    IO;
    int n,k,o=0;
    cin>>n>>k;
    forr(i,1,n){
    int x; cin>>x;
    if(x>=k)
        o++;
    }
    cout<<o;


}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#define int long long
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n;
int x[1000], y[1000];
const int m = 35;
int d[m];

signed main() {
	int i, j;
	
	cin >> n;
	rep(i, n) cin >> x[i] >> y[i];
	
	int guki = (abs(x[0]) + abs(y[0])) % 2;
	rep(i, n) if (guki % 2 != (abs(x[i]) + abs(y[i])) % 2) { cout << "-1" << endl; return 0; }
	
	int sumD = 0;
	if (guki % 2) {
		rep(i, m) { d[i] = (1LL << i); sumD += d[i]; }
	}
	else {
		rep(i, m - 1) { d[i] = (1LL << i); sumD += d[i]; }
		d[m - 1] = 1; sumD++;
	}
	
	cout << m << endl;
	rep(i, m) {
		cout << d[i];
		if (i + 1 < m) cout << " ";
	}
	cout << endl;
	
	rep(i, n) {
		int xx = x[i] - y[i];
		int yy = x[i] + y[i];
		
		rep(j, m - (guki % 2 == 0)) {
			int p = ((sumD - xx) >> (j + 1)) % 2;
			int q = ((sumD - yy) >> (j + 1)) % 2;
			if (p == 0 && q == 0) cout << "R";
			if (p == 0 && q == 1) cout << "D";
			if (p == 1 && q == 0) cout << "U";
			if (p == 1 && q == 1) cout << "L";
		}
		if (guki % 2 == 0) cout << "R";
		cout << endl;
	}
	return 0;
}
//d_i = 1 … マンハッタン距離の偶奇が全て等しい ⇔ 構成可能。以降マンハッタン距離の偶奇は全て等しいとする。
//1次元：偶→1,1,2,4,8,16,…. 奇→1,2,4,8,16…
//2次元：1次元×2回では回数が足りない。x,y同時に移動できれば… → 45°回転して見ると、実質ななめ移動に。
//命令の重ね合わせができる(L+D→左下、のような感じ）ので、m=40でも余裕。
//45°回転すると、x+yの偶奇が全て同じ⇒x'の偶奇が全て等しい, y'の偶奇が全て等しい, (x'の偶奇==y'の偶奇）
//だから、同じアームを使いまわせる。

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx")
//#pragma GCC optimize ("unroll-loops")
#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;

#define fi first
#define se second
#define pb push_back
#define sz(x)  ((int)x.size ())
#define all(x) (x).begin(), (x).end()
#define re return
#define mp make_pair
#define sqrt(x) sqrt (abs(x))
#define y0 y3451
#define y1 y4562
#define j0 j25624
#define j1 j45624
#define makeunique(x) sort(all(x)), (x).resize (unique(all(x)) - (x).begin())

typedef pair <int, int> ii;
typedef long long ll;
typedef unsigned long long ull;
typedef double D;
typedef long double ld;
typedef unsigned int uint;
typedef vector <string> vs;
typedef vector <int> vi;
typedef vector <ii> vii;
typedef vector <vi> vvi;

template <class T> using _tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> T abs (T x) { re x > 0 ? x : -x; }
template <class T> T sqr (T x) { re x * x; }
template <class T> T gcd (T a, T b) { re a ? gcd (b % a, a) : b; }
template <class T> int sgn (T x) { re x > 0 ? 1 : (x < 0 ? -1 : 0); }

#define filename ""

const D pi = acos(-1.);
const int N = 2e5 + 20;
const int inf = 1e9 + 7;

int n, m;
int a[3010];
ll dp[3010][3010][2];
bool vis[3010][3010][2];

ll go(int l, int r, int p) {
	if (l > r) re 0;
	if (vis[l][r][p]) re dp[l][r][p];
	vis[l][r][p] = 1;
	ll ans = 0;
	if (!p) ans = max(a[l] + go(l + 1, r, 1), a[r] + go(l, r - 1, 1));
	else ans = min(go(l + 1, r, 0) - a[l], go(l, r - 1, 0) - a[r]);	
	re dp[l][r][p] = ans;

}
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	cout << go(0, n - 1, 0);
}

Measured memory_bytes: 158336
use std::io::*;

fn main() {
    let mut input_string = String::new();
    stdin().read_line(&mut input_string).ok();
    let mut itr = input_string.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let m: usize = itr.next().unwrap().parse().unwrap();
    println!("{}", (n * (n - 1) + m * (m - 1)) / 2);
}

Measured memory_bytes: 2064
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

#define maxs(x,y) (x=std::max(x,y))
#define mins(x,y) (x=std::min(x,y))

struct P {
  ll x, y, c;
};

int main() {
  ll A, B, M;
  cin >> A >> B >> M;
  vector<ll> a(A);
  vector<ll> b(B);
  vector<P> d(M);
  rep(i,A) cin >> a[i];
  rep(i,B) cin >> b[i];
  rep(i,M) cin >> d[i].x >> d[i].y >> d[i].c;
  ll minest {a[0]+b[0]};

  rep(i,M) {
    mins(minest, a[d[i].x-1]+b[d[i].y-1]-d[i].c);
  }

  std::sort(a.begin(), a.end());
  std::sort(b.begin(), b.end());

  mins(minest, a[0]+b[0]);
  maxs(minest, 0ll);
  cout << minest << '\n';
}


Measured memory_bytes: 4224
def main(X, N, P):
    st = set(P)
    if N == 0:
        print(X)
    else:
        n = 0
        while True:
            if X - n not in st:
                print(X - n)
                exit()
            elif X + n not in st:
                print(X + n)
                exit()
            else:
                n += 1

if __name__ == '__main__':
    X, N = list(map(int, input().split()))
    P = list(map(int, input().split()))
    main(X, N, P)

Measured memory_bytes: 9140
# https://note.nkmk.me/python-union-find/

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
    #要素xが属するグループの根を返す
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    #xのグループとyのグループを併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    #xとyが同じグループかどうか
    def same(self, x, y):
        return self.find(x) == self.find(y)

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

uf = UnionFind(N)

for _ in range(M):
    x, y = map(int, input().split())
    uf.union(x-1, y-1)

ans = 0
for i in range(N):
    if uf.same(i, p[i]-1):
        ans += 1
print(ans)

Measured memory_bytes: 20356
def solve(string):
    n, k, *a = map(int, string.split())
    a, t = [_a - 1 for _a in a], [0] * n
    p = c = 0
    while not t[a[p]]:
        c += 1
        t[a[p]] = c
        p = a[p]
        if c == k:
            return str(p + 1)
    k = (k - t[a[p]] + 1) % (t[p] - t[a[p]] + 1)
    for _ in (range(k)):
        p = a[p]
    return str(p + 1)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 33468
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

template <class T, class Comp=less<T>>
struct BinarySearchTree {
    struct Node {
        T value;
        Node *parent, *left, *right;
        Node(T v=T()): value(v), parent(NULL), left(NULL), right(NULL) {}
    };
    Node *root;
    Comp comp;
    BinarySearchTree(): root(NULL) {}
    void insert(T value) {
        Node *z=new Node(value);
        Node *x=root;
        while (x != NULL) {
            z->parent = x;
            x = (comp(z->value, x->value)? x->left : x->right);
        }

        if (z->parent == NULL) {
            root = z;
        } else if (comp(z->value, z->parent->value)) {
            z->parent->left = z;
        } else {
            z->parent->right = z;
        }
    }
    Node *find(T value, Node *x) {
        if (x->value == value)
            return x;

        Node *left=x->left;
        if (left != NULL && comp(value, x->value)) {
            Node *res=find(value, left);
            if (res != NULL)
                return res;
        }

        Node *right=x->right;
        if (right != NULL && comp(x->value, value)) {
            Node *res=find(value, right);
            if (res != NULL)
                return res;
        }

        return NULL;
    }
    template <class Functor>
    void walk_inorder(Functor F, Node *x) {
        if (x == NULL) return;

        walk_inorder(F, x->left);
        F(x);
        walk_inorder(F, x->right);
    }
    template <class Functor>
    void walk_preorder(Functor F, Node *x) {
        if (x == NULL) return;

        F(x);
        walk_preorder(F, x->left);
        walk_preorder(F, x->right);
    }
    template <class Functor>
    void walk_postorder(Functor F, Node *x) {
        if (x == NULL) return;

        walk_postorder(F, x->left);
        walk_postorder(F, x->right);
        F(x);
    }
    ~BinarySearchTree() {
        auto del=[](Node *x) {
            delete x;
        };
        walk_postorder(del, root);
    }
};

int main() {
    size_t m;
    scanf("%zu", &m);

    auto output=[](BinarySearchTree<int>::Node *x)->int {
        return printf(" %d", x->value);
    };

    BinarySearchTree<int> tree;
    for (size_t i=0; i<m; ++i) {
        char buf[1<<3];
        scanf("%s", buf);
        string instr(buf);

        if (instr == "insert") {
            int key;
            scanf("%d", &key);
            tree.insert(key);
        } else if (instr == "find") {
            int key;
            scanf("%d", &key);
            BinarySearchTree<int>::Node *res=tree.find(key, tree.root);
            printf("%s\n", res!=NULL? "yes":"no");
        } else if (instr == "print") {
            tree.walk_inorder(output, tree.root);
            printf("\n");
            tree.walk_preorder(output, tree.root);
            printf("\n");
        }
    }

    return 0;
}

Measured memory_bytes: 21548
import java.io.PrintWriter

fun main(args: Array<String>) {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    val n = readInteger()
    val set = mutableSetOf<String>()
    repeat(n) {
        set += readLine()!!
    }
    println(set.distinct().size)
}


fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 78948
n = int(input())
a = [0]*n
cnt = 0
for i in range(1,100):
  for j in range(1,100):
    for k in range(1,100):
      b = i**2 + j**2 + k**2 + i*j + j*k + k*i
      if b <= n:
        a[b-1] += 1

for i in a:
  print(i)

Measured memory_bytes: 8988
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    while(1){
        string S;
        cin>>S;
        if(S=="-")break;
        int m;
        cin>>m;
        rep(i,m){
            int h;
            cin>>h;
            rep(j,h)S+=S[j];
            S = S.erase(0,h);
        }
        cout<<S<<endl;
    }
    return 0;
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using boost::multiprecision::cpp_int;

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

const ll INF = 1e17;
const ll MOD = 1e9+7;

int main() {
    // input, ready
    int X,Y,A,B,C;
    cin >> X >> Y >> A >> B >> C;
    vector<ll> A_vec(A);
    vector<ll> B_vec(B);
    vector<ll> ans_vec(C);
    for (int i=0; i<A; i++) cin >> A_vec[i];
    for (int i=0; i<B; i++) cin >> B_vec[i];
    for (int i=0; i<C; i++) cin >> ans_vec[i];

    // resolve
    sort(A_vec.begin(),A_vec.end());
    sort(B_vec.begin(),B_vec.end());
    reverse(A_vec.begin(),A_vec.end());
    reverse(B_vec.begin(),B_vec.end());

    for (int i=0; i<X; i++) ans_vec.push_back(A_vec[i]);
    for (int i=0; i<Y; i++) ans_vec.push_back(B_vec[i]);
    sort(ans_vec.begin(),ans_vec.end());
    reverse(ans_vec.begin(),ans_vec.end());   

    // output
    ll ans =0;
    for (int i=0; i<X+Y; i++) ans+=ans_vec[i];
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6512
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<numeric>
#include<utility>

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

#define INF 1000000000
#define MOD 1000000007

typedef  long long ll;

using namespace std;

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

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

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

ll gcd(ll  a,ll b){
    ll r;
    if(a < b){
        ll tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r = a % b){
        a = b;
        b = r;
    }
    return b;
}

void Integer_factorization(long long int b,long long int n){
    long long int a = 2;
    long long int count = 0;
    long long int ans = 1;
    long long int ndash = n;
    if(b == 1) cout << n << endl;
    else{
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    cout<<  ans << endl;
    }
}

ll r_fuct[2000];
ll fuct[2000];

//MOD逆元
void conb(ll n,ll k){
    fuct[0] = 1;
    for(int i = 1;i < k+1;i++){
        fuct[i] *= fuct[i-1]%MOD;
        
        ll b = MOD, u = 1, v = 0;
        ll value = fuct[i];
        while (b) {
            ll t = value / b;
            value -= t * b;
            swap(value, b);
            u -= t * v;
            swap(u, v);
        }
        u %= MOD;
        if (u < 0) u += MOD;
        r_fuct[i] = u;
    }
}






vector <ll>vec;
void solve() {

  ll n,m;
  cin >> n >> m;
  vector<pair<ll,ll>> a(n);
  for(int i = 0;i < n;i++){
    ll b,c;
    cin >> b >> c;
    a[i] = make_pair(b,c);
  }
  sort(a.begin(),a.end());
  ll ans = 0;
  ll num = 0;
  for(int i = 0;i < n;i++){
      if(num+a[i].second > m){
        ans += a[i].first*(m-num);
        break;
      }else{
        ans += a[i].first*a[i].second;
        num+=a[i].second;
      }
  }
  cout << ans << endl;
}
int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt(); //総距離
		int n = sc.nextInt(); //n軒
		
      	int[] d = new int[n]; //格家の距離代入
		for(int i = 0;i < n; i++) {
			d[i] = sc.nextInt();
		}
      
      	int maxs =0;  //一番距離が離れている二軒の距離
      	for( int i = 1 ; i < n ; i++){
			int value = d[i] - d[i-1];
			if( maxs <= value ){
				maxs = value;
				}
        }
        
      	int last = k - d[n-1] + d[0];
       	if( maxs <= last ){
				maxs = last;
				}
      
		int ans = 0;//最短移動距離
      	ans = k - maxs ;
     
		System.out.println(ans);

		sc.close();
	}
}

Measured memory_bytes: 85036
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl
#define show2(a, n, m) rep(i, n) { rep(j, m) {cout << a[i][j] << ' ';} cout << endl;} 
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
//	cout << fixed << setprecision(15);
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	vector<pll> p(a + b + c);
	rep(i, a) {
		ll q; cin >> q;
		p[i] = pll(q, 1);
	}
	rep(i, b) {
		ll q; cin >> q;
		p[i+a] = pll(q, 2);
	}
	rep(i, c) {
		ll q; cin >> q;
		p[i+a+b] = pll(q, 3);
	}
	sort(p.begin(), p.end(), greater<pll>());
	ll ans = 0;
	int r = 0, g = 0, no = 0;
	rep(i, a+b+c) {
		int type = p[i].second;
		if(type == 1) {
			if(r >= x) continue;
			r++;
		}
		else if(type == 2) {
			if(g >= y) continue;
			g++;
		}
		else if(type == 3) {
			no++;
		}
		ans += p[i].first;
		if(r + g + no >= x + y) break;
	}
	cout << ans << endl;
}


Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
using namespace std;
bool cmp(int a,int b)
{
    return a>b;
}
int main() {
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n,cmp);
    int sum=0;
    for(int i=0;i<k;i++)
    {
        sum+=a[i];
    }
    cout<<sum<<endl;
    return 0;
}


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

using namespace std;

int main()
{
	string S;
	int K;
	cin >> S >> K;

	if (S[0] == '1') {
		auto p = S.find_first_not_of('1');
		if (p == string::npos || K - 1 < p) {
			cout << 1 << endl;
		}
		else {
			cout << S[p] << endl;
		}
	}
	else {
		cout << S[0] << endl;
	}
}



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

using int64 = long long;

const int64 MOD = 1e9 + 7;

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

    vector<int64> T(N), A(N);
    for (int i = 0; i < N; i++) {
        cin >> T[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    vector<int64> ub(N),
                  lb(N);
    int64 prev = -1;
    for (int i = 0; i < N; i++) {
        if (T[i] > prev) {
            ub[i] = lb[i] = T[i];
            prev = T[i];
        } else {
            lb[i] = 1;
            ub[i] = T[i];
        }
    }

    prev = -1;

    int64 ans = 1;
    for (int i = N - 1; i >= 0; i--) {
        int64 l, u;
        if (A[i] > prev) {
            l = u = A[i];
            prev = A[i];
        } else {
            l = 1;
            u = A[i];
        }

        if (u < lb[i] or ub[i] < l) ans = 0;
        
        ub[i] = min(ub[i], u);
        lb[i] = max(lb[i], l);

        (ans *= ub[i] - lb[i] + 1) %= MOD;
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 3328
memTime = int(input())
memLate = input().split()
memLate = [int(i) for i in memLate]
colorList = []
memColor = 0
highLate = 0
for color in range(memTime):
    member = memLate[color]
    if member // 400 >= 8:
        highLate += 1
    elif ((member // 400) in colorList) == False:
        colorList.append(member // 400)
maxColor = len(colorList) + highLate
minColor = len(colorList)
if minColor == 0:
    minColor = 1
print(str(minColor) + " " + str(maxColor))

Measured memory_bytes: 3064
N=int(input()) #コマの個数
X=list(map(int, input().split())) #コマの場所
M=int(input()) #回数
A=list(map(int, input().split())) #どこの変化

for i in range(0,M):
    #print(A)
    #print(M)
    #print(X[A[i]-1])
    
    if (X[A[i]-1]+1 not in X) and X[A[i]-1]+1 <=2019:
        #print("not in",X[A[i]-1]+1,X)
        s=X[A[i]-1]
        X.insert(A[i],X[A[i]-1]+1)
        #print("X ",X)
        #print(s)
        X.remove(s)
        #print(X)

#print(" ")

X.sort()    
for i in range(len(X)):
    print(X[i])


Measured memory_bytes: 5612
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) std::cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) std::cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) std::cout << x << endl;
#define println(x) std::cout << x << endl;
using namespace std;
// using namespace atcoder;



//1-indexed, sum
class BIT {
public:
    ll n;
    vector<ll> bit;
    BIT(ll n):n(n),bit(n+1,0){}

    void add(ll i,ll x){
        if(i==0) return;
        for(ll k=i;k<=n;k+=(k & -k)){
            bit[k]+=x;
        }
    }

    ll sum(ll i){
        ll s=0;
        if(i==0) return s;
        for(ll k=i;k>0;k-=(k & -k)){
            s+=bit[k];
        }
        return s;
    }

    ll lower_bound(ll x){
        if(x<=0){
            return 0;
        }else{
            ll i=0;ll r=1;
            while(r<n) r=r<<1;
            for(int len=r;len>0;len=len>>1) {
                if(i+len<n && bit[i+len]<x){
                    x-=bit[i+len];
                    i+=len;
                }
            }
            return i+1;
        }
    }
};

void Main()
{
    ll n, Q;
    cin >> n >> Q;

    vector<ll> c(n);
    rep(i, n) cin >> c[i];
    
    vector<ll> l(Q), r(Q);
    rep(i, Q) cin >> l[i] >> r[i];
    
    vector<tuple<ll, ll, ll> > qs;
    rep(i, Q) {
        qs.push_back(make_tuple(i, l[i], r[i]));
    }
    
    sort(all(qs), [](const auto& l, const auto& r) {
        return std::get<2>(l) < std::get<2>(r);
    });

    BIT bit(n+1);
    vector<int> pos(n+1, -1);

    ll j = 0;
    vector<ll> res(Q);
    rep(i, Q) {
        ll qi = std::get<0>(qs[i]);
        ll a = std::get<1>(qs[i]) - 1;
        ll b = std::get<2>(qs[i]);

        while (j < b) {
            if (pos[c[j]] >= 0) {
                bit.add(1+pos[c[j]], -1);
            }
            pos[c[j]] = j;
            bit.add(1+pos[c[j]], 1);
            j++;
        }

        ll sumB = bit.sum(b);
        ll sumA = bit.sum(a);

        ll ans = sumB - sumA;
        res[qi] = ans;
    }

    rep(i, Q) put(res[i]);
}
signed main(){ Main();return 0;}

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

int main()
{
    int H, W;

    for (int k = 0; k<10000; k++)
    {
        cin >> H >> W;
        if (H != 0 && W != 0)
        {
            for (int i=1; i<=H; i++)
            {
                for (int j=1; j<=W; j++)
                {
                    cout << "#";
                }
                cout << endl;
            }
            cout << endl;
        }
        else k = 10000;
    }
    return 0;
}

Measured memory_bytes: 3092
h, w = map(int, input().split())

mat = []
dp = []
m = 10**9+7

for i in range(h):
    mat.append(list(input()))
    dp.append(list([0]*w))

dp[0][0] = 1


for x in range(h):
    for y in range(w):

        if x != 0 or y != 0:
            if mat[x][y] == "#":
                dp[x][y] = 0

            else:
                dp[x][y] += (dp[x - 1][y] + dp[x][y - 1]) % m

print(dp[h - 1][w - 1])



Measured memory_bytes: 52548
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;

int main() {
	int H1, M1, H2, M2, K;
	cin >> H1 >> M1 >> H2 >> M2 >> K;

	int ans = 60 * (H2 - H1);
	ans += (M2 - M1);
	ans -= K;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3652
N = int(input())
S = []
for i in range(N):
    S.append(input())

from collections import Counter
ls = Counter(S).most_common()
MAX = ls[0][1]
ans = []
for s,length in ls:
    if MAX == length:
        ans.append(s)
    else:
        break;

ans.sort()
print(*ans,sep='\n')

Measured memory_bytes: 45068
#どっちで出すか注意, rstrip注意
#提出前に見返すこと！
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    N = int(input())
    a = list(map(int, input().split()))
    res = 0
    for i in combinations(a, 2):
        res = max(res, abs(i[0]-i[1]))
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a),i##_end=(b);i<=i##_end;++i)
#define per(i,a,b) for(int i=(b),i##_end=(a);i>=i##_end;--i)
#define For(i,a,b) for(int i=(a),i##_end=(b);i<i##_end;++i)
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define Es(x,i) for(Edge *i=G[x];i;i=i->nxt)
typedef double ld;
typedef long long ll;
typedef long double lf;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f,mo=1e9+7;
template<typename A,typename B>inline bool upmx(A&x,const B&y){return x<y?x=y,1:0;}
template<typename A,typename B>inline bool upmn(A&x,const B&y){return x>y?x=y,1:0;}
template<typename T>inline T gcd(T x,T y){for(;y;swap(x,y))x%=y;return x;}
inline int Pow(int a,int b,int p=mo){int r=1;for(;b;b>>=1,a=1ll*a*a%p)if(b&1)r=1ll*r*a%p;return r;}
inline int rd(){
	int x,f=1,c;for(;!isdigit(c=getchar());)f=c!='-';x=c-'0';
	for(;isdigit(c=getchar());)x=x*10+c-'0';return f?x:-x;
}
#ifdef flukehn
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif


int main(){
	int a,b,c,x,y;
	a=rd(),b=rd(),c=rd(),x=rd(),y=rd();
	int ans=2000000000;
	for(int i=0;i<=max(x,y)*2;i++){
		ans=min(ans,i*c+a*max(0,x-i/2)+b*max(0,y-i/2));
	}
	cout<<ans;
}


Measured memory_bytes: 256
<?php
  fscanf(STDIN,"%d%d", $n,$m);
  for($i=0; $i<$m; $i++){
      fscanf(STDIN,"%d%d", $s,$c);
      if(!isset($ans[$s])){
          $ans[$s] = $c;
      }else{
          if($ans[$s] != $c){
              echo "-1";
              exit;
          }
      }
  }
  if($n==1){
      if(isset($ans[1])){
          echo $ans[1];
      }else{
          echo "0";
      }
      exit;
  }
  
  for($i=1; $i<=$n; $i++){
      if($i==1){
          if(isset($ans[$i])){
              if($ans[$i] == 0){
                  echo "-1";
                  exit;
              }
          }else{
              $ans[$i] = 1;
          }
      }
      if(!isset($ans[$i])){
          echo "0";
      }else{
          echo $ans[$i];
      }
  }


Measured memory_bytes: 4604
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

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


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


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


#define ARRAY_MAX 100005
const int INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

int dx4[4] = { 1,0,0,-1 };
int dy4[4] = { 0,1,-1,0 };
int dx2[2] = { 1,0 };
int dy2[2] = { 0,1 };

/******************************************************************************************/

char mp[15][1005];


int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);

	int h, w, k;
	cin >> h >> w >> k;

	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			cin >> mp[i][j];
		}
	}

	int ans = INF;
	for (int mask = 0; mask < (1 << (h - 1)); mask++)
	{
		vector<vector<int> > comp;
		vector<int> hoge(w + 10, 0);
		int cnt = 0;
		bool can = true;

		for (int i = 0; i < h; i++)
		{
			for (int j = 0; j < w; j++)
			{
				hoge[j + 1] += mp[i][j] - '0';
			}

			if ((mask >> i) & 1) {
				//ここで線が入る
				for (int j = 0; j <= w; j++)
				{
					if (hoge[j] > k) {
						can = false;
						break;
					}
				}

				if (!can)break;
				comp.push_back(hoge);
				fill_v(hoge, 0);
				cnt++;
			}
		}

		for (int j = 0; j <= w; j++)
		{
			if (hoge[j] > k) {
				can = false;
				break;
			}
		}
		if (!can)continue;
		
		comp.push_back(hoge);


		//あとは左から貪欲
		for (int j = 0; j < w; j++)
		{
			bool ok = true;
			for (int i = 0; i < comp.size(); i++)
			{
				ok &= (comp[i][j] + comp[i][j + 1] <= k);
			}


			if (ok) {
				for (int i = 0; i < comp.size(); i++)
				{
					comp[i][j + 1] += comp[i][j];
				}
			}
			else
			{
				cnt++;
			}
		}
		ans = min(ans, cnt);
	}


	cout << ans << endl;







	return 0;
}



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

const int maxn = 100001;
vector<int> adj[maxn];
int dep[maxn], deg[maxn];

void dfs(int u, int d) {
	if (dep[u]) return;
	dep[u] = d;
	vector<int> anc;
	for (const auto& v : adj[u]) dfs(v, d + 1);
	for (const auto& v : adj[u]) if (dep[v] < dep[u]) {
		if (deg[u]) {
			cout << u << ' ' << v << '\n';
			deg[u] = 0;
		} else {
			cout << v << ' ' << u << '\n';
			deg[v] ^= 1;
		}
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int N, M;
	cin >> N >> M;
	for (int i = 0; i != M; ++i) {
		int u, v;
		cin >> u >> v;
		adj[u].emplace_back(v);
		adj[v].emplace_back(u);
	}
	if (M & 1) return cout << -1 << endl, 0;
	dfs(1, 1);
}


Measured memory_bytes: 17024
N = int(input())
li = []
for i in range(N):
    S, P = map(str,input().split())
    li.append([S,int(P),i+1])
li.sort()
li = sorted(li,reverse=True,key=lambda x:(x[0]))
for i in range(N,0,-1):
    print(li[i-1][2])

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

from collections import defaultdict

def main():
    n, m = map(int, input().split())
    a = []
    b = []
    atoi = defaultdict(list)
    btoi = defaultdict(list)
    for i in range(m):
        aa, bb = map(int, input().split())
        a.append(aa - 1)
        b.append(bb - 1)
        atoi[aa - 1].append(i)
        btoi[bb - 1].append(i)

    achieved = [False for i in range(m)]
    res = 0
    aptr = -1  # Already achieved
    for x in range(n - 1):
        tobreak = False
        for i in btoi[x + 1]:
            if not achieved[i]:
                tobreak = True
        if tobreak:
            res += 1
            while aptr < x:
                aptr += 1
                for j in atoi[aptr]:
                    achieved[j] = True
    print(res)

if __name__ == "__main__":
    main()


Measured memory_bytes: 57220
<?php
class In {
    private $array = [];
    private $length = 0;
    private $count = 0;

    function __construct()	{
        while (!feof(STDIN)) {
            $str = trim(fgets(STDIN));
            $this->array = array_merge($this->array, explode(' ', $str));
        }
        $this->length = count($this->array);
    }
    
    public function get(int $i){
        $this->array[$i];
    }

    public function next() {
        return $this->array[$this->count++];
    }
    public function hasNext() {
        return $this->count < $this->length;
    }
    public function nextInt() {
        return (int)$this->next();
    }
    public function nextDouble() {
        return (double)$this->next();
    }
    public function nextString() {
        return (string)$this->next();
    }
}

class Out {
    public static function line($str = "") {
        echo $str . PHP_EOL;
    }
}

$in = new In();
$n = $in->nextInt();

$a = ($n - ($n % 100)) / 100;
$a = $a * 100 + $a * 10 + $a;
if($n % 100 > $a % 100){
    $a += 111;
}

Out::line($a);

Measured memory_bytes: 5112
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iomanip>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<30)

using namespace std;

#define ld long double
#define ll long long

map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  ll ans=0;
  ll x,y;
  cin >> x >> y;
  if(x>y){
    ans+=x;
    x--;
  }else{
    ans+=y;
    y--;
  }
  if(x>y){
    ans+=x;
    x--;
  }else{
    ans+=y;
    y--;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

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

const int MM = 1e9 + 7;
const double eps = 1e-8;
const int MAXN = 2e6 + 10;

int n, m;
char s[MAXN];

void read(){
	scanf("%s", s);
	int l = strlen(s);
	int ans = 0;
	for(int i = 1; i < l; i++)
		ans += (s[i] != s[i-1]);
	printf("%d\n", ans);
}

void solve(){

}

void printans(){

}
	

int main(){
	int T = 1;
//	cin>>T;
	while(T--){
		read();
		solve();
		printans();
	}
	return 0;
} 


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
struct Data {
    int w, h;
};
 
 
int main()
{
    int n, w, d;
 
    while(scanf("%d %d %d", &n, &w, &d), n||w||d) {
        Data data[128];
        data[1] = (Data){w, d};
        int ptr = 2;
        for(int i = 0; i < n; i++) {
            int p, s;
            scanf("%d %d", &p, &s);
            Data temp = data[p];
            s %= temp.w + temp.h;
             
            for(int j = p; j < ptr - 1; j++) {
                swap(data[j], data[j + 1]);
            }
 
            if(s < temp.w) { // ???????????°??£??¨??????
                int Pos = min(s, temp.w - s);
                data[ptr++] = (Data){temp.w - Pos, temp.h};
                data[ptr - 2].w = Pos;
            } else { // ?¨??????°
                s -= temp.w;
                int Pos = min(s, temp.h - s);
                data[ptr++] = (Data){temp.w, temp.h - Pos};
                data[ptr - 2].h = Pos;
            }
        }
        vector< int > dat;
        for(int i = 1; i < ptr; i++) {
            dat.push_back(data[i].w * data[i].h);
        }
        sort(dat.begin(), dat.end());
        bool first = false;
        for(int i = 0; i < dat.size(); i++) {
            if(first++) printf(" ");
            printf("%d",dat[i]);
        }
        printf("\n");
    }
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	int N, T;
	cin >> N >> T; 
	int A[200010] = {};
	for(int i = 0; i < N; i++){
	cin >> A[i]; 
	}
	A[N] = 2e9; 
	int ans = 0; 
	for(int i = 0; i < N; i++){
	ans += min(T, A[i+1] - A[i]); 
	}
	cout << ans << endl; 
}

Measured memory_bytes: 1024
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

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

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;
bool mv(lint& A,lint& B,lint& C){
  if(A%2 || B%2 || C%2) return false;
  if(A==B && B==C) return false;
  lint X=(B+C)/2,Y=(A+C)/2,Z=(A+B)/2;
  A=X;
  B=Y;
  C=Z;
  return true;
}
int main(){
  lint A,B,C;
  cin>>A>>B>>C;
  int res=0;
  while(mv(A,B,C)){
    ++res;
  }
  if(A%2==0 && A==B && B==C) res=-1;
  printf("%d\n",res);
  return 0;
}





Measured memory_bytes: 256