akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a[101];
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		if(a[i]%2==0){
			if(a[i]%3!=0 && a[i]%5!=0){
				cout<<"DENIED";
				return 0;
			}
		}
	}
	cout<<"APPROVED";
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int main(){
	int a,b,l,m,n,k,ans;
	cin>>a>>b;
	l=a+b;
	m=a-b;
	n=a*b;
	k=max(l,m);
	ans=max(k,n);
	cout<<ans;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
using pqueg = priority_queue<int, vector<int>, greater<int>>;
using pquel = priority_queue<int, vector<int>, less<int>>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
int lcm(int a, int b){
  return a / __gcd(a, b) * b;
}
int r_int(int a, int b){
  return rand() % b + a;
}
const lint mod=1e9+7;



int main()
{
  lint h, n;
  cin >> h >> n;
  vector<int> a(n);
  REP(i,n) cin >> a[i];

  REP(i,n) h -= a[i];

  cout << (h > 0 ? "No" : "Yes") << "\n";
  return 0;
}


Measured memory_bytes: 640
//============================================================================
// Name        : ITP_1_11_C.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <string>
using namespace std;

class dice {
public:
    int getTopFace(void);
    int getBottomFace(void);
    void rotate(char dir);
    void setFaceNumber(int *number);
    bool compareDice(dice d2);
private:
    int face[6];
    int getFaceIndex(int number);
    bool compareDiceFace(dice d2);
};

int dice::getTopFace(void) {
    return face[0];
}

int dice::getBottomFace(void) {
    return face[5];
}

int dice::getFaceIndex(int number) {
    int i;
    for(i=0; i<6; ++i) {
        if (face[i]==number) {
            return i;
        }
    }
    return -1;
}

void dice::rotate(char dir) {
    int temp;
    switch(dir) {
    case 'N' :
        temp=face[0];
        face[0]=face[1];
        face[1]=face[5];
        face[5]=face[4];
        face[4]=temp;
        break;
    case 'S' :
        temp=face[0];
        face[0]=face[4];
        face[4]=face[5];
        face[5]=face[1];
        face[1]=temp;
        break;
    case 'W' :
        temp=face[0];
        face[0]=face[2];
        face[2]=face[5];
        face[5]=face[3];
        face[3]=temp;
        break;
    case 'E' :
        temp=face[0];
        face[0]=face[3];
        face[3]=face[5];
        face[5]=face[2];
        face[2]=temp;
        break;
    }
}

void dice::setFaceNumber(int *number) {
    for(int i=0; i<6; ++i) {
        face[i]=*(number+i);
    }
}

bool dice::compareDiceFace(dice d2) {
	for(int i=0;i<6;++i) {
		if(d2.face[i]!=face[i]) {
			return false;
		}
	}
	return true;
}

bool dice::compareDice(dice d2) {
	for(int j=0;j<3;++j) {
		if(compareDiceFace(d2)) return true;
		for(int i=0;i<3;++i) {
			d2.rotate('E');
			if(compareDiceFace(d2)) return true;
		}
		d2.rotate('E');
		d2.rotate('N');
		d2.rotate('N');
		if(compareDiceFace(d2)) return true;
		for(int i=0;i<3;++i) {
			d2.rotate('E');
			if(compareDiceFace(d2)) return true;
		}
		d2.rotate('N');
	}
	return false;
}

int main() {
    int num[6];
    dice d[2];
    string str[2];

    for(int i=0;i<2;++i) {
        for(int j=0;j<6;++j) {
            cin >> num[j];
        }
        d[i].setFaceNumber(num);
    }
    cout << (d[0].compareDice(d[1])?"Yes":"No") << endl;
    return 0;
}

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

#define MAX 3

int main(){
    int x[3], tmp;
    
    cin >> x[0] >> x[1] >> x[2];
    
    for(int i = 2; i > 0; i--){
        for(int j = 0; j < i; j++){
            if(x[j] > x[j + 1]){
                tmp = x[j];
                x[j] = x[j + 1];
                x[j + 1] = tmp; 
            }
        }
    }
    
    cout << x[0] << " " << x[1] << " " << x[2] << endl;

    return 0;
}


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

static const int N = 100;

int main(){
	int n, p[N + 1],m[N + 1][N + 1];
	cin >> n;
	for(int i= 1; i <= n; i++){
		cin >> p[i-1] >> p[i];
	}
	
	
	for(int i = 1; i <= n; i++)m[i][i] = 0;
	for(int l = 2; l <= n; l++){
		for(int i=1; i <= n-l+1; i++ ){
			int j = i + l - 1;
			m[i][j] = (1 << 21);
			for(int k = i; k <= j - 1; k++){
				m[i][j] = min(m[i][j],m[i][k] + m[k+1][j] + p[i-1] * p[k] * p[j]);
			}
		}
	}
	
	cout << m[1][n] << endl;
	
	return 0;
}


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

using namespace std;
typedef long long ll;
#define T_ template
#define Tn typename
T_ <Tn T> inline bool cmin(T & a, const T & b) { return a > b ? a = b, 1 : 0;}
T_ <Tn T> inline bool cmax(T & a, const T & b) { return a < b ? a = b, 1 : 0;}
T_ <Tn L, Tn R> ostream & operator << (ostream &out, pair<L, R> t) { return out << "(" << t.first << "," << t.second << ")"; }
T_ <Tn T> ostream & operator << (ostream &out, vector<T> t) { for (unsigned i = 0; i < t.size(); i++) out << (" ("[!i]) << t[i] << (",)"[i == t.size() - 1]); return out; }

const int mod = 1e9 + 7, MaxM = 100010;
 
struct mat {
  int x[3][3];  
  int *operator[] (int i) {
    return x[i];  
  }
}o;

inline mat mul(mat a, mat b) {
  mat c = o;
  for (int i = 0; i < 3; i++)
    for (int j = 0; j < 3; j++) 
      for (int k = 0; k < 3; k++)
        c[i][j] = (c[i][j] + (ll) a[i][k] * b[k][j]) % mod;
  return c;
}

inline mat exp(mat a, int n) {
  mat c = o; 
  for (int i = 0; i < 3; i++)
    c[i][i] = 1;
  for (; n; n >>= 1) {
    if (n & 1)
      c = mul(c, a);
    a = mul(a, a);
  }
  return c;
}

int n, m, x[MaxM];
mat ta = {
1, 2, 1, 0, 1, 1, 1, 2, 2
};
mat tb, tc;

int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++)
    scanf("%d", &x[i]);
  x[++m] = n;
    
  tb = ta;
  --tb[2][0]; --tb[2][1]; --tb[2][1]; --tb[2][2];
  tc[0][0] = tc[0][2] = tc[0][1] = 1; ++tc[0][1];
  
  for (int i = 1, j = 1; i <= m; i++) {
    mat td = exp(ta, x[i] - j);
    tc = mul(tc, td);
    if (i == m)
      break;
    tc = mul(tc, tb);
    j = x[i] + 1;
  }
  printf("%d\n", tc[0][2]);
  return 0;
}
/*
f[i][0/1/2]


*/

