akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
using i64 = int64_t;
using u64 = uint64_t;

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

constexpr int64_t MOD = 1'000'000'007LL;

#define INT(NAME) int NAME; cin>>NAME;
#define INT64(NAME) int64_t NAME; cin>>NAME;
#define VECTOR(NAME, TYPE, SIZE) std::vector<TYPE> NAME((SIZE));\
    for(int xxxx_i=0; xxxx_i<SIZE; xxxx_i++) cin>>NAME[xxxx_i];
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)    


void solve() {
    INT(N)
    VECTOR(A,int,N)

    if (N==2) {
        cout<<max(A[0], A[1])<<endl;
        return;
    }

    if (N==3) {
        cout<<max(A[0]+A[2], A[1])<<endl;
        return;
    }

    i64 ans;
    if (N&1) {
        vector<i64> dp(A.begin(), A.begin()+3);
        vector<i64> next(3);
        for(int i=2; i+2<N; i+=2) {
            next[0] = A[i] + dp[0];
            next[1] = A[i+1] + max(dp[0], dp[1]);
            next[2] = A[i+2] + max(max(dp[0], dp[1]), dp[2]);
            swap(dp, next);
        }
        ans = *max_element(dp.begin(), dp.end());
    }
    else {
        vector<i64> dp(A.begin(), A.begin()+2);
        vector<i64> next(2);
        for(int i=2; i+1<N; i+=2) {
            next[0] = A[i] + dp[0];
            next[1] = A[i+1] + max(dp[0], dp[1]);
            swap(dp, next);
        }
        ans = *max_element(dp.begin(), dp.end());
    }
    cout<<ans<<endl;
}

int main() {
    solve();

    return 0;
}

Measured memory_bytes: 3988
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
using namespace std;
int main(void){
  int n,i,ax,b;
  long ans=0;
  vector<int> a;
  cin >> n;
  for (i=0;i<n;i++){
    cin >> ax;
    a.push_back(ax-i-1);
  }
  sort(a.begin(),a.end());
  if (n%2) b=a.at((n-1)/2);
  else b=a.at(n/2);
  for (i=0;i<n;i++) ans+=abs(a.at(i)-b);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main(){
    int x, y;
    cin >> x >> y;
    if (y % 2 || y / 2 < x || 2 * x < y / 2) cout << "No";
    else cout << "Yes";
    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  bool sat = false;
  rep(i,N){
    int x;cin >> x;
    if(x&1)sat = true;
  }
  if(sat)cout << "first" << endl;
  else cout << "second" << endl;
  return 0;
}


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

int main()
{
    int N, M;
    vector < pair < int , int > > vec;

    cin >> N;
    for ( int i = 0; i < N; i++ ) {
        int h, m;
        cin >> h >> m;
        vec.emplace_back(h, m);
    }

    cin >> M;
    for ( int i = 0; i < M; i++ ) {
        int h, m;
        cin >> h >> m;
        vec.emplace_back(h, m);
    }
    sort(begin(vec), end(vec));
    vec.erase(unique(begin(vec), end(vec)), end(vec));
    printf("%d:%02d", vec[0].first, vec[0].second);
    for ( int i = 1; i < vec.size(); i++ ) {
        printf(" %d:%02d", vec[i].first, vec[i].second);
    }
    putchar('\n');

    return ( 0 );
}



Measured memory_bytes: 3224
#include<stdio.h>

//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_4_D
//increasr the P to satisfy the requirement of the question
/*
5 3
8
1
7
3
9
*/

//deal with case: count>=1 , may be divvided into many subset which smaller than tracks
//TLE O(n^2)
//O(nlgn) 
int main(){
	int p = 0;// the max common load
	int n, track,max=0,total = 0;
	
	scanf("%d %d",&n,&track);
	int in[n+1];
	int count = track;
	for(int i = 0; i<n; i++){
		scanf("%d",&in[i]);
		if(in[i]>max) max = in[i];
		total += in[i];
	}
	//binary search	
	int left = 0;
	int right = total;
	int flag = 0;
	while(left+1<right){
		int i = (left+right)/2;
		//printf("%d %d %d\n",left,i,right);
		p = i;
		int k;
		count = track;
		//printf("i: %d\n",i);
		for(k = 0; k<n; k++){
			if(i<in[k]){
				count = 0; break;
			}
			if(p>=in[k]){
				//printf("in same subset\n");
				p = p - in[k]; 
			}else if(p<in[k]){
				//printf("new subset\n");
				count--;
				p = i-in[k];
			}
			//printf("%d %d %d %d\n",p, count,in[k],k);
			//if(count==1) break;// the first ele in the last subset
		}
		//printf("%d %d",k, count);
		//printf("count: %d\n",count);
		 if(count<1){  // deal with case
			left = i;
		 }
		 else {
		 	right = i;
		 }
		 p = right;
	}
	
	/*for(int i = max; i<=total; i++){
		//satisfy
		p = i;
		int k;
		count = track;
		//printf("i: %d\n",i);
		for(k = 0; k<n; k++){
			if(p>=in[k]){
				//printf("in same subset\n");
				p = p - in[k]; 
			}else if(p<in[k]){
				//printf("new subset\n");
				count--;
				p = i-in[k];
			}
			//printf("%d %d %d %d\n",p, count,in[k],k);
			//if(count==1) break;// the first ele in the last subset
		}
		//printf("%d %d",k, count);
		 if(count>=1){  // deal with case
			p = i; break;
		 }
	}*/
	if(track==1) printf("%d\n",total); 
	else printf("%d\n",p);
	
	return 0;
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
#define FIN         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii          pair<int,int>
#define F           first
#define S           second
#define pb          push_back
#define all(x)      (x).begin(),(x).end()
#define rall(x)     (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a)   for(int i = a; i >= 0; i--)
#define fori(i,m)   for(auto i = m.begin(); i != m.end(); i++) 
#define w(t)        while(t--)
#define sz(s)       int(s.size())
#define cls(a,car)  memset(a,car,sizeof (a))
#define db(x)       cerr << #x << " is " << x << '\n'
#define FL          freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout);
#define EjecuteTime cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
#define angle(x)    double(x * acos(-1) / 180.0)
using namespace std;
typedef long long   ll;
typedef vector<int> vi;
typedef vector<ii>  vii;
const int N = 1 * 1e7 + 5;
const ll mod = 1e9 + 7;
const double E = 1e-9;
int dx[] = {1, 0}, dy[] = {0, 1};
//int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//int dx[] = {2, 1, -1, -2, -2, -1, 1, 2}, dy[] = {1, 2, 2, 1, -1, -2, -2, -1};
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b)
int add(int a, int b){return  a + b > mod ? a + b - mod : a + b;}
int mul(int a, int b){return a * b > mod ? a * b % mod : a * b;}
int v[N];
int main(){
    //FL;
    FIN;
    for(int i = 1; i < N; i++)v[i] = 1;
    for(int i = 2; i < N; i++)
            for(int j = i; j < N; j += i)
                v[j]++;
    
    int n;
    cin >> n;
    ll ans = 0;
    for(int i = 1; i <= n; i++){
        ans += 1ll * i * v[i];
    }
    cout << ans << '\n';
    EjecuteTime;
    return 0;
}       


Measured memory_bytes: 42812
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto n = readln.chomp.to!size_t;
  auto a = readln.split.to!(long[]);
  auto b = readln.split.to!(long[]);
  auto c = readln.split.to!(long[]);

  auto as = a.sort();
  auto bs = b.sort();
  auto cs = c.sort();

  auto bc = new long[](n);
  foreach (i; 0..n)
    bc[i] = cs.upperBound(bs[i]).length;

  foreach_reverse (i; 0..n-1)
    bc[i] += bc[i+1];

  auto ans = 0L;
  foreach (i; 0..n) {
    auto at = bs.upperBound(as[i]);
    if (!at.empty) {
      auto j = bs.length - bs.upperBound(as[i]).length;
      ans += bc[j];
    }
  }

  writeln(ans);
}


