akhauriyash/Code-Regression huggingface dataset:
//2019.5.20 by ljz
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define eps 1e-10
#define RG register
#define db double
inline int read() {
    res s=0,ch=getchar();
    while(ch<'0'||ch>'9')ch=getchar();
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
    return s;
}
inline LL Read() {
    RG LL s=0;
    res ch=getchar();
    while(ch<'0'||ch>'9')ch=getchar();
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
    return s;
}
inline void swap(res &x,res &y) {
    x^=y^=x^=y;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N=1e5+10;
namespace MAIN {
    int n,m;
    int fa[N];
    inline int find(res x){
        while(x!=fa[x])x=fa[x]=fa[fa[x]];
        return x;
    }
    int ans;
    inline void MAIN(){
        n=read(),m=read();
        for(res i=1;i<=n;i++)fa[i]=i;
        while(m--){
            res x=read(),y=read();
            read();
            res fx=find(x),fy=find(y);
            if(fx==fy)continue;
            fa[fx]=fy;
        }
        for(res i=1;i<=n;i++)if(find(i)==i)ans++;
        printf("%d\n",ans);
    }
}
int main() {
//    srand((unsigned)time(NULL));
//    freopen("graph.in","r",stdin);
//    freopen("graph.out","w",stdout);
    MAIN::MAIN();
    return 0;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int h = scanner.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];

        for (int i = 0; i < n; i++) {
            a[i] = scanner.nextInt();
            b[i] = scanner.nextInt();
        }

        Arrays.sort(b);
        int max = Arrays.stream(a).max().getAsInt();
        int attacks = (int) Math.ceil(h*1.0/max);
        int minAttacks = attacks;
        int reduce = 0;
        int bAttacks = 0;
        for (int i = b.length - 1; i >= 0; i--) {
            reduce += b[i];
            bAttacks++;
            if (h < reduce){
                if (bAttacks < minAttacks) minAttacks = bAttacks;
                break;
            }
            attacks = (int) Math.ceil((h -  reduce)*1.0/max);
            if (attacks + bAttacks < minAttacks) minAttacks = attacks + bAttacks;
        }

        System.out.println(minAttacks);
    }
}


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

int h, w;

int main () {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> h >> w;
  char s[h][w];
  int b = 0;
  int d[h][w];
  int dx[] = {1, 0, -1, 0};
  int dy[] = {0, 1, 0, -1};
  rep(i, h) {
    rep(j, w) {
      cin >> s[i][j];
      if (s[i][j] == '#') ++b;
      d[i][j] = 0;
    }
  }
  d[0][0] = 1;
  queue<pair<int, int> > q;
  q.emplace(0, 0);
  while (!q.empty()) {
    int y = q.front().first;
    int x = q.front().second;
    q.pop();
    for (int i = 0; i < 4; ++i) {
      int yy = y + dy[i];
      int xx = x + dx[i];
      if (0 <= xx && 0 <= yy && xx < w && yy < h && s[yy][xx] == '.' && d[yy][xx] == 0) {
        d[yy][xx] = d[y][x] + 1;
        q.emplace(yy, xx);
      }
    }
  }
  if (d[h-1][w-1] == 0) cout << -1;
  else cout << (h*w - b - d[h-1][w-1]);
}


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


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

    int R;
    cin >> R;


    cout << 2*R*3.14159<<endl;


}

Measured memory_bytes: 3792
#include<iostream>
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define pb(x) push_back(x)
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()
#define lcm(a,b) (a*b)/gcd(a,b)
#define bits(x) __builtin_popcountll(x)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int32_t main()
{
int a,b;
  cin>>a>>b;
  cout<<a*b;
}


Measured memory_bytes: 3620
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------

signed main() {
	int h, w;
	while (cin >> h >> w && h + w) {
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if ((i + j) % 2==0) cout << "#";
				else cout << ".";
			}
			cout << endl;
		}
		cout << endl;
	}
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll Maxn=1e6+10;
ll a[Maxn];
bool vis[Maxn];
ll gcd(ll a,ll b){
    return (!b)?a:gcd(b,a%b);
}
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    ll n;
    cin>>n;
    for(ll i=1;i<=n;i++)    cin>>a[i];
    sort(a+1,a+n+1);
    bool f=0;
    for(ll i=1;i<=n;i++){
        ll limits=sqrt(a[i]+0.5);
        if(f) break;
        for(ll j=2;j<=limits;j++){
            if(!(a[i]%j)){
                if(vis[j]||vis[a[i]/j]){
                    f=1;
                    break;
                }
                vis[j]=vis[a[i]/j]=1;
            }
        }
        vis[a[i]]=1;
    }
    if(!f){
        cout<<"pairwise coprime";
        return 0;
    }
    ll now=a[1];
    for(ll i=2;i<=n;i++)    now=gcd(now,a[i]);
    if(now==1){
        cout<<"setwise coprime";
        return 0;
    }
    cout<<"not coprime";
    return 0;
}


