akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    string n;
    cin >> n;
    if(n.back()=='3'){
        cout << "bon" << endl;
    }
    else if(n.back()== '0'||n.back()== '1'||n.back()== '6'||n.back()== '8'){
        cout << "pon" << endl;
    }
    else{
        cout << "hon" << endl;
    }


	return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using intl = long long;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)((n) - 1); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define INF = 1e9;
#define debug(x) cout << #x << ":" << x << endl
using namespace std;
int main(){
    string s;
    cin >> s;
    char t[s.length()];
    intl cnt = 0;
    rep(i,s.length()){
        if(s[i] == '1'){
            t[cnt] = '1';
            cnt++;
        }
        if(s[i] == '0'){
            t[cnt] = '0';
            cnt++;
        }
        if(s[i] == 'B'){
            if(cnt > 0)cnt--;
        }
    }
    rep(i,cnt){
        cout << t[i];
    }
    return 0;
}

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

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

  int fx = 0;
  for (int i = 8; i >= 0; i--) {
    int n = N_tmp / pow(10, i);
    N_tmp -= n * pow(10, i);
    fx += n;
  }

  if (N % fx == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;

class Program
{
    public static void Main( )
    {

        var input = Console.ReadLine( ).Split( ).Select( long.Parse ).ToArray( );
        long N = input[ 0 ];
        long K = input[ 1 ];
        var A = Console.ReadLine( ).Split( ).Select( long.Parse ).ToArray( );
        var s = new long[A.Length+1];
        s[ 0 ] = 0;
        for ( long i = 1; i < s.Length; i++ )
        {
            s[ i ] = s[ i - 1 ] + A[ i-1 ];
        }

        for ( long i = 0; i < A.Length; i++ )
        {
            if ( K<=i )
            {
                long prevTotal = s[ i ] - s[ i - K ];
                long thisTimeTotal = s[ i + 1 ] - s[ i + 1 - K ];
                Console.WriteLine(prevTotal<thisTimeTotal ? "Yes" : "No");
            }

        }


    }


}

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

using namespace std;

int const inf = 0x3f3f3f3f;
int const maxn = 101010;

int day[maxn][3];
int dp[maxn][3];

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

    for (int i = 0; i < n; i++) {
        for (auto& j : day[i]) {
            cin >> j;
        }
    }

    auto cost = [&] (int i, int t) {
        if (t == 0) {
            return day[i][0] + max(dp[i + 1][1], dp[i + 1][2]);
        }
        else if (t == 1) {
            return day[i][1] + max(dp[i + 1][0], dp[i + 1][2]);
        }
        else {
            return day[i][2] + max(dp[i + 1][0], dp[i + 1][1]);
        }
    };

    for (int i = 0; i < 3; i++) {
        dp[n-1][i] = day[n-1][i];
    }

    for (int i = n-2; i >= 0; i--) {
        for (int j = 0; j < 3; j++) {
            dp[i][j] = cost(i, j);
        }
    }

    cout << max({dp[0][0], dp[0][1], dp[0][2]}) << "\n";
}

Measured memory_bytes: 2560
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function main()
	n,m = readline() |> split |> parseMap
	a = Array{Int}(2,n)
	for i in 1:n
		a[:,i] = readline() |> split |> parseMap
	end
	a = sortcols(a,by=x->x[1])
	t = 0
	y = 0
	i = 1
	while t < m
		if m-t > a[2,i]
			t += a[2,i]
			y += a[2,i]*a[1,i]
			i += 1
		else
			y += a[1,i]*(m-t)
			t = m
		end
	end
	println(y)
end
main()

Measured memory_bytes: 185424
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(string, s);
  VAR(int, K);
  set<string> st;

  int sl = s.length();
  rep(i, 0, max(sl, sl - K)) {
    rep(j, 1, K + 1) {
      st.insert(s.substr(i, j));
    }
  }
  int i = 0;
  each(x, st) {
    if (++i == K) {
      print(x);
      return;
    }
  }
}


Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long lli;

const lli N = 100LL;

lli n, p[N+1], q[N+1], r[N+1], b[N+1];
bool vis[N+1];

lli lcm(lli x, lli y){
  return x * y / __gcd(x, y);
}

lli solve(lli pos){
  lli t1 = 1, t2 = 1;
  if(r[pos]) t1 = solve(r[pos]);
  if(b[pos]) t2 = solve(b[pos]);
  lli tmp = lcm(t1 * p[pos], t2 * q[pos]);
  return tmp / p[pos] + tmp / q[pos];
}

main(){
  while(cin >> n && n){
    fill(vis, vis+N+1, false);
    for(lli i=1;i<=n;i++){
      cin >> p[i] >> q[i] >> r[i] >> b[i];
      lli tmp = __gcd(p[i], q[i]);
      p[i] /= tmp;
      q[i] /= tmp;
      vis[r[i]] = vis[b[i]] = true;
    }
    for(lli i=1;i<=n;i++) if(!vis[i]) cout << solve(i) << endl;
  }
}

Measured memory_bytes: 1160
# -*- coding: utf-8 -*-
import collections
n = int(input())
a = [int(i) for i in input().split()]

ans = 0
c = collections.Counter(a)
for i in set(a):
    if i < c[i]:
        ans += c[i] - i
    elif i > c[i]:
        ans += c[i]
print(ans)


