akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long[] line = Stream.of(sc.nextLine().split(" ", 0)).mapToLong(Long::parseLong).toArray();
		long[] desk_a = Stream.of(sc.nextLine().split(" ", 0)).mapToLong(Long::parseLong).toArray();
		long[] desk_b = Stream.of(sc.nextLine().split(" ", 0)).mapToLong(Long::parseLong).toArray();

		long desk_a_sum = 0;
		long desk_b_sum = 0;
		long max = 0;
		int piv = -1;
		for (int i = 0; i < line[1]; i++) {
			if (desk_b_sum + desk_b[i] > line[2]) {
				break;
			}
			desk_b_sum += desk_b[i];
			max++;
			piv++;
		}
		long max_let = max;
		for (int i = 0; i < line[0]; i++) {
			max_let++;
			desk_a_sum += desk_a[i];
			if (piv > -1) {
				for (int j = piv; j >= 0; j--) {
					if (desk_b_sum <= line[2] - desk_a_sum ) {
						if (max < max_let) {
							max = max_let;
						}
						break;
					} else {
						desk_b_sum -= desk_b[j];
						max_let--;
						piv--;
					}
				}
			} else {
				if (desk_b_sum + desk_a_sum <= line[2] ) {
					if (max < max_let) {
						max = max_let;
					}
				}else {
					break;
				}
			}
		}

		System.out.println(max);
	}
}


Measured memory_bytes: 99004
N, M = map(int, input().split())
sc = []
for i in range(M):
    sc.append(list(map(int, input().split())))

rl = [-1]*(N+1)

for s, c in sc:
    if rl[s] == -1 or rl[s] == c:
        rl[s] = c
    else:
        print(-1)
        exit()
    # if s == 1 and c == 0 and:
    #     print(-1)
    #     exit()

ans = ""
for nd in range(1, N+1):
    c = rl[nd]
    if c == -1:
        if nd == 1 and N != 1: c = 1
        else: c = 0
    ans += str(c)

if str(int(ans)) != ans:
    print(-1)
    exit()
print(ans)

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

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

using namespace std;

