akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int N=in(),K=in();
	vector<int> A(N,0);
	REP(i,K){
		int d=in();
		REP(j,d){
			A[in()-1]++;
		}
	}
	int sum=0;
	REP(i,N){
		if(A[i]==0) sum++;
	}
	out(sum);
	return 0;
}


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

int main() {
  int N, K, r=1;
  cin >> N >> K;
  
  for(; (r<K)&&(N>0); N--)
    r *= 2;
  
  for(; N>0; N--)
    r += K;
  
  cout << r << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+7;
typedef long long ll;
int a[maxn],b[maxn];
const int inf=0x6f6f6f6f;
int T;
int n,m,k;

int main()
{
    scanf("%d%d%d",&n,&m,&k);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);

    for(int j=1;j<=m;j++)
        scanf("%d",&b[j]);

    int sum,x,y,tmp,ans=inf;

    while(k--)
    {
        sum=0;
        scanf("%d%d%d",&x,&y,&tmp);
        sum=a[x]+b[y];
        ans=min(ans,sum-tmp);
    }
    sort(a+1,a+1+n);
    sort(b+1,b+1+m);
    printf("%d\n",min(a[1]+b[1],ans));

}


Measured memory_bytes: 1024
#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>

#include <numeric>

#include <map>

using namespace std;

typedef long long LL;

LL n, a, b;

