akhauriyash/Code-Regression huggingface dataset:
import javax.management.MBeanRegistration;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.util.StringTokenizer;
import java.util.Scanner;
import java.lang.*;
import java.io.*;
import java.util.*;
import java.lang.Integer;
import java.util.HashMap;

public class Main {
    // driver function to test the above functions
    public static void main(String args[]) throws IOException {
        Reader.init(System.in);
        long n = Reader.nextLong();
        long k = Reader.nextLong();

        long val = n%k;
        if (((val-k)*-1)>val){
            System.out.println(val);
        }
        else {
            System.out.println((val-k)*-1);
        }


    }
}

class Node{
    char val;
    Node nxt = null;
    Node prev=null;


}



class solu{

}

/** Class for buffered reading int and double values */
class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(
                new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }

    /** get next word */
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                    reader.readLine() );
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }

    static long nextLong() throws IOException {
        return Long.parseLong( next() );
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }

    static String line() throws IOException {
        return reader.readLine();
    }
}

Measured memory_bytes: 22356
#include<iostream>
#include <string>
#include<vector>
typedef long long ll;

using namespace std;
int main()
{
	int a,b,c,d,e,f;
	cin >> a>>b>>c>>d>>e>>f;

	double rate = 0;
	int satomizu = 0;
	int sato = 0;

	for (int i = 0; 100*a*i <= f; i++) {
		for (int j = 0; 100 * a*i + 100 * b*j <= f; j++) {
			for (int k = 0; 100 * a*i + 100 * b*j + c*k <= f; k++) {
				for (int l = 0; 100 * a*i + 100 * b*j + c * k + d * l <= f; l++) {
					if (a*i*e + b * j*e >= c * k + d * l) {
						if ((1.0*c * k + d * l) / (1.0 * 100 * a*i + 100 * b * j + c * k + d * l) >= rate) {
							rate = (1.0*c * k + d * l) / (1.0 * 100 * a*i + 100 * b * j + c * k + d * l);
							satomizu = 100 * a*i + 100 * b*j + c * k + d * l;
							sato = c * k + d * l;
						}
					}
				}
			}
		}
	}

	cout << satomizu <<" "<< sato<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
#define ARRAY_LEN(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int INTINF = 2147483647;
const int MOD = 1000000007;

int main() {
  int N; cin >> N;
  map<int, int> A;
  rep(i, N) { 
    int num; cin >> num;
    A[num]++;
  }

  int result = 0;
  for (auto x : A) {
    if (x.second%2==1) result++;
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 4864
#include<iostream>
#include <cstring>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int main()
{  
    // 整数の入力
    int a,b,c;
    cin >> a >> b>>c;
    int w[a];
    int h[a];
    
    //int len = a.length();
    int count = 0;
for (int i = 0; i <a;i++)
{
    cin >> w[i] >> h[i];
    if(w[i] >= b && h[i] >= c)
    {
        count ++;
    }
}
      cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long int
#define ld long double
#define fi first 
#define se second 
#define mp make_pair
#define pb push_back
#define ull unsigned long long int
#define vll vector<ll>
#define vld vector<ld>
#define pll pair<ll,ll> 
#define pld pair<ld,ld> 
#define vpll vector<pll>
#define vpld vector<pld>
#define all(X) X.begin(),X.end()
#define mo 1000000007
ll gcd(ll a ,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll poww(ll a,ll n){if(n==0)return 1;ll p=poww(a,n/2);p=(p*p)%mo;if(n%2)p=(a*p)%mo;return p;}
////////////////////////////////////////////////////

ll tn ; 
void solve()
{
  ll n ;cin>>n; 
  ll sum = 0; 
  for(ll i = 1; i<=n; i++)
  {
  	for(ll j = 1; j<=n; j++)
  	{  ll g = gcd(i,j); 
  		for(ll k = 1; k<=n ; k++)
  		{
  			sum+=gcd(g,k); 
		  }
	  }
   }
   cout<<sum;  
}
int main()
{ ios; 

ll t ;t = 1; 
  for(tn = 1; tn<=t; tn++)
	solve(); 
	return 0 ; 
}


Measured memory_bytes: 3648
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  int two = 0, fo = 0;
  FOR(i,0,N) {
    ll in;
    cin >> in;
    if(in % 4 == 0) {
      fo++;
    } else if(in % 2 == 0) {
      two++;
    }
  }
  if(N == 1){
    if(fo == 1) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
    return 0;
  }
  if (two == N)
  {
    cout << "Yes" << endl;
    return 0;
  }
  N -= two / 2 * 2;
  if(N <= 2 * fo + 1 && fo != 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
from heapq import heappush, heappop

def main():
  while True:
    n, m, s, g1, g2 = map(int, input().split())
    if n == 0:
      break
    s -= 1
    g1 -= 1
    g2 -= 1
  
    INF = 10 ** 20
    edges = [[] for _ in range(n)]
    for _ in range(m):
      b1, b2, c = map(int, input().split())
      b1 -= 1
      b2 -= 1
      edges[b1].append((b2, c))
  
    def dij(start):
      que = []
      heappush(que, (0, start))
      costs = [INF] * n
      costs[start] = 0
      
      while que:
        total, node = heappop(que)
        for to, dist in edges[node]:
          new_total = total + dist
          if costs[to] > new_total:
            costs[to] = new_total
            heappush(que, (new_total, to))
  
      return costs
    
    from_i = [dij(i) for i in range(n)]
    print(min([from_i[s][i] + from_i[i][g1] + from_i[i][g2] for i in range(n)]))
  
main()


Measured memory_bytes: 6612
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))

def main():
    h, w = MII()
    aa = [IS() for _ in range(h)]
    aa_w = [a for a in aa if '.'*w != a]
    aa_w_t = [''.join(list(a)) for a in zip(*aa_w)]
    w = len(aa_w_t[0])
    aa_w = [a for a in aa_w_t if '.'*w != a]
    aa_w_t = [''.join(list(a)) for a in zip(*aa_w)]
    aa_w_t = [''.join(list(a)) for a in zip(*aa_w)]
    for a in aa_w_t: print(a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
class Node():
    def __init__(self, value):
        self.value = value
        self.left = None
        self.right = None

def postorder(root, out):
    if root == None:
        pass
    else:
        postorder(root.left, out)
        postorder(root.right, out)
        out.append(root.value)

def build_tree(pres, ins):
    if len(pres) < 1:
        return None
    else:
        node = Node(pres[0])
        index = 0
        for i in range(len(ins)):
            if ins[i] == pres[0]:
                index = i
                break
        
        node.left = build_tree(pres[1:1+index], ins[0:index])
        node.right = build_tree(pres[1+index:], ins[1+index:])
        return node


if __name__ == '__main__':
    n = int(input())
    pres = [int(num) for num in input().split(' ')]
    ins = [int(num) for num in input().split(' ')]
    root = build_tree(pres, ins)
    out = []
    postorder(root, out)
    print(str(out).replace(',', '').replace('[', '').replace(']', ''))



Measured memory_bytes: 5612
#include <iostream>
 
using namespace std;
 
int main() {
    int n;
    cin >> n;

    int f[100][10];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 10; j++) {
            cin >> f[i][j];
        }
    }

    int p[100][11];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 11; j++) {
            cin >> p[i][j];
        }
    }

    int m = -2147483647;
    for (int i = 1; i < 1024; i++) {
        int a[10];
        for (int j = 0; j < 10; j++) {
            a[j] = (i >> j) & 1;
        }

        int s = 0;
        for (int j = 0; j < n; j++) {
            int c = 0;
            for (int k = 0; k < 10; k++) {
                if (a[k] && f[j][k]) {
                    c++;
                }
            }
            s += p[j][c];
        }

        if (s > m) {
            m = s;
        }
    }

    cout << m << endl;

    return 0;
}

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

using namespace std;

#define range(i, m, n) for(int i = m; i < n; i++)
#define husk(i, m, n) for(int i = m; i > n; i--)

string s;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> s;
  long long ans = 0;
  int cnt = 0;
  range(i, 0, (int) s.length()) if(s[i] == 'W') {
    ans += i;
    cnt++;
  }
  ans -= 1LL * (cnt - 1) * cnt / 2;
  cout << ans;
  return 0;
}


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

