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

using namespace std;

typedef long long ll;

ll dp[60][60][2600];

int main(){
        int N;
        int A;
        cin>>N>>A;
        vector <int> x(N);
        for(int i=0;i<N;i++){
                cin>>x[i];
        }
        ll res=0;
        for(int i=0;i<=N;i++){
                for(int j=0;j<=N;j++){
                        for(int k=0;k<=2500;k++){
                                dp[i][j][k]=0;
                        }
                }
        }
        dp[0][0][0]=1;
        for(int i=0;i<N;i++){
                for(int j=0;j<N;j++){
                        for(int k=0;k<2500;k++){
                                if(dp[i][j][k]){
                                        dp[i+1][j+1][k+x[i]]+=dp[i][j][k];
                                        dp[i+1][j][k]+=dp[i][j][k];
                                }
                        }
                }
        }
        for(int i=1;i<N+1;i++){
                res+=dp[N][i][i*A];
        }
        cout<<res<<endl;
        return 0;
}


Measured memory_bytes: 63488
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
# from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint
# from statistics import mean,median,mode

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

def MI():
    return map(int,input().split())

def RI():
    return list(map(int,input().split()))

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input().split())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input().split()) for _ in range(n) ]

x,y = MI()

if y%2==1:
    print("No")
else:
    a = 2*x - y//2
    b = y//2 - x
    if a>=0 and b>=0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 74428
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem B

if __name__ == '__main__':
    city_count, road_count = map(int, input().split())
    a = list()
    b = list()

    for _ in range(road_count):
        line = input().split()
        a.append(line[0])
        b.append(line[1])

    for i in range(1, city_count + 1):
        link_count = a.count(str(i)) + b.count(str(i))
        print(link_count)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <unistd.h>
#include <sys/time.h>
#include <stdlib.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> T;
typedef pair<long double , ll> Ps;
typedef pair<ll, bool> Pb;

const ll INF = 1e18;
const ll fact_table = 3200008;
long double Pi = 3.1415926535897932384626;

priority_queue <ll> pql;
priority_queue <P> pqp;
priority_queue <P> bag;
//big priority queue
priority_queue <ll, vector<ll>, greater<ll> > pqls;
priority_queue <P, vector<P>, greater<P> > pqps;
//small priority queue
//top pop

ll dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
ll dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};
char dir[] = "DRUL";
//↓,→,↑,←

/*
#define endl "\n"
#ifdef ENJAPMA
#undef endl
#endif
*/
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)();
#define pc(x) cout << x << ",";
#define rep(i, n) for (ll i = 0; i < (n); i ++)

// const ll mod = 998244353ll;
const ll mod = 1000000007ll;

ll mypow(ll a, ll b, ll mod) {ll x = 1; while (b) {while (!(b & 1)) {(a *= a) %= mod; b >>= 1;}(x *= a) %= mod; b--;} return x;}
void YES(bool cond) { if (cond) { p("YES");} else { p("NO");} return;}
void Yes(bool cond) { if (cond) { p("Yes");} else { p("No");} return;}
void line() { p("--------------------"); return;}

