akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
#define mod 1000000007
#define MOD 1000000037
#define mod1 998244353
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define INF 2e9

int prime[10000010]; 
int n;
void sieve() 
{ 
    int n=10000000;
    memset(prime, -1, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == -1) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = p; 
        } 
    } 
} 

int func(int a,int p)
{
    int ans=0;
    while(a%p==0)
    {
        ans+=1;
        a/=p;
    }
    return ans;
}

vector<int>ans;
int main()
{
  	fastio;
    sieve();
    cin >> n;
    ans.resize(n+1);
    ans[1]=1;
    for(int i=2;i<=n;i++)
    {
        if(prime[i]==-1)
            ans[i]=2;
        else
        {
            int t=i/(prime[i]);
            int cnt=func(t,prime[i]);
            int tt=(ans[t]/(cnt+1))*(cnt+2);
            ans[i]=tt;
        }
    }
    lli res=0;
    for(int i=1;i<=n;i++)
        res+=ans[i]*1LL*i;
    cout << res << endl;
}

Measured memory_bytes: 81312
N, K = gets.chomp.split.map(&:to_i)

h = []
N.times do
  h << gets.to_i
end

h.sort!
min = nil
(0..(N - K)).each do |i|
  diff = h[i + K - 1] - h[i]
  if min.nil? || diff < min
    min = diff
  end
end

puts min


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

int main(){
    string s;
    cin >> s;
    int n[4];
    for(int i=0;i<4;++i){
        n[i] = s[i] - '0';
    }
    for(int i=0;i<8;++i){
        int ans = n[0];
        for(int j=0;j<3;++j){
            if((i>>j)&1){
                ans += n[j+1];
            }else{
                ans -= n[j+1];
            }
        }
        if(ans == 7){
            cout << n[0];
            for(int j=0;j<3;++j){
                if((i>>j)&1){
                    cout << '+';
                }else{
                    cout << '-';
                }
                cout << n[j+1];
            }
            cout << "=7" << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)
#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)
#define EREP(i,u) for(int i=start[u];i;i=e[i].next)
#define fi first
#define se second
#define mkr(a,b) make_pair(a,b)
#define SZ(A) ((int)A.size())
template<class T>inline void chkmin(T &a,T b){ if(a>b)a=b;}
template<class T>inline void chkmax(T &a,T b){ if(a<b)a=b;}
inline int read()
{
	int s=0,f=1;char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')ch=getchar(),f=-1;
	while(isdigit(ch))s=s*10+ch-'0',ch=getchar();
	return ~f?s:-s;
}

const int maxn=1e6+20;
const int mod=998244353;

int jc[maxn],inv[maxn],jcn[maxn];

int n,k;

inline void prepare()
{
	jc[0]=jc[1]=jcn[0]=jcn[1]=inv[1]=1;
	REP(i,2,1e6)jc[i]=(ll)i*jc[i-1]%mod,inv[i]=(ll)(mod-mod/i)*inv[mod%i]%mod,jcn[i]=(ll)jcn[i-1]*inv[i]%mod;
}

inline void init()
{
	n=read();k=read();
}

inline int C(int n,int m){ if(m<0 || n<m)return 0;return 1ll*jc[n]*jcn[m]%mod*jcn[n-m]%mod;}

inline void doing()
{
	int ans=0;
	REP(a,n,k)
	{
		int b=k-a;
		if(a>=n)
		{
			int t=a-n;
			ans=(ans+C(k,a)-C(k,a+t+1))%mod;
		}
	}
	ans=(ans+mod)%mod;
	printf("%d\n",ans);
}

int main()
{
	prepare();
	init();
	doing();
	return 0;
}


Measured memory_bytes: 11904
fun main() {
    println((1000 - nextInt() % 1000) % 1000)
}

val sc = java.util.Scanner(System.`in`)
fun next(): String = sc.next()
fun nextInt() = sc.nextInt()
fun nextIntArray(size: Int) = IntArray(size) { nextInt() }
fun nextLong() = sc.nextLong()
fun nextLine(): String = sc.nextLine()
fun nextList() = nextLine().split(" ")
fun printYesNo(isYes: Boolean) = println(if (isYes) "Yes" else "No")
fun printString(action: StringBuilder.()-> Unit) = println(buildString(action))

Measured memory_bytes: 36368
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define PDD pair<double, double>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 1, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 0) u += MOD;
    return u;

}

LL exp(LL a, LL b){
    LL sum = a;
    LL res = 1;
    while(b){
        if(b&1){
            res = (res * sum)%MOD;
        }
        sum = (sum * sum) % MOD;
        b>>=1;
    }
    return res;
}