Measured memory_bytes: 11536
#include<stdio.h>
int main(void){
    int D;
    
    scanf("%d",&D);
    if(D==25){
        printf("Christmas");
    }
    if(D==24){
        printf("Christmas Eve");
    }
    if(D==23){
        printf("Christmas Eve Eve");
    }
    if(D==22){
        printf("Christmas Eve Eve Eve");
    }
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=a;i<=b;i++)
using namespace std;

const int maxn=1e5+5;

int n,m;

int tot,go[2*maxn],id[2*maxn],nxt[2*maxn],f1[maxn];
void ins(int x,int y,int i)
{
	go[++tot]=y;
	id[tot]=i;
	nxt[tot]=f1[x];
	f1[x]=tot;
}

bool vis[maxn],dfn[maxn],dg[maxn];
int e[maxn][2],e0;
void dfs(int k,int last)
{
	dfn[k]=1;
	for(int p=f1[k]; p; p=nxt[p]) if (!vis[id[p]])
	{
		vis[id[p]]=1;
		if (!dfn[go[p]])
		{
			dfs(go[p],k);
		} else
		{
			e[++e0][0]=k, e[e0][1]=go[p];
			dg[k]^=1;
		}
	}
	if (!last) return;
	if (dg[k]) e[++e0][0]=k, e[e0][1]=last;
		else e[++e0][0]=last, e[e0][1]=k, dg[last]^=1;
}

int main()
{
	scanf("%d %d",&n,&m);
	fo(i,1,m)
	{
		int x,y;
		scanf("%d %d",&x,&y);
		ins(x,y,i), ins(y,x,i);
	}
	
	dfs(1,0);
	
	if (dg[1]) puts("-1"); else
	{
		fo(i,1,m) printf("%d %d\n",e[i][0],e[i][1]);
	}
}

