akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
signed main(){
    int n;cin>>n;
    vector<int>v(n);rep(i,n)cin>>v[i];
    if(n==1){
        if(v[0]%2)cout<<2<<endl;
        else cout<<1<<endl;
        return 0;
    }
    int ans=1;
    int hoge=1;
    rep(i,n){
        ans*=3;
        if(v[i]%2)continue;
        else hoge*=2;
    }
    cout<<ans-hoge<<endl;
}



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

//#pragma gcc optimize("O3,unroll-loop")
//#pragma gcc target("sse,sse2,sse3,ssse3,sse4,avx,avx2,fma,abm,mmx,popcnt,tune=native")
//#define int long long
//#define double long double

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int d, t, s;
    cin >> d >> t >>s;
    if (s * t >= d)
        cout << "Yes\n";
    else
        cout << "No\n";

    return 0;
}

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

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


Measured memory_bytes: 3636
#line 1 "test/aoj/DSL_1_A.test.cpp"
#define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_1_A"
#line 1 "test/aoj/../../datastructure/union-find-tree.cpp"
#include <iostream>
#include <utility>
#include <vector>

using namespace std;

class UnionFind {
public:
  vector<int> data; // sizeとparを同時に管理する
  UnionFind(int size) : data(size, -1) {}

  int find(int x) {
    return data[x] < 0 ? x : data[x] = find(data[x]);
  }

  void unite(int x, int y) {
    int px = find(x);
    int py = find(y);
    if (px != py) {
      if (data[py] < data[px]) swap(px, py);
      data[px] += data[py]; data[py] = px;
    }
  }

  bool same(int x, int y) {
    return find(x) == find(y);
  }

  int size(int x) {
    return -data[find(x)];
  }
};
#line 3 "test/aoj/DSL_1_A.test.cpp"

int main() {
  int n, q; cin >> n >> q;
  UnionFind uf(n);
  for (int i = 0; i < q; ++i) {
    int c, x, y; cin >> c >> x >> y;
    if (c == 0) { uf.unite(x, y); }
    else {
      if (uf.same(x, y)) cout << 1 << endl;
      else cout << 0 << endl;
    }
  }
}



Measured memory_bytes: 3140
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var st = Console.ReadLine().Trim().Split().ToArray();
        var s = st[0];
        var t = st[1];
        var ab = Console.ReadLine().Split().ToArray().Select(x => int.Parse(x)).ToArray();
        var a = ab[0];
        var b = ab[1];
        var u = Console.ReadLine().Trim();

        if (u == s)
        {
            --a;
        }
        else
        {
            --b;
        }
        Console.WriteLine($"{a} {b}");
    }
}


Measured memory_bytes: 13396
a=int(input())
if a >= 1800:
  print("1")
elif  a >= 1600:
  print("2")
elif  a >= 1400:
  print("3")
elif  a >= 1200:
  print("4")
elif  a >= 1000:
  print("5")
elif  a >= 800:
  print("6")
elif  a >= 600:
  print("7")
else:
  print("8")


Measured memory_bytes: 9168
#include <stdio.h>

int main(void){
    int w,h,x,y,r;
	
    scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
	
    if (x-r < 0){
        puts("No");
    } else if(x+r > w){
        puts("No");
    } else if(y-r < 0){
        puts("No");
    } else if(y+r > h){
        puts("No");
    }else{
        puts("Yes");
    }
    return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    int n; cin >> n;
    vector<ll> a(100010,0),b(100010,0),c(100010,0);
    rep(i,n+1) cin >> a[i];
    if(n == 0) {
        if (a[0] == 1) cout << 1 << endl;
        else cout << -1 << endl;
        return 0;
    }
    else if (n > 0 && a[0] > 0) {
        cout << -1 << endl;
        return 0;
    }
    b = a;
    for (ll i = n -1;i >= 0;i-- ) b[i] += b[i+1];
    ll ans = 1;
    c[0] = 1;
    for(ll i = 1;i <= n; i++) {
        c[i] = min(c[i-1]*2,b[i]);
        ans += c[i];
        c[i]-=a[i];
        if(i<n && c[i] <= 0 || i == n&& c[i] < 0) {
            ans = -1;
            break;
        }
    }
    cout << ans << endl;
}


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