/*
ll fact[fact_table + 5],rfact[fact_table + 5];

void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = mypow(fact[fact_table],mod - 2, mod);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/

bool multicase = false;

ll n, m, k, num, a, b, c, e, h, q, ans, sum;

typedef vector<ll> vec;
typedef vector<vector<ll>> mat;

string s, t;

ll mygcd(ll a, ll b){
    if (a > b) swap(a, b);
    if (a == 0 || a == b) return b;
    return mygcd(b % a, a);
}

void solve() {
    cin >> n;
    ll bunsi = 360, bunbo = n;
    ll gcd = mygcd(bunsi, bunbo);
    bunsi /= gcd, bunbo /= gcd;
    p(bunsi);
    return;
}

int main() {
    // init();
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll q, testcase = 1;
    if (multicase) {
        cin >> q;
    } else {
        q = 1;
    }
    while (q--) {
        // pu("Case ");pu("#");pu(testcase);pu(": ");
        solve();
        testcase++;
    }
    // solve();
    return 0;
}



Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

Int n;
using P = pair<Int, Int>;
vector<P> v;
map<P, Int> mp;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	for(Int i=0; i<n; ++i){
		Int x, y; cin >> x >> y;
		v.push_back(P(x, y));
	}
	for(Int i=0; i<n; ++i)
		for(Int j=0; j<n; ++j){
			if(i == j) continue;
			P p = P(v[j].first-v[i].first, v[j].second-v[i].second);
			if(mp.count(p)) ++mp[p];
			else mp[p] = 1;
		}
	P p = mp.begin()->first;
	for(auto i=mp.begin(); i!=mp.end(); ++i)
		if(mp[p] < i->second)
			p = i->first;
	Int ans = n;
	for(Int i=0; i<n; ++i)
		for(Int j=0; j<n; ++j)
			if(P(v[j].first-v[i].first, v[j].second-v[i].second) == p)
				--ans;
	cout << ans << "\n";
}

Measured memory_bytes: 384
import sys
readline = sys.stdin.readline
 
 
def st(line):
    tmp = ''
    for l in line:
        if l == '\n':
            yield tmp
        elif l == ' ':
            yield tmp
            tmp = ''
        else:
            tmp += l



N = int(input())
As = st(readline())

d = dict()
total = 0
for a in As:
    a = int(a)

    if a in d:
        d[a] += 1
    else:
        d[a] = 1
    total += a

Q = int(input())
queries = (map(int, readline().strip().split()) for _ in range(Q))

for que in queries:
    b, c = que

    if b not in d:
        print(total)
        continue

    n_b = d[b]
    d[b] = 0

    if c not in d:
        d[c] = 0

    d[c] += n_b
    total += (c - b) * n_b

    print(total)



Measured memory_bytes: 15040
N, M = gets.split.map(&:to_i)
lr_list = M.times.map { gets.split.map(&:to_i) }
l = -1
r = N + 1
lr_list.each do |(l2, r2)|
  l = [l, l2].max
  r = [r, r2].min
end
ans = [r - l + 1, 0].max
puts ans


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

string mySubstr(int from, int to, string &s) {
  string new_s="";
  for(int i = from; i < to; i++) new_s+= s[i];
  return new_s;
}

int main() {
  string s, anw = "";
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'B') {
      if (anw.size() <= 1) anw = "";
      else anw = mySubstr(0, anw.size()-1, anw);

    } else{ anw+= s[i]; }
  }
  cout << anw << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] x = new int[n];
		int[] y = new int[n];
		for(int i = 0; i < n; i++){
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
		}
		double sum = 0;
		for(int i = 0; i < n; i++){
			for(int k = i + 1; k < n; k++){
				sum += Math.sqrt((x[i] - x[k]) * (x[i] - x[k]) + (y[i] - y[k]) * (y[i] - y[k]));
			}
		}
		// avg * (n - 1)
		System.out.println(sum / n * 2);
	}
}


Measured memory_bytes: 22996
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int A, B, T;
			A = sc.nextInt();
			B = sc.nextInt();
			T = sc.nextInt();
			
			int sum = 0;
			
			for (int time = 1; time <= T; time++) {
				if (time % A == 0) {
					sum += B;
				}
			}
			System.out.println(sum);
			
		} catch (Exception e) {
			// TODO: handle exception
		}
	}

}

Measured memory_bytes: 20052
from itertools import accumulate


def LS():
    return list(input().split())


N = int(input())
title = []
time = []
for _ in range(N):
    s, t = LS()
    time.append(int(t))
    title.append(s)
time.append(0)
Tsum = list(accumulate(time))
X = input()
for i in range(N):
    if title[i] == X:
        break
print(Tsum[N]-Tsum[i])

Measured memory_bytes: 8956
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a, b;
	cin >> a >> b;
	if ( a + b == 15) cout << "+" << endl;
	if ( a * b == 15) cout << "*" << endl;
	if ( a + b != 15 and a * b != 15) cout << "x" << endl;
 	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << max(a*b, c*d) << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

    public static void main(String[] args) throws Exception {

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }

        String s = mylist.get(0);

        char c = s.charAt(0);
        int num = (int) c + 1;
        System.out.println((char) num);

    }

}

Measured memory_bytes: 21204
import java.util.Scanner;

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

    int S, h, m, s;

    S = sc.nextInt();

    h = S/3600;

    S -= h*3600;

    m=S/60;

    S-= m*60;

    s = S;


    System.out.println( h + ":" + m + ":" + s );
    } 
}


Measured memory_bytes: 26340
from collections import Counter


def main():
    n = int(input())
    S = [input() for _ in range(n)]
    S_c = Counter(S)
    num = list(S_c.values()).count(max(list(S_c.values())))
    anss = S_c.most_common()[:num]
    for ans in sorted(anss):
        print(ans[0])


if __name__ == '__main__':
    main()


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
map<int,int> M;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	vector<int> V;
	FOR(i,N) {
		cin>>x, M[x]++;
		if(M[x]==2) {
			V.push_back(x);
			M[x]=0;
		}
	}
	V.push_back(0);
	V.push_back(0);
	sort(ALL(V));
	reverse(ALL(V));
	
	cout<<(ll)V[0]*V[1]<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 4992
#include<iostream>

using namespace std;

long long GCD(long long a,long long b);
int main(){
    long long a,b;
    cin>>a>>b;
    cout<<GCD(a,b)<<endl;
}
long long GCD(long long a,long long b){
    while(b!=0){
        long long r=a%b;
        a=b;
        b=r;
    }
    return(a);
}



Measured memory_bytes: 3088
import sys
input=sys.stdin.readline

def runLength(s):
    a = []
    for c in s:
        if len(a)==0 or a[-1][0]!=c:
            a.append([c,1])
        else:
            a[-1][1] += 1
    return a

def main():
    N,K = map(int, input().split())
    S = input().strip()
    ans = 0
    for i,c in enumerate(S):
        if c == "L":
            if i > 0 and S[i-1] == "L":
                ans += 1
        if c == "R":
            if i < N-1 and S[i+1] == "R":
                ans += 1
    A = runLength(S)
    A.sort(key=lambda x:x[1], reverse=True)
    for i in range(K):
        if i < len(A):
            ans += 2
            if ans >= N:
                break
    if ans >= N:
        ans = N-1
    print(ans)

if __name__ == '__main__':
    main()

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

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

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

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

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

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      n: usize,
      ss: [chars; n],
    }

    let mut ans = 0usize;
    let mut t = vec![vec!['a'; n]; n];
    for b in 0..n {
        for i in 0..n {
            for j in 0..n {
                t[i][(j+b)%n] = ss[i][j];
            }
        }

        let mut ok = true;
        for i in 0..n {
            for j in 0..n {
                if t[i][j] != t[j][i] {
                    ok = false;
                }
            }
        }
        if ok {
            ans += n;
        }
    }
    puts!("{}\n", ans);
}


Measured memory_bytes: 4476
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX - 100
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define lowb lower_bound
#define upb upper_bound
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



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

	int n, m;
	cin >> n >> m;
	cout << mod(n, m) << endl;
	return 0;
}

Measured memory_bytes: 256
l, r = map(int, input().split())

MOD = 2019
r = min(r, l + MOD - 1)

res = MOD - 1
for i in range(l, r):
    for j in range(i + 1, r + 1):
        res = min(res, (i % MOD) * (j % MOD) % MOD)
print(res)



Measured memory_bytes: 2940
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};
use std::collections::HashSet;


fn main() {
  let n = read::<i64>();
  let mut not_ten = vec![];
  let mut ans = 0;

  for _ in 0..n {
    let s = read::<i64>();
    if s % 10 != 0 {
      not_ten.push(s)
    }
    ans += s;
  }
  not_ten.sort();

  if not_ten.len() == 0 {
    println!("{}", 0);
  } else {
    if ans % 10 == 0 {
      println!("{}", ans - not_ten[0]);
    } else {
      println!("{}", ans);
    }

  }
}


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

int qtd[11];

bool check(string s)
{
	for(int i = 0; i < s.size(); i++)
		if( qtd[s[i] - '0'] )
			return false;
	
	return true;
}

int main()
{
	int n, k, a;
	cin >> n >> k;
	
	for(int i = 0; i < k; i++)
		cin >> a, qtd[a]++;
	
	for(int i = n; ; i++)
		if(check(to_string(i)))
			return cout << i << '\n', 0;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m;
int main(){
	scanf("%d%d",&n,&m);
	for(int i=m/n;i>=0;i--)
		if(!(m%i)&&(m/i>=n)){
			printf("%d\n",i);
			return 0;
		}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define REP(i,a) for (ll i = 0;i < (a);++i)
#define FOR(i,a,b) for (ll i = (a);i < (b); ++i)
#define FORR(i,a,b) for (ll i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;

int main(){
    ll n;
    cin >> n;
    vector<ll>index(12);
    index[0]=26;
    FOR(i,1,12){
        ll tmp = 1;
        REP(j,i+1)tmp*=26;
        index[i] = index[i-1]+tmp;
    }
    ll offset = lower_bound(ALL(index),n)-index.begin()+1;
    vector<char>answer(offset);
    FORR(i,offset-1,0){
        n--;
        answer[i]='a'+n%26;
        n/=26;
    }
    REP(i,offset)cout << answer[i];
    cout << endl;
    return 0;
}

Measured memory_bytes: 3612
n = int(input())
ab = [list(map(int,input().split())) for i in range(n)]

ab.sort(key= lambda x:x[1])
time = 0

for i in range(n):
    time += ab[i][0]
    if time > ab[i][1]:
        ans = "No"
        break
else:
    ans = "Yes"

print(ans)

Measured memory_bytes: 53600
#include <iostream>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <random>
#include <ctime>
#include <bitset>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define ld long double
#define ull unsigned long long
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fast_io cout.tie(0), cin.tie(0), ios_base::sync_with_stdio(0)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ld eps = (ld)1 / 1e10;
ll inf = 1e18, mod2 = 998244353, mod1 = 1e9 + 7;
ll sqr(ll a) { return a * a; }
ll qb(ll a) { return a * a * a; }
ll gcd(ll a, ll b) { return !a ? b : gcd(b % a, a); }
ll binpow(ll a, ll b, ll mod) { return b ? (b % 2 ? (a * (sqr(binpow(a, b / 2, mod)) % mod)) % mod : sqr(binpow(a, b / 2, mod)) % mod) : 1; }
ll binmult(ll a, ll b, ll mod) { return b ? (b % 2 ? (2 * binmult(a, b / 2, mod) + a) % mod : (2 * binmult(a, b / 2, mod)) % mod) : 0; }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main()
{
    fast_io;
    ld n, k;
    cin >> n;
    k = n / 3;
    cout << fixed << setprecision(10) << k * k * k;
    return 0;
}

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

   int A=sc.nextInt();
   int B=sc.nextInt();
   int C=sc.nextInt();
   int X=sc.nextInt();
   int count=0;
           int Cn= X/50;
           int Bn= X/100;
           int An= X/500;
           if(An>A)
               An=A;
           if(Bn>B)
               Bn=B;
           if(Cn>C)
               Cn=C;
    for(int i=0;i<=An;i++)
   {
        for (int j=0; j<=(X-(500*i))/100;j++)
        {
            if(j<=Bn){
            if((X-(500*i)-(100*j))<=(Cn*50))
                count++;
            else
                continue;
            }
        }


   }

           System.out.println(count);


   sc.close();
 }
}


Measured memory_bytes: 21844
n,q = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(n-1)]
e = [list() for _ in range(n)]
for a,b in ab:
    e[a-1] += [b-1]
    e[b-1] += [a-1]
px = [list(map(int,input().split())) for _ in range(q)]
omomi = [0]*n
for p,x in px:
    omomi[p-1] += x

visited = [0]*n
visited[0] = 1
stack = [0]

while stack:
    v = stack.pop()
    for k in e[v]:
        if visited[k]==0:
            omomi[k] += omomi[v]
            visited[k] = 1
            stack.append(k)

print(*omomi)

Measured memory_bytes: 126820
/*
   AUTHOR :- Gaurang_Kothiya
   
   Quote:-" Great things never come from comfort zones."                                                                                                                
*/
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>  
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
#include <bitset>
#include <cstdint>
#include <initializer_list>
 