Measured memory_bytes: 20588
#include <iostream>
int main(int argc, char const* argv[])
{

    long long a, b, k;
    std::cin >> a >> b >> k;
    if (a >= k) {
        a -= k;
    } else {
        k -= a;
        a = 0;
        if (b >= k) {
            b -= k;
        } else {
            b = 0;
        }
    }
    std::cout << a << " " << b;
    return 0;
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

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

ll I[9];

ll i, j, k;

int main(){
    fornum(i,0,5){
        scanf("%lld", &I[i]);
    }
    ll a = I[0] * 60 + I[1];
    ll b = I[2] * 60 + I[3];
    printf("%lld", max(0ll, b - a - I[4]));
    return 0;
}

Measured memory_bytes: 3812
// In the Name of Allah. Ya Ali!
#include<bits/stdc++.h>
typedef long long ll;
const ll MAX_N = 400+20;
const ll MOD = 1e9+7;
using namespace std;

ll dp[MAX_N][MAX_N];
ll sum[MAX_N];
ll a[MAX_N];
int n;

int main()
{
    cin >> n;
    for(int i = 1;i<=n;++i)
        cin >> a[i],sum[i] = sum[i-1]+a[i];
    for(int i = 2;i<=n;++i)
    {
        for(int j = 1;j<=n-i+1;++j)
        {
            dp[i][j] = 1e16;
            ll t = sum[i+j-1]-sum[j-1];
            for(int x = 1;x<i;++x)
                dp[i][j] = min(dp[i][j],t+dp[x][j]+dp[i-x][j+x]);
        }
    }
    cout << dp[n][1];
    return 0;
}


Measured memory_bytes: 1536
#!/usr/bin/env python3
import sys
from operator import itemgetter
# gcd
# from fractions import gcd
# 切り上げ，切り捨て
# from math import ceil, floor
# リストの真のコピー（変更が伝播しない）
# from copy import deepcopy
# 累積和。list(accumulate(A))としてAの累積和
# from itertools import accumulate
# l = ['a', 'b', 'b', 'c', 'b', 'a', 'c', 'c', 'b', 'c', 'b', 'a']
# S = Counter(l)  # カウンタークラスが作られる。S=Counter({'b': 5, 'c': 4, 'a': 3})
# print(S.most_common(2))  # [('b', 5), ('c', 4)]
# print(S.keys())  # dict_keys(['a', 'b', 'c'])
# print(S.values())  # dict_values([3, 5, 4])
# print(S.items())  # dict_items([('a', 3), ('b', 5), ('c', 4)])
# from collections import Counter
# import math
# from functools import reduce
#
# input関係の定義
# fin = open('in_3.txt', 'r')
# sys.stdin = fin
# 提出時はコメントアウト+上のshebangを有効にする
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template


def iterate_tokens():
    for line in sys.stdin:
        for word in line.split():
            yield word


if __name__ == '__main__':

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    W = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"

    # write code
    sumW = sum(W)
    ans = 10**9
    for i in range(N+1):
        if abs(sum(W[i:]) - sum(W[:i])) < ans:
            ans = abs(sum(W[i:]) - sum(W[:i]))
    print(ans)



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

#define ll long long
#define ull unsigned long long
#define pb push_back
#define pii pair<int, int>
#define sz size()

template<typename T> inline T gcd(T a, T b) {return (b?gcd(b,a%b):a);}
template<typename T> T lcm(T a, T b) {return (a*(b/gcd(a,b)));}
template<typename T> T mod(T a, T b) {return (a<b ? a : a%b);}
template<typename T> T mod_neg(T a, T b) {a=mod(a, b);if(a<0){a+=b;}return a;}
template<typename T> T power(T e, T n) {T x=1,p=e;while(n){if(n&1)x=x*p;p=p*p;n>>=1;}return x;}
template<typename T> T power(T e, T n, T m) {T x=1%m,p=e%m;while(n){if(n&1)x=mod(x*p,m);p=mod(p*p,m);n>>=1;}return x;}
template<typename T> T extended_euclid(T a, T b, T &x, T &y) {T xx=0,yy=1;y=0;x=1;while(b){T q=a/b,t=b;b=a%b;a=t;t=xx;xx=x-q*xx;x=t;t=yy;yy=y-q*yy;y=t;}return a;}
template<typename T> T mod_inverse(T a, T n) {T x,y;T d = extended_euclid(a, n, x, y);return (d>1?-1:mod_neg(x,n));}

#define int ll
const int MOD = 1e9 + 7;

void add(int &x, int y)
{
	x += y;
	if(x >= MOD)
		x -= MOD;
}

int mul(int x, int y)
{
	return x * y % MOD;
}

int n;

struct mat
{
	vector<vector<int>> m;
	
	mat()
	{
		m.resize(n, vector<int>(n));
	}

	mat operator*(const mat p)
	{
		mat q;
		int i, j, k;
		for(i=0;i<n;++i)
		{
			for(j=0;j<n;++j)
			{
				for(k=0;k<n;++k)
				{
					add(q.m[i][j], mul(m[i][k], p.m[k][j]));
				}
			}
		}
		return q;
	}
};

signed main()
{
	ios::sync_with_stdio(0);

	int i, j, k;
	cin>>n>>k;
	
	mat adj;
	
	for(i=0;i<n;++i)
		for(j=0;j<n;++j)
			cin>>adj.m[i][j];

	mat ans;
	for(i=0;i<n;++i)
		ans.m[i][i] = 1;

	while(k)
	{
		if(k & 1)
			ans = ans * adj;
		adj = adj * adj;
		k /= 2;
	}

	int ANS = 0;
	for(i=0;i<n;++i)
		for(j=0;j<n;++j)
			add(ANS, ans.m[i][j]);

	cout << ANS << "\n";

	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll t,n,i,j,k,x,sum=0;
    cin>>n;
    vector<ll> vi;
    for( i = 0 ;i< n;i++){
        cin>>x;
        vi.push_back(x);
        sum+=x;
    }
    sort(vi.begin(),vi.end());
    ll flag =0;
    if(sum%10 == 0){
    for(i = 0 ;i< n ;i++)
    {
        ll x= vi[i];
        if(x%10 !=0)
        {
            sum-=x;
            flag = 1;
            break;
        }
    }
    if(flag == 1)
    cout<<sum<<endl;
    else
        cout<<0<<endl;
    }
    else
        cout<<sum<<endl;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	// your code goes here
	int a[2], k;
	cin >> a[0] >> a[1] >> k;
	bool flag = false;
	for(int i = 0; i < k; i ++){
		if(a[flag] % 2)
			a[flag]--;
		a[!flag] += a[flag] / 2;
		a[flag] /= 2;
		flag = !flag;
	}
	for(auto& i : a){
		cout << i << " ";
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define taskname "test1"
#define int long long
using namespace std;

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);   cout.tie(nullptr);
    if (ifstream("test.inp"))
    {
        freopen("test.inp", "r", stdin);
        #ifdef CHECKING
            freopen(taskname".out", "w", stdout);
        #else
            freopen("test.out", "w", stdout);
        #endif //CHECKING
    }
    else if (ifstream(taskname".inp"))
    {
        freopen(taskname".inp", "r", stdin);
        freopen(taskname".out", "w", stdout);
    }

    int n;  cin >> n;
    vector<int> a(n);
    for (int &i : a) cin >> i;
    map<int, int> cnt;
    for (int i = 0; i < n; i += 2) ++cnt[a[i]];
    priority_queue<pair<int, int>> Q;
    for (auto p : cnt) Q.emplace(p.second, p.first);
    cnt.clear();
    for (int i = 1; i < n; i += 2) ++cnt[a[i]];
    vector<pair<int, int>> v;
    for (auto p : cnt) v.emplace_back(p.second, p.first);
    sort(v.begin(), v.end(), greater<pair<int, int>>());
    int m = v.size();
    int nodd = n / 2, neven = n - nodd;
    int ans = min(neven - Q.top().first + nodd, neven + nodd - v[0].first);
    while (!Q.empty())
    {
        auto p = Q.top();   Q.pop();
        int i = 0;
        if (m == 1 && p.second == v[i].second) continue;
        if (m > 1 && p.second == v[i].second) ++i;
        ans = min(ans, neven - p.first + nodd - v[i].first);
    }
    cout << ans;
}


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

using namespace std;

#define ll long long
#define pb push_back
#define pf push_front
#define loop(i, n) for(int i = 0 ; i < n ; ++i)
#define LOOP(i, a, b) for(int i = a ; i < b ; ++i)
#define max3(a, b, c) max(a, max(b,c))
#define max4(a, b, c, d) max3(a, b, max(c, d))
#define ff first
#define ss second
#define mkp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi>
#define vii vector<pii>
#define vvii vector<vii>
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define nmbr(c) (int)(c-'0')
#define ltr(c) (int)(c-'a')
#define INF 1e18
#define inf 1e9
#define MOD 1000000007 //check
#define _69e27 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

ll dp[1<<21][25];
int n;
bool v[25][25];

ll match(int mask, int i)
{
	if(mask == (1<<n)-1) return 1;
	ll &ans = dp[mask][i];
	if(ans != -1) return ans;
	ans = 0;
	loop(j, n)
	{
		if(mask & (1<<j)) continue;
		if(v[i][j])
		{
			ans += match(mask|(1<<j), i+1);
			ans %= MOD;
		}
	}
	return ans;
}
int main() {
	_69e27;
	memset(dp, -1, sizeof(dp));
	cin >> n;
	loop(i, n) loop(j, n) cin >> v[i][j];
	cout << match(0, 0);
	return 0;
}

Measured memory_bytes: 409984
#include<cstdio>
#include<iostream>
using namespace std;
#define nn 100000
int main()
{
	int n, w, dp[nn] = { 0 }, v[1000], ww[1000],a;
	scanf("%d%d", &n, &w);
	for (int i = 1; i <= n; i++)
	{
		scanf("%d %d", &v[i], &ww[i]);
	}
	for (int i =0; i <= w; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			if (i + ww[j] <= w)
			{
				a =  dp[i] + v[j];
				if (dp[i + ww[j]] < a)
					dp[i + ww[j]] = a;
			}
		}
	}
	printf("%d\n", dp[w]);
	return 0;
}