int main()
{
  ll x, k, d;
  cin >> x >> k >> d;
  x = abs(x);
  ll ans;
  if (x / d > k)
  {
    ans = x - d * k;
  }
  else
  {
    ll e = x / d;
    k -= e;
    x -= e * d;
    if (k % 2 == 1)
      x = abs(x - d);
    ans = x;
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3612
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val d = sc.nextInt()
    val xy = (0 until n).map { sc.next().toLong() to sc.next().toLong() }
    println(problem174b(n, d, xy))
}

fun problem174b(n: Int, d: Int, xy: List<Pair<Long, Long>>): Int {
    var count = 0
    for (i in 0 until n) {
        val (x, y) = xy[i]
        val ans = Math.sqrt((x * x).toDouble() + (y * y).toDouble())
        if (ans <= d) count++
    }
    return count
}

Measured memory_bytes: 77612
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()

x=I()
five=[i**5 for i in range(200)]
plus=[]
minus=[]
for i in range(200):
    for j in range(i,200):
        plus.append([five[i]+five[j],j,i])
        minus.append([five[j]-five[i],j,i])
#print(plus)
#print(minus)
for u in plus:
    if x==u[0]:
        print(u[1],end=" ")
        print(-u[2])
        sys.exit()
for u in minus:
    if x==u[0]:
        print(u[1],end=" ")
        print(u[2])
        sys.exit()

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

typedef long long lint;

int main(){
    int N,M;
    bool red[100000];
    int ball[100000],cnt;

    cin >> N >> M;
    red[0]=true;
    for(int i=1;i<N;i++) red[i]=false;
    for(int i=0;i<N;i++) ball[i]=1;
    cnt=1;

    for(int i=0;i<M;i++){
        int x,y;
        cin >> x >> y;
        ball[x-1]--;
        ball[y-1]++;
        if(red[x-1] && !red[y-1]){
            red[y-1]=true;
            cnt++;
        }
        if(ball[x-1]==0 && red[x-1]){
            red[x-1]=false;
            cnt--;
        }
    }

    cout << cnt << endl;
    return 0;
}//

Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
 
using namespace std;    
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
	string s;
  int n;
  cin>>n>>s;
  if(n%2==1) cout<<"No"<<'\n';
  else{
    rep(i,n/2){
      if(s[i]!=s[n/2+i]){
        cout<<"No"<<'\n';
        return 0;
      }
    }
    cout<<"Yes"<<'\n';
  }
    return 0;
}

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

using namespace std;

int main() {
	int k, x;
	scanf("%d%d", &k, &x);
	for(int i = x - k + 1; i <= x; i++) {
		printf("%d ", i);
	}
	for (int i = x + 1; i <= x + k - 1; i++) {
		printf("%d ", i);
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define pii pair<int, int>
#define pll pair<long long, long long>
#define ull unsigned long long
#define mp make_pair
#define F first
#define S second
#define mod 1000000007

int n;
bool dp[100005];
int k; 

int main()
{
    scanf("%d%d", &n, &k);
    vector<int> v(n+1);
    
    for(int i=1; i<=n; i++)
        scanf("%d", &v[i]);
    
    for(int i=1; i<=k; i++)
        for(int j=1; j<=n; j++)
            if(i-v[j] >= 0)
                dp[i] = (dp[i-v[j]] == false ? true: dp[i]);
        
    if(dp[k])
        cout << "First" << endl;
    else
        cout << "Second" << endl;


}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<cmath>
#include <iomanip>
#include <queue>

#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 all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e9

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef long double ld;
typedef std::pair <std::string, ll> P1;
typedef std::pair <ll, std::string> P2;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

using namespace std;

int main()
{
    ll n, k;
    cin >> n >> k;
    ll d = INF;
    ll q = INF;
    ll ans = 0;
    rep(i, n){
        ll p = k + i;
        if(abs(p) < d){
            d = abs(p);
            q = p;
        }
        ans += p;
    }

    cout << ans - q;



}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx")
//#undef LOCAL
#include <bits/stdc++.h>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

#ifdef LOCAL
struct PrettyOS {
    ostream& os;
    bool first;
    template <class T> auto operator<<(T&& x) {
        if (!first) os << ", ";
        first = false;
        os << x;
        return *this;
    }
};
template <class... T> void dbg0(T&&... t) {
    (PrettyOS{cerr, true} << ... << t);
}
#define dbg(...)                                            \
    do {                                                    \
        cerr << __LINE__ << " : " << #__VA_ARGS__ << " = "; \
        dbg0(__VA_ARGS__);                                  \
        cerr << endl;                                       \
    } while (false);
#else
#define dbg(...)
#endif

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    return os << "P(" << p.first << ", " << p.second << ")";
}

template <class T> ostream& operator<<(ostream& os, const V<T>& v) {
    os << "[";
    for (auto d : v) os << d << ", ";
    return os << "]";
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int a, b;
    cin >> a >> b;
    if (a >= 10 || b >= 10) cout << -1 << endl;
    else cout << a * b << endl;
    return 0;
}


Measured memory_bytes: 256
#include <string>
#include <algorithm>
#include <vector> 
#include <math.h>
#include <iostream>
using namespace std;
long long mod = 1000000000 + 7;




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

}


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

