akhauriyash/Code-Regression huggingface dataset:
def shortest_path_faster_algorithm(E, start):
    # ベルマンフォードの更新があるところだけ更新する感じのやつ
    # O(VE) だが実用上高速
    # E は隣接リスト
    # 検証: http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=4005805#1
    from collections import deque
    inf = float("inf")  # 10**18 は良くない
    N = len(E)
    q = deque([start])
    distance = [inf] * N;  distance[start] = 0
    in_q = [0] * N;        in_q[start] = True
    times = [0] * N;       times[start] = 1
    while q:
        v = q.popleft()
        in_q[v] = False
        dist_v = distance[v]
        for u, cost in E[v]:
            new_dist_u = dist_v + cost
            if distance[u] > new_dist_u:
                times[u] += 1
                if times[u] >= N:  # 負閉路検出
                    distance[u] = -inf
                else:
                    distance[u] = new_dist_u
                if not in_q[u]:
                    in_q[u] = True
                    q.append(u)
    return distance

import sys
def main():
    N, M, r = map(int, sys.stdin.readline().split())
    E = [[] for _ in range(N)]
    for s, t, d in zip(*[iter(map(int, sys.stdin.read().split()))]*3):
        E[s].append((t, d))
    distance = shortest_path_faster_algorithm(E, r)
    for d in distance:
        if d == float("inf"):
            print("INF")
        else:
            print(d)

main()



Measured memory_bytes: 184364
import java.util.Scanner;
import java.lang.Math;
public class Main {
  public static void main (String[]args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int t[] = new int[N+1];  //N+!個配列を作成
    int xt[] = new int[N+1];
    int yt[] = new int[N+1];
    t[0]=0; //0番目には０を代入
    xt[0]=0;
    yt[0]=0;
    for(int i = 1; i<=N; i++){ //１～N番目に代入
      t[i] = sc.nextInt();
      xt[i] = sc.nextInt();
      yt[i] = sc.nextInt();
    }
    boolean can = true;
    int dt=0;
    int dist=0;
    for(int i = 0; i<=N; i++){
      if(i!=N) {
        dt = t[i+1] - t[i];
        dist = Math.abs(xt[i+1] - xt[i]) + Math.abs(yt[i+1] - yt[i]);
      if(dt < dist) can = false;
      if(dist %2 != dt %2) can = false; //distとdtの偶奇は一致する必要あり
      }
    }
    if(can)   System.out.println("Yes");
    else System.out.println("No");
  }
}


Measured memory_bytes: 89524
//#include "stdafx.h"
#include <bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define e "\n"
#define MaRiaMa { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
#define fix(n) cout << fixed << setprecision(n);
using namespace std;
int main()
{
	MaRiaMa;
	int a, b;
	cin >> a >> b;
	if (a + b >= 24)
		cout << ((a + b) - 24);
	else
		cout << a + b;
}

Measured memory_bytes: 3632
#include"stdio.h"
int main()
{
	int a,b,max;
	int add,minus,m;
	while(scanf("%d%d",&a,&b)!=EOF)
	{
	max=add=a+b;
	minus=a-b;
	m=a*b;
	if(minus>max)
		max=minus;
	if(m>max)
		max=m;
	printf("%d\n",max);
	}
}

Measured memory_bytes: 128
import java.util.Scanner;

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

	int d = a / b;
	int r = a % b;
	double f = (double)a / b;

	System.out.printf("%d %d %.8f", d, r, f);
    }   
}

Measured memory_bytes: 17268
N,K = map(int,input().split())

calc = N-2
for i in range(3,N) :
    calc += (N-i)

if calc < K :
    print(-1)


else :
    ans = []
    ans.append([1,2])
    for i in range(3,N+1) :
        ans.append([2,i])
    
    cnt = calc - K
    
    
    for i in range(3,N+1) :
        if cnt > 0 :
        
            ans.append([1,i])
            cnt -= 1
        else :
            break
    
    for i in range(3,N) :
        if not cnt > 0 :
            break
        for j in range(i+1,N+1) :
            if not cnt > 0 :
                break
            
            ans.append([i,j])
            cnt -= 1

    M = len(ans)

    print(M)
    for a in ans :
        print(*a)

Measured memory_bytes: 4120
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int R;
	R<=4208;
	cin>>R;
	if(R<1200)
	cout<<"ABC";
	if(R>=1200 && R<2800)
	cout<<"ARC";
	if(R>=2800 && R<=4208)
	cout<<"AGC";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define maxn 100009
using namespace std;
int n,a[maxn],maxx,minx;
bool vis[maxn];
bool check(int x)
{
  if ((x<maxx)||(x>minx+1)) return false;
  int num=x,t=0;
  for (int i=1;i<=n;i++)
  if (x==a[i]) t++;
  else num--;
  //cout<<x<<" "<<num<<" "<<t<<endl;  
  if (num<0) return false;
  if ((t>0)&&(num==0)) return false;
  if ((t==0)&&(num>0)) return false;
  if (t>=num*2) return true;
  else return false;
}
int main()
{
  scanf("%d",&n);
  minx=2000000000;
  for (int i=1;i<=n;i++) 
  {
   scanf("%d",&a[i]);
   maxx=max(a[i],maxx);
   minx=min(a[i],minx);
  }
  if (maxx-minx>1) printf("No\n");
  else if (check(a[1])||check(a[1]+1)) printf("Yes\n");
  else printf("No\n");
  return 0;
}