int main(){
    int N;
    while(cin>>N&&N){
        int right=0;
        int left=0;
        int ans = 0;
        while(N>=2){
            if(right==left){
                string a;
                string b;
                cin >> a >> b;
                if(a[0]!=b[0])++ans;
                N-=2;
            }else{
                string a;
                cin>>a;
                if(a[0]=='l')++left;
                else ++right;
                --N;
            }
        }
        string d;
        REP(i, N)cin>>d;
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3160
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>

using namespace std;

const int mxx = 100000;

int H, W, h, w;

int main() {
	scanf("%d%d%d%d", &H, &W, &h, &w);
	if (!(H % h) && !(W % w)) {
		puts("No");
		return 0;
	}
	puts("Yes");
	if (H % h) {
		for (int i = 0; i < H; ++i) {
			for (int j = 1; j <= W; ++j) {
				if (i % h) { printf("%d ", -mxx); }
				else { printf("%d ", mxx * (h - 1) - 1); }
			}
			puts("");
		}
	}
	else {
		for (int i = 1; i <= H; ++i) {
			for (int j = 0; j < W; ++j) {
				if (j % w) { printf("%d ", -mxx); }
				else { printf("%d ", mxx * (w - 1) - 1); }
			}
			puts("");
		}
	}
	return 0;
}


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

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair

#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

int main(){
    double n, m;
    vector<pair<int, int> > v(4);
    while(cin >> n >> m){
        if(1.1 <= n) v[0].first++;
        else if(0.6 <= n && n < 1.1) v[1].first++;
        else if(0.2 <= n && n < 0.6) v[2].first++;
        else  v[3].first++;
        if(1.1 <= m) v[0].second++;
        else if(0.6 <= m && m < 1.1) v[1].second++;
        else if(0.2 <= m && m < 0.6) v[2].second++;
        else  v[3].second++;
    }

    rep(i, 4){
        cout << v[i].first << " " << v[i].second << endl;
    }
}

Measured memory_bytes: 1224
N=int(input())
L=[list(map(int,input().split())) for i in range(N)]
x=[]
y=[]
h=[]
for l in L:
    x.append(l[0])
    y.append(l[1])
    h.append(l[2])
Cx=0
Cy=0
H=0

for i in range(101):#Cx
    for j in range(101):#Cy
        flag=True
        for k in range(N):
            if h[k]!=0:
                H=h[k]+abs(i-x[k])+abs(j-y[k])
                break

        for k in range(N):
            if h[k]!=max(H-abs(i-x[k])-abs(j-y[k]),0):
                flag=False
                break
        
        if flag==True:
            Cx,Cy=i,j
            break
    if flag==True:
        break
print("{} {} {}".format(Cx,Cy,H))
        
        







Measured memory_bytes: 3064
N = int(input())
C = [x for x in input().split()]

def BubbleSort(C):
    N = len(C)
    for i in range(N):
        for j in reversed(range(i+1,N)):
            if C[j][1] < C[j-1][1]:
                C[j], C[j-1] = C[j-1], C[j]
    return C

def SelectionSort(C):
    N = len(C)
    for i in range(N):
        minj = i
        for j in range(i,N):
            if C[j][1] < C[minj][1]:
                minj = j
        C[i], C[minj] = C[minj], C[i]
    return C

D1 = C[:]
#注：D1 = Cだと参照渡しになる. つまり, D1を変更するとCも変更される
#C[:]を代入すると値渡しになる.
D1 = BubbleSort(D1)
for i in range(N-1):
    print(D1[i], end=" ")
print(D1[N-1])
print("Stable")

D2 = C[:]
D2 = SelectionSort(D2)
for i in range(N-1):
    print(D2[i], end=" ")
print(D2[N-1])
if D1 ==D2:
    print("Stable")
else:
    print("Not stable")



Measured memory_bytes: 5620
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;
using VL=vector<ll>;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
const long long INF =  999999999;
const int WHITE=0;
const int GREY=1;
const int BLACK=2;

int color[110],tt,n,d[110],f[110];
vector<int> g[110];

void dfs_visit(int v){
  color[v]=GREY;
  d[v]=++tt;
  REP(i,g[v].size()){
    if(color[g[v][i]]==WHITE){
      dfs_visit(g[v][i]);
    }
  }
  color[v]=BLACK;
  f[v]=++tt;
}

void dfs(){
  REP(i,n){
    color[i]=WHITE;
  }
  REP(i,n){
    if(color[i]==WHITE)dfs_visit(i);
  }

  REP(i,n){
    printf("%d %d %d\n",i+1,d[i],f[i]);
  }
}

int main(){
  cin  >>n;
  int u,k;
  REP(i,n){
    cin >>u>>k;
    u--;
    REP(i,k){
      int p;
      cin >>p;
      p--;
      g[u].push_back(p);
    }
  }
  tt=0;

  dfs();
}



Measured memory_bytes: 3264
#include <bits/stdc++.h>
#define MOD 1000000007
typedef long long int ll;
using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll t, n, inp, ans = 0;
	cin >> t >> n;
	while(t--){
		cin >> inp;
		if(inp >= n)
			ans++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long l = Long.parseLong(sc.next());
        long r = Long.parseLong(sc.next());
        long minMod = 2019;
        loop1:
        for (long i = l; i < r; i++) {
            for (long j = i + 1; j <= r; j++) {
                long tmpMod = (i * j) % 2019;
                if (tmpMod < minMod) {
                    minMod = tmpMod;
                }
                if (minMod == 0) {
                    break loop1;
                }
            }
        }
        System.out.println(minMod);
    }
}

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

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

    if (sqrtl(a * b) < (c - a - b) / 2){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <queue>
using namespace std;
int num[4];
int main()
{
        cin >> num[0] >> num[1] >> num[2];
        int cnt;
        sort(num,num+3);
        if((num[1]-num[0])%2==0)
        {
            cnt=(num[1]-num[0])/2;
            cnt=cnt+num[2]-num[1];
        }
        else
        {
            cnt=(num[1]+1-num[0])/2;
            cnt=cnt+num[2]-num[1]+1;
        }
        printf("%d\n",cnt);


}


Measured memory_bytes: 256
// -*- coding:utf-8-unix -*-

use proconio::{fastout, input};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap};

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [usize; n],
        b: [usize; n]
    }
    // Check the total numbers
    let mut a_occurrences: Vec<Vec<usize>> = vec![Vec::new(); n];
    let mut b_occurrences: Vec<Vec<usize>> = vec![Vec::new(); n];
    for i in 1..=n {
        a_occurrences[a[i - 1] - 1].push(i);
    }
    for i in 1..=n {
        b_occurrences[b[i - 1] - 1].push(i);
    }
    for j in 1..=n {
        if a_occurrences[j - 1].len() + b_occurrences[j - 1].len() > n {
            println!("No");
            return;
        }
    }
    // Generate the result
    let mut resulting_b = vec![0; n];
    let mut a_unpaired = BinaryHeap::new();
    let mut b_unpaired = BinaryHeap::new();
    for j in 1..=n {
        if a_occurrences[j - 1].is_empty() {
            continue;
        }
        a_unpaired.push((
            a_occurrences[j - 1].len(),
            a_occurrences[j - 1].len() + b_occurrences[j - 1].len(),
            j,
        ));
    }
    for j in 1..=n {
        if b_occurrences[j - 1].is_empty() {
            continue;
        }
        b_unpaired.push((
            b_occurrences[j - 1].len(),
            a_occurrences[j - 1].len() + b_occurrences[j - 1].len(),
            j,
        ));
    }
    while let Some((num1, _, j1)) = a_unpaired.pop() {
        let (mut num2, _, mut j2) = b_unpaired.pop().unwrap();
        if j1 == j2 {
            let (num3, _, j3) = b_unpaired.pop().unwrap();
            b_unpaired.push((
                num2,
                a_occurrences[j2 - 1].len() + b_occurrences[j2 - 1].len(),
                j2,
            ));
            num2 = num3;
            j2 = j3;
        }
        let i1 = a_occurrences[j1 - 1].pop().unwrap();
        let _i2 = b_occurrences[j2 - 1].pop().unwrap();
        resulting_b[i1 - 1] = j2;
        if num1 > 1 {
            a_unpaired.push((
                num1 - 1,
                a_occurrences[j1 - 1].len() + b_occurrences[j1 - 1].len(),
                j1,
            ));
        }
        if num2 > 1 {
            b_unpaired.push((
                num2 - 1,
                a_occurrences[j2 - 1].len() + b_occurrences[j2 - 1].len(),
                j2,
            ));
        }
    }
    println!("Yes");
    print!("{}", resulting_b[0]);
    for i in 2..=n {
        print!(" {}", resulting_b[i - 1]);
    }
    println!();
}


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

