akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
typedef pair <ll, int> P;

class UnionFind {
    vector<int> par;
    int n;
public:
    UnionFind(int n) : par(n, -1) {}
    int find(int x) {
        if (par[x] < 0) return x;
        return par[x] = find(par[x]);
    }
    bool unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
};

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

    int n, m;
    cin >> n >> m;

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

    UnionFind uf(n);
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        uf.unite(x, y);
    }

    if ((n - 1 - m) * 2 > n) {
        cout << "Impossible\n";
        return 0;
    }

    vector <priority_queue < ll, vector<ll>, greater<ll> > > q(n);
    set <int> st;
    for (int i = 0; i < n; i++) {
        int par = uf.find(i);
        q[par].push(a[i]);
        st.insert(par);
    }

    vector <int> parents;
    for (auto itr = st.begin(); itr != st.end(); itr++) {
        parents.push_back(*itr);
    }

    int sz = parents.size();
    if (sz == 1) {
        cout << 0 << "\n";
        return 0;
    }
    
    ll ans = 0;
    for (int par : parents) {
        ans += q[par].top();
        q[par].pop();
    }

    priority_queue < P, vector<P>, greater<P> > Q;
    for (int par : parents) {
        if (q[par].size()) {
            ll p = q[par].top();
            q[par].pop();
            Q.push(P(p, par));
        }
    }

    for (int i = 0; i < sz - 2; i++) {
        P p = Q.top();
        Q.pop();
        ans += p.first;
        int pa = p.second;
        if (q[pa].size()) {
            int t = q[pa].top();
            q[pa].pop();
            Q.push(P(t, pa));
        }
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 9592
Scanf.scanf "%d %d" (fun n m ->
    let nei = Array.make n [] in
    for i = 1 to m do
        Scanf.scanf " %d %d" (fun a b ->
            let a = a - 1 in
            let b = b - 1 in
            nei.(a) <- b :: nei.(a);
            nei.(b) <- a :: nei.(b);
        )
    done;

    Scanf.scanf " %d" (fun q ->
        let vdc = Array.init q (fun _ -> Scanf.scanf " %d %d %d" (fun v d c -> v - 1, d, c)) in
        let col = Array.make_matrix n 11 0 in
        for i = q - 1 downto 0 do
            let rec fill v d c =
                if col.(v).(d) = 0 then (
                    col.(v).(d) <- c;
                    if d > 0 then (
                        fill v (d - 1) c;
                        List.iter (fun next -> fill next (d - 1) c) nei.(v)
                    )
                )
            in
            let v, d, c = vdc.(i) in
            fill v d c
        done;
        Array.iter (fun a -> Printf.printf "%d\n" a.(0)) col
    )
)

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vector<int>> vvi;
typedef unordered_map<int,int> uoii;
typedef unordered_map<string,int> uosi;

const int MOD = 1e9+7;

const int INF = 1e10;




int32_t main()
{
    IOS
    string s;
    cin>>s;
    bool ans=false;
    for(int i=0;i<2;i++){
        if(s[i]=='A'&&s[i+1]=='B'||s[i]=='B'&&s[i+1]=='A')
            ans=true;
    }
    if(ans)
        cout<<"Yes";
    else cout<<"No";


    return 0;
}


Measured memory_bytes: 256
a,b=[],[]
c,time=0,0
for i in range(5):
  c=int(input())
  a.append(c)
  if c%10==0:
    b.append(10-c%10)
  else:
    b.append(c%10)#1~10
for i,j in enumerate(b):
  if j==10:
    time+=a[i]
  else:
    time+=a[i]+10-j

print(time-10+min(b))

Measured memory_bytes: 3060
# include<bits/stdc++.h>
using namespace std;
# define lowbit(x) ((x)&(-x))
# define pi acos(-1.0)
# define eps 1e-8
# define MOD 100000007
# define INF 1000000000
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(register int i=a; i<=n; ++i)
# define FDR(i,a,n) for(register int i=a; i>=n; --i)
# define bug puts("H");
# define lch p<<1,l,mid
# define rch p<<1|1,mid+1,r
# define mp make_pair
# define pb push_back
typedef pair<int,int> PII;
typedef vector<int> VI;
# pragma comment(linker, "/STACK:1024000000,1024000000")
typedef long long LL;
inline char nc(){
    static char buf[1000000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++;
}
inline int Scan(){
    char ch=nc();int sum=0, f=1;
    if (ch=='-') f=-1, ch=nc();
    while(!(ch>='0'&&ch<='9'))ch=nc();
    while(ch>='0'&&ch<='9')sum=sum*10+ch-48,ch=nc();
    return sum*f;
}
const int N=50005;
//Code begin....

int rr[10], G[205][205], n, m, R;
int a[10], b[10];

void Change(int a[], int b[]){
    FOR(i,0,R-1) b[i]=a[i];
    swap(b[rand()%R],b[rand()%R]);
}
int dist(int a[]){
    int res=0;
    FOR(i,1,R-1) res+=G[rr[a[i]]][rr[a[i-1]]];
    return res;
}
int sol(){
    double Max_P=10000, dec=0.99;
    FOR(i,0,R-1) a[i]=i;
    random_shuffle(a,a+R);
    while (Max_P>0.01){
        Change(a,b);
        int d_a=dist(a), d_b=dist(b);
        if (d_a>d_b||rand()<=exp(-(d_b-d_a)/Max_P)*RAND_MAX) FOR(i,0,R-1) a[i]=b[i];
        Max_P*=dec;
    }
    return dist(a);
}
int main ()
{
    srand(10086);
    int u, v, w;
    scanf("%d%d%d",&n,&m,&R);
    FOR(i,0,R-1) scanf("%d",rr+i);
    FOR(i,1,n) FOR(j,1,n) if (i!=j) G[i][j]=INF;
    FOR(i,1,m) scanf("%d%d%d",&u,&v,&w), G[u][v]=G[v][u]=w;
    FOR(k,1,n) FOR(i,1,n) FOR(j,1,n) G[i][j]=min(G[i][j],G[i][k]+G[k][j]);

    int ans=INF;
    int T=100;
    while (T--) ans=min(ans,sol());
    printf("%d\n",ans);
    return 0;
}


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

using ll =  long long;
using pint =  pair<int,int>;

#define rep(i,n) for(int (i)=0,temp=(int)(n);(i)<temp;++(i))
#define repi(i,start,end) for(int (i)=(start),temp=(int)(end);i<(end);++(i))
#define rfor(x,v) for(const auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort((v), (v)+(n))
#define vsort(v) sort((v).begin(), (v).end())
#define vfsort(v,lambda) sort(all((v)),(lambda))
#define vint vector<int>
#define vvint vector<vector<int>> //vvint v(n,vint(n))
#define vin(v) rep(i,(v).size()) {cin >> (v)[i];}
//最終奥義 #define int long long
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; }
//lambda: [&](int x, int y){return x<y;}

signed main(void){
    int x,a;cin>>x>>a;
    if(x<a){
        cout << 0 << endl;
    }else{
        cout << 10 << endl;
    }

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();

		if (a - b > 0) {

			System.out.println(b * c + (a - b) * d);
		} else {

			System.out.println(a * c);
		}
	}

}