Measured memory_bytes: 3620
#include<stdio.h>
int main(void)
{
    int n,m,a[100],i,s=0,j=0;
    scanf("%d%d",&n,&m);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        s+=a[i];
    }
    for(i=0;i<n;i++)
        if(a[i]>=(s*(1.0/(4.0*(double)m))))
            j++;
    if(j>=m) printf("Yes\n");
    else     printf("No\n");
    return 0;
}

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

namespace Computation2
{
    class Program
    {
        static void Main(string[] args)
        {
            double r = 1;
            string line = Console.ReadLine();
            r = double.Parse(line);
            Circle circle = new Circle(r);
            Console.WriteLine(circle.Area().ToString("F6") + " " + circle.Circumference().ToString("F6"));
        }
    }
}

/// <summary>
/// 半径rの円の面積と円周を算出するクラス
/// </summary>
public class Circle
{
    private double r;

    public Circle(double r)
    {
        this.r = r;
    }

    //半径rの円の面積を返す
    public double Area()
    {
        return r * r * Math.PI;
    }

    //半径rの円の円周を返す
    public double Circumference()
    {
        return 2 * r * Math.PI;
    }
}

Measured memory_bytes: 13936
import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result





arr_data = getinputdata()

a = int(arr_data[0][0])
b = int(arr_data[0][1])
c = int(arr_data[0][2])
d = int(arr_data[0][3])



