akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

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

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

string s;
bool dp[30303][11][11][11];

int main(void){
	int n,i,p,q,r,ans=0;
	cin >> n;
	cin >> s;
	dp[0][10][10][10] = true;
	for(i=0; i<n; ++i){
		for(p=0; p<11; ++p){
			for(q=0; q<11; ++q){
				for(r=0; r<11; ++r){
					dp[i+1][p][q][r] |= dp[i][p][q][r];
					dp[i+1][q][r][s[i]-'0'] |= dp[i][p][q][r];
				}
			}
		}
	}
		for(p=0; p<10; ++p){
			for(q=0; q<10; ++q){
				for(r=0; r<10; ++r){
					if(dp[n][p][q][r]){
						++ans;
					}
				}
			}
		}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 39296
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int a,b,c,d,e;
	cin >> a >> b >> c >> d >> e;
	cout << (min(a,min(b,c))+min(d,e))-50 << endl;
	return 0;
}

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

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
//const Int mod = 1e9+7;
const Int mod = 998244353;

bool print_space_enable = false;
void print() { 
    cout << endl; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

// mod付きコンビネーション
const int MAX = 1100000;
const int MOD = 998244353;

Int fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
Int COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

using ll = long long int;
ll RepeatSquaring(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P%2==0){
        ll t = RepeatSquaring(N, P/2, M);
        return t*t % M;
    }
    return N * RepeatSquaring(N, P-1, M) % M;
}

int main() {
    Int n, m, k;
    cin >> n >> m >> k;
    if (m == 1 and k == n - 1) {
        print(1);
        return 0;
    }
    COMinit();
    Int res = 0;
    for (Int i = 0; i <= (Int)k; i++) {
        Int sum = m;
        sum = sum * RepeatSquaring(m - 1, n - 1, mod) % mod;
        Int mul = RepeatSquaring(inv[m - 1], i, mod);
        sum = sum * mul % mod;
        sum = sum * COM(n - 1, i) % mod;
        res = (res + sum) % mod;
    }
    print(res);
    return 0;
}

Measured memory_bytes: 29412
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = list(input())
commands = [0] * N
ans = 0
for i in range(N):
    if T[i] == 'r':
        command = 'p'
        score = P
    elif T[i] == 's':
        command = 'r'
        score = R
    else:
        command = 's'
        score = S
    if i >= K and command == commands[i - K]:
        command = ' '
        score = 0
        
    commands[i] = command
    ans += score
print(ans)

Measured memory_bytes: 4788
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()


def main():
	r,c,k=MI()
	G=[[0]*(c+1) for _ in range(r+1)]
	dp=[[[0]*(c+1) for i in range(r+1)] for j in range(4)]
	for _ in range(k):
		rrr,ccc,v=MI()
		G[rrr][ccc]=v
	#print(G)

	#print(dp)

	for rr in range(1,r+1):
		for cc in range(1,c+1):
			if G[rr][cc]==0:
				for i in range(4):
					dp[i][rr][cc]=max(dp[i][rr][cc-1],dp[3][rr-1][cc])
			else:
				dp[0][rr][cc]=max(dp[3][rr-1][cc],dp[0][rr][cc-1])
				dp[1][rr][cc]=max(dp[0][rr][cc]+G[rr][cc],dp[1][rr][cc-1])
				dp[2][rr][cc]=max(dp[1][rr][cc-1]+G[rr][cc],dp[2][rr][cc-1],dp[1][rr][cc])
				dp[3][rr][cc]=max(dp[2][rr][cc-1]+G[rr][cc],dp[3][rr][cc-1],dp[2][rr][cc])
	#print(dp)
	print(dp[-1][-1][-1])















if __name__ == "__main__":
	main()


Measured memory_bytes: 428036
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>
#include<limits>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main() { 
  int n;
  cin>>n;
  VI a(n);
  rep(i,n) cin>>a[i];

  int cnt=0,minv=1e9;
  for(int i=0;i<n;i++){
      if(min(minv,a[i])==a[i]){
          cnt++;
          minv=min(minv,a[i]);
      }
  }
  cout<<cnt<<endl;

}



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

int main()
{
	std::string S, T;

	std::cin >> S >> T;

	size_t sizeS = S.size(), sizeT = T.size();

	int countSameCharactor = 0;

	for (size_t index = 0; index < sizeS - sizeT + 1; index++)
	{
		int sameChar = 0;

		for (size_t subindex = 0; subindex < sizeT; subindex++)
		{
			if (S.at(index + subindex)== T.at(subindex))
			{
				++sameChar;
			}
		}

		if (sameChar > countSameCharactor)
		{
			countSameCharactor = sameChar;
		}
	}

	std::cout << sizeT - countSameCharactor << std::endl;
}



Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_queue<int> pque;//これは大きい順
//typedef priority_queue<int, vector<int>, greater<int>> pque;//これは小さい順
//factorizeは、素因数分解用の関数

int main(){
	int k, x;
	cin >> k >> x;
	int min = -1000000;
	chmax(min,x-k+1);
	int max = 1000000;
	chmin(max, x+k-1);
	FOR(i,min,max+1){
		cout << i << endl;
	}

  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**8)
#from collections import deque