using namespace std;
using namespace __gnu_pbds;  

typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> data_set; 
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long  
#define ld long double
#define f(i,x,n) for(ll i=x;i<=n;i++)
#define fe(x,v)   for(auto &x :v)
#define nf(i,x,n) for(ll i=n;i>=x;i--)
#define all(a)   a.begin(),a.end()
#define rall(a)  a.rbegin(),a.rend()
#define b_s(a,b)   binary_search( all(a),b)
#define lb(v,n)  lower_bound(all(v) ,n )
#define ub(v,n)  upper_bound( all(v) , n)
#define gcd(a,b) __gcd(a,b)
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define RE rend()
#define RB rbegin()
#define B begin()
#define E end()
#define acc(v, x) accumulate(all(v), x)
#define p(a,b) pair<a,b>
#define F first
#define S second
#define sz size()
#define v(x) vector<x>
#define m(a,b) map<a,b>
#define u_m(a,b) unordered_map<a,b>
#define mm(a,b) multimap<a,b>
#define s(a) set<a>
#define us(a) unordered_set<a>
#define ms(a) multiset<a>
#define maxy __LONG_LONG_MAX__
#define miny INT_MIN
#define PI 3.14159265358979323846
#define MOD 1000000007

void Solve()
{
	ll n;
	cin>>n;
	
	ll ans=0,tmp=100;
	while(true)
	{
		if(tmp>=n)break;
		
		tmp= tmp+ tmp/100;
		ans++;
		
	}
	cout<<ans;
}


