akhauriyash/Code-Regression huggingface dataset:
#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; }

vector<bool> seen;

void dfs(const Graph& G, int v) {
    seen[v] = true; // v を訪問済にする

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) {
        if (seen[next_v]) continue; // next_v が探索済だったらスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

int abs_A(int num) {
    if (num > 0)
        return num;
    else
        return -num;
}

int abs_B(long long num, long long numb) {
    if (num - numb >= 0)
        return num - numb;
    else
        return -1 * (num - numb);
}

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

bool permutation(vector<int>& vec, vector<int>& P) {
    bool ok = true;
    for (int i = 0; i < vec.size(); i++) {
        //cout << vec.at(i);
        if (vec.at(i) != P.at(i)) {
            ok = false;
        }
    }
    return ok;
}

/*bool nibu(vector<int>& retu,int key) {

}*/

const long long MOD = 1000000007;
const int INF = 1001001001;

int main() {
    vector <int> retu(10001);
    int count = 0;
    for (int i = 0; i < 10001; i++) {
        cin >> retu.at(i);
        if (retu.at(i) == 0) {
            count = i;
            break;
        }
    }
    for (int i = 0; i < count; i++) {
        cout << "Case " << i + 1 << ": " << retu.at(i) << endl;;
    }

    
}



Measured memory_bytes: 3048
N = int(input())
A = list(map(int,input().split()))
count = [0]*60
ans = 0
for i in A:
    for j in range(60):
        if (i >> j) & 1 == 1:
            count[j] += 1

time = 1
for i in count:
    ans += i*(N-i)*time
    time = time*2
print(ans%(10**9+7))



Measured memory_bytes: 122808
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
#include <iomanip>
#include<queue>
#include<algorithm>
#include <functional>
#include<vector>
#include <math.h>
using namespace std;

int main() {
	int A, P;
	cin >> A >> P;
	cout << (3 * A + P) / 2 << endl;
}

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

int main(void) {
	int h, w;
	char a[100][100];
	scanf("%d %d", &h, &w);
	for (int i = 0; i < h; ++i) {
		scanf("%s", a[i]);
	}

	//upper
	for (int i = 0; i < w+2; ++i) {
		printf("#");
	}
	printf("\n");

	//middle line
	for (int i = 0; i < h; ++i) {
		printf("#");
		for (int k = 0; k < w; ++k) {
			printf("%c", a[i][k]);
		}
		printf("#\n");
	}
	//low
	for (int i = 0; i < w+2; ++i) {
		printf("#");
	}

	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <unordered_map>

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	ll n;
	int Q;
	cin>>n>>Q;
	vector<ll> q;
	q.push_back(n);
	for(int i=0; i<Q; i++){
		ll q0; cin>>q0;
		while(!q.empty() && q.back()>=q0) q.pop_back();
		q.push_back(q0);
	}
	//map<ll, ll> mp[2];
	map<ll, ll> mp;
	mp[q.back()]=1;
	for(int i=q.size()-2; i>=0; i--){
		map<ll, ll> mp2;
		for(auto itr=mp.lower_bound(q[i]); itr!=mp.end(); itr++){
			mp2[itr->first%q[i]]+=itr->second;
			mp2[q[i]]+=(itr->first/q[i]*itr->second);
		}
		while(!mp.empty()){
			auto itr=mp.end(); itr--;
			if(itr->first<q[i]) break;
			mp.erase(itr);
		}
		for(auto p:mp2){
			mp[p.first]+=p.second;
		}
	}
	ll ans[100002]={};
	for(auto p:mp){
		ans[1]+=p.second;
		ans[p.first+1]-=p.second;
	}
	for(int i=1; i<=n; i++){
		ans[i]+=ans[i-1];
		cout<<ans[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 12404
#include <stdio.h>

int main(void){
    int N,K,n;
    char S[20];

    scanf("%d",&N);
    scanf("%s",S);
    scanf("%d",&K);

    for(n=0 ; n < N ; n++){
        if(S[n] != S[K-1]){
            S[n] = '*';
        }
    }
    printf("%s\n",S);
    return 0;
}


Measured memory_bytes: 128
#define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <climits>
#include <cmath>
#include <utility>
#include <iomanip>

using namespace std;
using ll = long long int;


int main(int argc, char *argv[])
{
	int a, b;

	//input
	cin >> a >> b;


	//calc
	vector<int> price_candidate;
	for (int i = 1; i < 1200; i++){
		int tax = floor((double)i * 0.08);
		if (tax == a){
			price_candidate.push_back(i);
		}
	}

	sort(price_candidate.begin(), price_candidate.end());

	int ans = -1;
	for (int i = 0; i < price_candidate.size(); i++){
		int tax = floor((double)price_candidate[i] * 0.1);
		if (tax == b){
			ans = price_candidate[i];
			break;
		}
	}


	//ans
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{

    private static void Sequence(int[] a){
        Map<Integer, Integer> sequence = new HashMap<Integer, Integer>();
        for(int i = 0; i < a.length; i++){
            if(!sequence.containsKey(a[i])){
                sequence.put(a[i], 1);
            }
            else{
                sequence.put(a[i], sequence.get(a[i]) + 1);
            }
        }
        int remove = 0;
        for(Integer key : sequence.keySet()){
            if(key > sequence.get(key)) remove += sequence.get(key);
            else if(sequence.get(key) > key) remove += sequence.get(key) - key;
        }
        System.out.println(remove);
    }

    public static void main(String[] args){
        Scanner input = new Scanner(System.in);
        int N = input.nextInt();
        int[] a = new int[N];
        for(int i = 0; i < N; i ++){
            a[i] = input.nextInt();
        }
        input.close();
        Sequence(a);
    }
}

Measured memory_bytes: 54704
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>

using namespace std;
typedef pair<int, int> P;


void solve()
{
	int N;
	cin >> N;
	string s, t;
	cin >> s;
	cin >> t;
	int ans = 2 * N;
	for (int i = 1; i <= N; ++i)
	{
		string sTemp = "";
		string tTemp = "";
		for (int j = 0; j < i; ++j)
		{
			sTemp += s[N - 1 - j];
			tTemp += t[j];
		}
		reverse(sTemp.begin(), sTemp.end());
		if (sTemp == tTemp)
		{
			ans = min(ans, 2 * N - i);
		}
	}
	cout << ans << endl;
}

int main()
{
	solve();
	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);
		long A= sc.nextLong();
		long B = sc.nextLong();
		long N = sc.nextLong();
		if (N==1) {
			System.out.println(A/B-A*(1/B));
			return ;
		}
		if (N>=B) {
			System.out.println(A*(B-1)/B-A*((B-1)/B));
		} else {
			System.out.println(A*N/B-A*(N/B));
		}
	}
}

Measured memory_bytes: 35576
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> PA;
typedef priority_queue<int, vector<int>, greater<int> > PQG;
#define REP(i, a, n) for(ll i = (ll) a;i < (ll) n;i++)
#define fi first
#define se second
#define pb push_back
#define INF 1000000009
#define MOD 1000000007
#define MAXN 40
#define MAXC 100000000000014
#define MAXV 1000000009

int a, b, c, d;
string s;

int main()
{
    cin >> s;
    a = s[0] - '0';
    b = s[1] - '0';
    c = s[2] - '0';
    d = s[3] - '0';

    if(a + b + c + d == 7){
        printf("%d+%d+%d+%d", a, b, c, d);
    }
    else if(a + b + c - d == 7){
        printf("%d+%d+%d-%d", a, b, c, d);
    }
    else if(a + b - c + d == 7){
        printf("%d+%d-%d+%d", a, b, c, d);
    }
    else if(a + b - c - d == 7){
        printf("%d+%d-%d-%d", a, b, c, d);
    }
    else if(a - b - c - d == 7){
        printf("%d-%d-%d-%d", a, b, c, d);
    }
    else if(a - b - c + d == 7){
        printf("%d-%d-%d+%d", a, b, c, d);
    }
    else if(a - b + c - d == 7){
        printf("%d-%d+%d-%d", a, b, c, d);
    }
    else if(a - b + c + d == 7){
        printf("%d-%d+%d+%d", a, b, c, d);
    }
    printf("=7\n");


    return 0;
}
/*
5 8
0 1 3
1 2 5
2 3 5
3 4 3
4 0 7
0 3 4
2 0 4
4 1 6
*/















Measured memory_bytes: 256
from itertools import permutations
N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
a = 0
b = 0
for i, perm in enumerate(permutations(list(range(1, N+1))), 1):
    if perm == P:
        a = i
    if perm == Q:
        b = i
    if a != 0 and b != 0:
        break
print(abs(a - b))


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

#define ull unsigned long long int
#define ll long long int
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define MOD (ull)(double)(1e9 + 7)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vs vector<string>
#define pull pair<ull, ull>
#define m_p make_pair
#define debug(x) cout << #x << " " << x << endl

const long double PI = 3.141592653589793238462643383279502884197169399;

// Find Set LSB = (x&(-x)), isPowerOfTwo = (x & (x-1))

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int tt=1;
	//cin >> tt;
	
	while(tt--){
		int n;
		cin >> n;
		
		vi a(n), ref(1e6+1, 0);
		for(int& x : a){
			cin >> x;
			ref[x]++;
		}
		
		vi vis(1e6+1);
		for(int i=0 ; i<1e6+1 ; ++i){
			if(ref[i] && !vis[i]){
				for(int j=2*i ; j<1e6+1 ; j += i){
					vis[j] = 1;
				}
			}
		}
		
		int cnt=0;
		for(int i=0 ; i<1e6+1 ; ++i){
			if(ref[i] == 1 && !vis[i])cnt++;
		}
		cout << cnt;
	}
}


Measured memory_bytes: 11912
#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;
//create array dp[][] v[] w[] n maxw
#define MAX (101)
#define MAX_2 (10000001) 
#define MAX_3 (MAX*MAX_2) 
#define INFTY (1<<25)
int *dp[2];
int v[MAX];
int w[MAX];
int n, maxw;
int op;
int solve() {
	//memset or fill
	//for i: 0 to n
	for (int i = 1; i<n + 1; ++i)
		//for j: 0 to MAX_N*MAX_V
		for (int j = 0; j<=op; ++j)
			//dp[i][j] = min(dp[i-1][j],dp[i-1][j-v[i]]+ w[i]);
			dp[i&1][j] = ((j - v[i]) >= 0) ? min(dp[(i - 1)&1][j], dp[(i - 1)&1][j - v[i]] + w[i]) : dp[(i - 1)&1][j];
	//result = for i: 0 tp MAX_N*MAX_V
	int result;
	for (int i = 0; i<=op; ++i) {
		// find the value<=maxw
		if (dp[n&1][i] <= maxw)result = i;
	}
	return result;
}
int main() {
	cin >> n >> maxw;
	int tmp = -1;
	int sum = 0;
	for (int i = 1; i <= n; ++i) {
		cin >> v[i] >> w[i];
		if (v[i]>tmp)tmp = v[i];
	}
	op = n * tmp;
	dp[0] = new int[op];
	dp[1] = new int[op];
	fill(dp[0], dp[0] + op + 1, INFTY);
	dp[0][0] = 0;
//	cout << 1 << endl;
	cout << solve() << endl;
	return 0;
}


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

double zet(double x) {
  if (x>0) {
    return x;
  }
  else {
    return -x;
  }
}

int main() {
  int N,T,A;
  cin >> N >> T >> A;
  vector<int> H(N);
  for (int i=0;i<N;i++) {
    cin >> H.at(i);
  }
  
  double min_gap=1000000;
  int m;
  for (int i=0;i<N;i++) {
    if (min_gap > zet(A-T+0.006*H.at(i))) {
      min_gap = zet(A-T+0.006*H.at(i));
      m = i;
    }
  }
  
  cout << m+1 << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>//////////////////////////////////////////
#define deb(...)/////////////////////////////////////////////////
#define DBP(...)/////////////////////////////////////////////////
#ifdef LOC///////////////////////////////////////////////////////
#include"debuglib.h"/////////////////////////////////////////////
#endif///////////////////////////////////////////////////////////
#define x first//////////////////////////////////////////////////
#define y second/////////////////////////////////////////////////
#define pb push_back/////////////////////////////////////////////
#define sz(x)int((x).size())/////////////////////////////////////
#define each(a,x)for(auto&a:(x))/////////////////////////////////
#define all(x)(x).begin(),(x).end()//////////////////////////////
#define rep(i,b,e)for(int i=(b);i<(e);i++)///////////////////////
using namespace std;using ll=long long;using Pii=pair<int,int>;//
using Vi=vector<int>;void run();int main(){cin.sync_with_stdio///
(0);cin.tie(0);cout<<fixed<<setprecision(18);run();return 0;}////
//-------------------------------------------------------------//

void run() {
	int h, w; cin >> h >> w;
	vector<string> board(h);
	each(r, board) cin >> r;

	vector<Vi> dist(h, Vi(w, -1));
	queue<Pii> que;
	int ans = 0;

	rep(i, 0, h) rep(j, 0, w) {
		if (board[i][j] == '#') {
			que.push({i, j});
			dist[i][j] = 0;
		}
	}

	auto relax = [&](int i, int j, int d) {
		if (dist[i][j] == -1) {
			dist[i][j] = d;
			que.push({i, j});
			ans = max(ans, d);
		}
	};

	while (!que.empty()) {
		Pii v = que.front();
		int d = dist[v.x][v.y]+1;
		que.pop();

		if (v.x > 0) relax(v.x-1, v.y, d);
		if (v.y > 0) relax(v.x, v.y-1, d);
		if (v.x+1 < h) relax(v.x+1, v.y, d);
		if (v.y+1 < w) relax(v.x, v.y+1, d);
	}

	cout << ans << '\n';
}


Measured memory_bytes: 13456
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int> > min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int mon[20]={31,28,31,30,31,30,31,31,30,31,30,31};
ll gcd(ll x,ll y){return ((y==0)?x:gcd(y,x%y));}
inline int read(){
	int x=0;char ch=getchar();
	while(ch<'0'||ch>'9')ch=getchar();
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x;
}
int n,x,cnt;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>x;
		if((x&1)&&(i&1))cnt++;
	}
	cout<<cnt;
	return 0;
}



Measured memory_bytes: 3564
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n = f()[0]

    if n == 1:
        print('Hello World')
    else:
        a = f()[0]
        b = f()[0]
        print(a+b)


solve()


Measured memory_bytes: 3060
//デバッグ消し忘れ再提出
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;

int n, a[101010], b[101010], c[101010];

int main(){
  cin >> n;
  rep(i, n){
    cin >> a[i];
  }
  rep(i, n){
    b[i] = c[i] = 0;
  }
  b[0] = a[0]; c[n - 1] = a[n - 1];
  for(int i = 1; i < n; i++){
    b[i] = __gcd(b[i - 1], a[i]);
  }
  for(int i = n - 2; i >= 0; i--){
    c[i] = __gcd(c[i + 1], a[i]);
  }
  //rep(i, n) cerr << b[i] <<" ";cerr << endl;
  //rep(i, n) cerr << c[i] << " "; cerr << endl;
  
  int res = 0;
  for(int i = 1; i < n - 1; i++){
    int tmp = __gcd(b[i - 1], c[i + 1]);
    res = max(tmp, res);
  }
  res = max(b[n - 2], res);
  res = max(c[1], res);
  
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1408
# cook your dish here
import sys
import math
# sys.stdin=open('input.txt','r')
# sys.stdout=open('output2.txt','w')
from sys import stdin,stdout
from collections import deque,defaultdict
from math import ceil,floor,inf,sqrt,factorial,gcd,log2
from copy import deepcopy
ii1=lambda:int(stdin.readline().strip())
is1=lambda:stdin.readline().strip()
iia=lambda:list(map(int,stdin.readline().strip().split()))
isa=lambda:stdin.readline().strip().split()
mod=1000000007
# print('hi')
n,m,k=iia()
arr=[input()for i in range(n)]
res=0
for i in range(2**n):
    for j in range(2**m):
        ans=0
        for ii in range(n):
            for jj in range(m):
                if i>>ii & 1 and j>>jj &1 and arr[ii][jj]=='#':
                    ans+=1
        if ans==k:
            res+=1
print(res)



Measured memory_bytes: 9608
def check_kaibun(s):
    return s == s[::-1]


S = input()
i = (len(S) - 1) // 2
j = (len(S) + 3) // 2
if check_kaibun(S) and check_kaibun(S[:i]) and check_kaibun(S[j - 1:]):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
import sys


def solve(A: int, B: int, C: int):
    if A - B < C:
        return C - (A - B)
    else:
        return 0


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    ans = solve(A, B, C)
    if ans is not None:
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <cassert>
#include <cstdio>
#include <vector>
#include <set>

#include <map>
#include <unordered_map>
#include <deque>
#include <string>
#include <utility>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <climits>

using namespace std;

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

const int INF = 1e9;
const long long LINF = 1e18;

int main() {
	int N, M;
	cin >> N >> M;

	if (N == M) {
        cout << "Yes" << endl;
    }
		else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
vector<int>Col(100005);
struct Edge {
	int to, id;
	Edge(int to, int id) :to(to), id(id) {}
};
vector<Edge>g[100005];

void dfs(int v, int p = -1) {
	for (Edge e : g[v]) {
		if (p == e.to) {
			continue;
		}
		if( (0 == Col[v]&&0 == e.id)|| (1 == Col[v] && 1 == e.id)) {
			Col[e.to] = 0;
		}
		else{
			Col[e.to] = 1;
		}
		dfs(e.to,v);
	}
}

int main() {
	int N;
	cin >> N;
	for (int n = 0; n < N - 1; ++n) {
		int u, v,w;
		cin >> u >> v >>w;
		u--;
		v--;
		g[u].emplace_back(v, w%2);
		g[v].emplace_back(u, w%2);
	}
	Col[0] = 0;
	dfs(0);
	for (int n = 0; n < N; ++n) {
		cout << Col[n] << endl;
	}
	return 0;
}

Measured memory_bytes: 10972
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) *b;
	//a*bは64bit integer overflow
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}


int main() {
	int n; cin >> n;
	cout << n / 3;


	cout << endl;
	return 0;
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    let s: String = read();
    let p: String = read();
    let ss = s.to_string() + &s;
    if ss.find(&p).is_some() {
        println!("Yes");
    } else {
        println!("No");
    }

}



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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(long long i=s;i<n;i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<vll> vvll;
const double pi = acos(-1.0);
const ll mod = pow(10,9) + 7;
const ll INF = pow(2,31) - 1;

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

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{
    ll n;
    cin >> n;
    set<string> dic;

    rep(i,n){
        string com,s;
        cin >> com >> s;
        if(com == "insert")dic.insert(s);
        else cout << ((dic.find(s) != dic.end())? "yes" : "no") << endl;
    }

    
    return 0;
}


Measured memory_bytes: 32140
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;

const ll MOD = 1e9 + 7;

int main(int argc, char const *argv[])
{
    int n, m;
    cin >> n >> m;
    map<int, int> mp;
    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        mp[a]++;
        mp[b]++;
    }
    rep(i, n)
    {
        cout << mp[i] << endl;
    }
    return 0;
}


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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<char> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}

    mint &operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }

    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }

    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};


