akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
string s;
int n;
int main(){
    cin >> n;
    cin >> s;
    int ans = 0;
    for (int  i = 0; i < s.size() - 2; i++)
        if (s.substr(i,3) == "ABC") ans++;
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string.h>
using namespace std;
#define pb push_back
#define all(v) v. begin(),v. end()
#define  rep(i,n,v) for(i=n;i<v;i++)
#define per(i,n,v) for(i=n;i>v;i--)
#define ff first 
#define ss second 
#define pp pair<ll,ll>
#define ll  long long
#define endl '\n'
void solve()
{
  ll n, a,m=0,b=1, c,k=0, i, j,l=1e9+7;
  string s, r, y;
  cin>>s;
  rep(i,0,s.length())
  {
    k=0;
     while(s[i]=='R'){i++;k++;}
     m=max(m,k);
  }
  cout<<m<<endl;
}
int main()
{
 ios_base::sync_with_stdio(false);
  cin. tie(0);cout. tie(0);
    ll t=1;
   //cin>>t;
    while(t--)
    {
      solve();
    }
    return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll ar[300005],br[300004],cr[2000003];
ll i,k,j,sum,a,b,cnt,maxii,l;
map<ll,ll>mp;
vector<ll>vc;
string s,s1,s2;
int main()
{
    double n,x=0,t,y=0;
    j=0;
    cin>>a;
   x=a/3.0;
   y=a-(x+x);

   t=y*x*x;
   printf("%0.12lf",t);

}



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

// ----------- define --------------
#define int long long
#define ii pair<int,int>
#define fi first
#define sc second
#define all(x) (x).begin(),(x).end()
// ---------------------------------

void MAIN() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (auto &i : a) cin >> i;
  sort(all(a));
  int ans = 0;
  for (int i = 0; i < n - k; i++) {
    ans += a[i];
  }
  cout << ans << '\n';
}

signed main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 4716
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <stack>
#include <queue>
//#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
//input
int main(void)
{
    int N, K;
    cin >> N >> K;
    int a[N];
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
    }
    map<int, int> x;
    for (int i = 0; i < N; i++)
    {
        x[a[i]]++;
    }
    int cnt = 0;
    if (x.size() <= K)
    {
        cout << 0 << endl;
        return 0;
    }
    else
    {
        vector<int> y;
        for (auto j : x)
        {
            y.push_back(j.second);
        }
        sort(y.begin(), y.end());
        for (int i = 0; i < x.size() - K; i++)
        {
            cnt += y[i];
        }
        cout << cnt << endl;
    }
    return 0;
}


Measured memory_bytes: 14280
#include <iostream>
#include <string>//
#include <vector>//
#include <map>
#include <cstdlib>
#include <numeric>
#include <algorithm>//ソート等に使用
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <thread>///////////////////
#include <queue>//幅優先等のキュー

#define rep(i,m,n) for(int i=(m);i<(n);i++)
#define rem(i,m,n) for(int i=(m);i>(n);--i)

#define MOD 1000000007
//#define MOD 998244353
#define MAX 

using namespace std;

using ll = long long int;
using ld = long double;
using std::swap;

vector<int> v;
vector<int> w;
vector<long long int> vll;
vector<long long int> wll;
//vector<vector<int>> vec(50, vector<int>(4, 0));
vector<vector<int>> vv;
vector<vector<int>> ww;


int main() {
	int X, Y;
	cin >> X >> Y;
	rep(i, 0, X+1) {
		int leg = 4 * i + 2 * (X - i);
		if (leg == Y) {
			cout << "Yes" << '\n';
			return 0;
		}
	}
	cout << "No" << '\n';

	return 0;

}

Measured memory_bytes: 3596
#include"bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	ll mod = 1e9 + 7;
	int n;
	cin >> n;
	ll a,ans = 1;
	map<int, ll>mp;
	mp[-1] = 3;
	rep(i, n) {
		cin >> a;
		ans *= (mp[a - 1] - mp[a]);
		ans %= mod;
		mp[a]++;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 9716
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int[] b = new int[n];
    for(int i=0;i<k;i++) {
      int d = sc.nextInt();
      int[] a = new int[d];
      for(int j=0;j<d;j++){
        a[j]  = sc.nextInt();
        int c = a[j];
		b[c-1] = 1;
      }      
    }
    int count = 0;
    for(int x=0;x<b.length;x++) {
      if(b[x]==0) {
      count = count + 1;
      }
    }
    System.out.println(count);
  }
}


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

int main(){
    ll N,K;
    cin >> N >> K;
    map<ll,ll> mp;
    rep(i,N){
        ll a,b;
        cin >> a >> b;
        mp[a]+=b;
    }
    rep(i,100100){
        if(mp[i]>=K){
            cout << i << endl;
            return 0;
        }else{
            K-=mp[i];
        }
    }
    return 0;
}

Measured memory_bytes: 9856
/*
ID: espr1t
TASK: 
KEYWORDS: 
*/

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;
FILE* in = stdin; FILE* out = stdout;

const int MAX = 200002;

int n;
char a[MAX];
int A, B, C, D;

bool solve() {
    A--, B--, C--, D--;
    if (D < C) {
        bool okay = false;
        for (int i = B; i <= D; i++) {
            if (i > 0 && i + 1 < n) {
                if (a[i - 1] == '.' && a[i] == '.' && a[i + 1] == '.')
                    okay = true;
            }
        }
        if (!okay) return false;
    }
    
    for (int i = min(A, B); i < max(C, D); i++) {
        if (a[i] == '#' && a[i + 1] == '#')
            return false;
    }
    return true;
}

int main(void) {
//	in = fopen("A.in", "rt");
	
	fscanf(in, "%d %d %d %d %d", &n, &A, &B, &C, &D);
	fscanf(in, "%s", a);
	
	fprintf(out, "%s\n", solve() ? "Yes" : "No");
	
	return 0;
}

Measured memory_bytes: 384
#include <iostream>

