akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef vector<pair<ll,ll> > vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>(b);--i)
const int MOD = 1000000007;
const int MAX = 510000;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
int main(){
  ll n,x,tmp=0,ans=0;cin>>n>>x;
  rep(i,0,n){
    ll l;cin>>l;
    tmp+=l;
    if(tmp<=x){ans++;}
  }
  cout<<ans+1<<endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return true;}return false;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw2(62,1);vector<ll> pw10(19,1);

int main(){
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll K,S; cin>>K>>S;
    ll ans=0;
    rep(i,K+1)rep(j,K+1){
        if((0<=S-i-j) && (S-i-j<=K)) ans++;
    }
    cout<<ans;
}



Measured memory_bytes: 3640
#include <iostream>

int main(void) {
  int N, W[100], S = 0;
  std::cin >> N;
  for (int i = 0; i < N; i++) {
    std::cin >> W[i];
    S += W[i];
  }
  int best = S;
  int s = 0;
  for (int i = 0; i < N - 1; i++) {
    s += W[i];
    int score = (s < S - s) ? (S - s) - s : s - (S - s);
    if (score < best) {
      best = score;
    }
  }
  std::cout << best;
  return 0;
}


Measured memory_bytes: 256
l, r = map(int, input().split())

if r-l+1 >= 2019:
    print(0)
else:
    ans = 2019
    for i in range(l, r):
        for j in range(i+1, r+1):
            ans = min(ans, (i*j) % 2019)
            if ans == 0:
                break
        if ans == 0:
            break
    print(ans)


Measured memory_bytes: 2940
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int h[110000];
vector<int> path[110000];

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	cin>>n>>m;
	for(i=0;i<n;i++){
		cin>>h[i];
	}
	for(i=0;i<m;i++){
		cin>>a>>b;
		a--,b--;
		path[a].push_back(b);
		path[b].push_back(a);
	}
	int s=n;
	for(i=0;i<n;i++){
		for(auto to:path[i]){
			if(h[i]<=h[to]){
				s--;
				break;
			}
		}
	}
	cout<<s<<endl;
}

Measured memory_bytes: 9356
#include<cstdio>

long k;

int main() {
    scanf("%ld", &k);
    
    long ans = 0;
    for (long i = 0, j = 1; i < k; i++) {
        long x = ans + j;
        int y = 0;
        while (x > 0) {
            y += (x % 10);
            x /= 10;
        }
        if (y * j < ans + j) j *= 10;
        ans += j;
        printf("%ld\n", ans);
    }

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n;
	cin >> n;
	map<char, int> m;
	rep(i, n){
		string s;
		cin >> s;
		m[s[0]]++;
	}
	vector<int> su(5);
	su.at(0) = m['M'];
	su.at(1) = m['A'];
	su.at(2) = m['R'];
	su.at(3) = m['C'];
	su.at(4) = m['H'];

	ll ans = 0;
	rep(i, 3){
		ll ii = su.at(i);
		rep2(j, i+1, 4){
			ll jj = su.at(j);
			rep2(k, j+1, 5){
				ll kk = su.at(k);
				ll add = ii * jj * kk;
				ans += add;
			}
		}
	}
	cout << ans << endl;

	return 0;
}

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

using namespace std;

using ull = unsigned long long;

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

  std::vector<ull> v(n);
  std::vector<ull> c(n);

  for (ull i = 0; i < n; i++) cin >> v[i];
  for (ull i = 0; i < n; i++) cin >> c[i];
  
  ull m = 1 << n;
  int mval = 0;
  
  for (ull i = 0; i < m; i++) {
    int l = 0;
    ull i_ = i, k = 0;
    while (i_) {
      if (i_ & 0x01) {
	l = l + v[k] - c[k];
      }
      
      i_ = i_ >> 1;
      k++;
    }

    if (i) {
      mval = max(mval, l);
    } else {
      mval = l;
    }
  }

  cout << mval;
  
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
int n,a,b,c,d,i,j;
scanf("%d\n",&n);
int rank[100];
int point[100];
for(i=0;i<n;i++){
rank[i]=1;
point[i]=0;
}
int game = n*(n-1)/2;
for(i=0;i<game;i++){
scanf("%d %d %d %d\n",&a,&b,&c,&d);

if(c>d){
point[a-1]+=3;
}else if(c==d){
point[a-1]++;
point[b-1]++;
}else{
point[b-1]+=3;
}

}
for(i=0;i<n;i++){
for(j=0;j<n;j++){
if(point[i]<point[j])rank[i]++;
}
}
for(i=0;i<n;i++){
printf("%d\n",rank[i]);
}
return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i = 0; i < (n); ++i )
#define rep_rev(n,i) for(ll i = n; i >= 0; --i )
using namespace std;
using P = pair<int, int>;
const long long INF = 1LL << 60;

