akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main(){

  int tAtack,tHp;
  int aAtack,aHp;

  cin >> tHp >> tAtack;
  cin >> aHp >> aAtack;

  int timeT = (aHp+tAtack-1)/tAtack;//高橋くんが倒す回数
  int timeA = (tHp+aAtack-1)/aAtack;//青木くんが倒す回数
  //倒す回数が少ない方がかち

  if(timeT < timeA) cout << "Yes" << endl;
  else if(timeT == timeA) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3636
s = list(input())
i = len(s)
p = 0
while i >= 3:
    if s[i-1] == s[i-2]:
        i -= 3
        p += 2
    else:
        i -= 1
        p += 1

if i <= 1:
    print(p+i)
else:
    if s[i-1] == s[i-2]:
        print(p+1)
    else:
        print(p+2)

Measured memory_bytes: 10508
#include<stdio.h>
int main(){
    int A,B;
    int sum=0;
    scanf("%d",&A);
    scanf("%d",&B);
    if(A<=B){
        sum=sum+B;
        B=B-1;
    }else{
        sum=sum+A;
        A=A-1;
    }
    if(A<=B){
        sum=sum+B;
        B=B-1;
    }else{
        sum=sum+A;
        A=A-1;
    }
    printf("%d\n",sum);
    
}

Measured memory_bytes: 128
N, D = map(int, input().split())

X = [list(map(int, input().split())) for i in range(N)]
import math
ans = 0

for i in range(N-1):
  for j in range(i+1, N):
    kyori2 = 0
    for k in range(D):
      kyori2 = kyori2 + (X[i][k]-X[j][k])**2
    if math.sqrt(kyori2)%1 == 0:
      ans += 1
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
using namespace std;
 
int main() {
  int N; // 参考書の冊数
  int M; // 学びたいアルゴリズムの数
  int X; // 達成したい理解度
  cin >> N >> M >> X;
  vector<int> C(N); // 参考書の値段が入った配列
  vector<vector<int>> skill(N, vector<int>(M, 0)); // アルゴリズム理解度がどれくらい向上するかが入った配列
  
  int min_cost = 0;
  for (int i = 0; i < N; i++) {
    cin >> C.at(i); // i冊めの参考書の値段
    min_cost += C.at(i); // とりあえず最小値を全冊購入した時の値段にしておく
	for (int j = 0; j < M; j++) {
      cin >> skill[i][j]; 
    }
  }
  // skill_sumがXにひとつでも届いてなかったら-1を返す
  for (int j = 0; j < M; j++) {
    int skill_sum = 0;
	for (int i = 0; i < N; i++) {
      skill_sum += skill[i][j]; 
    }
    if (skill_sum < X) {
      cout << -1 << endl;
      return 0;
    }
  }

  // Logic
  for (int b = 0; b < (1<<12); b++) {
    bool ok = true;
    int cost = 0;
    for (int i = 0; i < N; i++) {
      if ((b>>i&1) == 1) {
        cost += C[i];
      }
    }
    
    for (int j = 0; j < M; j++) {
      int skill_sum = 0;
      for (int i = 0; i < N; i++) {
        if ((b>>i&1) == 1) {
          skill_sum += skill[i][j]; 
      	}
      }
      
      if (skill_sum < X) {
        ok = false;
      }
    }
    if (ok) min_cost = min(min_cost, cost);
  }
  cout << min_cost << endl;
  return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;
public class Main{
  public static void main(String[]args){
    Scanner sc=new Scanner(System.in);
    int N=sc.nextInt();
      int a[]=new int[N];
      int sum=0;
      for(int i=0;i<a.length;i++){
    a[i]=i+1;
        sum=sum+a[i];
      }
      System.out.println(sum);
    }
  }


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

string judge(int a, int b){
	int mod = (a * b) % 2;
  	if (mod == 0) {
	  	return "Even";
    }
  	else {
		return "Odd";
    }
}

int main() {
    int a, b;
    cin >> a >> b;
    cout << judge(a, b) << endl;
}



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

int main(){
  int a, b;
  cin >> a >> b;
  if(a <= b){
    for(int i = 0; i < b; i++){
      cout << a;
    }
  }
  else{
    for(int i = 0; i < a; i++){
      cout << b;
    }
  }
}

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

using namespace std;

int main(void) {
	string S;
	cin >> S;
	for(int i = 0; i + 1 < S.length(); ++i) {
		if(S.substr(i, 2) == "AC") {
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
	return 0;
}



Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String args[]) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int N = sc.nextInt();
		int[] A = new int[N];
		int[][] x= new int[N][N],y=new int[N][N];
		int[][] evidence = new int[N][N];
		for(int i=0;i<N;i++) {
			for(int j=0;j<N;j++) {
				evidence[i][j] = -1;
			}
		}
		for(int i=0;i<N;i++) {
			A[i] = sc.nextInt();
			for(int j=0;j<A[i];j++) {
				evidence[i][sc.nextInt()-1] = sc.nextInt();
			}
		}


		int result = 0;
		boolean flag = false;

		for(int i=0;i<(1<<N);i++) {
			flag = false;
			for(int j=0;j<N;j++) {
				if((i&(1<<j))!=0) {
					for(int k=0;k<N;k++) {
						int ins = (i&(1<<k))!=0 ? 1: 0;
						if(evidence[j][k] != -1 && evidence[j][k] != ins) {
							flag = true;
						}
					}
				}
			}
			if(!flag) result = Math.max(result, Integer.bitCount(i));
		}

//						for(int i=0;i<N;i++) {
//							for(int j=0;j<N;j++) {
//								out.println("evidence["+i+"]["+j+"]"+evidence[i][j]);
//							}
//						}
		out.println(result);

		out.flush();
	}


}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		}else{
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
	private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
	public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
	public String next() {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while(isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext()) throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			}else if(b == -1 || !isPrintableChar(b)){
				return minus ? -n : n;
			}else{
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) nl;
	}
	public double nextDouble() { return Double.parseDouble(next());}
}



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

