akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner scanner = new Scanner(System.in);
		
		String n = "1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51";
		
		String[] in = n.split(",");
		
		int p = scanner.nextInt();

		System.out.println(in[p - 1]);
		
		scanner.close();
	}

}


Measured memory_bytes: 21844
N, M = gets.chomp.split(" ").map(&:to_i);
L = []
R = []
M.times{|i|
  l, r = gets.chomp.split(" ").map(&:to_i);
  L << l
  R << r
}

c = R.min - L.max + 1
c = 0 if c < 0

puts c


Measured memory_bytes: 3460
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <iomanip>
#include <bitset>
#include <unordered_map>
#include <stack>
#include <memory.h>
#include <list>
#include <numeric>
#include <functional>
#include <complex>
#include <cassert>
#include <regex>
#include <random>

#define ll long long
#define ld long double
#define ull unsigned ll
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pii pair<int,int> 
#define vi vector<int>
#define vpii vector<pii>
#define vvi vector<vector<int>>
#define forn(it,from,to) for(int (it)=from; (it)<to; (it)++)
const int  Inf = 2 * 1000 * 1000 * 1000;
ll LINF = (ll)4e18;
using namespace std;
#define M_PI       3.14159265358979323846   // pi


int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	//freopen("sum.in", "r", stdin);
	//freopen("sum.out", "w", stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	vector<int>a(5);
	for (auto &x : a) cin >> x;
	sort(all(a));

	int k;
	cin >> k;

	for (int i = 0; i < 5; i++) {
		for (int j = i + 1; j < 5; j++) {
			if (a[j] - a[i] > k) {
				cout << ":(";
				return 0;
			}
		}
	}
	cout << "Yay!";
 	return 0;
}

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

using namespace std;

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

const int N = 2e5 + 5;

char s[N];
int n,cnt,ans;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  cin >> (s + 1);
  n = strlen(s + 1);
  for (int i = 1 ; i <= n ; i++) {
    if (s[i] == 'S')
      cnt++;
    else if (s[i] == 'T' && cnt) {
      cnt--;
      ans++;
    }
  }
  cout << n - ans * 2 << endl;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"

using namespace std;

const char en = '\n';
using  ll =          long long;
using ull = unsigned long long;
#define REP(i  ,n) for(int i=0;i<n;i++)
#define FOR(i,s,g) for(int i=s;i<g;i++)
const ll INFL = 810810191911451400;
const int INF =       1919114514;

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

	int sum=0,buf,MIN=INF;
	REP(i, 4){
		cin>>buf;
		sum+=buf;
		MIN=min(buf,MIN);
	}
	sum-=MIN;

	cin>>buf>>MIN;

	sum+=max(buf,MIN);

	cout<<sum<<en;
	return 0;
}

Measured memory_bytes: 3224
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+5;
int l[N],r[N],a[N];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=1;i<=n;i++)
        l[i]=max(l[i-1],a[i]);
    for(int i=n;i>=1;i--)
        r[i]=max(r[i+1],a[i]);
    for(int i=1;i<=n;i++)
    {
        if(i==1) printf("%d\n",r[2]);
        else if(i==n) printf("%d\n",l[n-1]);
        else printf("%d\n",max(l[i-1],r[i+1]));
    }
}


Measured memory_bytes: 10624
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <list>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;
vector<vector<edge>> g;
vector<int> ans;

void dfs(int v, int p, int c) {
    ans[v] = c;
    for (auto e: g[v]) {
        if (e.u == p) continue;
        if (e.w % 2 == 1) dfs(e.u, v, 1 - c);
        else dfs(e.u, v, c);
    }
}

int main() {
    int n; cin >> n;
    g.assign(n, vector<edge>());
    REP(i, n - 1) {
        int u, v, w; cin >> u >> v >> w;
        u--; v--;
        g[u].push_back(edge{v, u, w});
        g[v].push_back(edge{u, v, w});
    }
    ans.assign(n, 0);
    dfs(0, -1, 0);
    for (auto e: ans) cout << e << endl;
}


Measured memory_bytes: 10496
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC

const int N = 1007;
bool ans[N][N];
int want[N];
bool comp(int i, int j) {
    return want[i] > want[j];
}   
void print(int n, int m, int a, int b, int x, int y) {
    vector <int> per;
    for (int i = 0; i < m; ++i)
        per.app(i);

    for (int i = 0; i < y; ++i)
        want[i] = b;
    for (int i = y; i < m; ++i)
        want[i] = n - b;

    for (int i = 0; i < n; ++i) {
        sort(all(per), comp);
        
        int add;
        if (i < x)
            add = a;
        else
            add = m - a;

        for (int j = 0; j < add; ++j) {
            ans[i][per[j]] = 1;
            --want[per[j]];
        }
    }   

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

signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    int n, m, a, b;
    cin >> n >> m >> a >> b;
    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j <= m; ++j) {
            int k1 = i * a + (n - i) * (m - a);
            int k2 = j * b + (m - j) * (n - b);
            if (k1 == k2) {
                print(n, m, a, b, i, j);
            }   
        }   
    }   
    exit(1);
}

Measured memory_bytes: 2304
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<algorithm>
#include<cstring>

using namespace std;


