akhauriyash/Code-Regression huggingface dataset:
import java.io.*;

class Main {
	private static final int M = 104730;

	public static void main (String args[]) {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		String buf;

		int list[] = new int[M+1];
		for (int i=2;i<=M;i++) list[i] = 0;
		for (int i=2;i<=M;i++) {
			for (int j=2;i*j<=M;j++) {
				list[i*j] = 1;
			}
		}

		try {
			while ((buf = br.readLine()).equals("0")==false) {
				int n = Integer.parseInt(buf);
				int count = 0;
				long sum = 0;
				for (int i=2;i<=M;i++) {
					if (list[i]==0) {
						sum += (long)i;
						count++;
						if (count==n) break;
					}
				}
				System.out.println(sum);
			}
		} catch (Exception e) {
			//Exception
		}
	}
}

Measured memory_bytes: 19876
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>
#include<tuple>
#include<stack>


using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> tpl;
int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };

#define ARRAY_MAX 300

const int INF = 1 << 30;
const int MOD = 1e9 + 7;

template<typename T>
T maxSquare(vector< vector<T> >& board) {
	T H = board.size(), W = board[0].size();
	vector< vector<T> > dp(H, vector<T>(W));

	T ret = 0;
	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			if (board[i][j] == 1) continue;
			if (i == 0 || j == 0) dp[i][j] = 1;
			else {
				dp[i][j] = min(dp[i - 1][j - 1], min(dp[i][j - 1], dp[i - 1][j])) + 1;
			}
			ret = max(ret, dp[i][j]);
		}

	}
	return ret;
}

int main() {

	int n;

	while (cin >> n,n)
	{
		vector < vector<int> > vec(n, vector<int>(n));
		for (int i = 0; i < n; i++)
		{
			for (int j = 0; j < n; j++)
			{
				char c;
				cin >> c;
				if (c == '*')
				{
					vec[i][j] = 1;
				}
				else
				{
					vec[i][j] = 0;
				}
			}
		}
		cout << maxSquare(vec) << endl;
		vec.shrink_to_fit();
	}

	

	return 0;
}


Measured memory_bytes: 10716
#include<stdio.h>

int main(){
	char s[1000];
	int i = 0;
	scanf("%s",s);
	while(s[i]){
	if(s[i+1] == '\0'){
		if(s[i] == 's'){
			printf("%ses",s);
		}
		else{
			printf("%ss",s);
		}
	}
	i++;
	}
}
		

Measured memory_bytes: 1736
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};
fn main() {
    input! {//
        h1:i64,m1:i64,h2:i64,m2:i64,k:i64,
    }
    println!("{}", h2 * 60 + m2 - h1 * 60 - m1 - k);
}


Measured memory_bytes: 2116
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;

int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); }

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x[i]; }
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << "\n";


