akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cmath>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <cassert>
#include <string>
#include <cstring>
#include <queue>

using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define S2(x,y) scanf("%d%d",&x,&y)
#define P(x) printf("%d\n",x)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define pb push_back
#define mp make_pair

typedef long long int LL;
typedef pair<int, int > pii;
typedef vector<int > vi;

int main() {
  LL n,p;
  LL ans = 1;
  scanf("%lld%lld",&n,&p);
  for(LL i = 2; i * i <= p; i++) if(p % i == 0) {
    int cnt = 0;
    while(p % i == 0) {
      cnt++;
      p /= i;
      if(cnt == n) {
        ans *= i;
        cnt = 0;
      }
    }
  }
  if(n == 1 && p > 1) {
    ans *= p;
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main()
{
long long int n;
cin>>n;
string s;
cin>>s;
int count=0;
if(n==1){
    cout<<"No"<<endl;
}
else{
if(n%2==0)
{
int x=n/2;
for(int i=0;i<x;i++)
{
if(s[i]==s[i+x])
{
count=1;
}
else{
cout<<"No"<<endl;
count=0;
break;
}
}
if(count==1)
{
cout<<"Yes"<<endl;
}
}
else{
    cout<<"No"<<endl;
}
}
return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#define rep(i,a) for(int i=0;i<a;i++)
#define nrep(i,a,b) for(int i=a;i<b;i++)
#define INF 1145141919810
#define ll long long
using namespace std;
 
int main(){
    ll n; cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    ll sum=0;
    ll ans_1=0;
    ll ans_2=0;
    bool flag=true;
    rep(i,n){
        sum+=a[i];
        if(flag){
            if(sum>=0){
                ans_1+=abs(sum)+1;
                sum=-1;
            }
        }else{
            if(sum<=0){
                ans_1+=abs(sum)+1;
                sum=1;
            }
        }flag=!flag;
    }flag=false;
    sum=0;
    rep(i,n){
        sum+=a[i];
        if(flag){
            if(sum>=0){
                ans_2+=abs(sum)+1;
                sum=-1;
            }
        }else{
            if(sum<=0){
                ans_2+=abs(sum)+1;
                sum=1;
            }
        }flag=!flag;
    }cout<<min(ans_1,ans_2)<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <math.h>

double p_distance(double x1, double y1, double x2, double y2)
{
    double pow_x = pow((x2 - x1), 2.0);
    double pow_y = pow((y2 - y1), 2.0);
    return pow((pow_x + pow_y), 0.5);
}

int main(void)
{
    double x1, y1, x2, y2;
    scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
    printf("%f", p_distance(x1, y1, x2, y2));

    return 0;
}



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

void enqueue(int index);
int dequeue(void);

int Q[1001];
int lastQ = 0;

char name[1001][11];
int time[1001];

main(){

  int i, index, n, q, elapsedTime = 0;

  scanf("%d %d",&n,&q);

  for(i=0; i<n; i++){
    scanf("%s %d",name[i],&time[i]);
    enqueue(i);
  }

  while(n!=0){

    index = dequeue();
    time[index] -= q;
    elapsedTime += q;

    if(time[index] <= 0){
      elapsedTime += time[index];
      printf("%s %d\n",name[index],elapsedTime);
      n--;
    }else{
      enqueue(index);
    }

  }

  return 0;

}

void enqueue(int index){
  Q[lastQ++] = index;
}

int dequeue(void){

  int i,tmp = Q[0],len;

  for(i=0, len=--lastQ; i<lastQ; i++)
    Q[i] = Q[i+1];

  return tmp;

}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int inf = 1e9;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, b, a) for (int i = a - 1; i >= b; i--)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

int main() {
    int n;
    cin >> n;
    vector<vector<pint>> g (n);
    int a[n - 1], b[n - 1], c[n - 1];
    rep (i, 0, n - 1) c[i] = -1;
    int start = 0;
    rep (i, 0, n - 1) {
        cin >> a[i] >> b[i];
        g[--a[i]].push_back ({--b[i], i});
        g[b[i]].push_back ({a[i], i});
    }
    queue<int> q; //次の場所をためる
    q.push (0);
    int Cnt[n] = {};
    while (!q.empty()) {
        int cnt = 0;
        int now = q.front();
        q.pop();
        for (auto next : g[now]) {
            if (c[next.second] == -1) {
                // cout << now << " " << next.first << Cnt[next.first] << "\n";
                if (Cnt[now] == ++cnt) {
                    Cnt[next.first] = ++cnt;
                    c[next.second] = cnt;
                } else {
                    Cnt[next.first] = cnt;
                    c[next.second] = cnt;
                } /*
                 if (Cnt[next.first] == 0) {
                     Cnt[next.first] == ++cnt;
                     c[next.second] = cnt;
                 } else {
                     if (Cnt[next.first] == ++cnt) {
                         c[next.second] = ++cnt;
                     }
                 }*/
                // cout << cnt << "\n";
                q.push (next.first);
            }
        }
    }
    int ans = 0;
    rep (i, 0, n - 1) { ans = max (ans, c[i]); }
    cout << ans << "\n";
    rep (i, 0, n - 1) cout << c[i] << "\n";
}

Measured memory_bytes: 8192
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template<class T>
vector<T> divisor(T n){
    vector<T> ret;
    for(T i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i * i != n) ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return(ret);
}

int main() {
    ll n;
    cin >> n;
    auto v = divisor(n);
    ll ans = 0;
    for (auto &&i : v) {
        if(i == 1) continue;
        if(n/(i-1) == n%(i-1)) ans += i-1;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 384
/*
    Solution by:- 
	--------------Sannidhay Vashal
	----------------NIT SRINAGAR
 
*/
#include<iostream>
#include<vector>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<math.h>
#include<climits>
#include<set> 
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long int
#define ull unsigned long long int
#define cinll(x) ll x;cin>>x;
#define cini(x) int x;cin>>x;
#define cout(x) cout<<x;
#define vect(x) vector<ll> x;
#define vect1(x) vector<ll> x;x.push_back(0);
#define vectdef(x,size,val) vector<ll> x;for(ll i=0;i<size;i++){x.push_back(val);}
#define vectdef1(x,size,val) vector<ll> x;for(ll i=0;i<=size;i++){x.push_back(val);}
#define pb(x) push_back(x);
#define MAX INT_MAX;
#define MIN INT_MIN;
#define MOD 1000000007;
 
using namespace std;

int main(){
  	cinll(n);
  	cinll(k);
  	ll finalvalue = n%k;
  	ll finalvaluemod = -1*(finalvalue-k);
  	if(finalvalue==0){
    	cout<<finalvalue<<"\n";
    }else{
    	cout<<min(finalvalue,finalvaluemod);
    }
	return 0;
}

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

using namespace std;

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

    vector<int> sunuke(n, 0);
    for (int i = 0; i < n; i++) {
        int d;
        cin >> d;
        for (int j = 0; j < d; j++) {
            int a;
            cin >> a;
            sunuke[a-1]++;
        }
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (sunuke[i] == 0) {
            ans++;
        }
    }

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


Measured memory_bytes: 3632
package main

import "fmt"

func main() {
	var (
		a, b int
		op   string
	)
	fmt.Scan(&a, &b)

	ab := a - b

	switch {
	case ab == 0:
		op = "=="
	case ab > 0:
		op = ">"
	default:
		op = "<"
	}

	fmt.Println("a", op, "b")

}



Measured memory_bytes: 1088
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
using namespace std;
using ll = long long;


int main() {
	int D, G; cin >> D >> G;
	vector<int> p(D + 1), c(D + 1);
	for (int i = 1; i <= D; i++) cin >> p[i] >> c[i];
	vector<vector<ll>> dp(D + 4, vector<ll>(2004, -1e18));
	dp[1][0] = 0;
	for (int i = 1; i <= D; i++) {
		for (int j = 0; j <= 1000; j++) {
			if (dp[i][j] == -1) continue;
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
			for (int k = 1; k < p[i]; k++) {
				if (j + k > 1000) break;
				dp[i + 1][j + k] = max(dp[i + 1][j + k], dp[i][j] + k * 100 * i);
			}
			if (j + p[i] <= 1000) dp[i + 1][j + p[i]] = max(dp[i + 1][j + p[i]], dp[i][j] + p[i] * 100 * i + c[i]);
		}
	}
	
	for (int i = 0; i <= 1000; i++) {
		if (dp[D + 1][i] >= G) {
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}



Measured memory_bytes: 512
n = int(input())
a = list(map(int, input().split()))

ans = 10 ** 9
for i in a:
    count = 0
    while True:
        if i % 2 == 0 and i > 0:
            i >>= 1
            count += 1
        else:
            break
    ans = min(ans, count)
print(ans)


Measured memory_bytes: 38640
import java.util.Scanner;//入力を取得する(Scanner)

class Main {
				public static void main(String arts[]) {
								int N,K;
								Scanner sc = new Scanner(System.in);
								N = sc.nextInt();
								K = sc.nextInt();

								int ans = 0;

								for(int i = 0 ; i < N ; i++){
											int h;
											h = sc.nextInt();
											if(h>=K) ans++;
								}
								System.out.println(ans);

				}
}


Measured memory_bytes: 49100
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {
            int N = scanner.nextInt();
            int M = scanner.nextInt();
            int C = scanner.nextInt();
            int[][] feature = new int[N][M];
            int[] B = new int[M];
            for (int i = 0; i < M; i++) {
                B[i] = scanner.nextInt();
            }
            for (int i = 0; i < N; i++) {
                for (int j = 0; j < M; j++) {
                    feature[i][j] = scanner.nextInt();
                }
            }
            int count = 0;
            for (int i = 0; i < N; i++) {
                long sum = C;
                for (int j = 0; j < M; j++) {
                    sum += feature[i][j] * B[j];
                }
                if (sum > 0) {
                    count++;
                }
            }
            System.out.println(count);
        }
    }
}


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

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

  if (a % 3 == 0) {
    cout << "Possible" << endl;
  } else if (b % 3 == 0) {
    cout << "Possible" << endl;
  } else if ((a + b) % 3 == 0) {
    cout << "Possible" << endl;
  } else {
    cout << "Impossible" << endl;
  }

  return (0);
}

Measured memory_bytes: 256
import math
N, K = map(int, input().split())

p_win = 0
if N >= K:
    p_win += (N - K + 1) / N

k = K
i = 1
while k >= 1:
    half_k = k / 2
    if N < k:
        num_nums = max(N - math.ceil(half_k) + 1, 0)
    else:
        num_nums = math.ceil(k) - math.ceil(half_k)
    p_i = (num_nums/N) * ((1/2)**i)
    # print(f'{i}: {half_k=} <= n < {k=}, {num_nums=}, {p_i=}')
    p_win += p_i
    i += 1
    k = half_k

print(p_win)

Measured memory_bytes: 3064
n, x = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
for i in range(n-1):
    delta = max(0, a[i] + a[i+1] - x)
    a[i+1] -= delta
    if a[i+1] < 0:
        a[i] += a[i+1]
        a[i+1] = 0
    ans += delta
print(ans)

Measured memory_bytes: 14540
n = gets.to_i

edges = Array.new(n){Array.new}

(n-1).times do |i|
  u, v, w = gets.split.map(&:to_i)
  edges[u-1] << [v-1, w]
  edges[v-1] << [u-1, w]
end

dist = Array.new(n, 0)
visited = Array.new(n,false)
stack = [0]

while !stack.empty? do
  next_stack = []
  stack.each do |from|
    visited[from] = true

    edges[from].each do |(to, wgt)|
      next if visited[to]
      dist[to] = dist[from] + wgt
      next_stack << to
    end
  end
  stack = next_stack
end

n.times do |i|
  if dist[i] %2 == 0
    puts "0"
  else
    puts "1"
  end
end


Measured memory_bytes: 29308
import numpy as np
N, D = list(map(int, input().split(' ')))
v = []
for n in range(N):
    v.append(list(map(int, input().split(' '))))
vec = np.array(v)
c = 0
for i in range(N):
    for j in range(i+1, N):
        if np.linalg.norm(vec[i]-vec[j]) % 1 == 0:
            c += 1
print(c)

Measured memory_bytes: 12396
#include<stdio.h>
#include<stdlib.h>
#define SIZE 1000000
int main(){
  int n,x[SIZE],X;
  int i=1,j=1,k,l=1;
  int a[SIZE],b[SIZE],c;
  b[0]=2;
  scanf("%d%d", &n, &X);
  for(k=0;k<n;k++){
    scanf("%d", &x[k]);
  }
  for(k=0;k<n;k++){
    x[k]=abs(X-x[k]);
  }
  c=x[0];
  for(k=1;k<n;k++){
    if(x[k]<c) c=x[k];
  }
  while(i<b[j-1]){
    if(c%i==0){
      a[j]=i;
      b[j]=c/i;
      j++;
    }
    i++;
  }
  if(a[j-1]==b[j-1]){
    for(k=j;k<=2*j-3;k++){
      a[k]=b[k-2*l];
      l++;
    }
    k=2*j-3;
    l=0;
    while(l!=n){
      while(x[l]%a[k]==0&&l<n) {
	l++;
      }
      k--;
    }
    printf("%d\n",a[k+1]);
  }
  else{
    l=1;
    for(k=j;k<=2*(j-1);k++){
      a[k]=b[k-2*l+1];
      l++;
    }
    k=2*(j-1);
    l=0;
    while(l!=n){
      while(x[l]%a[k]==0&&l<n) {
	l++;
      }
      k--;
    }
    printf("%d\n",a[k+1]);
  }    
  return 0;
}


Measured memory_bytes: 4608
n=int(input())
c=list(map(int, input().split()))
count = 0
max_c = 0
for i in range(n-1):
  if c[i]>=c[i+1]:
    count = count+1
  else:
    max_c = max(count,max_c)
    count = 0
  if i == n-2:
    max_c = max(count,max_c)
    
print(max_c)
    

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

int main(){
	int x,y,z;
	int ans[4] = {0};

	while(1){
		cin >> x >> y >> z;
		if(x > y){
			int num = y;
			y = x;
			x = num;
		}
		if(y > z){
			int num = z;
			z = y;
			y = num;
		}
		if(x > y){
			int num = y;
			y = x;
			x = num;
		}
		if(x + y <= z)
			break;
		else if(x * x + y * y - z * z < 0)
			ans[3]++;
		else if(x * x + y * y - z * z > 0)
			ans[2]++;
		else if(x * x + y * y - z * z == 0)
			ans[1]++;

		ans[0] = ans[1] + ans[2] + ans[3];
	}
	for(int i = 0; i < 4; i++){
		cout << ans[i];
		if(i != 3) cout << " ";
	}
		cout << endl;
}

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

using namespace std;

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


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


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

int main() {

	std::string n = {};
	int ans = 0, a = 0, i = 0;
	bool flug = false;

	std::cin >> n;

	ans += (n.size() - 1) * 9;

	if (n[i] == '0') { a = 0; }
	else if (n[i] == '1') { a = 1; }
	else if (n[i] == '2') { a = 2; }
	else if (n[i] == '3') { a = 3; }
	else if (n[i] == '4') { a = 4; }
	else if (n[i] == '5') { a = 5; }
	else if (n[i] == '6') { a = 6; }
	else if (n[i] == '7') { a = 7; }
	else if (n[i] == '8') { a = 8; }
	else if (n[i] == '9') { a = 9; }

	if (n.size() == 1) {
		std::cout << n[0] << std::endl;
		return 0;
	}

	if (n[n.size()-1] == '9' && n[n.size() - 2] && n[n.size()-3] != '0') {
		ans += a;
	}
	else { ans += a - 1; }

	std::cout << ans << std::endl;

}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
    return string(1, val);
}

int main(){
    int N, M, X; cin >> N >> M >> X;
    vector<int> A(M); REP(i, M) cin >> A[i];

    int cnt_A = 0;
    int cnt_B = 0;

    for(int i = 0; i < X; ++i) {
        if(i == 0) continue;
        for(int k = 0; k < M; ++k) {
            if(A[k] == i) cnt_A++;
        }
    }

    for(int i = X; i <= N; ++i) {
        if(i == 0) continue;
        for(int k = 0; k < M; ++k) {
            if(A[k] == i) cnt_B++;
        }
    }

    int res =  min(cnt_A, cnt_B);
    cout << res << endl;
}

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

int main() {
  int n,ans;
  cin>>n;
  if(n%2==0){
    cout<<0.5;
  }
  else{
    int b=n/2+1;
    float t=b;
    float c=t/n;
    cout<<c;
  }
}


Measured memory_bytes: 256
# coding:utf-8


INF = float('inf')


def inpl(): return list(map(int, input().split()))


N, X = inpl()
A = inpl()
B = [0]
for a in A:
    B.append(B[-1] + a)

ans = []
for k in range(1, N + 1):
    e = 5
    cur = N - k
    tmp = e * (B[N] - B[cur]) + (N + k) * X
    cur -= k
    while True:
        tmp += e * (B[cur + k] - B[max(cur, 0)])
        if cur <= 0:
            break
        e += 2
        cur -= k

    ans.append(tmp)

print(min(ans))

Measured memory_bytes: 30572
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 0x3f3f3f3f
int one,two;
int a,b,c,d;
void Min(int &x,int y)
{
    x=min(x,y);
}
int main()
{
    scanf("%d%d%d%d",&a,&b,&c,&d);
    one=INF; two=INF;
    Min(one,a*4); Min(one,b*2); Min(one,c);
    Min(two,a*8); Min(two,b*4); Min(two,c*2); Min(two,d);
    ll n;
    scanf("%I64d",&n);
    ll ans=1LL*(n/2)*two+1LL*(n%2)*one;
    cout<<ans<<"\n";
    //printf("%I64d\n",ans);
    return 0;
}


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

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

using namespace std;

int h,w,k;

int calc(vector<string> B){
	int res=0;
	for(int t=0;;t++){
		bool end;
		do{
			end=true;
			for(int i=h-1;i>0;i--) rep(j,w) if(B[i][j]=='0' && B[i-1][j]!='0') {
				B[i][j]=B[i-1][j];
				B[i-1][j]='0';
				end=false;
			}
		}while(!end);

		bool found=false;
		rep(i,h) rep(j,w-k+1) if(B[i][j]!='0') {
			int len;
			for(len=1;j+len<w;len++) if(B[i][j+len]!=B[i][j]) break;
			if(len>=k){
				res+=(1<<t)*(B[i][j]-'0')*len;
				rep(d,len) B[i][j+d]='0';
				j+=len-1;
				found=true;
			}
		}
		if(!found) break;
	}
	return res;
}

int main(){
	cin>>h>>w>>k;
	vector<string> B(h);
	rep(i,h) cin>>B[i];

	int ans=0;
	rep(i,h) rep(j,w) {
		char c=B[i][j];
		B[i][j]='0';
		ans=max(ans,calc(B));
		B[i][j]=c;
	}
	cout<<ans<<'\n';

	return 0;
}


Measured memory_bytes: 256
#ALDS1_11_A Graph
import sys

n = int(input())
A = [[0] * n for _ in range(n)]

for i in range(n):
    Adj = list(map(int, sys.stdin.readline().strip().split()))
    if Adj[1] >= 1:
        v = Adj[2:]
        for j in v:
            A[i][j - 1] = 1
            # A[j - 1][i - 1] = 1

for i in A:
    print(' '.join(map(str, i)))



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

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

    vector<int> res(n,0);

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

    for(auto it:res)
        cout<<it<<endl;
    return 0;
}


Measured memory_bytes: 4052
/* while(!cin.eof()) */
 
#include<bits/stdc++.h>
using namespace std; 
#define int long long 
#define mod (int)(1e9+7)
#define MAXI (int)(1e15+100)
#define N 1000500


 
// Driver code to test above functions
int32_t main()
{
    
 
    
     
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int n;
    cin >> n;
    if(n%2==0)
        cout << 0.5000000000;
    else
        cout << (n+1)/(2*n*1.0);
    

    return 0;
} 

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

int main() {
	ll H,W,r=0;
	cin >> H >> W;

	if(H==1 || W==1)
		r = 1;
	else
		r = H*(W/2) + (H/2ll+H%2)*(W%2);
	cout << r << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
typedef long long LL;
using namespace std;
int countNumber(LL n) {
	int ans = 0;
	while(n) {
		ans++;
		n /= 10;
	}
	return ans;
}

void run() {
	LL N;
	while(cin >> N) {
		LL i = sqrt(N) + 1;
		LL ans = 0x3f3f3f3f;
		for(int j = 1; j <= i; j++) {
			if(j * (N / j) == N) {
				//cout << j << " " << N / j << endl;
				LL t = max(countNumber(j),countNumber(N / j));
				ans = min(ans, t);
			}
		}
		cout << ans << endl;
	}
}
int main(int argc, char *argv[]) {
	//freopen("data.txt", "r", stdin);
	run();
}

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

using namespace std;

const long long int MOD = 1e9 + 7;

long long int mypow(long long int x,long long int n)
{
	long long int res = 1;
	while(n>0)
	{
		if(n%2==1)
		{
			res = ((res%MOD)*(x%MOD)%MOD);
			res%=MOD;
		}
		x = ((x%MOD)*(x%MOD)%MOD);
		x%=MOD;
		n/=2;
	}
	return res;
}
int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	long long int n;

	cin >> n;

	long long int res = mypow(10,n);
	res = ((res%MOD) - (mypow(8,n)%MOD)%MOD);
	res%=MOD;
	if(res<0)
	{
		res+=MOD;
	}
	long long int val = mypow(9,n) - mypow(8,n);
	if(val < 0)
	{
		val+=MOD;
	}
	val *=2;
	val%=MOD;
	res -= val;
	if(res < 0)
	{
		res+=MOD;
	}

	cout << res << '\n';


	return 0;
}


Measured memory_bytes: 3608
n = int(input())
l = list(map(int,input().split()))
l.sort(reverse = True)

ans = 0

for i in range(len(l)):
    for j in range(i+1,len(l)):
        for k in range(j+1,len(l)):
            if l[i] != l[j] != l[k] and l[i] < l[j] + l[k]:
                ans +=1

print(ans)

Measured memory_bytes: 9104
#include <iostream>

using namespace std;

int main() {
  int N, M;
  int sum = 0;
  cin >> N >> M;
  
  for (int i = 0; i < 2; i++) {
	if (N > M) {
      sum += N;
      N--;
    } else {
      sum += M;
      M--;
    }
  }
  
  cout << sum << endl;
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
struct Trie{
  bool l;
  Trie *next[4];
 
  Trie(){
    l = false;
    fill(next,next+4,(Trie *)0);
  }
 
  int c(char ch){
    if(ch == 'A'){ return 0; }
    if(ch == 'C'){ return 1; }
    if(ch == 'G'){ return 2; }
    if(ch == 'T'){ return 3; }
    return -1;
  }
 
  void insert(char *s){
    Trie *t = this;
    for(int i = 0 ; i < (int)strlen(s) ; i++){
      int v = c(s[i]);
      if(!t->next[v]){
        t->next[v] = new Trie;
      }
      t = t->next[v];
    }
    t->l = true;
  }
 
  bool find(char *s){
    Trie *t = this;
    for(int i = 0 ; i < (int)strlen(s) ; i++){
      int v = c(s[i]);
      if(!t->next[v]){ return false; }
      t = t->next[v];
    }
    return t->l;
  }
};

int main(){
  int N;
  char c[7],str[13];
  Trie t;
  scanf("%d",&N);
  while(N--){
    scanf("%s%s",c,str);
    if(strcmp(c,"find") == 0){
      printf("%s\n",t.find(str) ? "yes" : "no");
    }else{
      t.insert(str);
    }
  }
  return 0;
}

Measured memory_bytes: 17476
//
//  main.cpp
//  ABC124
//
//  Created by hiroaki on 2019/05/07.
//  Copyright © 2019年 hiroaki. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>


//pair sort firstに揃う

#define int long long
#define pb(n) push_back(n)
#define Rap(n,i) for(int (i)=0;(i)<(n);(i)++)
#define Pr(n) cout<<n<<endl;
#define PairV vector<pair<int , int> >
#define F first
#define S second
#define Vector1  vector<int>
#define vector2 vector<vector<int> >
#define index(v,x) find((v).begin(), (v).end(), (x))-(v).begin()
#define ctoi(c) (int)(c-'0')
#define incin(n) int (n); cin>>(n);
#define stcin(s) string (s); cin>>(s);
#define all(v) (v).begin() , (v).end()
#define PI 3.14
#define Rad2Deg  57.29578

using namespace std;
 
signed  main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,l;
    cin >> n >> l;
    vector<string> s(n);
    Rap(n,i){
        cin >> s.at(i);
    }
    sort(all(s));
    string ans;
    Rap(n,i){
        ans+=s[i];
    }
    Pr(ans);
    return 0;
}


Measured memory_bytes: 256
from sys import stdin
import numpy as np

# N = int(stdin.readline().rstrip().split()[0])
# A = [int(x) for x in stdin.readline().rstrip().split()]
N, X = [int(x) for x in stdin.readline().rstrip().split()]


def func(n, x):
  # 動的計画法?
  if x==0:
    return 0
  elif x==1 and n==0:
    return 1
  elif x==4*2**n-3:
    return 2*2**n-1
  elif x <= 4*2**(n-1)-3 +1:
    return func(n-1, x-1)
  else:
    return  func(n-1, 2*2**n-3) + func(n-1,x-2*2**n+1) +1
print(func(N, X))

Measured memory_bytes: 12444
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String t = sc.next();
    int[][] memo = new int[s.length()+1][t.length()+1];
    System.out.println(solve(memo, s, t));
  }
  
  public static String solve(int[][] memo, String s, String t){
    for(int i = 1; i < memo.length; i++){
      for(int j = 1; j < memo[i].length; j++){
        if(s.charAt(i-1) == t.charAt(j-1)){
          memo[i][j] = memo[i-1][j-1]+1;
        }else{
          memo[i][j] = memo[i-1][j] > memo[i][j-1] ? memo[i-1][j] : memo[i][j-1];
        }
      }
    }
    return repair(memo, s, t);
  }
  
  public static String repair(int[][] memo, String s, String t){
    int i = s.length();
    int j = t.length();
    int n = memo[i][j];
    StringBuilder sb = new StringBuilder();
    while(n != 0){
      if(s.charAt(i-1) == t.charAt(j-1)){
        sb.append(s.charAt(--i));
        j--;
      }else if(memo[i][j-1] > memo[i-1][j]){
        j--;
      }else{
        i--;
      }
      n = memo[i][j];
    }
    return sb.reverse().toString();
  }
}