int main() {
  // ここにプログラムを追記
  int N,A,min;
  cin >> N;
  
  int i=0;
  while(i<N){
    cin >> A;
    
    int count=0;
    
    while(A%2 != 1){
      count++;
      A /=2;
    }
    if(i==0){
      min=count;
    }
    if(count < min){
      min = count;
    }
    
    i++;
  }
  
  cout << min << endl;
  
}

Measured memory_bytes: 256
#include<cmath>
#include<bitset>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int MAXN = 100005;
bitset <405> a[405];
int n, m, i, j, k, ans;
int x[MAXN], y[MAXN], gg[MAXN];
int main()
{
	cin >> n >> m;
	for(i = 1; i <= m; i ++)
		scanf("%d%d", &x[i], &y[i]);
	for(i = 1; i <= n; i ++)
	{
		a[i][i] = 1;
		for(j = m; j >= 1; j --)
			if (a[i][x[j]] && a[i][y[j]]){gg[i] = 1; break;}
			else if (a[i][x[j]]) a[i][y[j]] = 1;
			else if (a[i][y[j]]) a[i][x[j]] = 1;
	}
	for(i = 1; i <= n; i ++)
		if (!gg[i])
			for(j = 1 + i; j <= n; j ++)
				if (!gg[j])
					if ((a[i] & a[j]).count() == 0)
						ans ++;
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long ll;
typedef vector<int >    vecint;
typedef vector<string > vecstr;
int main()
{
  int x, a, b;
  cin >> x >>a >> b;
  string ans;
  if(b - a <= 0 ){
    ans = "delicious";
  }else if(b - a <= x){
    ans = "safe";
  }else{
    ans = "dangerous";
  }
  cout << ans << endl;
}


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

using namespace std;
const int MAX_N = 52;
const int MOD = 1000000007;
int N;
char grid[2][MAX_N];


int main() {
	ios_base::sync_with_stdio(false);
	cin >> N;
	for (int i = 0; i < 2; i++) {
		string s; cin >> s;
		for (int j = 0; j < N; j++) {
			grid[i][j] = s[j];
		}
	}
	int prev = -1; //0 : 1x2, 1 : 2x1 stacked
	int start = 0;
	unsigned long long ans;
	if (grid[0][0] == grid[1][0]) {
		start = 1;
		ans = 3;
		prev = 0;
	}
	else {
		start = 2;
		ans = 6;
		prev = 1;
	}
	for (int i = start; i < N;) {
		if (grid[0][i] == grid[1][i]) {
			if (prev == 0) {
				ans = (ans * 2) % MOD;
			}
			prev = 0;
			i++;
		}
		else {
			if (prev == 0) {
				ans = (ans * 2) % MOD;	
			}
			else {
				ans = (ans * 3) % MOD;
			}
			prev = 1;
			i += 2;
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }


const int q = 1e9+9;



int main()
{
    int n,m;
    cin>>n>>m;
    cout<<((n-1)*(m-1))<<endl;


    return 0;
}
// gotcha;


Measured memory_bytes: 256
my $w = <STDIN>;chomp $w;
my @word =split(//,$w);
my $word =@word;
my @b; my @f;
if($word/2 != int($word/2)){@b=splice(@word,0,($word-1)/2);@f=reverse(splice(@word,1));}
	else {@b=splice(@word,0,$word/2);@f=reverse(@word);}

	my $counter=0;$answer=0;
	while($counter<int($word/2)){if($b[$counter] ne $f[$counter]){$answer++;}$counter++;}
	print $answer;


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
	int k,n;
  	cin>>k>>n;
	vector<int>a(n);
  	vector<int>b(0);
  	for(int i=0;i<n;i++){
    	cin>>a[i];
    }
  	for(int i=0;i<n-1;i++){
    	b.push_back(abs(a[i+1]-a[i]));
    }
  	b.push_back(k-a[n-1]+a[0]);
  	sort(b.begin(),b.end());
  	cout<<k-b[n-1]<<endl;
  	
}

Measured memory_bytes: 2296
while True:
    m, f, r = map(int, input().split())
    if m == -1 and f == -1 and r == -1:
        break
    if m == -1 or f == -1:
        print('F')
    else:
        sum_mid_and_final = m + f
        if sum_mid_and_final >= 80:
            print('A')
        elif sum_mid_and_final >= 65:
            print('B')
        elif sum_mid_and_final >= 50:
            print('C')
        elif sum_mid_and_final >= 30:
            if r >= 50:
                print('C')
            else:
                print('D')
        else:
            print('F')



Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll mod = 1000000007;
ll INF = 1000000009;

/*
要するに迷路を解けという問題
左上から順に、min(上,左,下,右)をその位置での最短距離とする
#のスコアは-1
ただし、いずれも-1であるなら、その位置でのスコアは-1
これをh+w回繰り返す。(今回は制約的に間に合う)
*/

void solve(){
    int h,w;
    cin >> h >> w;
    char c[h+10][w+10];
    rep(i,h+2){
        rep(j,w+2){
            c[i][j]='#';
        }
    }
    int count=0;
    rep(i,h){
        string tmp;
        cin >> tmp;
        rep(j,w){
            if(tmp[j]=='#') count++;
            c[i+1][j+1] = tmp[j];
        }
    }
    //cout << count << endl;

    int score[h+10][w+10];
    rep(i,h+2){
        rep(j,w+2){
            score[i][j]=INF;
            //cout << c[i][j];
        }
        //cout << endl;
    }
    score[1][1]=0;
    rep(k, h*w){
    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            if(c[i][j]=='#'){
                score[i][j]=INF;
            }
            else{
                //cout << score[i][j-1] << " " << score[i][j+1] << " " << score[i-1][j] << " " << score[i+1][j] << endl;
                score[i][j]=min((min(min(score[i][j-1], score[i][j+1]),min(score[i-1][j], score[i+1][j]))+1), score[i][j]);
                //cout << "score[" << i << "][" << j << "]:" << score[i][j] << endl;
            }
        }
    }
    }

    if(score[h][w]==INF) cout << -1 << endl;
    else{
        cout << h*w - count - score[h][w] -1 << endl;
    }
}

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



Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author amotoma3
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int a = in.nextInt();
            int b = in.nextInt();

            out.println((b - a) % 2 == 0 ? "Alice" : "Borys");
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

long long inv_mod(long long a, long long m) {
  long long b, x, u, q, abs_m, tmp;

  abs_m = (m < 0) ? -m : m;
  b = m;
  x = 1;
  u = 0;
  while (b > 0) {
    q = a / b;
    tmp = u;
    u = x - q * u;
    x = tmp;
    tmp = b;
    b = a - q * b;
    a = tmp;
  }

  return (x < 0) ? abs_m + x : x;
}
template <long long MOD>
struct ModInt{
  long long value;

  ModInt(long long n = 0) : value(n % MOD){}


  operator long long() const noexcept {return value % MOD;}

  ModInt<MOD> operator++(int){
    ModInt<MOD> before = *this;
    value = (value + 1) % MOD;
    return before;
  }

  ModInt<MOD> operator--(int){
    ModInt<MOD> before = *this;
    value = (value - 1 + MOD) % MOD;
    return before;
  }

  ModInt<MOD>& operator++(){
    value = (value + 1) % MOD;
    return *this;
  }

  ModInt<MOD>& operator--(){
    value = (value - 1 + MOD) % MOD;
    return *this;
  }

  bool operator!() const noexcept{
    return !static_cast<bool>(value);
  }

  ModInt<MOD> operator+() const{
    return value;
  }
  
  ModInt<MOD> operator-() const{
    return (-value + MOD) % MOD;
  }

  ModInt<MOD>& operator*=(const ModInt<MOD>& m){
    return *this = ModInt<MOD>((this->value * m.value) % MOD);
  }
  ModInt<MOD>& operator+=(const ModInt<MOD>& m){
    return *this = ModInt<MOD>((this->value + m.value) % MOD);
  }
  ModInt<MOD>& operator-=(const ModInt<MOD>& m){
    return *this = ModInt<MOD>((this->value - m.value + MOD) % MOD);
  }
  ModInt<MOD>& operator/=(const ModInt<MOD>& m){
    return *this = ModInt<MOD>((this->value * inv_mod(m.value,MOD)) % MOD);
  }
 };

template<long long MOD>
ModInt<MOD> operator*(const ModInt<MOD>& m1,const ModInt<MOD>& m2){return ModInt<MOD>(m1) *= m2;}
template<long long MOD>
ModInt<MOD> operator+(const ModInt<MOD>& m1,const ModInt<MOD>& m2){return ModInt<MOD>(m1) += m2;}
template<long long MOD>
ModInt<MOD> operator-(const ModInt<MOD>& m1,const ModInt<MOD>& m2){return ModInt<MOD>(m1) -= m2;}
template<long long MOD>
ModInt<MOD> operator/(const ModInt<MOD>& m1,const ModInt<MOD>& m2){return ModInt<MOD>(m1) /= m2;}
template<long long MOD>
ModInt<MOD> operator*(const long long& m1,const ModInt<MOD>& m2){return ModInt<MOD>(m1) *= m2;}
template<long long MOD>
ModInt<MOD> operator+(const long long& m1,const ModInt<MOD>& m2){return ModInt<MOD>(m1) += m2;}
template<long long MOD>
ModInt<MOD> operator-(const long long& m1,const ModInt<MOD>& m2){return ModInt<MOD>(m1) -= m2;}
template<long long MOD>
ModInt<MOD> operator/(const long long& m1,const ModInt<MOD>& m2){return ModInt<MOD>(m1) /= m2;}

string r,b;
const i64 mm = 1e9 + 7;
ModInt<mm> dp[1010][1010];

int main(){
  cin >> r >> b;
  r = " " + r;
  b = " " + b;
  dp[0][0] = 1;
  for(int i = 1;i <= r.size();i++){
    for(int j = 0;j <= b.size();j++){
      dp[i][j] += dp[i - 1][j];
      if(j - 1 >= 0 && r[i] == b[j]){
        dp[i][j] += dp[i - 1][j - 1];
      }
    }
  }
  cout << dp[r.size()][b.size()] << endl;
}



Measured memory_bytes: 11156
from itertools import groupby
import heapq

X=input()
N=len(X)
X=[X[i] for i in range(0,N)]
X=groupby(X)
data=[]
i=0
for key,group in X:
    g=len(list(group))
    data.append((i,key,g))
    i+=1

if data[0][1]=='T':
    data=data[1:]
if data[-1][1]=='S':
    data=data[:len(data)-1]


heapq.heapify(data)
left=0
ans=0
while data:
    S=heapq.heappop(data)
    T=heapq.heappop(data)
    s=S[2]+left
    t=T[2]
    if s>=t:
        left=s-t
        ans+=t
    else:
        left=0
        ans+=s

print(N-2*ans)

Measured memory_bytes: 75640
#include<bits/stdc++.h>
#define rep(i,x,y) for(int i=x,i##end=y;i<=i##end;++i)
#define _rep(i,x,y) for(int i=x,i##end=y;i>=i##end;--i)
#define ll long long
#define N 1000005
const int mod=998244353;
inline void reduce(int&x){x-=mod,x+=x>>31&mod;}
int dp[N],sum[N],n,k,L[N],R[N];
int main(){
	std::ios::sync_with_stdio(0);
	std::cin>>n>>k;
	rep(i,1,k) std::cin>>L[i]>>R[i];
	dp[1]=sum[1]=1;
	rep(i,2,n){
		rep(j,1,k){
			if(i-L[j]<=0) continue;
			int l=std::max(1,i-R[j]),r=i-L[j];
			reduce(dp[i]+=sum[r]);
			reduce(dp[i]+=mod-sum[l-1]);
		}
		sum[i]=sum[i-1];
		reduce(sum[i]+=dp[i]);
	}
	std::cout<<dp[n]<<'\n';
	return 0;
}

Measured memory_bytes: 5212
A = input()
N = len(A)
count = {}
ans = 1

for i in range(N):
  if A[i] in count.keys():
    count[A[i]] += 1
  else:
    count[A[i]] = 1

L = list(count.values())
M = len(L)
for i in range(M):
  for j in range(i+1,M):
    ans += L[i] * L[j]
    
print(ans)

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    ll A, B, K;
    cin >> A >> B >> K;
    ll a = std::min(A, K);
    cout << A - a << " " << std::max(0LL, B - (K - a)) << endl;

   // cout << std::max(A - K, 0LL) << " " << std::max(B - K, 0LL) << endl;
    return 0;
}