int main(){
  int N,K; cin >> N >> K;
  vector<int> p(N);
  int idx[2];
  int t = 0;
  ll sum = 0;
  double ans = 0;
  rep(i,N){
    cin >> p[i];
    if(i == K-1){
      for(int j = 0; j < K; ++j) sum += p[j];
      if(t < sum){
        t = sum;
        idx[0] = 0;
        idx[1] = K-1;
      }
      sum -= p[0];
    }
    else if(i > K-1){
      sum += p[i];
      if(t < sum){
        t = sum;
        idx[0] = i-K+1;
        idx[1] = i;
      }
      sum -= p[i-K+1];
    }
  }
  for(int i = idx[0]; i <= idx[1]; ++i){
    int tmp = 0;
    rep(j,p[i]) tmp += j+1;
    ans += (double)tmp/(double)p[i];
  }
  printf("%0.10lf\n",ans);
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
#define A_MAX 1000000
#define A_MAX_HALF 500000
 
using namespace std;
 
int min_factor[A_MAX + 1];
int q[A_MAX + 1];
int a[A_MAX + 1];
 
int main() {
    vector<int> primes{ 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997 };
    for (int i = 2; i <= A_MAX_HALF; ++i) {
        if (!min_factor[i]) {
            min_factor[i] = i;
        }
        int min_factor_i = min_factor[i];
        for (int p : primes) {
            int n = i * p;
            if (n > A_MAX) {
                break;
            }
            min_factor[n] = p;
            if (p == min_factor_i) {
                q[n] = q[i];
                break;
            } else {
                q[n] = i;
            }
        }
    }
 
    int N = 0;
    char c = getchar_unlocked();
    do {
        N = 10 * N + c - '0';
    } while ((c = getchar_unlocked()) >= '0');
    for (int i = 0; i < N; ++i) {
        int A = 0;
        c = getchar_unlocked();
        do {
            A = 10 * A + c - '0';
    	} while ((c = getchar_unlocked()) >= '0');
        ++a[A];
    }
 
    int is_pairwise_coprime = 1;
    for (int n = A_MAX; n > 1; --n) {
        int an = a[n];
        if (an) {
            if (an > 1) {
                if (an == N) {
                    printf("not coprime\n");
                    return 0;
                }
                is_pairwise_coprime = 0;
            }
            a[min_factor[n]] += an;
            a[q[n]] += an;
        }
    }
    if (is_pairwise_coprime) {
        printf("pairwise coprime\n");
    } else {
        printf("setwise coprime\n");
    }
 
    return 0;
}

Measured memory_bytes: 15316
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;

int gcd(int n, int m){

    if(m > n)  return gcd(m, n);

    int r = n % m;
    if(r == 0) return m;
    else       return gcd(m, r);
}

int main(){

    int N, X; cin >> N >> X;

    vector<int> x;
    bool Xincluded = false;
    for(int i=0; i<N; i++){
        int temp;
        cin >> temp;
        x.push_back(temp);
        if(X == x[i]){
            Xincluded = true;
        }
    }
    if(!Xincluded){
        x.push_back(X);
    }
    sort(x.begin(), x.end());

    vector<int> dx;
    for(int i=1; i<x.size(); i++){
        dx.push_back(x[i] - x[i-1]);
    }

    // for(int i=0; i<dx.size(); i++){
    //     cout << dx[i] << endl;
    // }
    
    int ans = dx[0];
    for(int i=1; i<dx.size(); i++){
        int temp = gcd(ans, dx[i]);
        if(ans > temp){
            ans = temp;
        }
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() {
  string S;
  cin >> S;
  unordered_map<char, int> a{};
  REP(i, S.size()) a[S[i]]++;
  int mx = 0;
  REP(i, 3) { mx = max(mx, a[i + 'a']); }
  bool ok = true;
  REP(i,3){
    if(mx==a[i+'a']||mx-1==a[i+'a']){

    }else{
      ok = false;
    }
  }
  if(ok){
    puts("YES");
  }else{
    puts("NO");
  }
}

Measured memory_bytes: 3736
N,A,B = map(int,input().split())
S = input()

t1,t2 = 0,0
for ch in S:
  if ch == "c":
    print("No")
  elif ch == "a":
    if t1 >= A+B:
      print("No")
    else:
      t1 += 1
      print("Yes")
  else:
    if t1 >= A+B or t2 >= B:
      print("No")
    else:
      t1 += 1
      t2 += 1
      print("Yes")

Measured memory_bytes: 9284
import sys

def main():
  # Xはもっとも近い整数，Nは与えられるP
  N,K = map(int, input().split())

  # listを取得
  arr = list(map(int, input().split()))
  arr.sort()

  ans = 0
  for i in range(K):
    ans = ans + arr[i]
  print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9172
import Control.Monad

main = do
    all <- getContents
    mapM_ (putStrLn . show) (calc $ words all)
   



calc :: [String] -> [Int]
calc [] = []
calc (n:m:xs) =
    length (show x) : calc xs
    where
        n1 = read n
        m1 = read m
        x = n1 + m1



Measured memory_bytes: 4112
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define FOR(i, a, b) for(ll i=(a); i < (ll)(b); ++i)
template<class T> inline bool chmax(T& a, T b) { if(a < b){ a=b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if(a > b){ a=b; return 1; } return 0;}

int main(){
	int a,b,c,d,e,f;
	cin >> a >> b >> c >> d >> e >> f;
	
	int a_water = a*100;
	int a_sugar = 0;
	int water,sugar;
	for(int at=0; at*a*100<=f; at++){
		for(int bt=0; (at*a+bt*b)*100<=f; bt++){
			if(at+bt==0) continue;
			for(int ct=0; (at*a+bt*b)*100+ct*c<=f; ct++){
				for(int dt=0; (at*a+bt*b)*100+ct*c+dt*d<=f; dt++){
					water = (at*a+bt*b)*100;
					sugar = ct*c+dt*d;
					if(sugar > e*water/100) break;
					if(a_sugar*(water+sugar) < sugar*(a_water+a_sugar)){
						a_sugar = sugar;
						a_water = water;
					}
				}
			}
		}
	}
	
	cout << a_water+a_sugar<< " "<< a_sugar<<endl;
	
	return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#define N 101


main(){
  int i,j,n,k,u,Adj[N],array[N][N];
  
  scanf("%d",&n);
  
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      array[i][j] = 0;
    }
  }
  
  
  
  for(i=1;i<=n;i++){
    scanf("%d",&Adj[i]);
    scanf("%d",&k);
    for(j=1;j<=k;j++){
      scanf("%d",&u);
      array[i][u]=1;
    }
  }

  for(i=1;i<=n;i++){
    for(j=1;j<n;j++){
      printf("%d ",array[i][j]);
    }
    printf("%d\n",array[i][j]);
  }
  return 0;
}
 

Measured memory_bytes: 636
fun main() {
    val n = readLine()!!.toInt()

    val aList = readLine()!!.split(" ").map { it.toInt() }

    val a = IntArray(1000005) { _ -> 0}

    for (x in aList) {
        if (a[x] != 0) {
            a[x] = 2
            continue
        }
        for (j in x until a.size step x) {
            a[j] += 1
        }
    }

    var answer = 0
    for (x in aList) {
        if (a[x] == 1) {
            answer += 1
        }
    }
    print(answer)
}

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

int main() {
  int N;
  cin >> N;
  map<string,int> br;
  string tmp;
  rep(i,N) {
    cin >> tmp;
    br[tmp]++;
  }
  int M;
  cin >> M;
  rep(i,M) {
    cin >> tmp;
    br[tmp]--;
  }

  int ans=0;
  for(auto itr : br) {
    ans = max(ans,itr.second);
  }

  cout << ans << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
typedef long long ll;
int h,w,n;
int dp[3003];
pair<int,int>a[3003];
int inv[200005],fact[200005];
int fastpow(int x,int y){
	if(y==0)return 1;int ret=fastpow(x,y>>1);
	return y&1?(ll)ret*ret%mod*x%mod:(ll)ret*ret%mod;
}
void init(){
	fact[0]=1;
	for(int i=1;i<200005;i++)fact[i]=(ll)fact[i-1]*i%mod;
	inv[200004]=fastpow(fact[200004],mod-2);
	for(int i=200003;i>=0;i--)inv[i]=(ll)inv[i+1]*(i+1)%mod;
}
int C(int n,int m){
	return (ll)fact[n]*inv[m]%mod*inv[n-m]%mod;
}
int calc(int x,int y,int xx,int yy){
	return C(xx+yy-x-y,xx-x);
}
int main(){
	init();
	scanf("%d%d%d",&h,&w,&n);
	for(int i=0;i<n;i++)scanf("%d%d",&a[i].first,&a[i].second);
	sort(a,a+n);
	for(int i=0;i<n;i++)dp[i]=(dp[i]+calc(1,1,a[i].first,a[i].second))%mod;
	for(int i=0;i<n;i++)
		for(int j=0;j<i;j++)
			if(a[i].first>=a[j].first&&a[i].second>=a[j].second)
				dp[i]=(dp[i]-(ll)dp[j]*calc(a[j].first,a[j].second,a[i].first,a[i].second)%mod+mod)%mod;
	int ans=calc(1,1,h,w);
	for(int i=0;i<n;i++)ans=(ans-(ll)dp[i]*calc(a[i].first,a[i].second,h,w)%mod+mod)%mod;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const ll INF = 1LL << 60;

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

    // set<ll> ans;
    // for (int i = 0; i < N; i++) {
    //     for (int j = i + 1; j < N; j++) {
    //         for (int k = j + 1; k < N; k++) {
    //             // cout << i << " " << j << " " << k << endl;
    //             string tmp1 = { S[i] };
    //             string tmp2 = { S[j] };
    //             string tmp3 = { S[k] };
    //             string tmp = tmp1 + tmp2 + tmp3;
    //             // cout << ans << endl;
    //             ans.insert(stol(tmp));
    //         }
    //     }
    // }
    // cout << ans.size() << endl;
    ll ans = 0;
    for (int i = 0; i <= 9; i++) {
        for (int j = 0; j <= 9; j++) {
            for (int k = 0; k <= 9; k++) {
                // 1桁目            
                ll tmp1 = S.find(to_string(i));
                if (tmp1 == string::npos) {
                    continue;
                }
                ll tmp2 = S.find(to_string(j), tmp1 + 1);
                if (tmp2 == string::npos) {
                    continue;
                }
                ll tmp3 = S.find(to_string(k), tmp2 + 1);
                if (tmp3 == string::npos) {
                    continue;
                }
                ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <math.h>

#define ll long long
#define ull unsigned long long

using namespace std;

const int inf = 1000000000;
const double eps = 1e-7;

void solve() {
	int n, k;
	cin >> n >> k;
	int ans = 0;
	for (; n > 0; ++ans)
		n /= k;
	cout << ans << endl;
}

int main() {
	int t = 1;
	//cin >> t;
	for (int i = 0; i < t; ++i)
		solve();
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(int i=0; i<n; i++)
#define loop(i, j, n) for(int i=j; i<n; i++)
using namespace std;
// }}} End Header

int main()
{
	double n, T, t, a;
	cin >> n >> T >> a;
	vector<double> h(n);
	vector<double> dist(n);
	rep(i,n){
		cin >> h[i];
		t = T - h[i]*0.006;
	 	dist[i] = abs(a-t);
	}
	int ans = min_element(all(dist)) - dist.begin();
	cout << ans+1 <<endl;
	return 0;
}

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

namespace ITP1_3_C
{
    class Program
    {
        static void Main(string[] args)
        {
            

            while (true)
            {
            //2つの整数x,yを読み込み、値の小さい順に出力する
            string[] a = Console.ReadLine().Split(' ');
            int x = int.Parse(a[0]);
            int y = int.Parse(a[1]);

                if (x == 0 && y == 0)
                {
                    break;
                }
                else
                {
                    if (x <= y)
                    {
                        Console.WriteLine("{0} {1}", x, y);
                    }
                    else
                    {
                        Console.WriteLine("{0} {1}", y, x);
                    }
                }
                //Console.ReadKey();
            }


            //for (int i=0; i<=3000; i++)
            //{
            //    if (x == 0 && y == 0)
            //    { Console.ReadKey(); }
            //    else
            //    {
            //        if (x <= y)
            //        {
            //            Console.WriteLine("{0} {1}", x, y) ;
            //        }
            //        else
            //        {
            //            Console.WriteLine("{0} {1}", y, x) ;
            //        }
            //    }
            //}
            //Console.ReadKey();
        }
    }
}



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

int road[50];
int main()
{
    int N, M;
    cin >> N >> M;
    for (int i = 0; i < M; i++)
    {
        int a, b;
        cin >> a >> b;
        road[a - 1]++;
        road[b - 1]++;
    }
    for (int i = 0; i < N; i++)
    {
        cout << road[i] << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    int i,j;
    char a[2][3]= {0};
    for(i=0; i<2; i++)
    {
        for(j=0; j<4; j++)
        {
            scanf("%c",&a[i][j]);
        }
    }
    if(a[0][0]==a[1][2]&&a[0][1]==a[1][1]&&a[0][2]==a[1][0])
        printf("YES\n");
    else
        printf("NO\n");

}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int N, M;
  cin >> N >> M;
  ll A[N], B[N], C[N];
  rep(i, N){
    cin >> A[i] >> B[i] >> C[i];
  }
  ll ans = 0;
  ll D[N], E[N] , F[N];
  rep(i, 8){
    rep(j, N){
      D[j]=A[j]; E[j]=B[j]; F[j]=C[j];
    }
    rep(j, 3){
      if(i&(1<<j)) {
        if(j==0){ rep(k, N) D[k] = -A[k];}
        if(j==1){ rep(k, N) E[k] = -B[k];} 
        if(j==2){ rep(k, N) F[k] = -C[k];} 
      }
    }
    ll sum[N];
    rep(j, N){
      sum[j] = D[j]+E[j]+F[j];
    }
    sort(sum, sum+N, greater<ll>());
    ll tmp = 0;
    rep(j, M){
      tmp += sum[j];
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
    
    
     
}

  

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

using namespace std;

typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> PIII;

int main(void) {
    int n;
    cin >> n;
    int a = 0;

    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        if (s == "A") {
            a++;
        } else {
            a--;
        }
        if (a < 0) {
            cout << "NO" << endl;
            return 0;
        }
    }
    if (a == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 3140
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++) //for文マクロ
using namespace std;

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P; //ペア　タイプでふ
int main()
{
    int a;
    cin >> a;
    if (a == 25)
    {
        cout << "Christmas";
    }
    else if (a == 24)
    {
        cout << "Christmas Eve";
    }
    else if (a == 23)
    {
        cout << "Christmas Eve Eve";
    }
    else
    {
        cout << "Christmas Eve Eve Eve";
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <bitset>
#include <numeric>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <numeric>
#include <cstdlib>
#include <random>
#include <bits/stdc++.h>


using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll mod=1000000007ll;
const ll inf=1000000000000000ll;

const ll MAX_N=2*100000+10;

ll a,b,c,d;

int main(){
  cin>>a>>b>>c>>d;
  if(abs(a-c)<=d || (abs(a-b)<=d&&abs(c-b)<=d)) cout<<"Yes"<<endl;
  else cout<<"No"<<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>;

#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 x[4],y[4];
    
    for(int i = 0; i < 2; i++)
    {
        cin>>x[i]>>y[i];
    }
    int dx = x[1]-x[0];
    int dy = y[1]-y[0];
    x[2]= x[1]-dy;
    y[2]=y[1]+dx;
    x[3]=x[2]-dx;
    y[3]=y[2]-dy;

    cout<<x[2]<<" "<<y[2]<<" "<<x[3]<<" "<<y[3]<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <string>

#define PI 3.1415926
using namespace std;

#define LL long long

const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, 1, -1};

LL mod(LL x, LL md) {
	return ((x % md) + md) % md;
}

class Mint {
public:
	static LL md;
	LL x;
	Mint(LL _x) {
		x = mod(_x, md);
	}
	Mint(const Mint &y) {
		x = mod(y.x, md);
	}
};

void MintMyExgcd(LL a, LL b, LL &x, LL &y) {
	// solve equation ax + by = 1 (mod m)
	LL md = Mint::md;
	if (b == 0) {
		y = 0;
		x = 1;
		return ;
	}
	MintMyExgcd(b, a % b, x, y);
	LL t = y;
	y = mod(x - (a / b) * y, md);
	x = t;
}

LL MintNY(LL x) {
	if (x == 0) {
		return 1;
	}
	LL md = Mint::md;
	LL a, b;
	MintMyExgcd(x, md, a, b);
	while (a < 0) {
		a += md;
	}
	return a;
}

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

Mint operator+(Mint a, Mint b) {
	return Mint(mod(a.x + b.x, Mint::md));
}
Mint operator-(Mint a, Mint b) {
	return Mint(mod(a.x - b.x, Mint::md));
}
Mint operator*(Mint a, Mint b) {
	return Mint(mod(a.x * b.x, Mint::md));
}
Mint operator/(Mint a, Mint b) {
	Mint c = Mint(MintNY(b.x));
	return Mint(mod(a.x * c.x, Mint::md));
}

Mint operator-(Mint a) {
	return Mint(-a.x);
}
bool operator==(Mint a, Mint b) {
	return a.x == b.x;
}
bool operator!=(Mint a, Mint b) {
	return a.x != b.x;
}
bool operator>(Mint a, Mint b) {
	return a.x > b.x;
}
bool operator<(Mint a, Mint b) {
	return a.x < b.x;
}
bool operator>=(Mint a, Mint b) {
	return a.x >= b.x;
}
bool operator<=(Mint a, Mint b) {
	return a.x <= b.x;
}

void operator+=(Mint &a, Mint b) {
	a = a + b;
}
void operator-=(Mint &a, Mint b) {
	a = a - b;
}
void operator*=(Mint &a, Mint b) {
	a = a * b;
}
void operator/=(Mint &a, Mint b) {
	a = a / b;
}

ostream& operator<<(ostream &out, Mint a) {
	out << a.x;
	return out;
}

istream& operator>>(istream &in, Mint &a) {
	in >> a.x;
	return in;
}

Mint factorial(LL n) {
	if (n == 0) {
		return Mint(1);
	}
	Mint res = 1;
	for (LL i = 1; i <= n; ++i) {
		res *= i;
	}
	return res;
}
Mint multiRange(LL s, LL t) {
	Mint res = 1;
	for (LL i = s; i <= t; ++i) {
		res *= i;
	}
	return res;
}

Mint getC(LL n, LL k) {
	if (n - k < k) {
		return getC(n, n - k);
	}
	return multiRange(n - k + 1, n) / factorial(k);
}

Mint getA(LL n, LL k) {
	return multiRange(n - k + 1, n);
}

Mint countNonNegativeDivision(LL n, LL k) {
	return getC(n + k - 1, k - 1);
}
Mint countPositiveDivision(LL n, LL k) {
	if (n < k) {
		return 0;
	}
	if (k <= 0) {
		return 0;
	}
	return getC(n - 1, k - 1);
}
Mint quickMod(Mint a, LL b) {
	Mint res = 1;
	while (b > 0) {
		if (b % 2) {
			res *= a;
		}
		a *= a;
		b /= 2;
	}
	return res;
}

LL Mint::md = 1000000007;

int main() {
	double r;
	cin >> r; 
	double res = 2 * PI * r;
	printf("%.12lf\n", res);

	return 0;
}

Measured memory_bytes: 3788
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <algorithm>
#include <iomanip> //cout << fixed << setprecision(12) << ans << endl;
using namespace std;
 
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define loop(i, l, r) for(int i = l; i < r; i++)
#define rloop(i, l, r) for(int i = l; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vec_i;

const int dx[4] = {0, 0, 1, -1};
const int dy[4] = {1, -1, 0, 0};
const int INF = 1e9;
const int MOD = 1e9+7;

int main()
{
	int n;
	cin >> n;
	int ans = 0;
	for(int i=1;i<=n;i++){
		int j = i;
		int cnt = 0;
		while(j>0){
			j /= 10;
			cnt++;
		}
		if(cnt%2) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
const long long mod = 1e9 + 7;
typedef long long ll;
typedef priority_queue<int> PQ;
typedef vector<long long> VL; // VL a(n);
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VL> VLL; // VII a(n,VI(m)) n * m
typedef pair<ll, ll> PL;
typedef map<ll, ll> MP; // MP a;
typedef vector<pair<ll, ll>> PS;

template <class T, class U>
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp
// operator << (cout,a);
// chmin(min,a)

int main() {
  ll n,k,m,x=0,y=0,z = 0,h=0,w=0,ans=0,sum = 0, Max = -1, Min = 3e9+1;
  string s,t,ss,tt;
  bool ok=true;
  cin >> s >> t;
  VL a(26),b(26);
  rep(i,s.size()){
    a[s[i]-'a']++;
  }
  rep(i,t.size()){
    b[t[i]-'a']++;
  }
  s = ""; t="";
  for(int i=0; i<26; i++){
    if(a[i]>0){
      s += string(a[i], char(i+'a'));
    }
  }
  for(int i=25; i>=0; i--){
    if(b[i] > 0){
      t += string(b[i],char(i+'a'));
    }
  }
  if(s.size() > t.size()){
    rep(i,t.size()){
      if(s[i]-'a' < t[i]-'a'){
        pri("Yes");
        return 0;
      }
      else if(s[i]-'a' > t[i]-'a'){
        pri("No");
        return 0;
      }
    }

  }
  else{
    rep(i,s.size()){
      if(s[i]-'a' < t[i]-'a'){
        pri("Yes");
        return 0;
      }
      else if(s[i]-'a' > t[i]-'a'){
        pri("No");
        return 0;
      }
    }
  }
  if(s.size() < t.size())
    pri("Yes");
  else
    pri("No");
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define rp(a) while(a--)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int a,b,c;
	while(cin>>a>>b>>c){
		bool in[11]={0};
		in[a]=1;
		in[b]=1;
		in[c]=1;
		int co=0;
		loop(i,1,11)if(!in[i]&&20>=a+b+i)co++;
		if(co>3)cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
}

Measured memory_bytes: 1152
p = int(input().split()[1])
s = input()
if 10 % p == 0:
  r = sum(i for i, x in enumerate(s, 1) if int(x) % p == 0)
else:
  d = [1] + [0] * (p - 1)
  t, y = 0, 1
  for x in reversed(s):
    t = (t + int(x) * y) % p
    d[t] += 1
    y = y * 10 % p;
  r = sum(i * (i - 1) // 2 for i in d)
print(r)

Measured memory_bytes: 3500
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const long long MOD = 1000000000 + 7;//1000000000 + 7 998244353 924844033 1000000000 + 9;
constexpr long long INF = 1LL << 60;//numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct Edge { LL to, cost; };
struct edge {
	LL from, to, cost;
};
vector<vector<Edge>>g;
vector<edge>ed;
vector<Pll>pv;
set<LL>st;
map<Pll, LL>ma;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
string str, ss;
bool f;

struct Combination {
	int mod;
	vector< int64_t > mfact, rfact;
	Combination(int sz, int mod) : mfact(sz + 1), rfact(sz + 1), mod(mod) {
		mfact[0] = 1;
		for (int i = 1; i < mfact.size(); i++) {
			mfact[i] = mfact[i - 1] * i % mod;
		}
		rfact[sz] = inv(mfact[sz]);
		for (int i = sz - 1; i >= 0; i--) {
			rfact[i] = rfact[i + 1] * (i + 1) % mod;
		}
	}
	int64_t fact(int k) const {
		return (mfact[k]);
	}
	int64_t pow(int64_t x, int64_t n) const {
		int64_t ret = 1;
		while (n > 0) {
			if (n & 1) (ret *= x) %= mod;
			(x *= x) %= mod;
			n >>= 1;
		}
		return (ret);
	}
	int64_t inv(int64_t x) const {
		return (pow(x, mod - 2));
	}
};
Combination comb(200000, MOD);
LL n, m, s, t, h, w, k, q, p, ans, sum1[210000],sum2[210000]
, cnt, a[210000], b[210000],fact[210000],rfact[210000];
int main() {
	cin >> n;
	rep(i, n)cin >> a[i];
	rep(i, 200000)fact[i] = comb.mfact[i], rfact[i] = comb.rfact[i];
	rep(i, 200000) {
		sum1[i + 1] = (sum1[i] + rfact[i + 1] * fact[i] % MOD) % MOD;
	}
	// sum1[i]:1/1+1/2~1/i
	// sum2[i]=sum1[1]~sum1[i]
	rep(i, n) {
		LL num = (sum1[i + 1] + sum1[n - i] - 1);
		while (num < 0) {
			num += MOD;
		}
		num %= MOD;
		num *= fact[n];
		num %= MOD;
		ans += num * a[i];
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 11008
using System;
using System.Linq;

public class Test
{
	public static void Main()
	{
		int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
		if(x[0]+x[1]==x[2]+x[3])
		{
			Console.WriteLine("Balanced");
		}
		else
		{
			Console.WriteLine(x[0]+x[1]>x[2]+x[3]?"Left":"Right");
		}
	}
}

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

#include <vector>
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
using namespace std;

int main() {
  int n, max0, min0, max1, min1;
  cin >> n;
  int x[n], y[n];
  rep(i, n) cin >> x[i] >> y[i];
  max0 = min0 = x[0] - y[0];
  min1 = max1 = x[0] + y[0];
  rep(i, n) {
    min0 = min(min0, x[i] - y[i]);
    max0 = max(max0, x[i] - y[i]);
    min1 = min(min1, x[i] + y[i]);
    max1 = max(max1, x[i] + y[i]);
  }

  cout << max(max0 - min0, max1 - min1) << endl;
}

Measured memory_bytes: 5184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n;
  cin >> n;
  vector<ll> cnt(n, 0);
  REP(i, n - 1) {
    ll a;
    cin >> a;
    a--;
    cnt[a]++;
  }
  REP(i, n) { cout << cnt[i] << endl; }
}

Measured memory_bytes: 4844
#include <stdio.h>
#include<string.h>
char sen[100];
char letter[26];
int count[26] = {0};
int main() {
scanf("%[^\t]s",sen);
char alpha = 'a';
for(int i=0;i<26;i++,alpha++){
    letter[i] = alpha;
}
int len = strlen(sen);
for(int i=0;i<len;i++){
    if(sen[i]>=65 && sen[i]<=90){
        sen[i] += 32;
    }
    for(int j=0;j<26;j++){
        if(sen[i]==letter[j]){
            count[j]++;
        }
    }
}
for(int i=0;i<26;i++){
    printf("%c : %d\n",letter[i],count[i]);
}


    return 0;
}



Measured memory_bytes: 2132
import numpy as np

l,l2 = map(int,input().split())
x = np.array(list(map(int,input().split())))

dp = np.zeros(l,dtype=int)
dp[1] = abs(x[0]-x[1])

for i in range(2,l):
    y = max(i - l2,0)
    dp[i] = np.min(dp[y:i] + abs(x[y:i] - x[i]))
    
print(dp[-1])

Measured memory_bytes: 22880
/*
Task:
Author: John_05
State: Unknown
Lang: C++
Solution:
*/
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
const int INF=2e9+10;
#define fi first
#define se second
#define pb push_back
#define mp make_pair

int read() {
	int xx=0,ww=1;
	char ch=getchar();
	while(ch>'9'||ch<'0') {
		if(ch=='-') ww=-ww;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') {
		xx=10*xx+ch-48;
		ch=getchar();
	}
	return xx*ww;
}

const int MAXN=100010;
int n,m;
int fa[MAXN],a[MAXN],b[MAXN];
ll ans[MAXN],sz[MAXN];

int _find(int x){
	if(fa[x]!=x) fa[x]=_find(fa[x]);
	sz[x]=sz[fa[x]];
	return fa[x];
}

int main() {
	n=read();
	m=read();
	for(int i=1;i<=m;i++){
		a[i]=read();
		b[i]=read();
	}
	for(int i=1;i<=n;i++){
		fa[i]=i;
		sz[i]=1;
	}
	ans[m+1]=(ll)(n)*(ll)(n-1)/2LL;
	for(int i=m;i>=1;--i){
		ans[i]=ans[i+1];
		int faa=_find(a[i]);
		int fab=_find(b[i]);
		if(faa!=fab){
			fa[faa]=fab;
			ans[i]-=sz[faa]*sz[fab];
			sz[faa]=sz[faa]+sz[fab];
			sz[fab]=sz[faa];
		}
	}
	for(int i=2;i<=m+1;i++) printf("%lld\n",ans[i]);
	return 0;
}

Measured memory_bytes: 4096
def solve():
    s = list(input())
    
    a=s.count('a')
    b=s.count('b')
    c=s.count('c')

    if abs(a-b) <= 1 and abs(b-c) <= 1 and abs(c-a) <= 1:
        return 'YES'

    return 'NO'

print(solve())


Measured memory_bytes: 3956
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
typedef long long ll;
using namespace std;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (b - a == c - b) puts("YES");
	else puts("NO");
	return 0;
}

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

int main() {
  ll a,b,c;
  cin >> a >> b >> c;
  if(a == b && a != c) cout << "Yes" << endl;
  else if(b == c && a != b) cout << "Yes" << endl;
  else if(a == c && a != b) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N, L[2100];

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

  std::cin >> N;

  for(int i=0;i<N;++i){
      std::cin >> L[i];
  }

  std::sort(L, L + N);

  ll res = 0ll;

  for(int i=0;i<N;++i){
      for(int j=0;j<N;++j){
          if(i == j){
              continue;
          }

          int k1 = std::upper_bound(L, L + N, std::abs(L[i] - L[j])) - L,
              k2 = std::lower_bound(L, L + N, L[i] + L[j]) - L;
          int n = k2 - k1;

          if(k1 <= i && i < k2){
              n -= 1;
          }

          if(k1 <= j && j < k2){
              n -= 1;
          }

          res += n;
      }
  }

  res /= 6;

  std::cout << res << std::endl;
}


Measured memory_bytes: 256
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


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;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  string s,t,n;
  cin>>s>>t;
  ll a,b;
  cin>>a>>b;
  cin>>n;
  if(s==n) a--;
  else if(t==n) b--;
  cout<<a<<' '<<b<<endl;
}

Measured memory_bytes: 256
H, W, M = map(int,input().split())
H_dict = dict()
W_dict = dict()
mines = set()

for i in range(M):
    h,w = map(int,input().split())
    mines.add((h,w))
    if h in H_dict.keys():
        H_dict[h] += 1
    else:
        H_dict[h] = 1
    
    if w in W_dict.keys():
        W_dict[w] += 1
    else:
        W_dict[w] = 1
tmp = 0 
H_max = list()
W_max = list()

for key in H_dict.keys():
    if H_dict[key] > tmp:
        tmp = H_dict[key]
        H_max = list()
        H_max.append(key)
    elif H_dict[key] == tmp:
        H_max.append(key)
ans_h = tmp
tmp = 0        

for key in W_dict.keys():
    if W_dict[key] > tmp:
        tmp = W_dict[key]
        W_max = list()
        W_max.append(key)
    elif W_dict[key] == tmp:
        W_max.append(key)
ans_w = tmp
        
flag = False
for h in H_max:
    for w in W_max:
        if (h,w) not in mines:
            flag = True
            break

if flag:
    print(ans_w + ans_h)
else:
    print(ans_w + ans_h -1)


#print(H_max)
#print(ans_h)
#print(W_max)
#print(ans_w)
#print(mines)

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

int main()
{
	int n,k;
	cin>>n>>k;
	int a[n+1];
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	int ans=0;
	for(int i=0;i<=n;i++)
	{
		for(int j=0;i+j<=min(n,k);j++)
		{
			vector<int> v;
			int s=0;
			for(int x=1;x<=i;x++){v.push_back(a[x]);s++;}
			for(int x=0;x<j;x++){v.push_back(a[n-x]);s++;}
			sort(v.begin(),v.end());
			int k1=k-s;
			//cout<<k1<<" i "<<i<<" j "<<j<<" sum ";
			while(k1>0 && !v.empty() && *v.begin()<0)
			{
				v.erase(v.begin());
				k1--;
			}
			int sum=0;
			for(int d=0;d<v.size();d++)
			{
				sum+=v[d];
			}
			//cout<<sum<<endl;
			ans=max(ans,sum);	
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
n,m = map(int, input().split())
S = [list(map(int, input().split())) for i in range(m)]
P = list(map(int, input().split()))
c = 0
a = 0
for a in range(2**n):
  a2 = format(a, 'b').zfill(n)
  d = 0
  for i in range(m):
    o = 0
    for j in range(S[i][0]):
      o += int(a2[S[i][j+1]-1])
    if o % 2 == P[i]:
      d += 1
  if d == m:
    c += 1
print(c)

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

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007
#define IN freopen("nocross.in","r",stdin)
#define OUT freopen("nocross.out","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 2000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define LOG 19
#define off 2

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define maxn 1000005

pair<i64,i64> a[maxn] ;

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

    for(int i=1 ; i<=n ; i++) scanf("%lld %lld",&a[i].xx,&a[i].yy) ;

    if( n==2 )
    {
        printf("%lld\n" , (a[1].yy-a[1].xx+1)+(a[2].yy-a[2].xx+1) ) ;
        return 0 ;
    }

    for(int i=2 ; i<=n ; i++ )
    {
        if( a[i].yy < a[1].yy ) swap( a[i] , a[1] ) ;
    }

    sort( a+1+1 , a+n+1 ) ;

    long long ans = 0 ;

    i64 mx = 0 ;

    for(int i=2 ; i<=n ; i++)
    {
        mx = max( mx , a[i].yy-a[i].xx+1 ) ;
    }

    ans = max( ans , max( 0LL , a[1].yy - max( a[1].xx , a[n].xx ) + 1  ) + mx ) ;

   // printf("----%lld\n",ans) ;

    i64 mnR = INF ;

    for(int i=n ; i>=2 ; i--)
    {
        mnR = min( mnR , a[i].yy ) ;
        ans = max( ans ,  max( 0LL  , mnR - a[n].xx + 1 ) +  max( 0LL , a[1].yy - max( a[1].xx , a[i-1].xx ) + 1 )  ) ;
    }

    printf("%lld\n",ans) ;

    return 0 ;
}


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

int main() {
  int N;
  cin >> N;
  int64_t a = 2, b = 1;
  if (N >= 2) {
    for (int i = 0; i < N - 1; i++) {
      int64_t temp = a + b;
      a = b;
      b = temp;
    }
    cout << b << endl;
  }
  else {
    if (N == 0) {
      cout << 2 << endl;
    }
    else {
      cout << 1 << endl;
    }
  }
  
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
using namespace std;
int main() {
  int a, b, c, k;
  cin >> a >> b >> c;
  cin >> k;
  if (a >= b && a >= c)
    a = a * pow(2, k);
  else if (b >= c)
    b = b * pow(2, k);
  else
    c = c * pow(2, k);
  cout << a + b + c << endl;
  return 0;
}

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

int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	int n;cin>>n;
	vector<int>v[n+1];
	int dst[n+1];bool vstd[n+1];
	for(int i=1;i<=n;i++){
		int a;cin>>a;
		v[i].push_back(a);
	}
	memset(vstd,0,sizeof vstd);
	memset(dst,0,sizeof dst);
	queue<int>q;
	q.push(1);
	while(q.size()){
		int node=q.front();
		q.pop();
		if(vstd[node])continue;
		vstd[node]=true;
		for(auto u:v[node]){
			if(!vstd[u]){
				dst[u]=dst[node]+1;
				q.push(u);
			}
		}
	}
	if(dst[2]){
		cout<<dst[2];
	}else{
		cout<<-1;
	}
}

Measured memory_bytes: 9620