signed main() 
{
	speed		
	
	int q=1;
	//cin>>q;
	
	while(q--)
	Solve();
	
	//cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
	return 0;
}

 
 

Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

//#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

#include<iostream>
#include<vector>
#include<queue>

using namespace std;

typedef struct Edge {
	int Cost;
	int To;
	Edge(int t,int c){
		Cost = c;
		To = t;
	}
	bool const operator<(Edge e) const {
		return Cost < e.Cost;
	}
}Edge;


class Dijkstra
{
public:
	Dijkstra(int n,bool dir);
	int I;
	int V;
	int E;
	vector<int> Cost;
	void AddPath(int f, int t, int c);
	bool PathExist(int t);
	void Run(int f);
private:
	bool isNonDir = true;
	int INF = 100000000;
	vector<vector<Edge>> Adj;
};

Dijkstra::Dijkstra(int n,bool dir)
{
	isNonDir = dir;
	I = n + 1;
	V = n;
	Adj.resize(I);

}


void Dijkstra::AddPath(int f, int t, int c)
{
	E++;
	Adj[f].push_back(Edge(t, c));
	if (isNonDir) Adj[t].push_back(Edge(f, c));
}

bool Dijkstra::PathExist(int t)
{
	return Cost[t] != INF;
}

void Dijkstra::Run(int f)
{
	//プライオリティキュー
	priority_queue<Edge> pq;
	//コストをしまう配列
	Cost.resize(I);
	for (int i = 0; i < I; i++)
	{
		Cost[i] = INF;
	}
	//スタート地点からスタート地点への距離は0
	Cost[f] = 0;
	//初期位置をエンキュー
	pq.push(Edge(f, 0L));

	//キューが空になるまで
	while (!pq.empty())
	{
		//先頭を取り出す
		auto cur = pq.top();
		pq.pop();

		//取り出したやつのコストがすでに決まってるやつより大きかったらバイバイ
		if (Cost[cur.To] < cur.Cost) continue;
		//隣接リストを探索
		for (int i = 0; i < (int)Adj[cur.To].size(); i++)
		{
			auto tmp = Adj[cur.To][i];
			//取り出した値を
			if (Cost[tmp.To] > cur.Cost + tmp.Cost) {
				Cost[tmp.To] = cur.Cost + tmp.Cost;
				pq.push(Edge(tmp.To, Cost[tmp.To]));
			}
		}
        }
}


void solve(int w,int h){
  int x;
  Dijkstra dij(w * h,true);
  rep(i,h*2-1){
    if(i%2==0){
      rep(j,w-1){
	cin>>x;
	if(x==0)dij.AddPath(i/2*w+j,i/2*w+j+1,1);
      }
    }else{
      rep(j,w){
	cin>>x;
	if(x==0)dij.AddPath(i/2*w+j,(i/2+1)*w+j,1);
      }
    }
  }

  dij.Run(0);
  /*
  rep(i,h){
    rep(j,w){
      cout<<dij.Cost[i*w+j]<<" ";
    }
    cout<<endl;
  }
  */
  if(dij.Cost[h*w-1]!=100000000)cout<<dij.Cost[h*w-1]+1<<endl;
  else cout<<0<<endl;
}