Measured memory_bytes: 21972
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int N;
    cin >> N;
    int odd_cnt = 0;
    rep(i, N) {
        int A;
        cin >> A;
        odd_cnt += A % 2;
    }
    if (odd_cnt % 2) cout << "NO\n";
    else cout << "YES\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,m;
  cin>>n>>m;
  vector<pair<long int,long int>> eds(n);
  for(int i=0;i<n;i++){
    long int a,b;
    cin>>a>>b;
    eds.at(i)=pair<long int,long int>(a,b);
  }
  sort(eds.begin(),eds.end());
  long int bought=0,money=0;
  for(int i=0;i<n;i++){
    long int b=eds.at(i).second;
    if(m-bought>b){
      bought+=b;
      money+=eds.at(i).first*b;
    }else{
      long int buy=m-bought;
      money+=eds.at(i).first*buy;
      cout<<money<<endl;
      return 0;
    }
  }
}

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

const int mod = 1e9 + 7;

int main() { 
  int N, M;
  cin >> N >> M;
  if (abs(N-M) > 1) {
    cout << 0 << endl;
    return 0;
  }

  int d = 1, m = 1;
  for (int i = 1; i <= N; i++) d = (ll)d * i % mod;
  for (int j = 1; j <= M; j++) m = (ll)m * j % mod;
  int ans = (ll) d * m % mod;
  if (N == M) ans = (ll) ans * 2 % mod;

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

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;
typedef long long ll;
using Graph =vector<int>;
typedef pair<ll,int> P;

const ll MAX_N=131072;
int bit[MAX_N*2-1];
ll n;
int main(){
  int N;cin>>N;
  ll p=1,q=1;
  rep(i,N){
    int T,A;cin>>T>>A;
    ll m=max((p+T-1)/T,(q+A-1)/A);
    p=T*m;q=A*m;
  }
  cout<<p+q<<endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

// こちらを参考にした
// https://drken1215.hatenablog.com/

func main() {
	var A int
	var B string
	fmt.Scan(&A, &B)
	B1, _ := strconv.Atoi(string(B[0]))
	B2, _ := strconv.Atoi(string(B[2]))
	B3, _ := strconv.Atoi(string(B[3]))
	B100 := B1*100 + B2*10 + B3
	ans := (A * B100) / 100
	fmt.Println(ans)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func abs(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}


Measured memory_bytes: 1860
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC
{
    class ProgramA
    {
        static void Main(string[] args)
        {
            var x = long.Parse(Console.ReadLine());
            var a = long.Parse(Console.ReadLine());
            var b = long.Parse(Console.ReadLine());

            var nx = x - a;
            var d = nx / b;

            Console.WriteLine(nx - (b * d));
        }
    }
}


Measured memory_bytes: 27372
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: ident) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    let mut it = s.split_whitespace();
    let s: String = parse!(it);
    let q: usize = parse!(it);
    let mut flip = false;
    let mut head = vec![];
    let mut last = vec![];
    for _ in 0..q {
        let f: usize = parse!(it);
        if f == 1 {
            flip = !flip;
        } else {
            let t: usize = parse!(it);
            let c: char = it.next().unwrap().chars().next().unwrap();
            if t - 1 == (flip as usize) {
                head.push(c);
            } else {
                last.push(c);
            }
        }
    }
    head.reverse();
    if flip {
        head.reverse();
        last.reverse();
        print!("{}", last.into_iter().collect::<String>());
        print!("{}", s.chars().rev().collect::<String>());
        println!("{}", head.into_iter().collect::<String>());
    } else {
        print!("{}", head.into_iter().collect::<String>());
        print!("{}", s);
        println!("{}", last.into_iter().collect::<String>());
    }
}


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

int main(){
  ll n;
  cin >> n;
  ll ans = 0;
  for(ll i=1;i<n+1;i++){
    ll c = n/i;
    ans += i*c + c*(c-1)*i/2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<map>
#include<cstdio>
#include<cstring>
#define ll long long
#define lson (rt<< 1)
#define rson (rt<< 1 | 1)
#define gmid ((l+r)>> 1 )
using namespace std;

const int maxn=1020;
const int maxm=1000050;
ll p[maxm],a[maxm],s[maxm],cnt=0;
bool vis[maxm];

void init()
{
	for(int i=2;i<maxn;++i)
	  {
	  	  if(!vis[i]) p[cnt++]=i;
	  	  for(int j=0;j<cnt&&p[j]*i<maxn;++j)
	  	  {
	  	  	  vis[p[j]*i]=1;
	  	  	  if(i%p[j]==0) break;
	  	  }
	  }
}
int main()
{
	init();
	int n,mx=0;
	cin>>n;
	memset(s,0,sizeof(s));
	for(int i=1;i<=n;++i)
	  {
	  	  int x;
	  	  cin>>x;
	  	  if(x>mx) mx=x;
	  	  for(int j=0;j<cnt;++j)
	  	    if(x%p[j]==0)
	  	    {
	  	    	s[p[j]]++;
	  	    	while(x%p[j]==0)
	  	    	  {
	  	    	  	  x/=p[j];
	  	    	  }
	  	    }
		  if(x>1) s[x]++; 	   
	  }
	int f1=1,f2=1;  
	for(int i=1;i<mx;++i)
	  {
	  	  if(s[i]>1) f1=0;
	  	  if(s[i]==n) f2=0;
	  }  
	if(f1)
	{
		cout<<"pairwise coprime"<<endl;
	}  
	else
	{
		if(f2)
		{
			cout<<"setwise coprime"<<endl;
		}
		else cout<<"not coprime"<<endl;
	}
	
}


Measured memory_bytes: 11404
#include<stdio.h>

int main (void) {
  int N;
  int i;
  int a, b, c;

  scanf("%d\n", &N);

  for (i = 0; i < N; i++) {
    scanf("%d %d %d", &a, &b, &c);
    if (a > b && a > c) {
      if (a*a == b*b + c*c) {
        printf("YES\n");
      }  else printf("NO\n");
    }

    else if(b > a && b > c) {
      if(b*b == a*a + c*c) {
        printf("YES\n");
      }  else printf("NO\n");
    }

    else
      if(c*c == a*a + b*b) {
        printf("YES\n");
      }  else printf("NO\n");
  }
  return 0;
}

Measured memory_bytes: 580
// Author: HarshKumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll n, k, ans;
    cin >> n >> k;
    vector<ll> p(n + 1), c(n + 1), vis(n + 1);
    for (ll i = 1; i <= n; i++)
        cin >> p[i];
    for (ll i = 1; i <= n; i++)
        cin >> c[i];
    ans = *max_element(c.begin() + 1, c.end());
    for (ll i = 1; i <= n; i++)
        if (!vis[i])
        {
            ll j = i, ts = 0, mx = -M * M;
            vector<ll> cyc;
            while (!vis[j])
                cyc.push_back(c[j]), vis[j] = 1, j = p[j];
            ll cs = cyc.size();
            for (ll e : cyc)
                ts += e;
            ll kk = k;
            for (ll i = 0; i < cs; i++)
            {
                ll s = 0;
                for (ll j = 0; j < min(cs, kk); j++)
                    s += cyc[(i + j) % cs], mx = max(mx, s);
            }
            if (ts > 0 && kk > cs)
            {
                ll q = kk / cs;
                kk -= q * cs;
                mx = (q - 1) * ts + mx;
                ll tmmx = -M * M;
                for (ll i = 0; i < cs; i++)
                {
                    ll s = 0;
                    for (ll j = 0; j < min(cs, kk); j++)
                        s += cyc[(i + j) % cs], tmmx = max(tmmx, s);
                }
                mx = max(mx, q * ts + tmmx);
            }
            ans = max(ans, mx);
        }
    cout << ans;
}

Measured memory_bytes: 3788
#include<stdio.h>
#include<string.h>
int main(){
  int max=0,len,i;
  char s[11];
  scanf("%s",s);
  len=strlen(s);
  int count=0;
  for(i=0;i<len;i++){
    if(s[i]=='A' || s[i]=='G' || s[i]=='T' || s[i]=='C'){
      count++;
      if(count>max)
        max=count;
    }
    else
      count=0;
  }
  printf("%d\n",max);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

struct UnionFind {
  vector<int> par;
  vector<int> rank;
  vector<ll> Size;
  UnionFind(int n = 1) { init(n); }

  void init(int n = 1) {
    par.resize(n + 1);
    rank.resize(n + 1);
    Size.resize(n + 1);
    for (int i = 0; i <= n; ++i)
      par[i] = i, rank[i] = 0, Size[i] = 1;
  }

  int root(int x) {
    if (par[x] == x) {
      return x;
    } else {
      int r = root(par[x]);
      return par[x] = r;
    }
  }

  bool is_same(int x, int y) { return root(x) == root(y); }

  bool merge(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y)
      return false;
    if (rank[x] < rank[y])
      swap(x, y);
    if (rank[x] == rank[y])
      ++rank[x];
    par[y] = x;
    Size[x] += Size[y];
    return true;
  }

  ll size(int x) { return Size[root(x)]; }
};

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

  ll n, m;
  cin >> n >> m;
  vector<P> v(m);
  rep(i, 0, m) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    v[i] = make_pair(a, b);
  }

  vector<ll> ans(m);
  ans[m - 1] = (n * (n - 1)) / 2;

  UnionFind uf(n);
  repr(i, 0, m - 1) {
    if (uf.is_same(v[i + 1].first, v[i + 1].second))
      ans[i] = ans[i + 1];
    else
      ans[i] = ans[i + 1] -
               (ll)(uf.size(v[i + 1].first)) * (ll)(uf.size(v[i + 1].second));
    uf.merge(v[i + 1].first, v[i + 1].second);
  }

  rep(i, 0, m) cout << ans[i] << endl;
}


