akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

ll dp[3012][3012][4];
int a[3012][3012];

void rmax(ll &x, ll y)
{
	x=max(x,y);
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n,m; cin>>n>>m;
	int k; cin>>k;
	for(int i=0;i<k;i++)
	{
		int x,y; cin>>x>>y; x--; y--; int v; cin>>v;
		a[x][y]=v;
	}
	dp[0][0][0]=0;
	dp[0][0][1]=a[0][0];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			for(int k=0;k<=3;k++)
			{
				ll v=dp[i][j][k];
				if(i+1<n) 
				{
					rmax(dp[i+1][j][0],v);
					rmax(dp[i+1][j][1],v+a[i+1][j]);
				}
				if(j+1<m)
				{
					rmax(dp[i][j+1][k],v);
					if(k+1<=3) rmax(dp[i][j+1][k+1],v+a[i][j+1]);
				}
			}
		}
	}
	ll ans=0;
	for(int i=0;i<=3;i++) ans=max(ans,dp[n-1][m-1][i]);
	cout<<ans<<'\n';
}


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

int main() {
  string S;
  cin>>S;
  int N;
  cin>>N;
  string meirei1="replace";
  string meirei2="reverse";
  string meirei3="print";
  for(int i=0;i<N;i++){
    string a;
    cin>>a;
    int b,c;
    cin>>b>>c;
    if(a==meirei1){
      string U;
      cin>>U;
      int count=0;
      for(int j=b;j<=c;j++){
        S[j]=U[count];
        count++;
      }
    }else if(a==meirei2){
      int count=0;
      string T=S;
      for(int j=b;j<=c;j++){
        S[j]=T[c-count];
        count++;
      }
    }else{
      for(int j=b;j<=c;j++){
        cout<<S[j];
      }cout<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3176
from bisect import bisect_left as bl, bisect_right as br, insort
import sys
import heapq
#from math import *
from collections import defaultdict as dd, deque
def data(): return sys.stdin.buffer.readline().strip().decode()
def mdata(): return map(float, data().split())
out=sys.stdout.write
#sys.setrecursionlimit(100000)
INF=int(1e9)
mod=int(1e9)+7


n=int(data())
P=list(mdata())
dp=[0]*(n//2+2)
dp[1]=1
for i in range(n):
    dp1=dp[:]
    for j in range(1,len(dp)):
        k=dp[j-1]*(1-P[i])+dp[j]*(P[i])
        dp1[j]=k
    dp=dp1[:]
print(sum(dp))




Measured memory_bytes: 42716
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
use std::collections::HashSet;

#[fastout]
fn main() {
    input! {
        n: usize,
        mut k: usize,
        a: [Usize1; n],
    }
    let mut now = 0;
    let mut gone1 = vec![now];
    let mut gone1_dic = HashSet::new();
    gone1_dic.insert(now);
    loop {
        now = a[now];
        k -= 1;
        if k == 0 {
            println!("{}", now + 1);
            return;
        }
        if gone1_dic.contains(&now) {
            break;
        }
        gone1.push(now);
        gone1_dic.insert(now);
    }

    let mut gone2 = vec![now];
    let mut gone2_dic = HashSet::new();
    gone2_dic.insert(now);
    loop {
        now = a[now];
        k -= 1;
        if k == 0 {
            println!("{}", now + 1);
            return;
        }
        if gone2_dic.contains(&now) {
            break;
        }
        gone2.push(now);
        gone2_dic.insert(now);
    }

    let point = k % gone2.len();
    let ans = gone2[point] + 1;
    println!("{}", ans);
}


Measured memory_bytes: 12716
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

const int  MAX_V = 100000;
vector<int> es[MAX_V];
vector<int> col(MAX_V, -1);
bool loop = false;

void dfs(int now, int c){
    col[now] = c;
    for(auto &e: es[now]){
        if(col[e] == -1) dfs(e, c^1);
        if(col[e] == c) loop = true;
    }
}

int main(){
    ll N, M;
    cin >> N >> M;
    rep(i, M){
        int u, v; cin >> u >> v; u--, v--;
        es[u].pb(v), es[v].pb(u);
    }
    dfs(0, 0);
    if(loop) cout << N*(N-1)/2-M << endl;
    else{
        ll a = 0, b = 0;
        rep(i, N) (col[i]? a : b)++;
        cout << a*b-M << endl;
    }
}

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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, m, n) for (ll i = (m); i < (n); i++)
#define FORR(i, m, n) for (ll i = (m); i >= (n); i--)
#define INF 1e9
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl

int main(int argc, char const *argv[])
{
    string s, t;
    cin >> s;
    cin >> t;
    if (s == t)
    {
        cout << "No" << endl;
        return 0;
    }
    // ll n = s.length(), m = t.length();
    sort(ALL(s));
    sort(ALL(t), greater<char>());
    // if (n < m)
    // {
    //     if (s.substr(0, n) == t.substr(0, n))
    //     {
    //         cout << "Yes" << endl;
    //         return 0;
    //     }
    //     REP(i, n)
    //     {
    //         if (s[i] < t[i])
    //         {
    //             cout << "Yes" << endl;
    //             return 0;
    //         }
    //     }
    //     cout << "No" << endl;
    // }
    // else
    // {
    //     REP(i, m)
    //     {
    //         if (s[i] < t[i])
    //         {
    //             cout << "Yes" << endl;
    //             return 0;
    //         }
    //     }
    //     cout << "No" << endl;
    // }
    if (s < t)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


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

int main() {
  int M,D;
  cin>>M>>D;
  int ans=0;
  for(int i=1;i<M+1;i++){
    for(int j=1;j<D+1;j++){
      if(j>9){
        int a=j%10;
        int b=j/10;
        if(a*b==i&&a!=1&&b!=1){
          ans++;
        }
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {

    val (n, k) = readLine()!!.split(" ").map { it.toInt() }
    val h = (1..n).map { readLine()!!.toInt() }

    val selectedTree = h.sortedDescending().toTypedArray()

    var ans = Int.MAX_VALUE
    for (i in 0 .. n - k) {
        val max = selectedTree[i]
        val min = selectedTree[i + k - 1]

        if (max - min < ans) ans = max - min
    }

    println(ans)
}

Measured memory_bytes: 48492
import numpy as np
Q = int(input())
ans = []
for loop1 in range(Q):
    a, b, c, d = map(int,input().split())
    a, b, c, d = a-1, b-1, c-1, d-1
    a1, b1, c1, d1 = a, b, c, d
    A, B, C, D = [], [], [], []
    for loop2 in range(30):
        A.append(a1 % 3)
        B.append(b1 % 3)
        C.append(c1 % 3)
        D.append(d1 % 3)
        a1 //= 3
        b1 //= 3
        c1 //= 3
        d1 //= 3
        if a1 + b1 + c1 + d1 == 0:
            break
    k = len(A)
    A = np.array(A)
    B = np.array(B)
    C = np.array(C)
    D = np.array(D)
    if a > c:
        A = 2 - A
        a = 3 ** k - 1 - a
        C = 2 - C
        c = 3 ** k - 1 - c
    if b > d:
        B = 2 - B
        b = 3 ** k - 1 - b
        D = 2 - D
        d = 3 ** k - 1 - d
    R = [0, 0]
    end = False
    for i in range(1, k + 1):
        if end:
            break
        R[0] = R[0] * 3 + A[-i]
        R[1] = R[1] * 3 + B[-i]
        if A[-i] == C[-i] and B[-i] == D[-i]:
            if i == k:
                ans.append(0)
            continue
        if A[-i] != C[-i] and B[-i] != D[-i]:
            ans.append((c - a) + (d - b))
            break
        else:
            if B[-i] == D[-i]:
                a, b, c, d = b, a, d, c
                A, B, C, D = B[0:], A[0:], D[0:], C[0:]
                R = R[::-1]
            if A[-i] == 1:
                mid1 = R[0] * (3 ** (k - i)) - 1
                mid2 = (R[0] + 1) * (3 ** (k - i))
                route1 = (a - mid1) + (d - b) + (c - mid1)
                route2 = (mid2 - a) + (d - b) + (mid2 - c)
                ans.append(min(route1, route2))
                break
            else:
                if i == k:
                    ans.append(d - b)
                    break
                bt = B[-i]
                dt = D[-i]
                for j in range(i + 1, k + 1):
                    R[0] = R[0] * 3 + A[-j]
                    bt = bt * 3 + B[-j]
                    dt = dt * 3 + D[-j]
                    dis = dt - bt
                    if A[-j] != C[-j]:
                        ans.append((c - a) + (d - b))
                        end = True
                        break
                    else:
                        if A[-j] == 1:
                            if dis > 1:
                                mid1 = R[0] * (3 ** (k - j)) - 1
                                mid2 = (R[0] + 1) * (3 ** (k - j))
                                route1 = (a - mid1) + (d - b) + (c - mid1)
                                route2 = (mid2 - a) + (d - b) + (mid2 - c)
                                ans.append(min(route1, route2))
                                end = True
                                break
                            else:
                                if j == k:
                                    ans.append(d - b)
                                    end = True
                                continue
                        else:
                            if j == k:
                                ans.append(d - b)
                                end = True
                            continue
for a in ans:
    print(a)

Measured memory_bytes: 14664
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); (i)--)
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
using namespace std;
typedef long long lint;

typedef struct UnionFindTree{
  vector<int> par;
  vector<int> treerank;
  
  UnionFindTree(int n){
    par.resize(n); treerank.resize(n);
    rep(i, n) par[i] = i, treerank[i] = 0;
  }
  
  int find(int x){
    if(par[x] == x) return x;
    return par[x] = find(par[x]);
  }
  
  void unite(int x, int y){
    x = find(x); y = find(y);
    if(x == y) return;
    if(treerank[x] < treerank[y]) swap(x, y);
    if(treerank[x] == treerank[y]) treerank[x]++;
    par[y] = x;
    return;
  }
  
  bool same(int x, int y){
    return find(x) == find(y);
  }
}UF;

template<class T> struct edge{
    int from, to; T cost;
    edge(int f, int t, T c){
        from = f; to = t; cost = c;
    }
};

template<class T> struct Graph{
    vector<vector<edge<T>>> G;
    vector<edge<T>> E;
    int n;
    
    Graph(int n_){
        n = n_;
        G.resize(n);
    }
    
    void add_edge(int f, int t, T c){
        G[f].emplace_back(f, t, c);
        
    }
    
    vector<T> dijkstra(int s){
        using P = pair<T, int>;
        priority_queue<P, vector<P>, greater<P>> que;
        vector<T> d(n, numeric_limits<T>::max());
        d[s] = 0;
        que.push(P((T)0, s));
        while(!que.empty()){
            P p = que.top(); que.pop();
            int v = p.second;
            if(d[v] < p.first) continue;
            for(edge<T> &e : G[v]){
                if(d[e.to] > d[v] + e.cost){
                    d[e.to] = d[v] + e.cost;
                    que.push(P(d[e.to], e.to));
                }
            }
        }
        return d;
    }
    
    T kruskal(){
        rep(i, n)for(edge<T> &e : G[i]) E.push_back(e);
        sort(E.begin(), E.end(), [](const edge<T> &e1, const edge<T> &e2){return e1.cost < e2.cost;});
        UF uf(n);
        T res = 0;
        for(edge<T> &e : E){
            if(!uf.same(e.from, e.to)){
                uf.unite(e.from, e.to);
                res += e.cost;
            }
        }
        return res;
    }
};

int main(){
    int v, e, r; cin >> v >> e >> r;
    Graph<int> g(v);
    rep(i, e){
        int s, t, d; cin >> s >> t >> d;
        g.add_edge(s, t, d);
    }
    vector<int> d = g.dijkstra(r);
    rep(i, v){
        if(d[i] == INT_MAX) cout << "INF" << endl;
        else cout << d[i] << endl;
    }
}


Measured memory_bytes: 15416
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace mondai0039
{
	class Program
	{
		static void Main(string[] args)
		{
			while( true ) {
				var	str	= Console.ReadLine();
				if( str == null ) {
					break;
				}

				int	before	= 10000;
				int	sum		= 0;
				for( int i = 0; i < str.Length; i++ ) {
					int	now	= 0;
					switch( str[ i ] ) {
					case	'M':	now	= 1000;	break;
					case	'D':	now	=  500;	break;
					case	'C':	now	=  100;	break;
					case	'L':	now	=   50;	break;
					case	'X':	now	=   10;	break;
					case	'V':	now	=    5;	break;
					case	'I':	now	=    1;	break;
					}
					sum	+= now;
					if( before < now ) {
						sum	-= before * 2;
					}
					before	= now;
				}
				Console.WriteLine( sum );
			}
		}
	}
}

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

int main(int argc, char const *argv[]) {

  ll h, a;

  cin >> h;
  cin >> a;

  ll dmg = a;
  ll cnt = 1;
  while (dmg < h) {
    dmg += a;
    cnt++;
  }
  cout << cnt;

  return 0;
}


Measured memory_bytes: 256
from fractions import gcd
# from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
from bisect import *
import itertools
import fractions
# import sys
# sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
# input = sys.stdin.readline


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

def main():
    n = int(input())
    p = list(map(int, input().split()))
    q = list(map(int, input().split()))
    a, b = -1, -1
    c = 0
    v = [i for i in range(1  , n+1)]
    for l in itertools.permutations(v):
        c+=1
        aa,bb = True,True
        for j in range(n):
            if p[j] != l[j]:
                aa = False
            
            if q[j] != l[j]:
                bb = False

        if aa:
            a = c
        if bb:
            b = c
    print(abs(a - b))
        


    # n = int(input())
    # s = input()
    # ans = 0
    # for i in range(n - 3):
    #     if s[i:i + 3] == "ABC":
    #         ans += 1
    # print(ans)
    # n, m = map(int, input().split())
    # a = list(map(int, input().split()))

    # g = lcm(a[0], a[1])
    # for i in range(2, n):
    #     g = lcm(g, a[i])
    # if g // 2 > m:
    #     print(0)
    #     exit()
    # print(g)
    # print(math.ceil(m//g + 0.5))



    


if __name__ == '__main__':
    main()


Measured memory_bytes: 5588
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

int main()
{
    int N;
    cin>>N;
    long long A[N+1];
    long long B[N];
    for(int i= 0;i<N+1;i++)
    {
        cin>>A[i];
    }
    for(int i= 0;i<N;i++)
    {
        cin>>B[i];
    }   

    long long sum = 0;
    for(int i = N-1;i>=0;i--)
    {
        if(A[i+1]>=B[i])
        {
            sum=sum+B[i];
            A[i+1] = A[i+1] -B[i];
            B[i] = 0;
        }
        else
        {
            sum=sum+A[i+1];
            B[i] =B[i] - A[i+1];
            if(A[i]>=B[i])
            {
                sum=sum+B[i];
                A[i]=A[i] - B[i];
                B[i]=0;
            }
            else
            {
                sum=sum+A[i];
                B[i] = B[i] -A[i];
                A[i] = 0;
            }
        }
    }
    cout<<sum<<endl;

}

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

using namespace std;

int main(){
    string s,t;
    cin >> s;
    cin >> t;
    int cnt = 0;
    for(int i = 0; i < 3; i++){
        if(s[i] == t[i]){
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll s;
	cin>>s;
	ll x,y;
	y=s/1000000000;
	if(s%1000000000!=0)y++;
	x=y*1000000000-s;
	fcout(0);
	puta(0,0,1000000000,1,x,y);
}


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

using ll = long long;
#define debug(x) cerr << #x << ": " << x << endl;
#define line() cerr << "---------------" << endl;

int n;
int a[60];
int Max = 0;

void setMax() {
   for (int i = 1; i < n; i++) {
      if (abs(a[i]) > abs(a[Max])) {
         Max = i;
      }
   }
}

int main() {
   cin >> n;
   for (int i = 0; i < n; i++) {
      cin >> a[i];
   }

   setMax();

   // 全要素に足す
   int ans[2][109];
   int cnt = 0;
   for (int i = 0; i < n; i ++) {
      ans[0][cnt] = Max+1, ans[1][cnt] = i+1;
      cnt++;
      a[i] += a[Max];
   }

   // 累積和
   if ( a[Max] >= 0 ) {
      for (int i = 1; i < n; i++) {
         a[i] += a[i] + a[i-1];
         ans[0][cnt] = i, ans[1][cnt] = i+1;
         cnt++;
      }
   } else {
      for (int i = n-2; i >= 0; i--) {
         a[i] += a[i] + a[i+1];
         ans[0][cnt] = i+2, ans[1][cnt] = i+1;
         cnt++;
      }
   }

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

   // for (int i = 0; i < n; i++) {
   //    cout << a[i] << " ";
   // }
   // cout << endl;
     
   return 0;
}

Measured memory_bytes: 256
r,c=list(int(i) for i in input().split())
#
za=10**9+7
A=[]
for i in range(r):
	B=input()
	k=list(B)
	A.append(k)
dp=[[0 for i in range(c+1)]for j in range(r+1)]
if A[r-1][c-1]=="#":
	dp[r-1][c-1]=0
else:
	dp[r-1][c-1]=1
for i in range(r-1,-1,-1):
	for j in range(c-1,-1,-1):
		if A[i][j]!="#":
			if(i<r-1 and j<c-1):
				if A[i+1][j]=="#" and A[i][j+1]!='#':
					dp[i][j]=dp[i][j+1]
				elif A[i+1][j]!="#" and A[i][j+1]=='#':
					dp[i][j]=dp[i+1][j]
				elif A[i+1][j]!="#" and A[i][j+1]!="#":
					dp[i][j]=dp[i+1][j]+dp[i][j+1]
			elif j==c-1 and i!=r-1:
				if A[i+1][j]!="#":
					dp[i][j]=dp[i+1][j]
			elif(i==r-1 and j!=c-1):
				if A[i][j+1]!="#":
					dp[i][j]=dp[i][j+1]


print(dp[0][0]%za)


Measured memory_bytes: 248816
<?php

$tmp = explode(" ", trim(fgets(STDIN)));
$x = $tmp[0];
$y = $tmp[1];

if ($x % $y == 0) {
    echo "-1".PHP_EOL;
} else {
    $i = 2;
    while (true) {
        if ($x * $i % $y != 0) {
            echo ($x * $i).PHP_EOL;
            break;
        }
        $i++;
    }
}


Measured memory_bytes: 3828
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

//ABC166D
int main(void) {
  long long a, b, x, n, k, i, cou=0, tmp;
  scanf(" %lld", &x);

  a=0, b=0;
  while(1){
    if(pow(a, 5)-pow(b, 5)==x) break;
    a++, b=a;
    while(pow(a, 5)-pow(b, 5)<=x){
      if(pow(a, 5)-pow(b, 5)==x) break;
      b--;
    }

  }
  printf("%lld %lld", a, b);
}

Measured memory_bytes: 2540
n = int(input())
t = list(map(int, input().split()))
m = int(input())
px = [list(map(int, input().split())) for i in range(m)]

for i in range(m):
    tmp = t + [0]
    tmp[px[i][0]-1] = px[i][1]
    print(sum(tmp))

Measured memory_bytes: 38512
n, k = map(int, input().split())
a = list(map(int, input().split()))
a = [x-1 for x in a]
nxt = [[x for _ in range(60)] for x in a]
for j in range(1, 60):
	for i in range(n):
		nxt[i][j] = nxt[nxt[i][j-1]][j-1]

cur = 0
for j in range(59, -1, -1):
	if (k>>j)&1:
		cur = nxt[cur][j]
print(cur+1)

Measured memory_bytes: 205124
#include<stdio.h>

int main(void)
{

  int i,j,tmp;
  int mt[10];

  for(i=0;i<10;i++){
    scanf("%d ",&mt[i]);
  }

  for(i=9;i>=0;i--){
    for(j=0;j<i;j++){
      if(mt[j]<mt[j+1]){
	tmp = mt[j];
	mt[j] = mt[j+1];
	mt[j+1] = tmp;
      }
    }
  }

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

  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORX(i, a, b, x) for (int i = (a); i <= (b); i+=x)
#define debug(x) cerr << #x << " is= " << x << endl; //use for debugging
#define read(a) int a; cin >> a;
#define reads(s) string s; cin >> s;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 5] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}
 
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;}
 
#define FORD(i, a, b) for(int i = (a); i >= (b); i--)
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define mp(a,b) make_pair(a,b)
#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll long long int
#define vi         vector<int>
#define vll        vector<ll>
#define vpii       vector<pair<int,int>>
#define vov        vector<vector<int>> 
#define pr         pair<ll,ll>
#define vpll       vector<pair<ll,ll>>
#define all(v)     v.begin(),v.end()
#define rall(v)    v.rbegin(),v.rend()  //reverse of above;
#define sz(container) int((container).size())
#define cut(x) {cout<<x<<"\n"; return 0;}
#define setprec(x) cout << fixed << showpoint << setprecision(8)<<x<<endl;
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a*b/__gcd(a,b)
#define time cout << clock() / double(CLOCKS_PER_SEC) << endl;
#define endl "\n"
#define mod 1000000007
using namespace std;
using namespace __gnu_pbds;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; 
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
//*s.find_by_order() ->returns an iterator to the k-th largest element (counting from zero);
//s.order_of_key() ->number of elements strictly smaller then our item;
//st.rbegin()->second; last element in set
//st.erase(prev(st.end())); delete last element in set;
//sort(a+1,a+n+1,[](ll x,ll y){return abs(x)>abs(y);});
//sort(v.begin(), v.end(), greater<int>()); 
const int N=3e5+5;
ll n,a[N][65],ans=0,p=0,x,y,b[N];
void solve()
{
 //n*662;
 FOR(i,1,n)
 FOR(j,0,62)
 if(b[i]&(1ll<<j)) a[i][j]=1;

 //n*662;
 FOR(j,0,62)
 FOR(i,1,n)
 a[i][j]=a[i][j]+a[i-1][j];

 //n*662;
 FOR(i,1,n-1) // iterate for each row;
 FOR(j,0,62)
 {
   x=a[n][j]-a[i][j];
   y=n-i-x;
   if(b[i]&(1ll<<j)) ans+=(((1ll<<j)%mod)*y)%mod;
   else ans+=(((1ll<<j)%mod)*x)%mod;
   ans%=mod;
 }
 cout<<ans;
}
int main()
{
  fast_io;
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif
  cin>>n;
  FOR(i,1,n) cin>>b[i];
  solve();
}


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

int a, b, k, ka = 0;
vector<int> ta;
int iwa[200] = {};

int main(){
	cin >> a >> b >> k;
	for (int i = a; i <= a + k - 1; i++) {
		if (i <= b) {
			ta.push_back(i);
		}
	}
	for (int i = b - k + 1; i <= b; i++) {
		if (i >= a) {
			ta.push_back(i);
		}
	}
	for (int i = 0; i < ta.size(); i++) {
		iwa[i] = ta[i];
		ka++;
	}
	sort(iwa, iwa + ka);
	for (int i = 0; i < ka; i++) {
		if (iwa[i] != iwa[i - 1]) {
			cout << iwa[i] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
while True:
    try:
        n = int(input())
    except:
        exit()
    m = 9
    c = 0
    def loop(n,dep):
        l = n - m*(3-dep)
        u = n
        if (l < 0):l = 0
        if (m < u):u = 9
        return l,u+1

    il,iu= loop(n,0)
    for i in range(il,iu):
        jl,ju = loop(n-i,1)
        for j in range(jl,ju):
            ij = i+j
            kl,ku = loop(n-ij,2)
            for k in range(kl,ku):
                c += 1

    print(c)

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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    if (n % 2 == 1) {
        int mid_min = a[n / 2];
        int mid_max = b[n / 2];
        cout << mid_max - mid_min + 1 << endl;
    } else {
        int left_min = a[n / 2 - 1];
        int left_max = b[n / 2 - 1];;
        int right_min = a[n / 2];
        int right_max = b[n / 2];
        // a left sample is from [left_min, left_max]
        // a right sample is from [right_min, right_max]
        int mid_min_twice = left_min + right_min;
        int mid_max_twice = left_max + right_max;
        cout << mid_max_twice - mid_min_twice + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 4852
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
class ilds1_6_c{
    public static void Main(){
        int n = int.Parse(Console.ReadLine());
        Suit[] cardsForQuickSort = new Suit[n];
        Suit[] cardsForMergeSort = new Suit[n];
        for(int i=0; i<n; i++){
            string[] str = Console.ReadLine().Split(' ');
            cardsForQuickSort[i] = new Suit{
                Num = int.Parse(str[1]),
                Label = str[0],
            };
            cardsForMergeSort[i] = new Suit{
                Num = int.Parse(str[1]),
                Label = str[0],
            };
        }
        string ans = "Stable";
        QuickSort(cardsForQuickSort,0,n-1);
        MergeSort(cardsForMergeSort,0,n);
        for(int i=0; i<n; i++){
            if(CompareCard(cardsForMergeSort[i],cardsForQuickSort[i])){
                ans = "Not stable";
                break;
            }
        }
        Console.WriteLine(ans);
        for(int i=0; i<n; i++){
            Console.WriteLine("{0} {1}",cardsForQuickSort[i].Label,cardsForQuickSort[i].Num);
        }
    }
    public static void MergeSort(Suit[] cards, int left, int right){
        int mid;
        //Console.WriteLine("{0}~{1}",left,right);
        if( (left+1) < right){
            mid = (left+right)/2;
            MergeSort(cards,left,mid);
            MergeSort(cards,mid,right);
            Merge(cards,left,mid,right);
        }
    }
    public static void Merge(Suit[] cards, int left, int mid, int right){
        int n1 = mid-left;
        int n2 = right-mid;
        Suit[] c1 = new Suit[n1+1];
        Suit[] c2 = new Suit[n2+1];
        for(int x=0; x<n1; x++){
            c1[x] = cards[left+x];
        }
        for(int x=0; x<n2; x++){
            c2[x] = cards[mid+x];
        }
        c1[n1] = c2[n2] = new Suit{
            Label = "",
            Num = 2000000000,
        };
        int i = 0, j = 0;
        for(int k=left; k<right; k++){
            if(c1[i].Num <= c2[j].Num){
                cards[k] = c1[i++];
            }
            else{
                cards[k] = c2[j++];
            }
        }
    }
    public static void QuickSort(Suit[] cards, int start, int end){
        if(start < end){
            int q = Partition(cards,start,end);
            QuickSort(cards,start,q-1);
            QuickSort(cards,q+1,end);
        }
    }
    public static int Partition(Suit[] cards, int start, int end){
        int i,j;
        Suit x = new Suit();
        Suit t = new Suit();
        x = cards[end];
        i = start-1;
        for(j=start; j<end; j++){
            if(cards[j].Num <= x.Num){
                i++;
                t = cards[j];
                cards[j] = cards[i];
                cards[i] = t;
            }
        }
        t = cards[i+1];
        cards[i+1] = cards[end];
        cards[end] = t;
        return i+1;
    }
    public static bool CompareCard(Suit c1, Suit c2){
        return !(c1.Label == c2.Label)&&(c1.Num == c2.Num);
    }
}
class Suit{
    public int Num { set; get; }
    public string Label { set; get; }
}



Measured memory_bytes: 35028
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef trie<string, null_type, trie_string_access_traits<>, pat_trie_tag, trie_prefix_search_node_update> pref_trie;
typedef unsigned long long BITMASK; typedef long long ll; typedef long double ld;
#define smallest_on_bit(bit_mask) (__builtin_ctzint((bit_mask) & (-(bit_mask))))
#define CLOCK_START clock_t chrono_clk_beg = clock()
#define CLOCK_END clock_t chrono_clk_end = clock(); cerr << (double(chrono_clk_end - chrono_clk_beg) / CLOCKS_PER_SEC) << " sec"
#define bug(args ...) cerr << __LINE__ << ">> ", err(new istringstream(string(#args)), args), cerr << '\n'
#define toBinary(name, num) string name = bitset<8>(num).to_string();
#define toDecimal(name, binary) unsigned long name = bitset<8>(binary).to_ulong();
#define all(x) x.begin(), x.end()
#define mapfind(mp, x) (mp.find(x) != mp.end())
#define arrfind(arr, x) (find(all(arr), x) != arr.end())
#define removeDuplicates(vec) sort(vec.begin(), vec.end()); vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define int ll
#define double ld
#define INF LONG_MAX
void err(istringstream *iss) {} template<typename T, typename ... Args> void err(istringstream *iss, const T &_val, const Args & ... args) { string _name; *iss >> _name; if (_name.back()==',') _name.pop_back(); cerr << _name << " = " << _val << "; ", err(iss, args ...); }
#define MOD 1000000007

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int h, a;
    cin >> h >> a;
    int i = 0;
    while (h > 0) h -= a, i++;
    cout << i << '\n';
    return 0;
}

Measured memory_bytes: 256
Option Strict On

Module Module1

    Sub Main()
        'let'
        Dim tmp() As Long = Array.ConvertAll(Of String, Long) _
            (Console.ReadLine().Split(), AddressOf Long.Parse)
        Dim A As Long = tmp(0)
        Dim B As Long = tmp(1)

        'var'
        Dim ans() As Long = New Long() {A + B, A - B, A * B}

        Array.Sort(ans)
        Dim n As Int32 = UBound(ans)

        Console.WriteLine(ans(n))

    End Sub
End Module


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
int main(){
	int K, N; cin >> K >> N; 
	if(K == 1){
		for(int i = 0; i < (N+1)/2; i++){
			cout << 1 << " "; 
		}
		cout << endl; return 0; 
	}
	if(K % 2 == 0){
		cout << K/2 << " "; 
		for(int i = 0; i < N-1; i++){
			cout << K << " "; 
		}
		cout << endl; return 0;		
	}
	int A[300010] = {}; 
	for(int i = 0; i < N; i++) A[i] = (K+1)/2;
	int dec = N/2; int last = N-1; 
	while(dec--){
		A[last]--; 
		if(A[last]){
			for(int i = last+1; i < N; i++) A[i] = K; 
			last = N-1; 
		}
		if(A[last] == 0) last--;
	}
	for(int i = 0; i <= N; i++){
		if(A[i]) cout << A[i] << " "; 
		else{
			cout << endl; return 0; 
		}
	}
}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define uii             unordered_map<int,int>
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
void S_K_S()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int32_t main()
{
	S_K_S();
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int opt1=a*c,opt2=a*d,opt3=b*c,opt4=b*d;
	cout<<max(max(opt1,opt2),max(opt3,opt4));
}


Measured memory_bytes: 3644
import java.util.*;
import java.io.*;
import java.math.*;
 
 
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static final long mod=1000000007;
    
    public  static void main(String[] args)   throws Exception, IOException{
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
        // int n=sc.nextInt();
        // char c[][] = new char[h][w];
        // char c[]=sc.nextString().toCharArray();
        // for(int i=0; i<n; i++) {a[i]=sc.nextInt();}
        char c[]=sc.nextString().toCharArray();
        int w=sc.nextInt();
        String s="";
        for (int i=0; i<c.length;i+=w ) {
            s=s+c[i];
        }
        out.println(s);
        out.flush();
    }
    

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
     
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }
    
    static boolean bit(long x,int k){
        // weather k-th bit (from right) be one or zero
        return  ( 0 < ( (x>>k) & 1 )  )  ? true:false;
    }    

    class P implements Comparable<P>{
        long x;
        double d;
        P(long x, double d) {
            this.x=x;
            this.d=d;
        } 
          
        public int compareTo(P p){
            return (d - p.d)>0?1:-1;//des
        } 
    }
}
class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)

int main(){
 
 
  ll a;
  cin>>a;
  cout<<a/2+a%2<<endl;
}



Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
using ll = long long;
ll inf = 100000000007ll;

int main(void)
{
  ll n,k;
  cin >> n >> k;
  vector<ll> a(n),b(n);
  vector<tuple<ll,ll,ll> > sab(n);
  REP(i,n) b[i] = k+2*n-1 - i;
  REP(i,n) a[i] = k+((i+n)%2 ? (i+n)/2 : i/2);
  REP(i,n) sab[i] = make_tuple(a[i]+b[i],a[i],b[i]);
  sort(sab.begin(),sab.end());
  ll ma;
  tie(ma,ignore,ignore) = sab.back();
  if(ma >= k+3*n) {
    cout << -1 << endl;
    return 0;
  }
  REP(i,n) {
    ll x,y;
    tie(ignore,x,y) = sab[i];
    if(x+y>k+2*n+i) {
      cout << -1 << endl;
      return 0;
    }
    cout << x << " " << y << " " << k+2*n+i << endl;
  }
  return 0;
}


Measured memory_bytes: 6144
def so(x, i):
  if x % i == 0:
    return 1 + so(x // i, i)
  else:
    return 0

n, p = map(int, input().split())
soinsu = {}
i = 2
while i * i <= p:
  if so(p, i) != 0:
    soinsu[i] = so(p, i)
    p //= i ** so(p, i)
  i += 1
if p > i:
  soinsu[p] = 1
r = 1
for k in soinsu:
  r *= k ** (soinsu[k] // n)

print(r)

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

bot_a_cnt, top_b_cnt, bXa_cnt = 0, 0, 0
ab_cnt = 0

for i in range(N):
  S = input()
  top_b_cnt += 1 if S[0] == "B" else 0
  bot_a_cnt += 1 if S[-1] == "A" else 0
  bXa_cnt += 1 if S[0] == "B" and S[-1] == "A" else 0
  for j in range(len(S)-1):
    if S[j:j+2] == "AB":
      ab_cnt += 1
      
#print(bot_a_cnt, top_b_cnt, bXa_cnt, ab_cnt)
print(ab_cnt + min(bot_a_cnt, top_b_cnt) - (1 if bot_a_cnt > 0 and bot_a_cnt == top_b_cnt and top_b_cnt == bXa_cnt else 0))

Measured memory_bytes: 3064
#include<iostream>
#include<math.h>
using namespace std;
long long int mini(long long int *h,long long int *dp,long long int i,long long int n)
{
  if(i==n-1)
    return 0;
  else if(i==n-2)
    return (abs(h[i]-h[i+1]));
  if(dp[i]!=-1)
    return dp[i];
  long long int val1=mini(h,dp,i+1,n)+abs(h[i]-h[i+1]);
  long long int val2=mini(h,dp,i+2,n)+abs(h[i]-h[i+2]);
  dp[i]=val1<val2?val1:val2;
  return dp[i];
}
int main(void)
{
  long long int n;
  cin>>n;
  long long int h[n],dp[n],i;
  for(i=0;i<n;i++)
  {
    cin>>h[i];
  }
  for(i=0;i<n;i++)
  {
    dp[i]=-1;
  }
  long long int res=mini(h,dp,0,n);
  cout<<res;
  return 0;
}


Measured memory_bytes: 9600
class DP
  attr_accessor :value
end

def chmin(dp_object, value)
  if dp_object.value != nil
    if (dp_object.value > value)
      dp_object.value = value
      return dp_object.value
    end
    return dp_object.value
  else
    dp_object.value = value
    return dp_object.value
  end
end

def chmax(dp_object, value)
  if dp_object.value != nil
    if (dp_object.value < value)
      dp_object.value = value
      return dp_object.value
    end
    return dp_object.value
  else
    dp_object.value = value
    return dp_object.value
  end
end

#Test
a = DP.new
chmin(a, 3)
chmin(a, 1)

b = DP.new
chmax(b, 3)
chmax(b, 6)


#Sample
def handler(number, heights)
  result = [0]
  for i in 0..(number - 1)
    if i != 0
      before_row = i - 1
      if before_row != 0
        dp = DP.new
        cost1 = (heights[before_row] - heights[i]).abs + result[before_row]
        cost2 = (heights[i - 2] - heights[i]).abs + result[i - 2]
        chmin(dp, cost1)
        chmin(dp, cost2)
        result.push(dp.value)
      else
        cost = (heights[i - 1] - heights[i]).abs
        result.push(chmin(DP.new, cost))
      end
    end
  end
  return result[number - 1]
end

input1 = gets.chop.to_i
input2 = gets.chop.split.map(&:to_i)
p handler(input1, input2)

Measured memory_bytes: 13964
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>

#define pb push_back
#define mp make_pair
#define taskname "A"

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef tree <int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

const int maxn = 2e5 + 5;
bool cannot[10];
int n ,k;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen(taskname".INP","r")){
		freopen(taskname".INP", "r",stdin);
		freopen(taskname".OUT", "w",stdout);
    }
    cin >> n >> k;
    for(int i = 1 ; i <= k ; ++i){
        int x;cin >> x;
        cannot[x] = 1;
    }
    for( ; ; ++n){
        string s = to_string(n);
        bool ok = 1;
        for(char c : s)if(cannot[c - '0'])ok = 0;
        if(ok)return cout << n , 0;
    }
}


Measured memory_bytes: 256
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math

import itertools
import heapq
#import bisect

import copy
from functools import lru_cache

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]

def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)


def main():
    n,k=map(int,input().split())
    a=[]
    a.append(n)
    ans=n
    while True:
        if n>=k:
            dif=n-k
            kai=dif//k
            n-=kai*k
            if n>=k:
                n=abs(n-k)
        if n>k:
            tempn=n
            aftn=abs(n-k)
            if tempn<=aftn:
                break
            else:
                n=aftn
                break
        else:
            tempn = n
            aftn = abs(n - k)
            if tempn <= aftn:
                break
            else:
                n=aftn
                break
    print(n)


if __name__ == "__main__":

    main()

Measured memory_bytes: 40152
#include "bits/stdc++.h"

using namespace std;
using ll = long long;

int main() {
    int N, M;
    cin >> N >> M;
    vector<bool> AC(N, false);
    vector<int> WA(N, 0);
    for (int i = 0; i < M; ++i) {
        int p;
        string s;
        cin >> p >> s;
        p -= 1;
        if (s == "AC")
            AC[p] = true;
        else if(!AC[p])
            WA[p] += 1;
    }

    int cnt_ac = 0, cnt_p = 0;
    for (int i = 0; i < N; ++i) {
        if (AC[i]) {
            ++cnt_ac;
            cnt_p += WA[i];
        }
    }

    cout << cnt_ac << ' ' << cnt_p << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>

using namespace std;

struct s {
  long long l;
  long long r;
  bool operator<(const s& ss) const {
    return r < ss.r;
  }
};

int main(){
    long long N;
    cin>>N;
    vector<struct s> v;
    for(long long i=0;i<N;i++){
        long long X,L;
        cin>>X>>L;
        struct s ts;
        ts.l=X-L;
        ts.r=X+L;
        v.push_back(ts);
    }

    sort(v.begin(),v.end());

    long long ans=0;
    long long x=-99999999999;
    for(long long i=0;i<v.size();i++){
        //cout<<v[i].l<<","<<v[i].r<<endl;
        if(x<=v[i].l){
            ans++;
            x=v[i].r;
        }
    }

    cout<<ans<<endl;
}


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

using namespace std;

#define pii pair<int,int>
#define ll long long
#define s second
#define f first

string s;

bool is(string x){
 string k=x;
 reverse(k.begin(),k.end());
 return k==x;
}

int main(){
  cin >> s;
  if(is(s) && is(s.substr((s.size()+3)/2-1)) && is(s.substr(0,(s.size()-1)/2))){cout << "Yes";}
  else{cout << "No";}
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
template<class T>using vv = vector<vector<T>>;

#define in(v) v; cin >> v;
// #define rep(i,n) for(int i=0;i<(n);++i)
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define rrep(i,n) for(int i=(n);i>=0;--i)
const int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};
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;}

// debug
template<class T>ostream& operator<<(ostream& os,const vector<T>& vec){os<<"{";for(size_t i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
ostream& operator<<(ostream& os,const vector<char>&v){for(size_t i=0;i<v.size();++i)os<<v[i];return os;}
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>& rhs){os<<"("<<rhs.first<<", "<<rhs.second<<")";return os;}


#ifdef LOCAL
void debug() {cerr << "\n";}
template<class First> void debug(const First& first) {cerr<<first<<"\n";}
template<class First, class... Rest> void debug(const First& first, const Rest&... rest) {cerr<<first<<",";debug(rest...);}
#else
#define debug(...) 42
#endif

int main() {
  int in(N);

  ll ans = 0;
  rep(i, 1, N+1) {
    if (i % 3 == 0|| i % 5 == 0)
      continue;
    ans += i;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int A,B;
    string op;
    cin >> A >> op >> B;
    if (op == "+"){
        cout << A + B << endl;
    }
    else if (op == "-"){
        cout << A - B << endl;
    }
}


Measured memory_bytes: 256
a,b,c,d=map(int,input().split())
ab=list([a,b])
cd=list([c,d])
ans=ab[0]*cd[0]
for i in range(len(ab)):
    for j in range(len(cd)):
        temp=ab[i]*cd[j]
        ans=max(ans,temp)
print(ans)

Measured memory_bytes: 9076
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<string>
#include<functional>
#include<queue>
#include<math.h>
#define INF 999999

using namespace std;

int max_three(int a, int b, int c)
{
	int max_ab = max(a, b);
	int ans = max(max_ab, c);

	return ans;
}

int main()
{
	int n;
	cin >> n;

	int a[3];
	vector<string> ans;
	for (int i = 0; i < n; i++) {
		cin >> a[0] >> a[1] >> a[2];
		sort(a, a + 3);
		if (a[2] * a[2] == a[0] * a[0] + a[1] * a[1]) {
			ans.push_back("YES");
		}
		else ans.push_back("NO");
		
	}

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

	return 0;
}

Measured memory_bytes: 3188