akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void rd(char &c){
  int i;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i;
  int sz = 0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int N;
char S[102];
char T[102];
char res[202];
int main(){
  int i;
  int k = 0;
  rd(N);
  rd(S);
  rd(T);
  for(i=(0);i<(N);i++){
    res[k++] = S[i];
    res[k++] = T[i];
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20191214-1

// --- original code ---
// int N; char S[102], T[102], res[202];
// {
//   int k = 0;
//   rd(N,S,T);
//   rep(i,N){
//     res[k++] = S[i];
//     res[k++] = T[i];
//   }
//   wt(res);
// }


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

#define taskname ""
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex <ld> cd;
typedef vector <cd> vcd;
typedef vector <int> vi;

template<class T> using v2d = vector <vector <T> >;
template<class T> bool uin(T &a, T b)
{
    return a > b ? (a = b, true) : false;
}
template<class T> bool uax(T &a, T b)
{
    return a < b ? (a = b, true) : false;
}

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

const int maxN = 1e4 + 10;
const int maxA = 1e6 + 10;
const ll mod = 1e9 + 7;

int n, a[maxN];
vi pr;
int lp[maxA];
map <ll, int> mp;
ll lcm = 1, res;

void init()
{
    fore(i, 2, 1e6)
    {
        if (!lp[i])
        {
            lp[i] = i;
            pr.eb(i);
        }
        for (int j = 0; j < (int)pr.size() && pr[j] <= lp[i] && i * pr[j] <= 1e6; ++j)
        {
            lp[i * pr[j]] = pr[j];
        }
    }
}

ll power(ll a, ll b)
{
    if (b == 0)
    {
        return 1;
    }
    ll k = power(a, b / 2);
    if (b & 1)
    {
        return k * k % mod * a % mod;
    }
    return k * k % mod;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    init();
    cin >> n;
    for1(i, n)
    {
        cin >> a[i];
        ll tmp = a[i];
        map <ll, int> tp;
        while (tmp > 1)
        {
            ++tp[lp[tmp]];
            tmp /= lp[tmp];
        }
        for (auto &p: tp)
        {
            if (mp[p.fi] < p.se)
            {
                mp[p.fi] = p.se;
            }
        }
    }
    lcm = 1;
    for (auto &p: mp)
    {
        lcm *= power(p.fi, p.se);
        lcm %= mod;
    }
    for1(i, n)
    {
        res += power(a[i], mod - 2);
        if (res >= mod)
        {
            res -= mod;
        }
    }
    res = res * lcm % mod;
    cout << res;
    return 0;
}


Measured memory_bytes: 5112
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,a,b;
    cin>>n>>a>>b;
    if(n>1&&b>=a||n==1&&a==b)cout<<(n-2)*(b-a)+1<<endl;
    else cout<<0<<endl;
    return 0;
} 

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

int main() {

    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);

    /////////////////////
    // Write code below /
    int N;
    cin >> N;
    if(N%1000 == 0){
        N = 0;
    }else{
        N = 1000 - (N%1000);
    }
    cout << N << endl;
    /////////////////////


    return 0;
}


Measured memory_bytes: 3620
#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 vb=vector<bool>;
using vvb=vector<vb>;
using vc=vector<char>;
using vvc=vector<vc>;
using pii = pair<int,int>;
using pil = pair<int,ll>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using tiii = tuple<int,int,int>;
using vpii = vector<pii>;
using vpil = vector<pil>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#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++)
int INF=1e9+7;

vi dig(40);
vl sum(41);
int N;
vi Kbit(40);

ll dfs(int d,int k) {
  if(Kbit[d]<k) return 0;
  else if(Kbit[d]>k) return dig[d]*(1ll<<d)+sum[d];
  else {
    int x;
    if(k) x=N-dig[d];
    else x=dig[d];
    if(d) return x*(1ll<<d)+max(dfs(d-1,0),dfs(d-1,1));
    else return x*(1ll<<d);
  }
}

int main() {
  ll K;
  cin >> N >> K;
  vl A(N);
  rep(i,N) {
    cin >> A[i];
    rep(j,40) {
      if((1ll<<j)&A[i]) dig[j]++;
    }
  }
  
  rep(i,40) {
    sum[i+1]=sum[i]+max(dig[i],N-dig[i])*(1ll<<i);
    if(K&(1ll<<i)) Kbit[i]=1;
  }
  
  cout << max(dfs(39,0),dfs(39,1)) << endl;
}

Measured memory_bytes: 4052
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define fi first
#define se second
#define pii pair<int, int>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

signed main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
  int n, k;
  cin >> n >> k;
  int a[n + 1];
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  if (k <= n) {
    int ans = 1;
    for (int i = 0; i < k; i++) {
      ans = a[ans];
    }
    cout << ans << "\n";
  } else {
    set<int> st = {1};
    int cur = 1, lstep = 0;
    for (int i = 0; i < n; i++) {
      cur = a[cur];
      lstep++;
      if (st.find(cur) != st.end()) {
        break;
      }
      st.insert(cur);
    }
    int lcur = cur, fstep = 0;
    cur = 1;
    for (int i = 0; i < n; i++) {
      if (cur == lcur) {
        break;
      }
      cur = a[cur];
      fstep++;
    }
    if (lstep != fstep) {
      k -= lstep;
      k -= (lstep - fstep) * (k / (lstep - fstep));
      for (int i = 0; i < k; i++) {
        lcur = a[lcur];
      }
    }
    cout << lcur << "\n";
  }
}



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

