akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import static java.lang.System.*;

class Main {
	public static Scanner sc = new Scanner(in);
	public static Random rand=new Random();


	public void run() {
		while(true){
			int n=sc.nextInt(),m=sc.nextInt(),p=sc.nextInt();
			if(n==0 && m==0 && p==0)return;
			int[] x=nextIntArray(n);

			int sum=0,winner=x[m-1];
			for(int i=0;i<n;i++){
				sum+=x[i];
			}

			ln(winner==0?0:sum*(100-p)/winner);
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}

	public int[] nextIntArray(int n){
		int[] res=new int[n];
		for(int i=0;i<n;i++){
			res[i]=sc.nextInt();
		}
		return res;
	}
	public static void pr(Object o) {
		out.print(o);
	}
	public static void ln(Object o) {
		out.println(o);
	}
	public static void ln() {
		out.println();
	}
}

Measured memory_bytes: 27724
#include<iostream>
#include<complex>
#include<cmath>
#include<algorithm>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define EPS 1e-10
#define PI 3.141592653589793238
// sqrt重い
using namespace std;
typedef pair<double,double> P;

void display(complex<double> a,complex<double> b){
 cout << "(" << a.real() <<"," << a.imag() <<")"<< " " <<"("<< b.real() <<"," <<b.imag() << ")" << endl;
}

int main(){
  int n,ans;
  double xin,yin,X;
  complex<double> m;
  while(cin >> n && n){
    ans = 1;
    complex<double> point[n];
    for(int i=0;i<n;i++){
      cin >> xin >> yin;
      point[i] = complex<double>(xin,yin);
    }
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	if(i == j)continue;
	complex<double> Rr = point[i]-point[j];
	if(abs(Rr) <= 2+EPS){

	  complex<double> UKPC,U,P1,P2;
	  UKPC = (point[i]+point[j])*0.5;       
	  double T = sqrt(1-norm(point[i]-point[j])*0.25);

	  UKPC = (point[i]+point[j])*0.5;
  	  P1 = UKPC + (point[i]-point[j])/abs(point[i]-point[j])*polar(T,PI/2.0);
	  P2 = UKPC + (point[i]-point[j])/abs(point[i]-point[j])*polar(T,-PI/2.0);
	  //cout << "P1 = " << P1 << ", P2 = " << P2 << endl;
	  int cnt=0;
	  complex<double> CalcP;
	  double Calc;
	  for(int k=0;k<n;k++){
	    Calc = abs(P1-point[k]);
	    if(Calc < 1.0+EPS){
	      cnt++;
	    }
	  }	

	  ans = max(ans,cnt);
	  cnt = 0;
	  for(int k=0;k<n;k++){
	    Calc = abs(P2-point[k]);
	    if(fabs(Calc) < 1.0+EPS){
	      cnt++;
	    }
	  }	
  
	  ans = max(ans,cnt);
	  

	}

      }
    }

    cout << ans << endl;

  }
  return 0;
}

Measured memory_bytes: 988
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}

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

  string str;
  cin >> str;

  ll ans = 0;
  
  ll l = 0;
  ll r = str.size()-1;
  while(l<r){
    if(str[l]=='x' && str[r]!='x'){
      ans ++; l++;
    }
    else if(str[l]!='x' && str[r]=='x'){
      ans ++; r--;
    }
    else if(str[l]=='x' && str[r]=='x'){
      l++; r--;
    }
    else if(str[l]!='x' && str[r]!='x'){
      if(str[l]!=str[r]){
	cout << -1 << endl;
	return 0;
      }
      else{
	l++;r--;
      }
    }
    
  }

  cout << ans << endl;
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e3+5;
const int INF = 0x3f3f3f3f;

int a[N];