int main() {
    int n;
    cin >> n;
    vector<ll> numbers(n);
    rep(i, n)cin >> numbers[i];

    vector<int> pop_counts(61, 0);
    vector<int> zero_counts(61, 0);

    for (ll m : numbers) {
        for (ll j = 0; j <= 60; j++) {
            bool pop = ((m >> j) & 1);
            if (pop) {
                pop_counts[j]++;
            } else {
                zero_counts[j]++;
            }
        }
    }

    mint ans = 0;
    for (int i = 0; i < 61; i++) {
        mint s = mint(2).pow(i);
        int pc = pop_counts[i];
        int zc = zero_counts[i];
        mint now = s * pc * zc;
        ans += now;
    }

    cout << ans.x << endl;
}

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

#define int long long
#define ci(m)     for(int i=0;i<m;i++)
#define cj(m)     for(int j=0;j<m;j++)
#define ck(m)     for(int k=0;k<m;k++)
#define gcd            __gcd
#define endl           "\n"
#define pb             emplace_back
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define deci(x, y)      fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(NULL)
#define PI             3.141592653589793238
using namespace std;
set<int>s;
void solve(int i)
{
    if(i>10000000000)
        return ;
    s.insert(i);
    int last=i%10;
    if(last!=0)
    solve(i*10+last-1);
    solve(i*10+last);
    if(last!=9)
    solve(i*10+last+1);
}
int32_t main() {
    nitin;
    for(int i=1;i<=9;i++)
    {
        solve(i);
    }
    //cout<<s.size()<<endl;
    vector<int>v;
    for(auto c:s)
        v.push_back(c);
    int n;
    cin>>n;
    cout<<v[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 14572
//{{{
#include <bits/stdc++.h>
using namespace std;
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop,~))(__VA_ARGS__)
#define loop(n) rep2(_loop_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define repN(a) repX a
#define repX(a0,a1,a2,x,...) x
#define foreach(x,a) for(auto &x:a)
typedef long long ll;
const ll MOD = 1e9+7;
//}}}