Measured memory_bytes: 9856
class SegTree:
    def __init__(self,N,f,ini):
        """
        f(val,ini)=ini
        """
        n=1
        while n<N: n<<=1
        self.n=n
        self.arr=[ini]*(2*n-1)
        self.f,self.ini=f,ini
    
    def update(self,i,val):
        i += self.n-1
        self.arr[i]=val
        while i>0:
            i=(i-1)//2
            self.arr[i]=self.f(self.arr[2*i+1],self.arr[2*i+2])

    def find(self,s,t):
        """
        [s,t)
        """
        return self.__find(s,t,0,0,self.n)

    def __find(self,s,t,k,l,r):
        if t<=l or s>=r: return self.ini
        if s<=l and t>=r: return self.arr[k]
        vl=self.__find(s,t,2*k+1,l,(l+r)//2)
        vr=self.__find(s,t,2*k+2,(l+r)//2,r)
        return self.f(vl,vr)

N,Q=map(int,input().split())
CXY=[map(int,input().split()) for _ in range(Q)]
st = SegTree(N, lambda x,y: min(x,y), 2**31-1)

for c,x,y in CXY:
    if c==0:
        # update
        st.update(x,y)
    elif c==1:
        # find
        print(st.find(x,y+1))



Measured memory_bytes: 53212
n, m = map(int, input().split())
s = [1] * (n + 1)
for i in range(m):
    a = int(input())
    s[a] = 0
for i in range(2, n + 1):
    if s[i] == 0:
        continue
    else:
        if s[i - 2] == 0 and s[i - 1] == 0:
            print(0)
            exit()
        else:
            s[i] = s[i - 1] + s[i - 2]   
print(s[n] % 1000000007)

Measured memory_bytes: 460020
import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

"""
# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]

# 標準入力取得
## 文字列
    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())

## 数値
    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき
"""
# 連続していれば1を引く。
if __name__ == "__main__":
    N = int(sys.stdin.readline())
    L = list(map(int, sys.stdin.readline().split()))

    cnt = 0
    while True:
        if sum(L) == 0:
            print(cnt)
            exit()
        si = 0
        cont = False

        for i in range(len(L)):
            if L[i] != 0:
                if not cont:
                    cont = True
                    si = i
            elif L[i] == 0:
                if cont:
                    cont = False
                    for j in range(si, i):
                        L[j] -= 1
                    cnt += 1
            if cont and i == len(L) - 1:
                for j in range(si, i + 1):
                    L[j] -= 1
                cnt += 1

Measured memory_bytes: 5076
import java.util.*;

public class Main {
  public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int sum=0;
    int A[]=new int[N];
    int B[]=new int[N];
    int C[]=new int[N-1];
    for(int i=0;i<N;i++){
     A[i]=sc.nextInt();
     }
    for(int i=0;i<N;i++){
     B[i]=sc.nextInt();
     }
    for(int i=0;i<N-1;i++){
      C[i]=sc.nextInt();
    }
    for(int i=0;i<N;i++){
      if(i>0){
      if(A[i]-A[i-1]==1){
      	sum+=B[A[i]-1]+C[A[i]-2];
       }else{
        sum+=B[A[i]-1];
      }
      }else{
        sum+=B[A[i]-1];
      }
    } System.out.println(sum);
  }
}



Measured memory_bytes: 22868
//

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int main() {
	int A, B;
	cin >> A >> B;

	int ans = (A + B) % 24;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.ArrayList;

class Main{
  public static void main(String[] args){
    
    Scanner in = new Scanner(System.in);
    
    while (in.hasNext()){
      int n = in.nextInt();
      ArrayList<Integer> array = new ArrayList<Integer>();
      
      for (int i = 0; i < 10; i++){
        for (int j = 0; j < 10; j++){
          for (int k = 0; k < 10; k++){
            for (int l = 0; l < 10; l++){
              //System.out.println(i + "," + j + "," + k + "," + l);
              int total = i + j + k + l;
              if (total == n ){
                //System.out.println(i + "," + j + "," + k + "," + l);
               array.add(1);
              }
            }
          }
        }
      }
   System.out.println(array.size());
    }
  }
}

Measured memory_bytes: 27312
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
const int nmax=2002;
struct edge{ll to;ll cost;};
vector<edge> tree[nmax];
ll d[nmax];
ll n;
void dijkstra(ll s){
  priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>> pq;
  fill(d,d+n,1e18);
  d[s]=0;
  pq.push(make_pair(0,s));
  while(!pq.empty()){
    pair<ll,ll> p=pq.top();
    pq.pop();
    ll v=p.second;
    if(d[v]<p.first){
      continue;
    }
    for(auto x:tree[v]){
      edge e=x;
      if(d[e.to]>d[v]+e.cost){
        d[e.to]=d[v]+e.cost;
        pq.push(make_pair(d[e.to],e.to));
      }
    }
  }
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x,y;cin >> n >> x >> y;
    x--,y--;
    for(int i=0;i<n-1;i++){
        tree[i].push_back(edge{i+1,1});
        tree[i+1].push_back(edge{i,1});
    }
    tree[x].push_back(edge{y,1});
    tree[y].push_back(edge{x,1});
    vector<int> t(n);
    for(int i=0;i<n;i++){
        dijkstra(i);
        for(int j=0;j<n;j++){
            t[d[j]]++;
        }
    }
    for(int i=1;i<=n-1;i++){
        cout << t[i]/2 << endl;
    }
}

Measured memory_bytes: 384
#include <stdio.h>
 
int main(void)
{
	int n;
	int p[10];
	scanf("%d",&n);
	int i;
	int memo;
	int max=0;
	for(i=0;i<n;i++){
		scanf("%d",&p[i]); 
		if(max<=p[i]) {
			max=p[i];
			memo=i;
		}
	}
	int sum=0;
	for(i=0;i<n;i++){
		if(i!=memo)sum+=p[i];
		else sum+=max/2;
	}
	printf("%d\n",sum);
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int [] a = new int [n];
		int [] count = new int[n + 1];
		int way = 1;
		boolean s = true;
		for(int i = 0; i < n; i++){ a[i] = sc.nextInt(); }
		
		for(int i = 0; i < n; i++){ count[a[i]] ++; }
		
		if(n % 2 == 0){
		for(int i = 1; i <= n; i += 2){ if(count[i] != 2){ s = false; }}
		for(int i = 0; i <= n; i += 2){ if(count[i] != 0){ s = false; }}
		}
		else{ 
		for(int i = 2; i <= n; i += 2){ if(count[i] != 2){ s = false; }}
		for(int i = 1; i <= n; i += 2){ if(count[i] != 0){ s = false; }}			
		if(count[0] != 1){ s = false; }
		}
		
		if(s)
		{for(int i = 1; i <= n / 2; i++){way = (way * 2) % ((int)Math.pow(10, 9) + 7);}
		System.out.println(way);} else {System.out.println(0);}	
	}}

Measured memory_bytes: 60672
import numpy as np
import itertools
A = np.array([[0]*3 for i in range(3)])
for i in range(3):
    A[i] = list(map(int, input().split()))
    
N = int(input())

b = np.array([0]*N)
for i in range(N):
    b[i] = int(input())
    
arr = np.array([[0]*3 for i in range(3)])

for i, x, y in itertools.product(range(N), range(3), range(3)):
    if A[x][y] == b[i]:
        arr[x][y] = 1

flag = False
for i in range(3):
    if sum(arr[i]) == 3:
        flag = True

for i in range(3):
    if sum(arr[:,i]) == 3:
        flag = True
        
if arr[0][0] + arr[1][1] + arr[2][2] == 3:
    flag = True

if arr[0][2] + arr[1][1] + arr[2][0] == 3:
    flag = True
    
if flag:
    print('Yes')
else:
    print('No')

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


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

	int cnt = 0;
	while (true) {
		n /= k;
		cnt++;
		if (n == 0) {
			break;
		}
	}

	cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n;
    cin >> n;
    vector<ll> v(n), c(n);
    rep(i, 0, n) cin >> v[i];
    rep(i, 0, n) cin >> c[i];
    ll ans = 0;
    rep(i, 0, n) if (v[i] > c[i]) ans += v[i] - c[i];
    cout << ans << endl;
}

Measured memory_bytes: 256
#define  _USE_MATH_DEFINES