struct Ps{
  int r,c;
  Ps():r(0),c(0){}
  Ps(int r,int c):r(r),c(c){}
  Ps operator+(const Ps&p)const
  { return Ps(r+p.r,c+p.c);  }
  friend istream& operator>>(istream&is,Ps&p)
  {is >> p.r >> p.c; return is;  }
};

int main(){
  int h,w; cin >> h >> w;
  Ps s,g; cin >> s >> g;
  s = s+Ps(-1,-1);
  g = g+Ps(-1,-1);
  bitset<1000> mz[1000];
  for(int i = 0; i < h; ++i)for(int j = 0; j < w; ++j)
      mz[i][j] = []{char c; cin >> c; return c;}() == '.';
  optional<int> distance[1000][1000];
  deque<pair<Ps,int>> dq;
  dq.emplace_front(s,0);
  while(!dq.empty()){
    auto [ps,di] = dq.front();
    dq.pop_front();
    if(distance[ps.r][ps.c])continue;
    distance[ps.r][ps.c] = di;
    if(ps.r==g.r && ps.c==g.c)break;
    static int mr[] = {0,0,1,-1};
    static int mc[] = {1,-1,0,0};
    for(int i = 0; i < 4; ++i){
      Ps nps = ps + Ps(mr[i],mc[i]);
      if(nps.r < 0 || nps.c < 0 || nps.r >= h || nps.c >= w)continue;
      if(!mz[nps.r][nps.c])continue;
      if(distance[nps.r][nps.c])continue;
      dq.emplace_front(nps,di);
      mz[nps.r][nps.c] = 0;
    }
    for(int i = -2; i <= 2; ++i){
      for(int j = -2; j <= 2; ++j){
	if(abs(i)+abs(j)<=1)continue;
	Ps nps = ps + Ps(i,j);
	if(nps.r < 0 || nps.c < 0 || nps.r >= h || nps.c >= w)continue;
	if(!mz[nps.r][nps.c])continue;
	if(distance[nps.r][nps.c])continue;
	dq.emplace_back(nps,di+1);
      }
    }
  }
  cout << (distance[g.r][g.c] ? distance[g.r][g.c].value() : -1) << endl;
}


Measured memory_bytes: 12108
#include <iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<cmath>
#include<set>
typedef long long int ll;
using namespace std;