Measured memory_bytes: 4480
fn main() {
    let _ = read_vec::<i32>();
    let s = read_vec::<i32>();
    let _ = read_vec::<i32>();
    let t = read_vec::<i32>();

    let mut result = 0;
    for value in t {
        if let Some(_) = binary_search(&s, value) {
            result += 1;
        }
    }
    println!("{}", result);
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line)
        .ok()
        .expect("Faild to read Vec");
    line.trim().split_whitespace()
        .map(|i| i.parse().ok().unwrap()).collect()
}

// 2分探索木
pub fn binary_search<T: Ord>(a: &[T], key: T) -> Option<usize> {
    let mut left = 0;
    let mut right = a.len();

    while left < right {
        let mid = (left + right) / 2;
        if a[mid] == key {
            return Some(mid)
        } else if key < a[mid] {
            right = mid;
        } else {
            left = mid + 1;
        }
    }
    None
}


Measured memory_bytes: 5036
/*
1,32,243,1024,3125,7776,16807,32768,59049,100000,161051,248832,371293,537824,759375,1048576,1419857,1889568,2476099,3200000,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,24300000,28629151,33554432,39135393,45435424,52521875,60466176,69343957,79235168,90224199,102400000,115856201,130691232,147008443,164916224,184528125,205962976,229345007,254803968,282475249,312500000,345025251,380204032,418195493,459165024,503284375,550731776,601692057,656356768,714924299,777600000,844596301,916132832,992436543,1073741824,1160290625,1252332576,1350125107,1453933568,1564031349,1680700000,1804229351,1934917632,2073071593,-2075960672,-1921920421,-1759441920,-1588183139,-1407792928,-1217910897,-1018167296,-808182895,-587568864,-355926653,-112847872,142085829,409302880,689241911,982351872,1289092153,1609932704,1945354155,-1999119360,-1633050899,-1250894368,-852125217,-436207616,-2594335,449273376,919965907,1410065408
*/
#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>