using lint = long long;

int main() {
    int X[3], K;
    for (lint i = 0; i < 3; ++i) std::cin >> X[i];
    std::cin >> K;

    std::vector<lint> A(1, 0);

    for (lint i = 0; i < 3; ++i) {
        int L = A.size();
        std::vector<lint> B(L * X[i]);

        for (lint j = 0; j < X[i]; ++j) {
            lint C;
            std::cin >> C;
            for (lint k = 0; k < L; ++k) {
                B[j * L + k] = A[k] + C;
            }
        }

        std::swap(A, B);
        std::sort(A.begin(), A.end(), std::greater<lint>());
        A.resize(std::min((int)A.size(), K));
    }

    for (lint a : A) std::cout << a << std::endl;
    return 0;
}

Measured memory_bytes: 31488
import sys
sys.setrecursionlimit(10**7)

readline = sys.stdin.buffer.readline
def readstr():return readline().rstrip().decode()
def readstrs():return list(readline().decode().split())
def readint():return int(readline())
def readints():return list(map(int,readline().split()))
def printrows(x):print('\n'.join(map(str,x)))
def printline(x):print(' '.join(map(str,x)))

h,w,m = readints()

r = [0]*h
c = [0]*w

d = [set() for i in range(h)]
for i in range(m):
    a,b = (x-1 for x in readints())
    r[a] += 1
    c[b] += 1
    d[a].add(b)

mr = max(r)
mc = max(c)
R = [i for i,x in enumerate(r) if x==mr]
C = [i for i,x in enumerate(c) if x==mc]

flag = 1
if len(R)*len(C)>m:
    flag = 0
else:
    for x in R:
        for y in C:
            if y not in d[x]:
                flag = 0
                break

print(max(r)+max(c)-flag)






Measured memory_bytes: 206828
#include "bits/stdc++.h"
using namespace std;
#define INF 1000000000
#define rep(i, n) for(int i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> Vl;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
//stack<int> st;
// cout << << endl;
// cin >> ;

