akhauriyash/Code-Regression huggingface dataset:
/*
* @Author: Samson
* @Date:   2018-06-12 18:24:44
* @Last Modified by:   Samson
* @Last Modified time: 2018-06-13 12:48:59
*/
//   @URL : http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_12_A
#include<bits/stdc++.h>
#include<algorithm>
#include <cstdlib>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long LL;
const int MAXN = 1e2+10;

int p[MAXN],color[MAXN],a[MAXN][MAXN],t,n,d[MAXN];

int prim()
{
	int minv,u,v;
	memset(p,-1,sizeof p);
	memset(d,INF,sizeof d);

	d[2] = 0;
	int ans = 0;

	while(1)
	{
		minv = INF;
		u = -1;
		for(int i = 1; i <= n; ++i)
		{
			if(minv > d[i] && !color[i])
				minv = d[i],u = i;
		}
		if(u == -1)	break; //空集
		color[u] = 1; //从集合中删除
		for(int v = 1; v <= n; ++v)
		{
			if(!color[v] && a[u][v] != INF)
			{
				if(d[v] > a[u][v])
				{
					d[v] = a[u][v];
					p[v] = u;
				}
			}
		}
	}

	for(int i = 1; i <= n; ++i)
		if(p[i] != -1)
			ans += a[i][p[i]];
	return ans;
}

int main(void)
{
	ios::sync_with_stdio(false); 
	//cin.tie(0);
	cin>>n;
	for(int i = 1; i <= n; ++i)
	{
		for(int j = 1; j <= n; ++j)
		{
			cin>>t;
			a[i][j] = t==-1?INF:t;
		}
	}
	cout<<prim()<<'\n';
	return 0;
}


Measured memory_bytes: 3172
import java.util.*;

public class Main{

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

        // input
        int dmy = scan.nextInt();
        final int query = scan.nextInt();
        char[] input = scan.next().toCharArray();
        int[] counts = new int[100002];
        int count = 0;
        for(int i = 1; i < input.length; i++){
            if(input[i - 1] == 'A' && input[i] == 'C'){
                count++;
            }
            counts[i] = count;
        }
        
        // answer
        int[] answer = new int[query];
        for(int i = 0; i < query; i++){
            int left = scan.nextInt();
            int right = scan.nextInt();
            answer[i] = counts[right-1] - counts[left-1];
        }

        for(int i = 0; i < query; i++){
            System.out.println(answer[i]);
        }

    }
}

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

using namespace std;

