akhauriyash/Code-Regression huggingface dataset:
/*
I am not somebody you can put inside a box
And I am not somebody who will let you take my spot
It's written on my face I'm somebody who never stop
I do it because I gotta I don't do it for you props
Nah, you can keep those
I'm aiming way higher than planes in Heathrow
And I'm sorry to say but my game can't be sold
And look to be honest either you got it or don't
But if you got a dream and a vision
Put it in your mind that you gotta go out and get it
People try to stop you it's so hard in the beginning
But you said that you a winner so keep going ain't no quiting
I'm giving you the words that out me in this posotion
Some people hear and some people listen
Wanna be the best then you gotta learn the difference
*/
#include <bits/stdc++.h>                                           
 
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define int long long	
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define ll long long
#define vi vector < int >
#define pii pair < int, int > 
#define sz(s) (int)s.size()
#define all(x) x.begin(), x.end()                                                                    
#define pb push_back   
#define ppb pop_back
#define mp make_pair
#define s second
#define f first                                               
	
   
typedef tree < int, null_type, less < int >, rb_tree_tag, tree_order_statistics_node_update > ordered_set;   
   
const int N = 2e5 + 13, inf = 1e9, mod = 1e9 + 7, block = 444;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};
const ll INF = 1e18;
//fucking constants

int n, a[N];

main () {
	cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		ans = (ans + a[i] * a[i - 1]) % mod;
		a[i] = (a[i] + a[i - 1]) % mod;
	}

	cout << ans << endl;
	
}

Measured memory_bytes: 5144
#include <stdio.h>
#include <math.h>
#define ll long long

ll min(ll a, ll b)
{
    return (a >= b) ? b : a;
}

int main()
{
    ll n, k;
    scanf("%lld %lld", &n, &k);
    ll h[100001];
    for (int i = 0; i < n; i++)
    {
        scanf("%lld", &h[i]);
    }
    ll arr[100001], temp;
    arr[0] = 0;
    arr[1] = fabs(h[1] - h[0]);
    for (int i = 2; i < n; i++)
    {
        temp = arr[i - 1] + fabs(h[i] - h[i - 1]);
        for (int j = 1; j < min(k, i); j++)
        {
            temp = min(temp, arr[i - j - 1] + fabs(h[i] - h[i - j - 1]));
        }
        arr[i] = temp;
    }
    printf("%lld\n", arr[n - 1]);
    return 0;
}

Measured memory_bytes: 1664
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}

int main(){
  int r,w,c,sr,res;
  while(scanf("%d%d%d%d",&r,&w,&c,&sr),r!=0){
    res=0;
    while(r<w*c){
      r+=sr;
      res++;
    }
    printf("%d\n",res);
  }
  return 0;
}



Measured memory_bytes: 2096
#include <iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<string>

#define REP(i,n) for(int i=0;i<n;i++)

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<long> v(n);
    long dum;
    long sum = 0;
    REP(i,n) {
        cin >> dum;
        v[i] = dum;
        sum += dum;
    }

    vector<long> a(n);

    a[0] = sum;
    for (int i=1;i<n/2+1;i++) a[0] -= 2*v[2*i-1];
    
    for (int i=1;i<n-1;i++) a[i] = 2*v[i-1] - a[i-1];
    a[n-1] = 2*v[n-1] - a[0];

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


Measured memory_bytes: 2944
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<cstring>
#include<sstream>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
	int n;
	cin >> n;
	vector<long> a(n);
	long b[n];
	rep(i,0,n){
		cin >> a[i];
		b[i] = a[i];
	}
	
	vsort(a);
	long m = a[n/2-1];
	long M = a[n/2];


	rep(i,0,n){
		if(b[i] < M  ){
			P(M);
		}
		else{
			P(m);
		}
	}	
	
	
	ret 0;
}

Measured memory_bytes: 5248
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int D = sc.nextInt();

        
        int n=1;
        for(int i =1; i<=20; i++) {
            if( (2*D+1)*i >= N) {
                n = i;
                break;
            }
        }
        
        System.out.println( n);
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h> 
    //#define M_PI 3.14159265358979323846



using namespace std;

#define rep(i,a,b) for(int i=a;i<b;++i)
#define repb(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vl vector<long long int>
#define vc vector<char>
#define vld vector<ld>
#define vvi vector<vector<int> >
#define vvl vector<vector<long long> >
#define vvld vector<vector<ld> >
#define vpii vector<pii>
#define vpll vector<pll>
#define ld long double
#define ll long long
#define sz(a) (ll)a.size()
#define ssortA(arr)   stable_sort(arr.begin(),arr.end())
#define ssortB(arr)   stable_sort(arr.begin(),arr.end(),greater<pair<int,int> >());
#define pii pair<int,int>
#define pll pair<long long,long long>
#define ff first
#define ss second
#define search(arr,c)  binary_search(arr.begin(),arr.end(),c)
#define pb   push_back
#define pf push_front
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define endl "\n" 
#define PI acos(-1.0)
#define GCD(a,b) __gcd(a,b)
#define popcount(x) __builtin_popcountll(x)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define fix(f,n) fixed<<setprecision(n)<<f<<endl
#define checkin(ds, a) (ds.find(a)!=ds.end()?1:0)
#define mem(arr)  memset(arr,0,sizeof(arr))
const int M=(int)1e9+7;
int main(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll maxi=LLONG_MIN;
    maxi=max(maxi,a*c);
    maxi=max(maxi,a*d);
    maxi=max(maxi,b*c);
    maxi=max(maxi,b*d);
    cout<<maxi<<endl;
}

Measured memory_bytes: 3620
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if (x < y) x = y; }


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

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

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

	ModInt inverse() const {
		signed a = x, b = MOD, u = 1, v = 0;
		while (b) {
			signed t = a / b;
			a -= t * b; std::swap(a, b);
			u -= t * v; std::swap(u, v);
		}
		if (u < 0) u += Mod;
		ModInt res; res.x = (unsigned)u;
		return res;
	}
};