#define  rep(i, n) for(int i = 0; i < n; i++)
#define  repx(i, a, n) for(int i = a; i < n; i++)
#define  loop while(1)
#define  lli long long int
#define  aryout(ary) rep(i, ary.size()) cout << ary[i] << (i < ary.size() - 1 ? " " : "\n");
#define  arysort(v) sort(v.begin(), v.end())
#define  aryreverse(v) reverse(v.begin(),v.end())ﾎﾉ
#define  arysum(v) accumulate(v.begin(), v.end(), 0)
 
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <utility>
#include <set>

using namespace std;

vector<int> subset_sum_total(vector<int> v, int x) {
  
  int n = v.size();
  int sum = x;

  vector<int> tab1(sum + 1, 0);
  tab1[0] = 1;

  rep(i, n) {
    rep(j, sum - v[i] + 1)
      tab1[j + v[i]] += tab1[j];
  }
  return tab1;
}

int main() {

  int n, x;

  loop {
    cin >> n >> x;
    if (n + x == 0) break;

    vector<int> v(n);
    rep(i, n) cin >> v[i];

    vector<int> cost = subset_sum_total(v, x);

    for(int i = cost.size() - 1; i > 0; i--) {
      bool flag = false;
      if (cost[i] > 0) {
        flag = true;
        repx(j, 2, sqrt(i)) {
          if (i % j == 0) {
            flag = false;
            break;
          }
        }
      }
      if (flag) {
        cout << i << endl;
        break;
      }
      else if (i == 1) {
        cout << "NA" << endl;
      }
    }
  }

  return 0;
}



Measured memory_bytes: 9688
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,r;
    cin>>n;
    r=n%100;
    n=n/100;
    if(n>0 && r>0)
    {
        if(n>=1 && n<=12 && r>=1 && r<=12)cout<< "AMBIGUOUS";
        else if(n>12 && r>=1 && r<=12)cout<< "YYMM";
        else if(n>=1 && n<=12 && r>12)cout<< "MMYY";
        else cout<< "NA";
    }
    else if(n>=1 && n<=12 && r==0)cout<< "MMYY";
    else if(r>=1 && r<=12 && n==0)cout<< "YYMM";
    else cout<< "NA";

}



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

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

  vector<double> x(n);
  vector<string> u(n);
  double ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> u[i];
    if (u[i] == "BTC") {
      x[i] *= 380000;
    }
    ans += x[i];
  }
  cout << ans << endl;
}


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

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

int main(){
  int k,a,b;
  cin >> k >> a >> b;
  for (int i = a; i <= b; i++){
    if (i % k == 0){
      cout << "OK\n";
      return 0;
    }
  }
  cout << "NG\n";
  return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define iso ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef unsigned long long ull;
#define pb push_back
#define make_pair mp
#define clr(x,n) memset((x), n, sizeof(x))
#define mod 1000000007
#define MAX 1000005
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<ll ,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_tree;*/
vector<int> adj[100005];
int dp[100005];
int temp=0;
int dfs(int s)
{
    if(dp[s]!=-1)
        return dp[s];
    int temp = 0;
    for(int i=0;i<adj[s].size();i++)
    {
        temp=max(temp,dfs(adj[s][i])+1);
    }
    return dp[s]=temp;


}
int main()
{
    iso;
    int n,m,i,a,b;
    cin>>n>>m;
    for(i=0;i<m;i++)
    {
        cin>>a>>b;
        adj[a].pb(b);
    }
    int ans = 0,j;
    clr(dp,-1);
    for(i=1;i<=n;i++)
    {
        ans =max(ans,dfs(i));

    }

    cout<<ans;
    return 0;
}


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

int main() {
  int A, B, C, D, L, R;
  cin >> A >> B >> C >> D;
  L = A+B;
  R = C+D;
  
  if(L>R)
    cout << "Left" << endl;
  else if(L<R)
    cout << "Right" << endl;
  else
    cout << "Balanced" << endl;
}

Measured memory_bytes: 3604
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

#define INF (1ll<<60)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;

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

template<class T>bool umax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool umin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;

// gcd
int gcd(int a, int b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}
// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}

// sort big to small
// sort(A,A+N, greater<int>());

// v.front() = -BOUND;
// v.back() = BOUND;

// Iterator
// v.begin
// v.end

int main() {
    int N,A,B;
    long long ans=0;

    cin >> N >> A >> B;

    for(int i=1; i<=N; i++){
        int temp=i;
        int wa=0;
        while(temp>0){
            wa+=temp%10;
            temp/=10;
        }
        if(wa>=A && wa<=B) ans+=i;
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
s = input()
t = input()

s_length = len(s)
t_length = len(t)

ans = 1000

if s_length != t_length:
  for i in range(s_length - t_length):
    diff = 0
    parts = s[i:t_length+i]
    for j in range(t_length):
      if parts[j] != t[j]:
        diff += 1
    if ans > diff:
      ans = diff
else:
  ans = 0
  for j in range(t_length):
    if s[j] != t[j]:
      ans += 1

print(ans)


Measured memory_bytes: 67668
import java.util.*;
import java.io.*;

class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
    
            int a = scan.nextInt();
            int b = scan.nextInt();
            int C = scan.nextInt();
            
            double x = Math.sin(Math.toRadians(C));
            double y = Math.cos(Math.toRadians(C));
            double E = Math.sqrt(a*a + b*b - 2*a*b*y);
            double S = 0.5*a*b*x;
            double L = a + b + E;
            double h = S*2/a;

            System.out.println(S);
            System.out.println(L);
            System.out.println(h);
        
    }
}

Measured memory_bytes: 26108
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#define pb push_back 
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
typedef long long ll;
const int INF = 100000000, mod = 1000000007;
const ll LLINF = 1LL << 50;
using namespace std;


int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    cout << a + b + c + max(max(a, b), c)*(pow(2,k)-1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define TRUE 1
#define FALSE 0

int judgeSeven_100(int input){
	int hundredsPlace = input / 100;
  	int isSeven = FALSE;
  
  if(hundredsPlace == 7){
  	isSeven = TRUE;
  }
  	
  return isSeven;
}

int judgeSeven_10(int input){
	int tensPlace = (input % 100) / 10;
	int isSeven = FALSE;
  
  if(tensPlace == 7){
    isSeven = TRUE;
  }
  
	return isSeven;
}

int judgeSeven_1(int input){
	int onesPlace = (input % 10);
  int isSeven = FALSE;
  
  if(onesPlace == 7){
  	isSeven = TRUE;
  }

  return isSeven;
}

int main(){
  int input;
  int inputResult = 0;
  
	inputResult = scanf("%d", &input);
  
  if(judgeSeven_100(input) == TRUE){
       printf("Yes");
  }
  else if(judgeSeven_10(input) == TRUE){
       printf("Yes");
  }
  else if(judgeSeven_1(input) == TRUE){
       printf("Yes");
  }
  else{
  	printf("No");
  }
  
  return 0;
}  


Measured memory_bytes: 1732
#include<bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define RREP(i, n) for(int i=0; i>(int)(n); i--)
#define ALL(v) v.begin(), v.end()
#define INF 2e9
typedef long long ll;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return 1;}return 0;}

