akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <queue>
#include <cstring>
using namespace std;

int main() {
	int N, ans = 0; cin >> N;
	vector<int> L(N);
	vector<pair<int,int>> z;
	for (int i = 0; i < N; i++)cin >> L[i];
	sort(L.begin(), L.end());
	for (int i = N-2; i > 0; i--) {
		for (int j = N-1; j >1; j--) {
			if (i >= j)continue;
			int a=upper_bound(L.begin(), L.begin()+i, L[j] - L[i])- L.begin();
			int b = upper_bound(L.begin(), L.begin()+i, L[j] + L[i]) - L.begin();
			ans += abs(b - a);
		}
	}
	cout << ans << endl;
}





Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

int n, m;

vector<set<int>> adj;

int main() {
    GI(n);
    GI(m);

    adj.resize(n+1);

    int a;
    int b;

    FORN(i, m) {
        GI(a);
        GI(b);
        adj[a].insert(b);
        adj[b].insert(a);
    }

    for (int i = 2; i < n; i++) {
        if (adj[i].count(1) && adj[i].count(n)) {
            printf("POSSIBLE\n");
            return 0;
        }
    }

    printf("IMPOSSIBLE\n");
    return 0;
}

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

using namespace std;

#define int long long
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl '\n'
#define Endl '\n'
#define cont continue
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a*b/__gcd(a,b)
#define pb push_back
#define mp make_pair
#define mem(x) memset(x, 0, sizeof(x))

const ll inf=1e18;
const int mod=1e9+7;
inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
const int mxn = 2e5+10;

//ll fact[mxn];
//ll in_fact[mxn];
//fact[0] = 1;
//for(ll i = 1; i < mxn; i++) {
	//fact[i] = (i*fact[i-1])%mod;
//}
//in_fact[mxn-1] = bigmod(fact[mxn-1],mod-2);
//for(ll i = mxn-2; i >= 0; i--) {
	//in_fact[i] = (in_fact[i+1] * (i+1))%mod;
//}
//ll c(ll n,ll r) {
	//ll ans = (fact[n] * (in_fact[r] * in_fact[n-r]%mod))%mod;
	//return ans;
//}


signed main(){
    fast;
	//freopen ("input.txt", "r", stdin);
	//freopen ("output.txt", "w", stdout);
    int tt = 1;
    //cin>>tt;
    for(int tc = 1; tc <= tt; tc++) {
        int n,x,t;
        cin>>n>>x>>t;
        int d= n/x;
        if(n%x)d++;
        cout<<d*t<<endl;
			
        
        
    }



return 0;
}


Measured memory_bytes: 3656
import sys
sys.setrecursionlimit(10**7)
input = lambda: sys.stdin.readline().rstrip()
MOD = 10**9+7

n = int(input())
g = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = map(int, input().split())
    a -= 1; b -= 1
    g[a].append(b)
    g[b].append(a)