int main () {
  char b;
  std::cin >> b;
  if(b == 'A') std::cout << 'T' << std::endl;
  else if(b == 'T') std::cout << 'A' << std::endl;
  else if(b == 'G') std::cout << 'C' << std::endl;
  else std::cout << 'G' << std::endl;
  return 0;
}

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

using Lint=long long;

template<int mod> class ModInt
{
 private:
    Lint val;
 public:
    Lint value(){ return val; }
    ModInt(Lint x=0){ val=x%mod; }
    ModInt pow(int n){
        ModInt res(1),x(val);
        while(n>0){ if(n&1) res*=x; x*=x; n>>=1; }
        return res;
    }
    ModInt inv(){ return pow(mod-2); }
    ModInt& operator+=(ModInt rhs){ val+=rhs.val; if(val>=mod) val-=mod; return *this; }
    ModInt& operator-=(ModInt rhs){ val+=mod-rhs.val; if(val>=mod) val-=mod; return *this; }
    ModInt& operator*=(ModInt rhs){ val=val*rhs.val%mod; return *this; }
    ModInt& operator/=(ModInt rhs){ *this*=rhs.inv(); return *this; }
    ModInt operator+(ModInt rhs){ return ModInt(val)+=rhs; }
    ModInt operator-(ModInt rhs){ return ModInt(val)-=rhs; }
    ModInt operator*(ModInt rhs){ return ModInt(val)*=rhs; }
    ModInt operator/(ModInt rhs){ return ModInt(val)/=rhs; }
};
using mint=ModInt<1000000007>;

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

   vector<vector<mint>> dp(N+1,vector<mint>(N));
   for(int i=1;i<=N;i++) dp[1][i-1]=1;
   for(int i=1;i<N;i++){
      for(int j=0;j<=N-i;j++){
         int L,R;
         if(s[i-1]=='>'){
            if(j==0) continue;
            L=0; R=j-1;
         }else{
            if(N-i-j==0) continue;
            L=j; R=N-i-1;
         }
         dp[i+1][L]+=dp[i][j];
         dp[i+1][R+1]-=dp[i][j];
      }
      for(int j=1;j<N;j++) dp[i+1][j]+=dp[i+1][j-1];
   }
   cout<<dp[N][0].value()<<endl;
   return 0;
}


Measured memory_bytes: 70784
#include<stdio.h>
#include<string.h>

typedef struct {
	int Up;
	int Sorth;
	int East;
	int West;
	int North;
	int Down;
}DICE;
DICE North(DICE *t);
DICE Sorth(DICE *t);
DICE East(DICE *t);
DICE West(DICE *t);
void assignment(DICE *t);
int main()
{
	unsigned int i;
	char word[100];
	DICE Dice1;
	assignment(&Dice1);
	scanf("%s", word);
	for (i = 0; i < strlen(word); i++){
		switch (word[i]){
		case 'N':Dice1 = North(&Dice1);
			break;
		case 'S':Dice1 = Sorth(&Dice1);
			break;
		case 'E':Dice1 = East(&Dice1);
			break;
		case 'W':Dice1 = West(&Dice1);
			break;
		}
	}
	printf("%d\n", Dice1.Up);

	return 0;
}

void assignment(DICE *t){
	int i, as, a[6];
	DICE temp;
	for (i = 0; i < 6; i++){
		scanf("%d", &as);
		a[i] = as;
	}
	t->Up = a[0], t->Sorth = a[1], t->East = a[2], t->West = a[3], t->North = a[4], t->Down = a[5] ;
}
DICE North(DICE *t){
	DICE temp = { t->Sorth, t->Down, t->East, t->West, t->Up, t->North };
	return temp;
}
DICE Sorth(DICE *t){
	DICE temp = { t->North, t->Up, t->East, t->West, t->Down, t->Sorth };
	return temp;
}
DICE East(DICE *t){
	DICE temp = { t->West, t->Sorth, t->Up, t->Down, t->North, t->East };
	return temp;
}
DICE West(DICE *t){
	DICE temp = { t->East, t->Sorth, t->Down, t->Up, t->North, t->West };
	return temp;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, a;
  cin >> n;
  vector<ll> s(n);
  rep(i, n){
    cin >> a;
    a--;
    s[a] = i + 1;
  }
  rep(i, n){
    cout << s[i];
    hina;
  }
  memi;
}


Measured memory_bytes: 1536
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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