using namespace std;

int main(void)
{
	int A, B, C;
	cin >> A >> B >> C;
	if(A==B and B==C){
		cout << "Yes";
	}else{
		cout << "No";
	}
	cout << endl;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] skewers = new int[2*n];
		for (int i = 0; i < 2*n; i++) {
			skewers[i] = sc.nextInt();
		}
		Arrays.sort(skewers);
		int sum = 0;
		for (int i = 0; i < n; i++) {
			sum += skewers[2*i];
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <math.h>
using namespace std;

typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) a.begin(),a.end()

int main() {
	vi a(3);
	rep(i, 3)cin >> a.at(i);
	sort(all(a));
	if (a.at(0) == a.at(1))cout << a.at(2);
	else cout << a.at(0);
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma warning(disable:4996)
#include <stdio.h>
#include <string>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
#include <map>
#include <iomanip> 
#include <ctime>
#include <numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<string, int> P;

const double PI = 3.14159265358979323846;


int main(int argc, char *args[]) {
	int n; cin >> n;
	map<string, int> ma;
	rep(i, n) {
		string s; cin >> s;
		ma[s]++;
	}
	int max_value=0;
	for (auto itr = ma.begin(); itr != ma.end(); itr++) {
		if (max_value < itr->second) {
			max_value = itr->second;
		}
	}
	priority_queue<string,vector<string>, greater<string>> pq;
	for (auto itr = ma.begin(); itr != ma.end(); itr++) {
		if (max_value == itr->second) {
			pq.push(itr->first);
		}
	}
	while (!pq.empty()) {
		cout << pq.top() << endl;
		pq.pop();
	}
	return 0;
}

Measured memory_bytes: 26868
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int long long
#define pii pair<int,int>
#define endl '\n'
#define mod 1000000007
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define in insert
#define rep(i,a,b) for(int i = a ; i < b ; i++)
#define repr(i,a,b) for(int i = b ; i > a ; i--)

signed main() 
{	
	fast;
	int a, b;
	cin >> a >> b;
	if(a%b==0)
		cout << a/b;
	else
		cout << a/b+1;
}


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

int main (){
	int N;
	cin>>N;
	int K[N];
	int P[N];
	for(int i=0;i<N;i++){
		cin>>K[i]>>P[i];
	}
	for(int j=0;j<N;j++){
		if(K[j]%P[j]==0){
			cout<<P[j]<<endl;
		}else{
		cout<<K[j]%P[j]<<endl;
		}
	}
return 0;
}

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

int main()
{
	int d = 0;
	scanf("%d", &d);
	switch(d)
	{
		case 25:
			printf("Christmas\n");
			break;
		case 24:
			printf("Christmas Eve\n");
			break;
		case 23:
			printf("Christmas Eve Eve\n");
			break;
		case 22:
			printf("Christmas Eve Eve Eve\n");
			break;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
set<string>s;
int main()
{
	ios::sync_with_stdio(false);
	string st;
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>st;
		s.insert(st);
	}
	cout<<s.size()<<endl;
	return 0;
}

Measured memory_bytes: 19276
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int N;
  cin >> N;

  int ans = N * (N + 1) / 2;
  cout << ans << endl;
}


Measured memory_bytes: 3556
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>


#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define LOWER(a,x) lower_bound(ALL(a), x) - a.begin() - 1;
#define COUNT(a,x)  upper_bound(ALL(a), x) - lower_bound(ALL(a), x);
#define MCOUNT(a,x,y) upper_bound(ALL(a), y) - lower_bound(ALL(a), x);
#define scan(x) scanf("%lld",&x);
#define inf 5555555555555555555
#define mod 1000000007
#define pi 3.14159265358979323846
#define pb push_back
#define F first
#define S second
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef map<ll, ll> MAP;
typedef set<ll> SET;
ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0, ma = 0, mi = 0;
string s;
bool flag, ok;
ll dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 111111

ll w[MAX * 3], e[MAX * 3];
int main(void) {
  ll ww, ee;
  cin >> n;
  cin >> s;
  FOR(i, 1, n + 1) {
	w[i] = w[i - 1];
	e[i] = e[i - 1];
	if (s[i - 1] == 'W') {
	  w[i]++;
	}
	else {
	  e[i]++;
	}
  }
  ans = inf;
  FOR(i, 0, n) {
	ww = w[i];
	ee = e[n] - e[i + 1];
	tmp = ee + ww;
	ans = min(ans, tmp);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 5636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()

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

    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) cin >> A[i];
    int ans = 1e9;
    REP(i, N) {
        int cnt = 0;
        while (A[i] % 2 == 0) {
            A[i] /= 2;
            cnt++;
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int cv(char c){
    if(isdigit(c)) return c-'0';
    if(isupper(c)) return 10+c-'A';
    return 36+c-'a';
}

int READ(){
    int p;
    string m;
    cin >>p >>m;

    int ret = 0;
    for(char c:m) ret = ret*p + cv(c);
    return ret;
}

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

    int g = 0;
    rep(i,n) g ^= __builtin_popcount(READ());
    cout << (g==0?"lose":"win") << endl;
    return 0;
}



Measured memory_bytes: 3184
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ull, ull> UP;
typedef tuple<int, int, int> T;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
ll digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}
ll countpow(ll a, ll b) {
	int ans = 0;
	if (b == 0)return -1;
	while (1) {
		if (a % b == 0) {
			a /= b;
			ans++;
		}
		else break;
	}
	return ans;
}


int main() {
	IOS;
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b)cout << c << endl;
	if (a == c)cout << b << endl;
	if (c == b)cout << a << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }

int main(){
    ll N;
    cin >> N;
    if (N <= 999) cout << "ABC\n";
    else cout << "ABD\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i,n){
        cin >> d[i];
    }
    sort(d.begin(),d.end());
    int ret = 0;
    rep(i, 100002)
    {
        auto it = lower_bound(d.begin(),d.end(), i);
        int num = d.end()-it;
        if (num == n / 2)
        {
            ret++;
        }
    }
    cout << ret << endl;
}

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

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