int main(){
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  C *= 2;
  int ans = 0;
  ans = A * X + B * Y;
  ans = min(ans, max(X, Y) * C);
  ans = min(ans, X < Y ? (X * C + (Y - X) * B) : (Y * C + (X - Y) * A));
  cout << ans << endl;
  return 0;
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a;i<(int)b;++i)
int main(){
    int n;cin>>n;
    int minv=1e9;
    rep(i,n){
        int a;cin>>a;
        int tmp=0;
        while(a%2==0){
            a/=2;
            tmp++;
        }
        minv=min(minv,tmp);
    }
    cout<<minv<<endl;
    return 0;
}

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

int main() {
	
	int a,min=10000000,sa,i;
	
	while(1){
		cin >> a;
		
		if(a==0) break;
		
		int b[a];
		
		for(i=0;i<a;i++){
			cin >> b[i];
		}
		
		sort(b,b+a);
		
		for(i=0;i<a-1;i++){
			
			sa=b[i+1]-b[i];
			
			if(min>sa) min=sa;
			
		}
		
		cout << min << endl;
		min=10000000;
	}
	
	return 0;
}

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

using pii = pair<int, int>;
using vi = vector<int>;
using ll = long long;

int mypow(int x, int n) {
    int res = 1;
    while(n > 0) {
        if(n & 1) {
            res *= x;
        }
        x *= x;
        n >>= 1;
    }
    return res;
}