int main() {
	int n;
	cin >> n;
	int prev = 0;
	int now = 0;
	bool NG = false;
	long long ret = 0;
	for (int i = 0; i < n; i++) {
		prev = now;
		cin >> now;
		if(now > i ||now - prev > 1) { NG = true; }
		else if (now - prev <= 0) {
			ret += prev;
		}
	}
	ret += now;
	if (NG) ret = -1;
	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 384
#include <vector>
#include <iostream>
using namespace std;
int main() {
	long long N;
	cin >> N;
	vector<long long> d;
	for (int i = 1; 1LL * i * i <= N; ++i) {
		if (N % i == 0) {
			d.push_back(i);
			if (1LL * i * i != N) d.push_back(N / i);
		}
	}
	long long ans = 0;
	for (long long i : d) {
		long long x = i - 1;
		if (x > 0 && N / x == N % x) {
			ans += x;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
//============================================================================
//Everyone has a different way of thinking, so God Created us
//   Hope You Respect My Way..,Thank You ):
// Author      : Murad
// Name        : Codeforces.cpp & Atcoder.cpp
// Description : Problem name
//============================================================================
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
using namespace std;
#define pi 3.1415926536
#define forn(i,a,b)for(int i=a;i<b;i++)
#define LL long long
#define ULL unsigned long long
#define MP make_pair
#define ff first
#define ss second
#define endl '\n'
#define INF 1e9 + 1
#define _INF INT32_MIN
#define PQ priority_queue
#define MM multimap
#define PB push_back
#define vii vector<int>
#define ipair pair<int,int>
#define lpair pair<LL,LL>
#define MAXN 100004
#define El3zba ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define modd 1000000007
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
//std::transform(s1.begin(), s1.end(), s1.begin(),::tolower);
char alphz[27] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };
float Euclidean(LL x1, LL x2, LL y1, LL y2) {
	return sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
}
LL gcd(LL a,LL b) {
	return !b ? a : gcd(b, a % b);
}
LL LCM(LL a, LL b) {
	return (a*b) / gcd(a, b);
}
void PrimeFactor(LL n)
{
	while (n % 2 == 0) {
		printf("%d ", 2);
		//aa.insert(2);
		n /= 2;
	}
	for (int i = 3; i <= sqrt(n); i += 2)
	{
		if (n%i == 0) {
			printf("%d ", i);
	//		aa.insert(i);
			n /= i;
		}
	}
	if (n > 2){
		printf("%d ", n);
		//aa.insert(n);
	};
}
bool is_square(LL x) {
	LL l = 0, r = x;
	while (l <= r) {
		LL mid = l + (r - l) / 2;
		if (mid*mid == x)return true;
		if (mid*mid > x)r = mid - 1;
		else l = mid + 1;
	}
	return false;
}
LL power(LL x, LL y)
{
	LL temp;
	if (y == 0)return 1;
	temp = power(x, y / 2);
	if (y % 2 == 0)
		return temp*temp;
	else return x*temp*temp;
}
bool is_Prime(int x) {
	if (x == 2)return 1;
	else if (x % 2 == 0 || x < 2)return 0;
	for (int i = 3; i*i <= x; i += 2)
		if (x%i == 0)return 0;
	return 1;
}
int main()
{
	El3zba;
	/***  بسم الله الرحمن الرحيم   ***/
	LL a, b;
	scanf("%lld%lld", &a, &b);
	LL ans = gcd(a, b);
	int cnt = 1;
	set<LL> set;
	for (LL i = 2; i * i <= ans; ++i) {
		while (ans % i == 0) {
			if (set.find(i) == set.end())
				++cnt;
			set.insert(i);
			ans /= i;
		}
	}
	if (ans != 1)
		cnt++;
	cout <<cnt<< endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int c[100000];
vector <pair<int, int> > v[100000];

int dfs(int x, int y) {
    int i;
    
    c[x] = 1;
    
    for (i = 0; i < v[x].size(); i++) {
        if (v[x][i].first == y) continue;
        
        c[x] += dfs(v[x][i].first, x);
    }
    
    return c[x];
}

pair<long long, long long> dfs2(int x, int y) {
    int i;
    long long sum = 0, c = 1;
    
    for (i = 0; i < v[x].size(); i++) {
        pair<long long, long long> p;
        
        if (v[x][i].first == y) continue;
        
        p = dfs2(v[x][i].first, x);
        
        c += p.second;
        sum += p.first + p.second * v[x][i].second;
    }
    
    return make_pair(sum, c);
}

long long calc(int x) {
    int m = 1e9, i;
    long long ans = dfs2(x, -1).first * 2;
    
    for (i = 0; i < v[x].size(); i++) m = min(m, v[x][i].second);
    
    return ans - m;
}

long long calc2(int x, int y) {
    int i;
    long long ans = dfs2(x, -1).first * 2;
    
    for (i = 0; i < v[x].size(); i++) {
        if (v[x][i].first == y) ans -= v[x][i].second;
    }
    
    return ans;
}

int main() {
    int n, p = 0, q = -1, i;
    long long ans = 0;
    
    scanf("%d", &n);
    
    for (i = 0; i < n - 1; i++) {
        int x, y, z;
        
        scanf("%d %d %d", &x, &y, &z);
        
        x--;
        y--;
        
        v[x].push_back(make_pair(y, z));
        v[y].push_back(make_pair(x, z));
    }
    
    dfs(0, -1);
    
    while (1) {
        int f = 0;
        
        for (i = 0; i < v[p].size(); i++) {
            int x = v[p][i].first;
            
            if (x == q) continue;
            
            if (c[x] > n / 2) {
                q = p;
                p = x;
                f = 1;
                
                break;
            }
        }
        
        if (f == 0) break;
    }
    
    ans = calc(p);
    
    if (n % 2 == 0) {
        for (i = 0; i < v[p].size(); i++) {
            if (v[p][i].first == q) continue;
            
            if (c[v[p][i].first] == n / 2) ans = calc2(v[p][i].first, p);
        }
    }
    
    printf("%lld\n", ans);
    
    return 0;
}


Measured memory_bytes: 11392
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main(void)
{
  int n;
  cin >> n;
  
  vector<long int> a(n);
  

  for(int i = 0; i < n;i++)
  {
    cin >> a[i];
  }
  
  sort(a.begin(), a.end());
  
  int difference_count = 0;
  
  for(int i = 0; i < n; i++)
  {
    if(a[i] == a[i+1])
    {
      difference_count++;
      break;
    }
  }
  
  if(difference_count > 0)
  {
    cout << "NO";
  }
  else
  {
    cout << "YES";
  }
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
typedef long long int lint;
using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    sort(all(h));
    int ans = 1e+9 + 1;
    // i~i+k-1を飾ると思う
    for (int i = 0; i < n - k + 1; i++) {
        ans = min(ans, h[i + k - 1] - h[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    ll a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    ll ans = INF;
    for(ll i = 0; i <= 2 * max(x, y); i += 2){
        ll costab = c * i;
        ll resta = max(0LL, x - (i / 2));
        ll restb = max(0LL, y - (i / 2));
        ll restcost = resta * a + restb * b;
        ans = min(ans, costab + restcost);
    }
    cout << ans << endl;

}   

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repr(i,a,n) for(int i=a;i>n;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  string s;
  cin >> s;
  sort(ALL(s));
  if (s=="abc") cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
r=0...gets.to_i
x,y=$<.map{|l|l.split.map &:to_i}
c=r.map{|i|(x[i]-y[i]).abs}
(1..3).map{|p|puts"%f"%c.map{|v|v**p}.reduce(:+)**(1.0/p)}
p c.max.to_f

Measured memory_bytes: 6192
#include<stdio.h>
int main(void){
    int a[10]={};
    int b,c=0,d=0,e=0,f=0,g=0;
    for(b=0;b<10;b++){
    scanf("%d",&a[b]);
        if(c<a[b]){
            c=a[b];
            d=b;
        }
    }
    for(b=0;b<10;b++){
        if(e<a[b]){
            if(b==d)continue;
        e = a[b];
        f = b;
    }
    }
    for(b=0;b<10;b++){
        if(g<a[b]){
            if(b==d||b==f)continue;
        g = a[b]; 
        }
    }
    printf("%d\n",c);
    printf("%d\n",e);
    printf("%d\n",g);

 return 0;
}

Measured memory_bytes: 1768
// Aizu 2824: Coastline
// 2017.9.23 bal4u@uu

#include <stdio.h>

int a[100000], size;

int main()
{
	int t, d, l;
	int x, i, ans;

	while (scanf("%d%d%d", &t, &d, &l) && t > 0) {
		size = 0;
		for (i = 0; i < t; i++) {
			scanf("%d", &x);
			if (x >= l) a[size++] = i;
		}
		t--, ans = 0;
		for (i = 1; i < size; i++) {
			x = d;
			if (a[i-1] + d > t) x = t - a[i-1];
			if (a[i] < a[i-1] + x) ans += a[i] - a[i-1];
			else ans += x;
		}
		if (size > 0) {
			ans += (a[size-1] + d > t) ? t - a[size-1] : d;
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 2164
/* بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ */
//codeforces
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FASTIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define mp make_pair
#define pb push_back
#define sz(v) ((int)v.size())
#define all(v) v.begin(), v.end()
void parseArray(ll* A,ll n){ for ( ll K = 0; K < n; K++){ cin >> A[K]; } }
ll modInverse(ll a, ll b){ return 1<a ? b - modInverse(b%a, a)*b/a : 1; }
ll gcd(ll a, ll b){ return b?gcd(b, a % b):a; }
ll lcm(ll a, ll b){ return (a*b)/gcd(a, b); }
ld dist(ld x, ld y, ld a, ld b){ return sqrt((x-a)*(x-a) + (y-b)*(y-b)); }
void debug(ll* a, ll n) { for ( ll k = 0; k < n; k++ ){ cerr << a[k] << " ";} cout << "\n"; }
#define PI 3.14159265358979323846


int main(){
	FASTIO;
	ld n; cin >> n;
	cout << 2 * PI * n << endl;
	return 0;
}

Measured memory_bytes: 3868
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define INF (1<<29)
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
  long long x,y;
  cin >> x >> y;
  int res = 0;
  while(x <= y){
      x *= 2;
      res++;
  }

  cout << res << endl;
}

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

int main(){
   int n,m;
   int counter=0;
   int sum = 0;
   
   while(1) {
    
    cin >> n >> m;
    if (n == 0 && m ==0) break; 
    for (int i = 1; i <= n -2; i++) {
       for (int j = i+1; j <= n -1;j++) {
           for (int k = j+1; k <= n; k++) {
               sum = i + j + k;
               
               if(sum == m) counter += 1;
           }
       }
        }
     cout << counter << endl;
     counter = 0;            
   }
   
   
   
    return 0;
}

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

// この解放はきれいすぎて、本番で思いつけそうにないので、
// 桁DP + 二分探索の組合わせで腕力使って解けるようになりたい。

int main() {
    vector<long long> LnLnList;
    int K;
    cin >> K;
    queue<long long> que;
    for(int i = 1; i < 10; ++i){
        que.push((long long)i);
    }
    while(LnLnList.size() < K) {
        long long p = que.front(); que.pop();
        LnLnList.push_back(p);
        long long x = p%10;
        if(x > 0) que.push(10*p + x-1);
        que.push(10*p + x);
        if(x < 9) que.push(10*p + x+1);
    }
    /*
    for(int i = 0; i < K; ++i) {
        cout << LnLnList[i] << endl;
    }
    cout << endl;
    */
    //sort(LnLnList.begin(), LnLnList.end());
    cout << LnLnList[K-1] << endl;
    return 0;
}

Measured memory_bytes: 2548
n = int(input())
l = list(map(int,input().split()))
count1 = len([x for x in l if x%2 != 0])
count2 = len([x for x in l if (x%4 != 0) and (x%2 == 0)])
count4 = len([x for x in l if x%4 == 0])
print ("Yes") if (n - (count4*2) <= count2) or count4 >= n//2 else print ("No")


Measured memory_bytes: 14252
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

/*
 <url:https://cf17-relay-open.contest.atcoder.jp//tasks/relay2_b>
 問題文============================================================
 整数 N が与えられます。無限に伸びる完全 N 分木を考えます。
 
 各頂点には重複しない正の整数の番号が付いており、どの正の整数に対してもそれを頂点番号として持つ頂点が存在します。
 木の根の頂点番号は 1 です。その他の頂点には、上の段にある頂点ほど小さな番号が付けられています。
 同じ段にある頂点には、左に位置するほど小さな番号が付けられています。
 
 この木に関して、以下の形式の Q 個の問いに答えてください。i 番目の問い (1≤i≤Q) は次の通りです。
     頂点 vi と wi の最近共通祖先（注釈を参照）の頂点番号を求めよ。
 =================================================================
 解説=============================================================
 ================================================================
 */

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    ll N,Q; cin >> N >> Q;
    for(int i = 0; i < Q;i++){
        ll v,w; cin >> v >> w;
        if(N == 1 || v == 1 || w == 1){
            cout << min(v,w) << endl;
            continue;
        }
        if(v == w){
            cout << v << endl;
            continue;
        }
        ll add = N - 2;
        while(true){
            ll l = min(v,w), r= max(v,w);
            v = l; w = (r + add)/N;
            if(v == w){
                cout << v << endl;
                break;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 1280
#include <stdio.h>
 
#define H 250
 
int parent(int);
int left(int);
int right(int);
 
int main(){
 
 int i;
 int n;
 int p;
 int l;
 int r;
 int A[H];
 
 scanf("%d",&n);
 
 for(i=1;i<=n;i++){
 scanf("%d",&A[i]);
 }
 
 for(i=1;i<=n;i++){
 printf("node %d: key = %d, ",i,A[i]);
 
 p = parent(i);
 
 if(p!=0){
 printf("parent key = %d, ",A[p]);
 }
 
 l = left(i);
 
 if(l <= n){
 printf("left key = %d, ",A[l]);
 }
 
 r = right(i);
 
 if(r <= n){
 printf("right key = %d, ",A[r]);
 }
 
 printf("\n");
 }
 return 0;
}
 
int parent(int i){
 return i / 2;
}
 
int left(int i){
 return 2 * i;
}
 
int right(int i){
 return 2 * i + 1;
}

Measured memory_bytes: 600
#include<stdio.h>
#include<math.h>
int main(void) {
double a, b, C, s, S, L, h, c=0, PI = acos(-1.0), rad;
scanf("%lf %lf %lf", &a, &b, &C);
rad = C * (PI / 180);
c = sqrt((pow(a, 2) + pow(b, 2)) - 2.0 * a*b*cos(rad));
s = (a + b + c) / 2.0;
S = sqrt(s*(s-a)*(s-b)*(s-c));
h = S*2/a;
L = a + b + c;
printf("%f\n%f\n%f\n", S, L, h);
return 0;
}


Measured memory_bytes: 2104
N = int(input())
A = []
for i in range(N):
    a = int(input())
    for _ in range(a):
        x, y = map(int, input().split())
        A.append((i, x-1, y))

ans = 0
for i in range(2 ** N):
    for (j,x,y) in A:
        if i & 1 << j:
            if y == 1:
                if not i & (1 << x):
                    break
            else:
                if i & (1 << x):
                    break
    else:
        ans = max(ans, sum([1 for x in bin(i) if x == '1']))
print(ans)


Measured memory_bytes: 9204
l = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]

n = input()
for i in range(int(n)):
    b,f,r,v = input().split()
    l[int(b)-1][int(f)-1][int(r)-1] = l[int(b)-1][int(f)-1][int(r)-1] + int(v)

for b in range(4):
    for f in range(3):
        out = ""
        for r in range(10):
            out += " " + str(l[b][f][r])
        print(out)
    if 3 != b:
        print("####################")


Measured memory_bytes: 5608
n = list(map(int,input().split()))
price = []

# 場合分けしていくのは大変そうだった
for i in range(max(n[3], n[4]) + 1):
    temp = 2 * i * n[2]
    if n[3] - i > 0:
        temp += (n[3] - i) * n[0]
    if n[4] - i > 0:
        temp += (n[4] - i) * n[1]

    # 十分に大きい数値を最初用意して，2値を比較し小さい方を変数に入れる方がいいかも
    price.append(temp)

print(min(price))

Measured memory_bytes: 7096
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

int main() {
	int n, k;
	cin >> n >> k;
	map <int, int> m;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		m[x]++;
	}
	vector <int> v;
	for (auto g : m) {
		v.push_back(g.ss);
	}
	sort(all(v), greater<int>());
	int ans = 0;
	while((int) v.size() > k) {
		ans += v.back();
		v.pop_back();
	}
	cout << ans;
}


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

int main(){
    vector<int> ans(5);
    
    rep(i,5){
        cin >> ans[i];
    }
    
    rep(i,5){
        if(ans[i]==0){
            cout << i+1 << endl;
        }
    }
}


Measured memory_bytes: 3596
fn main() {
  let (n, x): (usize, i64) = read_tuple();
  let vec: Vec<i64> = read_vec();
  
  let mut buf = vec.clone();
  let mut tmin = i64::max_value();
  for k in 0 .. n {
    for i in 0 .. n {
      buf[i] = std::cmp::min(vec[(n+i-k)%n],buf[i]);
    }
    tmin = std::cmp::min(tmin, buf.iter().sum::<i64>() + k as i64 * x);
  }
  
  println!("{}", tmin);
}

fn read_tuple<T1: std::str::FromStr, T2: std::str::FromStr>() -> (T1, T2) {
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).ok();
  let mut it = buf.trim().split_whitespace();
  let x = it.next().unwrap().parse::<T1>().ok().unwrap();
  let y = it.next().unwrap().parse::<T2>().ok().unwrap();
  (x, y)
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).ok();
  buf.trim().split_whitespace().map(|t| t.parse::<T>().ok().unwrap()).collect()
}

Measured memory_bytes: 4352
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef vector<bool> vbool;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<llint> vllint;
typedef vector<vllint> vvllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;
#define Pi 3.1415926535897932384626
#define coutans rep(i, ans.size())cout << ans[i] << endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(int a, int b) {
	return a > b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= 1000000007;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, 1000000007);
		ans %= 1000000007;
	}
	return ans;
}

int main() {
	string s;
	vint table(26, 0);
	while (getline(cin, s)) {
		for (auto c : s) {
			if ('A' <= c && c <= 'Z') {
				c = c + 32;
			}
			if ('a' <= c && c <= 'z') {
				table[c - 'a']++;
			}
		}
	}
	rep(i, 26) {
		cout << (char)('a' + i) << " : " << table[i] << endl;
	}
	return 0;
}


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

int main() {
    int a, b, d, r;
    double f;
    cin >> a >> b;
    d = a / b;
    r = a % b;
    f = (double) a / (double) b;
    cout << d << " " << r << " " << fixed << setprecision(5) << f << endl;
}


Measured memory_bytes: 3224
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ld long double
#define inf 1e18
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mk make_pair
#define mod 1000000007
#define setbits __builtin_popcount
#define fi first
#define se second
int main()
{
    fastIO;
    char c;
    ll val;
    cin>>c;
    val=c-'a';
    cout<<char(97+val+1)<<'\n';
    return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
S = [""]*H
for i in range(H):
    S[i] = list(input())

for i in range(H):
    for j in range(W):
        if S[i][j] != "#":
            num = 0
            
            if i > 0:
                if j > 0:
                    if S[i-1][j-1] == "#":
                        num += 1
                if S[i-1][j] == "#":
                    num += 1
                if j < W-1:
                    if S[i-1][j+1] == "#":
                        num += 1
            if j > 0:
                if S[i][j-1] == "#":
                    num += 1
            if j < W-1:
                if S[i][j+1] == "#":
                    num += 1
            if i < H-1 :
                if j > 0:
                    if S[i+1][j-1] == "#":
                        num += 1
                if S[i+1][j] == "#":
                    num += 1
                if j < W-1:
                    if S[i+1][j+1] == "#":
                        num += 1
            
            S[i][j] = str(num)

for i in range(H):
    print("".join(S[i]))

Measured memory_bytes: 9276
import sys
input = sys.stdin.readline

N=int(input())
A=[input().strip() for i in range(N)]

X=[]

for a in A:
    TWO=0
    FIVE=0

    if "." in a:
        x=a.split(".")
        L=len(x[1])
        #print(x,L)
        TWO-=L
        FIVE-=L

        x=int("".join(x))

        #print(x)

        while x%2==0:
            x//=2
            TWO+=1

        while x%5==0:
            x//=5
            FIVE+=1

        #print(TWO,FIVE)

    else:
        x=int(a)
        while x%2==0:
            x//=2
            TWO+=1

        while x%5==0:
            x//=5
            FIVE+=1

    X.append((TWO,FIVE))

LIST=[[0]*100 for i in range(100)]

for x,y in X:
    LIST[x+35][y+35]+=1

#for l in LIST:
#    print(*l)

#print()

for i in range(100):
    for j in range(98,-1,-1):
        LIST[i][j]+=LIST[i][j+1]

for j in range(100):
    for i in range(98,-1,-1):
        LIST[i][j]+=LIST[i+1][j]

#for l in LIST:
#    print(*l)

ANS=0

for x,y in X:
    x2=-x
    y2=-y

    if x>=x2 and y>=y2:
        ANS-=1

    ANS+=LIST[x2+35][y2+35]

    #print(x,y,ANS)

print(ANS//2)

Measured memory_bytes: 41124
#include <cstdio>

using namespace std;

int main() {
    int a,b,c;
    int re;
    scanf("%d%d%d" , &a, &b, &c);

    if(a+b+1 > c){
        re = b+c;
    }else{
        re = a+b+1+b;
    }

    printf("%d",re);
    return 0;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vll = vector<ll>;
template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

int main() {
    ll A, B, K;
    cin >> A >> B >> K;
    cout << max(0ll, A - K) << " " << max(0ll, min(B, B - (K - A))) << endl;
    return (0);
}

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

int main(){
  long long N; cin >> N;
  double m=sqrt(N)+2;
  set<long long> div;
  set<long long> divminus;
  for(int i=1; i<=m; i++){
    if(N%i==0){
      div.insert(i);
      div.insert(N/i);
    }
  }
  for(int i=1; i<=m; i++){
    if((N-1)%i==0){
      divminus.insert(i);
      divminus.insert((N-1)/i);
    }
  }
  
  for(auto i:div){
    if(i!=1){
      //Nをiで割り切る
      //残りが1modiならOK
      long long NN=N;
      while(NN%i==0){
        NN/=i;
      }
      if(NN%i==1) divminus.insert(i);
    }
  }
  cout << divminus.size()-1 << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int L[200009],R[200009];
int l[200009],r[200009];
int C = 1e5+1;
main(){
   int n;
   cin >> n;
   L[C]++;
   R[C]++;
   for(int i = 1; i <= n; i++){
        cin >> l[i] >> r[i];
        l[i]+=C;
        r[i]+=C;

        R[r[i]]++;
        L[l[i]]++;
   }
   long long ans = 0;
   int ll = 0, rr = n+1;
   for(int i = 0; i <= 2e5; i++){
      ll += R[i];
      rr -= L[i];
      ans += 2*min(ll,rr);
   }
   cout<<ans<<endl;
}


Measured memory_bytes: 2560
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] V = new int[N];
        for(int i = 0; i < N; i++){
            V[i] = sc.nextInt();
        }
        
        int[][] values0 = new int[(int)1e5+1][2];
        int[][] values1 = new int[(int)1e5+1][2];        
        
        for(int i = 0; i < N; i++){
            if( i % 2 == 0){
                values0[V[i]][0] = V[i];
                values0[V[i]][1]++;
            } else {
                values1[V[i]][0] = V[i];
                values1[V[i]][1]++;
            }
        }
        
        Arrays.sort(values0, (a, b) -> Integer.compare(b[1], a[1]) );
        Arrays.sort(values1, (a, b) -> Integer.compare(b[1], a[1]) ); 
        
        if( values0[0][0] != values1[0][0] ){
            System.out.println( N - values0[0][1] - values1[0][1] );
        } else {
            if( values0[0][1] > values1[0][1] ){
                System.out.println( N - values0[0][1] - values1[1][1] );
            } else if( values0[0][1] < values1[0][1] ) {
                System.out.println( N - values0[1][1] - values1[0][1] );
            } else {
                if( values0[1][1] >= values1[1][1] ){
                    System.out.println( N - values0[1][1] - values1[0][1] );
                } else {
                    System.out.println( N - values0[0][1] - values1[1][1] );
                }
            }
        }
        
    }
}


Measured memory_bytes: 55744
///
// File:  b.go
// Author: ymiyamoto
//
// Created on Wed Jun  6 17:21:24 2018
//
package main

import "fmt"

var N, M int

func main() {
	fmt.Scan(&N, &M)

	arr := make([]int, N+1)
	for i := 0; i < M; i++ {
		var a, b int
		fmt.Scan(&a, &b)
		arr[a]++
		arr[b]++
	}

	for _, v := range arr {
		if v%2 == 1 {
			fmt.Println("NO")
			return
		}
	}
	fmt.Println("YES")
}


Measured memory_bytes: 7552
#include<bits/stdc++.h>
using namespace std;
long long n,s;
long long count(long long b){
	long long ans=0,val=n;
	while(val){
		ans+=val%b;
		val/=b;
	}
	return ans;
}
signed main(){
	cin >> n >> s;
	for(long long i=2;i*i<=n;i++){
		if(count(i)==s){
			cout << i;
			return 0;
		}
	}
	for(long long i=sqrt(n)-1;i>=1;i--){
		if(i>s){
			continue;
		}
		long long val = n -(s-i);
		if(val%i!=0){
			continue;
		}
		if(val/i<=s-i){
			continue;
		}
		if(val/i==1){
			continue;
		}
		cout << val/i;
		return 0;
	}
	if(s==1){
		if(n==1){
			cout << "2";
		}
		else{
			cout << n;
		}
		return 0;
	}
	if(s==n){
		cout << n+1;
		return 0;
	}
	cout << "-1";
}

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

int main() {
  int N;
  int64_t tmp;
  int64_t n = 2;
  int64_t m = 1;
  cin >> N;
  if(N == 1){
    cout << m << endl;
    return 0;
  }
  for (int i = 1; i < N; i++) {
    tmp = m;
    m += n;
    n = tmp;
  }
  cout << m << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;
Int gcd(Int a, Int b){
  if(a == 0)return b;
  return gcd(b % a, a);
}

bool edge[2160][2160];
Int a[2160];
bool come[2160];
Int n;
vector<int> children[2160];
void dfs(int x, int p = -1){
  if(come[x])return;
  if(p != -1)children[p].push_back(x);
  come[x] = true;
  for(int i = 0;i < n;i++){
    if(edge[x][i])dfs(i, x);
  }
}

vector<int> dfs2(int x){
  vector<int> res, tmp1, tmp2;
  for(int to:children[x]){
    tmp1 = res;
    tmp2 = dfs2(to);
    res.clear();
    int a = 0, b = 0;
    while(a < tmp1.size() || b < tmp2.size()){
      if(b == tmp2.size() || a < tmp1.size() && tmp1[a] > tmp2[b])res.push_back(tmp1[a++]);
      else res.push_back(tmp2[b++]);
    }
  }
  res.insert(res.begin(), x);
  return res;
}

int main(){
  cin >> n;
  for(int i = 0;i < n;i++)cin >> a[i];
  a[n] = 0;n++;
  sort(a, a+n);
  for(int i = 0;i < n;i++)
    for(int j = 0;j < n;j++)
      if(gcd(a[i], a[j]) != 1)edge[i][j] = edge[j][i] = 1;
  dfs(0);
  vector<int> res = dfs2(0);
  for(int i = 1;i < res.size();i++)cout << a[res[i]] << " ";
  for(int i = 1;i < n;i++)if(a[i] == 1)cout << 1 << " ";
  cout << endl;  
  return 0;
}

Measured memory_bytes: 5120
$R, $G, $B, $N = gets.split.map(&:to_i)
count = 0
(0..$N).each do |r|
  (0..$N).each do |g|
    b = ($N - $R * r - $G * g).to_f / $B
    if 0 <= b && b.ceil == b.to_i
      count += 1
    elsif b < 0
      break
    end
  end
end
puts count

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

int a[100], n;
int cost(int x) {
  int sum = 0;
  rep(i,n) sum += (a[i]-x) * (a[i]-x);
  return sum;
}
int main() {
  cin >> n;
  rep(i,n) cin >> a[i];
  int ans = INF;
  for (int i = -100; i <= 100; i++)
  {
    ans = min(ans, cost(i));
  }
  cout << ans << endl;
  return 0;
}

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

#define all(v) v.begin(), v.end()
#define mp make_pair
#define EPS (int)1e-9
#define PI acos(-1)
#define endl '\n'
#define pb push_back
#define fi first
#define se second

using namespace std;
using ld = long double;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;

const int mod = 1000000007;


int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n, m;
	cin >> n >> m;

	vector<vector<char>> a(n, vector<char>(n));
	vector<vector<char>> b(m, vector<char>(m));
	char c;

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

	for(int i = 0; i < m; i++)
	{
		for(int j = 0; j < m; j++)
		{
			cin >> b[i][j];
		}
	}

	bool ans = false;


	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < n; j++)
		{
			if(i+m-1 >= n or j+m-1 >= n)
				continue;
			
			bool flag = true;

			for(int r = 0; r < m; r++)
			{
				for(int c = 0; c < m; c++)
				{
					if(a[i+r][j+c] != b[r][c])
					{
						flag = false;
						break;
					}
				}
				if(!flag)
					break;
			}

			if(flag)
				ans = true;
		}
	}

	if(ans)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;


	return 0;	
}

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

void b(vector<int> A,vector<int> B,vector<int> C,int &k){
  int j=0;
  for(int i=0;i<3;i++){
    j+=abs(A[i]-C[i]);
    j+=10*(B[i]-1);
  }
  k=min(k,j);
}

void a(vector<int> A,vector<int> B,vector<int> C,vector<int> L,int N,int j,int &k){
  if(j==N){
    if(A[0]!=0 && A[1]!=0 && A[2]!=0)
      b(A,B,C,k);
    return;
  }
  for(int i=0;i<4;i++){
    A[i]+=L[j];
    B[i]++;
    a(A,B,C,L,N,j+1,k);
    A[i]-=L[j];
    B[i]--;
  }
}

int main(){
  int N,A,B,C;
  cin>>N>>A>>B>>C;
  vector<int> L(N);
  for(int &i:L)
    cin>>i;
  int j=1000000;
  a({0,0,0,0},{0,0,0,0},{A,B,C},L,N,0,j);
  cout<<j<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
   ll n;
   cin>>n;
   ll a[n];
   ll xorsum=0;
   for(ll i=0;i<n;i++){
       cin>>a[i];
       xorsum^=a[i];
   }
   ll num;
   for(ll i=0;i<n;i++){
       num=xorsum^a[i];
       cout<<num<<" ";
   }
}

Measured memory_bytes: 5108
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int h,w;
  cin>>h>>w;
  vector<string> ans(h);
  rep(i,h){
    cin>>ans[i];
  }
  rep(i,h){
    rep(j,2){
      cout<<ans[i]<<endl;
    }
  }
}

Measured memory_bytes: 3616
n,y = map(int,input().split())

check = False
for i in range(n+1):
    if check:
        break
    for j in range(n+1-i):
        p = (i*10000)+(j*5000)+((n-i-j)*1000)
        if p == y:
            check = True
            print(i,j,(n-i-j))
            break

if not check:
    print(-1,-1,-1)

Measured memory_bytes: 40812
#include <iostream>
#include <string>

using namespace std;

void extGCD(int a, int b, int& x, int& y)
{
	if (b != 0)
	{
		extGCD(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else
	{
		x = 1;
		y = 0;
	}
}

void solve()
{
	int a, b, x, y;
	cin >> a >> b;
	extGCD(a, b, x, y);
	cout << x << " " << y << endl;
}

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

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

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

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

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

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

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

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

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


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



int main() {

	ll N;
	cin >> N;
	vector<ll> s(N);
	rep(i, N) cin >> s[i];

	vector<ll> a(N);

	rep(i, N) a[i] = s[i] + s[N - 1 - i];

	ll ans = -INF;

	repn(i, N - 1) {
		ll bound = N - i;
		if ((N - 1) % i == 0) { bound = min(N-i,N / 2); }

		ll w = -INF;

		ll v = 0;

		for (ll j = 0; j < bound; j += i) {
			v += a[j];
			w = max(w, v);
		}


		ans = max(ans, w);
		
	}

	cout << ans;


	system("PAUSE");

	

}


Measured memory_bytes: 2040
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end()) // ユニークなvectorにする。連続した値を除去して切り出す。
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  int N;
  string S;
  cin >> N >> S;

  int x = 0;
  int maxX = 0;

  rep(i, N) {
    if (S[i] == 'I') {
      x++;
    } else {
      x--;
    }
    maxX = max(maxX, x);
  }

  cout << maxX << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long MOD = 1000000007;

        while (sc.hasNextInt()) {
            int n = sc.nextInt();
            int[] cnt = new int[1000002];

            for (int i = 0; i < n; i++) {
                cnt[sc.nextInt()]++;
            }

            if (n % 2 == 1 && cnt[0] != 1) {
                System.out.println("0");
                continue;
            }

            int start = (n % 2 == 0) ? 1 : 2;
            long ans = 1;

            for (int i = start; i < n; i += 2) {
                if (cnt[i] != 2) {
                    ans = 0;
                    break;
                }
                ans *= 2;
                ans %= MOD;
            }

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


Measured memory_bytes: 61172
/*
...........__________                                                                           ___  __
.............|       |                                                                           |   /
.............|       |                                                                           |  /
.............|       |                               |                         __                | /      _______
.............|_______|  _______            _______   |______   ________   /|  /  |               |/       |      |
.............| \               | |      | |          |      |          | / | /   |               |\       |
.............|  \       _______| |      | |_______   |      |   _______|   |/    |               | \      |
.............|   \      |      | |      |         |  |      |  |       |   |     |               |  \     |
...........__|    \__|  |______| |______| ________|  |      |_ |_______|   |     |__|           _|   \__ _|        .

*/
#include<bits/stdc++.h>
using namespace std ;
#define int                 long long
#define ull                 unsigned long long int
#define ld                  long double
#define vi                  vector<int>
#define vii                 vector<pair<int,int>>
#define vvi                 vector<vector<int>>
#define pii                 pair<int,int>
#define prec(x)             fixed<<setprecision(15)<<x
#define all(x)              x.begin(),x.end()
#define rall(x)             x.rbegin(),x.rend()
#define rev(x)              reverse(x.begin(),x.end())
#define mset(a,b)           memset(a,b,sizeof(a))
#define mcpy(a,b)           memcpy(a,b,sizeof(a))
#define fo0(i,n)            for(int i=0,i##end=n;i<i##end;i++)
#define fo1(i,n)            for(int i=1,i##end=n;i<=i##end;i++)
#define fo(i,a,b)           for(int i=a,i##end=b;i<=i##end;i++)
#define foe(i,x)            for(__typeof((x).end())i=(x).begin();i!=(x).end();++i)
#define fre(i,x)            for(__typeof((x).rend())i=(x).rbegin();i!=(x).rend();++i)
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
const int inf=1e18;const int mod=1e9+7;const int N=2e5+9;
void read_And_write(){
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}

void raushan_kumar(){
    int d=0,e=0,f=0,g=0,p=0,w=0,flag=0,ans=0,res=0,cnt=0,sum=0;double f1=0.0,f2=0.0,f3=0.0;
    int n,k;cin>>n>>k;
    set<int> s;
    while(k--){
    	int y;cin>>y;
    	while(y--){
    		int x;cin>>x;
    		s.insert(x);
    	}
    	
    }
    cout<<n-s.size();
}

int32_t main()
{
    read_And_write();fast;int t=1;
    // cin>>t;
    while(t--){raushan_kumar();}
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define pii pair<int, int>
#define fr(n) for (int i = 0; i < n; i++)
#define fr1(n) for (int i = 1; i <= n; i++)
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int n, a[102] = {}, b = 0;
    cin >> n;
    fr(n) cin >> b, a[b] = 1;
    b = 0;
    fr(102) b += a[i];
    cout << b;
    
}


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

int main(){
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    bool dp[k+1];
    memset(dp,false,sizeof(dp));
    for(int i=0;i<=k;i++){
        for(int j=0;j<n;j++){
            if(i>=a[j]&&!dp[i-a[j]]) dp[i]=true;
        }
    }
    if(dp[k]) cout<<"First";
    else cout<<"Second";
    return 0;
}

Measured memory_bytes: 384