typedef ModInt<1000000007> mint;
vector<mint> fact, factinv;
void nCr_computeFactinv(int N) {
	N = min(N, mint::Mod - 1);
	fact.resize(N + 1); factinv.resize(N + 1);
	fact[0] = 1;
	rer(i, 1, N) fact[i] = fact[i - 1] * i;
	factinv[N] = fact[N].inverse();
	for (int i = N; i >= 1; i--) factinv[i - 1] = factinv[i] * i;
}
mint nCr(int n, int r) {
	if (n >= mint::Mod)
		return nCr(n % mint::Mod, r % mint::Mod) * nCr(n / mint::Mod, r / mint::Mod);
	return r > n ? 0 : fact[n] * factinv[n - r] * factinv[r];
}


int main() {
	int N;
	while (~scanf("%d", &N)) {
		nCr_computeFactinv(N);
		int A; int B; int C; int D;
		scanf("%d%d%d%d", &A, &B, &C, &D);
		vector<vector<mint>> dp(B + 2, vector<mint>(N + 1));
		dp[A][N] = 1;
		rer(i, A, B) rer(n, 0, N) {
			mint x = dp[i][n];
			if (x.x == 0) continue;
			int m = n;
			mint y = x;
			for (int f = 0; m >= 0; ++ f) {
				if(f == 0 || (C <= f && f <= D))
					dp[i + 1][m] += y * factinv[f];
				y *= nCr(m, i);
				m -= i;
			}
		}
		mint ans = dp[B + 1][0];
		printf("%d\n", ans.get());
	}
	return 0;
}


Measured memory_bytes: 4224
#include <iostream>
#include <string>
#include <sstream>
#include <vector>

using namespace std;

vector<string> Split(const string& src, char delimiter) {
    vector<string> v;
    stringstream ss(src);
    string buffer;
    while (getline(ss, buffer, delimiter)) {
        v.push_back(buffer);
    }
    return v;
}

template <typename T>
void WriteArray(const vector<T>& v) {
    for (auto iterator = v.begin(); iterator != v.end(); iterator++) {
        cout << *iterator << (iterator + 1 != v.end() ? " " : "");
    }
    cout << endl;
}

template <typename T>
bool IsEqual(const vector<T>& v1, const vector<T>& v2) {
    if (v1.size() != v2.size()) return false;
    for (int i = 0; i < v1.size(); i++) {
        if (v1[i] != v2[i]) return false;
    }
    return true;
}

int main() {
    int len;
    cin >> len;
    vector<string> str(len);
    for (int i = 0; i < len; i++) cin >> str[i];

    vector<string> strCp1(str);

    strCp1 = str;

    //BubbleSort
    for (int i = 0; i < strCp1.size(); i++) {
        for (int j = strCp1.size() - 1; j > i; j--) {
            if (strCp1[j][1] < strCp1[j - 1][1]) swap(strCp1[j], strCp1[j - 1]);
        }
    }

    WriteArray(strCp1);
    cout << "Stable" << endl;

    vector<string> strCp2(str);
    
    //SelectionSort
    for (int i = 0; i < strCp2.size(); i++) {
        int minj = i;
        for (int j = i; j < strCp2.size(); j++) {
            if (strCp2[j][1] < strCp2[minj][1]) minj = j;
        }
        swap(strCp2[i], strCp2[minj]);
    }

    WriteArray(strCp2);
    cout << (IsEqual(strCp1, strCp2) ? "Stable" : "Not stable") << endl;

    return 0;
}

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

const int N = 4005;

int i, j, n, k, x, y, a[N][N], rs;
char c;

int getSquare(int x, int y, int xx, int yy) {
  if (xx < 0 || yy < 0) return 0;
  int ans = a[xx][yy];
  if (x > 0) ans -= a[x - 1][yy];
  if (y > 0) ans -= a[xx][y - 1];
  if (x > 0 && y > 0) ans += a[x - 1][y - 1];
  return ans;
}

int main() {
  ios_base::sync_with_stdio(0);

  cin >> n >> k;
  for (i = 1; i <= n; ++i) {
    cin >> x >> y >> c;
    if (c == 'B') y += k;
    x %= 2 * k;
    y %= 2 * k;
    ++a[x + 1][y + 1];
  }

  for (i = 1; i < N; ++i)
    for (j = 1; j < N; ++j)
      a[i][j] += a[i - 1][j] + a[i][j - 1] - a[i - 1][j - 1];

  for (i = 1; i <= 2 * k; ++i)
    for (j = 1; j <= 2 * k; ++j) {
      int aux = getSquare(i - k + 1, j - k + 1, i, j);
      aux += getSquare(i - 2 * k + 1, j - 2 * k + 1, i - k, j - k);
      aux += getSquare(i - 2 * k + 1, j + 1, i - k, j + k);
      aux += getSquare(i + 1, j - 2 * k + 1, i + k, j - k);
      aux += getSquare(i + 1, j + 1, i + k, j + k);
      aux += getSquare(i - k + 1, j + k + 1, i, j + 2 * k);
      aux += getSquare(i + k + 1, j - k + 1, i + 2 * k, j);
      rs = max(rs, aux);
    }

  cout << rs << '\n';
  
  return 0;
}



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

int main()
{
    int n, s=0, cost=0, mn=INT_MAX;
    cin>>n;
    int a[n];
    for(int i=0;i<n;++i)
    {
        cin>>a[i];
        s+=a[i];
    }
    if(s%n!=0)
    {
        s = (s/n)+1;
        for(int i=0;i<n;++i)
        cost+=(abs(a[i]-s)*abs(a[i]-s));
        mn = min(mn, cost);
        cost=0;
        s--;   
        for(int i=0;i<n;++i)
        cost+=(abs(a[i]-s)*abs(a[i]-s));
        mn = min(mn, cost);
        cost=0;
        s--;   
        for(int i=0;i<n;++i)
        cost+=(abs(a[i]-s)*abs(a[i]-s));
        mn = min(mn, cost);
        cout<<mn<<endl;
    }
    else
    {
        s/=n;
        for(int i=0;i<n;++i)
        cost+=(abs(a[i]-s)*abs(a[i]-s));
        cout<<cost<<endl;
    }
    return 0;
}

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