int calc(vector<int> const& v) {
    int res = 0;
    for(int i = 1; i < 3; ++i) {
        for(int j = 0; j < 15; ++j) {
            if(v[i] & (1 << j)) {
                res += i * mypow(3, j);
            }
        }
    }
    return res;
}

bool memo[30000000] = {};

int main() {
    int n, m;
    while(cin >> n >> m, n) {
        vi s(3);
        for(int i = 0; i < 3; ++i) {
            int k; cin >> k;
            for(int j = 0; j < k; ++j) {
                int x; cin >> x;
                s[i] |= (1 << x - 1);
            }
        }
        fill(begin(memo), end(memo), false);
        memo[calc(s)] = true;
        queue<pair<vi, int>> que;
        que.emplace(move(s), 0);
        int res = -1;
        while(!que.empty()) {
            auto now = move(que.front().first);
            int step = que.front().second;
            que.pop();
            if(step > m) {
                continue;
            }
            if(now[0] == (1 << n) - 1 || now[2] == (1 << n) - 1) {
                res = step;
                break;
            }
            for(int i = 0; i < 3; ++i) {
                if(now[i] == 0) {
                    continue;
                }
                for(int j = i - 1; j <= i + 1; j += 2) {
                    if(j < 0 || 3 <= j) {
                        continue;
                    }
                    int xi = (31 - __builtin_clz(now[i]));
                    if(now[j] == 0 || (31 - __builtin_clz(now[j])) < xi) {
                        now[j] |= (1 << xi);
                        now[i] ^= (1 << xi);
                        if(!memo[calc(now)]) {
                            memo[calc(now)] = true;
                            que.emplace(now, step + 1);
                        }
                        now[i] |= (1 << xi);
                        now[j] ^= (1 << xi);
                    }
                }
            }
        }
        cout << res << endl;
    }
}