int main() {
    cin >> n >> a >> b;
    LL ans = n / (a+b);
    LL ans1 = ans * (a+b);
    LL res = ans * a;
    if (n - ans1 > 0) {
        res += min(a, n-ans1);
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <set>
#include <cstdio>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <ctime>
#include <cmath>
#include <complex>
#include <algorithm>
#include <tuple>
#include <algorithm>
#include <limits>
#include <map>
#include <valarray>
#include <list>

using namespace std;

typedef long long ll;

template<class T>
struct Pi {
    T x, y;
    Pi() {}
    Pi(T xx, T yy) {
        x = xx; y = yy;
    }
    bool operator<(const Pi &r) const {
        if (x != r.x) return x < r.x;
        return y < r.y;
    }
    bool operator>(const Pi &r) const {
        if (x != r.x) return x > r.x;
        return y > r.y;
    }
    bool operator==(const Pi &r) const {
        if (x != r.x) return false;
        return y == r.y;
    }
};

template<class T>
struct Ti {
    T x, y, z;
    Ti() {}
    Ti(T xx, T yy, T zz) {
        x = xx; y = yy; z = zz;
    }
    bool operator<(const Ti &r) const {
        if (x != r.x) return x < r.x;
        if (y != r.y) return y < r.y;
        return z < r.z;
    }
    bool operator>(const Ti &r) const {
        if (x != r.x) return x > r.x;
        if (y != r.y) return y > r.y;
        return z > r.z;
    }
    bool operator==(const Ti &r) const {
        if (x != r.x) return false;
        if (y != r.y) return false;
        return z == r.z;
    }
};

const int MN = 1000010;
bool isP[MN];
int main() {
    for (int i = 2; i < MN; i++) {
        bool f = true;
        for (int j = 2; j*j <= i; j++) {
            if (!(i%j)) {
                f = false;
                break;
            }
        }
        isP[i] = f;
    }
    int n;
    while (cin>>n) {
        int res = 0;
        for (int i = 0; i <= n; i++) {
            if (isP[i]) res++;
        }
        printf("%d\n", res);
    }
    return 0;
}

Measured memory_bytes: 2112
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <climits>
#include <utility>
typedef long long ll;
using namespace std;

vector<pair<ll,ll> > primeFactorize(ll n) {
  vector<pair<ll,ll> > ret;//prime,cnt;
  ll cnt;
  for(ll i=2;i*i<=n;i++) {
    if(n%i==0){
      cnt=0;
      while(n%i==0) {
        cnt++;
        n/=i;
      }
      ret.push_back({i,cnt});
    }
  }
  if(n!=1)ret.push_back({n,1});
  return ret;
}

int main(void){
  ll n;
  int i, j, ans;
  cin >> n;

  auto p = primeFactorize(n);

  ans = 0;
  for(i=0;i<p.size();i++){
    j = 1;
    while(p[i].second>=j){
      p[i].second -= j;
      ans++;
      j++;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <queue>
#include <set>
#include <bitset>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
 
#define ll long long
#define uint unsigned int
#define ull unsigned ll
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define speedhack() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define do(x) for(int i = 1; i <= x; i++){ solve(); }
#define sz(x) (int)x.size()
#define pii pair < int, int >
using namespace std;
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
 
const ll MAXN = 1e18;
const ll SIZE = 1e5+2; //are u sure?
const ll mod = 1e9+7;
ll line[3][SIZE];

void solve(){
	int n; cin >> n;
	string s, t; cin >> s >> t;
	string res = "";
	int i = 0, j = 0;
	while(j < t.size()){
		res += s[i];
		i++;
		res += t[j];
		j++;
	}
	cout << res << endl;
}


int main(){
	speedhack()
	// int it; cin >> it;
	int it = 1;
	do(it);
	return 0;
}

Measured memory_bytes: 256
N, *AB = map(int, open(0).read().split())
A, B = AB[:N], AB[N:]

C = [0] * (N + 1)
D = [0] * (N + 1)

for i, (a, b) in enumerate(zip(A, B)):
    C[a] += 1
    D[b] += 1

if any(c + d > N for c, d in zip(C, D)):
    print("No")
    quit()

for i in range(1, N + 1):
    C[i] += C[i - 1]
    D[i] += D[i - 1]

x = max(C[i] - D[i - 1] for i in range(1, N + 1))

print("Yes")
print(*[B[(i + N - x) % N] for i in range(N)])

Measured memory_bytes: 54928
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

ll calc(VVL d){
    int n = d.size();
    VI p(n);
    REP(i,n) p[i] = i;
    ll ret = 0;
    do {
        ll s = 0;
        REP(i,n-1) s += d[p[i]][p[i + 1]];
        chmax(ret, s);
    }while (next_permutation(ALL(p)));
    return ret;
}

int main() {
    ll n;
    cin >> n;

    VL a(n-1);
    a[0] = 1;
    a[1] = 2;
    FOR(i,2,n-2){
        set<int> st;
        REP(j,i) st.insert(a[j]);
        REP(j,i) REP(k,j) st.insert(a[j] + a[k]);
        FOR(x,1,1e5){
            if (st.count(x)) continue;
            bool ok = true;
            REP(j,i) if (st.count(x + a[j])) ok = false;
            if (ok){
                a[i] = x;
                break;
            }
        }
    }

    // REP(i,n-1) cout << a[i] << endl;

    VVL d(2, VL(2));
    d[0][1] = d[1][0] = 1;
    FOR(x,2,n-1){
        ll m = calc(d);
        REP(i,x) d[i].push_back((m + 1) * a[i]);
        d.push_back(VL());
        REP(i,x) d[x].push_back((m + 1) * a[i]);
        d[x].push_back(0);
    }

    REP(i,n){
        REP(j,n) cout << d[i][j] << " ";
        cout << endl;
    }


    return 0;
}


Measured memory_bytes: 256
"use strict";

const permutateWithoutRepetitions = permutationOptions => {
  if (permutationOptions.length === 1) {
    return [permutationOptions];
  }

  // Init permutations array.
  const permutations = [];

  // Get all permutations for permutationOptions excluding the first element.
  const smallerPermutations = permutateWithoutRepetitions(permutationOptions.slice(1));

  // Insert first option into every possible position of every smaller permutation.
  const firstOption = permutationOptions[0];

  for (let permIndex = 0; permIndex < smallerPermutations.length; permIndex += 1) {
    const smallerPermutation = smallerPermutations[permIndex];

    // Insert first option into every possible position of smallerPermutation.
    for (let positionIndex = 0; positionIndex <= smallerPermutation.length; positionIndex += 1) {
      const permutationPrefix = smallerPermutation.slice(0, positionIndex);
      const permutationSuffix = smallerPermutation.slice(positionIndex);
      permutations.push(permutationPrefix.concat([firstOption], permutationSuffix));
    }
  }

  return permutations;
}
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0]);
    const xy = arg.slice(1, N + 1).map(n=>n.split(" ").map(l=>parseInt(l)));
    
    const combos = permutateWithoutRepetitions(xy);
    const results = [];
    
    for(let i in combos) {
        let temp = 0;
        
        for(let j=0; j<combos[i].length-1; j++) {

            let x = Math.pow(combos[i][~~j + 1][0] - combos[i][j][0], 2);
            let y = Math.pow(combos[i][~~j + 1][1] - combos[i][j][1], 2);

            temp += Math.sqrt(x + y);
        }

        results.push(temp)
    }
    
    console.log(results.reduce((m,n)=>m+n) / combos.length);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 44420
/**
 *    author:  tesnik      
**/
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  
  int sum = 0;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  sum /= n;
  int ans = 1e9;
  for (int k: {0, 1}) {
    int ca = 0;
    for (int i = 0; i < n; i++) {
      ca += (a[i] - sum - k) * (a[i] - sum - k);
    } 
    ans = min(ca, ans);
  }
  cout << ans << "\n";
  
  return 0;
}

Measured memory_bytes: 256
# coding: utf-8

S = input()
Q = int(input())

query = []

for i in range(Q):
    query.append(input().split())


bool = True
pre =''
suf =''

for i in query:
    if len(i) == 1:
        bool = not(bool)

    else:
        if i[1]=="1":
            if bool:
                pre = i[2]+pre
            else:
                suf += i[2]
        else:
            if bool:
                suf += i[2]
            else:
                pre = i[2]+pre

S = pre+ S +suf
print(S) if bool else print(S[::-1])


Measured memory_bytes: 40628
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

int main(){
    int N,M;
    vector<int> s[100];
    cin >> N >> M;
    rep(i,M){
        int k;
        cin >> k;
        rep(j,k){
            int a;
            cin >> a;
            a--;
            s[i].push_back(a);
        }
    }
    vector<int> p(M);
    rep(i,M)cin >> p[i];

    int res = 0;
    for(int bit = 0;bit<(1<<N);bit++){
        int num = 0;
        for(int i=0;i<M;i++){
            int cnt = 0;
            for(int j=0;j<s[i].size();j++){
                if(bit&(1<<s[i][j]))cnt++;
            }
            if(cnt%2==p[i])num++;
        }
        if(num==M)res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <map>
#include <iostream>
#include <string>

using namespace std;




int main(void){

  int N;
  cin>>N;
  string S[N];
  int i,max=0;
  for(i=0;i<N;i++)
    cin>>S[i];

   map <string,int> m;
  for(i=0;i<N;i++){
    m[S[i]]++;
     if(max<m[S[i]])
       max=m[S[i]];
  }
    
   for(i=0;i<N;i++){
    if(max<m[S[i]])
      max=m[S[i]];
      }
   for(auto i=m.begin();i!=m.end();i++){
    if(i -> second==max){
      cout<< i-> first<<endl;
      
    }   
  }
 



  
  return 0;
}


Measured memory_bytes: 26752
n = int(input())
list_A = list(map(int, input().split()))
list_A.sort()
max_value = max(list_A)
a = max_value/2
b = pow(10, 10)
c = 0
for num in list_A:
    if abs(a-num) < b:
        b = abs(a-num)
        c = num

print(max_value, c)

Measured memory_bytes: 14428
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
const int INF = 1e8;
using namespace std;
 
int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
 
    int ans = min(b,d) - max(a,c);
    cout << (ans < 0 ? 0 : ans) << endl;
}

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

using namespace std;

const int MOD = 1e9 + 7;

void add(int &x, int y) {
   x += y;
   if (x >= MOD) x -= MOD;
}

int main() {
   ios_base::sync_with_stdio(false);
   int N;
   cin >> N;
   vector<int> A(2 * N - 1);
   for (int &x : A) cin >> x;
   sort(A.begin(), A.end());
   vector<vector<int>> dp(2 * N, vector<int>(2 * N));
   dp[1][0] = 1;
   for (int z = 0; z < N - 1; ++z) {
      int vl = A[N - 1 - z] > A[N - 1 - (z + 1)];
      int vr = A[N - 1 + z] < A[N - 1 + (z + 1)];
      vector<vector<int>> ndp(2 * N, vector<int>(2 * N));
      for (int cnt = 1; cnt < 2 * N; ++cnt) {
         for (int cur = 0; cur < cnt; ++cur) {
            if (dp[cnt][cur] == 0) continue;
            for (int nxt = 0; nxt < vl + vr + cnt; ++nxt) {
               int ncnt = cnt + vl + vr;
               int ncur = nxt;
               if (ncur > (cur + vl)) {
                  int delta = ncur - (cur + vl + 1);
                  ncur -= delta;
                  ncnt -= delta;
               } else if (ncur < (cur + vl)) {
                  ncnt -= ((cur + vl) - (ncur + 1));
               }
               add(ndp[ncnt][ncur], dp[cnt][cur]);
            }
         }
      }
      dp = ndp;
   }
   int ans = 0;
   for (auto vv : dp) for (int v : vv) add(ans, v);
   cout << ans << "\n";
   return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string.h>

#define MAX_LINE 8
#define MAXA_DATA 50

using namespace std;

// プロトタイプ宣言
void searchString(string box);

// main関数
int main() {
    int count = 0;
    int max = MAX_LINE * MAXA_DATA;
    char str[8];
    string box;
    for (int i = 0; i < max; i++) {
        cin >> str;
        box.append(str);
        count++;
        // 8行ごとにチェック
        if(count%MAX_LINE == 0){
            searchString(box);
            box = "";
        }
    }
}

// 文字列チェック
void searchString(string box){
    string A("1100000011");
    string B("1000000010000000100000001");
    string C("1111");
    string D("1000000110000001");
    string E("11000000011");
    string F("100000001100000001");
    string G("110000011");
    
    // find関数は文字列がみつからなかったときにnposを返す
    if (box.find(A) != std::string::npos) {
        cout << "A" << endl;
    }
    else if(box.find(B) != std::string::npos) {
        cout << "B" << endl;
    }
    else if(box.find(C) != std::string::npos) {
        cout << "C" << endl;
    }
    else if(box.find(D) != std::string::npos) {
        cout << "D" << endl;
    }
    else if(box.find(E) != std::string::npos) {
        cout << "E" << endl;
    }
    else if(box.find(F) != std::string::npos) {
        cout << "F" << endl;
    }
    else if(box.find(G) != std::string::npos) {
        cout << "G" << endl;
    }
}


Measured memory_bytes: 3104
def gcd(a, b):
    a = int(a)
    b = int(b)
    m = int(0)
    while(b > 0):
        m = a 
        a = b
        b = m % a
    return a
    

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

n = int(input())
t = []
for i in range(0, n):
    t.append(int(input()))
cur = t[0]
for i in range(1, n):
    cur = lcm(cur, t[i])
print(int(cur))

Measured memory_bytes: 3064
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        long N = in.nextLong(), ans = Long.MAX_VALUE;
        for(long i = 1; i*i <= N; i++){
            if(N % i == 0){
                long j = N/i;
                ans = Math.min(ans, i-1+j-1);
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23124
#include<cstdio>
using namespace std;
int n,k,h[100110],dp[100110];
int abss(int a,int b){
	return a>b?a-b:b-a;
}
int minn(int a,int b){
	return a>b?b:a;
}
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)scanf("%d",&h[i]),dp[i]=0x3f3f3f3f;
	dp[1]=0;
	for(int i=1;i<n;i++)
	for(int j=1;j<=k;j++)
	dp[i+j]=minn(dp[i+j],dp[i]+abss(h[i],h[i+j]));
	printf("%d",dp[n]);
}

Measured memory_bytes: 896
#include<iostream>
#include<list>
#include<vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<math.h>
#include<unordered_map>
#include<map>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using lst = list<ll>;


vec parent;
vec a;

int find(int x)
{
	if (parent[x] == x)return x;
	return parent[x] = find(parent[x]);
}


void unite(int x,int y)
{
	x = find(x);
	y = find(y);

	if (x == y)return;

	if (a[y] < a[x])
	{
		parent[x] = y;
	}
	else
	{
		parent[y] = x;
	}
}


int main()
{
	int N, M;
	cin >> N >> M;

	parent = vec(N);
	a = vec(N);

	for (int i = 0; i < N; ++i)
	{
		cin >> a[i];
		parent[i] = i;
	}

	for (int i = 0; i < M; ++i)
	{
		int x, y;
		cin >> x >> y;
		unite(x, y);
	}

	ll ans = 0;
	int TreeNum = 0;
	list<int> last;
	for (int i = 0; i < N; ++i)
	{
		if (find(i) == i)
		{
			ans += a[i];
			TreeNum++;
		}
		else
		{
			last.emplace_back(a[i]);
		}
	}

	if (TreeNum == 1)
	{
		cout << 0 << endl;
		return 0;
	}
	last.sort();

	if (last.size() < TreeNum - 2)
	{
		cout << "Impossible" << endl;
		return 0;
	}

	for (int i = 0; i < TreeNum - 2; ++i)
	{
		ans += last.front();
		last.pop_front();
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4992
#include<iostream>
#include<vector>
#include<algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
int main(void){
    int N;//入力
   cin >>N;
   vector<double> x(N,0);
   vector<double> y(N,0);
    for(int i=0; i<N; i++){
     cin >>x[i]; 
     cin >>y[i]; 
   }
    double A;
    double summ=0;//N=3なら1-2 1-3 2-3 の合計
    for(int j=0; j<N; j++){
        for(int k=0; k<N-1-j; k++){
        
        A=(x[j]-x[k+1+j])*(x[j]-x[k+1+j])+(y[j]-y[k+1+j])*(y[j]-y[k+1+j]);
        A=pow(A,0.5);
        summ+=A;
       
   }
   }
   double B=(double)N/2.0;

   double ans=0;//答え
   ans= summ/B;  
   cout<< fixed << setprecision(10) <<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
u = input().split(" ")
n = int(u[0])
m = int(u[1])
l = {}
e = 0
a = []
if n == 1:
	a = ["0"]
elif n == 2:
	a = ["1","0"]
elif n == 3:
	a = ["1","0","0"]
for i in range(m):
	c = input().split(" ")
	s = int(c[0]) - 1
	if s in l:
		if l[s] != c[1]:
			e = 1
	else:
		l[s] = c[1]
		a[s] = c[1]
if e == 1:
	print(-1)
else:
	if n != 1 and a[0] == "0":
		print(-1)
	else:
		print("".join(a))

Measured memory_bytes: 3064
#include <iostream>/*{{{*/
#include <bits/stdc++.h>
#define rep(i, x) for(int i = 0; i < (int)(x); i++)
#define reps(i,x) for(int i = 1; i <= (int)(x); i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i >= n;i--)
#define foreach(x,a) for(auto& (x) : (a) )
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define fill(x,y) memset(x,y,sizeof(x))
#define pb(a) push_back(a)
#define debug(x)                 cerr << __LINE__ << ": " << #x << " -> " << x << '\n'
#define debug2(x, y)             cerr << __LINE__ << #x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define debug3(x, y, z)          cerr << __LINE__ << #x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define debug4(a, b, c, d)       cerr << __LINE__ << #a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define debug5(a, b, c, d, e)    cerr << __LINE__ << #a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define debug6(a, b, c, d, e, f) cerr << __LINE__ << #a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define INF 999999999
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef vector<vii> vvii;
typedef tuple<int,int,int> iii;
typedef set<int> si;
typedef complex<double> pnt;
typedef vector<pnt> vpnt;
typedef priority_queue<pii,vii,greater<pii> > spq;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};/*}}}*/

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

  int a,b;
  cin >> a >> b;

  if (a<=8 && b<=8){
    cout << "Yay!" << endl;
  }
  else{
    cout << ":(" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
def prime_factor(n):
    ass = []
    for i in range(2,int(n**0.5)+1):
        while n % i==0:
            ass.append(i)
            n = n//i
    if n != 1:
        ass.append(n)
    return ass

A,B = map(int,input().split())

A_s = set(prime_factor(A))
B_s = set(prime_factor(B))

from fractions import gcd

print(len(A_s&B_s)+1)


Measured memory_bytes: 5232
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    set<P> s;
    cin >> n >> m;
    REP(i, m){
        int a, b;
        cin >> a >> b;
        s.insert(make_pair(a, b));
    }

    FOR(i, 1, n){
        if(s.count(make_pair(1, i)) > 0 && s.count(make_pair(i, n)) > 0){
            cout << "POSSIBLE" << "\n";
            return 0;
        }
    }

    cout << "IMPOSSIBLE" << "\n";


    return 0;
}


Measured memory_bytes: 9600
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log,gcd
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')

#Pythonを用いる場合
#numpy 1.18.0, scipy 1.4.1, scikit-learn 0.22, numba 0.47.0, networkx 2.4
 
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix

 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
w,h,n=mii()

mat=np.array([[1]*w for _ in range(h)])

for _ in range(n):
    x,y,a=mii()
    if a==1:
        mat[:,:x]=0
    elif a==2:
        mat[:,x:]=0
    elif a==3:
        mat[:y,:]=0
    else:
        mat[y:,:]=0
#print(mat)
print(np.sum(mat))


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

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

    if(K < N){
        cout << K*X + (N-K)*Y << endl;
    }else{
        cout << N*X << endl;
    }

    return 0;
}

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

const int MOD=1000000007;

ll gcd(ll x, ll y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
ll lcm(ll x, ll y) {
    return x * y / gcd(x, y);
}


void solve(long long A, long long B){
    if (A>=13) {
        cout << B << endl;
    } else if (A<=12 && A>=6) {
        cout << B/2 << endl;
    } else {
        cout << 0 << endl;
    }
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


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

f1=fractions.gcd(c,d)
f2=c*d//f1

a=a-1
aa=a-a//c-a//d+a//f2
bb=b-b//c-b//d+b//f2

print(bb-aa)



Measured memory_bytes: 64492
#include <stdio.h>

int main(void){
  double a;
  double s;
  while(scanf("%lf",&a)!=EOF){
    s=a;
    for(int i=2;i<=10;i++){
      if(i%2==0)a=a*2;
      else a=a/3;
      s+=a;
    }
    printf("%.16lf\n",s);
  }
  return 0;
}



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

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

//  if (!(2 <= n  n <= 100)) {
//    return 1;
//  }
  if (a >= b) {
    return 2;
  }
  // if gap is 2*n Borys win
  if ((b - a) % 2 == 0){
    cout << "Alice" << endl;
  }else {
    cout << "Borys" << endl;
  }



  return 0;
}


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

using namespace std;


int main (){
	int n;
	cin >> n;
	int ax, i;
	bool fi = 0;
	for(i = 1; i <= n; i++){
		cin >> ax;
		if(ax%2==1) fi = 1;
	}
	if(fi) cout << "first"  << endl;
	else   cout << "second" << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int N=scanner.nextInt();
        if(N==0){
            System.out.println(0);
            return;
        }
        StringBuilder reverseResult=new StringBuilder();
        int count=0;
        while(N-func(reverseResult.toString())!=0){
            //System.out.println(count+":"+(N-func(reverseResult.toString())));
            if((N-func(reverseResult.toString()))%(2l<<reverseResult.length())==0){
                reverseResult.append(0);
            }else{
                reverseResult.append(1);
            }
            count++;
        }
        System.out.println(reverseResult.reverse());
    }
    public static long func(String reverseString){
        long result=0;
        for(int i=0;i<reverseString.length();i++){
            if(reverseString.charAt(i)=='1'){
                result+=(i%2==0?1:-1)*(1l<<i);
            }
        }
        return result;
    }


}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
#define INF (1e9)

int main() {
    ll N, ans = 0;
    cin >> N;
    vi A(1e6);
    for (ll i = 0; i < N; i++) {
        ll a;
        cin >> a;
        A[a]++;
        A[a + 1]++;
        A[a + 2]++;
    }
    for (ll a : A) {
        ans = max(ans, a);
    }

    cout << ans << endl;
}


Measured memory_bytes: 8064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static long Solve(int[] A)
    {
        int N = A.Length;
        long count = 0;
        int a = 0;
        for (int i = 0; i < N; ++i)
        {
            count += (A[i] + a) / 2;
            a = (A[i] > 0) ? (A[i] + a) % 2 : 0;
        }
        return count;
    }
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        int[] A = new int[N];
        for (int i = 0; i < N; ++i)
        {
            A[i] = int.Parse(Console.ReadLine());
        }
        Console.WriteLine(Solve(A));
    }
}


Measured memory_bytes: 7248
values=input().split()
x1=float(values[0])
y1=float(values[1])
x2=float(values[2])
y2=float(values[3])
x_distance=x2-x1
y_distance=y2-y1
print(pow(pow(x_distance,2)+pow(y_distance,2),0.5))


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

#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define ALL(v) (v).begin(), (v).end()
#define INF 1e9

using namespace std;
typedef pair<int, int> pii;

int main(){
  int n;
  while(cin >> n and n){
    int res = 0;
    bool lu = false; bool ru = false; bool ground = true;
    REP(i, n){
      string info;
      cin >> info;
      if(info == "lu"){
        if(ru == true and ground == true) { res++; ground = false; }
        lu = true;
      }
      if(info == "ru"){
        if(lu == true and ground == true) { res++; ground = false; }
        ru = true;
      }
      if(info == "ld"){
        if(ru == false and ground == false) { res++; ground = true; }
        lu = false;
      }
      if(info == "rd"){
        if(lu == false and ground == false) { res++; ground = true; }
        ru = false;
      }
    }
    cout << res << endl;
  }
  return 0;
}

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

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int A, B, K; cin >> A >> B >> K;

	set<int> ans; ans.clear();

	rep (i, K){
		int curr = A + i;
		if (curr >= A && curr <= B){
			ans.insert(curr);
		} // end if
	} // end rep
	rep (i, K){
		int curr = B - i;
		if (curr >= A && curr <= B){
			ans.insert(curr);
		} // end if
	} // end rep

	set<int>::iterator it = ans.begin();
	for (; it != ans.end(); ++it){
		int res = (*it);
		cout << res << endl;
	} // end for

	return 0;
}

Measured memory_bytes: 256
n = int(input())
s= input()
ans=0
for x in range(1000):
    num=str("{0:03d}".format(x))
    s1=s.find(num[0])
    if(s1!=-1):
        s2=s.find(num[1],s1+1)
        if(s2!=-1):
            s3=s.find(num[2],s2+1)
            if(s3!=-1):
                ans+=1
print(ans)


Measured memory_bytes: 3060
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

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

func scanInts(n int) []int {
	sl := make([]int, n)
	for i := range sl {
		sl[i] = scanInt()
	}
	return sl
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	a, b := scanInt(), scanInt()
	s := scanString()

	slice := strings.Split(s, "-")
	if len(slice) != 2 {
		fmt.Println("No")
		return
	}

	if len(slice[0]) != a || len(slice[1]) != b {
		fmt.Println("No")
		return
	}

	fmt.Println("Yes")
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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


Measured memory_bytes: 640
#include<iostream>
using namespace std;
main()
{
    int a,b;
    int ar[3]={1,2,3};
    cin>>a>>b;
    for(int i=0;i<3;i++)
    {
        if(ar[i]!=a && ar[i]!=b)
        {
            cout<<ar[i];


        }
    }
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int w,n,a[30],b[30],i,e[30],tmp;
	scanf("%d",&w);
	scanf("%d",&n);
	for(i=0;i<w;i++)
		e[i]=i+1;
	for(i=0;i<n;i++){
		scanf("%d,%d",&a[i],&b[i]);
		tmp=e[a[i]-1];
		e[a[i]-1]=e[b[i]-1];
		e[b[i]-1]=tmp;
	}
	for(i=0;i<w;i++){
	printf("%d\n",e[i]);
	}
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
map<LL,LL>m;
int N;
int main(){
    cin>>N;
    REP(i,N){
        LL a;
        cin>>a;
        m[a]++;
    }
    LL ans=0;
    for(auto it:m){
        if(it.first>it.second){
           ans+=it.second;
        }else{
           ans+=it.second-it.first;
        }
    }
    cout<<ans<<endl;
    return(0);
}

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

using namespace std;

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

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

ll dist[100][100];
ll INF = 1e18;

int main() {
  int v, e;
  cin >> v >> e;
  REP(i, v) REP(j, v) dist[i][j] = (i == j ? 0 : INF);
  REP(i, e) {
    int s, t, d;
    cin >> s >> t >> d;
    dist[s][t] = d;
  }
  REP(k, v) {
    REP(i, v) {
      if (dist[i][k] == INF) continue;
      REP(j, v) {
        if (dist[k][j] == INF) continue;
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  bool negative = false;
  REP(i, v) if (dist[i][i] < 0) negative = true;
  if (negative) {
    puts("NEGATIVE CYCLE");
  } else {
    REP(i, v) {
      REP(j, v) {
        if (j) cout << " ";
        if (dist[i][j] == INF) {
          cout << "INF";
        } else {
          cout << dist[i][j];
        }
      }
      cout << "\n";
    }
  }
  return 0;
}


Measured memory_bytes: 3176
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        double b = sc.nextDouble();

        long bb = Math.round(b * 100);
        long ans = a * bb;

        System.out.println(ans / 100);
    }
}



Measured memory_bytes: 37364
// --https://kenkoooo.com/atcoder/#/table/soma62jp
#include <iostream>
#include <string>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstring>

using namespace std;


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

	long long N,ans,wrk;

	cin >> N;

	wrk = 0;
	ans = 0;
	do{
		ans = wrk * wrk;
		if(ans > N){
			ans = (wrk - 1) * (wrk - 1);
			break;
		}
		wrk++;
	}while(1);

	cout << ans << endl;

	return 0;

}


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

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;


//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)


struct Edge {
    int to, from;
    ll cost;
    Edge(int from, int to, ll cost): from(from), to(to), cost(cost) {}
};

typedef vector<vector<Edge>> AdjList;
AdjList graph;

typedef vector<ll> vec;
typedef vector<vec> mat;

mat mul(mat &A, mat &B) {
    mat C(A.size(), vec((int)B[0].size()));
    for(int i=0; i<A.size(); ++i){
        for(int k=0; k<B.size(); ++k){
            for(int j=0; j<B[0].size(); ++j){
                C[i][j] = (C[i][j] + A[i][k] * B[k][j] %MOD) % MOD;
            }
        }
    }
    return C;
}
mat mat_pow(mat A, ll n) {
    mat B(A.size(), vec((int)A.size()));

    for(int i=0; i<A.size(); ++i){
        B[i][i] = 1;
    }

    while(n > 0) {
        if(n & 1) B = mul(B, A);
        A = mul(A, A);
        n >>= 1;
    }
    return B;
}



int main() {
    //cin.tie(0);
    //ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N; cin >> N;
    vector<pii> vp;
    REP(i, N){
        int x, y; cin >> x>> y;
        vp.PB({x, y});
    }

    sort(all(vp), [](const pii& a, const pii& b) {
        return atan2(a.second, a.first) < atan2(b.second, b.first);
    });
    double ans = 0;
    for(int i=0; i<N; ++i){
        double xx=0, yy=0;
        for(int j=0; j<N; ++j){
            xx += vp[(i+j)%N].first;
            yy += vp[(i+j)%N].second;
            ans = max(ans, sqrt(xx*xx+ yy*yy));
        }
    }

    
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (X) = readLine()!!.split(' ').map(String::toInt)
    val dp = Array(200000) { false }
    dp[0] = true
    for (i in 0..X) {
        if (dp[i]) {
            for (j in 0..5) {
                dp[i + 100 + j] = true
            }
        }
    }
    println(if(dp[X]) 1 else 0)
}

Measured memory_bytes: 38344
N = int(input())
ans = 0

## execute
d = 2
while d*d <= N:
  if N % d == 0:
    z = d
    while N % z == 0:
      N /= z
      ans += 1
      z *= d
    while N % d == 0:
      N /= d
  d += 1

if N > 1: ans += 1 # N is prime
print(ans)

Measured memory_bytes: 63268
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 2010

// {a, {b, c}} : a = gcd(p, q) = bp + cq
pair<ll,pair<ll,ll>> ext_gcd(ll p, ll q) {
  if (q == 0) return {p, {1, 0}};
  auto r = ext_gcd(q, p%q);
  return {r.first, {r.second.second, r.second.first - p/q*r.second.second}};
}


/* 中国剰余定理 */

pair<ll,ll> CRT(ll a1, ll m1, ll a2, ll m2){
  auto eg = ext_gcd(m1, m2);
  ll d = eg.first;
  if((a2 - a1) % d) return {0, -1};
  ll m = m1 / d * m2;
  ll r = ((a1 + m1 * ((__int128_t)(a2 - a1) / d * eg.second.first % (m2/d))) % m + m) % m;
  return {r, m};
}


int main(){
  int N, p[SIZE], q[SIZE], revp[SIZE];
  bool used[SIZE] = {};

  scanf("%d", &N);

  for(int i=0; i<N; i++) { scanf("%d", p+i); p[i]--; revp[p[i]] = i;}
  for(int i=0; i<N; i++) { scanf("%d", q+i); q[i]--; }

  ll ansA = 0, ansB = 1;

  for(int i=0 ;i<N; i++) {
    if (used[i]) continue;

    int t = i, start = i;
    vector<int> vec, to, idx;

    do{
      to.push_back(t);
      used[t] = true;
      t = revp[q[p[t]]];
    }while(t != start);

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

    idx = to;

    for(int i=0; i<to.size(); i++) {
      vec.push_back(p[to[i]]);
      to[i] = p[to[i]];
    }

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

    // a mod b
    int a = -1, b;

    b = vec.size();

    for(int i=0; i<vec.size(); i++) {
      if (vec == idx) { a = i; break; }

      for(int j=0; j<vec.size(); j++)
        vec[j] = q[vec[j]];
    }

    if (a == -1) {
      ansB = -1;
    } else {
      auto res = CRT(a, b, ansA, ansB);
      //auto res = CRT(ansA, ansB, a, b);
      ansA = res.first;
      ansB = res.second;
    }

    if (ansB == -1) {
      puts("-1");
      return 0;
    }
  }

  cout << ansA << endl;

  return 0;
}



Measured memory_bytes: 3272
package main

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

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt(A ...*int) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.Atoi(L[i])
  }
}
func NextIntVec(A *[]int) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]int, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.Atoi(l)
  }
}
func NextFloat(A ...*float64) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.ParseFloat(L[i], 64)
  }
}
func NextFloatVec(A *[]float64) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]float64, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.ParseFloat(l, 64)
  }
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func WriteIntVec(A []int) {
  S := make([]string, len(A))
  for i, a := range A {
    S[i] = strconv.Itoa(a)
  }
  Write(strings.Join(S, " "))
}
func Output() {
  _ = writer.Flush()
}