int main(){
    ll x=0,y=0,d=0,n,h,w,k,max=-100000,min=1000000,ans=0,count=0,sum=0;
    string s;
    cin >> n;
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            if(i*j==n){
              cout << "Yes" << endl;
              return 0;
            }
        }
    }

    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
class UnionFind():
    def __init__(self,n):
        self.parents = [-1]*n

    def find(self,x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    
    def union(self,x,y):
        x = self.find(x)
        y = self.find(y)
        
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x,y = y,x
            
        self.parents[x] += self.parents[y]
        self.parents[y] = x
        
N,M = map(int,input().split())    
uf = UnionFind(N)

for i in range(M):
    A,B = map(lambda x:int(x)-1,input().split())
    uf.union(A,B)
    #print(uf.parents)

print(abs(min(uf.parents)))

Measured memory_bytes: 14524
var s,p:ansistring;
    i,j,t:longint;
    a:int64;
begin
  readln(s);
  i:=1;
  while i<=length(s) do
  begin
    if s[i]='A' then
      p:=p+'A';
    if s[i]='B' then
      if (i<>length(s))and(s[i+1]='C') then
      begin
        p:=p+'B';
        inc(i,2);
        continue;
      end
      else
        p:=p+'C';
    if s[i]='C' then
      p:=p+'C';
    inc(i);
  end;
  s:=p;
  for i:=1 to length(s) do
    case s[i] of
      'A':inc(t);
      'B':inc(a,t);
      'C':t:=0;
    end;
  writeln(a);
end.

Measured memory_bytes: 608
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(a) (a).begin(), (a).end()
typedef vector<int> vi;
const int INF = 1LL << 58;
const int MOD = 1000000007;
const int MAX_N = 200100;

int dp[110][2][5];
signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    string N;
    int K;
    cin >> N >> K;
    REP(i, 110)
    {
        REP(j, 2)
        {
            REP(k, 5)
            {
                dp[i][j][k] = 0;
            }
        }
    }

    dp[0][0][0] = 0;
    dp[0][1][0] = 1;

    REP(i, N.size())
    {
        int c = N[i] - '0';
        REP(j, 4)
        dp[i + 1][0][j] += dp[i][0][j];

        if (c == 0)
        {
            REP(j, 4)
            {
                dp[i + 1][0][j + 1] += dp[i][0][j] * 9;
                dp[i + 1][1][j] += dp[i][1][j];
            }
        }
        else
        {
            REP(j, 4)
            {
                dp[i + 1][0][j + 1] += dp[i][0][j] * 9;
                dp[i + 1][0][j] += dp[i][1][j];
                dp[i + 1][0][j + 1] += dp[i][1][j] * (c - 1);
                dp[i + 1][1][j + 1] += dp[i][1][j];
            }
        }
        dp[i + 1][0][0] = 1;
    }
    // REP(i, N.size() + 1)
    // {
    //     REP(j, 2)
    //     {
    //         REP(k, 4)
    //         {
    //             cout << dp[i][j][k] << " ";
    //         }
    //         cout << endl;
    //     }
    //     cout << endl;
    // }

    cout << dp[N.size()][0][K] + dp[N.size()][1][K] << endl;

    return 0;
}

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