int main(){	
	int n;
	scanf("%d",&n);
	for(int i = 1;i <= n;++i) scanf("%d",&a[i]);
	
	int ans = INF;
	for(int i = 1;i <= 100;++i){
		int sum = 0;
		for(int j = 1;j <= n;++j) sum += (i-a[j])*(i-a[j]);
		ans = min(ans,sum);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
	string s;
	cin>>s;
	ll l=0,r=s.size()-1,ans=0;
	while(l<r){
		if(s[l]==s[r]){
			l++;
			r--;
		}else{
			if(s[l]=='x'){
				l++;
				ans++;
			}
			else if(s[r]=='x'){
				r--;
				ans++;
			}
			else{
				cout<<-1<<"\n";
				return 0;
			}
		}
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <random>
#include <stdio.h>
#include <bitset>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

typedef long long LL;
typedef long double LD;
typedef string ST;


#define REP(i,n) for(LL (i)=0;(i)<(n);(i)++)
#define ALL(v) v.begin(), v.end()
#define PRINTLN(v) for(auto (a): v )   cerr << a << endl
#define PRINTSP(v) for(auto (a): v ) {cerr << a << " ";} cerr << endl


void func() {
  LL N;
  cin >> N;
  vector<LL> A(N);
  REP(i, N) {
    LL a;
    cin >> a;
    A[i] = a - (i + 1);
  }
  //PRINTSP(A);
  sort(ALL(A));
  //PRINTSP(A);
  LL median = A[N / 2];
  
#if 0
  for (LL m = -10; m <= 10; m++) {
    LL kanasisa = 0;
    REP(i, N) {
      kanasisa += abs(A[i] - m);
    }
    cout << m << " : " << kanasisa << endl;

  }
#endif
 
  LL kanasisa = 0;
  REP(i, N) {
    kanasisa += abs(A[i] - median);
  }
  cout << kanasisa;

}

#ifdef CALC_TIME 
#include <windows.h>
int main()
{
  LARGE_INTEGER freq;
  QueryPerformanceFrequency(&freq);
  LARGE_INTEGER start, end;
  QueryPerformanceCounter(&start);
  // 何かの処理
  func();
  QueryPerformanceCounter(&end);
  double time = static_cast<double>(end.QuadPart - start.QuadPart) * 1000.0 / freq.QuadPart;
  fprintf(stderr, "\n%lf[ms]\n", time);
  return 0;
}
#else 
int main()
{
  func();
  return 0;
}
#endif





Measured memory_bytes: 1792
import java.util.*;
public class Main {
    public static void main(String[] args){
        String[] cal;
        Scanner sc = new Scanner(System.in);
        String S = sc.nextLine();
        String[] difs = S.split("/");
        int dif0 = Integer.parseInt(difs[0]);
        int dif1 = Integer.parseInt(difs[1]);
        int dif2 = Integer.parseInt(difs[2]);
        if(dif0 <= 2019 && dif1 <= 4 && dif2 <= 30){
            System.out.print("Heisei");
        }else{
            System.out.print("TBD");
        }
    }
}

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

int main() {

  int N,A,P;
  
  cin >> N;
  cin >> A;
   
    P = N % 500;
    
    if(P<=A){
      cout << "Yes" << endl; 
    }
    
    else{
      cout << "No" << endl; 
    }
}


Measured memory_bytes: 256
from scipy.sparse import*;N=int(input());Z=[[i]+list(map(int,input().split()))for i in range(N)]
def X(k):Z.sort(key=lambda a:a[k]);return{(min(abs(b-e),abs(c-f)),a,d)for(a,b,c),(d,e,f)in zip(Z,Z[1:])}
d,*x=zip(*X(1)|X(2));print(int(csgraph.minimum_spanning_tree(csr_matrix((d,x),(N,N))).sum()))

Measured memory_bytes: 78504
import sys
import math
import copy
import heapq
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter
sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = float("inf")
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)

def nck(n, k, kaijyo):
    return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD

def npk(n, k, kaijyo):
    if k == 0 or k == n:
        return n % MOD
    return (kaijyo[n] * divide(kaijyo[n-k])) % MOD

def fact_and_inv(SIZE):
    inv = [0] * SIZE  # inv[j] = j^{-1} mod MOD
    fac = [0] * SIZE  # fac[j] = j! mod MOD
    finv = [0] * SIZE  # finv[j] = (j!)^{-1} mod MOD
    inv[1] = 1
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    for i in range(2, SIZE):
        inv[i] = MOD - (MOD // i) * inv[MOD % i] % MOD
        fac[i] = fac[i - 1] * i % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD

    return fac, finv

class TwoDimGrid:
    # 2次元座標 -> 1次元
    def __init__(self, h, w, wall="#"):
        self.h = h
        self.w = w
        self.size = (h+2) * (w+2)
        self.wall = wall
        self.get_grid()
        self.init_cost()

    def get_grid(self):
        grid = [self.wall * (self.w + 2)]
        for i in range(self.h):
            grid.append(self.wall + getS() + self.wall)

        grid.append(self.wall * (self.w + 2))
        self.grid = grid
    def init_cost(self):
        self.cost = [INF] * self.size

    def pos(self, x, y):
        return y * (self.w + 2) + x
    def getgrid(self, x, y):
        return self.grid[y][x]
    def get(self, x, y):
        return self.cost[self.pos(x, y)]
    def set(self, x, y, v):
        self.cost[self.pos(x, y)] = v
        return
    def show(self):
        for i in range(self.h+2):
            print(self.cost[(self.w + 2) * i:(self.w + 2) * (i+1)])

    def search(self, s, g):
        grid = self.grid
        move = [(0, 1), (0, -1), (1, 0), (-1, 0)]
        move_eight = [(0, 1), (0, -1), (1, 0), (-1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]



def solve():
    h, w = getList()
    cost = []
    for i in range(10):
        cost.append(getList())

    V = 10
    for k in range(V):
        for i in range(V):
            for j in range(V):
                if cost[i][k] != INF and cost[k][j] != INF:
                    cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j])

    wall = []
    ans = 0
    for i in range(h):
        for num in getList():
            if num != -1:
                ans += cost[num][1]
    print(ans)
    # print(cost)
    return
def main():
    n = getN()
    for _ in range(n):
        solve()

    return
if __name__ == "__main__":
    # main()
    solve()

Measured memory_bytes: 74572
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define re register
#define gc getchar
#define pc putchar
#define st static
#define cs const

inline
ll getint(){
    re ll num=0;
    re char c=gc();
    while(!isdigit(c))c=gc();
    while(isdigit(c))num=(num<<1)+(num<<3)+(c^48),c=gc();
    return num;
}

int n,a[300005];

inline
bool check(int l,int r){
    int maxn=0,minn=n+1;
    for(int re i=l;i<=r;++i){
        maxn=max(maxn,a[i]);
        minn=min(minn,a[i]);
    }
    if(maxn!=r||minn!=l)return false;
    int submaxn=0;
    maxn=0;
    for(int re i=l;i<=r;i+=2){
        if(maxn<a[i])maxn=a[i];
        else if(submaxn<a[i])submaxn=a[i];
        else return false;
    }
    return true;
}

int main(){
    n=getint();
    for(int re i=1;i<=n;++i){
        a[i]=getint();
    }
    for(int re i=1;i<=n;++i){
        if(a[i]==i)continue;
        int p;
        for(p=i;p<=n-2;p+=2){
            if(a[p+1]!=p+1||a[p+2]==p+2)break;
        }
        if(!check(i,p)){
            puts("No");
            return 0;
        }
        i=p;
    }
    puts("Yes");
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-10;
const bool debug = 0;
//----------------------//

int a, b, c;

int main() {
	cin >> a >> b >> c;
	
	int ans[3][3] = {};
	FOR(s, -1000, 1000) {
		ans[0][0] = a;
		ans[0][1] = b;
		ans[1][1] = c;
		ans[0][2] = s - a - b;
		ans[2][1] = s - ans[0][1] - ans[1][1];
		ans[2][2] = s - a - c;
		ans[2][0] = s - ans[2][2] - ans[2][1];
		ans[1][0] = s - ans[0][0] - ans[2][0];
		ans[1][2] = s - ans[1][0] - ans[1][1];
		
		bool ok = true;
		REP(i, 3) {
			int sum = 0;
			REP(j, 3) sum += ans[i][j];
			ok &= sum == s;
		}
		
		REP(j, 3) {
			int sum = 0;
			REP(i, 3) sum += ans[i][j];
			ok &= sum == s;
		}
		
		ok &= ans[0][0] + ans[1][1] + ans[2][2] == s;
		ok &= ans[2][0] + ans[1][1] + ans[0][2] == s;
		
		if (ok) {
			REP(i, 3) REP(j, 3) printf("%d%c", ans[i][j], j == 2 ? '\n' : ' ');
			return 0;
		}
	}
	
	return 0;
}


Measured memory_bytes: 256
import collections as cl
def l(): #intのlist
    return list(map(int,input().split()))
def onem(): #Nとかの取得
    return int(input())
n = onem()

on = []
de = cl.deque()
ppp = [n-1 for i in range(n)]
for i in range(n):
    k = l()
    for j in range(n-1):
        k[j] -= 1
    k.reverse()
    de.append([k[0],i])
    on.append(cl.deque(k))


co = 1
ddd = cl.deque()
de.append([-1,-1])
ppppp = [1 for i in range(n)]
cl = ppppp[:]
while de:
    kkk = de.popleft()
    if kkk[0] == -1 and kkk[1] == -1:
        if sum(cl) == n:
            co = -1
            break
        if len(de) == 0:
            break
        de.append([-1,-1])
        co += 1
        cl = ppppp[:]

    elif ppp[kkk[0]] != 0 and on[kkk[0]][0] == kkk[1] and cl[kkk[0]] and cl[kkk[1]]:
        cl[kkk[0]] = 0
        cl[kkk[1]] = 0
        on[kkk[0]].popleft()
        on[kkk[1]].popleft()
        ppp[kkk[0]] -= 1
        ppp[kkk[1]] -= 1
        if ppp[kkk[1]] != 0 != 0 and ppp[kkk[0]] != 0 and on[kkk[1]][0] == kkk[0] and on[kkk[0]][0] == kkk[1]:
            de.append([on[kkk[1]][0],kkk[1]])
        else:
            if len(on[kkk[1]]) != 0:
                de.append([on[kkk[1]][0],kkk[1]])
            if len(on[kkk[0]]) != 0:
                de.append([on[kkk[0]][0],kkk[0]])


print(co)


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

int main(){

  double w,h;
  double x,y;
  double s;

  scanf("%lf %lf %lf %lf", &w, &h, &x, &y);

  s = (w * h)/2;

  printf("%f ", s);

  if(x == w/2 && y == h/2) printf("1\n");

  else printf("0\n");

  return 0;
}


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

using namespace std;

void solve()
{
	int n,m,ans=0;
	cin>>n >> m;
	for(int i=0;i<n;i++){
		double a,b;
		cin >> a >>b;
		double k=(a*a)+(b*b);
		k= sqrt(k);
		if(m<k)
			ans++;
	}
	cout << n-ans << endl;
}

int32_t main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	
	//int t;cin >> t;while(t--)
		solve();

	return 0;
}

Measured memory_bytes: 3788
from random import *
D=int(input())
C=list(map(int,input().split()))
S=[list(map(int,input().split())) for i in range(D)]
X=[0]*26
XX=X[:]
Y=X[:]
YY=X[:]
P=[]
SC=0
N,M,L,O=0,0,0,0
for i in range(D):
  for j in range(26):
    X[j]+=C[j]
    XX[j]+=X[j]
  N,M=-1,-10**20
  L,O=N,M
  for j in range(26):
    if Y==-1:
      N,M=0,X[0]+S[i][0]
    if M<X[j]+S[i][j]:
      L,O=N,M
      N,M=j,X[j]+S[i][j]
    elif O<X[j]+S[i][j]:
      L,O=j,X[j]+S[i][j]
  XX[N]-=X[N]
  X[N]=0
  P.append([N,L])
  SC+=X[N]
SC2=0
for i in range(10**5):
  SC2=SC
  d,q=randrange(0,D),randrange(0,26)
  SC2-=S[d][P[d][0]]
  SC2+=S[d][q]
  for j in range(26):
    Y[j]=0
  YY[P[d][0]],YY[q]=0,0
  for j in range(D):
    if j==d:
      Z=q
    else:
      Z=P[j][0]
    Y[P[d][0]]+=C[P[d][0]]
    Y[q]+=C[q]
    Y[Z]=0
    YY[P[d][0]]+=Y[P[d][0]]
    YY[q]+=Y[q]
  if SC2-sum(YY)>=SC-sum(XX) or randrange(0,1000)==0:
    P[d][0]=q
    XX=YY[:]
    SC=SC2
for d in range(D):
  for q in range(26):
    SC2=SC
    SC2-=S[d][P[d][0]]
    SC2+=S[d][q]
    for j in range(26):
      Y[j]=0
    YY[P[d][0]],YY[q]=0,0
    for j in range(D):
      if j==d:
        Z=q
      else:
        Z=P[j][0]
      Y[P[d][0]]+=C[P[d][0]]
      Y[q]+=C[q]
      Y[Z]=0
      YY[P[d][0]]+=Y[P[d][0]]
      YY[q]+=Y[q]
    if SC2-sum(YY)>=SC-sum(XX):
      P[d][0]=q
      XX=YY[:]
      SC=SC2
for i in range(D):
  SC2=SC
  d,q=i,P[i][1]
  SC2-=S[d][P[d][0]]
  SC2+=S[d][q]
  for j in range(26):
    Y[j]=0
  YY[P[d][0]],YY[q]=0,0
  for j in range(D):
    if j==d:
      Z=q
    else:
      Z=P[j][0]
    Y[P[d][0]]+=C[P[d][0]]
    Y[q]+=C[q]
    Y[Z]=0
    YY[P[d][0]]+=Y[P[d][0]]
    YY[q]+=Y[q]
  if SC2-sum(YY)>=SC-sum(XX):
    P[d]=P[d][::-1]
    XX=YY[:]
    SC=SC2
for i in range(D):
  print(P[i][0]+1)

Measured memory_bytes: 86500
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.Arrays;

class Main {

    public static void main(String[] args) throws IOException {
        doit(args, System.in, System.out);
    }

    static void doit(String[] args, InputStream in, PrintStream out)
            throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        int n = Integer.parseInt(reader.readLine());
        for (int i = 0; i < n; i++) {
            char[] numbers = reader.readLine().toCharArray();
            Arrays.sort(numbers);
            int minValue = 0;
            int maxValue = 0;
            int minDigit = 10000000;
            int maxDigit = 1;
            for (int j = 0; j < 8; j++) {
                int number = numbers[j] - '0';
                minValue += number * minDigit;
                maxValue += number * maxDigit;
                minDigit /= 10;
                maxDigit *= 10;
            }
            out.println(maxValue - minValue);
        }
    }
}

Measured memory_bytes: 9304
#include<cstdio>
using namespace std;
int main(){
	int t;
	scanf("%d", &t);
	while(t--){        
		int a, b = -1, c = -1;
		bool flag = true;
		for(int i = 1; i <= 10; i++){
			scanf("%d", &a);
			if(flag){
				if(a > b)   //????¬?????????????b??¶?????¢??? 
					b = a;
				else if(a > c)
					c = a;
				else
					flag = false;
			}
		}
		printf("%s\n", flag? "YES" :"NO");
	}
	return 0;
}

Measured memory_bytes: 2588
#include <iostream>
#include <queue>
#include <map>
#define INF 10000000
using namespace std;

typedef pair<int, int> P;

int H, W, N;
int d[1000][1000];
char cell[1000][1000];
int si, sj, sum = 0;

void bfs(P start, int search){
	//4????????¨
	int vi[4] = {0, 0, -1, 1}, vj[4] = {-1, 1, 0, 0};

	int gi, gj;

	//???????????¢???INF?????????????????????????????´???????????§?¨??????????
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			d[i][j] = INF;
			if(cell[i][j] == search + '0'){
				gi = i;
				gj = j;
			}
		}
	}

	//start??????????????¢0????????????
	d[start.first][start.second] = 0;

	queue<P> que;
	que.push(start);

	while(!que.empty()){
		P p = que.front();
		que.pop();

		//?????´??§break
		if(p.first == gi && p.second == gj) break;

		//next(i, j)
		int ni, nj;

		//4?????????
		for(int i=0;i<4;i++){
			ni = p.first + vi[i];
			nj = p.second + vj[i];

			if(ni >= 0 && ni < H && nj >= 0 && nj < W && cell[ni][nj] != 'X' && d[ni][nj] == INF){
				que.push(P(ni, nj));
				d[ni][nj] = d[p.first][p.second] + 1;
			}
		}
	}

	sum += d[gi][gj];

	if(search != N)	bfs(P(gi, gj), search+1);
}

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

	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			cin >> cell[i][j];
			if(cell[i][j] == 'S'){
				si = i;
				sj = j;
			}
		}
	}
	
	bfs(P(si, sj), 1);

	cout << sum << endl;
}

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