int main(){
  int h,w;
  while(cin>>w>>h){
    if(h==0&&w==0)break;
    solve(w,h);
  }
  return 0;
}



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

ans = 0
ab = 0
tail_a = 0
head_b = 0

for _ in range(N):
    s = input()
    ans += s.count('AB')

    if s[-1] == 'A' and s[0] == 'B':
        ab += 1
    elif s[-1] == 'A' and s[0] != 'B':
        tail_a += 1
    elif s[-1] != 'A' and s[0] == 'B':
        head_b += 1

if ab == 0:
    print(ans+min(tail_a, head_b))
elif ab > 0 and max(tail_a, head_b) > 0:
    print(ans+ab+min(tail_a, head_b))
elif max(tail_a, head_b) == 0:
    print(ans+ab-1)


Measured memory_bytes: 9180
x,y,a,b,c=map(int,input().split())
p=sorted(list(map(int,input().split())))[a-x:]
q=sorted(list(map(int,input().split())))[b-y:]
r=sorted(list(map(int,input().split())))
ans=sum(sorted(p+q+r)[c:])
print(ans)

Measured memory_bytes: 22504
#include <bits/stdc++.h>
#define MAXN 100100
#define DIM 51
#define pii pair<int, int>
#define pb push_back
typedef long long ll;

using namespace std;

ll mod = 1e9 + 7;
struct matrix{
	ll a[DIM][DIM];
	matrix(){
		for(int i = 0; i < DIM; i++){
			for(int j = 0; j < DIM; j++){
				a[i][j] = 0;
			}
		}
	}

	matrix operator*(matrix b){
		matrix c;
		for(int k = 0; k < DIM; k++) { 
			for(int i = 0; i < DIM; i++) {
				for(int j = 0; j < DIM; j++) {
					c.a[i][j] = (c.a[i][j] + a[i][k] * b.a[k][j]) % mod;
				}
			}
		}
		return c;
	}
	vector<ll> times(vector<ll> v){
		vector<ll> c(DIM, 0);
		for(int i = 0; i < DIM; i++){
			for(int j = 0; j < DIM; j++){
				c[i] += v[j] * a[i][j];
				//cout << v[j] << " ";
				c[i] %= mod;
			}
		}
		return c;
	}


};

matrix pow_matrix(matrix a, ll n) {
	//cout << n << " ";
	if (n == 1) return a;
	matrix b = pow_matrix(a, n / 2);
	b = b * b;
	if (n & 1) b = b * a;
	return b;
}

int n;
ll k;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    cin >> n >> k;
    matrix m;
    for(int i = 0; i < n; i++){
    	for(int j = 0; j < n; j++){
    		cin >> m.a[i][j];
    	}
    }

    vector<ll> base(DIM, 1), v;
    m = pow_matrix(m, k);
    v = m.times(base);
    ll ans = 0;
    for(auto i : v){
    	ans += i;
    	ans %= mod;
    }
    cout << ans;
}

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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;
using namespace std;

signed main() {
  ll N, M;
  cin >> N >> M;
  map<PLL, vector<PLL>> edges; // 頂点(i, l) から別の頂点へのエッジ
  for (int i=0; i<M; i++) {
    ll u, v;
    cin >> u >> v;
    edges[make_pair(u, 0)].push_back(make_pair(v, 1));
    edges[make_pair(u, 1)].push_back(make_pair(v, 2));
    edges[make_pair(u, 2)].push_back(make_pair(v, 0));
  }
  ll s, t;
  cin >> s >> t;
  map<PLL, ll> dist;
  priority_queue<pair<ll, PLL>, vector<pair<ll, PLL>>, greater<pair<ll,PLL>>> q;
  q.push(make_pair(0, make_pair(s, 0)));
  while (!q.empty()) {
    ll d;
    PLL v;
    tie(d, v) = q.top();
    q.pop();
    if (dist.find(v) != dist.end() && dist[v] <= d) {
      continue;
    }
    dist[v] = d;
    for (auto e: edges[v]) {
      q.push(make_pair(d+1, e));
    }
  }
  if (dist.find(make_pair(t, 0)) != dist.end())
    cout<<dist[make_pair(t, 0)]/3<<endl;
  else
    cout<<-1<<endl;
  return 0;
}


Measured memory_bytes: 51840
#include <bits/stdc++.h>
 
using namespace std;
 
const long long mod = 1e9 + 7ll ;
const int MAX = 100010 , N = 110 ;
long long dp[MAX][N] , dp2[MAX][N] ;
 
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n , k ;
    cin>>n>>k ;
    long long arr[n+1] ;
    for(int i = 1 ; i <= n ; ++i)
        cin>>arr[i] ;
    for(int i = 0 ; i <= k ; ++i)
    {
        for(int j = 1 ; j <= n ; ++j)
        {
            if(j == 1)
            {
                if(i <= arr[j])
                    dp[i][j] = 1ll ;
            }
            else if(i - arr[j] <= 0)
                dp[i][j] = dp2[i][j-1] % mod;
            else
                dp[i][j] = (dp2[i][j-1] - dp2[i-arr[j]-1][ j-1] + mod) % mod ;
            if(i == 0)
                dp2[i][j] = 1ll ;
            else
                dp2[i][j] = (dp[i][j] + dp2[i-1][j]) % mod ;
        }
    }
    return cout<<dp[k][n]<<"\n" , 0 ;
}