int main() {
    int N;
    string S;
    cin >> N >> S;
    if (N%2) {
        cout << "No" << endl;
        return 0;
    }

    cout << (S.substr(0, N/2) == S.substr(N/2, N/2) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
S = input()
X,Y = map(int,input().split())

# [文字,その文字が連続する数]
from collections import deque
sumS = deque()
import itertools
for key,g in itertools.groupby(S):
  sumS.append([key,len(list(g))])
  
startx = 0 # Fで始まる場合はX軸の正の方向にあらかじめ進めて置く
# 最初のTが出るまではX軸正の方向に進む
if sumS[0][0] == "F":
  startx = sumS[0][1]
  sumS.popleft()

xdir = True # X軸方向を向いている
dpXcur = set()
dpXcur.add(startx)
dpYcur = set()
dpYcur.add(0) # Y軸は必ず0から始まる
dpXnex = set()
dpYnex = set()
for i in range(len(sumS)):
  if sumS[i][0] == "F":
    steps = sumS[i][1] # 進む数
    if xdir: # X軸方向を向いている場合
      for x in dpXcur:
        dpXnex.add(x + steps)
        dpXnex.add(x - steps)
      dpXcur = dpXnex
      dpXnex = set()
    else:
      for y in dpYcur:
        dpYnex.add(y + steps)
        dpYnex.add(y - steps)
      dpYcur = dpYnex
      dpYnex = set()
  elif sumS[i][0] == "T":
    turns = sumS[i][1] # 方向転換する数
    if turns % 2 == 1:
      # 奇数回の場合はX/Y軸の切り替え (偶数回の場合は何も起こらない)
      xdir ^= True
      
if X in dpXcur and Y in dpYcur:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 4980
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(a){return a?cin[cid++]:+cin[cid++];}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

function mul(a,b){
  var ah = a >> 16, al = a & 0xffff;
  var h = ah * b, l = al * b;
  l += 0x10000 * (h & 0xffff), h = Math.floor(h / 0x10000);
  h += Math.floor(l / 0x100000000);
  return [l>>>0,h];
}
function add(a,b){
  var l = a[0]+b[0], h = a[1]+b[1];
  if(l > 0xffffffff)h++, l -= 0x100000000;
  return [l,h>>0];
}
function minus(a,b){
  var l = a[0]-b[0], h = a[1]-b[1];
  if(l < 0)h--, l += 0x100000000;
  return [l,h>>0];
}
function half(a){
  return [(a[0]>>>1) + (a[1]&1 ? 0x80000000 : 0),a[1]>>1];
}
function compare(a,b){
  if(a[1]>b[1])return 1;
  if(a[1]<b[1])return -1;
  if(a[0]>b[0])return 1;
  if(a[0]<b[0])return -1;
  return 0;
}
function toString(a){
  var neg = 0;
  if(a[1] < 0){
    neg = 1, a[1] = -a[1];
    if(a[0])a[0] = 0x100000000 - a[0], a[1]--;
  }
  var ih = 42949, il = 67296;
  var al = a[1] * il + a[0], ah = a[1] * ih + Math.floor(al / 100000);
  al %= 100000;
  var res = "";
  if(ah === 0)res += al;
  else{
    al = ("00000" + al).slice(-5);
    res = ah + al;
  }
  if(neg && res !== "0")res = "-" + res;
  return res;
}

var zero = 0, neg = [], pos = [];
var nsize, psize;

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var n = next(), k = next();
  for(var i = 0; i < n; i++){
    var a = next();
    if(a === 0)zero++;
    else if(a < 0)neg.push(a);
    else pos.push(a);
  }
  nsize = neg.length, psize = pos.length;
  neg.sort((a,b)=>a-b);
  pos.sort((a,b)=>a-b);
  var u = nsize * psize;
  if(k <= u)return negsolve(k);
  u += (2*n - zero - 1) * zero / 2;
  if(k <= u)return 0;
  return possolve(k-u);
}

function negsolve(k){
  var ok = [0xffffffff,-1], ng = add(ok,mul(-1e9,1e9));
  while(compare(minus(ok,ng),[1,0]) === 1){
    var m = half(add(ok,ng)), cnt = 0, l = 0;
    for(var i = 0; i < psize && cnt < k; i++){
      while(l < nsize && compare(mul(neg[l],pos[i]), m) <= 0)l++;
      cnt += l;
    }
    if(k <= cnt)ok = m; else ng = m;
  }
  return toString(ok);
}

function possolve(k){
  neg.reverse();
  var ok = mul(1e9,1e9), ng = [0,0];
  while(compare(minus(ok,ng),[1,0]) === 1){
    var m = half(add(ok,ng)), cnt = 0;
    for(var i = 0, l = psize-1; i < psize && cnt < k; i++){
      while(l > i && compare(mul(pos[l],pos[i]), m) > 0)l--;
      if(l <= i)break;
      cnt += l-i;
    }
    for(var i = 0, l = nsize-1; i < nsize && cnt < k; i++){
      while(l > i && compare(mul(neg[l],neg[i]), m) > 0)l--;
      if(l <= i)break;
      cnt += l-i;
    }
    if(k <= cnt)ok = m; else ng = m;
  }
  return toString(ok);
}

Measured memory_bytes: 55784
import datetime

def main():
    y,m,d = map(int, input().split('/'))

    diff = datetime.date(2019,4,30)-datetime.date(y,m, d)
    if diff.days >= 0:
        print('Heisei')
    else:
        print('TBD')

if __name__ == '__main__':
    main()


Measured memory_bytes: 42352
#include<bits/stdc++.h>
using namespace std;
int main(){
 int n,k;
 cin>>n>>k;
 vector<int> p(n,0);
 for(int i=0; i<k; i++){
   int d;
   cin>>d;
 
 for(int j=0; j<d; j++){
   int a;
   cin>>a;
   p[a-1]=1;
 }
 }
 int ans=0;
 for(int i=0; i<n; i++){
 if(p[i]==0)  ans++;
 }
 cout<<ans<<endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define siz(v) (ll)(v).size()
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define repr(i, a, n) for (ll i = n - 1; (ll)a <= i; i--)
#define lb lower_bound
#define ub upper_bound
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 + 99);
vector<ll> dx = {-1, 1, 0, 0}, dy = {0, 0, -1, 1};
template <typename T, typename U>
void chmin(T &t, const U &u)
{
    if (t > u)
        t = u;
}
template <typename T, typename U>
void chmax(T &t, const U &u)
{
    if (t < u)
        t = u;
}
template <typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <typename T>
T mpow(T a, T n)
{
    T res = 1;
    for (; n; n >>= 1)
    {
        if (n & 1)
            res = res * a;
        a = a * a;
    }
    return res;
}

//cin.tie(0);ios::sync_with_stdio(false);
//cout<<fixed<<setprecision(20);

signed main()
{
    int n, t;
    cin >> n >> t;
    int ans = INF;
    rep(i, 0, n)
    {
        int a, b;
        cin >> a >> b;
        if (b <= t)
            chmin(ans, a);
    }

    if (ans == INF)
    {
        cout << "TLE" << endl;
    }
    else
    {
        cout << ans << endl;
    }
}    

    //( ・ __ ・ ) KEEP BEING ORGANIZED
    //CHECK overflow,vector_size,output_format?

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int b,f,r,v,n;
  int room[4][3][10];
  scanf("%d",&n);
  for(int i=0;i<4;i++){
    for(int j=0;j<3;j++){
      for(int h=0;h<10;h++){
        room[i][j][h]=0;
      }
    }
  }
  for(int i=0;i<n;i++){
    scanf(" %d %d %d %d",&b,&f,&r,&v);
    room[b-1][f-1][r-1]+=v;
  }
  for(int j=0;j<3;j++){
    for(int h=0;h<10;h++){
      printf(" %d",room[0][j][h]);
    }
     printf("\n");
  } 
  for(int i=1;i<4;i++){
    printf("####################\n");
    for(int j=0;j<3;j++){
      for(int h=0;h<10;h++){
        printf(" %d",room[i][j][h]);
      }
      printf("\n");
    }
  }
  return 0;
}   