class Util{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		int X = ri();

        string ans = "No";
        if(X >= 30) ans = "Yes";
        
		Console.WriteLine(ans);
		Console.ReadLine();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
    static int[] generateNums(int num, int N){return Enumerable.Repeat(num, N).ToArray();}
    static int[] generateSuretsu(int N){return Enumerable.Range(0, N).ToArray();}
}

public static class Combination {
	//使い方:int[][] Is = Combination.Enumerate(nums, k, withRepetition:false).ToArray();
    public static IEnumerable<T[]> Enumerate<T>(IEnumerable<T> items, int k, bool withRepetition) {
        if (k == 1) {
            foreach (var item in items)
                yield return new T[] { item };
            yield break;
        }
        foreach (var item in items) {
            var leftside = new T[] { item };

            // item よりも前のものを除く （順列と組み合わせの違い)
            // 重複を許さないので、unusedから item そのものも取り除く
            var unused = withRepetition ? items : items.SkipWhile(e => !e.Equals(item)).Skip(1).ToList();

            foreach (var rightside in Enumerate(unused, k - 1, withRepetition)) {
                yield return leftside.Concat(rightside).ToArray();
            }
        }
    }
}


Measured memory_bytes: 27528
#include<iostream>
#include<cmath>
using namespace std;
int main(){
    long long int h;cin >> h;;
    int t = 0;
    while(h > 0){
        h /= 2;
        t++;
    }
    long long int ans = 1;
    for(int i = 0; i < t; i++){
        ans *= 2;
    }
    --ans;
    cout << ans << "\n";
}

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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