int main(){
	int n; cin>>n;
	int a[2][100];
	rep(i,2) rep(j,n) cin>>a[i][j];

	int dp[2][101]={};
	rep(i,n){
		dp[0][i+1]=dp[0][i]+a[0][i];
		dp[1][i+1]=max(dp[1][i],dp[0][i+1])+a[1][i];
	}
	cout<<dp[1][n]<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>

using namespace std;
typedef long long ll;

/*迷路
const int INF = 50;

typedef pair<int,int> P;
char field[52][52];
int d[51][51];
int r,c;
int sx,sy;
int gx,gy;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int bfs(){
    queue<P> que;
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            d[i+1][j+1] = INF;
        }
    }
    que.push(P(sy,sx));
    d[sy][sx]=0;
while(que.size()){
    P p=que.front();
    que.pop();
    if(p.second==gx&&p.first==gy) break;
    for(int i=0;i<4;i++){
        int nx=p.second+dx[i];
        int ny=p.first+dy[i];

        if(1<=nx&&nx<=c&&1<=ny&&ny<=r&&field[ny][nx]!='#'&&d[ny][nx]==INF){
            que.push(P(ny,nx));
            d[ny][nx] = d[p.first][p.second] + 1;
        }
    }
}
return d[gy][gx];
}
*/
void f(int n, int y){
    int c;
    for(int a = 0; a<=n;a++){
        for(int b = 0; b<=n;b++){
            c = n - a - b;
             if(y == 10000*a+5000*b+1000*c&&c>=0){
                cout<<a<<' '<<b<<' '<<c<<endl;
                return;
            }
         }
    }
  cout<<"-1 -1 -1"<<endl;
}
int main(){
  int n,y;
  cin>>n>>y;
  f(n,y);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
int t;
ll gcd(ll x,ll y){
    return y==0?x:gcd(y,x%y);
}
ll a,b,c,d;

int main(){
    ios::sync_with_stdio(false);
    cin>>t;
    for(int i=1;i<=t;i++){
        cin>>a>>b>>c>>d;
        if(a<b){
            cout<<"No"<<endl;
        } else if(d<b){
            cout<<"No"<<endl;
        } else if(c-b-1>=0){
            cout<<"Yes"<<endl;
        } else{
            ll tmp = gcd(b,d);
            if((a-b)/tmp<(a-c-1)/tmp){
                cout<<"No"<<endl;
            } else{
                cout<<"Yes"<<endl;
            }
        }
    }
}



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

int main() {
	ll n, a, b;
	cin >> n >> a >> b;
	ll sum = a+b;
	ll r1 = n/sum;
	ll aa = r1*a;
	ll bb = r1*b;
	r1 = n-r1*sum;
	if(r1 >= a) {
		aa += a;
		bb += (r1-a);
	}
	else aa += r1;
	cout << aa;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5+100;
typedef long long LL;
LL num[maxn];
int main()
{
    LL h;
    cin >> h;
    LL ans = 0,tmp = 1;
    while(h!=1)
    {
        ans+=tmp;
        tmp*=2;
        h/=2;
    }
    cout << ans+tmp<< endl;
    return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/m-solutions2020

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

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

int main() {
    int X;
    cin >> X;
    
    int target[] = {400, 600, 800, 1000, 1200, 1400, 1600, 1800};
    int count = 8;
    for (int i = 0; i < 7; ++i){
        if (X >= target[i] and X < target[i+1]) {
            cout << count << endl;
            return 0;
        } else if (X >= 1800 and X < 2000) { // ここのことを忘れてた
            cout << 1 << endl;
            return 0;
        }
        --count;
    }
    return 0;
}


Measured memory_bytes: 3632
public class Main {

	public static void main(String[] args) {
		java.util.Scanner sc = new java.util.Scanner(System.in);

		String s1 = sc.next();
		String s2 = sc.next();
		String s3 = sc.next();

		System.out.println(s1.substring(0,1).toUpperCase() + s2.substring(0,1).toUpperCase() + s3.substring(0,1).toUpperCase());
	}

}


Measured memory_bytes: 23252
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

class Main {

    public static void main( final String[] args ) {

	final Scanner stdin = new Scanner( System.in );

	while( true ) {
	    final int a = stdin.nextInt();
	    final int b = stdin.nextInt();

	    if ( a == 0 && b == 0 ) {
		break;
	    }
	    
	    final int[][] map = new int[ b + 1 ][ a + 1 ];
	    final int n = stdin.nextInt();
	    for ( int i = 0; i < n; i++ ) {
		final int x = stdin.nextInt();
		final int y = stdin.nextInt();
		map[ y ][ x ] = -1;
	    }
	    
	    map[ 1 ][ 1 ] = 1;
	    for ( int i = 1; i <= b; i++ ) {
		for ( int j = 1; j <= a; j++ ) {
		    if ( ( i != 1 || j != 1 ) && map[ i ][ j ] != -1 ) {
			if ( map[ i - 1 ][ j ] != -1 ) {
			    map[ i ][ j ] += map[ i - 1 ][ j ];
			}
			if ( map[ i ][ j - 1 ] != -1 ) {
			    map[ i ][ j ] += map[ i ][ j - 1 ];
			}
		    }
		}
	    }
	    System.out.println( map[ b ][ a ] );
	}
    }    
}

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

int main() {
    double n, m, d, ans;
    cin >> n >> m >> d;
    if (d == 0) {
        ans = (m - 1) / n;
    }
    else {
        ans = (m - 1) * 2 * (n - d) / (n * n);
    }
    cout << fixed;
    cout << setprecision(7) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <limits.h>
#include <utility>
#include <map>
#include <algorithm>
#include <set>
using namespace std;
using P = pair<int,int>;
using ll = long long;
const int MOD=1e9+7;
int main(){
    int n,m;
    cin>>n>>m;
    vector<ll> x(n),y(n),z(n),s(n);
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i]>>z[i];
    }
    ll ret=0;
    for(int a=-1;a<=1;a+=2){
        for(int b=-1;b<=1;b+=2){
            for(int c=-1;c<=1;c+=2){
                for(int i=0;i<n;i++)s[i]=x[i]*a+y[i]*b+z[i]*c;
                sort(s.rbegin(),s.rend());
                ll cnt=0;
                for(int i=0;i<m;i++){
                    cnt+=s[i];
                }
                ret=max(ret,cnt);
            }
        }
    }
    cout<<ret<<endl;
}

Measured memory_bytes: 3548
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s,t;
    cin>>s>>t;
    vector<int> c1(26);
    vector<int> c2(26);
    for(int i=0;i<s.size();i++){
        c1[s[i]-'a']++;
        c2[t[i]-'a']++;
        if(c1[s[i]-'a']!=c2[t[i]-'a']){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


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

int wa(int a, int b) {
  int awa = 0, bwa = 0;
  while (a > 0) {
    awa += a % 10;
    a /= 10;
  }
  while (b > 0) {
    bwa += b % 10;
    b /= 10;
  }
  return awa + bwa;
}

int main() {
  int n;
  cin >> n;
  int minsum = 10000;
  for (int a = 1; a < n; a++) {
    int b = n - a;
    minsum = min(minsum, wa(a, b));
  }
  cout << minsum;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define PP pair<P,P>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x != 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 kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	random_device rnd;
	mt19937_64 mt64(rnd());
	uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt64);
}
/*--------Library Zone!--------*/



int n;
int a[1010][1010];
vector<int>v[1000100];
int g[1000010];
int cost[1000010];
queue<int>que;
signed main() {
	cin >> n;
	rep(i, n) {
		rep(j, n - 1) {
			cin >> a[i][j]; a[i][j]--;
		}
	}
	rep(i, n) {
		rep(j, n - 2) {
			int k = a[i][j], l = i;
			int k2 = a[i][j + 1], l2 = i;
			if (l > k)swap(l, k);
			if (l2 > k2)swap(l2, k2);
			v[l * n + k].push_back(l2 * n + k2);
			g[l2 * n + k2]++;
		}
	}
	rep(i, n) {
		for (int j = i + 1; j < n; j++) {
			if (!g[i * n + j]) {
				que.push(i * n + j); cost[i * n + j] = 1;
			}
		}
	}
	while (!que.empty()) {
		int p = que.front(); que.pop();
		for (auto q : v[p]) {
			g[q]--;
			if (!g[q]) {
				que.push(q);
				cost[q] = cost[p] + 1;
			}
		}
	}
	int ma = 0;
	rep(i, n) {
		for (int j = i + 1; j < n; j++) {
			if (!cost[i * n + j]) {
				cout << -1 << endl; return 0;
			}
			chmax(ma, cost[i * n + j]);
		}
	}
	cout << ma << endl;
}


Measured memory_bytes: 62848
#include <iostream>
#include <string>
using namespace std;
int main() {
	string a, b;
	string ans;
	cin >> a >> b;

	if (a.size() == b.size()) {
		//����������
		bool e = true;
		for (int i = 0; i < (int)a.size(); i++)
		{
			if (a[i] - '0' > b[i] - '0') {
				ans = "GREATER";
				e = false;
				break;
			}
			else if (a[i] - '0' < b[i] - '0') {
				ans = "LESS";
				e = false;
				break;
			}
		}
		if (e) {
			ans = "EQUAL";
		}

	}
	else if (a.size() < b.size()) {
		ans = "LESS";
	}
	else {
		ans = "GREATER";
	}

	cout << ans << endl;

	return 0;
}

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

using std::cin;
using std::cout;
using std::endl;
using std::cerr;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::stack;
using std::priority_queue;

using std::min;
using std::max;
using std::sort;
using std::abs;

typedef long long int ll;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;

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

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

    int ans = INF;
    for(int i = -100; i <= 100; i++){
        int diff = 0;
        for(int j = 0; j < n; j++){
            diff += (a[j] - i) * (a[j] - i);
        }
        ans = min(ans, diff);
    }

    cout << ans << endl;

    return 0;
}

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

namespace AtCoder.Abc
{
    class Abc_085_B
    {
        // https://atcoder.jp/contests/abc085/tasks/abc085_b
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数の入力
            int n = int.Parse(Console.ReadLine());

            // 整数配列の入力
            List<int> inputIntList = new List<int>();

            for (int i = 0; i < n; i++)
            {
                int moti = int.Parse(Console.ReadLine());
                if (!inputIntList.Contains(moti))
                {
                    inputIntList.Add(moti);
                }
            }

            Console.WriteLine(inputIntList.Count);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 13148
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
         int a= sc.nextInt();
         int b= sc.nextInt();
         int c= sc.nextInt();
         if(a<b && b<c){
         System.out.println("Yes");
         }else
        	 System.out.println("No");
    }
}

Measured memory_bytes: 26244
#include<stdio.h>
 
int main(){
	char s[5];
	int count=0;
	scanf("%s",s);
	int i,j;
	for(i=0;i<4;i++){
		for(j=i+1;j<4;j++){
			if(s[i]==s[j])
				count++;
		}
	}
	if(count==2)
		printf("Yes");
	else
		printf("No");
	return 0;
}
				
	

Measured memory_bytes: 128
#include <iostream>

using namespace std;

long a[100000] = {};
long x[100001] = {};
int main()
{
	int n;
	int y = 0;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < n; i++)
	{
		x[a[i] - 1] = x[a[i] - 1] + 1;
		x[a[i]] = x[a[i]] + 1;
		x[a[i] + 1] = x[a[i] + 1] + 1;
	}
	for (int i = 0; i <= 100001; i++)
	{
		if (y < x[i])
		{
			y = x[i];
		}
	}
	cout << y;
	return 0;
}

Measured memory_bytes: 1792
let () =
  let n = read_int () in
  let tbl = Hashtbl.create ~random:true n in
  for _ = 0 to n - 1 do
    match Scanf.scanf "%s %s\n" (fun inst str -> (inst, str)) with
    | ("find", s) -> print_endline (if Hashtbl.mem tbl s then "yes" else "no")
    | (_, s) -> Hashtbl.add tbl s ()
  done

Measured memory_bytes: 43988
def solve(n):
    D = {k: 0 for k in range(1, n+1)}
    m = int(n**0.5)
    for x in range(1, m+1):
        for y in range(1, m+1):
            for z in range(1, m+1):
                k = x**2 + y**2 + z**2 + x*y + y*z + z*x
                if k <= n:
                    D[k] += 1
                else:
                    break
    for k in range(1, n+1):
        print(D[k])

n = int(input())
solve(n)



Measured memory_bytes: 9840
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#include <cmath>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;

int d(lli k){
	if(k<10) return 1;
	return d(k/10)+1;
}

int main(){
	lli N;
	cin>>N;
	int ans=d(N);
	rep1(i,1e5){
		if(N%i!=0)continue;
		ans=min(max(d(i),d(N/i)),ans);
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;
constexpr long long int INF = std::numeric_limits<long long int>::max();
#define int long long int

int search(vector<int> &a, int k) {
  int lb = -1, ub = a.size();
  while (ub - lb > 1) {
    int mid = (lb + ub) / 2;
    if (a[mid] >= k) {
      ub = mid;
    } else {
      lb = mid;
    }
  }
  return ub;
}

void solve() {
  int N;
  cin >> N;

  vector<int> A(N), B(N), C(N);
  for (auto &a : A) {
    cin >> a;
  }
  for (auto &b : B) {
    cin >> b;
  }
  for (auto &c : C) {
    cin >> c;
  }

  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  sort(C.begin(), C.end());

  vector<int> V;
  V.push_back(0);
  int x = 0;
  for (int i = 0; i < B.size(); i++) {
    int a = search(A, B[i]);
    x += a;
    V.push_back(x);
  }

  int ans = 0;
  for (int i = 0; i < C.size(); i++) {
    int a = search(B, C[i]);
    ans += V[a];
  }

  cout << ans << endl;
}

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


Measured memory_bytes: 3832
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	cout << a[0] << " " << a[1] << " " << a[2] << endl;
	return 0;
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define pi pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,a,b) for(int i = a ; i <= b;i++)
using namespace std;
void debug(int x){
    cerr<<x<<endl;
}
void debug(vector<int> v){
    for(int i = 0 ; i<v.size(); i++) cerr<<v[i]<<" ";
    cerr<<"\n";
}
void debug(int *A, int N){
    for(int i = 0 ; i < N;i++) cerr<<A[i]<<" ";
    cerr<<endl;
}
void debug(int *A, int i, int j){
    for(int k = i;k<=j;k++) cerr<<A[k]<<" ";
    cerr<<endl;
}
void scan(vector<int> &h,int N){
    for(int i = 0 ; i < N;i++){
        scanf("%d",&h[i]);
    }
}

int dp[100005] = {0};
int main(){
    int N, K;
    cin>>N>>K;
    vector<int> a(N+1);
     int mn;
     bool one_found = false;
    for(int i = 1; i <=N;i++){
        cin>>a[i];
        if(a[i] == 1) one_found = true;
    }
    //dp[sum] is the winner with sum amount of stones
    //dp[sum] = 0 indicates player making first move from here wins
    //and 1 indicates that second player wins

    dp[1] = (one_found)?0:1; //if one is found then player 1 wins else player 2

    for(int i =2;i<=K;i++){
                 dp[i] = -1;
             for(int j = 1; j <=N; j++){
                  if(i == a[j]){
                       dp[i] = 0; //first player wins
                       break;
                  }
                  else if( i > a[j] ){
                       if(dp[i - a[j]] == 1){
                           dp[i] = 0; break;
                       }
                  }
             }
             if(dp[i] == -1){
                 dp[i] = 1;
             }
    }
    string ans = (dp[K] == 0)?"First":"Second";
    cout<<ans<<"\n";

}

Measured memory_bytes: 640
n = int(input())
s = input()

t = [set() for _ in range(n)]
t[-1] = {int(s[-1])}

for i in range(1, n):
    base = t[n - i].copy()
    base.add(int(s[n - i - 1]))
    t[n - i - 1] = base

ans = 0
for a in range(10):
    ai = 0

    if a not in t[ai]:
        continue

    while ai < n:
        if s[ai] == str(a):
            break
        else:
            ai += 1
    if ai >= n - 2:
        continue
    for b in range(10):
        bi = ai + 1

        if b not in t[bi]:
            continue

        while bi < n:
            if s[bi] == str(b):
                break
            else:
                bi += 1
        if bi >= n - 1:
            continue
        for c in range(10):
            ci = bi + 1

            if c not in t[ci]:
                continue

            while ci < n:
                if s[ci] == str(c):
                    break
                else:
                    ci += 1
            if ci == n:
                continue
            else:
                ans += 1

print(ans)
exit(0)


x = int(input())
dp = [False for _ in range(x + 1)]
dp[0] = True
for item in [100, 101, 102, 103, 104, 105]:
    for i in range(x + 1):
        if i - item >= 0:
            if dp[i - item]:
                dp[i] = True

print(1 if dp[x] else 0)
exit(0)


Measured memory_bytes: 61020
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>

int main(void) {
	int n;
	char ans[51],str[50][51];
	
	scanf("%d %s",&n,ans);
	for (int i = 1;i < n;i++) {
		scanf("%s",str[i-1]);
	}
	
	char tmp;
	for (int i = 0;i < strlen(ans);i++) {
		for (int j = i+1;j < strlen(ans);j++) {
			if (ans[i] > ans[j]) {
				tmp = ans[i];
				ans[i] = ans[j];
				ans[j] = tmp;
			}
		}
	}
	
	for (int i = 0;i < n-1;i++) {
		for (int j = 0;j < strlen(ans);j++) {
			bool flag = false;
			if (ans[j] == ' ') {
				continue;
			}
			for (int k = 0;k < strlen(str[i]);k++) {
				if (ans[j] == str[i][k]) {
					str[i][k] = ' ';
					flag = true;
					break;
				}
			}
			if (!flag) {
				ans[j] = ' ';
			}
		}
	}
	
	for (int i = 0;i < strlen(ans);i++) {
		if (ans[i] != ' '){
			printf("%c",ans[i]);
		}
	}
	printf("\n");
	
	return 0;
}


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

int main()
{
  int n;
  cin >> n;
  int a[n], b[n - 1];
  int ans = 0;
  rep(i, n - 1) cin >> b[i];
  if(n == 1) cout << b[0] * 2 << endl;
  else{
    a[0] = b[0];
    rep(i, n - 1){
      if(i == n - 2) a[i + 1] = b[i];
      else a[i + 1] = min(b[i], b[i + 1]);
    }
    ll sum = 0;
    rep(i, n) sum += a[i];
    cout << sum << endl;
  }


  return 0;
}

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

int main(void){
    int n, ans = 0;
    vector<int> a(20);
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = 1; i < n - 1; i++){
        if(min(a[i], a[i+1]) == max(a[i], a[i-1]) 
        || min(a[i], a[i-1]) == max(a[i], a[i+1])){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import scala.io.Source.stdin

object Main extends App {
  var b = new StringBuilder

  for(d<-stdin.getLines.map(_.toInt)) {
    var (j,s) = (0,0)

    while(j*d < 600) {
      s += j*j
      j += 1
    }
    b.append(s*d*d*d+"\n")
  }

  print(b.result)
}

Measured memory_bytes: 43636
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

vector<int> init(int size){
  vector<int> par(size,-1);
  return par;
}

int root(int x, vector<int>& par){
  if(par[x] < 0){
    return x;
  }else{
    return par[x] = root(par[x],par);
  }
}

bool same(int x, int y, vector<int>& par){
  return root(x, par) == root(y, par);
}

void unite(int x, int y, vector<int>& par){
  x = root(x, par), y = root(y, par);
  if(same(x,y, par))return;
  par[x] += par[y];
  par[y] = x;
}

int size(int x, vector<int>& par){
  return -par[root(x, par)];
}

signed main(){
  char c;cin>>c;int a;string s;cin>>a>>s;
  if(c=='A'){
    cout << 'T' << endl;
  }else if(c=='T'){
    cout << 'A' << endl;
  }else if(c == 'C'){
    cout << 'G' << endl;
  }else if(c=='G'){
    cout << 'C' << endl;
  }
}


Measured memory_bytes: 256
S = input()

S = S[::-1]

word_list1 = "dream"
word_list2 = "dreamer"
word_list3 = "erase"
word_list4 = "eraser"

s = ""
ans = ""

word_list = [word_list1[::-1],word_list2[::-1],word_list3[::-1],word_list4[::-1]]

for i in S:
    s += i
    if s in word_list:
        ans += s
        s = ""

if S == ans:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

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

    int A, B; cin >> A >> B;
    cout << max(A + B, max(A - B, A * B));
    return 0;
}

// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 256
def convert(s):
    cur = [0]
    def dfs():
        result = [0, 0]
        cur[0] += 1 # '('
        if s[cur[0]] == '(':
            result[0] = dfs()
        cur[0] += 1 # ','
        if s[cur[0]] == '(':
            result[1] = dfs()
        cur[0] += 1 # ')'
        return result
    return dfs()
def rconvert(C):
    def dfs(node):
        res = ["", ""]
        if node[0]:
            res[0] = rconvert(node[0])
        if node[1]:
            res[1] = rconvert(node[1])
        return "(%s,%s)" % tuple(res)
    return dfs(C)
def solve(A, B, t):
    def get(i):
        if A[i] and B[i]:
            return solve(A[i], B[i], t)
        elif t is 'u':
            return A[i] or B[i]
    return [get(0), get(1)]
try:
    while 1:
        ipt = raw_input().split()
        print rconvert(solve(convert(ipt[1]), convert(ipt[2]), ipt[0]))
except:pass

Measured memory_bytes: 6404
N = int(input())
c = [0, 0, 0, 0]
for k in range(N):
    s = input()
    if s == 'AC':
        c[0] +=1
    elif s == 'WA':
        c[1] +=1
    elif s == 'TLE':
        c[2] +=1
    else:
        c[3] +=1

print('AC x', c[0])
print('WA x', c[1])
print('TLE x', c[2])
print('RE x', c[3])

Measured memory_bytes: 9208
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(llint i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define Pll pair<llint,llint>
#define keta(a)  fixed << setprecision(a)
const ll mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
const ll INF = 1000000000;



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

Measured memory_bytes: 3632
#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 N;
  unsigned long long A[100010];
  unsigned long long answer = 1;
  const unsigned long long max = 1000000000000000000;

  cin >> N;

  rep(i, N) {
    cin >> A[i];
    if (A[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }

  rep(i, N) {
    if (A[i] <= max / answer) {
      answer *= A[i];
    } else {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << answer << endl;

  return 0;
}


Measured memory_bytes: 4412
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int[] foods = new int[5];
        for(int i = 0 ; i < 5 ; i++){
            foods[i] = sc.nextInt();
        }
        sc.close();

        int[] yobun = new int[5];
        
        for(int k = 0 ; k < 5 ; k++){
            for(int i = 10 ;i < 140 ; i+=10){
                if(i-foods[k]>0 && i-foods[k]!=10){
                    yobun[k] = i-foods[k];
                    break;
                }else if(i-foods[k]==10){
                    yobun[k] = 0 ;
                    break;
                }
            }
        }
        Arrays.sort(yobun);
        int ans = 0;

        for(int i = 0; i < 5 ; i++){
            ans += foods[i];
            ans += yobun[i];
        }
        System.out.println(ans-yobun[4]);
    }
}

Measured memory_bytes: 23124
#include<cstdio>

using namespace std;

int main(){
    int a,b,c,o=0;
    scanf("%d %d %d",&a,&b,&c);
    if(a == b && b == c)o++;
    if( a != b){
        o++;
    }
    if( b != c){
        o++;
    }
    if( a!= c){
        o++;
    }
    printf("%d \n",o);

}


Measured memory_bytes: 128
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx2")

#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< lo,lo > PII;

#define fi first
#define se second
#define mp make_pair
#define int long long
#define endl "\n"
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo inf = 1000000000000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 100002;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t,dp[li][5];
int cev;
string s;
vector<int> v[li];

inline int add(int x,int y){
	if(x+y>=mod)return x+y-mod;
	return x+y;
}

inline int mul(int x,int y){
	return (x%mod)*(y%mod)%mod;
}

inline void dfs(int node,int ata){
	int sum[2]={1,1};
	flag=0;
	for(int i=0;i<(int)v[node].size();i++){
		int go=v[node][i];
		if(go==ata)continue;
		flag=1;
		dfs(go,node);
		sum[0]=mul(sum[0],add(dp[go][0],dp[go][1]));
		sum[1]=mul(sum[1],dp[go][0]);
	}
	if((int)v[node].size()==1 && ata!=0){
		dp[node][0]=1;
		dp[node][1]=1;
	}
	else{dp[node][0]=sum[0];dp[node][1]=sum[1];}
}

main(void){
	//~ memset(dp,-1,sizeof(dp));
	scanf("%lld",&n);
	for(int i=1;i<n;i++){
		int x,y;
		scanf("%lld %lld",&x,&y);
		v[x].pb(y);
		v[y].pb(x);
	}
	dfs(1,0);
	printf("%lld\n",add(dp[1][1],dp[1][0]));
	return 0;
}



Measured memory_bytes: 21540
#include <iostream>
#include <cmath>

using namespace std;

int main(){
  int x_max;
  std::cin >> x_max;

  int ans = 1;
  for(int x = 1; x <= x_max; x++){
    for(int p = 2; p <= 1000; p++){
      int exp_num = pow(x, p);
      if(x_max >= exp_num){
        if(ans < exp_num) ans = exp_num;
      }
    }
  }

  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 384
using System.Linq;
using System;

class Program
{
  static void Main() => new Program().solve();

  void solve()
  {
    var n = int.Parse(Console.ReadLine());
    var ans = (n % fun(n:n) == 0) ? "Yes" : "No";
    Console.WriteLine(ans);
  }

  int fun(int sum = 0, int n = 1)
  {
    if(n == 0) return sum;
    return fun(sum + n % 10, n / 10);
  }
}

Measured memory_bytes: 11092
import java.util.Scanner;

public class Main{	
	public static void main(String[] arts){
		Scanner sc = new Scanner(System.in);
		char[] alpha = new char[26];
		for(int i=0;i<26;i++){
			alpha[i]=(char)(97+i);
		}
		int[] list = new int[26];
		while(sc.hasNext()){
			String s = sc.nextLine();
			for(int i=0;i<s.length();i++){
				int c = s.toLowerCase().codePointAt(i);
				if(c>=97 && c<=122)
					list[c-97]++;
			}
		}
		for(int i=0;i<26;i++){
				System.out.printf("%c : %d\n",alpha[i],list[i]);
		}
	}
}


Measured memory_bytes: 30472
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
using namespace std;
long long N,ans;
multiset<int,greater<int>>s;
int main(){
    cin>>N;
    vector<long long>A(N);
    for(int i=0;i<N;i++)cin>>A[i];
    sort(A.rbegin(),A.rend());
    s.emplace(A[0]);
    for(int i=1;i<N;i++){
        //cout<<*s.begin()<<endl;
        ans+=*s.begin();
        s.erase(s.begin());
        s.insert(A[i]);s.insert(A[i]);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 14008
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(), v.end()
#define PI 3.141592653589793238462643383279
typedef long long int ll;
typedef unsigned long long ull;
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;}
typedef pair<ll,ll> P;
const long long MOD = 1e9+7;
const ll INF = 1LL << 60;

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

    vector<int> b(m);
    vector<vector<int>> a(n,vector<int>(m));

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

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

    for(int i = 0; i < n; i++){
        int cnt = 0;
        for(int j = 0; j < m; j++){
            cnt += b[j] * a[i][j];
        }
        cout << cnt << endl;
    }


}


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

using namespace std;
typedef long long ll;

int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    int l = 1, r = (n - 1) / 2;
    int ll = r + 1, rr = ll + r;
    int cnt = 0;
    for (int i = 0; i < 2; i++) {
        while (l < r && cnt < m) {
            printf("%d %d\n", l, r);
            cnt++;
            l++, r--;
        }
        l = ll, r = rr;
    }
}


Measured memory_bytes: 3800
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<int,P> PP;

vector<PP> v;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

int main()
{
	int n,x,l,ans=1,sum=0;
	cin >> n >> x;
	rep(i,n){
		cin >> l;
		sum += l;
		if(sum <=x) ans++;
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
    int n, m;
    cin >> n >> m;
    ll s[n], t[m];

    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    for (int j = 0; j < m; j++) {
        cin >> t[j];
    }

    ll dp[n + 1][m + 1];

    for (int i = 0; i <= n; i++) {
        dp[i][0] = 1;
    }
    for (int i = 0; i <= m; i++) {
        dp[0][i] = 1;
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (s[i] == t[j]) {
                dp[i + 1][j + 1] = (dp[i + 1][j] + dp[i][j + 1]) % mod;
            } else {
                dp[i + 1][j + 1] =
                    (dp[i + 1][j] + dp[i][j + 1] - dp[i][j] + mod) % mod;
            }
        }
    }
    cout << dp[n][m] << endl;
}


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

Int power(Int n, Int m) {
  Int ans = 1;
  rep(i,m) {
    ans *= n;
  }
  return ans;
}

int main(){ 
  Int N, ans;
  cin >> N;
  
  if (N % 2 == 1) ans == 0;
  else {
    for(int n = 1; 2 * power(5, n) <= N; n++) {
      ans += (N / (2 * power(5,n)));
    }
  }
  
  cout << ans << endl;
}


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

int main(){
    int n,k,min = INT_MAX;
    cin >> n >> k;
    k--;
    int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    sort(a,a+n);
    for(int i=0;i<n-k;i++){
        if(min > a[i+k] - a[i]){
            min = a[i+k] - a[i];
        }
    }
    cout << min;
}


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
ll INF = 1LL << 60;
 
using vc = vector<char>;
using vi = vector<int>;

int A, B;
int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> A >> B;
    int lo = min(A, B); int hi = max(A, B);
    const int S = 97;
    vector<bitset<S>> grid (97);
    lo -= 1;
    for (int i = 1; i + 3 < S; i += 4) {
        for (int j = 1; j + 3 < S; j += 4) {
            if (hi > 0) {
                F0R(x,3) F0R(y, 3) grid[i+y][j+x] = true;
                --hi;
            }
            if (lo > 0) {
                grid[i+1][j+1] = false;
                --lo;
            }
        }
    }
    cout << S << " " << S << endl;
    F0R(i, S) {
        F0R(j, S) {
            cout << ((grid[i][j] != (max(A, B) == A)) ? '#' : '.');
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int n;
  cin>>n;
  int ma=0,sum=0;
  int l[n+1]={};
  for(int i=0;i<n;i++){
    cin>>l[i];
    if(ma<l[i]){
      ma=l[i];
    }
    sum+=l[i];
  }

  if(ma<sum-ma) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
#define EPS (1e-10)
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	int n; VI h(2); cin>>n>>h[0]>>h[1];
	int ans=0;
	rep(i,n){
		VI a(2); cin>>a[0]>>a[1];
		if(a[0]>=h[0]&&a[1]>=h[1]) ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
  int n, i;
  cin>>n;
  if(n%111==0)
    cout<<n<<endl;
  else{
    for(i=1; i<9; i++){
      if(111*i>n)
	break;
    }
    cout<<111*i<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  int N;
  cin >> N;
  
  vector<int> a(N);
  for (int i=0; i<N ;i++){
    cin >> a.at(i);
  }
  
  sort(a.begin(),a.end());
	int mochi=0;
  for (int i=0; i<N-1; i++){
  	if (a.at(i)!=a.at(i+1)){
      mochi++;
    }
    
  }
  cout << mochi+1 << endl;
  
  
}

Measured memory_bytes: 764
N, = (int(x) for x in input().split())

SP_arr = []
for _ in range(N):
    S,P = input().split()
    SP_arr.append([S, int(P)])

I_arr = list(range(N))
I_arr.sort(key=lambda x: SP_arr[x][1], reverse=True)
I_arr.sort(key=lambda x: SP_arr[x][0])

for i in I_arr:
    print(i+1)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int getRoot(vector<int>*groups,int v){
  vector<int>&xs=*groups;
  if(xs[v]==v)return v;
  return xs[v]=getRoot(&xs,xs[v]);
}
void unite(vector<int>*groups,int u,int v){
  vector<int>&xs=*groups;
  u=getRoot(&xs,u);
  v=getRoot(&xs,v);
  xs[max(u,v)]=min(u,v);
}
bool isSameGroup(vector<int>*groups,int u,int v){
  return getRoot(groups,u)==getRoot(groups,v);
}
main(){
  int N,M;
  cin>>N>>M;
  vector<int>groups(N+1),p(N+1);
  for(int i=1;i<=N;++i)groups[i]=i;
  for(int i=1;i<=N;++i)cin>>p[i];
  for(int i=1;i<=M;++i){
    int x,y;
    cin>>x>>y;
    unite(&groups,x,y);
  }
  int count_=0;
  for(int i=1;i<=N;++i){
    if(isSameGroup(&groups,i,p[i]))++count_;
  }
  cout<<count_<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1000000000; 

int main(){
  string s;
  cin >> s;
  if(s[0] == s[1] && s[1] == s[2] && s[0] == 'A'){
    cout << "No" << endl;
    return 0;
  }
  else if(s[0] == s[1] && s[1] == s[2] && s[0] == 'B'){
    cout << "No" << endl;
    return 0;
  }
  else{
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define mem(a,k) memset(a,k,sizeof(a))
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

#define Pr(f,...) fprintf(stderr,f,##__VA_ARGS__),fflush(stderr)

typedef long long ll;

template<typename T>
void read(T &x){
	x=0; 
	char c;
	for(c=getchar();!isdigit(c);c=getchar()); 
	for(;isdigit(c);c=getchar())x=x*10+c-'0'; 
}

const int N=6e5+50,G=5,P=924844033;

int mul(int a,int b){ return 1ll*a*b%P; }
int add(int a,int b){ a+=b; return a>=P?a-P:a; }
int sub(int a,int b){ a-=b; return a<0?a+P:a; }
int power(int a,int k){
	int res=1;
	for(;k;k>>=1,a=mul(a,a))if(k&1)res=mul(res,a);
	return res;
}
int inverse(int x){ return power(x,P-2); }

void ntt(int n,int *x,bool rev){
	for(int i=0,j=0;i<n;++i){
		if(i<j)swap(x[i],x[j]); 
		for(int l=n>>1;(j^=l)<l;l>>=1);
	}	
	for(int s=2;s<=n;s<<=1){
		int m=s>>1,wn=power(G,(P-1)/s);
		if(rev)wn=inverse(wn);
		for(int j=0;j<n;j+=s){
			int w=1;
			lop(k,0,m){
				int z=mul(x[j+m+k],w);
				x[j+m+k]=sub(x[j+k],z);
				x[j+k]=add(x[j+k],z);
				w=mul(w,wn);
			}
		}
	}
	if(rev){
		int invN=inverse(n);
		lop(i,0,n)x[i]=mul(x[i],invN);
	}
}

vector<int> g[N];
int n,siz[N],inv[N],fac[N],a[N],b[N],c[N];

int C(int n,int m){
	if(m<0||m>n)return 0; 
	return mul(mul(fac[n],inv[n-m]),inv[m]); 
}

void dfs(int v,int p){
	siz[v]=1; 
	for(int d:g[v])if(d!=p){
		dfs(d,v); 
		++a[siz[d]];
		++a[n-siz[d]];
		siz[v]+=siz[d];
	}
}

void polyMul(int n,int *a,int m,int *b,int *c){
	int p=1; while(p<n+m-1)p<<=1;
	ntt(p,a,false),ntt(p,b,false);
	lop(i,0,p)c[i]=mul(a[i],b[i]); 
	ntt(p,c,true);
}

int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
	freopen("dat.in","r",stdin);
	//freopen("my.out","w",stdout);
#endif
	fac[0]=1; lop(i,1,N)fac[i]=mul(fac[i-1],i); 
	inv[1]=1; lop(i,2,N)inv[i]=mul(P-P/i,inv[P%i]); 
	inv[0]=1; lop(i,1,N)inv[i]=mul(inv[i-1],inv[i]); 

	scanf("%d",&n); 	
	rep(i,1,n-1){
		int u,v;
		scanf("%d%d",&u,&v); 
		g[u].pb(v),g[v].pb(u); 
	}
	dfs(1,0);
	rep(i,1,n)a[i]=mul(a[i],fac[i]); 
	reverse(a,a+n+1);
	
	rep(i,0,n)b[i]=inv[i];
	polyMul(n+1,a,n+1,b,c);
	rep(k,1,n){
		printf("%d\n",sub(mul(n,C(n,k)),mul(inv[k],c[n-k])));	
	}
	return 0;
}

Measured memory_bytes: 47104
#include "bits/stdc++.h"

using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
#define lin "\n"
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(0)
int a[105], b[105], c[105];

void solve() {
    int m, n;
    cin >> m >> n;
    ll cnt = 0;
    for (int i = m; i <= n; ++i) {
        string s = to_string(i);
        bool ok = true;
        for (int j = 0; j < s.size() / 2; ++j) {
            if (s[j] != s[s.size() - j - 1]) {
                ok = false;
                break;
            }
        }
        if (ok)
            cnt++;
    }
    cout << cnt << lin;
}

int main() {
    fast_io;
    int t = 1;
//    cin >> t;
    int c = 1;
    while (t--) {
//        printf("Case %lld: ",c);
//        cout<<"Case "<<c<<": ";
        solve();
        c++;
    }
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<pll> vpll;

void INX(){}
template<typename Head, typename... Tail>
void INX(Head&& head, Tail&&... tail)
{
    cin >> head;
    INX(forward<Tail>(tail)...);
}
void OUTX(){}
template<typename Head, typename... Tail>
void OUTX(Head&& head, Tail&&... tail)
{
    cout << head << endl;
    OUTX(forward<Tail>(tail)...);
}

#define ADD emplace_back
#define MP make_pair
#define VVEC(type) vector<vector<type>>


int main()
{
    ll K;
    INX(K);

    string tmp = "ACL";
    string result = "";
    for (ll i = 0; i < K; i++)
    {
        result.append(tmp);
    }
    OUTX(result);



    return 0;
}


Measured memory_bytes: 3504
#define ll				long long
#define MOD				1000000007
#define VTX_MAX			10000
#define EDGE_MAX		10000

#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>


FILE *in, *ans;
int tno;

int out(const char *s) {
#ifdef TEST
	char buf[8192];
	fgets(buf, sizeof(buf), ans);
	if (strcmp(buf, s)) {
		printf("err\n");
	}
#else
	printf(s);
#endif
	return 0;
}

int outi(int i) {
	char s[128];
	sprintf(s, "%d\n", i);
	out(s);
	return 0;
}

int outd(double d) {
	char s[128];
	sprintf(s, "%.10lf\n", d);
	out(s);
	return 0;
}

int outll(ll l) {
	char s[128];
	sprintf(s, "%lld\n", l);
	out(s);
	return 0;
}

int geti() {
	int i;
	fscanf(in, "%d", &i);
	return i;
}

ll getll() {
	ll l;
	fscanf(in, "%lld", &l);
	return l;
}

int getstr(char *s) {
	fscanf(in, "%s", s);
	return 0;
}

typedef struct data {
	char c;
	int cnt;
} data;

char s[200010];
data datas[200010];
int dcnt;

ll fnc2() {
	int i, j, k, ret;

	getstr(s);

	datas[0].c = s[0];
	datas[0].cnt = 1;
	dcnt = 1;

	for (i = 1; ; i++) {
		if ('A' <= s[i] && s[i] <= 'C') {
			if (s[i] == s[i - 1]) {
				datas[dcnt - 1].cnt++;
			}
			else {
				datas[dcnt].c = s[i];
				datas[dcnt].cnt = 1;
				dcnt++;
			}
		}
		else {
			break;
		}
	}

	ll ocnt = 0;
	for (i = 0; i < dcnt - 2; i++) {
		if (datas[i].c == 'A') {
			if (datas[i + 1].c == 'B') {
				if (datas[i + 1].cnt == 1) {
					if (datas[i + 2].c == 'C') {
						ocnt += datas[i].cnt;
						if (datas[i + 2].cnt == 1) {
							datas[i + 2].c = 'A';
							datas[i + 2].cnt = datas[i].cnt;
							if (datas[i + 3].c == 'A') {
								datas[i + 3].cnt += datas[i + 2].cnt;
							}
						}
					}
				}
			}
		}
	}

	return ocnt;
}

int fnc1() {
	ll ret = fnc2();
	outll(ret);
	return 0;
}

int main() {

#ifdef TEST
	for (tno = TEST_SNO; tno <= TEST_ENO; tno++) {
		char str[128];
		sprintf(str, "test%d.txt", tno);
		in = fopen(str, "r");
		sprintf(str, "ans%d.txt", tno);
		ans = fopen(str, "r");
		fnc1();
		fclose(in);
		fclose(ans);
	}
	printf("end\n");
#else
	in = stdin;
	fnc1();
#endif

	return 0;
}


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


void solve(long long N){
    if(N % 2 == 1){
        cout<<0<<endl;
    }else{
        ll ans = 0;
        ll cnt = 10;
        ll s = N;
        for(int i = 0;i < 18;i++){
            ans += (N / cnt);
            cnt *= 10;
        }
        //cout<<ans<<endl;
        cnt = 25;
        ll uku = 0;
        for(int i = 0;i < 26;i++){
            uku += (s / cnt) / 2;
            cnt *= 5;
        }
        //cout<<uku<<endl;
        cout<<uku + N/10<<endl;
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256