int main() {
	int arr[5], k;
	string s = "Yay!";
	
	for (int i = 0; i < 5; i++) cin >> arr[i];
	cin >> k;
	
	for (int i = 0; i < 4; i++) {
		for (int j = 1; j < 5; j++) {
			if (arr[j] - arr[i] > k) s = ":(";
		}
	}
	
	cout << s;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
#include <numeric>
using namespace std;
int main(){
  	int N, digit, a, b, i;
    cin >> N;
    digit= log10(N)+1;
	b=0;
  	if(digit%2==0){ 
      for(i=0; digit>i; i=i+2){
      b=b+(9*pow(10.0, i));}
      cout<<b<<endl;
    }else{
      for(i=0; (digit-1)>i; i=i+2){
      b=b+(9*pow(10.0, i));}
      a=N-(pow(10.0, digit-1))+1;
      
      cout<<a+b<<endl;}
  

 
 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll>pi;
#define pb push_back
//ll adj[1001][1005];
vector<pi>adj[1005];
ll dist[1005];
#define mn -10000000000000
int main()
{
    ll n,m;cin>>n>>m;
    for(ll i=0;i<m;i++)
    {
        ll u,v,w;cin>>u>>v>>w;
//        adj[u][v]=w;
        adj[u].pb({w,v});
    }
//    bool cycle=false;
    bool cycle[1005];
    for(ll i=0;i<=n;i++)dist[i]=mn;
    dist[1]=0;
    for(ll i=0;i<n-1;i++)
    {
        for(ll j=1;j<=n;j++)
        {
            for(ll k=0;k<adj[j].size();k++)
            {
                ll chi=adj[j][k].second;
                ll cst=adj[j][k].first;
                if(dist[j]+cst>dist[chi])
                {
                    dist[chi]=dist[j]+cst;
                }
            }
        }
    }
    memset(cycle,0,sizeof cycle);
    for(int i=0;i<n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            for(int k=0;k<adj[j].size();k++)
            {
                ll chi=adj[j][k].second;
                ll cst=adj[j][k].first;
                if(dist[j]+cst>dist[chi])
                {
                    dist[chi]=dist[j]+cst;
                    cycle[chi]=true;
                }
            }
        }
    }
    if(cycle[n]==true)cout<<"inf"<<endl;
    else cout<<dist[n]<<endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<algorithm>
#include<functional>
#include<deque>
#include<string.h>
#include<ctype.h>
#include<time.h>
#include<stdlib.h>
using namespace std;
 
char c[85];
 
bool search_th(){
  bool f = false;
  for (int i = 0; i < strlen(c); i++){
    if ((c[i] == 't' && c[i+1] == 'h' && c[i+2] == 'e') ||
        (c[i] == 't' && c[i+1] == 'h' && c[i+2] == 'i' && c[i+3] == 's') ||
        (c[i] == 't' && c[i+1] == 'h' && c[i+2] == 'a' && c[i+3] == 't')){
          f = true;  break;
    }
  }
  return f;
}
 
int main(){
  while (cin.getline(c, sizeof(c))){
    while (1){
      if (search_th() == true){
        cout << c << endl;
        break;
      }
      for (int j = 0; j < strlen(c); j++){
        if (c[j] >= 'a' && c[j] <= 'y') c[j]++;
        else if (c[j] == 'z')                c[j] = 'a';
      }
    }
    for (int i = strlen(c); i < 85; i++){
      c[i] = '\0';
    }
  }
  return 0;
}


Measured memory_bytes: 3052
import sys
from collections import Counter


def input():
    return sys.stdin.readline().strip()


MOD = 10 ** 9 + 7


def main():
    N, K = map(int, input().split())
    ans = 0
    for k in range(K, N + 2):
        m = k * (k - 1) // 2
        M = k * (2 * N - k + 1) // 2
        a = (M - m + 1) % MOD
        ans += a
        ans %= MOD
    print(ans)


if __name__ == "__main__":
    main()


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

int main(void){

    int A, B, X;
    int result;

    //printf("Input A B X : \n");
    scanf("%d %d %d",&A,&B,&X);

    //printf("A;%d, B:%d, X:%d\n",A,B,X);

    if(A > X){
        result = 0;
    }else{
        if( (A+B) <= X){
            result =  0;
        }else{
            result = 1;
        }
    }

    if(result == 1){
        printf("YES\n");
    }else{
        printf("NO\n");
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 1e5
#define INF 1<<30
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S;
ll ans = 0;
int main() {
	cin >> H >> W;
	vector<vector<ll>>c(10, vector<ll>(10));
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> c[i][j];
		}
	}
	for (int k = 0; k < 10; k++) {
		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 10; j++) {
				c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
			}
		}
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> A;
			if (A != -1 && A != 1)ans += c[A][1];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
 
int main() {
	int A, B;
cin>>A>>B;
if(A>=1&&A<=13&&B>=1&&B<=13) {
if((A>B||A==1)&&(B!=1) ){
cout<<"Alice" ;
}else if((B>A||B==1)&&(A!=1) ) {
cout<<"Bob";
} else if(A==B) {
cout<<"Draw" ;
} 
 
 
} 
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N;
int C[1000], W[1000];
int WS[1000];
bool ok[1000][1000];
int dp[1001][1001];

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  rep(i, N) cin >> C[i] >> W[i];
  rep(i, N) {
    WS[i] = W[i];
    if (i > 0) WS[i] += WS[i-1];
  }
  rep(i, N) ok[i][i] = 1;
  for (int len=1; len<N; len++) {
    rep(l, N) {
      int r = l+len;
      if (r >= N) break;
      // [l, r]
      int sum = WS[r];
      if (l > 0) sum -= WS[l-1];
      bool f = false;
      if (ok[l+1][r] && sum <= C[l]+W[l]) f = true;
      else if (ok[l][r-1] && sum <= C[r]+W[r]) f = true;
      ok[l][r] = f;
    }
  }

  rep(i, N+1) rep(j, N+1) dp[i][j] = INF;
  dp[0][0] = 0;
  rep(i, N) {
    rep(j, N+1) dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
    rep(j, i+1) {
      if (ok[j][i]) dp[i+1][i+1] = min(dp[i+1][i+1], dp[i][j] + 1);
    }
  }
  cout << dp[N][N] << "\n";
  return 0;
}

Measured memory_bytes: 8092
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
ll n;
cin>>n;
ll arr[n];
for(int i=0; i<n;i++)
cin>>arr[i];
sort(arr, arr+n);
ll ans=0;
for(int i=0; i<n;i++)
for(int j=i+1; j<n;j++)
for(int k=j+1; k<n;k++)
     if(arr[i]!=arr[j] && arr[j] != arr[k] && arr[k] < arr[i] + arr[j]){
    //cout<<arr[i]<<' '<<arr[j]<<' '<<arr[k]<<endl;;
    ans++;
    }
         
cout<<ans;
}

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

ll T1, T2, A1, A2, B1, B2, ans=0, tmp=0;

signed main(){
    cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;
    if(A1*T1+A2*T2==B1*T1+B2*T2) {
        cout << "infinity" << endl;
        return 0;
    }
    if(A1>B1&&A2*T2+A1*T1>B2*T2+B1*T1||A1<B1&&A2*T2+A1*T1<B2*T2+B1*T1) {
        cout << 0 << endl;
        return 0;
    }
    ans = abs((A1-B1)*T1)/abs((A1-B1)*T1+(A2-B2)*T2);
    ans = 2*ans+1;
    //cout << ans << endl;
    if(abs((A1-B1)*T1)%abs((A1-B1)*T1+(A2-B2)*T2)==0) {
        ans--;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    string o,e; cin>>o>>e;
    int i=0,j=0;
    REP(k,o.size()+e.size()){
        if(k%2==0) cout<<o[i++];
        else cout<<e[j++];
    }
    cout<<endl;
}


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

using namespace std;

int main(){
  int m,n,a,b,sum, temp;
  int ans;
  priority_queue<int> que;

  while(1) {
    sum = 0;
    cin>>n>>m;

    if(n == 0 && m == 0){
      break;
    }

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

    for(int i = 1;i<=n;++i){
      b = que.top();
      que.pop();
      if(i % m != 0){
	sum += b;
      }
    }

    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 3120
#include <iostream>

using namespace std;

int main() {
    int x, a, b;
    cin >> x >> a >> b;
    int xa = abs(x - a);
    int xb = abs(x - b);
    if (xa < xb) {
        cout << "A\n";
    } else {
        cout << "B\n";
    }
}

Measured memory_bytes: 888
import math

class Dice:
    def __init__(self, top, south, east, west, north, bottom):
        self.top = top
        self.south = south
        self.east = east
        self.west = west
        self.north = north
        self.bottom = bottom

    def roll_east(self):
        tmp = self.top
        self.top = self.west
        self.west = self.bottom
        self.bottom = self.east
        self.east = tmp

    def roll_north(self):
        tmp = self.top
        self.top = self.south
        self.south = self.bottom
        self.bottom = self.north
        self.north = tmp

    def roll_south(self):
        tmp = self.top
        self.top = self.north
        self.north = self.bottom
        self.bottom = self.south
        self.south = tmp

    def roll_west(self):
        tmp = self.top
        self.top = self.east
        self.east = self.bottom
        self.bottom = self.west
        self.west = tmp

    def spin_left(self):
        tmp = self.north
        self.north = self.east
        self.east = self.south
        self.south = self.west
        self.west = tmp

    def check(self, south):
        for x in range(4):
            if south == self.south:
                print(self.east)
                return
            self.spin_left()

    def top_check(self, top, south):
        if top == self.top:
            self.check(south)
        elif top == self.south:
            self.roll_north()
            self.check(south)
        elif top == self.east:
            self.roll_west()
            self.check(south)
        elif top == self.west:
            self.roll_east()
            self.check(south)
        elif top == self.north:
            self.roll_south()
            self.check(south)
        elif top == self.bottom:
            self.roll_south()
            self.roll_south()
            self.check(south)


a, b, c, d, e, f = map(int, input().split())
dice = Dice(a, b, c, d, e, f)
num = int(input())
for x in range(num):
    top, south = map(int, input().split())
    dice.top_check(top, south)



Measured memory_bytes: 5668
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
int main(){
ll x,y,p,q,r;
cin>>x>>y>>p>>q>>r;
V<ll> ad(p),bd(q),cd(r);
priority_queue<ll,V<ll>,greater<ll>> a,b;
for(int i=0;i<p;i++)cin>>ad[i];
for(int i=0;i<q;i++)cin>>bd[i];
for(int i=0;i<r;i++)cin>>cd[i];
sort(all(ad),greater<ll>());
sort(all(bd),greater<ll>());
sort(all(cd),greater<ll>());
for(int i=0;i<x;i++)a.emplace(ad[i]);
for(int i=0;i<y;i++)b.emplace(bd[i]);
for(int i=0;i<r;i++){
    ll t=a.top(),u=b.top();
    if(cd[i]<=t&&cd[i]<=u)break;
    if(t>u){
        b.pop();
        b.emplace(cd[i]);
    }else{
        a.pop();
        b.emplace(cd[i]);
    }
}
ll ans=0;
while(a.size()){
    ans+=a.top();
    a.pop();
}while(b.size()){
    ans+=b.top();
    b.pop();
}
cout<<ans<<"\n";
}


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

int main(){
  int N;
  string S;
  cin >> N >> S;
  int64_t r=0;
  int64_t g=0;
  int64_t b=0;
  for(int i=0;i<N;i++){
    if(S.at(i)=='R'){
      r++;
    }else if(S.at(i)=='G'){
      g++;
    }else{
      b++;
    }
  }
  int64_t ans=r*g*b;
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      if(S.at(i)==S.at(j)){
        continue;
      }
      int k=2*j-i;
      if(k>=N){
        break;
      }
      if((S.at(i)!=S.at(k))&&(S.at(j)!=S.at(k))){
        ans--;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3612
import sys
sys.setrecursionlimit(300000)

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


K = I()
S = input()

if len(S) <= K:
    print(S)
else:
    print(S[:K] + '...')

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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
#define MOD 1000000007
typedef pair<li, li> PI;

int main(void)
{
	string s;
	cin >> s;
	li n = s.size();

	li cost[2] = {};
	rep(i, n) {
		if (i % 2 == s[i] - '0') {
			cost[0]++;
		} else {
			cost[1]++;
		}
	}
	cout << min(cost[0], cost[1]) << endl;

	return 0;
}

Measured memory_bytes: 512
//--- pA ---//
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main {
	public static void main (String[] args) throws java.lang.Exception {
		new Solution();
	}
}
class Solution {
	Reader reader;
	public Solution () {
		reader = new Reader();
		while (reader.hasNext()) {
			run_case();
		}
	}
	private void run_case() {
		int N = ni();
		// System.out.println("N = " + N);
		int res = (int)Math.ceil(1.0 * N / 2);
		System.out.println(res);
		return;
	}
	private int ni() {return Integer.parseInt(reader.next());}
	private String ns() {return reader.next();}
}

class Reader {
	BufferedReader br;
	StringTokenizer st;
	public Reader(){
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public String next() {
		if (st.hasMoreTokens()) return st.nextToken();
		try {
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return st.nextToken();
	}
	public boolean hasNext() {
		try {
			if (!st.hasMoreTokens() && !br.ready()) return false;
			else return true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}
}


Measured memory_bytes: 21460
a=65280; b=61680; c=52428; d=43690; e=65535
L = {el: 1 for el in [a, b, c, d, e, 0]}
for i in range(6):
    R = sorted(L.items(), key=lambda x: x[1])
    for p, l in R:
        if l < 16:
            L[p ^ e] = min(L.get(p ^ e, 16), l+1)
            if l+3 < 16:
                for q, r in R:
                    if l+r+3 <= 16:
                        L[p & q] = min(L.get(p & q, 16), l+r+3)
                        L[p ^ q] = min(L.get(p ^ q, 16), l+r+3)
                    else: break
        else: break
print(*(L[e & eval(s)] for s in open(0).read().replace(*"-~").replace(*"*&").replace(*"1e").split()[:-1]),sep='\n')

Measured memory_bytes: 7848
X,A,B = map(int,input().split())
N = int(input())
for i in range(N):
  word = input()
  if word == "nobiro":
    X = X + A
  elif word == "tidime":
    X = X + B
  elif word == "karero":
    X = 0
  
  if X < 0:
    X = 0
print(X)


Measured memory_bytes: 5600
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<ll> Vl;
typedef vector<int> Vi;
typedef pair<int, int> Pi;

#define INF   (1e9+7)
#define MAX_N (200000)
#define MAX_K (100000)
#define MAX_L (100000)

class UnionFind {
private:
  int par[MAX_N];
public:
  void init(int n) {
    for (int x = 0; x < n; x++) par[x] = x;
  }
  int find(int x) {
    return (par[x] == x)? x: par[x] = find(par[x]);
  }
  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x != y) par[y] = x;
  }
  bool same(int x, int y) {
    return find(x) == find(y);
  }
};

int N, K, L;
std::vector<int> GR[MAX_N], GT[MAX_N];
UnionFind UFR, UFT;
map<Pi, int> COUNTS;

int encode(int n, int m) {
  return (m + n) * (m + n + 1) / 2 + n;
}

void mapping(vector<int> *g, UnionFind &uf) {
  uf.init(N);
  for (int v = 0; v < N; v++) {
    if (uf.find(v) != v) continue;
    queue<int> q;
    q.push(v);
    while (!q.empty()) {
      int u = q.front(); q.pop();
      for (int i = 0; i < g[u].size(); i++) {
        int w = g[u][i];
        if (!uf.same(u, w)) {
          uf.unite(u, w);
          q.push(w);
        }
      }
    }
  }
}

void solve() {
  mapping(GR, UFR);
  mapping(GT, UFT);
  for (int v = 0; v < N; v++){
    Pi p = Pi(UFR.find(v), UFT.find(v));
    COUNTS[p] = COUNTS[p] + 1;
  }
  for (int v = 0; v < N; v++) {
    printf("%d ", COUNTS[Pi(UFR.find(v), UFT.find(v))]);
  }
  printf("\n");
}

int main() {
  scanf("%d %d %d", &N, &K, &L);
  for (int i = 0; i < K; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    u--; v--;
    GR[u].push_back(v);
    GR[v].push_back(u);
  }
  for (int i = 0; i < L; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    u--; v--;
    GT[u].push_back(v);
    GT[v].push_back(u);
  }


  solve();

  return 0;
}


Measured memory_bytes: 27940
n = int(input())

if n % 10 == 2 or n % 10 == 4 or n % 10 == 5 or n % 10 == 7 or n % 10 == 9:
    print("hon")

elif n % 10 == 0 or n % 10 == 1 or n % 10 == 6 or n % 10 == 8:
    print('pon')

else:
    print("bon")


Measured memory_bytes: 9108
#include<bits/stdc++.h>
#include <iostream>
#include <numeric>
#include <math.h>
#define ll  long long
#define ull unsigned long
#define mpa make_pair
#define pb push_back
#define ff first
#define pii pair<ll,ll>
#define dd double
#define trace(x) cerr << #x << " : " << x << endl
#define ss second
#define boost ios_base::sync_with_stdio(0)
#define forp(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n)    for(ll i=0;i<n;++i)
#define ren(i,n)    for(ll i=n-1;i>=0;i--)
#define forn(i,a,b) for(ll i=a;i>=b;i--)
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end();
#define sc(x) scanf("%lld",&x)
#define clr(x,val) memset(x,val,sizeof(x))
#define pr(x) printf("%lld\n",x) 
#define gc getchar
#define pdd pair<dd,dd>
#define prec(x) cout<<fixed<<setprecision(x)
using namespace std;
ll a[2000005];
int main(){
	
    ll n,k;
    vector<char> sol;

    cin>>n;
    ll su=0;
    for(ll i=1;i<=n;i++){
    	cin>>a[i];
    	su^=a[i];
	}
	for(ll i=1;i<=n;i++){
		cout<<(su^a[i])<<" ";
	}
}
    


	
	
    



Measured memory_bytes: 5176
from collections import deque

def receive():
    v = input()
    return v.split(' ')

input_val = receive()
n = int(input_val[0])
q = int(input_val[1])
tasks = deque([])
time_total = 0

for _ in range(n):
    input_val = receive()
    name = input_val[0]
    time = int(input_val[1])
    tasks.append({"name": name, "time": time})

while len(tasks) > 0:
    current_task = tasks.popleft()
    if current_task["time"] <= q:
        time_total += current_task["time"]
        print(current_task["name"] + ' ' + str(time_total))
    else:
        current_task["time"] -= q
        time_total += q
        tasks.append(current_task)


Measured memory_bytes: 21144
//#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>

using namespace std;

#define ll long long

void solve()
{
    ll N;
    cin >> N;
    vector<ll> A(N);
    for (ll i = 0; i < N; i++)
    {
        cin >> A.at(i);
    }

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

    for (ll i = 1; i < N; i++)
    {
        if (A.at(i) == A.at(i - 1))
        {
            cout << "NO" << endl;
            return;
        }
    }

    cout << "YES" << endl;
    return;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <sstream>
#include <math.h>
#include <cstring>
#include <algorithm>
#include <queue>
using namespace std;
const long long INF = 1LL<<60;
//for (int i = 0; i < N; i++){}
const int MAX_N = 110;
const int MAX_V = 100100;

int N, W;
long long w[MAX_N], v[MAX_N];
long long dp[MAX_N][MAX_V];

int main() {
    cin >> N >> W;
    for (long long i = 0; i < N; i++){
        cin >> w[i] >> v[i];
    }

    for (int i = 0; i < MAX_N; i++){
        for (int j = 0; j < MAX_V; j++){
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;

    for (long long i = 0; i < N; i++){
        for (long long tot = 0; tot <= MAX_V; tot++){
            if(tot >= v[i]){
                dp[i+1][tot] = min((dp[i][tot]), (dp[i][tot - v[i]] + w[i]));
            }else{
                dp[i+1][tot] = dp[i][tot];
            }
        }
    }

    long long res = 0;
    for (int sum_v = 0; sum_v < MAX_V; sum_v++) {
        if (dp[N][sum_v] <= W){
            res = sum_v;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 86272
a,b,k=map(int,input().split())
lisa=[]
lisb=[]
for i in range(1,a+1):
  if a%i==0:
    lisa.append(i)
for j in range(1,b+1):
  if b%j==0:
    lisb.append(j)
for l in range(max(a,b)+1):
  l=max(a,b)+1-l
  if l in lisb and l in lisa and k>0:
    k-=1
    if l in lisb and l in lisa and k==0:
      print(l)
      break

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
using i64 = int64_t;

int main()
{
    string s;
    cin >> s;

    bool flg = s[2] == s[3] && s[4] == s[5];

    cout << (flg ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=200020,mod=998244353;
#define lson o<<1,l,mid
#define rson o<<1|1,mid+1,r
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define MEM(x,v) memset(x,v,sizeof(x))
inline int read(){
	int x=0,f=0;char ch=getchar();
	while(ch<'0' || ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
	return f?-x:x;
}
int n,k,el,head[maxn],to[maxn*2],nxt[maxn*2],l[maxn],r[maxn],p[maxn],ans[maxn],q[maxn],fr,ba;
int dep[maxn],fa[maxn],sz[maxn],son[maxn],top[maxn],dfn[maxn],cnt;
int stk[maxn],tp,el2,head2[maxn],to2[maxn*2],nxt2[maxn*2],rt,fa2[maxn];
bool isp[maxn];
inline void add(int u,int v){
	to[++el]=v;nxt[el]=head[u];head[u]=el;
}
inline void add2(int u,int v){
	to2[++el2]=v;nxt2[el2]=head2[u];head2[u]=el2;
}
inline bool cmp(int x,int y){return dfn[x]<dfn[y];}
void dfs1(int u,int f){
	dep[u]=dep[fa[u]=f]+1;
	sz[u]=1;
	for(int i=head[u];i;i=nxt[i]){
		int v=to[i];
		if(v==f) continue;
		dfs1(v,u);
		sz[u]+=sz[v];
		if(sz[v]>sz[son[u]]) son[u]=v;
	}
}
void dfs2(int u,int topf){
	top[u]=topf;dfn[u]=++cnt;
	if(son[u]) dfs2(son[u],topf);
	for(int i=head[u];i;i=nxt[i]){
		int v=to[i];
		if(v==fa[u] || v==son[u]) continue;
		dfs2(v,v);
	}
}
int lca(int u,int v){
	while(top[u]!=top[v]){
		if(dep[top[u]]<dep[top[v]]) swap(u,v);
		u=fa[top[u]];
	}
	return dep[u]<dep[v]?u:v;
}
void dfs3(int u){
	for(int i=head2[u];i;i=nxt2[i]){
		int v=to2[i];
		fa2[v]=u;
		dfs3(v);
		int ll=l[v]-(dep[v]-dep[u]),rr=r[v]+(dep[v]-dep[u]);
		if(isp[u]){
			if(abs(r[u])%2!=abs(rr)%2) puts("No"),exit(0);
		}
		else l[u]=-1e9,r[u]=1e9;
		l[u]=max(l[u],ll);r[u]=min(r[u],rr);
		if(l[u]>r[u]) puts("No"),exit(0);
		isp[u]=true;
	}
}
void dfs4(int u){
	for(int i=head2[u];i;i=nxt2[i]){
		int v=to2[i];
		l[v]=max(l[v],l[u]-(dep[v]-dep[u]));
		r[v]=min(r[v],r[u]+(dep[v]-dep[u]));
		dfs4(v);
	}
}
int main(){
	n=read();
	FOR(i,1,n-1){
		int u=read(),v=read();
		add(u,v);add(v,u);
	}
	k=read();
	FOR(i,1,k) isp[p[i]=read()]=true,l[p[i]]=r[p[i]]=read();
	dfs1(1,0);dfs2(1,1);
	sort(p+1,p+k+1,cmp);
	int tmpk=k;
	FOR(i,1,k-1) p[++tmpk]=lca(p[i],p[i+1]);
	k=tmpk;
	sort(p+1,p+k+1,cmp);k=unique(p+1,p+k+1)-p-1;
	FOR(i,1,k){
		while(tp && !(dfn[stk[tp]]<=dfn[p[i]] && dfn[stk[tp]]+sz[stk[tp]]-1>=dfn[p[i]])) tp--;
		if(tp) add2(stk[tp],p[i]);
		stk[++tp]=p[i];
	}
	rt=p[1];
	dfs3(rt);dfs4(rt);
	FOR(i,1,k) ans[p[i]]=l[p[i]];
	ROF(i,k,2){
		int cnt=dep[p[i]]-dep[fa2[p[i]]],dif=ans[p[i]]-ans[fa2[p[i]]];
		int cntp=(cnt+dif)/2,cntn=(cnt-dif)/2;
		int tmp=p[i];
		FOR(j,1,cntp) ans[fa[tmp]]=ans[tmp]-1,tmp=fa[tmp],isp[tmp]=true;
		FOR(j,1,cntn) ans[fa[tmp]]=ans[tmp]+1,tmp=fa[tmp],isp[tmp]=true;
	}
	fr=1;ba=0;
	FOR(i,1,n) if(isp[i]) q[++ba]=i;
	while(fr<=ba){
		int u=q[fr++];
		for(int i=head[u];i;i=nxt[i]){
			int v=to[i];
			if(isp[v]) continue;
			isp[v]=true;
			ans[v]=ans[u]+1;
			q[++ba]=v;
		}
	}
	puts("Yes");
	FOR(i,1,n) printf("%d\n",ans[i]);
}

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

N, A, B = map(int, input().split())
X = list(map(int, input().split()))

ans = 0

for i in range(len(X) - 1):
    if (X[i + 1] - X[i]) * A > B:
        ans += B
    else:
        ans += (X[i + 1] - X[i]) * A

print(ans)


Measured memory_bytes: 14168
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long long int llint;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
ll Q,H,S,D;
ll N;
int main(){
    cin >> Q >> H >> S >> D >> N;
    ll mxli = min(4*Q, min(2*H, S));
    if(mxli*2 <= D){
        cout << N*mxli << endl;
        return 0;
    } else {
        if(N % 2 == 0){
            cout << (N/2)*D << endl;
            return 0;
        } else {
            cout << (N/2)*D + mxli << endl;
            return 0;
        }
    }
}

 

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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  int64_t h;
  cin >> h;
  
  // 1 + 2 + 2*2 + 2^3 ... + 2^n
  
  int count = 0;
  while(h>0){
    h /= 2;
    count++;
  }
  
  int64_t totalCount = 0;
  int64_t currentTwoPow = 1;

  for(int i = 0; i<count;i++){
    totalCount += currentTwoPow;
    currentTwoPow *= 2;
  }
  cout << totalCount << endl;
  return 0;
}


Measured memory_bytes: 3676
n = int(input())
cn = []
sn = []
fn = []
for i in range(n-1):
    ci, si, fi = map(int, input().split())
    cn.append(ci)
    sn.append(si)
    fn.append(fi)

ans = [0] * n

for i in range(n-1):
     c = cn[i]
     s = sn[i]
     f = fn[i]
     ans[i] += s + c
     t = ans[i]
     for j in range(i+1, n-1):
        c2 = cn[j]
        s2 = sn[j]
        f2 = fn[j]
        if s2 <= t and t % f2 == 0:
            w = 0
        elif s2 > t:
            w = s2 - t
        else:
            w = f2 - (t % f2)
        ans[i] += w+c2
        t = ans[i]

for i in ans:
    print(i)

Measured memory_bytes: 3188
#!/usr/bin/env python3
import sys
input = sys.stdin.readline

n = int(input())
lsd = n % 10

if lsd in [2, 4, 5, 7, 9]:
    print("hon")
elif lsd in [0, 1, 6, 8]:
    print("pon")
else:
    print("bon")

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

const int N = 1e6 + 100, M = 13;

int v[N], w[N];

vector<pair<int,int>> pre[1<<M];

int main() {
    // freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> v[i] >> w[i];
    }
    int till = min(1<<M, n+1);
    pre[0].push_back({0,0});
    for(int i = 1; i < min(n+1, 1<<M); i++) {
        int p = i/2;
        vector<pair<int,int>> A = pre[p], B = pre[p];
        for(int j = 0; j < B.size(); j++) {
            B[j].first += w[i];
            B[j].second += v[i];
        }
        vector<pair<int,int>> opts;
        merge(A.begin(), A.end(), B.begin(), B.end(), back_inserter(opts));
        int mx = -1;
        for(auto t : opts) {
            if(t.second <= mx) continue;
            mx = t.second;
            pre[i].push_back(t);
        }
    }
    int q;
    cin >> q;
    while(q--) {
        int u, L;
        cin >> u >> L;
        if(u < till) {
            int idx = lower_bound(pre[u].begin(), pre[u].end(), make_pair(L,(int)1e9)) - pre[u].begin() - 1;
            assert(idx >= 0);
            cout << pre[u][idx].second << "\n";
        }
        else {
            vector<pair<int,int>> alls;
            while(u >= till) {
                alls.push_back({v[u], w[u]});
                u /= 2;
            }
            int sz = alls.size();
            int best = 0;
            for(int mask = 0; mask < (1<<sz); mask++) {
                int tot_w = 0, tot_v = 0;
                for(int k = 0; k < mask; k++) {
                    if((mask>>k) & 1) {
                        tot_v += alls[k].first;
                        tot_w += alls[k].second;
                    }
                }
                if(tot_w > L) continue;
                int idx = lower_bound(pre[u].begin(), pre[u].end(), make_pair(L-tot_w,(int)1e9)) - pre[u].begin() - 1;
                assert(idx >= 0);
                int cur = pre[u][idx].second + tot_v;
                best = max(best, cur);
            }
            cout << best << "\n";
        }
    }
    return 0;
}



Measured memory_bytes: 282668
#include<cstdio>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<fstream>
using namespace std;
int main()
{
	long long n,ans=2;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		ans=(ans+1)*2;
	}
	cout<<ans<<endl;
	return 0;
}

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

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

  std::vector<int> d;
  for (int i = 0; i < n; ++i) {
    int td;
    std::cin >> td;
    d.push_back(td);
  }

  std::sort(d.begin(), d.end());
  int low = d[d.size() / 2 - 1];
  int high = d[d.size() / 2];

  std::cout << high - low << std::endl;
}

Measured memory_bytes: 892
l=tuple(input())
for i in range(8):
    c=1
    s=list(l)
    for j in range(3):
        s.insert(j+c,"+-"[(i>>j)&1::2])
        c+=1
    a="".join(s)
    if eval(a)==7:
        print(a+"=7")
        exit()

Measured memory_bytes: 38384
n = int(input())
A = list(map(int,input().split()))
L = [False]*8
cnt = 0
for a in A:
  if 1 <= a <= 399:
    L[0] = True
  elif 400<=a<=799:
    L[1] = True
  elif 800<=a<=1199:
    L[2] = True
  elif 1200<=a<=1599:
    L[3] = True
  elif 1600<=a<=1999:
    L[4] = True
  elif 2000<=a<=2399:
    L[5] = True
  elif 2400<=a<=2799:
    L[6] = True
  elif 2800<=a<=3199:
    L[7] = True
  else:
    cnt += 1
if cnt == n:
  print(1, n)
else:
  print(sum(L),sum(L)+cnt)

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

using namespace std;

int main()
{
  int n, a[50], total = 0;
  
  cin>>n;
  
  for(int i = 0; i < n; i++)
    cin>>a[i];
  
  for(int i = 0; i < n; i++)
    for(int j = i+1; j < n; j++)
      total += a[i]*a[j];

  cout<<total<<endl;
  
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
typedef pair<LL, LL> P;
const LL INF = 1LL << 60;
const LL MOD = 1000000007LL;
LL distS[100000];
LL distT[100000];
vector<int> orderS;
vector<int> orderT;
int r_orderS[100000];
int r_orderT[100000];
LL dpS[100000];
LL dpT[100000];
vector<P> G[100000];
bool vis[100000];
int N, M;
void dijkstra(int v, LL *dist) {
	priority_queue<P, vector<P>, greater<P>> Q;
	fill(vis, vis + N, 0);
	fill(dist, dist + N, INF);
	dist[v] = 0;
	Q.push(P(0, v));
	while (!Q.empty()) {
		P p = Q.top(); Q.pop();
		if (dist[p.second] != p.first) continue;
		for (P e : G[p.second]) {
			int to = e.first;
			int d = e.second;
			if (dist[to] > dist[p.second] + d) {
				dist[to] = dist[p.second] + d;
				Q.push(P(dist[to], to));
			}
		}
	}
}
void topo_sort(int v, LL *dist, vector<int> &order) {
	vis[v] = 1;
	for (P x : G[v]) {
		int to = x.first;
		LL d = x.second;
		if (dist[v] + d == dist[to] && !vis[to]) topo_sort(to, dist, order);
	}
	order.push_back(v);
}
void route_count(LL *dp, LL *dist, vector<int> &order, int *r_order) {
	dp[0] = 1;
	for (int i = 0; i < N; i++) {
		int v = order[i];
		for (P x : G[v]) {
			int to = x.first;
			LL d = x.second;
			if (dist[v] + d == dist[to]) (dp[r_order[to]] += dp[i]) %= MOD;
		}
	}
}
int main() {
	cin >> N >> M;
	int S, T;
	cin >> S >> T; S--; T--;
	for (int i = 0; i < M; i++) {
		int U, V, D;
		cin >> U >> V >> D;
		U--; V--;
		G[U].push_back(P(V, D));
		G[V].push_back(P(U, D));
	}
	dijkstra(S, distS);
	dijkstra(T, distT);
	fill(vis, vis + N, 0);
	for (int i = 0; i < N; i++) {
		if (!vis[i]) topo_sort(i, distS, orderS);
	}
	reverse(orderS.begin(), orderS.end());
	for (int i = 0; i < N; i++) r_orderS[orderS[i]] = i;
	fill(vis, vis + N, 0);
	for (int i = 0; i < N; i++) {
		if (!vis[i]) topo_sort(i, distT, orderT);
	}
	reverse(orderT.begin(), orderT.end());
	for (int i = 0; i < N; i++) r_orderT[orderT[i]] = i;
	route_count(dpS, distS, orderS, r_orderS);
	route_count(dpT, distT, orderT, r_orderT);
	LL ans = 0;
	for (int i = 0; i < N; i++) {
		for (P x : G[i]) {
			int to = x.first;
			LL d = x.second;
			if (distS[i] + d + distT[to] == distS[T] && abs(distS[i] - distT[to]) < d) {
				LL tmpS = (dpS[r_orderS[i]] * dpS[r_orderS[i]]) % MOD;
				LL tmpT = (dpT[r_orderT[to]] * dpT[r_orderT[to]]) % MOD;
				LL tmp = (tmpS*tmpT) % MOD;
				(ans += tmp) %= MOD;
			}
		}
		if (distS[i] == distT[i] && distS[i] + distT[i] == distS[T]) {
			LL tmpS = (dpS[r_orderS[i]] * dpS[r_orderS[i]]) % MOD;
			LL tmpT = (dpT[r_orderT[i]] * dpT[r_orderT[i]]) % MOD;
			LL tmp = (tmpS*tmpT) % MOD;
			(ans += tmp) %= MOD;
		}
	}
	LL total = (dpS[r_orderS[T]] * dpS[r_orderS[T]]) % MOD;
	cout << (total - ans + MOD) % MOD << endl;
}

Measured memory_bytes: 21924
import collections

import sys
a = []
for l in sys.stdin:
    a.append(l.rstrip('\n'))
cc = collections.Counter(a)
print("AC x {}".format(cc["AC"]))
print("WA x {}".format(cc["WA"]))
print("TLE x {}".format(cc["TLE"]))
print("RE x {}".format(cc["RE"]))

Measured memory_bytes: 74780
use std::io;

fn main() {
    let mut buf = String :: new();
    io::stdin().read_line(&mut buf).expect("Failed");
    let mut iter = buf.split_whitespace();
    let x: usize = iter.next().unwrap().parse().unwrap();
    let a: usize = iter.next().unwrap().parse().unwrap();

    if x < a {
        println!("0");
    } else {
        println!("10");
    }
}


Measured memory_bytes: 4352
#include <stdio.h>
int main(void){
    int X, M, i, p, q;
    scanf("%d", &X);
    M=1;
    for (i=2; i<=31; i++){
        p=i*i; q=i;
        while (p<=X) {
            if (p>M) M=p;
            p*=q;
        }
    }
    printf("%d", M);
    return 0;
}


Measured memory_bytes: 128
import sys
input = sys.stdin.readline
from heapq import *


n, m = map(int, input().split())
tmp = [ [] for _ in range(10 ** 5 + 1) ]
for _ in range(n):
    a, b = map(int, input().split())
    tmp[a].append(b)

h = []
ans = 0
for i in range(1, m+1):
    for bb in tmp[i]:
        heappush(h, -bb)
    if h:
        ans += -heappop(h)
print(ans)

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

// 約数列挙
vector<ll> divisor(ll N) {
    vector<ll> res;
    for (ll i = 1L; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            ll j = N / i;
            if (j != i)  {
                res.push_back(j);
            }
        }
    }
    sort(res.begin(), res.end());
    return res;
}

// void Main() {
//     ll N; cin >> N;
//     vector<ll> A(N); rep(i, N){cin >> A.at(i);}
//     ll cnt = 0;
//     rep(i, N){
//         vector<ll> res = divisor(A.at(i)); // 約数群
//         bool flag = true;
//         rep(j, N){
//             if (i == j){continue;}
//             if (binary_search(res.begin(), res.end(), A.at(j))){
//                 flag = false; break;
//             };
//         }
//         if (flag){cnt++;}
//     }
//     cout << cnt << endl;
// }


void Main() {
    ll N; cin >> N;
    vector<ll> A(N); rep(i, N){cin >> A.at(i);}
    // set<ll> Aset(A.begin(), A.end());,
    map<ll, ll> m;
    for (auto a: A){
        if (m.find(a) != m.end()){m[a]++;}else{m[a] = 1;}
    }

    ll cnt = 0;
    rep(i, N){
        vector<ll> res = divisor(A.at(i)); // 約数群
        bool flag = true;
        rep(j, res.size()){
            ll num = res.at(j);
            if (j == res.size() - 1){
                if (m.find(num) != m.end() && m[num] > 1){flag = false;}
            } else {
                if (m.find(num) != m.end()){flag = false;}
            }
        }
        if (flag){cnt++;}
    }
    cout << cnt << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


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

using namespace std;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define show(x) cerr << #x << x << endl

typedef long long ll;
typedef unsigned long long ull;

constexpr const int INT_INF=0x3f3f3f3f; // 1061109567
constexpr const ll LL_INF=0x3f3f3f3f3f3f3f3f; // 4557430888798830399

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

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

// INT
#define GCD(a, b) __gcd(a, b)
template <typename T> T LCM(T a, T b) {return a / GCD(a, b) * b;}
template <typename T> T EXTGCD(T a, T b, T& x, T& y) {
    T d = a;
    if (b != 0) {d=EXTGCD(b,a%b,y,x);y-=(a/b)*x;}
    else x=1,y=0;
    return d;
}
template <typename T> bool is_prime(T a) {
    for(int i=2;i*i<=a;i++)if(a%i==0)return 1;
    return 0;
}

// MOD
const ll MOD = 1000000000 + 7;
#define add(a, b) ((a % MOD) + (b % MOD)) % MOD
#define mul(a, b) ((a % MOD) * (b % MOD)) % MOD
#define sub(a, b) ((a % MOD) + MOD - (b % MOD)) % MOD
template <typename T> T mod_inverse(T a, T mod, bool prime){ // if mod is prime, "prime" is true.
    if(prime){
        T tmp=mod-2,now=a,res=1;while(tmp){if(tmp&1)res=mul(res,now);now=mul(now,now);tmp>>=1;}
        return res;
    }else{T x,y;EXTGCD(a,mod,x,y);return (mod+x%mod)%mod;}
}
#define divide(a, b) ((a % MOD) * (mod_inverse(b, MOD, true))) % MOD

//
//
//  　　┓　　　┏
//  　＊┗┓　┏┛
//  　　　┫　┣　＊
//  　┏┳┻━┻┳┓
//  　┗┫　　　┣┛
//  ＊　┣　　━┃　＊        Merry Christmas!!
//  　┏┛　　〃┃
//  　┃●　　　┣━┳┓
//  　┗┻┳━━┛　┣┛
//  　＊　┃┏┓┣┓┃
//WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW

int n;
string s;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    FILE *stream1;
    //FILE *stream2;
    stream1 = freopen("C:\\Users\\naruse\\CLionProjects\\competitive\\cmake-build-debug\\in.txt", "r", stdin);
    //stream2 = freopen("out.txt", "w", stdout);
    if (stream1 == nullptr) return 0;
    //if (stream2 == NULL) return 0;
#endif
    cin >> n;
    int _max = -1;
    int sum = 0;
    for (int i = 0; i < n; i++) {
        int a; cin >> a;
        chmax(_max, a);
        sum += a;
    }
    cout << sum - _max + _max / 2 << endl;
#ifdef  LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
#endif
    return 0;
}

Measured memory_bytes: 256
#include <cstring>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
int N, K;
int A[101];
int DP[100003][2]; //残りの山の数, そのとき先手(0)か後手(1)か. 未捜査(-1)か先手が勝つ(0)か後手が勝つ(1)か

// 残りの石のうち、どれかが相手を負けにすることができることならば、自分の勝ちとする。
int dfs(int rest, int turn){
  if (DP[rest][turn] > -1) return DP[rest][turn]; 
  int next = (turn+1)%2;
  int ans = next;
  rep(i, N){
    if (rest - A[i] >= 0){
      int flag = dfs(rest - A[i], next);
      if (flag == turn){
        ans = turn;
        break;
      }
    }
  }
  DP[rest][turn] = ans;
  return ans;
}

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

  cin >> N >> K;
  rep(i, N){
    cin >> A[i];
  }

  rep(i, K+1) {
    DP[i][0] = -1;
    DP[i][1] = -1;
  }

  DP[0][0] = 1;
  DP[0][1] = 0;

  string ans = (dfs(K, 0)==0)?"First":"Second";
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 7296
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <vector>
#include <set>
using namespace std;




int main(){

	int h, w, h1, w1;

	cin >> h >> w >> h1 >> w1;

	cout << h * w - h1 * w - h * w1 + h1 * w1 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
class UnionFind {
	mutable std::vector<int> vec;
public:
	UnionFind(const int size) : vec(size, -1) {};
	int find(int a) const {
		if (vec[a] < 0) return a;
		else return vec[a] = find(vec[a]);
	}
	bool same(int a, int b) const { return find(a) == find(b); }
	void unite(int a, int b) {
		a = find(a);
		b = find(b);
		if (a != b) {
			if (vec[a] < vec[b]) {
				vec[a] += vec[b];
				vec[b] = a;
			}
			else {
				vec[b] += vec[a];
				vec[a] = b;
			}
		}
	}
	void clear() {
		std::fill(vec.begin(), vec.end(), -1);
	}
};
struct Bridge {
	int id, from, to, cost;
};
int main() {
	int n, m; std::cin >> n >> m;
	std::vector<Bridge> bridges(m); 
	for (auto i = 0; i < m; ++i){
		bridges[i].id = i;
		std::cin >> bridges[i].from >> bridges[i].to >> bridges[i].cost; --bridges[i].from, --bridges[i].to;
	}
	UnionFind uft(n);
	std::vector<bool> use_for_tree(bridges.size(), false);
	std::sort(bridges.begin(), bridges.end(), [](const Bridge& a, const Bridge& b) {return a.cost < b.cost; });
	int min_cost = 0;
	for (const auto b : bridges) {
		if (!uft.same(b.from, b.to)) {
			uft.unite(b.from, b.to);
			use_for_tree[b.id] = true;
			min_cost += b.cost;
		}
	}
	int alt_count = 0, alt_sum = 0;
	for (auto i = 0; i < bridges.size(); ++i) if (use_for_tree[bridges[i].id]) {
		uft.clear();
		int count = 0;
		int cost = 0;
		for (const auto b : bridges) if (b.id != bridges[i].id) {
			if (!uft.same(b.from, b.to)) {
				uft.unite(b.from, b.to);
				cost += b.cost;
				if (++count == bridges.size()) break;
			}
		}
		if (count != n - 1 || cost != min_cost) {
			++alt_count;
			alt_sum += bridges[i].cost;
		}
	}
	std::cout << alt_count << ' ' << alt_sum << '\n';
}



Measured memory_bytes: 3632