constexpr int mod = 1e9 + 7;
constexpr int32_t inf = 1001001001;
constexpr int64_t infll = 1001001001001001001ll;
constexpr int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const string YES = "YES", NO = "NO", Yes = "Yes", No = "No", yes = "yes", no = "no";

// clang-format off
// ostream &operator<<(ostream &os, __int128_t value) { if (ostream::sentry(os)) { __uint128_t tmp = value < 0 ? -value : value; char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __int128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } if (in[0] == '-') value *= -1; return is; }
// ostream &operator<<(ostream &os, __uint128_t value) { if (ostream::sentry(os)) { char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[value % 10]; value /= 10; } while (value != 0); int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __uint128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } return is; }
template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { os << v[0]; for (int i = 1; i < v.size(); ++i) os << " " << v[i]; return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;

inline int64_t in() { int64_t x = 0; cin >> x; return x; }

template <typename T> void sort(vector<T> &v) { sort(all(v)); }
template <typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

signed main(int argc, char *argv[]) {
  int64_t n = in(), m = in();
  string s, t;
  cin >> s >> t;

  int64_t d = __gcd(n, m), ans = n / d * m;
  bool f = true;
  int64_t a = 0, b = 0;
  for (int i = 0; i < d; ++i) {
    if (s[a] != t[b]) f = false;
    a += n / d;
    b += m / d;
  }

  cout << (f ? ans : -1) << endl;
}


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

using namespace std;

int main()
{
    string S;
    cin >> S;
    int min = 1000;
    for (int i = 0; i < S.length() - 2; ++i)
    {
        string strNum = S.substr(i, 3);
        int num = stoi(strNum);
        int diff = abs(num - 753);
        if (diff < min) min = diff;
    }
    cout << min << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int cost[105];
int n,w;
int value[105];
ll dp[101][100005];
ll call(int pos,int w)
{
    if(w<=0 || pos==n)return 0;
    if(dp[pos][w]!=-1)return dp[pos][w];
    ll hh=0;
    if(value[pos]<=w)hh=call(pos+1,w-value[pos])+cost[pos];
    return dp[pos][w]=max(hh,call(pos+1,w));
}
int main()
{
    memset(dp,-1,sizeof dp);
    cin>>n>>w;
    for(int i=0;i<n;i++)cin>>value[i]>>cost[i];
    cout<<(ll)call(0,w);

}


Measured memory_bytes: 79232
#include <iostream>
#include <vector>
#include <bits/stdc++.h>

using namespace std;


long long int a,b[100010],c[100010],d[100010],ans =0,ant=0;

int main(){
  cin >> a;
  
    for(int i=0;i<a;i++)
      cin >> b[i];
  
   c[0] = b[0];
  {
  if(c[0]<=0){
    ans+=1-c[0];
    c[0] =1;
  }
  }
  
  
  for(int i=0;i<a-1;i++){
     
      c[i+1] = c[i]+ b[i+1];
    
    if((i+1)%2 == 0 && c[i+1] <=0){
      ans += abs(1-c[i+1]);
      c[i+1] = 1;
    }
    
    else if((i+1)%2 != 0 && c[i+1] >= 0){
    ans+= abs(c[i+1]+1);
      c[i+1] = -1;
    }
  }
  
   d[0] = b[0];
  {
  if(d[0] >=0){
    ant+= d[0]+1;
    d[0] =-1;
  }
  }
  for(int i=0;i<a-1;i++){
     
      d[i+1] = d[i]+ b[i+1];
    
    if((i+1)%2 != 0 && d[i+1] <=0){
      ant += abs(1-d[i+1]);
      d[i+1] = 1;
    }
    
    else if((i+1)%2 == 0 && d[i+1] >= 0){
    ant += abs(d[i+1]+1);
      d[i+1] = -1;
    }
  }
   
  cout << min(ans,ant) << endl;

  
  
  
}
      
	


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

using namespace std;

typedef long long ll;
#define fi first
#define se second
#define pb push_back

int main() {
    //ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, k;
    scanf("%d %d", &n, &k);
    int res = 0;
    for (int i = 0; i < n; i++) {
        int x;
        scanf("%d", &x);
        if (x >= k) res++;
    }
    printf("%d", res);
    
    return 0;
}


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

using namespace std;

int main()
{

    long long n, a[200005], pehele[200005], baadme[200005], ans=0;
    cin>>n;
    for(int i=1; i<=n; i++)
        cin>>a[i];
    stack<int> low;
    stack<int> up;
    a[0]=0;
    a[n+1]=0;
    low.push(0);
    up.push(n+1);
    for(int i=1; i<=n; i++)
    {
        while(true)
        {
            if(a[low.top()]<a[i]){
                pehele[i]=low.top();
                break;
            }
            else
                low.pop();
        }
        low.push(i);
    }
    for(int i=n; i>0; i--)
    {

        while(true)
        {

            if(a[up.top()]<a[i]){
                baadme[i]=up.top();
                break;
            }
            else
                up.pop();
        }
        up.push(i);
    }
    for(int i=1; i<=n; i++)
    {
            ans += a[i]*(baadme[i]-i)*(i-pehele[i]);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 5760
object Main extends App {
  val n = io.StdIn.readInt()
  val h = io.StdIn.readLine().split(' ').map(_.toInt)
  val dp = Array.fill(n)(-1)
  for (i <- 0 until n) {
    if (i == 0) dp(i) = 0
    else {
      val x = {
        val tmp = dp(i-1) + Math.abs(h(i-1) - h(i))
        if (i == 1) tmp else tmp.min(dp(i-2) + Math.abs(h(i-2) - h(i)))
      }
      if (dp(i) == -1 || x < dp(i)) dp(i) = x
    }
  }
  println(dp(n-1))
}

Measured memory_bytes: 40388
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<stack>
#include<queue>
#include<bitset>
#include<iomanip>

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

using namespace std;

typedef long long int lli;
typedef vector<int> vi;

int main() {
	double a, b;

	cin >> a >> b;

	cout << setprecision(14) << a / b;

	return 0;
}

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

using namespace std;

typedef int64_t ll;
typedef vector<ll> vi;

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

    string S; cin >> S;
    if (S.length() % 2 == 1) cout << "No";
    else {
        bool ok = true;
        for (ll i = 0; i < S.length()/2; i++) {
            if (S[i*2] != 'h' || S[i*2+1] != 'i') ok = false;
        }
        if (ok) cout << "Yes";
        else cout << "No";
    }
    return 0;
}


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

signed main(){
 lint N, M; cin >> N >> M;
  vector<lint> h(N);
  for(lint i = 0; i < N; i++) cin >> h[i];
  vector<lint> ans(N, 0);
  for(lint i = 0; i < M; i++){
    lint a, b; cin >> a >> b;
    if(h[a - 1] < h[b - 1]) ans[a - 1]--;
    if(h[a - 1] > h[b - 1]) ans[b - 1]--;
    if(h[a - 1] == h[b - 1]) ans[a - 1]--, ans[b - 1]--;
  }
  cout << count(ans.begin(), ans.end(), 0) << endl;
}

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

using namespace std;

int main()
{
  int N=26;
  string s;
  cin >> s;

  int packet[26]={0};

  for(int i = 0; s[i] != '\0'; ++i){
    ++packet[s[i] - 'a'];
  }

  for (int i = 0; i < N; i++) {
    if(packet[i] == 0){
      cout << (char)(i+'a') << endl;
      return 0;
    }
  }

  cout << "None" << endl;

  return 0;
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
string S;
  cin>>S;
  if(S=="SAT"){cout<<1;}
  else if (S=="SUN"){cout<<7;}
   else if (S=="MON"){cout<<6;}
   else if (S=="TUE"){cout<<5;}
   else if (S=="WED"){cout<<4;}
   else if (S=="THU"){cout<<3;}
   else if (S=="FRI"){cout<<2;}
 
 
 
 return 0;
}

Measured memory_bytes: 256
////////////////////////////////////////////////////////////////////
// This source code is for Visual Studio
////////////////////////////////////////////////////////////////////
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <stack>
#include <functional>
#include <iomanip>
#include <string>
#include <cstring>
#include <deque>
#include <math.h>
#include <assert.h>

#define	numberof(a)	(sizeof(a) / sizeof(a[0]))
#define	INF32		INT32_MAX
#define	INF64		INT64_MAX
#define Rep(i,n) for(int i = 0; i < (n); ++i )

using namespace std;

typedef vector< vector<int> > MAT;
typedef pair<int, int> PINT;
typedef long long ll;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int32_t s32;
typedef int64_t s64;

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

// main function
int main()
{
	ll N = 0;
	ll ans = 0;

	cin >> N;

	vector<ll> A(N, 0);
	vector<ll> B(N, 0);
	vector< pair<ll, ll> > C(N, make_pair(0, 0));
	Rep(i, N) {
		cin >> A[i] >> B[i];
		C[i].first = A[i] + B[i];
		C[i].second = i;
	}
	sort(C.begin(), C.end(), greater_equal< pair<ll, ll> >());
	Rep(i, N) {
		ll index = C[i].second;
		ans += (i % 2 == 0) ? A[index] : - B[index];
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

s64 mypow(s64 x, s64 n)
{
    s64 ret = 1;
    while (n > 0)
    {
        if (n & 1)
        {
            ret = ret * x % MOD;
        }
        x = x * x % MOD;
        n >>= 1;
    }
    return ret;
}

void comdiv(map<int, s64>& x, s64 y)
{
    map<int, s64> vy;
    for (int i = 2; i * i <= y; ++i)
    {
        s64 temp = 0;
        if (y % i == 0)
        {
            while (y % i == 0)
            {
                temp++;
                y /= i;
            }
            x[i] = MAX(x[i], temp);
        }
    }
    x[y] = MAX(x[y], 1);
}

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

    s64 N;
    s64 a;
    vs64 ainv;
    cin >> N;
    ainv.resize(N);
    map<int, s64> com;
    com[1] = 0;
    rep (i, N)
    {
        cin >> a;
        comdiv(com, a);
        ainv[i] = mypow(a, MOD - 2ULL);
    }

    s64 g = 1;
    for (auto mcom : com)
    {
        g *= mypow(mcom.first, mcom.second);
        g %= MOD;
    }

    s64 ans = 0;
    rep (i, N)
    {
        ans += (g * ainv[i]) % MOD;
        ans %= MOD;
    }

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



Measured memory_bytes: 1024
ans = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 24, 25, 27, 28,
       30, 32, 35, 36, 40, 42, 45, 48, 49, 54, 56, 63, 64, 72, 81]
a = int(input())
if a in ans:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 3060
s = input()
x = []
for i in range(len(s)):
    if s[i] == "0":
        x.append("0")
    elif s[i] == "1":
        x.append("1")
    elif s[i] == "B" and len(x) > 0 :
        x.pop(-1)
print("".join(x))

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

int m, n;
bool grid[90][90];
int dy[4] = {0, -1, 1, 0};
int dx[4] = {-1, 0, 0, 1};
int ans = 0;

void dfs(int y, int x, int cnt) {
	grid[y][x] = false;

	ans = max(ans, cnt);

	rep(i,4) {
		int ny = y + dy[i], nx = x + dx[i];
		if (0 <= ny && ny < n && 0 <= nx && nx < m && grid[ny][nx]) {
			dfs(ny, nx, cnt + 1);
		}
	}

	grid[y][x] = true;
}

signed main()
{
	while (true) {
		cin >> m >> n;
		if (m == 0 && n == 0) break;

		rep(i,n) rep(j,m) cin >> grid[i][j];

		ans = 0;
		rep(i,n) rep(j,m) if (grid[i][j]) {
			dfs(i, j, 1);
		}
		cout << ans << endl;

		/*
		rep(i,n) {
			rep(j,m) {
				if (grid[i][j]) printf("1 ");
				else printf("0 ");
			}
			cout << endl;
		}
		*/
	}
}

Measured memory_bytes: 1168
#include "bits/stdc++.h"
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = int(1e9) + 1;
const LL LLINF   = LL(1e18) + 1;
#define pow10(n) int(1e##n + n)

void solve()
{
    int A, B;
    cin >> A >> B;
    cout << max(max(A + B, A - B), A * B) << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.math.*;

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

    long[][] dp = new long[N][N];
    long ans = l(dp, a, 0, N - 1);
    System.out.println(ans);
  }

  private static long l(long[][] dp, int[] a, int head, int tail) {
    if (dp[head][tail] != 0) return dp[head][tail];
    if (head == tail) return a[head];
    long res = Math.max(
        a[head] - l(dp, a, head + 1, tail),
        a[tail] - l(dp, a, head, tail - 1));
    dp[head][tail] = res;
    return res;
  }
}

Measured memory_bytes: 129368
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include <iomanip>
using namespace std;

int main(){
	int n;
	cin>>n;
	if(n==22){
		cout<<"Christmas Eve Eve Eve"<<endl;
	}
	else if(n==23){
		cout<<"Christmas Eve Eve"<<endl;
	}
	else if(n==24){
		cout<<"Christmas Eve"<<endl;
	}
	else{
		cout<<"Christmas"<<endl;
	}
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <utility>

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810

int n, town;
int g[15][15];int d[15][15];


int main()
{
	while(cin>>n, n)
	{
		town = 0;
		REP(i,15)REP(j,15)
		{
			g[i][j] = INF;
			if(i==j) g[i][j] = 0;
		}
		REP(i,n)
		{
			int a,b,c;
			cin >> a >> b >> c;
			if(town < max(a,b)) town = max(a,b);
			g[a][b] = c;
			g[b][a] = c;
		}

		town++;

		REP(k,town)REP(i,town)REP(j,town)
		{
			g[i][j] = min(g[i][j],g[i][k]+g[k][j]);
		}
		int ans = INF;
		int anstown;
		REP(i,town)
		{
			int a = 0;
			REP(j,town)
			{
				a += g[i][j];
			}
			if(a < ans)
			{
				ans = a;
				anstown = i;
			}
		}
		cout << anstown <<" "<< ans <<endl;
	}

}

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

typedef pair<int, int> P;

int N;
int r[100];
int c[100][3];

int judge() {
	vector<P> sum(N);
	for(int i = 0; i < 3; i++) {
		vector<P> res(N);
		for(int j = 0; j < N; j++) {
			res[j] = { c[j][i], j };
		}
		sort(res.begin(), res.end());
		reverse(res.begin(), res.end());

		int v = r[0];
		for(int j = 0; j < N; j++) {
			if(j != 0 && res[j - 1].first != res[j].first) {
				v = r[j];
			}
			sum[res[j].second].first += v;
		}
	}
	for(int i = 0; i < N; i++) {
		sum[i].second = -i;
	}
	sort(sum.begin(), sum.end());
	reverse(sum.begin(), sum.end());
	for(int i = 0; i < N; i++) {
		if(sum[i].second == 0) return i;
	}
	assert(false);
	return -1;
}

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

	cin >> N;
	for(int i = 0; i < N; i++) {
		cin >> r[i];
	}
	for(int i = 0; i < N; i++) {
		for(int j = 0; j < 3; j++) {
			cin >> c[i][j];
		}
	}

	const int MAX = 101;
	int ans = MAX;
	for(int i = 0; i < 3; i++) {
		for(int j = 1; j <= MAX; j++) {
			c[0][i] += j;
			bool ok = judge() <= 7;
			c[0][i] -= j;
			if(ok) {
				ans = min(ans, j);
				break;
			}
		}
	}

	if(ans == MAX) {
		cout << "Saiko" << endl;
	}
	else {
		cout << ans << endl;
	}
}

Measured memory_bytes: 3208
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 2000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}

ll n, ans;
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> n;
    ll x; cin >> x;
    ans = x;
    rep(i, 1, n) {
        ll t;
        cin >> t;
        ans = lcm(ans, t);
    }
    cout << ans << endl;
    return 0;
}


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

#include <vector>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <climits>

using namespace std;


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

	vector<char> s(n);
	vector<int> arr(n);
	vector<int> answers(1000);
	vector<int> num(1000);

	for (int i = 0; i < n;i++) cin >> s[i];

	for(int i=0;i<n;i++)arr[i]= int(s[i] - '0');

	//数を判定
	int ans = 0;

	for (int i = 0; i < 1000; i++) {
		//iを3桁に変換
		int kurai1 = i / 100;
		int kurai2 = (i-kurai1*100) / 10;
		int kurai3 = i - kurai1 * 100 - kurai2 * 10;
		
		int count1 = 10;
		int count2 = 10;
		int count3 = 10;

		int point1 = 0;
		int point2 = 0;

		//100の位の数があるか
		for (int i = 0; i < n-2; i++) {
			if (arr[i] == kurai1) {
				count1 = arr[i];
				point1 = i;
				break;
			}
		}
		//10の位の数があるか（100の位がなければcontine）
		if (count1 == 10) {
			continue;
		}
		else {
			for (int i = point1 + 1; i < n - 1; i++) {
				if (arr[i] == kurai2) {
					count2 = arr[i];
					point2 = i;
					break;
				}
			}
			
		}

		//1の位の数があるか
		if (count2 == 10) {
			continue;
		}
		else {
			for (int i = point2 + 1; i < n; i++) {
				if (arr[i] == kurai3) {
					ans++;
					break;
				}
			}

		}

	}

	cout << ans << endl;
	

	return 0;
}


