akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<(n);i++)
typedef long long ll;


int main() {
    int x; cin >> x;
    int ans=0;
    rep(i,50){
        rep2(j,9){
            int k=i;
            rep(y,j) k*=i;
            if(k>ans && k<=x){
                ans=k;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

string t[4]={"dream", "dreamer", "erase", "eraser"};

int main(){
	string s;
	cin>>s;
	bool update = true;
	while(s.size()>0 && update){
		update = false;
		rep(i, 4){
			int sz = t[i].size();
			if(s.size() < sz) continue;
			if(s.substr(s.size()-sz, sz) == t[i]) {
				s = s.substr(0, s.size()-sz);
				update = true;
				break;
			}
		}
	}
	cout<< (s.size()== 0?"YES":"NO")<<endl;
}

Measured memory_bytes: 512
n=int(input())
count=[[0]*9 for _ in range(9)]
for i in range(1,n+1):
  if i%10>0:  
    i=str(i)
    x,y=int(i[0])-1,int(i[-1])-1
    count[x][y]+=1
    
ans=0
for i in range(9):
  for j in range(9):
      ans+=count[i][j]*count[j][i]
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	static Scanner scan = new Scanner(System.in);
	
	public static void main(String[] args){
		int min = 0, hour = 0;
	//	int sec = Integer.parseInt(args[0]);
		int sec = scan.nextInt();
		if(sec >= 60*60){
			hour = sec / (60 *60);
		}
			sec = sec - hour*60*60;

		if(sec>=60){
			min = sec /60;
		}
		sec = sec - min * 60;
	//	int sec = sec % 60;
		System.out.println(hour + ":" + min +":" + sec);
	}
}



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

using namespace std;

#ifdef WIN32
	#define I64 "%I64d"
#else
	#define I64 "%lld"
#endif

typedef long long ll;

#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(s) s.begin(), s.end()
#define sz(s) (int(s.size()))
#define fname "a"

int a[20002];

int main()
{
	#ifdef LOCAL
	freopen(fname".in", "r", stdin);
	freopen(fname".out", "w", stdout);
	#endif

	int n, x;
	scanf("%d%d", &n, &x);
	for (int i = 0; i < n; ++i)
		scanf("%d", &a[i]);

	sort(a, a + n);
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		if (x >= a[i]) {
			++ans;
			x -= a[i];
		} else {
			x = 0;
		}
	}
	printf("%d\n", ans - (x ? 1 : 0));

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			int[] a = IntStream.range(0, n).map(i -> scanner.nextInt()).toArray();
			// sum[i]=a[0]+...+a[i]
			long[] sum = new long[n];
			sum[0] = a[0];
			IntStream.range(1, n).forEach(i -> sum[i] = sum[i - 1] + a[i]);
			System.out.println(
					IntStream.range(0, n - 1).mapToLong(i -> Math.abs(sum[n - 1] - 2 * sum[i])).min().getAsLong());
		}
	}
}


Measured memory_bytes: 61044
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long N;
    cin >> N;
    long long sum{}, result{}, input;
    vector<long long> a(N);
    for(auto& item: a) {
        cin >> input;
        item = input;
        sum += input;
    }
    if (sum % N) {
        auto y = sum / N;
        size_t _1{};
        for(auto&& x: a) {
             _1 += pow(x - y, 2);
        }
        y = sum / N + 1;
        size_t _2{};
        for(auto&& x: a) {
            _2 += pow(x - y, 2);
        }
        result = std::min(_1, _2);
    }
    else {
        auto y = sum / N;
        for(auto&& x: a) {
            result += pow(x - y, 2);
        }
    }
    cout << result << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
int i=0,j=0,x=0;
for(i=1;i<=9;i++)
	for(j=1;j<=9;j++)
	{
		x=i*j;
		printf("%dx%d=%d\n",i,j,x);
	}
return 0;
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(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);}