Measured memory_bytes: 1984
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int K;
string S;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> K >> S;
    if(S.length() <= K){
        cout << S << endl;
    }else{
        for(int i = 0; i < K; ++i) cout << S[i];
        cout << "..." << endl;
    }
    return 0;
}

Measured memory_bytes: 3644
#include <cstdio>
#include <algorithm>
using namespace std;

void mult(int K, bool matA[][100], bool matB[][100], bool matC[][100]) {
  for(int i = 0; i < K; i++) {
    for(int j = 0; j < K; j++) {
      matC[i][j] = false;
      for(int k = 0; k < K; k++) {
        matC[i][j] = matC[i][j] | (matA[i][k] & matB[k][j]);
      }
    }
  }
}

int main() {
  for(int tci = 0; ; tci++) {
    int N, M, Z; scanf("%d%d%d", &N, &M, &Z); Z--;
    if(N==0) break;
    static int ef[100], et[100];
    for(int i = 0; i < M; i++) {
      int s, d; scanf("%d%d", &s, &d); s--; d--;
      ef[i*2+0] = s; et[i*2+0] = d;
      ef[i*2+1] = d; et[i*2+1] = s;
    }
    int K = M*2;
    static bool mat1[100][100], mat2A[100][100], mat3A[100][100];
    bool (*mat2)[100] = mat2A;
    bool (*mat3)[100] = mat3A;
    for(int e1 = 0; e1 < K; e1++) {
      for(int e2 = 0; e2 < K; e2++) {
        mat1[e1][e2] = (et[e1] == ef[e2] && et[e2] != ef[e1]);
        // fprintf(stderr, "mat1[%d][%d] = %d\n", e1, e2, mat1[e1][e2]);
      }
    }
    for(int e1 = 0; e1 < K; e1++) {
      for(int e2 = 0; e2 < K; e2++) {
        mat2[e1][e2] = (e1 == e2);
      }
    }
    for(int i = 30; i >= 0; i--) {
      mult(K, mat2, mat2, mat3);
      if((Z>>i)&1) {
        mult(K, mat1, mat3, mat2);
      } else {
        swap(mat2, mat3);
      }
    }
    bool ok = false;
    for(int e1 = 0; e1 < K; e1++) {
      for(int e2 = 0; e2 < K; e2++) {
        ok = ok | (ef[e1] == 0 && et[e2] == N-1 && mat2[e1][e2]);
      }
    }
    printf("%s\n", ok ? "yes" : "no");
    // break; //TODO
  }
  return 0;
}

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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define MOD 1e9+7
#define sp ' '


using ll = long long;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}

int main(){

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

    int c[4];
    rep(i, 4){
        cin >> c[i];
    }

    sort(c, c+4);
    if(c[0] == 1 and c[1] == 4 and c[2] == 7 and c[3] == 9)
        YES();
    else
        NO();






    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    string s;
    cin >> s;
    int n = s.size();
    int ans = 0;
    rep(i, n/2) {
        if(s[i]!= s[n-i-1]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    string s;
    cin>>s;
    if(s.back()=='s') cout<<s+"es"<<endl;
    else cout<<s+"s"<<endl;
}

Measured memory_bytes: 3624
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        int first = scan.nextInt();
        int second = scan.nextInt();
        String result = "";
        int flg = (first + second) % 2;
        if (flg == 1) {
            result = "IMPOSSIBLE";
        } else {
            result = String.valueOf((first + second) / 2);
        }
        
        System.out.println(result);
    }
 }

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    ll n, a, b;
    cin >> n >> a >> b;
    cout << (n / (a + b)) * a + min((n - (a + b) * (n / (a + b))), a) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int MOD = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct edge{
    ll to, cost;
};


ll gcd(ll a,ll b){
    if(b == 0){
        return a;
    }else{
        return gcd(b, a%b);
    }
}

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 素数
vector<bool> IsPrime;
void sieve(size_t max){
    if(max+1 > IsPrime.size()){
        IsPrime.resize(max+1,true);
    } 
    IsPrime[0] = false;
    IsPrime[1] = false;

    for(size_t i=2; i*i<=max; ++i){
        if(IsPrime[i]){
            for(size_t j=2; i*j<=max; ++j){
                IsPrime[i*j] = false;
            }
        }
    }
}