print(a*b if a*b>=c*d else c*d)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
#pragma GCC optimize("O3")

#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

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

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

template<class T>
struct UnionFind {
  vector<T> parent, siz;

  UnionFind(int n) : parent(n), siz(n) {
    for (int i = 0; i < n; ++i) {
      parent[i] = i;
      siz[i] = 1;
    }
  }

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

  bool unite(T x, T y)
  {
    x = root(x);
    y = root(y);

    if (x == y) return false;

    if (siz[x] < siz[y]) swap(x, y);
    parent[y] = x;
    siz[x] += siz[y];

    return true;
  }

  bool same(T x, T y)
  {
    return root(x) == root(y);
  }

  T size(T x)
  {
    return siz[root(x)];
  }
};

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n, m; cin >> n >> m;
  vpi edge(m);

  UnionFind<int> uf(n);

  rep(i, m) cin >> edge[i].fi >> edge[i].se, --edge[i].fi, --edge[i].se;
  reverse(all(edge));

  ll val = n * (n - 1) / 2;
  vi ans;

  ans.eb(val);

  rep(i, m-1) {
    if (!uf.same(edge[i].fi, edge[i].se)) {
      val -= uf.size(edge[i].fi) * uf.size(edge[i].se);
      uf.unite(edge[i].fi, edge[i].se);
    }
    ans.eb(val);
  }

  reverse(all(ans));
  rep(i, m) cout << ans[i] << endl;

  return (0);
}


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

const int MOD = 1e9 + 7;

int a[2005];
int n, k;

int main()
{
	scanf("%d%d", &n, &k);
	
	long long p = (long long)(k + 1) * k / 2;
	long long q = (long long)k * (k - 1) / 2;
	p %= MOD, q %= MOD;
	
	long long ans = 0;
	for(int i = 1; i <= n; i++) 
	{
		scanf("%d", &a[i]);
		for(int j = 1; j < i; j++)
			if (a[i] > a[j])
				ans += q;
			else if (a[i] < a[j])
				ans += p;
		ans %= MOD;
	}
	printf("%d\n", (int)ans);
	
	return 0;
}

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

#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;

void solve()
{
  int x,y,z,k;
  cin>>x>>y>>z>>k;
  vector<ll> a(x, 0);
  vector<ll> b(y, 0);
  vector<ll> c(z, 0);
  for (int i=0; i<x; i++) {
    cin >> a[i];
  }
  for (int i=0; i<y; i++) {
    cin >> b[i];
  }
  for (int i=0; i<z; i++) {
    cin >> c[i];
  }
  sort(a.begin(),a.end(),greater<ll>());
  sort(b.begin(),b.end(),greater<ll>());
  sort(c.begin(),c.end(),greater<ll>());

  vector<ll> vec;
  for (int i=0; i<x; i++) {
    for (int j=0; j<y; j++) {
      for (int l=0; l<z; l++) {
        if((i+1)*(j+1)*(l+1)<=k) {
          vec.push_back(a[i]+b[j]+c[l]);
        } else {
          break;
        }
      }
    }
  }
  sort(vec.begin(),vec.end(),greater<ll>());
  for (int i=0; i<k; i++) {
    cout << vec[i] << endl;
  }
}

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


Measured memory_bytes: 1404
# ABC111C - /\/\/\/
from collections import Counter

n = int(input())
lst = list(map(int, input().rstrip().split()))
even = Counter(lst[::2]).most_common(2)
odd = Counter(lst[1::2]).most_common(2)
ans = 0
if even[0][0] != odd[0][0]:
    print(n - even[0][1] - odd[0][1])