int main() {

  int N, K;
  cin >> N >> K;
  vector<ll> V(N);
  REP(i, N) cin >> V[i];

  std::vector<ll> acc_l(N), acc_r(N);
  REP(i, N){
    if (i == 0) {
      acc_l[0] = V[0];
      acc_r[N - 1] = V[N - 1];
    }else{
      acc_l[i] = acc_l[i - 1] + V[i];
      acc_r[N - 1 - i] = acc_r[N - i] + V[N - 1 - i];
    }
  }
  //cout << "a" << endl;

  ll tmp = 0;
  ll tmp_l = 0;
  ll tmp_max = 0;
  vector<ll> p;
  REP(i, K + 1){
    if (i > N) continue;
    if (i == 0) tmp_l = 0;
    else{
      tmp_l = acc_l[i - 1];
    }
    REP(j, K + 1 - i){
      if (i + j > N) continue;
      if (j == 0) tmp = tmp_l;
      else if (j != 0){
        tmp = tmp_l + acc_r[N - j];
      }

      p = {};
      p.insert(p.end(), V.begin(), V.begin() + i);
      p.insert(p.end(), V.end() - j, V.end());
      //for(auto x : p) cout << x;
      //cout << endl;
      sort(p.begin(), p.end());
        //cout << "a" << endl;
      REP(k, K + 1 - i - j){
        //cout << i << " " << j << " " << k << " " << tmp << endl;
        if (k == 0) continue;
        if (k > p.size()) break;
        if (p[k - 1] > 0) break;

        tmp -= p[k - 1];
      }
      tmp_max = max(tmp_max, tmp);

      //cout << "a" << endl;

    }
  }

  cout << tmp_max << endl;


  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int LL;
char s[105];
int main(){
    scanf("%s",s);
    int a=0,b=0;
    for(int i=0;s[i];i++){
        if(s[i]=='C') a=1;
        if(s[i]=='F' && a==1) b=1;
    }
    if(b) puts("Yes");
    else puts("No");
}


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

#define TRUE 1
#define FALSE 0

int main(void) {
	int N, numR = 0, numB = 0;
	char s;
	scanf("%d", &N);
	for (int i = 0; i <= N; i++) {
		scanf("%c", &s);
		if (s == 'R') {
			numR++;
		}
		else if (s == 'B') {
			numB++;
		}
	}
	if (numR > numB) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	return 0;
}

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

int main(){
    int n, k;
    string s;
    cin >> n >> s >> k;
    k -= 1;

    for(int i=0; i<n; i++){
        if(s[i] != s[k]) s[i] = '*';
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3584
n = int(input())
s = dict()
s["AC"]=0
s["WA"]=0
s["TLE"]=0
s["RE"]=0

for i in range(n):
    si = input()
    s[si] += 1

a = ["AC", "WA", "TLE", "RE"]
for i in a:
    print(i + " x " + str(s[i]))

Measured memory_bytes: 9200
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int dp[100100];
int main()
{
	int n,inf=100100;
	rep(i,100100) dp[i]=inf;dp[0]=0;
	rep(i,100100){
		for(int j=1;i+j<100100;j*=6) dp[i+j]=min(dp[i+j],dp[i]+1);
		for(int j=1;i+j<100100;j*=9) dp[i+j]=min(dp[i+j],dp[i]+1);
	}
	cin>>n;cout<<dp[n]<<endl;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int main(int argc, const char * argv[]) {
    int n, x[100], y[1000];
    double p=0, p1=0, p2=0, p3=0, p4=0;
    int i, max=0;
    scanf("%d", &n);
    for(i=0;i<n;i++){
        scanf("%d", &x[i]);
    }
    for(i=0;i<n;i++){
        scanf("%d", &y[i]);
    }
    for(i=0; i<n; i++){
        p += abs(x[i]-y[i]);
        p1 = abs(x[i]-y[i]);
        p2 += abs((x[i]-y[i])*(x[i]-y[i]));
        p3 += abs((x[i]-y[i])*(x[i]-y[i])*(x[i]-y[i]));
        if(max < p1){
            max = p1;
        }
    }
    p2 = sqrt(p2);
    p3 = pow(p3, 1.0/3.0);
    p4 = max;
    printf("%lf\n", p);
    printf("%lf\n", p2);
    printf("%lf\n", p3);
    printf("%lf\n", p4);
    
    return 0;
}

Measured memory_bytes: 676
s = input()
K = int(input())

t = sorted(set(s))[0:K]

l = sorted(set(s))[0:K]

for i in range(min(K,len(t))):
    w = t[i]
    for j in range(len(s)):
        if s[j]==w:
            for k in range(2,6):
                l.append(s[j:j+k])

l = sorted(set(l))

print(l[K-1])

Measured memory_bytes: 40816
#include <stdio.h>
int main() {
    int i, cnt = 0;
    char c;
    for (i = 0; i < 4; i++) {
        if (scanf("%c", &c) == -1) return -1;
        if (c == '2') cnt++;
    }
    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  vector<int> B(N);
  for (int i = 0; i < N; i++) {
    B.at(A.at(i)-1)=i+1;
  }
  for(int i=0;i<N;i++){
    cout <<B.at(i)<< endl;
  }  
}

Measured memory_bytes: 1664
n,k = map(int,input().split())
cnt=[0 for _ in range(n)]
for i in range(k):
    d=int(input())
    a= list(map(int,input().split()))
    for x in a:
        cnt[x-1]+=1
ans=0
for x in cnt:
    if x==0:
        ans+=1
print(ans)


Measured memory_bytes: 9180
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(){
        int a,b,k;
        int i,j;
        cin>>a>>b>>k;
        if(a>b-k+1) for( i=a; i<=b; ++i) cout<<i<<endl;
        else{
                for( i=a; i<a+k; ++i) cout<<i<<endl;
        for( j=max(i,b-k+1); j<=b; ++j) cout<<j<<endl;
        }
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args) {
        int n = int.Parse(Console.ReadLine());
        List<int> r = new List<int>();
        r.Add(int.Parse(Console.ReadLine()));
        r.Add(int.Parse(Console.ReadLine()));
        int ans = r[1]-r[0];
        int min = Math.Min(r[0],r[1]);
        for (int i = 2; i < n; i ++) {
            r.Add(int.Parse(Console.ReadLine()));
            int tmp = r[i] - min;
            if(ans < tmp) ans = tmp;
            if(min > r[i]) min = r.Min();
        }
        Console.WriteLine(ans);
    }
}


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


int main()
{


        long long n,m,a,b,c,d,e,f,g,p,q,r,fr,sc,tr,sz,tz,sz1,sz2,i,j,k,mx=-9,mn=999999999999; string str,ttr,ntr;
        long long x=0,y=0,cnt=0,res=0,ttl=0,ans=0,sum=0; long long flg=0,flag=1,na=0,as=1;
        vector<long long>u,v,w; vector< pair<long long,long long> >vct,tct; vector<string>vst;
        set<long long>st,nt,tt; map<long long,long long>mp,nq,qr,mp1,mp2;

        //scanf("%lld",&n);

        cin>>a>>b>>c;


        if(c>=a+b)
        {

        fr=c-a-b;  sc=fr*fr;

        tr=4*a*b;

        if(sc>tr)cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
        }
        else
        {
            cout<<"No"<<endl;
        }

















    return 0;
}





Measured memory_bytes: 256
#include<stdio.h>

long long nums1[270000], nums2[270000], leaves;

void help(int node, int left, int right) {
  if (nums2[node] == 0)
    return;

  nums1[node] += nums2[node] * (right - left);
  
  if (right - left > 1) {
    nums2[node * 2] += nums2[node];
    nums2[node * 2 + 1] += nums2[node];
  }

  nums2[node] = 0;
}

void add(int nl, int nr, int val, int node, int left, int right) {
  help(node, left, right);

  if (right <= nl || left >= nr)
    return;
  else if (left >= nl && right <= nr) {
    nums2[node] += val;
    help(node, left, right);
  } else {
    add(nl, nr, val, node * 2, left, (left + right) / 2);
    add(nl, nr, val, node * 2 + 1, (left + right) / 2, right);
    nums1[node] = nums1[node * 2] + nums1[node * 2 + 1];
  }
}

long long get(int nl, int nr, int node, int left, int right) {
  help(node, left, right);
  
  if (left >= nr || right <= nl)
    return 0;
  else if (left >= nl && right <= nr)
    return nums1[node];
  else
    return get(nl, nr, node * 2, left, (left + right) / 2) + get(nl, nr, node * 2 + 1, (left + right) / 2, right);
}

int main() {
  int n, q, i, x, y, z, command, d[100010] = {};
  
  scanf("%d %d", &n, &q);

  for(leaves = 1; leaves < n; leaves *= 2);

  for(i = 0; i < leaves; i++) {
    if (i < n)
      nums1[leaves + i] = d[i];
    else
      nums1[leaves + i] = 0;
  }

  for (i = leaves - 1; i; i--)
    nums1[i] = nums1[i * 2] + nums1[i * 2 + 1];

  for(i = 0; i < q; i++) {
    scanf("%d %d %d", &command, &x, &y);
    
    if (command)
      printf("%lld\n", get(x - 1, y, 1, 0, leaves));
    else {
      scanf("%d", &z);
      add(x - 1, y, z, 1, 0, leaves);
    }
  }
}



Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;




int main()
{
    int N,T;
    cin >> N >> T;
    vl t(N);
    in(N,t);
    t.pb(2e9+2);
    
    ll ans = 0;
    ll s = -1, f = -1;
    rep(i,N+1){
        if(t[i] <= f) f = t[i]+T;
        else ans += (f-s), s = t[i], f = t[i]+T;
    }
    cout << ans << endl;

    
    
    
    

    return 0;
}


Measured memory_bytes: 4864
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std; using P=pair<int,int>; using ll=long long; ll m=1e9+7;

int main() {
  int h,w,k; cin>>h>>w>>k; w--; k--; if (w==0) return puts("1")*0;
  // 0<=pw<=wに注意
  ll path[w+1][w+1]; fill(path[0],path[w+1],0);
  for(int i=0;i<(1<<w);i++) {
    bool ok=true, b[w];
    for(int j=0;j<w;j++) {
      if ((i&(1<<j)) && (i&(1<<j+1))) ok=false;
      if (i&(1<<j)) b[j]=true; else b[j]=false;
    }
    if (!ok) continue;
    for(int j=0;j<=w;j++) {
      if (j!=0 && b[j-1]) path[j][j-1]++;
      else if (j!=w && b[j]) path[j][j+1]++;
      else path[j][j]++;
      //cout<<j<<" "<<b[j]<<endl;
    }
  }
  /*
  for(int i=0;i<=w;i++) {
    for(int j=0;j<=w;j++){
      cout<<path[i][j]<<" ";
    } cout<<endl;
  } cout<<endl;*/

  ll dp[h+1][w+1]; fill(dp[0],dp[h+1],0); dp[0][0]=1;
  for(int i=0;i<h;i++) {
    for(int j=0;j<=w;j++)  {
      for(int l=0;l<=w;l++) {
        dp[i+1][j]+=dp[i][l]*path[l][j]%m; dp[i+1][j]%=m;
      }
      dp[i+1][j]%=m;
    }
  }
  cout<<dp[h][k]<<endl;
}

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

int N;
pair<int,int> red[100];
pair<int,int> blue[100];

int main(){
    int N,Q;
    string S;
    cin>>N>>Q>>S;
    int l[Q],r[Q];
    for(int i=0;i<Q;i++){
      cin>>l[i]>>r[i];
      l[i]--;
      r[i]--;
    }
    int ans[N]={0};
    for(int i=1;i<N;i++){
        ans[i]=ans[i-1];
        if(S.at(i-1)=='A'&&S.at(i)=='C')ans[i]++;
    }
    for(int i=0;i<Q;i++){
        cout<<ans[r[i]]-ans[l[i]]<<endl;
    }
}


Measured memory_bytes: 2176
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

    public static void main(String[] args) throws Exception {

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            String[] input = br.readLine().split(" ");
            int trainCharge = Integer.parseInt(input[0]);
            int dicountBusCharge = Integer.parseInt(input[1]) / 2;
            int sumCharge = trainCharge + dicountBusCharge;

            System.out.println(sumCharge);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 22996
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var str = ReadLine();
        var isMatch = true;
        var alfa = "qwertyuiopasdfghjklzxcvbnmAC";
        var isC = 0;
        for(var i = 0; i < str.Length; i++)
        {
            if (i == 0 && !(str.Substring(i, 1) == "A")) isMatch = false;
            if (i >= 2 && i <= str.Length - 2 && str.Substring(i, 1) == "C") isC++; 
            if (!alfa.Contains(str.Substring(i, 1))) isMatch = false;
        }
        if (isC!=1) isMatch = false;
        WriteLine(isMatch ? "AC" : "WA");
    }
}



Measured memory_bytes: 13140
N,M = map(int,input().split())
maxn,minn = map(int,input().split())
for i in range(M-1):
    L,R = map(int,input().split())
    if L > maxn:
        maxn = L
    if R < minn:
        minn = R
if minn < maxn:
    ans = 0
else:
    ans = minn - maxn + 1
print(ans)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int main(){
    char a[105];
    int b,ans=0,flag=0;
    string display;

    cin>>a;

    b=strlen(a);
    for(int i=0;i<b;i++){

        if(a[i]=='0'&&flag==0||a[i]=='1'&&flag==0){
            flag=1;
            display=a[i];
        }else if(flag==1&&a[i]!='B'){
            display=display+a[i];
        }else if(display.empty()){
            
        }else if(a[i]=='B'){
            display.pop_back();
        }
    }
        cout<<display<<endl;

}

Measured memory_bytes: 256
n = int(input())
p = list(map(int, input().split(" ")))

ans = 0
for i, num in enumerate(p):
    if num == i + 1:
        ans += 1
        if i == n - 1:
            p[i], p[i - 1] = p[i - 1], p[i]
        else:
            p[i], p[i + 1] = p[i + 1], p[i]

print(ans)


Measured memory_bytes: 14004
local n = io.read("*n", "*l")
local t = {}
for i = 1, 5 do
  t[i] = 0LL
end
local z = {}
z.M = 1
z.A = 2
z.R = 3
z.C = 4
z.H = 5
for i = 1, n do
  local s = io.read()
  local ss = s:sub(1, 1)
  if z[ss] then
    t[z[ss]] = t[z[ss]] + 1
  end
end
local ret = 0LL
ret = ret + t[1] * t[2] * (t[3] + t[4] + t[5])
ret = ret + t[1] * t[3] * (t[4] + t[5])
ret = ret + t[1] * t[4] * t[5]
ret = ret + t[2] * t[3] * (t[4] + t[5])
ret = ret + t[2] * t[4] * t[5]
ret = ret + t[3] * t[4] * t[5]
local rets = tostring(ret):gsub("LL", "")
print(rets)


Measured memory_bytes: 384
function main(input){
  const lines = input.split('\n');
  const N = lines[0].split(' ').map(x => parseInt(x))[0];
  const K = lines[0].split(' ').map(x => parseInt(x))[1];
  const A = lines[1].split(' ').map(x => parseInt(x)).sort();

  const size_sorted_A = [];
  var current_number = A[0];
  var count = 1;
  for(var i = 1;i<=A.length;i++){
    if(A[i-1]==A[i]){
      count++;
    }else{
      size_sorted_A.push(count);
      count=1;
    }
    current_number = A[i];
  }
//console.log('---')
//console.log(size_sorted_A)

  size_sorted_A.sort((a, b) => a - b);
//console.log(size_sorted_A)

  var result = 0;

  if(size_sorted_A.length <= K){
    console.log(result);
    return;
  }

  for(var i=0;i<size_sorted_A.length;i++){
    var size = size_sorted_A[i];
    result+=size;
    if(size_sorted_A.length-(i+1) <= K){
      console.log(result);
      return;
    }
//console.log(size_sorted_A)
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));



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

int main() {
    string s;
    int count=0;
    cin >> s;
    int l = (int)(s.size());
        for(int i = 0;i < l/2;i++){
            if(s[i] != s[l-i-1]){
                count++;
            }
        }
        cout << count;
}

Measured memory_bytes: 256
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve
ll dp[3001][3001];
int n;
vector<ll> a;

ll calc(int i, int j){
  if(dp[i][j] >= 0)return dp[i][j];
  if(j == i + 1)return a[i];
  ll res = -linf;

  res = max(res, a[i] - calc(i+1, j));
  res = max(res, a[j-1] - calc(i, j-1));

  return dp[i][j] = res;
}

int main(int argc, char const* argv[])
{
  cin >> n;
  a = vector<ll>(n, 0);
  rep(i, n)cin >> a[i];
  rep(i, n+1){
    rep(j, n+1){
      dp[i][j] = -1;
    }
  }
  cout << calc(0, n) << endl;
	return 0;
}


Measured memory_bytes: 70784
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define LL long long

void _143() {
    int n;
    cin >> n;

    vector<int> L;
    int tmp;
    for (int i = 0; i < n; ++i) {
        cin >> tmp;
        L.push_back(tmp);
    }
    sort(L.begin(), L.end());

    LL count = 0;
    for (int i = 0; i < n - 2; ++i) {
        for (int j = i + 1; j < n - 1; ++j) {
            for (int k = j + 1; k < n; ++k) {
                if (L[i] + L[j] <= L[k]) {
                    break;
                } 
                count++;
            }
        }
    }

    cout << count << endl;
}

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define f(i, a, b) for(ll i = a; i <= b; ++i)
#define ff(i, a, b) for(ll i = a; i < b; ++i)
#define F(i, a, b) for(ll i = a; i >= b; --i)
#define FF(i, a, b) for(ll i = a; i > b; --i)
#define x first
#define y second
#define X real()
#define Y imag()
using namespace std;
typedef complex<ll> P;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;

ll n;
string s;
map<string, ll> mp;

signed main(){
//	freopen("PERFECT1.inp","r",stdin);
//	freopen("PERFECT1.out","w",stdout);
//	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	f(i,1,n){
		cin >> s;
		sort(s.begin(), s.end());
		mp[s]+=1;
	}
	ll ans = 0;
	for(auto i : mp){
		ans += (i.y*(i.y-1)/2);
	}
	cout << ans;
}



Measured memory_bytes: 11136
n1 = 0
n2 = 0
n4 = 0
nb = int(input())
for v in map(int,input().split()):
   if v%4 == 0:
      n4 += 1
   elif v%2 == 0:
      n2 += 1
   else:
      n1 += 1
if (n1 <= n4) or (n1 == n4 + 1 and n2 == 0):
   print('Yes')
else:
   print('No')


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

int main() {
  int64_t N, count=1;
  string S;
  cin >> N;
  vector <string> vec(N);
  
  for (int i=0; i<N; i++) {
    cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  
  for (int i=1; i<N; i++) {
    //cout << i << " " << vec.at(i);
    if (vec.at(i-1)!=vec.at(i)) count++;
        //cout << count << endl;
  }
  cout << count << endl;
}

Measured memory_bytes: 9564
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int y[] = {0, 0};
		int x[] = {0, 0};

		x[1] = sc.nextInt();
		y[1] = sc.nextInt();
		int n = sc.nextInt();

		for(int i = 0;i < n;i++){
			int x2 = sc.nextInt();
			int y2 = sc.nextInt();
			int a = sc.nextInt();

			if(a == 1 && x[0] < x2)x[0] = x2;
			else if(a == 2 && x[1] > x2)x[1] = x2;
			else if(a == 3 && y[0] < y2)y[0] = y2;
			else if(a == 4 && y[1] > y2)y[1] = y2;
		}

		if((x[1]-x[0]) < 0 || (y[1]-y[0]) < 0 )System.out.println(0);
		else System.out.println((x[1]-x[0])*(y[1]-y[0]));

	}
}


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

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

    int sum = 0;
    for(int i=0;i<n;i++){
        int x;
        cin >> x;

        sum += (k-x < x ? (k-x) * 2 : x * 2);
    }
    
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define UINF 18446744073709551615
#define F first
#define S second
#define ll long long
#define N 100010
using namespace std;
ll n,a,b,c,nxt[3],nx[N];
string ans="",ss[N];
int main(){
	ll i,j;
	cin>>n>>a>>b>>c;
	for(i=0;i<n;i++)
	{
		cin>>ss[i];
	}
	nxt[0]=nxt[1]=nxt[2]=n;
	for(i=n-1;i>=0;i--)
	{
		if(ss[i]=="AB")
		{
			nx[i]=min(nxt[1],nxt[2]);
			nxt[0]=i;
		}
		else if(ss[i]=="AC")
		{
			nx[i]=min(nxt[0],nxt[2]);
			nxt[1]=i;
		}
		else
		{
			nx[i]=min(nxt[0],nxt[1]);
			nxt[2]=i;
		}
	}
	for(i=0;i<n;i++)
	{
		if(ss[i]=="AB")
		{
			if(a==b&&a==0)
			{
				puts("No");
				return 0;
			}
			if(a<b)
			{
				ans+="A";
				a++;
				b--;
			}
			else if(a>b)
			{
				ans+="B";
				a--;
				b++;
			}
			else
			{
				j=nx[i];
				if(j!=n)
				{
					if(ss[j]=="BC")
					{
						ans+="B";
						a--;
						b++;
					}
					else
					{
						ans+="A";
						a++;
						b--;
					}
				}
				else
				{
					ans+="A";
					a++;
					b--;
				}
			}
		}
		else if(ss[i]=="AC")
		{
			if(a==c&&a==0)
			{
				puts("No");
				return 0;
			}
			if(a<c)
			{
				ans+="A";
				a++;
				c--;
			}
			else if(a>c)
			{
				ans+="C";
				a--;
				c++;
			}
			else
			{
				j=nx[i];
				if(j!=n)
				{
					if(ss[j]=="BC")
					{
						ans+="C";
						a--;
						c++;
					}
					else
					{
						ans+="A";
						a++;
						c--;
					}
				}
				else
				{
					ans+="A";
					a++;
					c--;
				}
			}
		}
		else
		{
			if(b==c&&b==0)
			{
				puts("No");
				return 0;
			}
			if(b<c)
			{
				ans+="B";
				b++;
				c--;
			}
			else if(b>c)
			{
				ans+="C";
				b--;
				c++;
			}
			else
			{
				j=nx[i];
				if(j!=n)
				{
					if(ss[j]=="AC")
					{
						ans+="C";
						b--;
						c++;
					}
					else
					{
						ans+="B";
						b++;
						c--;
					}
				}
				else
				{
					ans+="B";
					b++;
					c--;
				}
			}
		}
		if(a<0||b<0||c<0)
		{
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	for(i=0;i<ans.size();i++)
	{
		cout<<ans[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 7672
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,q,p=0,lena=0,lenb,ans=0;
  int s[100000],t[50000];
  cin>>n;
  for(int i=0;i<n;i++) cin>>s[i];
  cin>>q;
  for(int j=0;j<q;j++) cin>>t[j];
  for(int i=0;i<q;i++){
    lena=0;
    lenb=n;
    p=0;
    while(lena<lenb){
      p=(lena+lenb)/2;
      if(t[i]==s[p]){
	ans++;
	break;
      }
      else if(t[i]<s[p]) lenb=p;
      else if(t[i]>s[p]) lena=p+1;
    }
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3632
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
num=0
dist=abs(a-(t-h[0]*0.006))
for i in range(1,n):
    if dist>abs(a-(t-h[i]*0.006)):
        num=i
        dist=abs(a-(t-h[i]*0.006))
print(num+1)


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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> VECINT;
typedef vector<ll> VECLL;

int main() {
  int A,B;cin>>A>>B;

  int ans = 0;
  FOR(i,A,B+1) {
    string strnum = to_string(i);
    if (strnum[0]==strnum[4] && strnum[1]==strnum[3]) ans++;
  }
  OUT(ans);

  return 0;
}

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

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

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

  vector<ll> fact(n+1); //階乗
  vector<ll> fact_inv(n+1); //階乗の逆元
  fact[0] = 1;
  for (int i = 0; i < n; i++) fact[i+1] = (fact[i] * (i+1)) % MOD;
  fact_inv[n] = modPow(fact[n], MOD-2, MOD);
  for (int i = n-1; i >= 0; i--) fact_inv[i] = (fact_inv[i+1] * (i+1)) % MOD;

  ll ret = 0;
  for (int m = 0; m <= min(k, n-1); m++) {
    ll n_c_m = (((fact[n] * fact_inv[n-m]) % MOD) * fact_inv[m]) % MOD;
    ll n_h_m = (((fact[n-1] * fact_inv[n-m-1]) % MOD) * fact_inv[m]) % MOD;

    ret = (ret + (n_c_m * n_h_m) % MOD) % MOD;
  }

  cout << ret << endl;
}


Measured memory_bytes: 3328
A, B, C, X, Y = gets.chomp.split(" ").map(&:to_i)
# A円 X枚
# B円 Y枚
# C円
results = []

def cost(c_num)
  return C*c_num + A*([X-c_num/2,0].max) + B*([Y-c_num/2,0].max)
end

(0..2*[X,Y].max).each do |c_num|
  next if c_num%2 != 0
  results << cost(c_num)
end
puts results.min


Measured memory_bytes: 2684
N, M = map(int, input().split())
a, b = [0]*M, [0]*M
ls = []
for i in range(M):
    a[i], b[i] = map(int, input().split())
    ls.append([a[i], b[i]])
ls.sort(key=lambda x:x[1])

ans = 0
start, end = 0, 0

for x in ls:
    if x[0] < end:
        continue
    else:
        ans += 1
        start = x[0]
        end = x[1]
print(ans)

Measured memory_bytes: 22876
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(dead_code)]

use itertools::Itertools;
use proconio::input;
use proconio::marker::{Chars, Usize1};

#[allow(unused_macros)]
#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    //($arg:expr) => (println!("{:?}",$arg));
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
}
#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}

macro_rules! echo {
    ($($a:expr),*) => {
          $(println!("{}",$a))*
      }
}

use std::cmp::*;
use std::collections::*;
use std::ops::{Add, Div, Mul, Sub};

#[allow(dead_code)]
static INF_I64: i64 = 92233720368547758;
#[allow(dead_code)]
static INF_I32: i32 = 21474836;
#[allow(dead_code)]
static INF_USIZE: usize = 18446744073709551;
#[allow(dead_code)]
static M_O_D: usize = 1000000007;
#[allow(dead_code)]
static PAI: f64 = 3.1415926535897932;

trait IteratorExt: Iterator {
    fn toVec(self) -> Vec<Self::Item>;
}

impl<T: Iterator> IteratorExt for T {
    fn toVec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

trait CharExt {
    fn toNum(&self) -> usize;
    fn toAlphabetIndex(&self) -> usize;
    fn toNumIndex(&self) -> usize;
}
impl CharExt for char {
    fn toNum(&self) -> usize {
        return *self as usize;
    }
    fn toAlphabetIndex(&self) -> usize {
        return self.toNum() - 'a' as usize;
    }
    fn toNumIndex(&self) -> usize {
        return self.toNum() - '0' as usize;
    }
}

trait VectorExt {
    fn joinToString(&self, s: &str) -> String;
}
impl<T: ToString> VectorExt for Vec<T> {
    fn joinToString(&self, s: &str) -> String {
        return self
            .iter()
            .map(|x| x.to_string())
            .collect::<Vec<_>>()
            .join(s);
    }
}

trait StringExt {
    fn get_reverse(&self) -> String;
}
impl StringExt for String {
    fn get_reverse(&self) -> String {
        self.chars().rev().collect::<String>()
    }
}

trait UsizeExt {
    fn pow(&self, n: usize) -> usize;
}
impl UsizeExt for usize {
    fn pow(&self, n: usize) -> usize {
        return ((*self as u64).pow(n as u32)) as usize;
    }
}

fn main() {
    input! {
       s:Chars
    }

    let mut ans: usize = 0;
    let a = s.iter().map(|&x| x as usize - '0' as usize).toVec();
    let sum: usize = a.iter().sum();
    if sum % 9 == 0 {
        echo!("Yes");
    } else {
        echo!("No");
    }
}


Measured memory_bytes: 4616
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
Scanner scan=new Scanner(System.in);
int n[]=new int[1000];
int i=0;
int a=scan.nextInt();
int b=scan.nextInt();
int c=scan.nextInt();
do {
	n[i]=scan.nextInt();
	i++;
	if(i==a) {break;}
}while(true);
i=0;
double ans1=1000000;
double ans12=100000;
double ans2=1000000;
int ans3=0;
do {
	ans1=b-0.006*n[i];
	ans12=c-ans1;
	if(ans12<0) {ans12=ans12*-1;}
	if(ans12<ans2) {ans2=ans12;ans3=i+1;}
	i++;
	if(i==a) {break;}
}while(true);
System.out.println(ans3);
}
}

Measured memory_bytes: 23888
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
lint x[100100],y[100100];
lint mo=1000000007;
lint cal(vector<lint> a){
	int n=a.size();lint ret=0;
	rep(i,n){
		ret+=((lint)(i+1)*(n-i))%mo*a[i];
		ret%=mo;
	}
	return ret;
}
int main()
{
	int n,m;
	cin>>n>>m;
	vector<lint> a,b;
	rep(i,n) cin>>x[i];
	rep(i,m) cin>>y[i];
	rep(i,n-1) a.pb(x[i+1]-x[i]);
	rep(i,m-1) b.pb(y[i+1]-y[i]);
	cout<<(cal(a)*cal(b))%mo<<endl;
}


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

const int INF = 1e9;
const int mod = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);

vector<string> dp(10010);

int main()
{
    int b[10] = {0,2,5,5,4,5,6,3,7,6};
    int n,m;
    cin >> n >> m;
    int a[m];
    for(int i = 0; i < m; i++){
        cin >> a[i];
        dp[b[a[i]]] = char(a[i]+'0');
    }
    for(int i = 0; i <= n; i++){
        for(int j = 0; j < m; j++){
            if(dp[i] != ""){
                string s = dp[i] + char(a[j]+'0');
                sort(s.rbegin(),s.rend());
                if(dp[i+b[a[j]]].size() > s.size()) continue;
                else if(dp[i+b[a[j]]].size() < s.size()){
                    dp[i+b[a[j]]] = s;
                }else{
                    dp[i+b[a[j]]] = max(dp[i+b[a[j]]],s);
                }
            }
        }
    }
    //for(int i = 0; i <= 20; i++) cout << i << ' ' << dp[i] << endl;
    cout << dp[n] << endl;
    return 0;
}

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

int compare_int(const void *a, const void *b){
  return *(int*)a - *(int*)b;
}

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

  int O[N/2 + 1], E[N/2 + 1];
  O[N/2] = 0;
  E[N/2] = 0;

  int i, j;

  for(i = 0; i < N; i++){
    if(i%2 == 1) scanf("%d", &O[i/2]);
    else scanf("%d", &E[i/2]);
  }

  qsort(O, N/2, sizeof(int), compare_int);
  qsort(E, N/2, sizeof(int), compare_int);
  
  int max[2][2][2] = {};

  int count_O = 1, count_E = 1;

  for(i = 0; i < N/2; i++){
    if(O[i] != O[i+1]){
      if(max[0][0][0] < count_O){
        max[0][1][0] = max[0][0][0];
        max[0][1][1] = max[0][0][1];
        max[0][0][0] = count_O;
        max[0][0][1] = O[i];
      } else if(max[0][1][0] < count_O){
        max[0][1][0] = count_O;
        max[0][1][1] = O[i];
      }
      count_O = 1;
    } else count_O++;

    if(E[i] != E[i+1]){
      if(max[1][0][0] < count_E){
        max[1][1][0] = max[1][0][0];
        max[1][1][1] = max[1][0][1];
        max[1][0][0] = count_E;
        max[1][0][1] = E[i];
      } else if(max[1][1][0] < count_E){
        max[1][1][0] = count_E;
        max[1][1][1] = E[i];
      }
      count_E = 1;
    } else count_E++;
  }
  int ans;
  if(max[0][0][1] == max[1][0][1]){
    ans = N - max[1][0][0] - max[0][1][0];
    if(ans > N - max[0][0][0] - max[1][1][0]) ans = N - max[0][0][0] - max[1][1][0];
  } else ans = N - max[0][0][0] - max[1][0][0];

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

  return 0;
}