Measured memory_bytes: 640
#### import ####
import sys
sys.setrecursionlimit(10**7)
import math
from collections import defaultdict

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
  read_all = [tuple(map(int, input().split())) for _ in range(N)]
  return map(list,zip(*read_all))

#################

N,M = II()
a,b = Line(M)

can_visit = defaultdict(list)
for i in range(M):
  can_visit[a[i]-1].append(b[i]-1)
  can_visit[b[i]-1].append(a[i]-1)
from itertools import permutations
road = list(permutations([i for i in range(N)]))
counter = 0
for r in road:
  if r[0]!=0:
    continue
  temp = 0
  check_visited = [False]*N
  check_visited[0] = True
  for i in r[1:]:
    if (i in can_visit[temp]) and (check_visited[i]==False):
      temp = i
      check_visited[i] = True
      if check_visited == [True]*N:
        counter += 1
        break
    else:
      break
print(counter)

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

using static Input;
using static Util;
class Program
{
    static int A;
    static int B;
    static void INPUT()
    {
        A = NextInt();
        B = NextInt();
    }

    static void OUT()
    {
        var ans = -1;
        for (var n = B * 10; n < (B + 1) * 10; n++)
        {
            if ((int)(n * 0.08) == A)
            {
                ans = n;
                break;
            }
        }
        
        Console.WriteLine(ans);
    }
    static void Main(string[] args)
    {
#if DEBUG  
        //TESTINPUT();
        INPUT();

#else
        INPUT();
#endif
        OUT();
    }

    static void TESTINPUT()
    {
    }

}

public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}

class Util
{

}




Measured memory_bytes: 13268
#include<stdio.h>
#include<string.h>
int num[200];
int main(){
	char a[50];
	while(scanf("%s",a)!=EOF){
		memset(num,0,sizeof(num));
		int s=strlen(a),i,g;
		for(i=0;i<s;i++){
			g=a[i]-'a';
			num[g]++;
		}
		int flag=0;
		for(i=0;i<=26;i++){
			if(num[i]>1){
				flag=1;
				break;
			}
		}
		if(flag==0)
			printf("yes\n");
		else
			printf("no\n");
	}
	return 0;
}

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

int main() {
    int n, m, c;
    int a[30][30], b[30];
    int ans = 0;
    cin >> n >> m >> c;
    for (int i = 0; i < m; i++) cin >> b[i];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) cin >> a[i][j];
    }

    for(int i = 0; i < n; i++) {
        int sum = 0;
        for(int j = 0; j < m; j++) {
            sum += a[i][j] * b[j];
        }
        if (sum + c > 0) ans++;
    }

    cout << ans << endl;
}


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

long long inp_c1, inp_c2, inp_n1, inp_n2, i1, out_s;

long long inp_a[100005];

bool marker[100005];

long long readNumber() {
	long long temp_func;
	scanf("%lld", &temp_func);
	return temp_func;
};
long long printNumber(long long temp_func) {
	printf("%lld ", temp_func);
	return 0;
};

int main() {
	
	memset(marker, true, sizeof(marker));
	
	inp_c1 = readNumber();
	
	inp_c2 = readNumber();
	
	for (i1 = 1; i1 <= inp_c1; i1++) {
		
		inp_a[i1] = readNumber();
		
	};
	
	for (i1 = 1; i1 <= inp_c2; i1++) {
		
		inp_n1 = readNumber();
		
		inp_n2 = readNumber();
		
		if (inp_a[inp_n1] > inp_a[inp_n2]) {
			
			marker[inp_n2] = false;
			
		} else if (inp_a[inp_n1] < inp_a[inp_n2]) {
			
			marker[inp_n1] = false;
			
		} else {
			
			marker[inp_n1] = false;
			
			marker[inp_n2] = false;
			
		};
		
	};
	
	for (i1 = 1; i1 <= inp_c1; i1++) {
		
		out_s += marker[i1];
		
	};
	
	printNumber(out_s);
	
}

Measured memory_bytes: 2604
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
	int n;
	int a,b;
	int m,ans;
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		scanf("%d%d",&a,&b);
		int a1,b2;
		a1=n-a+1;
		b2=n-b+1;
		if(a1<a)a=a1;
		if(b2<b)b=b2;
		//cout<<a<<b<<endl;
		if(b>a){
			ans=a%3;
			if(ans==0)ans=3;
		}
		else{
			ans=b%3;
			if(ans==0)ans=3;
		}
		printf("%d\n",ans);
	}
}

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

struct bank_t {
    int b, r, t;
    bank_t(int b, int r, int t) : b(b), r(r), t(t) {}
    double interest(int y) {
        double ret = 1.0;
        if (t == 1) {
            ret += ret * r / 100.0 * y;
        } else {
            for (int i = 0; i < y; i++) {
                ret *= (1.0 + r / 100.0);
            }
        }
        return ret;
    }
};

