akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
using namespace std;

int main()
{
	int N;
	pair<int,int> R[110],B[110];
	int Rused[110]={};
	int ans=0;
	
	cin >> N;
	for(int i=0;i<N;i++)
		cin >> R[i].first >> R[i].second;
	for(int i=0;i<N;i++)
		cin >> B[i].first >> B[i].second;
	
	sort(R,R+N);
	sort(B,B+N);
	
	for(int i=0;i<N;i++)
	{
		int max=-1,maxj=-1;
		for(int j=0;j<N;j++)
		{
			if(Rused[j]==1)continue;
			if(R[j].first>=B[i].first)break;
			if(R[j].second>max && R[j].second<B[i].second)
			{
				max=R[j].second;
				maxj=j;
			}
		}
		if(maxj>=0)
		{
			Rused[maxj]=1;
			ans++;
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    n = ri()
    la = rli()
    rev = sum(1/a for a in la)
    print(1/rev)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
def resolve():
    '''
    code here
    '''

    X = int(input())

    is_flag = True
    x = 100
    cnt = 0
    while is_flag:
        cnt += 1
        x *= 1.01
        x = int(x)
        if x >= X:
            is_flag = False

    print(cnt)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 9116
#include <bits/stdc++.h>
#define INF (1<<30)
#define INFLL (1ll<<60)
using namespace std;
map <int,int> mp;
typedef pair<int, int> P;
typedef long long ll;
static const int MAX=100000;

int main(){
    int N;
    cin>>N;
    cout<<N*(N+1)/2<<"\n";
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
int main(){
    int n;
    cin>>n;
    int h[n];
    int ans = 1;
    rep(i,0,n-1) cin>>h[i];
    int hoge = h[0];
    rep(i,1,n-1){
        if(hoge<=h[i]){
            ans++;
            hoge = h[i];
        } 
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector> 
#include <algorithm>
 
using namespace std;
 
int main(){
 
    int a ,b;
    cin >> a >> b;
    vector <int> tmp;
    tmp.push_back(a+b);
    tmp.push_back(a-b);
    tmp.push_back(a*b);
    int max = * max_element(tmp.begin(), tmp.end());
    cout << max <<endl;
}

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

int main() {
	int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
	int x = x2;
	int y = y2;
	int dx = x2 - x1;
	int dy = y2 - y1;
	for (int i = 0; i < 2; i++) {
		swap(dx, dy);
		dx = -dx;
		x += dx;
		y += dy;
		cout << x << ' ' << y << ' ';
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
a, b, c = map(int, input().split())
if (a+b+c)%2 :
    if a%2 and b%2 and c%2 :
        total = a + b + c
        mx = max(a,b,c)
        diff = 3*mx - total
        print(diff//2)
    else :
        if not a%2 :
            a += 1
        if not b%2 :
            b += 1
        if not c%2 :
            c += 1
        total = a + b + c
        mx = max(a,b,c)
        diff = 3*mx -total
        ans = 1 + diff//2
        print(ans)
else :
    if not (a%2 or b%2 or c%2) :
        total = a + b + c
        mx = max(a,b,c)
        diff = 3*mx -total
        print(diff//2)
    else :
        if a%2 :
            a += 1
        if b%2 :
            b += 1
        if c%2 :
            c += 1
        total = a + b + c
        mx = max(a,b,c)
        diff = 3*mx - total
        ans = 1 + diff//2
        print(ans)


Measured memory_bytes: 9012
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    int a[1000];
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    sort(a, a+n,greater<int>());
    cout << a[0] - a[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

//#include <tuple>

//#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back

int main() {
  int K, X;
  cin >> K >> X;
  if (K*500 >= X) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
}


Measured memory_bytes: 256
#[allow(dead_code)]
struct Utree {
    n: usize,
    par: Vec<usize>,
    rank: Vec<usize>,
    size: Vec<usize>,
    diff_weight: Vec<i64>,
}
#[allow(dead_code)]
impl Utree {
    fn new(n: usize) -> Utree {
        Utree {
            n: n,
            par: (0..n).collect(),
            rank: vec![0; n],
            size: vec![1; n],
            diff_weight: vec![0; n],
        }
    }
    fn find(&mut self, x: usize) -> usize {
        if self.par[x] == x {
            x
        } else {
            let parent = { self.par[x] };
            let ret = self.find(parent);
            self.diff_weight[x] += self.diff_weight[parent];
            self.par[x] = ret;
            ret
        }
    }
    fn get_weight(&mut self, x: usize) -> i64 {
        self.find(x);
        self.diff_weight[x]
    }
    fn get_size(&mut self, x: usize) -> usize {
        let x_root = self.find(x);
        self.size[x_root]
    }
    fn is_same(&mut self, x: usize, y: usize) -> bool {
        let x_root = self.find(x);
        let y_root = self.find(y);
        x_root == y_root
    }
    fn unite(&mut self, x: usize, y: usize, w: i64) {
        let mut dw = w;
        dw += self.get_weight(x);
        dw -= self.get_weight(y);
        let x_root = self.find(x);
        let y_root = self.find(y);
        if x_root == y_root {
            return;
        };
        if self.rank[x_root] < self.rank[y_root] {
            self.par[x_root] = y_root;
            self.size[y_root] += self.size[x_root];
            self.diff_weight[x_root] -= dw;
        } else {
            self.par[y_root] = x_root;
            self.size[x_root] += self.size[y_root];
            self.diff_weight[y_root] += dw;
            if self.rank[x_root] == self.rank[y_root] {
                self.rank[x_root] += 1;
            }
        }
    }
}

fn main() {
    use std::io::Read;
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    
    let n: usize = iter.next().unwrap().parse::<usize>().unwrap();
    let m: usize = iter.next().unwrap().parse::<usize>().unwrap();
    let mut utree = Utree::new(n);
    let mut ret = true;
    for _ in 0..m {
        let l: usize = iter.next().unwrap().parse::<usize>().unwrap()-1;
        let r: usize = iter.next().unwrap().parse::<usize>().unwrap()-1;
        let d: i64 = iter.next().unwrap().parse::<i64>().unwrap();
        if utree.is_same(l, r) {
            if utree.get_weight(r) - utree.get_weight(l) != d {
                ret = false;
                break;
            }
        } else {
            utree.unite(l, r, d);
        }
    }

    println!("{}", if ret {"Yes"} else {"No"});
}


Measured memory_bytes: 12280
#include<vector>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
int id[600][600],n,d1,d2,R;
vector<int> e[360000];
int id2[600][600];
int col[360000],px[360000],py[360000];
vector<int> A,B;
void add_edge(int dx,int dy){
	for(int i=0; i<R; i++)for(int j=0; j<R; j++){
		if(id[i][j] == -1)continue;
		int i2 = i+dx, j2 = j+dy;
		if(i2>=0 && i2<R && j2>=0 && j2<R && id[i2][j2] !=-1){
			e[id[i][j]].push_back(id[i2][j2]);
		}
	}
}
void dfs(int x,int c){
	if(col[x] == 0){
		if(c==1){
			A.push_back(x);
		}else
			B.push_back(x);
		col[x] = c;
		for(auto y : e[x]){
			dfs(y, -c);
		}
	}
}
void proc(int&m,int X){
	for(int i=0; i<m; i++){
		e[i].clear();
		col[i] = 0;
	}
	for(int i=0; i<R; i++)for(int j=0; j<R; j++)if(id[i][j]!=-1){
		px[id[i][j]] = i;
		py[id[i][j]] = j;
	}
	for(int i=0; i*i<=X; i++){
		int z=X-i*i;
		int j=(int)sqrt(z+.5);
		if(j*j==z){
			add_edge(i,j);
			if(j>0)add_edge(i,-j);
			if(i>0)add_edge(-i,j);
			if(i>0&&j>0)add_edge(-i,-j);
		}
	}
	int m2 = 0;
	for(int i=0; i<R; i++)for(int j=0; j<R; j++)if(id[i][j] != -1 && col[id[i][j]] == 0){
		A.clear();
		B.clear();
		dfs(id[i][j],1);
		if(A.size() < B.size())swap(A,B);
		for(auto cur : A){
			id2[px[cur]][py[cur]] = m2++;
		}
		for(auto cur : B){
			id2[px[cur]][py[cur]] = -1;
		}
	}
	memcpy(id,id2,sizeof(id));
	m = m2;
}
int main(){
	scanf("%d%d%d",&n,&d1,&d2);
	R = 2 * n;
	int t=0;
	for(int i=0; i<R; i++)
	for(int j=0; j<R; j++)
		id[i][j] = t++;
	proc(t,d1);
	proc(t,d2);
	for(int i=0,t=n*n; i<R&&t>0; i++)
		for(int j=0; j<R&&t>0; j++)
			if(id[i][j] != -1){
				printf("%d %d\n",i,j);
				--t;
			}
	return 0;
}


Measured memory_bytes: 82028
#!/usr/bin/env python3


def main():
    s = input()
    first = int(s[:2])
    last = int(s[2:])

    if first == 0 or first > 12:
        if last >= 1 and last <= 12:
            print('YYMM')
            return
        else:
            print('NA')
            return
    else:
        # first = 1 ~ 12
        if last >= 1 and last <= 12:
            print('AMBIGUOUS')
            return
        else:
            print('MMYY')
            return

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds; 
using namespace std;
#define int long long
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define mii map<int,int>
#define mp make_pair
#define pb push_back
#define rep(i,b) for(ll (i)=0;i<(b);i++)
#define all(c) (c).begin(), (c).end()
#define F first
#define S second
#define CLR(p) memset(p, 0, sizeof(p))
#define SET(p) memset(p, -1, sizeof(p))
#define DEBUG true
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
//typedef long long int ll;
typedef tree<int, null_type, less<int>, rb_tree_tag, 
tree_order_statistics_node_update> new_data_set; 
const int MAX=200005;
#define MOD 1000000007
/*std::cout << std::fixed;
std::cout << std::setprecision(6);*/
//(a%mod-b%mod+mod)%mod



/************************************


 
*************************************/

vector<vector<ll>>v;
ll T=0;
ll cnt1=0,cnt0=0;
vector<ll>dep;
bool visited[MAX];
vector<ll>par;
vector<ll>tin,tout;
vector<ll>col;
ll f=0,k=1;
map<pll,ll>m;
ll dp1[MAX],dp2[MAX];
ll red,blue;
ll ans;
ll dp[MAX];

ll lca(ll u,ll v){
	while(u!=v){
		ll l1,l2;
		l1 = log2(u);
		l2 = log2(v);
		//cout<<l1<<"$$"<<l2<<endl;
		if(l1<l2)
			swap(u,v);
		u /=2;
	}
	return u;
}





signed main(){
	boost;
	int t=1;
	// cin>>t;
	while(t--){
		int m,n;
		cin>>n>>m;
		int a[n];
		int sum=0;
		rep(i,n){
			cin>>a[i];
			sum+=a[i];
		}
		
		int x = ceil((1.0*sum)/(4*m));
		// cout<<sum<<" "<<x<<endl;
		int cnt=0;
		rep(i,n){
			if(a[i]>=x)
				cnt++;
		}
		if(cnt>=m)
			cout<<"Yes\n";
		else cout<<"No\n";
	}

	return 0;
}

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

const int LOOP=100;
double solve(int n){
    double pw; cin>>pw;
    vector<double> vw(n),pf(n),vf(n),th(n);
    for(int i=0;i<n;i++) cin>>vw[i]>>pf[i]>>vf[i]>>th[i];
    
    auto calc=[&](double w){
        double res=w*pw;
        for(int i=0;i<n;i++){
            if(w*vw[i]>=th[i]) continue;
            else res+=(th[i]-w*vw[i])/vf[i]*pf[i];
        }
        return res;
    };
    double lb=0,ub=100;
    for(int loop=0;loop<LOOP;loop++){
        double midl=(lb*2+ub)/3;
        double midr=(lb+ub*2)/3;
        if(calc(midl)<calc(midr)) ub=midr;
        else lb=midl;
    }
    return calc(lb);
}
int main(){
    int n;
    cout<<setprecision(10)<<fixed;
    while(cin>>n,n){
        cout<<solve(n)<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 6044
#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 ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


int main() {
    int N; cin >> N;
    vector<int> B(N+1, INF);
    REP(i,N-1){
        cin >> B[i+1];
    }
    int ans = 0;
    REP(i,N){
        ans += min(B[i], B[i+1]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3588
N, K = map(int, input().split())
A = list(map(int, input().split()))
for i in range(N):
    A[i] -= 1

reached = [0] * N

next = A[0]
cnt = 1
while not reached[next]:
    reached[next] = cnt
    next = A[next]
    cnt += 1

cnt2 = 1
start = next
#print("start:"+ str(start))
next = A[start]
while  start != next:
    cnt2 += 1
    next = A[next]

if K < cnt:
    #print("K<cnt")
    for i in range(N):
        if reached[i] == K:
            print(i+1)
elif K == cnt:
    #print("K==cnt")
    print(start+1)
elif K > cnt:
    #print("K > cnt")
    #print("K:"+str(K))
    #print("cnt:"+str(cnt))
    #print("cnt2:"+str(cnt2))
    tmp = K - cnt
    r = tmp % cnt2
    next = A[start]
    for i in range(r-1):
        next = A[next]
    if r == 0:
        print(start+1)
    else:
        print(next+1)




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

int main(){
    int N,T;
    cin >> N >> T;
    int c[1000],t[1000];
    for(int i=0;i<N;i++){
        cin >> c[i] >> t[i];
        if(t[i]>T)
        c[i]=1001;
    }
    sort(c,c+N);
    if(c[0]==1001){
        cout << "TLE" << endl;
        return 0;
    }
    cout << c[0] << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int n,m,i,j;
	int a[100][100];
	int b[100];	
	int x[100];
	scanf("%d %d",&n,&m);
	
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			scanf("%d",&a[i][j]);
			}		
	}
	
	for(j=0;j<m;j++){
		scanf("%d",&b[j]);
		}
	
	
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			x[i]+=a[i][j]*b[j];
			}
			printf("%d\n",x[i]);		
	}
	
return 0;
}


Measured memory_bytes: 2100
N = int(input())
lex = [chr(i) for i in range(97,123)]

if N == 1:
    print("a")
    exit()

def equiv(s, n, pat) :
    if n == N-1 :
        for i in range(pat+1) :
            print(s + lex[i])
    else :
        for i in range(pat+1) :
            if i == pat :
                equiv(s+lex[i], n+1, pat+1)
            else :
                equiv(s+lex[i], n+1, pat)
    return True

equiv("a", 1, 1)


Measured memory_bytes: 56664
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	ll ans = 0;
	int tmp;
	int n;
	cin >> n;
	cout << (2199 - n)/200 << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n;
  string s;
  cin >> n >> s;
  int ans=0;
  rep(i,1000){
    int a=i/100,b=i%100/10,c=i%10;
    int q=0;
    int an=0;
    while((s[q]-'0')!=a){
      if(q==n-1){
        an++;
        break;
      }
      q++;
    }
    if(q==n-1)continue;
    q++;
    while((s[q]-'0')!=b){
      if(q==n-1){
        an++;
        break;
      }
      q++;
    }
        if(q==n-1)continue;
    q++;
    while((s[q]-'0')!=c){
      if(q==n-1){
        an++;
        break;
      }
      q++;
    }
    if(an==0){
      //cout << i << endl;
      ans++;
    }  
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#define int long long
#define endre getchar();getchar();return 0
#define moder 1000000007
#define inf 1000000000000000000
#define rep(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

class weight_unionfind {
	int par[100005], Rank[100005], diff_weight[100005];
public:
	weight_unionfind(int x) {
		rep(i, x) {
			par[i] = i;
			Rank[i] = 0;
			diff_weight[i] = 0;
		}
	}
	int find(int x) {
		if (par[x] == x)return x;
		int r = find(par[x]);
		diff_weight[x] += diff_weight[par[x]];
		return par[x] = r;
	}
	int weight(int x) {
		find(x);
		return diff_weight[x];
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
	void unite(int x, int y, int w) {
		w += weight(x); w -= weight(y);
		x = find(x);
		y = find(y);
		if (x == y)return;
		if (Rank[x] < Rank[y])swap(x, y), w *= -1;
		if (Rank[x] == Rank[y])Rank[x]++;
		par[y] = x;
		diff_weight[y] = w;
	}
	int diff(int x, int y) {
		if (same(x, y))return weight(y) - weight(x);
		return inf;
	}
};
signed main() {
	int n, q;
	cin >> n >> q;
	static weight_unionfind uf(n);
	rep(i, q) {
		int a, b, c, d;
		cin >> a;
		if (!a) {
			cin >> b >> c >> d;
			uf.unite(b, c, d);
		}
		else {
			cin >> b >> c;
			if (uf.diff(b, c) != inf)cout << uf.diff(b, c) << endl;
			else cout << "?" << endl;
		}
	}
	endre;
}


Measured memory_bytes: 5452
from itertools import product

n = int(input())

res = 0
for pattern in product(["0", "3", "5", "7"], repeat=len(str(n))):
    p = int("".join(pattern))
    if "0" not in str(p):
        if p <= n:
            for i in ["3", "5", "7"]:
                if i not in str(p):
                    break
            else:
                res += 1
print(res)


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


int const INF = 1001001001;


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


string s;
cin >> s;
regex re("A?KIHA?BA?RA?");
bool res = regex_match(s, re);
cout << (res?"YES":"NO") << endl;


return 0;
}

Measured memory_bytes: 256
nx = list(map(int, input().split()))
n = nx[0]
x = nx[1]
p = 0
for i in range(n):
    l_thick = 2 ** (n - i + 1) - 3
    if x == 1:
        break
    elif x <= l_thick:
        x = x - 1
    elif x == l_thick + 1 :
        p += 2 ** (n - i) - 1
        break
    elif x <= l_thick * 2 + 1:
        x = x - l_thick - 2
        p += 2 ** (n - i)
    else:
        p += 2 * (2 ** (n - i) - 1) + 1
        break
print(p)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(long long i=0;i<(n);i++)
#define REP1(i,n) for(long long i=1;i<=(n);i++)
#define REP2D(i,j,h,w) for(long long i=0;i<(h);i++) for(long long j=0;j<(w);j++)
#define REP2D1(i,j,h,w) for(long long i=1;i<=(h);i++) for(long long j=1;j<=(w);j++)
#define PER(i,n) for(long long i=((n)-1);i>=0;i--)
#define PER1(i,n) for(long long i=(n);i>0;i--)
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define FORE(i,a,b) for(long long i=(a);i<=(b);i++)
#define ITE(arr) for(auto ite=(arr).begin();ite!=(arr).end();++ite)
#define ALL(a) ((a).begin()),((a).end())
#define RANGE(a) (a),((a)+sizeof(a))
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define YNPRT(b) cout<<((b)?"Yes":"No")<<endl
#define ENTER printf("\n")
#define REV(arr) reverse(ALL(arr))
#define PRT(a) cout<<(a)<<endl

#ifdef DEBUG
#define DBPRT(a) cout << "[Debug] - " << #a << " : " << (a) << endl
#define DBSTART if(1){
#define DBEND }
#define PRTLST(arr,num) REP(_i,num) cout<<_i<<" - "<<arr[_i]<<endl;
#define PRTLST2(arr2,d1,d2) REP(_i,d1) REP(_j,d2) cout<<_i<<","<<_j<<" : "<<arr2[_i][_j]<<endl;
#define PRTLST2D(arr2,d1,d2) do{cout<<"L\t";REP(_i,d2) cout<<_i<<"\t"; cout<<endl; REP(_i,d1){cout<<_i<<"\t";REP(_j,d2){cout<<arr2[_i][_j]<<"\t";}cout<<endl;}}while(0);
#else
#define DBPRT(a) if(0){}
#define DBSTART if(0){
#define DBEND }
#define PRTLST(arr,num) if(0){}
#define PRTLST2(arr2,d1,d2) if(0){}
#define PRTLST2D(arr2,d1,d2) if(0){}
#endif

#define TOSUM(arr,sum,n) {sum[0]=arr[0];REP1(i,n-1) sum[i]=sum[i-1]+arr[i];}

#define MIN(target,v1) (target)=min(target,v1)
#define MAX(target,v1) (target)=max(target,v1) 
#define P1 first
#define P2 second
#define PB push_back
#define UB upper_bound
#define LB lower_bound
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INF_INT = 2147483647;
const ll INF_LL = 9223372036854775807LL;
const ull INF_ULL = 18446744073709551615Ull;
const ll P = 92540646808111039LL;
const int Move[4][2] = {-1,0,0,1,1,0,0,-1};
const int Move_[8][2] = {-1,0,-1,-1,0,1,1,1,1,0,1,-1,0,-1,-1,-1};
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p) {os<<"( "<<p.P1<<" , "<<p.P2<<" )";return os;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {ITE(v) os << (ite-v.begin()) << " : " << *ite <<endl;return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v) {os<<" { ";ITE(v) {os<<*ite;if(ite!=--v.end()){os<<" , ";}} os<<" } ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& m) {ITE(m) {os<<ite->P1<<"\t\t|->\t\t"<<ite->P2<<endl;} return os;}

//---------------------
#define MAXN 100000
//---------------------

ll a,b;

int main(){
	cin >> a >> b;
	bool bl[4];
	REP1(i,3) bl[i] = false;
	bl[a] = true;
	bl[b] = true;
	REP1(i,3) if(!bl[i]) PRT(i);


	return 0;
}









Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define LB(c, x) lower_bound(c.begin(), c.end(), x)
#define UB(c, x) upper_bound(c.begin(), c.end(), x)
#define LI(c, x) distance(c.begin(), LB(c, x))
#define UI(c, x) distance(c.begin(), UB(c, x))

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int N = S.size(), res1 = 0, res2 = 0;
    REP(i, N) {
        if (i % 2 == 0 && S[i] == '1') {
            res1++;
        } else if (i % 2 == 1 && S[i] == '0') {
            res1++;
        }
        if (i % 2 == 0 && S[i] == '0') {
            res2++;
        } else if (i % 2 == 1 && S[i] == '1') {
            res2++;
        }
    }
    cout << min(res1, res2) << endl;
    return 0;
}


Measured memory_bytes: 512
n = int(input())
a = [int(i) - 1 for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]

result = 0
for i in range(n):
  result += b[a[i]]
  if i > 0 and a[i-1] + 1 == a[i]:
    result += c[a[i-1]]
    
print(result)

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

int main() {
	
	int n,a[200][3]={},count[3][102]={},score[201]={};
	
	cin>>n;

	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++){
			cin>>a[i][j];
			count[j][a[i][j]]++;
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++){
			if(count[j][a[i][j]] == 1) score[i]+=a[i][j];
		}
	cout<<score[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#include<stdio.h>

int main(void)
{
	int a, b;
	int d, r;
	double f;
	
	scanf("%d %d\n", &a, &b);
	
	d = a / b;
	r = a % b;
	f = (double)a / (double)b;
	
	printf("%d %d %lf", d, r, f);
	
	return 0;
}


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

using namespace std;

int main() {
    int N, Q;
    string S;
    cin >> N >> Q >> S;
    vector<int> index(N + 1, 0);
    for (int i = 0; i < S.size() - 1; i++) {
        int count = S[i] == 'A' && S[i + 1] == 'C' ? 1 : 0;
        index[i + 1] = index[i] + count;
    }

    // for (auto v : index) { cout << v << " "; } cout << endl;
 
    vector<int> ans(Q, 0);
    for (int i = 0; i < Q; i++) {
        int l, r; cin >> l >> r; l--; r--;
        ans[i] = index[r] - index[l];
    }

    for (auto v : ans) {
        cout << v << endl;
    }
}

Measured memory_bytes: 1792
import numpy as np
import sys

if __name__ == "__main__":
    read = sys.stdin.buffer.read
    readline = sys.stdin.buffer.readline
    readlines = sys.stdin.buffer.readlines

    a, b, c, d = map(int, readline().split())
    print(max(a * c, b * d, a * d, b * c))


Measured memory_bytes: 26968
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////




int main() {

	ll N;
	cin >> N;

	vector<vector<ll>> t(N + 1);

	repn(i, N - 1) {
		ll a, b;
		cin >> a >> b;
		t[a].push_back(b);
		t[b].push_back(a);
	}

	vector<ll> c(N + 1);
	repn(i, N) cin >> c[i];
	sort(++c.begin(), c.end(), greater<ll>());

	queue<ll> q;
	vector<ll> ans(N + 1, -1);

	ll pos = 1;
	q.push(1);
	ans[1] = c[pos];

	while (!q.empty()) {
		ll v = q.front();
		q.pop();

		for (ll w : t[v]) {
			if (ans[w] != -1) { continue; }
			pos++;
			q.push(w);
			ans[w] = c[pos];
		}
	}

	ll sum = 0;
	for (ll i = 2; i <= N; i++) { sum += c[i]; }

	cout << sum << endl;
	repn(i, N) cout << ans[i] << " ";


	system("PAUSE");
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
int n;
int a[205];
int cal(int x)
{
    return x / 2;
}
int main()
{
    scanf("%d",&n);
    for(int i = 1;i <= n;i++){
        scanf("%d",&a[i]);
    }
    int last = 1;
    int ans = 0;
    for(int i = 1;i <= n + 1;i++){
        if(a[i] != a[i - 1]){
            ans += cal(i - last);
            last = i;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;

ll n, a, s[100005]={1}, mx=1e18, fl;
int main() {
	cin >> n;
	for(ll i=1; i<=n; i++) {
		scanf("%lld", &a);
		if(!a) return puts("0"), 0;
		s[i] = s[i-1] * a;
		if(s[i]>mx || s[i] < s[i-1]) fl = 1;
	}
	if(fl) cout << -1;
	else cout << s[n];
	return 0;
}


Measured memory_bytes: 4544
//#define DEB1 //input from input.txt
//#define NDEBUG
#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <thread>
#include <mutex>
#include <iomanip>
#include <cassert>

#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define INF(a) memset(a, 0x3f, sizeof(a))
#define ALL(t) (t).begin(),(t).end()
#define FILL(a,c) fill(a, a+ sizeof(a)/sizeof(*a),c)
#define FILL2D(A,c) fill(A[0], A[0] +sizeof(A)/sizeof(**A),c)
#define FILL3D(A,c) fill(A[0][0], A[0][0] +sizeof(A)/sizeof(***A),c)
#define REP(i,m) for(int i=0;i<(m);++i)
// closed interval, inverse repeat
#define CIREP(i,start,fin) for(int i=(start);i>=(fin);i--)
#define CREP(i,start,fin) for(int i=(start);i<=(fin);i++)
#define RNG(i,start,fin) for(int i=(start);i<(fin);i++)
#define IN(a, x, b) (a<=x && x<b)
#define PB push_back
#define SZ(x) (int)(x).size()

using namespace std;

using LL = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<LL,LL>;
using VI = vector<int>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VVI = vector<VI>;
const LL LINF = 1001002003004005006ll;
/* 
template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,SZ(v))i>>v[j];return i;}

template<typename T>string join(const vector<T>&v)
{stringstream s;REP(i,SZ(v))s<<' '<<v[i];return s.str().substr(1);}

template<typename T>inline ostream& operator<<(ostream&o,const vector<T>&v)
{if(SZ(v))o<<join(v);return o;}
*/

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;
}




/*
constant values
*/

//const int dx[] = {1,0,-1,0};
//const int dy[] = {0,1,0,-1};
//const int MX = 31001;

//const ll INF= 1LL<<60 ;//INF = 1001001001001; //1e9


// Main program
void solve(){
    int N,K;
    cin >> N >> K;
    int cnt = 0;
    int cur = 1;
    while(1){
        cur = cur*K;
        cerr << cur << " " << cnt << endl;
        if(cur > N){
            break;
        }
        ++cnt;
    }
    cout << cnt + 1 << endl;
    return;
}

// ----------------------------------------------
int main(){

#ifdef DEB1
    cout << "DEBUG MODE"  << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf()); //for debug
#endif

    int T=1; 

    for (int i = 0; i < T; ++i) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
using namespace std;
 
#define N 100
#define INFTY 1000000
 
int M[N][N],d[N];
int n,u,k,v;
 
//bfs
void bfs(int s){
 
  queue <int> Q;
  //十分大きな数字に初期化
  for(int i = 0; i < N; i++ ) d[i] = INFTY;
  
  //最初の訪問先
  d[s] = 0;
  Q.push(s);

  //Qが空でないとき
  while ( !Q.empty() ){

    //queueから出す
    u = Q.front(); Q.pop();

    for( int v = 0; v < n; v++ ){

      //つながってないとき
      if( M[u][v] == 0 ) continue;

      //既に訪問ずみのとき
      if( d[v] != INFTY ) continue;

      //時間を入力
      d[v] = d[u] + 1;

      //queueに追加
      Q.push(v);
    }
  }
 
  //出力
  for( int i = 0; i < n; i++ ){
    cout << i+1 << " ";
    if ( d[i] == INFTY ) cout << -1;
    else cout << d[i];
    cout << endl;
  }
 
}
 
 
int main(){

  //初期化
  for( int i = 0; i < n; i++ ){
    for( int j = 0; j < n; j++ ) M[u][v] = 0;
  }
  
  //入力
  cin >> n;
  for( int i = 0; i < n; i++ ){
    cin >> u;
    u--;
    cin >> k;
    for( int j = 0; j < k; j++ ){
      cin >> v;
      v--;
      //つながっているとき
      M[u][v] = 1;
    }
  }
  
  //bfs
  bfs(0);
   
  return 0;
}

Measured memory_bytes: 1240
object Main {
  import java.util.Scanner

  def readStrings(n: Int)(implicit sc: Scanner): Array[String] = Array.fill(n) { sc.next() }
  def readInts(n: Int)(implicit sc: Scanner): Array[Int] = Array.fill(n) { sc.nextInt() }
  def readLongs(n: Int)(implicit sc: Scanner): Array[Long] = Array.fill(n) { sc.nextLong() }
  def readLineStrings(implicit sc: Scanner): Array[String] = sc.nextLine().split(' ')
  def readLineInts(implicit sc: Scanner): Array[Int] = readLineStrings.map(_.toInt)
  def readLineLongs(implicit sc: Scanner): Array[Long] = readLineStrings.map(_.toLong)

  def main(args: Array[String]): Unit = solve(new Scanner(System.in))

  def mode[T](list: List[T]): (T, Int) = list.groupBy(identity).mapValues(_.size).maxBy(_._2)
  def secondMode[T](list: List[T]): Option[(T, Int)] = {
    list.groupBy(identity).mapValues(_.size).toList.sortBy(_._2).reverse.drop(1).headOption
  }

  def solve(implicit sc: Scanner): Unit = {
    val Array(n) = readLineInts
    val v = readLineInts
    val even = v.zipWithIndex.filter { case (_, index) => index % 2 == 0}.map(_._1).toList
    val odd = v.zipWithIndex.filter { case (_, index) => index % 2 == 1}.map(_._1).toList
    val (evenModeElem, evenModeNumber) = mode(even)
    val (oddModeElem, oddModeNumber) = mode(odd)
    if (evenModeElem == oddModeElem) {
      if (evenModeNumber > oddModeNumber) {
        println(n - (evenModeNumber + secondMode(odd).get._2))
      } else if (evenModeNumber < oddModeNumber) {
        println(n - (oddModeNumber + secondMode(even).get._2))
      } else { // evenModeNumber == oddModeNumber
        if (evenModeNumber == (n / 2)) {
          println(evenModeNumber)
        } else {
          println(n - (evenModeNumber + Math.max(secondMode(even).get._2, secondMode(odd).get._2)))
        }
      }
    } else {
      println(n - (evenModeNumber + oddModeNumber))
    }
  }
}


Measured memory_bytes: 116400
N = int(input())
S = input()

count = 0
for i in range(10):
  for j in range(10):
    for k in range(10):
      pas = (str(i),str(j),str(k))
      key = 0
      for c in S:
        if c == pas[key]:
          key += 1
          if key ==3:
            count +=1
            break
print(count)

Measured memory_bytes: 42524
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    long long N, A, B, C, D, E;
    cin >> N >> A >> B >> C >> D >> E;
    cout << max( (N - 1) / A, max((N - 1) / B, max((N - 1) / C,max( (N - 1) / D, (N - 1) / E )))) + 5 << endl;
    return 0;
}


Measured memory_bytes: 256
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int x = 0;

  if(c == -1 || d == -1) x = a - b;
  else x = - (c - d);

  if(x > 0) cout << "Bob" << endl;
  else if(x < 0) cout << "Alice" << endl;
  else cout << "Draw" << endl;
  return 0;
}



Measured memory_bytes: 3212
import java.util.*;
import java.lang.*;

class Main {
    
    public static void main(String[] areg) {
        Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
        int[] a = new int[N];
        for (int i = 0; i < N; i++)
            a[i] = sc.nextInt();
		sc.close();
        
        int bit = 0;
        int free = 0;
        for (int i = 0; i < N; i++) {
            if (a[i] < 400)
                bit |= (1 << 0);
            if (a[i] >= 400 && a[i] < 800)
                bit |= (1 << 1);
            if (a[i] >= 800 && a[i] < 1200)
                bit |= (1 << 2);
            if (a[i] >= 1200 && a[i] < 1600)
                bit |= (1 << 3);
            if (a[i] >= 1600 && a[i] < 2000)
                bit |= (1 << 4);
            if (a[i] >= 2000 && a[i] < 2400)
                bit |= (1 << 5);
            if (a[i] >= 2400 && a[i] < 2800)
                bit |= (1 << 6);
            if (a[i] >= 2800 && a[i] < 3200)
                bit |= (1 << 7);
            if (a[i] >= 3200)
                free++;
        }
        
        int count = 0;
        for (; bit != 0 ; bit &= bit - 1)
            count++;
        
        System.out.print(Math.max(1, count));
        System.out.print(" ");
        System.out.print(count + free);
    }
}

Measured memory_bytes: 21844
#include<stdio.h>

int main(){
  int n,k,i,ans=0;
  scanf("%d%d",&n,&k);
  for(i=0;i<n;i++){
    int a;
    scanf("%d",&a);
    if(a>=k)ans++;
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N = I()
a = LI()
ans = 0
for i,x in enumerate(a,1):
    if x=='*':
        continue
    if a[x-1]==i:
        ans += 1
        a[x-1] = '*'
print(ans)


Measured memory_bytes: 23464
def main():
    from fractions import gcd
    n=int(input())
    for _ in range(n):
        a,b,c,d=list(map(int,input().split()))
        if a<b or b>d:
            print("No")
            continue
        k=(a-c-1)//b+1
        e=a-b*k
        if e<0:
            print("No")
            continue
        if b<=c+1 and b<=d:
            print("Yes")
            continue
        g=gcd(b,d)
        if b-c>g:
            print("No")
        else:
            print("Yes")
main()


Measured memory_bytes: 5332
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = null;
		try{
			scan = new Scanner(System.in);
			boolean[][] card = new boolean[4][13];
			String[] set ={"S","H","C","D"};
			int n = scan.nextInt();
			for(int i = 0 ; i < n;i++){
				String color = scan.next();
				int num = scan.nextInt();
				for(int j = 0;j< set.length;j++){
					if(set[j].equals(color)){
						card[j][num -1] = true;
						break;
					}
				}
			}
			for(int i = 0;i < card.length;i++){
				for(int j = 0 ;j < card[i].length;j++){
					if(!card[i][j]){
						System.out.println(set[i] +" "+(j + 1));
					}
				}
			}
		}finally{
			if(scan != null)scan.close();
		}
	}
}

Measured memory_bytes: 18052
#include<bits/stdc++.h>
using namespace std;
typedef long long int64;
const int64 P = 1000000000ll + 7;
int64 n,m,k;
int64 fz[1000010],fm[1000010];
int64 fb[1000010],fc[1000010];
int64 mpow(int64 x, int64 y)
{
	int64 tmp = x, ret = 1;
	while(y)
	{
		if(y & 1) ret = ret * tmp % P;
		tmp = tmp * tmp % P;
		y >>= 1;
	}
	return ret;
}
int64 C(int x, int y)
{
	if(x < y) return 0;
	return fz[x] * fm[y] % P * fm[x - y] % P;
}
int main()
{
    cin >> n >> m >> k;
    fz[0]=fm[0]=1;
    for(int i = 1; i <= 1000000; i++)
		fz[i] = fz[i - 1] * i %P, fm[i] = mpow(fz[i], P - 2);
	int64 ans = 0;
	for(int i = n; i < n + m + k + 1; i++)
	{
		int64 cnt = C(i - 1, n - 1);
		fb[i] = (fb[i - 1] * 2 % P + C(i - (n + 1), i - n - (m + 1))) % P;
		fc[i] = (fc[i - 1] * 2 % P + C(i - (n + 1), i - n - (k + 1))) % P;
		ans = (ans + cnt * ((mpow(2, i - n) - (fb[i] + fc[i]) % P) % P + P) % P * mpow(3, n + m + k - i) % P) % P;
	}
	cout << ans << endl;
    return 0;
}


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    long long a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    long long resp = 0;
    long long s = 0;
    for (int i = 0; i < n; i++) {
        if (i % 2 == 0) {
            if (s + a[i] > 0) {
                s += a[i];
            } else {
                resp += 1 - s - a[i];
                s = 1;
            }
        } else {
            if (s + a[i] < 0) {
                s += a[i];
            } else {
                resp += s + a[i] + 1;
                s = -1;
            }
        }
    }
    long long resm = 0;
    s = 0;
    for (int i = 0; i < n; i++) {
        if (i % 2 == 1) {
            if (s + a[i] > 0) {
                s += a[i];
            } else {
                resm += 1 - s - a[i];
                s = 1;
            }
        } else {
            if (s + a[i] < 0) {
                s += a[i];
            } else {
                resm += s + a[i] + 1;
                s = -1;
            }
        }
    }
    long long res = min(resp, resm);
    cout << res << "\n";
    return 0;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  int mx = (n-1)*(n-2)/2;
  if (mx < k) {
    puts("-1");
    return 0;
  }
  vector<P> ans;
  rep(i,n-1) {
    ans.push_back(P(i+1,n));
  }
  int add = mx-k;
  vector<P> edge;
  rep(i,n-1)rep(j,i) edge.push_back(P(i+1,j+1));
  rep(i,add) ans.push_back(edge[i]);
  cout << ans.size() << endl;
  rep(i,ans.size()) {
    cout << ans[i].first << " " << ans[i].second << endl;
  }
  return 0;
}

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


using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0; i<ll(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const int  INF = 1 << 29;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;



int main(){

	int a, b;
	cin >> a >> b;
	if (a > b) {
		swap(a, b);
	}
	REP(i, b) {
		cout << a;
	}

}

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

//https://diverta2019.contest.atcoder.jp/tasks/diverta2019_a
//すぬけ君は 1,2,[ldots],N の N 個の整数を持っています。 すぬけ君はこれらの整数から K 個の整数を選んで高橋君にあげようと考えています。

//連続する K 個の整数を選ぶ方法は何通りありますか？

    int main() {
        int N,K;
        cin >> N >> K;
        int i;
        i = N - K + 1;
        cout << i << endl;
    }


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		
		int ary[][] = new int[num][6];
		
		for(int i=0; i<num; i++){
			for(int j=0; j<6; j++){
				ary[i][j] = sc.nextInt();
			}
		}
		int ary2[] = new int[6];
		int ary3[] = new int[6];
		int co = 0;
	it:	for(int i=0; i<num-1; i++){
			for(int j=i+1; j<num; j++){
				for(int k=0; k<6; k++){
					ary2[k]=ary[i][k];
					ary3[k]=ary[j][k];
				}
				co = plan(ary2,ary3);
				if(co==4)break it;
			}
		}
		if(co==4){
			System.out.println("No");
		}else{
			System.out.println("Yes");
		}
	}
		
		public static int plan(int[] d, int[] t){
		int sd1ary[] = {d[0], d[5], d[1], d[2], d[4], d[3]};
		int sd2ary[] = {t[0], t[1], t[2], t[3], t[4], t[5]};
		int sd3ary[][] = 
			   {{t[0], t[5], t[1], t[2], t[4], t[3]}, 
				{t[1], t[4], t[0], t[3], t[5], t[2]}, 
				{t[2], t[3], t[4], t[0], t[1], t[5]},  
				{t[3], t[2], t[4], t[5], t[1], t[0]},  
				{t[4], t[1], t[2], t[5], t[3], t[0]},  
				{t[5], t[0], t[3], t[4], t[2], t[1]}};
		int count = 0;
		int add = 0;
		
  out : for(int k=0; k<6; k++){
			if(sd1ary[0] == sd2ary[k]){
				if(sd1ary[1]!=sd3ary[k][1])break;
				for(int j=2; j<6; j++){
					count=0;
					if(sd1ary[2]==sd3ary[k][j]){
						for(int n=0; n<4; n++){
							add = j+n;
							if(add>5) add=add-4;

							if(sd1ary[n+2]==sd3ary[k][add]){
								count++;
								if(count==4)break out;
							}
						}
					}
				}
			}
		}
		return count;
	}
}

Measured memory_bytes: 30216
N, K = map(int, input().split())
d = []
A = []

s0 = set([i for i in range(1,N+1)])
s1 = set()

for i in range(K):
    d.append(int(input()))
    A.append(list(map(int, input().split())))

    for j in range(d[i]):
        s1.add(A[i][j])

s_diff = s0 - s1

print(len(s_diff))

Measured memory_bytes: 9212
module.exports=function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){"use strict";var n=r(1),i=new(r(2))(n.readFileSync("/dev/stdin","utf8").trim().split(/\s+/g));r(4)(i)},function(t,e){t.exports=require("fs")},function(t,e,r){"use strict";var n=r(3);t.exports=class{constructor(t){this.inp=new n(t)}inr(){return this.inp.deq()}in(){return parseInt(this.inp.deq(),10)}fin(){this.inp.clear()}}},function(t,e,r){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.size=t.length,this.items=t,this.ind=0}enq(t){this.size+=1,this.items.push(t)}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}clear(){this.items=[],this.size=0,this.ind=0}}},function(t,e,r){"use strict";t.exports=function(t){for(var e=t.in(),r=1;r<=3500;r++)for(var n=1;n<=3500;n++){var i=e*r*n/(4*r*n-e*(r+n));if(i%1==0&&0<i&&i<=3500){var o=[r,n,i];return void console.log(o.join(" "))}}}}]);

Measured memory_bytes: 7756
#include<bits/stdc++.h>
using namespace std;
bool comp(pair<long long int,long long int>a,pair<long long int,long long int>b)
{
    if(a.first==b.first)
    {
        if(a.second<=b.second)
        return true;
        else
        return false;
    }
    if(a.first>b.first)
    return true;
    else return false;
}
long long int gcd(long long int bdda,long long int chota)
{
    if(chota==0)
        return bdda;
    return gcd(chota,bdda%chota);
}
void solve()
{
    long long int a,b,c;
    cin>>a>>b>>c;
    long long int num=0;
    while(true){
        if(a%2==1||b%2==1||c%2==1){
            cout<<num;return ;
        }
        if(a==b&&b==c){
            cout<<-1;return ;
        }
        ++num;
        long long int x,y,z;
        x=(b/2+c/2);y=(a/2+c/2);z=(a/2+b/2);
        a=x;b=y;c=z;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;    
    t=1;

    //cin>>t;
    while(t--)
    {
        solve();
    }
}


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

const int64_t MOD = 1000000007;
typedef int64_t ll;
typedef uint64_t ull;

#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

ll pCount(int x){
  if(x==0) return 1;
  return pCount(x-1)*2 + 1;
}

ll allCount(int x){
  if(x==0) return 1;
  return allCount(x-1)*2 + 3;
}


signed main() {
  ull n;
  ll x;
  cin >> n >> x;
  
  ll v;
  ull g = 0;
  for(ull i=0;i<n;i++){
    cin >> v;
    if(0==g) g=abs(v-x);
    g = gcd(abs(v-x),g);
  }
  cout << g << endl;
  
  return 0;
}



Measured memory_bytes: 3640
object Main {
  def main(args: Array[String]) = {
    import scala.io.StdIn.readLine

    val sc = new java.util.Scanner(System.in)
    val times = readLine.split(" ").map(_.toInt).toList
    sc.close()

    val result = times.permutations.map(t => t(0) + t(1)).toList.min

    println(result)
  }
}

Measured memory_bytes: 27196