Measured memory_bytes: 256
s = input()
p = input()
can_make = False
for i in range(len(s)):
    ss = ""
    if i+len(p) > len(s):
        ss = s[i:] + s[0:(i+len(p))-len(s)]
    else:
        ss = s[i:i+len(p)]
    if ss == p:
        can_make = True
        break
if can_make:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 5564
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn f(s: &[char]) -> bool {
    let m = s.len();
    for i in 0..m {
        if s[i] != s[m - 1 - i] {
            return false;
        }
    }
    true
}

use std::iter::Iterator;

fn main() {
    input! {
        s: chars,
    }

    let n = s.len();


    if f(&s) && f(&s[0..(n-1)/2]) && f(&s[(n+3)/2-1..n]) {
        println!("Yes");
    } else {
        println!("No");
    }
  

  
    
}


Measured memory_bytes: 4352
use std::collections::*;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let m: usize = sc.read();
    let mut g: Vec<Vec<Edge>> = vec![vec![]; n];
    for _ in 0..m {
        let a: usize = sc.read();
        let b: usize = sc.read();
        g[a - 1].push(Edge::new_nonweight(b - 1));
        g[b - 1].push(Edge::new_nonweight(a - 1));
    }
    let mut dist: Vec<i32> = vec![10000000; n];
    dist[0] = 0;
    let mut bfs: VecDeque<usize> = VecDeque::new();
    bfs.push_back(0);
    while !bfs.is_empty() {
        let now = bfs.pop_front().unwrap();
        for e in g[now].iter() {
            if dist[now] + 1 < dist[e.to] {
                dist[e.to] = dist[now] + 1;
                bfs.push_back(e.to);
            }
        }
    }
    let mut ans: Vec<usize> = vec![10; n];
    for i in 1..n {
        for e in g[i].iter() {
            if dist[e.to] + 1 == dist[i] {
                ans[i] = e.to;
                break;
            }
        }
    }
    println!("Yes");
    for i in 1..n {
        println!("{}", ans[i] + 1);
    }
}