int main(){
 vector<int>A(3);
 cin>>A[0]>>A[1]>>A[2];
 sort(A.begin(),A.end());
 if((A[0]==A[1]&&A[1]!=A[2])||(A[0]!=A[1]&&A[1]==A[2])){
   cout<<"Yes"<<endl;
 }
 else{
   cout<<"No"<<endl;
 }
}
  

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

using namespace std;

#define pb push_back
#define mp make_pair
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n, k;
vector<int> g[2000];
queue<int> q;
int dist[2000], sub[2000], sum[2000];

int main() {
    scanf("%d%d", &n, &k);
    REP(i, n - 1) {
        int from, to;
        scanf("%d%d", &from, &to), --from, --to;
        g[from].pb(to);
        g[to].pb(from);
    }
    int ans = 0;
    REP(i, n) {
        REP(j, n) dist[j] = -1;
        q.push(i);
        dist[i] = 0;
        sub[i] = -1;
        while (!q.empty()) {
            int v = q.front();
            q.pop();
            for (int to : g[v]) if (dist[to] == -1) {
                dist[to] = dist[v] + 1;
                if (sub[v] == -1) {
                    sub[to] = to;
                } else {
                    sub[to] = sub[v];
                }
                q.push(to);
            }
        }
        int cnt = 0;
        REP(j, n) sum[j] = 0;
        REP(j, n) if (2 * dist[j] <= k) {
            ++cnt;
        } else if (2 * dist[j] == k + 1) {
            ++sum[sub[j]];
        }
        int mx = 0;
        REP(j, n) mx = max(mx, sum[j]);
        ans = max(ans, cnt + mx);
        //cerr << cnt << ' ' << mx << endl;
    }
    cout << n - ans << endl;
    return 0;
}




Measured memory_bytes: 384
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    ll a, b, c, d, n;
    string s;
    cin >> n >> a >> b >> c >> d >> s;
    bool p = true, op = false;
    a--; b--; c--; d--;
    vector <bool> vis(n, false);
    ll ib = b;
    if(a > b)
    {
        swap(a, b);
        swap(c, d);
    }
    while(b < d && p)
    {
        if(s[b + 1] == '.')
        {
            if(b + 2 <= d)
            {
                if(s[b + 2] == '.')
                    op = true;
            }
            b++;
        }
        else if(s[b + 1] == '#' && s[b + 2] == '.')
            b += 2;
        else
            p = false;
    }
    // cout << ib << endl;
    while(a < c && p)
    {
        if(s[a + 1] == '.')
        {
            if(a + 2 <= c)
            {
                // cout << ib << ' ' << a << endl;
                if(s[a + 2] == '.' && a >= ib - 1 && a < d)
                    op = true;
            }
            a++;
        }
        else if(s[a + 1] == '#' && s[a + 2] == '.')
            a += 2;
        else
            p = false;
    }
    if(c < d && p)
        cout << "Yes\n";
    else if(c > d && p && op)
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}

Measured memory_bytes: 592
use std::io;

fn gets() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn main() {
    let line = gets();
    let s = line.trim().parse::<char>().ok().unwrap();
    if s.is_ascii_lowercase() {
        println!("a");
    } else {
        println!("A");
    }
}


Measured memory_bytes: 2144
n = int(input())
arr = list(map(int, input().split()))

rem = []
count = 1
for i in range(len(arr)):
    if count == arr[i]:
        rem.append(arr[i])
        count += 1

if len(rem) == 0:
    print(-1)
else:
    print(len(arr) - len(rem))


Measured memory_bytes: 26268
#include <iostream>
#include <iomanip>

int main(void)
{
    u_int a, b;
    std::cin >> a >> b;

    int d = a / b;
    int r = a % b;
    double f = (double)a / b;
    std::cout << d << " " << r << "  " <<
        std::fixed << std::setprecision(6) << f << std::endl;

    return 0;
}