Measured memory_bytes: 13256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int hn[2000][2000];
int vn[2000][2000];
string masu[2000];

int main() {
  int h,w;
  cin >> h >> w;
  for (int i = 0; i < h; i++) {
    cin >> masu[i];
  }

  for (int i = 0; i < h; i++) {
    int cnt = 0, prev = -1;
    for (int j = 0; j < w; j++) {
      if (masu[i][j] == '.') {
        cnt++;
      } else {
        for (int k = prev+1; k < j; k++) {
          hn[i][k] = cnt;
        }
        cnt = 0;
        prev = j;
      }
    }
    if (cnt != 0) {
      for (int k = prev+1; k < w; k++) {
        hn[i][k] = cnt;
      }
    }
  }
  for (int i = 0; i < w; i++) {
    int cnt = 0, prev = -1;
    for (int j = 0; j < h; j++) {
      if (masu[j][i] == '.') {
        cnt++;
      } else {
        for (int k = prev+1; k < j; k++) {
          vn[k][i] = cnt;
        }
        cnt = 0;
        prev = j;
      }
    }
    if (cnt != 0) {
      for (int k = prev+1; k < h; k++) {
        vn[k][i] = cnt;
      }
    }
  }


  int ans = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      ans = max(ans, hn[i][j] + vn[i][j] - 1);
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 35584
N,M=map(int,input().split())
A=[1]*(N+1)
B=[0]*(N+1)
B[1]=1

for i in range(M):
  x,y=map(int,input().split())
  A[x]-=1
  A[y]+=1
  if B[x]:
    B[y]=1
    if not A[x]:
      B[x]=0
  #print(A)
  #print(B)
  #print("")
print(sum(B))

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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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; }

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int N; cin >> N;
    vector<ll> A(N);
    for(int i = 0; i < N; i++)  cin >> A[i];

    ll ans = 0;
    
    ll start = 0;
    ll sum = 0;
    ll end = 0;
    while(end < N){
        if( (sum ^ A[end]) != (sum + A[end]) ){
            ans += ll(end - start);
            sum -= A[start];
            start++;
        } else {
            sum += A[end];
            end++;
        }
    }
    
    ans += (end - start) * (end-start + 1) /2;

    cout << ans << endl;

    return 0;
}


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