using namespace std;

typedef long long ll;
const ll N = 110;
ll x;

int main() {
	cin >> x;

	for (ll b = -1000; b <= 1000; b++) {
		ll t = b * b * b * b * b;
		for (ll a = b + 1; a <= 1000; a++) {
			ll tt = a * a * a * a * a;
			if (tt - t == x) {
				cout << a << " " << b << endl;
				return 0;
			}
			if (tt - t > x) {
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 3636
/*
 Copyright (c) 2019 ... All rights reserved.
 ...
*/
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;


int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

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

    // source code
    int N, M;
    vector<int> L, R;

    cin >> N >> M;
    for (int i = 0; i < M; i++){
        int l;
        int r;
        cin >> l;
        cin >> r;
        L.push_back(l);
        R.push_back(r);
    }

    int min_r = 9999999;
    int max_l = -1;

    for (int i = 0; i < M; i++){
        min_r = min(min_r, R[i]);
        max_l = max(max_l, L[i]);
    }

    int ans = 0;

    if (min_r - max_l >= 0){
        ans = min_r - max_l + 1;
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 1276
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
#include<set>
#include<queue>
#include<deque>
#include<iomanip>
#include<sstream>
#include<cmath>
#include<tuple>
#include<bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(int i = 1;i <=  n; i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(obj) begin(obj), end(obj)
typedef long long int ll;
typedef long double ld;
const ll INF = (1<<60);
int k, x, m, n, h, r, w,y,d; ll sum = 0,c; string s,t;
const ld PI = acos(-1);
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
    std::fill((T*)array, (T*)(array + N), val);
}
vector<bool> visit(100010, 0);
vector<vector<int>> G;
void dfs(int s) {
    if (visit[s]) return;
    visit[s] = 1;
    for (int i : G[s]) dfs(i);
}
int main() {
    cin >> n >> m; G.resize(n);
    rep(i, m) {
        cin >> x >> y >> d; x--; y--;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    rep(i, n) {
        if (!visit[i]) {
            sum++;
            dfs(i);
        }
    }cout << sum << endl;
}

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

int main()
{
  int N;
  cin >> N;
  int ans;
  if (N%2 == 0) {
    ans = (N/2);
  } else {
    ans = N/2 + 1;
  }
  cout << ans << endl;
}

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

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

int main()
{
	int X,Y;
	while(cin >> X >> Y, (X||Y))
	{
		int f[15][17]={0}, dp[15][17]={0};
		for(int i=0; i<Y; i++)
		for(int j=0; j<X; j++)
			cin >> f[j][i];
			
		for(int i=0; i<X; i++)
			if(f[i][0]==0) dp[i][0]=1;
			
		for(int i=0; i<Y-1; i++)
		for(int j=0; j<X; j++)
		{
			if(dp[j][i]==0) continue;
			if(f[j][i]==2)
			{
				int ty=i+2;
				if(f[j][ty]!=1)
					dp[j][ty]+=dp[j][i];
				
				continue;
			}
			
			for(int k=0; k<3; k++)
			{
				int tx=j+dx[k];
				if(tx<0||tx>=X) continue;
				if(f[tx][i+1]==1) continue;
				if(k!=1&&f[tx][i+1]==2) continue;
				
				dp[tx][i+1]+=dp[j][i];
			}
		}
		
		int ans=0;
		for(int j=-1; j<2; j++)
		for(int i=0; i<X; i++)
			ans+=dp[i][Y+j];
			
		cout << ans << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll MOD = 1000000007;
int main() {
  int N, K;
  cin >> N >> K;
  vector<ll> A(N);
  REP(i, N) cin >> A[i];
  while (K > 0) {
    vector<ll> imos(N + 10);
    REP(i, N) {

      imos[max<ll>(0, i - A[i])]++;
      imos[min<ll>(N+1, i + A[i] + 1)]--;
    }
    ll num = 0;
    ll n_num = 0;
    REP(i, N) {
      num += imos[i];
      A[i] = num;
      if (A[i] == N) n_num++;
    }
    if (n_num == N) break;
    K--;
  }
  REP(i, N) {
    cout << A[i];
    if (i != N - 1) cout << " ";
  }
  cout << endl;
}

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

int main() {
  string N;
  cin >> N;
  
  if(N[0] == '7') {
    cout << "Yes" << endl;
  }
  
  else if(N[1] == '7') {
    cout << "Yes" << endl;
  }
  
  else if(N[2] == '7') {
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3616
#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 N,M;
    cin >> N >> M;

    vector<int> divisor_list(0);
    for (int i = 1; i * i <= M; i++){
        if (M % i == 0){
            divisor_list.push_back(i);
            divisor_list.push_back(M / i);
        }
    }
    sort(all(divisor_list));
    int len = divisor_list.size();
    int ans = 1;
    rep(i,len){
        if (M / divisor_list[i] >= N){
            ans = divisor_list[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3608
#include <stdio.h>
#include <string.h>

int  main(){
 int n,i,flag;
 char S[100],T[100];
 scanf("%s%s",S,T);

 for(n=0;n<strlen(S);n++){
   flag=0;
    for(i=0;i<strlen(S);i++){
    if(S[(n+i)%strlen(S)]!=T[i]){flag=1;break;}
   }
   if(flag==0){break;}
 }
  if(flag==0){printf("Yes\n");}
  if(flag==1){printf("No\n");} 

 return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
using namespace std;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//uniform_int_distribution<int>(1000,10000)(rng)
 
ll max(ll a, ll b)
{
    if (a>b)
        return a;
    return b;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll ans[200000];
    ans[0]=0;
    for (int i=1;i<200000;++i)
        ans[i]=ans[i%(__builtin_popcount(i))]+1;
    ll b=0,n;
    string s;
    cin>>n;
    cin>>s;
    for (auto c : s)
        if (c=='1')
            ++b;
    ll bin1[n],bin2[n],sc1[n+1],sc2[n+1],c1=0,c2=0,x;
    bin1[0]=1%(max(b-1,1));
    bin2[0]=1%(b+1);
    for (int i=1;i<n;++i)
    {
        bin1[i]=bin1[i-1]*2;
        bin1[i]%=(max(b-1,1));
        bin2[i]=bin2[i-1]*2;
        bin2[i]%=(b+1);
        //cout<<bin1[i]<<" "<<bin2[i]<<" <-\n";
    }
    sc1[n]=0;sc2[n]=0;
    for (int i=n-1;i+1;--i)
    {
        sc1[i]=sc1[i+1]+(s[i]-'0')*bin1[n-1-i];
        sc1[i]%=(max(b-1,1));
        sc2[i]=sc2[i+1]+(s[i]-'0')*bin2[n-1-i];
        sc2[i]%=(b+1);
        //cout<<sc1[i]<<" "<<sc2[i]<<"\n";
    }
    for (int i=0;i<n;++i)
    {
        //cout<<"! "<<c1<<" "<<c2<<"\n";
        if (b==1&&s[i]=='1')
            cout<<"0\n";
        else if (s[i]=='1')
        {
            x=c1*2;
            x+=(1-(s[i]-'0'));
            x%=(max(b-1,1));
            x*=bin1[n-1-i];
            x+=sc1[i+1];
            //cout<<ans[x%(b-1)]+1<<" "<<x%(b-1)<<"!\n";
            cout<<ans[x%(b-1)]+1<<"\n";
        }
        else
        {
            x=c2*2;
            x+=(1-(s[i]-'0'));
            //cout<<x<<" here\n";
            x%=(b+1);
            //cout<<x<<" here\n";
            x*=bin2[n-1-i];
            //cout<<x<<" here\n";
            x+=sc2[i+1];
            //cout<<x<<" here\n";
            //cout<<ans[x%(b+1)]+1<<" "<<x%(b+1)<<"!!\n";
            cout<<ans[x%(b+1)]+1<<"\n";
        }
        c1*=2;
        c1+=((s[i]-'0'));
        c1%=(max(b-1,1));
        c2*=2;
        c2+=((s[i]-'0'));
        c2%=(b+1);
    }
    return 0;
}

Measured memory_bytes: 11592
#include <bits/stdc++.h>
using namespace std;
#define MAX 500000

int H, A[MAX+1];

void maxHeapify(int i)
{
    int left = i * 2, right = i * 2 + 1, largest;

    if ( left <= H && A[left] > A[i] ) largest = left;
    else largest = i;
    if ( right <= H && A[right] > A[largest] ) largest = right;

    if ( largest != i ) {
        swap(A[i], A[largest]);
        maxHeapify(largest);
    }
}
int main(void)
{
    int i;
    cin >> H;
    for ( i = 1; i <= H; ++i ) cin >> A[i];

    for ( i = H/2; i >= 1; --i ) maxHeapify(i);

    for ( i = 1; i <= H; ++i ) {
        cout << " " << A[i];
    }
    cout << endl;

    return 0;
}



Measured memory_bytes: 5036
A,B,C,K = map(int, input().split())
sum=0

if K>=A:
    K-=A
    sum+=A
elif K<A:
    sum+=K
    K=0

if K>=B:
    K-=B
elif K<B:
    K=0

if K>=C:
    K-=C
    sum-=C
elif K<C:
    sum-=K
    K=0

print(sum)

Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

const int N=5010;
int n,f[N],sz[N],se[N];
ll dp[N];
int find(int x) { return f[x]==x?x:f[x]=find(f[x]); }

int main() {
	scanf("%d",&n);
	for (int i=1;i<=n;i++) f[i]=i,sz[i]=1;
	for (int i=1;i<=n;i++) {
		int p;
		scanf("%d",&p);
		if (p!=-1) {
			int u=find(i),v=find(p);
			if (u!=v) {
				f[u]=v;
				sz[v]+=sz[u];
				se[v]+=se[u];
			}
			se[find(u)]+=1;
		}
	}
	VI v;
	ll ans=0;
	rep(i,1,n+1) if (find(i)==i) {
		if (se[i]==sz[i]) ans++;
		else v.pb(sz[i]);
	}
	dp[0]=1;
	rep(i,0,SZ(v)) {
		per(j,1,SZ(v)+1) dp[j]=(dp[j]+dp[j-1]*v[i])%mod;
	}
	ll ff=1;
	rep(i,2,SZ(v)+1) {
		ff=ff*(i-1)%mod;
		ans=(ans+dp[i]*ff%mod*powmod(n-1,mod-1-i))%mod;
	}
	for (auto x:v) {
		ans=(ans+(x-1)*powmod(n-1,mod-2))%mod;
	}
	ans=(n+mod-ans)%mod;
	ans=ans*powmod(n-1,SZ(v))%mod;
	printf("%lld\n",ans);
}


Measured memory_bytes: 3904
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define ll long long
//#define cccgift
//#define getchar()(p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
//char buf[1<<21],*p1=buf,*p2=buf;
template<typename T>
inline void read(T &x)
{
    static char ch;bool f=1;
    for(x=0,ch=getchar();!isdigit(ch);ch=getchar()) if(ch=='-') f=0;
    for(;isdigit(ch);x=(x<<1)+(x<<3)+(ch^48),ch=getchar());x=f?x:-x;
}
template<typename T>
void print(T x)
{
    if (x<0) x=-x,putchar('-');
    if (x>9) print(x/10);
    putchar(x%10+48);
}
template<typename T>
inline void print(T x,char ap) {print(x);if (ap) putchar(ap);}
template<typename T>
inline void chkmax(T &x,const T &y) {x=x<y?y:x;}
template<typename T>
inline void chkmin(T &x,const T &y) {x=x<y?x:y;}
int a,b,c;
int main()
{
	ios::sync_with_stdio(false);
	cin>>a>>b>>c;
	if(a+b+c>=22) cout<<"bust"<<'\n';else cout<<"win"<<'\n';
	cout<<flush;
	return 0;
}
/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?), set tle
    * do something instead of nothing and stay organized
*/ 

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int n,y,i,j,l,f=0,x,k,z;
  scanf("%d%d",&n,&y);
  for(i=0;i<n+1;i++){
    for(j=0;j+i<n+1;j++){
      l=n-(i+j);
        if(y==i*1000+j*5000+l*10000&&i+j+l==n){
        	printf("%d %d %d\n",l,j,i);
          return 0;
        }
      }
    }
    printf("-1 -1 -1\n");
  return 0;
}
        
    


Measured memory_bytes: 1692
#include <bits/stdc++.h>
#include <stdio.h>
# define M_PI  3.14159265358979323846
using namespace std;

typedef long long ll;
const int N = 2e5 + 9, M = 9e2 + 9, OO = 0x3f3f3f3f;
const double EPS = 0.00000000001;
const int mod = 1000000000+7;


int n, a, b;
vector<pair<int, int>> job;

bool check(){
  int t = 0;
  for(int i = 0 ; i < n ; ++i){
    if(t > job[i].first || t+job[i].second > job[i].first) return 0;
    t += job[i].second;
  }
  return 1;
}

int main(){

  scanf("%d", &n);
  for(int i = 0 ; i < n ; ++i){
    scanf("%d%d", &a, &b);
    job.push_back({b, a});
  }
  sort(job.begin(), job.end());
  if(check()) puts("Yes");
  else puts("No");

  return 0;
}


Measured memory_bytes: 2420
import copy

n = int(input())

goal = list(map(int, input().split(" ")))

output = -1

procReverse = []

temp_goal = copy.copy(goal)

for _ in range(n):
  index = list(range(1,len(temp_goal)+1))
  for i in range(len(temp_goal)-1, -1, -1):
    #print(i, index, temp_goal)
    if index[i] == temp_goal[i]:
      procReverse.append(temp_goal[i])
      temp_goal.pop(i)
      break
  else:
    print(-1)
    break
else:
  for i in range(n-1, -1, -1):
    print(procReverse[i])
  

Measured memory_bytes: 39280
#include <stdio.h>
#include <string.h>

int main(void)
{
	char x,y;
	scanf("%c %c",&x,&y);
	
	if(x==y){
		printf("=\n");
	} else if(x>y){
		printf(">\n");
	} else{
		printf("<\n");
	}
	return 0;
}

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

using namespace std;

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

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


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

int main()
{
    int N;
    cin >> N;
    map<ll, ll> A;

    int a;
    rep(i, N) {
        cin >> a;
        A[a]++;
    }

    for (auto mp : A) {
        if (mp.second > 1) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;

    return 0;
}

Measured memory_bytes: 12800
#include <iostream>
#include <vector>
using namespace std;
int main()
{
	vector<char> v;
	string n;
	while(cin>>n){
		for(int i=0;i<n.length();i++)
		{
			if(n[i]=='0')
				v.push_back('0');
			else if(n[i]=='1')
				v.push_back('1');
			else if(n[i]=='B' && !v.empty())
				v.pop_back();
		}
		for(int i=0;i<v.size();i++)
			cout<<v[i];
		cout<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (PrintWriter out = new PrintWriter(System.out); Scanner sc = new Scanner(System.in);) {
			Task task = new Task();
			task.solve(sc, out);
			out.flush();

		} catch (Exception e) {
			// DO NOT USE
		}
	}

	static class Task {
		public void solve(Scanner sc, PrintWriter out) {
			// TODO
			String s = nstr(sc);
			long k = nlong(sc);
			String[] a = s.split("");

			int stock = 1;
			int count = 0;
			for (String string : a) {
				count++;
				if (string.equals("1")) {
					continue;

				} else {
					stock = Integer.parseInt(string);
					break;
				}
			}
			count--;

			if (s.length() == 1) {
				out.print(s);
				return;
			}
			if (a[0].equals("1") && k == 1) {
				out.println(1);
				return;
			}
			if (a[0].equals("1")) {
				if (count >= k) {
					out.println(1);
					return;
				} else {
					out.println(stock);
					return;
				}
			}

			out.print(a[0]);

		}
	}

	// method
	static int nint(Scanner sc) {
		return Integer.parseInt(sc.next());
	}

	static long nlong(Scanner sc) {
		return Long.parseLong(sc.next());
	}

	static double ndouble(Scanner sc) {
		return Double.parseDouble(sc.next());
	}

	static float nfloat(Scanner sc) {
		return Float.parseFloat(sc.next());
	}

	static String nstr(Scanner sc) {
		return sc.next();
	}

	static long[] longLine(Scanner sc, int size) {
		long[] lLine = new long[size];
		for (int i = 0; i < size; i++) {
			lLine[i] = nlong(sc);
		}
		return lLine;
	}

	static int[] intLine(Scanner sc, int size) {
		int[] iLine = new int[size];
		for (int i = 0; i < size; i++) {
			iLine[i] = nint(sc);
		}
		return iLine;
	}

	static String[] strLine(Scanner sc, int size) {
		String[] strLine = new String[size];
		for (int i = 0; i < size; i++) {
			strLine[i] = nstr(sc);
		}
		return strLine;
	}

	static long maxFromList(List<Long> longList) {
		return longList.stream().max(Comparator.naturalOrder()).get();
	}

	static long minFromList(List<Long> longList) {
		return longList.stream().min(Comparator.naturalOrder()).get();
	}

	public static int sumDigits(int n) {
		int sum = 0;
		while (n != 0) {
			sum += n % 10;
			n /= 10;
		}
		return sum;
	}

	public static long sumDigits(long n) {
		long sum = 0;
		while (n != 0) {
			sum += n % 10;
			n /= 10;
		}
		return sum;
	}

	static List<Integer> getIntegerList(Scanner sc, int size) {
		List<Integer> list = new ArrayList<>();
		for (int i = 0; i < size; i++) {
			list.add(nint(sc));
		}
		return list;
	}

	static List<Long> getLongList(Scanner sc, int size) {
		List<Long> list = new ArrayList<>();
		for (int i = 0; i < size; i++) {
			list.add(nlong(sc));
		}
		return list;
	}
}

Measured memory_bytes: 25044
// AtCoder Beginner Contest 151
// F - Enclose All
// https://atcoder.jp/contests/abc151/tasks/abc151_f
// 最小包含円
#include <bits/stdc++.h>
using namespace std;
struct _I { _I() {cin.tie(0);ios::sync_with_stdio(false);}} __I;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class F, class S> istream& operator >> (istream& s, pair<F, S>& p)
{ cin >> p.first >> p.second; return s;}
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_h(const vector<T>& c, int n=INT_MAX)
{ rep(i, min(n, (int)c.size())) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
#define D1(a) cout<<#a<<":"<<a<<"\n"
#define D2(a,b) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<endl 
#define D3(a,b,c) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c <<endl
#define D4(a,b,c,d) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c<<","<<#d<<":"<<d<<endl 
#define MOD 1000000007

int main()
{
    int N; cin >>N;
    vector<int> T(N), A(N);
    rep(i, N) cin >> T[i] >> A[i];

    ll t = T[0], a = A[0];
    // D2(t, a);
    rep1(i, N) {
        ll mul = max((t+T[i]-1)/T[i], (a+A[i]-1)/A[i]);
        t = T[i] * mul;
        a = A[i] * mul;
        // D2(t, a);
    }

    cout << t+a << endl;
}


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

using namespace std;

int main()
{
    long long int a,b,c,d;
    cin>> a >> b >> c >>d;
    long long int ans[4];
    ans[0]=a*c;
    ans[1]=a*d;
    ans[2]=b*c;
    ans[3]=b*d;
    sort(ans,ans+4);
    cout << ans[3];
    return 0;
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1002000007
#define INF LONG_LONG_MAX

int n,x[100],ans=INF;

signed main() {
    cin >> n;
    rep(i,n) cin >> x[i];
    rep(i,101) {
        int tmp = 0;
        rep(j,n) tmp += (i-x[j])*(i-x[j]);
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
X = int(input())

if 400 <= X <= 599:
    print(8)
elif 600 <= X <= 799:
    print(7)
elif 800 <= X <= 999:
    print(6)
elif 1000 <= X <= 1199:
    print(5)
elif 1200 <= X <= 1399:
    print(4)
elif 1400 <= X <= 1599:
    print(3)
elif 1600 <= X <= 1799:
    print(2)
else:
    print(1)


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


import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


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


def read_float():
    return float(buff_readline())


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


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


def read_str_n():
    return readline().strip().split()

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


def mt(f):
    import time

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

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

    return wrap


@mt
def slv(N, A):
    S = reduce(xor, A, 0)
    ans = []
    for a in A:
        ans.append(S ^ a)
    return ans


def main():
    N = read_int()
    A = read_int_n()
    print(*slv(N, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 32740
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
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 vvi				vector< vi > 
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define loop(i,n)		for(int i=0;i<n;i++)
#define Loop(i,n)		for(int i=1;i<=n;i++)
#define sz(a)			int(a.size())
#define all(c) 			c.begin(),c.end()
#define tr(c,i) 		for(auto i = c.begin(); i != c.end(); i++)
#define present(c,x) 	(c.find(x) != c.end())
#define cpresent(c,x) 	(find(all(c),x) != c.end())
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
 
void Gur27()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
 
int32_t main()
{
    Gur27();
    set<string> s;
    w(n)
    {
        string a;
        cin>>a;
        s.insert(a);
    }
    cout<<s.size();
    return 0;
}


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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/

ll MOD = 1e9+7;
int main() {
  string l;
  cin >> l;
  RREP(i,l.length()){
    if(l[i]=='0'){
      l[i] = '1';
      break;
    }
    l[i] = '0';
    if(i==0) {
      l = "1"+l;
      break;
    }
  }
  ll tmp = 1;
  ll ans = 0;
  RREP(i,l.length()){
    if(l[i]=='1'){
      ans *= 2;
      ans += tmp;
      ans %= MOD;
    }
    tmp *= 3;
    tmp %= MOD;
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
	int A[5][4][11], n;
	for (int i = 1; i <= 4; i++)
		for (int j = 1; j <= 3; j++)
			for (int k = 1; k <= 10; k++)A[i][j][k] = 0;

	cin >> n;
	for (int i = 0; i < n; i++) {
		int n, b, f, r, v;
		cin >> b >> f >> r >> v;
		A[b][f][r] += v;
	}

	for (int f = 1; f <= 4; f++) {
		if (f > 1) {
			for (int a = 0; a < 20; a++) {
				cout << "#";
			}cout << endl;
		}
		for (int b = 1; b <= 3; b++) {
			for (int r = 1; r <= 10; r++) {
				cout << " " << A[f][b][r];
			}
			cout << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 3128
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    if (N == 3) {
        writeln("2 5 63");
    } else if (N == 4) {
        writeln("2 5 20 63");
    } else if (N == 5) {
        writeln("2 3 5 8 12");
    } else {
        int[] r;
        r.length = N;
        int i, n = 2, m;
        while (i < N) {
            r[i++] = n;
            m = (m + n) % 6;
            do {
                ++n;
            }
            while (n%2 != 0 && n%3 != 0);
        }
        switch (m) {
            case 2:
                i = 4;
                while (n%6 != 0) ++n;
                break;
            case 3:
                i = 5;
                while (n%6 != 0) ++n;
                break;
            case 5:
                i = 5;
                while (n%6 != 4) ++n;
                break;
            default:
                i = 0;
                n = r[i];
        }
        r[i] = n;
        writeln(r.to!(string[]).join(" "));
    }
}

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

#define endl '\n'

using namespace std;

const int maxn = 103;

int n, m;
int a[maxn];
void read()
{
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
}

void solve()
{
    int all = 0;
    for (int i =1; i <= n; i++)
        all += a[i];

    double border = (double)all / (4.0 * m);
    sort (a + 1, a + n + 1);
    if (a[n-m+1] < border)
    cout << "No" << endl;

    else
        cout << "Yes" << endl;
}

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

    read();
    solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>
int main(){
  int N, K;
  scanf("%d", &N);
  scanf("%d", &K);
  long long ans = 0;
  long long mod = 1e9+7;
  long long plus = 0;
  long long minus = 0;
  ans += plus-minus+1;
  ans %= mod;
  //std::cout << "ans=" << ans << std::endl;    
  for (int n=N; n>=K; n--){
    plus += n;
    minus += (N-n);
    ans += plus-minus+1;
    ans %= mod;
    //std::cout << "ans=" << ans << std::endl;    
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 3256