akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T = int> void print(vector<T> v){for(auto a:v)cout<<a<<" ";cout<<endl;}

/*
*/

ll h,w,dx[]={0,1},dy[]={1,0};
pair<ll,ll> d[110][110];
string s[110];

bool comp(pair<ll,ll> a, pair<ll,ll> b){
	if(a.first>b.first)return true;
	if(a.first==b.first && a.second<b.second)return true;
	return false;
}

int main(void){
	cin>>h>>w;
	rep(i,h)cin>>s[i];
	rep(i,h)rep(j,w)d[i][j]={1e9,0};
	if(s[0][0]=='#'){
		d[0][0]={1,1};
	}else{
		d[0][0]={0,0};
	}
	priority_queue<pair<pair<ll,ll>,pair<ll,ll>>> Q;
	Q.push({d[0][0],{0,0}});
	while(!Q.empty()){
		auto p = Q.top();Q.pop();
		ll y=p.second.first,x=p.second.second;
		rep(i,2){
			if(y + dy[i] < h && x + dx[i] < w){
				auto ne = d[y][x];
				if(s[y + dy[i]][x + dx[i]]=='.'){
					if(ne.second%2==1)ne.second--;
					if(comp(d[y + dy[i]][x + dx[i]] ,ne)){
						d[y + dy[i]][x + dx[i]] = ne;
						Q.push({d[y + dy[i]][x + dx[i]] ,{y + dy[i], x + dx[i]}});
					}
				}else{
					if(ne.second==0){
						ne.second++;
						ne.first++;
					}else if(ne.second>0 && ne.second%2==0){
						ne.second-=2;
					}
					if(comp(d[y + dy[i]][x + dx[i]] ,ne)){
						d[y + dy[i]][x + dx[i]] = ne;
						Q.push({d[y + dy[i]][x + dx[i]] ,{y + dy[i], x + dx[i]}});
					}
				}
			}
		}
	}
	cout<<d[h-1][w-1].first<<endl;
	return 0;
}

Measured memory_bytes: 512
#include "iostream"
#include "algorithm"
#include "vector"

int main(int argc, char const *argv[]) {
  /* code */
  int N;
  std::cin >> N;

  std::vector<int> v(N);
  std::vector<int> flag(N);
  for (size_t i = 0; i < N; i++) {
    /* code */
    std::cin >> v[i];
    flag[i] = 0;
  }

  int res = 0;

  for (size_t i = 0; i < N; i++) {
    /* code */
    if (flag[i] == 0) {
      /* code */
      flag[i] = 1;
      int j = i + 1;
      while (j < N) {
        /* code */

        if(v[i] == v[j])
        {
          if ((j -i)%2 == 1) {
            /* code */
            res +=1;
          }
          flag[j] = 1;
          j+=1;
        }
        else
        {
          j=N;
        }
      }
    }
  }
  std::cout << res << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  char a[4];
  int ans=0;
  scanf("%s\n",a);
for (int i = 0; i < 3; i++) {
  if (a[i]=='a') {
    ans+=1;
  }
  if (a[i]=='b') {
    ans+=2;
  }
  if (a[i]=='c') {
    ans+=4;
  }
}
if (ans==7) {
  printf("Yes\n");
}else{
  printf("No\n");
}
  return 0;
}


Measured memory_bytes: 128
k, n = map(int, input().split())
a = list(map(int, input().split()))
kyori = []

for i in range(n):
    if i == n - 1:
        kyori.append(a[0] + k - a[i])
    else:
        kyori.append(a[i+1] - a[i])
print(k - max(kyori))


Measured memory_bytes: 26100
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <tuple>

#define rep(i,n) for(ll i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;
//	std::cout<<std::fixed<<std::setprecision(10);

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

	rep(i, S.size()) {
		char tmp = S[i] + N;
		if(tmp > 'Z') tmp = tmp - 'Z' + 'A' - 1;	
		S[i] = tmp;
	}

	cout << S << endl;

	return 0;
}

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

using namespace std;
int cl[100005],lst[100005];
vector<int>est[100005];
int v[100005],d[100005],c[100005];
int n,m,q; 
void dfs(int v,int d,int c){
	if(!cl[v])cl[v]=c;
	if(lst[v]>=d)return;
	lst[v]=d;
	if(d==0)return;
	for(int i=0;i<est[v].size();i++)dfs(est[v][i],d-1,c);
}
int main(){
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		a--,b--;
		est[a].push_back(b);
		est[b].push_back(a);
	} 
	cin>>q;
	for(int i=0;i<q;i++){
		cin>>v[i]>>d[i]>>c[i];
	}	
	for(int i=q;i>=0;i--)dfs(v[i]-1,d[i],c[i]);
	for(int i=0;i<n;i++)cout<<cl[i]<<endl;
	return 0;
}

Measured memory_bytes: 8440
N,S = gets.split.map &:to_i
A = gets.split.map &:to_i

M = 998244353

dp = Array.new(N+1){[0]*(S+1)}
dp[0][0]=1
(0..N-1).each do |i|
    (0..S).each do|j|
        dp[i+1][j] = (dp[i][j]*2) % M
        if j-A[i]>=0 then
            dp[i+1][j] += dp[i][j-A[i]]
            dp[i+1][j] %= M
        end
    end
end

p dp[N][S]

Measured memory_bytes: 84772
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define mem(a,k) memset(a,k,sizeof(a))
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;
 
#define Pr(f,...) //fprintf(stderr,f,##__VA_ARGS__),fflush(stderr)
 
typedef long long ll;
 
template<typename T>
void read(T &x){
	x=0; 
	char c;
	for(c=getchar();!isdigit(c);c=getchar()); 
	for(;isdigit(c);c=getchar())x=x*10+c-'0'; 
}
 
const int N=2e5+50,P = 998244353;
 
 
int mul(int a,int b){ return 1ll*a*b%P; }
int add(int a,int b){ a+=b; return a>=P?a-P:a; }
int sub(int a,int b){ a-=b; return a<0?a+P:a; }
int gcd(int a,int b){ return !b?a:gcd(b,a%b); }
void upd(int &a,int b){ a=add(a,b); }
int powMod(int x, int k) {
	int res = 1;
	for (;k;k >>= 1, x = mul(x, x)) if (k & 1) res = mul(res, x); 
	return res;
}
int inv(int x) { return powMod(x, P - 2); } 
int frac(int a,int b){ return mul(a, inv(b)); }
 
