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

using namespace std;

typedef long long ll;

ll t[888888];
ll n;
vector<ll> a;

void build (ll v, ll tl, ll tr) {
    if (tl == tr) {
        t[v] = a[tl];
        return;
    }

    ll tm = (tl + tr) / 2;
    build(v * 2, tl, tm);
    build(v * 2 + 1, tm + 1, tr);

    t[v] = min(t[v * 2], t[v * 2 + 1]);
}

ll getMin(ll v, ll tl, ll tr, ll l, ll r) {
    if (l > r)
        return INT_MAX;

    if (tl == l && tr == r) {
        return t[v];
    }

    ll tm = (tl + tr) / 2;

    ll ans1 = INT_MAX, ans2 = INT_MAX;
    if (l <= min(r, tm))
        ans1 = getMin(v * 2, tl, tm, l, min(r, tm));
    if (max(l, tm + 1) <= r)
        ans2 = getMin(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r);

    return min(ans1, ans2);
}

ll find_min_pos (ll x, ll pos) {
    ll l = pos, r = n + 1;
    while (r - l > 1) {
        ll m = (l + r) / 2;
        ll mn = getMin(1, 1, n, pos, m);
        if (mn >= x) {
            l = m;
        }
        else {
            r = m;
        }
    }

    return l + 1;
}


int main () {
    //freopen("input.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin >> n;

    a.resize(n + 1);
    for (ll i = 1; i <= n; ++i) {
        cin >> a[i];
    }

    build(1, 1, n);

    vector<ll> ans(n + 2);
    set<pair<ll,ll>>numbers;

    ans[n] = a[n];
//    numbers.insert(make_pair(a[n - 1], n - 1));

    for (ll i = n - 1; i > 0; --i) {
        ll pos = n;
//        auto it = numbers.lower_bound(make_pair(a[i], i));
//        if (it != numbers.begin())
//            pos = (--it)->second;
//
        pos = find_min_pos(a[i], i);

        ans[i] = a[i] * (pos - i) + ans[pos];
//        add_number(make_pair(a[i], i));
    }

    ll answer = 0;
    for (ll i = 1; i <= n; ++i) {
        answer += ans[i];
    }

    cout << answer;
    return 0;
}


Measured memory_bytes: 7424
#include <stdio.h>

int main(){
    int K,A,B;
    scanf("%d",&K);
    scanf("%d %d",&A,&B);
    if(A/K==B/K){
        if(A%K==0||B%K==0) printf("OK\n");
        else printf("NG\n");
    }else printf("OK\n");
    return 0;
}

Measured memory_bytes: 1644
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n;
    cin>>n;
    long long int freq[n+1];
    fill(freq,freq+n+1,0);
    long long int arr[n];
    for(long long int i=0;i<n;i++)
    {
        cin>>arr[i];
        freq[arr[i]]++;
    }
    long long int sum=0;
    for(long long int i=0;i<n+1;i++)
    {
        sum=sum+(freq[i]*(freq[i]-1))/2;
    }
    long long int ans;
    for(long long int i=0;i<n;i++)
    {
        if(freq[arr[i]]==1)
        {
            cout<<sum<<endl;
        }
        else 
        {
            ans=sum-(freq[arr[i]]*(freq[arr[i]]-1))/2+((freq[arr[i]]-1)*(freq[arr[i]]-2))/2;
            cout<<ans<<endl;
        }
    }
}

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

int main () {
	int k, cnt = 0;
	cin >> k;

	for (int i = 1; i <= k; i++) {
		for (int j = 1; j <= k; j++) {
			if (i % 2 == 0 && j % 2 == 1) cnt++;
		}
	}

	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <cmath>
#include <cassert>
#include <cstdio>

// #include <unordered_set>
// #include <unordered_map>

#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())

#define pb push_back
#define mp make_pair

int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}

typedef std::pair<int, int> P;
typedef long long ll;
typedef long double ld;

const int MOD = 1000000007;
const int INF = 1e9;
const ll LINF = INF * 1ll * INF;
const ld DINF = 1e200;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

using namespace std;

// #define int long long

signed main(){
  

    ios::sync_with_stdio(false);
    cin.tie(0);
	//cin高速化

	string a,b;
	cin>>a>>b;

	if(a>b){
		cout<<">"<<endl;
	}else if(a<b){
		cout<<"<"<<endl;
	}else{
		cout<<"="<<endl;
	}
  
 	return 0;

}