Measured memory_bytes: 1236
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string rstring(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return rstring.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtypes!real;
T[][] rtypess(T)(int n, int m){ return n.iota.map!(i => rtypes!T(m)).array; } alias rint = rtypess!int, rlong = rtypess!long, rreal = rtypess!real;
T chmin(T)(ref T x, T y){ if(x > y) x = y; return x; } T chmax(T)(ref T x, T y){ if(x < y) x = y; return x; }

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
	int h = rint, n = rint;
	long[] as, bs;
	foreach(j; 0 .. n) as ~= rlong, bs ~= rlong;

	long[] dp = new long[](h + 1); // dp[i][j]: 体力i以上を削るために必要な魔力の最小値
	long infty = 1_0000_0000_000;

	foreach(i; 0 .. h + 1){
		if(i == 0) dp[i] = 0;
		else{
			dp[i] = infty;
			foreach(j; 0 .. n){
				if(i <= as[j]) dp[i].chmin(bs[j]);
				else dp[i].chmin(dp[i - as[j]] + bs[j]);
			}
		}
	}

	dp[h].writeln;	

}

Measured memory_bytes: 2428
#include<cstdio>

int main()
{
  int n, m, c;
  int a[20], b[20];
  scanf("%d%d%d", &n, &m, &c);
  for (int i=0; i<m; i++) {
  	scanf("%d", &b[i]);
  }
  int ans = 0;
  for (int i=0; i<n; i++) {
    int s = c;
    for (int j=0; j<m; j++) {
      scanf("%d", &a[j]);
      s += a[j] * b[j];
    }
    if (s > 0) {
    	ans++;
    }
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 128
n=int(input())
csf = [list(map(int,input().split())) for i in range(n-1)]
ans1=[]
for j in range(n-1):
  requ_time=csf[j][1]+csf[j][0]
  for i in range(j,n-1):
    if i!=j:
      if requ_time <= csf[i][1]:
        requ_time+=(csf[i][0]+(csf[i][1]-requ_time))
  #elif requ_time > csf[i][1] and csf[i][0]+csf[1] > requ_time:
      else:
        requ_time+=(csf[i][0]+(csf[i][2]-(requ_time-csf[i][1])%csf[i][2])%csf[i][2])
  ans1.append(requ_time)
for i in ans1:
  print(i)
print(0)
  

Measured memory_bytes: 9228
import collections
n = int(input())
l = []
for i in range(n):
    s = str(input())
    l.append(s)

l = collections.Counter(l)
x = max(l.values())
t = [kv[0] for kv in l.items() if kv[1] == x]
t.sort()

for i in range(len(t)):
    print(t[i])

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

bool path[10][10] = {};

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> v(N);
  rep(i,N){
    v[i] = i;
  }
  //無効グラフの作成
  rep(i,M){
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    path[a][b] = true;
    path[b][a] = true;
  }
  //N!全探索
  int res = 0;
  do{
    if(v[0] != 0) break;
    bool flag = true;
    rep(i,N-1){
      if(!path[v[i]][v[i+1]]) flag = false;
    }
    if(flag) res++;
  }while(next_permutation(v.begin(),v.end()));
  cout << res << endl;
}

Measured memory_bytes: 256
module Main where

import Control.Applicative
import Control.Monad
import Data.List

f k ms = foldr g 1 ms
  where
    g 'a' acc = acc * 2
    g 'b' acc = acc + k

main :: IO ()
main = do
    n <- readLn
    k <- readLn
    let ps = sequence $ replicate n "ab"
    let ans = minimum $ fmap (f k) ps
    print ans

Measured memory_bytes: 1020
def main():
    n, k, c = map(int, input().split())
    s = input()

    def f(r):
        interval = 0
        count = k
        for i in r:
            if count == 0:
                break
            if interval > 0:
                interval -= 1
                continue
            if s[i] == 'o':
                yield i
                count -= 1 
                interval = c

    for i, j in zip(f(range(0, n)), reversed(list(f(range(n-1, -1, -1))))):
        if i == j:
            yield str(i+1)


print("\n".join(main()))

Measured memory_bytes: 24048
#include<cstdio>
int main(void){int n,m,A[100][100],b,c[100]={0},i,j;for(scanf("%d%d",&m,&n),i=0;i<m;++i){for(j=0;j<n;++j){scanf("%d",&A[i][j]);}}for(i=0;i<n;++i){scanf("%d",&b);for(j=0;j<m;++j){c[j]+=A[j][i]*b;}}for(i=0;i<m;++i){printf("%d\n",c[i]);}return(0);}


Measured memory_bytes: 2720
#include<bits/stdc++.h>
using namespace std;
string s="CODEFESTIVAL2016";
string a;
int ans;
int main()
{
    cin>>a;
    if(a[0] != 'C') ans++;
    if(a[1] != 'O') ans++;
    if(a[2] != 'D') ans++;
    if(a[3] != 'E') ans++;
    if(a[4] != 'F') ans++;
    if(a[5] != 'E') ans++;
    if(a[6] != 'S') ans++;
    if(a[7] != 'T') ans++;
    if(a[8] != 'I') ans++;
    if(a[9] != 'V') ans++;
    if(a[10] != 'A') ans++;
    if(a[11] != 'L') ans++;
    if(a[12] != '2') ans++;
    if(a[13] != '0') ans++;
    if(a[14] != '1') ans++;
    if(a[15] != '6') ans++;
    cout<<ans<<endl;
}

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

const int MOD = 1000000007;
struct mint
{
    int64_t x;
    mint(int64_t x = 0) : x((x % MOD + MOD) % MOD) {}
    mint operator-() const { return mint(-x); }
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= MOD)
            x -= MOD;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += MOD - a.x) >= MOD)
            x -= MOD;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(int64_t n) const
    {
        if (n == 0)
            return 1;
        mint t = pow(n >> 1);
        t *= t;
        if (n & 1)
            t *= *this;
        return t;
    }
    mint inv() const { return pow(MOD - 2); }
    mint &operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};