#define ll long long
#define sz 100005
#define mod 10000

using namespace std;

int main()
{
    ll a,b,c,d;

    scanf("%lld %lld %lld %lld",&a,&b,&c,&d);

    ll mx=max(a,c);
    ll mn=min(b,d);

    ll dif=mn-mx;

    if(dif<0)
        printf("0\n");

    else
        printf("%lld\n",dif);

    return (0);
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#define EPS 1e-9
#define INF MOD
#define MOD 1000000007LL
#define fir first
#define iss istringstream
#define sst stringstream
#define ite iterator
#define ll long long
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define sec second
#define sh(i) (1LL<<i)
#define sz size()
#define vi vector<int>
#define vc vector
#define vl vector<ll>
#define vs vector<string>

int h,w,c[55][55],dy[]={0,1,0,-1},dx[]={1,0,-1,0};
char m[55][55];

void dfs(int y,int x,int C){
	if((c[y][x]|C)==c[y][x])return;
	c[y][x]|=C;
	rep(i,4){
		int ny=y+dy[i],nx=x+dx[i];
		if(0<=ny&&ny<h&&0<=nx&&nx<w&&m[ny][nx]=='.')dfs(ny,nx,C);
	}
}

int main(){
	while(cin>>w>>h,w){
		int B=0,W=0;
		memset(c,0,sizeof(c));
		rep(i,h)cin>>m[i];
		rep(i,h)rep(j,w){
			if(m[i][j]=='B')dfs(i,j,1);
			if(m[i][j]=='W')dfs(i,j,2);
		}
		rep(i,h)rep(j,w)if(m[i][j]=='.'){
			if(c[i][j]==1)B++;
			if(c[i][j]==2)W++;
		}
		cout<<B<<" "<<W<<endl;
	}
}

Measured memory_bytes: 0
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
//*********************************************DO IT NOW****************************************************************
#include<bits/stdc++.h> 
#include<random>
#define int long long   
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back
#define mod 1000000007
#define pi 3.14159265359
#define mk(arr,n,type)  type *arr=new type[n];
#define sl s1.length();
#define yes cout<< "YES"<<endl
#define no  cout<< "NO"<<endl
#define all(v) (v).begin(),(v).end()
#define s(v)   sort(v,v+n)
#define  mt mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define read(a,n) for(int i=0;i<n;i++)cin>>a[i]
#define print(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" "
using namespace std;
//**********************************************DO IT NOW***************************************************************
void fastio()
{  
  #ifndef ONLINE_JUDGE
  freopen("INPUT.txt","r",stdin);
  freopen("OUTPUT.txt","w",stdout); 
  #endif
  ios_base :: sync_with_stdio(false); 
  cin.tie(NULL) ; 
  cout.tie(NULL);
}
int dp[101][1001],ans1=1e9,dp1[1000001];
int num[10];
int a[1000000];
signed main()
{   
    fastio();
    int t=1;
   // cin>>t;
    while(t--)
    {
       string s,ss;
       cin>>s>>ss;
       string s1=ss+s;
       cout<<s1;
    }
    
}
// 🍪 🍪 🍪


Measured memory_bytes: 3640
#include <algorithm>
#include <cstring>
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

int main() {
  string n;
  cin >> n;
  for (int i = 0; i < 3; i++) {
    if (n[i] == '7') {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll,ll> pll;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define ARRAY_MAX 305

const ll INF = 1e17+7;
const ll MOD = 1e9+7;


vector<vector<ll> > mp(ARRAY_MAX,vector<ll>(ARRAY_MAX,0));
vector<vector<bool> > memo(ARRAY_MAX,vector<bool>(ARRAY_MAX,true));

int main(){

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

    ll ans = 0;
    for(int k = 0;k < n;k++){
        for(int i = 0;i < n;i++){
            for(int j = 0;j < n;j++){
                
                if(i == k || j == k){
                    //頂点Eから頂点Eへする場合は飛ばす
                    continue;
                }
                if(mp[i][j] > mp[i][k] + mp[k][j]){
                    cout << "-1" << endl;
                    return 0; 
                }
                if(mp[i][j] == mp[i][k] + mp[k][j]){
                    //他の経路を使用したほうが最適な場合は道はいらない
                    memo[i][j] = false;
                }
            }
        }
    }
    for(int i = 0;i < n;i++){
        for(int j = 0;j < n;j++){
            if(memo[i][j]){
                ans += mp[i][j];
            }
        }
    }
    cout << ans/2 << endl;//２回数えているので2で割る

    return 0;
}

Measured memory_bytes: 1024
open System
open System.Collections.Generic

module InputUtility =
    let InputTokens = new Queue<string>()

    let EnsureInput () =
        if InputTokens.Count = 0 then
            let input = Console.ReadLine ()
            let s = input.Split ([|' '|], StringSplitOptions.RemoveEmptyEntries)
            if s.Length > 0 then
                for x in s do InputTokens.Enqueue(x)
                true
            else false
        else true

    let rec ReadNext () =
        if EnsureInput () then InputTokens.Dequeue ()
        else ReadNext ()

    let ReadNextInt () = ReadNext () |> int

    let Read2Int () = ReadNextInt (), ReadNextInt ()

    let ReadListOf f n =
        let rec loop acc = function
            | 0 -> List.rev acc
            | c -> loop ((ReadNext () |> f) :: acc) (c-1)
        loop [] n

    let MultipleCaseWithId f =
        let caseNum = ReadNextInt ()
        let rec loop index =
            if index = caseNum then ()
            else
                f index
                loop (index + 1)
        loop 0

    let MultipleCase f = MultipleCaseWithId (fun _ -> f ())

open InputUtility

module AGC015 =
    let private ``A+...+B Problem`` () =
        let g = ReadNext >> int64
        let n, a, b = g (), g (), g ()
        if a > b then 0L
        elif n = 1L then
            if a = b then 1L else 0L
        else
            let s = (n - 1L) * a + b
            let t = a + (n - 1L) * b
            t - s + 1L
        |> printfn "%d"

    let Entry = ``A+...+B Problem``

AGC015.Entry ()

Measured memory_bytes: 14160
s = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14,
     1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

k = int(input())
print(s[k-1])


Measured memory_bytes: 2940
/** 
 *                                                                   
 *   |    |                        ,   .              ,--.,--.,--.,--.
 *   |    |    ,---..    ,,---.    |   |,---..   .      -||  ||  ||  |
 *   |    |    |   | \  / |---'    `---'|   ||   |       ||  ||  ||  |
 *   `    `---'`---'  `'  `---'      |  `---'`---'    `--'`--'`--'`--'
 *                                   `                                
**/
#include <bits/stdc++.h>
using namespace std;

int n;
double p[3005], dp[3005][3005];
bitset<3005> visited[3005];

double solve(int id, int head) {
	if (id == n) {
		if (head > n / 2) return 1;
		else return 0;
	}
	if (visited[id][head]) return dp[id][head];

	visited[id][head] = 1;
	return dp[id][head] = solve(id + 1, head + 1) * p[id] + solve(id + 1, head) * (1.0 - p[id]);
}

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

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

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

	dp[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= i; j++) {
			dp[i][j] = dp[i - 1][j] * (1 - p[i]);
			if (j) dp[i][j] += dp[i - 1][j - 1] * (p[i]);
		}
	}

	double ans = 0;
	for (int j = n / 2 + 1; j <= n; j++) {
		ans += dp[n][j];
	}

	cout << setprecision(10) << fixed << ans << '\n';

	return 0;
}

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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<set<int>> ans;
    if (n % 2 == 1) {
        ans.push_back(set<int>({n}));
        n--;
    }
    REP(i, 0, n / 2) {
        ans.push_back(set<int>({i + 1, n - i}));
    }
    vector<int> a, b;

    if (ans.size() == 2) {
        for (auto s1 : ans[0]) {
            for (auto s2 : ans[1]) {
                a.push_back(s1);
                b.push_back(s2);
            }
        }
    } else {
        REP(i, 0, ans.size()) {
            int j = (i + 1) % ans.size();
            for (auto s1 : ans[i]) {
                for (auto s2 : ans[j]) {
                    a.push_back(s1);
                    b.push_back(s2);
                }
            }
        }
    }
    cout << a.size() << endl;
    REP(i, 0, a.size()) {
        cout << a[i] << " " << b[i] << endl;
    }
    return 0;
}


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

int main(){
  string str;
  cin >> str;
  vector<int> A(26, 0);
  string flag = "yes";


  for (int i=0; i<str.size(); i++){
    if (A[str[i] - 'a'] == 0){
      A[str[i] - 'a']++;
    }else{
      flag = "no";
      break;
    }
  }
  cout << flag << endl;

  return 0;
}


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

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

    ll a, b;
    cin >> a >> b;

    if(a==0 || b==0 || (a*b<0)) puts("Zero");
    else if(a>0 && b>0) puts("Positive");
    else{
        if((b-a)%2) puts("Positive");
        else puts("Negative");
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(ll i=0;i<n;i++)
#define fro(i,j,n) for(ll i=j;i<n;i++)
#define ifr(i,n) for(ll i=n-1;i>=0;i--)


int main() {
    ll mod=1000000007;
    ll n,k;
	cin >> n>> k;
    ll ans=0;
    fro(i,k,n+2){
      ans+=(n+1-i)*i+1;
      ans%=mod;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define mod 1000000007
#define int long long

void solve() {
	int n;
	cin >> n;
	int a[n];
	int i;
	for (i = 0; i < n; i++)cin >> a[i];
	int dp[n] = {0};
	dp[0] = 0;
	dp[1] = abs(a[1] - a[0]);
	for (i = 2; i < n; i++) {
		dp[i] =  min(abs(a[i] - a[i - 1]) + dp[i - 1], abs(a[i] - a[i - 2]) + dp[i - 2]);
	}
	cout << dp[n - 1] << endl;
	return;
}

int32_t main() {

	std::ios::sync_with_stdio(false);
	cout.tie(0);
	cin.tie(0);
	int t = 1;
	// cin >> t;
	while (t--)solve();
	return 0;
}

Measured memory_bytes: 5128
import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]

class UnionFind():
    """
    要素数nで初期化
    """
    
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        """
        union(x, y)でx, yをグルーピング
        """
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        """
        same(x, y)同じグループに属しているか
        """
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
    
def main():
    N, M = MI()
    Union = UnionFind(N)
    Num = N*(N-1) // 2
    res = [0]*M
    res[0] = Num
    L = [LI() for i in range(M)]
    
    for index, l in enumerate(reversed(L[1:])):
        a, b = l
        if not Union.same(a-1, b-1):
            res[index+1] -= Union.size(a-1) * Union.size(b-1)
        res[index+1] += res[index]
        Union.union(a-1, b-1)
        if res[index+1] == 0:
            break

    for i in reversed(res):
        print(i)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 93592
N = int(input())
F = [list(map(int, input().split())) for _ in range(N)]
P = [list(map(int, input().split())) for _ in range(N)]

# bit全探索
inf = float("inf")
ans = -inf
for i in range(1, 2**10):
    op = []
    for j in range(10):
        if (i >> j) & 1:
            op.append(1)
        else:
            op.append(0)

    res = 0
    for k in range(N):
        temp = 0
        for l in range(10):
            if op[l] == 1 and F[k][l] == 1:
                temp += 1
        res += P[k][temp]
    ans = max(ans, res)

print(ans)

Measured memory_bytes: 9236
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int V, E; cin >> V >> E;
	vector<vector<int>>G(V, vector<int>(V, INF));
	rep(i, 0, E) {
		int s, t, d; cin >> s >> t >> d;
		G[s][t] = d;
	}
	vector<vector<int>>dp(1 << V, vector<int>(V, -1));
	function<int(int, int)> tsp = [&](int S, int v) {
		if (dp[S][v] >= 0)return dp[S][v];
		if (S == (1 << V) - 1 && v == 0)return dp[S][0] = 0;

		int ret = INF;
		rep(i, 0, V) {
			if (!(S&(1 << i)))chmin(ret, tsp(S | (1 << i), i) + G[v][i]);
		}
		return dp[S][v] = ret;

	};
	int ans = tsp(0, 0);
	cout << (ans == INF ? -1 : ans) << endl;
	return 0;
}

Measured memory_bytes: 6232
#include <iostream>
#include <vector>

int main()
{
    std::vector<int> n(26, 0);
    for (int i = 0; i < 4; i++)
    {
        char c; std::cin >> c;
        n[c-'A']++;
    }

    bool b = true;
    for (const auto nn: n)
    {
        if (nn != 2 && nn != 0)
        {
            b = false;
        }
    }

    std::cout << (b?"Yes":"No") << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

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

	char ans;

	if( a == 'H' and b == 'H' )  ans = 'H';
	if( a == 'D' and b == 'H' )  ans = 'D';
	if( a == 'H' and b == 'D' )  ans = 'D';
	if( a == 'D' and b == 'D' )  ans = 'H';

	std::cout << ans << std::endl;

	return 0;
}


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

int main(){
  string s;
  int i,n,j;
  cin >> s;
  n=0;
  j=s.size();
  for(i=0;i<j;i++){
    n+=std::stoi(s.substr(i,1));
    n=n%9;
  }
  if(n==0){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
}

Measured memory_bytes: 3720
#include <iostream>
#include <string>
#include <vector>
#include <cassert>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REPEAT(i, n) FOR(i, 0, n)

using namespace std;

void c_3_2() {
	int n;

	cin >> n;
	// int price[n];
	vector<int> a(n);
	REPEAT(i, n) {
		cin >> a[i];
	}
	REPEAT(k, a.size()) {
		cout << (k ? " " : "") << a[k];
	}
	cout << endl;
	FOR(i, 1, n) {
		int j;

		const auto v = a[i];
		j = i - 1;
		while (j >= 0 and a[j] > v) {
			a[j + 1] = a[j];
			j--;
		}
		a[j + 1] = v;
		REPEAT(k, a.size()) {
			cout << (k ? " " : "") << a[k];
		}
		cout << endl;
	}
}

void c_2_5() {
	//string s;
	int n;
	cin >> n;
	// int price[n];
	vector<int> price(n);
	REPEAT(i, n) {
		cin >> price[i];
	}
	int maxPrice[n];
	int currentMaxPrice;
	currentMaxPrice = 0;	// or -infinite
	for (int i = n - 1; i >= 0; i--) {
		if (price[i] > currentMaxPrice) {
			currentMaxPrice = price[i];
		}
		maxPrice[i] = currentMaxPrice;
	}
	int maxUp = maxPrice[1] - price[0];
	for (int i = 1; i < n - 1; i++) {
		const int diff = maxPrice[i + 1] - price[i];
		if (diff > maxUp) {
			maxUp = diff;
		}
	}
	cout << maxUp << "\n";
	// 正解との違い: 最大ではなく最小を保持するようにすれば先頭から処理でき、配列を使う必要すらない
	// 競技プログラミングとしてのアドバイス: FOR, REPEATマクロを使いタイプミスをする可能性を減らす
	//   配列の変わりにvectorを用いて宣言以上の領域へのアクセスを検知したりsegmentation faultで落ちるようにする
}

int main() {
	ios::sync_with_stdio(false);
	c_3_2();
	return 0;
}



Measured memory_bytes: 3192
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define ll2(x, y) ll x, y; cin >> x >> y;
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

signed main(void){
  int i, j;
  int p, q, t, b;
  int stk[200];
  for(int testcase = 0;testcase >= 0;testcase++){
    if(scanf("%d %d", &p, &q) == -1)break;

    t = p * 10; b = q;
    rep(i, 200){
      stk[i] = t / b;
      t = t % b;
      t *= 10;
    }

    per(i, 200)if(stk[i] != 0)break;
    if(i < 100){
      rep(j, i + 1)printf("%d", stk[j]);
      puts("");
      continue;
    }

    int l, r, w;
    bool isok = true;
    rep(l, 100)for(r = l + 1;r < 100;++r){  //[l, r)loop
      isok = true;
      w = r - l;
      for(i = r;i < 200;++i)if(stk[l + ((i - l) % w)] != stk[i]){
        isok = false; break;
      }
      if(i == 200){
        rep(j, r)printf("%d", stk[j]);
        kara;
        rep(j, l)printf(" ");
        for(j = l;j < r;++j)printf("^");
        kara;
        l = 100; break;
      }
    }


//*/

//*/ break;
  }
  return 0;
}

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

struct Node{
	int key;
	struct Node *prev, *next;
};

struct Node *nil;

void init(){
	nil = (struct Node*)malloc(sizeof(struct Node));
	nil->next = nil;
	nil->prev = nil;
}

struct Node* listSearch(int k){
	struct Node *cur = nil->next;
	while(cur != nil && cur->key != k){
		cur = cur->next;
	}
	return cur;
}

void deleteNode(struct Node *x){
	if(x == nil)return;
	x->prev->next = x->next;
	x->next->prev = x->prev;
	free(x);
}

void insert(int k){
	struct Node *x = (struct Node*)malloc(sizeof(struct Node));
	x->key = k;
	x->next = nil->next;
	nil->next->prev = x;
	nil->next = x;
	x->prev = nil;
}

void delete(int k){
	deleteNode(listSearch(k));
}

void PrintList(){
	struct Node *cur = nil->next;
	int i;
	while(1){
		if(cur == nil){
			break;
		}
		if(i++ > 0){
			printf(" ");
		}
		printf("%d",cur->key);
		cur = cur ->next;
	}
	printf("\n");
}

int main(void){
	int n,d,i;
	char order[20];
	init();
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s %d",order,&d);
		if((strcmp(order,"insert"))==0){
			insert(d);
		}else if((strcmp(order,"delete"))==0){
			delete(d);
		}else if((strcmp(order,"deleteFirst"))==0){
			deleteNode(nil->next);
		}else if((strcmp(order,"deleteLast"))==0){
			deleteNode(nil->prev);
		}
	}
	PrintList();
	return 0;
}


Measured memory_bytes: 33024
#include <bits/stdc++.h>
using namespace std;
void Main();

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define YN(y, n, b) (b? y : n)
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

void Main() {
    i32 N;
    cin >> N;
    Vec<i32> A(N + 1);
    Vec<i32> B(N + 1);
    Vec<i32> C(N + 1);
    for (i32 i = 1; i <= N; i++) cin >> A[i];
    for (i32 i = 1; i <= N; i++) cin >> B[i];
    for (i32 i = 1; i < N; i++) cin >> C[i];
    i32 sum = 0;
    for (i32 i = 1; i <= N; i++) {
        i32 index = A[i];
        sum += B[index];
        if (i != 1 && A[i - 1] + 1 == A[i]) sum += C[index - 1];
    }
    cout << sum << endl;

}


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

int main(){
  int N, A;

  cin >> N;
  cin >> A;

  int n = N / 500;
  N = N - (500 * n);

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define forn(i,n) for(ll (i) = 0 ; (i) < (n) ; ++(i))
#define for1(i,n) for(ll (i) = 1 ; (i) <= (n) ; ++(i))
#define vll vector<ll>
#define pll pair<ll ,ll >
#define vpll vector< pll >
#define mp make_pair
#define pb push_back
const ll MOD=1e9+7;
//#define endl "\n"
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define deb1(args...) do {cerr << #args << " : "; dbg,args; cerr << "\n";} while(0)

ll extended_GCD(ll a , ll b , ll &x , ll &y){
    if(a == 0){
        x = 0;
        y = 1;
        return b;
    }
    ll x1 , y1;
    ll gcd = extended_GCD(b%a , a , x1 , y1);
    x = y1 - (b/a)*x1; 
    y = x1;
    return gcd;
}
ll modinv(ll a , ll mod = MOD){
    ll x , y;
    extended_GCD(a , mod , x , y);
    if(x < 0) x += mod;
    return x;
}
ll power(ll a, ll b, ll m = MOD) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
ll binomialCoeff(ll n,ll k) 
{ 
    ll res = 1; 
    if ( k > n - k ) 
        k = n - k; 

    for (  ll i = 0; i < k; ++i) 
    { 
        res = (res* (n - i))%MOD; 
        res = (res* modinv(i + 1))%MOD; 
    } 
    return res; 
} 

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //#ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //#endif
    ll t=1;
    // cin>>t;
    while(t--){
        ll n,x,c=0,sum=0;
        cin>>n;
        vll a(n),ans(n,0);
        forn(i,n) cin>>a[i];
        forn(i,n){
            if(i-1>=0){
                ans[i]=ans[i-1]+abs(a[i]-a[i-1]);
            }
            if(i-2>=0){
                ans[i]=min(ans[i],ans[i-2]+abs(a[i]-a[i-2]));
            }
            // cout<<ans[i]<<" ";
        }
        // cout<<endl;
        cout<<ans[n-1]<<endl;
    }
    //#ifndef ONLINE_JUDGE
      //  cout<<endl<<"Time Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec"<<endl;
    //#endif
}

Measured memory_bytes: 1792
#include<stdio.h>

void maxHeapify(int);

int n, A[2000001];

int main(){
  int i;

  scanf("%d",&n);

  for(i = 1 ; i <= n ; i++){
    scanf("%d",&A[i]);
  }
  
  for(i = n / 2 ; i >= 1 ; i--) maxHeapify(i);
  
  for(i = 1 ; i <= n ; i++){
    printf(" %d",A[i]);
  }

  printf("\n");
  
  return 0;
}

void maxHeapify(int x){
  int right, left, largest;
  int tmp;
  left = 2 * x;
  right = 2 * x + 1;

  if(left <= n && A[left] > A [x]) largest = left;
  else largest = x;

  if(right <= n && A[right] > A[largest]) largest = right;

  if(largest != x){
    tmp = A[x];
    A[x] = A[largest];
    A[largest] = tmp;

    maxHeapify(largest);
  }
}




Measured memory_bytes: 3732
#include <bits/stdc++.h>
#include <math.h>
#include <float.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

const int MOD = 1000000007;


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

    int ans = 0;
    for (int i = 0; i <= 999; i++){
        stringstream ss;
        ss << setfill('0') << setw(3) << i;
        string tmp = ss.str();
        int index = 0;
        for (int j = 0; j < N; j++){
            if (tmp[index] == S[j]){
                index++;
            }
            if (index == 3){
                ans++;
                break;
            }
        }
        
    }

    cout << ans << endl;
}

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

using namespace std;

#ifdef DGC
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<double> point;
#define F first
#define S second

const ll mod = 1e9+7;
ll Pow(ll a, ll b)
{
	ll x = 1;
	for (; b > 0; b >>= 1)
	{
		if (b&1) x = x * a % mod;
		a = a * a % mod;
	}
	return x;
}

int main()
{
	#ifdef DGC
		//freopen("a.in", "r", stdin);
		//freopen("b.out", "w", stdout);
	#endif

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

	int n, k;
	cin >> n >> k;
	vector<ll> a(n);
	for (auto &i : a) cin >> i;

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

	vector<ll> f = {1};
	for (int i = 0; i < n; ++i)
	{
		ll x = f.back() * (k-1+i) % mod * Pow(i+1, mod-2) % mod;
		f.push_back(x);
	}

	for (int i = 1; i <= n; ++i)
		f[i] = (f[i] + f[i-1]) % mod;

	ll ans = 0;
	for (int i = 0; i+k <= n; ++i)
		ans = (ans + mod - f[n-k-i] * a[i] % mod) % mod;

	reverse(a.begin(), a.end());
	for (int i = 0; i+k <= n; ++i)
		ans = (ans + mod + f[n-k-i] * a[i] % mod) % mod;

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 2168
def is_b(l):
    return all([a[i][j] in b for i, j in l])

a = [list(map(int, input().split())) for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]
t = [[(i, j) for j in range(3)] for i in range(3)]
t += [[(j, i) for j in range(3)] for i in range(3)]
t += [[(i, i) for i in range(3)]] + [[(2 - i, i) for i in range(3)]]
print('Yes' if any([is_b(ti) for ti in t]) else 'No')

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

using namespace std;
typedef long long ll;

#define INF (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

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



int main(void)
{
  string s;
  cin >> s;
  bool ok = false;
  int i = 0;
  while(i < s.size()) {
    if(s[i] == 'C') {
      ok = true;
      break;
    }
    i++;
  }
  if(!ok) {
    cout << "No" << endl;
    return 0;
  }
  ok = false;
  while(i < s.size()) {
    if(s[i] == 'F') {
      ok = true;
      break;
    }
    i++;
  }
  cout << (ok?"Yes":"No") << endl;
  
  
  
}


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

int main(){
  int n, k;
  cin >> n >> k;
  
  int ans;
  for (int i=1 ; ; i++){
    int keta = pow(k, i);
    if (n/keta == 0){
      ans = i;
      break;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 4000
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <numeric>
#include <string>
#include <bitset>
#include <functional>

using ld = long double;
using vld = std::vector<ld>;
using vvld = std::vector<vld>;
using vvvld = std::vector<vvld>;
using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
using pll = std::pair<ll, ll>;
using vpll = std::vector<pll>;
using str = std::string;
using vstr = std::vector<str>;

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

constexpr ld PI = 3.141592653589793L;
constexpr ld EPS = std::numeric_limits<ld>::epsilon();

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }
bool isprime(ll n) {
    if (n < 2) return false;
    for (ll i = 2; i * i <= n; i++)
        if (n % i == 0) return false;
    return true;
}
vll sieve(ll n) {
    str flg(n + 1, '1');
    for (ll i = 2; i * i <= n; i++) {
        if (flg[i] == '0') continue;
        for (ll j = i * i; j <= n; j += i)
            flg[j] = '0';
    }
    vll res;
    for (ll i = 2; i <= n; i++)
        if (flg[i] == '1') res.push_back(i);
    return res;
}
ll rpow(ll x, ll n) {
    if (n == 0) return 1;
    ll k = 1;
    for (; n > 1; n /= 2) {
        if (n & 1) k *= x;
        x *= x;
    }
    return k * x;
}
ll modpow(ll x, ll n, ll mod) {
    if (n == 0) return 1;
    ll k = 1;
    for (; n > 1; n /= 2) {
        if (n & 1) (k *= x) %= mod;
        (x *= x) %= mod;
    }
    return k * x % mod;
}
ll modcomb(ll n, ll r, ll mod) {
    if (r < 0 || n < r) return 0;
    chmin(n - r, r);
    ll mul = 1, div = 1;
    for (ll i = 0; i < r; i++) {
        (mul *= n - i) %= mod;
        (div *= i + 1) %= mod;
    }
    return mul * modpow(div, mod - 2, mod) % mod;
}

/*----------------------------------------------------------------*/

void solve();

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15);

    solve();
}
void solve() {
    ll r, g, b, n;
    std::cin >> r >> g >> b >> n;

    ll ans = 0;
    for (ll i = 0; r * i <= n; i++) for (ll j = 0; r * i + g * j <= n; j++) {
        ll bk = n - (r * i + g * j);
        ans += bk % b == 0;
    }

    std::cout << ans << '\n';
}


Measured memory_bytes: 3600
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

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

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

ll nCm(ll n, ll m){
    if(m == 0 || m == n){
        return 1;
    } else if(m == 1){
        return n;
    }
    return (nCm(n - 1, m) + nCm(n - 1, m - 1));
}

//-----------------------ここから-----------

int main(void){
    int a, b, c;
    cin >> a >> b >> c;

    if(a == b){
        cout << c << endl;
    } else if(b == c){
        cout << a << endl;
    } else {
        cout << b << endl;
    }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;


    void solve()
    {
        var S = cin.next;
        var T = cin.next;
        var L = new List<string>();
        int N = S.Length;
        int M = T.Length;

        for (int i = 0; i < N; i++)
        {
            if (i + M - 1 >= N) break;
            var flag = true;
            for (int j = 0; j < M; j++)
            {
                if (S[i + j] == '?' || S[i + j] == T[j])
                {

                }
                else
                {
                    flag = false;
                    break;
                }
            }
            if (flag)
            {
                var sb = new StringBuilder();
                for (int j = 0; j < N; j++)
                {
                    if(i <= j && j <= i + M - 1)
                    {
                        sb.Append(T[j - i]);
                    }
                    else if (S[j] == '?')
                    {
                        sb.Append('a');
                    }
                    else
                    {
                        sb.Append(S[j]);
                    }
                }
                L.Add(sb.ToString());
            }
        }
        if (L.Count == 0)
        {
            WriteLine("UNRESTORABLE");
            return;
        }
        L.Sort();
        WriteLine(L[0]);
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 11360
using System;

public class AtCoder
{
    public static void Main()
    {
        bool f = true;
        string[] s;
        int[] a = new int[6];
        for(int i=0; i<3; i++)
        {
            s = NextS();
            a[i*2] = int.Parse(s[0]);
            a[i*2+1] = int.Parse(s[1]);

        }
        int[] b = new int[5];
        for(int i=0; i<6; i++)
        {
            b[a[i]]++;
        }
        for(int i=0; i<5; i++)
        {
            if (b[i] == 3) f = false;
        }
        if (f) Console.WriteLine("YES");
        else Console.WriteLine("NO");


    }

    public static void DebugWL(object x) { System.Diagnostics.Debug.WriteLine(x); }
    public static string[] NextS() { return Console.ReadLine().Trim().Split(' '); }
}


Measured memory_bytes: 11092
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

#define minimize(a, b) a = min(a, b)

int main() {
    int n;
    cin >> n;
    long rui[n+1];
    rui[0] = 0;
    long ans = 1000000000000000000;
    for (int i=1; i<=n; i++) {
        long ai;
        cin >> ai;
        rui[i] = ai + rui[i-1];
    }
    for (int m=0; m<=n; m++) {
        long lsum = rui[m],
             rsum = rui[n] - lsum;
        int l = upper_bound(rui,   rui+m, lsum / 2) - rui,
            r = upper_bound(rui+m, rui+n, lsum + rsum / 2) - rui;
        long P, Q, R, S;
        if (l == 0 || abs(lsum - rui[l] * 2) < abs(lsum - rui[l-1] * 2))
            P = rui[l];
        else 
            P = rui[l-1];
        Q = lsum - P;
        if (r == m || abs(rsum - (rui[r] - rui[m]) * 2) < abs(rsum - (rui[r-1] - rui[m]) * 2))
            R = rui[r] - rui[m];
        else 
            R = rui[r-1] - rui[m];
        S = rsum - R;
        minimize(ans, max({P, Q, R, S}) - min({P, Q, R, S}));
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 1792
import numpy as np

H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]
  
dx = [1, 1,  1, 0,  0, -1, -1, -1]
dy = [1, 0, -1, 1, -1,  1,  0, -1]

for h, row in enumerate(S):
  for w, i in enumerate(row):
    if i == '.':
      S[h][w] = 0
    if i == '#':
      for x, y in zip(dx, dy):
        if 0 <= x+w < W and 0 <= y+h < H:
          if S[y+h][x+w] == '#':
            continue
          elif S[y+h][x+w] == '.':
            S[y+h][x+w] = 1
          else:
            S[y+h][x+w] += 1
            
for s in S:
  print(''.join(map(str, s)))

Measured memory_bytes: 23584
package main

import "fmt"

func main() {
	var k, a, b int
	fmt.Scan(&k, &a, &b)
	for i := a; i <= b; i++ {
		if i%k == 0 {
			fmt.Println("OK")
			return
		}
	}
	fmt.Println("NG")
}


Measured memory_bytes: 1752
//
//  A - Move and Win.cpp
//  atcoder grand contest 020
//
//  Created by Huang,Zhiqiang on 2018/2/21.
//  Copyright © 2018年 Huang,Zhiqiang. All rights reserved.
//

#include <iostream>
#include <vector>
using namespace std;

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    int space = B - A;
    if (space == 0 || (space - 1) % 2 == 0) {
        cout << "Borys" << endl;
    } else {
        cout << "Alice" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll zero = 0;
const ll INF = 10000000000000000; //10^16
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(void){
    ll X;
    cin >> X;
    ll mon = 100;
    for(ll i = 1; i < INF; i++){
        mon = (ll)(mon * 1.01);
        if(mon >= X){
            printf("%lld\n", i);
            return 0;
        }
    }
    
}


Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(n*a,b);
    return 0;
}

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

int main() {
	
	int n; cin >> n;
	string a, b, c; cin >> a >> b >> c;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] != b[i] && b[i] != c[i] && c[i] != a[i]) {
			ans += 2;
		}
		else if ((a[i] == b[i] && b[i] != c[i]) || (b[i] == c[i] && c[i] != a[i]) || (c[i] == a[i] && a[i] != b[i])) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3572
#include <iostream>

using namespace std;
 
int main(){
    int K,S;
    int sum = 0;
 
    cin >> K >> S;

    for(int i = 0; i <= K; i++){
        for(int j = 0; j <= K; j++){
            if(S - i - j >= 0 && S - i - j <= K){
                sum++;
            }
        }
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256