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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		int x [] = new int [N];
		int y [] = new int [N];
		int h [] = new int [N];
		
		for (int i=0; i<N; i++){
			x[i]=sc.nextInt();
			y[i]=sc.nextInt();
			h[i]=sc.nextInt();
		}
		
		int H = 0;
	
		int i=0;
		while (h[i]<1){
			i++;
		}
		
		
			
		for (int j=0; j<101; j++){
			for (int l=0; l<101; l++){
				
				H = h[i]+ ver(x[i], j, y[i], l); //i is chosen so that h>0
				boolean check = true;
				
				for (int k=0; k<N; k++){
					int temp = H- ver(x[k], j, y[k], l);
					temp = Math.max(temp, 0);
					
					if (temp!=h[k]){
						check=false;
						break;
					}
				}
				if (check==true)
					System.out.println(j+" "+l+" "+H);
				
			}
		}
		
		
		sc.close();
	}
	public static int ver (int x, int cx, int y, int cy){
		return Math.abs(x-cx)+Math.abs(y-cy);
	}

}

Measured memory_bytes: 24148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define int ll
//#define double ld
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ifstream in("input.txt");ofstream out("output.txt");
const int inf=1e18;
const int mod=1e9+7;
int n,k;
vector<int> vec;
vector<char> dp;

void init()
{
    cin>>n>>k;
    vec.resize(n);
    for(int i=0;i<n;i++)
        cin>>vec[i];
    dp.resize(k+1,2);
}

char go(int x)
{
    if(x<0)
        return 1;
    if(dp[x]!=2)
        return dp[x];
    bool ans=0;
    for(int i=0;i<n;i++)
    {
        if(!go(x-vec[i]))
            ans=1;
    }
    return dp[x]=ans;
}

signed main()
{
    init();
    if(go(k))
        cout<<"First";
    else
        cout<<"Second";
    return 0;
}




Measured memory_bytes: 4992
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

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

    double ans = ((n + (2 -1)) / 2);
    printf("%.6lf", ans / n);

    return 0;
}


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

constexpr int MOD = 1000000007;
// constexpr int MOD = 998244353;
constexpr int MAX = 510000;

vector<long> fact(MAX), finv(MAX), inve(MAX);

void init() {
  fact.at(0) = fact.at(1) = 1;
  finv.at(0) = finv.at(1) = 1;
  inve.at(1) = 1;
  for (int i = 2; i < MAX; i++) {
    fact.at(i) = fact.at(i - 1) * i % MOD;
    inve.at(i) = MOD - inve.at(MOD % i) * (MOD / i) % MOD;
    finv.at(i) = finv.at(i - 1) * inve.at(i) % MOD;
  }
}

long com(long n, long r) {
  if (n < r || n < 0 || r < 0) return 0;
  return fact.at(n) * (finv.at(r) * finv.at(n - r) % MOD) % MOD;
}

long mpow(long a, long b) {
  long res = 1;
  while (b > 0) {
    if (b & 1) res = res * a % MOD;
    a = a * a % MOD;
    b >>= 1;
  }
  return res;
}

long com2(long n, long r) {
  if (n < r || n < 0 || r < 0) return 0;
  long x = 1, y = 1;
  for (int i = 1; i <= r; i++) {
    x = x * (n - i + 1) % MOD;
    y = y * i % MOD;
  }
  return x * mpow(y, MOD - 2) % MOD;
}