else:
    if len(even) == 1 or len(odd) == 1:
        print(n // 2)
    else:
        print(n - max(even[0][1] + odd[1][1], even[1][1] + odd[0][1]))

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


namespace org{
    template<class T>
    T make_value(){
        T tmp;
        return tmp;
    }

    template<class T>
    T VALUE(){
        T tmp;
        std::cin >> tmp;
        return tmp;
    }

    template<class T>
    std::vector<T> make_vector(long long size){
        std::vector<T> tmp(size);
        return tmp;
    }

    template<class T> 
    std::vector<T> VECTOR(long long size){
        auto tmp=make_vector<T>(size);
        for(long long i=0;i<tmp.size();i++){
            std::cin >> tmp.at(i);
        }
        return tmp;
    }

    template<class T>
    std::vector<std::vector<T>> make_matrix(long long line,long long row){
        std::vector<std::vector<T>> tmp;
        tmp.resize(line);
        for(long long i=0;i<tmp.size();i++){
            tmp.at(i).resize(row);
        }
        return tmp;
    }

    template<class T>
    std::vector<std::vector<T>> MATRIX(long long line,long long row){
        auto tmp=make_matrix<T>(line,row);
        for(long long i=0;i<tmp.size();i++){
            for(long long j=0;j<tmp.at(0).size();j++){
                std::cin >> tmp.at(i).at(j);
            }
        }
        return tmp;
    }

    
}

std::ostream& operator<<(std::ostream& os, const std::vector<long long> vec)
{
    for(long long i=0;i<vec.size();i++){
        os << vec.at(i) << " ";
    }
    return os;
}


std::ostream& operator<<(std::ostream& os, const std::vector<std::vector<long long>> vec)
{
    for(long long i=0;i<vec.size();i++){
        for(long long j=0;j<vec.at(0).size();j++){
            os << vec.at(i).at(j) << " ";
        }
        os << std::endl;
    }
    return os;
}

using ll = long long;
using namespace std;

using org::MATRIX;
using org::VECTOR;
#define VEC(name,size,type) auto name=org::VECTOR<type>(size)
#define MAT(name,line,row,type) auto name=org::MATRIX<type>(line,row)
#define llV(name,size) VEC(name,size,long long)
#define stV(name,size) VEC(name,size,std::string)
#define llM(name,line,row) MAT(name,line,row,long long)
#define stM(name,line,row) MAT(name,line,row,std::string)
#define ll(name) auto name=org::VALUE<long long>()

#define rep1(max1) for(long long i=0;i<max1;i++)
#define rep2(max1,max2) for(long long i=0;i<max1;i++)for(long long j=0;j<max1;j++)
int main()
{
    ll(A);
    ll(B);
    ll(C);
    ll(K);
    ll counter=0;
    while(A>=B){
        B*=2;
        counter++;
    }
    while(B>=C){
        C*=2;
        counter++;
    }
    if(counter<=K){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
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() {
    int k, x;
    cin >> k >> x;
    if (k * 500 >= x) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
fun main(array: Array<String>) {
    var x = readLine()!!.toInt()
    while (true) {
        if(sosu(x)) {
            print(x)
            return
        }
        else {
            x++
        }
    }
}

fun sosu(x: Int): Boolean {
    var i = 2
    while (i * i <= x) {
        if(x % i == 0) {
            return false
        }
        i++
    }
    return true
}

Measured memory_bytes: 31644
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string N;cin>>N;
    int count=0;
    for(int i=0;i<N.size();i++){
        count+=N[i]-'0';
    }
    if(count%9==0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

const int MAX = 20000;

int main() {
  int N;
  while (cin >> N, N) {
    auto xs = vector<int>(N);
    auto ys = vector<int>(N);
    for (int i = 0; i < N; ++i) cin >> xs[i] >> ys[i];

    int xmin = MAX, xmax = -MAX, ymin = MAX, ymax = -MAX;
    for (int i = 0; i < 4; ++i) {
      int a, b; cin >> a >> b;
      xmin = min(xmin, a);
      xmax = max(xmax, a);
      ymin = min(ymin, b);
      ymax = max(ymax, b);
    }

    int ans1 = 0, ans2 = 0;
    auto fx = [&](int val) { return max(xmin, min(xmax, val)); };
    auto fy = [&](int val) { return max(ymin, min(ymax, val)); };
    for (int cur = 0; cur < N; ++cur) {
      int nxt = (cur + 1) % N;
      if (ys[cur] == ys[nxt]) {
        ans2 += ys[cur] * (xs[nxt] - xs[cur]);
        ans1 += fy(ys[cur]) * (fx(xs[nxt]) - fx(xs[cur]));
      }
    }
    cout << abs(ans2 - ans1) << endl;
  }
  return 0;
}



Measured memory_bytes: 3096
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
#define rep(i, f, n) for (ll i = (f); i < (ll)(n); i++)
#define repe(i, f, n) for (ll i = (f); i <= (ll)(n); i++)
#define accum(x) accumulate((x).begin(), (x).end(), 0)
using namespace std;
using ll = long long;
using pint = pair<int, int>;

int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  rep(i, 0, n) cin >> a[i];

  // 偶数番目と奇数番目どちらを正にするかで2通り考え小さい方を答えにする

  ll ans1 = 0, ans2 = 0, tot = 0;
  rep(i, 0, n) {
    tot += a[i];
    if (i % 2 == 0 && tot >= 0) {
      ans1 += tot + 1;
      tot = -1;
    } else if (i % 2 == 1 && tot <= 0) {
      ans1 += -tot + 1;
      tot = 1;
    }
  }

  tot = 0;
  rep(i, 0, n) {
    tot += a[i];
    if (i % 2 == 1 && tot >= 0) {
      ans2 += tot + 1;
      tot = -1;
    } else if (i % 2 == 0 && tot <= 0) {
      ans2 += -tot + 1;
      tot = 1;
    }
  }

  cout << min(ans1, ans2) << endl;

  return 0;
}


Measured memory_bytes: 4036
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0 ; i < n ; i++) a[i] = sc.nextInt();
		int[] b = new int[100010];
		for(int i = 0 ; i < n ; i++) {
			b[a[i]]++;
		}
		int ans = 0;
		for(int i = 1 ; i < 100009 ; i++) {
			ans = Math.max(ans, b[i - 1] + b[i] + b[i + 1]);
		}
		System.out.println(ans);
	}
}

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

using namespace std;
using int64 = long long;
//const int mod = 1e9 + 7;
const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  string A;
  cin >> A;
  if(A[0] != A[1] || A[1] != A[2]) cout << "Yes\n";
  else cout << "No\n";
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define F0(i,n) for(int i=0;i<int(n);++i)
#define F1(i,n) for(int i=1;i<=int(n);++i)
#define X first
#define Y second
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef pair<int,int> pii;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int s,w;
    cin>>s>>w;
    cout<<(w>=s? "unsafe\n":"safe\n");
}


Measured memory_bytes: 3132
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N;
    string S;
    cin >> N >> S;
    ll cnt=0;
    rep(i,N){
        if(S[i]=='R'){
            cnt++;
        }
    }
    ll ans=0;
    rep(i,cnt){
        if(S[i]=='W'){
            ans++;
        }
    }
    cout << ans << endl;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ll long long

using namespace std;
  
ll gcd(ll a, ll b){
  if(a==1 || b==1)return 1;
  if (a < b)swap(a,b);
  
  return b ? gcd(b, a % b) : a;
}

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