int main() {

    CIN(ll, R);
    CIN(ll, G);
    CIN(ll, B);
    CIN(ll, N);

    ll ans = 0;

    for (ll r = 0; r <= N/R+1; r++) {
        for (ll g = 0; g <= N/G+1; g++) {
            ll b1 = N - R * r - G * g;
            if ( b1 >= 0 && b1 % B ==0 ) {
                ans++;
            }
        }
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
import math,itertools,bisect,sys,copy,queue

def LI(): return [int(x) for x in sys.stdin.readline().split()]

V,E = LI()
q = queue.PriorityQueue()
for _ in range(E):
    s,t,w = LI()
    q.put((w,s,t))

g = [i for i in range(V)]
root = [[i] for i in range(V)]

ans = 0
while not q.empty():
    w, s, t = q.get()
    if g[s] == g[t]: continue
    ans += w
    if len(root[g[s]]) < len(root[g[t]]):
        s ,t = t, s
    g_t = g[t]
    for i in root[g_t]:
        g[i] = g[s]
    root[g[s]].extend(root[g_t])
    root[g_t] = []

print (ans)


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

dp = [[0] * (n + 1) for _ in range(n + 1)]

res = 0
for i in range(n - 1, -1, -1):
    for j in range(n - 1, i, -1):
        if s[i] == s[j]:
            dp[i][j] = dp[i + 1][j + 1] + 1
            # dp[i][j] = max(dp[i][j], dp[i + 1][j + 1] + 1)
        res = max(res, min(dp[i][j], j - i))
print(res)


Measured memory_bytes: 229896
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
using namespace std;
long input(){
  long x;
  cin>>x;
  return x;
}
int abs(int x){
  if(x>=0){
    return x;
  }else{
    return -x;
  }
}
int gcd(int x, int y){
	if(x<y){
    return gcd(y,x);
  }
  if(y==0){
    return x;
  }
  return gcd(y,x%y);
}



int main() {
  string S;
  cin>>S;
  if(S.size()>=4){
    if(S.at(0)=='Y'&&S.at(1)=='A'&&S.at(2)=='K'&&S.at(3)=='I'){
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
  }else{
    cout<<"No"<<endl;
  }





  
  
}

 



  
  
  


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a, b;
    cin >> a >> b;
    
    if (a < b) cout << "a < b" << endl;
    else if (a > b) cout << "a > b" << endl;
    else if (a == b) cout << "a == b" << endl;
    
}



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

#define INF 0x3f3f3f3f

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

int n;
vector<int> v;
int cnt;

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

	cin >> n;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		v.push_back(a);
	}

	for (int i = 0; i < n-1; i++) {
		if (v[i] == i+1) {
			swap(v[i], v[i+1]);
			cnt++;
		}
	}

	if (v[n-1] == n) {
		cnt++;
	}

	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include <string>
#include <vector>
#include <queue>

using namespace std;

struct process{

  string name;
  int time;

  process(){}
  process(string name, int time){
    this->name = name;
    this->time = time;
  }
};
int main(){

  int n;
  int q;

  cin >> n >> q;

  queue<process> que;

  for(int i = 0; i < n; i++){
    string name;
    int time;
    cin >> name >> time;
    process p(name, time);
    que.push(p);
  }
  /*//確認
  for(int i = 0; i < n; i++){//queは先頭か後尾にしかアクセスできない！！！！！！！！！！！
    cout << que.front().name << " " << que.front().time << '\n';
    que.pop();
  }
*/
  vector<process> ans;
  int time = 0;//経過時間

  while(que.size()){
    if(que.front().time - q <= 0){
      time += que.front().time;
      process p(que.front().name, time);
      ans.push_back(p);
      que.pop();
    }
    else{
      process p = que.front();
      p.time -= q;
      que.pop();
      que.push(p);
      time += q;
    }
  }

  for(int i = 0; i < ans.size(); i++){
    cout << ans[i].name << " " << ans[i].time << '\n';
  }

  return 0;
}



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

int main() {
	int S, h, m, s;
	cin >> S;
	h = S / 3600;
	m = (S % 3600) / 60;
	s = (S % 3600) % 60;
	cout << h << ":" << m << ":" << s << endl;
	
}



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

using namespace std;

int main(){
  int k, t;
  cin >> k >> t;
  vector<int> a(t);
  for(int i = 0;i < t;i++){
    cin >> a[i];
  }

  if(t == 1){
    cout << a[0] - 1 << endl;
    return 0;
  }


  sort(a.begin(), a.end(), greater<int>());
  while(a[1] != 0){
    a[0]--;
    a[1]--;
    sort(a.begin(), a.end(), greater<int>());
  }

  if(a[0] != 0){
    a[0]--;
  }
  cout << a[0] << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import re

def solve(S: str):
    pattern = "A[a-z][a-z]*C[a-z]+"
    if re.fullmatch(pattern, S):
        print("AC")
    else:
        print("WA")

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    S = str(input())
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include<stdio.h>
int main(){
  int n, k, h, ans = 0;
  scanf("%d %d", &n, &k);
  for(int i = 0; i < n; ++i){
    scanf("%d", &h);
    if(h >= k) ans++;
  }
  printf("%d\n", ans);
  return 0;
}

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

using namespace std;

#define int long long
int const maxn = 305;
int mod = 998244353;
int dp[maxn][maxn][maxn][2][2];

main() {
#ifdef HOME
    freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    int k, n = (int)s.size();
    cin >> k;
    k = min(k, n);
    s = "#" + s;
    dp[0][0][0][0][0] = 1;
    for (int i = 1; i <= n; ++i) {
        if (s[i] == '0') {
            for (int del = 0; del <= k; ++del) {
                int cur = 0;
                for (int bal = 0; bal <= n; ++bal) {
                    cur = (cur + dp[i - 1][bal][del][0][0]) % mod;
                    dp[i][bal][del][0][0] = cur + dp[i - 1][bal][del][1][1] + dp[i - 1][bal][del][0][1];
                }
            }
        }
        else {
            if (s[i - 1] == '0') {
                for (int bal = 0; bal <= n; ++bal) {
                    for (int del = 0; del <= k; ++del) {
                        dp[i][bal][del + 1][1][1] += dp[i - 1][bal + 1][del][0][0];
                        dp[i][bal][del][0][0] += dp[i - 1][bal][del][0][0];
                    }
                }
            }
            else {
                for (int bal = 0; bal <= n; ++bal) {
                    for (int del = 0; del <= k; ++del) {
                        dp[i][bal][del + 1][1][1] += dp[i - 1][bal + 1][del][1][1];
                        dp[i][bal][del][0][1] += dp[i - 1][bal][del][0][1] + dp[i - 1][bal][del][1][1];
                        dp[i][bal][del][0][0] += dp[i - 1][bal][del][0][0];
                    }
                }
            }
        }
        for (int bal = 0; bal <= n; ++bal) {
            for (int del = 0; del <= k; ++del) {
                for (int s = 0; s <= 1; ++s) for (int t = 0; t <= 1; ++t) dp[i][bal][del][s][t] %= mod;
            }
        }
    }
    int ans = 0;
    for (int d = 0; d <= k; ++d) ans += dp[n][0][d][0][0] + dp[n][0][d][0][1] + dp[n][0][d][1][1];
    cout << ans % mod << '\n';
    return 0;
}



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

void main() {
  int N = readln.chomp.to!(int);
  int[] a = readln.chomp.split.to!(int[]);

  sort(a);
  int cnt = 1, now = a[0];
  int ans;
  for (int i = 1; i < N; i++) {
    if (now == a[i]) {
      cnt++;
    }
    else {
      if (now <= cnt) {
        ans += cnt - now;
      }
      else {
        ans += cnt;
      }
      now = a[i];
      cnt = 1;
    }
  }
  if (now <= cnt) {
    ans += cnt - now;
  }
  else {
    ans += cnt;
  }

  writeln(ans);
}


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

bool a[99];

int main(){

  int n;

  for(int i=0;i<28;i++){
    cin >> n;
    a[n] = true;
  }
  
  for(int i=1;i<31;i++){
    if(!a[i]) cout << i << endl;
  }

}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 10;
int n,a[maxn];
int main() {
	scanf("%d",&n);
	bool f = true;
	for (int i = 1; i <= n; i++) {
		scanf("%d",&a[i]);
		if (a[i] % 2 == 0 && a[i] % 3 != 0 && a[i] % 5 != 0)
			f = false;
	}
	if (f) puts("APPROVED");
	else puts("DENIED");
}

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

int main(){
  int W, H;
  cin>>W>>H;

  int x, y, r;
  cin>>x>>y>>r;

  if(x - r >= 0 && y - r >= 0 && x + r <= W && y + r <= H)
    cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}



Measured memory_bytes: 3104
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>

#define rep(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)

using namespace std;
typedef long long int ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef priority_queue<int> PQI;
typedef priority_queue<int,vector<int>,greater<int> > PQSI;
typedef priority_queue<ll> PQL;
typedef priority_queue<ll,vector<ll>,greater<ll> > PQSL;

const int MOD = 1000000007;
struct mint { int n; mint(int n_ = 0) : n(n_) {} };
mint operator-(mint a) { return -a.n + MOD * (a.n != 0); }
mint operator+(mint a, mint b) { int x = a.n + b.n; return x - (x >= MOD) * MOD; }
mint operator-(mint a, mint b) { int x = a.n - b.n; return x + (x < 0) * MOD; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
istream &operator>>(istream &i, mint &a) { return i >> a.n; }
ostream &operator<<(ostream &o, mint a) { return o << a.n; }

vector<mint> F_{1, 1}, R_{1, 1}, I_{0, 1};
void check_fact(int n) {
  for (int i = I_.size(); i <= n; i++) {
    I_.push_back(I_[MOD % i] * (MOD - MOD / i));
    F_.push_back(F_[i - 1] * i);
    R_.push_back(R_[i - 1] * I_[i]);
  }
}

mint I(int n) { check_fact(abs(n)); return n >= 0 ? I_[n] : -I_[n]; }
mint F(int n) { check_fact(n); return n < 0 ? 0 : F_[n]; }
mint R(int n) { check_fact(n); return n < 0 ? 0 : R_[n]; }
mint C(int n, int r) { return F(n) * R(n - r) * R(r); }
mint P(int n, int r) { return F(n) * R(n - r); }
mint H(int n, int r) { return n == 0 ? (r == 0) : C(n + r - 1, r); }

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T>
T gcd(T x, T y){
    if (y == 0) return x;
    else return gcd(y, x % y);
}

template<typename T>
T lcm(T x, T y){
    return (x / gcd(x, y)) * y;
}

int K, X;
int main(void){
    cin >> K >> X;
    for(int i=max(X-(K-1), -1000000);i<=min(X+(K-1),1000000);i++)
        cout << i << " ";
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
import sys
input = sys.stdin.readline

import math

def main():
    a,b,h,m = map(int, input().split())

    x = abs((h*30+(m/2)) - m*6)

    if x == 0 or x== 360:
        print(abs(a-b))
    elif x == 180:
        print(a+b)
    else:


        rad = math.radians(x)

        ans_2 = a*a + b*b - 2*a*b*(math.cos(rad))

        print(math.sqrt(ans_2))

if __name__ == '__main__':
    main()


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

int main() {
    int d, t, s;
    cin >> d >> t >> s;
    cout << (d <= t * s ? "Yes" : "No") << '\n';
    return 0;
}


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

using namespace std;

int main() {
	cin.sync_with_stdio(false);
	int W, H, N;
	cin >> W >> H >> N;
	vector<int>x(N), y(N), a(N);
	for (int i = 0;i < N;i++) {
		cin >> x[i] >> y[i] >> a[i];
	}
	int xmax=W, xmin=0, ymax=H, ymin=0;
	for (int i = 0;i < N;i++) {
		if (a[i] == 1) {
			xmin = max(xmin, x[i]);
		}
		if (a[i] == 2) {
			xmax = min(xmax, x[i]);
		}
		if (a[i] == 3) {
			ymin = max(ymin, y[i]);
		}
		if (a[i] == 4) {
			ymax = min(ymax, y[i]);
		}
	}
	if (xmax - xmin > 0 && ymax - ymin > 0) {
		cout << (xmax - xmin)*(ymax - ymin) << endl;
	}
	else {
		cout << 0 << endl;
	}
	return 0;


}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int i = sc.nextInt();
        if(i == 3 || i == 5 || i == 7) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}

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

using namespace std;
int main() {
	vector<string>VS{ "Opened by ","Closed by ","Unknown " };
	set<string>SS;
	int N;
	cin >> N;
	for( size_t i = 0; i < N; i++ ) {
		string S;
		cin >> S;
		SS.insert( S );
	}
	cin >> N;
	bool x = 0;
	for( size_t i = 0; i < N; i++ ) {
		string S;
		cin >> S;
		if( SS.end() == find( SS.begin(), SS.end(), S ) ) {
			cout << VS[2] << S << endl;
		} else {
			cout << VS[x] << S << endl;
			x = 1 - x;
		}
	}
	return 0;
}

Measured memory_bytes: 3208
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(int argc, char const *argv[]) {
  int n;
  std::cin >> n;
  std::vector<int> v;;

  for (size_t i = 0; i < n; i++) {
    int c;
    std::cin >> c;
    v.push_back(c);
  }

  std::sort(v.begin(), v.end());

  int center = n / 2;

  std::cout << v[center] - v[center - 1] << '\n';
  // std::cout << v[center] << v[center-1] << '\n';
  return 0;
}


Measured memory_bytes: 892
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<string>
using namespace std;
#define INFTY 1<<21

int main() {
  int x;
  int ans = 0;
  int i = 0;
  cin >> x;
  while(x>ans){
	i++;
	ans += i;
  }
  cout << i << endl;
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;  // 2次元配列
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
//    cout << fixed << setprecision(15);

    i64 t1, t2, a1, a2, b1, b2;
    cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;

    i64 d1 = (b1-a1)*t1, d2 = (b2-a2)*t2;  // d1, d2 は非ゼロである
    i64 mov = d1+d2;

    if(mov == 0) {
        cout << "infinity" << '\n';
        return 0;
    }

    if(d1 < 0) {
        d1 *= (-1);
        d2 *= (-1);
        mov *= (-1);
    }
    if(mov > 0) {
        cout << 0 << '\n';
    }
    else {
        mov *= (-1);
        i64 ans = d1/mov * 2 + (d1%mov? 1 : 0);
        cout << ans << '\n';
    }


    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


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

using namespace std;

int main(void) {
        int n, k;
        vector<int> val;
        cin >> n >> k;
        for (int i = 0; i < n; i++) {
                int tmp;
                cin >> tmp;
                val.push_back(tmp);
        }

        sort(val.begin(), val.end());
        int sum=0;
        for (int i = 0; i < k; i++) {
                sum += val[i];
        }

        cout << sum << endl;

        return 0;
}

Measured memory_bytes: 3608
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
A = readInts()
money = 1000
kabu = 0
for i in range(1,n):
    if A[i-1] < A[i]:
        kabu = money // A[i-1]
        money -= kabu * A[i-1]
        money += kabu * A[i]
        kabu = 0
    #print(money,kabu)
print(money)


Measured memory_bytes: 76912
#include <bits/stdc++.h>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}
int main(void){
    int n;
    string s;
    cin>>n>>s;
    vector<ll> l(n+1),r(n+1);
    rep(i,1,n){
        if(s[i-1]=='W')l[i]=l[i-1]+1;
        else l[i]=l[i-1];
    }
    for(int i=n-2;i>=0;i--){
        if(s[i+1]=='E') r[i]=r[i+1]+1;
        else r[i]=r[i+1];
    }
    ll ans=INF;
    rep(i,0,n){
        ans=min(ans,l[i]+r[i]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5380
import collections
def prime_factorize(n):
	list = []
	while n % 2 == 0:
		list.append(2)
		n //= 2
	f = 3
	while f * f <= n:
		if n % f == 0:
			list.append(f)
			n //= f
		else:
			f += 2
	if n != 1:
		list.append(n)
	return list

A, B = map(int, input().split())
while A % B != 0:
	A, B = B, A % B
G = B
c = collections.Counter(prime_factorize(G))
print(len(list(c.keys())) + 1)

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

#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()

#define pb(x) push_back(x)

using namespace std;
using ll=long long;

ll mod=1000000007;

const ll INF = 1LL << 60;

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


int main() {
  ll n;cin >> n;
  ll cnt=0;
  while(n>0){
    n=n/2;
    cnt++;
  }

  ll ans=(ll)pow(2,cnt)-1;
  cout <<ans;
}

Measured memory_bytes: 256
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
using namespace std;
typedef long long ll;
int a[100000+100];
int b[100000+100];
ll my_max(ll c,ll d)
{
	return c>d?c:d;
}
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
	sort(a,a+n);
	int ls=n/2;
	ll sum=abs(a[n-1]-a[0]);
	for(int i=1;i<ls;i++)
	{
		ll e,b,c,d;
		e=a[i-1];
		b=a[i];
		d=a[n-i];
		c=a[n-1-i];
		sum+=(ll)(abs(c-e)+abs(d-b));
	} 
	if(n%2==1)
	{
		int z=n/2;
		sum+=my_max(abs(a[z]-a[z+1]),abs(a[z]-a[z-1]));	
	}
	printf("%lld\n",sum);
	return 0;
 } 

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N;
        public long[] A;

        public void Run()
        {
            N = Input.ReadInt();
            A = Input.ReadLongArray();

            for (int i = 0; i < N; i++)
            {
                A[i] -= (1 + i);
            }

            Array.Sort(A);
            int m = N / 2;
            long b = A[m];

            long ret = 0;
            for (int i = 0; i < N; i++)
                ret += Math.Abs(A[i] - b);

            Console.WriteLine(ret);
        }
    }

    // libs ----------
    

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1LL<<60;
const int MINF = 1e9;
const int MOD = 1e9+7;

using vi = vector<int>;
using vii = vector<vi>;

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

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

int main(){
    char s[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;cin >> k;
    cout << (int)s[k-1] << endl;
    return 0;
}

Measured memory_bytes: 256
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""
 
def main():
  n = int(input())
  H = list(map(int,input().split()))
  cnt = 1
  for i in range(1,n):
    flag = True
    for j in range(0,i+1):
      if H[j] > H[i]:
        #print(i,j)
        flag = False
        break
    if flag:cnt+=1
  print(cnt)
if __name__ == '__main__':
  main()

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cout << (#x) << ": " << (x) << endl
#define DEBUG_VEC(v)            \
    cerr << #v << ": ";         \
    REP(__i, (v).size())        \
    cerr << ((v)[__i]) << ", "; \
    cerr << endl

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

int f(int x) {
    return ((x + 9) /10) * 10;
}

int main()
{
    ios::sync_with_stdio(false);
    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;

    int x = 10;
    vi xs {a, b, c, d, e};
    REP(i, 5) {
        int tmp = xs[i] % 10;
        if (tmp > 0) x = min(x, tmp);
    }
    x = 10 - x;
    cout << f(a) + f(b) + f(c) + f(d) + f(e) - x << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		while(s.hasNextInt()) {
			int h = s.nextInt();
			int w = s.nextInt();
			if(h == 0 && w == 0) return;
			for(int i = 0; i < h; ++i) {
				for(int j = 0; j < w; ++j) {
					System.out.print('#');
				}
				System.out.println();
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 28736
#include <cstdio>
#include <algorithm>

using namespace std;
using ll = long long;

constexpr int MAXN = 222;
constexpr int INF = 5e8;
int n, m, r;
int order[MAXN];
ll dist[MAXN][MAXN];

int main() {
    scanf("%d %d %d", &n, &m, &r);
    for (int i = 0; i < r; ++i) {
        scanf("%d", order + i);
        --order[i];
    }

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            dist[i][j] = INF;
        }

        dist[i][i] = 0;
    }

    int u, v;
    ll w;
    for (int i = 0; i < m; ++i) {
        scanf("%d %d %lld", &u, &v, &w);
        --u; --v;
        dist[u][v] = dist[v][u] = min(dist[u][v], w);
    }

    for (int k = 0; k < n; ++k) {
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }

    sort(order, order + r);
    ll ans = 1e18;
    do {
        ll cur = 0LL;
        for (int i = 1; i < r; ++i) {
            cur = cur + dist[order[i - 1]][order[i]];
        }

        ans = min(ans, cur);
    } while (next_permutation(order, order + r));

    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 640
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <stdlib.h>
#include <stdio.h>
using namespace std;
using Graph = vector<vector<int>>;
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; }
const int INF = 1000000000;
const int MOD = 1000000007;

typedef pair<int, int> P;
int myAbs(int num) {
    if (num > 0)
        return num;
    else
        return -num;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

/*vector<bool> seen;
void dfs(const Graph& G, int v, int count) {
    seen[v] = true;
    count = 0;
    for (auto next_v : G[v]) {
        if (seen[next_v]) continue;
        if (count > 2) continue;
        count++;
        cout << count << ":" << next_v << endl;
        dfs(G, next_v, count);
    }
}*/

int main() {
    int K; cin >> K;
    vector<int> retu{ 1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51 };
    cout << retu.at(K - 1) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

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

int N;
string S,ans="";

int main(){
    cin>>N>>S;
    rep(i,S.size()){
        ans+=((S[i]-'A'+N)%26+'A');
    }
    out(ans);
    
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
int sum,n,b[200001];
signed main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&b[i]);
		sum^=b[i]; 
	}
	for(int i=1;i<=n;i++)
		cout<<(sum^b[i])<<" ";
	return 0;
}

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


int main(){    
    int s,w ;
    cin >> s >> w ;
    if (s > w)
    {
        cout << "safe" << endl ;
    }else
    {
        cout << "unsafe" << endl ;
    }
    
    
}

Measured memory_bytes: 3596
//do not think about past and stay in this moment
//organize and work - Abhinav IIITA
#include <bits/stdc++.h>
#include <ctime>
using namespace std;
#define int long long
#define ld long double
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end() 
const ld pi = acos(-1.0);
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int mod;
int Arr[100005];
void seive(){
		Arr[0]=Arr[1]=1;
		for(int i=2;i<100005;++i){
			if(Arr[i]==0)
			for(int j=2*i;j<100005;j+=i)
			Arr[j]=1;
		}
}


bool isprime(int a){
	if(a<2)
	return false;
	if(a==2)
	return true;
	if(a%2==0)
	return false;
	for(int i=3;i*i<=a;i+=2)
	if(a%i==0)
	return false;
	return true;
}




// -----------------------------------------------------------------------


// -----------------------------------------------------------------------



void q1(){
	int k,x;
	cin>>k>>x;
	int pp=500*k;
	if(pp>=x)
	cout<<"Yes";
	else
	cout<<"No";	
}
// -----------------------------------------------------------------------


void q2(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	int ans=0;
	for(int i=0;i<=n-3;++i){
		if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')
		ans++;
	}
	cout<<ans;
}

// -----------------------------------------------------------------------

void q3(){
	int n;
	cin>>n;
	int c[n-1],s[n-1],f[n-1];
	for(int i=0;i<n-1;++i)
	cin>>c[i]>>s[i]>>f[i];
	int res[n];
	res[n-1]=0;
	for(int i=n-2;i>=0;--i){
		int t=s[i]+c[i];
		for(int j=i+1;j<n-1;++j){
			if(t<=s[j]){
				t=s[j];
				t+=c[j];
			}else{
				int next = (t+f[j]-1)/f[j];
				next*=f[j];
				t=next+c[j];
			}
		}
		res[i]=t;
	}
	for(int i=0;i<n;++i)
	cout<<res[i]<<endl;
}


// -----------------------------------------------------------------------

void q4(){
	seive();
	//cout<<Arr[23]<<endl;
	int ans[100005];
	ans[0]=0;ans[1]=0;ans[2]=0;
	for(int i=3;i<=100005;i+=2)
	{
		int num=i+1;
		num/=2;
		if(Arr[i]==0 && Arr[num]==0)
		ans[i]=1;
		else
		ans[i]=0;
	}
	//cout<<ans[3]<<endl;
	
	for(int i=1;i<100005;++i)
	ans[i]+=ans[i-1];
	//cout<<ans[7]<<endl;

	int q;cin>>q;
	while(q--){
		int l,r;
		cin>>l>>r;
		cout<<ans[r+1]-ans[l]<<endl;
		/*int cp=0;
		for(int i=l;i<=r;++i){
			int num=i+1;
			num/=2;
			if(i%2==1)
			if(isprime(i) && isprime(num))
			cp++;
		}
		cout<<cp<<endl;*/
	}
}

// -----------------------------------------------------------------------


int32_t main()
{
	mod=1e+7;
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); 	
	int t=1;
	//cin>>t;
	while(t--)
	q2();
	return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 8)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7
res = f_inf


def resolve():
    k = int(input())
    x = 7 % k
    s = set()
    i = 1
    while x not in s:
        if x == 0:
            print(i)
            break
        s.add(x)
        x = (x * 10 + 7) % k
        i += 1
    else:
        print(-1)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 77888
data = []
tmp = []
for x in range(0,1000000):
    a,b,c = map(int, input().split())
    if a==-1 and b==-1 and c==-1:
        break
    else:
        data.append((a,b,c))
for x in range(0,len(data)):
    tmp = list(data.pop(0))
    if tmp[0] == -1 or tmp[1] == -1 or tmp[0]+tmp[1] <30:
        print("F")
    elif 79< (tmp[0]+tmp[1]) :
        print("A")
    elif 64< (tmp[0]+tmp[1]) <80:
        print("B")
    elif 49<(tmp[0]+tmp[1])<65 or (29<(tmp[0]+tmp[1])<50 and  49<tmp[2]):
        print("C")
    else:
        print("D")
    tmp.clear()


Measured memory_bytes: 7756
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
#include <string>

using namespace std;

void solve();

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

void solve() {
    int N,P;
    cin >> N >> P;
    int A[N];
    for(int i = 0; i < N; i++) {
        cin >> A[i];
    }

    long long int dp[N+1][2];
    for(int i = 0; i < N+1; i++) {
        dp[i][0] = dp[i][1] = 0;
    }
    dp[0][0] = 1;
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < 2; j++) {
            dp[i+1][j] += dp[i][j];
            if((j + A[i]) % 2 == 0) {
                dp[i+1][0] += dp[i][j];
            } else {
                dp[i+1][1] += dp[i][j];
            }
        }
    }
    cout << dp[N][P] << endl;

    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
#pragma optimize("JARU SOSISONI")

using namespace std;

#define int long long
#define fast cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#define geometry cout.setf(ios::fixed); cout.precision(15);
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;

const int INF = 1e9 + 100;
const int MOD1 = 998244353;
const int MOD = 1e9 + 7;
const int N = 2e5 + 10;
const int nul = 0;
const int SIZE = 1e6 * 3;


signed main() {
#ifdef parasha
    freopen("A.in", "r", stdin);
#endif // parasha
    fast;
    int n;
    cin >> n;
    vector<int> a(n);
    for (int &i : a) cin >> i;
    int now = 1, ans = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] == now) now++;
        else if (a[i] > now) {
            ans += (a[i] - 1) / now;
        }
        now = max(now, 2ll);
    }
    cout << ans << endl;

}












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

int main() {
  
  string sA, sB, sC; cin >> sA >> sB >> sC;
  
  char tmp = 'a';
  
  while (true) {
    
    if (tmp == 'a') {
      
      if (sA == "") { cout << "A" << endl; return 0; }
      
      int sizeMemoA = sA.size(); tmp = sA.at(0);
      
      if (sizeMemoA == 1) sA = "";
      
      else sA = sA.substr(1, sizeMemoA - 1);
      
    }
    
    if (tmp == 'b') {
      
      if (sB == "") { cout << "B" << endl; return 0; }
      
      int sizeMemoB = sB.size(); tmp = sB.at(0);
      
      if (sizeMemoB == 1) sB = "";
      
      else sB = sB.substr(1, sizeMemoB - 1);
      
    }
    
    if (tmp == 'c') {
      
      if (sC == "") { cout << "C" << endl; return 0; }
      
      int sizeMemoC = sC.size(); tmp = sC.at(0);
      
      if (sizeMemoC == 1) sC = "";
      
      else sC = sC.substr(1, sizeMemoC - 1);
      
    }
    
  }
  
}

Measured memory_bytes: 3624
def swap(ary,start,target)
  tmp = ary[target]
  ary[target] = ary[start]
  ary[start] = tmp
  ary
end

ary = gets.chomp.split(" ")
ary = swap(ary,0,1)
ary = swap(ary,0,2)
puts ary.join(" ")

Measured memory_bytes: 1788
k = int(input())
n = 50
d = k // n
a = [d + i for i in range(n)]  # d*n operations
k = k % n
for i in range(k):
    a[i] += n
    for j in range(n):
        if j != i:
            a[j] -= 1
print(n)
print(' '.join(map(str, a)))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
long long counter;
counter=0;
long long counter2=0;
string S; cin>>S;
for(long long i=0; i<S.size();i++){
if(S.at(i)=='B'){
counter2++;}
else
counter+=counter2;}
cout<<counter<<endl;}

Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<algorithm>
#define mx 0x3f3f3f
using namespace std;
int main()
{
    int n,a[105],ans,sum;
    while(~scanf("%d",&n))
    {
        memset(a,0,sizeof(a));
        for(int i=0;i<n;i++)
            scanf("%d",&a[i]);
            sort(a,a+n);
        ans=mx;
       for(int i=a[0];i<=a[n-1];i++)
       {
           sum=0;
           for(int j=0;j<n;j++)
             sum+=(a[j]-i)*(a[j]-i);
            if(ans>sum)
                ans=sum;
       }
       printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define eps LDBL_EPSILON
#define moder 1000000007
#define double long double
#define INF LLONG_MAX/10000
#define P pair<int,int>
#define prique priority_queue
using namespace std;
int n;
string s[110];
int v[110];
vector<pair<string, int>> vec;
bool func(pair<string, int> a, pair<string, int> b) {
	if (a.first < b.first)return true;
	if (a.first == b.first && a.second > b.second)return true;
	return false;
}
signed main() {
	cin >> n;
	rep(i, n) {
		cin >> s[i] >> v[i];
		vec.push_back(make_pair(s[i],v[i]));
	}
	sort(vec.begin(), vec.end(), func);
	for (auto i : vec) {
		rep(j, n) {
			if (s[j] == i.first && v[j] == i.second) {
				cout << j + 1 << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <map>
#include <queue>
#include <tuple>
#include <math.h>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef tuple<int,int,int> P;


int main(){
    int A,B;
    cin >> A >> B;
    if(A>=10 || B>=10) cout << -1 << endl;
    else cout << A*B << endl;


    return 0;
}

Measured memory_bytes: 3620
#include<stdio.h>
#include<stdlib.h>
#define N 2000000
#define MAX 10000

void CountingSort(int *,int *,int);

int main(){
  int n,i; 
  int *A,*B;
  
  
  scanf("%d",&n);
  
  A = (int *)malloc(n * sizeof(int));
  B = (int *)malloc(n * sizeof(int));
  
  for(i=0; i<n; i++) scanf("%d",&A[i]);
  
  CountingSort(A,B,n);
  
  for(i=0; i<n-1; i++) printf("%d ",B[i]);
  printf("%d\n",B[i]);
  
  free(A);
  free(B);
  
  return 0;
}

void CountingSort(int *A,int *B,int k){
  int i;
  int C[MAX];
  
  for(i=0; i<MAX; i++) C[i]=0; 
  
  for(i=0; i<k; i++) C[A[i]]++;
  
  for(i=1; i<MAX; i++) C[i]+=C[i-1];
  
  for(i=k-1; i>=0; i--){
  C[A[i]]--;
    B[C[A[i]]] = A[i];

  }
}

Measured memory_bytes: 16504
import functools
N = int(input())
n_lis = sorted(list(map(int, input().split())), reverse=True)

while len(set(n_lis)) > 1:
    n_lis = sorted(n_lis)
    n_lis = [n_lis[0]] + [n_lis[i] % n_lis[0] for i in range(0, len(n_lis))]
    #print(n_lis)
    n_lis = [item for item in n_lis if item > 0]

print(min(n_lis))

Measured memory_bytes: 14980
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  ll N; cin >> N;
  vector<ll> T(N);
  vector<ll> A(N);
  rep(i,N) cin >> T[i] >> A[i];
  ll takahasi = 1;
  ll aoki = 1;
  rep(i,N){
    if(i==0){
      takahasi = T[i];
      aoki = A[i];
      continue;
    }
    ll lastT = takahasi;
    ll lastA = aoki;
    ll tt = max(takahasi/T[i], aoki/A[i]) * T[i];
    ll aa = max(takahasi/T[i], aoki/A[i]) * A[i];
    while(1){
      if(tt >= lastT && aa >= lastA){
        takahasi = tt;
        aoki = aa;
        break;
      }
      tt += T[i];
      aa += A[i];
    }
  }

  cout << takahasi + aoki << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;

int main(){

  string s;
  map<char,ll>mp;
  while(cin>>s){
    rep(i,0,s.size()){
      mp[(char)tolower(s[i])]++;
    }
  }

  for(char i='a';i<='z';i++){
    out(i<<" : "<<mp[i]);
  }


  return 0;
}



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

int imos[100100];

signed main() {

    int n, m;
    scanf("%d %d", &n, &m);
    for ( int i = 0; i < m; i++ ) {
        int l, r;
        scanf("%d %d", &l, &r);
        r++;
        imos[l]++;
        imos[r]--;
    }
    int cnt = 0;
    int now = 0;
    for ( int i = 1; i <= n; i++ ) {
        now += imos[i];
        if ( now == m ) cnt++;
    }
    printf("%d\n", cnt);

    return 0;
}

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

int check(vector<int> t){
  int res = 24;
  sort(t.begin(), t.end());
  t.erase(unique(t.begin(), t.end()), t.end());
  
  for(int i=0;i<t.size();++i){
    int diff = abs(t[i]-t[(i+1)%t.size()]);
    res = min(min(24-diff, diff), res);
  }
  
  if (res>12) return 0;
  return res;
}

signed main() {
  int n;cin>>n;
  vector<int> c(13,0);
  for(int i=0;i<n;++i){
    int f;cin>>f;
    ++c[f];
  }

  if(c[0]){
    cout<<0<<endl;
    return 0;
  }
  
  vector<int> single, db;
  for(int i=0;i<13;++i){
    if(c[i]>=3) {
      cout<<0<<endl;
      return 0;
    }
    else if(c[i]==2) db.push_back(i);
    else if(c[i]==1) single.push_back(i);
  }
  
  int ans = 0;
  vector<int> table;
  table.push_back(0);
  for(int i=0;i<db.size();++i){
    table.push_back(db[i]);
    if (db[i]!=12) table.push_back(24-db[i]);
  }
  
  if (single.size()==0) {
    ans = check(table);
  }
  
  for(int bit=0;bit<(1<<single.size());++bit){
    vector<int> p(single);
    for(int i=0;i<single.size();++i){
      if((bit>>i) & 1) {
        p[i] = 24 - p[i];
      }
    }

    vector<int> tt(table);
    for(int i=0;i<single.size();++i){
      tt.push_back(p[i]);
    } 
    ans = max(check(tt), ans);
  }

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


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

using namespace std;
#define ll long long

ll MOD = 1e9 + 7;

vector<ll> fac, inv, finv;
void COMinit(int m) {
    fac.resize(m);
    finv.resize(m);
    inv.resize(m);
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < m; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
ll COM(int n, int k) {
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    int X, Y;
    cin >> X >> Y;
    if((X + Y) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }
    int n = (X + Y) / 3;
    COMinit(X + Y);
    cout << COM(X - n + Y - n, X - n) << endl;
    return 0;
}

Measured memory_bytes: 50168
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    int N, P; cin >> N >> P;
    string S; cin >> S;
    Int ans = 0;
    if (P == 2 || P == 5) {
        for (int i = 0; i < N; i++) {
            if ((S[i] - '0') % P == 0) {
                ans += i + 1;
            }
        }
    } else {
        vector<int> P10(N);
        P10[0] = 1;
        for (int i = 1; i < N; i++) P10[i] = P10[i - 1] * 10 % P;
        vector<int> A(N + 1);
        A[N - 1] = (S[N - 1] - '0') % P;
        for (int i = N - 2; i >= 0; i--) {
            A[i] = ((S[i] - '0') * P10[N - 1 - i] + A[i + 1]) % P;
        }
        map<int, int> M;
        for (int i = 0; i <= N; i++) M[A[i]]++;
        for (int i = N; i >= 0; i--) {
            M[A[i]]--;
            ans += M[A[i]];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2452