func MaxInt(A ...int) int {
  max := A[0]
  for _, a := range A {
    if max < a { max = a }
  }
  return max
}
func MinInt(A ...int) int {
  min := A[0]
  for _, a := range A {
    if a < min { min = a }
  }
  return min
}
func SumInt(A ...int) int {
  sum := 0
  for _, a := range A {
    sum += a
  }
  return sum
}
func AbsInt(x int) int {
  if x < 0 { x = -x }
  return x
}

func Find(R *[]int, u int) int {
  if (*R)[u] == u { return u }
  (*R)[u] = Find(R, (*R)[u])
  return (*R)[u]
}
func Union(R *[]int, u, v int) {
  ru, rv := Find(R, u), Find(R, v)
  if ru < rv {
    (*R)[rv] = ru
  } else if rv < ru {
    (*R)[ru] = rv
  }
}

func Bipartite(G [][]int, D []int, u int) bool {
  D[u] = 0
  Q := make([]int, 0)
  Q = append(Q, u)
  for 0 < len(Q) {
    q := Q[0]
    Q = Q[1:]
    for _, adj := range G[q] {
      if D[adj] < 0 {
        D[adj] = 1 - D[q]
        Q = append(Q, adj)
      } else if D[q] == D[adj] {
        return false
      }
    }
  }
  return true
}