vector<mint> fac;
vector<mint> fac_inv;
vector<mint> inv;
void init_comb(int mx)
{
    fac = vector<mint>(mx + 1), fac_inv = vector<mint>(mx + 1), inv = vector<mint>(mx + 1);
    fac.at(0) = fac.at(1) = 1;
    fac_inv.at(0) = fac_inv.at(1) = 1;
    inv.at(1) = 1;
    for (int i = 2; i <= mx; i++)
    {
        fac.at(i) = fac.at(i - 1) * i;
        inv.at(i) = -inv.at(MOD % i) * (MOD / i);
        fac_inv.at(i) = fac_inv.at(i - 1) * inv.at(i);
    }
}
mint comb(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac.at(n) * fac_inv.at(k) * fac_inv.at(n - k);
}

void solve(int X, int Y)
{
    if ((X + Y) % 3 != 0)
    {
        cout << 0 << endl;
        return;
    }
    if (X < (X + Y) / 3 || Y < (X + Y) / 3)
    {
        cout << 0 << endl;
        return;
    }
    int n = (X + Y) / 3, k = Y - (X + Y) / 3;
    init_comb(n);
    cout << comb(n, k).x << endl;
}

int main()
{
    int X;
    cin >> X;
    int Y;
    cin >> Y;
    solve(X, Y);
    return 0;
}


Measured memory_bytes: 15872
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long a = sc.nextLong();
    long b = sc.nextLong();
    long p = gcd(a, b);
    System.out.println(p * (a / p) * (b / p));
  }

  public static long gcd(long x, long y) {
    if(y == 0) return x;
    return gcd(y, (x % y));
  }
}

Measured memory_bytes: 22996
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;

namespace CP
{
    class Atria
    {
        static void Main(string[] args)
        {
            int[] nk = ReadLine().Split(' ').Select(int.Parse).ToArray();
            int n = nk[0];
            int k = nk[1];
            var s = ReadLine().Split(' ').Select(int.Parse).Select(y => ExpectedValue(y)).ToList();

            var ls = new List<double>();
            ls.Add(0);
            for (int i = 0; i < s.Count; i++)
            {
                ls.Add(ls[i] + s[i]);
            }
            double ans = 0;
            for (int i = 0; i < ls.Count-k; i++)
            {
                ans = Max(ans, ls[k+i] - ls[i]);
            }
            WriteLine(ans);
        }

        static double ExpectedValue(int x)
        {
            double ans = 0;
            for (double i = 1; i <= x; i++)
            {
                ans += i / x;
            }
            return ans;
        }
    }
}


Measured memory_bytes: 35548
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


vll ls;
void calc(vint num) {
    ll res = 0;
    for (int x : num) {
        res *= 10;
        res += x;
        if (res > 1e9) return;
    }
    ls.push_back(res);
}

void dfs(vint num, int add) {
    num.push_back(add);
    if (num.size()>10) return;
    calc(num);
    dfs(num, 3);
    dfs(num, 5);
    dfs(num, 7);
}

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

    vint e;
    dfs(e, 3);
    dfs(e, 5);
    dfs(e, 7);

    int ans = 0;
    for (ll x : ls) {
        if (x>n) continue;
        bool s = false, f = false, t = false;
        while (x) {
            if (x%10 == 7) s = true;
            if (x%10 == 5) f = true;
            if (x%10 == 3) t = true;
            x /= 10;
        }
        if (s&f&t) ans++;
    }

    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int, int> ii;