int main(){
    ll n,a,cnt=1,brk=0;
    cin>>n;
    rep(i,n){
        cin>>a;
        if(a==cnt) cnt++;
        else brk++;
    }
    if(cnt==1) cout<<-1<<endl;
    else cout<<brk<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s; cin>>s;
    unsigned long min=-1;
    for(int i=0;i<s.size()-2;i++){
        long t= (s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0');
        if(abs(t-753)<min)
            min=abs(t-753);
    }
    cout<<min;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(A, B, C):
    return max(0, C - (A - B))


def main():
    A, B, C = read_int_n()
    print(slv(A, B, C))


if __name__ == '__main__':
    main()


Measured memory_bytes: 7108
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
typedef pair<pii, ll>pi3;
ll mod = 1000000007;
ll t[100];
int main()
{
	int a;
	scanf("%d", &a);
	t[0] = 2, t[1] = 1;
	for (int i = 2; i < 100; i++)t[i] = t[i - 1] + t[i - 2];
	printf("%lld\n", t[a]);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(a) (a).begin(), (a).end()
#define forn(i,a,b) for (int i = a; i <= b; i++)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define rc(s) return cout<<s,0
#define rcc(s) cout<<s,exit(0)
#define er erase
#define in insert
#define pi pair <int, int>
# define sz(x) (int)((x).size())
#define int long long
 
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
 
const ll inf = 0x3f3f3f3f3f3f3f;
const ll mod = 1000000007;
const int N = 2e5 + 11;
int ans[N],anss;
vector<int>v[N];

int dfs(int nod){
	
	int cur = 0;
	for(auto it:v[nod]){
		if(!ans[it])dfs(it);
		cur = max(cur , ans[it]);
	}
	
	return ans[nod] = cur+1;
}

int32_t main(){
ios_base::sync_with_stdio(0); cin.tie(0); cerr.tie(0); cout.tie(0);
	
	int n,m;
	cin>>n>>m;
	while(m--){
		int x,y;
		cin>>x>>y;
		v[x].pb(y);
	}
	
	forn(i,1,n){
		if(!ans[i])ans[i] = dfs(i);
		anss = max(anss , ans[i]);
		//cout<<ans[i]<<' ';
	}//cout<<'\n';
	
 	cout<<(anss-1)<<'\n';
return 0;
}

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

def solve():
    s = input()
    xa, ya = map(int, input().split())
    xset = set([0])
    yset = set([0])

    if "T" not in s:
        print("Yes" if len(s) == xa and ya == 0 else "No")
        return

    fcnt = 0
    tcnt = 0
    for c in s:
        if "T" == c:
            if fcnt > 0:
                if tcnt % 2 == 0:
                    if tcnt == 0:
                        xset = set([x + fcnt for x in xset]) 
                    else:
                        xset = set([x + fcnt for x in xset]) | set([x - fcnt for x in xset])
                else:
                    yset = set([y + fcnt for y in yset]) | set([y - fcnt for y in yset])
            fcnt = 0
            tcnt += 1
        if "F" == c:
            fcnt += 1

    if fcnt > 0:
        if tcnt % 2 == 0:
            if tcnt == 0:
                xset = set([x + fcnt for x in xset]) 
            else:
                xset = set([x + fcnt for x in xset]) | set([x - fcnt for x in xset])
        else:
            yset = set([y + fcnt for y in yset]) | set([y - fcnt for y in yset])
    
    print("Yes" if (xa in xset) and (ya in yset) else "No")

if __name__=="__main__":
    solve()


Measured memory_bytes: 79964
x, y = map(int, input().split())
a = (2 * y - x) / 3
b = (2 * x - y) / 3

def cmb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n - r] % mod

mod = 10 ** 9 + 7
N = 10 ** 6
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range(2, N + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod // i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)

if a.is_integer() and b.is_integer():
    a = int(a)
    c = int(a + b)
    print(cmb(c, a, mod))
else:
    print(0)

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

def readInts():
  return [int(s) for s in input().split(" ")]

def main():
  N = readInts()[0]
  restaurants = []
  for i in range(N):
    S, P = input().split(" ")
    restaurants.append((S, int(P), i+1))
  restaurants.sort(key=lambda x: (x[0], -1 * x[1]))
  for _, _, n in restaurants:
    print(n)

if __name__ == "__main__":
  main()


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

int main() {
	int N;
    cin >> N;
    while ( N >= 100 ) {
    N = N - 100;
    }
    while ( N >= 10 ) {
    N = N - 10;
    }
    if ( N == 3 ) {
    cout << "bon" << endl;
    }
    else if ( N == 0 || N == 1 || N ==6 || N == 8 ) {
    cout << "pon" << endl;
    }
    else {
    cout << "hon" << endl;
    }
    
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
bool isprime(int x){
	for(int i=2;i*i<=x;++i)if(x%i==0)return 0;
	return 1;
}
int main(){
#ifdef XZZSB
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	int X=gi();
	while(!isprime(X))++X;
	printf("%d\n",X);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
long long yi[100100];
long long er[100100];
long long san[100100];
int main()
{
	long long n;
	cin >> n;
	int i;
	for (i = 1; i <= n; i++)
		cin >> yi[i];
	for (i = 1; i <= n; i++)
		cin >> er[i];
	for (i = 1; i <= n; i++)
		cin >> san[i];

	sort(yi, yi + n + 1);
	sort(er, er + n + 1);
	sort(san, san + n + 1);

	long long answer = 0;
	for (i = 1; i <= n; i++)
	{
		long long l = 1, r = n, mid, res = 0;
		while (l <= r)
		{
			mid = (l + r) / 2;
			if (yi[mid] < er[i] && (yi[mid + 1] >= er[i] || mid + 1 > n))
			{
				res = mid;
				break;
			}
			else if (yi[mid + 1] < er[i])
				l = mid + 1;
			else
				r = mid - 1;
		}
		long long left = 1, right = n, midd, result = 0;
		while (left <= right)
		{
			midd = (left + right) / 2;
			if (san[midd] > er[i] && (san[midd - 1] <= er[i] || midd - 1 < 1))
			{
				result = n - midd + 1;
				break;
			}
			else if (san[midd - 1] > er[i])
				right = midd - 1;
			else
				left = midd + 1;
		}
		long long ans = res*result;
		answer += ans;
	}
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

string s;
int n, dp[200004][2];

int main() {
	cin >> s;
	s = "@@" + s + ".";
	n = SI(s) - 1;
	
	dp[2][0] = 0;
	dp[2][1] = 0;
	incID(i, 2, n) {
		string pre[2] = {
			s.substr(i - 1, 1), 
			s.substr(i - 2, 2)
		}, nex[2] = {
			s.substr(i, 1),
			s.substr(i, 2)
		};
		
		inc(j, 2) {
		inc(k, 2) {
			if(pre[j] != nex[k]) { setmax(dp[i + (k + 1)][k], dp[i][j] + 1); }
		}
		}
	}
	
	cout << max(dp[n][0], dp[n][1]) << endl;
	
	return 0;
}


Measured memory_bytes: 2620
// A - AtCoder *** Contest

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const int MOD = 1e9 + 7;

int main() {
	string a, s, c;
	cin >> a >> s >> c;

	cout << 'A' << s[0] << 'C' << endl;

	return 0;
}

Measured memory_bytes: 256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}
const int MOD = 1e9+7;

int main() {
    string s;
    cin >> s;
    int n = s.size();

    vector<vector<int>> dp(n+1, vector<int>(13, 0));
    vector<int> coef = {1, 10, 9, 12, 3, 4};
    
    dp[0][0] = 1;
    for(int i=1;i<=s.size();i++){
        int co = coef[(i-1) % 6];
        char c = s[n-i];
        if(c == '?'){
            for(int j=0;j<=9;j++){
                for(int k=0;k<=12;k++){
                    dp[i][k] = (dp[i][k] + dp[i-1][(k+130-j*co)%13]) % MOD;
                }
            }
        }
        else {
            int num = c - '0';
            for(int j=0;j<=12;j++){
                dp[i][j] = (dp[i][j] + dp[i-1][(j+130-num*co)%13]) % MOD;
            }
        }
    }

    cout << dp[n][5] << endl;


    return 0;
}

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

#define ll long long
 
/*unordered_map <int, vector<int>> adj;
 
void dfs(int s, int *vis)
{
    vis[s] = true;
    for(autp i = adj[s].begin(); i != adj[s].end(); i++)
    {
        if(vis[*i] == false)
        {
            dfs(*i, vis);
        }
    }
}*/
 
 
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
	ll n;
	cin >> n;
	
	int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
	
	for(ll i = 0; i < n; i++)
	{
	    string x;
	    cin >> x;
	    
	    if(x[0] == 'A') c1++;
	    if(x[0] == 'W') c2++;
	    if(x[0] == 'T') c3++;
	    if(x[0] == 'R') c4++;
	}
	
	cout<<"AC x "<<c1<<"\n";
	cout<<"WA x "<<c2<<"\n";
	cout<<"TLE x "<<c3<<"\n";
	cout<<"RE x "<<c4<<"\n";
	
	return 0;
}


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

#define pb push_back
#define eb emplace_back
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;

const int N = 200007;

const ll isQuery = -(1LL << 62);

struct Line {
	ll m, b;int id;
	Line(ll m_, ll b_, int id_) : m(m_), b(b_), id(id_) {}
	mutable multiset<Line>::iterator it, e;
	const Line * succ() const {
		return next(it)==e ? 0 : &*next(it);
	}
	bool operator<(const Line& rhs) const {
		if(rhs.b != isQuery) return m < rhs.m;
		const Line* s = succ();
		if (!s) return 0;
		ll x=rhs.m;
		return b - s->b < (s->m - m) * x;
	}
};

struct DynamicHull : public multiset<Line> {
	bool bad(iterator y) {
		auto z=next(y);
		if(y == begin()) {
			if (z == end()) return 0;
			return y->m == z -> m && y->b <= z->b;
		}
		auto x = prev(y);
		if(z == end()) return y->m == x->m and y->b <= x->b;
		return (x->b - y->b) * (z->m - y->m) >= (y->b - z->b) * (y->m - x->m);
	}

	void insertLine(ll m, ll b, int id) {
		auto y = insert({m, b, id});
		y->it = y;
		y->e = end();
		if(bad(y)) { erase(y); return; }
		while( next(y) != end() and bad(next(y)) ) erase(next(y));
		while(y != begin() and bad(prev(y))) erase(prev(y));
	}

	pair<ll, int> getMax(ll x) {
		auto l = *lower_bound({x, isQuery, 0});
		return {l.m * x + l.b, l.id};
	}
};

ll h[N];
ll f[N];

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

	cin >> n >> c;

	DynamicHull hull;
	for(int i = 0; i < n; i++) {
		cin >> h[i];
	}

	for(int i = n-1; i >= 0; --i) {
		if(i < n-1) f[i] = h[i] * h[i] + c;
		else f[i] = 0;


		if(hull.size()) f[i] -= hull.getMax(h[i]).fi;

		hull.insertLine(2ll * h[i], -(h[i] * h[i] + f[i]), i);
	}

	cout << f[0] << '\n';
}


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

using namespace std;

int main() {
    string s;
    cin >> s;
    int counter = 0;

    if (s[0] == '1') ++counter;
    if (s[1] == '1') ++counter;
    if (s[2] == '1') ++counter;
    cout << counter << endl;
}

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

int main() {
  int n;
  cin >> n;
  set<int> a;
  for(int i = 0; i < n; i++) {
    int ai;
    cin >> ai;
    if(a.count(ai)) a.erase(ai); 
    else a.insert(ai);
  }
  int ans = a.size();
  cout << ans;
}

Measured memory_bytes: 8220
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
	int N; cin >> N;
	vector<int> T(N),A(N);
	rep(i,N) cin >> T[i];
	rep(i,N) cin >> A[i];
	vector<int> kari(N);
	vector<int> kaku(N);
	int now = 0;
	rep(i,N){
		if(T[i] != now){
			kaku[i] = T[i];
		}
		else kari[i] = T[i];
		now = T[i];	
	}

	now = 0;
	for(int i = N-1; i >= 0; i--){
		if(A[i] != now){
			if(kaku[i] != 0){
				if(kaku[i] != A[i]){
					cout << 0 << endl;
					return 0;
				}
			}
			else{
				kaku[i] = A[i];
				kari[i] = 0;
			}
		}
		else{
			if(kaku[i] != 0){
				if(kaku[i] > A[i]){
					cout << 0 << endl;
					return 0;
				}
			}
			else{
				kari[i] = min(kari[i],A[i]);
			}
		}
		now = A[i];
	}
	ll ans = 1;
	rep(i,N){
		//cout << kari[i] << endl;
		if(kari[i] != 0){
			ans *= kari[i];
			ans %= MOD;
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  int inf=1000000007;
  int n,k;cin>>n>>k;
  vector<int>h(n);
  for(int i=0;i<n;i++){
    cin>>h.at(i);
  }
  vector<int>dp(n,inf);
  dp.at(0)=0;
  for(int i=1;i<n;i++){
    int count=1;
    while(1){
      dp.at(i)=min(dp.at(i),dp.at(i-count)+abs(h.at(i)-h.at(i-count)));
      count++;
      if(i-count==-1||count-1==k){
        break;
      }
    }
  }
  cout <<dp.at(n-1)<<endl;
}

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

#define unsigned int long long
#define p(a, b) pair<a,b>

using namespace std;

//ifstream cin("Input.txt");
//ofstream cout("Output.txt");

int main() {
    int n, m, q;
    cin >> n >> m >> q;
    vector<vector<int>> v(n + 2, vector<int>(n + 2, 0));
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        v[x][y]++;
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            v[i][j] = v[i][j] + v[i][j - 1] + v[i - 1][j] - v[i - 1][j - 1];
        }
    }
    for (int i = 0; i < q; i++) {
        int x, y;
        cin >> x >> y;
        cout << v[y][y] - v[y][x - 1] - v[x - 1][y] + v[x - 1][x - 1] << '\n';
    }
    return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <set>
using namespace std;
using std::sort;


int main(){
    int  x,n;
    set<int> a;
//    printf("1\n");
    scanf("%d",&n);
    while(n--){
        scanf("%d",&x);
        if(a.count(x)==1){
            a.erase(x);
        }else{
            a.insert(x);
        }
        
      

    }
    printf("%d",a.size());
}


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

using namespace std;
using ll = long long;

int main() {
    string n;
    cin >> n;
    ll sum = 0;
    for (int i = 0; i < n.size(); i++) {
        sum += n[i] - '0';
    }
    if (sum % 9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3724
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>
#include <fstream>
#include <stdio.h>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<double> VEC;
typedef vector<VEC> MAT;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef vector<LL> VLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define MT(a,b,c) MP(a, MP(b, c))
#define T1 first
#define T2 second.first
#define T3 second.second


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EPS 1e-8

int y[111];

int main(){
	while(1){
		int n,a,b,c,x;
		cin>>n>>a>>b>>c>>x;
		if(n==0)return 0;
		REP(i,n)scanf("%d",&y[i]);
		int idx = 0;
		REP(i,10001){
			if(x==y[idx]){
				idx++;
				if(idx==n){
					cout << i << endl;
					break;
				}
			}
			x=(a*x+b)%c;
		}
		if(idx != n)cout << -1 << endl;
	}
}

Measured memory_bytes: 1240
A = int(input())
B = int(input())
if A == 1 and B == 2:
  print(3)
elif A == 1 and B == 3:
  print(2)
elif A == 2 and B == 3:
  print(1)
elif A == 2 and B == 1:
  print(3)
elif A == 3 and B == 1:
  print(2)
elif A == 3 and B == 2:
  print(1)

Measured memory_bytes: 3060
"use strict"

const Main=(input)=>{
  
  
  const Array=input.trim().split("\n");
  const Array1=Array[0].split("")
  const Array2=Array[1].split("")
  const Array3=Array[2].split("")
  const Answer=`${Array1[0]}${Array2[1]}${Array3[2]}`

  console.log(Answer)
}


Main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
int f(int x){
  int res = 0;
  while(x > 0){
    res += x;
    --x;
  }
  return res;
}

int main(){
  int N;
  cin >> N;
  if(N < 3){
    cout << 0 << endl;
    return 0;
  }
  int L[N];
  for(int i=0; i<N; ++i) cin >> L[i];
  int cnt = 0;
  for(int i=0; i<N; ++i){
    for(int j=i+1; j<N; ++j){
      for(int k=j+1; k<N; ++k){
        set<int>s;
        s.insert(L[i]);
        s.insert(L[j]);
        s.insert(L[k]);
        if(s.size() == 3 && L[i] + L[j] > L[k] && L[j] + L[k] > L[i] && L[k] + L[i] > L[j]){
          ++cnt;
        }
      }
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3640
#include<iostream>
using namespace std;
int main()
{
	int x, a, b;
	cin >> x >> a >> b;
	int y = x - a;
	int z = x - b;
	if (y < 0)
    	y = y * -1;
	if (z < 0)
		z = z * -1;
	if (y < z)
		cout << "A" ;
	else
		cout << "B";

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(v) v.begin(),v.end()

const int maxn = 1e5 + 100;
const ll inf = 2e18, mod = 1e9 + 7;

int n, w[maxn], pos;
ll l, t, x[maxn], y[maxn], ans[maxn];

void calcPos() {
	for (int i = 0; i < n; i++) {
		if (w[i] == 1) {
			pos = (pos - ((t + x[i]) / l) % n + n) % n;
		}
		else {
			pos = (pos + ((t - x[i] + l - 1) / l) % n + n) % n;
		}
	}
}

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

	cin >> n >> l >> t;
	for (int i = 0; i < n; i++) { 
		cin >> x[i] >> w[i];
		y[i] = (x[i] + (w[i] == 1 ? t : -t) % l + l) % l;
	}
	sort(y, y + n);

	calcPos();

	for (int i = 0; i < n; i++) {
		ans[(pos + i) % n] = y[i];
	}

	for (int i = 0; i < n; i++) {
		cout << ans[i] << endl;
	}
}



Measured memory_bytes: 6336
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 1LL<<60
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n,m;cin>>n>>m;
    ll dp[1100][5000];
    vector<ll> a(m),b(m);
    vector<ll>c(m,0);
    for(int i=0;i<m;i++){
        cin>>a[i]>>b[i];
        for(int j=0;j<b[i];j++){
            int t;cin>>t;t--;
            c[i]+=(1<<t);
        }
    }
    for(int i=0;i<1100;i++)
        for(int j=0;j<5000;j++)
            dp[i][j]=INF;
    dp[0][0]=0;
    for(int i=0;i<m;i++){
        for(int j=0;j<(1<<n);j++){
            chmin(dp[i+1][j],dp[i][j]);
            chmin(dp[i+1][j|c[i]],dp[i][j]+a[i]);
        }
    }
    cout<<(dp[m][(1<<n)-1]<INF?dp[m][(1<<n)-1]:-1)<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


Measured memory_bytes: 43264
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N; cin >> N;
  vector<int> vec(N);
  
  for(int i = 0; i < N; i++) {
    int a; cin >> a;
    vec.at(i) = a;
  }
  
  int ans = 0;
  
  for (int i = 0; i < N; i++) {
    
    int max = 0;
    
    for (int j = 0; j < N; j++) {
      if (max < vec.at(j)) max = vec.at(j);
    }
    
    if (i % 2 == 0) ans += max;
    else ans -= max;
    
    for (int j = 0; j < N; j++) {
      if (max == vec.at(j)) {
        vec.at(j) = 0;
        break;
      }
    }
    
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
N,C=map(int,input().split())

sushi=[]
for _ in range(N):
    x,v=map(int,input().split())
    sushi.append([x,v])

sushi_2=list(map(lambda x:[x[0]+C, x[1]] , sushi))

sushi+=sushi_2

cal=[[0,0] for i in range(2*N)]

pre_x=C
for i in range(N, 2*N):
    x, v = sushi[i][0], sushi[i][1]
    cal[i][0], cal[i][1] = v-(x-pre_x), v-2*(x-pre_x)
    pre_x=x


pre_x=C
for i in range(N)[::-1]:
    x, v = sushi[i][0], sushi[i][1]
    cal[i][0], cal[i][1] = v-(pre_x-x), v-2*(pre_x-x)
    pre_x=x

left=[[0,0] for i in range(N)]
right=[[0,0] for i in range(N)]

temp_0,temp_1=cal[N][0],cal[N][1]
right[0][0], right[0][1] = max(0,temp_0), max(0,temp_1)
for i in range(N+1,2*N):
    temp_0+=cal[i][0]
    temp_1+=cal[i][1]
    right[i-N][0], right[i-N][1] = max(right[i-N-1][0],temp_0), max(right[i-N-1][1],temp_1)

temp_0,temp_1=cal[N][0],cal[N][1]
right[0][0], right[0][1] = max(0,temp_0), max(0,temp_1)
for i in range(N+1,2*N):
    temp_0+=cal[i][0]
    temp_1+=cal[i][1]
    right[i-N][0], right[i-N][1] = max(right[i-N-1][0],temp_0), max(right[i-N-1][1],temp_1)

temp_0, temp_1=cal[N-1][0], cal[N-1][1]
left[-1][0], left[-1][1] = max(0,temp_0), max(0,temp_1)
for i in range(N-1)[::-1]:
    temp_0+=cal[i][0]
    temp_1+=cal[i][1]
    left[i-N][0], left[i-N][1] = max(left[i-N+1][0],temp_0), max(left[i-N+1][1],temp_1)

"""
print(sushi)
print(cal)
print(right)
print(left)
"""

ans=max(left[0][0],0)
for i in range(1,N):
    ans=max(ans,left[i][0]+right[i-1][1])

ans=max(right[N-1][0],ans)
for i in range(N-1)[::-1]:
    ans=max(ans,right[i][0]+left[i+1][1])


print(ans)

Measured memory_bytes: 100100
/**
 * author: moririn_cocoa       
**/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;

int main(void) {
  
  int A;
  int B;
  int C;
  int D;
  
  cin >> A;
  cin >> B;
  cin >> C;
  cin >> D;
  
  if ( A * B >= C * D ) {
    
    cout << A * B << endl;
  }
  
  else {
    
    cout << C * D << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3584
//----------------------------------------------------------------------
#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(void) {
    string s; cin >> s;

    int tota= 0;
    int totb= 0;
    rep(i,(int)s.size()) {
       if(s[i] == 'A')
           tota++;
       else if(s[i] == 'B')
           totb++;
    }
    if(tota==3||totb==3)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

const double EPS = 1e-10;
typedef long long ll;
typedef pair<int, int> pint;


int main()
{
	string r, g, below;
	while (cin >> r, r != "-")
	{
		cin >> g >> below;
		queue<char> red, green;
		rep (i, r.size())
			red.push(r[i]);
		rep (i, g.size())
			green.push(g[i]);

		rep (i, 2)
		{
			red.push(' ');
			green.push(' ');
		}


		char center;
		if (below[0] == red.front())
		{
			center = red.front();
			red.pop();
		}
		else
		{
			center = green.front();
			green.pop();
		}

		string res;
		while (!red.empty() && !green.empty())
		{
			if (below.find(center) != string::npos)
			{
				center = red.front();
				red.pop();
			}
			else
			{
				res += center;
				center = green.front();
				green.pop();
			}
		}
		if (below.find(center) != string::npos)
			res += center;

		res.erase(remove(all(res), ' '), res.end());
		cout << res << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define SZ(v) int((v).size())
#define ALL(vec) begin(vec), end(vec)

typedef long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
#ifdef Rahul
# define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#else
# define error(...) 42;
#endif
string to_string(char c) { return "'" + string(1, c) + "'";}
string to_string(string s) { return '"' + s + '"';}
string to_string(const char* s) { return to_string((string) s);}
template<typename A> string to_string(A);
template<typename A, typename B> string to_string(pair<A, B> p){
  return "(" + to_string(p.first) + ": " + to_string(p.second) + ")";}
template<typename A> string to_string(A v) {bool f = false; string r = "{"; 
  for (auto x: v) {if (f) r += ", "; r += to_string(x); f = true;} return r += "}";}
template<typename A> string to_string(vector<vector<A>> v) {string r; 
  for (auto x: v) r += "\n" + to_string(x); return r;}
int Nerr;
template<typename A> string to_string(A *p) {return to_string(vector<A>(p, p + Nerr));}
void err(istream_iterator<string>) { cerr << endl; }
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << to_string(a) << "; "; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
int const MOD = 1e9 + 7;
long long const INF = 1e18 + 42;
/***********************************************************************/

int32_t main() {
  cin.tie(nullptr) -> sync_with_stdio(false);
  
  int n; cin >> n;
  kek((n + 1) >> 1);
}


Measured memory_bytes: 256
import math
import sys
import queue
from collections import Counter
from itertools import accumulate
from fractions import gcd
from functools import reduce


def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

sys.setrecursionlimit(10000)

mod = 1000000007

"""
# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]

# 標準入力取得
## 文字列
    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())

## 数値
    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

from math import sin
from math import cos
from math import radians as rad
import numpy as np

if __name__ == "__main__":
    x1, y1, x2, y2 = map(int, sys.stdin.readline().split())
    p1 = np.array([x1, y1])
    p2 = np.array([x2, y2])
    Rot = np.array([[cos(rad(90)), -sin(rad(90))], [sin(rad(90)), cos(rad(90))]])

    p3 = np.dot(Rot, p2 - p1) + p2
    p4 = np.dot(Rot, p3 - p2) + p3    
    print(int(round(p3[0])), int(round(p3[1])), int(round(p4[0])), int(round(p4[1])))


Measured memory_bytes: 14012
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <sstream>
#include <set>
#include <map>
#define LLMAX 9223372036854775807

using namespace std;
using ll = long long;

int main() {
	ll argN;
	cin >> argN;

	vector<ll> argH(argN);
	for (auto itr = argH.begin(); itr != argH.end(); ++itr) {
		cin >> *itr;
	}

	ll ret = 1;
	for (ll i = 1; i < argN; ++i) {
		bool visible = true;
		for (ll j = i - 1; j >= 0; --j) {
			visible &= (argH.at(j) <= argH.at(i));
		}
		if (visible) {
			ret++;
		}
	}

	cout << ret << endl;
}

Measured memory_bytes: 888
#include <iostream>

using namespace std;
int main()
{
    int n;
    int a=0;
    int b=0;
    string str;
    cin >> n;
    cin >> str;
    for (int i=0; i<n; i++){
        if (str[i] == 'R') a++;
        else b++;
    }
    if(a > b) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int n, k;
    scanf("%d %d", &n, &k);
    int a[200001];
    for(int i = 0; i<n; i++){
        scanf("%d", &a[i]); 
    }
   
    for(int i = 0, j = k; i<n-k; i++, j++){
        if(a[j] > a[j-k]){
            printf("Yes\n");
        }
        else{
            printf("No\n");
        }
    }

    return 0;
}

Measured memory_bytes: 2424
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  int32_t main()
  {        
  



      int a,b;
 
      cin>>a>>b;
      if(b==1)
      {
        cout<< 0;
      }
      else if(a>=b)
      {
        cout<<1;
      }
      else
      {

        int ans = (b-1)/(a-1);

        if((b-1)%(a-1)!=0)
        {
          ans++;
        }

        cout<<ans<<endl;
      }
 
    return 0;
 
     }

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<limits>
#define ll long long
#define F first
#define S second
#define pb push_back
#define oo 1e18
#define endl '\n'
#define si size()
#define all(v) v.begin(),v.end()
#define FASTIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

using namespace std;
int dx[] = {0,0,1,-1};
int dy[] = {1,-1,0,0};
const long double Pi=acos(-1),e=2.718;
const int N=3e3+10,mod=3e7;
ll dp[N][N],n,m;
string s,t,ans;
ll solve(int i,int j){
    if(i==n || j==m)return 0;
    ll &ret=dp[i][j];
    if(ret+1)return ret;
    ret = 0;
    if(s[i]==t[j])ret = max(ret,solve(i+1,j+1)+1);
    else{
        ret = max(ret,solve(i+1,j));
        ret = max(ret,solve(i,j+1));
    }
    return ret;
}
void Trace(int i,int j){
    if(i==n || j==m)return ;
    if(s[i]==t[j]){
        ans += s[i];
        Trace(i+1,j+1);
    }
    else{
        if(dp[i+1][j] > dp[i][j+1]) Trace(i+1,j);
        else Trace(i,j+1);
    }
}
int main()
{
    memset(dp,-1,sizeof dp);
    FASTIO
    cin >> s >> t;
    n = s.si;
    m = t.si;
    solve(0,0);
    Trace(0,0);
    cout << ans << endl;
    return 0;
}
/**

*/


Measured memory_bytes: 71296
#include<bits/stdc++.h>
#define ll long long

using namespace std;
int main()
{
    vector<int>v;
    vector<int>v1;
    vector<int>v2;
    set <char>s;
    int t,coun1=0,n,a,ans3,coun2=0,x,y=0,ans1=0,b,sum=0,flag=0,ans2;


    cin >>x>>y;

    cout << x*y;




return 0;
}


Measured memory_bytes: 3532
n,x = map(int,input().split())
lis = list(map(int,input().split()))
cou = 0
if lis[0] > x:
  cou += (lis[0] - x)
  lis[0] -= (lis[0] -x)
for i in range(n-1):
  if lis[i+1] + lis[i] > x:
    cou += (lis[i+1] + lis[i] -x)
    lis[i+1] -= (lis[i+1] + lis[i] -x)
print(cou)

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

int main() {
  int point;cin >> point; 
  
  int ans;
  if(point < 600) {
    ans = 8;
  } else if ( point < 800) {
     ans = 7;
  } else if ( point < 1000) {
     ans = 6;
  } else if ( point < 1200) {
     ans = 5;
  } else if ( point < 1400) {
     ans = 4;
  } else if ( point < 1600) {
     ans = 3;
  } else if ( point < 1800) {
     ans = 2;
  } else {
     ans = 1;
  }
    
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>//本当は必要なヘッダファイルだけインクルードするべきです
using namespace std;//本当は個別にusingするか変数や関数ごとにstd::をつけるべきです
//本当は関数内に宣言し明示的に初期化するべきです
int N,cnt;
vector<int>A;
void selectionSort(){
  for(int i=0;i<N;i++){
    int min_j=i;
    for(int j=i+1;j<N;j++){
      if(A[j]<A[min_j]){
        min_j=j;
      }
    }
    if(A[i]>A[min_j]){
      swap(A[i],A[min_j]);
      cnt++;
    }
  }
}
int main(void){
  cin>>N;
  A.resize(N);
  for(int i=0;i<N;i++)cin>>A[i];
  selectionSort();
  for(int i=0;i<N;i++)cout<<A[i]<<(i==N-1?'\n':' ');
  cout<<cnt<<endl;
  return 0;
}



Measured memory_bytes: 3120
package main

import "fmt"

func main() {
	var x, y int
	fmt.Scan(&x, &y)

	n := x
	count := 0

	// if x%2 == 0 {
	// 	n = n * 3 / 2
	// 	count++
	// }

	for n <= y {
		n *= 2
		count++
	}

	fmt.Println(count)
}


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

int main() {
	string str;
	cin >> str;
	if (str[str.size() - 1] == 's') cout << str << "es";
	else cout << str << "s";


	
	
	return 0;
}

Measured memory_bytes: 3592
import unittest
import collections


class TestD(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think(15), 23)

    def test_2(self):
        self.assertEqual(think(1), 1)

    def test_3(self):
        self.assertEqual(think(13), 21)

    def test_4(self):
        self.assertEqual(think(100000), 3234566667)


def solve():
    k = read()
    result = think(k)
    write(result)


def read():
    return read_int(1)[0]


def read_int(n):
    return read_type(int, n, sep=' ')


def read_float(n):
    return read_type(float, n, sep=' ')


def read_type(t, n, sep):
    return list(map(lambda x: t(x), read_line().split(sep)))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(k):
    k_max = 10 ** 5
    list_of_lunlun_number = prepare_lunlun_number(k_max)
    return list_of_lunlun_number[k - 1]


def write(result):
    print(result)


def prepare_lunlun_number(k_max):
    lunlun_number = collections.deque([])
    deque = collections.deque(list(range(1, 10)))
    length = 0
    while length < k_max:
        d = deque.popleft()
        lunlun_number.append(d)
        length += 1
        if d % 10 == 0:
            deque.append(d * 10 + 0)
            deque.append(d * 10 + 1)
        elif d % 10 == 9:
            deque.append(d * 10 + 8)
            deque.append(d * 10 + 9)
        else:
            m = d % 10
            deque.append(d * 10 + m - 1)
            deque.append(d * 10 + m)
            deque.append(d * 10 + m + 1)
    return lunlun_number


if __name__ == '__main__':
    # unittest.main()
    solve()

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

int main(){
    int n;cin>>n;
    string acc = "No";
    for (int i=1;i<=9;i++){
        if (n % i == 0){
            int d = n / i;
            if (1 <= d && d <= 9){
                acc = "Yes";
            }
        }
    }
    cout << acc << endl;
    return 0;
}

Measured memory_bytes: 256
from math import factorial
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N, M = map(int, input().split())

if N - 2 >= 0:
    a = cmb(N,2)
else:
    a = 0


if M - 2 >= 0:
    b = cmb(M,2)
else:
    b = 0

print(int(a)+int(b))

Measured memory_bytes: 3572
#include <stdio.h>

int max(int,int,int);

int main(void){
    int a,b;
    int i;
    scanf("%d %d",&a,&b);
    
    int c,d,e;
    c=a+b;
    d=a-b;
    e=a*b;
    
    int ans;
    ans=max(c,d,e);
    printf("%d",ans);
    
    return 0;
}

int max(a,b,c){
    int i;
    if(a>=b){
        if(a>=c){
            return a;
        }else{
            return c;
        }
    }else if(a>=c){
        return b;
    }else{
        if(b>c){
            return b;
        }else{
            return c;
        }
    }
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
#define mod 1000000007
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	int status=0;
	long long ans=1;
	string  s1,s2;
	cin>>s1>>s2;
	for(int i=0;i<n;i++)
	{
		if(s1[i]==s2[i])
		{
			if(status==0) ans=(ans%mod)*(3%mod)%mod;		
			else if(status==1) ans=(ans%mod)*(2%mod)%mod;
			status=1;
		}
		else
		{
			if(status==0) ans=(ans%mod)*(6%mod)%mod;
			else if(status==1) ans=(ans%mod)*(2%mod)%mod;
			else if(status==2) ans=(ans%mod)*(3%mod)%mod;
			status=2;
			i++;
		}
	}
	printf("%ld\n",ans);
	return 0; 
}

Measured memory_bytes: 256
a=int(input())
b=int(input())
c=int(input())
x=int(input())

ans=0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if 500*i+100*j+50*k==x:
        ans+=1

print(ans)

Measured memory_bytes: 9104
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  string S;
  cin>>S;
  long long R=0;
  long long G=0;
  long long B=0;
  long long sum=0;
  for(int i=0;i<N;i++){
    if(S.at(i)=='R'){
      R=R+1;
    }
    else if(S.at(i)=='G'){
      G=G+1;
    }
    else{
      B=B+1;
    }
  }
  sum=R*G*B;
  long long count=0;
  if(N<3){
    cout<<0<<endl;
  }
  else{
    for(int i=0;i<N-2;i++){
      for(int j=i+1;j<N-1;j++){
        int m=2*j-i;
        if(m<N){
          if((S.at(i)!=S.at(j))&&(S.at(i)!=S.at(m))&&(S.at(m)!=S.at(j))){
            count=count+1;
          }
        }
      }
    }
    cout<<sum-count<<endl;
  }
}

Measured memory_bytes: 3608
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<cstring>

using namespace std;

int main()
{
	int n,a,b;
	while(~scanf("%d",&n))
	{
		a = n % 10;
		b = n / 10;
		if(a==9 || b==9)
			printf("Yes\n");
		else
			printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 256