Measured memory_bytes: 3792
import math
N, A, B = map(int, input().split())
H = [0] * N
maxh = 0
for i in range(N):
  h = int(input())
  H[i] = h
  maxh = max(h, maxh)
lower = 0
upper = math.ceil(maxh / B)
def search(upper, lower):
  if lower + 1 == upper:
    return upper
  else:
    mid = (upper + lower) // 2
    _H = [h - mid * B for h in H]
    cnt = 0
    for h in _H:
      if h > 0:
        cnt += math.ceil(h / (A - B))
    if cnt <= mid:
      return search(mid, lower)
    else:
      return search(upper, mid)
print(search(upper, lower))

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

#define rep(i, n) for(int i=0; i<n; ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
#define ll long long int

int main(){
    int x, y, z;
    cin>>x>>y>>z;
    cout << z<<" "<<x<<" "<<y << endl;
    return 0;
}


Measured memory_bytes: 3584
def BFS(graph):
    flags = [False]*n
    deque = collections.deque()
    deque.append(min(graph.keys()))
    while len(deque) > 0:
        item = deque.popleft()
        for i in graph[item]:
            if flags[i-1] == False:
                deque.append(i)
                flags[i-1] = True
    return all(flags)

import collections
def solve(n, m, ab_list):
    count = 0

    for i in range(m):
        graph = {}
        tmp_list = ab_list.copy()
        tmp_list.pop(i)
        for a, b in tmp_list:
            if a not in graph:
                graph[a] = []

            if b not in graph:
                graph[b] = []

            graph[a].append(b)
            graph[b].append(a)
        tmp = BFS(graph)
        if tmp == False:
            count += 1

    return count