long inv(long a) {
  long b = MOD, u = 1, v = 0;
  while (b) {
    long t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= MOD; 
  if (u < 0) u += MOD;
  return u;
}

int main() {
  ios::sync_with_stdio(false);
  init();
  int X, Y;
  cin >> X >> Y;
  if ((X + Y) % 3) return cout << 0 << "\n", 0;
  cout << com2((X + Y) / 3, Y - (X + Y) / 3) << "\n";
}

Measured memory_bytes: 12160
import java.util.Scanner;
class Main{

	public void solve(){
    Scanner sc=new Scanner(System.in);
		
		int a=sc.nextInt();
		int b=sc.nextInt();
		
		
		System.out.println(a*b+" "+(2*a+2*b));
	}
	public static void main(String[] args){
        Main obj =new Main();
        obj.solve();
    }
}

Measured memory_bytes: 17156
import std.stdio;

void main(){
	long n, m, k, i;
	while (readf("%d\n", &n), n) {
		for (i = 0, m = 0; n; i++) {
			k = n % 8;
			if (k >= 4) k++;
			if (k >= 6) k++;
			n /= 8;
			m += 10^^(i) * k;
		}
		writeln(m);
	}
}

Measured memory_bytes: 984
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <tuple>

using namespace std;




int main(void)
{
    /*
    ABC 054 C
    https://atcoder.jp/contests/abc054/tasks/abc054_c
    */
    int N_vertices, N_edges;
    cin >> N_vertices>> N_edges;

    vector< vector<int> > Graph(N_vertices, vector<int>(N_vertices, 0) );
    vector<int> permutation(N_vertices);
    for(int i=0; i<N_vertices; i++)
    {
        permutation[i] = i;
    }

    int i, j;
    for(int k=0; k<N_edges; k++)
    {
        cin >> i >> j;
        Graph[i-1][j-1] = 1;
        Graph[j-1][i-1]=1;
    }


    int comb = 0;
    bool flag = true;
    int pos, next;
    do
    {
        flag = true;
        pos = 0;
        for(int i=0; i<N_vertices-1; i++)
        {
            next = permutation[i+1];
            if(Graph[pos][next]==0)
            {
                flag=false;
                break;
            }
            pos = next;
        }
        if(flag) comb++;
    }while( next_permutation( permutation.begin()+1, permutation.end() ) );

    cout << comb << endl;



    return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<cstring>
#include<queue>
using namespace std;

#define REP(i,a,b) for(i=a; i<b; ++i)
#define rep(i,n) REP(i,0,n)

vector<int> cv,pv;
int n,U;

bool visited[1<<20] = {};

struct state {
  int used,cost;
  state(int used,int cost) : used(used), cost(cost) {;}
};

int pop(int x) {
  int n = 0;
  while(x != 0) {
    n++;
    x &= (x-1);
  }
  return n;
}

int bfs() {
  queue<state> Q;
  Q.push(state(0,0));
  int i;

  while(!Q.empty()) {
    state ns = Q.front(); Q.pop();
    if(visited[ns.used]) continue;
    if(ns.cost >= U) {
      return pop(ns.used);
    }

    visited[ns.used] = 1;

    for(i=0; i<n; ++i) {
      if(!(ns.used&(1<<i)) && (ns.used & pv[i])==pv[i]) {
	Q.push( state(ns.used|(1<<i), ns.cost+cv[i]) );
      }
    }
  }
  return 0;
}

int main() {
  int i,j,k,c,r,tmp;
  while(cin>>n>>U, n|U) {
    cv.clear();
    pv.clear();
    pv.resize(n);

    rep(i, 1<<n) visited[i] = false;
    rep(i,n) {
      cin>>c>>k;
      cv.push_back(c);
      tmp = 0;
      rep(j,k) {
	cin>>r;
	tmp |= (1<<r);
      }
      pv[i] = tmp;
    }

    cout<<bfs()<<endl;
  }
}

Measured memory_bytes: 17000
#include <iostream>
using namespace std;
int main()
{
	int N;
	int A;
	int B;
	int sum = 0;
	int man;
	int sen;
	int hyaku;
	int ten;
	int ichi;

	cin >> N >> A >> B;
	for (int i = 1; i <= N; i++)
	{
		man = i / 10000;
		sen = i % 10000 / 1000;
		hyaku = i % 1000 / 100;
		ten = i % 100 /10;
		ichi = i % 10;
		if (man + hyaku + sen + ten + ichi >= A && man + sen + hyaku + ten + ichi <= B)
			sum += i;
	}
	cout << sum;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b) { return *(int *)a - *(int *)b; }                            /* 1,2,3,4.. */
int des(const void *a, const void *b) { return *(int *)b - *(int *)a; }                            /* 8,7,6,5.. */
int char_acs(const void *a, const void *b) { return *(char *)a - *(char *)b; }                     /* a,b,c,d.. */
int str_acs(const void *a, const void *b) { return strcmp(*(const char **)a, *(const char **)b); } /* aaa,aab.. */
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)

#define MAX 200001

typedef struct list
{
  int node;
  struct list *next;
} list;

list *graph[MAX];
int counter[MAX] = {0};
int n = 0;

void dfs(int node, int parent)
{
  int child;
  list *edge = graph[node];
  while (edge != NULL)
  {
    child = edge->node;
    if (child != parent) // 辺があり、その頂点が子である
    {
      counter[child] += counter[node];
      dfs(child, node);
    }
    edge = edge->next;
  }
  return;
}

void add_edge(int node1, int node2)
{
  list *new1 = (list *)malloc(sizeof(list *));
  new1->node = node2;
  new1->next = graph[node1];
  graph[node1] = new1;

  list *new2 = (list *)malloc(sizeof(list *));
  new2->node = node1;
  new2->next = graph[node2];
  graph[node2] = new2;
}

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

  int i;
  int node1, node2, init;

  for (i = 1; i <= n; i++)
    graph[i] = NULL;

  for (i = 0; i < n - 1; i++)
  {
    scanf("%d %d", &node1, &node2);
    add_edge(node1, node2);
  }

  for (i = 0; i < q; i++)
  {
    scanf("%d %d", &node1, &init);
    counter[node1] += init;
  }

  dfs(1, 0);

  for (node1 = 1; node1 <= n; node1++)
    printf("%d ", counter[node1]);
  printf("\n");

  return 0;
}


Measured memory_bytes: 26496
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

#define M_PI       3.14159265358979323846

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

std::string pad(int num)
{
    char buffer[4];
    std::snprintf(buffer, sizeof(buffer), "%03d", num);
    return buffer;
}

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }


int solve()
{
    string s;

    cin >> s;

    int i = 0, j = s.length() - 1;
    int counter = 0;

    while (i < j)
    {
        if (s[i] != s[j])
            ++counter;
        ++i;
        --j;
    }

    cout << counter << endl;

    return 0;
}

int main()
{
    solve();

    return 0;
}

Measured memory_bytes: 256
import collections
a,b,k = map(int,input().split())
n = b-a +1
if n < 2*k :
    for i in range(a,b+1):
    	print(i)
else :
    for i in range(a,a+k):
        print(i)
    for j in range(b+1-k,b+1):
        print(j)   

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll n,k;
ll ar[100001];
ll dp[100001];
ll func(ll idx)
{
	if(idx==0)
	return 0;
	if(idx<0)
	return 999999999999;
	if(dp[idx]!=-1)
	return dp[idx];
	ll ret=99999999999;
	for(ll i=1;i<=k;i++)
	{
		if(idx-i>=0)
		ret=min(ret,func(idx-i)+abs(ar[idx]-ar[idx-i]));
	}
	return dp[idx]=ret;
}
int main()
{
	cin>>n>>k;
	for(ll i=0;i<n;i++)
	cin>>ar[i];
	for(ll i=0;i<100001;i++)
	{
		dp[i]=-1;
	}
	cout<<func(n-1);
}