double heikin = 0;
vector<int> A(N);
for( int i = 0; i < N; i++ ){
cin >> A.at(i);
heikin += A.at(i);
}

heikin = heikin/ (double)N;

double sa = 1000;
int ans;
for( int i = 0; i < N; i++ ){
if( abs( heikin - A.at(i) ) < sa ){
ans = i;
sa = abs( heikin - A.at(i) );
}
}

cout << ans << endl;




            
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
//解説閲覧後

bool isOK(string ss,string t)
{//sをi文字目からtと同じ文字数で切り取ったものがssとして届く
 //cout << ss<<":"<<t<<endl;
 rep(i,ss.size())
 { 
   if(ss[i]!='?'&&ss[i]!=t[i])
   {return false;}
 }
 //cout<<"true!"<<endl;
 return true;

}

int main() {
 string s,t,ans="~";
 //s,tは小文字なので、どんなSでも置き換えられる 置き換えることができなければそのままUNRESTORABLE

 cin >> s >>t;

 for (int i = 0; i <= (int)s.size()-(int)t.size(); i++)
 {
	 if(isOK(s.substr(i,t.size()),t))//そこに挿入可なら
	 {//実際に挿入
	  string v=s;
	  for(int j=0; j<t.size(); j++)
	  {v[j+i]=t[j];}

	  //?を置き換え
	 rep(j,i)//i(挿入開始地点)まで見る
	 {if(v[j]=='?')v[j]='a';}
	 for(int j=i+t.size(); j <s.size();j++)
	 {if(v[j]=='?')v[j]='a';}

	 
	 ans=min(ans,v);
	 }
	 
 }
 
	if(ans=="~")
	{ans="UNRESTORABLE";}
 
	cout << ans <<endl;
	return 0;
}