#define repa(i, a, b) for (auto i = (a); i <= (b); i++)
#define repd(i, a, b) for (auto i = (a); i >= (b); i--)
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define zero(a)  memset((a), 0, sizeof (a))
#define sz(x) (int)(x).size()
#define debug(x) cout << (x) << "\n";
#define mp make_pair
#define pb push_back

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int a, b, c;
	cin >> a >> b >> c;
	printf("%d %d %d\n", c, a, b);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define sci(a) scanf("%d", &a)
#define fto(i, a, b) for (int i = a; i <= b; ++i)
#define fdto(i, a, b) for (int i = a; i >= b; --i)
#define scii(a, b) scanf("%d %d", &a, &b)
#define ll long long
#define ff first
#define ss second
#define vi vector<int>
#define pi pair<int, int>
#define maxN 100005
#define oo 1000000007
#define mp make_pair
#define pb push_back
#define bug(a) cout << #a << "= " << a << endl;
#define bugarr(a, x, y) cout << #a << "[" << x << ", " << y << "]= "; for (int i = x; i <= y; ++i) cout << a[i] << ", "; cout << endl;
#define sz(a) (int)a.size()
#define vii vector<pi>
#define db double
#define forit(var, it) for(__typeof(var.begin()) it = var.begin(); it != var.end(); ++it)

using namespace std;

int n, m, a[1005], b[1005], c[1005], f[maxN];

int main() {
    //#ifndef ONLINE_JUDGE
     //   freopen("GetEverything.inp", "r", stdin);
      //  freopen("GetEverything.out", "w", stdout);
   // #endif // ONLINE_JUDGE

    scii(n, m);
    fto(i, 1, m) {
        scii(a[i], b[i]);
        fto(j, 1, b[i]) {
            int x; sci(x); x-=1;
            c[i] += (1 << x);
        }
        //cout << c[i] << "\n";
    }
    int doangioi = (1 << (n));
    fto(i, 0, doangioi) f[i] = -1;
   // cout << doangioi << "\n";
    f[0] = 0;
    fto(i, 1, m) {
        fto(j, 0, doangioi) {
            if (f[j] != -1) {
                int y = j | c[i];
                if (y != j) {
                    if (f[y] == -1) f[y] = f[j] + a[i];
                    else f[y] = min(f[y], f[j] + a[i]);
                }
            }
        }
    }
    printf("%d\n", f[doangioi-1]);

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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

using ll = long long;

ll N;
ll A, B;
ll P[110];
ll cnt1, cnt2, cnt3;

int main()
{
  std::cin >> N >> A >> B;
  rep( i, N )
    std::cin >> P[i];

  rep( i, N )
  {
    if( P[i] <= A )
      ++cnt1;
    else if( P[i] <= B )
      ++cnt2;
    else
      ++cnt3;
  }

  std::cout << std::min( cnt1, std::min( cnt2, cnt3 )) << std::endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N, X, Y; cin >> N >> X >> Y;
    X--; Y--;

    vec ans(N);
    REP(i, N) REP(j, i){
        int d = llabs(i - j);
        Min(d, llabs(i - X) + llabs(j - Y) + 1);
        Min(d, llabs(i - Y) + llabs(j - X) + 1);
        ans[d]++;
    }
    FOR(i, 1, N) Out(ans[i]);

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e5+5;
int a,b,n,m,ans=-1;
ll dp[N];
int main()
{
	cin>>n>>m;
	for(int i=0;i<N;i++)dp[i]=100000000000000;
	dp[0]=0;
	while(n--)
	{
		cin>>a>>b;
		for(int j=1e5;j>=b;j--)
		{
			if(dp[j-b]+a>m)continue;
			dp[j]=min(dp[j],dp[j-b]+a);
			ans=max(ans,j);
		}
	}
	cout<<ans;
	return 0;
}
/*
3 8
3 30
4 50
5 60
*/

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
#include <stack>
#include <iomanip>
#include <map>
#include <math.h>
#include <list>
#include <deque>
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int MOD = 1000000007;
const ll INF = 1LL << 60;

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll LCM(ll a, ll b) {return a / GCD(a, b) * b;}


int main()
{
	int A,B;
	cin >> A >> B;
	cout << A * B << endl;
}


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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1000000007;

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	priority_queue<int> que;
	int n,m;
	int sum = 0;
	int a;
	cin >> n >> m;
	rep(i,n){
		cin >> a;
		que.push(a);
		sum += a;
	}
	while(true){
		if(m == 0){
			break;
		}
		int x = que.top();
		sum -= (x + 2 - 1) / 2;
		x /= 2;
		que.pop();
		que.push(x);
		--m;
	}
	cout << sum << '\n';
	return 0;
}



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

#define ll long long
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define x first
#define y second

int main(){
	
	long double a,b;
	cin>>a>>b;
	ll res=a*b;
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 3732
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <bitset>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
#define MODn 1000000009;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  string S;
  std::cin >> S;
  int muki[4]={0, 0, 0, 0};
  range(i, S.size()){
    switch(S[i]){
      case 'N':muki[0]=1;
               continue;
      case 'E':muki[1]=1;
               continue;
      case 'S':muki[2]=1;
               continue;
      case 'W':muki[3]=1;
    }
  }
  std::cout << (muki[0]==muki[2]&&muki[1]==muki[3]?"Yes":"No") << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, ll> Pl;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int mod = 1e+9 + 7;
const int INF = 1e+9;

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

    int m1, d1, m2, d2;
    cin >> m1 >> d1 >> m2 >> d2;
    if(m1 == m2){
        cout << 0 << endl;
    }
    else{
        if(d2 == 1){
            cout << 1 << endl;
        }
        else{
            cout << 0 << endl;
        }
    }
}

Measured memory_bytes: 256
import itertools

n = int(input())
l = list(map(int, input().split()))

c = list(itertools.combinations(l, 3))
ans = 0
for i in c:
    j = sorted(i)
    if j[0] != j[1] != j[2] != j[0]:
        if j[2] < j[0]+j[1]:
            ans += 1
print(ans)

Measured memory_bytes: 20536
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int i = 1;
    while (true) {
      int x = scanner.nextInt();
      if (x == 0) break;
      System.out.println("Case " + i + ": " + x);
      i += 1;
    }
  }
}

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

