akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main () {
    int X, Y; cin >> X >> Y;

    if (X % Y == 0) cout << -1 << endl;
    else {
        int i = 1;
        while (1) {
            i *= X;
            if (i % Y != 0) break;
        }
        cout << i << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"
template<class T> void chmax(T &a, const T b){ a = max(a, b); }
template<class T> void chmin(T &a, const T b){ a = min(a, b); }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    vector<vector<pair<ll, ll>>> g(n);
    rep(i, n - 1) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(make_pair(b, i));
        g[b].push_back(make_pair(a, i));
    }
    vector<ll> ans(n - 1, -1);
    rep(from, n) {
        set<ll> used;
        for(auto &x : g[from]) {
            ll to = x.first, idx = x.second;
            if (ans[idx] != -1) {
                used.insert(ans[idx]);
            }
        }
        ll val = 1;
        for(auto &x : g[from]) {
            ll to = x.first, idx = x.second;
            if (ans[idx] != -1) continue;
            while(used.count(val) > 0) {
                val++;
            }
            ans[idx] = val;
            val++;
        }
    }
    cout << *max_element(all(ans)) << endl;
    rep(i, n - 1) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 11156
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007ll
#define INF 1000000000
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

int H, W; cin >> H >> W;
VVI c(10, VI(10)), A(H, VI(W));
rep(i, 0, 10) rep(j, 0, 10) cin >> c[i][j];
rep(i, 0, H) rep(j, 0, W) cin >> A[i][j];
int ans = 0;

rep(k, 0, 10) rep(i, 0, 10) rep(j, 0, 10)
    if(c[i][j] > c[i][k] + c[k][j]) c[i][j] = c[i][k] + c[k][j];

rep(i, 0, H) {
    rep(j, 0, W){
        if (A[i][j] == -1) continue;
        ans += c[A[i][j]][1];
    }
}
cout << ans << "\n";
}

// 境界，出力文字列 チェック



Measured memory_bytes: 384
H,W=map(int,input().split())
A=[]
count=0
for i in range(H):
    a=input()
    A.append(a)
chk=[[0 for _ in range(W)] for i in range(H)]
if A[0][0]=="#":
    chk[0][0]=1
    count+=1
else:
    print("Impossible")
    exit()

for i in range(H):
    for j in range(W):
        if i==0 and j==0:
            continue
        if A[i][j]==".":
            continue
        count+=1
        if i!=0:
            if A[i-1][j]=="#":
                if chk[i-1][j]!=0:
                    chk[i][j]=1
        if j!=0:
            if A[i][j-1]=="#":
                if chk[i][j-1]!=0:
                    chk[i][j]=1
if count!=(W+H-1):
    print("Impossible")
    exit()
if chk[-1][-1]==1:
    print("Possible")
else:
    print("Impossible")

Measured memory_bytes: 38256
n, m = [int(i) for i in input().split()]
dp = [[float("inf") for i in range(2**n)] for j in range(m+1)]
dp[0][0] = 0

for i in range(m):
    a, _ = [int(_) for _ in input().split()]
    c = sum([2**(int(_)-1) for _ in input().split()])

    for j in range(2**n):
        dp[i+1][j|c] = min(dp[i][j|c], dp[i][j] + a, dp[i+1][j|c])
        dp[i+1][j] = min(dp[i][j], dp[i+1][j])

print([dp[-1][-1], -1][dp[-1][-1] == float("inf")])

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


int main() {
  int n; cin>>n;
  vector<int>  vec(n),v(n);
 //vector<int> v(n)==vec(n);
  for(int i=0;i<n;i++){
    cin>>vec.at(i);
    v.at(i)=vec.at(i);//順番に注意,vにvecの値を代入する
   // cout<<vec.at(i);
  }
  sort (vec.begin(),vec.end());
  for(int i=0;i<n;i++){
    if(v.at(i)<=vec.at(n/2-1))cout<<vec.at(n/2)<<endl;
    else{cout<<vec.at(n/2-1)<<endl;}
  }
  
}






Measured memory_bytes: 3712
x, y = map(int, input().split())
mod = 10**9+7 
def check(x, y):
  if (2*y-x)/3 < 0 or (2*x -y)/3 < 0:
    return False
  if (x+y)%3 != 0:
    return False
  return True

def modPow(a, n, mod):
  if n == 1:
    return a % mod
  if n%2 == 1:
    return (a * modPow(a, n - 1, mod)) % mod
  t = modPow(a, n / 2, mod)
  return (t * t) % mod

def comb(n, r, mod):
    r = min(r, n-r)
    x, y  = 1, 1
    for i in range(1, r+1):
      y =  y* i % mod
      x =  x* (n+1-i) % mod
    return x * modPow(y, mod-2, mod) % mod
  