Measured memory_bytes: 175520
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n - 1):
    if a[i] == i + 1:
        a[i], a[i + 1] = a[i + 1], a[i]
        ans += 1
        
if a[n - 1] == n:
    ans += 1
print(ans)

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

int main() {
  int n,m;
  cin>>n>>m;
  tuple<int,int,int> py[100005];
  for (int i=0; i<m; i++) {
    int p,y;
    cin>>p>>y;
    py[i]=make_tuple(p,y,i);
  }

  sort(py,py+m);
  P ans[100005];
  int p=0,r;
  for (int i=0; i<m; i++) {
    if (get<0>(py[i])!=p) {
      p=get<0>(py[i]);
      r=1;
    }
    else r++;
    ans[get<2>(py[i])]=make_pair(p,r);
  }

  for (int i=0; i<m; i++) {
    printf("%06d%06d\n",ans[i].first,ans[i].second);
  }
  return 0;
}

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

class hist{
public:
	int s,e;
	hist(int s,int e):s(s),e(e){};
};

bool operator < (hist a,hist b){
	if(a.s!=b.s) return a.s<b.s;
	return a.e<b.e;
}

int main()
{
	int N,M;
	while(cin>>N>>M && N!=0){
		vector<int> PC(N+1,-1);
		vector<vector<hist> > Stu(M+1);
		int r;
		cin>>r;
		for(int i=0;i<r;i++){
			int t,n,m,s;
			cin>>t>>n>>m>>s;
			if(s==0)
				Stu[m].push_back(hist(PC[n],t));
			else{
				PC[n]=t;
			}
		}
		int q;
		cin>>q;
		for(int i=0;i<q;i++){
			int s,e,m;
			cin>>s>>e>>m;
			sort(Stu[m].begin(),Stu[m].end());
			int ans=0;
			int time=s;
			for(int k=0;k<Stu[m].size();k++){
				if(min(Stu[m][k].e,e)-max(time,Stu[m][k].s)<0) continue;
				ans+=min(Stu[m][k].e,e)-max(time,Stu[m][k].s);
				time=min(Stu[m][k].e,e);
			}
			cout<<ans<<endl;
		}
	}
}

Measured memory_bytes: 0
import std.stdio, std.conv, std.string;
import std.algorithm, std.array, std.container;
import std.numeric, std.math;
import core.bitop;

T RD(T = string)() { static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T)(in string str) { return str.split.to!(T[]); }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

long mod = pow(10, 9) + 7;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

struct UnionFind
{
	void init(long n) { par = new long[](n); foreach (i; 0..n) par[i] = i; }
	long root(long i) { return par[i] == i ? i : (par[i] = root(par[i])); }
	bool same(long i, long j) { return root(i) == root(j); }
	void unite(long i, long j) { i = root(i); j = root(j); if (i == j) return; par[i] = j; }
	long[] par;
}

void main()
{
	auto cnt = new long[](4);
	foreach (i; 0..3)
	{
		auto a = RD!long - 1;
		auto b = RD!long - 1;
		++cnt[a];
		++cnt[b];
	}
	long cnt1, cnt2;
	foreach (e; cnt)
	{
		if (e == 1) ++cnt1;
		else if (e == 2) ++cnt2;
	}

	writeln(cnt1 == 2 && cnt2 == 2 ? "YES" : "NO");
	stdout.flush();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, M, K;
  cin >> N >> M >> K;
  vector<int> A(M), B(M), C(K), D(K);
  for (int i = 0; i < M; i++){
    cin >> A[i] >> B[i];
    A[i]--;
    B[i]--;
  }
  for (int i = 0; i < K; i++){
    cin >> C[i] >> D[i];
    C[i]--;
    D[i]--;
  }
  //友達関係を辺として考える
  vector<set<int>> F(N);
  for (int i = 0; i < M; i++){
    F[A[i]].insert(B[i]);
    F[B[i]].insert(A[i]);
  }
  vector<set<int>> b(N);
  for (int i = 0; i < K; i++){
    b[C[i]].insert(D[i]);
    b[D[i]].insert(C[i]);
  }
  vector<int> a(N, -1); //連結成分
  set<int> S;
  for (int i = 0; i < N; i++){
    S.insert(i);
  }
  queue<int> Q;
  int count = 0;
  while (!S.empty()){
    Q.push(*S.begin());
    a[Q.front()] = count;
    while (!Q.empty()){
      int i = Q.front();
      S.erase(i);
      for (auto j : F[i]){
        if (a[j] == -1){
          a[j] = count;
          S.erase(j);
          Q.push(j);
        }
      }
      Q.pop();
    }
    count++;
  }
  vector<set<int>> P(count);
  for (int i = 0; i < N; i++){
    P[a[i]].insert(i);
  }
  int Fc;
  for (int i = 0; i < N; i++){
    Fc = P[a[i]].size() - F[i].size() - 1;
    for (auto j : b[i]){
      if (a[i] == a[j]){
        Fc--;
      }
    }
    cout << Fc << ' ';
  }
}

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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))
#define X first
#define Y second

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vl = vector<ll>;
using vs = vector<string>;