// べき乗の余り
ll modpow(ll a, ll n){
    ll res = 1;
    while(n){
        if(n & 1){
            res = res * a % MOD;
        }
        a = a * a % MOD;
        n = n >> 1;
    }
    return res;
}

// コンビネーション
ll MAXN = 2e5+10;
vector<ll> inv(MAXN);
ll nCk(ll n, ll k) {
	ll res = 1;
	for(ll i = 1; i <= k; i++) {
		res = res*(n-i+1) % MOD;
	}
 
	for(ll i = 1; i <= k; i++) {
		res = res*inv[i] % MOD;
	}
	return res;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll n, a, b, c, d;
    cin>>n>>a>>b>>c>>d;
    a--; b--; c--; d--;
    string s;
    cin>>s;

    for(ll i=a;i<c;++i){
        if(s[i] == s[i+1] and s[i] == '#'){
            cout<<"No"<<endl;
            return 0;
        }
    }

    for(ll i=b;i<d;++i){
        if(s[i] == s[i+1] and s[i] == '#'){
            cout<<"No"<<endl;
            return 0;
        }
    }

    bool flag = false;
    if(c < d){
        cout<<"Yes"<<endl;
        return 0;
    }else{
        for(ll i=b;i<=d;++i){
            if(s[i] == '.' and s[i-1] == '.' and s[i+1] == '.'){
                flag = true;
            }
        }
        if(flag){
        cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 5192
#include "bits/stdc++.h"

using namespace std;

const int mx = 1e5 + 9;

int par[mx];
int p[mx], idx[mx];

int fnd(int x) {
    if (par[x] == x) return x;
    return par[x] = fnd(par[x]);
}

int main() {
    for (int i = 0; i < mx; i++) par[i] = i;
    int n, m; scanf("%d %d", &n, &m);
    
    for (int i = 1; i <= n; i++) {
        scanf("%d", &p[i]);
        idx[p[i]] = i;
    }

    for (int i = 1; i <= m; i++) {
        int x, y; scanf("%d %d", &x, &y);
        x = fnd(x), y = fnd(y);
        par[x] = y;
    }

    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (idx[i] == i) {
            ans++;
            continue;
        }

        int x = p[i];
        int y = idx[i];

        if (fnd(y) == fnd(i)) {
            ans++;
            p[i] = i; idx[i] = i;
            p[y] = x; idx[x] = y;
        }
    }

    printf("%d\n", ans);
}

Measured memory_bytes: 4916
a = input()
ans = [0] * len(a)
now = "R"
l_stack = 0
r_stack = 0
switch = 0
for key, i in enumerate(a):
  if now == "R":
    if i == "L":
      ans[key-1] += int((r_stack+1) / 2)
      ans[key] += int(r_stack / 2) + 1
      r_stack = 0
      l_stack += 1
      switch = key
    elif i == "R":
      r_stack += 1
  else:
    if i == "L":
      l_stack += 1
      if not l_stack % 2:
        ans[switch-1] += 1
      else:
        ans[switch] += 1
    else:
      l_stack = 0
      r_stack += 1
  now = i
print(*ans)

Measured memory_bytes: 7668
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int n,m;
	cin >> n >> m;
	cout << ((n==m)?"Yes":"No") << endl;
	return 0;
}


Measured memory_bytes: 256
n, q = map(int, input().split())
s = input()
ac_list = [0]*len(s)

'''while True:
    ac_index = s[i:].find("AC")
    if ac_index == -1:
        break
    else:
        ac_list[ac_index+i] = 1
        i = ac_index + i + 2'''

for i in range(len(s)-1):
    if s[i:i+2] == 'AC':
        ac_list[i+1] = ac_list[i] + 1
    else:
        ac_list[i+1] = ac_list[i]
# print(ac_list)
for _ in range(q):
    l, r = map(int, input().split())
    print(ac_list[r-1] - ac_list[l-1])


Measured memory_bytes: 6188
import math
a,b,h,m=map(int,input().split())

t=abs((h*30+m*0.5)-m*6)
if t>180:
  t=360-t
else:
  pass

ans=math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(t)))

print(ans)

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int t,p,r;
//int snum[55],pnum[55][11],penalty[55];
struct team{
	int id,snum,pnum[11],penalty;
};
bool comp(const team& a,const team& b){
	if(a.snum==b.snum){
		if(a.penalty==b.penalty)return a.id<b.id;
		else return a.penalty<b.penalty;
	}else return a.snum>b.snum;
}
team teams[55];