Measured memory_bytes: 6528
#include <iostream>
#include <vector>
using namespace std;
int main() {
    long long  n, m = 1000; cin >> n;
    vector<long long> a(n);
    for(long long &c : a) {
        cin >> c;
    }
    for(int i = 0; i < n - 1; ++i) {
        if(a.at(i) < a.at(i + 1)) {
            long long c = m / a.at(i);
            m += c * (a.at(i + 1) - a.at(i));
        }
    }
    cout << m << endl;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

ll H, W;
VS s;
VVL rec;

struct union_find{
    vector<ll> parent;
    vector<ll> nums;
    union_find(ll n){
        parent.resize(n);
        nums.resize(n, 1LL);
        rep(i, 0, n) parent[i] = i;
    }

    ll root(ll x){
        if(parent[x] == x) return x;
        parent[x] = root(parent[x]);
        return parent[x];
    }

    void unite(ll x, ll y){
        ll rx = root(x);
        ll ry = root(y);
        if(rx != ry){
            parent[rx] = ry;
            nums[ry] += nums[rx];
        }
    }

    bool same(ll x, ll y){
        ll rx = root(x);
        ll ry = root(y);
        if(rx == ry) return true;
        return false;
    }

    ll size(ll x){
        return nums[root(x)];
    }
};  

int main(){
    cin >> H >> W;
    s.resize(H);
    rec.resize(H, VL(W, -1));
    rep(i, 0, H) cin >> s[i];
    union_find t(H*W);
    rep(h, 0, H){
        rep(w, 0, W){
            if(w != W-1 && s[h][w] != s[h][w+1]) t.unite(h*W+w, h*W+w+1);
            if(h != H-1 && s[h][w] != s[h+1][w]) t.unite(h*W+w, (h+1)*W+w);
        }
    }
    map<ll, ll> mp1, mp2;
    rep(h, 0, H){
        rep(w, 0, W){
            if(s[h][w] == '#') mp1[t.root(h*W+w)]++;
            else mp2[t.root(h*W+w)]++;
        }
    }
    ll ans = 0;
    for(auto p : mp1){
        if(mp2.count(p.first) > 0) ans += p.second * mp2[p.first];
    }
    cout << ans << endl;
    return 0;
}

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

const int maxn = 1e5;
int n, k;

struct perm {
	int n, a[maxn + 3];

	perm(int m) {
		n = m;
		for (int i = 1; i <= n; i++) {
			a[i] = i;
		}
	}

	friend perm operator * (perm p, perm q) {
		perm r(p.n);
		for (int i = 1; i <= p.n; i++) {
			r.a[i] = p.a[q.a[i]];
		}
		return r;
	}

	perm inv() {
		perm r(n);
		for (int i = 1; i <= n; i++) {
			r.a[a[i]] = i;
		}
		return r;
	}

	void print() {
		for (int i = 1; i <= n; i++) {
			printf("%d%c", a[i], " \n"[i == n]);
		}
	}
};

perm g(perm p, perm q) {
	return p * q * p.inv();
}

perm qpow(perm p, int k) {
	perm q(n);
	for (; k; k >>= 1, p = p * p) {
		if (k & 1) q = p * q;
	}
	return q;
}

int main() {
	scanf("%d %d", &n, &k);
	perm p(n), q(n), r(n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &p.a[i]);
	}
	for (int i = 1; i <= n; i++) {
		scanf("%d", &q.a[i]);
	}
	int x = (k - 1) / 6;
	r = q * p.inv() * q.inv() * p;
	r = qpow(r, x);
	k -= x * 6;
	if (k == 1) {
		g(r, p).print();
	} else if (k == 2) {
		g(r, q).print();
	} else if (k == 3) {
		g(r, q * p.inv()).print();
	} else if (k == 4) {
		g(r, q * p.inv() * q.inv()).print();
	} else if (k == 5) {
		g(r, q * p.inv() * q.inv() * p * q.inv()).print();
	} else {
		g(r, q * p.inv() * q.inv() * p * p * q.inv()).print();
	}
	return 0;
}

Measured memory_bytes: 25216
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int n,a[200],ans=0;
  cin >> n;
  for(int i=0; i<2*n; i++) {
    cin >> a[i];
  }
  sort(a,a+2*n);
  for(int i=0; i<2*n; i+=2) {
    ans+=a[i];
  }
  cout << ans << endl;
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int a[maxn];
int main(){
    int n; cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    sort(a+1,a+1+n);
    if(n%2==0){
        int d=a[n/2+1]-a[n/2];
        cout<<d<<endl;
    }

}


Measured memory_bytes: 640
// #include <iostream>
// #include <vector>
// #include <array>
// #include <algorithm>
// #include <cmath>
// #include <cstdio>

// using namespace std;
// typedef long long ll;

// int main(){
//     ll n;
//     cin >> n;
//     vector<array<double, 3>> p;
//     for(int i = 0; i < n; ++i){
//         double x, y;
//         cin >> x >> y;
//         if(x == 0 && y == 0){ continue; }
//         array<double, 3> tmp;
//         tmp.at(0) = atan2(y, x);
//         tmp.at(1) = x;
//         tmp.at(2) = y;
//         p.push_back(tmp);
//     }
//     sort(p.begin(), p.end());

//     double ans = 0;
//     for(int i = 0; i < p.size(); ++i)
// 	{
//         double x = 0, y = 0;
//         for(int j = 0; j < p.size(); ++j)
// 		{
// 			// cout<<(i+j)%p.size()<<' ';
//             x += p.at((i + j) % p.size()).at(1);
//             y += p.at((i + j) % p.size()).at(2);
//             ans = max(ans, sqrt(x * x + y * y));
// 			// cout<<x<<' '<<y<<'\n';
//         }
// 		// cout<<'\n';
//     }
//     printf("%.20f\n", ans);
//     return 0;
// }





#include<bits/stdc++.h>
using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ll long long
#define rep(i,j,n) for(int i=j; i<n; i++)
#define INF 1000000000000000000 // If you use it, make sure not to put in "int" type variable ;(, use long long int
void optimizeIO() { ios_base::sync_with_stdio(false); cin.tie(NULL); }
const ll mod=1000000007;

int main()
{
    optimizeIO();
    int nT; nT=1;
	while(nT--)
	{
		ll n; cin>>n;
		array<double,3>a[n];
		rep(i,0,n) { double x,y; cin>>x>>y; a[i]={atan2(y,x),x,y}; }
		sort(a,a+n);
		double dp[n];
		dp[0]=a[0][1]*a[0][1]+a[0][2]*a[0][2];
		double ans=0;
		for(int i = 0; i < n; ++i)
		{
			double x = 0, y = 0;
			for(int j = 0; j < n; ++j)
			{
				// cout<<(i+j)%p.size()<<' ';
				x += a[((i + j) % n)].at(1);
				y += a[((i + j) % n)].at(2);
				ans = max(ans, sqrt(x * x + y * y));
				// cout<<x<<' '<<y<<'\n';
			}
			// cout<<'\n';
		}
		printf("%.20f\n", ans);
	}
	return 0;
}


