akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int H,W;
    cin >> H >> W;
    vector<string> S(H);
    for (int i=0; i< H; i++) {
        cin >> S[i];
    }
    int U[H][W];
    int D[H][W];
    int L[H][W];
    int R[H][W];

    for (int i=0; i< H; i++) {
        for (int j=0; j < W; j++) {
            U[i][j] = 0;
            D[i][j] = 0;
            L[i][j] = 0;
            R[i][j] = 0;
        }
    }
    for (int i=0; i < H; i++) {
        for (int j=0; j < W; j++) {
            if (i > 0){
                if (S[i-1][j] == '#') {
                    U[i][j] = 0;
                } else {
                    U[i][j] = U[i - 1][j] + 1;
                }
            }
            if (j > 0) {
                if (S[i][j-1] == '#') {
                    L[i][j] = 0;
                }else {
                    L[i][j] = L[i][j-1] + 1;
                }
            }
        }
    }
    for (int i= H-1; i>= 0; i--) {
        for (int j= W-1; j >= 0; j--) {
            if (i<H-1) {
                if (S[i+1][j] =='#') {
                    D[i][j] = 0;
                }else{
                    D[i][j] = D[i+1][j] +1;
                }
            }
            if (j < W-1) {
                if (S[i][j+1] == '#'){
                    R[i][j] = 0;
                }else {
                    R[i][j] = R[i][j+1] + 1;
                }
            }
        }
    }

    int res = 0;
    for (int i=0; i < H; i++) {
        for (int j=0; j < W; j++) {
            if (S[i][j] != '#') {
                res = max(res, U[i][j] + D[i][j] + R[i][j] + L[i][j]);
            }
        }
    }
    cout << res+1 << endl;
    return 0;
}

Measured memory_bytes: 66816
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cmath>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <complex>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <unordered_map>

using namespace std;
typedef long long ll;

int main()
{
	int a,b,t;
	std::cin >> a;
	std::cin >> b;
	std::cin >> t;

	t += 0.5;
	int hoge = t / a;
	cout << hoge*b << endl;
}

Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()
mod = 10**9 + 7

days = ["SUN","MON","TUE","WED","THU","FRI","SAT"]
d = {}
for i in range(7):
    d[days[i]] = 7 - i
s = input()
print(d[s])

Measured memory_bytes: 3060
using System;

class Program
{
    static void Main(string[] args)
    {
        var s = Console.ReadLine();
        if (s == "Sunny") Console.WriteLine("Cloudy");
        else if (s == "Cloudy") Console.WriteLine("Rainy");
        else if (s == "Rainy") Console.WriteLine("Sunny");
    }
}