n, m = map(int, input().split())
depth = [0 for _ in range(n)]
chil = [[] for _ in range(n)]
rank = [0 for _ in range(n)]
parent = [-1 for _ in range(n)]
#visited = [False for _ in range(n)]
for _ in range(n+m-1):
	a, b = map(int, input().split())
	chil[a-1].append(b-1)
	rank[b-1] += 1

#print(chil)
for i in range(n):
	if rank[i] == 0:
		par = i
		break

parent[par] = -1

#def bfs(x):
#	que = deque([[x, 0]])
#	while que:
#		l = que.pop()
#		y, d = l[0], l[1]
#		print(y, d)
#		if d < depth[y]:
#			continue
#		for c in chil[y]:
#			if depth[c] == -1:
#				depth[c] = d+1
#				parent[c] = y
#				que.appendleft([c, d+1])
#			elif depth[c] < d+1:
#				depth[c] = d+1
#				parent[c] = y
#				que.appendleft([c, d+1])
#
#	return

#bfs(par)

def dfs(x):
	true_chil = []
	for c in chil[x]:
		if rank[c] == 1:
			true_chil.append(c)
		else:
			rank[c] -= 1
	for t in true_chil:
		parent[t] = x
		dfs(t)

	return

dfs(par)

for p in parent:
	print(p+1)

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

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
  int hoge[] = {31,29,31,30,31,30,31,31,30,31,30,31};
  string s[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};

  int foo[12][31];
  int dd = 3;
  for (int i=0; i<12; i++) {
    for (int j=0; j<hoge[i]; j++) {
      foo[i][j] = dd%7;
      dd++;
    }
  }
  
  int m, d;
  while(cin >> m >> d, m+d) {
    cout << s[foo[m-1][d-1]] << endl;
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define ll long long
const int w=5e5+5;
const ll mod=998244353;
int n,m;
bool cheak(int x)
{
    for(int i=2;i*i<=x;i++)
    {
        if(x%i==0)
            return 0;
    }
    return 1;
}
int main()
{
    int i,j;
    int x;
    cin>>x;
    for(i=x;;i++)
    {
        if(cheak(i))
        {
            cout<<i<<endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <vector>
#include <cstdlib>
#include <string>
#include <climits>

using namespace std;

int main(void)
{

    int r,g,b,n;
    cin >>r >>g >>b >>n;

    int ct = 0;
    for(int ri = 0; ri * r <= n; ri++){
        for(int gi = 0; ri * r + gi * g <= n; gi++){
            int diff =  n - (ri * r + gi*g);
            if(diff % b == 0){
                ct++;
            }
        }
    }
    printf("%d\n", ct);

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
 
typedef long long ll;
typedef pair<int, int> ii;

int main() {
	
	vector<string> v(10);
	v[1] = ".,!? ";
	v[2] = "abc";
	v[3] = "def";
	v[4] = "ghi";
	v[5] = "jkl";
	v[6] = "mno";
	v[7] = "pqrs";
	v[8] = "tuv";
	v[9] = "wxyz";
	
	int n;
	cin >> n;
	rep(i, n){
		string s, ans;
		cin >> s;
		rep(j, s.size()){
			int cnt = 0;
			if(s[j] == '0') continue;
			while(s[j] == s[j+1]){
				j++;
				cnt++;
			}
			int num = (int)(s[j] - '0');
			ans += v[num][cnt % v[num].size()]; 
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 3136
import sys

def get_input():
    return map(int, input().split(' '))

def gcd(i,j):
    if i > j:
        if i % j == 0:
            return j
        else:
            return gcd(j, i % j)
    else:
        if j % i == 0:
            return i
        else:
            return gcd(i, j % i)
    
def main():
    for line in sys.stdin:
        ls = list(map(int, line.split(' ')))
        g = gcd(ls[0], ls[1])
        print(g, int(ls[0]*ls[1]/g))

if __name__ == '__main__':
    main()

Measured memory_bytes: 7644
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    n = int(input())
    a = [int(x) for x in input().split()]
    b = deque()
    for i in range(n):
        if i % 2:
            b.appendleft(a[i])
        else:
            b.append(a[i])
    if n % 2:
        b.reverse()
    print(*b)


t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

abc

"""


Measured memory_bytes: 32148
#include<bits/stdc++.h>
using namespace std;
#define rep(i, c) for(ll i = 1; i <= (ll)c; i++)
#define ll long long
#define upd_max(maxer, updater) if (maxer < updater) maxer = updater;
#define upd_min(miner, updater) if (miner > updater) miner = updater;
const int inf = 1000000000; // 10^9

int main(){
    double r, pi;
    cin >> r;

    pi = 3.1415926535;
    cout << r * 2 * pi << endl;

    return 0;
}


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

int main() {
    ll x; cin >> x;
    ll year = 0;
    ll money = 100;
    while (money < x) {
        year++;
        money += money * 0.01;
    }
    cout << year << endl;
    return 0;
}

Measured memory_bytes: 3644
import math
n = int(input())
a = list(map(int, input().split()))

ans = 1
up = [1 for _ in range(n)] # ノードの上限 - a[i]
node = [1 for _ in range(n+1)] # n層目のノード
node[-1] = a[-1]

if n == 0:
    if a[0] == 1:
        print(1)
    else:
        print(-1)
    exit()

elif a[0] >= 1:
    print(-1)
    exit()

# print(up)
for i in range(1, n):
    up[i] = up[i-1]*2 - a[i]
    if up[i] <= 0:
        print(-1)
        exit()
for i in range(n-1, -1, -1):
    tmp_node = node[i+1] + a[i]
    if node[i+1]/2 + a[i] > up[i]+a[i]:
        print(-1)
        exit()
    node[i] = min(tmp_node, up[i]+a[i])
# print(up)
# print(node)
print(sum(node))


Measured memory_bytes: 674076
#include <bits/stdc++.h>
#include <numeric>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

ll SumXor(ll n) {
    ll now = n;
    ll res = n;

    while (now%4 != 0) {
        --now;
        res ^= now;
    }

    return res;
}

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

    ll A, B; cin >> A >> B;

    if (A > 0) cout << (SumXor(A-1) ^ SumXor(B)) << "\n";
    else cout << SumXor(B) << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <numeric>
#include <vector>
#include <queue>
#include <map>
typedef unsigned long long ull;
typedef long long ll;
#define MAX 15
using namespace std;
int main() {
  int x, y;
  cin >> x >> y;
  cout << x+y/2 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<bitset>
using namespace std;
typedef long long ll;

int main() {
	int N, A, B, ans = 0;
	cin >> N >> A >> B;
	for (int i = 1; i <= N; i++) {
		int sum = 0, temp = i;
		while (1) {
			sum += (temp % 10);
			temp /= 10;
			if (temp == 0) break;
		}
		if (A <= sum && sum <= B) ans += i;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a,b,c,x,y;
long long ans=0;
int main()
{
	scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
	ans=1LL*a*x+1LL*b*y;
	for (int i=0;i<=max(x,y);i++)
	{
		long long now=2LL*c*i;
		now+=1LL*a*max(0,x-i);
		now+=1LL*b*max(0,y-i);
		ans=min(ans,now);
	}
	printf("%lld\n",ans);
	return 0;
}


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

int main()
{
    ll i,j,x,y,x1,y1,x2,y2,q,p,r,z,k,t,n,m;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>m>>k;
    ll a[n],b[m];
    for(i=0;i<n;i++){
    cin>>x;
        if(i==0)
        {
            a[i]=x;  
        }
        else
        {
            a[i]=a[i-1]+x;
        }
    }
    for(j=0;j<m;j++)
    {
        cin>>x;
        if(j==0)
        {
            b[j]=x;  
        }
        else
        {
            b[j]=b[j-1]+x;
        }
    }
    ll mx=lower_bound(b,b+m,k)-b;
    if(binary_search(b,b+m,k))
        mx++;
    for(i=0;i<n;i++)
    {
        
        if(a[i]>k)
        {
            break;
        }
        
        if(b[0]<=k-a[i]){
            
        j=lower_bound(b,b+m,k-a[i])-b;
        if(binary_search(b,b+m,k-a[i]))
        j++;
        
        
        }
        else
        {
            j=0;
        }
        mx=max(mx,i+j+1);

    }
    cout<<mx;
       
    
    return 0;
}


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

using namespace std;

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

using ll = long long;

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

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

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	int len = v.size();
    cout << '[';
	for (int i = 0; i < len; ++i) {
		s << v[i]; if (i < len-1) s << ", ";
	}
    cout << ']';
	return s;
}




int main(){

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

    int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) {
		cin >> a[i];
		if(n%2 and a[i]%2 or !(n%2) and !(a[i]%2)){
			ppp(0);
			return 0;
		}
	}

	sort(a.begin(), a.end());
	for(int i = 0; i < n; ++i){
		if(n%2 and a[i] != i%2+i){
			ppp(0);
			return 0;
		}
		else if(!n%2 and a[i] != 2*i-((i+1)%2)){
			ppp(0);
			return 0;
		}
	}

	ppp(powMod(2, n/2, MOD));
    return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    string S;
    cin >> S;
    int ans = 0;
    int N = S.size();
    rep(i, N) {
        rep2(j, i, N) {
            string T = "";
            rep2(k, i, j + 1) {
                T += S[k];
            }
            bool ok = true;
            rep(k, T.size()) {
                if (T[k] == 'A' || T[k] == 'C' || T[k] == 'G' || T[k] == 'T') continue;
                ok = false;
            }
            if (ok) ans = max(ans, (int) T.size());
        }
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define mp make_pair
#define pb push_back
#define ld long double
#define pii pair<int,int>
#define sz(x) (int)x.size()
#define piii pair<pii,pii>
#define precise cout<<fixed<<setprecision(10)
#define st first
#define nd second
#define ins insert
#define vi vector<int>
#define BOOST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
void setIO(string name) {
    ios_base::sync_with_stdio(0); cin.tie(0);
    freopen((name+".in").c_str(),"r",stdin);
    freopen((name+".out").c_str(),"w",stdout);
}
int fastpow(int a,int b){
	int wynik=1;
	while (b){
		if (b&1)wynik=(wynik*a);
		a=(a*a);
		b>>=1;
	}
	return wynik;
}


int32_t main()
{
  BOOST;
  int n,m;
  cin>>n>>m;
	int ile=m*1900+(n-m)*100;
	ile*=fastpow(2,m);
	cout<<ile;
  return 0;
}


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

const int mod = 1000000007;


struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint fact(int n){
    if(n<=1) return 1;
    else return fact(n-1)*n;
}
mint combi(int n, int r){
    if(n<r) return 0;
    else return fact(n)/(fact(r)*fact(n-r));
}

int main(void){
    int N,K;
    cin >> N >> K;

    for(int i=1;i<=K;i++){
        int n = N-K+1;
        int r = i;
        mint a = combi(n,r);
        n = K-1;    r--;
        mint b = combi(n,r);
        cout << a*b << endl;
    }
    return 0;
}

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

int main() {
  int S,W;
  cin >> S >> W;
  
  if(W>=S){
    cout << "unsafe" << endl;
    return 0;
  }
  cout << "safe" << endl;
  
}

//cout << fixed << setprecision(10) << (long double)2*sum/(long double)N << endl;


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin>>n;
  int i=1,a,ans=0;
  while(n>=1){
  	a=n%10;
    if(a==1){ans+=9*i;}
    else if(a==9){ans+=i;}
    else{ans+=a*i;}
    n=n/10;
    i=i*10;
  }
  cout<<ans<<endl;
}

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

using namespace std;
using ll = long long;

using Field = vector<vector<int>>;
using Graph = vector<vector<int>>;
using VI = vector<int>;
using VC = vector<char>;
using PI = pair<int, int>;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(x) x.begin(), x.end()

const long long INF = 1LL<<60;
const int mod = 1000000007;

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; }

int N;
vector<int> A;

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

    cin >> N;
    A.resize(N, 0);
    REP(i, N - 1) {
        int x;
        cin >> x;
        x--;
        A.at(x)++;
    }

    for (auto x:A) {
        cout << x << endl;
    }
    
    return 0;
}

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

const int N = 1e5 + 6;
#define LL long long int

LL a[N], b[N], c[N];
int n;
LL dp[N][4];

LL solve(int idx, int prev)
{
	if(idx > n)return 0;
	
	LL &ret = dp[idx][prev];
	if(ret != -1)return ret;
	
	LL ans = 0;
	
	if(prev == 1)
	{
		ans = max(b[idx] + solve(1 + idx, 2), c[idx] + solve(idx + 1, 3));
	}
	else if(prev == 2)
	{
		ans = max(a[idx] + solve(idx + 1, 1), c[idx] + solve(idx + 1, 3));
	}
	else
	ans = max(a[idx] + solve(idx + 1, 1), b[idx] + solve(idx + 1, 2));
	
	return ret = ans;
}

int main()
{
	for(int i = 0; i < N; i++)for(int j = 0; j < 4; j++)dp[i][j] = -1;
	
	cin >> n;
	for(int i = 1; i <= n; i++)cin >> a[i] >> b[i] >> c[i];
	cout << max(a[1] + solve(2, 1), max(b[1] + solve(2, 2), c[1] + solve(2, 3)));
	
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define MAX(a, b) ((a) < (b) ? (b) : (a))

const long long INF = 1LL << 60;
typedef long long ll;
const long long MOD = 1000000000 + 7;

int main()
{
    int n;
    cin >> n;
    vector<pair<ll, ll>> v;
    ll a, b;
    rep(i, n)
    {
        cin >> a >> b;
        v.push_back({b, a});
    }
    ll time = 0;
    sort(v.begin(), v.end());
    rep(i, n)
    {
        time += v[i].second;
        if (time > v[i].first)
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 7440
import java.util.*;
import java.io.*;
import java.lang.*;

public 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 d = sc.nextInt();

        System.out.println(Math.min(a,b)+Math.min(c,d));
    }
}


Measured memory_bytes: 35608
#!/usr/bin/env python3
import sys


def solve(X: int, A: int, B: int):
    print((X-A)%B)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(X, A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <complex>
#include <vector>
#include <algorithm>
#include <cmath>
#include <array>
using namespace std;
const double EPS = 1e-10;
const double INF = 1e12;
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define X real()
#define Y imag()

typedef complex<double> P;
typedef vector<P> VP;
struct L : array<P, 2>{
    L(const P& a, const P& b){ at(0)=a; at(1)=b; }
    L(){}
};

namespace std{
    bool operator < (const P& a, const P& b){
        return !EQ(a.X,b.X) ? a.X<b.X : a.Y+EPS<b.Y;
    }
    bool operator == (const P& a, const P& b){
        return abs(a-b) < EPS;
    }
}

double dot(P a, P b){
    return (conj(a)*b).X;
}
double cross(P a, P b){
    return (conj(a)*b).Y;
}
int ccw(P a, P b, P c){
    b -= a;
    c -= a;
    if(cross(b,c) > EPS) return +1; //ccw
    if(cross(b,c) < -EPS) return -1; //cw
    if(dot(b,c) < -EPS) return +2; //c-a-b
    if(abs(c)-abs(b) > EPS) return -2; //a-b-c
    return 0; //a-c-b
}

P crosspointLL(const L &l, const L &m) {
  double A = cross(l[1]-l[0], m[1]-m[0]);
  double B = cross(l[1]-l[0], l[1]-m[0]);
  return m[0] + B/A *(m[1]-m[0]);
}
double getarea(const VP &poly){
    double ret = 0;
    for (int i=0; i<(int)poly.size(); i++){ 
        ret += cross(poly[i], poly[(i+1)%poly.size()]);
    }
    return ret*0.5;
}
VP convex_cut(const VP& p, const L& l){
    VP ret;
    int n = p.size();
    for(int i=0; i<n; i++){
        P curr = p[i];
        P next = p[(i+1)%n];
        if(ccw(l[0], l[1], curr) != -1) ret.push_back(curr);
        if(ccw(l[0], l[1], curr) *ccw(l[0], l[1], next) == -1){
            ret.push_back(crosspointLL(L(curr, next), l));
        }
    }
    return ret;
}


int main(){
    while(1){
        int n;
        cin >> n;
        if(n==0) break;

        double in;
        VP a(n+2),b(n+2),c(n+2),d(n+2);
        for(int i=1; i<=n; i++){ cin >> in; a[i] = P(in, 0); }
        for(int i=1; i<=n; i++){ cin >> in; b[i] = P(in, 1); }
        for(int i=1; i<=n; i++){ cin >> in; c[i] = P(0, in); }
        for(int i=1; i<=n; i++){ cin >> in; d[i] = P(1, in); }
        VP sq{P(0,0),P(1,0),P(1,1),P(0,1)};
        a[0] = c[0] = sq[0];
        a[n+1] = d[0] = sq[1];
        b[n+1] = d[n+1] = sq[2];
        b[0] = c[n+1] = sq[3];

        double ans = 0;
        for(int i=0; i<n+1; i++){
            for(int j=0; j<n+1; j++){
                L cut[4] = {L(b[i], a[i]), L(a[i+1], b[i+1]), L(c[j], d[j]), L(d[j+1], c[j+1])};
                VP poly = sq;
                for(int t=0; t<4; t++){
                    poly = convex_cut(poly, cut[t]);
                }
                ans = max(ans, getarea(poly));
            }
        }
        cout << fixed << setprecision(6);
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3296
#include <bits/stdc++.h>
using namespace std;
 
int main() {

int H,N,sum,i;
cin >> H >> N;
sum = 0;
int A[N];
for(i=0;i<N;i++)
	{
	cin >> A[i];
	sum = sum + A[i];
	if(sum >= H)
		break;
	}
if(sum >= H)
	cout << "Yes" << endl;
else
	cout << "No" << endl;

}

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

int main() {
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
  string S;
  cin>>S;
  int N=S.size();
  int INF =100000;
  int s,t=0;
  int p,q=0;
  int64_t m,n=0;
  int64_t answer=0;
  rep(i,N){
    if((S[i] == '>' && S[i+1] == '<' )|| (i == N-1)){
      t=i+1;
      for(int j=s; j<t;j++){
        if(S[j] == '<')
          p++;
        else if(S[j] == '>')
          q++;
      }
        n=max(p,q);
        m=min(p,q);
        answer+=n*(n+1)/2 + m*(m-1)/2;
      s=t;
      p=0;
      q=0;
    }
  }
  cout<<answer;
}

Measured memory_bytes: 900
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <limits.h>
#include <cmath>
#include <queue>
#include <map>
#include <iomanip>
#include <random>
#include <fstream>
#define rep(i, n) for (int i = 0; i < n; i++)
#define pi 3.14159265358979323846
using namespace std;
typedef long long ll;

ll gcd(ll a, ll b)
{
  ll r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}

int main()
{

  int ab, bc; cin >> ab >> bc;
  cout << ab * bc / 2 << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


def count(N):
    cnt = []
    r = 1
    while r < N:
        res = (N // (2 * r)) * r + max(N % (2 * r) - r, 0)
        cnt.append(res)
        r *= 2
    return cnt


def main():
    A, B = map(int, input().split())

    cnt_A = count(A)
    cnt_B = count(B + 1)

    cnt = [b for b in cnt_B]
    for i, a in enumerate(cnt_A):
        cnt[i] -= a

    res = 0
    for i, c in enumerate(cnt):
        if c % 2 != 0:
            res += 2 ** i

    print(res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38892
#include <iostream>
using namespace std;
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <math.h>
#include <string>
#include <cstdlib>
#include <fstream>

int main(){
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		char s;
		cin >> s;
		if(s=='Y'){
			cout << "Four" <<endl;
			return 0;
		}
	}
	cout << "Three" <<endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

public class Main {
    public static void main(String args[]) throws IOException {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String list[] = br.readLine().split(" ");
	Set<String> listSet = new HashSet<String>(Arrays.asList(list));

	if (listSet.size() == 2)
	    System.out.println("Yes");
	else
	    System.out.println("No");
    }
}

Measured memory_bytes: 23124
loop do
    e = gets.to_i
    break if e == 0
    m = Float::INFINITY
    for z in 0..100
        break if z**3 > e
        y = Math.sqrt((e-z**3)).floor
        x = e - y**2 - z**3
        m = x + y + z if x + y + z < m
    end
    puts m
end

Measured memory_bytes: 6124
import os
import heapq
import sys,threading
import math
import bisect
import operator
from collections import defaultdict
sys.setrecursionlimit(10**5)
from io import BytesIO, IOBase
def gcd(a,b):
    if b==0:

        return a
    else:
        return gcd(b,a%b)
def power(x, p,m):
    res = 1
    while p:
        if p & 1:
            res = (res * x) % m
        x = (x * x) % m
        p >>= 1
    return res
def inar():
    return [int(k) for k in input().split()]

def lcm(num1,num2):
    return (num1*num2)//gcd(num1,num2)

def main():
    a,b,c,d=inar()
    print(max(a*c,b*d,a*d,b*c))


BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == "__main__":
    main()
    #threadin.Thread(target=main).start()


Measured memory_bytes: 68700
#include<stdio.h>
int main(void)
{
	int a,n,i,min=1000000,max=-1000000;
	long int sum=0;

	scanf("%d",&n);
	   for(i=0;i<n;i++){
	    scanf("%d",&a);
	    sum+=a;

	   if(min>a) min=a;
	   if(max<a) max=a; } 
	printf("%d %d %ld\n",min,max,sum);

	return 0;
}


Measured memory_bytes: 2136
import java.util.Scanner;
import java.util.Set;
import java.util.stream.Collectors;


public class Main {
	
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int h = s.nextInt();
		int w = s.nextInt();
		s.nextLine();
		int n = s.nextInt();
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
			arr[i] = s.nextInt();
		}
		int x = 0, y = 0;
		int turn = 0;
		int[][] move = {{1, 0}, {-1, 0}};
		int[][] d = new int[h][w];
		
		for (int i = 0; i < n; i++) {
			while (arr[i] != 0) {
				
				arr[i]--;
				d[x][y] = i + 1;
				x += move[turn % 2][0];
				y += move[turn % 2][1];
				if (x < 0 || y < 0 || x == h || y == w) {
					turn++;
					y++;
					x += move[turn % 2][0];
					y += move[turn % 2][1];
				}
				
			}
		}
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if(j==0)
				System.out.print(d[i][j]);
				else System.out.print(" "+d[i][j]);
			}
			System.out.println();
		}
		
		
	}
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int s;
  cin>>s;
  vector<int>S(4);
  for(int i=0;i<4;i++){
    S[i]=s%10;
    s/=10;
  }
  reverse(rng(S));
  int one=S[0]*10+S[1];
  int two=S[2]*10+S[3];
  bool YYMM=false;
  bool MMYY=false;
  if(1<=one&&one<=12)MMYY=true;
  if(1<=two&&two<=12)YYMM=true;
  if(YYMM&&MMYY)cout<<"AMBIGUOUS"<<endl;
  else if(YYMM&&!MMYY)cout<<"YYMM"<<endl;
  else if(!YYMM&&MMYY)cout<<"MMYY"<<endl;
  else cout<<"NA"<<endl;
  return 0;
}


Measured memory_bytes: 256
# ALDS1_3_C
import sys
class Cell():
    def __init__(self, x):
        self.key = x
        self.prev = None
        self.next = None


class DoubleLinkedList():
    def __init__(self):
        self.head = None
        self.tail = None

    def insert(self, x):
        new = Cell(x)
        tmp = self.head

        if tmp is None:
            new.next = None
            self.tail = new

        else:
            new.next = tmp
            tmp.prev = new

        self.head = new
        new.prev = None
        return

    def delete(self, x):

        if (self.head is None) & (self.tail is None):
            return

        tmp = self.head

        while tmp.key != x:
            tmp = tmp.next
            if tmp is None:  # 一番後ろまで要素　xが存在しなかったら
                return

        if self.head is self.tail:
            self.head = None
            self.tail = None
        elif tmp is self.head:
            tmp.next.prev = None
            self.head = tmp.next
        elif tmp is self.tail:
            tmp.prev.next = None
            self.tail = tmp.prev
        else:
            tmp.prev.next = tmp.next
            tmp.next.prev = tmp.prev
        return

    def deleteFirst(self):
        if self.head:
            self.head = self.head.next

        if self.head:
            self.head.prev = None
        else:
            self.tail = None
        return

    def deleteLast(self):
        if self.tail:
            self.tail = self.tail.prev

        if self.tail:
            self.tail.next = None
        else:
            self.head = None
        return

    def show(self):
        tmp = self.head

        while tmp:
            print(tmp.key, end='')
            if tmp.next:
                print(' ', end='')
            tmp = tmp.next
        else:
            print('')
        return

    def shown(self):
        tmp = self.head
        keys = []
        while tmp:
            keys.append(tmp.key)
            tmp = tmp.next
        keys = ' '.join(keys)
        print(keys)
        return

def main():
    l = DoubleLinkedList()

    N = int(sys.stdin.readline())

    for i in range(N):
        comand = sys.stdin.readline().strip()

        if comand == 'deleteFirst':
            l.deleteFirst()
        elif comand == 'deleteLast':
            l.deleteLast()
        else:
            comand, number = comand.split()
            if comand == 'insert':
                l.insert(number)
            else:
                l.delete(number)

    l.show()


if __name__ == '__main__':
    main()


Measured memory_bytes: 227580
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    unsigned long long mons = 0;
    cin >> N;
    vector<int> A(N + 1), B(N);
    for (int i = 0; i < N + 1; i++)
    {
        cin >> A[i];
    }
    for (int i = 0; i < N; i++)
    {
        cin >> B[i];
    }

    for (int i = N - 1; i >= 0; i--)
    {
        if (B[i] >= A[i + 1])
        {
            B[i] -= A[i + 1];
            mons += A[i + 1];
            A[i + 1] = 0;

            if (B[i] >= A[i])
            {
                B[i] -= A[i];
                mons += A[i];
                A[i] = 0;
            }
            else
            {
                mons += B[i];
                A[i] -= B[i];
                B[i] = 0;
            }
        }
        else
        {
            mons += B[i];
            A[i + 1] -= B[i];
            B[i] = 0;
        }
    }
    cout << mons << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#include<cmath>
#include<queue>
#include<stack>

#include<stdio.h>
#include<stdlib.h>

#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
#define chmax(a,b) {if(a < b) a = b;}
#define chmin(a,b) {if(a > b) a = b;}

using namespace std;
typedef long long ll;
ll gcd(ll, ll);
vector<bool> to_binary(int);
ll nCr(ll n, ll r);

const ll INF = 1LL << 60;

typedef tuple<ll, ll> mtupl;

bool mycomp(mtupl x, mtupl y) {
	return get<1>(x) < get<1>(y);
}

int vsum(vector<int> v) {
	int res = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		res += *it;
	return res;
}

int vmin(vector<int> v) {
	int min = INT32_MAX;
	for (auto it = v.begin(); it != v.end(); it++)
		min = std::min(min, *it);
	return min;
}

int vmax(vector<int> v) {
	int max = INT32_MIN;
	for (auto it = v.begin(); it != v.end(); it++)
		max = std::max(max, *it);
	return max;
}

ll gcd(ll A, ll B) {
	if (A == 0 || B == 0) return max(A, B);
	int r = A % B;
	while (r != 0) {
		A = B;
		B = r;
		r = A % B;
	}
	return B;
}

vector<ll> prime_factor(int64_t n) {
	//map< ll, ll > ret;
	vector<ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			//ret[i]++;
			ret.push_back(i);
			n /= i;
		}
	}
	if (n != 1)ret.push_back(n);// ret[n] = 1;
	return ret;
}

const int MAX = 1000000;
const int MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
ll COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

struct edge {
	ll to;
	ll cost;
};

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//Program Start	

	int A, B;
	cin >> A >> B;

	int i;
	for (i = 0;; i++) {
		if (1 + (A - 1) * i >= B) break;
	}

	cout << i << endl;

ProgramEndPointLabel:;

	//Program End
#ifndef DEBUG
	system("pause");
#endif // !DEBUG


	return 0;
}




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

struct StNode
{
  StNode* m_poParnt;
  StNode* m_poLeft;
  StNode* m_poRigt;
  int m_nKey;

  StNode(int nNo) :
    m_poParnt(nullptr), m_poLeft(nullptr), m_poRigt(nullptr), m_nKey(nNo)
  { }
};

void fnInsert(StNode*& rpoRoot, StNode* poNewMe)
{
  StNode*  poParnt = nullptr;
  StNode** ppoNode = &rpoRoot;

  while (*ppoNode)
  {
    poParnt = *ppoNode;
    if (poNewMe->m_nKey < poParnt->m_nKey)
      ppoNode = &poParnt->m_poLeft;
    else
      ppoNode = &poParnt->m_poRigt;
  }

  poNewMe->m_poParnt = poParnt;
  *ppoNode = poNewMe;
}

StNode* fnFind(StNode* poRoot, int nNo)
{
  StNode* poNode = poRoot;
  while (poNode)
    if (nNo == poNode->m_nKey)
      return poNode;
    else if (nNo < poNode->m_nKey)
      poNode = poNode->m_poLeft;
    else
      poNode = poNode->m_poRigt;

  return nullptr;
}

void fnDelete(StNode*& rpoRoot, StNode* poDelMe)
{
  StNode** ppoPrToMe;
  if (poDelMe == rpoRoot)
    ppoPrToMe = &rpoRoot;
  else
    if (poDelMe->m_nKey < poDelMe->m_poParnt->m_nKey)
      ppoPrToMe = &poDelMe->m_poParnt->m_poLeft;
    else
      ppoPrToMe = &poDelMe->m_poParnt->m_poRigt;

  int nDegr = 0;
  StNode* poMeToCd;
  if (poDelMe->m_poLeft)
  {
    ++nDegr;
    poMeToCd = poDelMe->m_poLeft;
  }
  if (poDelMe->m_poRigt)
  {
    ++nDegr;
    poMeToCd = poDelMe->m_poRigt;
  }

  if (!nDegr)
  {
    *ppoPrToMe = nullptr;
    delete poDelMe;
  }
  else if (nDegr == 1)
  {
    *ppoPrToMe = poMeToCd;
    poMeToCd->m_poParnt = poDelMe->m_poParnt; 
    delete poDelMe;
  }
  else if (nDegr == 2)
  {
    StNode* poNext = poDelMe->m_poRigt;
    while (poNext->m_poLeft)
      poNext = poNext->m_poLeft;

    poDelMe->m_nKey = poNext->m_nKey;
    fnDelete(rpoRoot, poNext);
  }
}

void fnInOrder(StNode* poNode)
{
  if (!poNode)  return;

  fnInOrder(poNode->m_poLeft);
  cout << " " << poNode->m_nKey;
  fnInOrder(poNode->m_poRigt);
}

void fnPreOrder(StNode* poNode)
{
  if (!poNode)  return;

  cout << " " << poNode->m_nKey;
  fnPreOrder(poNode->m_poLeft);
  fnPreOrder(poNode->m_poRigt);
}

void fnBinSchTree(StNode*& rpoRoot)
{
  int nMaxSiz;
  cin >> nMaxSiz;

  for (int i = 0; i < nMaxSiz; ++i)
  {
    string sCmd;
    cin >> sCmd;
    if (sCmd[0] == 'i')
    {
      int nNo;
      cin >> nNo;
      StNode* poNewMe = new StNode(nNo);
      fnInsert(rpoRoot, poNewMe);
    }
    else if (sCmd[0] == 'f')
    {
      int nNo;
      cin >> nNo;
      if (fnFind(rpoRoot, nNo))
        cout << "yes" << endl;
      else
        cout << "no" << endl;
    }
    else if (sCmd[0] == 'd')
    {
      int nNo;
      cin >> nNo;
      StNode* poDelMe;
      if (poDelMe = fnFind(rpoRoot, nNo))
        fnDelete(rpoRoot, poDelMe);
      else;
    }
    else if (sCmd[0] == 'p')
    {
      fnInOrder(rpoRoot);
      cout << endl;
      fnPreOrder(rpoRoot);
      cout << endl;
    }
    else;
  }
}

void fnPstOrder(StNode* poNode)
{
  if (!poNode)  return;

  fnPstOrder(poNode->m_poLeft);
  fnPstOrder(poNode->m_poRigt);
  delete poNode;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  StNode* poRoot = nullptr;

  fnBinSchTree(poRoot);
  fnPstOrder(poRoot);
  return 0;
}

Measured memory_bytes: 21884
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>

using namespace std;


int main(){
    int n;
    cin >> n;
    int d[n];
    for (int i=0;i<n;i++) d[i]=i+1;
    int p[n],q[n];
    for (int i=0;i<n;i++) cin >> p[i];
    for (int i=0;i<n;i++) cin >> q[i];
    int pa,qa;
    
    int pamute=0;
    do{
        pamute++;
        int ps=1;
        int qs=1;
        //一致判定
        for(int i=0;i<n;i++){
            if(d[i]!=p[i]) ps=0;
            if(d[i]!=q[i]) qs=0;
        }
        if(ps) pa=pamute;
        if(qs) qa=pamute;
        
    }while(next_permutation(d, d+n));
           
           cout << abs(pa-qa) << endl;
}





Measured memory_bytes: 256
import sys

k, n = map(int, sys.stdin.readline().split())
a = list(map(int, sys.stdin.readline().split()))
a.sort()

max_len = 0
total = 0
for i in range(n):
    if a[i] < a[i-1]:
        l = a[i] + k - a[i-1]
    else:
        l = a[i] - a[i-1]
    max_len = max(max_len, l)
    total += l

print(total-max_len)


Measured memory_bytes: 72012
import java.util.*;

public class Main {
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner sc = new Scanner(System.in);
        List<Integer> list = new ArrayList<>();
        int N = sc.nextInt();
        for (int i = 0; i < N; i++) {
            list.add(sc.nextInt());
        }
        Collections.sort(list);

        int sum = 0;
        for (int i : list) {
            sum += i;
        }
        if(sum % 10 != 0){
            System.out.println(sum);
            return ;
        }
        int tmp = sum;
        for (int i : list) {
            if (sum % 10 == 0 && i%10!=0) {
                sum -= i;
            } 
        }
        if(tmp == sum)
            sum = 0;
        System.out.println(sum);

    }

}


Measured memory_bytes: 21844
using System;
using System.Text.RegularExpressions;
class Program
{
    static void Main(string[] args)
    {
        int tmpnum = 0;
        int Savernum = Convert.ToInt32(Console.ReadLine());
        Double[] CityMonster = new Double[Savernum + 1];
        Double destroy = 0;
        foreach (string x in Regex.Split(Console.ReadLine(), @"\s+"))
        {
            CityMonster[tmpnum] = Convert.ToDouble(x);
            tmpnum += 1;
        }
        tmpnum = 0;
        foreach (string x in Regex.Split(Console.ReadLine(), @"\s+"))
        {
            destroyMons(ref destroy, ref CityMonster, Convert.ToDouble(x), tmpnum);
            tmpnum += 1;
        }
        Console.WriteLine(destroy);
    }
    public static void destroyMons(ref Double destroy,ref Double[] CityMonster,Double saver,int num)
    {
        Double sum = CityMonster[num] + CityMonster[num + 1];
        if (saver > sum)
        {
            destroy += sum;
            CityMonster[num] = 0;
            CityMonster[num + 1] = 0;
        }
        else
        {
            destroy += saver;
            Double tmpnum = CityMonster[num] - saver;
            if (tmpnum < 0)
            {
                CityMonster[num] = 0;
                CityMonster[num + 1] += tmpnum;
            }
            else
            {
                CityMonster[num] = tmpnum;
            }
        }
    }
}

Measured memory_bytes: 37816