Measured memory_bytes: 32400
#include "bits/stdc++.h"
using namespace std;
bool equals(string v, int ss){
    for(auto c:v) if(c != ss) return false;
    return true;
}
int main(){
    string s;
    cin >> s;
    int ans = 34485934;
    for(int e = 'a'; e <= 'z'; e++){
        string nova = s;
        int ptr = 0, ops = 0;
        while(!equals(nova, e)){
            string ntt;
            for(int f = 0; f < nova.length()-1; f++)
                if(nova[f] == e || nova[f+1] == e){
                    ntt.push_back(e);
                } else
                    ntt.push_back(nova[f]);
            nova = ntt;
            ops++;
        }
        ans = min(ans, ops);
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second

using namespace std;
typedef long long int64;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int s, w;
    cin >> s >> w;
    if (w >= s) {
        cout << "unsafe";
    }
    else cout << "safe";
    
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int n;
    cin>>n;
    cout<<800*n-(n/15)*200<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
int main() {
  ll N,W;
  cin >> N >> W;
  vector<ll> w(110);
  vector<ll> v(110);
  vector<vector<ll>> dp(110, vector<ll>(100100));
  for(ll i = 0;i<N;i++){
    cin >> w[i];
    cin >> v[i];
  }
  
  for(ll i = 0;i<N;i++){
    for(ll sum_w = 0;sum_w<=W;sum_w++){
        if(sum_w - w[i] >= 0){
        chmax(dp[i+1][sum_w],dp[i][sum_w-w[i]]+v[i]);
        }
        chmax(dp[i+1][sum_w],dp[i][sum_w]);
       }
     }
  
cout << dp[N][W]<<endl;
  
}

Measured memory_bytes: 87296
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int W, H;
		for (;;) {
			H = sc.nextInt();
			W = sc.nextInt();
			if (H == 0)
				break;
			for (int i = 0; i < H; i++) {
				for (int j = 0; j < W; j++) {
					if ((i+j)%2==0) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
				}
				System.out.println();
			}

			System.out.println();
		}
		sc.close();
	}
}