Measured memory_bytes: 640
#include <stdio.h>
static int xs[256];
int main(void){
    int i;
    while((i=getchar())-'\n')
        ++xs[i];
    for(i='a';i<='z';++i)
        if(xs[i]%2){
            puts("No");
            return 0;
        }
    puts("Yes");
    return 0;}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int L = A + B, R = C + D;
  if (L > R) { 
    cout << "Left" << endl;
  }

  else if(L==R){
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include<bits/stdc++.h>
using namespace std;
int main(){
	cin.tie(0),cin.sync_with_stdio(0),cout.tie(0),cout.sync_with_stdio(0);
	int a, b;
	cin>>a>>b;
	for(int i=1;i<=1e5;i++){
		if(i/10==b && (i*2)/25==a)
			return cout<<i, 0;
	}
	cout<<-1;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(q, l, r) for (int q = l; q <= r; q++)
#define mid (l + r) / 2
#define pl (i << 1)
#define pr (i << 1 | 1)
#define pb push_back
#define mk make_pair
typedef long long ll;
typedef pair<int, int> pi;
const int maxn = 100;
const int INF = 1e9 + 7;
const ll mod = 1e9 + 7;
const ll LINF = 1e14;
int a[maxn],b[maxn],c[maxn];
int main()
{
    int n;
    scanf("%d",&n);
    for (int q=1;q<n;q++)
        scanf("%d",&a[q]);
    ll s=0;
    s+=a[1];
    for (int q=2;q<n;q++)
    s+=min(a[q-1],a[q]);
    s+=a[n-1];

    cout<<s<<endl;

    return 0;
    
}

Measured memory_bytes: 256
n , k = map(int , input().split())
sum = 0
mod = 1e9+7
def func(x):
    return (2 * n - x + 1) * x / 2 - (x - 1) * x / 2 + 1
for i in range(k , n+2):
    sum = (sum + func(i)) % mod
print(int(sum))

Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

char s[5];

int main(){
	scanf("%s", s);
	int ans = 0;
	REP(i, 3){
		if(s[i] == 'S') continue;
		DEBUG("i=%d\n", i);
		FOR(j, i, 3){
			DEBUG("  j=%d\n", j);
			if(s[i] != s[j]) break;
			LAR(ans, j-i+1);
		}
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 3784
#include<iostream>
#include<vector>
using namespace std;
string s,t;
main()
{
	while(cin>>s,s!=".")
	{
		cin>>t;
		vector<string>a,b;
		string now="";
		for(int i=0;i<s.size();i++)
		{
			if(s[i]=='"')
			{
				a.push_back(now);
				now="";
			}
			else now+=s[i];
		}
		a.push_back(now);
		now="";
		for(int i=0;i<t.size();i++)
		{
			if(t[i]=='"')
			{
				b.push_back(now);
				now="";
			}
			else now+=t[i];
		}
		b.push_back(now);
		int cnt=a.size()!=b.size()?2:0;
		for(int i=0;i<a.size();i++)
		{
			if(i>=b.size())cnt+=2;
			else
			{
				if(a[i]!=b[i])
				{
					cnt+=2-i%2;
				}
			}
		}
		cout<<(cnt?cnt>1?"DIFFERENT":"CLOSE":"IDENTICAL")<<endl;
	}
}



Measured memory_bytes: 3068
// inputに入力データ全体が入る
function Main(input) {
	var args = input.split(" ");
	var N = parseInt(args[0],10);
	var min = parseInt(args[1],10);
	var max = parseInt(args[2],10);
	var array = [];
	var sum = 0;
	var answer = 0;

	for(var i = 0;i <= N;i++){
		sum = 0;
		var num_string = i + "";
		var num_array = num_string.split("");
		for(var j in num_array){
		sum += parseInt(num_array[j],10);
		}
		if(sum >= min && sum<= max) array.push(i);
	}

	for(var i =0;i < array.length; i++){
		answer += array[i];
	}
	//出力
	console.log(answer);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 22956
from collections import deque
dq = deque()
for _ in [None]*int(input()):
    s = input()
    if s == "deleteFirst":
        dq.popleft()
    elif s == "deleteLast":
        dq.pop()
    else:
        a, b = s.split()
        if a == "insert":
            dq.appendleft(b)
        else:
            if b in dq:
                dq.remove(b)
print(" ".join(dq))



Measured memory_bytes: 85360
#include<stdio.h>

int main()
{
 int x, y, m;
  while(1){
    scanf("%d %d",&x, &y);
    if (x==0 && y==0) break;
    if(x>y){
     m=x;
     x=y;
     y=m;
    }
    printf("%d %d\n",x,y);
    
  }

}

Measured memory_bytes: 2584
#include <bits/stdc++.h>
#define ll long long
#define ar array
#define nl '\n'
#define AC ios_base::sync_with_stdio(0); cin.tie(NULL);
using namespace std;
const int M = 1e9+7;
const int N = 2*1e5;

int hasSnack[105];

int main(){
    AC
    int n, k;
    cin>>n>>k;
    for(int i=0; i<k; i++){
        int d;
        cin>>d;
        for(int j=0; j<d; j++){
            int x;
            cin>>x;
            hasSnack[--x] = 1;
        }
    }

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

Measured memory_bytes: 3616
n, k = gets.split.map(&:to_i)

nums = gets.split.map(&:to_i)

DIV = 10**9 + 7

$FACT_MUL = {}

def fact(num, i) 
    res = num
    mul = i * (i + 1) / 2
    # if $FACT_MUL.has_key?(i)
    #     mul = $FACT_MUL[i]
    # else
    #     1.upto(i) do |j|
    #         mul += j
    #         $FACT_MUL[j] = mul
    #     end
    # end
    res * [mul, 1].max
end

res = 0
nums.each_with_index do |outer_num, outer_idx|
    left_num = 0
    right_num = 0
    
    nums.each_with_index do |inner_num, inner_idx |
        if outer_num > inner_num
            if inner_idx < outer_idx
                left_num += 1
            else
                right_num += 1
            end
        end
    end
    res += fact(right_num, k)
    res += fact(left_num, k - 1)
end

puts res % DIV

Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int row = sc.nextInt();
        int n = sc.nextInt();
        int save, x, y;
        int[] ans =  new int[row+1];
        for(int i=1; i<=row; i++) {
            ans[i] = i;
        }
        for(int i=0; i<n; i++) {
            String line = sc.next();
            String[] a = line.split(",");
            x = Integer.parseInt(a[0]);
            y = Integer.parseInt(a[1]);
            save = ans[x];
            ans[x] = ans[y];
            ans[y] = save;

        }
        for(int i=1; i<=row; i++) {
            System.out.println(ans[i]);
        }
    }
}



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

using namespace std;
char field[52][52];
int dx[8] = {-1, -1, -1,  0, 0,  1, 1, 1};
int dy[8] = {-1,  0,  1, -1, 1, -1, 0, 1};

void DFS(int y, int x)
{
	field[y][x] = '0';
	for(int i = 0; i < 8; ++i)
	{
		int nx = x + dx[i];
		int ny = y + dy[i];
		if(field[ny][nx] == '1')
		{
			DFS(ny, nx);
		}
	}
}

void solve()
{
	int w, h;
	while(cin >> w >> h, w || h)
	{
		memset(field, 0, sizeof(field));
		for(int i = 1; i <= h; ++i)
		{
			for(int j = 1; j <= w; ++j)
			{
				cin >> field[i][j];
			}
		}
		int count = 0;
		for(int i = 1; i <= h; ++i)
		{
			for(int j = 1; j <= w; ++j)
			{
				if(field[i][j] == '1')
				{
					++count;
					DFS(i, j);
				}
			}
		}
		cout << count << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1228
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REPR(i, n) for (int i = (n)-1; i >= 0; i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase(unique(ALL(v)), v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const ll LINF = 2e18;
const double PI = acos(-1);

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	std::string S;
	std::cin >> S;
	int ans = 0;
	REP(i, SZ(S))
	{
		if (S[i] == '2')
			ans++;
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
  int N,K;
  cin >> N >> K;
  int sum =0;
  for(int i=0;i<N;i++) {
    int x;
    cin >> x;
    if(x<=K-x) {
      sum+=x;
    }
    else {
      sum+=K-x;
    }
  }
  cout << 2*sum << endl;
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M, cnt = 0;
  cin >> N >> M;
  int H[N+1],A[N+1]={0};
  for(int i = 1; i < N+1; i++) cin >> H[i];
  for(int i = 0; i < M; i++){
    int a, b;
    cin >> a >> b;
    if(H[a] <= H[b]) A[a] = -1;
    if(H[b] <= H[a]) A[b] = -1;
  }
  for(int i = 1; i < N+1; i++) if(A[i] == 0) cnt++;
  cout << cnt << endl;
}

Measured memory_bytes: 4416
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
#define REP3D(i,s,g) for(int i=s;i>=g;i--)
using namespace std;

int main() {
    int N, W;
    cin >> N >> W;
    int v[N], w[N];
    vector<pair<int, int> > pairs(N);
    REP(i,N){
        cin >> v[i] >> w[i];
        pairs[i] = make_pair(w[i],v[i]);
    }
    sort(pairs.begin(),pairs.end());
    
    int dp[W+1];
    REP(i,W+1)
        dp[i] = 0;

    REP(i,W+1){
        REP(j,N){
            if (i+w[j] <= W)
                dp[i+w[j]] = max(dp[i+w[j]],dp[i]+v[j]);
        }
    }
    cout << dp[W] << '\n';
}

Measured memory_bytes: 1240
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const double EPS = 1e-10;
const int INF = 1e9;
const ll LINF = 1e15;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int main() {
	int n, k;
	cin >> n >> k;
	if (k == 0) {
		ll ans = (ll) n * n;
		cout << ans << endl;
		return 0;
	}

	ll ans = 0;
	for (int b = 1; b <= n; b++) {
		if (b <= k) continue;
		ll x = (n / b) * (b - k);
		ll y = max(0ll, (ll) n % b - k + 1);
		ans += x + y;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3560
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double PI = 3.14159265358979;
const double E = 2.718281828459045;
const double root2 = sqrt(2);
typedef pair<int, int> P;
typedef unsigned int ui;
int main() {
	int n, m, k, p, l;
	while (cin >> n) {
		if (n == 0)break;
		vector<int> s[101]; int cnt[101] = {};
		for (int i = 0; i < n; i++) {
			cin >> m;
			for (int j = 0; j < m; j++) {
				cin >> p; s[p].push_back(i+1);
			}
		}
		cin >> k;
		for (int i = 0; i < k; i++) {
			cin >> l;
			int len = s[l].size();
			for (int j = 0; j < len; j++) {
				cnt[s[l][j]]++;
			}
		}
		int ck = 0;
		for (int i = 1; i <= n; i++) {
			if (cnt[i] == k) {
				if (ck == 0) {
					ck = i;
				}
				else ck = -1;
			}
		}
		if (ck <= 0)cout << -1 << endl;
		else cout << ck << endl;
	}
	return 0;
}


Measured memory_bytes: 3176
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<unordered_map>
#include<unordered_set>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592
#define PI acos(-1.0);

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    cout << fixed << setprecision(5);
    int r; cin >> r;
    double ans = 2*r*PI;
    cout << ans <<endl;

}



Measured memory_bytes: 3784
# -*- coding: utf-8 -*-

N = int(raw_input())

if N >= 64:
    print '64'
elif N >= 32:
    print '32'
elif N >= 16:
    print '16'
elif N >= 8:
    print '8'
elif N >= 4:
    print '4'
elif N >= 2:
    print '2'
else:
    print '1'


Measured memory_bytes: 2568
from collections import Counter

class UnionFind():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        # root[x]<0ならそのノードが根かつその値が木の要素数
        # rootノードでその木の要素数を記録する
        self.root = [-1]*(n+1)
        # 木をくっつける時にアンバランスにならないように調整する
        self.rnk = [0]*(n+1)

    # ノードxのrootノードを見つける
    def find_root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            # ここで代入しておくことで、後の繰り返しを避ける
            #経路圧縮
            self.root[x] = self.find_root(self.root[x])
            return self.root[x]
    # 木の併合、入力は併合したい各ノード
    def unite(self, x, y):
        # 入力ノードのrootノードを見つける
        x = self.find_root(x)
        y = self.find_root(y)
        # すでに同じ木に属していた場合
        if(x == y):
            return
        # 違う木に属していた場合rnkを見てくっつける方を決める
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            # rnkが同じ（深さに差がない場合）は1増やす
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    # xとyが同じグループに属するか判断
    def isSame(self, x, y):
        return self.find_root(x) == self.find_root(y)

    # ノードxが属する木のサイズを返す
    def size(self, x):
        return -self.root[self.find_root(x)]
        
n,k,l = map(int,input().split())
fe = UnionFind(n)
bus = UnionFind(n)
for _ in range(k):
    p,q = map(int,input().split())
    fe.unite(p,q)
for _ in range(l):
    r,s = map(int,input().split())
    bus.unite(r,s)
cnt = Counter()
for i in range(1,n+1):
    cnt[fe.find_root(i),bus.find_root(i)] += 1

print(*[cnt[fe.find_root(i),bus.find_root(i)]for i in range(1,n+1)])

Measured memory_bytes: 44524
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    String[] S = new String[N];
    int[] P = new int[N];


    for (int i = 0; i < N; i++) {
      String s = sc.next();
      P[i] = sc.nextInt();
      String p_ = String.format("%03d", 100 - P[i]);
      String i_ = String.format("%03d", i);
      S[i] = s + "_" + p_ +  "_" + i_;
    }

    sc.close();

    Arrays.sort(S);

    for (int i = 0; i < N; i++) {
      String[] s_ = S[i].split("_");
      System.out.println(Integer.valueOf(s_[2]) + 1);
    }

  }

}

Measured memory_bytes: 23764
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    static private Scanner scan = new Scanner(System.in);
    public static void main(String args[]) {
        int int1 = Integer.parseInt(scan.next());
        int int2 = Integer.parseInt(scan.next());
//        int int3 = Integer.parseInt(scan.next());
//        String temp_str1 = "";
//        String temp_str2 = "";
        int temp_int1 = 0;
//        String str1 = scan.next();
        int ans_int = 0;
        String ans = "";
//        double ans_dob = 0;
        if((int1+int2)%3 == 0 || int1%3 == 0 || int2%3 == 0){
            ans = "Possible";
        }else{
            ans = "Impossible";
        }

        PrintWriter out = new PrintWriter(System.out);
        out.println(ans);
        out.flush();
        scan.close();
    }
}


Measured memory_bytes: 21972
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>

const int INF = 0x3f3f3f3f;
const int DOWN = 1;
const int LEFT = 2;
const int DIAG = 3;

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

	string s, t;
	cin >> s >> t;

	int m = s.size();
	int n = t.size();
	int c[m+1][n+1];  // c[i][j] is length of LCS of s_i and t_j: namely, s[0] ... s[i-1] vs t[0] ... t[j-1]
	int b[m][n];      // b[i-1][j+1] tells us what choice we made for c[i][j]
	for (int i = 0; i < m+1; i++) {
	  c[i][0] = 0;
	}
	for (int j = 0; j < n+1; j++) {
	  c[0][j] = 0;
	}
	for (int i = 1; i < m+1; i++) {
	  for (int j = 1; j < n+1; j++) {
	    if (s[i-1]  == t[j-1]) {
	      c[i][j] = c[i-1][j-1] + 1;
	      b[i-1][j-1] = DIAG;
	    } else {
	      int left = c[i][j-1];
	      int down = c[i-1][j];
	      if (left > down) {
		c[i][j] = left;
		b[i-1][j-1] = LEFT;
	      } else {
		c[i][j] = down;
		b[i-1][j-1] = DOWN;
	      }
	    }
	  }
	}

	// Now read off the answer backwards.
	string ans;
	while (m > 0 && n > 0) {
	  int cur = b[m-1][n-1];
	  if (cur == DIAG) {
	    ans.push_back(s[m-1]);
	    m -= 1;
	    n -= 1;
	  } else if (cur == DOWN) {
	    m -= 1;
	  } else {
	    n -= 1;
	  }
	}
	std::reverse(ans.begin(), ans.end());
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 70656
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

const int mod = 1e9 + 7;
const int MX = 1100000;
ll inv[MX], f[MX], invf[MX];
void calc(){
	inv[0] = inv[1] = f[0] = f[1] = invf[0] = invf[1] = 1;
	for (int i = 2; i < MX; i++){
		inv[i] = mod - mod / i * inv[mod % i] % mod;
		f[i] = f[i - 1] * i % mod;
		invf[i] = invf[i - 1] * inv[i] % mod;
	}
}
inline ll C(ll n, ll k){
	if(n < k || k < 0) return 0;
	return f[n] * invf[k] % mod * invf[n - k] % mod;
}
int main(){
	calc();
	cin.tie(0); cin.sync_with_stdio(0);
	int n, m; cin >> n >> m;
	vi a(n), b(m);
	rep(i, n) cin >> a[i];
	rep(i, m) cin >> b[i];
	sort(all(a)); sort(all(b));
	
	ll ans = 1;
	int x = 0, y = 0, use = 0;
	
	for(int i = n * m, j = n - 1, k = m - 1; i > 0; i--){
		while(j >= 0 && a[j] > i) j--;
		while(k >= 0 && b[k] > i) k--;
		bool af = j >= 0 && a[j] == i;
		bool bf = k >= 0 && b[k] == i;
		
		if(!af && !bf){
			ans *= x * y - n * m + i;
		}
		else if(af && bf){
			x++; y++; use++;
		}
		else if(af){
			ans *= y; x++; use++;
		}
		else{
			ans *= x; y++; use++;
		}
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 26112
#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define LOCAL 1

#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#define dbg(...) cout<<#__VA_ARGS__ ": ["; for(auto e: __VA_ARGS__){cout<<e<<", ";} cout<<"]\n"
#define dbg1(...) cout<<#__VA_ARGS__ " "<< __VA_ARGS__ 
#else
#define dbg(...) 1;
#define dbg1(...) 1;
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
constexpr ll R=2e5+69, INF=2e9+6969;

int n;

int main()
{
	scanf("%d", &n);
	while(n--)
	{
		cout << "ACL";
	}
	puts("");
	return 0;
}


Measured memory_bytes: 3760
#include <algorithm>
#include <cstdio>
const int MAXN = 1e5+5;
int d[MAXN];
int N;

int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) {
    scanf("%d", &d[i]);
  }
  std::sort(d, d+N);
  int h = N/2;
  printf("%d\n", d[h] - d[h-1]);
  return 0;
}

Measured memory_bytes: 512
#import math
import fractions as math

N, X = list(map(int, input().split()))
x = sorted([X] + list(map(int, input().split())))
nums = [-(x[i]-x[i+1]) for i in range(N)]
ans = 0
for n in nums:
    ans = math.gcd(ans, n)
print(ans)

Measured memory_bytes: 16284
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define SPEED ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define RFOR(i, b, a) for (ll i = b; i >= a; --i)
#define ALL(x) x.begin(), x.end()
#define DEBUG(args...) { string _s = #args; replace(ALL(_s), ' ', '\0');\
replace(ALL(_s), ',', ' ');\
stringstream _ss(_s); istream_iterator<string> _it(_ss); _debug(_it, args);}
#define endl "\n"
#define F first
#define S second
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void _debug(istream_iterator<string>) {}
template<typename T, typename... Args>
void _debug(istream_iterator<string> it, T first, Args... args) {
    cerr << ">> " << *it << " : " << first << endl; _debug(++it, args...);
}
template <typename T1, typename T2>
inline ostream& operator << (ostream& out, const pair<T1, T2>& p) {
    return out << "(" << p.F << ", " << p.S << ")";
}
template<typename T>
inline ostream& operator << (ostream& out, const vector<T>& v) {
    if (v.empty()) return out << "[]";
    else { out << '['; for (auto& e : v) { out << e << ", "; } return out << "\b\b]"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const set<T>& s) {
    if (s.empty()) return out << "{}";
    else { out << '{'; for (auto& e : s) { out << e << ", "; } return out << "\b\b}"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const unordered_set<T>& s) {
    return out << set<T>(ALL(s));
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const map<T1, T2>& m) {
    if (m.empty()) return out << "{}";
    out << '{'; for (auto& p : m) { out << p << ", "; } return out << "\b\b}";
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const unordered_map<T1, T2>& m) {
    return out << map<T1, T2>(ALL(m));
}
template<typename T>
inline ostream& operator << (ostream& out, const ordered_set<T>& s) {
    return out << set<T>(ALL(s));
}

typedef long long ll;
typedef long double ld;
typedef vector<long long> vll;
typedef pair<ll, ll> pll;
typedef vector<pair<ll, ll>> vpll;
typedef unordered_map<ll, ll> STll;
/************************************** MAIN PROGRAM ********************************************/

int main()
{
    //freopen("input.txt", "r", stdin);
    SPEED
    int k, n;
    cin >> k >> n;
    int gap = 0;
    vector<int> a(n);
    FOR(i, 0, n) {
        cin >> a[i];
    }
    for (int i = 0; i < n; ++i) {
        int cur = (a[(i + 1) % n] - a[i] + k) % k;
        gap = max(gap, cur);
    }
    cout << k - gap;
}
/************************************** END OF PROGRAM ******************************************/
/** Stuff you should look for:
 * int overflow, array bounds, over-counting
 * special cases (n=1?), set/unordered_set TLE, multi-set/set error
 * do something instead of nothing and stay organized
 */


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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int V = int.Parse(input[0]);
            int E = int.Parse(input[1]);

            Dictionary<int, List<int>> G = new Dictionary<int, List<int>>();
            for (int i = 0; i < V; i++) G.Add(i, new List<int>());

            for (int i = 0; i < E; i++)
            {
                input = Console.ReadLine().Split(' ');
                int s = int.Parse(input[0]);
                int t = int.Parse(input[1]);

                G[s].Add(t);
            }

            Console.WriteLine(IsDAG(G) ? "0" : "1");
        }

        static bool IsDAG(Dictionary<int, List<int>> G)
        {
            int n = G.Count;

            int[] color = new int[n];

            for (int i = 0; i < n; i++)
            {
                if (color[i] == 0 && !Visit(G, i, color)) return false;
            }
            return true;
        }

        static bool Visit(Dictionary<int, List<int>> G, int v, int[] color)
        {
            color[v] = 1;

            foreach (var e in G[v])
            {
                if (color[e] == 2) continue;
                if (color[e] == 1) return false;
                if (!Visit(G, e, color)) return false;
            }

            color[v] = 2;
            return true;
        }
    }
}

Measured memory_bytes: 9612
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    boolean[] color = new boolean[8];
    int free = 0;
    int count = 0;
    for(int i=0;i<n;i++){
      int x = sc.nextInt();
      if(1<=x && x<=399){
        if(!color[0]){
          count++;
        }
        color[0] = true;
      }else if(400<=x && x<=799){
        if(!color[1]){
          count++;
        }
        color[1] = true;
      }else if(800<=x && x<=1199){
        if(!color[2]){
          count++;
        }
        color[2] = true;
      }else if(1200<=x && x<=1599){
        if(!color[3]){
          count++;
        }
        color[3] = true;
      }else if(1600<=x && x<=1999){
        if(!color[4]){
          count++;
        }
        color[4] = true;
      }else if(2000<=x && x<=2399){
        if(!color[5]){
          count++;
        }
        color[5] = true;
      }else if(2400<=x && x<=2799){
        if(!color[6]){
          count++;
        }
        color[6] = true;
      }else if(2800<=x && x<=3199){
        if(!color[7]){
          count++;
        }
        color[7] = true;
      }else{
        free++;
      }
    }

    int min = count;
    int max = count+free;
    if(min==0){
      min = 1;
      max = n;
    }
    
      System.out.println(min+" "+max);
  }
}

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

int main(){
    int k;
    cin >> k;
    vector<int> a(k);
    for(int i=0; i<k; i++) a.at(i) = i+1;
    int ans = 0;
    int count = k/2;
    if(k % 2 == 0){
        for(int i=0; i<k-1; i++){
            ans += count;
            if(i==0 || i%2==0){
                count--;
            }
        }
    }
    else {
        for(int i=0; i<k-1; i++){
            ans += count;
            if(i%2 != 0) count--;
        }
    }

    cout << ans << endl;
}

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

#define F first
#define S second

using namespace std;

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

const int N = 60, M = 1010;

LL a, b;

LL get(LL n)
{
	if (n == -1) return 0;
	else if (n % 4 == 0) return n;
	else if (n % 4 == 1) return 1;
	else if (n % 4 == 2) return n ^ 1;
	else if (n % 4 == 3) return 0;
}

int main()
{
	cin >> a >> b;
	cout << (get(b) ^ get(a - 1)) << endl;
	return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

const int M = 200000;
int n, a[M], b[M];

int main() {
	scanf("%d", &n);
	inc(i, n) { scanf("%d", &a[i]); }
	inc(i, n) { scanf("%d", &b[i]); }
	
	int ans = 0;
	dec(k, 28 + 1) {
		inc(i, n) {
			a[i] &= (2 << k) - 1;
			b[i] &= (2 << k) - 1;
		}
		sort(a, a + n);
		sort(b, b + n, greater<>());
		
		int c = 0, p1 = 0, p2 = 0, p3 = 0;
		inc(i, n) {
			while(p1 < n && a[i] + b[p1] >= (1 << k)) { p1++; }
			while(p2 < n && a[i] + b[p2] >= (2 << k)) { p2++; }
			while(p3 < n && a[i] + b[p3] >= (3 << k)) { p3++; }
			c ^= (p1 - p2 + p3) & 1;
		}
		ans |= c << k;
	}
	
	printf("%d\n", ans);
	
	return 0;
}


Measured memory_bytes: 1792
# D
n,m = map(int, input().split())
b = [0,2,5,5,4,5,6,3,7,6]
a = [0]+list(map(int, input().split()))
f = [-1]*10010
f[0]=0
for i in range(1,n+1):
    for j in range(1,m+1):
        x = a[j]
        if(i-b[x]<0):
            continue
        f[i] = max(f[i],f[i-b[x]]*10 + x)
print(f[n])

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

#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define fr(i,k,n) for (int i = k; i < n; ++i)
#define fri(i,k,n) for (int i = k; i >= n; --i)
#define INF (int)1e9
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define all(arr) arr.begin(),arr.end()

void boost(){
  ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

void solve(){
  int n;
  cin>>n;
  int arr[n];
  int x,y;
  fr(i,0,n){
    cin>>x>>y;
    arr[i]=(x==y);
  }
  fr(i,0,n-2){
    if(arr[i]==arr[i+1] && arr[i+1]==arr[i+2] && arr[i]==1){
      cout<<"Yes"<<endl;
      return;
    }
  }
  cout<<"No"<<endl;
  return;
}

int main()
{
  boost();
  
  int tc=1;
  //cin>>tc;
  while(tc--)
    solve();
  return 0;
} 

Measured memory_bytes: 3688
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<climits>
#include<cstring>
#include<queue>
#include<complex>
using namespace std;

typedef complex<double> P;
struct L : public vector<P>{
    L(const P &a, const P &b){
        push_back(a), push_back(b);
    }
};
const double EPS = 1e-8;

namespace std {
  bool operator < (const P& a, const P& b) {
    return imag(a) != imag(b) ? imag(a) < imag(b) : real(a) < real(b);
  }
}

double cross(const P &a, const P &b){
    return imag(conj(a)*b);
}

double dot(const P &a, const P &b){
    return real(conj(a)*b);
}

int ccw(P a, P b, P c){
    b -= a;
    c -= a;
    if(cross(b,c) > 0) return +1;
    if(cross(b,c) < 0) return -1;
    if(dot(b,c) < 0) return +2;
    if(norm(b) < norm(c)) return -2;
    return 0;
}

P crosspoint(const L &l, const L &m) {
    double A = cross(l[1] - l[0], m[1] - m[0]);
    double B = cross(l[1] - l[0], l[1] - m[0]);
    if (abs(A) < EPS && abs(B) < EPS) return m[0]; // same line
    return m[0] + B / A * (m[1] - m[0]);
}

#define curr(G, i) G[i%n]
#define next(G, i) G[(i+1)%n]

double area(vector<P> &G){
    int n = G.size();

    double S = 0;
    for (int i=0;i<n;i++){
        P p = curr(G, i);
        P q = next(G, i);
        S += (1.0/2)*cross(p, q);
    }

    return S;
}

double convexCut(vector<P> &G, P &p1, P &p2){
    int n= G.size();
    L l(p1, p2);
    vector<P> leftG;

    for (int i=0;i<n;i++){
        if(ccw(p1, p2, curr(G,i))!= -1){
            leftG.push_back(curr(G,i));
            if(ccw(p1, p2, next(G,i)) == -1 ){
                L s(curr(G, i), next(G, i));
                leftG.push_back(crosspoint(l, s));
            }
        }else{
            if(ccw(p1, p2, next(G,i)) != -1 ){
                L s(curr(G, i), next(G, i));
                leftG.push_back(crosspoint(l, s));
            }
        }
    }
    return area(leftG);
}

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

    vector<P> G;
    P p, q;
    for (int i=0;i<n;i++){
        cin >> p.real() >> p.imag();
        G.push_back(p);
    }

    cin >> Q;
    for (int i=0;i<Q;i++){
        cin >> p.real() >> p.imag() >> q.real() >> q.imag();
        printf("%.7f\n", convexCut(G, p, q));
    }

    return 0;
}

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

#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define lrp(i,n) for(long long i=0;i<n;i++)
#define lrep(i,m,n) for(long long i=m;i<=n;i++)
#define all(a) a.begin(),a.end()
#define pb push_back

typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;

int main(){
    ll a,b,x;
    cin >> a >> b >> x;
    ll A,B;
    A = (a%x==0?a/x:a/x+1);
    B = b/x+1;
    cout << B-A << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#define fi first
#define se second
const int INF = 0x7fffffff;
const int maxn = 100000010;

using namespace std;

int a[2000010];

int main(void)
{
    int n;
    int flag = 1;
    while(~scanf("%d",&n)){
    int rec = n;
    for(int i = 1; i <= n; i++) scanf("%d",&a[i]);
    if(n==1) printf("%d\n",a[1]);
    else if(n==2) printf("%d %d\n",a[2],a[1]);
    else if(n==3) printf("%d %d %d\n",a[3],a[1],a[2]);
    else{
    printf("%d",a[n]);
    n -= 2;
    while(n >= 1) {printf(" %d",a[n]);n -= 2;}
    if(n&1) n = 2; else n += 1;
    while(n < rec) {printf(" %d",a[n]);n += 2;}
    cout << '\n';
    }
    }
    return 0;
}


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

int main()
{
	// ios_base::sync_with_stdio(false);
 //    cin.tie(NULL);
 //    cout.tie(NULL);
    ll n;
    cin>>n;
    double a;
    a=(ceil((double)n/2))/(double)n;
    cout<<a<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int main(){
    int n;
    while(scanf("%d",&n),n){
        n /= 4;
        int sum = 0;
        int x;
        for(int i = 0;i < n; i++){
            scanf("%d",&x);
            sum += x;
        }
        printf("%d\n",sum);
    }
    return 0;
}

Measured memory_bytes: 1028
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}

int main(void){
	int c[3][3];
	scanf("%d%d%d", c[0], c[0]+1, c[0]+2);
	scanf("%d%d%d", c[1], c[1]+1, c[1]+2);
	scanf("%d%d%d", c[2], c[2]+1, c[2]+2);
	if(0);
	else if(c[0][0]-c[0][1] != c[1][0]-c[1][1] || c[0][0]-c[0][1] != c[2][0]-c[2][1]);
	else if(c[0][0]-c[0][2] != c[1][0]-c[1][2] || c[0][0]-c[0][2] != c[2][0]-c[2][2]);
	else{
		puts("Yes");
		return 0;
	}
	puts("No");
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define N 100
using namespace std;
int a[2][N];
int s[2][N];
int main() {
    int n = 2, m;
    cin >> m;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            if(i == 0 && j == 0) {
                s[i][j] = a[i][j];
            } else if(i == 0) {
                s[i][j] = a[i][j] + s[i][j-1];
            } else if(j == 0) {
                s[i][j] = a[i][j] + s[i-1][j];
            } else {
                s[i][j] = a[i][j] + max(s[i-1][j], s[i][j-1]);
            }
        }
    }
    cout << s[n-1][m-1] << endl;
}

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

int main() {
  int A, B;
  cin >> A >> B;
  
  if(A>=13){
    cout << B << endl;
  }
  else if(A>=6){
    cout << B/2 << endl;
  }
   else{
     cout << 0 << endl;
   }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define il inline
#define RG register
#define ll long long
#define N (10000005)

using namespace std;

struct edge{ int nt,to; }g[1000005];

int prime[N/10],vis[N],can[N],head[510],vi[510],lk[510],a[510],b[510],k,n,num,cnt,cnt1,cnt2;

il int gi(){
  RG int x=0,q=1; RG char ch=getchar();
  while ((ch<'0' || ch>'9') && ch!='-') ch=getchar();
  if (ch=='-') q=-1,ch=getchar();
  while (ch>='0' && ch<='9') x=x*10+ch-48,ch=getchar();
  return q*x;
}

il void insert(RG int from,RG int to){
  g[++num]=(edge){head[from],to},head[from]=num; return;
}

il int dfs(RG int x){
  for (RG int i=head[x],v;i;i=g[i].nt){
    v=g[i].to; if (vi[v]==cnt) continue; vi[v]=cnt;
    if (!lk[v] || dfs(lk[v])){ lk[v]=x; return 1; }
  }
  return 0;
}

il void pre(){
  vis[1]=1;
  for (RG int i=2;i<N;++i){
    if (!vis[i]) prime[++cnt]=i;
    for (RG int j=1,k;j<=cnt;++j){
      k=i*prime[j]; if (k>=N) break;
      vis[k]=1; if (i%prime[j]==0) break;
    }
  }
  vis[2]=1; return;
}

int main(){
  n=gi(),pre();
  for (RG int i=1;i<=n;++i) can[gi()]=1;
  for (RG int i=1;i<N;++i){
    if (can[i]==can[i-1]) continue;
    (i&1)?a[++cnt1]=i:b[++cnt2]=i;
  }
  for (RG int i=1;i<=cnt1;++i)
    for (RG int j=1;j<=cnt2;++j)
      if (!vis[abs(a[i]-b[j])]) insert(i,j);
  for (RG int i=1;i<=cnt1;++i) ++cnt,k+=dfs(i);
  cout<<k+(cnt1-k)/2*2+(cnt2-k)/2*2+(cnt1-k)%2*3; return 0;
}


Measured memory_bytes: 82176
import java.util.Scanner;

/**
 *
 * @author kouki
 */
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int x = scan.nextInt();
        int y = scan.nextInt();
        int z = scan.nextInt();
        
        System.out.println((x*y)/2);
        
    }
    
}

Measured memory_bytes: 23508
#include <iostream>
using namespace std;
int main(){
  int n,ans=0;
cin>>n;
long long int k[n];
for(int i=0;i<n;i++){
  cin>>k[i];
  if(k[i]%2==0) {
    ans+=1;
    k[i]/=2;
    if(i==n-1){
      i=0;
    }
  }
  else {
    break;
  }
}
if(ans<n) cout<<"0"<<endl;
else cout<<ans/n+1<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int main(){
    long n,k;
    cin >> n >> k;
    n %= k;
    cout << min(n,k-n) << endl;
}

Measured memory_bytes: 256