// https://atcoder.jp/contests/abc139/submissions/7294031


Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }
 
    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();
        HashMap<Integer, Set<Integer>> graph = new HashMap<>();
        for (int i = 0 ; i < N ; i++) {
            graph.put(i, new HashSet<>());
        }
 
        for(int i = 0; i < N; i++) {
            String S = scan.next();
            char sChar[] = S.toCharArray();
            for (int j = 0; j < sChar.length; j++) {
                if(sChar[j] == '1') {
                    graph.get(i).add(j);
                    graph.get(j).add(i);
                }
            }
        }
 
        int min = 1000;//N <= 200
        long answer = 0;
        for (int i = 0; i < graph.size(); i++) {
            ArrayList<Integer> firstGp = new ArrayList<>();
            HashSet<Integer> secondGp = new HashSet<>();
            HashSet<Integer> visited = new HashSet<>();
            firstGp.add(i);
            long count = 0;
            HashMap<Integer, Set<Integer>> tempGraph = new HashMap<>();
            for (int j = 0 ; j < N ; j++) {
                tempGraph.put(j, new HashSet<>(graph.get(j)));
            }
            while(!firstGp.isEmpty()) {
                count++;
                for (Integer pos : firstGp) {
                    visited.add(pos);
                    for (Integer childPos : graph.get(pos)) {
                        if (visited.contains(childPos)) {
                            os.println(-1);
                            return;
                        }
                        secondGp.add(childPos);
                    }
                }
                for (Integer deletePos : firstGp) {
                    for (Integer pos : secondGp) {
                        graph.get(pos).remove(deletePos);
                    }
                }
                firstGp.clear();
                firstGp.addAll(secondGp);
                secondGp.clear();
            }
            graph = tempGraph;
            answer = Math.max(answer, count);
        }
        os.println(answer);
 
    }
 
}

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

template<int MOD>
struct mod_int {
	static const int mod = MOD;
	unsigned x;
	mod_int() : x(0) { }
	mod_int(int sig) { int sigt = sig % MOD; if (sigt < 0) sigt += MOD; x = sigt; }
	mod_int(long long sig) { int sigt = sig % MOD; if (sigt < 0) sigt += MOD; x = sigt; }
	int get() const { return (int)x; }