int main(){
    ll n,s;
    cin >> n >> s;
    
    
    ll ans=-1;
    if(s < n){//メインパート
        for(int i=2;i <= (int)sqrt(1.0*n)+1;i++){//各桁の和がsになればループ終了
            ll tmp = n;
            ll n_b=0;
            while(tmp>0){
                n_b += (tmp%i);
                tmp = tmp/i;
            }
            if(n_b == s){
                ans = i;
                break;
            }
        }
        if(ans == -1){
            //ここから先、解がn >= ans > sqrt(n)の時の処理
            for(int i = (int)sqrt(1.0*(n-s)) ; i>=1 ; i--){
                if( (n-s)%i==0 ){
                    ll b = (n-s)/i + 1;
                    if(0 <= s-i && s-i < b){
                        ans = b;
                        break;
                    }
                }
            }
        }
    }else if(s==n){
        ans = n+1;
    }else{//s > nつまり不可能
        ans = -1;
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<iostream>
#include<string>
using namespace std;

int main()
{
    string a;
    cin >> a;
    int len = a.length();
    for (int i = 0;i < len;i++)
    {
        if (a[i] == '1')
            cout << "9";
        else if (a[i] == '9')
            cout << "1";
        else
            cout << a[i];
    }
    cout << endl;
}

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

using lint = long long;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    vector<int> stones(n);
    for (int i = 0; i < n; ++i) cin >> stones[i];
    vector<int> dp(n+1, INT_MAX/2);
    dp[0] = 0;
    for (int i = 0; i < n; ++i) {
    	if (i < n-1) dp[i+1] = min(dp[i+1], dp[i] + abs(stones[i] - stones[i+1]));
    	if (i < n-2) dp[i+2] = min(dp[i+2], dp[i] + abs(stones[i] - stones[i+2]));
    }
    cout << dp[n-1] << '\n';
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int) (n); i++)
#define _GLIBCXX_DEBUG

template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int n;