int n,a[N],b[N];
long long ans;
struct F{
bool operator()(int x,int y){return a[x]>a[y];}} fff;
priority_queue<int,vector<int>,F> Q;
 
void chk(int i){
	int l = (i - 1 + n) % n, r = (i + 1) % n;
	if(a[i]>b[i]&&a[i]-(a[l]+a[r])>=b[i])Q.push(i);
}
 
void calc(int i) {
	int l = (i - 1 + n) % n, r = (i + 1) % n;
	if(a[i]<b[i])return;
	int t = (a[i] - b[i]) / (a[l] + a[r]);
	a[i] -= t * (a[l] + a[r]),ans+=t;
	chk(l),chk(r);
}
 
int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
	freopen("d.in", "r", stdin); 
#endif
	read(n); 
	lop(i,0,n)read(b[i]);
	lop(i, 0, n) read(a[i]); 
	lop(i,0,n)chk(i);
	while(!Q.empty()){
		int t=Q.top();
		Q.pop();
		calc(t);
	//	lop(i,0,n)printf("%d ",b[i]);puts("");
	}
	bool suc=true;
	rep(i,1,n)suc&=a[i]==b[i];
	printf("%lld\n",suc?ans:-1);
	return 0;
}

Measured memory_bytes: 2428
use std::io::Read;

fn main() {
    let mut buf = String::new();

    // 標準入力から全部bufに読み込む
    std::io::stdin().read_to_string(&mut buf).unwrap();

    // 行ごとのiterが取れる
    let mut iter = buf.split_whitespace();
    let input: String = iter.next().unwrap().parse().unwrap();

    let mut patterns = Vec::new();
    for i in 0..(1 << input.len() - 1) {
        let mut row = Vec::new();
        for j in 0..input.len() {
            // j桁右シフトして最初のbitが1かチェック
            if ((i >> j) & 1) == 1 {
                row.push(j);
            }
        }
        patterns.push(row);
    }

    let mut result = 0;
    for pattern in patterns {
        let mut left = 0;
        for right in pattern {
            let n: u64 = input[left..right + 1].parse().unwrap();
            result += n;
            left = right + 1;
        }
        let n: u64 = input[left..].parse().unwrap();
        result += n;
    }
    println!("{:?}", result);
}


Measured memory_bytes: 4352
#include <iostream>
using namespace std;
#include <math.h>

int main(void){
    int H=0 ,N=0 , i=0;
    scanf("%d %d",&H ,&N);
    //cin >> H,A;
    int *c;        /* 割り振られた領域のアドレスを格納するためのint型のポインタipを宣言 */
        c = (int *)malloc(N * sizeof(int));  /* メモリ領域の確保 */
    for(i=0;i<N;i++){
        scanf("%d",&c[i]);
    }
    
    //技の和
    int total = 0;
    for(i=0;i<N;i++){
        total += c[i];
    }
    
    if(total >= H){
        printf("Yes");
    }
    else{
        printf("No");
    }
 
    free(c);
}


Measured memory_bytes: 640
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;


vector<int> v;
vector<vector<int>> m;
int sizen,sizem,x;

void checkmoney(vector<int> p,int n,int total){
    if(n < sizen){
        vector<int> pcopy = p;
        checkmoney(pcopy,n+1,total);
        total+=m[n][0];
        bool ans= true;
        rep(i,sizem){
            pcopy[i]+=m[n][i+1];
            if(pcopy[i]<x){
                ans =false;
            }
        }
        if(ans){
            v.push_back(total);
        }else{
            checkmoney(pcopy,n+1,total);
        }
    }
}

int main(){
    cin >> sizen>>sizem>>x;
    rep(i,sizen){
        vector<int> p;
        rep(j,sizem+1){
            int a;
            cin >> a;
            p.push_back(a);
        }
        m.push_back(p);
    }
    vector<int> zer;
    rep(i,sizem){
        zer.push_back(0);
    }
    checkmoney(zer,0,0);
    sort(v.begin(),v.end());
    if(v.empty())cout << -1 << endl;
    else cout << v[0] << endl;
}

Measured memory_bytes: 3160
#include<bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for (int i=0;i<(n);i++)
#define PI 3.14159265358979323846264338327950L
using namespace std;
using P = pair<int,int>;
using ll = long long;
using namespace std;
int main(void){
    int n;
    cin >> n;
    int d[n];
    rep(i, n){cin >> d[i];}
    int cnt = 0;
    rep(i, n-1){
        for(int j = i+1; j<n; j++){
            cnt += d[i]*d[j];
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct node{
    ll p;
    ll v;
}a[2010];

ll dp[2010][2010]; //dp[i][j] i表示移左边数量 j表示移右边数量

bool cmp(node x,node y){
    if(x.v==y.v) return x.p<y.p;
    return x.v>y.v;
}

int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i].v;
        a[i].p=i;
    }
    sort(a,a+n,cmp);
    
    for(int i=0;i<n;i++){
        for(int j=0;i+j<n;j++){
            int t=i+j;
            dp[i+1][j]=max(dp[i+1][j],dp[i][j]+abs(a[t].p-i)*a[t].v);
            dp[i][j+1]=max(dp[i][j+1],dp[i][j]+abs(a[t].p-(n-1-j))*a[t].v);
        }
    }
    
    ll ans=0;
    for(int i=0;i<=n;i++) ans=max(ans,dp[i][n-i]);
    cout<<ans;
    return 0;
}


Measured memory_bytes: 26340
#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

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