int main(){
  ll l,n, m;cin>>n>>m;
  string s,t;cin>>s>>t;
  l = lcm(n,m);
  map<ll, char>log;
  rep(i,n)log[1+i*l/n]=s[i];
  bool f=true;
  rep(i,m){
    ll index = 1+i*l/m;
    if(log.count(index)>0 && log[index]!=t[i]){
      f=false;
      break;
    }
  }

  if(f)cout<<l;
  else cout<<-1;

  return 0;
}



Measured memory_bytes: 6144
import java.util.Scanner;

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

    int ans = n - 2*m;
    if(ans>0){
      System.out.println(ans);
    }else{
      System.out.println("0");
    }

  }
}


Measured memory_bytes: 22612
n = int(input())
a = list(map(int, input().split()))
ans = 0
f = 1
d = -1
for i in range(n-1):
    if f == 1:
        if a[i] < a[i+1]:
            d = 1
        elif a[i] > a[i+1]:
            d = 0
        
        f = 0
    else:
        if d == 0:
            if a[i] < a[i+1]:
                f = 1
                d = -1
                ans += 1
        elif d == 1:
            if a[i] > a[i+1]:
                f = 1
                d = -1
                ans += 1
        elif d == -1:
            if a[i] < a[i+1]:
                d = 1
            elif a[i] > a[i+1]:
                d = 0

print(ans+1)


Measured memory_bytes: 14480
#include <bits/stdc++.h>
using namespace std;
//#define LOCAL
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define forn(i,a,b) for(ll i=a;i<b;i++)
#define ft first
#define sd second
#define sz size()
#define pb push_back
#define pob pop_back()
#define pf push_front
#define pof pop_front()
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
typedef pair<double,double> pdd;
typedef pair<long long,long long> pll;
//cout << fixed << setprecision(12) <<x<<endl;

int main(){
fastIO;
#ifdef LOCAL
     freopen("in.txt", "r", stdin);
#endif
string n;
cin>>n;
if(n=="0") cout<<"Yes"<<endl;
else{
ll sum=0;
forn(i,0,n.sz){
    sum+=(n[i]-'0');
}
//cout<<sum<<endl;
if(sum%9==0){
    cout<<"Yes"<<endl;
}else{
    cout<<"No"<<endl;
}
}

}


Measured memory_bytes: 3772
n = int(raw_input())

for _ in range(n):
    Y, M, D = map(int, raw_input().split())
    days = 0
    for i in range(1, Y):
        if i % 3 == 0:
            days += 200
        else:
            days += 39*5
    
    for i in range(1, M):
        if Y % 3 != 0 and i % 2 == 0:
            days += 19
        else:
            days += 20

    days += D

    print 196471 - days



Measured memory_bytes: 4668
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
using namespace std;
int main() {
    string s;
    cin >> s;
    int ans=0;
    int len=s.length();
    for(int i=0;i<len;i++){
        if(s[i] != s[len-1-i]){
            ans++;
        }
    }
    cout << ans/2 << endl;
    return 0;
}

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

using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

int main(void)
{
    ll n;
    cin >> n;
    set<string> st;
    string s;
    for(ll i=0;i<n;i++)
    {
        cin >> s;
        st.insert(s);
    }
    cout << st.size() << endl;
    return 0;
}