int main(){
  int N, AC = 0, WA = 0, TLE = 0, RE = 0;
  string tmp;
  cin >> N;
  
  for(int i = 0; i < N; i++){
    cin >> tmp;
    if(tmp == "AC") AC++;
    else if(tmp == "WA") WA++;
    else if(tmp == "TLE") TLE++;
    else if(tmp == "RE") RE++;
  }
  
  cout << "AC x " << AC << endl
       	<< "WA x " << WA << endl
    	<< "TLE x " << TLE << endl
    	<< "RE x " << RE << endl;
    
  return 0;
}
    

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

using pii = pair<int, int>;
using ppii = pair<int, pii>;

pii x[100010], y[100010];

// 頂点
vector<ppii> edges;

// 素集合データ構造
struct UnionFind {
  // par[i]：データiが属する木の親の番号。i ==
  // par[i]のとき、データiは木の根ノードである
  vector<int> par;
  // sizes[i]：根ノードiの木に含まれるデータの数。iが根ノードでない場合は無意味な値となる
  vector<int> sizes;

  UnionFind(int n) : par(n), sizes(n, 1) {
    // 最初は全てのデータiがグループiに存在するものとして初期化
    for (int i = 0; i < n; i++) par[i] = i;
  }

  // データxが属する木の根を得る
  int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);  // 根を張り替えながら再帰的に根ノードを探す
  }

  // 2つのデータx, yが属する木をマージする
  void unite(int x, int y) {
    // データの根ノードを得る
    x = find(x);
    y = find(y);

    // 既に同じ木に属しているならマージしない
    if (x == y) return;

    // xの木がyの木より大きくなるようにする
    if (sizes[x] < sizes[y]) swap(x, y);

    // xがyの親になるように連結する
    par[y] = x;
    sizes[x] += sizes[y];
    // sizes[y] = 0;  // sizes[y]は無意味な値となるので0を入れておいてもよい
  }

  // 2つのデータx, yが属する木が同じならtrueを返す
  bool same(int x, int y) { return find(x) == find(y); }

  // データxが含まれる木の大きさを返す
  int size(int x) { return sizes[find(x)]; }
};

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

  for (int i = 0; i < n; i++) {
    cin >> x[i].first >> y[i].first;
    x[i].second = y[i].second = i;
  }

  sort(x, x + n);
  sort(y, y + n);

  for (int i = 0; i < n - 1; i++) {
    edges.push_back(ppii(abs(x[i].first - x[i + 1].first),
                         pii(x[i].second, x[i + 1].second)));
  }

  for (int i = 0; i < n - 1; i++) {
    edges.push_back(ppii(abs(y[i].first - y[i + 1].first),
                         pii(y[i].second, y[i + 1].second)));
  }

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

  long long res = 0;

  UnionFind uf(n);

  for (int i = 0; i < edges.size(); i++) {
    ppii t = edges[i];

    if (!uf.same(t.second.first, t.second.second)) {
      uf.unite(t.second.first, t.second.second);
      res += t.first;
    }
  }

  cout << res << endl;
}