Measured memory_bytes: 13140
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int h, w;
    int i, j, d, a, b;

    for(;;){
      h = sc.nextInt();
      w = sc.nextInt();
      if(h == 0 && w == 0)break;
      d = h * h + w * w;
      a = 150; b = 150;

      for(i = 1;i < 150;i++){
        for(j = i + 1;j < 150;j++){
          if(i * i + j * j > d || (i * i + j * j == d && i > h)){
            if(i * i + j * j < a * a + b * b ||
            (i * i + j * j == a * a + b * b && i < a)){
              a = i; b = j;
            }
          }
        }
      }
      out.println(a + " " + b);
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

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

using namespace std;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 1e9
typedef long long ll;
ll mod =   998244353;

long long fast_exp(long long a, long long b)
{
	if(b <= 0)
	   return 1;
	else
	{
	   long long res = 1;
	   res = fast_exp(a,b/2);
	   res = (res*res)%mod;
	   if(b%2 == 1)
		  res = (res*a)%mod;
	   return res;
 
	}
}




int main()
{
	// ios_base::sync_with_stdio(false);
	// cin.tie(NULL);
	long long n,d,a;
	cin>>n>>d>>a;

	set < pair< long long,pair<long long,long long> > > mons;
	long long x,h;
	for(long long i = 0; i<n ; i++)
	{
		cin>>x>>h;
		mons.insert(mp(x,mp(h,1)));
	}
	long long dam = 0;
	long long cnt = 0;
	for(auto itr : mons)
	{
		if(itr.ss.ss == 2)
			dam += itr.ss.ff;
		else
		{
			if(itr.ss.ff - dam > 0)
			{
				long long curx = itr.ff;
				long long rem =  itr.ss.ff - dam;
				long long curcount = 0;
				curcount =  (rem + a-1)/(a);
				dam += curcount * a;
				cnt += curcount;
				mons.insert(mp(curx + 2*d + 1,mp(-curcount * a,2)));
			}
		}
	}
	
	cout<<cnt<<endl;

	return 0; 
}

Measured memory_bytes: 25216
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Oct 24 00:11:24 2019

@author: iwao_yuuki
"""

n = int(input(""))
S = [int(x) for x in input().split()]

q = int(input(""))
T = [int(x) for x in input().split()]

cnt = 0
for i in T:
    flag = False
    for j in S:
        if i == j:
            cnt += 1
            flag = True
        if flag:
            break

print(cnt)


Measured memory_bytes: 6568
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Diagnostics;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
    static void Main()
    {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        new Program().Solve();
        Console.Out.Flush();
    }
    Scanner cin = new Scanner();

    void Solve()
    {
        int N = cin.Nextint;
        var T = cin.Scanint;
        int M = cin.Nextint;

        int sum = T.Sum();
        for (int i = 0; i < M; i++)
        {
            int P = cin.Nextint - 1, X = cin.Nextint;
            Console.WriteLine(sum - T[P] + X);
        }
    }
}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] Scan { get { return Console.ReadLine().Split(); } }
    public int[] Scanint { get { return Array.ConvertAll(Scan, int.Parse); } }
    public long[] Scanlong { get { return Array.ConvertAll(Scan, long.Parse); } }
    public double[] Scandouble { get { return Array.ConvertAll(Scan, double.Parse); } }
    public string Next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return Next;
        }
    }
    public int Nextint { get { return int.Parse(Next); } }
    public long Nextlong { get { return long.Parse(Next); } }
    public double Nextdouble { get { return double.Parse(Next); } }
}

Measured memory_bytes: 2776
//C
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

//C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Others
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;
}
const int dx[8] = { -1,0,1,-1,1,-1,0,1 };
const int dy[8] = { 1,1,1,0,0,-1,-1,-1 };


//LOVE NyantakoGG	https://www.youtube.com/channel/UC6XdFs8T6Ei54O0FYl3PVVA


using namespace std;



int main() {
	int N, A, B;
	cin >> N >> A >> B;
	int ans = 0;
	for (int i = 1; i <= N; i++) {
		int n = 0;
		for (int j = 0; j < (int)floor(log10(i)) + 1; j++) {
			char c = to_string(i)[j];
			n += (int)c - 48;
		}
		if (A <= n && n <= B) {
			ans += i;
		}
	}
	cout << ans << endl;
}

//TLE Code

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

int main() {
	string n;
	int i;
	bool check = false;

	cin >> n;
	
	if (n[0] != 'A') {
		cout << "WA";
		return 0;
	}

	for (i = 1; i < n.length(); i++) {
		if (n[i] == 'C' && i!=1 && i!=n.length()-1) {
			if (check==true) {
				cout << "WA";
				return 0;
			}
			check = true;
		}
		else if (!('a' <= n[i] && n[i] <= 'z')) {
			cout << "WA";
			return 0;
		}
	}
	if (check)
		cout << "AC";
	else
		cout << "WA";

	return 0;
}

Measured memory_bytes: 256
n = int(input())
li = [0]*n
p = int(n**0.5)
for x in range(1,p+1):
    for y in range(1,p+1):
        for z in range(1,p+1):
            k = x**2+y**2+z**2+x*y+y*z+z*x
            if k<=n:
                li[k-1]+=1

print(*li,sep="\n")

Measured memory_bytes: 9576
#include<stdio.h>
int main(void){
    char x[4];
    scanf("%s",x);
    if((x[0]==x[1]&&x[1]==x[2]) || (x[1]==x[2]&&x[2]==x[3])){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}





Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)




int main() {
	string s; cin >> s;
	if (s == "Sunny") cout << "Cloudy" << endl;
	if (s == "Cloudy") cout << "Rainy" << endl;
	if (s == "Rainy") cout << "Sunny" << endl;
}

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

const int MOD = (int)1e9+7;

int main(){
	int N,K;
	string S;
	cin >> N >> K >> S;
	
	vector<int> x;
	int count=1;
	if(S.at(0)=='0')	x.push_back(0);
	for(int i=1;i<N;i++){
		if(S.at(i)==S.at(i-1))	count++;
		else{
			x.push_back(count);
			count=1;
		}
	}
	x.push_back(count);
	if(S.at(N-1)=='0')	x.push_back(0);
	
	vector<int> sum(x.size()+1);
	sum.at(0)=0;
	for(int i=1;i<sum.size();i++){
		sum.at(i)=sum.at(i-1)+x.at(i-1);
	}
	
	int ans=0;
	int left,right;
	for(left=0;left<sum.size();left+=2){
		right=left+2*K+1;
		if(right>=sum.size())	right=sum.size()-1;
		int a=sum.at(right)-sum.at(left);
		ans=max(ans,a);
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 1272
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
s = input()

ans =[]
for i in range(len(s)):
	if s[i] != "B":
		ans.append(s[i])
	else:
		if ans != []:
			del ans[-1]

print("".join(ans))

Measured memory_bytes: 5144
#include <bits/stdc++.h>
#define INF 2000000000
using namespace std;
typedef long long ll;
int read(){
    int f = 1, x = 0;
    char c = getchar();
    while(c < '0' || c > '9'){if(c == '-') f = -f; c = getchar();}
    while(c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar();
    return f * x; 
}
int n, q;
char s[500005], ss[3];
set<int> st[26];
void init(){
    n = read();
    scanf("%s", s);
    for (int i = 0; i < n; ++i)
        st[s[i] - 'a'].insert(i + 1);
    q = read();
}
void solve(){
    while (q--){
        int opt = read();
        if (opt == 1){
            int pos = read();
            scanf("%s", ss);
            int from = s[pos - 1] - 'a';
            st[from].erase(pos);
            s[pos - 1] = ss[0];
            st[ss[0] - 'a'].insert(pos);
        }else{
            int l = read(), r = read();
            int cnt = 0;
            for (int i = 0; i < 26; ++i)
                if (st[i].lower_bound(l) != st[i].lower_bound(r + 1))
                    ++cnt;
            printf("%d\n", cnt);
        }
    }
}
int main(){
    init();
    solve();
    return 0;
}

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

namespace abc156_b
{
  class Program
  {
    static void Main(string[] args)
    {
      var N = CIn.ReadInt();
      var K = CIn.ReadInt();

      var ans = (int)Math.Log(N, K) + 1;

      Console.WriteLine(ans);
    }
  }

  static class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }
      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(int n)
    {
      var array = new string[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }
      return array;
    }

    public static int[] ReadIntArray(int n)
    {
      var array = new int[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }
      return array;
    }

    public static long[] ReadLongArray(int n)
    {
      var array = new long[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }
      return array;
    }

    public static double[] ReadDoubleArray(int n)
    {
      var array = new double[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }
      return array;
    }

    public static char[,] ReadCharMatrix(int h, int w)
    {
      var array = new char[h, w];
      for (var i = 0; i < h; i++)
      {
        var l = Console.ReadLine().ToCharArray();
        for (var j = 0; j < w; j++)
        {
          array[i, j] = l[j];
        }
      }
      return array;
    }
  }
}


Measured memory_bytes: 11348
import sys
sys.setrecursionlimit(1 << 25)
readline = sys.stdin.buffer.readline
read = sys.stdin.readline  # 文字列読み込む時はこっち

import numpy as np
from functools import partial
array = partial(np.array, dtype=np.int64)
zeros = partial(np.zeros, dtype=np.int64)
full = partial(np.full, dtype=np.int64)

ra = range
enu = enumerate


def a_int(): return int(read())


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import

from collections import defaultdict, Counter, deque
from operator import itemgetter, xor, add
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from functools import reduce

K = np.array(list(map(int, list(input()))))
D = a_int()

'''
ある数xにおいて総和がDの倍数であるかの判定
x[0]+x[1]...+x[n] ≡ 0 (mod D) 各桁の和にMODを取れば良い。つまり桁ごとに処理できる

dp[i,j,k] ... K[:i]以下の整数のうち、k=mod Dとなるような数字の個数。j==1は上位桁が一致している場合の通りの個数。j==0は上位桁が一致しなくなったときの個数。

遷移
for l in range(10):
    dp[i+1,0,(k+l)%D] += dp[i,0,k] #1~9を考慮可能
for l in range(K[i]):
    dp[i+1,0,(k+l)%D] += dp[i,1,k] #1~K[i]-1をつけるとぴったりにならないグループへ行く

dp[i+1,1,(k+K[i])%D] += dp[i,1,k]
'''
# print(K, D)

from numba import njit


@njit('(i8[:],i8)', cache=True)
def solve(K, D):
    N = K.shape[0]
    dp = np.zeros((N + 1, 2, D), dtype=np.int64)
    dp[0, 1, 0] = 1
    for i in range(N):  # 各桁について
        for k in range(D):  # 各あまりについて処理
            for l in range(10):  # 各数字について処理
                dp[i + 1, 0, (k + l) % D] += dp[i, 0, k]  # 1~9を考慮可能
                if l < K[i]:
                    dp[i + 1, 0, (k + l) % D] += dp[i, 1, k]
                    # 1~K[i]-1をつけるとぴったりにならないグループへ行く
                dp[i + 1, 0, (k + l) % D] %= MOD
            # ぴったりグループ
            dp[i + 1, 1, (k + K[i]) % D] += dp[i, 1, k]
            # dp[i + 1, 1, (k + K[i]) % D] %= MOD

    print((dp[-1, :, 0].sum() - 1) % MOD)  # -1は0の分


solve(K, D)


Measured memory_bytes: 131140
#include<cstdio>
#include<cstring>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int ans[3101010];
int main()
{
	int n,a,b,dnn,rem,i,uplength,tmp;
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%d%d%d",&n,&a,&b);
	if(a+b>n+1||(long long)a*b<n)
	{
		printf("-1");
		return 0;
	}
	dnn=0;
	rem=n;
	while(1)
	{
		//printf("%d\n",dnn);
		uplength=rem-(b-dnn)+1;
		//printf("%d %d\n",rem,uplength);
		if(uplength<=a)//dnn+1+rem-a<b)
		{
			tmp=0;
			for(i=dnn*a+1;i<=dnn*a+uplength;i++)
			{
				tmp++;
				//printf("%d",i);
				ans[i]=rem-uplength+tmp;
			}
			//dnn++;
			//printf("%d %d %d\n",n,b,dnn);
			for(i=dnn*a+uplength+1;i<=n;i++)
			{
				ans[i]=n-i+1;
			//	printf("%d %d\n",i,ans[i]);
			}
			break;
		}
		else
		{
			tmp=0;
			for(i=dnn*a+1;i<=(dnn+1)*a;i++)
			{
				tmp++;
				ans[i]=tmp+n-a*(dnn+1);
			}
			rem-=a;
			dnn++;
		}
	}
	for(i=1;i<=n;i++)
		printf("%d ",ans[i]); 
	return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

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

	if (s == t) {
		cout << "Yes" << endl;
		return 0;
	}

	for (int i = 1; i < s.length(); i++) {
		string a = s.substr(i, s.length());
		string b = s.substr(0, i);
		string c = a + b;

		if (c == t) {
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<utility>
#include<string>
using namespace std;

int main(){
    int a , b , c , d;
    cin>>a>>b>>c>>d;

    if( abs(c - a) <= d ){
        cout<<"Yes"<<endl;
        return 0;
    }else{
        if( abs(c-b) <= d && abs(b-a) <= d ){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

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

#define rep(i, n) for(int i = 0 ; i < n ; i++)
using namespace std;
void dfs(int x, int y);

int cnt = 0;
string data[20];
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, 1, 0, -1};
int w, h;

int main()
{
    while(true){
      cin >> w >> h;
      if(w == 0 && h == 0) break;
      
      int sx, sy;
      for(int i = 0 ; i < h ; i++){
	cin >> data[i];
	for(int j = 0 ; j < w ; j++){
	  if(data[i][j] == '@'){
	    sx = j;
	    sy = i;
	  }
	}
      }
      dfs(sx, sy);
      cout << cnt << '\n';
      cnt = 0;
  }
}

void dfs(int x, int y)
{
  data[y][x] = '#';
  cnt++;

  rep(i, 4){
    int nx = x + dx[i], ny = y + dy[i];
    if(0 <= nx && nx < w && 0 <= ny && ny < h && data[ny][nx] == '.'){
      dfs(nx, ny);
    }
      }
}

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

int main() {
    ll H, W;
    cin >> H >> W;
    if (H == 1LL || W == 1LL) {
        cout << 1 << endl;
    } else {
        cout << (H * W) / 2LL + ((H * W) % 2LL == 0LL ? 0LL : 1LL) << endl;
    }
}

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

using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
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;
}

void solve(long long N, std::vector<long long> X, std::vector<long long> L) {
    vector<pair<ll, ll> > segs;
    for (int i = 0; i < N; i++) {
        segs.emplace_back(X[i] + L[i], X[i] - L[i]);
    }
    sort(segs.begin(), segs.end());

    ll cur = -1e18;

    int ans = 0;
    for (auto s : segs) {
        if (cur <= s.second) {
            cur = s.first;
            ans++;
        }
    }
    cout << ans << endl;
}

int main() {
    long long N;
    scanf("%lld", &N);
    std::vector<long long> X(N);
    std::vector<long long> L(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &X[i]);
        scanf("%lld", &L[i]);
    }
    solve(N, std::move(X), std::move(L));
    return 0;
}


Measured memory_bytes: 4464
#include <bits/stdc++.h>
using namespace std;
#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,n) (int i=a;i<n;i++)
#define per(i,a,n,s) (int i=n-1;i>=a;i--)
#define range(...) _overload3(__VA_ARGS__,per,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define vecin(x) for(auto&youso_: (x) ) cin >>  youso_
#define vecout(x) for(auto&youso_: (x) ) cout << youso_ << " " ; cout << endl
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; }
const int inf = 1e9+10;
const int mod = 1e9+7;
const long long llinf = 1e18;
#define _GLIBCXX_DEBUG
// head

int main(){
    int ans1=inf,ans2=1;
    vector<int> a(2),c(2);
    vector<int> x,y;
    int e,f;
    vecin(a);vecin(c);
    cin >>e>>f;
    int i=-1,j=-1;
    while ((a[0]*(++i)+a[1]*j)*100<=f){
        while ((a[0] * i + a[1] * (++j))*100 <= f){
            x.push_back((a[0]*i+a[1]*j)*100);
        }j=-1;
    }
    i = -1; j = -1;
    while (c[0]*(++i)+c[1]*j<=f){
        while (c[0] * i + c[1] * (++j) <= f){
            y.push_back(c[0]*i+c[1]*j);
        }j=-1;
    }
    for range(i,x.size()){
        for range(j,y.size()){
            if (x[i]+y[j]<=f && x[i]/100*e>=y[j] && ans1*y[j]>=ans2*(x[i]+y[j])){
                ans1=x[i]+y[j];ans2=y[j];
            }
        }
    }
    // cout <<y[0]<<endl;
    cout << ans1 << " " << ans2 <<endl;
}

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

// @@ !! LIM(binsearch)
// --> binsearch
// ---- inserted library file binsearch.cc

template<typename T>
T binsearch(auto check, T yes, T no, T err = (T)1) {
  while (abs(yes - no) > err) {
    T mid = (yes + no) / (T)2;
    if (check(mid)) yes = mid;
    else            no  = mid;
  }
  return yes;
}

// ---- end binsearch.cc
// @@ !! LIM  -- end mark --

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N, K; cin >> N >> K;
  vector<ll> A(N);
  for (ll i = 0; i < N; i++) cin >> A[i];
  auto check = [&](ll x) -> bool {
    ll cnt = 0;
    for (ll i = 0; i < N; i++) {
      cnt += (A[i] + x - 1) / x - 1;
    }
    return cnt <= K;
  };
  ll x = binsearch<ll>(check, 1e9, 0);
  cout << x << endl;

  return 0;
}



Measured memory_bytes: 4792
program sample
    implicit none
    real(8)::x,y,z
    integer(8) :: a,b,c,i,j,m,n,k,a1,b1,c1
    
    
  
    read(*,*) a,b
    n=0
    do while (a*n-n+1<b)
        n=n+1
    end do
    
    write(*,*) n
    
    stop
end program sample
  



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

#define ll long long
#define Fi first
#define Se second
#define Pb push_back
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
#define vvp vector<vector<pair<int,int>>>

const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>; //Caution!! Segmentation Fault!! Don't forget to add +1!

#define all(v) v.begin(),v.end()
#define output_s(a) printf("%s\n",(a).c_str())

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m) for(int i=(int)(n);i>=(int)(m);i--)
#define RepA(x) for(auto &item:(x))

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template<typename TypeInt> //最大公約数
TypeInt GCD(TypeInt a,TypeInt b){
    if(a%b==0) return b;
    else return GCD(b,a%b);
}
template<typename TypeInt> //最小公倍数
TypeInt LCM(TypeInt a,TypeInt b){
    return a*b/GCD(a,b);
}

int IN_int(){
    int x;
    scanf("%d",&x);
    return x;
}

//----------------------library------------------------//

//const int dx[4]={1,0,-1,0};
//const int dy[4]={0,1,0,-1};
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

const int NMAX = 200;
bool flag;

bool comp(int x,int y){
    return abs(0-x)<abs(0-y);
}


signed main(){
    CIN(N,M);
    vi A(N);
    int sum=0;
    rep(i,N){
        cin>>A[i];
        sum+=A[i];
    }
    double cls=(double)sum/(4*M);
    int ans=N;
    rep(i,N){
        if(A[i]<cls)ans--;
    }
    printf(ans>=M?"Yes":"No");

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mx *max_element
#define mn *min_element
#define fo(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define rfo(i,n) for(ll i=n-1;i>=0;i--)
#define rloop(i,a,b) for(ll i=a;i>=b;i--)
#define all(x) x.begin(),x.end()
#define sortall(x) sort(all(x))
#define precision cout<<fixed<<setprecision(10)
#define mem(x,p) memset(x,p,sizeof(x))
#define w(t) ll t;cin>>t;while(t--)
#define kk "\n"
#define setbits(x) __builtin_popcountll(x)
const double pi=3.1415926535897932384626;
//const ll mod = 998244353;
const ll mod=1e9+7;
int main()
{
  IOS
  ll n;
  cin>>n;
  ll a[n];
  fo(i,n)
  cin>>a[i];
  ll ans=1000,q=0,p=-1;
  fo(i,n)
  {
      if(p!=-1)
      {
          if(p<a[i])
          {
              ll g=0;
              for(ll j=i+1;j<n;j++)
              {
                  if(a[j]>a[i])
                  {
                      g=1;
                      break;
                  }
                  else
                  break;
              }
              if(!g){
              ans+=(q*a[i]);
              q=0;
              p=-1;}
              continue;
          }
      }
      ll f=0,s=0;
      for(ll j=i+1;j<n;j++)
      {
          if(a[j]>a[i])
          {
              f=1;
              s=j;
              break;
          }
      }
      if(f)
      {
          ll h=0;
          for(ll u=i+1;u<s;u++)
          {
              if(a[u]<a[i])
              {
                  h=1;
                  //cout<<u<<" ";
                  break;
              }
          }
          if(!h){
              //cout<<i<<" ";
              p=a[i];
          q+=(ans/a[i]);
          ans=ans%a[i];}
          //cout<<ans<<" ";
      }
      else
      {
          if(q>0)
              ans+=(q*a[i]);
              //cout<<ans<<"\n";  
              p=-1;        
          q=0;
      }
  }
  cout<<ans;


  return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<string> s(n);
	rep(i, n) cin >> s[i];

	string ans = "";
	for (char i = 'a'; i <= 'z'; ++i) {
		int k = 100;
		rep(j, n) {
			int a = count(all(s[j]), i);
			k = min(k, a);
		}
		if (k == 100) continue;
		while (k > 0) {
			ans += i;
			k--;
		}
	}

	sort(all(ans));
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long LL;
LL f(LL b, LL n)
{
	if(n<b) return n;
	else return f(b,n/b)+(n%b);
}
LL solve()
{
	LL n, s; cin >> n >> s;
	
	LL b;
	for(b = 2; b*b <= n; b++)
		if(f(b,n)==s)
			return b;
	
	//else, b = first value such that b*b > n
	// b > n/b > floor(n/b), therefore b > q
	
	for(LL q = b; q > 0; q--)
		if(s-q >= 0 && (n-(s-q))%q==0 && (n-(s-q))/q > 1 && f((n-(s-q))/q,n)==s)
			return (n-(s-q))/q;
	
	if(n==s) return n+1;
	return -1;
}
int main()
{
	cout<<solve()<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * Created by zzt on 17-2-18.
 */
public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(reader.readLine());
        String s = reader.readLine();
        char[] ch = s.toCharArray();
        boolean[] isSheep = new boolean[n];
        for (int i = 0; i < 2; i++) {
            isSheep[0] = i == 0;
            for (int j = 0; j < 2; j++) {
                isSheep[1] = j == 0;
                for (int k = 2; k < n; k++) {
                    if (isSheep[k - 1]) {
                        if (ch[k - 1] == 'o')
                            isSheep[k] = isSheep[k - 2];
                        else
                            isSheep[k] = !isSheep[k - 2];
                    } else {
                        if (ch[k - 1] == 'o')
                            isSheep[k] = !isSheep[k - 2];
                        else
                            isSheep[k] = isSheep[k - 2];
                    }
                    if (k == n - 1) {
                        boolean isFirstSheep;
                        boolean isLastSheepByFirst;
                        if (isSheep[k]) {
                            if (ch[k] == 'o')
                                isFirstSheep = isSheep[k - 1];
                            else
                                isFirstSheep = !isSheep[k - 1];
                        } else {
                            if (ch[k] == 'o')
                                isFirstSheep = !isSheep[k - 1];
                            else
                                isFirstSheep = isSheep[k - 1];
                        }
                        if (isSheep[0]) {
                            if (ch[0] == 'o')
                                isLastSheepByFirst = isSheep[1];
                            else
                                isLastSheepByFirst = !isSheep[1];
                        } else {
                            if (ch[0] == 'o')
                                isLastSheepByFirst = !isSheep[1];
                            else
                                isLastSheepByFirst = isSheep[1];
                        }
                        if (isFirstSheep == isSheep[0]&&isLastSheepByFirst==isSheep[k]) {
                            StringBuilder sb = new StringBuilder();
                            for (int l = 0; l < n; l++) {
                                if (isSheep[l])
                                    sb.append("S");
                                else sb.append("W");
                            }
                            System.out.println(sb.toString());
                            return;
                        }
                    }
                }
            }
        }
        System.out.println(-1);
    }
}

Measured memory_bytes: 26960
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;


int main(){
  ll n,k;
  cin >> n >> k;
  double p;
  double ans = 0;
  ll cheak;
  double sum = 0.0;
  for(int i = 1; i <= n; i++){
    p = 1;
    cheak = i;
    while(cheak < k){
      cheak *= 2;
      p *= 0.5;
    }
    sum += p/n;
    // printf("%lld %lf\n", cnt,pow(0.5,cnt));
  }
  // ans = sum;
  printf("%.12f\n", sum);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0 ,-1};
signed main(){
    int A;
    string S;
    cin >> A >> S;
    cout << (A*(S[3]-'0')+A*(S[2]-'0')*10+A*(S[0]-'0')*100)/100 << endl;
}


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


signed main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    cout << fixed << setprecision(33);

    
    ll n,k;
    cin>>n>>k;
    ll a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    vector<ll> v;
    for(int i=0;i<n;i++){
        ll sum = 0;
        for(int j=i;j<n;j++){
            sum += a[j];
            v.push_back(sum);
        }
    }

    ll ans = 0;

    for(ll i=44;i>=0;i--){
        vector<ll> ret;
        for(auto j:v){
            if((j&(1LL<<i))){
                ret.push_back(j);
            }
        }
        if(ret.size()>=k){
            v = ret;
            ans += (1LL<<i);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 6128
#include<bits/stdc++.h>
using namespace std;
const int md = 1e9+7;
int n, x, s[205];
long long memo[205][100005];
bool used[205][100005];
long long solve(int v, int m){
    if(!m) return v % s[m];
    if(used[m][v]) return memo[m][v];
    used[m][v] = true;
    return memo[m][v] = (solve(v%s[m], m-1) + solve(v, m-1) * m) % md;
}
int main(){
    scanf("%d%d", &n, &x);
    for(int i = 0; i < n; i++) scanf("%d", s+i);
    sort(s, s+n);
    printf("%lld\n", solve(x,n-1));
}

Measured memory_bytes: 177408
N,K = map(int,input().split())
td = sorted([list(map(int,input().split())) for _ in range(N)],key = lambda x: (-x[1],x[0]))

head = []
no_head = []
is_used = [False]*(N+1)
for t,d in td[:K]:
    if is_used[t]:
        no_head.append(d)
    else:
        head.append(d)
        is_used[t] = True

unused_head = []
for t,d in td[K:]:
    if not is_used[t]:
        unused_head.append(d)
        is_used[t] = True
        
n = min(len(no_head),len(unused_head))
sum_head = sum(head)
sum_no_head = sum(no_head)
sum_unused_head = 0
l_head = len(head)
l_no_head = len(no_head)
ans = sum_head + sum_no_head + l_head ** 2
for i in range(n):
    sum_no_head -= no_head[-1-i]
    sum_unused_head += unused_head[i]
    ans = max(ans,sum_head+sum_no_head+sum_unused_head + (l_head+i+1)**2)
print(ans)

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;  cin >> n;
    string s;  cin >> s;
    int ans = Inf;
    vector<int> e(n + 1), w(n + 1);
    rep(i, n) {
      if (s[i] == 'W') {
        w[i + 1] = w[i] + 1;
        e[i + 1] = e[i];
      } else {
        w[i + 1] = w[i];
        e[i + 1] = e[i] + 1;
      }
    }
    rep(i, n) {
      ans = min(ans, w[i] + e[n] - e[i + 1]);
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 2964
#include <iostream>
#include <vector>
#include <algorithm>
#include<stdio.h>
using namespace std;
int main()
{
    int x,a,b;
    scanf("%d%d%d",&x,&a,&b);
    if(a >= b)
        printf("delicious");
    else if((b-a) <= x)
        printf("safe");
    else
        printf("dangerous");
    return 0;
}


Measured memory_bytes: 256
n = int(input())
ws = list(map(int, input().split()))
total_weight = sum(ws)
current_total_weight = 0

ret = float('inf')
for i in range(n):
    current_total_weight += ws[i]
    rem = total_weight - current_total_weight
    ret = min(ret, abs(rem - current_total_weight))
print(ret)


Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll x;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>x;
    ll ans = 0;
    ll tmp = 100;
    while(1){
        tmp += tmp/100;
        ans++;
        if(tmp>=x)break;
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  while(n!=0){
    int i;
    double s[1000]={},sum=0,a=0;
    for(i=0;i<n;i++){
      cin>>s[i];
      sum+=s[i];
    }
    for(i=0;i<n;i++){
      a+=(pow((sum/n)-s[i],2)/n);
    }
    printf("%.5f\n",sqrt(a));
    cin>>n;
  }
}


Measured memory_bytes: 3208
from collections import defaultdict

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    MOD = 10 ** 9 + 7
    A2 = A + A
    d2 = defaultdict(int)
    for i in range(2*N):
        for j in range(i,2*N):
            if A2[i] > A2[j]:
                d2[A2[i]] += 1

    d = defaultdict(int)
    for i in range(N):
        for j in range(i,N):
            if A[i] > A[j]:
                d2[A2[i]] -= 1
                d[A[i]] += 1
    ans = 0

    for key,value in d2.items():
        ans += (K * ((2 * d[key] + (K - 1) * (value - d[key])))) // 2
        
    print(int(ans) % MOD)

main()

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

int main(void) {
	char input1[8],input2[8];
	int i,j;
	int hit,blow;
	while(1) {
		scanf("%s%s",input1,input2);
		if(input1[0]=='0' && input1[1]==0 &&
			input2[0]=='0' && input2[1]==0)break;
		hit=blow=0;
		for(i=0;i<4;i++) {
			for(j=0;j<4;j++) {
				if(input1[i]==input2[j]) {
					if(i==j)hit++; else blow++;
				}
			}
		}
		printf("%d %d\n",hit,blow);
	}
	return 0;
}

Measured memory_bytes: 0
import scala.io.StdIn

object Main extends App {
  StdIn.readLine

  val sqr = Iterator.continually(StdIn.readLine)
    .takeWhile(_ != null)
    .filter(_.contains('#'))
    .map(_.toCharArray)
    .toArray
    .transpose
    .filter(_.contains('#'))
    .transpose
    .toArray
    .foreach(ch => println(ch.mkString))
}

Measured memory_bytes: 29332
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define int  long long
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mod 998244353
// order_of_key and *find_by_order
int32_t main() {
	fast;
	int h1, m1, h2, m2, k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	int to = 0;
	if (h1 == h2) {
		to = m2 - m1;
	}
	else {
		to += 60 - m1;
		to += m2;
		to += 60 * (h2 - h1 - 1);
	}
	cout << to - k;






}

Measured memory_bytes: 3636
N = int(input())

ans = 0
ctable = [[-1 for _ in range(10)] for _ in range(10)]

def c(x, y):
    cnt = 0
    strx = str(x)
    stry = str(y)
    for i in range(1, N+1):
        stri = str(i)
        if stri[0] == strx and stri[-1] == stry:
            cnt += 1
    return cnt

for i in range(10):
    for j in range(10):
        ctable[i][j] = c(i, j)

for i in range(10):
    for j in range(10):
        ans += ctable[i][j] * ctable[j][i]

print(ans)


Measured memory_bytes: 41196
import java.util.*;

public class Main {

    /* チェックリスト
     * 結果はintの範囲を超えていませんか？(必要な時以外はlongを使いましょう)
     * TLEしそうな処理はありませんか？
     */
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        String[] ss = sc.nextLine().split(" ");
        int a = Integer.parseInt(ss[0]);
        int b = Integer.parseInt(ss[1]);
        if(b == 1){
            System.out.println(0);
            return;
        }
        for(int i = 1;i < Integer.MAX_VALUE;i++){
            int r = (a - 1) * (i - 1) + a;
            if(r >= b){
                System.out.println(i);
                break;
            }
        }
    }
}

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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  
  int P1 = A * N,
  	  P2 = B;
  if (P1 <= P2) {
    cout << P1 << endl;
  } else {
    cout << P2 << endl;
  }
  
}

Measured memory_bytes: 256
N,M,K=map(int,input().split())
P=998244353
class FactInv:
    def __init__(self,N,P):
        fact=[];ifact=[];fact=[1]*(N+1);ifact=[0]*(N+1)
        for i in range(1,N):
            fact[i+1]=(fact[i]*(i+1))%P
        ifact[-1]=pow(fact[-1],P-2,P)
        for i in range(N,0,-1):
            ifact[i-1]=(ifact[i]*i)%P
        self.fact=fact;self.ifact=ifact;self.P=P
    def comb(self,n,k):
        return (self.fact[n]*self.ifact[k]*self.ifact[n-k])%self.P
FI=FactInv(N+10,P)
ans=0
for k in range(0,K+1):
    ans+=(M*FI.comb(N-1,k)*pow(M-1,N-1-k,P))%P
    ans%=P
print(ans)

Measured memory_bytes: 24608
#include <bits/stdc++.h>
using namespace std;
 
#define FAST ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
 
#define MAXX 100005
 
#define PI   3.14159265358979323846264338327950

#define PB push_back 
#define F first
#define S second
 
#define ll 	 long long int

#define mod  1000000007


map<char, int> m;


int main()
{
	FAST;
	string s;
	cin >> s;
	for(ll i = 0; i < s.size(); i ++){
		m[s[i]] = 1;
	}
	ll x = 0;
	for(char i = 'A' ;i <= 'Z'; i++){
		x += m[i];
	}
	if(x == 2){
		cout << "Yes";
		return 0;
	}
	cout << "No";
	return 0;
}

Measured memory_bytes: 3596
#include <algorithm>
#include <boost/multiprecision/cpp_int.hpp>
#include <cmath>
#include <deque>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;
using mpint = mp::cpp_int;  // 多倍長整数（任意精度）

/*
 * 定数
 */
const long double PI = (acos(-1));
const long double EPS = 1e-10;
const long long INF = 1e18;



int main() {
  ll a, b, c, k;

  cin >> a >> b >> c >> k;

  ll ans = 0;

  for (ll i = 0; i < k; ++i) {
    if (a > 0) {
      ++ans;
      --a;
      continue;
    }
    if (b > 0) {
      --b;
      continue;
    }
    --ans;
  }

  cout << ans << endl;

  return 0;
}


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

int main(){  
	string s;
	cin >> s;
	string text = "";
	for(int i = 0; i < s.size(); i++){
		if(s[i] == 'B'){
			if(text != ""){
				text.pop_back();
			}
		}else{
			text.push_back(s[i]);
		}
	}
	cout << text << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int,input().split()))

A.sort()

mn = min(A)
mx = max(A)
if mx - mn > 1:
    print('No')
    exit()

if mn == mx:
    if N == mn + 1 or N >= 2*mn:
        print('Yes')
    else:
        print('No')
    exit()

nsolo = A.count(mn)
ndup = N - nsolo

if nsolo  > mn:
    print('No')
    exit()

if ndup < 2*(mn - nsolo+1):
    print('No')
    exit()

print('Yes')




Measured memory_bytes: 83968
#include<iostream>
#include<string>

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	string S;
	int K;
	cin >> S >> K;
	K--;
	for (int i = 0; i <= K; i++){
		if (S[i] != '1') {
			cout << S[i] << endl;
			return 0;
		}
	}
	cout << '1' << endl;

	return 0;
}

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

using namespace std;

#define rep(i, x)   for (__typeof(x) i = 0; i < x; i++)
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define all(x)         (x).begin(), (x).end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define repi(i, x)  for (__typeof(x) i = x-1; i >= 0; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
typedef long long      ll;
typedef pair<int, int> ii;
typedef pair<ii, int>  iii;
typedef vector<int>    vi;
typedef vector<ii>     vii;
typedef vector<iii>    viii;
typedef vector<vector<int> > vvi;
const   int            infi = numeric_limits<int>::max();
const   double         eps = 0;
const   int            ms  = 0;

int main()
{
    ios::sync_with_stdio(false);//endl->"\n"
    cin.tie(0);

    int n, k;
    cin >> n >> k;
    vi x(n);
    rep(i, n)cin >> x[i];
    int ans = infi;
    for(int i = 0; i+k-1 < n; i++){
        int a = x[i];
        int b = x[i+k-1];
        if(b <= 0){
            ans = min(ans, abs(a));
        } else if(0 <=a){
            ans = min(ans, b);
        } else {
            ans = min(ans, min(-a, b)+(b-a));
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 640