if __name__ == "__main__":
    n, m = [int(i) for i in input().split()]
    ab_list = [[int(j) for j in input().split()] for i in range(m)]
    print(solve(n, m, ab_list))


Measured memory_bytes: 3316
t = input()
n = len(t)
moji = ""
res = ""
if t[-1] ==  "?":
    moji = "P"
    
for i in range(n-1, 0, -1):
    if t[i] == "?":
        if moji == "D" and t[i -1] == "D":
            res += "P"
        elif moji == "P" or moji == "D" and t[i -1] == "P" :
            res += "D"
        elif moji == "P"  and t[i -1] == "?" :
            res += "D"            
        elif moji == "D"  and t[i -1] == "?" :
            res += "P"
           
    else:
        res += t[i]
    moji = res[-1]
if t[0] ==  "?":
    if moji == "P":
        res += "D"
    else:
        res += "P"
else:
    res += t[0]

res = res[::-1]
print(res)

Measured memory_bytes: 9468
//A
#include <bits/stdc++.h>
#define reg register

using namespace std;

typedef long long ll;
const int maxn = 100005;

inline ll read() {
    reg ll s = 0, t = 0; reg char ch = getchar();
    while (!isdigit(ch)) t |= ch == '-', ch = getchar();
    while (isdigit(ch)) s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}