Measured memory_bytes: 256
while True:
    x = input().split()
    
    a = int(x[0])
    b = int(x[2])
    op = x[1]
    
    if (op == "?"):
        break
    
    if (op == "+"):
        print(a + b)
    elif(op == "-"):
        print(a - b)
    elif(op == "*"):
        print(a * b)
    elif(op == "/"):
        print(a // b)


Measured memory_bytes: 5592
#include<bits/stdc++.h>
 #define N (2009)
 #define K (10009)
 #define S (1000009)
 using namespace std;
 
 int n,k,cnt,len[N];
 char s[N][K];
 bitset<K>f[N];
 pair<int,int>v[2][K];
 
 int main()
 {
     cin>>n>>k;
     for (int i=1; i<=n; ++i)
         cin>>s[i], len[i]=strlen(s[i]);
     f[n+1][0]=1;
     for (int i=n; i>=1; --i)
         f[i]=f[i+1]|(f[i+1]<<len[i]);
     for (int i=1; i<=n; ++i)
         if (f[i+1][k-len[i]])
             v[0][++cnt]=make_pair(i,0);
     for (int i=1; i<=k; ++i)
     {
         char Min='z'; int ncnt=0;
         for (int j=1; j<=cnt; ++j)
             Min=min(Min,s[v[i-1&1][j].first][v[i-1&1][j].second]);
         putchar(Min);
         int ID=n+1;
         for (int j=1; j<=cnt; ++j)
         {
             int id=v[i-1&1][j].first,pos=v[i-1&1][j].second;
             if (s[id][pos]!=Min) continue;
             if (pos<len[id]-1) v[i&1][++ncnt]=make_pair(id,pos+1);
             else ID=min(ID,id);
         }
         for (int j=ID+1; j<=n; ++j)
             if (k-i-len[j]>=0 && f[j+1][k-i-len[j]])
                 v[i&1][++ncnt]=make_pair(j,0);
         cnt=ncnt;
     }
}

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

int main() {
  int n;
  cin >> n;
  vi a(n);
  int ans=0;
  rep(i,n) cin >> a[i];
  for(int i=0; i<n; i+=2){
    if(a[i]%2 == 1) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3592
import java.io.BufferedReader;
import java.io.InputStreamReader;
 
public class Main {
 
    public static void main(String[] args) throws Exception {
        // TODO ?????????????????????????????????????????????
         
        boolean first=true;
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            int i=0;
            while ((line = br.readLine()) != null) {
                double r=Double.parseDouble(line);
                System.out.println(String.format("%.6f",r*r*Math.PI)+" "+String.format("%.6f",2*r*Math.PI));
                 
                break;
            }
        }
    }
}



 

Measured memory_bytes: 24772
#include<bits/stdc++.h>
#define PI acos(-1.0)
#define eps 1e-67
#define pf printf
#define sf scanf
#define sd(n) scanf("%d",&n)
#define sd2(n1,n2) scanf("%d %d",&n1,&n2)
#define slf(n) scanf("%lf",&n)
#define slf2(n1,n2) scanf("%lf %lf",&n1,&n2)
#define sLf(n1) scanf("%Lf",&n1)
#define sLf2(n1,n2) scanf("%Lf %Lf",&n1,&n2)
#define sl(n) scanf("%lld",&n)
#define sl2(n1,n2) scanf("%lld %lld",&n1,&n2)
#define rep(i,a,b) for( i=a;i<b;i++)
#define repb(i,a,b) for( i=a;i>=b;i--)
#define repa(i,a,b,c) for( i=a;i<b;i=i+c)
#define reps(i,a,b,c) for(i=a;i>b;i=i-c)
#define asort(a) sort(a.begin(),a.end())
#define asortb(a,comp) sort(a.begin(),a.end(),comp)
#define arev(a) reverse(a.begin(),a.end())
#define all(v) (v).begin(),(v).end()
#define allc(v,comp) (v).begin(),(v).end(),comp
#define allrc(v,a,b,comp) (v).begin()+a,(v).end()-b,comp
#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define pbb pop_back
#define mp make_pair
#define mt make_tuple
#define sq(a) ((a)*(a))
#define cube(a) ((a)*(a)*(a))
#define mx 1000
#define MX 100000
#define mod 1000000007
using namespace std;
typedef string str;
typedef long long int ll;
typedef double lf;
typedef long double llf;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef char ch;
typedef map<ll,ll> mp;
void Solve()
{
    ll n,m,h,a,b,i,j,k,l;
    ll c=0,mmm=0;
    cin>>n>>m;
    vll v(n+1);
    vpll v2[n+1];
    rep(i,0,n)
    {
        cin>>h;
        v[i+1]=h;
    }

    rep(i,0,m)
    {
        cin>>a>>b;
        pll p;
         p.F=a;
         p.S=v[a];
         v2[b].pb(p);
         p.F=b;
         p.S=v[b];
         v2[a].pb(p);
    }
    rep(i,1,n+1)
    {
        if(v2[i].size()==0)
        {
            c++;
        }
        else {
        rep(j,0,v2[i].size())
        {
           if(v[i]>v2[i][j].S)
           {
               mmm++;
           }

        }
        if(mmm==v2[i].size())
        {
            c++;
        }
        }
        mmm=0;
    }
    cout<<c<<"\n";
}
int main()
{
    Solve();
    return 0;
}

Measured memory_bytes: 11692
#include <stdio.h>

int main(void)
{
	int a1count=0,a2count=0,a4count=0;
	int i,N,x;
	scanf("%d",&N);
	while(N--)
	{
		scanf("%d",&x);
		if(x%4==0)
			a4count++;
		else if(x%2==0)
			a2count++;
		else
			a1count++;
	}
	if(a2count>0 && a1count<=a4count)
		printf("Yes\n");
	else if(a2count==0 && a1count<=a4count+1)
		printf("Yes\n");
	else
		printf("No\n");

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
using namespace std;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;

inline int read()
{
	int X=0; bool flag=1; char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') flag=0; ch=getchar();}
	while(ch>='0'&&ch<='9') {X=(X<<1)+(X<<3)+ch-'0'; ch=getchar();}
	if(flag) return X;
	return ~(X-1);
}

int n;
int a[N];

int main() {
    //ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	n=read();
	for(int i=1;i<=n;++i){
		a[i]=read();
	}
	ll sum=0;
	for(int i=2;i<=n;++i){
		if(a[i]<a[i-1]){
			sum+=a[i-1]-a[i];
			a[i]+=a[i-1]-a[i];
		}
	}	

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

    return 0;
}

Measured memory_bytes: 4556
var
    a,b,c,i,j,z:longint;
    s:array[1..10000]of string;//仅用来判断位数
    k:array[1..10000]of longint;//记录数字（10^4=10000）
    ans:qword;//要开大点，如果是1+……+10000用int64会爆
begin
    read(a,b,c);
    for i:=1 to a do
    begin
        str(i,s[i]);//把数字转为字符串
        for j:=1 to length(s[i]) do//判断位数
        begin
            val(s[i][j],z);//一个个数字枚举
            k[i]:=k[i]+z;//把每一位数加起来
        end;
        if(k[i]>=b)and(k[i]<=c)then inc(ans,i);//判断
    end;
    writeln(ans);//输出
end.

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int N;
    int A,B;
    int p;
    int ans[3] = {};

    Scd3(N,A,B);
    Rep(i,N){
        Scd(p);
        if( p <= A ) ans[0]++;
        else if( p <= B ) ans[1]++;
        else ans[2]++;
    }

    printf ("%d\n", min( ans[0], min( ans[1] , ans[2] )));

    return 0;
}



Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000)
n,m = map(int,input().split())
a = [0]*m
b = [0]*m
for i in range(m):
  u,v = map(int, input().split())
  a[i] = u-1
  b[i] = v-1
par = [i for i in range(n)]
size = [1]*n
incomb = [n*(n-1)//2]*m

def root(x):
  if par[x] == x: 
    return x
  else:
    par[x] = root(par[x])
    return par[x]
    
def isSame(x,y):
  return par[x] == par[y]

def union(x,y):
  x = root(x)
  y = root(y)
  if x == y:
    return
  else:
    par[y] = x
    size[x] += size[y]
    
def size_count(x):
  return size[root(x)]

for i in reversed(range(1,m)):
  q_a = a[i]
  q_b = b[i]
  size_a = size_count(q_a)
  size_b = size_count(q_b)
  if not isSame(q_a,q_b):
    union(q_a,q_b)
    incomb[i-1] = incomb[i] - size_a*size_b
  else:
    incomb[i-1] = incomb[i]

for i in incomb:
  print(i)

Measured memory_bytes: 32176
N = int(input())
A = list(map(int, input().strip().split()))

Budget = 1000
Bond = 0

for n in range(len(A)-1):
  if A[n] < A[n+1]:
    Bond = Budget//A[n]
    Budget = (Budget - Bond*A[n]) + Bond*A[n+1]
    
print(Budget)

Measured memory_bytes: 9188
#include <iostream>

using namespace std;

int main(){
    int A,B,Max;

    cin >> A >>B;
    Max=A+B;
    if(A-B >Max){
        Max= A-B;
    }
    if(A*B >Max){
        Max= A*B;
    }

    cout <<Max;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#define rep(i,n) for(int i=0;i<(n); ++i)
using namespace std;
typedef long long ll;


int main()
{
	ll a;
	string s;
	cin >> a >> s;
	cout << (a < 3200 ? "red" : s) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;


const int MAX_N = 1000010;
// cnt[i][0]->a_iの0の数
// cnt[i][1]->a_iの1の数
int cnt[60][2];
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	VE a(n); rep(i, n)cin >> a[i];
	rep(i, n) {
		rep(j, 60) {
			// bit演算
			// ビットa[i]にj番目のフラグが立っているかどうか
			cnt[j][(bool)(a[i] & (1LL << j))]++;
		}
	}
	int ans = 0;
	repr(i, 59) {
		ans = (ans * 2) % MOD;
		ans += cnt[i][0] * cnt[i][1] % MOD;
	}
	cout << ans % MOD << endl;
	return 0;
}


Measured memory_bytes: 2560
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def solve(S):
    dp = [0] * 2019
    pow10 = 1
    answer = 0
    for x in S[::-1]:
        dp[0] += 1
        x = x * pow10 % 2019
        newdp = [0] * 2019
        for i in range(2019-x):
            newdp[x+i] += dp[i]
        for i in range(x):
            newdp[i] += dp[2019-x+i]
        answer += newdp[0]
        pow10 *= 10
        pow10 %= 2019
        dp = newdp
    return answer


S = [x - ord('0') for x in read().rstrip()]
print(solve(S))


Measured memory_bytes: 83952
import math
n=int(input())
dp=[0]*(n+2)
sq=int(math.sqrt(n))
for x in range(1,sq+1):
    for y in range(1,sq+1):
        for z in range(1,sq+1):
            aa=(x*x+y*y+z*z+x*y+y*z+z*x)
            if aa<=n:
                dp[aa]+=1
for i in range(1,n+1):
    print(dp[i])

Measured memory_bytes: 9224
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
using namespace std;

int main() {
	int N; cin >> N;
	vector<long long> A(N + 1);
	vector<long long> B(N);

	for (int i = 0; i < N + 1; i++) {
		cin >> A.at(i);
	}
	for (int i = 0; i < N; i++) {
		cin >> B.at(i);
	}
	long long res = 0;
	for (int i = 0; i < N; i++) {
		if (A.at(i) >= B.at(i)) {
			res = res + B.at(i);
			A.at(i) = A.at(i) - B.at(i);
			B.at(i) = 0;
		}
		else {
			res = res + A.at(i);
			B.at(i) = B.at(i) - A.at(i);
			A.at(i) = 0;
		}

		if (A.at(i  + 1) >= B.at(i)) {
			res = res + B.at(i);
			A.at(i + 1) = A.at(i + 1) - B.at(i);
			B.at(i) = 0;
			
		}
		else {
			res = res + A.at(i + 1);
			B.at(i) = B.at(i) - A.at(i + 1);
			A.at(i + 1) = 0;
		}
	}

	cout << res << endl;
}

Measured memory_bytes: 1792
/*
    Life Before Death, Strength Before Weakness, Journey Before Destination
    ------------------------------------------------------------------------
    You don't become great by trying to be great.
    You become great by wanting to do something,
    and then doing it so hard that you become great in the process.
    */
 
    //#pragma comment(linker, ack:200000000")
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #include <bits/stdc++.h>
    using namespace std;
    
    #define TRACE
    
    #ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
      cerr << name << " : " << arg1 << std::endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
      const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
    #else
    #define trace(...)
    #endif
    
    #define rep(i, n)    for(ll i = 0; i < (n); ++i)
    #define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
    #define repD(i, a, n)  for(ll i = a; i >= (n); --i)
    #define trav(a, x) for(auto& a : x)
    #define all(x) x.begin(), x.end()
    #define sz(x) (int)(x).size()
    #define fill(a)  memset(a, 0, sizeof (a))
    #define fst first
    #define snd second
    //#define mp make_pair
    #define pb push_back
    #define PI           3.141592653589793238462643383279502884197169399  /* pi */
    #define te  ll ti;   cin >> ti;  while(ti--) solve();  
    typedef long double ld;
    typedef long long ll;
    typedef unsigned long long ull;
    typedef pair<ll, ll> pii;
    typedef vector<ll> vi;
    const int maxN = 200100;

    void solve(){
        ll a, b, val, cnt = 0;
        cin >> a >> b;
        val = 1;
        while(val < b){
            cnt++;
            val += (a-1);
        }
        cout << cnt << endl;
    }
 
    int main() {
      cin.sync_with_stdio(0); cin.tie(0);
      cin.exceptions(cin.failbit);
     /*
      #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
      #endif
     */
      //te
      solve();
      return 0;
    } 


Measured memory_bytes: 256
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define ms(a,b) memset(a,b,sizeof(a))
#define msn(a,n,b) for(int i=0;i<=n;i++)a[i]=b
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define fi first
#define se second
using namespace std;
mt19937 rng_32(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef double db;
const int mod=1e9+7;
const int seed=233;
const double PI=acos(-1.0);
const double eps=1e-7;
const int inf=0x3f3f3f3f;
const int max_n=100005;
ll ceil(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?(x+y-1)/y:-x/y;}
ll floor(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?x/y:-(x+y-1)/y;}
namespace {
    inline int Add(int x,int y){return (x+=y)>=mod?x-mod:x;}
    inline int Sub(int x,int y){return (x-=y)<0?x+mod:x;}
    inline int Mul(int x,int y) {return 1ll*x*y%mod;}
    inline int Pow(int x,int y=mod-2){if(y==0)return 1;int res=1;while(y){if(y&1)res=1ll*res*x%mod;x=1ll*x*x%mod;y>>=1;}return res;}
}
/**********************head************************/
int x,y,z;
int main(){
    scanf("%d%d%d",&x,&y,&z);
    printf("%d %d %d\n",z,x,y);
    return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc084/tasks/abc084_b

#include <bits/stdc++.h>
using namespace std;

bool is_digit(int d)
{
    return 0 <= d & d < 10;
}

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

    for (int i = 0; i < a; i++)
    {
        if (not is_digit(s[i] - '0'))
        {
            cout << "No" << endl;
            return 0;
        }
    }

    if (s[a] != '-')
    {
        cout << "No" << endl;
        return 0;
    }

    for (int i = a + 1; i < a + b + 1; i++)
    {
        if (not is_digit(s[i] - '0'))
        {
            cout << "No" << endl;
            return 0;
        }
    }

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


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  vector<long> A(N), B(N), C(N);
  for(int i = 0; i < N; i++)cin >> A.at(i);
  for(int i = 0; i < N; i++)cin >> B.at(i);
  for(int i = 0; i < N; i++)cin >> C.at(i);
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  sort(C.begin(), C.end());
  long counta = 0, countc = 0, ans = 0;
  for(int i = 0; i < N; i++){
    for(int j = counta; j < N; j++){
      if(A.at(counta) < B.at(i))counta++;
      else break;
    }
    for(int j = countc; j < N; j++){
      if(C.at(countc) <= B.at(i))countc++;
      else break;
    }
    ans += counta * (N - countc);
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

struct pot {
    int a, b, c, d;
};

vector<vector<int>> arr;

int n, m, q;

void generate(int pos, vector<int> v, int last) {
    if (pos == n) {
        arr.push_back(v);
        return;
    }
    for (int i = last; i <= m; i++) {
        v.push_back(i);
        generate(pos + 1, v, i);
        v.pop_back();
    }
}

void solve() {
    cin >> n >> m >> q;

    vector<pot> v(q);
    for (int i = 0; i < q; i++)
        cin >> v[i].a >> v[i].b >> v[i].c >> v[i].d;

    vector<int> tp;
    int ans = 0;
    generate(0, tp, 1);
    for (auto &x : arr) {
        int pans = 0;
        for (auto &j : v) {
            if (x[j.b - 1] - x[j.a - 1] == j.c)pans += j.d;
        }
        ans = max(ans, pans);
    }
    cout << ans << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 13932
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

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

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll N;
  cin >> N;
  vll V(N);
  umll M;
  REP(i, 0, N) {
    cin >> V[i];
    if (M.find(V[i]) != M.end()) {
      M[V[i]]++;
    } else {
      M[V[i]] = 1;
    }
  }
  if (M.size() == 1) {
    cout << N / 2 << endl;
    return 0;
  }
  vector<pll> P(M.begin(), M.end());
  sort(P.begin(), P.end(), [](pll a, pll b) {
    return a.second > b.second;
  });
  ll v1 = P[0].first;
  ll v2 = P[1].first;
  ll ans1 = 0;
  ll ans2 = 0;
  REP(i, 0, N) {
    if (i % 2 == 0) {
      if (V[i] != v1) {
        ans1++;
      }
      if (V[i] != v2) {
        ans2++;
      }
    } else {
      if (V[i] != v2) {
        ans1++;
      }
      if (V[i] != v1) {
        ans2++;
      }
    }
  }
  cout << min(ans1, ans2) << endl;

  return 0;
}


Measured memory_bytes: 6692
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
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; }
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;
ll const MOD = 1000000007;


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

string S;
cin >> S;
int N = S.size();

int cnt = 0;

rrep(i,N-1) {
    if(S[i] == S[i-1]){
        cnt++;
        if(S[i-1] == '0') S[i] = '1';
        else S[i] = '0';
    }
}

cout << cnt << endl;

return 0;
}

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

using namespace std;

#define INF 1000000007
#define LINF 1000000000000000007

typedef long long i64;
typedef pair<i64,i64> P;


int r;

int main(){
	cin >> r;
	
	cout << 3 * r *r << endl;
	
	return 0;
}

Measured memory_bytes: 256
import bisect
a,b = map(int,input().split())

c = [[] for i in range(a)]
z = []
for _ in range(b):
  f,g = map(int,input().split())
  c[f - 1].append(g)
  z.append([f,g])

for i in range(a):
    if c[i] != []:
        c[i].sort()

x =''
y = ''
for j in range(b):                    
    x = str(z[j][0])
    x = '0' * (6 - len(x)) + x
    y = str(bisect.bisect(c[z[j][0] - 1], z[j][1]))
    y = '0' * (6 - len(y)) + y
    print(x + y)

Measured memory_bytes: 32776
#include <iostream>
#include <algorithm>
using namespace std;
bool cmp(int a,int b)
{
    return a%10<=b%10;
}
int main()
{
    int a[5],i,sum=0,flag;
    for(i=0; i<5; i++)
        cin>>a[i];
    sort(a,a+5,cmp);
    for(i=0; i<5; i++)
    {
        if(a[i]%10!=0)
        {
            flag=i;
            break;
        }
    }

    for(i=0; i<5; i++)
    {
        if(i!=flag){
        if(a[i]%10==0)
            sum+=a[i];
        else
        {
            a[i]/=10;
            a[i]++;
            sum+=a[i]*10;
        }
    }
    else    sum+=a[i];
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 256
MAX_INT = int(10e10)

N,W = list(map(int,input().split()))
w = [0]
v = [0]

for i in range(N):
  a,b = list(map(int,input().split()))
  w.append(a)
  v.append(b)
V_MAX = max(v)

# dp[i][v] = w
dp = [[MAX_INT]*(N*V_MAX+1) for i in range(N+1)]

for i in range(N+1):
  dp[i][v[i]] = w[i]
for i in range(1,N+1):
  for j in range(1,N*V_MAX+1):
    if j < v[i]:
      dp[i][j] = dp[i-1][j]
    else:
      dp[i][j] = min(dp[i-1][j], dp[i-1][j-v[i]]+w[i],dp[i][j])  # max(iの品を使わない時, iの品を使う時)
for j in range(N*V_MAX,0,-1):
  for i in range(1,N+1):
    if dp[i][j] <= W:
      print(j)
      exit()


Measured memory_bytes: 120556
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int a[3], n; double b, c;
int main() {
	while (true) {
		cin >> a[0] >> a[1] >> a[2];
		if (!a[0] && !a[1]) { break; }
		sort(a, a + 3);
		b = sqrt(a[0] * a[0] + a[1] * a[1]) / 2;
		cin >> n;
		for (int i = 0; i < n; i++) {
			cin >> c;
			if (b >= c) { cout << "NA" << endl; }
			else { cout << "OK" << endl; }
		}
	}
}

Measured memory_bytes: 1240
#include<bits/stdc++.h>
#define rep(i,a,b) for (int i=(a); i<=int(b); i++)
using namespace std;

const int maxn = 205, MOD = 998244353;
int x[maxn], y[maxn], bin[maxn], n, ans, cnt;

inline int mul(int a, int b) {
	return 1LL * a * b % MOD;
}
inline int add(int a, int b) {
	a += b;
	if (a >= MOD) a -= MOD;
	if (a < 0) a += MOD;
	return a;
}

int main() {
	scanf("%d", &n); bin[0] = 1;
	rep (i, 1, n) scanf("%d%d", &x[i], &y[i]);
	rep (i, 1, n) bin[i] = bin[i-1] * 2 % MOD;
	ans = add(bin[n], -n-1);
	rep (i, 1, n) rep (j, i+1, n) {
		cnt = 0;
		rep (k, j+1, n)
			if ((x[i]-x[k])*(y[j]-y[k]) - (x[j]-x[k])*(y[i]-y[k]) == 0) cnt++;
		ans = add(ans, -bin[cnt]);
	}
	ans = (ans % MOD + MOD) % MOD;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main(){
    int a, b;
    cin >> a >> b;
    if(a<b){
        for (int i = 0; i < b; i++)
        {
            cout << a;
        }
        cout << endl;
    }
    else{
        for (int i = 0; i < a; i++)
        {
            cout << b;
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/m-solutions2019/tasks/m_solutions2019_a
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        n: usize
    };
    println!("{}", (n-2)*180);
}


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

sum=0
if len(str(N))%2==0:
    for i in range(1,len(str(N)),2):
        sum+=9*pow(10,(i-1))
else:
    for i in range(1,len(str(N)),2):
        sum+=9*pow(10,(i-1))
    sum+=N+1-1*pow(10,len(str(N))-1)
print(sum)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
// #pragma GCC diagnostic warning "-std=c++11"

#define ll long long
#define pb  push_back
#define mod  1000000007
#define inf  1000000000000000000
#define pi  acos(-1.0)
#define maxn  1000009
#define sorted(s)  sort(s.begin(),s.end())
#define slc(n) scanf("%lld", &n)
#define sl(n)  scanf("%lld", &n)
#define sf(n)  scanf("%lf", &n)
#define si(n)  scanf("%d", &n)
#define sch(n)  scanf(" %c", &n)
#define ss(n)  scanf("%s", n)
#define pb  push_back
#define fr first
#define sc second
#define all(a)  a.begin(),a.end()

using namespace std;

ll n, a[maxn], ans = inf, dp[maxn], k;

ll rec(ll from, ll to)
{
	// cout << from << " " << to << " " << dp[to] << endl;
	if(to>n)
		return inf;
	if(to==n)
		return abs(a[to]-a[from]);
	if(dp[to]==-1){
		// dp[to] = min(rec(to, to+1), rec(to, to+2));
		ll x = inf;
		for(ll j=1;j<=k;j++)
			x = min(x, rec(to, to+j));
		dp[to] = x;
	}
	return dp[to] + abs(a[to]-a[from]);
}

int main()
{
	memset(dp,-1, sizeof dp);
	cin>>n>>k;
	for(ll i=1;i<=n;i++)
	{
		slc(a[i]);
	}
	ll ans = rec(1,1);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 15104
A,B,C,D = map(int,input().split(' '))

#最大公約数
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

#最小公倍数
def lcm(a,b):
    return a*b//gcd(a,b)

c_num = (B//C - (A-1)//C)
d_num = (B//D - (A-1)//D)
cd_num = (B//lcm(C, D) - (A-1)//lcm(C, D))
print((B-A+1) - (c_num+d_num-cd_num))

Measured memory_bytes: 3064
import java.util.Scanner;

class Main{
	public static void main(String arg[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Y = sc.nextInt();
		sc.close();
		
		for(int i = 0; i <= N; i++) {
			for(int j = 0; j <= N - i; j++) {
				int k = N - i - j;
				if(i + j + k == N) {
					int ans = 10000*i + 5000*j + 1000*k;
					if(ans == Y) {
						System.out.println(i + " " + j + " " + k + " ");
						System.exit(0);
					}
				}
			}
		}
		System.out.println(-1 + " " + -1 + " " + -1);
	}
}

Measured memory_bytes: 22996
n,m,c = map(int, input().split())
B = list(map(int, input().split()))
count = 0
for i in range(n):
  A = list(map(int, input().split()))
  d = 0
  for j in range(m):
    d += A[j]*B[j]
  d += c
  if d > 0:
    count += 1
print(count)

Measured memory_bytes: 9224
from itertools import product

ABCD = input()

for op in product(("+", "-"), repeat=3):
    ans = ""
    for i in range(len(ABCD)-1):
        ans += ABCD[i] + op[i]
    ans += ABCD[-1]
    if eval(ans) == 7:
        print(ans+"=7")
        exit()

Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  string s; cin >> s;
  int ans = 0;
  FOR(i, 1, n) {
    string mae = s.substr(0, i), ushiro = s.substr(i);
    map<char, bool> mp;
    for (char c : mae) mp[c] = true;
    vector<bool> used(26, false);
    int tmp = 0;
    for (char c : ushiro) if (!used[c-'a'] && mp[c]) {
      ++tmp;
      used[c-'a'] = true;
    }
    ans = max(ans, tmp);
  }
  cout << ans << '\n';
  return 0;
}


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

int main()
{

  int n;
  cin >> n;
  int day[n + 1][3];

  for (int i = 0; i < n; i++)
  {
    cin >> day[i][0] >> day[i][1] >> day[i][2];
  }

  long long int dp[3];
  for (int i = 0; i < 3; i++)
    dp[i] = day[0][i];

  for (int i = 1; i < n; i++)
  {
    long long int m[3] = {0};
    for (int j = 0; j < 3; j++)
    {
      for (int k = 0; k < 3; k++)
      {
        if (j != k)
        {

          m[j] = max(m[j], dp[k] + day[i][j]);
        }
      }
    }
    for (int x = 0; x < 3; x++)
      dp[x] = m[x];
  }

  cout << max(dp[0], max(dp[1], dp[2]));

  return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;
const int inf = 1001001000;
const long long int Inf = 1001001001001001000;

void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

//最大公約数を返す関数.
long long int gcd(long long int x, long long int y){
    if (x < y) swap(x,y);
    while (y > 0){
        long long int r = x % y;
        x = y;
        y = r;
    }
    return x;
}
//最小公倍数を返す関数.gcdが必要.
long long int lcm(long long int x, long long int y){
	return x / gcd(x, y) * y;
}


int main()
{
	long long int a, b;
	cin >> a >> b;
	
	cout << lcm(a, b) << endl;

	return 0;
}

Measured memory_bytes: 256
def main():
  N, K  = map(int, input().split())
  max_pair = (N-1)*(N-2)//2
  if max_pair < K:
    print(-1)
  else:
    edge = []
    for i in range(N-1):
      edge.append([1, 2+i])
    from_ = 2
    to_ = 3
    for i in range(max_pair-K):
      edge.append([from_, to_])
      to_ += 1
      if to_ > N:
        from_ += 1
        to_ = from_ + 1
    num = len(edge)
    print(num)
    [print(*edge[i]) for i in range(num)]
    
if __name__ == "__main__":
  main()  

Measured memory_bytes: 4120
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

const int N=2e3+5;
int n,dp[N],sum[N];
char num[N];
vector <int> son[N];

template <typename _Tp> inline void IN(_Tp&x) {
	char ch;bool flag=0;x=0;
	while(ch=getchar(),!isdigit(ch)) if(ch=='-') flag=1;
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	if(flag) x=-x;
}
inline void addedge(int u=0,int v=0) {
	IN(u),IN(v),son[u].push_back(v),son[v].push_back(u);
}

void dfs(int u,int fa) {
	dp[u]=0,sum[u]=num[u]-'0';
	for(auto v:son[u]) if(v!=fa)
		dfs(v,u),sum[u]+=sum[v],dp[u]+=dp[v]+sum[v];
}
int solve(int u,int fa) {
    if(!u) return 0;
	int mx=0;
	for(auto v:son[u]) if(v!=fa&&dp[v]+sum[v]>dp[mx]+sum[mx]) mx=v;
	int tmp=solve(mx,u)+sum[mx];
	if(dp[u]-dp[mx]-sum[mx]>=tmp) return dp[u]&1;
	else return tmp-(dp[u]-dp[mx]-sum[mx]);
}

int main() {
	IN(n),scanf("%s\n",num+1);
	for(int i=2;i<=n;++i) addedge();
	int ans=1e9;
	for(int i=1;i<=n;++i) {
		dfs(i,0);
		if(!solve(i,0)) ans=min(ans,dp[i]>>1);
	}
	printf("%d\n",ans==1e9?-1:ans);
	return 0;
}

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

bool cmp( pair<int,int> p, pair<int,int> q)
{
    return p.first < q.first;//升序
}

int main(){
	int n;
	pair<int,int> a[100010];
	scanf("%d",&n);
	for(int i=1; i<=n ; i++){
		scanf("%d",&a[i].first); //人数 
		a[i].second=i;
	}
	sort(a+1,a+n+1,cmp);
	for(int i=1; i <=n; i++){
		printf("%d ",a[i].second);
	}
	printf("\n");
	return 0;
}



Measured memory_bytes: 1536
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
inline int read(){
	char ch=getchar();int o=0,f=1;
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') o=(o<<3)+(o<<1)+(ch^48),ch=getchar();
	return f*o;
}
int n,m,a,b,c; 
int main(){
	n=read(),m=read();
	cout<<max(0,n-m*2)<<endl;
	return 0;
}

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

int main(){
  int N,flag=1;
  cin >> N;
  vector<string> vec(N);
  cin >> vec[0];
  for(int i=1;i<N;i++){
    cin >> vec[i];
    if(vec[i].at(0)!=vec[i-1].at(vec[i-1].size()-1))
      flag=0;
    for(int j=0;j<i;j++){
      if(vec[i]==vec[j])
        flag=0;
    }
  }
  if(flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    _LI = lambda : [-int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()
    DD = ((1,0),(0,1),(-1,0),(0,-1))
    eps = 10**(-10)

    N = NI()

    for n in range(1,N+1):
        ans = 0
        m = int(math.sqrt(n)) + 1
        for x in range(1,m):
            for y in range(1,m):
                a0 = x*x + y*y + x*y - n
                a1 = x + y
                if a1*a1 - 4*a0 >= 0:
                    z = (-a1 + math.sqrt(a1*a1 - 4*a0)) / 2
                    if z - int(z+eps) == 0.0 and z > 0:
                        ans += 1
        print(ans)

if __name__ == '__main__':
    main()

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

int main(){
  int n;
  cin >> n;
  int mx = 0, ans = 0;
  for(int i = 0; i < n; ++i){
    int p;
    cin >> p;
    ans += p;
    mx = max(mx, p);
  }
  
  cout << ans - mx / 2 <<endl;
}

Measured memory_bytes: 256
let pi = atan 1. *. 4.
let (a, b, x) = Scanf.sscanf (read_line ()) "%f %f %f" @@ fun a b x -> (a, b, x /. a)

let s = a *. b /. 2.

let r1 = atan (2. *. x /. (b *. b))

let r2 = atan ((2. *. (a *. b -. x) /. (a *. a)))

let angle_of_rad r = r *. 180. /. pi

let () = Printf.printf "%f\n" @@ 
  if s = x then angle_of_rad @@ atan (a /. b)
  else if s > x then 90. -. angle_of_rad r1
  else angle_of_rad r2

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const int P=1e9+7;
int dp[100010][14];
char s[100010];
int main(){
	scanf("%s",s+1);
	int n=strlen(s+1);
	dp[0][0]=1;
	for(int i=1;i<=n;i++){
		if(s[i]!='?'){
			for (int j=0;j<=12;j++) {
				dp[i][j]=dp[i-1][((13+j-s[i]+'0')*4)%13];
			}
		}else{
			for(int j=0;j<13;j++){
				for(int k=0;k<=9;k++){
					dp[i][j]=(dp[i][j]+dp[i-1][((13+j-k)*4)%13])%P;
				}
			}
		}
	}
	cout<<dp[n][5];
	return 0;
}


Measured memory_bytes: 5760
import collections

INF = float('inf')

N, M = list(map(int, input().split()))
d = {i: [] for i in range(N)}

for _ in range(M):
    a, b = list(map(int, input().split()))
    a -= 1
    b -= 1
    d[a].append(b)
    d[b].append(a)

queue = collections.deque()
queue.append((0, 0))
results = {i: (INF, -1) for i in range(N)}
results[0] = (0, 0)
used = set()

while queue:
    cost, cur = queue.pop()
    if cur in used:
        continue
    used.add(cur)
    next_list = d[cur]

    for next_cur in next_list:
        next_cost = cost+1
        if next_cost < results[next_cur][0]:
            results[next_cur] = (next_cost, cur)
            queue.appendleft((next_cost, next_cur))

is_no = False
for k, result in results.items():
    if k == 0:
        continue
    if result[1] == -1:
        is_no = True

if is_no:
    print('No')
else:
    print('Yes')
    for k, result in results.items():
        if k == 0:
            continue
        print(result[1] + 1)


Measured memory_bytes: 115064
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a;
  cin >> a;
  int n = a/100;

  int N = n*100+n*10+n;
  if(a <= N){
    cout << N<<endl;
  }
  else{
    cout << (n+1)*100+(n+1)*10+n+1<<endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;



int main(){
string a,b;cin>>a>>b;
string ans1,ans2;
int l=atoi(a.c_str()),m=atoi(b.c_str());
for(int i=0;i<l;i++){
    ans1 += b;
}
for(int j=0;j<m;j++){
    ans2 += a;
}
if(ans1>ans2)cout << ans2 << endl;
else cout << ans1 << endl;
    return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


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

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

Measured memory_bytes: 256