#define int long long
const int N = 1e5 + 5;
const int MOD = 1e9 + 7;

int n;
string s;
int dp[N][15];

int solve(int curr, int so_far)
{
      if(curr == n)
            return(so_far == 5);

      int &res = dp[curr][so_far];
      if(res != -1)
            return res;

      res = 0;

      if(s[curr] == '?')
      {
            int tmp;
            for(int dig = 0; dig <= 9; dig++)
            {
                  tmp = (so_far * 10 + dig) % 13;
                  res += solve(curr + 1, tmp);
                  res %= MOD;
            }
      }
      else
      {
            int dig = s[curr] - '0';
            so_far = (so_far * 10 + dig) % 13;
            res += solve(curr + 1, so_far);
            res %= MOD;
      }
      return res;

}

int32_t main()
{
      cin >> s;
      n = s.size();
      memset(dp, -1, sizeof(dp));
      cout << solve(0, 0);

      return 0;
}


Measured memory_bytes: 18432
let split_string ?(pattern="") = Str.split @@ Str.regexp pattern
let n = Scanf.sscanf (read_line ()) "%d" @@ fun n -> n
let s = read_line () |> split_string |> List.sort compare

let m_1e9 = int_of_float 1e9 + 7
let ( +^ ) x y = (x + y) mod m_1e9
let ( -^ ) x y = x - y + if x < y then m_1e9 else 0
let ( *^ ) x y = ((x mod m_1e9) * (y mod m_1e9)) mod m_1e9

let ss = List.fold_left (fun acc n ->
  match acc with
    | [] -> [(n, 1)]
    | (v, cnt) as t :: xs -> if v = n then (v, cnt + 1) :: xs else (n, 1) :: t :: xs
) [] s

let () = 
    Printf.printf "%d\n" @@ List.fold_left (fun sum (_, i) -> sum *^ (i + 1)) 1 ss -^ 1

Measured memory_bytes: 17052
#!/usr/bin/env python3
import sys

H, W = map(int, input().split())
a = ""
for i in range(H):
    a += input()

# count = {}
count_all = len(a)
count_4 = 0
count_2 = 0
count_1 = 0

for s in "abcdefghijklmnopqrstuvwxyz":
    # count[s] = a.count(s)
    c = a.count(s)
    count_4 += c//4
    c = c%4
    count_2 += c//2
    c = c%2
    count_1 += c

if W%2 == 1 and H%2 == 0:
    W, H = H, W