lim = 10**5*2
fact = [1, 1] + [0] * (lim-1)
fact_inv = [1, 1] + [0] * (lim-1)
inv = [0, 1] + [0] * (lim-1)
for i in range(2, lim+1):
    fact[i] = fact[i-1] * i % MOD
    inv[i] = MOD - inv[MOD % i] * (MOD//i) % MOD
    fact_inv[i] = fact_inv[i-1] * inv[i] % MOD
def comb(n, m):
    if n < m or n < 0 or m < 0: return 0
    return fact[n] * (fact_inv[m] * fact_inv[n-m] % MOD) % MOD
def icomb(n, m):
    if n < m or n < 0 or m < 0: return 0
    return fact_inv[n] * (fact[m] * fact[n-m] % MOD) % MOD

dp = [1] * n
size = [0] * n

def dfs(v, pv):
    for nv in g[v]:
        if nv == pv: continue
        dfs(nv, v)
        ns = size[nv]+1
        size[v] += ns
        dp[v] *= dp[nv] * comb(size[v], ns) % MOD
        dp[v] %= MOD

def dfs2(v, pv):
    for nv in g[v]:
        if nv == pv: continue
        d, sz = dp[v], size[v]
        d *= pow(dp[nv], MOD-2, MOD) * icomb(sz, size[nv]+1) % MOD
        d %= MOD
        sz -= size[nv]+1

        size[nv] += sz+1
        dp[nv] *= d * comb(size[nv], sz+1) % MOD
        dp[nv] %= MOD
        dfs2(nv, v)

dfs(0, -1)
dfs2(0, -1)
print(*dp, sep="\n")


Measured memory_bytes: 105896
import fractions

abcd = list(map(int, input().split()))
a = abcd[0]
b = abcd[1]
c = abcd[2]
d = abcd[3]

aa = a - 1
lcm = (c * d) // fractions.gcd(c, d)

a_count = aa - (aa // c) - (aa // d) + (aa // lcm)
b_count = b - (b // c) - (b // d) + (b // lcm)

print(b_count - a_count)

Measured memory_bytes: 5052
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define mp(a,b) make_pair(a,b)
#define vi vector<int>
#define mii map<int,int>
#define mpi map<pair<int,int>,int>
#define vp vector<pair<int,int> >
#define pb(a) push_back(a)
#define fr(i,n) for(i=0;i<n;i++)
#define rep(i,a,n) for(i=a;i<n;i++)
#define F first
#define S second
#define endl "\n"
#define fast std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define dom 998244353
#define pi 3.14159265
#define sl(a) (int)a.length()
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
#define pii pair<int,int> 
#define mini 2000000000000000000
#define time_taken 1.0 * clock() / CLOCKS_PER_SEC
//mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
void shikhar7s(int cas)
{
    string s,t;
    cin>>s>>t;
    int n=sl(s),c=0,i;
    fr(i,n)
    {
        if(s[i]!=t[i])
            c++;
    } 
    cout<<c;
}
signed main()
{
    fast;
    int t=1;
    //cin>>t;
    int cas=1;
    while(cas<=t)
    {
    shikhar7s(cas);
    cas++;
    }
    return 0;
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

ll T;

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

	int N; cin >> N;
	vll arrA (N);
	F0R(i, N) cin >> arrA[i];
	vll arrB(N);
	F0R(i, N) cin >> arrB[i];

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


	ll res = 0;

	FOR(i, 0, 30) {
		int count = 0;

		T = pow(2, i);

		vll A (N);
		F0R(i, N) A[i] = arrA[i] % (2 * T);

		vll B (N);
		F0R(i, N) B[i] = arrB[i] % (2 * T);

		sort(A.begin(), A.end());
		sort(B.begin(), B.end());

		int j = 0;
		int k = 0;
		int l = 0;

		for (int i = N - 1; i >= 0; --i) {
			while (j < N && B[j] + A[i] < T) ++j;
			while (k < N && B[k] + A[i] < 2 * T) ++k;
			while (l < N && B[l] + A[i] < 3 * T) ++l;
			count += k - j;
			count += N - l ;
		}

		if (count % 2) res |= (1 << i);
	}
	print(res);
}

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

bool solve() {
    string S;
    cin >> S;
    if ( S.size() < 4 ) return false;
    if ( S.substr(0,4) == "YAKI") return true;
    return false;
}

int main() {
    string ans = solve() ? "Yes" : "No";
    cout << ans << "\n";
    return 0;
}

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

cnt = 0

for i in range(10):
    x = 0
    while S[x] != str(i) and x != (len(S)-3):
        x += 1
    if S[x] == str(i):
        for j in range(10):
            y = x + 1
            while S[y] != str(j) and y != (len(S)-2):
                y += 1
            if S[y] == str(j):
                for k in range(10):
                    z = y + 1
                    while S[z] != str(k) and z != (len(S)-1):
                        z +=1
                    if S[z] == str(k):
                        cnt +=1

print(cnt)             

Measured memory_bytes: 43868
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "cmath"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;


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

	cin >> N >> M;
	vector<int>num(M);
	for (int i = 0; i < M; i++) {
		cin >> num[i];
		if (num[i] % 2) {
			K++;
		}
	}
	if (K > 2) {
		cout << "Impossible\n";
		return 0;
	}
	for (int i = 0; i < M; i++) {
		if (num[i] % 2) {
			swap(num[i], num[0]);
			break;
		}
	}
	for (int i = M - 1; i >= 0; i--) {
		if (num[i] % 2) {
			swap(num[i], num[M - 1]);
			break;
		}
	}
	for (int i = 0; i < M; i++) {
		cout << num[i] << " ";
	}
	cout << endl;
	if (M == 1) {
		if (num[0] == 1) {
			cout << 1 << endl << 1 << endl;
			return 0;
		}
		cout << 2 << endl;
		cout << num[0] - 1 << " " << 1 << endl;
		return 0;
	}
	if (num[0] == 1) {
		cout << M - 1 << endl;
	}
	else {
		cout << M << endl;
	}
	num[0]--;
	num[M - 1]++;
	for (auto i : num) {
		if (i) {
			cout << i << " ";
		}
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
 
const ll INF = LLONG_MAX/3;
 
struct MinSegTree{
    int n; vector<ll> dat;
    //初期化
    MinSegTree(int _n){
        n=1;
        while(n<_n) n*=2;
        dat=vector<ll>(2*n-1,INF);
    }
    //k番目(0-indexed)の値をaに変更
    void update(int k, ll a){
        k+=n-1;
        dat[k]=a;
        //更新
        while(k>0){
            k=(k-1)/2;
            dat[k]=min(dat[2*k+1],dat[2*k+2]);
        }
    }
    //内部的に投げられるクエリ
    ll _query(int a, int b, int k, int l, int r){
        if(r<=a || b<=l) return INF;
 
        if(a<=l && r<=b) return dat[k];
 
        ll vl=_query(a,b,2*k+1,l,(l+r)/2);
        ll vr=_query(a,b,2*k+2,(l+r)/2,r);
        return min(vl,vr);
    }
    ll query(int a, int b){
        return _query(a,b,0,0,n);
    }
};
 
int main()
{
    int n,Q,A,B;
    scanf(" %d %d %d %d", &n, &Q, &A, &B);
    --A;
    --B;
 
    vector<int> x(Q+1);
    x[0]=A;
    rep(i,Q)
    {
        scanf(" %d", &x[i+1]);
        --x[i+1];
    }
 
    ll all_add = 0;
 
    MinSegTree L(n),R(n);
    L.update(B, -B);
    R.update(B, B);
    rep(i,Q)
    {
        ll mm = min(L.query(0,x[i+1]+1)+x[i+1], R.query(x[i+1],n)-x[i+1]) + all_add;
 
        all_add += abs(x[i+1]-x[i]);
 
        L.update(x[i],mm-x[i]-all_add);
        R.update(x[i],mm+x[i]-all_add);
    }
 
    ll ans=INF;
    rep(i,n) ans=min(ans,L.query(i,i+1)+i);
    printf("%lld\n", ans+all_add);
    return 0;
}

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

const ll mod = 1e9+7;

int main(){
    ll n, sum=0;
    vector<ll> a;

    cin >> n;
    a.assign(n,0);
    for(int i=0;i<n;i++){
        cin >> a[i];
        sum= (sum + a[i])%mod;
    }

    ll answ=0;
    for(int i=0;i<n;i++){
        sum = ((sum-a[i])%mod+mod)%mod;
        answ = (answ + (a[i]*sum)%mod)%mod;
    }

    cout << answ <<'\n';

    return 0;
}

Measured memory_bytes: 4756
#include "bits/stdc++.h"
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define Alint(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1ll << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, MAX = 1e18, INF = -1e9;
typedef long double ld;

lint A, B;
int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> A >> B;
	cout << A*B;
}

Measured memory_bytes: 3688
#include <iostream>

template <typename T> T gcd(T a, T b) {
	T r;

	while (b) {
		r = a % b;
		a = b;
		b = r;
	}

	return a;
}

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

int main() {
	using namespace std;
	for (;;) {
		int a, b;
		cin >> a >> b;
		if (cin.eof()) { break; }

		int g = gcd(a, b);
		int l = lcm(a, b);
		cout << g << ' ' << l << endl;
	}
	return 0;
}

Measured memory_bytes: 0
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import heapq

def main():
    n, m = map(int, input().split())
    ab = [list(map(int, input().split())) for i in range(n)]
    a_t = list(zip(*ab))
    AB = [[] for _ in range(m+1)]
    for a, b in zip(*a_t):
        if a <= m:
            AB[a].append(b*-1)
    # print(AB)
    cnt = 0
    h = [] 
    heapq.heapify(h)
    for i in AB:
        for j in i:
            heapq.heappush(h, j)
            # print('h', h)
        if h:
            cnt += heapq.heappop(h)
    print(-1*cnt)   

if __name__ == '__main__':
    main()

Measured memory_bytes: 41728
import java.util.Scanner;

public class Main {

  /**
   * @param args
   */
  public static void main(String[] args) {
    // TODO 自動生成されたメソッド・スタブ
    Scanner cin = new Scanner(System.in);
    int A = cin.nextInt();
    int B = cin.nextInt();
    int C = cin.nextInt();
    int K = cin.nextInt();

    int ans = 0;
    for (int i=0;i<A;i++){
      K = K - 1;
      if (K < 0) break;
      ans = ans + 1;
    }
    for (int i=0;i<B;i++){
      K = K - 1;
      if (K < 0) break;
      ans = ans + 0;
    }
    for (int i=0;i<C;i++){
      K = K - 1;
      if (K < 0) break;
      ans = ans - 1;
    }
    System.out.println(ans);
  }

}


Measured memory_bytes: 27168
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	int a[n];
	for(int i=0;i<n;i++) cin >> a[i];
	int v,j;
	for(int i=0;i<n;i++){
		v=a[i];
		j=i-1;
		while(j>=0 && a[j]>v){
			a[j+1]=a[j];
			j--;
		}
		a[j+1]=v;
		for(int j=0;j<n;j++){
			cout << a[j];
			if(j==n-1)cout << endl;
			else cout << " ";
		}
	}
	return 0;
}

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

#define MAX_A 100000

// i日後に支払われるのかでまとめる。
vector<int> salary[MAX_A] = {};
priority_queue<int> getMoneyJob;

int main()
{
	const int MAX_N = 100000;
	int n, m;
	cin >> n >> m;

	for (int i = 0; i < n; i++)
	{
		int _a, _b;
		cin >> _a >> _b;
		salary[_a].push_back(_b);
	}


	int answer = 0;

	// 期限まで1日前からはじめて、報酬を得られる仕事を追加していく。
	// 行った仕事は削除していく
	for (int i = 1; i <= m; i++)
	{
		// 報酬取得可能な仕事の追加
		int iSize = salary[i].size();
		if (iSize > 0)
		{
			for (int j = 0; j < iSize; j++)
				getMoneyJob.push(salary[i][j]);
		}

		// 最も高額なものを取り出す
		if (!getMoneyJob.empty())
		{
			answer += getMoneyJob.top();
			getMoneyJob.pop();
		}
	}

	cout << answer;


	return 0;
}



Measured memory_bytes: 5632
#include<iostream>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1 << 21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

void dijkstra() {
   int minv;
   int color[MAX], d[MAX];
   
   for(int i = 0; i < n; i++) {
   	  d[i] = INFTY; 
	  color[i] = WHITE;
   } 
   
   d[0] = 0;
   color[0] = GRAY;
   
   while( 1 ) {
      minv = INFTY;
      int u = -1;
      for(int i = 0; i < n; i++) {
      	  if(minv > d[i] && color[i] != BLACK) {
  	      	  minv = d[i];
  	      	  u = i;
  	      }
      }
      if(u == -1) break;
      color[u] = BLACK;
      for(int v =  0; v < n; v++) {
      	  if(color[v] != BLACK && M[u][v] != INFTY) {
  	      	if(d[v] > d[u] + M[u][v]) {
	      	  	d[v] = d[u] + M[u][v];
	      	  	color[v] = GRAY;
      	    }
         }
      }
   }
   
   for(int i = 0; i < n; i++) {
   	   cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl; 
   }
}

int main() {
	cin >> n;
	int u, k, c, v;
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < n; j++) {
			M[i][j] = INFTY;
		}
	}
	
	for(int i = 0; i < n; i++) {
		cin >> u >> k;
		for(int j = 0; j < k; j++) {
			cin >> v >> c;
			M[u][v] = c;
		}
	}
	
	dijkstra();
	
	return 0;
} 

Measured memory_bytes: 3104
#include <bits/stdc++.h>
 
//#include <vector>
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
ll mod =  1000000007;
ll maxn = 1000000000;
 
//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pii = pair<int, int>; // これ以降 pii という型名はpair<int, int> と同じ意味で使える
//---------------------------------------------------------------------------------------------------
 
int main(){
  int n,m;
  ll ans=0;
  cin>>n>>m;
  vector<vector<int>> A(m+1);
  rep(i,n){
      int a,b;
      cin>>a>>b;
      if(a>m)continue;
      else{
          A.at(a).push_back(b);
      }
  }
  priority_queue<int> p;
  for(int i=1;i<=m;i++){
      for(int b:A.at(i)){
          p.push(b);
      }
      if(!p.empty()){
          int maxb;
          maxb=p.top();
          ans+=maxb;
          p.pop();
          //cout<<maxb<<endl;
      }
      else ans+=0;
  }
  
  
  
  
  cout<<ans<<endl;
}

Measured memory_bytes: 5632
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
 int b1,b2,b3;
cin>>b1>>b2>>b3;
	if(b1==1&&b2==0&&b3==0){
		cout<<"Close"<<endl;
	}
	else if(b1==0&&b2==1&&b3==0){
		cout<<"Close"<<endl;
	}
	else if(b1==1&&b2==1&&b3==0){
		cout<<"Open"<<endl;
	}
	else if(b1==0&&b2==0&&b3==1){
		cout<<"Open"<<endl;
	}
	else if(b1==0&&b2==0&&b3==0){
		cout<<"Close"<<endl;		
	}
return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll
#define INF 1e16
#define mod 1000000007
using Graph = vector<vector<ll>>;
ll n,m;
ll a,b;
ll ans = 0;
// vector<ll> a,b;
// vector< vector<ll> > edge(vector<ll>(),0);
vector<bool> vis(false);

void dfs(const Graph &G, ll v, ll cnt) {
     // v を訪問済にする
    // v から行ける各頂点 next_v について
    if(cnt==n) ans++;
    for (auto next_v : G[v]) { 
        if (vis[next_v]) continue; // next_v が探索済だったらスルー
        vis[next_v] = true;
        dfs(G, next_v,cnt+1); // 再帰的に探索
        vis[next_v] = false;
    }
}
int main(){
    cin>>n>>m;
    // a.resize(n);
    // b.resize(n);
    vis.resize(n);
    Graph G(n);
    rep(i,m) {
        cin>>a>>b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vis[0] = true;
    dfs(G, 0, 1);
    cout<<ans<<endl;
    return 0;
}


	// #include <iostream>
    // #include <vector>
    // using namespace std;
    // using Graph = vector<vector<int>>;
    // // 深さ優先探索
    // vector<bool> seen;
    // void dfs(const Graph &G, int v) {
    // seen[v] = true; // v を訪問済にする
    // // v から行ける各頂点 next_v について
    // for (auto next_v : G[v]) { 
    // if (seen[next_v]) continue; // next_v が探索済だったらスルー
    // dfs(G, next_v); // 再帰的に探索
    // }
    // }
    // int main() {
    // // 頂点数と辺数
    // int N, M; cin >> N >> M;
    // // グラフ入力受取 (ここでは無向グラフを想定)
    // Graph G(N);
    // for (int i = 0; i < M; ++i) {
    // int a, b;
    // cin >> a >> b;
    // G[a].push_back(b);
    // G[b].push_back(a);
    // }
    // // 頂点 0 をスタートとした探索
    // seen.assign(N, false); // 全頂点を「未訪問」に初期化
    // dfs(G, 0);
    // }

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    #[allow(unused_mut)]
    let mut s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn main() {
  input! {
    n: usize,
    aa: [i64; n]
  }
  let mut dp = vec![vec![0i64; n+1]; n+1];
  for len in 1 .. n + 1 {
    for l in 0 .. n + 1 - len {
      let r = l + len;
      let p = dp[l+1][r];
      let q = dp[l][r-1];
      if (n - len) % 2 == 0 {
        dp[l][r] = cmp::max(p + aa[l], q + aa[r-1]);
      } else {
        dp[l][r] = cmp::min(p - aa[l], q - aa[r-1]);
      }
    }
  }
  println!("{}", dp[0][n]);
}


Measured memory_bytes: 90364
#   ????????°??¶???????????? s ???????????????????????????????¨????????????£?¶????????????????????????????????????§???????????? p ??????????????????????????????????????°??????
#   ????????°??¶????????????s????¨??????\?????????????????????
s = list(input())
#   ??????????±??????????p????¨??????\?????????????????????
p = list(input())
#   ?????????s??????????????????????????????????????????s?????????s?????????
s = s + s
#   print(s)
#   ???????????????????????????????????????????????°
flag = 0
for i in range(len(s) // 2):
    if s[i] == p[0]:
        for j in range(len(p)):
            if s[i + j] != p[j]:
                break
            if j == len(p) - 1:
                flag = 1
if flag == 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 7472
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <random>
#include <ctime>
#include <string>
#include <iomanip>
#include <set>
#include <map>
#include <queue>
#include <stack>

using namespace std;

typedef long long li;
typedef unsigned long long uli;
typedef pair<int, int> pii;
typedef long double ld;

#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define fr first
#define sc second
#define pb push_back
#define forn(i, n) for(int i = 0; i < int(n); ++i)
#define fore(i, l, r) for(int i = int(l); i < int(r); ++i)
#define forb(i, n) for(int i = int(n) - 1; i >= 0; --i)

const int INF = 1e9 + 1000;
const li INF64 = 1e15 + 1000;
const int M = 100 + 10;
const int N = 100 * 1000 + 100;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = 3.14159265359;

li gcd(li a, li b) {
    return a == 0 ? b : gcd(b % a, a);
}

int main() {
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);

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

    vector<string> d(n);
    forn(i, n) {
        cin >> d[i];
    }

    vector<vector<li>> dp(n + 1, vector<li>(m + 1));

    dp[0][0] = 1;

    forn(i, n) {
        forn(j, m) {
            dp[i + 1][j] += (i + 1 < n && d[i + 1][j] == '.') * dp[i][j];
            dp[i + 1][j] %= MOD;
            dp[i][j + 1] += (j + 1 < m && d[i][j + 1] == '.') * dp[i][j];
            dp[i][j + 1] %= MOD;
        }
    }

    cout << dp[n - 1][m - 1] << '\n';

}


Measured memory_bytes: 9216
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;




int main(){
    char s[510],ans[510];
    cin.getline(s,501);
    int len=strlen(s),cur=0;
    for(int i=0;i<len;i++){
    	if(s[i]=='0' || s[i]=='1'){
    		ans[cur]=s[i];
    		cur++;
		}
		if(s[i]=='B' && cur>0){
			cur--;
		}
	}
	ans[cur]=0;
	printf("%s\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
    詰まった時に、別の分野の問題として考え直す（これdpでは？、グラフとしてみればいいのでは？）
    多くの問題はパターンマッチだが、パターンに落とし込むまでが難しく、そのための訓練としてわからない問題をあれこれ色々な角度から考察してみるのではないか
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */



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

    int n; cin >> n;
    vector<vector<int>> a(n, vector<int>(n));

    rep(i, n) rep(j, n) cin >> a[i][j];
    vector<ll> dp(1<<n, 0);

    dp[0]=1;
    repr(S, 1, 1<<n){
        int i=0;
        rep(j, n) if(S&1<<j) ++i;
        rep(j, n) if(S&1<<j && a[i-1][j]==1){
            dp[S]+=dp[S^(1<<j)];
            chmod(dp[S]);
        }
    }
    cout << dp[(1<<n)-1] << endl;

    return 0;
}


Measured memory_bytes: 16640
#include<iostream>

using namespace std;

int main()
{
	int n,k;
	
	cin>>n>>k;
	
	int ans=0;
	
	for(int i=0;i<n;i++)
	{
		int input;
		cin>>input;
		if(input>=k) ans++;
	}
	
	cout<<ans;
	return 0;
}

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

int main() {

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

    int i,j,k,l;
    int ans[m];
    for(i=0;i<m;i++) ans[i]=0;
    for(i=0;i<n;i++){
        cin >> k;
        for(j=0;j<k;j++){
            cin >> l;
            ans[l-1]++;
        }
    }

    int count=0;
    for(i=0;i<m;i++){
        if(ans[i]==n){
            count++;
        }
    }
    cout << count << endl;

    return 0;
}


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

// 区間[i, j)に水やりをする関数
// 戻り値は水やりをした回数
int water(vector<int> &hs, int i, int j) {
  // 対象がないときにresult = 200が返っちゃう
  if (i >= j) { return 0; }

  int result = 200;
  for (int p = i; p < j; p++) {
    result = min(result, hs[p]);
  }
  for (int p = i; p < j; p++) {
    hs[p] -= result;
  }
  return result;
}

int main(void) {
  int n;
  cin >> n;
  vector<int> hs(n + 1, 0);
  for (int i = 0; i < n; i++) {
    cin >> hs[i];
  }

  int result = 0;
  int head = 0;
  int tail = 0;

  for (int i = 0; i < 100 * 1000; i++) {
    while (hs[head] == 0) { head++; }
    tail = head + 1;
    while (hs[tail] != 0) { tail++; }

    // 区間[i, j)に対して水やり
    if (head > n) { break; }
    result += water(hs, head, tail);
  }

  cout << result << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;

int main(){ 
  Int A, B, ans;
  cin >> A >> B;
  
  ans = (A / __gcd(A, B)) * B;
  
  cout << ans << endl;
}

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

INF = 10 ** 9 

list = [S]

con = 0

for i in range(INF):
	if S % 2 == 0:
		S = int(S / 2)
		list.append(S)
		con += 1

	else:
		S = (3 * S) + 1
		list.append(S)
		con += 1

	if S in list[:i]:
		break



print(con + 1)

Measured memory_bytes: 3060
#include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
    long long n,sum=0,i;
    scanf("%lld",&n);
    for(i=1; i<=n; i++)
    {
        if(i%3==0)
            continue;
        else if(i%5==0)
            continue;
        else if(i%3==0&&i%5==0)
            continue;
        else
            sum+=i;
    }
    printf("%lld\n",sum) ;
    return 0;
}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const long long INF = 1LL << 60;
// const int INF=1010101010;
using Graph = vector<vector<int>>;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  vector<bool> boo(n, true);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    if (h[a] <= h[b]) boo[a] = false;
    if (h[b] <= h[a]) boo[b] = false;
  }
  int cnt = 0;
  rep(i, n) if (boo[i]) cnt++;
  cout << cnt << endl;
}

Measured memory_bytes: 3784
#include "bits/stdc++.h"
using namespace std;
typedef unsigned long long ll;

int main(){
  int a[3][3],n,b;
  for(int i=0;i<3;++i){
    for(int j=0;j<3;++j){
      cin>>a[i][j];
    }
  }
  cin>>n;
  for(int q=0;q<n;++q){
    cin>>b;
    for(int i=0;i<3;++i){
      for(int j=0;j<3;++j){
        if(a[i][j]==b){
          a[i][j]=-1;
        }
      }
    }
  }
  
  if((a[0][0]==-1&&a[0][1]==-1&&a[0][2]==-1)||
    (a[1][0]==-1&&a[1][1]==-1&&a[1][2]==-1)||
    (a[2][0]==-1&&a[2][1]==-1&&a[2][2]==-1)||
    (a[0][0]==-1&&a[1][0]==-1&&a[2][0]==-1)||
    (a[0][1]==-1&&a[1][1]==-1&&a[2][1]==-1)||
    (a[0][2]==-1&&a[1][2]==-1&&a[2][2]==-1)||
    (a[0][0]==-1&&a[1][1]==-1&&a[2][2]==-1)||
    (a[0][2]==-1&&a[1][1]==-1&&a[0][2]==-1)){
    cout<<"Yes";
  }
  else{
    cout<<"No";
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;
typedef int64_t ll;

int main() {
    int D;
    cin >> D;
    vector<int> c(26), lastc(26);

    for (int i = 0; i < 26; i++){
        cin >> c.at(i);
    }
    vector<vector<int>> score(365, vector<int>(26));
    for (int i = 0; i < 365; i++){
        for (int j = 0; j < 26; j++){
            cin >> score.at(i).at(j);
        }
    }
    for (int i = 0; i < D; i++){
        int M = -1000000007, t= 0;
        for (int j = 0; j < 26; j++){
            M = max(M, score.at(i).at(j));
            if (score.at(i).at(j) == M){
                t = j + 1;
            }
        }
        cout << t << endl;
    }

}

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

main(){
  int H, W;
  char c;
  cin >> W >> H >> c;

  assert(3 <= W && W <= 21);
  assert(3 <= H && H <= 21);
  assert( W%2 && H%2 && 'A' <= c && c <= 'Z' );

  for ( int i = 0; i < H; i++ ){
    for ( int j = 0; j < W; j++ ){
      if ( i == 0 && j == 0 ||
           i == 0 && j == W-1 ||
           i == H-1 && j == 0 ||
           i == H-1 && j == W-1 ){
        cout << '+';
      } else if ( i == 0 || i == H-1 ){
        cout << '-';
      } else if ( j == 0 || j == W-1 ){
        cout << '|';
      } else if ( i == H/2 && j == W/2 ){
        cout << c;
      } else {
        cout << '.';
      }
    }
    cout << endl;
  }
}




Measured memory_bytes: 3132
from itertools import product
N = int(input())
A = tuple(map(int, input().split()))
Q = int(input())
query = tuple(map(int, input().split()))

cand = set()
for p in product(range(2), repeat=N):
    val = sum(x * y for x, y in zip(p, A))
    cand.add(val)

ans = ["yes" if v in cand else "no" for v in query]
print(*ans, sep="\n")


Measured memory_bytes: 5724
package main

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

func main() {
	sc = initScanner(os.Stdin)
	s, t := scanString(sc), scanString(sc)
	fmt.Println(solve(s, t))
}

func solve(s, t string) string {
	for i:=0;i< len(s);i++ {
		if s == t {
			return "Yes"
		}
		s = s[len(s)-1:] + s[0:len(s)-1]
	}
	return "No"
}

// --------------- BASE DEFINITIONS ---------------

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
	return sc
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func scanIntSlice(sc *bufio.Scanner, n int) []int {
	is := make([]int, n)
	for i := 0; i < n; i++ {
		is[i] = scanInt(sc)
	}

	return is
}

func scanFloat64(sc *bufio.Scanner) float64 {
	sc.Scan()
	f, _ := strconv.ParseFloat(sc.Text(), 64)
	return f
}

func scanFloat64Slice(sc *bufio.Scanner, n int) []float64 {
	fs := make([]float64, n)
	for i := 0; i < n; i++ {
		fs[i] = scanFloat64(sc)
	}

	return fs
}

func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func scanStringSlice(sc *bufio.Scanner, n int) []string {
	ss := make([]string, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		ss[i] = sc.Text()
	}

	return ss
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}


Measured memory_bytes: 1780
//https://atcoder.jp/contests/abc106/tasks/abc106_c

import java.io.*;

class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String S = br.readLine();
        String str = br.readLine();
        long K = Long.parseLong(str);
        if (K!=1){
            for (int i=0;i<S.length();i++){
                if (i==K-1 && String.valueOf(S.charAt(i)).equals("1")){
                    System.out.println(String.valueOf(S.charAt(i)));
                    break;
                }
                if (!String.valueOf(S.charAt(i)).equals("1")){
                    System.out.println(String.valueOf(S.charAt(i)));
                    break;
                }
            }
        } else {
            System.out.println(String.valueOf(S.charAt(0)));
        }
    }
}

Measured memory_bytes: 21204
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
std::mt19937 rnd(time(NULL));
#define rand rnd
#define pr std::pair<int,int>
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
template<class T>void cxk(T&a,T b){a=a>b?a:b;}
template<class T>void cnk(T&a,T b){a=a<b?a:b;}
#ifdef mod
int pow(int x,int y){
	int ret=1;
	while(y){
		if(y&1)ret=1ll*ret*x%mod;
		x=1ll*x*x%mod;y>>=1;
	}
	return ret;
}
template<class Ta,class Tb>void inc(Ta&a,Tb b){a=a+b>=mod?a+b-mod:a+b;}
template<class Ta,class Tb>void dec(Ta&a,Tb b){a=a>=b?a-b:a+mod-b;}
#endif
int n,S,T,fir[200010],head[200010],dep[200010],dis[1000010],nxt[1000010],w[1000010],id=1;
void link(int a,int b,int c){
	nxt[++id]=fir[a],fir[a]=id,dis[id]=b,w[id]=c;
	nxt[++id]=fir[b],fir[b]=id,dis[id]=a,w[id]=0;
}
int que[200010],hd,tl,el[100010];
std::vector<pr>E[100010];
bool BFS(){
	hd=tl=0;memset(dep,0,sizeof dep);
	dep[S]=1;que[tl++]=S;
	while(hd^tl){
		int x=que[hd++];
		for(int i=fir[x];i;i=nxt[i])
			if(w[i]&&!dep[dis[i]])
				dep[dis[i]]=dep[x]+1,que[tl++]=dis[i];
	}
	return dep[T];
}
int Dinic(int x,int maxflow){
	if(x==T)return maxflow;
	int ret=0;
	for(int&i=head[x];i;i=nxt[i])
		if(w[i]&&dep[dis[i]]==dep[x]+1){
			int d=Dinic(dis[i],std::min(maxflow-ret,w[i]));
			w[i]-=d,w[i^1]+=d,ret+=d;if(ret==maxflow)break;
		}
	return ret;
}
int match[100010],fa[100010],set[1000010];
int ax[100010],ay[100010];
void DFS(int x){
	for(int i=fir[x];i;i=nxt[i])
		if(w[i]&&dis[i]!=S&&!fa[match[dis[i]-n]]){
			fa[match[dis[i]-n]]=x;
			set[match[dis[i]-n]]=dis[i]-n;
			DFS(match[dis[i]-n]);
		}
}
int main(){
#ifdef LOCAL
	freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
#endif
	n=gi();
	for(int i=1;i<n;++i){
		int o=gi(),x;E[i].resize(o);
		for(int j=0;j<o;++j)link(x=gi(),i+n,1),E[i][j]={id,x};
	}
	S=n+n,T=n+n+1;
	for(int i=1;i<=n;++i)link(S,i,1),el[i]=id;
	for(int i=n+1;i<n+n;++i)link(i,T,1);
	int flow=0;
	while(BFS())memcpy(head,fir,sizeof head),flow+=Dinic(S,1e9);
	if(flow<n-1)puts("-1"),exit(0);
	int r=0;
	for(int i=1;i<=n;++i)if(!w[el[i]])r=i;
	for(int i=1;i<n;++i)for(pr j:E[i])if(w[j.fi])match[i]=j.se;
	fa[r]=-1;DFS(r);
	int cnt=0;for(int i=1;i<=n;++i)cnt+=!!fa[i];
	if(cnt<n)puts("-1"),exit(0);
	for(int i=1;i<=n;++i)if(~fa[i])ax[set[i]]=i,ay[set[i]]=fa[i];
	for(int i=1;i<n;++i)printf("%d %d\n",ax[i],ay[i]);
	return 0;
}


Measured memory_bytes: 27776
#include <bits/stdc++.h>
#define int long long
#define P(x) cout << x << endl
#define D(x) P(#x << ": " << x)
#define F(i,n) for (int i=0; i<(int)(n); i++)
#define DEC(i,n) for (int i=(int)(n); --i>=0;)
#define S(s) (int)((s).size())
#define ALL(v) v.begin(), v.end()
#define MI(a,v) a = min(a,(v))
#define MA(a,v) a = max(a,(v))
#define V vector
#define pb push_back
#define mt make_tuple
using namespace std;
const int B=10, LARGE=30, LEN=18;

int _ways[2][LARGE];
inline int ways(int diff, bool first) {
    return _ways[first][B+diff];
}
int p10[30];

int poss(int d, int len, bool first) {
    //P(len<<' '<<d);
    if (len == 0) return d==0;
    else if (len == 1) return (d==0) * ways(0, first);
    if (abs(d) >= p10[len]) return 0;
    int fact = p10[len-1]-1;
    //D(fact);
    int tot=0;
    for (int i=-9; i<=9; i++) {
        if ((d-i*fact) % 10 == 0) {
            int here = ways(i, first) * poss((d-i*fact)/10, len-2, false);
            //if (here) P(i<<": "<<here);
            tot += here;
        }
    }
    return tot;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    //P("CHANGE LENGTH");
    F(i,B) F(j,B) {
        if (j!=0) _ways[true][B+i-j]++;
        _ways[false][B+i-j]++;
    }
    p10[0] = 1;
    F(i,LARGE-1) p10[i+1] = p10[i] * B;
    int d; cin>>d;
    int tot=0;
    for (int l=1; l<=LEN; l++) {
        //P(l<<": "<<poss(d,l,true));
        tot += poss(d, l, true);
    }
    P(tot);
}

Measured memory_bytes: 256
def abc145_c():    
    n = int(input())
    xy = [list(map(int,input().split())) for i in range(n)]
    ans = 0
    for i in range(n):
        for j in range(n):
            ans += ((xy[i][0] - xy[j][0])** 2 + (xy[i][1] - xy[j][1])** 2)**0.5
    print(ans / n)
    
if __name__ == '__main__':
    abc145_c()

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

#define rep(i, u) for (int i = 0; i < u; i++)

using ll = long long;
using ull = unsigned long long;

int main() {
  int n, a, ans = 0;
  cin >> n;
  rep(i, n) {
    cin >> a;
    bool x = true;
    if (a % 2 == 0 && a > 2) x = false;
    else {
      for (int i = 3; i <= sqrt(a); i += 2) {
        if (a % i == 0) {
          x = false;
          break;
        }
      }
    }
    if (x) ans++;
  }
  cout << ans << endl;
  return 0;
}



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

int main(void){
  int N, c=0, i, a, ans;
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&a);
    if(a%2==0) c++;
  }
  ans = pow(3,N)-pow(2,c);
  printf("%d\n",ans);

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n)  for (int i = 0; i < (int) (n); i++)
#define REP1(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
using ll = long long;