constexpr int MOD = int(1e9 + 7);
constexpr int INF = int(1e9 + 1);
constexpr ll LLINF = ll(4 * 1e18 + 1);
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(10);
	int n, t;
	cin >> n >> t;
	vector<pii> a(n);
	for(int i = 0; i < n; ++i){
		cin >> a[i].first >> a[i].second;
	}
	sort(begin(a), end(a));
	for(int i = 0; i < n; ++i){
		if(a[i].second <= t){
			cout << a[i].first << "\n";
			return 0;
		}
	}
	cout << "TLE\n";
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>

const int N=3000;

int g1[N][N],g2[N][N],g3[N][N];
char c[N][N];
int i,j,m,n,q,t1,t2,t3,x1,x2,y1,y2;

int main()
{
	scanf("%d%d%d",&n,&m,&q);
	for (i=1;i<=n;i++)
		scanf("%s",c[i]+1);
	for (i=1;i<=n;i++)
		for (j=1;j<=m;j++)
		{
			if (c[i][j]=='1')
				g1[i][j]=1;
			if ((c[i][j]=='1') && (c[i+1][j]=='1'))
				g2[i][j]=1;
			if ((c[i][j]=='1') && (c[i][j+1]=='1'))
				g3[i][j]=1;
		}
	for (i=1;i<=n;i++)
		for (j=1;j<=m;j++)
		{
			g1[i][j]=g1[i-1][j]+g1[i][j-1]-g1[i-1][j-1]+g1[i][j];
			g2[i][j]=g2[i-1][j]+g2[i][j-1]-g2[i-1][j-1]+g2[i][j];
			g3[i][j]=g3[i-1][j]+g3[i][j-1]-g3[i-1][j-1]+g3[i][j];
		}
	for (i=1;i<=q;i++)
	{
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		t1=g1[x2][y2]-g1[x1-1][y2]-g1[x2][y1-1]+g1[x1-1][y1-1];
		t2=g2[x2-1][y2]-g2[x1-1][y2]-g2[x2-1][y1-1]+g2[x1-1][y1-1];
		t3=g3[x2][y2-1]-g3[x1-1][y2-1]-g3[x2][y1-1]+g3[x1-1][y1-1];
		printf("%d\n",t1-t2-t3);
	}
	return 0;
}

Measured memory_bytes: 83584
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

int a, b = 0, n, k;
string s, t;
//cout<<<<endl;