struct Edge {
    to: usize,
    cost: i64,
}
impl Edge {
    //pub fn new(to: usize, cost: i64) -> Edge {
    //    Edge { to: to, cost: cost }
    //}
    pub fn new_nonweight(to: usize) -> Edge {
        Edge { to: to, cost: 1 }
    }
}
impl Clone for Edge {
    fn clone(&self) -> Self {
        Edge {
            to: self.to,
            cost: self.cost,
        }
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}

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

using namespace std;

typedef long long ll;

const int MAXH = 10;

int h;
vector<vector<int> > st(MAXH, vector<int>(5, 0));

int solve(){
    int ans = 0;

    int mis = 10;

    while(1){
        // DEBUG
        /*
        for(int i=0;i<h;i++){
            for(int j=0;j<5;j++){
                cout << st[i][j] << " ";
            }
            cout << endl;
        }
        */

        // 各行について連鎖するかどうか
        for(int i=0;i<h;i++){
            if(st[i][0] == st[i][1] && st[i][1] == st[i][2] && st[i][2] == st[i][3] && st[i][3] == st[i][4]){
                ans += 5 * st[i][0];
                for(int j=0;j<5;j++) st[i][j] = -1;
            }else if(st[i][0] == st[i][1] && st[i][1] == st[i][2] && st[i][2] == st[i][3]){
                ans += 4 * st[i][0];
                for(int j=0;j<4;j++) st[i][j] = -1;
            }else if(st[i][1] == st[i][2] && st[i][2] == st[i][3] && st[i][3] == st[i][4]){
                ans += 4 * st[i][1];
                for(int j=1;j<5;j++) st[i][j] = -1;
            }else if(st[i][0] == st[i][1] && st[i][1] == st[i][2]){
                ans += 3 * st[i][0];
                for(int j=0;j<3;j++) st[i][j] = -1;
            }else if(st[i][1] == st[i][2] && st[i][2] == st[i][3]){
                ans += 3 * st[i][1];
                for(int j=1;j<4;j++) st[i][j] = -1;
            }else if(st[i][2] == st[i][3] && st[i][3] == st[i][4]){
                ans += 3 * st[i][2];
                for(int j=2;j<5;j++) st[i][j] = -1;
            }
        }

        // cout << ans << endl;

        bool deleted = false;

        for(int i=0;i<h;i++){
            for(int j=0;j<5;j++){
                deleted |= (st[i][j] == -1);
            }
        }

        if(!deleted) return ans;

        vector<vector<int> > prev = st;

        // 次の盤面を生成
        for(int j=0;j<5;j++){
            int nh = h - 1;
            for(int i=h-1;i>=0;i--){
                if(prev[i][j] == -1) continue;
                st[nh][j] = prev[i][j];
                nh--;
            }
            while(nh >= 0){
                st[nh][j] = mis;
                mis++;
                nh--;
            }
            assert(nh < 0);
        }
    }
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    while(1){
        cin >> h;
        if(h == 0){
            break;
        }
        for(int i=0;i<h;i++){
            for(int j=0;j<5;j++){
                cin >> st[i][j];
            }
        }
        cout << solve() << endl;
    }
}


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

using namespace std;

#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                        \
	sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) \
	{
sim > struct rge
{
	c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug
{
#ifdef LOCAL
	~debug()
	{
		cerr << endl;
	}
	eni(!=) cerr << boolalpha << i;
	ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d)
{
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d)
{
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
	sim dor(const c &)
	{
		ris;
	}
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define forn(i, n) for (ll i = 0; i < int(n); i++)
#define rfor(n, i) for (ll i = (n - 1); i >= 0; --i)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define M_PI 3.14159265358979323846
#define EPS 1e-7

int cnt = 0;


void solve()
{
	int a, b; cin >> a >> b;
	for (int i = 0; i < 1270; ++i)
	{
		if ((int)(double)(i * 0.1) == (double)b && (int)(double)(i * 0.08) == (double)a)
		{
			cout << i << endl;
			return;
		}
	}
	cout << -1;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	solve();
}


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

using namespace std;

typedef long long int lli;

int gcd(int a, int b) {
    if(a < b) return gcd(b, a);
    int r;
    
    while ((r=a%b)) {
        a = b;
        b = r;
    }

    return b;
}

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

    int n, a[100000];

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

    int ans = a[0];
    for (int i=1; i<n; i++) ans = gcd(ans, a[i]);

    cout << ans << endl;

    return 0;
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

vector<int> funami(int x)
{
    vi ret;
    if (!x) {
        ret.pb(0);
        return ret;
    }
    while (x) {
        ret.pb(x % 2);
        x /= 2;
    }
    reverse(all(ret));
    return ret;
}

int toshino(vi &data)
{
    int ret = 0;
    rep(i, data.size()) {
        ret <<= 1;
        ret += data[i];
    }
    return ret;
}

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

    Int(n);

    vector<pair<int, pii>> output;
    vi data = funami(n);
    /*
    rep(i, data.size()) {
        cout << data[i] << " ";
    }
    cout << endl;
    */

    Rep(i, data.size()) {
        output.pb({1 << (i-1), {data.size()-i, data.size()-i+1}});
        output.pb({0, {data.size()-i, data.size()-i+1}});
    }

    reverse(all(data));
    rep(i, data.size()-1) {
        if (data[i]) {
            data[i] = 0;
            reverse(all(data));
            output.pb({toshino(data), {1, data.size()-i}});
            reverse(all(data));
        }
    }

    cout << data.size() << " " << output.size() << endl;

    rep(i, output.size()) {
        cout << output[i].sfir << " " << output[i].ssec << " " << output[i].fir << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    int h,w;cin>>h>>w;
    char t[h][w];
    rep(i,h)rep(j,w) cin>>t[i][j];
    vector<vector<char>> r(h,vector<char>(w,'#'));
    int roty[8]={1,1,0,-1,-1,-1,0,1},rotx[8]={0,1,1,1,0,-1,-1,-1};
    rep(i,h)rep(j,w){
        if(t[i][j]=='#')continue;
        int tmp=0;
        rep(k,8){
            int ny=i+roty[k],nx=j+rotx[k];
            if(0>ny||ny>=h||0>nx||nx>=w)continue;
            if(t[ny][nx]=='#')tmp++;
        }
        r[i][j]=tmp+'0';
    }
    rep(i,h){
        rep(j,w){
            cout<<r[i][j];
        }
        cout<<endl;
    }
}

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

int main() {
    long long A, B, r, l;
    cin >> A >> B;
    r = A;
    l = B;
    while (r != l) {
        if (r < l) swap(r, l);
        r = r - l;
    }
    cout << A * B / r << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{

  int N,i;
  int P[200001];
  int count=0;
  int tmp=200002;
  scanf("%d",&N);
  for(i=0;i<N;i++)
  {
    scanf("%d ",&P[i]);
    if(P[i]<=tmp) 
    {
      tmp = P[i];
      count++;
    }
  }
  printf("%d\n",count);
    
 return 0;
}


Measured memory_bytes: 896
#include <iostream>

using namespace std;

typedef long long ll;

int main(int argc, char *argv[])
{
	ll A, B, K;
	
	cin >> A >> B >> K;

	ll x = K - A;
	if (x >= 0) {
		A = 0;
		ll y = x - B;
		if (y >= 0) {
			B = 0;
		} else {
			B = -y;
		}
	} else {
		A = -x;
	}

	printf("%lld %lld\n", A, B);

	return 0;
}

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

int main()
{
	int n;
	cin>>n;
	vector<int> p(n), q(n), order(n);
	for(int i=0;i<n;i++) cin>>p[i];
	for(int i=0;i<n;i++) cin>>q[i];
	for(int i=0;i<n;i++) order[i] = i+1;
	int cntp = 0, cntq = 0, cnt = 1;
	do{
        bool pflag = true, qflag = true;
		for(int i=0;i<n;i++){
			if(order[i]!=p[i]) pflag = false;
		}
		for(int i=0;i<n;i++){
			if(order[i]!=q[i]) qflag = false;
		}
		if(pflag) cntp = cnt;
		if(qflag) cntq = cnt;
		cnt++;
	}while(next_permutation(order.begin(), order.end()));
	cout<<abs(cntp-cntq)<<endl;
}


Measured memory_bytes: 256
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let c = rl().chars().next().unwrap();
    println!("{}", (c as u8 + 1) as char)
}


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

typedef long long ll;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

struct LazySegmentTree {
private:
    int n;
    vector<ll> node,lazy;
public:
    LazySegmentTree(vector<ll> v) {
        int sz = v.size();
        n = 1;
        while (n < sz) n *= 2;
        node.resize(2*n-1);
        lazy.resize(2*n-1,0);
        for (int i = 0;i < sz;++i) node[i+n-1] = v[i];
        for (int i = n-2;i >= 0;--i) node[i] = min(node[i*2+1],node[i*2+2]);
    }

    void eval(int k,int l,int r) {
        if (lazy[k] != 0) {
            node[k] += lazy[k]/(r-l);
            if (r-l > 1) {
                lazy[2*k+1] += lazy[k]/2;
                lazy[2*k+2] += lazy[k]/2;
            }
            lazy[k] = 0;
        }
    }

    void add(int a,int b,ll x,int k = 0,int l = 0,int r = -1) {
        if (r < 0) r = n;
        eval(k,l,r);
        if (b <= l || r <= a) return;
        if (a <= l && r <= b) {
            lazy[k] += (r-l)*x;
            eval(k,l,r);
        } else {
            add(a,b,x,2*k+1,l,(l+r)/2);
            add(a,b,x,2*k+2,(l+r)/2,r);
            node[k] = min(node[2*k+1],node[2*k+2]);
        }
    }

    ll getmin(int a,int b,int k = 0,int l = 0,int r = -1) {
        if (r < 0) r = n;
        if (b <= l || r <= a) return INT64_MAX;
        eval(k,l,r);
        if (a <= l && r <= b) return node[k];
        ll vl = getmin(a,b,k*2+1,l,(l+r)/2);
        ll vr = getmin(a,b,2*k+2,(l+r)/2,r);
        return min(vl,vr);
    }
};

int main() {
    int n,q;
    cin >> n >> q;
    LazySegmentTree seg(vector<ll>(n,0));
    for (int i = 0;i < q;++i) {
        int c,s,t;
        cin >> c >> s >> t;
        if (c) cout << seg.getmin(s,t+1) << endl;
        else {
            int x;
            cin >> x;
            seg.add(s,t+1,x);
        }
    }
    return 0;
}


Measured memory_bytes: 7608
#include <iostream>
#include <vector>
#include <set>
using namespace std;
 
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
 
int main() {
    int Q;
    while (cin >> Q) {
        multiset<long long> S;
        multiset<long long>::iterator median;
        size_t median_index;
        long long b_sum = 0, a_diff = 0;
 
        {
            int qt; cin >> qt; // ignore
            long long a, b; cin >> a >> b;
            a_diff = 0;
            b_sum = b;
            S.insert(a);
            median = S.begin();
            median_index = 0;
        }
 
        REP(q, Q-1) {
            int qt; cin >> qt;
            if (qt == 1) {
                long long a, b; cin >> a >> b;
                a_diff += abs(*median - a);
                b_sum += b;
                S.insert(a);
                if (S.size() % 2 == 0) {
                    if (a < *median) {
                        long long m_old = *median;
                        --median;
                        long long d = abs(*median - m_old);
                        size_t n_left = median_index + 1;
                        size_t n_right = S.size() - median_index - 1;
                        a_diff += d * (n_right - n_left);
                    } else {
                        // do nothing
                    }
                } else {
                    if (a < *median) {
                        ++median_index;
                    } else {
                        long long m_old = *median;
                        ++median; ++median_index;
                        long long d = abs(*median - m_old);
                        size_t n_left = median_index;
                        size_t n_right = S.size() - median_index;
                        a_diff += d * (n_left - n_right);
                    }
                }
                //cout << "a_diff=" << a_diff << "; b_sum=" << b_sum << "; median_index=" << median_index << "; median=" << *median << '\n';
            } else {
                cout << *median << " " << a_diff + b_sum << '\n';
            }
        }
    }
}

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

int main(){
  int l,r,d;
  cin >> l >> r>>d;
  cout << r/d - (l-1)/d << endl;
  return 0;
}

Measured memory_bytes: 3564
import math
N = input()
datas = []
for _ in range(N):
	data = map(long, raw_input().split(" "))
	datas.append(data)

t_min = datas[0][0]
o_min = datas[0][1]
for _ in range(N-1):
	t = datas[_+1][0]
	o = datas[_+1][1]
	t_mul = t_min/t + 1 if t_min%t != 0 else t_min/t
	o_mul = o_min/o + 1 if o_min%o != 0 else o_min/o
	if t_mul < o_mul:
		t_min = o_mul*t
		o_min = o_mul*o
	else:
		t_min = t_mul*t
		o_min = t_mul*o

print t_min+o_min

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

using namespace std;

void solve()
{
	int t;
	cin >> t;
	for(int i = 0; i < t; ++i)
	{
		int n;
		cin >> n;
		vector<int> Vec(n);
		for(int j = 0; j < n; ++j)
		{
			cin >> Vec[j];
		}
		int Up = 0;
		int Down = 0;
		int height = Vec[0];
		for(int j = 1; j < n; ++j)
		{
			int diff = Vec[j] - Vec[j - 1];
			if(diff > Up)
			{
				Up = diff;
			}
			else if(diff < Down)
			{
				Down = diff;
			}
		}
		cout << Up << " " << -Down << endl;
	}
}

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

Measured memory_bytes: 0
import sys
input = sys.stdin.readline
N = int(input())
pret, prex, prey = 0, 0, 0

for i in range(N):
  t,x,y = map(int,input().split())
  if (t - pret >= abs(x-prex)+abs(y-prey)) and (t-pret)%2 == (abs(x-prex)+abs(y-prey))%2:
    pret,prex,prey = t,x,y    
    continue
  else:
    print("No")
    exit()
print("Yes")

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

using namespace std;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  short n;
  cin >> n;
  if (n == 22) cout <<"Christmas Eve Eve Eve";else
  if (n == 23) cout <<"Christmas Eve Eve";else
  if (n == 24) cout <<"Christmas Eve";else
  if (n == 25) cout <<"Christmas";else
  return 0;
}

Measured memory_bytes: 256
while True:
  a, b = map(int, input().split())
  if a == 0 and b == 0:
    break
  if a < b:
    a, b = b, a
  cnt = 0
  while b != 0:
    r = a % b
    a = b
    b = r
    cnt += 1
  print(a, cnt)


Measured memory_bytes: 5604
mod = int(1e9+7)

n = int(input())
s = input()

a = [1 if s[i] == 'B' else 0 for i in range(len(s))]
ans = 1

if a[0] == 0:
    print(0)
    exit()

c = 1

for i in range(1,len(s)):
    if (a[i] + c) % 2 == 1:
        c += 1
    else:
        ans = (ans*c) % mod
        c -= 1

if c != 0:
    print(0)
    exit()

for i in range(n):
    ans = (ans*(i+1)) % mod

print(ans)




Measured memory_bytes: 53216
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = std::vector<T>;
using vvi = std::vector<vt<int>>;

int main(){
  int n;
  std::cin >> n;
  vt<int> a(n);
  rep(i,n) {
    if(i != 0)
      std::cin >> a[i];
  }

  vt<int> bu(n);
  rep(i,n) {
    if(i != 0) {
      ++bu[a[i]-1];
    }
  }

  rep(i,n)
    std::cout << bu[i] << '\n';
  return 0;
}


Measured memory_bytes: 4844
def nrc_mod(n, r, mod=10**9+7):
    r = min(n - r, r)
    if r == 0:
        return 1
 
    over = 1
    for i in range(n, n - r, -1):
        over = over * i % mod
 
    under = 1
    for i in range(1, r + 1):
        under = under * i % mod
 
    inv = pow(under, mod - 2, mod)
    return over * inv % mod
 
 
n, a, b = map(int, input().split())
MOD = 10**9 + 7

ans = pow(2, n, MOD) - 1
ans -= nrc_mod(n, a, MOD)
ans -= nrc_mod(n, b, MOD)
while ans < 0:
    ans += MOD
print(ans)


Measured memory_bytes: 3064
import java.util.*;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        // 電車1人A
        // タクシーN人B
        Scanner scan = new Scanner(System.in);
 
        int num = scan.nextInt();
      int train = scan.nextInt();
      int taxi = scan.nextInt();
      
        
        if (num * train < taxi) { 
            System.out.println(num * train);
        } else if (num * train > taxi) {
            System.out.println(taxi);
        } else {
                      System.out.println(taxi);
        }
          
        
    }
}