int main() {
  ll a, b, n;
  cin >> a >> b >> n;
  if (n >= b) {
	  cout << a * (b - 1) / b;
	} else {
	  cout << a * n / b << endl;
	}
  return 0;
}


Measured memory_bytes: 3620
N = gets.to_i
xs = gets.split.map(&:to_i)

histo = {  }
xs.each do |x|
  histo[x] = 0 unless histo.has_key? x
  histo[x] += 1
end

ret = 0
#puts histo
histo.each do |k,v|
  if k > v
    ret += v
  else
    ret += v - k
  end
end

puts ret


Measured memory_bytes: 14468
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define IN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef long long ll;
/////////////////////////(๑•﹏•๑｀)/////////////////////////
int main() {
	int a,b;
	SCD2(a,b);

	if(a+b==15){
		printf("+\n");
	}else if(a*b == 15){
		printf("*\n");
	}else{
		printf("x\n");
	}

	return 0;
}

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

int main()
{
	int n;
	char suits[4] = { 'S', 'H', 'C', 'D' };
	bool d[4][13] = { false };

	cin >> n;

	for (int i = 0; i < n; i++)
	{
		char mark;
		int A;

		cin >> mark >> A;

		if (mark == suits[0]) d[0][A - 1] = true;
		else if (mark == suits[1]) d[1][A - 1] = true;
		else if (mark == suits[2]) d[2][A - 1] = true;
		else if (mark == suits[3]) d[3][A - 1] = true;

	}

	for (int i = 0; i < 4; i++)
	{
		for (int j = 0; j < 13; j++)
		{
			if (d[i][j] == false) cout << suits[i] << " " << j + 1 << "\n";
		}
	}

	return 0;
}

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