int main()
{
	cin >> a>>b;
	int x = a; int count = 1;
	if (b == 1)
	{
		cout << 0 << endl; return 0;
	}
	while(x<b)
	{
		x += a - 1;
		count++;
	}
	
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 256
n, k, c = map(int, input().split())
s = input()

l = [""] * n
r = [""] * n
x = 1
y = 0
for i in range(n):
    y -= 1
    if s[i] == "o" and y < 0:
        l[i] = x
        x += 1
        y = c
    if x > k:
        x -= 1
        break

y = 0
for i in range(n)[::-1]:
    y -= 1
    if s[i] == "o" and y < 0:
        r[i] = x
        x -= 1
        y = c
    if x <= 0:
        break

for i in range(n):
    if l[i] and l[i] == r[i]:
        print(i+1)

Measured memory_bytes: 73024
#include<cstdio>
#include<iostream>
#include<cstring>
#define RG register
using namespace std;
const int N=1e5+10;
int n,m,q,num[N],cnt,sum[N],pos[N],a[N];
bool vis[N];
template<typename I> inline void read(I &ot){
	I ch=getchar(), x=0, f=1;
	while(ch<'0' || ch>'9'){if(ch=='-') f=-1; ch=getchar();	}
	while(ch>='0' && ch<='9'){x=x*10+ch-'0'; ch=getchar();	}
	ot=x*f;}
template<typename I, typename... U> inline void read(I &x,U&... y){read(x); read(y...);}
template<typename I>inline I mi(const I &a,const I &b){return a<b ? a : b;}
int main()
{
	//freopen("LRU Puzzle.in","r",stdin);
	read(n,m,q);
	for(RG int i=1;i<=q;i++) read(a[i]);
	for(RG int i=q;i;i--)
	 if(!vis[a[i]])
	 {
		num[++cnt]=a[i];
		pos[a[i]]=cnt;
		vis[a[i]]=1;
	 }
	for(RG int i=1, cnt2=0;i<=m;i++) if(!vis[i]) num[cnt+(++cnt2)]=i;
	sum[0]=n;
	for(RG int i=q;i;i--)
	{
		int tt=pos[a[i]];
		if(sum[tt-1])
		{
			sum[tt-1]--;
			sum[tt]++;
		}
	}
	int st=n;
	for(RG int i=0;i<=cnt && st==n;i++) if(sum[i]) st=i;
	for(RG int i=st+2;i<=mi(m,cnt+1);i++)
	 if(num[i]<num[i-1])
	 {
		printf("No\n");
		return 0;
	 }
	printf("Yes\n");
	return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)

#define ALL(v) v.begin(), v.end()

bool IsPrime(int64_t num){
  if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く
  double sqrtNum = sqrt(num);
  for (int i = 3; i <= sqrtNum; i += 2){
    if (num % i == 0) return false;
  }
  return true;
}


int main() {
  int64_t X;
  cin >> X;
  while(!IsPrime(X)){
    X++;
  }
  cout << X << endl;
  

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define VPII vector<pair<int,int> >
#define F first
#define S second
#define RF(x) freopen(x,"r",stdin)
#define WF(x) freopen(x,"w",stdout)
typedef long long LL;
using namespace std;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
typedef pair<double,double> PDD;
const LL MOD = 1e9+7;
const int SIZE = 1e6+5;
const LL INF = 1<<30;
const double eps = 1e-13;

int main(){
	LL n,a,b;scanf("%lld%lld%lld",&n,&a,&b);
	if(b<a){printf("0");return 0;}
	if(n==1){
		printf("%d",a==b);return 0;
	}
	printf("%lld",(n-1)*b+a-((n-1)*a+b)+1);
}


Measured memory_bytes: 256
import math

lst = []
min_1 = "129"
for i in range(5):
    s = input()
    lst.append(s)
    if s[-1] != "0" and s[-1] <= min_1[-1]:
        min_1 = s
if min_1 == "129": min_1 = lst[0]        
lst.remove(min_1)
a = list(map(lambda x:math.ceil(int(x)/10)*10,lst))
print(sum(a) + int(min_1))

Measured memory_bytes: 62188
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <deque>
#include <cmath>

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
ll n;
cin>>n;
int cnt=0;
int same=0;
reps(a,sqrt(n),1){
    reps(b,n,a){
        if(a*b<n){
            if(a==b)cnt++;
            else cnt+=2;
        }
    }
}
cout<<cnt<<endl;
return 0;
}

Measured memory_bytes: 3688
#![allow(unused_imports)]
#![allow(non_snake_case)]

use procon::*;
use std::cmp::{max, min};
use std::collections::*;
use std::ops::*;
use std::*;

pub fn main() {
    let N = read_line().parse::<usize>().unwrap();
    let mut T = Vec::new();
    let mut A = Vec::new();

    for _ in 0..N {
        let words = read_words::<i64>();
        T.push(words[0]);
        A.push(words[1]);
    }

    let mut cur = (T[0], A[0]);
    for i in 1..N {
        let (t, a) = cur;

        // cur' = (k T[i], k A[i])

        // min k s.t.
        // k T[i] >= t
        // k A[i] >= a

        let k = max((t + T[i] - 1) / T[i], (a + A[i] - 1) / A[i]);

        cur = (k * T[i], k * A[i]);
    }

    println!("{}", cur.0 + cur.1);
    return;
}

pub mod procon {
    use std;
    use std::collections::*;
    use std::io;
    use std::mem;
    use std::str::FromStr;

    pub fn read_line() -> String {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        buf.trim_right().to_owned()
    }

    pub fn read_words<T>() -> Vec<T>
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        buf.split_whitespace()
            .map(|word| T::from_str(word).unwrap())
            .collect()
    }

    pub fn read_vec(len: usize) -> Vec<String> {
        let mut vec = Vec::new();
        while vec.len() < len {
            let line = read_line();
            for word in line.split_whitespace() {
                vec.push(word.to_owned());
            }
        }
        assert!(vec.len() == len);
        vec
    }
}


Measured memory_bytes: 4352
using System;
class latte
{
    static int gcd(int a, int b)
    {
        if (b == 0) return a;
        return gcd(b, a % b);
    }
    static int lcm(int a, int b)
    {
        return a / gcd(a, b) * b;
    }
    static void Main()
    {
        while (true)
        {
            string s = Console.ReadLine();
            if (s == null) break;
            string[] t = s.Split();
            int a = int.Parse(t[0]);
            int b = int.Parse(t[1]);
            Console.WriteLine(gcd(a, b) + " " + lcm(a, b));
        }
    }
}



Measured memory_bytes: 15908
// @author: Amirul Islam

#include <bits/stdc++.h>
using namespace std;
#define LLI long long int
#define PII pair <int, int>
#define MP make_pair
#define PB push_back

const int le = 1e6+5;
const LLI INF = 1e15;

int main() {
    // freopen("in", "r", stdin);
    int n, x, sum = 0;
    string s[1000], z;
    int a[10000];
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s[i] >> a[i];
        sum += a[i];
    }
    cin >> z;
    for (int i = 0; i < n; i++) {
        sum -= a[i];
        if (s[i] == z) break;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1001001001;
const int MOD = 1000000007;
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 (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

int main() {
    ll MAX; cin >> MAX;
    vector<ll> cnt(MAX+2);
    cnt[1] = 1;
    for(int i=2; i<=MAX; i++) cnt[i] = 2;
    for(int i=2; i<=MAX/2; i++)
    for(int j=2*i; j<=MAX; j+=i) cnt[j]++;
    debug(cnt);
    ll ans = 0ll;
    rep(i, MAX+1) ans += i*cnt[i];
    cout << ans << endl;
}

Measured memory_bytes: 81376