Measured memory_bytes: 34896
import java.util.*;

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

	while(sc.hasNext()){
	    String Roman = sc.next();

	    int ans = getNum(Roman);

	    System.out.println(ans);
	}
    }

    public static int getNum(String roman){
	int sum = 0;
	int a = 0;
	if(roman.length()>1){
	    a = getFigure(roman.substring(roman.length()-2,roman.length()-1));
	}
	int b = getFigure(roman.substring(roman.length()-1,roman.length()));
	sum = b;
	if(a<b){sum -= a;}
	if(a>=b){sum += a;}
	for(int i=roman.length()-3; i>=0; i--){
	    b = a;
	    if(i!=-1)a = getFigure(roman.substring(i,i+1));
	    if(a<b){sum -= a;}
	    if(a>=b){sum += a;}
	}
	return sum;
    }

    public static int getFigure(String num){
	if(num.equals("I")){return 1;}
	if(num.equals("V")){return 5;}
	if(num.equals("X")){return 10;}
	if(num.equals("L")){return 50;}
	if(num.equals("C")){return 100;}
	if(num.equals("D")){return 500;}
	if(num.equals("M")){return 1000;}
	return 0;
    }
}

Measured memory_bytes: 11000
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N;
map<string,ll> mp;
int main(){
    cin>>N;
    ll ma=0;
    for(ll i=0;i<N;i++){
        string s;
        cin>>s;
        mp[s]++;
        ma=max(mp[s],ma);
    }
    for(auto o:mp){
        if(o.second==ma){
            cout<<o.first<<endl;
        }
    }

    return 0;
}

Measured memory_bytes: 25216
/* C */
// ?????\??? P89

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

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

typedef struct pp
{
	char name[10];
	int time;
} P;

P Q[100001];

int head;
int tail;

//-------------------------------------------
void enque(P x){
	Q[tail] = x;
	tail = (tail+1)%100001;
}

//-------------------------------------------
P deque(void){
	P x = Q[head];
	head = (head + 1)%100001;
	return	x;
}

//-------------------------------------------
void exe( int q){
	int elaps = 0; //???????????????

	while( head != tail ){
		P x = deque();

		if(x.time - q <= 0){
			// ????????????
			elaps += x.time;
			printf("%s %d\n", x.name, elaps );
		}else{
			// ??????????????????????????£????????§??????????????????????????????
			elaps += q;
			x.time -= q;
			enque(x);
		}
	}
}

int main(int argc, char const *argv[])
{
	int loop;
	int n, q;
	head = 0;
	tail = 0;
	P x;

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

	for(loop = 0; loop < n; ++loop)
	{
		scanf("%s %d", x.name, &x.time);
		enque(x);
	}

	exe(q);

//	printf("========== END!! (^o^)/ ==========\n");

	return 0;
}

Measured memory_bytes: 2168
n = int(input())
b = list(map(int, input().split()))

a = []

for _ in range(n):
    a.append(list())

for index, value in enumerate(b):
    a[index].append(value)
    a[index + 1].append(value)

min_sum = sum([min(collection) for collection in a])

print(min_sum)


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

int main() {
  int N; cin >> N;
  vector<pair<pair<string, int>, int>> restaurant;
  for (int i = 0; i < N; i++) {
    string name;
    int score;
    cin >> name >> score;
    restaurant.push_back(make_pair(make_pair(name, score * -1), i + 1));
  }
  sort(restaurant.begin(), restaurant.end());
  for (auto r : restaurant) {
    cout << r.second << endl;
  }
}


Measured memory_bytes: 256
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys

while True:
    a, op, b = sys.stdin.readline().split()
    ai = int(a)
    bi = int(b)
    if op == '?':
        break
    elif op == '+':
        print(ai + bi)
    elif op == '-':
        print(ai - bi)
    elif op == '*':
        print(ai * bi)
    elif op == '/':
        print(ai // bi)
    else:
        raise ValueError





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

using namespace std;

const int MAXN = 5e5 + 10;
const int C = 26 + 1;
const int LOG = 19;

int n, nxt[MAXN][C], ss[MAXN][LOG];
string s;

bool check(int l, int r){
	for (int w = LOG - 1; ~w; w--)
		if (ss[l][w] != -1 && ss[l][w] <= r)
			l = ss[l][w];
	return l == r;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> s; n = s.size();
	memset(nxt, -1, sizeof(nxt));
	memset(ss, -1, sizeof(ss));
	for (int i = n-1; ~i; i--){
		nxt[i][s[i] - 'a'] = i+1;
		for (int w = s[i] - 'a'+1; w < C; w++){
			int t = nxt[i][w - 1];
			if (t >= n || t == -1) break;
			nxt[i][w] = nxt[t][w - 1];
		}
		for (int w = 0; w < s[i] - 'a'; w++){
			int t = nxt[i][C - 1];
			if (t == -1) break;
			nxt[i][w] = nxt[t][w];
		}
		ss[i][0] = nxt[i][C - 1];
	}

	for (int w = 1; w < LOG; w++)
		for (int v = 0; v < n; v++)
			if (~ss[v][w - 1])
				ss[v][w] = ss[ss[v][w - 1]][w - 1];
			else
				ss[v][w] = -1;
	
	int q;	cin >> q;
	while (q--){
		int l, r;	cin >> l >> r, l--;
		if (check(l, r))
			cout << "Yes\n";
		else
			cout << "No\n";
	}
	return 0;
}


Measured memory_bytes: 91164
N,M=map(int,input().split())
graph={i:[] for i in range(1,N+1)}
for _ in range(M):
    x,y=map(int,input().split())
    graph[x].append(y)
    graph[y].append(x)
visited=[False for i in range(N+1)]
par=[-1 for i in range(N+1)]
from collections import deque
d=deque()
visited[1]=True
d.append(1)
e=deque()
while d:
    while d:
        x=d.popleft()
        for node in graph[x]:
            if visited[node]==False:
                par[node]=x
                visited[node]=True
                e.append(node)
    if e:
        d=e
        e=deque()
    else:
        d=deque()
flag=True
for i in range(2,N+1):
    if par[i]<0:
        flag=False
        break
if flag:
    print("Yes")
    for i in range(2,N+1):
        print(par[i])
else:
    print("No")

Measured memory_bytes: 107804
n, t = map(int, input().split())
c = 10000
for i in range(n):
    tmp = input().split()
    if t >= int(tmp[1]):
        if int(tmp[0]) < c:
            c = int(tmp[0])
if c == 10000:
    print('TLE')
    exit()
else:
    print(c)

Measured memory_bytes: 9164
#include <stdio.h>
#include <math.h>
int main(void) {
    int x, b, p;
    scanf("%d", &x);
    
    while(x>0) {
        for(b=1; b<32; b++) {
            for(p=2; p<11; p++) {
                if(pow(b, p)==x) {
                    printf("%d\n", x);
                    return 0;
                }
            }
        }
        x--;
    }
    
    return 0;
}


Measured memory_bytes: 384
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args){

		solve_abc150_c();
	}
  
 	public static void solve_abc150_c(){

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		StringBuilder P = new StringBuilder();
		StringBuilder Q = new StringBuilder();

		for(int i=0;i<N;i++){
			P.append(sc.next());
		}

		for(int i=0;i<N;i++){
			Q.append(sc.next());
		}

		StringBuilder in	= new StringBuilder();
		String ans	= "";

		for(int i=1;i<=N;i++){
			in.append(i);
		}

		List<String> perm = new ArrayList<String>();
		//System.out.println(in.toString());

		solve_abc150_c_permutation(in.toString(), ans, perm);
		Collections.sort(perm);
		String Ps = P.toString();
		String Qs = Q.toString();
		int a = -1;
		int b = -1;

		for(int i=0;i<perm.size();i++){
			
			String tmp = perm.get(i);

			if(tmp.equals(Ps)){
				a = i;
			}
			
			if(tmp.equals(Qs)){
				b = i;
			}
		}

		System.out.println(Math.abs(a - b));

		sc.close();

	}

	public static void solve_abc150_c_permutation(String in, String ans, List<String> permutation){

		//if q.length <= 1
		if(in.length() <= 1){

			//return ans + q
			permutation.add(ans + in);
			//System.out.println(ans + in);
		}
		else{
			//for i=0~q.length-1
			for(int i=0;i<in.length();i++){
				//order(q.substring(0~i-1) + q.substring(i+1~end), ans + q.charAt(i))
				solve_abc150_c_permutation(in.substring(0,i) + in.substring(i+1), ans + in.charAt(i) , permutation);
			}
		}
	}
}

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

int main()
{   
    int n,m,X,Y;
    cin>>n>>m>>X>>Y;
    int x[n],y[m];
    for(int i=0;i<n;i++) cin>>x[i];
    for(int i=0;i<m;i++) cin>>y[i];
    
    sort(x,x+n);
    sort(y,y+m);
    
    if(y[0]>x[n-1] && y[0]>X && y[0]<=Y) cout<<"No War"<<endl;
    else cout<<"War"<<endl;
    

    
}


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

public class Main {
    public static void main(String[] args) {
        try (InputReader in = new InputReader(); PrintWriter out = new PrintWriter(System.out)) {
            new Main().solve(in, out);
            out.flush();
        }
    }

    void solve(InputReader in, PrintWriter out) {
        int n = in.nextInt();
        Shop[] shops = new Shop[n];
        for (int i = 0; i < n; i++) {
            String s = in.next();
            int p = in.nextInt();
            shops[i] = new Shop(s, p, i + 1);
        }

        Arrays.sort(shops);
        for (Shop s : shops) {
            out.println(s.index);
        }
    }
}

class Shop implements Comparable<Shop> {
    String name;
    int p;
    int index;

    Shop(String name, int p, int index) {
        this.name = name;
        this.p = p;
        this.index = index;
    }

    @Override
    public int compareTo(Shop o) {
        if (name.compareTo(o.name) == 0) {
            if (this.p == o.p) {
                return 0;
            } else if (this.p < o.p) {
                return 1;
            } else {
                return -1;
            }
        }

        return name.compareTo(o.name);
    }

    @Override
    public String toString() {
        return name + " " + p;
    }
}