Measured memory_bytes: 6388
#include <cstdio>
using std::scanf;
using std::printf;

const int kNil = -1;

struct Node { int parent, left, right; };

void SetDepth(struct Node tree[], int cur_node, int cur_depth, int depth[]) {
  depth[cur_node] = cur_depth;
  if (tree[cur_node].left != kNil) {
    SetDepth(tree, tree[cur_node].left, cur_depth + 1, depth);
  }
  if (tree[cur_node].right != kNil) {
    SetDepth(tree, tree[cur_node].right, cur_depth, depth);
  }
}

int main() {
  int n;
  scanf("%d", &n);

  // ??¨?????\???
  struct Node tree[n];
  for (int i = 0; i < n; ++i) {
    tree[i].parent = kNil;
    tree[i].left = kNil;
    tree[i].right = kNil;
  }
  for (int i = 0; i < n; ++i) {
    int id;
    scanf("%d", &id);

    int k;
    scanf("%d", &k);
    if (k == 0) {}
    if (k == 1) {
      int c;
      scanf("%d", &c);
      tree[id].left = c;
      tree[c].parent = id;
    }
    if (k >= 2) {
      int c1, c2;
      scanf("%d", &c1);
      tree[id].left = c1;
      tree[c1].parent = id;
      for (int j = 0; j < k - 1; ++j) {
        scanf("%d", &c2);
        tree[c1].right = c2;
        tree[c2].parent = id;
        c1 = c2;
      }
    }
  }

  // ??±????????????
  int root;
  for (int i = 0; i < n; ++i) {
    if (tree[i].parent == kNil) {
      root = i;
      break;
    }
  }
  int depth[n];
  SetDepth(tree, root, 0, depth);

  //?????????
  for (int i = 0; i < n; ++i) {
    int parent = tree[i].parent;
    int child = tree[i].left;

    printf("node %d: parent = %d, depth = %d, ", i, parent, depth[i]);

    if (parent == kNil) {
      printf("root, ");
    } else if (child == kNil) {
      printf("leaf, ");
    } else {
      printf("internal node, ");
    }

    // ??????????????????????????????
    printf("[");
    if (child != kNil) {
      printf("%d", child);
      while (tree[child].right != kNil) {
        child = tree[child].right;
        printf(", %d", child);
      }
    }
    printf("]\n");
  }

  return 0;
}

Measured memory_bytes: 4244
// C - management
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(int)(n); i++)
using namespace std;
using ll = long long;
using ull = unsigned long long;

int main(){
    int n;
    cin >> n;
    vector<int> a(n-1);
    vector<int> b(n, 0);
    rep(i, n-1){
        cin >> a[i];
        b[a[i]-1]++;
    }
    rep(i, n) cout << b[i] << endl;
    return 0;
}

Measured memory_bytes: 4788
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B, cost= 0;
  cin >> A >> B;
  if (A <= 5) {
     cost = 0;
  }
  else if (A <13) {
    cost =  B / 2;
  }
  else {
    cost = B;
  }
  cout << cost << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,b,c,k,count=0;
    cin>>a>>b>>c>>k;
    if(k<=a) cout<<k<<endl;
    else{
            count=a;
        k=k-a;
        k=k-b;
        if(k<=0) cout<<count<<endl;
        else{
            count+=(-1*k);
            cout<<count<<endl;
        }

    }
}


Measured memory_bytes: 3584
#include <iostream>
#include <map>

using namespace std;

int main() {
    int r = 0, n;
    cin >> n;
    map<int, int> m;
    for (int i = 0; i < n; ++i) {
        int a;
        scanf("%d", &a);
        r ^= a;
        int u = __builtin_ffs(a);
        if(!m[u-1]) m[u-1]=a;
    }
    int x = 1 << 30, ans = 0;
    for (int p = 30; p >= 0; --p) {
        if(r & x){
            if(!m[p]) {
                puts("-1");
                return 0;
            }else {
                r ^= m[p];
                r ^= (m[p]-1);
                ans++;
            }
        }
        x /= 2;
    }
    cout << ans << "\n";
    return 0;
}


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

using namespace std;
 
double degToRad(int deg) {
  return deg * M_PI / 180;
}
 
int main(void) {
  double x = 0.0, y = 0.0;
  int deg = 90;
 
  while(1) {
    int l, d;
    scanf("%d,%d", &l, &d);
    if(l == 0 && d == 0) break;
 
    x += l*cos(degToRad(deg));
    y += l*sin(degToRad(deg));
 
    deg -= d;
  }
 
  cout << (int)x << endl;
  cout << (int)y << endl;
 
  return 0;
}

Measured memory_bytes: 1212