Measured memory_bytes: 792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll);
ll mod_fact(ll, ll);
ll mod_inv(ll, ll);
ll gcd(ll, ll);
//
int main(){
    ll a;
    cin >> a;
    cout << a * (a - 1) / 2;
}

Measured memory_bytes: 256
def main():
    n, d = map(int, input().split())
    xy = [list(map(int, input().split())) for _ in [0]*n]
    cnt = 0
    for i in range(n):
        x, y = xy[i]
        if x**2 + y**2 <= d**2:
            cnt += 1
    print(cnt)


main()


Measured memory_bytes: 46920
#include<bits/stdc++.h>
#define REP(i,n) for(int (i)=0 ;(i)<(n);(i)++)
#define REPR(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(x) x.begin(),x.end()
#define REVERSE(x) reverse(x.begin(),x.end())
#define SORT(x,n) sort(x,x)
#define P pair<int,int>
typedef long long LL;
const int INF=1000000007;
using namespace std;
int main(){
  int N,M;
  cin>>N>>M;
  int a[M];
  REP(i,M){
    cin>>a[i];
  }
  sort(a,a+M);
  int dis[M-1];
  REP(i,M-1){
  dis[i]=a[i+1]-a[i];
  }
  sort(dis,dis+M-1);
  reverse(dis,dis+M-1);
  int ans=0;
  if(N>=M){
    cout<<ans;
  }
  else{
  
  REP(i,N-1){
    ans+=dis[i];
  }
  cout<<a[M-1]-a[0]-ans;
}
}