int main() {
  long N,K;
  cin>>N>>K;
  if(K>(N-1)*(N-2)/2){
    cout<<-1<<endl;
    return 0;
  }
  cout<<N-1+(N-1)*(N-2)/2-K<<endl;

  vector<vector<long>> a(N+1,vector<long>(N+1));
  for(int i=0;i<=N;i++)  a[i][i]=1;
  for(int i=0;i<N-1;i++){
    cout<<1<<" "<<i+2<<endl;
    a[1][i+2]=1;
    a[i+2][1]=1;
  }
  int k=0;

  while(k<(N-1)*(N-2)/2-K){
    int i=rand()%N+1;
    int j=rand()%N+1;
    if(a[i][j]==0){
      k++;
      a[i][j]=1,a[j][i]=1;
      cout<<min(i,j)<<" "<<max(i,j)<<endl;
    }
  }


}


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

using namespace std;

#define REP(i,n)	for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,s,n)	for(int i=(s), i##_len=(n); i<i##_len; ++i)

#define ALL(obj)	(obj).begin(),(obj).end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define VEC vector

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

typedef pair<int,int>			P;
typedef vector<int>				Vint;
typedef vector<Vint>			VV;

template<typename T>string join(const v(T)&v)
{stringstream s;REP(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define MAX 		400010

const ll LINF = (ll)9e18+7;		//
const int INF = 100100100;			//2,147,483,647 (Max int)
const ll MOD = 1e9+7;
// テンプレ終了
//====================================================================//

// int DP[MAX];

//
int main(){
	int N,K;cin >> N >> K;


	ll ans = 0;

	REPS(i,K,N+2){
		ll t = (ll)(N-i+1)*i+1;
		// cout << " " << t;
		ans = (ans + t)%MOD;
	}

	cout << ans << endl;

	return 0;
}




Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
struct Node{
  int no;
  int par;
  int white;int black;
  vector<Node*> child;
  void build(int i){
    no=i;par=i;white=0;black=0;
  }
};
void rec(Node& node){
    if(node.child.size()==1&&node.par!=node.no){
        node.black=1;node.white=1;
    }
    else{
        int num=node.child.size();
        int buf_w=1;
        int buf_b=1;
        rep(i,num){
            if(node.child[i]->no==node.par)continue;
            rec(*node.child[i]);
            buf_w*=node.child[i]->white+node.child[i]->black;
            buf_b*=node.child[i]->white;
            buf_w%=MOD;
            buf_b%=MOD;
        }
        node.white=buf_w;
        node.black=buf_b;
    }
}
signed main(){
  int n;cin>>n;
  vector<Node> node(n+1);
  rep(i,n-1){
      int a,b;cin>>a>>b;
      node[a].child.push_back(&node[b]);
      node[b].child.push_back(&node[a]);
  }
  rep1(i,n){
      node[i].build(i);
  }
  queue<Node> que;
  que.push(node[1]);
  while(!que.empty()){
      Node buf=que.front();que.pop();
      int num=buf.child.size();
      rep(i,num){
          if(buf.child[i]->no!=buf.par){
              buf.child[i]->par=buf.no;
              que.push(*buf.child[i]);
          }
      }
  }
  rec(node[1]);
  cout<<(node[1].white+node[1].black)%MOD<<"\n";
  return 0;
}

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

ll N, T, H[100000];

int main(void) {
  cin >> N >> T;
  REP(i, 0, N) cin >> H[i];

  ll sum = 0, m = 0;
  REP(i, 0, N) {
    ll t = T - sum;
    m = max(m, H[i]);
    if(t <= 0) cout << 1 << endl;
    else cout << t / m + (t % m >= H[i] ? 1 : 0) + 1 << endl;
    sum += H[i];
  }
}

Measured memory_bytes: 3876
import java.util.*;

public class Main {
    private static final Scanner scn = new Scanner(System.in);
    
    public static void main(String[] args) {
        printMap(createMap());
    }
    
    private static Map<String, List<Integer>> createMap() {
        Map<String, List<Integer>> msl = new TreeMap<>();
        while(scn.hasNext()) {
            String str = scn.next();
            int page = scn.nextInt();
            List<Integer> li = null;
            if(msl.containsKey(str)) {
                li = msl.get(str);
            } else {
                li = new ArrayList<Integer>();
            }
            li.add(page);
            msl.put(str, li);
        }
        return msl;
    }
    
    private static void printMap(Map<String, List<Integer>> msl) {
        for(String str : msl.keySet()) {
            StringBuilder sb = new StringBuilder();
            List<Integer> li = msl.get(str);
            Collections.sort(li);
            for(int page : li) {
                sb.append(page + " ");
            }
            System.out.println(str);
            System.out.println(sb.toString().trim());
        }
    }
}

Measured memory_bytes: 26396
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll ;
typedef double db;
const double pi = 3.141592654;
#define pb         push_back
#define forab(i,a,b)       for(int i=(a);i<=(b);i++)
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)
#define pcase(z,x)     printf("Case %ld: %lld\n",z,x)
#define nw				"\n"
int main(void)
{
	CIN;
	ll tc,l,k,sum=0,x=0,y,z=0,m=1,n=0,ans=0,cnt=0;
	ll x1,x2,y1,y2;
	cin>>x1>>y1>>x2>>y2;
	x=x2-x1,y=y2-y1;
	cout<<(x2-y)<<" "<<(y2+x)<<" "<<x1-y<<" "<<y1+x;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cstdlib>
#include <list>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
 
int main(void)
{
    int N, A, B;
    cin >> N >> A >> B;

    if (A * N < B)
    {
        cout << A * N;
    }
    else 
    {
        cout << B;
    }
    
    

    return 0;
}


Measured memory_bytes: 764
N, K = map(int, input().split())
R, S, P = map(int, input().split())

T = input()
used = [False] * N

score = 0
for i, c in enumerate(T):
    if i >= K:
        if c == T[i - K] and used[i - K]:
            pass
        else:
            if c == 'r':
                score += P
            elif c == 'p':
                score += S
            else:
                score += R
            used[i] = True
    else:
        if c == 'r':
            score += P
        elif c == 'p':
            score += S
        else:
            score += R
        used[i] = True

print(score)

Measured memory_bytes: 4084
N = int(input())
ans = 0

for i in range(N):
  if (i + 1) % 2 == 1:
    d = 0
    for j in range(i + 1):
      if (i + 1) % (j + 1) == 0:
        d += 1
    if d == 8:
      ans += 1

print(ans)
        


Measured memory_bytes: 2940
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void){
	double n, k;
    scanf("%lf %lf", &n, &k);
    long double p = 0;
    double i = n;
	    double j = 0.0;
	    while (i > 0){
		        if (pow(2, j) * i >= k){
			            p += pow(0.5, j);
			            i -= 1.0;
			
		}
		else{
			            j += 1.0;
			
		}
		
	}
	    printf("%.12Lf\n", p / n);
	    return 0;
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
 
//int dxy[5] = {0, 1, 0, -1, 0};
// assign

typedef struct data{
    int num, value;
    vector< i_i > time;
}data;

int n, ans;
data input[100];

void dfs(int st, int table, int score);

signed main()
{
    while (cin >> n, n) {
        memset(input, 0, sizeof(input));
        rep(i, n) {
            cin >> input[i].num >> input[i].value;
            rep(j, input[i].num) {
                int a, b;
                cin >> a >> b;
                input[i].time.pb(mp(a, b));
            }
        }
        ans = 0;
        dfs(0, 0, 0);
        cout << ans << endl;
    }

    return 0;
}

void dfs(int st, int table, int score)
{
    //cout << st << endl;
    //rep(i, 16) { cout << (table >> i) % 2 << " "; } cout << endl;
    bool fl = true;
    int ntable = table;
    ans = max(ans, score);
    if (st == n) { return ; }
    rep(i, input[st].num) {
        for (int j = input[st].time[i].first;
                j < input[st].time[i].second; j++) {
            int tmp = 1 << (j-6);
            if (table & tmp) {
                fl = false;
            } else {
                ntable |= tmp;
            }
        }
    }
    if (fl) { 
        dfs(st+1, ntable, score + input[st].value);
    }
    dfs(st+1, table, score);
}

Measured memory_bytes: 3448
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    l=[]
    n=int(input())
    for i in range(n):
        s,p=input().split()
        ll=[s,int(p),i+1]
        l.append(ll)
    lll = sorted(l, key=lambda x:x[1], reverse=True)
    llll=sorted(lll,key=lambda x:x[0])
    for s,p,i in llll:
        print(i)
resolve()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define prArr(Arr,n) for(int _=0;_<n;_++)   cout<<(Arr)[_]<<" ";
#define f first
#define s second
using namespace std;
const int INF=(int)0x3f3f3f3f;
const int MOD=(int)1e9+7;
const double eps=1e-9;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,k;
    cin>>n>>k;
    cout<<(k==1?0:n-k);
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, M; cin >> N >> M;
    vector<int> X(M); for (int& x : X) cin >> x;
    sort(begin(X), end(X));
    vector<int> span(M-1);
    for (int i = 0; i < M-1; i++) span[i] = X[i+1] - X[i];
    sort(rbegin(span), rend(span));
    int ans = X[M-1] - X[0];
    for (int i = 0; i < N-1 && i < M-1; i++) ans -= span[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}
int read() {
	int tmp;
	cin >> tmp;
	return tmp;
}
int xor128() {
	static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	int t = (x xor (x << 11));
	x = y; y = z; z = w;
	return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}

signed main() {
	int x;
	cin >> x;
	if ((x % 100) % 5 == 0) {
		if (x / 100 < (x % 100) / 5) {
			cout << 0 << endl;
		}
		else cout << 1 << endl;
	}
	else {
		if (x / 100 < (x % 100) / 5 + 1) {
			cout << 0 << endl;
		}
		else cout << 1 << endl;
	}

	return 0;
}


Measured memory_bytes: 256
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
INF =  float("inf")
import bisect

N = int(input())
S = input()

alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

ans = ""
for i in range(len(S)):
    for j in range(26):
        if S[i] == alphabet[j]:
            k = (j+N) % 26
            ans += alphabet[k]
            break

print(ans)



Measured memory_bytes: 73964
#include<bits/stdc++.h>
using namespace std;
using UL = unsigned long;
using ULL = unsigned long long;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

    vector<ULL> P;

    void Primes() {
        bool Table[10000] = {};
        Table[0] = Table[1] = true;
        for (UL i = 2; i <= 100; i++) {
            if (Table[i]) continue;
            for (UL j = i * i; j < 10000; j += i) Table[j] = true;
        }
        Table[2] = true;
        for (UL i = 1; P.size() < 1000; i++) if (!Table[i]) P.push_back(i);
    }

    ULL ans[502][502];

    void Solve() {
        Primes();
        rep(i, 502) rep(j, 502) ans[i][j] = 1;
        rep(i, 500) rep(j, 500) {
            if ((i ^ j) & 1) continue;
            ULL tmp = P[(i + j) >> 1] * P[((i + 499 - j) >> 1) + 500];
            ans[i + 1][j + 1] = tmp;
        }
        rep(i, 500) rep(j, 500) if ((i ^ j) & 1) {
            ans[i + 1][j + 1] = ans[i + 1][j] * ans[i + 1][j + 2];
            if (j == 0 || j == 499) {
                ans[i + 1][j + 1] = ans[i][j + 1] * ans[i + 2][j + 1];
                if (i == 0 || i == 499) ans[i + 1][j + 1] *= ans[i + 1][j] * ans[i + 1][j + 2];
            }
            ans[i + 1][j + 1]++;
        }

        UL N; cin >> N;
        rep(i, N) {
            rep(j, N) {
                if (j) cout << " ";
                cout << ans[i + 1][j + 1];
            } cout << endl;
        }
    }
};
int main() {
    unique_ptr<Problem> p(new Problem());
    cout << fixed << setprecision(10);
    p->Solve();
    return 0;
}


Measured memory_bytes: 5120
#include<bits/stdc++.h>
#define ll long long int
ll a[1000000+9];
using namespace std;
int main()
{
    ll n,i,cnt=0;;

    cin>>n;
    ll x=0;
    for(i=0; i<n; i++)
    {
        cin>>a[i];
        if(a[i]%2==1)
        {
            x=1;
        }
    }
    if(x==1)
    {
        cout<<0<<endl;
    }
    else
    {
        ll f=0;
        while(1)
        {
            for(i=0; i<n; i++)
            {
                if(a[i]%2==0)
                {
                    a[i]=a[i]/2;
                }
                else if(a[i]%2==1)
                {
                    f=1;
                    break;
                }
            }
            cnt++;
            if(f==1)break;
        }
        cout<<cnt-1<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9;
const int mod = 1e9+7;
using ll = long long;
using P = pair<ll, ll>;
double PI = acos(-1);

struct Edge {
    int to, id;
};

int color[MX];
int x[MX];
int y[MX];

vector<vector<Edge>> g;
vector<int> ans;
int ma;
void dfs(int vertex,int c = -1, int p=-1) {
    int tmp = 1;
    //cout << vertex << endl;
    for(auto v: g[vertex]) {
        int u = v.to, ei = v.id;
        if(u==p) continue;
        if(tmp==c) tmp++;
        ans[ei] = tmp;
        ma = max(ma, ans[ei]);
        tmp++;
        dfs(u, ans[ei], vertex);
    }
}

signed main(){
    ll n;
    cin >> n;
    color[0] = 1;
    g.resize(n);
    ans.resize(n-1);
    rep(i,n-1) {
        ll a,b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(Edge{b,i});
        g[b].push_back(Edge{a,i});

    }

    dfs(0);
    cout << ma << endl;
    for(auto a: ans) cout << a << endl;
    return 0;
}



Measured memory_bytes: 11776
#include <cstdio>
#include <iostream>
#include <cstdlib>
using namespace std;
int fl[10][10],h,w,ans=0,a,b;

int main(){
	scanf("%d%d",&h,&w);
	for(int i=0;i<10;i++)
	  for(int j=0;j<10;j++)
	    scanf("%d",&fl[i][j]);
	for(int k=0;k<10;k++)
	  for(int j=0;j<10;j++)
	    for(int i=0;i<10;i++)
	      fl[i][j]=min(fl[i][j],fl[i][k]+fl[k][j]);
	for(int i=1;i<=h;i++)
	  for(int j=1;j<=w;j++){
	  	scanf("%d",&a);if(a!=-1 and a!=1)ans+=fl[a][1];
	  }
	printf("%d",ans);
	return 0;
}

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

using namespace std;

#define int long long

int n;
int a[100010];
int b[100010];

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin >> n;
    int sum1 = 0, sum2 = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        sum1 += a[i];
    }
    for(int i = 0; i < n; i++){
        cin >> b[i];
        sum2 += b[i];
    }
    if(sum1 < sum2) cout << -1;
    else{
        set < pair < int, int > > q;
        int need = 0;
        int an = 0;
        for(int i = 0; i < n; i++){
            q.insert({b[i] - a[i], i});
            if(a[i] < b[i]) need += b[i] - a[i], an++;
        }
        for(auto u : q){
            if(need <= 0) break;
            need += u.first;
            an++;
        }
        cout << an;
    }
    return 0;
}


Measured memory_bytes: 9216
#include <cstdio>
#include <algorithm>
#include <queue>
#define INF (ll)1<<60
#define maxn 300010
using namespace std;
typedef long long ll;
int n;
ll a[maxn],d1[maxn],d2[maxn];
ll ans=-INF;
struct cmp {
	bool operator() (ll a,ll b) {
		return a>b;
	}
};
struct cmp2 {
	bool operator() (ll a,ll b) {
		return a<b;
	}
};

priority_queue<ll,vector<ll>,cmp> q;
priority_queue<ll,vector<ll>,cmp2> p;

int main() {
	scanf("%d",&n);
	for (int i=1;i<=3*n;i++)
		scanf("%lld",&a[i]);
	d1[0]=0;
	for (int i=1;i<=n;i++) {
		d1[i]=d1[i-1]+a[i];
		q.push(a[i]);
	}
	for (int i=n+1;i<=2*n;i++) {
		d1[i]=d1[i-1]+a[i];
		q.push(a[i]);
		d1[i]-=q.top();
		q.pop();
	}
	d2[3*n+1]=0;
	for (int i=3*n;i>=2*n+1;i--) {
		d2[i]=d2[i+1]+a[i];
		p.push(a[i]);
	}
	for (int i=2*n;i>=n;i--) {
		d2[i]=d2[i+1]+a[i];
		p.push(a[i]);
		d2[i]-=p.top();
		p.pop();
	}
	for (int i=n;i<=2*n;i++)
		ans=max(ans,d1[i]-d2[i+1]);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 8180
#include<bits/stdc++.h>
using namespace std;
using ll=long long;

int main(){
  ll n;
  cin >> n;
  ll y;
  ll ans=0;
  for(ll x=1;x<=n;++x){
    y=n/x;
    ans+=y*(y+1)/2*x;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw`(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

bool DEBUG = 0;
template<class T> void dprint(T s){
  if(DEBUG){ cout << s << "\n"; }
}
const ll MAX = MOD;

ll mpow(ll x,ll n){
  ll r = 1LL;
  while(n>0){
    if(n&1){r = r*x %MOD;}
    x = x*x%MOD;
    n >>= 1;
  }
  return r%MOD;
}

void solve(){
  int N; cin>>N;
  ll x = mpow(10,N);
  ll y = mpow(9,N);
  ll z = mpow(8,N);
  ll ans = x+MOD - (y-z+y)%MOD;
  ans %= MOD;
  dprint(MOD);
  cout << ans << "\n";
}

int main(int argc, char *argv[]){
  if(argc>1 && argv[1][0]=='D'){ DEBUG = 1;}
  solve();
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <math.h>
#include <queue>
#include <vector>
#include <set>


using namespace std;
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

template<class T> inline bool chmin(T& a, T b) {
  //aの方が大きければ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;
}
bool compare_a_big(pair<int,int> l,pair<int,int> r){
  //firstが大きい方からソート、firstが同じならbが小さい方から
  if(l.first != r.first){
    return l.first>r.first;
  }
  else{
    return l.second < r.second;
  }
}
bool compare_a_b_big(pair<int,int> l,pair<int,int> r){
  //firstが大きい方からソート、firstが同じならbが大きい方から
  if(l.first != r.first){
    return l.first>r.first;
  }
  else{
    return l.second > r.second;
  }
}
bool compare_b_small(pair<int,int> l,pair<int,int> r){
  //secondが小さい方からソート、firstが同じならfirstが小さい方から
  if(l.second != r.second){
    return l.second<r.second;
  }
  else{
    return l.first < r.first;
  }
}
const int INF = 1e9;




int main(){
  int r;
  cin >> r;
  cout << r*r << endl;



}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
int W =0, H = 0, N = 0;

std::vector< std::vector<int> > area;

int main(void){
    std::cin >> W >> H >> N;
    area.resize(H, std::vector<int>(W, 1));

    int i, j, k;
    int js,je,ks,ke;

    int x = 0, y = 0, a = 0;
    for(i=0; i<N; ++i){
        std::cin >> x >> y >> a;
        if(a == 1){
            js = 0;
            je = H;
            ks = 0;
            ke = x;
        }else if(a == 2){
            js = 0;
            je = H;
            ks = x;
            ke = W;
        }else if(a == 3){
            js = 0;
            je = y;
            ks = 0;
            ke = W;
        }else{
            js = y;
            je = H;
            ks = 0;
            ke = W;
        }
        for(j=js; j<je; ++j){
            for(k=ks; k<ke; ++k){
                area[j][k] = 0;
            }
        }
    }

    int S = 0;
    for(i=0; i<H; ++i){
        for(j=0; j<W; ++j){
            S += area[i][j];
        }
    }
    std::cout << S << std::endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include <cmath>

using namespace std;

long long i,j,k,H,W,ans,a,b,c;


int main()
{
  cin >>a>>b>>c;
  if(a+b>c)
  {
    cout <<"No";
    return 0;
  }
  
  ans=(c-a-b)*(c-a-b)-4*a*b;
  if(ans>0)
  {
    cout <<"Yes";
  }
  else
  {
    cout <<"No";
  }

  
}

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

using namespace std;

int m[55][55]={};

void fill(int x,int y){
  m[x][y]=0;
  for(int i=-1;i<2;++i){
    for(int j=-1;j<2;++j){
      if(m[x+i][y+j]==1) fill(x+i,y+j);
    }
  }
}

int main(){
  int w,h;
  while(1){
    cin >> w >> h;
    if(w == 0 && h ==0) break;
    
    for(int i=1;i<=h;++i)
      for(int j=1;j<=w;++j)
	cin >> m[i][j];
    int cnt=0;
    for(int i=1;i<=h;++i)
      for(int j=1;j<=w;++j)
	if(m[i][j]==1){
	  fill(i,j);
	  cnt ++;
	}

    cout << cnt << endl;
  }
  return 0;
}



Measured memory_bytes: 3172
N,A,B = map(int,input().split())
a = min(A,B)
b = max(A,B)
d = b - a

#差が偶数の時：d/2
#差が奇数の時：どちらかの端で一回稼ぐ

if d%2 == 0:
  print(d//2)
else:
  r = min(a,N-b+1)
  r += (b-a-1)//2
  print(r)

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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

/*
ほぼ模範解答写経
ある頂点・それに繋がる頂点が同色でない組み合わせ

DFS的に末端の方から子を塗り分けていく。
親・自身が決まっているなら{}_{K-2}P_C
 */
ll dfs(ll K,const vector<vector<int>> &graph, int now,int from){
    if(K<=graph[now].size()) return 0;//K<=接続数：塗り分けようがないので0

    int can_use_color_num=K-2;//自分と親
    if(from==-1)can_use_color_num++;//rootなので
    ll case_num=1;
    /* 範囲ベース forループ */
    /* 子のP 計算(末端なら1) */
    for (auto e : graph[now]){
        if(e==from)continue;
        /* graph[now]に含まれる要素(from以外) */
        case_num*=can_use_color_num;
        can_use_color_num--;
        case_num%=mod;
    }
    /* 各孫の計算 */
    for(auto e: graph[now]){
        if(e==from)continue;
        /* graph[now]に含まれる要素(from以外) */
        case_num *=dfs(K,graph,e,now);
        case_num%=mod;
    }
    return case_num;
}

int main() {
    int N,K,a,b;
    cin >>N>>K;
    vector<vector<int>> graph(N);
    //接続情報の配列化
    rep(i,N-1){
        cin>>a>>b;a--;b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    //-----------------------------------
    ll ans=dfs(K,graph,0,-1)*K;/*rootの塗り分け方 */
    ans%=mod;

    cout << ans <<endl;
    return (0);
}

Measured memory_bytes: 11520
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int x = scanner.nextInt();
    int count500 = x / 500;
    int count5 = (x % 500) /5;

    System.out.println(count5 * 5 + count500 * 1000);

   }
}


Measured memory_bytes: 23764
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = int64_t;
using ull = uint64_t;
using PLL = pair<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace init__ {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
#include "../debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

int main() {
    V<ll> pow2;
    for(ll i = 0; i * i <= 1e8; i++) pow2.push_back(i * i);
    ll N, D;
    cin >> N >> D;
    VV<ll> X(N, V<ll>(D));
    for(auto &&v : X) for(auto &&ele : v) cin >> ele;

    ll ans = 0;
    for(ll i = 0; i < N; i++) {
        for(ll j = i + 1; j < N; j++) {
            ll calc = 0;
            for(ll d = 0; d < D; d++) {
                ll diff = X[i][d] - X[j][d];
                diff *= diff;
                calc += diff;
            }
            auto ite = lower_bound(ALL(pow2), calc);
            if(*ite == calc) ans++;
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main() {
	int N, T, c, t;
	int min = 100000;
	cin >> N >> T;

	for (int i = 0; i < N; i++)
	{
		cin >> c >> t;
		if (T >= t) {
			if (c < min) {
				min = c;
			}
		}
	}
	if (min == 100000) {
		cout << "TLE" << endl;
	}
	else {
		cout << min << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Fri Jul 26 04:39:44 2019

@author: matsui
"""

N,K=map(int,input().split())
D=input().split()
D=[int(D[i]) for i in range(K)]
    
        
for n in range(N,100000):
    a=n//10000
    b=n%10000//1000
    c=n%1000//100
    d=n%100//10
    e=n%10
    
    if a+b+c+d ==0:
        if e not in D :
            print(n)
            break
    if a+b+c ==0:
        if d not in D and e not in D :
            print(n)
            break
    elif a+b ==0:
        if c not in D and d not in D and e not in D :
            print(n)
            break
    elif a ==0:
        if b not in D and c not in D and d not in D and e not in D :
            print(n)
            break
    else:
        if a not in D and b not in D and c not in D and d not in D and e not in D :
            print(n)
            break
    
    

Measured memory_bytes: 3064
#include <cstdio>
#include <vector>

using namespace std;

int main()
{
	int n, r;
	vector<int> p, c;
	vector<int> fuda1, fuda2;
	
	
	while (true)		//１データセットに対する処理を１ループで行う
	{
		scanf("%d %d", &n, &r);
		if (n==0) return 0;
		
		p.resize(r);
		c.resize(r);
		fuda1.resize(n);
		fuda2.resize(n);
		
		for (int i=0; i<r; i++)
		{
			scanf("%d %d", &p[i], &c[i]);
		}
		
		//fuda1の初期化
		for (int i=0; i<n; i++)
		{
			fuda1[i] = n - i;
		}
		
		//シャッフル
		for (int i=0; i<r; i++)		//iはシャッフルの回数
		{
			for (int i2=0; i2<c[i]; i2++)
			{
				fuda2[i2] = fuda1[(p[i]-1)+i2];
			}
			
			for (int i2=0; i2<p[i]-1; i2++)
			{
				fuda2[c[i]+i2] = fuda1[i2];
			}
			
			for (int i2=0; i2<(n-(p[i]+c[i]-1)); i2++)
			{
				fuda2[p[i]+c[i]-1+i2] = fuda1[p[i]+c[i]-1+i2];
			}
			
			for (int i2=0; i2<n; i2++)
			{
				fuda1[i2]=fuda2[i2];
			}
		}
		
		printf("%d\n", fuda1[0]);
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

ll stu[50][2];
ll che[50][2];

int main()
{
	int n,m;
	ll ans=0;
	cin>>n>>m;
	for(int i=0;i<n;i++)
		cin>>stu[i][0]>>stu[i][1];
	for(int i=0;i<m;i++)
		cin>>che[i][0]>>che[i][1];
	
	for(int i=0;i<n;i++)
	{
		int index;
		ans=1e15;
		for(int j=0;j<m;j++)
		{
			ll man = abs(stu[i][0]-che[j][0])+abs(stu[i][1]-che[j][1]);
			if(man<ans)
			{
				index=j+1;
				ans=man;
			}
		}
		cout<<index<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bits/stdc++.h>
using namespace std;
int n;
int l[13];
int main(){
	cin>>n;
	for (int i=0;i<n;i++)
		cin>>l[i];
	sort (l,l+n);
	int ss=0;
	for (int i=0;i<n-1;i++)
		ss+=l[i];
	if (ss<=l[n-1]) cout<<"No";
	else cout<<"Yes";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define ll long long
#define int ll
#define eps 1e-7
#define all(x) ((x).begin()),((x).end())
#define usecppio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
using pii = pair<int, int>;
using cd = int;
const bool debug = 0;

int ans = INT_MAX;
int32_t main()
{
	usecppio
    string S, T;
    cin >> S >> T;
    int n = S.size(), m = T.size();
    for (int i = 0; i<=n-m; i++)
    {
        int cnt = 0;
        for (int j = 0; j<m; j++)
        {
            if (S[i+j]!=T[j])
                cnt++;
        }
        ans = min(ans, cnt);
    }
    cout << ans << '\n';
}

Measured memory_bytes: 3648
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            int minAmari = 10;
            int sum = 0;
            foreach (var time in consoleReader.RepeatReadLinesInt32(5))
            {
                var amari = time % 10;
                if (amari == 0)
                {
                    sum += time;
                }
                else
                {
                    sum += time + 10 - amari;
                    if (amari < minAmari)
                    {
                        minAmari = amari;
                    }
                }
            }

            if (minAmari < 10)
            {
                sum -= (10 - minAmari);
            }


            return sum;
        }

        private readonly ConsoleReader consoleReader;
        public Program() : this(new ConsoleReader()) { }
        public Program(ConsoleReader consoleReader)
        {
            this.consoleReader = consoleReader;
        }
        static void Main() => Console.WriteLine(new Program().Calc());
    }

    public class ConsoleReader
    {
        public virtual string ReadLine() => Console.ReadLine();
        public int ReadLineInt32() => int.Parse(ReadLine());
        public long ReadLineInt64() => long.Parse(ReadLine());
        public ulong ReadLineUInt64() => ulong.Parse(ReadLine());
        public double ReadLineDouble() => double.Parse(ReadLine());
        public string[] ReadLineSplit() => ReadLine().Split().ToArray();
        public int[] ReadLineSplitInt32() => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public long[] ReadLineSplitInt64() => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public ulong[] ReadLineSplitUInt64() => ReadLine().Split().Select(s => ulong.Parse(s)).ToArray();
        public double[] ReadLineSplitDouble() => ReadLine().Split().Select(s => double.Parse(s)).ToArray();

        public IEnumerable<string> RepeatReadLines(int count)
        {
            for (int i = 0; i < count; i++)
                yield return ReadLine();
        }
        public IEnumerable<int> RepeatReadLinesInt32(int count)
        {
            for (int i = 0; i < count; i++)
                yield return ReadLineInt32();
        }
        public IEnumerable<string[]> RepeatReadLinesSplit(int count)
        {
            for (int i = 0; i < count; i++)
                yield return ReadLineSplit();
        }
    }
    static class DicExt
    {
        public static V GetOrDefault<K, V>(this Dictionary<K, V> dic, K key)
        {
            V val;
            return dic.TryGetValue(key, out val) ? val : default(V);
        }
    }
}


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

int main(){
	int n,k;
  cin>>n>>k;
  vector<string> s(n);
  for(auto &a:s){
  	cin>>a;
  }
  sort(s.begin(),s.end());
  for(auto a:s){
  	cout<<a;
  }
}

Measured memory_bytes: 256