// 多次元 vector 生成
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> A(N), B(N), C(N);
    REP(i, N) { cin >> A.at(i); }
    REP(i, N) { cin >> B.at(i); }
    REP(i, N) { cin >> C.at(i); }
    sort(ALL(A));
    sort(ALL(B));
    sort(ALL(C));
    /*
        REP(i, N) { cout << A[i] << " "; }
        cout << endl;
        REP(i, N) { cout << B[i] << " "; }
        cout << endl;
        REP(i, N) { cout << C[i] << " "; }
        cout << endl;
    */
    vector<ll> Bc(N);
    REP(i, N) {
        Bc[i] = N - (upper_bound(ALL(C), B[i]) - C.begin());
        // cout << Bc[i] << " ";
    }
    // cout << endl;

    for (int i = N - 2; i >= 0; i--) {
        Bc[i] += Bc[i + 1];
    }
    /*
    REP(i, N) { cout << Bc[i] << " "; }
    cout << endl;
    */
    ll ans = 0;
    REP(i, N) {
        int ind = upper_bound(ALL(B), A[i]) - B.begin();
        if (ind != N) {
            ans += Bc[ind];
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3328
function Main(input){
  var input=input.split(' ');
  var a=parseInt(input[0]);
  var b=parseInt(input[1]);
  var c=parseInt(input[2]);
  var d=parseInt(input[3]);

  var L=a+b;
  var R=c+d;
  if(L>R){
    console.log('Left');
  }else if(L==R){
    console.log('Balanced');
  }else if(L<R){
    console.log('Right');
  }
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));


Measured memory_bytes: 23476
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <math.h>
#include <cmath>
using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];

const int mod = 1000000007;
const int INF = 2000000015;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}


int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res=res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}



signed main() {
	int a, b;
	cin >> a >> b;
	if ((a * b) % 2 == 1) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main()
{
    fast_cin;
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif


    string s;
    cin>>s;
    int l=s.size();
    if(s[l-1]=='s'){
         cout<<s+"es"<<"\n";
    }
    else{
        cout<<s+"s"<<"\n";
    }

}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)