int main() {
    int n;
    while (cin >> n, n != 0) {
        int y; cin >> y;
        vector<bank_t> banks;
        for (int i = 0; i < n; i++) {
            int b, r, t;
            cin >> b >> r >> t;
            banks.push_back(bank_t(b, r, t));
        }

        double max_interest = 0;
        int bank_n;
        for (int i = 0; i < banks.size(); i++) {
            double i_interest = banks[i].interest(y);
            if (max_interest < i_interest) {
                max_interest = i_interest;
                bank_n = banks[i].b;
            }
        }

        cout << bank_n << endl;
    }
    return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int sBeforeLength = s.length();
        String p = sc.next();
        s = s + s.substring(0, p.length()-1);
        int flag = 1;
        for(int i=0; i<=sBeforeLength-1; i++){
            if( p.equals( s.substring( i, i+p.length() ) ) ) flag=0;
        }
        if(flag==0) {System.out.println("Yes");}
        else{System.out.println("No");}
    }
}


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

const string YES = "Yes";
const string NO = "No";

void solve(std::string S){
    cout << (S[2] == S[3] && S[4] == S[5] ? YES : NO) << endl;
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	ll k;
	cin >> k;
	if(k==0){
		cout << 2 << endl;
		cout << 0 << " " << 0 << endl;
		return 0;
	}

	int n=50, r=k%n;
	ll a[n];
	for(int i=0; i<r; i++) a[i]=2*n+(k/n)-r;
	for(int i=r; i<n; i++) a[i]=n+(k/n)-r-1;
	cout << n << endl;
	for(int i=0; i<n; i++){
		cout << a[i];
		if(i!=n-1) cout << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline

def main():
    ans = ''
    index = 0
    s = input().rstrip('\n')
    k = int(input())
    for i in range(len(s)):
        if s[i] != '1':
            ans = s[i]
            index = i
            break
    if ans == '' or k < index+1:
        ans = '1'
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9176
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[5],b,c,aa;
	bool bj=0;
	cin>>a[1]>>a[2]>>a[3];
	if((a[1]-a[2])==(a[2]-a[3]))cout<<"YES\n";
	else cout<<"NO\n";
	return 0;
}

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

inline int read()
{
	char ch=getchar();
	int x=0,f=0;
	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,a[100010];
int main()
{
	n=read();
	for(int i=1;i<=2*n;i++)
	{
		a[i]=read();
	}
	sort(a+1,a+2*n+1);
	int ans=0;
	for(int i=1;i<=2*n;i+=2)
	ans+=a[i];
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
fun main (args : Array<String>) {
	val (n, m, c) = readLine()!!.split(" ").map(String::toInt)
	val N : Int = n.toInt()
	val M : Int = m.toInt()
	val C : Int = c.toInt()
	val list1 = readLine()!!.split(" ").map(String::toInt)
	var bList : MutableList<Int> = mutableListOf()
	for (i in 0..M - 1) {
		bList.add(list1[i])
	}
	var aList : MutableList<Int> = mutableListOf()
	var calc : Int = 0
	var count : Int = 0
	for (i in 0..N - 1) {
		var list2 = readLine()!!.split(" ").map(String::toInt)
		for (j in 0..M - 1) {
			aList.add(list2[j])
			calc += (bList[j] * aList[j])
		}
		calc += C
		if (calc > 0) {
			count++
		}
		calc = 0
		aList.clear()
	}
	println("${count}")
}

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

//関数
    
//main関数
int main() {
    
    
    //入力
    long N;
    cin>>N;
    vector<long> A(N);
    bool ans=true;
    
    for(int i=0;i<N;i++){
        cin>>A.at(i);
        if(A.at(i)%2==1) ans=1-ans;
    }
    
    //計算

    
    //出力
    if(ans){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}


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

#define ll long long

#define p 2019

using namespace std;

int main()

{

	int l, r;

	cin >> l >> r;

	if (r - l >= p) {puts("0"); return 0;}

	ll ans = p;

	for (ll i = l; i < r; i ++) for (ll j = i + 1; j <= r; j ++) ans = min(ans, i * j % p);

	cout << ans << endl;

}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
        int n,a,b,s,c[5],i,j,k;

        scanf("%d%d%d",&n,&a,&b);

        s=0;
        for(i=1;i<=n;i++){
                c[0]=i/10000;
                c[1]=(i%10000)/1000;
                c[2]=(i%10000)%1000/100;
                c[3]=((i%10000)%1000)%100/10;
                c[4]=((i%10000)%1000)%100%10;
                k=c[0]+c[1]+c[2]+c[3]+c[4];
                if(k>=a && k<=b) s+=i;
        }

        printf("%d\n",s);
        return 0;
}


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

int main() {
  int n;

  cin >> n;

  vector<int> x(n);

  rep(i,n){
    cin >> x.at(i);
    // sum += x.at(i);
  }

  int zahyou = 1;

  int ans = 1000000000;

  for(int i = 1; i<=100; i++){
    int dis =0;
    rep(j,n){dis += (i-x.at(j))*(i-x.at(j));}
      
      
      ans = min(ans,dis);
    }
  

  cout << ans;
}

Measured memory_bytes: 3644
use std::vec::Vec;

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 read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
  let v: Vec<T> = read_vec();
  assert_eq!(v.len(), 2);
  (v[0], v[1])
}

fn main() {
    let c: Vec<char> = read::<String>().chars().collect();
    let c = c[0];
    let ASCII_LOWER = [
    'a', 'b', 'c', 'd', 'e', 
    'f', 'g', 'h', 'i', 'j', 
    'k', 'l', 'm', 'n', 'o',
    'p', 'q', 'r', 's', 't', 
    'u', 'v', 'w', 'x', 'y', 
    'z',
    ];

    for i in 0..26 {
      if ASCII_LOWER[i] == c {
        println!("{}", ASCII_LOWER[i+1]);
        break
      }
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    string s;
    cin >> s;
    if(s[1] == 'B')cout << "ARC" << endl;
    else cout << "ABC" << endl;
    return 0;
}

Measured memory_bytes: 3592
import bisect

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

mem =[0 for i in range(0,N +1,1)]
count =0

for i in range(N-1,-1,-1):
    if A[i]+i < N:
        count+=mem[A[i]+i]

    if i - A[i] > 0:
        mem[i - A[i]]+=1

print(count)

Measured memory_bytes: 100024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <climits>

using namespace std;

int main() {
  int A, B;
  cin >> A >> B;

  string ans;
  if (A * B % 2 == 1) {
    ans = "Yes";
  } else {
    ans = "No";
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
import numpy as np
N, W = map(int, input().split())
ndp = np.zeros(W+1, dtype= np.int64)
for _ in range(N):
    w, v = map(int,input().split())

    # 離散より連続で扱った方が簡単になる。
    np.maximum(ndp[:-w] + v, ndp[w:], out = ndp[w:])
print(ndp[-1])


Measured memory_bytes: 21004
import java.util.Scanner;

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

		char[] chars = s.toCharArray();
		int count = 0;
		for (int i = 0; i < chars.length / 2; i++) {
			if (chars[i] != chars[chars.length - 1 - i]) {
				count++;
			}
		}

		System.out.println(count);
	}
}


Measured memory_bytes: 23764
import sys
from collections import deque
inf=100000000000000000000
fastinput=sys.stdin.readline
N=int(fastinput())
path=[[] for hoge in range(N)]
for fuga in range(N-1):
    a,b,c=[int(hoge) for hoge in fastinput().split()]
    path[a-1].append([b-1,c])
    path[b-1].append([a-1,c])
Q,K=[int(hoge) for hoge in fastinput().split()]
stack=deque()
stack.append(K-1)
Kcost=[0]*N#あとあと初期化
went=[False]*N
went[K-1]=True
while stack:
    cur=stack.pop()
    curcost=Kcost[cur]
    for next,c in path[cur]:
        if c and not went[next]:
            went[next]=True
            Kcost[next]=curcost+c
            stack.append(next)
for q in range(Q):
    x,y=[int(hoge) for hoge in fastinput().split()]
    print(Kcost[x-1]+Kcost[y-1])
    

Measured memory_bytes: 85936
#include<iostream>
#include<queue>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    priority_queue<int> box;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        box.push(a);
    }
    for(int i=0;i<m;i++){
        int vmax=box.top();
        box.pop();
        vmax/=2;
        box.push(vmax);
    }
    long long sum=0;
    for(int i=0;i<n;i++){
        sum+=box.top();
        box.pop();
    }
    cout<<sum<<"\n";
    return(0);
}

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

const int MAXN = 1000000 + 10;

char a[MAXN],c[MAXN];
int b,sum,l;
int main() {
	cin>>a;
	b = strlen(a);
	for(int i = b - 1; i >= 0; i--) {
		c[sum] = a[i];
		if(c[sum] == 'b') c[sum] = 'd';
		else if(c[sum] == 'd') c[sum] = 'b';
		else if(c[sum] == 'p') c[sum]='q';
		else if(c[sum] == 'q') c[sum]='p';
		sum++;
	}
	for(int i = 0; i <= b - 1; i++) {
		if(a[i] != c[i]) {
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int gcd(int p, int q){
    while (q!=0){
        int r = p%q;
        p=q;
        q=r;
    }

    return p;
}

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

    long long ans=0;
    


    for (int a = 1; a < K+1; ++a) {
        for (int b = 1; b < K+1; ++b) {
            long long G=gcd(a,b);
            for (int c = 1; c < K+1; ++c) {
                ans+=gcd(G,c);
            }
        }
    }


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


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

int main() {
  char S[10],T[10],K[10]; cin>>S>>T;
  int n, m; cin>>n>>m;
  cin>>K;
  
  if (strcmp(S, K)==0) cout<<n-1<<" "<<m<<endl;
  else cout<<n<<" "<<m-1<<endl;
}

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

int main()
{
  int A, B; cin >> A >> B;
  int a[10];
  int ans = 0;
  for(int i = A; i <= B; i++){
    a[0] = i / 10000 % 10;
    a[1] = i / 1000 % 10;
    a[3] = i / 10 % 10;
    a[4] = i % 10;
    if(a[0] == a[4] && a[1] == a[3]) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int main(){
  double hensa_2,hensa,a,b,c,m,i,n,S[1000];

  
     while(1){
      cin >> n;
      if(n==0)break;
  c=0;
  a=0;
      for(int i=0;i<n;i++){
	cin >> S[i];
	c+=S[i];
      }
      m=c/n;
    
      for(int i=0;i<n;i++){
	b=S[i]-m;
	a+=b*b;
       
      }
      hensa_2=a/n;
      hensa=sqrt(hensa_2);
      printf("%.8f\n",hensa);
    }
    return 0;
}
   

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

using namespace std ; 

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

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

const int INF = 1 << 29;
int N;
int dp[100010];

int rec(int i) {
    if(dp[i] < INF) return dp[i];
    if(i == 0) return 0;
    int res = INF;
    for(int j = 1; j <= i; j *= 6) res = min(res, rec(i-j) + 1);
    for(int j = 1; j <= i; j *= 9) res = min(res, rec(i-j) + 1);
    return dp[i] = res;
}

int main() {
    cin >> N;
    for(int i = 0; i <= N; ++i) dp[i] = INF;
    
    cout << rec(N) << endl;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define INF 0x3f3f3f3f

int main()
{
    LL n,a,b;
    while(cin>>n>>a>>b)
    {
        if ((n==1&&a!=b)||a>b)
            printf("0\n");
        else
        {
           LL x = a+b+(n-2)*a;
           LL y = a+b+(n-2)*b;
           cout<<y-x+1<<endl;
        }
    }
    return 0;
}


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

            using namespace std;

            #define fastIO  std::ios::sync_with_stdio(false);cin.tie(NULL)
            #define uli unsigned long long int
            #define lli long long int
            #define Lf long double
            #define mod 1000000007
            #define N 21
            #define NN 21
            #define vi vector<int>
            #define vl vector<long>
            #define vll vector<long long>
            #define vc vector<char>
            #define ii <int, int>
            #define ll <long, long>
            #define lll <long long, long long>
            #define loop(i,s,n) for(int i=s;i<n;i++)
            #define loopr(i,n,s) for(int i=n-1;i>=s;i--)
            #define pb push_back

            lli modadd(lli n,lli m){
                lli sum = ((n+m)%mod+mod)%mod;
                return sum;
            }

            lli modsub(lli n,lli m){
                lli diff = ((n-m+mod)%mod+mod)%mod;
                return diff;
            }

            lli modpro(lli n,lli m){
                lli pro = ((n*m)%mod+mod)%mod;
                return pro;
            }

            lli pow(int a,int x){
                lli powe = 1;
                loop(i,0,x){
                    powe*=a;
                }
                return powe;
            }

        lli powmod(int a,int x){
                lli powe = 1;
                loop(i,0,x){
                    powe=modpro(powe,a);
                }
                return powe;
            }




            int main(){
              lli n;
              cin>>n;
              cout<<((n-1)*n)/2;

            return 0;
            }




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

using namespace std;
int main(void){
    string a;
    getline(cin,a);
    for(int i=0;i<a.size();i++){
        if('A'<=a[i] && a[i]<='Z')cout<<(char)(a[i]+('a'-'A'));
        else if('a'<=a[i] && a[i]<='z')cout<<(char)(a[i]+('A'-'a'));
        else cout<<a[i];
    }
    
    cout<<endl;
    
    return 0;
}



Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll a, b, x;
    cin >> a >> b >> x;

    using R = long double;
    R h = (R)x / a / a;
    R area = a * h;
    R PI = acosl(-1);

    if(2 * h < b) {
        // area <= b*b / tan(t)/2 であるような最大のt
        auto check = [&](R mid) {
            return area <= b*b / tanl(mid) / 2;
        };
        R lb = 0, ub = PI/2;
        REP(i, 100) {
            R mid = (lb+ub) / 2.0;
            if(check(mid)) lb = mid;
            else ub = mid;
        }
        R ans = lb * 180 / PI;
        cout << fixed << setprecision(9) << ans << endl;
    } 
    // 面積比で半分以上
    else {
        // area <= a*b - a*a*tan(t) / 2 であるような最大のt
        auto check = [&](R mid) {
            return area <= a*b - a*a*tanl(mid)/2;
        };
        R lb = 0, ub = PI/2;
        REP(i, 100) {
            R mid = (lb+ub) / 2.0;
            if(check(mid)) lb = mid;
            else ub = mid;
        }
        R ans = lb * 180 / PI;
        cout << fixed << setprecision(10) << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <limits>
using namespace std;
typedef long long ll;
 
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define FOREACH(i,Itr) for(auto (i)=(Itr).begin();(i)!=(Itr).end();(i)++)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))

template <class T> struct SegmentTreeMin {
  vector<T> node;
  const T INF = numeric_limits<T>::max() / 2;
  SegmentTreeMin (int n) { 
    node.resize(4<<(int)log2(n), INF); 
  }
  void update(int idx, T val){
    idx += (int) node.size() / 2;
    node[idx] = val;
    while (idx > 0) {
      node[idx>>1] = min(node[idx], node[idx^1]);
      idx >>= 1;
    }
  }
  T get_min(int l, int r) { 
    T ret = INF;
    l += (int) node.size() / 2;
    r += (int) node.size() / 2;
    while (l < r) {
      if (l & 1) ret = min(ret, node[l++]);
      if (r & 1) ret = min(ret, node[--r]);
      l >>= 1; r >>= 1;
    }
    return ret;
  }
};
 
SegmentTreeMin<ll> inst(100010);

int main() {
  int n,q; cin >> n >> q;
  REP(i,q) {
    int com,x,y; cin >> com >> x >> y;
    if(com == 0) {
      inst.update(x,y);
    } else {
      ll ans = inst.get_min(x,y+1);
      cout << (ans==inst.INF ? 2147483647 : ans) << endl;
    }
  }

  return 0;
}

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

int main() {
 int A, B, C;
  char op;
  cin >> A >> op >> B;
  if(op == '+'){
    C = A + B;
  }
  else if(op == '-'){
    C = A - B;
  }
  cout << C << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[3];
int main(int argc, const char * argv[])
{
    int ans=0;
    for(int i=0;i<3;i++)
        cin>>a[i];
    sort(a,a+3);
    ans=a[2]-a[0];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
N, C = list(map(int, input().split()))
D = [list(map(int, input().split())) for _ in range(C)]
c = [list(map(int, input().split())) for _ in range(N)]
D0 = {}
D1 = {}
D2 = {}
for color in range(1, C + 1):
    D0[color] = 0
    D1[color] = 0
    D2[color] = 0
    
for color in range(1, C + 1):
    for i in range(N):
        for j in range(N):
            if (i + j) % 3 == 0:
                D0[color] = D0[color] + D[ c[i][j] - 1 ][ color - 1 ] 
            if (i + j) % 3 == 1:
                D1[color] = D1[color] + D[ c[i][j] - 1 ][ color - 1 ] 
            if (i + j) % 3 == 2:
                D2[color] = D2[color] + D[ c[i][j] - 1 ][ color - 1 ] 

ans = 1000000000000000
for i in range(1, C + 1):
    for j in range(1, C + 1):
        for k in range(1, C + 1):
            if i != j and j != k and k != i:
                tmp = D0[i] + D1[j] + D2[k]
                if tmp < ans:
                    ans = tmp
print(ans)


Measured memory_bytes: 48988
/*
    Created by Tejas Chaudhari
    link:
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;

void re_curse()
{
    ll n;
    cin>>n;
    vector<ll> arr(n,0);
    for(int i=1;i<n;i++)
    {
        ll x;
        cin>>x;
        x--;
        arr[x]++;
    }
    for(auto i:arr)
    {
        cout<<i<<endl;
    }
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    re_curse();
    return 0;
}

Measured memory_bytes: 4784
#include<cstdio>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cstring>
#include<utility>
using namespace std;
#define MS(m,z) memset(m,z,sizeof(m))
typedef unsigned U;typedef long long ll;typedef pair<int,int > P;
void inp();
int main(){
#ifdef XS
	freopen("C.in","r",stdin);
#endif
	//int ttt;scanf("%d",&ttt);for(int i=1;i<=ttt;i++)
	inp();
	return 0;
}
const int N = 2e5 + 100;
struct Node{
	int d,i;
	Node(int d,int i){
		this->d = d, this->i = 0;
	}
	Node(){
		this->d = 0,this->i = 0;
	}
}A[N];
int ans[N];
bool operator < (Node & a,Node & b){
	if( a.d == b.d )return a.i < b.i;
	return a.d < b.d;
}
map<int ,int >pos;
void inp(){
	int n;scanf("%d",&n);
	int tmp;
	for(int i = 1;i<=n;i++){
		scanf("%d", &tmp);
		A[i].i = i;
		A[i].d = tmp;
	}
	sort(A + 1, A + n + 1);
	for(int i = 1;i<=n;i++){
		pos[ A[i].i ] = i;
	}
	int mval= A[n / 2].d;
	int mpos = n/2;
//	for(int i = 1;i<=n;i++)printf("(%d %d)", A[i].d, A[i].i );
//			putchar('\n');
	for(int i = 1;i<=n;i++){
		int xi = A[i].i ;
		int xival = A[i].d;
		if( xival <= mval ){
				ans[ xi ] = A[mpos + 1].d;
		}
		else if ( xival > mval ){
			ans[xi] = A[ mpos ].d;
		}
	}
	for(int i = 1;i<=n;i++)printf("%d\n", ans[i]);
}
//C.cc by xsthunder at Sat Apr 14 20:12:05 2018


Measured memory_bytes: 13952
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <deque>
#include <queue>
#include <set>
#include <functional>
#include <cmath>


//マクロ
/*動かない・・・
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _roverload3(_1,_2,_3,name,...) name
#define _rrep(i,n) repi(i,0,n)
#define rrepi(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(...) _roverload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
//*/
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)
//*/
#define All(a) (a).begin(),(a).end()
#define dump(x)  cerr << #x << " = " << (x) << endl;

//定数
#define INF 1e9
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
//*/
using namespace std;
using Graph = vector<vector<int>>;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数
ll h;

//使用する関数
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;
}

ll calc(ll a) {
	if (a == 1)return 1;
	return calc(a / 2) * 2 + 1;
}

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

	cin >> h;

	cout << calc(h) << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long int lli;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define ff first
#define ss second
#define pi pair<lli,lli>
#define pii pair<pi,lli>
#define endl "\n"
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 1e5 + 5;


int main() {
	IOS
	int T = 1;
	// cin >> T;

	while(T--)
	{
		lli a;
		cin >> a;
		cout << a + (a*a) + (a*a*a) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3648
(function main() {
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());
  const MAX = 1000;
  const c = Array.from(Array(MAX + 1), () => []);

  let i, j, X, Y, xlen, ylen, maxlen;
  while ((X = lines.shift()) && (Y = lines.shift())) {
    xlen = X.length;
    ylen = Y.length;
    for (i = 0; i <= xlen; i++) c[i][0] = 0;
    for (j = 0; j <= ylen; j++) c[0][j] = 0;

    for (i = 1; i <= xlen; i++) {
      for (j = 1; j <= ylen; j++) {
        if (X[i-1] === Y[j-1]) c[i][j] = c[i - 1][j - 1] + 1;
        else c[i][j] = Math.max(c[i - 1][j], c[i][j - 1]);
      }
    }
    console.log(c[xlen][ylen]);
  }
})();



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

ll n_pairs(int x){
  return (ll)x*(x-1)/2;
}

int main(){
  int N, M;cin>>N>>M;
  vll A;for (int i=0;i<N;++i){ll a;cin>>a;A.push_back(a);}

  vll cummod(N+1);
  cummod[0]=0;
  for (int i=0;i<N;++i){
    cummod[i+1]=(cummod[i]+A[i])%M;
  }

  map<int, int> cnt;
  for (int i=0;i<N+1;++i) cnt[cummod[i]]++;

  ll ans=0;
  for (auto p: cnt){
    ans+=n_pairs(p.second);
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

using ll = int64_t;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = INT_MAX;
constexpr ll L_INF = LLONG_MAX;

//===




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

	int N;
	string S;
	cin >> N >> S;

	for (int i = 0; i < S.size(); ++i) {
		int a = S[i] - 'A';
		a = (a + N) % 26;
		S[i] = a + 'A';
	}

	cout << S << endl;

	return 0;
}

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

typedef struct cell{
  int money, prog;
}cell;

int main(){
  int x, y, z;
  while(cin >> x >> y >> z, x){
    vector<vector<double> > dp(y + 1, vector<double>(1e4,0));
    vector<int> next(x);
    dp[0][0] = 1;
    for (int i = 0; i < x; i++) {
      std::cin >> next[i];
    }
    vector<cell> game(y + 1, (cell){1e9, 1e9});
    for (int i = 0; i < z; i++) {
      int a, b, c;
      std::cin >> a >> b >> c;
      if(b == 1){
        game[a].prog = c;
      }else if(b == 2){
        game[a].money = c;
      }else{
        game[a].money = -c;
      }
    }
    for (int i = 0; i < y; i++) {
      for (int j = 0; j < 1e4; j++) {
        for (int k = 0; k < x; k++) {
          if(game[i + next[k]].prog != 1e9){
            int n = game[i + next[k]].prog;
            dp[min(y, i + next[k] + n)][j] +=
              dp[i][j]/next.size();
          }else if(game[i + next[k]].money != 1e9){
            int n = game[i + next[k]].money;
            dp[min(y, i + next[k])][max(0, j + n)] +=
              dp[i][j]/next.size();
          }else{
            dp[i + next[k]][j] += dp[i][j]/next.size();
          }
        }
      }
    }
    double ans = 0;
    for (int i = 0; i < 1e4; i++) {
      ans += dp[y][i]*i;
    }
    std::cout << (int)ans << std::endl;
  }
  return 0;
}

Measured memory_bytes: 5032
#include<iostream>
#include<vector>
#include<deque>

using namespace std;

#define int long long

signed main(){
	const int INF = (1<<30);
	
	int N, Q;
	vector<deque<int>> gs;
	
	cin>>N>>Q;
	
	gs.resize(N);
	
	for(int i = 0; i < Q; i++){
		int query;
		
		cin>>query;
		
		if(query == 0){
			int lane;
			
			cin>>lane;
			
			lane--;
			
			cout<<gs[lane].front()<<endl;
			
			gs[lane].pop_front();
			
		} else if(query == 1){
			int car;
			int minj = 0;
			
			cin>>car;
			
			for(int j = 0; j < N; j++){
				if(gs[minj].size() > gs[j].size()) {
					minj = j;
				}
			}
			
			gs[minj].push_back(car);
			
		}
	}
}


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

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

  int h, n;
  cin >> h >> n;

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

  vector<int> dp(h + 1, 1000000000);
  dp[0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < h; j++) {
      int dmg = min(j + a[i], h);
      dp[dmg] = min(dp[dmg], dp[j] + b[i]);
    }
  }

  cout << dp[h] << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	vi v;
	FOR(i, 1, 1000)FOR(j, 2, 10)
	{
		int a = pow(i, j);
		if (a <= 1000) v.push_back(a);
	}
	sort(ALL(v));
	int x; cin >> x;
	for (int i = v.size() - 1; i >= 0; i--)
	{
		if (x >= v[i])
		{
			cout << v[i] << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define faster ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define ll long long
#define FO(n) for (ll i = 0; i < n; i++)
#define endl "\n"
const long long int M = 10e9 + 7;
void solve()
{
    long double d, t, s;
    cin >> d >> t >> s;
    s = (s * 1.0) / 60.0;
    t = (t * 1.0) * 60.0;
    long double chk = (d*1.0) / (s*1.0);
    if (chk <= t)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

int main()
{
    faster;
    //int t;
    //cin >> t;
    //while (t--)
    solve();
    return 0;
}

Measured memory_bytes: 3716
s = input()

num = 0
kisu = {'R', 'U', 'D'}
guusu = {'L', 'U', 'D'}
result = True
for i in s:
    num += 1
    if ((num % 2) == 1) and (i in kisu):
        continue
    elif ((num % 2) == 0) and (i in guusu):
        continue
    else:
        result = False

if result:
    print('Yes')
else:
    print('No')

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

int read() {
    int x=0,f=1,ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
#define REP(i,e,s) for(register int i=e; i<=s; i++)

#define MAXN (100000+10)

int s[MAXN];

int main () {
    int n=read();
    REP(i,1,n) s[i]=read();
    int t=read(),ans=0; 

    REP(i,1,t) {
        int q=read();
        int left=1,right=n+1,mid;
        while(left<right) {
            mid=(left+right)/2;
            if(s[mid]==q) {
                ans++;
                break;   
            }
            if(s[mid]<q) left=mid+1;
            else right=mid;
        }
        //if(s[mid]==q) cout<<q<<" ";
    }
    //puts("");
    printf("%d\n",ans);
}




Measured memory_bytes: 3532
def main():
    from builtins import int, map, list, print
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = (lambda: (sys.stdin.readline()).rstrip())
    input_list = (lambda: input().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    A, B = input_number_list()
    print((A - 1) * (B - 1))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9124
A,B,C,X = [int(input()) for i in range(4)]
count = 0
for i in range(A + 1):
    for j in range(B + 1):
        for k in range(C + 1):
            if 500 * i + 100 * j + 50 * k == X:
                count += 1
print(count)

Measured memory_bytes: 2940
import java.util.*;

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

        int r = sc.nextInt();
        int g = sc.nextInt();
        int b = sc.nextInt();

        int amari = (10 * g + b) % 4;
        if (amari == 0) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}

Measured memory_bytes: 21844
import math
n,p = map(int, input().split())
aa = list(map(int, input().split()))

aa = list(map(lambda x:x%2, aa))
odd = aa.count(1)
even = aa.count(0)
ans = 2**even
# if p==1:
#     ans*=odd
#     odd-=1
# 偶数個の選び方
pattern = 0
for i in range(p, odd+1, 2):
    # print(even, odd, i, math.factorial(odd) // (math.factorial(i)*math.factorial(odd-i)))
    pattern += math.factorial(odd) // (math.factorial(i)*math.factorial(odd-i))
print(ans*pattern)

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

int main(){
	int tall[10];
	for(int i=0;i<10;i++){
		cin >> tall[i];
	}
	sort(tall,tall+10);

	for(int i=9;i>6;--i){
		cout << tall[i] << endl;
	}

	return 0;
}

	

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int N; scanf("%d", &N);
  vector<int> T(N + 5, 0), X(N + 5, 0), Y(N + 5, 0);
  for (int i = 1; i <= N; ++i) {
    scanf("%d %d %d", &T[i], &X[i], &Y[i]);
  }

  bool ok = true;
  for (int i = 1; ok and i <= N; ++i) {
    int interval = T[i] - T[i - 1];
    int d = abs(X[i] - X[i - 1]) + abs(Y[i] - Y[i - 1]);
    if (d > interval) { ok = false; }
    if ((d - interval) % 2 != 0) { ok = false; }
  }
  printf("%s\n", ok ? "Yes" : "No");
  return 0;
}


Measured memory_bytes: 1408
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SimpleCalculator
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string line = Console.ReadLine();
                string[] strs = line.Split(' ');
                int lValue = int.Parse(strs[0]);
                string op = strs[1];
                int rValue = int.Parse(strs[2]);
                SimpleCalculator problem = new SimpleCalculator();
                if (op.Equals("?")) break;

                int answer = 0;
                if (op.Equals("+")) answer = problem.Sum(lValue, rValue);
                if (op.Equals("-")) answer = problem.Sub(lValue, rValue);
                if (op.Equals("*")) answer = problem.Mul(lValue, rValue);
                if (op.Equals("/")) answer = problem.Div(lValue, rValue);
                Console.WriteLine(answer);
                
            }
        }
    }

    /// <summary>
    /// 単純な計算機クラス
    /// </summary>
    public class SimpleCalculator
    {
        public int Sum(int lValue, int rValue)
        {
            return lValue + rValue;
        }

        public int Sub(int lValue, int rValue)
        {
            return lValue - rValue;
        }

        public int Mul(int lValue, int rValue)
        {
            return lValue * rValue;
        }

        public int Div(int lValue, int rValue)
        {
            return lValue / rValue;
        }

    }
}

Measured memory_bytes: 5616
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main(){
    int N;
    string S;
    cin >> N >> S;
    if(N!=0){
        for(int i = 0;i<N;i++){
            for(int j =0;j<S.size();j++){
                if(S[j]=='Z'){
                    S[j]-=25;
                }
                else{
                    S[j] += 1;
                }
            }
        }
    }
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
#define MOD 1000000007
using namespace std;
int matrix[1010][1010];
signed main() {
  int H, W, A, B;
  cin >> H >> W >> A >> B;
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (j < A && i < B) {
        cout << 0;
      } else if (j < A && i >= B) {
        cout << 1;
      } else if (j >= A && i < B) {
        cout << 1;
      } else {
        cout << 0;
      }
    }
    cout << endl;
  }
}



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

int main()
{
    std::string b, res;
    std::cin >> b;

    if (b == "A")
    {
        res = "T";
    }
    else if (b == "T")
    {
        res = "A";
    }
    else if (b == "C")
    {
        res = "G";
    }
    else if (b == "G")
    {
        res = "C";
    }
    std::cout << res << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL; 
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<=n;i++)
	{
		if(i%4==0 && (n-i)%7==0)
		{
			printf("Yes");
			return 0;
		}
	}
	printf("No");
	return 0;
}

Measured memory_bytes: 256