# sys.stderr.write(str(321))
if W%2 == 0 and H%2 == 0:
    sys.stderr.write(str((count_4, W*(H-1)//4)))
    if count_4 < W*H//4:
        print("No")
    else:
        print("Yes")
elif W%2 == 0 and H%2 == 1:
    if count_4 < W*(H-1)//4:
        # print(count_4, W*(H-1)//4)
        sys.stderr.write(str((count_4, W*(H-1)//4)))
        print("No")
    elif 2*(count_4 - W*(H-1)//4) + count_2 < W//2:
        print("No")
    else:
        print("Yes")
else:
    if count_4 < (W-1)*(H-1)//4:
        print("No")
    elif 2*(count_4 - (W-1)*(H-1)//4) + count_2 < (W+H-2)//2:
        print("No")
    else:
        print("Yes")


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

using ll = long long;

// 区間の情報を二分木で管理
struct LazySegmentTree{
    // 配列サイズを 2 べきにしたときのサイズ
    int sz;
    // 1-indexed で管理
    vector<ll> data;
    vector<ll> lazy;

    LazySegmentTree(int n){
        sz = 1;
        while(sz < n)   sz <<= 1;
        data.assign(sz << 1, 0);
        lazy.assign(sz << 1, 0);
    }

    void set(int idx, const int& x){
        data[idx + sz] = x;
    }

    // k : セグメント木上のインデックス
    //     (set された配列のどの区間かを表す)
    void build(){
        for(int k = sz - 1; k >= 0; --k){
            data[k] = max(data[k << 1], data[k << 1 | 1]);
        }
    }

    // 子ノードへの伝播
    void propagate(int k){
        if(lazy[k] == 0)    return;

        if(k < sz){
            lazy[k << 1] += lazy[k];
            lazy[k << 1 | 1] += lazy[k];
        }
        data[k] += lazy[k];
        lazy[k] = 0;
    }

    // [a, b) の各要素に対して x を一様加算
    ll update(int a, int b, const ll& x, int k = 1, int l = 0, int r = -1){
        if(r == -1) r = sz;
        
        propagate(k);

        // 更新する範囲が今見ている区間内にない
        if(b <= l || r <= a)    return data[k];

        // 更新する区間が今見ている区間を内包している
        else if(a <= l && r <= b){
            lazy[k] += x;
            propagate(k);
            return data[k];     // 子ノードの更新は遅延させる
        }

        else{
            return data[k] = max(update(a, b, x, k << 1, l, (l + r) >> 1),
                                update(a, b, x, k << 1 | 1, (l + r) >> 1, r));
        }
    }

    // [a, b) における最大値を取得
    ll query(int a, int b, int k = 1, int l = 0, int r = -1){
        if(r == -1) r = sz;
        
        propagate(k);
        
        if(b <= l || r <= a)    return 0;
        else if(a <= l && r <= b)   return data[k];
        else{
            return max(query(a, b, k << 1, l, (l + r) >> 1),
                        query(a, b, k << 1 | 1, (l + r) >> 1, r));
        }
    }

    ll operator[](const int& idx){
        return query(idx, idx + 1);
    }
};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    vector<vector<pair<int, int>>> table(n + 1);
    for(int i = 0; i < m; ++i){
        int l, r, a;
        cin >> l >> r >> a;
        table[r].emplace_back(l, a);
    }
    LazySegmentTree dp(n + 1);
    for(int i = 1; i <= n; ++i){
        dp.update(i, i + 1, dp.query(0, i));
        for(auto p : table[i]){
            int l = p.first;
            ll a = p.second;
            dp.update(l, i + 1, a);
        }
    }
    cout << dp.query(0, n + 1) << endl;
}

Measured memory_bytes: 19456
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <queue>
#include <vector>
#include <list>

using namespace std;

static const int MAX = 10000;

static const bool DEBUG = false;

vector<int> G[MAX];
list<int> out;
bool V[MAX];
int N;
int indeg[MAX];

void bfs(int s) {
	queue<int> q;
	q.push(s);
	V[s] = true;
	//DEBUG
	if (DEBUG == true) {
		cout << "in BFS 1" << endl;
		cout << "V[i]:" << endl;
		for (int i = 0; i < N; i++) {
			cout << V[i] << " ";
		}
		cout << endl;

		cout << "indeg[i]:" << endl;
		for (int i = 0; i < N; i++) {
			cout << indeg[i] << " ";
		}
		cout << endl;
	}

	while (!q.empty()) {
		int u = q.front(); q.pop();
		out.push_back(u);
		for (unsigned int i = 0; i < G[u].size(); i++) {
			int v = G[u][i];
			indeg[v]--;
			//if (indeg[v] == 0 && !V[v]) {
			if (indeg[v] == 0) {
				V[v] = true;
				q.push(v);
				if (DEBUG == true) {
					//DEBUG
					cout << "in BFS 2" << endl;
					cout << "V[i]:" << endl;
					for (int i = 0; i < N; i++) {
						cout << V[i] << " ";
					}
					cout << endl;

					cout << "indeg[i]:" << endl;
					for (int i = 0; i < N; i++) {
						cout << indeg[i] << " ";
					}
					cout << endl;
				}
			}

		}
	}
}

void tsort() {
	for (int i = 0; i < N; i++) {
		indeg[i] = 0;
	}

	for (int u = 0; u < N; u++) {
		for (unsigned int i = 0; i < G[u].size(); i++) {
			int v = G[u][i];
			indeg[v]++;
		}
	}

	if (DEBUG == true) {
		//DEBUG
		cout << "V[i]: ";
		for (int i = 0; i < N; i++) {
			cout << V[i] << " ";
		}
		cout << endl;

		cout << "indeg[i]: ";
		for (int i = 0; i < N; i++) {
			cout << indeg[i] << " ";
		}
		cout << endl;
	}


	for (int u = 0; u < N; u++) {
		if (indeg[u] == 0 && !V[u]) {
			bfs(u);
		}
	}

	for (list<int>::iterator it = out.begin(); it != out.end(); it++) {
		cout << *it << endl;
	}
}

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

	for (int i = 0; i < N; i++) V[i] = false;

	for (int i = 0; i < M; i++) {
		cin >> s >> t;
		G[s].push_back(t);
	}

	tsort();

	return 0;
}

Measured memory_bytes: 2208
#include <stdio.h>

int main()
{
	int n;
	scanf("%d", &n);
	
	while(n > 0)
	{
		if(n >= 1000)
		{
			n = n - 1000;
		} else if(n < 1000)
		{
			n = (n - 1000) * -1;
			break;
		}
	}
	printf("%d", n);

	
	return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
const int MAX_N=105;
const int MAX_W=100050;
long long dp[MAX_N][MAX_W];
int w[MAX_N],v[MAX_N];
int main()
{
	int n,W;
	scanf("%i %i",&n,&W);
	for(int i=1;i<=n;i++)
	{
		scanf("%i %i",&w[i],&v[i]);
	}
	for(int j=0;j<=W;j++)
	{
		dp[0][j]=0;
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=W;j++)
		{
			dp[i][j]=dp[i-1][j];
            if(j>=w[i])
			{
				dp[i][j]=max(dp[i][j],dp[i-1][j-w[i]]+v[i]);
			}
		}
	}
	printf("%lld\n",dp[n][W]);
	return 0;
}

Measured memory_bytes: 80128
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    ABC=[tuple(map(int,input().split())) for i in range(n)]
    dp=[[0,0,0]for _ in range(n+1)] #i日目にjをするときの幸福度の総和
    for i in range(n):
        ni=i+1
        dp[ni][0]=max(dp[i][1],dp[i][2])+ABC[ni-1][0]
        dp[ni][1]=max(dp[i][0],dp[i][2])+ABC[ni-1][1]
        dp[ni][2]=max(dp[i][0],dp[i][1])+ABC[ni-1][2]
    print(max(dp[n]))

if __name__=='__main__':
    main()

Measured memory_bytes: 40244
import difflib

S = input()
T = input()

A = len(S)
B = len(T)

moji = []

for i in range(A-B+1):
  moji.append(S[i:i+B])
  

cnt = 0
cnt_list = []
for i in range(len(moji)):
  for j in range(B):
    if moji[i][j] != T[j]:
      cnt += 1
  cnt_list.append(cnt)
  cnt = 0
  
print(min(cnt_list))

Measured memory_bytes: 10064
#include <bits/stdc++.h>
using namespace std;
template <typename T> bool chmax(T &u, const T z) { if (u < z) {u = z; return true;} else return false; }
template <typename T> bool chmin(T &u, const T z) { if (u > z) {u = z; return true;} else return false; }
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long 

int main(){
	int n;
	cin>>n;
	vector<long long>a(n);
	rep(i,n)cin>>a[i];
	long long wa=0;
	long long saidai=a[0];
	for(int i=1;i<n;i++){
		if(saidai >a[i])wa+=saidai-a[i];
		saidai=max(saidai,a[i]);
	}
	cout<<wa<<endl;
	return 0;
}

Measured memory_bytes: 4712
const main = (input) => {
  input = input.trim().split('\n')
  const [H, W, K] = input[0].split(' ').map(Number)
  const grid = input.slice(1)

  let ans = 0

  const r = (hr, wr, count) => {
    if (count === H + W) {
      let count = 0
      for (let h=0; h<H; h++) {
        if (hr.includes(h)) continue
        for (let w=0; w<W; w++) {
          if (wr.includes(w) && grid[h][w] === '#') count++
        }
      }
      if (count === K) ans++
      return null
    }

    if (count < H) {
      r([...hr, count], wr, count + 1)
      r(hr, wr, count + 1)
    } else {
      r(hr, [...wr, count - H], count + 1)
      r(hr, wr, count + 1)
    }
  }

  r([], [], 0)

  console.log(ans)
}

process.env.MYTEST ? test() : main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 33540
#include <iostream>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
using namespace std;

int main() {
    vector <int> vSize(2);
    long long K;

    cin >> vSize[0] >> vSize[1] >> K;

    vector< vector <int> > A(2);
    vector< vector <long long> > acc(2);

    for (int i = 0; i < 2; ++i) {
        A[i] = vector<int>(vSize[i]);
        acc[i] = vector<long long>(vSize[i]+1);

        for (int j = 0; j < vSize[i]; ++j) {
            cin >> A[i][j];
            acc[i][j+1] = acc[i][j] + A[i][j];
        }
    }



    int ans = 0;

    for (int i = 0; i <= vSize[0]; ++i) {
        if (acc[0][i] > K) {
            break;
        }

        int low = 0;
        int up = vSize[1];
        int mid = 0;
        int best = 0;

        while (low <= up) {
            mid = (low + up) / 2;

            if (acc[1][mid] + acc[0][i] <= K) {
                best = mid;
                low = mid+1;
            } else {
                up = mid-1;
            }
        }

        ans = max(ans, i+best);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 7944
v, e = gets.split.map(&:to_i)
vst = [false]*v
g = v.times.map{[]}
rg = v.times.map{[]}
e.times do
  s,t = gets.split.map(&:to_i)
  g[s] << t
  rg[t] << s
end
cnt = 0
while vst.any?{ |e| !e }
  rg.each_with_index do |arr, i|
    if arr.empty? && !vst[i]
      vst[i] = cnt
      g[i].each{|t| rg[t].delete(i)}
      break
    end
  end
  cnt += 1
end
vst.map.with_index{|e, i| [e, i]}.sort.each{|a| p a[1]}

Measured memory_bytes: 12644
#include<iostream>
using namespace std;
int main()
{
    long long int A,M,N,v,s=0;
    cin>>N>>M;
    for(int i=1;i<=M;i++)
    {
        cin>>A;
        s=s+A;
    }
    v=N-s;
    if(v>0||v==0)
    cout<<v;
    else
        cout<<-1;
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  double n, k;
  cin >> n >> k;
  double ans = 0;
  rep2(i, 1, n + 1) {
    double now = i, cnt = 0;
    while(now < k) {
      now *= 2;
      cnt += 1;
    }
    ans += 1 / pow(2, cnt);
  }
  ans /= n;
  printf("%.12f\n", ans);
}

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

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)

int main(){
  const int M = 1000000007;
  int n;
  cin >> n;
  vector<uint64_t> a(n);
  REP(i, n) cin >> a[i];
  sort(a.begin(), a.end());
  uint64_t r = 0;
  REP(i, n){
    r += a[n - i - 1] * (i + 2);
    r %= M;
  }
  REP(i, n - 1){
    r *= 4;
    r %= M;
  }
  cout << r << endl;
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	string s;
  cin>>s;
  stack<char>st;
  ll ans=0;
  for(ll i=0;i<s.length();i++)
  {
    if(s[i]=='T')
    {
      if(st.empty())
        ans++;
      else
        st.pop();
    }
    else
    {
      st.push(s[i]);
    }
  }
  ans+=st.size();
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3724
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i = (int)(b-1);i>=(int)(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;
 
signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);
  
  int r,g,b,n;
  cin >> r >> g >> b >> n;

  int ans = 0;

  REP(i, n + 1) REP(j, n + 1){
    double tmp_d = (double)(n - r * i - g * j) / b;
    int tmp_ll = (int)(tmp_d + 0.5);
    if(tmp_d == tmp_ll) ans++; 
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;

const double PI = acos(-1);

int main() {
	int a, b, h, m;
	cin >> a >> b >> h >> m;
	double hh = double(60 * h + m) / 720 * 2 * PI;
  	double mm = double(m) / 60 * 2 * PI;
  	double dd = abs(hh - mm);
	double ans = double(a * a + b * b) - 2 * a * b * cos(dd);
	ans = sqrt(ans);
	printf("%.15f", ans);
}


Measured memory_bytes: 3956
N, M = map(int, input().split())
Alist = [list(input()) for _ in range(N)]
Blist = [list(input()) for _ in range(M)]


def check_in(add_tate, add_yoko):
    for A, B in zip(Alist[add_tate:add_tate + M], Blist):
        try:
            assert A[add_yoko:add_yoko + M] == B
        except AssertionError:
            return False
    return True


from sys import exit
if Alist == Blist:
    print("Yes")
    exit()
for add_tate in range(N - M):
    for add_yoko in range(N - M):
        if check_in(add_tate, add_yoko):
            print("Yes")
            exit()
print("No")


Measured memory_bytes: 3064
let () =
  let a = Scanf.scanf "%d" (fun n -> Array.init n (fun _ -> Scanf.scanf " %d" (fun x -> x-1))) in
  let rec f c x =
    if a.(x) < 0 then -1
    else if a.(x) = 1 then c
    else (let x' = a.(x) in a.(x) <- -1; f (c+1) x') in
  f 1 0 |> Printf.printf "%d\n"


Measured memory_bytes: 5376
#include <iostream>
using namespace std;
int main(int argc, char const *argv[])
{
	int a,b;
	cin>>a>>b;
	if(a * b == 15)
	{
		printf("*");
	}
	else if(a + b == 15)
	{
		printf("+");
	}
	else
	{
		printf("x");
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
a = []
for _ in range(3):
    at = [int(num) for num in input().split()]
    a.append(at)
b = [[0,0,0] for _ in range(3)]
n = int(input())
for t in range(n):
    num = int(input())
    for i in range(3):
        for j in range(3):
            if num == a[i][j]:
                b[i][j] = 1
                
ans = "No"
for i in range(3):
    if b[i][0] == 1 and b[i][1] == 1 and b[i][2] == 1:
        ans = "Yes"
for j in range(3):
    if b[0][j] == 1 and b[1][j] == 1 and b[2][j] == 1:
        ans = "Yes"
if b[0][0] * b[1][1] * b[2][2] == 1:
    ans = "Yes"
if b[0][2] * b[1][1] * b[2][0] == 1:
    ans = "Yes"
    
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
int main(void){
  int h,a,ans=0,i;
  scanf("%d%d",&h,&a);
 for(i=1;i<=10000;i++){
   h-=a; 
   ans++;
    
   if(h<=0){
     
    printf("%d",ans);
     return 0;
   }
 }
 
 
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void)
{
  int a,b;
  int flag=0;
  int tmp;
  scanf("%d %d",&a,&b);
  tmp=b;

  do{
    a*=10;
    b/=10;
  }while(b>0);
  tmp+=a;
  for(int i=0;i<=10000;i++){
    if(tmp==i*i){
      flag=1;
      break;
    }else{
      flag=0;
    }
  }
  if(flag==1){
    puts("Yes");
  }else{
    puts("No");
  }
  return 0;
}


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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int m1,d1,d2,m2;
  cin >> m1 >> d1;
  cin >> m2 >> d2;
  if(m1 != m2){
    cout << 1<< endl;
  }else cout << 0 << "\n";
  return 0;
}


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

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define MOD 1000000007

int main() {
    ll n, x, m;
    cin >> n >> x >> m;
    vector<int> id(m, -1);
    vector<int> a;
    int len = 0;
    ll tot = 0;
    while (id[x] == -1) {
        a.push_back(x);
        id[x] = len;
        len++;
        tot += x;
        x = x * x % m;
    }
    int c = len - id[x];
    ll sum = 0;
    rep2(i, id[x], len) {
        sum += a[i];
    }

    ll ans = 0;
    if (n <= len) {
        rep(i, n) {
            ans += a[i];
        }
    } else {
        ans += tot;
        n -= len;
        ans += sum * (n / c);
        n %= c;
        rep(i, n) {
            ans += a[id[x] + i];
        }
    }
    cout << ans << endl;
    return 0;
}

// int main() {
//     ll n, x, m;
//     cin >> n >> x >> m;
//     vector<ll> head, loop;
//     head.push_back(x);
//     ll interval;
//     rep(i, n - 1) {
//         ll tmp = head[i] * head[i] % m;
//         auto it = find(head.begin(), head.end(), tmp);
//         if (it != head.end()) {
//             loop = vector<ll>(it, head.end());
//             interval = loop.size();
//             head.erase(it, head.end());
//             break;
//         }
//         head.push_back(tmp);
//     }
//     ll sum = 0;
//     for (auto e : head) {
//         sum += e;
//     }
//     if (!loop.size()) {
//         cout << sum << endl;
//         return 0;
//     }
//     cout << "head.size: " << head.size() << endl;
//     ll remain = n - head.size();
//     ll div = remain / loop.size();
//     ll mod = remain % loop.size();
//     for (auto e : loop) {
//         sum += div * e;
//     }
//     rep(i, mod) {
//         sum += loop[i];
//     }
//     cout << sum << endl;
//     cout << "interval: " << interval << endl;
//     cout << "head:" << endl;
//     for (auto e : head) {
//         cout << e << endl;
//     }
//     cout << "loop:" << endl;
//     for (auto e : loop) {
//         cout << e << endl;
//     }
//     return 0;
// }


Measured memory_bytes: 4056
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, a, b;
	cin >> n >> a >> b;
	vector<int> ans(n);
	if(a == 1){
		if(n == b){
			rep(i,n) cout << n-i << " ";
			cout << endl;
		}
		else{
			cout << -1 << endl;
		}
	}
	else if(b == 1){
		if(n == a){
			rep(i,n) cout << i+1 << " ";
			cout << endl;
		}
		else{
			cout << -1 << endl;
		}
	}
	else if(n <= a || n <= b){
		cout << -1 << endl;
	}
	else{
		if(a <= b){
			rep(i,a) ans[i] = n - a + i + 1;
			int bound = n - a + 1;
			if(b < 2 || a < (n - a + b - 2) / (b - 1) || bound < b){
				cout << -1 << endl;
			}
			else{
				int idx = a;
				int cnt = 1;
				while(idx < n){
					rep(i,b-1){
						ans[idx++] = min(n - a - i, (b - 1) * cnt - i);
						if(idx == n) break;
					}
					++cnt;
				}
				rep(i,n) cout << ans[i] << " ";
				cout << endl;
			}
		}
		else{
			rep(i,b) ans[i] = b - i;
			int bound = n - b + 1;
			if(a < 2 || b < (n - b + a - 2) / (a - 1) || bound < a){
				cout << -1 << endl;
			}
			else{
				int idx = b;
				int cnt = 1;
				while(idx < n){
					rep(i,a-1){
						ans[idx++] = max(b + 1 + i, n - (a - 1) * cnt + i + 1);
						if(idx == n) break;
					}
					++cnt;
				}
				rep(i,n) cout << ans[i] << " ";
				cout << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 4492
def solve():
    """
    基本方針:
        a <= b <= c で三角形を作る.
        a, b を決定して取りうる c を計算で求める(O(N ** 2)).
    """
    MAX_LENGTH = 10 ** 3
    N = input()
    L = [int(i) for i in input().split()]
    L.sort()

    # 移動和を求められるようにしておく
    O = [0] * (MAX_LENGTH + 1)
    for l in L:
        O[l] += 1
    O2 = [0] * (MAX_LENGTH + 1)
    for i in range(1, MAX_LENGTH + 1):
        O2[i] = O2[i - 1] + O[i]

    # △カウント
    sum_count = 0
    for i in range(len(L)):
        a = L[i]
        for j in range(i + 1, len(L)):
            b = L[j]
            # c の上限の決定
            c_high = a + b - 1
            if c_high > MAX_LENGTH:
                c_high = MAX_LENGTH
            # △の数加算
            sum_count += O2[c_high] - (j + 1)  # b <= c なので 1 ~ b までの辺を除外
            # print(i, j , O2[c_high] - (j + 1))

    print(sum_count)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
#define myCeil(dividend, divisor) ceil((double)(dividend) / (double)(divisor))
#define myFloor(dividend, divisor) floor((double)(dividend) / (double)(divisor))
#define calcDigits(num) floor(log10(num))+1

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl;
#define dv(name, value) cerr << (name) << " is " << (value) << endl;
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl;
#define dpa(v) cerr << "[ " << endl;REPI(itr, v) { cerr << "  [" << (*itr).first << ", " << (*itr).second << ']' << (itr != --v.end() ? "," : "") << endl; } cerr << "]" << endl;


void solve(long long N){
  cout << (ll)pow(N, 3.0) << endl;
}

signed main(){
  long long N;
  scanf("%lld",&N);
  solve(N);
}


Measured memory_bytes: 384
'''
問題：
    二つの長方形があります。
    一つ目の長方形は、縦の辺の長さが A、横の辺の長さが B です。
    二つ目の長方形は、縦の辺の長さが C、横の辺の長さが D です。

    この二つの長方形のうち、面積の大きい方の面積を出力してください。 なお、二つの長方形の面積が等しい時は、その面積を出力してください。
'''

'''
制約：
    入力は全て整数である
    1 ≦ A ≦ 10000
    1 ≦ B ≦ 10000
    1 ≦ C ≦ 10000
    1 ≦ D ≦ 10000
'''

# 標準入力から A, B, C, D の値を取得する
a, b, c, d = map(int, input().split())

result = [a * b, c * d] # 結果格納用リスト
print(max(result))


Measured memory_bytes: 9124
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
function unionFind(n){
  this.a=[];for(var i=0;i<=n;i++)this.a[i]=i;
}
unionFind.prototype={
  root:function(x){var a=this.a;return a[x]===x?x:a[x]=this.root(a[x]);},
  same:function(x,y){return this.root(x)===this.root(y);},
  unite:function(x,y){x=this.root(x);y=this.root(y);if(x!==y)this.a[x]=y;},
}

console.log(main());
function main(){
  var n = o.a();
  var m = o.a();
  var uf = new unionFind(n);
  var ans = n;
  for(var i = 0; i < m; i++){
    var t = o.l();
    var x = t[0], y = t[1], z = t[2];
    if(uf.same(x, y))continue;
    uf.unite(x, y);
    ans--;
  }
  return ans;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define printYes() cout << "Yes" << endl;
#define printNo() cout << "No" << endl;
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  int D, N;
  cin >> D >> N;
  D = pow(100, D);
  if (N == 100)
    N++;
  int ans = D * N;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <set>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <map>

using namespace std;


namespace {
	const map<int, int> param{ {3, 0b100}, { 5, 0b010 }, { 7,0b001 } };
}

int DFS(long long tmpN, int N, unsigned bitFlags, int depth) // tmpNは一時的に1e10になる。
{
	if (tmpN > N) {
		return 0;
	}

	int sum = 0;
	if (bitFlags == 0b111) {
		sum = 1;
	}

	for (const auto& elem : param) {
		sum += DFS(tmpN * 10 + elem.first, N, bitFlags | elem.second, depth + 1);
	}
	//DFS(tmpN + 5 * 10, N, bit | 0b100);
	//DFS(tmpN + 7 * 10, N, bit | 0b100);
	return sum;
}


int main()
{
	int N = 0;
	cin >> N;

	unsigned bitFlags(0b00); // 3, 5, 7 
	cout << DFS(0, N, bitFlags,0) << endl;

	return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)
var ReadString func() string
var ReadLine func() string
var ReadInt64 func() int64
var ReadInt func() int
var ReadIntSlice func(int) []int
var ReadInt64Slice func(int) []int64
var GetIntAbs func(int) int
var Atoi func(string) int
var FindMin func([] int) int
var FindMax func([] int) int
var StrReverse func(string) string

func init() {
	ReadString = newReadString()
	ReadLine = readLine
	ReadInt64 = readInt64
	ReadInt = readInt
	ReadIntSlice = readIntSlice
	FindMin = findMin
	FindMax = findMax
	StrReverse = strReverse
	GetIntAbs = getIntAbs
}

func main() {
  n := ReadInt()
  a := ReadIntSlice(n)
  child := 0.0
  for _, v := range a {
    child += 1.0 / float64(v)
  }
  rs := 1.0 / child
  fmt.Println(rs)
}

func strReverse(s string) string {
	runes := []rune(s)
	l := len(runes)
	for i, j := 0, l-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}


func newReadString() func() string {
	sc.Buffer(make([]byte, 202400), 404800)
	sc.Split(bufio.ScanWords)
	return func() string {
		if !sc.Scan() {
			panic("scanできなかった")
		}
		return sc.Text()
	}
}

func readLine() string {
	if !sc.Scan() {
		panic("line をscanできなかった")
	}
	return sc.Text()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		fmt.Println("parseInt失敗")
		panic(err.Error())
	}
	return int64(i)
}

func readInt() int {
	i := ReadInt64()
	return int(i)
}

func readIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ReadInt()
	}
	return arr
}

func readInt64Slice(n int) []int64 {
	arr := make([]int64, n)
	for i := 0; i < n; i++ {
		arr[i] = ReadInt64()
	}
	return arr
}

/*------ number util ------*/

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

func atoi(a string) int {
	i, err := strconv.Atoi(a)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func findMin(arr []int) int {
	if len(arr) == 0 {
		return 0
	}
	min := arr[0]
	for _, v := range arr {
		if v < min {
			min = v
		}
	}
	return min
}

func findMax(arr []int) int {
	if len(arr) == 0 {
		return 0
	}
	max := arr[0]
	for _, v := range arr {
		if v > max {
			max = v
		}
	}
	return max
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;
const int INF = 1001001001;

int main(){
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> key;
  rep(i, m){
    int a, b;
    cin >> a >> b;
    int s = 0;
    rep(j, b){
      int c;
      cin >> c;
      --c;
      s |= 1<<c;
    }
    key.emplace_back(a, s);
  }

  vector<int> dp(1<<n, INF);
  dp[0] = 0;
  rep (s, 1<<n) {
    rep(i, m) {
      int t = s | key[i].second;
      int cost = key[i].first + dp[s];
      dp[t] = min(cost, dp[t]);
    }
  }
  int ans = dp.back();
  if(ans == INF) ans = -1;
  cout << ans << endl;
}

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

using namespace std;

#define long long long
#define INF ((long) 2e18)
#define MOD ((long) (1e9 + 7))
#define umap unordered_map

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

    long t = 1;
    //cin >> t;

    while (t--) {
        long a, b;
        cin >> a >> b;

        for (long x = 1; x < 1e4; x++) {
            if ((long) (x * 0.08) == a and (long) (x * 0.1) == b) {
                printf("%lld\n", x);
                return 0;
            }
        }
        puts("-1");
    }
}


Measured memory_bytes: 3744
/*
  -------------
  Prateek Celly
  DA-IICT
  -------------
*/
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
#define PB push_back
#define ff first
#define ss second
#define MOD 1000000007
 
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll a,b;
  cin>>a>>b;
  if(a<=5) cout<<0;
  else if(a<13) cout<<b/2;
  else cout<<b;
  return 0;
}

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

int main() {
  string s;
  cin >> s;
  if(s == "ABC") cout << "ARC" << endl;
  else cout << "ABC" << endl;
}


Measured memory_bytes: 3592
#include <stdio.h>
#include <stdlib.h>

#define P 1000000007

// a^x
long m(long a, int x){
	if(x==0) return 1;
	long b = m(a, x/2);
	if(x%2==0){
		b = b*b%P;
	}else{
		b = b*b%P*a%P;
	}
	return b;
}

// 1/a
long r(long a){
	return m(a, P-2);
}

// a!
long k(long a){
	long b=1;
	while(a>0){
		b=b*a%P;
		a--;
	}
	return b;
}

// (a+b)! / (a! b!)
long f(int a, int b){
	return r(k(a))*r(k(b))%P*k(a+b)%P;
}

int main(void){
	int r1, r2, c1, c2;
	scanf("%d%d%d%d\n", &r1, &c1, &r2, &c2);
	long ans = f(c2+1, r2+1) + f(c1, r1) - f(c2+1, r1) - f(c1, r2+1) + P*2;
	printf("%ld\n", ans%P);
}


Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using u64 = uint_fast64_t;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln = '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true;} return false; }
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true;} return false; }
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
void print() { cout << "\n"; }
template<class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<ll> X(N),Y(N);
    rep(i,N) cin >> X[i] >> Y[i];

    vector<ll> d;
    vector<string> ans(N);
    rep(i,N) {
        if (abs(X[i]+Y[i])%2 != abs(X[0]+Y[0])%2) {
            cout << -1 << ln;
            return 0;
        }
    }
    if (abs(X[0]+Y[0])%2==0) {
        d.emplace_back(1);
        rep(i,N) {
            X[i]--;
            ans[i] += 'R';
        }
    }
    vector<ll> XX(N),YY(N);
    ll offset = (1LL<<31)-1;
    rep(i,N) {
        XX[i] = (X[i] + Y[i] + offset) >> 1;
        YY[i] = (X[i] - Y[i] + offset) >> 1;
    }
    rep(i,31) d.emplace_back(1LL<<i);
    rep(i,N) {
        rep(bit,31) {
            ll x = ((XX[i]>>bit)&1);
            ll y = ((YY[i]>>bit)&1);
            if (x==1 and y==1) ans[i] += 'R';
            else if (x==1 and y==0) ans[i] += 'U';
            else if (x==0 and y==1) ans[i] += 'D';
            else ans[i] += 'L';
        }
    }
    int LOCAL = 0;
    if (LOCAL) {
        int K = d.size();
        rep(i,N) {
            ll x = 0, y = 0;
            rep(j,K) {
                if (ans[i][j]=='R') x += d[j];
                else if (ans[i][j]=='U') y += d[j];
                else if (ans[i][j]=='D') y -= d[j];
                else x -= d[j];
            }
            print(x,y);
        }
    } else {
        cout << d.size() << ln;
        for (auto i : d) cout << i << " ";
        cout << ln;
        rep(i,N) print(ans[i]);
    }
}


Measured memory_bytes: 3808