Measured memory_bytes: 22612
import java.util.Scanner;

//Simple Othello
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		int n = s.length;
		System.out.println(s[0]==s[n-1]&&s[0]=='x'?'x':'o');
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

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

int main(){
 
  int N;
  double P;
  cin >> N;
  
  if (N % 2 == 0) {
    P = 0.5;
  }else{
    P = (double)(N - N / 2) / (double)N;
  }
  
  printf("%.7f", P);
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    System.out.println(y[x-1]);
    
  }
}

Measured memory_bytes: 35624
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		String s = sc.next();
		String res = "Heisei";
		String[] date = s.split("/");
		int year = Integer.parseInt(date[0]);
		int month = Integer.parseInt(date[1]);
		int day = Integer.parseInt(date[2]);
		
		if (year >= 2019) {
			if (month > 4) {
				res = "TBD";
			} 
		}
		
		System.out.println(res);
	}
	
	static class FastReader { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine()); 
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try{ 
                str = br.readLine(); 
            } catch (IOException e) { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
}


Measured memory_bytes: 21332
n = gets.to_i
_s = n.times.map{gets.chomp.split.map(&:to_s)}
sum = 0
_s.each do |i,s|
  if s == "BTC"
    sum += i.to_f * 380000.0
  else
    sum += i.to_f
  end
