akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll=long long;

int main(){
  ll n,m,k;
  cin >> n >> m >> k;
  vector<ll> a(n),b(m);
  vector<ll> aa(n+1,0),bb(m+1,0);
  for(int i=0;i<n;++i){
    cin >> a[i];
    aa[i+1]=aa[i]+a[i];
  }
  for(ll i=0;i<m;++i){
    cin >> b[i];
    bb[i+1]=bb[i]+b[i];
  }
  ll ans=0;
  ll j=m;
  for(ll i=0;i<=n;++i){
    if(aa[i]>k) break;
    while(bb[j]>k-aa[i]){
      j--;
    }
    ans=max(ans,i+j);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 9568
import itertools
from collections import defaultdict
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N = ii()
    count = defaultdict(lambda:0)

    for i in range(N):
        s = input()
        count[s[0]] += 1

    ans =0
    X = []
    for x in ["M","A","R","C","H"]:
        if count[x] < 1: continue
        X.append(x)
    
    if len(X) < 3:
        print(0)
        exit()

    for V in itertools.combinations(X,3):
        U = list(V)
        res = 1
        for u in U:
            res *= count[u]
        
        ans += res


    print(ans)

        
     


if __name__ == "__main__":
    main()

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

#define all(x) x.begin(),x.end()

#define MAXN 100005
vector<int> adj[MAXN];

void __DFS(int v, vector<bool> &visited, vector<int> &len){
    visited[v] = true;
    for(int u: adj[v]){
        if(!visited[u])
            __DFS(u, visited, len);
        len[v] = max(len[u]+1, len[v]);
    }
}

int DFS(int n){
    vector<bool> visited(n+1);
    vector<int> len(n+1);
    for(int i=1; i<=n; i++)
        if(!visited[i])
            __DFS(i, visited, len);
    return *max_element(all(len));
}

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

	int n, m;
	cin >> n >> m;
	for(int i=0; i<m; i++){
		int x, y;
		cin >> x >> y;
		adj[x].push_back(y);
	}

	cout << DFS(n) << endl;

	return 0;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
#define N 4005
using namespace std;
char a[N],b[N];
int L[N],R[N],id[N],q[N];
int n,tot,ans=1000000000;
bool cmp(int x,int y){
	return R[x]!=R[y]?R[x]<R[y]:L[x]<L[y];
}
int cal(int st,int ed,int mn,int mx){
	if (st>ed) swap(st,ed);
	return 2*(max(mx,ed)-min(mn,st))-abs(st-ed);
}
int main(){
	scanf("%s%s",b+1,a+1);
	n=strlen(a+1);
	for (int i=1;i<=n;i++)
		a[i+n]=a[i];
	int fl1=0,fl2=0;
	for (int i=1;i<=n;i++)
		fl1|=(a[i]!='0'),fl2|=(b[i]!='0');
	if (!fl1&&!fl2) return puts("0"),0;
	if (!fl1) return puts("-1"),0;
	for (int i=1;i<=n;i++){
		L[i]=0; R[i]=0;
		for (;a[i+n+L[i]]==48;L[i]--);
		for (;a[i+R[i]]==48;R[i]++);
	}
	for (int i=1;i<=n;i++)
		id[i]=i;
	sort(id+1,id+n+1,cmp);
	for (int i=-n+1;i<n;i++){
		tot=0;
		for (int j=1;j<=n;j++)
			if (b[id[j]]!=a[id[j]+(i<0?i+n:i)])
				q[++tot]=id[j];
		int mn=0;
		for (int j=tot;j;j--){
			//printf("%d %d %d %d\n",i,q[j],mn,L[q[j]]);
			ans=min(ans,cal(0,i,mn,R[q[j]])+tot);
			mn=min(mn,L[q[j]]);
		}
		ans=min(ans,cal(0,i,mn,0)+tot);
		//printf("%d %d\n",i,ans);
	}
	printf("%d",ans);
}

Measured memory_bytes: 384
mod = 10**9+7
M = 5*10**5

fact = [1]*(M+1)
factinv = [1]*(M+1)
inv = [1]*(M+1)
for n in range(2,M+1):
    fact[n] = n*fact[n-1]%mod
    inv[n] = -inv[mod%n]*(mod//n)%mod
    factinv[n] = inv[n]*factinv[n-1]%mod

N,M = map(int,input().split())
ans = 0

for n in range(N+1):
    ans += (-1)**n*fact[N]*factinv[n]*factinv[N-n]*fact[M]*factinv[M-n]*fact[M-n]*factinv[M-N]*fact[M-n]*factinv[M-N]%mod
    ans %= mod
print(ans)    

Measured memory_bytes: 92252
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define double long double
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=1e9+7;
int main(){
    ll n,k;cin>>n>>k;
    double ans=0;
    double ma=0;
    vector<double>p(n);
    rep(i,n){
        cin>>p[i];
        p[i]+=1.0;
    }
    rep(i,k)ans+=p[i]/2.0;
    ma=ans;
    REP(i,k,n){
        ans-=p[i-k]/2.0;
        ans+=p[i]/2.0;
        ma=max(ma,ans);
    }
    cout<<fixed<<setprecision(7)<<ma<<endl;
}


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

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

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

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

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


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



int main() {

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

	if (a > b) {
		rep(i, a) cout << b;
	}
	
	else { rep(i, b) cout << a; }
	
	system("PAUSE");

}


Measured memory_bytes: 504
#include<bits/stdc++.h>
using namespace std;
int n;
int k;
vector<long long> op,np; 
long long a[1001000];
long long q[1001000];
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		q[i]=q[i-1]+a[i];
	}
	for(int i=1;i<=n;i++){
		for(int j=i;j<=n;j++){
			op.push_back(q[j]-q[i-1]);
		}
	}
	long long res=0;
	for(int bit=60;bit>=0;bit--){
		np.clear();
		for(int i=0;i<op.size();i++){
			if((bit!=0&&((op[i]>>bit)&1))||(bit==0&&(op[i]&1)))
				np.push_back(op[i]);
		}
		if(np.size()>=k){
			res+=(1LL<<bit);
			op=np;
		}
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 8304
#include <bits/stdc++.h>
using namespace std;
#define PII pair<int, int>
#define VI vector<int>
#define VPII vector<PII>
#define LL long long
#define LD long double
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
#define SIZ(c) (int)(c).size()
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, b, e) for(int i = (b); i <= (int)(e); ++i)
#define FORD(i, b, e) for(int i = (b); i >= (int)(e); --i)

#define sim template<class n
sim, class s> ostream & operator << (ostream &p, pair<n, s> x)
{return p << "<" << x.f << ", " << x.s << ">";}
sim> auto operator << (ostream &p, n y) ->
typename enable_if<!is_same<n, string>::value, decltype(y.begin(), p)>::type 
{int o = 0; p << "{"; for(auto c: y) {if(o++) p << ", "; p << c;} return p << "}";}
void dor() {cerr << endl;}
sim, class...s> void dor(n p, s...y) {cerr << p << " "; dor(y...);}
sim, class s> void mini(n &p, s y) {if(p>y) p = y;}
sim, class s> void maxi(n &p, s y) {if(p<y) p = y;}
#ifdef DEB
#define debug(...) dor(__FUNCTION__, ":", __LINE__, ": ", __VA_ARGS__)
#else
#define debug(...)
#endif 

#define I(x) #x " =", (x), " "
#define A(a, i) #a "[" #i " =", i, "] =", a[i], " "

int n;
int med(VI V)
  {
  if(n % 2 == 1)
    {
    return V[n/2] / 2;
    }
  else
    {
    return ((LL)V[n/2-1] + V[n/2]) / 2;
    }

  }

int main()
  {
  ios_base::sync_with_stdio(0); 
  cin >> n;
  VI V1, V2;
  FOR(i, 1, n)
    {
    int a, b;
    cin >> a >> b;
    a *= 2;
    b *= 2;
    V1.PB(a);
    V2.PB(b);
    }
  sort(ALL(V1));
  sort(ALL(V2));

  cout << med(V2) - med(V1) + 1 << endl;

  }


Measured memory_bytes: 6524
#include <iostream>

#define MAXN 100000

using namespace std;

bool A[MAXN+1];
int B[MAXN+1];

bool judge ( int x )
{
  return ( A[x] && A[(x+1)/2] );
}

int main()
{
  int Q;
  int l, r;
  A[0] = A[1] = false;
  for ( int i = 2; i <= MAXN; ++i ) A[i] = true;
  for ( int i = 2; i <= MAXN; ++i ) {
    if ( A[i] ) {
      for ( int j = i*2; j <= MAXN; j += i ) A[j] = false;
    }
  }

  for ( int i = 0; i <= MAXN; ++i ) {
    if ( judge(i) )  B[i] = 1;
    else B[i] = 0;
  }

  for ( int i = 1; i <= MAXN; ++i ) B[i] += B[i-1];
  cin >> Q;
  while ( Q-- ) {
    scanf("%d%d", &l, &r);
    cout << B[r]-B[l-1] << "\n";
  }
  /*
  for ( int i = 0; i <= 10; ++i ) cout << B[i] << " "; cout << "\n";
  for ( int i = 0; i <= 10; ++i ) cout << A[i] << " "; cout << "\n";
  */
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  int x=99999999;
  int k;
  int y=0;
  for(int i=-100;i<101;i++){
    for(int j=0;j<n;j++){
      y=y+(a[j]-i)*(a[j]-i);
    }
    if(x>y){
      x=y;
    }
    y=0;
  }
  cout << x << endl;
}


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

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

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

  ll ans = 0;
  for(ll i = 1; i <= k; ++i){
    for(ll j = 1; j <= k; ++j){
      for(ll l = 1; l <= k; ++l){
        ll tmp = gcd(i, j);
        ans += gcd(tmp, l);
      }
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
int main()
{
    int a,N,root = 1;
    std::cin >> N;
    for(int b = 0;b < N;b++){
        std::cin >> a;
        if((a % 2) == 0){
            root = root * 2;
        }else{
            root = root * 1;
        }
    }
    int f = 1;
    for(int s = 0;s < N;s++){
        f = f * 3;
    }
    std::cout << f - root << std::endl;
    return 0;
}


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

typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n;
string str;
int main(){
	cin>>n;
	cin>>str;
	ll ans = 0;
	for(int mask=0;mask<(1<<n);mask++){
		int sz = __builtin_popcount(mask);
		vector<int>v1,v2;
		for(int i=n-1;i>=0;i--){
			if(((mask>>i)&1)) v1.pb(i);
			else v2.pb(i);
		}
		int dp[20][20]={};
		dp[0][0] = 1;
		for(int i=0;i<n;i++){
			int pt = n+i;
			for(int j=0;j<=v1.size();j++){
				if(dp[j][i-j] == 0) continue;
				if(j != v1.size() && str[v1[j]] == str[pt]){
					dp[j+1][i-j] += dp[j][i-j];
				}
				if(i-j != v2.size() && str[v2[i-j]] == str[pt]){
					dp[j][i-j+1] += dp[j][i-j];
				}
			}
		}
		ans+=dp[v1.size()][v2.size()];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

#define mp make_pair
#define all(c) (c).begin() , (c).end()
#define sz(c) ((long long)((c).size()))
#define phb push_back
#define ppb pop_back
#define phf push_front
#define ppf pop_front

using namespace __gnu_pbds;
using namespace std;

#define int ll

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

#define x first
#define y second

template
<
    class key,
    class val=null_type,
    class comp=less<key>
>
using ord_set=tree
<
    key,
    val,
    comp,
    rb_tree_tag,
    tree_order_statistics_node_update
>;

const int N=1e5+100;

array<int,3> card[N];

int p[2*N],ver[2*N],ed[2*N];

int par(int x)
{
    return x==p[x]?x:p[x]=par(p[x]);
}

int un(int x,int y)
{
    x=par(x);
    y=par(y);
    if(x==y)
        return x;
    ver[x]=ver[y]=ver[x]+ver[y];
    ed[x]=ed[y]=ed[x]+ed[y];
    if(rand()%2)
        return p[x]=y,y;
    else
        return p[y]=x,x;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    for(int i=0;i<2*N;i++)
        p[i]=i,ver[i]=1;

    int n,h,w;
    cin>>n>>h>>w;
    for(int i=1;i<=n;i++)
        cin>>card[i][1]>>card[i][2]>>card[i][0];
    sort(card+1,card+n+1,greater<array<int,3>>());
    int ans=0;
//    set<pii> s;
    for(int i=1;i<=n;i++)
    {
        int r=card[i][1],c=card[i][2],a=card[i][0];
        int x=r,y=N+c;
        x=par(x),y=par(y);
        bool b1=ver[x]==ed[x];
        bool b2=ver[y]==ed[y];
        if(b1&&b2)
            continue;
        ed[un(x,y)]++;
        ans+=a;
    }
    cout<<ans;
}


Measured memory_bytes: 7296
//writer：Sakura
//problem：Find Symmetries
//id：
//from：

#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
//#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int n;
string s[305];
int ans=0;

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%d",&n);
	for(int i=0;i<n;i++)cin>>s[i];
	for(int i=0;i<n;i++){
		bool flag=1;
		for(int j=0;j<n;j++){
			for(int k=0;k<n;k++){
				if(s[(i+j)%n][k]!=s[(i+k)%n][j]){
					flag=0;
					j=n;
					break;
				}
			}
		}
		if(flag)ans++;
	}
	ans*=n;
	printf("%d\n",ans);
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  string ans = "Three";
  for (int i = 0; i < N; ++i)
  {
  	string s;
  	cin >> s;
  	if (s == "Y"){
  		ans = "Four";
  	}
  }
  cout << ans << endl;
}

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

constexpr int MAXT = 2 * 101 * 200, MAXV = 2 * 101;
constexpr double inf = 1e9;
double dp[MAXT][MAXV];

int main(){
    cin.tie(0); ios_base::sync_with_stdio(false);
    int N; cin >> N;
    int T[100], V[100];

    for(int i=0; i < N; ++i) cin >> T[i];
    for(int i=0; i < N; ++i) cin >> V[i];

    // memorize max v of each area
    int cur = 0;
    int area_max_v[MAXT];
    for(int i=0; i < N; ++i) {
        for(int j=cur; j < cur + T[i] * 2; ++j) area_max_v[j] = V[i] * 2;
        cur += T[i] * 2;
    }
    //

    // Init DP table
    for(int i=0; i < MAXT; ++i) for(int j=0; j < MAXV; ++j) dp[i][j] = -inf;
    //

    // DP
    dp[0][0] = 0;
    for(int i=0; i < cur; ++i) {
        for(int j=0; j < MAXV; ++j) {
            if(dp[i][j] != -inf && j <= area_max_v[i]){
                if (j > 0) dp[i + 1][j - 1] = max(dp[i + 1][j - 1], dp[i][j] + j + j - 1);
                if (j + 1 <= area_max_v[i]) dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + j + j + 1);
                dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + j + j);
            }
        }
    }
    //

    cout << fixed << setprecision(10) << dp[cur][0] / 8.0 << '\n';
    return 0;
}

Measured memory_bytes: 64128
#include<bits/stdc++.h>
#define md 998244353
using namespace std;
string s;
int u, sz, dp[4005] = {1}, a;
int main(){
  cin >> s; sz = s.size();
  for(int i = 1; i <= sz*2; i++){
   if(i <= sz) u += '2' - s[i-1];
   for(int j = i; j >= 0; j--){
     if(j) dp[j] = (dp[j] + dp[j-1]) % md;
     if(u < j || (i <= sz ? u-i : u+i-2*sz) > j) dp[j] = 0;
     if(i == sz*2) a = (a + dp[j]) % md;
   }
  }
  printf("%d\n", a);
}

Measured memory_bytes: 256
n, y = map(int, input().split())
ans = s = 0
ts = y // 10000 + 1
for i in reversed(range(ts)):
    for j in range(n-i+1):
        if 10000 * i + 5000 * j + 1000 * (n-i-j) == y:
            ans = [i, j, n-i-j]
            s = 1
            break
    if s == 1:
        break
if ans == 0:
    ans = [-1, -1, -1]
    print(*ans)
else: print(*ans)

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

int main(){
	long int a, b, k;
	cin >> a >> b >> k;

	if (a >= k) {
		cout << a - k << " " << b << endl;
	}
	else if (k <= a + b) {

		cout << 0 << " " << b - (k - a) << endl;
	}
	else
	{
		cout << 0 << ' ' << 0 << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
//#include<algorithm>
#include<map>
using namespace std;
int main()
{
    int n,i,s=0;
    cin>>n;
    int m[n];
    for(i=0;i<n;i++)
    {
        cin>>m[i];
    }
    //sort(m,m+n);
    map<int,int>mp;
    for(i=0;i<n;i++)
    {
        mp[m[i]]++;
    }
    for(auto i:mp)
    {
        if(i.first>i.second)
        {
            s=s+i.second;
        }
        else
        {
            s=s+i.second-i.first;
        }
    }
    cout<<min(n,s)<<endl;
    return 0;
}


Measured memory_bytes: 8460
package main

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

func main() {

	// 繰り返し回数
	N, _ := strconv.Atoi(readLine())

	strWords := strings.Fields(readLine())

	arr := make([]Card, 0)
	arr1 := make([]Card, 0)
	arr2 := make([]Card, 0)

	for _, strWord := range strWords {
		card := Card{label: strWord}
		arr = append(arr, card)
		arr1 = append(arr1, card)
		arr2 = append(arr2, card)
	}

	formattedCardArray := bubble(arr1, N)
	if isStable(arr, formattedCardArray) {
		fmt.Println("Stable")
	} else {
		fmt.Println("Not stable")
	}

	formattedCardArray = selection(arr2, N)
	if isStable(arr, formattedCardArray) {
		fmt.Println("Stable")
	} else {
		fmt.Println("Not stable")
	}

	return
}

func bubble(arr []Card, N int) []Card {
	changeNum := 0

	// n
	for n := 0; n < N; {

		last := N - 1
		first := n

		// 最終ラインまで
		for ; first != last; {

			last_m := arr[last]
			last_n := arr[last-1]

			// 比較する
			if last_n.toInt() > last_m.toInt() {
				changeNum ++
				temp := arr[last]
				arr[last] = arr[last-1]
				arr[last-1] = temp
				//fmt.Println(reduce(arr), "交換")
			}

			// 最後から減らしていく。
			last -= 1
		}
		//fmt.Println(reduce(arr))
		n++
	}
	fmt.Println(reduce(arr))
	return arr
}

func selection(arr []Card, N int) []Card {
	changeNum := 0
	// n
	for n := 0; n < N-1; {

		//fmt.Println(arr[n], "ターゲット", n)
		//fmt.Println(arr)
		//fmt.Println(range_f, "####", range_l)

		range_f := n
		range_l := N - 1

		min_k := range_f

		// 最終ラインまで
		for ; range_f != range_l+1; {

			// 最小値を更新する
			if arr[min_k].toInt() > arr[range_f].toInt() {
				min_k = range_f
			}
			range_f++
		}

		// 最小値とターゲットを交換
		if min_k != n {
			//fmt.Println(arr[n], " ==> ", arr[min_k])

			changeNum++

			temp := arr[n]
			arr[n] = arr[min_k]
			arr[min_k] = temp
		}
		//fmt.Println(arr)
		n++
	}

	fmt.Println(reduce(arr))

	return arr
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func reduce(cardArray []Card) string {
	reducedString := ""
	for _, card := range cardArray {
		reducedString += " " + card.label
	}
	return strings.Trim(reducedString, " ")
}

type
	Card struct {
		label string
	}

func (c *Card) toInt() int {
	num, _ := strconv.Atoi(string([]rune(c.label)[1:]))
	return num
}

func (c *Card) toMark() string {
	return string([]rune(c.label)[1:])
}

func isStable(cardArray []Card, formattedCardArray []Card) bool {

	checkedCardLabels := make([]string, 0)

	for _, card := range formattedCardArray {
		for _, otherCard := range cardArray {

			// 順序が一緒だったらok
			if otherCard.label == card.label {
				checkedCardLabels = append(checkedCardLabels, card.label)
				break
			}

			if otherCard.toInt() == card.toInt() && !arrayContains(checkedCardLabels, otherCard.label) {
				return false
			}
		}
	}
	return true
}

func arrayContains(arr []string, str string) bool {
	for _, v := range arr {
		if v == str {
			return true
		}
	}
	return false
}



Measured memory_bytes: 3308
fun main(args: Array<String>) {
    val s0 = Array<String>(3) { next() }.sorted()
    val s = Array<String>(3) { s0[it] }
    val MX = 2001
    var ans = MX * 3
    val d = Array(3) { Array(3) { BooleanArray(MX) } }
    do {
        for (i in 0 until 3) for (j in 0 until 3) for (k in 0 until s[i].length) {
            if (i >= j) continue
            var ok = true
            for (ni in k until s[i].length) {
                val nj = ni - k
                if (nj >= s[j].length) break
                if (s[i][ni] == '?' || s[j][nj] == '?') continue
                if (s[i][ni] != s[j][nj]) ok = false
            }
            d[i][j][k] = ok
        }
        fun f(i: Int, j: Int, k: Int) = if (k >= s[i].length) true else d[i][j][k]
        for (x in 0 until MX) for (y in 0 until MX) {
            if (!f(0, 1, x)) continue
            if (!f(1, 2, y)) continue
            if (!f(0, 2, x + y)) continue
            val now = listOf(s[0].length, x + s[1].length, x + y + s[2].length).max()!!
            ans = Math.min(ans, now)
        }
    } while (nextPermutation(s))
    println(ans)
}
fun nextPermutation(a: Array<String>): Boolean {
    for (i in a.size - 1 downTo 1) {
        if (a[i - 1] < a[i]) {
            val swapIndex = find(a[i - 1], a, i, a.size - 1)
            val temp: String = a[swapIndex]
            a[swapIndex] = a[i - 1]
            a[i - 1] = temp
            a.sort(i, a.size)
            return true
        }
    }
    return false
}
private fun find(dest: String, a: Array<String>, s: Int, e: Int): Int {
    if (s == e) return s
    val m = (s + e + 1) / 2
    return if (a[m] <= dest) find(dest, a, s, m - 1) else find(dest, a, m, e)
}
fun next() = readLine()!!


Measured memory_bytes: 120880
#include <iostream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;


struct rec
{
	ll s,t,c;
	
};

struct st
{
	ll s,t;
};

bool cmp(const st &a,const st &b)
{
	return a.t<b.t;
}

int main()
{
	int n,c;cin >> n >> c;
	vector<ll> lap(500005);
	rep(i,500000)lap[i]=0;
	vector<rec> stc(n);
	rep(i,n)
	{
		cin >> stc[i].s >>stc[i].t>>stc[i].c;
		stc[i].c--;
	}

	vector<vector<st>> St(c);
	vector<vector<bool>> isuse(c);
	rep(i,n)
	{
		st foo;
		foo.s=stc[i].s;
		foo.t=stc[i].t;
		isuse[stc[i].c].push_back(true);	
		St[stc[i].c].push_back(foo);
	}

	rep(i,c)
	{
		sort(St[i].begin(),St[i].end(),cmp);
	}

	
	
	rep(i,c)
	{
		if(!St[i].empty())
		rep(j,St[i].size()-1)
		{
			if(St[i][j].t==St[i][j+1].s)
			{
				St[i][j+1].s=St[i][j].s;
				//St[i].erase(St[i].begin()+j);

				isuse[i][j]=false;
				
			}
		}
	}

	//vector<ll> lap(500005);

	rep(i,c)
	{
		rep(j,St[i].size())
		{
			if(isuse[i][j])
			{
				lap[St[i][j].s]++;
				lap[St[i][j].t+1]--;
			}
			
		}
	}

	rep(i,500000)lap[i+1]+=lap[i];

	ll ans=0;

	rep(i,500000)ans=max(ans,lap[i]);
	
	//rep(i,100)cout<<lap[i];

	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 9216
#include <stdio.h>

int main(void)
{
    char b;

    scanf("%c",&b);
    switch(b){
        case 'A':
            printf("T");
            break;
        case 'T':
            printf("A");
            break;
        case 'G':
            printf("C");
            break;
        case 'C':
            printf("G");
            break;
    }
    printf("\n");

    return 0;

}

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


int main(void){
    // Your code here!
    int n, m, x, y;
    cin>>n>>m>>x>>y;
    
    vector<int> a(n+1), b(m+1);
    a[0]=x;
    b[0]=y;
    
    for(int i=1; i<n+1; i++){
        cin>>a[i];
    }
    for(int i=1; i<m+1; i++){
        cin>>b[i];
    }
    
    int mx=-101, my=101;
    
    for(int i=0; i<n+1; i++){
        mx=max(mx, a[i]);
    }
    for(int i=0; i<m+1; i++){
        my=min(my, b[i]);
    }
    
    
    if(my>mx){
        cout<<"No War"<<endl;
    }else{
        cout<<"War"<<endl;
    }
}


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

int main() {
  const unsigned long long MOD = 1000000007;
  unsigned long long N;
  std::cin >> N;
  std::vector<unsigned long long> f(N + 1, 0);
  std::vector<bool> b(N + 1, false);
  for (auto i = 1ull; i <= N; ++i) {
    for (auto j = 2ull; j < i; ++j) {
      if (b[j]) { continue; }
      if (i % j == 0) {
        b[i] = true;
        ++f[j];
        auto x = i / j;
        while (x % j == 0) {
          ++f[j];
          x /= j;
        }
      }
    }
    if (!b[i]) { f[i] = 1; }
    else { f[i] = 0; }
  }
  auto ans = 1ull;
  for (auto i = 2ull; i <= N; ++i) {
    ans *= f[i] + 1;
    ans %= MOD;
  }
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 256
def divisor(x):
    ret = []
    i = 1
    while i*i <= x:
        if x%i == 0:
            ret.append(i)
            if x//i != i:
                ret.append(x//i)
        i += 1
    return sorted(ret, reverse=True)

n,m = map(int,input().split())
for g in divisor(m):
    if m//g >= n:
        print(g)
        break


Measured memory_bytes: 2940
//https://atcoder.jp/contests/abc140/tasks/abc140_a
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int n;
    cin >> n;
    cout << n*n*n << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    int n ;cin >> n ;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<int> rev(n);
    rep(i,n) {
        rev[a[i]-1] = i+1;
    } 
    rep(i,n) cout << rev[i] << " " ;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
const int N=100010;
int n,a[N],b[N],ca[N],cb[N],p[N],ans;
map<int,int> mp;
set<int > gm;
int find(int x)
{
	while(p[x]!=x)
	{
		p[x]=p[p[x]];
		x=p[x];
	}
	return x;
}
int main()
{
	ans=0;
	gm.clear();
	scanf("%d",&n);
	a[n]=b[n]=0;
	int ind=1;
	for(int i=0;i<N;i++)
	{
		p[i]=i;
	}
	for(int i=0;i<n;i++)
	{
		scanf("%d",a+i);
		mp[a[i]];
		a[n]^=a[i];
		ca[i]=a[i];
	}
	for(int i=0;i<n;i++)
	{
		scanf("%d",b+i);
		mp[b[i]];
		b[n]^=b[i];
		cb[i]=b[i];
	}
	cb[n]=b[n];
	ca[n]=a[n];
	mp[a[n]];
	mp[b[n]];
	sort(ca,ca+n+1);
	sort(cb,cb+n+1);
	for(int i=0;i<n+1;i++)
	{
		if(ca[i]!=cb[i])
		{
			printf("-1");
			return 0;
		}
	}
	for( auto& it : mp)
	{
		it.second=ind++;
	}
	for(int i=0;i<n+1;i++)
	{
		a[i]=mp[a[i]];
		b[i]=mp[b[i]];
	}
	for(int i=0;i<n;i++)
	{
		if(a[i]!=b[i])
		{
			ans++;
			int x=find(a[i]);
			int y=find(b[i]);
			if(x!=y)
			{
				p[x]=y;
			}
		}
	}
	int x=find(a[n]);
	int y=find(a[n]);
	if(x!=y)
	p[x]=y;
	for(int i=0;i<n+1;i++)
	{
		if(a[i]!=b[i]||i==n)
		gm.insert(find(a[i]));
	}
	ans+=(int)gm.size();
	ans--;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  set<int> S;
  int q;
  cin >> q;
  while (q--) {
    int op, x;
    cin >> op >> x;
    if (op == 0) {
      S.insert(x);
      cout << S.size() << endl;
    } else if (op == 1) {
      cout << (S.find(x) != S.end()) << endl;
    } else if (op == 2) {
      S.erase(x);
    } else {
      int l = x, r;
      cin >> r;
      auto left = S.lower_bound(l);
      auto right = S.upper_bound(r);
      for (auto it = left; it != right; it++) {
        cout << *it << endl;
      }
    }
  }
}


Measured memory_bytes: 12480
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
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...));
}
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 (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
// const int MOD = 1e9 + 7;

int main() {
    string s;
    cin >> s;
    cout << "ABC";
    cout << s;
}


Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return read.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtype!real;
// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //
void solve(){
	int n = rint;
	long[] hs = rlong(n);
	
	string ans = "Yes";
	foreach(i; 0 .. n){
		if(i == 0) hs[i] -= 1;
		else if(hs[i - 1] > hs[i]){
			ans = "No";
			break;
		}
		else if(hs[i - 1] == hs[i]){
			continue;
		}
		else{
			hs[i] -= 1;
		}
	}
	ans.writeln;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl '\n';
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll POSITIVE_INFINITY = 9223372036854775807;
const ll NEGATIVE_INFINITY = -9223372036854775807;
const ll MOD = 1000000007;
const ld PI = acos(-1.0);

template <typename T> inline T bigMod(T A,T B,T M = MOD){A %= M;T ret = 1;while(B){if(B & 1) ret = (ret * A) % M;A = (A * A) % M;B = B >> 1;}return ret;}
template <typename T> inline T invMod (T A,T M = MOD){return bigMod(A,M-2,M);}

const int N = 200005;

int main(){
  FASTER;
  string str;
  cin >> str;
  int n = str.size();
  string ans(n, 'x');
  cout << ans << "\n";  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  string s;
  cin >> s;
  for (int i = 1; i <= s.size(); ++i) {
    if (s[i - 1] == (i % 2 ? 'L' : 'R')) {
      puts("No");
      return 0;
    }
  }
  puts("Yes");
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
	int X,Y; cin >> X >> Y;
	if(X % Y == 0){
		cout << -1 << endl;
		return 0;
	}
	cout << X << endl;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main(){
    long long a,v,b,w,t;
    cin >> a >> v >> b >> w >> t;
    if(w>=v){
        cout << "NO" << endl;
    }else{
        long long d = max(b - a,a - b);
        if(d<=t*(v - w)){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }
}

Measured memory_bytes: 3636
n,k = map(int,input().split())
t = [0] * n

for _ in range(k):
    d = int(input())
    a = list(map(int,input().split()))

    for e in a:
        t[e-1] += 1
ans = 0
l = [i for i in t if i == 0]
# print(l)
print(len(l))

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

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

	int H, N;
	scanf("%d %d", &H, &N);

	vector<pair<int, int>> M(N);
	for (int i = 0; i < N; i++) {
		scanf("%d %d", &(M[i].first), &(M[i].second));
	}

	vector<int> MP(H + 1);
	MP[0] = 0;
	for (int i = 1; i <= H; i++) {
		MP[i] = 100000000 + 1;
		for (int j = 0; j < N; j++) {
			if (M[j].first > i) {
				MP[i] = min(MP[i], M[j].second);
			} else {
				MP[i] = min(MP[i], M[j].second + MP[i - M[j].first]);
			}
		}
		// cout << "MP[" << i << "]=" << MP[i] << "\n";
	}

	cout << MP[H];
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(){
    long long n, k;
    std::cin >> n >> k;
    long long ans = 0;
    for(long long i = k; i <= n+1; i++){
        ans += (2*n+1-i)*i/2-(i-1)*i/2+1;
        ans %= 1000000007;
    }
    std::cout << ans << std::endl;
}


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

//{ SFT
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
//gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bit(n) (1LL << (n))
#define bits(n) bitset(n)
#define pcnt(x) __builitin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique(x).begin(),(x).end()),(x).end());
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).flont_back(a)
#define eb(x, a) (x).emplaes_back(a)
#define F first
#define S second
#define cauto (const auto &)
template <class A, class B>
using pii = vector<pair<A, B>>;
template <class T> //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T> //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <class T>
bool chmax(T &a, const T &b) //最大値更新 返り値はbool
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) //最小値更新 返り値はbool
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr long long mod1 = 1e9 + 7;
constexpr long long mod2 = 998244353;
//} END

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int n, cnt = 0;
    string s;
    cin >> n >> s;

    rep(i, 0, s.size())
    {
        if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
        {
            ++cnt;
        }
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define oo 1000000010
#define mod 998244353
const int N = 310;

char s[N];

int n , k;

vector< int > v;

int dp[N][N][N];

int solve(int i,int give,int used){
	if(used > k)
		return 0;
	if(i == (int)v.size()){
		if(give > 0)
			return 0;
		return 1;
	}
	if(dp[i][give][used] != -1)
		return dp[i][give][used];
	dp[i][give][used] = solve(i + 1 , give, used);
	for(int j = 1;j <= give;j++){
		dp[i][give][used] += solve(i + 1 , give - j , used);
		if(dp[i][give][used] >= mod) dp[i][give][used] -= mod;
	}
	for(int j = 1;j <= v[i];j++){
		dp[i][give][used] += solve(i + 1 , give + j , used + j);
		if(dp[i][give][used] >= mod) dp[i][give][used] -= mod;
	}
	return dp[i][give][used];
}

int main(){
	scanf("%s",s);
	n = strlen(s);
	scanf("%d",&k);
	int cnt = 0;
	for(int i = 0 ;i < n;i++){
		if(s[i] == '0'){
			v.push_back(cnt);
			cnt = 0;
		}
		else
			cnt++;
	}
	v.push_back(cnt);
	reverse(v.begin(),v.end());
	memset(dp,-1,sizeof(dp));
	cout << solve(0 , 0 , 0) << endl;
	return 0;
}


Measured memory_bytes: 120152
#include <bits/stdc++.h>
using namespace std;
 
int N, a, ganjil, dua=0, empat=0;
int main(){
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> a;
        if(a%2==1) ganjil++;
        else if(a%4==0) empat++;
        else dua++;
    }
    if(dua==0) empat++;
    if(empat>=ganjil){
    	cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	} 
}

Measured memory_bytes: 3620
main = do
  [n,y] <- map read . words <$> getLine
  putStrLn $ unwords . map show $ head ([[a,b,n-a-b] |a <- [0..n],b<- [0..n-a],(n-a-b) >= 0 && 10000*a + 5000*b + 1000*(n-a-b) == y] ++ [[-1,-1,-1]])

Measured memory_bytes: 892
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long n,k,subtraction;

        n = sc.nextLong();
        k = sc.nextLong();
        
        subtraction = n - ((n / k) * k);
        
        
        if(subtraction >= Math.abs(subtraction - k)){
            subtraction = Math.abs(subtraction - k);
        }
        
        System.out.println(subtraction);
    }
}


Measured memory_bytes: 23636
///**PEACE AND MERCY BE UPON YOU**\\\

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const int MOD = 1e9 + 7;

//********FILE READ AND WRITE*************************\\

#define INPUT(x)                freopen(x,"r",stdin)
#define OUTPUT(x)               freopen (x,"w",stdout)

//----------------------------------------------------\\

#define pb                      push_back
#define endl                    '\n'
#define LCM(a,b)                (a/__gcd(a,b))*b
#define GCD(a,b)                __gcd(a,b)
#define SP(x,y)                 fixed<<setprecision((y))<<(x)
#define PI                      acos(-1.0)
#define distance(x1,y1,x2,y2)   sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1))

#define taratari                ios_base::sync_with_stdio(0);cin.tie(NULL);


///**********************************************************************************\\\


int main()
{
    taratari

    int x,b,t;
    cin>>x>>b>>t;

    if(x>t)
    {
        cout<<"0";
        return 0;
    }

    int sum=0,i=2;

    int start=x;

    while(start<=t)
    {
      sum+=b;
      start=x*i;
      i++;
    }

    cout<<sum;



    return 0;
}



Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;
int H, W, A, B;
const int MAXH = 100010;
const int MAXW = 100010;
int mod = 1e9 + 7;

ll a[MAXW];
// (H + W)!
ll fact[MAXH + MAXW];
//(H + W)!^{-1}
ll invfact[MAXH + MAXW];

// a^n modを計算
ll modpow(ll a, ll n, ll mod) {
	ll res = 1;
	while(n > 0) {
		if(n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}

	return res;
}

ll modinv(ll a, ll m) {
	return modpow(a, m - 2, m);
}

ll modkaijo(ll n) {
	ll res = 1;
	while(n > 1) {
		res = (res % mod) * (n % mod);
		n--;
	}

	return res;
}

void init() {
	fact[0] = invfact[0] = 1;
	rep(i, 1, MAXH + MAXW) {
		fact[i] = (fact[i - 1] * i) % mod;
		invfact[i] = modinv(fact[i], mod);
	}
}

ll nCr(ll n, ll r) {
	return fact[n] * invfact[r] % mod * invfact[n - r] % mod;
}

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

	cin >> H >> W >> A >> B;
	init();

	memset(a, 0, sizeof(a));

	for(int i = W; i > B; i--) {
		(a[i] = nCr(i - 1 + H - A - 1, H - A - 1)) %= mod;
		(a[i] *= nCr(W - i + A - 1, A - 1)) %= mod;
	}

	ll rsl = 0;
	for(int i = W; i > B; i--) (rsl += a[i]) %= mod;

	cout << rsl % mod << endl;

}


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

using namespace std;

#define PB push_back
#define MP make_pair

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vii;

const int MOD = 1e9+7;
const int INF = 1e9;

int main() {
  string s;
  cin >> s;
  int len = s.length();
  if (len == 1) {
    cout << s << endl;
    return 0;
  } else {
    for (int i = 0; i < len; i++) {
      int tmp = 0;
      for (int j = i+1; j < len; j++) {
        tmp += s[j] - '0';
      }
      if (tmp < (len-i-1)*9 - 1) {
        s[i]--;
        for (int j = i+1; j < len; j++) {
          s[j] = '9';
        }
      }
    }
  }
  cerr << s << endl;
  int ans = 0;
  for (int i = 0; i < len; i++) {
    ans += s[i]-'0';
  }

  cout << ans << endl;
  return 0;
}


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

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


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int a,b;
    cin>>a>>b;
    for (int i = 1; i < 4; i++)
    {
        if (i!=a &&i!=b)
        {
            cout<<i<<endl;
        }
        
    }
    
    
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
from operator import mul


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


class UnionFind:
    def __init__(self, n):
        # 負  : 根であることを示す。絶対値はランクを示す
        # 非負: 根でないことを示す。値は親を示す
        self.table = [-1] * n
        self.size = [1] * n
        # self.group_num = n

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

    def get_size(self, x):
        r = self.root(x)
        return self.size[r]

    def is_same(self, x, y):
        return self.root(x) == self.root(y)

    def union(self, x, y):
        r1 = self.root(x)
        r2 = self.root(y)
        if r1 == r2:
            return
        # ランクの取得
        d1 = self.table[r1]
        d2 = self.table[r2]
        if d1 <= d2:
            self.table[r2] = r1
            self.size[r1] += self.size[r2]
            if d1 == d2:
                self.table[r1] -= 1
        else:
            self.table[r1] = r2
            self.size[r2] += self.size[r1]
        # self.group_num -= 1

n, m, k = LI()
U = UnionFind(n)
G1 = [[] for _ in range(n)]
for _ in range(m):
    a, b = LI()
    G1[a - 1] += [b - 1]
    G1[b - 1] += [a - 1]
    U.union(a - 1, b - 1)

G2 = [[] for _ in range(n)]
for _ in range(k):
    c, d = LI()
    G2[c - 1] += [d - 1]
    G2[d - 1] += [c - 1]

for i in range(n):
    ret = U.get_size(i) - 1 - len(G1[i])
    for j in G2[i]:
        if U.is_same(i, j):
            ret -= 1
    print(ret, end=" ")

Measured memory_bytes: 113028
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
class d{
    public static void Main(){
        long n = int.Parse(Console.ReadLine());
        string[] str = Console.ReadLine().Split(' ');
        long[] a = new long[n+1];
        for(int i=0; i<n; i++){
            a[i] = long.Parse(str[i]);
        }
        a[n] = Int32.MinValue;
        long money = 1000;
        long stock = 0;
        for(int i=0; i<n; i++){
            if(a[i] < a[i+1]){
                stock += money/a[i];
                money %= a[i];
            }
            if(a[i] > a[i+1]){
                money += stock * a[i];
                stock = 0;
            }
        }
        Console.WriteLine(money);
    }
}


Measured memory_bytes: 17880
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    // 入力値
    String input = sc.nextLine();

    int sum = 0;
    for (int i=0; i<input.length(); i++) {
      sum += Integer.parseInt(input.substring(i, i+1));
    }

    // 9で割れるか
    int amari = sum % 9;
    String result = amari == 0 ? "Yes" : "No";
    System.out.println(result);
  }
}


Measured memory_bytes: 51076
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll; typedef unsigned long long ull; typedef unsigned int uint; typedef long double ld;
 
int main() { ios_base::sync_with_stdio(false); cin.tie(0);
 
int n;
cin >> n;
ll t;
ld ans = 1;
for (int i = 0; i < n; i++)
{
    cin >> t;
    if (ans != -1)
       ans *= t;
    if (ans > 1000000000000000000 || ans < 0)
       ans = -1;
    if (t == 0)
       ans = 0;
}
cout << (ll)ans<<endl;
return 0;
}

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

int main() {
    int n;cin >> n;
    int v[20];
    int c[20];
    for(int i=0;i<n;i++) cin >> v[i];
    for(int i=0;i<n;i++) cin >> c[i];

    int ans = 0;
    for(int bit=0;bit<(1<<n);bit++){
        int sum = 0;
        for(int i=0;i<n;i++){
            if((bit >> i) & 1){
                sum += v[i] - c[i];
            }
        }
        ans = max(ans, sum);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <atcoder/all>

#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
//#define inf 2000000000
#define inf 8000000000000000000
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#define ykh mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;
using namespace atcoder;

const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
const int maxn=200005;
//i_am_noob
int n;

signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0);
    cin >> n;
    rep(n) cout << "ACL";
    cout << "\n";
    return 0;
}


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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  ll a,b,c;
  cin>>a>>b>>c;
  ll x = c - a - b;

  if(x > 0 && x * x > 4 * a * b){
    puts("Yes");
  }else{
    puts("No");

  }
  
  return 0;
}


Measured memory_bytes: 256