int main(){
  long long  n,a,b;
  cin >> n >> a >> b;
  long k=n/(a+b);
  long r=n%(a+b);
  if(r>a){
    r=a;
  }
  cout << (k*a)+r;
  return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7

a=sorted(a)
flgs=[]
if n%2==0:
    k=n//2
    for i in range(1,k+1):
        flgs.append(2*i-1)
        flgs.append(2*i-1)
else:
    k=(n-1)//2
    flgs.append(0)
    for j in range(1,k+1):
        flgs.append(2*j)
        flgs.append(2*j)

flgs=sorted(flgs)
if flgs==a:
    ans=2**k
    print(ans%mod)
else:
    print(0)

Measured memory_bytes: 20440
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#define lc (x<<1)
#define rc (x<<1|1)
#define gc getchar()//(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define mk make_pair
#define pi pair<int,int>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=2e5+10,size=1<<20;

//char buf[size],*p1=buf,*p2=buf;
template<class o> void qr(o &x) {
	char c=gc; x=0; int f=1;
	while(!isdigit(c)){if(c=='-')f=-1; c=gc;}
	while(isdigit(c)) x=x*10+c-'0',c=gc;
	x*=f;
}
template<class o> void qw(o x) {
	if(x/10) qw(x/10);
	putchar(x%10+'0');
}
template<class o> void pr1(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); putchar(' ');
}
template<class o> void pr2(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); puts("");
}