Measured memory_bytes: 1024
#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

const double PI = acos(-1);
constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class Task{
public:
    void solve(istream& in, ostream& out){
        int M;
        in>>M;
        lint k = 0, dsum = 0;
        while(M--){
            lint d, c;
            in>>d>>c;
            k += c;
            dsum += d * c;
        }
        lint S = 9 * k + dsum;
        out<<(S-10)/9<<'\n';
    }
};

int main(){
    istream& in(cin);
    ostream& out(cout);
    ios_base::sync_with_stdio(false);
    in.tie(nullptr), out.tie(nullptr);
    Task solver;
    solver.solve(in, out);
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int main(){
    ios::sync_with_stdio(false);
    int n,m,s,t;
    cin >> n >> m >> s >> t;
    s--;t--;
    struct edge {int to, c1, c2;};
    vector<vector<edge>> G(n);
    rep(i, m) {
        int u,v,a,b;
        cin >> u >> v >> a >> b;
        G[u-1].push_back({v-1,a,b});
        G[v-1].push_back({u-1,a,b});
    }
    using P = pair<ll,int>;
    const ll INF = INT64_MAX>>3;
    priority_queue<P, vector<P>, greater<P>> pq;
    vector<ll> d1(n,INF);
    d1[s] = 0;
    pq.emplace(d1[s], s);
    while(!pq.empty()) {
        P p = pq.top();
        pq.pop();
        int v = p.second;
        if(p.first < d1[v]) continue;
        for(edge e: G[v]) {
            if(d1[v] + e.c1 < d1[e.to]) {
                d1[e.to] = d1[v] + e.c1;
                pq.emplace(d1[e.to], e.to);
            } 
        }
    }
    vector<ll> d2(n,INF);
    d2[t] = 0;
    pq.emplace(d2[s], t);
    while(!pq.empty()) {
        P p = pq.top();
        pq.pop();
        int v = p.second;
        if(p.first < d2[v]) continue;
        for(edge e: G[v]) {
            if(d2[v] + e.c2 < d2[e.to]) {
                d2[e.to] = d2[v] + e.c2;
                pq.emplace(d2[e.to], e.to);
            } 
        }
    }
    vector<ll> ans(n);
    ll init_money = 1e15;
    if(d1[n-1] == INF || d2[n-1] == INF)  {
        ans[n-1] = 0;
    } else {
        ans[n-1] = init_money - d1[n-1] - d2[n-1];
    }
    for(int i = n-2; i >= 0; i--) {
        if(d1[i] == INF || d2[i] == INF) {
            ans[i] = ans[i+1];
        } else {
            ans[i] = max(ans[i+1], init_money - d1[i] - d2[i]);
        }
        
    }
    rep(i,n) cout << ans[i] << endl;
}

Measured memory_bytes: 11252
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N = 0;
  cin >> N;
  int count = 1;
  vector<tuple<string, int, int>> SP;
  
  for (int i = 0; i < N; i++) {
    string s;
    int p;
    cin >> s >> p;
    SP.push_back(make_tuple(s, 100 - p, count));
    count++;
  }
  
  sort(SP.begin(), SP.end());
  for (auto t : SP) {
  	cout << get<2>(t) << endl;
  }
}


Measured memory_bytes: 3612