int M, d;
bool used[102];
int main() {
    M = read(), d = read(); int ans = 0;
    for (reg int m = 1; m <= M; m++) {
        memset(used, 0, sizeof(used));
        for (int i = 2; i <= sqrt(m); i++) {
            if (m % i == 0) {
                if (i + 10 * (m / i) <= d && i < 10 && (m / i) < 10) used[i + 10 * (m / i)] = true;
                if (m / i + 10 * i <= d && i < 10 && (m / i) < 10) used[m / i + 10 * i] = true;
            }
        }
        for (reg int i = 1; i <= d; i++) ans += used[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 200003
#define f(i,n) for(int i=0;i<(int)(n);i++)
#define N 200000


int main() {
	printf("%d\n", 30844);
	printf("< 2 0 4\n");
	printf("< 2 1 5\n");
	printf("+ 4 5 3\n");
	printf("< 2 3 11\n");
	f(i, 60)printf("+ %d %d %d\n", 11 + i, 11 + i, 12 + i);
	for (int i = 29; i >= 0; i--) {
		f(j, i)printf("+ %d %d %d\n", 100 + i, 11 + j, 100 + i);
		printf("< %d %d %d\n", 100 + i, 0, 200 + i);
		printf("< %d %d %d\n", 2, 200 + i, 500);
		f(j, i)printf("+ %d %d %d\n", 500 + j, 500 + j, 501 + j);
		printf("+ %d %d %d\n", 700, 500 + i, 700);
		printf("+ %d %d %d\n", 99 + i, 700, 99 + i);
	}
	for (int i = 29; i >= 0; i--) {
		f(j, i)printf("+ %d %d %d\n", 300 + i, 11 + j, 300 + i);
		printf("< %d %d %d\n", 300 + i, 1, 400 + i);
		printf("< %d %d %d\n", 2, 400 + i, 500);
		f(j, i)printf("+ %d %d %d\n", 500 + j, 500 + j, 501 + j);
		printf("+ %d %d %d\n", 800, 500 + i, 800);
		printf("+ %d %d %d\n", 299 + i, 800, 299 + i);
	}

	f(i, 30) {
		f(j, 30) {
			printf("+ %d %d %d\n", 200 + i, 400 + j, 1000);
			printf("< 11 %d %d\n", 1000, 1000);
			f(ii, i + j)printf("+ %d %d %d\n", 1000 + ii, 1000 + ii, 1001 + ii);
			printf("+ 2 %d 2\n", 1000 + i + j);
		}
	}

	return 0;
}


Measured memory_bytes: 1508
#include<bits/stdc++.h>
using namespace std;
typedef long long l;
int main(){
    l N;
    cin>>N;
    l i,j,a,b;
    l n,h,w;
    for(i=1;i<3500;i++){
        for(j=1;j<3500;j++){
            a = N*i*j;
            b = 4*i*j - N*j - N*i;
            if(b !=0 && a%b==0 && a/b >= 1 ) {
                h = i;
                n =j;
                w = a/b;
                break;
            }
        }
        
    }
    cout<<h<<" "<<n<<" "<<w;
    return 0;
}


Measured memory_bytes: 256
import math
S = input()
ans = [0] * len(S)
# 左から右に見ていく
flag = False
n = 0
for i, c in enumerate(S):
  if flag:
    if c == 'R':
      n += 1
    else:
      # ここで振動し始める
      ans[i-1] += math.ceil(n/2)
      ans[i] += math.floor(n/2)
      n = 0
      flag = False
  else:
    if c == 'R':
      n = 1
      flag = True

# 右から左に見ていく
flag = False
n = 0
for i, c in reversed(list(enumerate(S))):
  if flag:
    if c == 'L':
      n += 1
    else:
      # ここで振動し始める
      ans[i+1] += math.ceil(n/2)
      ans[i] += math.floor(n/2)
      n = 0
      flag = False
  else:
    if c == 'L':
      n = 1
      flag = True
print(' '.join(map(str, ans)))

Measured memory_bytes: 14324
#include<iostream>
#include<vector>
#include<map>
using namespace std;

typedef pair<int,int> P;

int n,m;
vector<P> g[500];
int a,b,c;
int d[500];

int rec(int v){
  if(d[v]>=0)return d[v];

  int res = 0;
  for(int i=0;i<g[v].size();i++){
    res = std::max(res,g[v][i].first + rec(g[v][i].second));
  }
  return d[v] = res;
}

int main(){
  cin >> n >> m;
  for(int i=0;i<m;i++){
    cin >> a >> b >> c;
    g[b].push_back(P(c,a));
  }

  for(int i=0;i<n;i++)d[i]=-1; d[0] = 0;
  cout << rec(n-1) << endl;
}

Measured memory_bytes: 1216
import scala.io.StdIn
 
object Main {
  def main(args: Array[String]){

    @annotation.tailrec
    def f(t: Int, r: Int, n: Int): (Int, Int) =
        if (r >= t) f(t, r - t, n + 1) else (n, r)
		
    val ss = StdIn.readLine().toInt
    val (hh, ss2) = f(3600, ss,  0)
    val (mm, ss3) = f(60,   ss2, 0)
    println(f"${hh}%d:${mm}%d:${ss3}%d")
  }
}


Measured memory_bytes: 43928