Measured memory_bytes: 19268
#include <iostream>
using namespace std;
int main() {
    bool cards[4][14];
    int n,rank;
    char suit;
    for(int s=0;s<4;s++) {
        for(int r = 1;r<=13;r++) {
            cards[s][r] = 0;
        }
    }
    cin >> n;
    for(int i=0;i<n;i++) {
        cin >> suit >> rank;
        if(suit=='S') cards[0][rank] = 1;
        if(suit=='H') cards[1][rank] = 1;
        if(suit=='C') cards[2][rank] = 1;
        if(suit=='D') cards[3][rank] = 1;
    }
    for(int s=0;s<4;s++) {
        for(int r=1;r<=13;r++) {
            if(cards[s][r]) continue;
            if(s == 0) suit = 'S';
            if(s == 1) suit = 'H';
            if(s == 2) suit = 'C';
            if(s == 3) suit = 'D';
            cout << suit << " " << r << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3080
#include <iostream>
#include <vector>
#include <set>
#include <unordered_map>

using namespace std;

#define int long long  

const int maxn = 1e5 + 5 ;
const int inf = 1e9 ;

vector< int > memo(maxn, -1);
vector< int > a (maxn);
int n;

int dp(int i) {
    if(i >= n ) return inf ;

    if(i == n - 1 ) {
        return 0;
    }

    int  &ans = memo[i];

    if(ans != -1) {
     return ans;
    }

    ans = min(inf , abs(a[i] - a[i+1]) + dp(i+1));
    

    if(i + 2 < n ) {
        ans = min(ans, abs(a[i] - a[i+2]) + dp(i+2));
    }



    return ans;
}


int32_t main(){

	// #ifndef ONLINE_JUDGE 
	//   freopen("input.txt", "r", stdin);
	//   freopen("output.txt", "w", stdout);
	// #endif
    
    cin >> n ;

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


    cout << dp(0) << endl;

    return 0;


}

Measured memory_bytes: 9548
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(size_t i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long

const int mod=1e9+7;

int bikkuri(int a){
    int ret =1;
    for(int i=1;i<=a;i++){
        ret*=i;
        ret = ret%mod;
    }
    return ret;
}


int modPow(int a,int n){
    if(n==1){
        return a%mod;
    }
    if(n%2==1){
        return(a*modPow(a,n-1))%mod;
    }
    int t=modPow(a,n/2);
    return (t*t)%mod;
}

int conbinate(int n,int r){
    int ret=1;
    REP(i,r){
        ret *=(n-i);
        ret %=1000000007;
      	if(ret<0){
      		ret+=1000000007;
    	}
    }
    int gyaku=modPow(bikkuri(r),1e9+5);
    ret = ret*gyaku%mod;
    return ret;
}

signed main(){
    int N,a,b;
    cin>>N>>a>>b;
    int ans=modPow(2,N)-1;
    ans -=conbinate(N,a);
    ans -=conbinate(N,b);
    ans %=mod;
  	if(ans<0){
      ans+=mod;
    }
    cout <<ans <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define llint long long

using namespace std;

llint n;
bool prime[5000005];
vector<llint> pvec, rvec, vec;
llint ans[505][505];

llint gcd(llint a, llint b)
{
	if(b == 0) return a;
	return gcd(b, a%b);
}
llint lcm(llint a, llint b)
{
	return a / gcd(a, b) * b;
}

int main(void)
{
	cin >> n;
	
	for(int i = 2; i < 5000005; i++){
		if(prime[i]) continue;
		for(int j = 2*i; j < 5000005; j+=i) prime[j] = true;
	}
	for(int i = 2; i < 5000005; i++) if(!prime[i]) pvec.push_back(i);
	
	pvec.resize(1000);
	rvec = pvec;
	reverse(rvec.begin(), rvec.end());
	
	for(int i = 0; i < 500; i++){
		vec.push_back(pvec[i]);
		vec.push_back(rvec[i]);
	}
	
	for(int i = 0; i < 500; i++){
		for(int j = 0; j < 500; j++){
			ans[i][j] = 1;
		}
	}
	
	for(int i = 0; i < 500; i++){
		for(int j = 0; j < 500; j++){
			if((i+j)%2) continue;
			ans[i][j] *= vec[(i+j)/2];
		}
	}
	for(int i = 0; i < 500; i++){
		for(int j = 0; j < 500; j++){
			if((i-j+500)%2) continue;
			ans[i][j] *= vec[(i-j+500)/2 + 500];
		}
	}
	for(int i = 0; i < 500; i++){
		for(int j = 0; j < 500; j++){
			if(ans[i][j] != 1) continue;
			if(i-1 >= 0) ans[i][j] = lcm(ans[i][j], ans[i-1][j]);
			if(i+1 < 500) ans[i][j] = lcm(ans[i][j], ans[i+1][j]);
			if(j-1 >= 0) ans[i][j] = lcm(ans[i][j], ans[i][j-1]);
			if(j+1 < 500) ans[i][j] = lcm(ans[i][j], ans[i][j+1]);
			ans[i][j]++;
		}
	}
	
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			cout << ans[i][j] << " ";
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 14060
N,W = map(int,input().split())
wv = [list(map(int,input().split())) for _ in range(N)]
dp = [[0]*(W+1) for _ in range(N+1)]

def chmax(a,b):
    if a < b:
        return b
    else:
        return a 
    
for i in range(N): #i番目より前に重さw以下
    for w in range(W+1): #wの重さ
        if wv[i][0] <= W - w:
            dp[i+1][w+wv[i][0]] = chmax(dp[i+1][w+wv[i][0]],dp[i][w]+wv[i][1])
        
        dp[i+1][w] = chmax(dp[i+1][w],dp[i][w])
        
print(dp[N][W])

Measured memory_bytes: 121452
#include<stdio.h>
int main()
{
    int a, b, c, n = 0;
    scanf("%d%d%d", &a, &b, &c);
    for(int i = a;i <= b;i++){
        if(c % i == 0){
            n++;
        }
    }
    printf("%d\n", n);
    return 0;
}


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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();

    set< int> s;

    int n, k, d, t;

    cin>> n>> k;

    for(int i=0; i<k; i++)
    {
        cin>> d;

        for(int j=0; j< d;  j++)
        {
            cin>> t;
            s.insert(t);
        }
    }

    cout<< n- s.size() << '\n';


    return 0;
}




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


#define	ll_int	long long int


int main()
{
	int n, m;
	ll_int *A, *B;
	int count;
	int i, j, k;

	scanf("%d", &n);
	A = (ll_int *)malloc(sizeof(ll_int) * n);
	for(i = 0; i < n; i++)
		scanf("%lld", &A[i]);

	scanf("%d", &m);
	B = (ll_int *)malloc(sizeof(ll_int) * (m + 1));
	for(i = 0; i < m; i++)
		scanf("%lld", &B[i]);
	B[m] = 1000000001;


	// A - B の実行
	for(i = 0, j = 0; i < n; i++){
		while(j < m && B[j] < A[i])
			j++;
		if(A[i] != B[j])
			printf("%lld\n", A[i]);
	}

	return 0;
}


Measured memory_bytes: 4876
"use strict"
function Main(input) {
  input = input.trim().split('\n');
  const N = input[0].trim().split(' ').map(Number)[0];
  const M = input[0].trim().split(' ').map(Number)[1];
  const P = input.slice(1, M+1);

  let ans = new Array();
  for(let i=0; i<N; i++){
    ans.push([0, 0]);
  }

  for(let i=0; i<M; i++){
    let p = P[i].trim().split(' ')[0];
    let S = P[i].trim().split(' ')[1];
    if(ans[p-1][0] === 1) continue;

    if(S === 'WA'){
      ans[p-1][1] += 1;
    } else {
      ans[p-1][0] += 1;
    }
  }

  let ac = 0;
  let wa = 0;
  for(let i=0; i<N; i++){
    if(ans[i][0] > 0) {
      ac += ans[i][0];
      wa += ans[i][1];
    }
  }
  console.log(ac, wa);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main()
{
    int a, b;
    cin >> a >> b;
    if(a<b) cout << "a < b" << endl;
    if(a==b) cout << "a == b" << endl;
    if(a>b) cout << "a > b" << endl;
    return 0;
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define fast                                                                   \
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define ll long long
#define f(i, n) for (int i = 0; i < n; i++)
#define fo(i,a,n) for (i = a; i <= n; i++)
#define F first
#define S second
#define pii pair<int,int>
#define sz size()
#define all(v) v.begin(),v.end()
#define pb push_back
#define pf push_front    
#define PB pop_back
#define pll pair<long long, long long>
#define vi vector<int>
#define vl vector<int>
#define mp make_pair
#define mod 1000000007
typedef unsigned long long ull;
const int N = 200005;
const int MOD = 998244353 ;


void solve(){
    int n, ans = 0;
    cin>>n;
    int dp[10][10];
    f(i,10)f(j,10)dp[i][j] = 0;
    for(int i = 1; i<= n; i++){
        int k = i;
        while(k >= 10)k /= 10;
        dp[k][i%10]++;
    }
    for(int i = 1; i<= n; i++){
        int k = i;
        while(k >= 10)k /= 10;
        ans += dp[i%10][k];
    }
    cout<<ans;
}

int32_t main() {
    fast
    int t;
    t = 1;
    //cin >> t;
    while(t--)solve();
    return 0;
}


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

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

    double arr[n+1];
    for(ll i=1;i<=n;i++) cin>>arr[i];

    double dp[n+1][n+1];

    dp[0][0] = 1;
    for(ll i=1;i<=n;i++) dp[i][0] = dp[i-1][0]*(1-arr[i]);
    for(ll i=1;i<=n;i++) dp[0][i] = 0;

    for(ll i=1;i<=n;i++)
    {
        for(ll j=1;j<=n;j++)
        {
            if(j>i) dp[i][j] = 0;
            else    dp[i][j] = dp[i-1][j]*(1-arr[i]) + dp[i-1][j-1]*arr[i];;
        }
    }

    double ans = 0;
    ll i = n/2 + 1;
    while(i<=n)
    {
        ans += dp[n][i];
        i++;
    }

    printf("%.10f",ans);
    return 0;
}


Measured memory_bytes: 70528
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod 100000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
ll lcm(ll a, ll b)
{
    return a * b / __gcd(a, b);
}

int main()
{
    int N, M;
    cin >> N >> M;
    vector<ll> A(N);
    ll sum = 0;
    for (int i = 0; i < M; i++)
    {
        cin >> A[i];
        sum += A[i];
    }
    if(N -sum < 0){
        cout << -1 << endl;
    }
    else{
        cout << N - sum << endl;
    }
}


Measured memory_bytes: 11176
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;

typedef long long ll;
#define READ(a) int a; cin >> a;
#define READARR(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define READMAT(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}
#define print(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b + c >= 22) cout << "bust";
	else cout << "win";
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX_DATA 100000

int temp[MAX_DATA];    /* 最小でも配列と同じサイズの領域が必要 */

void MergeSort(int x[ ], int left, int right);

  /* 配列 x[ ] の left から right の要素のマージソートを行う */
void MergeSort(int x[ ], int left, int right)
{
    int mid, i, j, k;
	
    if (left >= right)              /* 配列の要素がひとつなら */
        return;                     /* 何もしないで戻る */

                                    /* ここでは分割しているだけ */
    mid = (left + right) / 2;       /* 中央の値より */
    MergeSort(x, left, mid);        /* 左を再帰呼び出し */
    MergeSort(x, mid + 1, right);   /* 右を再帰呼び出し */

      /* x[left] から x[mid] を作業領域にコピー */
    for (i = left; i <= mid; i++)
        temp[i] = x[i];

      /* x[mid + 1] から x[right] は逆順にコピー */
    for (i = mid + 1, j = right; i <= right; i++, j--)
        temp[i] = x[j];

    i = left;         /* i とj は作業領域のデーターを */
    j = right;        /* k は配列の要素を指している */

    for (k = left; k <= right; k++)    /* 小さい方から配列に戻す */
        if (temp[i] <= temp[j])        /* ここでソートされる */
            x[k] = temp[i++];
        else
            x[k] = temp[j--];
}

int main(void){
    int n, k, h[MAX_DATA];
    scanf("%d %d", &n, &k);
    for(int i = 0; i < n; i++){
        scanf("%d", &h[i]);
    }

    MergeSort(h, 0, n - 1);

    /*for(int i = 0; i < n; i++){
        printf("h[%d] = %d%c", i, h[i], (i == n - 1)? '\n' : ' ');
    }*/

    int min = 1000000009;
    for(int i = 0; i < n - (k - 1); i++){
        int diff = h[i + (k - 1)] - h[i];
        if(diff < min){
            min = diff;
        }

        if(min == 0){
            break;
        }
    }
    printf("%d\n", min);
    return 0;
}

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

int X;

int sieve_of_eratosthenes() {
  vector<bool> is_prime(100003, true);
  is_prime[0] = is_prime[1] = false;
  for(int i=2; i<=X; i++)
    if(is_prime[i]) {
      for(int k=2; k * i <= 100003; k++)
        is_prime[k*i] = false;
    }
  for(int i=X; i<=100003; i++)
    if(is_prime[i]) return i;
  return 0;
}

signed main() {
  cin >> X;
  cout << sieve_of_eratosthenes() << endl;
}


Measured memory_bytes: 256