/*vector <int> a(3);
for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }*/

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while(true){
			String tmp = scan.nextLine();
			if(tmp.equals("0")){
				break;
			}
			int cnt = 0;
			int sum = 0;
			while(cnt < tmp.length())
				{
					String s = String.valueOf(tmp.charAt(cnt));
					sum += Integer.parseInt(s);
					cnt++;
				}
				System.out.println(sum);
		}
	}
}



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

using i64 = long long;

const i64 MOD = 1e9 + 7;
const int N = 2e5 + 5;

i64 fact[N];

i64 ant;

static i64 expow(i64 b, i64 e) {
	i64 ant(1);

	for (; e > 0; e/= 2) {
		if (e % 2)
			ant = ant * b % MOD;
		b = b * b % MOD; }

	return ant; }

static i64 inv(i64 x) {
	return expow(x, MOD - 2); }

static i64 comb(i64 n, i64 k) {
	return fact[n] * inv(fact[n - k]) % MOD * inv(fact[k]) % MOD; }

static i64 roads(int a, int b) {
	return comb(a + b, b); }

int main() {
#ifdef HOME
	freopen("atc.in", "r", stdin);
	freopen("atc.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int n, m, a, b;

	fact[0] = 1;
	for (int i = 1; i < N; ++i)
		fact[i] = fact[i - 1] * i % MOD;

	cin >> n >> m >> a >> b;
	
	a = n - a + 1;

	for (int i = 1; a - i > 0 && b + i <= m; ++i)
		ant = (ant + roads(a - i - 1, b + i - 1) * roads(n - (a - i), m - (b + i))) % MOD;

	cout << ant << endl;
	cerr << ant << endl;

	return 0; }


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

using namespace std;

int main() {
	int n, i, j, nn;

	cin >> n;

	nn = n;

	for (i = 0; i * 7 <= n; i++) {
		nn -= i * 7;
		for (j = 0; j * 4 <= nn; j++) {
			if (nn == j * 4) {
				cout << "Yes";
				return 0;
			}
		}
		nn = n;
	}

	cout << "No";

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N; cin >> N;
  vector<tuple<string, int, int>> guidebook;
  for(int i=1;i<N+1;i++){
    string S;
    int P;
    cin >> S >> P;
    P=-P;
    guidebook.push_back(tie(S,P,i));
  }
  sort(guidebook.begin(), guidebook.end());
  for (int i=0;i<N;i++){
    cout << get<2>(guidebook.at(i)) << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
const int maxn=1e5+3;
const int M=998244353;
const int inv2=(M+1)/2;
const int P=1000000000000000000ll%M;
const int E=1<<17;
vector <int> h[maxn];
int sg[maxn],n,m,cnt[3][E],a[maxn],ans[maxn];
bool f[maxn];
void add(int &x,int y){
    x+=y;if (x>=M)x-=M;
}
void FWT(int a[],int n){
    for(int d=1;d<n;d<<=1)
        for(int m=d<<1,i=0;i<n;i+=m)
            for(int j=0;j<d;j++){
                int x=a[i+j],y=a[i+j+d];
                a[i+j]=(x+y)%M,a[i+j+d]=(x-y+M)%M;
            }
}
void UFWT(int a[],int n){
    for(int d=1;d<n;d<<=1)
        for(int m=d<<1,i=0;i<n;i+=m)
            for(int j=0;j<d;j++){
                int x=a[i+j],y=a[i+j+d];
                a[i+j]=1ll*(x+y)*inv2%M,a[i+j+d]=1ll*(x-y+M)*inv2%M;
            }
}
int main(){
    scanf("%d",&n);
    a[0]=1;
    for (int i=1;i<=n;i++) a[i]=1ll*a[i-1]*P%M;
    for (int i=0;i<3;i++){
        scanf("%d",&m);
        for (int j=1;j<=n;j++) h[j].clear();
        for (int j=0;j<m;j++){
            int u,v;scanf("%d%d",&u,&v);
            if (u>v) swap(u,v);
            h[u].pb(v);
        }
        for (int j=n;j;j--){
            sg[j]=0;
            for (auto v:h[j]) f[sg[v]]=1;
            while (f[sg[j]]) sg[j]++;
            for (auto v:h[j]) f[sg[v]]=0;
            add(cnt[i][sg[j]],a[j]);
        }
        FWT(cnt[i],E);
    }
    for (int i=0;i<E;i++) ans[i]=1ll*cnt[0][i]*cnt[1][i]%M*cnt[2][i]%M;
    UFWT(ans,E);
    printf("%d\n",ans[0]);
    return 0;
}


Measured memory_bytes: 7936
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		String num = scan.nextLine();
		String out;
		
        for (int i = 0; i < num.length() ; i++) {
        	char c = num.charAt(i);
        	if(c == '1') {
        		System.out.print("9");
        	} else {
        		System.out.print("1");
        	}
        }
	}
}


Measured memory_bytes: 22996
#include <iostream>
using namespace std;
#define ABS(x) (((x)<0)?(-x):(x))
int main()
{
  ios::sync_with_stdio(false);
  int x, y;
  cin >> x >> y;
  int ax = ABS(x);
  int ay = ABS(y);
  int ret = 0;
  if( ax < ay ){
    if( x < 0 ) ret++;
    ret += ay - ax;
    if( y < 0 ) ret++;
  } else if( ax > ay ) {
    if( x > 0 ) ret++;
    ret += ax - ay;
    if( y > 0 ) ret++;
  } else {
    if( x < 0 && y > 0 ) ret++;
    if( x > 0 && y < 0 ) ret++;
  }
  cout << ret << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
typedef pair<string, string> pss;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

int s(int n) {
    int r = 0;
    while(n) {
        r += n%10;
        n /= 10;
    }
    return r;
}

int main() {
    int n;
    scanf("%d", &n);
    int ret = 100000;
    for(int i = 1; i < n; i++) {
        ret = min(ret, s(i) + s(n-i));
    }
    printf("%d\n", ret);
}


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

void solve() {
	
}

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

    int five = 0;
    int seven = 0;
    
    int a;
    for (int i=0; i<3; i++){
    	cin >> a;
    	if (a == 5){
    		five++;
    	}
    	
    	if (a == 7){
    		seven++;
    	}
    }
    
    if (five == 2 && seven == 1){
    	cout << "YES";
    }
    else{
    	cout << "NO";
    }

    return 0;
}

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

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<int> v_int;
typedef std::vector<v_int > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<v_ll > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<v_string > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<v_bool > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

const double PI = 3.1415926535897932;
const int INF = (int)1e9;
const ll LINF = 1e18;
const ll MOD = 1000000007;
const int dr[4] = {1, 0, -1, 0};
const int dc[4] = {0, 1, 0, -1};

using namespace std; 

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p)
{
    return o << "{" << p.first << "," << p.second << "}";
}