using LL  = long long;
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    string s;cin >> s;
    int n = s.size();
    for(int i=0;i<n;i++){
        s.pop_back();
        int c = s.size()/2;
        if(s.substr(0, c) == s.substr(c)){
            cout << s.size() << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <functional>

using namespace std;

int main() {
    int a,b,c,ans = 0;

    cin >> a >> b >> c;

    while(1){
        a -= c;
        a -= b;

        if(a - c < 0){
            break;
            
        }
        
        ans++;
    }

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


Measured memory_bytes: 256
const main = (input) => {
  const args = input.trim().split("\n");
  const [x, n] = args[0]
    .trim()
    .split(" ")
    .map((n) => parseInt(n, 10));

  const excluded = (() => {
    if (n === 0) {
      return [];
    } else {
      return args[1]
        .trim()
        .split(" ")
        .map((n) => parseInt(n, 10));
    }
  })();

  const selection = [...Array(101 + 1).keys()].filter(
    (s) => !excluded.includes(s)
  );

  const abs = (n) => {
    if (n < 0) return -n;
    else {
      return n;
    }
  };
  const byAsc = (a, b) => a[1] - b[1];

  const answer = selection
    .map((s) => [s, abs(x - s)])
    .sort(byAsc)[0][0];

  console.log(answer);
};

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

Measured memory_bytes: 29660
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define lps(i,j,n) for(int i=j;i<n;i++)
#define fordebug int hoge;cin>>hoge;
#define DEKAI 1000000007;
#define INF (1<<28)
#define int long long
#define double long double
#define floot10 cout<<fixed<<setprecision(10)
bool dp[1100][1100];

signed main(){
  int w,h;
  cin>>w>>h;
  char a[1100][1100];
  lp(i,1100)lp(j,1100){
    dp[i][j]=false;
    a[i][j]='#';
  }
  int gx,gy;
  lp(i,h){
    lp(j,w){
      cin>>a[i+1][j+1];
      if(a[i+1][j+1]=='t'){
	gx=i+1;
	gy=j+1;
      }
    }
  }
  queue<pair<int,int>> q;
  q.push({1,1});
  dp[1][1]=true;
  int ax[4]={0,0,-1,1};
  int ay[4]={-1,1,0,0};
  int n;
  cin>>n;
  int hox[1010],hoy[1010];
  lp(i,n){
    cin>>hox[i]>>hoy[i];
  }
  lp(z,n+1){
    while(!q.empty()){
      int x,y;
      x=q.front().first;
      y=q.front().second;
      //cout<<x<<y<<endl;
      q.pop();
      lp(i,4){
	int nex=x+ax[i];
	int ney=y+ay[i];
	if(nex==gx&&ney==gy){
	  cout<<z<<endl;
	  return 0;
	}
	if(dp[nex][ney]==false){
	  dp[nex][ney]=true;
	  if(a[nex][ney]=='.'){
	    q.push({nex,ney});
	  }
	}
      }
    }
    if(z==n) break;/*
    lp(i,10){
      lp(j,10){
	if(dp[i+1][j+1]==false){
	  cout<<0;
	}
	else cout<<1;
      }
      cout<<endl;
    }
    lp(i,10){
      lp(j,10){
	cout<<a[i+1][j+1]
      }
      cout<<endl;
      }*/
    int bx,by;
    bx=hoy[z];
    by=hox[z];
    bx++;
    by++;
    if(a[bx][by]=='#'){
      a[bx][by]='.';
      if(dp[bx][by]==true){
	q.push({bx,by});
      }
    }
  }
  cout<<-1<<endl;
  return 0;
}




Measured memory_bytes: 5532
#include <iostream>

using namespace std;
typedef long long LL;

int main() {
    LL N, A, B, ans = 0;
    cin >> N >> A >> B;
    if (A == 0) {
        cout << 0 << endl;
    } else {
        ans += N / (A + B) * A;
        ans += N % (A + B) >= A ? A : N % (A + B);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 888
q=input
w=range
n, m = map(int, q().split())
V = n + m
par = [i for i in w(V)]
sizes = [1] * V


def f(x):
    if x == par[x]:
        return x
    par[x] = f(par[x])
    return par[x]


def u(x, y):
    x, y = f(x), f(y)
    if x == y:
        return
    if sizes[x] < sizes[y]:
        x, y = y, x
    par[y] = x
    sizes[x] += sizes[y]


[u(i,l-1+n)for i in w(n)for l in [int(k)for k in q().split()][1:]]
print("NO"if len([i for i in w(n)if f(i)!=f(0)])>0 else"YES")


Measured memory_bytes: 12676
def cal():

    num = int(input())
    if num >= 10:
        ben = num % 10
    else:
        ben = num
    
    if ben == 3:
        print("bon")
    elif ben == 0 or ben == 1 or ben == 6 or ben == 8:
        print("pon")
    elif ben == 2 or ben == 4 or ben == 5 or ben == 7 or ben == 9:
        print("hon")
    


cal()

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


int main(){
    string s,t;
    cin >> s >> t;
    int ans = 0;
    rep(i,s.size()){
        if(s[i]!=t[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

ll dampode (int n, vector<ll> ht)
{
    vector<ll> dp (n+1,-1);
    dp[1] = 0;
    dp[2] = abs(ht[2]-ht[1]);
    
    for(int i=3;i<=n;i++)
    {
        dp[i] = min(dp[i-1]+abs(ht[i]-ht[i-1]), dp[i-2] + abs(ht[i]-ht[i-2]));
    }
    
    return dp[n];
}

int main()
{
    int n;
    cin>>n; 
    
    vector<ll> ht(n+1);
    for(int i=1;i<=n;i++)
    {
        cin>>ht[i];
    }

    cout<<dampode(n, ht)<<endl;
    
}

Measured memory_bytes: 5568
function Main(input) {
  input = input.split('\n'); // 1行目がinput[0], 2行目がinput[1], …に入る
  var h = input[0].split(" ")[1]
  var w = input[0].split(" ")[2]
  var ans = 0
  for(var i=1;i<input.length;i++){
    var th = input[i].split(" ")[0]
    var tw = input[i].split(" ")[1]
    if(-1<(th-h) && -1<(tw-w)) {
      ans++
    }
  }
  console.log(ans)
}

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

Measured memory_bytes: 21064
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <string>
#include <limits>
#include <algorithm>
#include <map>
#include <sstream>
#include <unordered_map>
#include <set>

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
static ull tenq = 1000000000;
static ull mod = tenq + 7;

using namespace std;

int main()
{
  string s;
  cin >> s;
  ll year, month;
  year = stoi(s.substr(0, 4));
  month = stoi(s.substr(5, 2));
//  day = stoi(s.substr(6, 2));

  if (year > 2019 || (year == 2019 && month > 4)) {
    cout << "TBD" << endl;
  } else {
    cout << "Heisei" << endl;
  }

  return 0;
}


Measured memory_bytes: 760
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

public class Main {
	static char[] s;
	static int id;
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		int t = sc.nextInt();
		while(t--!=0){
			s = sc.next().toCharArray();
			id = 0;
			System.out.println(exp());
		}
	}
	static int exp(){
		int r = term();
		while(true){
			char c = s[id++];
			if(c=='+')r+=term();
			else if(c=='-')r-=term();
			else break;
		}
		return r;
	}

	static int term(){
		int r = fact();
		while(true){
			char c = s[id++];
			if(c=='*') r*=fact();
			else if(c=='/')r/=fact();
			else break;
		}
		id--;
		return r;
	}

	static int fact(){
		char c = s[id++];
		if(c=='(')return exp();
		if(c=='-'){
			return -fact();
		}
		if(c=='+'){
			return fact();
		}
		int x = c-'0';
		while(true){
			c = s[id++];
			if(Character.isDigit(c)){
				x *= 10;
				x += c-'0';
			}
			else break;
		}
		id--;
		return x;
	}

}
class SC {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;
	public SC(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
	}
	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
		return tokenizer.nextToken();
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
	public String nextLine() {
		try {
			return reader.readLine();
		} catch (IOException e) {
			throw new UncheckedIOException(e);
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
}


Measured memory_bytes: 24252
# A - Takahashi Calendar
M, D = map(int,input().split())
count = 0
for k in range(4, M+1):
    for i in range(22, D+1):
        if i // 10 >= 2 and i % 10 >= 2:
            if k == (i//10)*(i % 10):
                count = count + 1
            else:
                pass
        else:
            pass
print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 long long a;
  cin>>a;
  long long count=0;
  vector<long long>vec1(a+1);
  vector<long long>vec2(a);
  for(int i=0;i<a+1;i++){
    cin>>vec1.at(i);
  }
  for(int j=0;j<a;j++){
    cin>>vec2.at(j);
  }
  for(int k=0;k<a;k++){
    if(vec1.at(k)>=vec2.at(k)){
      vec1.at(k)-=vec2.at(k);
      count+=vec2.at(k);
    }
    else{
      count+=vec1.at(k);
      vec2.at(k)-=vec1.at(k);
      if(vec1.at(k+1)>=vec2.at(k)){
      count+=vec2.at(k);
      vec1.at(k+1)-=vec2.at(k);
      }
      else{
        count+=vec1.at(k+1);
        vec1.at(k+1)=0;
      }
    }
  }
    cout<<count<<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
int n,r,i,j,a[100];
main(){
scanf("%d",&n);
for(;i<n;i++)scanf("%d",&a[i]);
for(i=0;i<n;i++){
for(j=0;j<i;j++){
if(a[i]<a[j])r++;
}
}
std::sort(a,a+n);
for(int i=0;i<n;i++){if(i)printf(" ");printf("%d",a[i]);}
printf("\n%d\n",r);
}

Measured memory_bytes: 3264
N = int(input())
A = list(map(int, input().split()))

x = A[0]
y = sum(A[1:])
ans = abs(y - x)
for i in range(1, N - 1):
    x += A[i]
    y -= A[i]
    ans = min(ans, abs(y - x))
print(ans)


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

using lint = long long;

void solve() {
    int n, q;
    lint s, t;
    std::cin >> n >> q >> s >> t;

    auto diff = [&](lint d) {
        return (d > 0 ? s : t) * (-d);
    };

    std::vector<lint> ds(n);
    lint prev;
    std::cin >> prev;
    for (int i = 0; i < n; ++i) {
        lint x;
        std::cin >> x;
        ds[i] = x - prev;
        prev = x;
    }

    lint ans = 0;
    for (auto d : ds) ans += diff(d);

    while (q--) {
        int l, r;
        lint x;
        std::cin >> l >> r >> x;

        {
            ans -= diff(ds[l - 1]);
            ds[l - 1] += x;
            ans += diff(ds[l - 1]);
        }

        if (r < n) {
            ans -= diff(ds[r]);
            ds[r] -= x;
            ans += diff(ds[r]);
        }

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

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

    solve();

    return 0;
}



Measured memory_bytes: 4416
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		int n = scanner.nextInt();
		int m = scanner.nextInt();
		
		int[][] a = new int[n][m];
		int[] b = new int[m];
		
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++)
				a[i][j] = scanner.nextInt();
		}
		
		for (int i = 0; i < m; i++)
			b[i] = scanner.nextInt();

		for (int i = 0; i < n; i++) {
			int c = 0;
			for (int j = 0; j < m; j++) {
				c += (a[i][j] * b[j]);
			}
			System.out.println(c);
		}
	}

}



Measured memory_bytes: 40956
#include <iostream>
#define llint long long

using namespace std;

llint n, a, b, c, x;
llint y[105];

int main(void)
{
	while(1){
		cin >> n >> a >> b >> c >> x;
		if(n == 0) break;
		for(int i = 1; i <= n; i++) cin >> y[i];
		
		llint p = 1;
		for(int i = 0; i <= 10000; i++){
			if(x == y[p]) p++;
			if(p == n+1){
				cout << i << endl;
				break;
			}
			x = (a*x+b)%c;
		}
		if(p <= n) cout << -1 << endl;
	}
	
	return 0;
}


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

int main(){
	long long int n,m;
	long long int ans = 0;
	cin>>n>>m;
	if(n >= m/2){
		ans = m/2;
	}
	else{
		m = m - 2*n;
		ans += n;
		ans += m/4;
	}
	cout<<ans;
}

Measured memory_bytes: 256
def resolve():
    w, a, b = map(int, input().split())

    a1 = a
    a2 = a + w

    b1 = b
    b2 = b + w

    ans = 0
    if a2 < b1:
        ans = b1 - a2
    elif b2 < a1:
        ans = a1 - b2
    else:
        ans = 0
    
    print(ans)

resolve()

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <cstring>

#define LP(i,n) for(int i=0;i<n;i++)
#define Mset(x,v) memset(x,v,sizeof(x))

using namespace std;
using LL=long long;

int main(){
    int n,x,y,maxl;
    string X,Y;
    cin>>n;
    LP(i,n){
        int c[1001][1001];
        cin>>X>>Y;
        x=X.size();
        y=Y.size();
        X=' '+X;
        Y=' '+Y;
        maxl=0;
        for(int j=0;j<=x;j++) c[j][0]=0;
        for(int j=1;j<=y;j++) c[0][j]=0;
        for(int j=1;j<=x; j++){
            for(int k=1;k<=y;k++){
                if(X[j]==Y[k]){
                    c[j][k]=c[j-1][k-1]+1;
                }
                else{
                    c[j][k]=max(c[j-1][k],c[j][k-1]);
                }
                maxl=max(maxl,c[j][k]);
            }
        }
        cout<<maxl<<endl;
    }
    return 0;
}



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

int main() {
	int T, D, N;
	cin >> D >> N;
	if (N == 100) {
		N = N + 1;
	}
	switch (D) {
	case 0:
		cout << N << endl;
		break;
	case 1:
		cout << N * 100 << endl;
		break;
	case 2:
		cout << N * 10000 << endl;
	}
}

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

int main()
{
    std :: ios_base :: sync_with_stdio(false);

    long long n;
    std :: cin >> n;

    long long height[n] , res{} , jmp{};

    std :: cin >> height[0];
    for(auto i = 1 ; i < n ; i++)
    {
        std :: cin >> height[i];
        if(height[i - 1] >= height[i])
            jmp++;
        else
        {
            res = res < jmp ? jmp : res;
            jmp = 0;
        }
    }

    res = res < jmp ? jmp : res;

    fflush(stdin);

    std :: cout << res << '\n';

    fflush(stdout);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる





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

  for(int i=1;i<=5555;i++){
    int x=10*i+1;
    bool sosu=true;
    for(int j=2;j*j<=x;j++){
      if(x%j==0) sosu=false;
    }
    if(n && sosu) {
      cout << x << endl;
      n--;
    }
  }


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define MAXN 200002
 
int n, k, c;
string s;
stack <int> sta;
 
int main () {
	cin >> n >> k >> c >> s;
	for (int i = n - 1, j = 0; i >= 0 && j < k; i --) {
		if (s[i] == 'o') {
			sta.push (i);
			j ++; i -= c;
		}
	}
	for (int i = 0, j = 0; i < n && j < k; i ++) {
		if (s[i] == 'o') {
			if (sta.top () == i) cout << (i + 1) << endl;
			sta.pop ();
			j ++; i += c;
		}
	}
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i=0; i<n; i++){
    cin >> a[i];
  }
  int ans = 0;
  for (int i=1; i<n-1; i++) {
    if (a[i] > a[i-1] && a[i] < a[i+1]) ans++;
    else if (a[i] < a[i-1] && a[i] > a[i+1]) ans++;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
#define rep(i,a,b) for(int i=(a),i##_end_=(b);i<=i##_end_;i++)
#define dwn(i,a,b) for(int i=(a),i##_end_=(b);i>=i##_end_;i--)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn=1600010;
char s[maxn];
int n,f[maxn],cnt[30];
ll ans[30],g[1000][30];
int get_next() {
	f[0]=f[1]=0;
	rep(i,1,n-1) {
		int j=f[i];
		while(j&&s[j]!=s[i]) j=f[j];
		f[i+1]=(s[i]==s[j]?j+1:0);
	}
	int j=f[n];
	while(j&&j>=(n+1)/2) j=f[j];
	int m=n;
	rep(i,j,n-j-1) s[m++]=s[i];
	return n=m;
}
int K;
void init() {
	f[0]=f[1]=0;
	rep(i,1,n-1) {
		int j=f[i];
		while(j&&s[j]!=s[i]) j=f[j];
		f[i+1]=(s[i]==s[j]?j+1:0);
	}
	int j=f[n];
	while(j&&j>=(n+1)/2) j=f[j];
	if(j) K=n/2;
	else K=n;
	n-=j;
}
int main() {
	ll l,r;
	scanf("%s%lld%lld",s,&l,&r);
	n=strlen(s);
	init();s[n]='\0';
//	printf("%s\n",s);
	int st=n;
	int a=get_next();
	int b=get_next();
	int c=get_next();
	if(b*2==a+c) { // equal
		rep(i,1,n) if(i>=l&&i<=r) ans[s[i-1]-'a']++;
		rep(i,b,c-1) cnt[s[i]-'a']++;
		r-=n;l-=n+1;
		rep(x,0,25) {
			ll k=r/(c-b);if(r<0) k=0;
			ans[x]+=k*cnt[x];
			ll k2=l/(c-b);if(l<0) k2=0;
			ans[x]-=k2*cnt[x];
			if(x==25) {
				r-=k*(c-b);l-=k2*(c-b);
				rep(i,1,r) ans[s[i-1]-'a']++;
				rep(i,1,l) ans[s[i-1]-'a']--;
			}
		}
	}
	else { // fib
		g[1][26]=K;g[2][26]=st;
		rep(i,0,K-1) g[1][s[i]-'a']++;
		rep(i,0,st-1) g[2][s[i]-'a']++;
		int m;
		rep(i,3,1000) {
			rep(x,0,26) g[i][x]=g[i-1][x]+g[i-2][x];
			if(g[i][26]>=r) {m=i;break;}
		}
	//	rep(i,1,m) printf("%lld ",g[i][26]);puts("");
		dwn(j,m,1) if(r>=g[j][26]) {
			rep(x,0,25) ans[x]+=g[j][x];
			r-=g[j][26];
		}
		rep(i,1,r) ans[s[i-1]-'a']++;
		l--;
		dwn(j,m,1) if(l>=g[j][26]) {
			rep(x,0,25) ans[x]-=g[j][x];
			l-=g[j][26];
		}
		rep(i,1,l) ans[s[i-1]-'a']--;
	//	printf("%d %d\n",l,r);
	}
	rep(i,0,25) printf("%lld%c",ans[i],i==25?'\n':' ');
	return 0;
}
/*
abbaabba
3 52523523
*/

Measured memory_bytes: 4864
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

int main() {
	double L;
	cin >> L;
	L /= 3;
	cout <<setprecision(30)<< L * L * L << endl;
}


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

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

bool isOK(vector<ll> &a, vector<ll> &f, ll score, ll try_nax){
    ll trial = 0;
    int N = a.size();
    rep(i,N){
        if(a[i] * f[i] > score){
            ll rest = a[i] * f[i] - score;
            trial += rest / f[i] + (rest % f[i] != 0);
        }
    }
    //printf("[goal_score = %lld] -> [trial = %lld]\n", score, trial);
    return trial <= try_nax;
}

ll BInary_search(vector<ll> &a, vector<ll> &f, ll nax, ll K){
    ll ng = -1;
    ll ok = nax;
    while(abs(ok-ng) > 1){
        ll mid = (ok + ng)/2;
        if(isOK(a, f, mid, K))ok = mid;
        else ng = mid;
    }
    return ok;
}

int main(){
    ll N, K;
    cin >> N >> K;
    vector<ll> a(N), f(N);
    rep(i,N)cin >> a[i];
    rep(i,N)cin >> f[i];
    sort(all(f));
    sort(all(a), greater<ll>());
    cout << BInary_search(a, f, 10000000000000, K) << endl;
    return 0;
}


Measured memory_bytes: 6424
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()


int main() {
#ifdef local
	freopen("in.txt", "r", stdin);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int n; cin >> n;
	vector<pair<ll, ll> > d(n);
	for(int i = 0; i < n; i++) {
		ll x; cin >> x;
		d[i] = make_pair(x, i);
	}
	vector<int> sz(n, 1);
	sort(all(d), greater<pair<ll,ll>>());
	vector<pair<int, int> > edges;
	vector<vector<int> > adj(n);
	for(int i = 0; i < n - 1; i++) {
		ll id = d[i].se, dis = d[i].fi;
		int dt = n - 2*sz[id];
		dis -= dt;
		auto it = lower_bound(all(d), pair<ll, ll>(dis, n), greater<pair<ll, ll> >());
		if(it == d.end() || it->fi != dis) {
			cout << "-1\n";
			return 0;
		}
		sz[it->se] += sz[id];
		adj[it->se].push_back(id);
		edges.emplace_back(id + 1, it->se + 1);
	}
	function<ll(int)> dfs = [&](int u) {
		ll ret = 0;
		for(auto &v : adj[u]) {
			ret += dfs(v) + sz[v];
		}
		return ret;
	};
	if(dfs(d[n-1].se) != d[n-1].fi) {
		cout << "-1\n";
		return 0;
	}
	sort(all(edges));
	for(auto &e : edges) {
		cout << e.fi << ' ' << e.se << '\n';
	}
	return 0;
}


Measured memory_bytes: 12788
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)

	if s[len(s)-1] == 's' {
		fmt.Println(s + "es")
	} else {
		fmt.Println(s + "s")
	}
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}


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

using namespace std;

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

    int cnt[31] = {};
    for (int i = 0; i < n; ++i) {
        int k;
        cin >> k;
        while (k--) {
            int a;
            cin >> a;
            cnt[a]++;
        }
    }

    int ans = 0;
    for (int i = 1; i <= m; ++i) {
        if (cnt[i] == n) ans++;
    }

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


Measured memory_bytes: 256
n,m=map(int,input().split())
x=sorted(list(map(int,input().split())))
dis=[]
bx=x[0]
if n>=m:
    print(0)
else:
    for ax in x[1:]:
        dis.append(ax-bx)
        bx=ax
    dis.sort(reverse=True)
    print(sum(dis[n-1:]))

Measured memory_bytes: 13968
#include<stdio.h>
#include<iostream>
using namespace std;

const int M=1e5+5;
int a[M];
int fun(int *a,int i,int &tot,int n)
{
	if(tot>n) return 0;
	if(i==2) 
	{
		return 1;
	}
	else 
	{
		tot++;
		fun(a,a[i],tot,n);
	}
}
int main()
{
	int n;
	int tot=0;
	cin>>n;
	for(int i=1;i<n+1;i++)
	{
		cin>>a[i];
	}
	if(fun(a,1,tot,n))
	cout<<tot;
	else 
	cout<<"-1";
}

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

int main() {
  string N; cin >>N;
  cout <<"ABC" <<N <<endl;
  return 0;
}


Measured memory_bytes: 256
using System;
 
class Program
{
  static void Main(string[] args)
  {
    string[] input = Console.ReadLine().Split(' ');
    int n = int.Parse(input[0]);
    int a = int.Parse(input[1]);
    int b = int.Parse(input[2]);
    
    if(a * n <= b) Console.WriteLine("{0}", a * n);
    else Console.WriteLine("{0}", b);
  }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
#define F first 
#define S second
const ll N = 200222 ; 
int n, m, k, x, y, X, Y;
string s, t;
int main()
{
	ios::sync_with_stdio(false);cin.tie();cout.tie() ;
	cin >> n >> m >> k >> x >> y >> s >> t ;
	X = x ;
	for(int i = 0 ; i < s.size() ; i ++){
		if(s[i] == 'D') X ++ ;
		if(X > n) return cout << "NO", 0 ;
		if(t[i] == 'U' and X > 1) X -- ;  
	}
	X = x ;
	for(int i = 0 ; i < s.size() ; i ++){
		if(s[i] == 'U') X -- ;
		if(X < 1) return cout << "NO", 0 ;
		if(t[i] == 'D' and X < n) X ++ ;  
	}
	Y = y ;
	for(int i = 0 ; i < s.size() ; i ++){
		if(s[i] == 'R') Y ++ ;
		if(Y > m) return cout << "NO", 0 ;
		if(t[i] == 'L' and Y > 1) Y -- ;  
	}
	Y = y ;
	for(int i = 0 ; i < s.size() ; i ++){
		if(s[i] == 'L') Y -- ;
		if(Y < 1) return cout << "NO", 0 ;
		if(t[i] == 'R' and Y < m) Y ++ ;  
	}
	cout << "YES" ;
}

Measured memory_bytes: 920
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<iostream>
using namespace std;
long long int lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
using ll =long long int;
#define ci(a) cin>>a
#define co(a) cout<<a<<endl
#define gcd(a,b) __gcd(a,b)
#define vec vector<ll>
#define For(i,a,b) for(ll i=a;i<b;i++)
#define rFor(i,a,b) for(ll i=a;i>b;i--)
#define wFor(i,a,b) for(ll i=a;i<b;i+=2)
#define wrFor(i,a,b) for(ll i=a;i>b;i-=2)
#define sort(a,b) sort(a.begin(),b.end())
#define reverse(a,b) reverse(a.begin(),b.end())
//gcd 最大公約数
//lcm 最小公倍数
//double 少数（変数）
//string 文字列（変数）
//sqrt 平方根
//ceil 天井関数
//floor 床関数
//abs 絶対値
//pow 累乗
//cbrt  立方根
//hypot 平方和の平方根
//(string-'0') 文字列を数字に変換
//(char-'0') 数字に変換
//vector<vector<int>> data(a,vector<int>(b)) a×b行列
//for(int i=0;i<a;i++)
//for(int j=0;j<b;j++)
//cin>>data.at(i).at(j)  a×b行列の入力
//floor(log10(a)+1) aの10進法での桁数
//ceil(log10(a)) aの10進法での桁数

int main() {
  ll a;
  ci(a);
  vec b(a);
  For(i,0,a)
    ci(b[i]);
  ll an;
  For(i,0,a)
    For(j,i+1,a)
      an+=b[i]*b[j];
  co(an);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define rep(i,n) FOR(i,0,n)
 
int main(){
	
	string s;cin >> s;
	if(s[0] =='Y' and s[1] =='A' and s[2] =='K' and s[3] =='I') cout << "Yes" << endl;
	else cout << "No" << endl;
}

//cout << ans << endl;

Measured memory_bytes: 256
A=int(input())
B=int(input())
C=int(input())
D=int(input())
E=int(input())

#注文するべき順番は下一桁が０であるのが最強、１が最弱９は０にだけまける。下一桁を０にしたやつを足す
#これ順番はどうでもよい？
#要は注文時間の下一桁切り上げを足せってことですかね？
#最後の料理は０に切り上げる必要がないね
import math
a=10*(math.ceil(A/10))
b=10*(math.ceil(B/10))
c=10*(math.ceil(C/10))
d=10*(math.ceil(D/10))
e=10*(math.ceil(E/10))
Q=max(a-A,b-B,c-C,d-D,e-E)
if Q==a-A:
    print(b+c+d+e+A)
elif Q==b-B:
    print(a+c+d+e+B)
elif Q==c-C:
    print(a+b+d+e+C)
elif Q==d-D:
    print(a+b+c+e+D)
elif Q==e-E:
    print(a+b+c+d+E)    

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int mod = 1000000007;
int n, k;
int comb[3000][3000];

signed main() {
	int i, j;
	
	cin >> n >> k;
	
	comb[0][0] = 1;
	for (i = 1; i < 3000; i++) {
		comb[i][0] = 1;
		for (j = 1; j <= i; j++) {
			comb[i][j] = (comb[i-1][j-1] + comb[i-1][j]) % mod;
		}
	}
	
	for(i = 1; i <= k; i++) {
		cout << comb[k-1][i-1] * comb[n-k+1][i] % mod << endl;
	}
	return 0;
}

Measured memory_bytes: 68864
n = gets.to_i

s = 0
l = []

n.times do
    x = gets.to_i
    if x%10 != 0
        l.append(x)
    end
    s += x
end


l.sort!

if l.empty?
    puts 0
else
    if s % 10 == 0
        puts s-l[0]
    else
        puts s
    end
end

Measured memory_bytes: 14352
//go:generate echo "https://atcoder.jp/contests/dp/tasks/dp_d"
package main

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

type scanner struct{ *bufio.Scanner }

func newScanner(r io.Reader) *scanner {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	s.Buffer(nil, 100000000)
	return &scanner{s}
}

func (s *scanner) Int() int {
	s.Scan()
	n, _ := strconv.Atoi(s.Text())
	return n
}

func (s *scanner) IntSlice(l int) []int {
	if l == 0 {
		return []int{}
	}
	sl := make([]int, l, l)
	for i := range sl {
		sl[i] = s.Int()
	}
	return sl
}

func chmax(x *int, v int) {
	if *x < v {
		*x = v
	}
}

func solve(N, W int, wvs [][]int) int {
	t := make([][]int, N+1, N+1) // t[item_index][weight]
	for i := range t {
		t[i] = make([]int, W+1, W+1)
	}
	for i, wv := range wvs {
		w, v := wv[0], wv[1]
		for sumWeight := 0; sumWeight <= W; sumWeight++ {
			if wdiff := sumWeight - w; wdiff >= 0 {
				chmax(&t[i+1][sumWeight], t[i][wdiff]+v)
			}
			chmax(&t[i+1][sumWeight], t[i][sumWeight])
		}
	}
	return t[N][W]
}

func main() {
	scan := newScanner(os.Stdin)
	N, W := scan.Int(), scan.Int()
	wvs := make([][]int, N, N)
	for i := 0; i < N; i++ {
		wvs[i] = []int{scan.Int(), scan.Int()}
	}
	fmt.Println(solve(N, W, wvs))
}


Measured memory_bytes: 82588
main(i,z){
	double p=atan2(1,0)*2,r;
	for(;scanf("%lf",&r),r;){
		for(i=0;i<1000000;i++){
			z=(int)(p*i);
			if(p-r<z*1.0/i){printf("%d/%d\n",z,i);break;}
			if((z+1)*1.0/i<p+r){printf("%d/%d\n",z+1,i);break;}
		}
	}
	exit(0);
}

Measured memory_bytes: 616
import java.util.Scanner;

public class Main {
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		int r = scanner.nextInt();
		int c = scanner.nextInt();
		int[][] a = new int[r+1][c+1];

		for(int i=0; i<r+1; i++)
		{
			for(int j=0; j<c+1; j++)
			{
				if(i==r || j==c)
				{
					a[i][j] = 0;
				}
				else {
					a[i][j] = scanner.nextInt();
				}
			}
		}
		for(int i=0; i<r; i++)
		{
			for(int j=0; j<c; j++)
			{
				a[i][c] += a[i][j];
				a[r][j] += a[i][j];
			}
			a[r][c] += a[i][c];
		}
		
		
		for(int i=0; i<r+1; i++)
		{
			for(int j=0; j<c+1; j++)
			{
				System.out.print(a[i][j]+(j<c?" ":"\n"));
			}
		}
	}
}



Measured memory_bytes: 40772
module ABC124

  ! <module>s to import
  use, intrinsic :: iso_fortran_env

  ! require all variables to be explicitly declared
  implicit none

  ! accessibility of <subroutine>s and <function>s in this <module>
  public  :: task_A
  private :: update_num_coins

  ! variables for this <module>
  integer(kind=INT8) :: A, B
  integer(kind=INT8) :: num_coins

  ! contained <subroutine>s and <function>s are below
  contains

  subroutine update_num_coins

    if (A .gt. B) then
      num_coins = num_coins + A
      A         = A - 1_INT8
    else
      num_coins = num_coins + B
      B         = B - 1_INT8
    end if

  end subroutine update_num_coins

  subroutine task_A

    ! variables for this <subroutine>
    integer(kind=INT8) :: itr_trial

    ! STEP.01
    ! read out the size of the bottons
    read(unit=INPUT_UNIT, fmt=*) A, B

    ! STEP.02
    ! initialize the number of got coins
    num_coins = 0_INT8

    ! STEP.03
    ! calculate the maximum number of the coins
    do itr_trial = 1_INT8, 2_INT8, 1_INT8
      call update_num_coins
    end do

    ! STEP.04
    ! output the result
    write(unit=OUTPUT_UNIT, fmt='(I0)', advance='yes') num_coins

    ! STEP.END
    return

  end subroutine task_A

end module ABC124


program main

  ! <module>s to import
  use, non_intrinsic :: ABC124

  ! require all variables to be explicitly declared
  implicit none

  call task_A

end program main

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    ll n;
    cin >> n;
    const ll mod = 1000000007;
    ll ans = 1;
    rep2(i,1,n+1) {
        ans = ans*i%mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF=pow(2,31)-1;

std::vector<int> v(1e6,INF);
int N=1;
int mi(int a,int b,int k,int l,int r){
  if(r<=a||b<=l)return INF;
  if(a<=l&&r<=b)return v[k];
  else{
    int vl=mi(a,b,k*2+1,l,(l+r)/2);
    int vr=mi(a,b,k*2+2,(l+r)/2,r);
    return min(vl,vr);
  }
}
void update(int a,int b){
  int k=a+N-1;
  v[k]=b;
  while(k){
    k=(k-1)/2;
    v[k]=min(v[k*2+1],v[k*2+2]);
  }
}

signed main(){
  int n,M;
  cin>>n>>M;
  while(n>N)N*=2;
  std::vector<int> ans;

  for(int i=0;i<M;i++){
    int t,l,r;cin>>t>>l>>r;
    if(t)ans.push_back(mi(l,r+1,0,0,N));
    else update(l,r);
  }
  for(int p:ans)cout<<p<<endl;
}



Measured memory_bytes: 11252
#include <iostream>
#include <vector>
#include <deque>
#include <cmath>
#include <map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include "iomanip"
#include <cstdio>
#include <cstring>

using namespace std;


int main() {
    int a, b;
    cin >> a >> b;
    cout << ((a % 3 == 0 || b % 3 == 0 || (a + b)  % 3 == 0) ? "Possible" : "Impossible");

}

Measured memory_bytes: 256