int n,a[N],v[N],cnt,f[N];
ll k;

int main() {
	qr(n);qr(k);for(int i=1;i<=n;i++) qr(a[i]);
	int x=1;
	do {
		v[x]=1;
		if(cnt==k) pr2(x),exit(0);
		f[cnt++]=x;
		x=a[x];
	} while(!v[x]);
	k-=cnt; cnt=0;
	do {
		v[x]=2;
		f[cnt++]=x;
		x=a[x];
	} while(!(v[x]&2));
	pr2(f[k%cnt]);
	return 0;
}



Measured memory_bytes: 5248
using System;
using System.Collections.Generic;
using System.Windows;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    public class Program
    {
        static void Main(string[] args)
        {
            var n = Read().Int();
            var al = new long[n];
            var ar = ReadSplit();
            for (int i = 0; i < n; i++)
            {
                al[i] = ar[i].Long();
            }
            var count = new long[n];
            for (int i = n - 1; i >= 0; i--)
            {
                var k = al[i];
                long j = i + 1;
                long tmp = j;
                long c = 0;
                while (tmp <= n)
                {
                    c += count[tmp - 1];
                    tmp += j;
                }
                if (k == 1 && c % 2 == 0)
                {
                    count[i] = 1;
                }
                if (k == 0 && c % 2 == 1)
                {
                    count[i] = 1;
                }
            }
            var m = count.Sum();
            Write(m);
            if (m == 0)
            {
                return;
            }
            var sb = new StringBuilder();
            for (int i = 0; i < n; i++)
            {
                if (count[i] == 1)
                {
                    sb.Append(i + 1);
                    sb.Append(" ");
                }
            }
            WriteRead(sb.ToString());
        }
        
        public static string Read()
        {
            return Console.ReadLine();
        }

        public static string[] ReadSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        public static void WriteRead(object str)
        {
            Console.WriteLine(str);
            Read();
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
        }

        private static bool ChangeMin<T>(ref T a, T b) where T : IComparable
        {
            if (a.CompareTo(b) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }

        private static bool ChangekMax<T>(ref T a, T b) where T : IComparable
        {
            if (b.CompareTo(a) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }
    }
}


public static class Extentions
{
    public static int Int(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static long Long(this object obj)
    {
        return long.Parse(obj.ToString());
    }

    public static decimal Decimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double Double(this object obj)
    {
        return double.Parse(obj.ToString());
    }

    public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key) where T2 : struct
    {
        T2 value;
        if (d.TryGetValue(key, out value))
        {
            return value;
        }
        return new T2();
    }
}



Measured memory_bytes: 33368