template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &v)
{
    int len = v.size();
    for(int i = 0; i < len; i++) { 
        os << v[i];
        if(i != len-1) { os << ","; } 
    } 
    return os;
}

int main(void)
{
    int n; cin >> n;
    string s; cin >> s;
    
    v2_int digits(10);

    irep(i, n) {
        int d = s[i]-'0';
        digits[d].push_back(i);
    }

    int ans = 0;

    irep(str, 1000) {
        int num = str;
        int p = 0;

        irep(j, 3) {
            int d = num%10;
            auto it = lower_bound(digits[d].begin(), digits[d].end(), p);
            if(it != digits[d].end()) {
                p = *it+1;
                if(j == 2) { ans++; }
            } else {
                break;
            }
            num /= 10;
        }
    }
    cout << ans << endl;
    return 0;
}

/*atcoder*/


Measured memory_bytes: 512
#include<stdio.h>
int Sosuu(int );

int main(){
  int n,a,count=0,i=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a);
    if( Sosuu(a) )count++;
  }
  printf("%d\n",count);
  return 0;
}
int Sosuu(int x){
  int i;
  if(x<2)return 0;
  else if(x==2)return 1;
  if(x%2==0)return 0;

  for(i=3;i*i<=x;i+=2){
    if(x%i==0)return 0;
  }
  return 1;
}




Measured memory_bytes: 2084
#include <stdio.h>
#include <string.h>

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch){
  if(ch == 'A') return 1;
  else if(ch == 'C') return 2;
  else if(ch == 'G') return 3;
  else if(ch == 'T') return 4;
  else return 0;
}

long long getKey(char str[]){
  long long sum = 0,p = 1,i;
  for(i=0;i<strlen(str);i++){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){
  return key % M;
}
int h2(int key){
  return 1 + (key % (M - 1));
}

int find(char str[]){
  long long key,i,h;
  key = getKey(str);
  for(i=0;;i++){
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h],str) == 0) return 1;
    else if(strlen(H[h]) == 0) return 0;
  }
  return 0;
}

int insert(char str[]){
  long long key,i,h;
  key = getKey(str);
  for(i=0;;i++){
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h],str) == 0) return 1;
    else if(strlen(H[h]) == 0){
      strcpy(H[h],str);
      return 0;
    }
  }
}

int main(){
  int i,n;
  char str[L],com[9];
  for(i=0;i<M;i++) H[i][0] = '\0';
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s %s",com,str);
    
    if(com[0] == 'i'){
      insert(str);
    }
    else{
      if(find(str)){
	printf("yes\n");
      }
      else {
	printf("no\n");
      }
    }
  }
  return 0;
}



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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
	string s,t;cin>>s>>t;
	int cnt=0;
	rep(i,s.size()){
		if(s[i]!=t[i])cnt++;
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 3844
n1=int(input())
n2 = [int(x) for x in input().split()]

cnt = 0

len_min2 = len(n2) - 2

for i in range(len_min2):
  if n2[i+2] >= n2[i+1] and n2[i+1] >= n2[i]:
    cnt += 1
  elif n2[i+2] <= n2[i+1] and n2[i+1] <= n2[i]:
    cnt += 1
    
print(cnt)

Measured memory_bytes: 3060