end
puts sum


Measured memory_bytes: 1788
def main():
    S = input().strip()

    cnt = 0
    flag = True
    Set_1 = {"R","U","D"}
    Set_2 = {"L","U","D"}
    for s in S:
        cnt += 1
        if cnt % 2 == 0 and s in Set_2:
            continue
        elif cnt % 2 == 1 and s in Set_1:
            continue
        else:
            flag = False
    
    if flag == True:
        print("Yes")
    else:
        print("No")



if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

int main(int argc, const char *argv[])
{
  int n, m;
  cin >> n >> m;

  vector<int> a(n);
  vector<pair<int, int>> bc(m);
  for (auto &n : a) cin >> n;
  for (auto &p : bc) cin >> p.first >> p.second;
  
  // ソートする
  sort(a.begin(), a.end());
  sort(bc.begin(), bc.end(),
      [](pair<int, int> &a, pair<int, int> &b) { return b.second < a.second; });
  int cur = 0;
  for (auto &p : bc) {
    if (a[cur] >= p.second) {
      break;
    }

    int i = 0;
    while (i < p.first && a[cur] < p.second) {
      a[cur] = p.second;
      cur++;
      i++;
    }
  }

  cout << accumulate(a.begin(), a.end(), 0llu) << "\n";
  return 0;
}

Measured memory_bytes: 1408
require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N, K = get_ints
P = get_ints

P.sort!

ans = 0
K.times do |i|
  ans += P[i]
end

puts ans


Measured memory_bytes: 14452