class InputReader implements AutoCloseable {
    private final Scanner sc = new Scanner(System.in);

    String next() {
        return this.sc.next();
    }

    int nextInt() {
        return Integer.parseInt(this.sc.next());
    }

    long nextLong() {
        return Long.parseLong(this.sc.next());
    }

    double nextDouble() {
        return Double.parseDouble(this.sc.next());
    }

    @Override
    public void close() {
        this.sc.close();
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <math.h>
#define m 256
using namespace std;
int main(){
	int n;
	while(cin>>n){
		if(n==0) break;
		int ii[n+1],r[n+1],o[n+1];
		for(int i=1;i<=n;i++){
			cin>>ii[i];
		}
		int ss=16,aa=16,cc=16;
		float h,mh=100;
		for(int s=15;s>=0;s--){
			for(int a=15;a>=0;a--){
				for(int c=15;c>=0;c--){
					int oc[m];
					for(int i=0;i<m;i++){
						oc[i]=0;
					}
					h=0;
					r[0]=s;
					for(int i=1;i<=n;i++){
						r[i]=(a*r[i-1]+c)%m;
						o[i]=(r[i]+ii[i])%m;
						oc[o[i]]++;
					}
					for(int i=0;i<m;i++){
						if(oc[i]>0){
							float h1=oc[i],h2=n;
							h=h-(10*h1/h2)*log(h1/h2);
						}
					}
					if(h<mh){
						ss=s;
						aa=a;
						cc=c;
						mh=h;
					}
					else if(h==mh){
						if(s<ss||a<aa||c<cc){
							ss=s;
							aa=a;
							cc=c;
						}
					}
				}
			}
		}
		cout<<ss<<" "<<aa<<" "<<cc<<endl;
	}
    return 0;
}

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

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] canUse = new int[10];
		for (int i = 0; i < K; i++) {
			int tmp = sc.nextInt();
			canUse[tmp] = -1;
		}
		for (int i = N; i <= 100000; i++) {
			boolean judge = true;
			for (int j = 0; j < 10; j++) {
				if (canUse[j] == 0) {
					continue;
				}
				if (String.valueOf(i).contains(String.valueOf(j))) {
					judge = false;
					break;
				}
			}
			if (judge) {
				System.out.print(i);
				break;
			}
		}
	}
}

Measured memory_bytes: 37500
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <string>
#include <string.h>
#include <stack>
#include <queue>
#include <set>
using namespace std;

const int MAX_N=10000;
int c[6],s=0;

int main(){
	for(int i=0;i<6;i++) cin >> c[i];
	for(int i=0;i<6;i++){
		s += c[i] * (i?(i==1?5:(i==2?10:(i==3?50:(i==4?100:500)))):1);
		if(s>=1000){
			cout << 1 << endl;
			return 0;
		}
	}
	cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 3120
from collections import Counter
n = int(input())
can_use = Counter(input())
for _ in range(n-1):
    S = Counter(input())
    for k in "abcdefghijklmnopqrstuvwxyz":
        can_use[k] = min(can_use[k], S[k])
ans = []
for k, v in can_use.items():
    for _ in range(v):
        ans.append(k)
ans.sort()
print("".join(ans))


Measured memory_bytes: 39280
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template<int Modulo = MOD> struct Mint {
	Int val;
	constexpr Mint(Int v = 0) noexcept : val(v% Modulo) {
		if (val < 0) v += Modulo;
	}
	constexpr int getmod() { return Modulo; }
	constexpr Mint operator - () const noexcept { return val ? Modulo - val : 0; }
	constexpr Mint operator + (const Mint& r) const noexcept { return Mint(*this) += r; }
	constexpr Mint operator - (const Mint& r) const noexcept { return Mint(*this) -= r; }
	constexpr Mint operator * (const Mint& r) const noexcept { return Mint(*this) *= r; }
	constexpr Mint operator / (const Mint& r) const noexcept { return Mint(*this) /= r; }
	constexpr Mint& operator += (const Mint& r) noexcept {
		val += r.val;
		if (val >= Modulo) val -= Modulo;
		return *this;
	}
	constexpr Mint& operator -= (const Mint& r) noexcept {
		val -= r.val;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr Mint& operator *= (const Mint& r) noexcept {
		val = val * r.val % Modulo;
		return *this;
	}
	constexpr Mint& operator /= (const Mint& r) noexcept {
		Int a = r.val, b = Modulo, u = 1, v = 0;
		while (b) {
			Int t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % Modulo;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr bool operator == (const Mint& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const Mint& r) const noexcept {
		return this->val != r.val;
	}
	friend ostream& operator << (ostream& os, const Mint<Modulo>& x) noexcept {
		return os << x.val;
	}
	friend istream& operator >> (istream& is, Mint<Modulo>& x) noexcept {
		Int tmp; is >> tmp;
		x = Mint<Modulo>(tmp);
		return is;
	}
	friend constexpr Mint<Modulo> modpow(const Mint<Modulo>& a, Int n) noexcept {
		Mint res(1), tmp = a;
		while (n > 0) {
			if (n & 1) res *= tmp;
			tmp *= tmp;
			n >>= 1;
		}
		return res;
	}
};

using mint = Mint<>;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N;
	cin >> N;

	cout << N * N * N << "\n";


}

Measured memory_bytes: 256