int main(){
    cin >> n;
    bool poss = false;
    rep2(i, 1, 10) rep2(j, 1, 10){
      if(i*j == n) poss = true;
    }
    if(poss) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3596
abc = gets.split.map(&:to_i)
ans = 0
until abc[0] == abc[1] && abc[0] == abc[2]
  abc.sort!
  if abc[2] - abc[0] >= 2
  then
    abc[0] += 2
  else
    abc[0] += 1
    abc[1] += 1
  end
  ans += 1
end
puts ans

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

int main()
{
    ll X,K,D;cin >> X >> K >> D;
    ll first=abs(X/D);
    if (K<first){
        if (X>0) cout << abs(X-K*D) << endl;
        else cout << abs(X+K*D) << endl;
        return 0;
    }
    K-=first;
    ll now;
    if (X<0){
        now=X+D*first;
        if (K==0){
            cout << abs(now) << endl;
            return 0;
        }
        if (abs(now)>abs(now+D)){
            now=now+D;
            K-=1;
        }
    }else
    {
        now=X-D*first;
        if (K==0){
            cout << abs(now) << endl;
            return 0;
        }
        if (now>abs(now-D)){
            now=now-D;
            K-=1;
        }
    }
    if (K%2==0){
        cout << abs(now) << endl;
    }
    else{
        if (abs(now+D)<abs(now-D)) cout << abs(now+D) << endl;
        else cout << abs(now-D) << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int n,d[30][2]; bool u[30];
bool dfs(int prev){
	bool f=1;
	rep(j,n)if(!u[j])f=0;
	if(f)return 1;
	rep(i,n)if(!u[i]&&(d[i][0]==prev||d[i][1]==prev)){
		u[i]=1;
		f=dfs(d[i][0]==prev?d[i][1]:d[i][0]);
		u[i]=0;
		if(f)return 1;
	}
	return 0;
}
int main(){
	while(cin>>n){
		char b[9];
		rep(i,n)cin>>b,d[i][0]=b[0]-'0',d[i][1]=b[1]-'0',u[i]=0;
		bool f=0;
		rep(i,n)rep(j,2){
			u[i]=1;
			if(!f&&dfs(d[i][j]))f=1;
			u[i]=0;
		}
		cout<<(f?"Yes":"No")<<endl;
	}
	return 0;
}

Measured memory_bytes: 860
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int , int> P;
typedef pair<ll, ll> PL;
const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}
 

ll a,b,k;

int main(){
    cin >> a >> b >> k;

    for(int i = 0; i < k; i++){
        if(i % 2 == 0){
        if(a%2 == 1){
            --a;
        }
            b += a/2;
            a = a/2;

        }else{
        if(b%2 == 1){
            --b;
        }
            a += b/2;
            b = b/2;

        }
    }
    cout << a << ' ' << b << endl;
    
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from itertools import permutations

def gcd(a: int, b: int):
    """ https://cocodrips.hateblo.jp/entry/2014/03/05/143623
    """
    while b:
        a, b = b, a%b
    return a

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


def main():
    N = int(input())
    #K,X = map(int, input().split())
    vP = tuple(map(int, input().split()))
    vQ = tuple(map(int, input().split()))
    vA = list(range(1,N+1))

    p,q = 0,0
    for i,vI in enumerate(permutations(vA)):
        #print(i,vI)
        #if i==7: break
        if vI==vP:
            p = i
        if vI==vQ:
            q = i
    print(abs(p-q))
    #S = input().rstrip()
    #print(S)
    #print(lcm(N, M))
    #print("Yes" if X<=500*K else "No")
    #print(S.count("ABC"))


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;

int gcd(int n, int m);

int main(){
	mp::cpp_int a, b, c, d;
	cin >> a >> b >> c >> d;

	mp::cpp_int lcm = c * d / gcd(c, d);

	mp::cpp_int num_c = (b / c)- ((a - 1) / c);
	mp::cpp_int num_d = b / d - (a - 1) / d;
	mp::cpp_int num_lcm = b / lcm - (a - 1) / lcm;

	cout << b - a + 1 - (num_c + num_d - num_lcm) << endl;
	return 0;
}

mp::cpp_int gcd(mp::cpp_int n, mp::cpp_int m){
	mp::cpp_int c = n;
	mp::cpp_int d = m;
	mp::cpp_int temp;

	if (c < d) {
		temp = d;
		d = c;
		c = temp;
	}

	mp::cpp_int r = c % d;
	while (r != 0) {
		c = d;
		d = r;
		r = c % d;
	}

	return d;
}

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

bool Check(std::unordered_map<int, int>& dict) {
  if (dict.size() == 1 && dict.count(0)) {
    return true;
  }
  auto temp = dict.begin();
  if (dict.size() == 2) {
    int x = temp->first;
    temp++;
    int y = temp->first;
    if (dict[x] > dict[y]) {
    	std::swap(x, y);
    }
    if (dict[x] * 2 == dict[y] && x == 0) {
      return true;
    }
  }
  if (dict.size() == 3) {
    int x = temp->first;
    temp++;
    int y = temp->first;
    temp++;
    int z = temp->first;
    if (dict[x] == dict[y] && dict[x] == dict[z] && ((x ^ y) == z)) {
      return true;
    }
  }
  return false;
}

int main() {
  int n;
  std::unordered_map<int, int> dict;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    dict[x]++;
  }
  if (Check(dict)) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 3620
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>

using namespace std;
typedef long long ll;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define DEC(i, s) for (int i = (s); i >= 0; i--)

#define SIZE(v) (int)((v).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define FIND(m, w) ((m).find(w) != (m).end())

int w, h;
int ans;
int sx, sy, gx, gy;
int field[50][50];
const int dx[4] = { 1, -1, 0, 0 };
const int dy[4] = { 0, 0, 1, -1 };

void dfs(int depth, int x, int y) {
  if (depth == 10) { return; }
  if (depth >= ans) { return; }
  REP(i, 4) {
    int nx = x;
    int ny = y;
    if (field[y + dy[i]][x + dx[i]] == 1) { continue; }
    while (true) {
      nx += dx[i];
      ny += dy[i];
      if (nx < 0 || nx >= w || ny < 0 || ny >= h) { goto next; }
      if (nx == gx && ny == gy) {
        ans = min(ans, depth + 1);
        return;
      }
      if (field[ny][nx] == 1) {
        field[ny][nx] = 0;
        nx -= dx[i];
        ny -= dy[i];
        break;
      }
    }
    dfs(depth + 1, nx, ny);
    field[ny + dy[i]][nx + dx[i]] = 1;
next:;
  }
}

int main() {
  while (scanf("%d %d", &w, &h), w|h) {
    REP(y, h) REP(x, w) {
      scanf("%d", &field[y][x]);
      if (field[y][x] == 2) { sx = x; sy = y; }
      if (field[y][x] == 3) { gx = x; gy = y; }
    }
    ans = 100;
    dfs(0, sx, sy);
    if (ans == 100) {
      puts("-1");
    } else {
      printf("%d\n", ans);
    }
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    int n;
    cin >> n;
    vector<int> t(n), x(n),y(n);
    rep(i,n) cin >> t[i] >> x[i] >> y[i];
    int nowx = 0, nowy = 0;
    rep(i,n){
        if(i == 0){
            if(x[i] + y[i] > t[i]){
                cout << "No" << endl;
                return 0;
            }else{
                if((x[i] + y[i])%2 == 0 && t[i]%2 == 0) continue;
                else if((x[i] + y[i])%2 != 0 && t[i]%2 != 0) continue;
                else{
                    cout << "No" << endl;
                    return 0;
                }
            }
        }else{
            if(abs(x[i]  + y[i] - x[i-1] - y[i-1]) > t[i] - t[i-1]){
                cout << "No" << endl;
                return 0;
            }else{
                if(abs(x[i]  + y[i] - x[i-1] - y[i-1])%2 == 0 && (t[i]-t[i-1])%2 == 0) continue;
                else if(abs(x[i]  + y[i] - x[i-1] - y[i-1])%2 != 0 && (t[i]-t[i-1])%2 != 0) continue;
                else{
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "Yes" << endl;
    return 0; 
}

Measured memory_bytes: 4256
#include <stdio.h>
#define MAX 100000
int main(){
	int n1,n2,cnt=0,i=0,j=0;
	int s[MAX],key;
	int right,left,mid;
	
	
	scanf("%d",&n1);
	
	for(i=0;i<n1;i++){
		scanf("%d",&s[i]);
	}
	
	scanf("%d", &n2);
	

	for(j=0;j<n2;j++){
		scanf("%d",&key);
		left = 1;
		right = n1;
		while(left < right){
			mid = (left+right)/2;
			//printf("left:%d\nmiddle:%d\nright:%d\n\ncnt:%d\n",left,mid,right,cnt);
			if( s[mid] > key ) right = mid;
			
			else if( s[mid] < key ) left = mid + 1;
			
			else if(s[mid]==key){
				cnt++;
				break;
			}
		}
	}
	printf("%d\n",cnt);
	return 0;
}
		


Measured memory_bytes: 2088
(function(input) {
    var p = input.split('\n');
    var n = Number(p.shift());
    var A = p.slice(0, n);
    var C = [].concat(A);

    partition(A, 0, A.length - 1);
    console.log(check(C, A) ? 'Stable' : 'Not stable');
    console.log(A.join('\n'));
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

function getNumber(a) {
    return Number(a.slice(1, a.length));
}

function getWords(a, n) {
    var r = '';
    for (var i = 0; i < a.length; i++) {
        if (getNumber(a[i]) === n) {
            r += a[i];
        }
    }
    return r;
}

function check(c, a) {
    var i = 0;
    while (i < a.length) {
        var n = getNumber(c[i]);
        if (getWords(c, n) !== getWords(a, n)) {
            return false;
        }

        i++;
    }
    return true;
}

function partition(A, p, r) {
    //console.log(A, p, r);
    if (p >= r || r >= A.length) {
        return;
    }
    var flg = true;
    var minj = p;
    for (var j = p + 1; j <= r; j++) {
        if (getNumber(A[minj]) > getNumber(A[j])) {
            flg = false;
        }
        minj = j;
    }
    if (flg) {
        return;
    }

    //var rnd = Math.floor(Math.random() * (r - p)) + p;
    ////console.log(rnd);
    //var tmp = A[r];
    //A[r] = A[rnd];
    //A[rnd] = tmp;

    var x = A[r];
    var i = p - 1;
    var flg = false;
    for (var j = p; j <= r - 1; j++) {
        if (getNumber(A[j]) <= getNumber(x)) {
            i++;
            var tmp = A[i];
            A[i] = A[j];
            A[j] = tmp;
        }
    }
    var tmp = A[i + 1];
    A[i + 1] = A[r];
    A[r] = tmp;

    //console.log(i + 1);
    partition(A, p, i);
    partition(A, i + 2, r);
}

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

typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    set<string> st;
    int n;
    cin >> n;
    string com,str;
    for(int i=0;i<n;i++){
        cin >> com >> str;
        if(com == "insert"){
            st.insert(str);
        }else{
            auto itr = st.find(str);
            if(itr != st.end())cout << "yes\n";
            else cout << "no\n";
        }
    }
}



Measured memory_bytes: 29792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("abc161/abc161_c.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  long N, K;
  cin >> N >> K;

  long ret = N % K;
  ret = min(ret, abs(ret - K));

  cout << ret << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		while(scanner.hasNextLine()){
			String[] input = scanner.nextLine().split(" ");
			int a = Integer.parseInt(input[0]);
			int b = Integer.parseInt(input[2]);

			if(input[1].equals("+")){
				System.out.println(a+b);
			}else if(input[1].equals("-")){
				System.out.println(a-b);
			}else if(input[1].equals("*")){
				System.out.println(a*b);
			}else if(input[1].equals("/")){
				System.out.println(a/b);
			}else{break;}
		}
	}
}

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

using namespace std;




int main()
{
    string s;
    cin>>s;
    int count = 0;
    for(int i = 0;i<3;i++)
        if(s[i] == 'R')
            count++;
    if(count == 2 && s[1] == 'S')
        count--;
    cout<<count;
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

ll a;
V vi;

int main(){
	REP(i, 5){
		cin >> a;
		vi.push_back(a);
	}
	sort(ALL(vi), greater<int>());
	REP(i, 5){
		cout << vi[i];
		if (i == 4)cout << endl;
		else cout << " ";
	}
}

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

int main(){
	string Class;
	double n;
	
	while( cin >> n){
		if(n<=48.00){
			Class = "light fly";			
		}else if(n<=51.00){
			Class = "fly";
		}else if(n<=54.00){
			Class = "bantam";
		}else if(n<=57.00){
			Class = "feather";
		}else if(n<=60.00){
			Class = "light";
		}else if(n<=64.00){
			Class = "light welter";
		}else if(n<=69.00){
			Class = "welter";
		}else if(n<=75.00){
			Class = "light middle";
		}else if(n<=81.00){
			Class = "middle";
		}else if(n<=91.00){
			Class = "light heavy";
		}else{
			Class = "heavy";
		}
		cout << Class << endl;
	}
	return 0;
}

Measured memory_bytes: 0
const val mod = 1000000007L

fun main() {
    val input = rspint()
    function(input[0], input[1])
}

fun function(n: Int, k: Int) {
    val nums = LongArray(k + 1)
    var sum = 0L
    for (i in k downTo 1) {
        val num = k / i
        nums[i] = pow(num, n)
        for (j in 2..num) {
            nums[i] -= nums[i * j]
        }
        sum += i * (nums[i])
    }
    println(sum % mod)
}

fun pow(a: Int, b: Int): Long {
    var r = 1L
    var s = a.toLong()
    var t = b
    while (t > 0) {
        if (t % 2 != 0) {
            r = r * s % mod
        }
        s = s * s % mod
        t /= 2
    }
    return r
}

fun rl() = readLine()!!
fun rsp() = readLine()!!.split(" ")
fun rint() = readLine()!!.toInt()
fun rspint() = readLine()!!.split(" ").map { it.toInt() }

Measured memory_bytes: 37232
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>

using namespace std;
typedef long long ll;
double A, B, H, M;

double dist(double x1, double x2, double y1, double y2){
    return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2)); 
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> A >> B >> H >> M;
    double x1 = A*cos(2.0*M_PI*(H/12.0+M/(12.0*60.0)));
    double y1 = A*sin(2.0*M_PI*(H/12.0+M/(12.0*60.0)));
    double x2 = B*cos(2.0*M_PI*M/60.0);
    double y2 = B*sin(2.0*M_PI*M/60.0);
    cout << dist(x1, x2, y1, y2) << endl;
}

Measured memory_bytes: 4112
#include <stdio.h>
#include <vector>
#include <algorithm>
#define pb push_back
using namespace std;

const int MAXN = (int)1e5 + 5;

vector<int> g[MAXN];
int dp[MAXN];

int solve(int node) {
    if (dp[node]) return dp[node];

    dp[node] = 1;
    for (int i = 0; i < (int)g[node].size(); i++) {
        int viz = g[node][i];
        dp[node] = max(dp[node], 1 + solve(viz));
    }
    return dp[node];
}

int main(void) {
    int n, m;
    int x, y;

    scanf(" %d %d", &n, &m);
    for (int i = 0; i < m; i++) {
        scanf(" %d %d", &x, &y);
        g[x].pb(y);
    }

    int ans = 0;
    for (int i = 1; i <= n; i++) {
        ans = max(ans, solve(i) - 1);
    }
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 8192
n=int(input())
a=list(map(int,input().split()))

d={}


for i in range(n):
    if a[i] in d:
        d[a[i]]+=1
    else:
        d[a[i]]=1

can = list(d.items())

edge=[]
for i in range(len(can)):
    if can[i][1]<2:
        continue
    else:
        edge.append(can[i])

if len(edge)==0:
    print(0)
    exit(0)
elif len(edge)==1 and edge[0][1]<4:
    print(0)
    exit(0)
elif len(edge)==1 and edge[0][1]>=4:
    print(edge[0][0]**2)
    exit(0)

edge = sorted(edge,key=lambda x: x[0],reverse=True)

k=len(edge)

s=1
if edge[0][1]>=4:
    print(edge[0][0]**2)
else:
    print(edge[0][0]*edge[1][0])





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

int main()
{
    int n;
    cin>>n;
    vector<int> a(n);
    REP(i,n)cin>>a[i];
    int q;
    cin>>q;
    REP(i,q)
    {
        int b,e,k;
        cin>>b>>e>>k;
        vector<int>::iterator ib=a.begin(),ie=a.begin();
        ib+=b;ie+=e;
        cout<<count(ib,ie,k)<<endl;
    }
}


Measured memory_bytes: 3080
#include<bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds;

#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout) 
#define lli long long int
#define pb push_back
#define pob pop_back
#define rep(i,a,b) for(lli i=a;i<b;i++)
#define repv(a,b) for(int i=a;i>=b;i--)
#define itr vector<lli> :: iterator
#define maximum(a,b,c)  max(a,max(b,c))
#define minimum(a,b,c) min(a,min(b,c))
#define tim clock_t

inline void fast()
{
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}


void solve()
{
	lli a,b,ctr=0;
	cin>>a>>b;
	
  lli c=1;
  while(c<b)
  {
   	c+=(a-1);
    ctr++;
  }
cout<<ctr;
}

int main()
{
	fast();
	lli t=1,n,m;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    A, B, C = map(int, readline().split())
    if A%2==0 or B%2==0 or C%2==0:
        ans = 0
    else:
        ans = min(A*B, B*C, C*A)
    print(ans)



if __name__ == '__main__':
    main()

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

using namespace std;

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> D(K);

	for (int i = 0; i < K; i++) {
		cin >> D.at(i);
	}

	int ans = N;
	bool cdt = false;

	while (!cdt) {
		cdt = true;
		for (int i = 0; i < K; i++) {
			int a = ans;
			while (a > 0) {
				if (a % 10 == D.at(i)) {
					cdt = false;
					ans++;
					break;
				}
				a /= 10;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

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

using LL = long long;

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); ++(i))
#define RFOR(i, a, b) for (int(i) = (a); (i) > (b); --(i))
#define SORT(x) sort(ALL((x)))
#define RSORT(x) sort(RALL((x)))
#define SZ(x) (int)(x).size()
#define debug(x) cerr << #x << " : " << x << '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const LL LINF = 1e18;

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

  string ans;
  int N, M;
  cin >> N >> M;

  if(N == M){
    ans = "Yes";
  } else {
    ans = "No";
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int N;
    cin >> N;
    int L = N*2;
    string S,T;
    cin >> S >> T;

    string U[L];

    int j=0,k=0;

    for(int i=0;i<L;i++){
        if(i==0||i%2==0) {
            cout << S[j];
            j++;
        }
        else{
            cout << T[k];
            k++;
        }
    }

    return 0;
 
}

Measured memory_bytes: 3556
from collections import defaultdict
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    n, l = map(int, input().split())
    ss = [input()[:-1] for _ in range(n)] + ["$"]
    ss.sort()
    # print(ss)

    # 隣同士のsを先頭から比べて、異なるところでそのlevelの木を消して、それ以降の木を追加する
    cnt_tree = defaultdict(int)
    cnt_tree[l] = 2
    for s0, s1 in zip(ss, ss[1:]):
        for depth, (c0, c1) in enumerate(zip(s0, s1)):
            if c0 == c1: continue
            cnt_tree[l - depth] -= 1
            for lv in range(l - depth - 1, l - len(s1), -1):
                cnt_tree[lv] += 1
            # print(cnt_tree)
            break

    # Grundy数をlv & -lvで求め、xorをとる
    sum_xor = 0
    for lv, cnt in cnt_tree.items():
        if cnt % 2 == 0: continue
        sum_xor ^= lv & -lv

    if sum_xor:
        print("Alice")
    else:
        print("Bob")

main()


Measured memory_bytes: 15456
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	ll a, b, c;
	std::cin >> a >> b >> c;
	if (b - a == c - b) {
		std::cout << "YES";
	}
	else {
		std::cout << "NO";
	}

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int calc(int a, int b) {
    return ((b - 1) + (a - 2)) / (a - 1);
}

int main(void) {
    int a, b;

    scanf("%d %d", &a, &b);

    printf("%d\n", calc(a, b));

    return 0;
}


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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    int a,b;
    cin >> a >> b;
    if(a%3==0||b%3==0||(a+b)%3==0){
        cout << "Possible"
             << "\n";
    }else{
        cout << "Impossible"
             << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(void){
    int a,b;
    while(1){
        std::cin >> a >> b;
        if(!a && !b) break;
        if(a>b){
            std::cout << b << " " << a << std::endl;
        }else{
            std::cout << a << " " << b << std::endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3004
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long 
int arr[100000+5];
int nums[100000+5];

int main(int argc, char const *argv[])
{
	int n;
	while(~scanf("%d",&n)){
		memset(nums,0,sizeof(nums));
		for (int i = 0; i < n ; ++i)
		{
			scanf("%d",&arr[i]);
			arr[i]++;
		}
		ll ans=1;
		nums[0]=3;
		for (int i = 0; i < n; ++i){
			// printf("arr[%-2d]==%d  3-num[%-2d] == %-2d ,pre numscnt==%-2d  ,min==%-2d\n",i,arr[i],arr[i],3-nums[arr[i]],nums[ arr[i]-1 ],min(3-nums[ arr[i] ],nums[ arr[i]-1 ]) );
			ans=(ans%mod*min(3-nums[ arr[i] ],nums[ arr[i]-1 ]-nums[ arr[i]]))%mod;
			nums[ arr[i] ]++;
	
		}
		printf("%lld\n",ans );
	}
	return 0;
}	

Measured memory_bytes: 1024
// BWOTSHEWCHB

#include <bits/stdc++.h>

using namespace std ;

#define int long long
#define pb push_back
#define in insert
#define X first
#define Y second

const int MAXN = 1e6 + 69 , MOD = 1e9 + 7 ;

string str ;
int n , occ[30] ;

int32_t main() {
	ios::sync_with_stdio(false) ;
	cin.tie(0) ; cout.tie(0) ;
	cin >> n >> str ;
	int ans = 1 ;
	for ( int i = 0 ; i < n ; i ++ )
		occ[str[i] - 'a'] ++ ;
	for ( int i = 0 ; i < 26 ; i ++ )
		ans = (ans * (occ[i] + 1)) % MOD ;
	cout << ans - 1 << "\n" ;
}


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


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

    cout<<max(max(a+b,a-b),a*b)<<endl;


    return 0;
}

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

long long a[100005];

int main(){
	long long k,i;
	cin >> k;
	long long ans_min,ans_max;
	for(i=0;i<k;i++){
		cin >> a[i];
	}
	ans_min = 2;
	ans_max = 2;
	bool flag = true;
	if(k==1&&a[0]!=2) flag = false;
	for(i=k-1;i>=0;i--){
		if(a[i]>ans_min&&a[i]>ans_max){
			flag = false;
			break;
		}
		else{
			if(ans_min%a[i]) ans_min += a[i];
			ans_min = (ans_min/a[i])*a[i];
			ans_max = (ans_max/a[i]+1)*a[i]-1;
			if(ans_min>ans_max){
				flag = false;
				break;
			}
		}
	}
	if(ans_min<2||ans_max<2) flag = false;
	if(flag){
		cout << ans_min << " " << ans_max << endl;
	}
	else{
		cout << -1 << endl;
	}
	return 0;
}

Measured memory_bytes: 1024
n,m,l = list(map(int,input().split()))
A = [list(map(int,input().split())) for i in range(n)]
B = [map(int,input().split()) for i in range(m)]
B_T = list(map(list, zip(*B)))
for a in A:
    row = []
    for b in B_T:
        row.append(sum([x*y for (x,y) in zip(a,b)]))
    print(' '.join(map(str,row)))

Measured memory_bytes: 9056
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int n,p;
    cin>>n>>p;
    if (n==1) {
        cout<<p<<endl;
    } else {
        long long int ans=0;
        for (long long int i=1;powl(i,n)<=p;i++) {
            if (p%long(powl(i,n))==0) {
                ans=max(ans,i);
            }
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 3704
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
    return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
    return a > b && (a = b, true);
}
/*-------------------------------------------*/

int D;
int c[26];
ll s[365][26];

int last[26];

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

    cin >> D;
    rep(i, 26) cin >> c[i];
    rep(i, D) rep(j, 26) cin >> s[i][j];

    rep(d, D) {
        ll a = -1, mx = -1;
        rep(i, 26) if(chmax(mx, (d + 1 - last[i]) * c[i] + s[d][i])) a = i;
        cout << a + 1 << endl;
        last[a] = d + 1;
    }

    return 0;
}

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

int main(){
	int a,b;
	cin >> a >>b;
	if(a==b)cout << "Draw" << endl;
	else if(a==1||b==1)cout << (a==1?"Alice":"Bob") << endl;
	else cout << (a>b?"Alice":"Bob") << endl;
	return 0;
}

Measured memory_bytes: 256
#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 a, b, c, k;
    cin >> a >> b >> c >> k;
    int ans = 0;
    if (a >= k) ans = k;
    else {
        ans += a;
        if (a+b < k) ans -= k-(a+b);
    }
    cout << ans << endl;
    return 0;
}

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

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


Measured memory_bytes: 256
from scipy.misc import comb

def f2(n, k):
    return comb(n+k-1, k-1, exact=True)

def f(n, k):
    if n < k:
        return 0
    if n == 0 and k == 0:
        return 1
    if k < 1:
        return 0

    return f2(n-k, k)


if __name__ == "__main__":
    N, K = map(int, input().split())

    blue = K
    red = N - K

    for i in range(1, K+1):
        blue = f(K, i)
        red = f2(N-K-(i-1), i+1)
        ans = blue * red
        print(int(ans % 1000000007))


Measured memory_bytes: 15204