Measured memory_bytes: 83152
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
template<class A,size_t N,class T>void Fill(A(&a)[N],const T&v){fill((T*)a,(T*)(a+N),v);}

const int MOD = 1e9+7; //998244353;

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m=MOD){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m=MOD){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>Fac,Rac;void setF(int n,int m=MOD){Fac=Rac=V<ll>(++n);Fac[0]=1;FOR(i,1,n)Fac[i]=Fac[i-1]*i%m;Rac[n-1]=modInv(Fac[n-1],m);FORR(i,n-1,1)Rac[i-1]=Rac[i]*i%m;}
//ll comb(int a,int b,int m=MOD){return a<b||b<0?0:Fac[a]*Rac[b]%m*Rac[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int N = 2e5;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x;
  cin >> x;
  cout << (x>=30 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,i,j,s=0,s2=0,k=0;
	cin>>a>>b>>c;
	for(i=1;i<120;i++){
		s=0;
		for(j=1;j<=60;j++){
			s+=a+b;
			if(s-a-b<=c&&s-b>=c){k++;break;}
		}
		if(k==1)break;
		if(i==111){c=-1;break;}
		c+=60;
	}
	cout<<c<<endl;
}

Measured memory_bytes: 1164
def main(argv)
  (l, r) = gets.chomp.split(' ').map(&:to_i)
  
  w = r - l + 1
  if w >= 2019 then
    puts 0.to_s
    return 0
  end
  
  m = 2020
  w.times do |i|
    ((i + 1)...w).each do |j|
      m = [m, ((l + i) % 2019) * ((l + j) % 2019) % 2019].min
    end
  end
  puts m.to_s
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1000000007;
string alp="abcdefghijklmnopqrstuvwxyz";

int main(){
    ll N,K;
    cin >> N >> K;
    vector<vector<ll>> B(K,vector<ll>(K,0)),W(K,vector<ll>(K,0));
    rep(i,N){
        ll x,y;
        char c;
        cin >> x >> y >> c;
        ll a=x%K,b=y%K;
        ll z=(x-a)/K+(y-b)/K;
        if (c=='B'){
            if (z%2==0){
                B[a][b]++;
            }
            else {
                W[a][b]++;
            }
        }
        else {
            if (z%2==0){
                W[a][b]++;
            }
            else {
                B[a][b]++;
            }
        }
    }
    rep(i,K){
        rep(j,K-1){
            B[i][j+1]+=B[i][j];
            W[i][j+1]+=W[i][j];
        }
    }
    rep(i,K-1){
        rep(j,K){
            B[i+1][j]+=B[i][j];
            W[i+1][j]+=W[i][j];
        }
    }
    ll ans=0;
    rep(i,K){
        rep(j,K){
            ll count=0;
            count+=2*B[i][j];
            count+=W[i][K-1]-W[i][j];
            count+=W[K-1][j]-W[i][j];
            count+=B[K-1][K-1]-B[K-1][j]-B[i][K-1];
            count=max(count,N-count);
            ans=max(ans,count);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 16000
/*
**    Date: Friday, 17 April, 2020
**    Time: 19:26:30 UTC+5:30
*/

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define sz(x) (int)x.size()
#define rep(a, b, i) for (int i = a; i < b; i++)
#define repi(a, b, i) for (int i = a; i > b; i--)
#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define __                            \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0)
#define CPU cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." << endl;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

const int MOD = 1e9 + 7;
const ll inf = 1e18 + 5;
const ld pi = 3.141592653589793;
const int maxn = 1e5 + 5;

int32_t main()
{
    __;

    int k;
    cin >> k;
    ll ans = 0;
    rep(1, k + 1, i) rep(1, k + 1, j) rep(1, k + 1, p) ans += __gcd(i, __gcd(j, p));
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3652
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;
static import std.ascii;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    auto S = sread();
    long N = S.length;
    long X, Y;
    scan(X, Y);

    auto ls = new long[][](2, 1);
    {
        long s;
        foreach (i; 0 .. N)
        {
            if (S[i] == 'T')
            {
                ls[s] ~= 0;
                s = s ^ 1;
            }
            if (S[i] == 'F')
            {
                ls[s][$ - 1]++;
            }
        }
    }
    {
        bool[long] D;
        D[ls[0][0]] = true;
        foreach (j; ls[0][1 .. $])
        {
            bool[long] D2;
            foreach (k; D.byKey)
            {
                D2[k + j] = D2[k - j] = true;
            }
            D = D2;
        }
        if (X !in D)
        {
            writeln("No");
            return;
        }
    }
    {
        bool[long] D;
        D[0] = true;
        foreach (j; ls[1])
        {
            bool[long] D2;
            foreach (k; D.byKey)
            {
                D2[k + j] = D2[k - j] = true;
            }
            D = D2;
        }
        if (Y !in D)
        {
            writeln("No");
            return;
        }
    }
    writeln("Yes");

}


Measured memory_bytes: 12028
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int nilai[n];
    for(int i=0;i<n;i++)
        cin>>nilai[i];
    sort(nilai,nilai+n);
    cout<<nilai[n-1]-nilai[0]<<endl;
    return 0;
}


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

int main() {
	char a,t;
	cin >> a;
	cin >> t;
	if(a=='H'){
	if(t=='H'){
	cout << "H";
	}
	else {
	cout << "D";
	}
	}
	else{
	if(t=='H'){
	cout << "D";
	}
	else{
	cout << "H";
	}
	}
	return 0;
}

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

#define vi vector<int>
#define vl vector<long long>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPD(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORD(i, a, b) for (int i = (int)(a); i >= (int)(b); i--)
#define INF 1e18
#define MOD 1e9+7

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

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

const int MAX_N = 310;
vector< vector<int> > dp;
int w[MAX_N];

//dp[l][r]:[l, r)までのブロックで取り除ける最大の数
//dp[l][l+2] = 2 ? w[l]-w[l+1] <= 1 else 0

int rec(int l, int r) {
    if (dp[l][r] >= 0) return dp[l][r];
    if (r-l<=1) return dp[l][r] = 0;
    if (abs(w[r-1]-w[l]) <= 1 && rec(l+1, r-1) == r-l-2) chmax(dp[l][r], r-l);
    FOR(i, l+1, r) {
        chmax(dp[l][r], rec(l, i)+rec(i, r));
    }
    return dp[l][r];
}

int main() {
    while (1) {
        int n;
        cin >> n;
        if (n == 0) break;
        REP(i, n) {
          cin >> w[i];
        }
        dp.assign(n+1, vector<int>(n+1, -1));
        cout << rec(0, n) << endl;
    }
    return 0;
}


Measured memory_bytes: 3284
#include<bits/stdc++.h>
using namespace std;
const long long md=1e9+7;
long long n,k,dp[202020],ans;
long long pw(long long x,long long y)
{
	long long nw=1ll;
	while(y)
	{
		if(y&1)
		{
			nw*=x;
			nw%=md;
		}
		y>>=1;
		x*=x;
		x%=md;
	}
	return nw;
}
int main()
{
	cin>>n>>k;
	for(int i=k;i>=1;i--)
	{
		long long mx=k/i,cnt=pw(mx,n);
		for(int j=i+i;j<=k;j+=i)
		{
			cnt=(cnt+md-dp[j])%md;
		}
		dp[i]=cnt;
		cnt*=(i*1ll);
		cnt%=md;
		ans+=cnt;
		ans%=md;
	}
	cout<<ans<<endl;
	return 0;
}

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

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(type, x, y) do { type tmp = x; x = y; y = tmp; } while (0)

#define MOD 1000000007 

//昇順
int desc(const void* a, const void* b){
    long p=*(long*)a;
    long q=*(long*)b;
    if(q-p>0) return 1;
    else if(q-p<0) return -1;
    else return 0;
}

long comb(long p,long q){
	if(q==0 || p==q)return 1;
	if(q>p/2)q=p-q;
	long ans=1;
	for(long i=1;i<=q;i++){
		ans*=p-i+1;
		ans/=i;
	}
	return ans;
}

int main(void){
    int N,A,B;
    scanf("%d%d%d",&N,&A,&B);

    long* v;
    NEW(v,N);
    for(int i=0;i<N;i++){
        scanf("%ld",&v[i]);
    }
    qsort(v,N,sizeof(long),desc);

    //平均値を求める
    double avg=0;
    for(int i=0;i<A;i++){
        avg+=v[i];
    }
    avg/=A;

    //l...v[A-1]より大きい値の数、m...v[A-1]と同じ値の数
    int l=0;
    int m=0;
    for(int i=0;i<N;i++){
        if(v[i]>v[A-1]) l++;
        else if(v[i]==v[A-1]) m++;
        else break;
    }

    long ans=0;
    long tmp;
    if(l==0){
        for(int i=A;i<=MIN(B,m);i++){
            //mCiを足せば良い
            tmp=comb(m,i);
            ans+=tmp;
        }
    }
    else{
        //mC(m-l)がans
        ans=comb(m,A-l);
    }

    printf("%.6f\n",avg);
    printf("%ld\n",ans);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
#define INF 1e8
using namespace std;
#define ll long long

#define MAX 100020
#include <iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
#define INF 1e8
using namespace std;
#define ll long long

#define MAX 100020

int main(){

int n;
string s;
cin>>n>>s;

if(n%2==1)
{
    cout<<"No";
    return 0;
}
string a,b;
a= s.substr(0,n/2);
b= s.substr(n/2,n/2);

if(a==b)
cout<<"Yes";
else
cout<<"No";
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define mod 1000000007
using namespace std;
ll binpow(ll x,ll y)/* (x^y)%p in O(log y) */{ll res=1;while (y > 0){if(y&1)res=(res*x);y = y>>1;x=(x*x);}return res;}
ull binpowmod(ull x,ull y,ull p)/* (x^y)%p in O(log y) */{ull res=1;x=x%p;while (y > 0){if(y&1)res=(res*x)%p;y = y>>1;x=(x*x)%p;}return res;}
ll mod_inverse(ll n,ll p)/* Returns n^(-1) mod p */{return binpowmod(n,p-2,p);}
ull gcd(ull x,ull y)
{
    if(y==0)
        return x;
    return gcd(y,x%y);
}
bool comp(pair<int,int> x,pair<int,int> y)
{
    if(x.first<y.first)
        return true;
    else if(x.first==y.first)
        return x.second>y.second;
    else
        return false;
}
bool comp_pairs_by_s(pair<ll,ll> &x ,pair<ll,ll> &y)
{
    return x.second<y.second;
}
bool isPowerOfTwo (ll x)  
{  
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));  
}

class cmp      //comparator for priority_queue 
{               //declaration: priority_queue<int,vector<int>,cmp>
public:         
    bool operator()(pair<int,int> A,pair<int,int> B)
    {
        if(abs(A.first-A.second)==abs(B.first-B.second))
            return A.first>B.first;
        return abs(A.first-A.second)<abs(B.first-B.second);
    }
};
// int prime[100005]={0};
// void sieve(void)
// {
//  int i,j;
//  for(i=0;i<100005;i++)
//         prime[i]=1;
//  prime[0]=0,prime[1]=0;
//  for(i=2;i<=sqrt(100005);i++){
//      if(prime[i]){
//          for(j=i*i;j<100005;j+=i){
//              prime[j]=0;
//          }
//      }
//  }
    
// }
void swap(int &x,int &y){
    int temp=x;
    x=y;
    y=temp;
}
vector<int> g[200001];
void solve()
{   
    ll n,k;
    cin>>n>>k;
    ll ans=0;
    for(ll i=k;i<=n;i++){
        ll minsum=(i-1)*i/2;
        ll maxsum=i*(2*n-i+1)/2;
        // if(i==k)
        //     cout<<maxsum-minsum;
        ans=(ans+maxsum-minsum+1)%mod;
        //cout<<ans<<'\n';
        //cout<<i<<' '<<ans<<'\n';
    }
    cout<<ans+1;

}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
}


Measured memory_bytes: 8348
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l():
	return list(map(int,input().split()))
def m():
	return map(int,input().split())
def s(x):
	a = []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa == x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x):
	return " ".join(map(str,x))

n = int(input())

a = []

for i in range(n):
	v,b = input().split();
	a.append([v,int(b),i+1])

a.sort(key = lambda x:(x[0],-x[1]))
for i in range(n):
	print(a[i][2])

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

using namespace std;

const int MAXN=3e5+5;
int n;
int pre[MAXN],suf[MAXN];
char s[MAXN];

int main(){
	scanf("%d",&n);
	scanf("%s",s+1);
	for(int i=1;i<=n;++i)
		pre[i]=pre[i-1]+(s[i]=='W');
	for(int i=n;i;--i)
		suf[i]=suf[i+1]+(s[i]=='E');
	int ans=INT_MAX;
	for(int i=1;i<=n;++i)
		ans=min(ans,pre[i-1]+suf[i+1]);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 2944
import sys
import numpy as np
TYPE_NUM = 26
WEIGHT = 1

def resolve():

    inp = sys.stdin.readlines()
    D = int(inp[0])
    c = np.array(list(map(int, inp[1].split(' '))))
    s = []
    last = np.zeros(TYPE_NUM, dtype=int)
    types = []

    for i in range(2, len(inp)):
        s.append(list(map(int, inp[i].split(' '))))
    s = np.array(s, dtype=int)

    for d in range(D):
        temp_delta_satis = np.zeros([TYPE_NUM, TYPE_NUM], dtype=int)
        for idx in range(TYPE_NUM):
            val = s[d, idx]
            org = last[idx]
            last[idx] = d+1
            temp_delta_satis[:, idx] = (np.sum(-c*(d+1-last)) + val)*WEIGHT
            if D != d+1:
                for idx2 in range(TYPE_NUM):
                    val2 = s[d+1, idx2]
                    org2 = last[idx2]
                    last[idx2] = d+2
                    temp_delta_satis[idx2, idx] += np.sum(-c*(d+2-last)) + val2
                    last[idx2] = org2
            last[idx] = org
        opt_idx = np.unravel_index(np.argmax(temp_delta_satis), temp_delta_satis.shape)[1]
        last[opt_idx] = d+1
        types.append(opt_idx+1)
    print(*types, sep='\n')

resolve()

Measured memory_bytes: 27328
#include<bits/stdc++.h>
#define ll long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;

signed main(){
    fastio
    int n;
    cin>>n;
    ll sum=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            for(int k=1;k<=n;k++){
                sum+=__gcd(i,__gcd(j,k));
            }
        }
    }
    cout<<sum<<"\n";
    return 0;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
#define mins(a,b) a=min(a,b)
#define maxs(a,b) a=max(a,b)
using namespace std;
int main(){
  string a,b;
  cin>>a>>b;
  int c;
  c=stoi(a+b);
  bool ok=false;
  for(int i=0;i<1000;i++){
    if(c==i*i)
      ok=true;
  }
  if(ok)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);

    string s;
    cin >> s;

    unordered_map<char, int> m;

    for (int i = 0; i < s.size(); ++i) {
        m[s[i]]++;
    }

    int t = 1;
    for (auto it = m.begin(); it != m.end(); ++it) {
        if (it->second % 2 != 0) {
            t = 0 ;
        }
    }

    cout << (t == 1 ? "Yes" : "No");
}


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

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main()
{	
	ll n, k;
	cin >> n >> k;
	ll ans = n;

	ans = n % k;

	if(abs(ans - k) < abs(ans)){
		cout << abs(ans - k) << endl;
	}
    else {
    	cout << abs(ans) << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll gcd2(ll a,ll b){
	while(b!=0){
		ll w=a%b;
		a=b;
		b=w;
	}
	return a;
}

ll lcm(ll a,ll b){
	return a*b/gcd2(a,b);
}
ll count(ll a,ll m){
	ll x=a%m,i;
	for(i=1;x!=1;++i){
		x=a*x%m;
	}
	return i;
}
int main(){
	int a1,a2,a3,m1,m2,m3;
	while(cin>>a1>>m1>>a2>>m2>>a3>>m3){
		if(a1==0&&a2==0&&a3==0&&m1==0&&m2==0&&m3==0)break;
		int xc,yc,zc;
		xc=count(a1,m1);
		yc=count(a2,m2);
		zc=count(a3,m3);
		cout<<lcm(lcm(xc,yc),zc)<<"\n";
	}
	return 0;
}

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

int main(){
  int n;
  int i;
  ll ans = 1;

  scanf("%d", &n);
  for(i = 1;i <= n;i++){
    ans = ans*i % MODSIZE;
  }

  printf("%lld\n", ans);
  return 0;
}


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

using namespace std;

int gcd(int x, int y) {
    if (x < y) {
        int tmp = x;
        x = y;
        y = tmp;
    }
    int r = -1;

    while(r != 0) {
        r = x % y;
        x = y;
        y = r;
    }
    return x;
}

int check(vector<int> skip) {
    int ans = gcd(skip[0], skip[1]);
    for (int i = 1; i < skip.size() - 1; i++) {
        ans = gcd(ans, skip[i + 1]);
    }
    return ans;
}

int main()
{
    int n, x; cin >> n >> x;
    vector<int> skip;

    for (int i = 0; i < n; i++) {
        int cp; cin >> cp;
        skip.push_back(abs(cp - x));
    }

    cout << (skip.size() == 1 ? skip[0] : check(skip)) << endl;

    return 0;
}

Measured memory_bytes: 1144
#include<bits/stdc++.h>
#define dbug printf("I am here\n");
#define Fast ios_base::sync_with_stdio(false); cin.tie(0);
#define vs            v.size()
#define ss            s.size()
#define sot(v)        sort(v.begin(),v.end())
#define rev(v)        reverse(v.begin(),v.end())
#define ii            pair<int, int>
#define int           long long
#define ull           unsigned long long
#define pb            push_back
#define mpp           make_pair
#define Okay          0
#define pi            3.14159

const int inf = 1e8;
const int cont = 1e18;
const int mod = 1e5;
using namespace std;


void solve(){
    string s;
    cin>>s;
    if(s[s.size()-1] == 's')cout<<s<<"es"<<endl;
    else cout<<s<<"s"<<endl;
}

int32_t main() {
   Fast;
//   int tst;
//   cin>>tst;
//   for(int i=1; i<=tst; i++){
        solve();
//   }
    return Okay;
}



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

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int ans = min(a, b) + min (c, d);
	cout << ans << endl;
	return 0;
}


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

public class Main {

	void solve() {
		char[] c = in.nextToken().toCharArray();
		int n = c.length;
		int[] count = new int[26];
		for (int i = 0; i < n; i++) {
			count[c[i] - 'a']++;
		}
		long result = 1L * n * (n + 1) / 2;
		for (int i = 0; i < 26; i++) {
			result -= 1L * count[i] * (count[i] + 1) / 2;
		}
		out.println(result + 1);
	}

	FastScanner in;
	PrintWriter out;

	void run() {
		in = new FastScanner();
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

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

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

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

		public int nextInt() {
			return Integer.parseInt(nextToken());
		}

		public long nextLong() {
			return Long.parseLong(nextToken());
		}

		public double nextDouble() {
			return Double.parseDouble(nextToken());
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}


Measured memory_bytes: 25172
import scala.annotation.tailrec
import scala.collection.mutable

object Main extends App{
  import scala.io.StdIn._
  solve()
  @tailrec def solve(): Unit = {
    val Array(h, w) = readLine.trim.split(' ').map(_.toInt)
    if (h == 0) return
    val map = mutable.Map[Char, Coordinate]()
    for (height ← 0 until h){
      val line = readLine.trim
      for (width ← 0 until w if line(width) != '_') {
        map(line(width)) = Coordinate(height, width)
      }
    }
    val statement = readLine.trim
    var current = Coordinate(0, 0)
    var sum = 0
    for (s ← statement) {
      val next = map(s)
      sum += current.manhattanDistance(next) + 1
      current = next
    }
    println(sum)
    solve()
  }
  case class Coordinate(x: Int, y: Int) {
    def manhattanDistance(that: Coordinate): Int = math.abs(x - that.x) + math.abs(y - that.y)
  }
}


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


int main() {
  int n, ans=0;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  for(int i=1; i<n-1; i++) {
    if(a[i-1]<a[i]&&a[i]<a[i+1]) ans++;
    else if(a[i-1]>a[i]&&a[i]>a[i+1]) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3596