func Solve() {
  var N, M int
  NextInt(&N, &M)
  G := make([][]int, N)
  for i := range G {
    G[i] = make([]int, 0)
  }
  R := make([]int, N)
  for i := range R {
    R[i] = i
  }
  var a, b int
  for i := 0; i < M; i++ {
    NextInt(&a, &b)
    a, b = a - 1, b - 1
    G[a] = append(G[a], b)
    G[b] = append(G[b], a)
    Union(&R, a, b)
  }
  U := make([]int, N)
  for i := range R {
    U[Find(&R, i)]++
  }
  C := make([]int, 3)
  D := make([]int, N)
  for i := range D {
    D[i] = -1
  }
  for i, u := range U {
    if u == 0 { continue }
    if u == 1 {
      C[0]++
    } else if Bipartite(G, D, i) {
      C[1]++
    } else {
      C[2]++
    }
  }
  Write((2 * N - C[0]) * C[0] + 2 * (C[1] + C[2]) * C[1] + C[2] * C[2])
}

func main() {
  Solve()
  Output()
}

Measured memory_bytes: 16128
#include <iostream>

using namespace std;

int main(){
    int n;
    cin >> n;

    for(int i = 0; i < 100; i++){
        for(int j = 0; j < 100; j++){
            int tmp = 4 * i + 7 * j;
            if(tmp == n){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
attrs = Array.new
while line = $stdin.gets
    attrs << line.chomp.split.map{|v| v.to_i }
end

N = attrs.shift[0]
V = attrs.shift
C = attrs.shift

r = []

for i in 0..(N - 1) do
  r << V[i] - C[i]
end

result = 0

r.each{|n| result += n if n > 0 }
puts result

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

#define N_MAX 25
#define NIL -1

struct Node {
    long parent;
    long left;
    long right;
};

struct Node T[N_MAX];
long D[N_MAX], H[N_MAX];


void setDepth(long id, long d) {
    D[id] = d;
    if (T[id].left != NIL) {
        setDepth(T[id].left, d + 1);
    }
    if (T[id].right != NIL) {
        setDepth(T[id].right, d + 1);
    }
}

long setHeight(long id) {
    long h_left = 0;
    long h_right = 0;
    if (T[id].left != NIL) {
        h_left = setHeight(T[id].left) + 1;
    }
    if (T[id].right != NIL) {
        h_right = setHeight(T[id].right) + 1;
    }

    return H[id] = max(h_left, h_right);
}

long getSibling(long id) {
    if (T[id].parent == NIL) {
        return NIL;
    }
    else if (T[T[id].parent].left == id && T[T[id].parent].right != NIL) {
        return T[T[id].parent].right;
    }
    else if (T[T[id].parent].right == id && T[T[id].parent].left != NIL) {
        return T[T[id].parent].left;
    }
    else {
        return NIL;
    }
}

void print(long id) {
    cout << "node " << id << ": ";

    cout << "parent = " << T[id].parent << ", ";

    cout << "sibling = " << getSibling(id) << ", ";

    long deg = 0;
    if (T[id].left != NIL) {
        deg++;
    }
    if (T[id].right != NIL) {
        deg++;
    }
    cout << "degree = " << deg << ", ";

    cout << "depth = " << D[id] << ", ";

    cout << "height = " << H[id] << ", ";

    if (T[id].parent == NIL) {
        cout << "root";
    }
    else if (T[id].left == NIL && T[id].right == NIL) {
        cout << "leaf";
    }
    else {
        cout << "internal node";
    }

    cout << endl;
}

int main() {
    long n;
    cin >> n;
    for (long i = 0; i < n; i++) {
        T[i].parent = NIL;
        T[i].left = NIL;
        T[i].right = NIL;
    }

    long id, l, r;
    for (long i = 0; i < n; i++) {
        cin >> id >> l >> r;
        T[id].left = l;
        T[id].right = r;
        if (l != NIL) {
            T[l].parent = id;
        }
        if (r != NIL) {
            T[r].parent = id;
        }
    }

    long id_root;
    for (long i = 0; i < n; i++) {
        if (T[i].parent == NIL) {
            id_root = i;
            break;
        }
    }

    setDepth(id_root, 0);
    setHeight(id_root);

    for (long i = 0; i < n; i++) {
        print(i);
    }
}



Measured memory_bytes: 3092
#include<bits/stdc++.h>
int x[101];

int main() {
    int N;
    scanf("%d", &N);
    for(int i = 0;i < N; i++)
        scanf("%d", &x[i]);
    int ans = 0x3f3f3f3f;
    for(int i = 1; i < 100; i++) {
        int sum = 0;
        for(int j = 0; j < N; j++) {
            sum += (x[j] - i) * (x[j] - i);
        }
        ans = std::min(ans, sum);
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 256