int main(){
	cin.sync_with_stdio(false);
	while(1){
		cin>>t>>p>>r;
		if(t==0)break;
		rep(i,t){
			teams[i].id=i;
			teams[i].snum=0;
			teams[i].penalty=0;
			rep(j,p)teams[i].pnum[j]=0;
		}
		rep(i,r){
			int tid,pid,time; string mes;
			cin>>tid>>pid>>time>>mes;
			tid--; pid--;
			if(mes=="CORRECT"){
				teams[tid].snum++;
				teams[tid].penalty+=teams[tid].pnum[pid]*1200+time;
			}else{
				teams[tid].pnum[pid]++;
			}
		}
		sort(teams,teams+t,comp);
		rep(i,t){
			cout<<teams[i].id+1<<" "<<teams[i].snum<<" "<<teams[i].penalty<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3216
#include <iostream>
#include <cstdio>

using namespace std;
const int maxn = 4;
char a[maxn+1];
int getbit(int x,int y)
{
	return (x>>y) & 1;
}
int main()
{
	ios_base::sync_with_stdio(0);
	//freopen("input.txt","r",stdin);
	cin >> a[1] >> a[2] >> a[3] >> a[4];
	a[1]-='0';
	a[2]-='0';
	a[3]-='0';
	a[4]-='0';
	for (int i=0; i<(1<<3); i++)
	{
		int sum=a[1];
		for (int j=0; j<3; j++)
		if (getbit(i,j)) sum+=a[j+2];
		else sum-=a[j+2];
		if (sum==7)
		{
			cout << (char) (a[1]+'0');
			for (int j=0; j<3; j++)
			if (getbit(i,j)) cout << '+' << (char) (a[j+2]+'0');
			else cout << '-' << (char) (a[j+2]+'0');
			cout << "=7";
			return 0;
		}
	}
	
	return 0;
}

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

int main() {
    int N, L, T; cin >> N >> L >> T;
    int x[N], w[N]; for (int i = 0; i < N; i++) cin >> x[i] >> w[i];
    int y[N];
    for (int i = 0; i < N; i++)
        y[i] = ((x[i] + T * (w[i] == 1 ? 1 : -1)) % L + L) % L;
    int y0 = y[0];
    sort(y, y+N);
    long long m = 0;
    for (int i = 1; i < N; i++)
        if (w[0] == 1 && w[i] == 2)
            m += (L + x[0] - x[i] + 2LL * T - 1) / L;
        else if (w[0] == 2 && w[i] == 1)
            m += (x[i] - x[0] + 2LL * T) / L;
    int j = w[0] == 1 ? m % N : ((- m) % N + N) % N;
    int p = lower_bound(y, y+N, y0) - y;
    int ans[N];
    for (int i = 0; i < N; i++)
        ans[(j + i) % N] = y[(p + i) % N];
    for (int x : ans) cout << x << endl;
}


Measured memory_bytes: 2816
// XORは桁ごとに独立に計算できる

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

const char wall = '#';
vector<vector<char>> fields;
vector<vector<bool>> used;
vector<vector<ll>> dist;
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0};

vector<ll> A;
// vectorのリサイズ
// A.resize(N);

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return b/gcd(a,b)*b;}

const int mod =1e9+7;

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

  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  ll ans = 0;
  rep(i, 60) {
    ll x = 0;
    // XORだから0, 1の組み合わせしか1にならない
    // i桁目が1であるものをxとして数える
    rep(j, n) if (a[j]>>i&1) ++x;
    // (n-x) は0の個数
    ll now = x*(n-x)%mod;
    // i桁分2をかける
    rep(j,i) now = now*2%mod;
    //cout << "now: " << now << endl;
    ans += now;
    //cout << "ans:" << endl;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2560
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

const int MAX_N = 3005, MOD = 1000000007;

int f[MAX_N][2], g[MAX_N][2];
int N, M;

inline void update(int &x, int y) {
  x = (x + y) % MOD;
}

int main() {
  scanf("%d%d", &N, &M);
  for (int i = 0; i <= N; ++i) f[i][0] = 1;
  for (int i = 1; i <= M; ++i) {
    memset(g, 0, sizeof g);
    for (int j = 0; j <= N; ++j) 
      for (int x = 0; x < 2; ++x) {
	int R = j, B = N - j;
	if (R >= 1) {
	  update(g[j - 1][(R == 1) | x], f[j][x]);
	  update(g[j][(R == 1) | x], f[j][x]);
	}
	if (B >= 1) {
	  update(g[j + 1][(B == N) | x], f[j][x]);
	  update(g[j][(B == N) | x], f[j][x]);
	}
      }
    memcpy(f, g, sizeof f);
  }
  int result = 0;
  for (int i = 0; i <= N; ++i)
    update(result, f[i][1]);
  printf("%d\n", result);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K,sum=0;
  cin >> N >> K;
  for (int i =0 ; i <N ; i++) {
  int x;
  cin >> x;
  if (x*2 <= (K-x)*2 ){
  sum += x*2;
  }
  else {
  sum += (K-x)*2;
  }
 } 
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	double A,B;
	cin>>A>>B;
	if(B == 1){cout<<0<<endl; return 0;}
	int ans = 1; B -= A;
	cout<<ans + ceil(B/(A-1))<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A,*B;

  int C[VMAX+1];
  int n,i,j;
  scanf("%d",&n);

  A=malloc(sizeof(short)*n+1);
  B=malloc(sizeof(short)*n+1);

  for(i=0;i<=VMAX;i++) C[i]=0;

  for(i=0;i<n;i++){
    scanf("%hu",&A[i+1]);
    C[A[i+1]]++;
  }

  for(i=1;i<=VMAX;i++) C[i]=C[i]+C[i-1];
  
  for(j=1;j<=n;j++){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }

  for(i=1;i<=n;i++){
    if(i>1) printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");

  return 0;
}



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

int const MAX = 100005;
long long a[MAX];

int main() {
	int n; long long x;
	cin >> n >> x;
	a[0] = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	long long ans = 0;
	for (int i = 1; i <= n; i++) {
		long long eat;
		eat = a[i] -x + a[i - 1];
		if (eat < 0) { eat = 0; }
		ans += eat;
		a[i] -= eat;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
# }}}

def solve():
    s = input()
    if s == "ABC":
        print("ARC")
    else:
        print("ABC")

    return 0

if __name__ == "__main__":# {{{
    solve()

# vim: set foldmethod=marker: }}}


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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

typedef long long LL;
const LL mod=1000000007;
#define MAX 10000
#define NIL -1
const double PI  = acos(-1.0);
const int INF = 1e9 + 7;
//-------------------------------------------


string s;
int w;

int main(){

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

    cin >> s;
    cin >> w;
    int x = 0;

    //dump( sizeof(s));


    for( int i = 1 ; i <= s.size() ; i = i +  w){

        cout << s[i-1];

    }

    //cout << endl;




    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<map>
#include<math.h>
#include<queue>
using namespace std;

int keta(int a) {
	int cnt = 1;
	while (a/10!= 0) {
		a /= 10;
		cnt++;
	}
	return a;
}

int main() {
	int n;
	cin >> n;
	int c[10][10];
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			c[i][j] = 0;
		}
	}
	for (int i = 1; i < 10; i++) {
		for (int j = 1; j < 10; j++) {
			for (int k = 1; k <= n; k++) {
				if (keta(k) == i && k % 10 == j)c[i][j]++;
			}
		}
	}
	
	int ans=0;
	for (int i = 1; i < 10; i++) {
		for (int j = 1; j < 10; j++) {
			ans += c[i][j] * c[j][i];
		}
	}
	cout << ans << endl;
	return 0;

	
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
  string s;
  cin >> s;
  map<char, int> c;
  for (int i = 0; i < (int)s.size(); ++i) c[s[i]] += 1;

  for (auto& p : c) {
    if (p.second % 2) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iomanip>
#include <random>
#include <time.h>
#include <vector>
#include <queue>
#include <functional>
#include <map>
#include <string>
#include <cstdlib>
#include <typeinfo>
#include <math.h>
#include <algorithm>
#include <iostream>
#include <list>
#include <stack>
#include <set>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
using namespace std;
int main() {
	ll n, m, a, dp[55][2] = {};
	cin >> n >> m;
	dp[0][0] = 1;
	for (int i =1 ; i <= n; i++) {
		cin >> a;
		dp[i][0] = dp[i - 1][0];
		dp[i][1] = dp[i - 1][1];
		if (a % 2)dp[i][1] += dp[i - 1][0], dp[i][0] += dp[i - 1][1];
		else {
			dp[i][0] += dp[i - 1][0];
			dp[i][1] += dp[i - 1][1];
		}
	}
	cout << dp[n][m] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
    long long a, bf, bb;
    scanf("%lld %lld.%lld", &a, &bf, &bb);

    long long ans = (a * (bf * 100LL + bb)) / 100LL;

    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 1732
#include<stdio.h>

int main()
{
	int N,A,B,C,D;
	char S[200005];
	int i,j;
	scanf("%d %d %d %d %d",&N,&A,&B,&C,&D);
	scanf("%s",&S);
        for(i=A;i<C-1;i++)
        {
                if((S[i]=='#')&&(S[i+1]=='#'))
                {
                        printf("No\n");
                        return 0;
                }
        }
	for(i=B;i<D-1;i++)
        {
                if((S[i]=='#')&&(S[i+1]=='#'))
                {
                        printf("No\n");
                        return 0;
                }
        }

	if(C<D)
	{
		printf("Yes\n");
		return 0;
	}else{
		// Find a spot where A can pass B
		for(i=B-1;i<D;i++) 
		{
			if((S[i-1]=='.')&&(S[i]=='.')&&(S[i+1]=='.'))
			{
			   printf("Yes\n");
			   return 0;
			}
		}
		printf("No\n");
		return 0;
	}
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int SelectionSort(int *arr,int n)
{
    int min = 0;
    int t = 0;

    for (int i = 0; i < n; i++)
    {
        min = i;

        for (int j = i + 1; j < n; j++)
        {
            if (arr[j] < arr[min])
            {
                min = j;
            }
        }

        if (min != i)
        {
            arr[i]       ^= arr[min];
            arr[min] ^= arr[i];
            arr[i]       ^= arr[min];
            t++;
        }
    }
    return t;
}

int main(int argc, char *argv[])
{
    int Num = 0;
    int Operations = 0;
    cin >> Num;
    int *arr = new int[Num];

    for (int i = 0; i < Num; i++)
    {
        cin >> arr[i];
    }

    Operations = SelectionSort(arr, Num);

    for (int i = 0; i < Num; i++)
    {
        if (i == 0)
        {
            cout << arr[i];
        }
        else
        {
            cout << " " << arr[i];
        }
    }
    cout << "\n" << Operations << endl;

    return 0;
}


Measured memory_bytes: 3136