if check(x, y):
  print(comb((2*y-x)//3+(2*x -y)//3, (2*y-x)//3, mod))
else:
  print(0)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define sz(a) int((a).size())
#define pb push_back
#define allc c.begin(),c.end()
#define tr(c,i) for(typeof(c).begin() i = c.begin(); i != c.end(); i++)
#define present(c,x) (c.find(x) != c.end())
#define cpresent(c,x) (find(allc,x) != c.end())
using namespace std;
#define ll long long
bool isPalindrome(string str)
{
    int l = 0;
    int h = str.size() - 1;
    while (h > l)
    {
        if (str[l++] != str[h--])
        {
            return 0;
        }
    }
   return 1;
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	string s;
	cin>>s;
	int n = s.size();
	string s2 = s.substr(0,(n-1)/2);
	string s3 = s.substr((n+1)/2,(n-1)/2);
	if(isPalindrome(s)&&isPalindrome(s2)&&isPalindrome(s3))
        cout<<"Yes"<<endl;
    else
        cout<<"No";

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;


void solve(){
  int n,m;
  cin >> n >> m;
  string ans = (n==m ? "Yes": "No");
  cout << ans << endl;
}

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


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

int main(){
	string input;
	while(cin >> input){
		for(int i=0; i < input.size(); i++){
			if(input[i] == '@'){
				i++;
				int n = input[i] - '0';
				i++;
				for(int j=0; j < n; j++){
					cout << input[i];
				}
			}
			else cout << input[i];
		}
		cout << endl;
	}
}

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

int n, k, x[100], ans = 0;

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

	for (int i = 0; i < n; i++) {
		ans += 2 * min(x[i], abs(x[i] - k));
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())




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

	string n;
	cin >> n;
	int dp[11][2][1 << 3] = {};

	
	dp[0][0][0] = 1;
	rep(i, n.size()) {
		rep(c, 2)rep(j,1<<3)if(dp[i][c][j]) {
			if ('3' <= n[i] || c==1) {
				dp[i + 1][c || n[i] > '3'][j | 1] += dp[i][c][j];
			}
			if ('5' <= n[i] || c == 1) {
				dp[i + 1][c || n[i] > '5'][j | 2] += dp[i][c][j];
			}
			if ('7' <= n[i] || c == 1) {
				dp[i + 1][c || n[i] > '7'][j | 4] += dp[i][c][j];
			}
		}
	}
	int ans = dp[n.size()][0][7] + dp[n.size()][1][7];
	int p3 = 27;
	for (int i = 3; i < n.size();i++) {
		ans += p3 - 3 * ((1 << i) - 2) - 3;
		p3 *= 3;
	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<utility>
#include<vector>
#include<cstdio>
using namespace std;
void check();
void syoki();
#define DEBUG for(int i=1;i<=n;i++){for(int j=1;j<=n;j++){cout<<square[j][i]<<" ";}cout<<endl;}
int n,add=2;
    pair<int,int> ad;//x,y
vector<vector<int> >square(20,vector<int>(20,-1)) ;
int main(){
    while(1){
        cin>>n;
        if(n==0){
            break;
        }
        ad.first=n/2+1;
        ad.second=n/2+2;
        square[ad.first][ad.second]=1;
        while(1){
            if(add==n*n+1)break;
            add+=1;
            ad.first+=1;
            ad.second+=1;
            check();
            if(square[ad.first][ad.second]!=-1){
                ad.first-=1;
                ad.second+=1;
                check();
                square[ad.first][ad.second]+=add;
            }
            else{
                square[ad.first][ad.second]+=add;
            }
        }
            for(int i=1;i<=n;i++){
                for(int j=1;j<=n;j++){
                    if(j==n && i==n){
                        printf("%4d",square[j][i]);
                    }
                    else{
                        printf("%4d",square[j][i]);
                    }
                }cout<<endl;
            }
        syoki();
    }
    return 0;
}
void check(){
    if(ad.first>n){
                ad.first=1;
            }
            if(ad.first<=0){
                ad.first=n;
            }
            if(ad.second>n){
                ad.second=1;
            }
    return ;
}
void syoki(){
    for(int i=0;i<20;i++){
        for(int j=0;j<20;j++){
            square[i][j]=-1;
        }
    }
    add=2;
    return ;
}

Measured memory_bytes: 3264
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
int main(void){
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    cout << H * W - (h * W + w * (H - h));
}

Measured memory_bytes: 256
package main

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

func main() {
	var n int
	fmt.Scan(&n)

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	par := make([]int, 200000)
	xcount := make([]int, 200000)
	ycount := make([]int, 200000)
	for i := 0; i < 200000; i++ {
		par[i] = i
	}
	for i := 0; i < 100000; i++ {
		xcount[i] = 1
	}
	for i := 100000; i < 200000; i++ {
		ycount[i] = 1
	}

	root := func(i int) int {
		for par[i] != i {
			i = par[i]
		}
		return i
	}

	union := func(x int, y int) {
		xroot := root(x)
		yroot := root(y)
		if xroot == yroot {
			return
		}

		par[xroot] = yroot
		xcount[yroot] += xcount[xroot]
		ycount[yroot] += ycount[xroot]
	}

	for i := 0; i < n; i++ {
		scanner.Scan()
		x, _ := strconv.Atoi(scanner.Text())
		x = x - 1
		scanner.Scan()
		y, _ := strconv.Atoi(scanner.Text())
		y = y + 99999
		union(x, y)
	}

	var sum int
	for i := 0; i < 200000; i++ {
		if root(i) == i {
			sum += xcount[i] * ycount[i]
		}
	}

	fmt.Println(sum - n)
}


Measured memory_bytes: 6272
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll a,b;
    cin >> a >> b;
    cout << a*b;
    return 0;
}


Measured memory_bytes: 3156
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
#define dbg(x...) do { cout << "\033[32;1m" << #x <<" -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<class T, class... Ts> void err(const T& arg,const Ts&... args) { cout << arg << " "; err(args...); }
const int N = 100 + 5;
typedef double db;
const db eps = 1e-8;
const db INF = 1e20;
const db pi = acos(-1.0);
const int maxp = 1010;
// Compares a double to zero
int sgn(db x){
    if(fabs(x) < eps) return 0;
    if(x < 0) return -1;
    return 1;
}
struct Point{
    db x, y;
    Point(){}
    Point(db x, db y):x(x), y(y){}
    void input(){
        //如果为longdouble则需要改为Lf
        scanf("%lf%lf",&x, &y);
    }
    bool operator < (Point b)const{
        return sgn(x-b.x) == 0 ? sgn(y - b.y) < 0 : x < b.x;
    }
    //叉积
    db operator ^ (const Point &b)const{
        return x * b.y - y * b.x;
    }
    //点积
    db operator * (const Point &b)const{
        return x * b.x + y * b.y;
    }
    Point operator - (const Point &b)const{
        return Point(x - b.x, y - b.y);
    }
    Point operator + (const Point &b)const{
        return Point(x + b.x, y + b.y);
    }
    //返回两点距离 
    db distance(Point p){
        return hypot(x - p.x, y - p.y);
    }
    // 返回长度
    db len(){
        return hypot(x, y);
    } 
    // 化为长度为 r 的向量
    Point trunc(db r){
        db l = len();
        if(!sgn(l)) return *this;
        r /= l;
        return Point(x*r, y*r);
    }
    // 逆时针旋转90度
    Point rotleft(){
        return Point(-y, x);
    }
    // 顺时针转90度
    Point rotright(){
        return Point(y, -x);
    }
};
struct circle{
    Point p;
    db r;
    circle(){}
    circle(Point p, db r):p(p), r(r){}
    void input(){
        p.input();
        // 注意类型
        scanf("%lf", &r);
    }
    /*
        两圆的关系
        5 相离
        4 外切
        3 相交
        2 内切
        1 内含
    */
    int relationcircle(circle v){
        db d = p.distance(v.p);
        if(sgn(d - r - v.r) > 0) return 5;
        if(sgn(d - r - v.r) == 0) return 4;
        db l = fabs(r - v.r);
        if(sgn(d - r - v.r) < 0 && sgn(d - l) > 0) return 3;
        if(sgn(d - l) == 0) return 2;
        if(sgn(d - l) < 0) return 1;
    }
    int pointcrosscircle(circle v, Point &p1, Point &p2){
        int rel = relationcircle(v);
        if(rel == 1 || rel == 5) return 0;
        db d = p.distance(v.p);
        db l = (d * d + r * r - v.r * v.r) / (2 * d);
        db h = sqrt(r * r - l * l);
        Point tmp = p + (v.p - p).trunc(l);
        p1 = tmp + ((v.p - p).rotleft().trunc(h));
        p2 = tmp + ((v.p - p).rotright().trunc(h));
        if(rel == 2 || rel == 4)return 1;
        return 2;
    }
};
int main(){
    circle c1, c2;
    c1.input();
    c2.input();
    Point p1, p2;
    c1.pointcrosscircle(c2, p1, p2);
    if(p2 < p1) swap(p1, p2);
    printf("%.8f %.8f %.8f %.8f\n", p1.x, p1.y, p2.x, p2.y);
    return 0;
}


Measured memory_bytes: 3272
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
    const s = lines[0].split("").sort();
    let flg = false;
    s.reduce((a,v)=>{
        if(a===v) flg=true;
        return v;
    },"")
    console.log(!flg?"yes":"no");
    
});


Measured memory_bytes: 31064
#include <bits/stdc++.h>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b?a:b;}
ll min(ll a, ll b) {return a<b?a:b;}



int main(void) {
  ll N;
  cin >> N;
  ll p[10], q[10];
  ll i;
  
  for(i=0; i<N; i++) cin >> p[i];
  for(i=0; i<N; i++) cin >> q[i];
  
  vector<ll> v{1,2,3,4,5,6,7,8};
  
  ll cnt=1;
  ll a=0, b=0;
  
  do {
    ll f=1;
    ll g=1;
    for(i=0; i<N; i++) {
      if(p[i]!=v[i]) f=0;
      if(q[i]!=v[i]) g=0;
    }
    
    if(f) a=cnt;
    if(g) b=cnt;
    cnt++;
  }while(next_permutation(v.begin(), v.begin()+N));
  
  pt(abs(a-b));
}


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

int main()
{
    int n;
    cin>>n;
    vector<double> bal(n);
    for(int i = 0;i<n;i++)cin>>bal[i];
    sort(bal.begin(),bal.end());
    double p = (bal[0]+bal[1])/2;
    for(int i = 2;i<n;i++)
        p = (p+bal[i])/2;
    cout<<p<<endl;
    //main();
    return 0;
}


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

typedef long long ll;
typedef double lf;
typedef long double Lf;
typedef pair <int,int> pii;
typedef pair <ll, ll> pll;

#define TRACE(x) cerr << #x << "  " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define _ << " " <<

#define fi first
#define sec second
#define mp make_pair

string s;

bool imam[30];

int main() {
  cin >> s;
  if (s == "zyxwvutsrqponmlkjihgfedcba") {
    puts("-1");
    return 0;
  }
  int n = s.size();
  REP(i, n) imam[s[i] - 'a'] = 1;
  REP(i, 26) {
    if (!imam[i]) {
      cout << s << (char)(i + 'a') << endl;
      return 0;
    }
  }
  memset(imam, 0, sizeof imam);
  do {
    int let = s.back();
    s.pop_back();
    int t = -1;
    REP(i, 30) if (imam[i] && i > let - 'a') {t = i; break;}
    imam[let - 'a'] = 1;
    if (t == -1) continue;
    cout << s << (char)(t + 'a') << endl;
    return 0;
  } while (1);
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l=LI()

  ans=1
  a=l[0]

  for x in l[1:]:
    if a>x:
      ans+=1
    if a>x:
      a=x

  return ans

# main()
print(main())


Measured memory_bytes: 26684
//
//  main.cpp
//  ABC167A

#include <iostream>
#include <string>
using namespace std;
int main(int argc, const char * argv[]) {
    string S,T;
    cin >> S >> T;
    
    long long len_s=S.length();
    long long len_t=T.length();
    if (len_t!=(len_s+1)) {
        cout<<"No"<<endl;
        return 0;
    }
    for (long long i=0; i<S.length(); i++) {
        if (S.at(i)!=T.at(i)) {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


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

int n,m;
vector<ll> a(110),b(110),c(110),d(110),ans(110);

int main(){
    cin>>n>>m;
    rep(i,n) cin>>a[i]>>b[i];
    rep(i,m) cin>>c[i]>>d[i];
    rep(i,n){
        ll res=INF;
        rep(j,m){
            ll l=abs(a[i]-c[j])+abs(b[i]-d[j]);
            if(res>l){
                res=l;
                ans[i]=j+1;
            }  
        }
    }
    rep(i,n) cout<<ans[i]<<"\n";

    return 0;
}

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , "; logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 100005;

/* ...o(^-^)o... */


int main(){
    int x, n; cin >> x >> n;
    vector<bool> p(105, false);
    rep(i, n){
        int r; cin >> r; p[r] = true;
    }

    vector<P> q;
    rep(i, 105){
        if(p[i]) continue;
        q.push_back(P(abs(x-i), i));
    }
    sort(all(q));
    out(q[0].se);
}

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

using namespace std;

int main()
{
    int n ;
    cin>>n ;
    int cnt = 0 , cnt1 = 0 ;
    for(int i = 0 ; i < n ; ++i)
    {
        char c ;
        cin>>c ;
        if(c == 'R')
            cnt++ ;
        else
            cnt1++ ;
    }
    if(cnt > cnt1)
        cout<<"Yes\n";
    else
        cout<<"No\n";
    return 0 ;
}


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

if a<=b and b<=c:
    print(a, b, c)
elif a<=b and b>c and a<=c:
    print(a, c, b)
elif a>b and b<=c and a<=c:
    print(b, a, c)
elif a>b and b<=c and a>c:
    print(b, c, a)
elif a<=b and b>c and a>c:
    print(c, a, b)
else:
    print(c, b, a)


Measured memory_bytes: 5592
#include <iostream>

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    int ans = 1;
    for(int i = 0; i < n; i++)
    {
        if(ans * 2 > ans+k)
            ans = ans + k;
        else
            ans = ans * 2;
    }
    cout << ans << endl;
    return 0;
}


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

int main()
{
	int n, m;
	int a[100][100] = { 0 };
	int b[100] = { 0 };

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

	for (int i = 0; i < n; i++) {
		int c = 0;
		for (int j = 0; j < m; j++) {
			c += a[i][j] * b[j];
		}
		cout << c << endl;
	}

	return 0;
}


Measured memory_bytes: 3140
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#include <bitset>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

unordered_map<long, vector<pair<long, long> > > joint;
unordered_map<long, vector<long> > daiku_result;
long N, M, R;

void daiku(long root) {
  vector<long> ret(N+1, 10000000000000l);
  ret[root] = 0;
  queue<long> q;
  q.push(root);
  while (q.size()) {
    long current = q.front();
    q.pop();
    for (auto it: joint[current]) {
      if (ret[it.first] <= ret[current] + it.second) continue;
      ret[it.first] = ret[current] + it.second;
      q.push(it.first);
    }
  }
  daiku_result[root] = ret;
}

void solve() {
  cin >> N >> M >> R;
  vector<long> r(R);
  rep (i, R) cin >> r[i];
  sort(r.begin(), r.end());
  rep (i, M) {
    long a, b, c;
    cin >> a >> b >> c;
    joint[a].push_back(make_pair(b, c));
    joint[b].push_back(make_pair(a, c));
  }
  for (auto it: r) {
    daiku(it);
  }
  long ans = 10000000000000l;
  while (true) {
    long tmp = 0;
    rep (i, R-1) tmp += daiku_result[r[i]][r[i+1]];
    ans = min(tmp, ans);
    if (not next_permutation(r.begin(), r.end())) break;
  }
  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intput(i) cout << i << endl
#define ll long long
#define stringput(s) cout << (string)(s) << endl


int main(){
  ll N;
  cin >> N;
  int ans = 0;
  while(N >= 500){
    ans += 1000;
    N -= 500;
  }
  while(N >= 5){
    ans += 5;
    N -= 5;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int mod = 1e9 + 7;

int main(){
  int N;
  cin >> N;
  vector< vector<int> > A(N,vector<int>(N));
  for(int i = 0; i < N; ++i)
    for(int j = 0; j < N; ++j)
      cin >> A[i][j];
  vector<int> dp(1<<N,0);
  dp[0] = 1;
  for(int i = 0; i < N; ++i){
    for(int j = 0; j < (1<<N); ++j){
      if(__builtin_popcount(j) != i) continue;
      for(int k = 0; k < N; ++k){
        if((j>>k)&1) continue;
        if(not A[i][k]) continue;
        dp[j|(1<<k)] += dp[j];
        dp[j|(1<<k)] %= mod;
      }
    }
  }
  cout << dp[(1<<N)-1] << endl;
}


Measured memory_bytes: 8448
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long double a,b,c,d,e;
	cin>>a>>b>>c;
	e=-2*sqrt(a*b);
	d=a+b-c;
	if (d<e)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 256
def calc(a, b, c, d):
    if abs(c - a) < abs(d - b): a, b, c, d = b, a, d, c
    if c < a: a, b, c, d = c, d, a, b
    
    s = 3 ** 29
    while s:
        bb = b // s
        dd = d // s
        if bb != dd: return c - a + abs(d - b)
        if bb % 3 == 1 and c // s - a // s >= 2:
            l = bb * s - 1
            r = (bb + 1) * s
            return c - a + min(b + d - 2 * l, 2 * r - b - d)
        s //= 3
    return c - a + abs(d - b)

Q = int(input())
for _ in range(Q):
    a, b, c, d = map(int, input().split())
    print(calc(a-1, b-1, c-1, d-1))

Measured memory_bytes: 69208
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll mod= 1e9 + 7;



int main() {
  int a,b,h;
  cin >> a >>b >>h;
  cout << (a+b)*h/2 << endl;
}


Measured memory_bytes: 3604
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	int n;
	cin>>n;
	vector<vector<bool>> f(n,vector<bool>(10));
	REP(i,0,n-1) {
		REP(j,0,9) {
			int val;
			cin>>val;
			f[i][j]=val==1;
		}
	}
	vector<vi> p(n,vi(11));
	int sum = INT_MIN;
	for(auto &i:p)for(auto &j:i)cin>>j;
	for(int i=1;i<(1<<10);i++) {
		vi now(n,0);
		for(int j=0;j<10;j++) {
			if((i>>j)&1) {
				REP(k,0,n-1) {
					if(f[k][j])now[k]++;
				}
			}
		}
		int ns = 0;
		REP(j,0,n-1)ns+=p[j][now[j]];
		sum = max(ns,sum);
	}
	cout<<sum;
}//2^10 all samples except none. find sum for all possible options;

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#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++)
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define ld PRId64
#define n_max int(1e5)


int main(){
    int n;
    cin >>n;
    llong A[3*n_max +5];
    REP(i,3*n) scanf("%lld" , &A[i]);

    llong ma[n_max +3],mi[n_max+3];
    ma[0]=0;
    mi[0]=0;

    priority_queue<llong,vector<llong>,greater<llong>> Que;
    REP(i,n){
        ma[0]+=A[i];
        Que.push(A[i]);
    }

    REP(i,n){
        if(Que.top() < A[n+i]){
            ma[i+1]= ma[i] - Que.top() + A[n+i];
            Que.pop();
            Que.push(A[n+i]);
        }
        else ma[i+1] = ma[i];
    }

    reverse(A,A+3*n);
    priority_queue<llong> Que1;
    REP(i,n){
        mi[0]+=A[i];
        Que1.push(A[i]);
    }





    REP(i,n){
        if(Que1.top() > A[n+i]){
            mi[i+1]= mi[i] - Que1.top() + A[n+i];
            Que1.pop();
            Que1.push(A[n+i]);
        }
        else mi[i+1] = mi[i];
    }

    llong ans=ma[n] - mi[0];
    FOR(i,1,n+1){
        if(ans < ma[n-i] - mi[i]) ans = ma[n-i] - mi[i];
    } 

    cout << ans << endl;


}

Measured memory_bytes: 6516
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <queue>
using namespace std;
 
map<string, int> dp;
int direction[4] = { 1, -1, 4, -4 };
 
void bfs()
{
    queue<string> que;
    que.push("01234567");
    dp["01234567"] = 0;
    while (!que.empty())
    {
        string now = que.front(); que.pop();
        // p???'0'?????????
        int p = 0;
        for (int j = 0; j < 8; ++j)
        {
            if (now[j] == '0')
            {
                p = j;
                break;
            }
        }
 
        for (int i = 0; i < 4; ++i)
        {
            int n = p + direction[i];
            if (0 <= n && n < 8 && 
                !(p == 3 && i == 0) && // ???????§???????????????????
                !(p == 4 && i == 1))   // ???????§???????????????????
            {
                string next = now;
                swap(next[p], next[n]);
                if (dp.find(next) == dp.end())
                {
                    dp[next] = dp[now] + 1;
                    que.push(next);
                }
            }
        }
    }
}
 
int main(int argc, char *argv[])
{
 
    bfs();
    string line;
    while (getline(cin, line))
    {
        line.erase(remove(line.begin(), line.end(), ' '), line.end());
        cout << dp[line] << endl;
    }
 
    return 0;
}

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

template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
int character_count(string text, char character){ int ans = 0; for(int i = 0; i < text.size(); i++){ ans += (text[i] == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))

int main(){
    int D, N;
    cin >> D >> N;
    if(N == 100){
        cout << power(100, D, 1e9) * 101 << endl;
    }else{
        cout << power(100, D, 1e9) * N << endl;
    }
}


Measured memory_bytes: 256
i = input()
arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(arr[int(i)-1])

Measured memory_bytes: 3060
#include<stdio.h>
int main(){
  char a,b[1201]={0};
  int c=0;
  while(1){
    scanf("%c",&a);
    if(a>='A'&&a<='Z'){
      a+=32;
    }
    else if(a>='a'&&a<='z'){
      a-=32;
    }
    if(a=='\n'){
      break;
    }
    b[c]=a;
    c++;
  }
  printf("%s\n",b);
}

Measured memory_bytes: 2600
#include <bits/stdc++.h>
using namespace std;
const int N = 3e3 + 5;
int arr[N];
bool lose[N];
int n;
vector < vector < int > > v(N);
bool dfs(int node){
	for(int to : v[node]){
		if(arr[to] >= arr[node]) continue;
		if(!dfs(to)) return true;
	}
	return false;
}
int main(){
	scanf("%d" , &n);
	for(int i = 1 ; i <= n ; i++){
		scanf("%d" , &arr[i]);
		lose[i] = true;
	}
	for(int i = 0 ; i < n - 1 ; i++){
		int x , y;
		scanf("%d %d" , &x , &y);
		v[x].emplace_back(y);
		v[y].emplace_back(x);
	}
	for(int i = 1 ; i <= n ; i++){
		if(dfs(i)) printf("%d ", i);
	}
	puts("");
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	int a, b; cin >> a >> b;
	cout << max({ a + b,a - b,a*b }) << endl;
	return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
R, S, P = list(map(int, input().split())) #グー・チョキ・パー
W=str(input())#rはグー・sはチョキ・pはパー
Q=list()
for i in range(len(W)):
    if i <K:
        if W[i]=='r':
            Q.append(P)
        elif W[i]=='s':
            Q.append(R)
        elif W[i]=='p':
            Q.append(S)
    else:
        if W[i]==W[i-K]:
            if Q[i-K]!=0:
                Q.append(0)
            else:
                if W[i]=='r':
                    Q.append(P)
                elif W[i]=='s':
                    Q.append(R)
                elif W[i]=='p':
                    Q.append(S)
        else:
            if W[i]=='r':
                Q.append(P)
            elif W[i]=='s':
                Q.append(R)
            elif W[i]=='p':
                Q.append(S)
print(sum(Q))

Measured memory_bytes: 4212
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  string S, T;
  cin >> S >>T;
  int ans=0;
  for (int i=0; i<3; i++) {
    if (S.at(i)==T.at(i)) {
      ans=ans+1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3600
#include <stdio.h>
int main(void){
    int a,b,c,X;
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    
    if(a>b){
        X=a;
        a=b;
        b=X;
    }
    if(b>c){
        X=b;
        b=c;
        c=X;
    }
    if(a>b){
        X=a;
        a=b;
        b=X;
    }

    printf("%d %d %d\n",a,b,c);
    return 0;
}


Measured memory_bytes: 2104
#include <stdio.h>

int main(void)
{
	int ticket[3];
	
	scanf("%d %d %d", &ticket[0], &ticket[1], &ticket[2]);
	
	if (ticket[0] == 1 && ticket[1] == 1){
		printf("Open");
	}
	else if (ticket[2] == 1){
		printf("Open");
	}
	else {
		printf("Close");
	}
	
	printf("\n");
	
	return (0);
}

Measured memory_bytes: 588
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);


int n = 0;
vector<int> h;

void solve() {
    int ans = 0;
    int prev = 0;
    rep(i, n) {
        if (prev >= h[i]) prev = h[i];
        else {
            ans += h[i] - prev;
            prev = h[i];
        }
    }
    cout << ans << endl;
}

int main() {
    cin >> n;
    h.resize(n);
    rep(i, n) cin >> h[i];
    solve();
    return 0;
}

Measured memory_bytes: 256
n = int(input())
ac = 0
wa = 0
tle = 0
re = 0

for _ in range(n):
  x = input()
  if x == 'AC':
    ac += 1
  elif x == 'WA':
    wa += 1
  elif x == 'TLE':
    tle += 1
  else:
    re += 1
    
print('AC x ', ac)
print('WA x ', wa)
print('TLE x ', tle)
print('RE x ', re)


Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os << "[ "; 
	for(auto v:V)os << v << " "; return os << "]";
}
template<class T> ostream& operator<<(ostream &os, set<T> S){ os << "{ "; 
	for(auto s:S) os<<s<<" ";  return os<<"}"; 
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
	return os<<"("<<P.first<<","<< P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
	os<<"{ ";for(auto m:M)os<<"("<<m.F<<":"<<m.S<<")";
	return os<<"}";
}
#define cerr cout
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert 
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define For(i,n) for(int i=0;i<(int)n;++i)
#define Rev(i,n) for(int i=(int)n-1;i>=0;--i)
#define Rep(i,n) for(int i=1;i<=(int)n;++i)
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpii;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)


int main(){
	fio; cout<<fixed<<setprecision(25);	
	int n , m;
	cin >> n >> m;
	if(n == m){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
MOD = 10**9 + 7

n, k = map(int, input().split())

def getComb(n, k, MOD):
    if n < k:
        return 0
    if n-k < k:
        k = n-k
    comb = 1
    for x in range(n-k+1, n+1):
        comb = (comb * x) % MOD
    d = 1
    for x in range(1, k+1):
        d = (d * x) % MOD
    comb *= pow(d, MOD-2, MOD)
    return comb % MOD

def getCombNs(n, invs, MOD):
    combNs = [1] * (n//2+1)
    for x in range(1, n//2+1):
        combNs[x] = (combNs[x-1] * (n-x+1) * invs[x]) % MOD
    return combNs + combNs[:(n+1)//2][::-1]

def getInvs(n, MOD):
    invs = [1] * (n+1)
    for x in range(2, n+1):
        invs[x] = (-(MOD//x) * invs[MOD%x]) % MOD
    return invs


ans = getComb(2*n-1, n, MOD)

if k < n-1:
    m = n-1-k
    invs = getInvs(n+3, MOD)
    combNs = getCombNs(n, invs, MOD)
    combN1s = getCombNs(n-1, invs, MOD)

    for i in range(m):
        ans -= combN1s[i] * combNs[i+1] % MOD
        ans %= MOD

print(ans)


Measured memory_bytes: 66764
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rrep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define maxe(x) *max_element(all(x))
#define mine(x) *min_element(all(x))
#define Size(x) ((int)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

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

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo,gyakugen
//mint,dijkstra

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        ll x;
        cin>>x;
        rep(i,x){
            if((i+1)*(i+2)/2>=x){
                cout<<i+1<<endl;
                return 0;
            }
        }
    }

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

cnt = 1

if(K%2 == 0):
    print(-1)
elif(K%5 == 0):
    print(-1)
else:
    n = 0
    a = 0
    while(1):
        n = a*10+7
        a = n%K
        if(a==0):
            print(cnt)
            break
        cnt += 1


Measured memory_bytes: 9188
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int r = sc.nextInt();
		if (n >= 10) {
			System.out.println(r);
		} else {
			System.out.println(r + 100 * (10 - n));
		}
	}
}

Measured memory_bytes: 21844
def solve():
    import sys
    input = sys.stdin.readline

    ordA = ord('a')

    N = int(input())
    Ss = input().strip()
    nos = [ord(S)-ordA for S in Ss]
    Q = int(input())

    idEle = 0
    def _binOpe(x, y):
        return x | y
    def makeSegTree(numEle):
        numPow2 = 2 ** (numEle-1).bit_length()
        data = [idEle] * (2*numPow2)
        return data, numPow2
    def setInit(As):
        for iST, A in enumerate(As, numPow2):
            data[iST] = A
        for iST in reversed(range(1, numPow2)):
            data[iST] = _binOpe(data[2*iST], data[2*iST+1])
    def _update1(iA, A):
        iST = iA + numPow2
        data[iST] = A
    def update(iA, A):
        _update1(iA, A)
        iST = iA + numPow2
        while iST > 1:
            iST >>= 1
            data[iST] = _binOpe(data[2*iST], data[2*iST+1])
    def getValue(iSt, iEn):
        L = iSt + numPow2
        R = iEn + numPow2
        ans = idEle
        while L < R:
            if L & 1:
                ans = _binOpe(ans, data[L])
                L += 1
            if R & 1:
                R -= 1
                ans = _binOpe(ans, data[R])
            L >>= 1
            R >>= 1
        return ans

    data, numPow2 = makeSegTree(N)

    As = [(1<<no) for no in nos]
    setInit(As)

    anss = []
    for _ in range(Q):
        tp, v1, v2 = input().split()
        if tp == '1':
            pos = int(v1)-1
            c = ord(v2)-ordA
            update(pos, 1<<c)
        else:
            L, R = int(v1)-1, int(v2)-1
            v = getValue(L, R+1)
            ans = bin(v).count('1')
            anss.append(ans)

    print('\n'.join(map(str, anss)))


solve()


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

const int64_t MAX = 510000;
const int64_t MOD = 1000000007;

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

int64_t modpow(int64_t a,int64_t n){
  int64_t res=1;
  if(n==0) return res;
  while(n>0){
    if(n&1) res=(res*a)%MOD;
    a=(a*a)%MOD;
    n >>= 1;
  }
  return res;
}


int main(){
  COMinit();

  int64_t n,a,b;
  cin>>n>>a>>b;
  int64_t ans;
  ans += modpow(2,n);
  ans -= 1;
  ans -= COM(n,a);
  ans -= COM(n,b);
  
  if(ans<0){
  while(ans<0){
  ans += MOD;
  }
  }
  
  cout<<ans%MOD<<endl;
}

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

int main() {
  //入力値取得
  int N;	cin >> N;
  vector<string> str_blue(N);
  for(int i=0; i<N; i++){
    cin >> str_blue.at(i);
  }
  
  int M;	cin >> M;
  vector<string> str_red(M);
  for(int i=0; i<M; i++){
    cin >> str_red.at(i);
  }
  
  //勘定
  int max = 0;
  //青カード
  for(int i=0; i<N; i++){
    int counter = 0;
   //青カード比較
    for(int j=0; j<N; j++){
      if(str_blue.at(i) == str_blue.at(j)){
        counter++;
      }
    }
    //赤カード比較
    for(int j=0; j<M; j++){
      if(str_blue.at(i) == str_red.at(j)){
        counter--;
      }
    }
    
    if(counter > max)
      max = counter;
  }

  //赤カード
  for(int i=0; i<M; i++){
    int counter = 0;
   //青カード比較
    for(int j=0; j<N; j++){
      if(str_red.at(i) == str_blue.at(j)){
        counter++;
      }
    }
    //赤カード比較
    for(int j=0; j<M; j++){
      if(str_red.at(i) == str_red.at(j)){
        counter--;
      }
    }
    
    if(counter > max)
      max = counter;
  }

  cout << max << endl;
  
  //確認
  /*
  cout << N << ' ' << M << endl;
  for(int i=0; i<N; i++){
    cout << str_blue.at(i) << ' ';
  }
  cout << endl;
  for(int i=0; i<M; i++){
    cout << str_red.at(i) << ' ';
  }
  cout << endl;
  */
}


Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long



using namespace std;

void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;
const int N=1e6+5,M=2e6+5,MOD=1e9+7,OO=1e9;

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();
	
	int n,x;

	scanf("%d %d",&n,&x);
	int ans = 0;
	for(int i=0,xx;i<n;i++)scanf("%d",&xx),ans=__gcd(ans,abs(xx-x));
	printf("%d\n",ans );
}	



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int N;
  cin >> N;
  int ans = 0;
  REP(i, N) {
    int l, r;
    cin >> l >> r;
    ans += r - l + 1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//:/
#define pb push_back
#define mp make_pair
#define nt _ll128
#define ld long double
long double PI =3.14159265358979323846;
using ll = long long;



const ll modo=998244353;
const ll inf=1e17;
const ll ms=(1e5)+5;

int ar[ms];


int main()
{
    idfc;
    int n;
    cin>>n;
    int i;
    for(i=1;i<=n;i++)cin>>ar[i];

    sort(ar+1,ar+n+1);


    int x=ar[1];
    int a,b,c,d;
    for(i=2;i<n;i++)
    {
        a=x;
        b=ar[n]-x;
        c=ar[i];
        d=ar[n]-ar[i];
        if(a>b)swap(a,b);
        if(c>d)swap(c,d);

        if(b>d)x=ar[i];
    }
    cout<<ar[n]<<" "<<x;

    return 0;
}

Measured memory_bytes: 3996