	mod_int &operator+=(mod_int that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
	mod_int &operator-=(mod_int that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
	mod_int &operator*=(mod_int that) { x = (unsigned long long)x * that.x % MOD; return *this; }
	mod_int &operator/=(mod_int that) { return *this *= that.inverse(); }

	mod_int operator+(mod_int that) const { return mod_int(*this) += that; }
	mod_int operator-(mod_int that) const { return mod_int(*this) -= that; }
	mod_int operator*(mod_int that) const { return mod_int(*this) *= that; }
	mod_int operator/(mod_int that) const { return mod_int(*this) /= that; }

	mod_int inverse() const {
		long long a = x, b = MOD, u = 1, v = 0;
		while (b) {
			long long t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		return mod_int(u);
	}
};

template<int MOD>
istream& operator >> (istream& is, mod_int<MOD>& val) {
	long long x;
	is >> x; val = x;
	return is;
}

template<int MOD>
ostream& operator << (ostream& os, const mod_int<MOD>& val) {
	os << val.get();
	return os;
}

using mint = mod_int<1000000007>;

const int MAX = 2e6;

bool inited = false;
mint fac[MAX + 1];
mint rfac[MAX + 1];

void init() {
	inited = true;
	fac[0] = 1;
	for (int i = 1; i <= MAX; i++) {
		fac[i] = fac[i - 1] * i;
	}
	rfac[MAX] = fac[MAX].inverse();
	for (int i = MAX; i >= 1; i--) {
		rfac[i - 1] = rfac[i] * i;
	}
}

mint nPr(int n, int r) {
	if (!inited) init();
	return r < 0 || n < r ? 0 : fac[n] * rfac[n - r];
}

mint nCr(int n, int r) {
	if (!inited) init();
	return r < 0 || n < r ? 0 : fac[n] * rfac[n - r] * rfac[r];
}

mint nHr(int n, int r) {
	if (!inited) init();
	return r == 0 ? 1 : nCr(n + r - 1, r);
}

int main()
{
	int N, M, K;
	cin >> N >> M >> K;
	mint res = 0;
	for (int i = 1; i < N; i++) {
		res += mint(M * i) * mint(M * (N - i)) * nCr(N * M - 2, K - 2);
	}
	for (int i = 1; i < M; i++) {
		res += mint(N * i) * mint(N * (M - i)) * nCr(N * M - 2, K - 2);
	}
	cout << res << endl;
	return 0;
}


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

// int/long:		-2147483648 - 2147483648 (-2^31 <= int < 2^31)
// long/long long:	-9223372036854775808 - 9223372036854775807 (-2^63 <= long < 2^63)
#define	INF (1<<29)
//536870912

#define	MOD 1000000007

int	main() {
	int N;
	cin >>N;
	vector<long> A(N, 0);
	vector<long> B(N, 0);
	for (int i=0; i<N; i++)
		cin >>A.at(i) >>B.at(i);
	long S=0;
	for (int i=N-1; i>=0; i--) {
		long a=A.at(i)+S;
		long b=B.at(i);
		if (0==a%b)
			continue;
		S += b-a%b;
	}
	cout <<S <<endl;
	return 0;
}



Measured memory_bytes: 1792
#include <stdio.h>


int main(void){
	char str[16];
	char code[] = "CODEFESTIVAL2016";
	int i, cnt = 0;
	
	for (i = 0; i < 16; i++){
		scanf("%c", &str[i]);
		if (str[i] != code[i]) cnt++;
	}
	
	printf("%d\n", cnt);
	
	return 0;
}

Measured memory_bytes: 128
use std::io;
use std::cmp;

fn main() {
    let mut line = String::new();
    io::stdin().read_line(&mut line);
    let N = line.trim().parse::<usize>().unwrap();
    
    let mut line = String::new();
    io::stdin().read_line(&mut line);
    let mut line = line.split_whitespace();
    let mut a = Vec::<usize>::with_capacity(N);
    for i in 0..N {
        let n = line.next().unwrap().parse::<usize>().unwrap();
        a.push(n);
    }

    let mut c = [0usize; 8];
    let mut t = 0usize;

    for i in 0..N {
        match a[i] {
            1usize...399usize => { c[0] = 1 },
            400usize...799usize => { c[1] = 1 },
            800usize...1199usize => { c[2] = 1 },
            1200usize...1599usize => { c[3] = 1 },
            1600usize...1999usize => { c[4] = 1 },
            2000usize...2399usize => { c[5] = 1 },
            2400usize...2799usize => { c[6] = 1 },
            2800usize...3199usize => { c[7] = 1 },
            3200usize...4800usize => { t += 1usize },
            _ => ()
        }
    }

    let mut min = c.iter().fold(0usize, |sum, &x| sum + x);
    let max = min + t;
    min = cmp::max(1usize, min);

    println!("{} {}", min, max);
}

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

int main() {
  int N;
  cin >> N;
  vector<int>value(N);
  for(int i=0;i<N;i++){
    cin >> value.at(i);
  }
  vector<int>cost(N);
  for(int i=0;i<N;i++){
    cin >> cost.at(i);
  }
  int ans=0;
  for(int i=0;i<N;i++){
    if(value.at(i)>cost.at(i)) ans+=value.at(i)-cost.at(i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3608
#include<iostream>
#include<algorithm>
#define MAX 26
#define NIL -1
using namespace std;
struct  Tree
{
    int id;
    int left;
    int right;
    int parent;
};
Tree tree[MAX];
void Postorder(int p){
    if(tree[p].left!=NIL){
        Postorder(tree[p].left);
    }
    if(tree[p].right!=NIL){
        Postorder(tree[p].right);
    }
    cout << ' ' << p;
}
void Inorder(int p){
    if(tree[p].left!=NIL){
        Inorder(tree[p].left);
    }
    cout << ' ' << p;
    if(tree[p].right!=NIL){
        Inorder(tree[p].right);
    }
}
void preorder_tree_work(int p){
    cout << ' ' << p;
    if(tree[p].left!=NIL){
        preorder_tree_work(tree[p].left);
    }
    if(tree[p].right!=NIL){
        preorder_tree_work(tree[p].right);
    }
}
int find_root(int n){
    int root;
    for(int i=0;i<n;i++){
        if(tree[i].parent==NIL){
            //cout << i << endl;
            root = i;
            break;
        }
    }
    return root;
}
int main(void){
    int n,root;
    cin >> n;
    for(int i=0;i<n;i++){
        tree[i].parent = NIL;
    }
    for(int i=0;i<n;i++){
        int id;
        cin >> id;
        cin >> tree[id].left >> tree[id].right;
        if(tree[id].right!=NIL){
            tree[tree[id].right].parent = id;
        }
        if(tree[id].left!=NIL){
            tree[tree[id].left].parent = id;
        }
        // cout << id << tree[id].left << tree[id].right << endl;
    }
    root = find_root(n);
    cout << "Preorder" << endl;
    preorder_tree_work(root);
    cout << endl;
    cout << "Inorder" << endl;
    Inorder(root);
    cout << endl;
    cout << "Postorder" << endl;
    Postorder(root);
    cout << endl;
    return 0;
}


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

int main(){
	while (true)
	{
		int R[10], S[10], n, z=0;
		string str;
		R[0] = 1;
		S[0] = 0;
		for (int i = 1; i < 10; i++) {
			R[i] = R[i - 1] * 2;
			S[i] = 0;
		}
		cin >> n;
		if (cin.eof() || n == 0) { break; }
		for(int i=9;i>=0;i--){
			if(n>=R[i]){
				n -= R[i];
				S[i] += 1;
			}
		}
		for(int i=0;i<10;i++){
			if (S[i] == 1 && z==0) {
				str += to_string(R[i]);
				z = 1;
			}
			else if(S[i] == 1){
				str += " ";
				str += to_string(R[i]);
			}
		}
		cout << str << endl;
	}
	return 0;
}

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

int dp[111][55][311];
int S,D,M;
vector<int> W[111];
vector<int> P[111];
int F[111];

void update(int &a,int b){
  a = max( a, b );
}

pair<int,int> solve(){
  memset(dp,0,sizeof(dp));
  for(int d=0;d<D;d++){
    int nd = F[d];
    for(int m=0;m<=M;m++){
      for(int k=0;k<(int)W[nd].size();k++){
        int nw = W[nd][k], np = P[nd][k];        
        update( dp[d][k+1][m], dp[d][k][m] );
        if( m + np <= M )
          update( dp[d][k+1][m+np], dp[d][k][m]+nw );
      }
      update( dp[d+1][0][m], dp[d][W[nd].size()][m] );
    }    
  }
  pair<int,int> res = make_pair(0,0);
  for(int i=0;i<=M;i++) res=max( res, make_pair(dp[D][0][i],-i) );
  res.second *=-1;
  return res;
}

int main(){
  while( cin >> S >> D>> M ){
    for(int i=0;i<S;i++){
      int k; cin >> k;
      W[i].clear(); P[i].clear();
      for(int j=0;j<k;j++){
        int w,p; cin >> w >> p;
        W[i].push_back( w );
        P[i].push_back( p );
      }
    }
    for(int i=0;i<D;i++) 
      cin >> F[i];
    pair<int,int> res= solve();
    cout << res.first << " " << res.second << endl;
  }
}

Measured memory_bytes: 8700
# -*- coding: utf-8 -*-
from bisect import bisect_left
def inpl(): return list(map(int, input().split()))
N = int(input())
A = [int(input()) for _ in range(N)]

LIS = [A[0]]

for a in A[1:]:
    if a > LIS[-1]:
        LIS.append(a)
    else:
        LIS[bisect_left(LIS, a)] = a

print(len(LIS))


Measured memory_bytes: 11148
#include <utility>
#include <vector>
#include <iostream>
#include <cstdlib>
#include<bits/stdc++.h>
#include <limits>
#include <set>
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
using namespace std;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
    ul A, B, C;
    int K;
    cin >> A >> B >> C >> K;
    ul target = max(A, max(B, C));
    ul sum = A+B+C -target;
    for (int i =0; i < K; i++){
        target *=2;
    }
    sum += target;
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M; cin >> N >> M;
  vector<int> s(M, 0);
  vector<int> c(M, 0);
  REP(i, M){
    int tmp; cin >> tmp >> c[i];
    tmp--; s[i] = tmp;
  }
  vector<bool> ans(1000, false);
  REP(i, 1000){
    if(N == 3 && i < 100) continue;
    if(N == 2 && (i > 100 || i < 10)) continue;
    if(N == 1 && i > 10) continue;
    string S = to_string(i);
    int n = S.size();
    bool flag = true;
    REP(j, M){
      if((S[s[j]] - '0') != c[j]) flag = false;
    }
    if(flag) ans[i] = true;
  }
  REP(i, 1000){
    if(ans[i]){
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}

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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const ll MAX=1<<18;
const ll INF=0x3f3f3f3f3f3f3f;
ll a[MAX],n,ans;
int main(){
    ll k=0,u=0;
    scanf("%lld",&n);
    for(ll i=0;i<n;i++) scanf("%lld",&a[i]);
    u=0;
    for(ll i=0,t=1;i<n;i++,t*=-1){
        u+=a[i];
        if(t>0&&u<=0) k+=1-u,u=1;
        else if(t<0&&u>=0) k+=u+1,u=-1;
    }
    ans=k,u=0,k=0;
    for(ll i=0,t=-1;i<n;i++,t*=-1){
        u+=a[i];
        if(t>0&&u<=0) k+=1-u,u=1;
        else if(t<0&&u>=0) k+=u+1,u=-1;
    }
    ans=min(ans,k);
    printf("%lld\n",ans);
}


Measured memory_bytes: 1024
#include<stdio.h>

int main(void)
{
	int n, cnt = 0;
	int a[100];

	scanf("%d",&n);
	for (int i = 0; i < n; i++)		scanf("%d",&a[i]);

	for (int i = 0; i < n; i++)
	{
		if (i == 0)
		{
			if ( a[i] == a[i + 1] )
			{
				if (a[i + 1] == a[i + 2])		goto LEAVE;
				cnt++;
				while( a[i] == a[i + 1] )	a[i] += 1;
			}
			LEAVE:;
		}
		else if (i == n-1)
		{
			if (a[i] == a[i + 1])
			{
				cnt++;
				while (a[i] == a[i - 1])	a[i] += 1;
			}
		}
		else
		{
			if ((a[i] == a[i - 1]) || (a[i] == a[i + 1]))
			{
				if ( (a[i + 1] == a[i + 2]) && (a[i] != a[i - 1]) )		goto LEAVE2;
				cnt++;
				while ((a[i] == a[i - 1]) || (a[i] == a[i + 1]))	a[i] += 1;
			}
			LEAVE2:;
		}
	}

	printf("%d\n", cnt);

	return 0;
}

Measured memory_bytes: 128
#include <fstream>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <sstream>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <cmath>
#include <queue>
#include <random>

using namespace std;

#define INT_MAX_VALUE 2147483647
#define LONG_LONG_MAX_VALUE 9223372036854775807
#define ll long long

template <class T>
T mymax(T a,T b){
    if(a>=b) return a;
    return b;
}
template <class T>
T mymin(T a,T b){
    if(a<=b) return a;
    return b;
}

ll gcd(ll a, ll b){
    if(a<b){
        swap(a,b);
    }
    while(b){
        ll r = a%b;
        a=b;
        b=r;
    }
    return a;
}

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

struct XX{
    ll a;
    int b;
    int j;
    int i;
};

class xxGreater {
public:
    bool operator()(const XX& riLeft, const XX& riRight) const {
        //第2条件
        if((riLeft.a) == (riRight.a)){
            return riLeft.i < riRight.i;//<:昇順(小さいものから順番)、>:降順(大きいものから順番)
            //プライオリティキューの場合は > で、top()すると値の小さいものがとれる
        }
        //第1条件
        return (riLeft.a) < (riRight.a);
    }
};


//map<long long,long long> prime_f(long long n){
//    map<long long,long long>res;
//    for(int i=2;i*i<=n;i++){
//        while(n%i==0){
//            ++res[i];
//            n/=i;
//        }
//    }
//    if(n!=1)res[n]=1;
//    return res;
//}

int mat[100][100];
pair<int,int> pmax;
pair<int,int> pmin;
int maxheight=0;
int minheight=200000;
void chouten(){
    for(int i=0;i<100;i++){
        for(int j=0;j<100;j++){
            if(maxheight<mat[i][j] && mat[i][j]>=100){
                maxheight=mat[i][j];
                pmax=make_pair(i,j);
            }
            if(minheight>mat[i][j]){
                minheight=mat[i][j];
                pmin=make_pair(i,j);
            }
        }
    }
}


int main(int argc, const char * argv[])
{
    //scanf("%s",S);
    //scanf("%d",&N);
    //scanf("%lld %lld",&target1,&target2);
    //sscanf(tmp.c_str(),"%dd%d%d",&time[i], &dice[i], &z[i]);
    //getline(cin, target);
    //cin >> x >> y;
    //テスト用
    //ifstream ifs( "1_06.txt" );
    //ifs >> a;
    //ここから
    
    //入力高速化
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int c[3][3];
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin >> c[i][j];
        }
    }
    
    for(int i=0;i<=100;i++){
        for(int j=0;j<=100;j++){
            for(int k=0;k<=100;k++){
                if(c[0][1]==c[0][0]-i+j &&
                   c[0][2]==c[0][0]-i+k &&
                   c[1][2]==c[1][1]-j+k &&
                   
                   c[1][0]==c[1][1]-j+i &&
                   c[2][0]==c[2][2]-k+i &&
                   c[2][1]==c[2][2]-k+j){
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "No" << endl;
    
    //ここまで
    //cout << "ans" << endl;改行含む
    //printf("%.0f\n",ans);//小数点以下表示なし
    //printf("%.7f\n",p);
    
    return 0;
}



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

int main(){
    int cnt[11]={0};
    int a, b, c;
    cin >> a >> b >> c;
    cnt[a]++;
    cnt[b]++;
    cnt[c]++;
    if(cnt[5] == 2 && cnt[7] == 1)cout << "YES";
    else cout << "NO";
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * a.cc: C: Factors of Factorial
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 1000;

typedef long long ll;
const ll MOD = 1000000007;

/* typedef */

typedef vector<int> vi;

/* global variables */

bool primes[MAX_N + 1];

/* subroutines */

void gen_primes(int maxp, vi &pnums) {
  memset(primes, true, sizeof(primes));
  primes[0] = primes[1] = false;

  int p;
  for (p = 2; p * p <= maxp; p++)
    if (primes[p]) {
      pnums.push_back(p);
      for (int q = p * p; q <= maxp; q += p) primes[q] = false;
    }
  for (; p <= maxp; p++)
    if (primes[p]) pnums.push_back(p);
}

bool prime_decomp(int n, vi &pnums, vi& pds) {
  int pn = pnums.size();
  for (int i = 0; i < pn; i++) {
    int pi = pnums[i];
    if (pi * pi > n) {
      if (n > 1) {
	int j = lower_bound(pnums.begin(), pnums.end(), n) - pnums.begin();
	pds[j]++;
      }
      return true;
    }

    while (n % pi == 0) n /= pi, pds[i]++;
  }
  return false;
}

/* main */

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

  vi pnums;
  gen_primes(n, pnums);
  int pn = pnums.size();
  //printf("pn=%d\n", pn);

  vi pds(pn, 0);
  for (int m = 2; m <= n; m++)
    prime_decomp(m, pnums, pds);

  ll ans = 1;
  for (int i = 0; i < pn; i++)
    ans = (ans * (pds[i] + 1)) % MOD;

  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 256
/*
** 最大堆
*/

# include <cstdio>
# include <algorithm>
using namespace std;

const int MAX = 500000 + 10;

int n, a[MAX];

void maxHeapify(int i) {
    int l = 2 * i;
    int r = 2 * i + 1;
    int largest;
    if (l <= n && a[l] > a[i]) {
        largest = l;
    }
    else {
        largest = i;
    }
    if (r <= n && a[r] > a[largest]) {
        largest = r;
    }

    if (largest != i) {
        swap(a[largest], a[i]);
        maxHeapify(largest);
    }
}

void solve() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
    }

    for (int i = n / 2; i >= 1; i--) {
        maxHeapify(i);
    }

    for (int i = 1; i <= n; i++) {
        printf(" %d", a[i]);
    }

    printf("\n");
}

int main() {
    // freopen("infile", "r", stdin);
    // freopen("outfile", "w", stdout);
    solve();
    return 0;
}


Measured memory_bytes: 4556
#include <cstdio>
#include <vector>
using namespace std;

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef vector<int> vi;

const int LEN = 100001;

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

    vi L(M), R(M);
    REP(i, M) {
        scanf("%d", &L[i]);
        scanf("%d", &R[i]);
    }

    vi imos(LEN, 0);
    REP(i, M) {
        ++imos[L[i]];
        --imos[R[i]+1];
    }

    vi sum(LEN+1, 0);
    REP(i, LEN) {
        sum[i+1] = sum[i] + imos[i];
    }

    int result = 0;
    REP(i, LEN+1) {
        if (sum[i] == M) {
            ++result;
        }
    }
    
    printf("%d\n", result);

    return 0;
}

Measured memory_bytes: 1792
def insertion_sort(A, n, g):
    cnt = 0
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v

    return cnt

n = int(input())

A = [int(input()) for _ in range(n)]

G = [1]
G[0] = 1
for i in range(1, 100):
    G.append(G[i-1] * 3 + 1)
    if G[i] > n:
        del G[-1]
        break

m = len(G)
cnt = 0
for i in range(m):
    cnt += insertion_sort(A, len(A), G[m-1-i])

print(m)
print(*reversed(G))
print(cnt)
print(*A, sep='\n')


Measured memory_bytes: 53288
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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; }

vector<ll> ans;

void dfs(ll n) {
  if(3234566667<n) return;
  ans.pb(n);
  ll d=n%10;
  if(d!=0) dfs(n*10+d-1);
  if(d!=9) dfs(n*10+d+1);
  dfs(n*10+d);
}

int main(int argc, char const *argv[]) {
  ll k; cin >> k;
  rep(i,9) dfs(i+1);
  sort(all(ans));
  cout << ans[k-1] << endl;
  return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

vector<ll> inv, fact, invfact;
void mod_build(int n = 1010100){
    fact.resize(n+1);
    inv.resize(n+1);
    invfact.resize(n+1);
    fact[0] = inv[0] = invfact[0] = 1;
    inv[1] = 1;
    REP(i, n){
        fact[i+1] = fact[i] * (i+1) % MOD;
        if(i > 0) inv[i+1] = MOD - inv[MOD % (i+1)] * (MOD / (i+1)) % MOD;
        invfact[i+1] = invfact[i] * inv[i+1] % MOD;
    }
}
ll perm(ll n, ll k){
    if(n < 0 || k < 0 || k > n) return 0;
    return fact[n] * invfact[n-k] % MOD;
}
ll comb(ll n, ll k){
    if(n<0 || k<0 || k>n) return 0;
    return (fact[n] * invfact[n-k] % MOD) * invfact[k] % MOD;
}

int main(void)
{
    ll X,Y;
    cin >> X >> Y;
    
    mod_build();

    // if((X&1)==0 && (Y&1)==0){
    //     pr(0);
    //     return 0;
    // }

    if(X<Y){
        int tmp = X;
        X = Y;
        Y = tmp;
    }

    if(X==Y && (X%3) == 0){
        pr(comb((X/3)*2, Y/3) % MOD);
    }else{
        REP(i, 1000002){
            ll x = X + i;
            ll y = Y - i;
            if(y < 0){
                pr(0);
                break;
            }
            if(x == y*2){
                pr(comb(x/2, i) % MOD);
                break;
            }
        }
        return 0;
    }

}

Measured memory_bytes: 23936
#include<stdio.h>
#include<math.h>
int main(void)
{
	double x,h,S,y,l;
	while(1){
	scanf("%lf %lf",&x,&h);
	if(x==0 && h==0){
		break;
	}
	y=x*x;
	l=sqrt(h*h+(x/2)*(x/2))*x*2;
	S=y+l;
	printf("%f\n",S);
	}
	return 0;
}

Measured memory_bytes: 1072
//DPL_1B
#include <iostream>
#include <vector>
#include <algorithm>
#define DIAGONAL 1
#define TOP 0
using namespace std;
 
static const int NMAX=105;
static const int WMAX=10005;

struct Item{
 int value,weight;
};

int N,W;
Item items[NMAX+1];
int C[NMAX+1][WMAX+1],G[NMAX+1][WMAX+1];

void compute(int &maxValue,vector<int> &selection){
 for(int w=0;w<=W;w++){
  C[0][w]=0;
  G[0][w]=DIAGONAL;
 }
 for(int i=1;i<=N;i++) C[i][0]=0;
 for(int i=1;i<=N;i++){
  for(int w=1;w<=W;w++){
   C[i][w]=C[i-1][w];
   G[i][w]=TOP;
   if(items[i].weight>w) continue;
   if(items[i].value+C[i-1][w-items[i].weight]>C[i-1][w]){
    C[i][w]=items[i].value+C[i-1][w-items[i].weight];
    G[i][w]=DIAGONAL;
   }
  }
 }
 maxValue=C[N][W];
 selection.clear();
 for(int i=N,w=W;i>=1;i--){
  if(G[i][w]==DIAGONAL){
   selection.push_back(i);
   w-=items[i].weight;
  }
 }
 reverse(selection.begin(),selection.end());
}

void input(){
 cin>>N>>W;
 for(int i=1;i<=N;i++){
  cin>>items[i].value>>items[i].weight;
 }
}

int main(){
 int maxValue;
 vector<int> selection;
 input();
 compute(maxValue,selection);
 cout<<maxValue<<endl;
 return 0;
}

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

const int mod=1000;
const int maxn=1000;

int d[maxn];
int n,k;

int main()
{
    scanf("%d%d", &n, &k);
    for( int i=1;i<=k;i++ )
    {
    	int x;scanf("%d",&x);
    	for( int j=1;j<=x;j++ )
    	{
    		int t;scanf("%d",&t);
			d[t]++; 
    	} 
    }
	int ans=0;
	for( int i=1;i<=n;i++ ) ans+= d[i]==0; 
    printf("%d\n", ans);
}

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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	char a,b;
	cin>>a>>b;
	string s,t;
	rep(i,b-'0')s+=a;
	rep(i,a-'0')t+=b;
	cout<<min(s,t)<<endl;
	return 0;
}

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

int main() {
  
  int a=0, b=0;
  
  cin >> a >> b;
  
  string str;
  
  if(a<=b) {
    
    for(int i=0; i<b; i++) {
      
      cout << a;
      
    }
      
  } else if(b<a) {
    
    for(int i=0; i<a; i++) {
      
      cout << b;
    
    }
    
  }
  
  return 0;
  
}

Measured memory_bytes: 384
// Problem : C - Next Prime
// Contest : AtCoder Beginner Contest 149
// URL : https://atcoder.jp/contests/abc149/tasks/abc149_c
// Memory Limit : 1024,000000 MB 
// Time Limit : 2000,000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor2)

#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <vector>

using namespace std;

bool isprime(int what) {
  if (what == 2) {
    return true;
  }
  
  if (what % 2 == 0) {
    return false;
  }
  
  for (int i = 3; i < ceil(sqrt(what)); i += 2) {
    if (what % i == 0) {
      return false;
    }
  }
  
  return true;
}

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

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

  cout.precision(16);
  cout << fixed;
  
  int x;
  cin >> x;
  
  while (!isprime(x)) {
    ++x;
  }
  
  cout << x;
}


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

class Program
{

    static void Main(string[] args)
    {
        string a = Console.ReadLine();
        string b = Console.ReadLine();
        int nagasa = a.Length;
        
        b = b.Remove(nagasa,1);

        
        if (a == b)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 25796
n, k = gets.chomp.split(' ').map(&:to_i)


f = [1]

n.times do |i|
  f[i+1] = f[i] * (i+1)
end

for i in 1..k
  if i > k
    puts 0
  else
    pat_i = f[n-k+1] / (f[i] * f[n-k+1-i])
    pat_k = f[k-1] / (f[i-1] * f[k-i])
    puts (pat_i * pat_k) % (1_000_000_000 +7)
  end
end

Measured memory_bytes: 9596
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  vl a(3);
  rep(i, 3) cin >> a[i];
  sort(ALL(a), greater<ll>());
  ll ans = a[0] * 10 + a[1] + a[2];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {

	var a, b, c, d, e, k int
	fmt.Scan(&a)
	fmt.Scan(&b)
	fmt.Scan(&c)
	fmt.Scan(&d)
	fmt.Scan(&e)
	fmt.Scan(&k)
	ret := k < e-d || k < e-c || k < e-b || k < e-a ||
		k < d-c || k < d-b || k < d-a ||
		k < c-b || k < c-a ||
		k < b-a
	if ret {
		fmt.Println(":(")
	} else {
		fmt.Println("Yay!")
	}
}

Measured memory_bytes: 512