akhauriyash/Code-Regression huggingface dataset:
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

a,b,x=get_i
puts b/x-(a-1)/x

Measured memory_bytes: 14376
N, M = list(map(int, input().split()))
sc = []
for i in range(M):
    sc.append(list(map(int, input().split())))
    
for i in range(1000):
    if len(str(i)) == N:
        for j in range(M):
            s = sc[j][0]
            c = sc[j][1]
            if str(i)[s-1] != str(c):
                break
        else:
            print(i)
            break
    
else:
    print(-1)
        
            
                

Measured memory_bytes: 3064
n = int(input())
abc_list = [list(map(int, input().split())) for i in range(n)]
dp = [[0] * 3 for i in range(n)]
dp[0] = [abc_list[0][0], abc_list[0][1], abc_list[0][2]]

for i in range(1, n):
    for j in range(3):
        for k in range(3):
            if j != k:
                dp[i][j] = max(dp[i][j], dp[i - 1][k] + abc_list[i][j])
                
print(max(dp[n - 1]))

Measured memory_bytes: 74200
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<ll,ll> P;

int main(void){
	          ll i;

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

	      	  ll N,H;
	      	  cin >> N >> H;

	      	  vector<ll> a(N),b(N);
	      	  for(i=0;i<N;i++) cin >> a[i] >> b[i];

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

	      	  ll S=0,p=0;
	      	  REP(i,N){
	      		  if(b[i]<a[0]) break;
	      		  S+=b[i];
	      		  p++;
	      		  if(S>=H){
	      			  cout << p << endl;
	      			  return 0;
	      		  }
	      	  }

	      	  ll x=H-S;

	      	  cout << p+(x+a[0]-1LL)/a[0] << endl;

	          return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
 
int main() {
  int n; 
  cin >> n;
  string stones;
  cin >> stones;
  rep(i,n) {
    if (stones[n-i-1] == 'R') {stones = stones.substr(0,n-i); break;}
  }
  n = stones.size();
  
  int cnt = 0;
  queue<int> red, white;
  rep(i,n) {
    if (stones[n-i-1] == 'R') red.push(n-i-1);
    if (stones[i] == 'W') white.push(i);
  }
  while (!red.empty() && !white.empty())
  {
    int r = red.front(), w = white.front();
    red.pop(); white.pop();
    if (r < w) break;
    cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 4420
a=int(input())#500
b=int(input())#100
c=int(input())#50
x=int(input())#sum
ans=0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if(500*i+100*j+50*k == x):
                ans+=1
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(0)
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
typedef long long ll;
#define pri(n) printf("%d\n",n)
#define lpri(n) printf("%lld\n",n);
#define rep(i,st,ed) for(int i=st;i<ed;i++)
#define var(n) int n; scn(n)
#define F first
#define S second 
#define pb(n) push_back(n)
const int N=55;
const ll M=1e9+7;
const ll inf=1e18;

void add(int& a,int b)
{
	a+=b;
	a%=M;
}

int main()
{
	// a better implementation Thanks to Errichto
	ios;
	string s;
	int n;
	cin>>s>>n;
	int len = s.size();
	vector<vector<int>> dp(n,vector<int> (2));

	// dp states are
	// sum,<a boolean value which shows whether I have already taken some digit smaller than the corresponding to the digit in k or not>

	dp[0][0]=1; // base case this means that total number of ways taking the imaginary digit at position -1 which is equal to its corresponding digit in s;

	for(int i=0;i<len;i++)
	{
		vector<vector<int>> v(n,vector<int> (2));

		for(int sum=0;sum<n;sum++)
		{
			for(bool already : {true,false})
			{
				for(int dig = 0;dig<10;dig++)
				{
					if(dig>s[i]-48 and !already)
						break;
					add(v[(sum+dig)%n][already || dig<s[i]-48],dp[sum][already]);
				}
			}
		}
		dp = v;
	}

	int ans = (dp[0][0]+dp[0][1])%M;
	ans--;
	if(ans<0)
		ans+=M;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
mod = 10**9 + 7

ans = 0

for bit in range(61):
    now = 0
    for x in a:
        if x&(1<<bit):now += 1

    ans += (2**bit)*(now*(n - now))
    ans %= mod


print(ans)

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

const int INF = 1e9 + 10;

const double eps = 1e-11;
double cross_product(complex<double> a, complex<double> b) {
  return (conj(a) * b).imag();
}

int main() {
  double x1, y1, x2, y2, x3, y3, xp, yp;
  while (cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp) {
    complex<double> a = {x1, y1}, b = {x2, y2}, c = {x3, y3}, p = {xp, yp};
    double t1 = cross_product(b - a, p - a);
    double t2 = cross_product(c - b, p - b);
    double t3 = cross_product(a - c, p - c);
    bool sign = (t1 > 0);
    if (sign == (t2 > 0) && sign == (t3 > 0) && t1 && t2 && t3) {
      cout << "YES" << endl;
    } else
      cout << "NO" << endl;
  }
}



Measured memory_bytes: 3192
fun main(args: Array<String>) {
    val nk = readLine()?.split(" ")?.map { it.toInt() } ?: return
    val n = nk[0]
    val k = nk[1]
    val heights = readLine()?.split(" ")?.map { it.toInt() } ?: return

    var count = 0

    heights.forEach {
        if (it >= k) count++
    }

    println(count)
}

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

#define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
#define fb(i,a,b) for(int (i) = (a); (i) >= (b); --(i))
#define mod 998244353
#define xx first
#define yy second
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define ll long long
#define pii pair<int,int>


using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;/// find_by_order(x)(x+1th) , order_of_key() (strictly less)
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());



int n,m,k;

int mat[10][10];
int pmat[10][10];

int main()
{

    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n >> m >> k;
    ff(i,0,n - 1){
        string x;
        cin >> x;
        ff(j,0,m - 1){
            if(x[j] == '.')mat[i][j] = 0;
            else mat[i][j] = 1;
        }
    }
    int res = 0;
    ff(r,0,(1<<n) - 1){
        ff(t,0,(1<<m) - 1){
            ff(i,0,n - 1){
                ff(j,0,m - 1){
                    pmat[i][j] = mat[i][j];
                }
            }

            ff(i,0,n - 1){
                if((1<<i) & r){
                    ff(j,0,m - 1)pmat[i][j] = 0;
                }
            }

            ff(j,0,m - 1){
                if((1<<j) & t){
                    ff(i,0,n - 1)pmat[i][j] = 0;
                }
            }


            int pom = 0;
            ff(i,0,n - 1){
                ff(j,0,m - 1){
                    if(pmat[i][j] == 1)pom++;
                }
            }
            if(pom == k)res++;
        }
    }
    cout << res << "\n";
    return 0;
}


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

const int mod = 998244353;

int solve() {
	int N;
	cin >> N;
	vector<int> D(N);
	for (auto& x : D) cin >> x;
	if (D[0] != 0) return 0;
	for (int i = 1; i < N; ++ i) if (D[i] == 0) return 0;
	vector<long long> cnt(N+1);
	for (int i = 0; i < N; ++ i) ++ cnt[D[i]];
	int m = 0;
	for (int i = 0; ; ++ i) if (cnt[i] == 0) { m = i; break; }
	for (int i = m; i < N; ++ i) if (cnt[i] > 0) return 0;
	long long r = 1;
	for (int i = 1; i < m; ++ i) {
		for (int j = 0; j < cnt[i]; ++ j) (r *= cnt[i-1]) %= mod;
	}
	return r;
}

int main() {
	cout << solve() << endl;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int Nmax = 2e5;
int N;
ll X[Nmax], Y[Nmax];

int main(){
	cin >> N;
	for(int i=0; i<N; i++) cin >> X[i] >> Y[i];

	ll amax = 0, amin = 1e10;
	for(int i=0; i<N; i++){
		amax = max(amax, max(X[i], Y[i]));
		amin = min(amin, min(X[i], Y[i]));
	}

	ll min_max = max(X[0], Y[0]);
	ll max_min = min(X[0], Y[0]);
	for(int i=1; i<N; i++){
		min_max = min(min_max, max(X[i], Y[i]));
		max_min = max(max_min, min(X[i], Y[i]));
	}
	ll ans = (amax-min_max)*(max_min-amin);

	vector<pair<ll, int>> mins;
	for(int i=0; i<N; i++) mins.push_back({min(X[i], Y[i]), i});
	sort(mins.begin(), mins.end());
	ll min_min = mins[0].first;
	max_min = mins[N-1].first;
	min_max = 1e10;
	ll max_max = 0;
	ll min_diff = min_max-min_min;
	for(int i=0; i<N; i++) {
		int k = mins[i].second;
		ll m = max(X[k], Y[k]);
		if(mins[i].first > min_max) break;
		min_max = min(min_max, m);
		max_max = max(max_max, m);
		min_min = i==N-1?1e10:mins[i+1].first;
		//cout << max_max << " " << max_min << " " << min_max << " " << min_min << endl;
		min_diff = min(min_diff, max(max_max, max_min)-min(min_max, min_min));
	}
	ans = min((amax-amin)*min_diff, ans);

	cout <<  ans << endl;

	return 0;
}


Measured memory_bytes: 9584
n, *cards = map(int, open(0).read().split())
sum_cards = sum(cards)

snuke = cards[0]
araiguma = sum_cards - cards[0]

ans = abs(snuke - araiguma)

for num in cards[1:n-1]:
    snuke += num
    araiguma -= num
    ans = min(ans, abs(snuke-araiguma))

print(ans)

Measured memory_bytes: 24064
#include<stdio.h>
int main(){
  int m;
  int h=0;
  scanf("%d",&m);
  if(m>=500){
    do{
      m -= 500;
      h += 1000;
    }while(m>=500);
  }
  if(m>=5){
    do{
      m -= 5;
      h += 5;
    }while(m>=5);
  }
  
  printf("%d",h);
  
  return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back 
#define mp make_pair
#define f first
#define s second
#define sz(x) ((int)x.size())
const ll maxint=2e18;
const ll minint =-2e18;
/*******\
(͡ ° ͜ʖ ͡ °) : Hello there, relax.
\*     */

int main(){
    int n;
    cin>>n;
    vector<ll> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int res = 0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(a[j]==a[i])continue;
            for(int k=j+1;k<n;k++){
                if(a[k]==a[j] || a[k]==a[i])continue;
                if(a[i]+a[j] > a[k] && a[k]+a[j]>a[i] && a[k]+a[i] > a[j])res++;
            }
        }
    }
    cout<<res<<'\n';
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>

using namespace std;
int main (){
    string s;
    int len;
    cin >> len >> s;
    if(len%2==1){
        cout << "No" << "\n";
    }
    else{
        bool flag=1;
        for (int i = 0; i < len/2; i++){
            if(s[i]!=s[i+len/2]) flag=0;
        }
        if(flag) cout << "Yes" << "\n";
        else     cout << "No" << "\n";
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
using Int = long long;
#define REP(i, n) for (int i = 0; i < n; i++)
Int mygcd(Int a, Int b)
{
    return b ? mygcd(b, a % b) : a;
}
Int mylcm(Int a, Int b)
{
    return (__int128)a * b / mygcd(a, b);
}
int main()
{
    int N; cin >> N;
    vector<Int> T(N); REP(i, N) cin >> T[i];
    cout << accumulate(T.begin(), T.end(), (Int)1, mylcm) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;
int D[3][4005];
int getNum(char c) {
  switch(c) {
    case 'R': return 0;
    case 'G': return 1;
    case 'B': return 2;
  }
  return 0;
}
int main() {
  ios::sync_with_stdio(false);
  int N;
  string S;
  cin >> N;
  cin >> S;
  for (int i=0; i<N; i++) {
    D[0][i+1] = D[0][i] + (S[i] == 'R');
    D[1][i+1] = D[1][i] + (S[i] == 'G');
    D[2][i+1] = D[2][i] + (S[i] == 'B');
  }
  ll ret = 0;
  for (int i=0; i<N; i++) {
    for (int j=i+1; j<N; j++) {
      if (S[i] == S[j]) continue;
      int idx = 3 - getNum(S[i]) - getNum(S[j]);
      ret += D[idx][N] - D[idx][j+1];
      int k = j + (j - i);
      if (k < N) {
        if (S[k] != S[j] && S[k] != S[i]) ret--;
      }
    }
  }
  cout << ret << endl;
}

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

int main() {
    string str;
    while(cin >> str, str != "#") {
        int flag = -1;
        int ans=0;
        for(int i=0; i<str.size(); ++i) {
            char c = str[i];
            if(c <= 'g' || ('q' <= c && c <= 't') || ('v' <= c && c <= 'x') || c == 'z') {
                if(flag == 1) {
                    ans++;
                }
                flag = 0;
            } else {
                if(flag == 0) {
                    ans++;
                }
                flag = 1;
            }
        }
        cout << ans << endl;
    }
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define out(S) cout<<(S)<<endl;
#define ShowAll(collection) for(auto i:collection){out(i);}
#define beginend(v) v.begin(),v.end()
#define Foreach(item,collection) for(auto item : collection)

using pii=pair<int,int>;
using vb=vector<bool>;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vvc=vector<vector<char>>;
using ti3=tuple<int,int,int>;
template<typename T> void removeAt(vector<T>& v, int index) { v.erase(v.begin() + index); }
#define OCB(c) (c&1)|(c&2)<<2|(c&4)<<4|(c&8)<<6|(c&16)<<8|(c&32)<<10|(c&64)<<12|(c&128)<<14


const int MAX=7368791+1;
ll solve(int m,int n){
    vb box(MAX,false);
    int j=m;
    rep(i,n) {
        while(box[j]) ++j;
        for(int k=j;k<MAX; k+=j) box[k]=true;
        while(box[j])++j;
    }
    return j;
}

int main(){
    int n,m;
    while(cin >> m>>n,n|m) out(solve(m,n));
}



Measured memory_bytes: 3992
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;

int main() {
	int N; cin >> N;
	vector<int> r(N);
	for (int i = 0; i < N; i++)
		cin >> r[i];
	sort(r.begin(), r.end());
	double ma = 0;
	for (int n = 3; n <= N; n++) {
		vector<int> a(r.end() - n, r.end());
		do {
			vector<double> x(n), y(n);
			for (int i = 0; i < n; i++) {
				x[i] = a[i] * cos(M_PI*2 / n * i);
				y[i] = a[i] * sin(M_PI*2 / n * i);
			}
			for (int t = 0; t < 1000; t++) {
				int i = rand() % n;
				int j = (i + n - 1) % n, k = (i + 1) % n;
				double dx = x[k] - x[j], dy = y[k] - y[j];
				double _dx = dy, _dy = -dx;
				double r = sqrt(_dx * _dx + _dy * _dy);
				x[i] = _dx / r * a[i];
				y[i] = _dy / r * a[i];
			}
			double sum = 0;
			for (int i = 0; i < n; i++) {
				int j = (i + 1) % n;
				sum += x[i] * y[j] - y[i] * x[j];
			}
			ma = max(ma, sum);
		} while (next_permutation(a.begin() + 1, a.end()));
	}
	printf("%.15f\n", ma / 2);
}

Measured memory_bytes: 3656
# # # # unionfind.py # # # #

# usage: uf = Unionfind(n) ; x = uf.root(y); uf.conn(a,b)

class Unionfind:

  def __init__(s,n):
    s.sz = [1] * n
    s.ances = [i for i in range(n)]
  
  def root(s,x):
    a = []
    y = x
    while s.ances[y] != y:
      a.append(y)
      y = s.ances[y]
    for z in a:
      s.ances[z] = y
    return y
  
  def conn(s,x,y):
    i = s.root(x)
    j = s.root(y)
    if i==j:
      return
    #k  = [i,j].min
    k  = j if (s.sz[i]<s.sz[j]) else i
    if k==j:
      s.ances[i] = j
    else:
      s.ances[j] = i
    s.sz[k] = s.sz[i] + s.sz[j]
  
# # # # end unionfind.py # # # #

printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)


n,m,k = inm()
uf = Unionfind(n+1)
friend = [{} for i in range(n+1)]
for i in range(m):
    a,b = inm()
    friend[a][b] = 1
    friend[b][a] = 1
    uf.conn(a,b)
blk = [{} for i in range(n+1)]
for i in range(k):
    a,b = inm()
    blk[a][b] = 1
    blk[b][a] = 1
gr = {}
for i in range(1,n+1):
    r = uf.root(i)
    if r in gr:
        gr[r] += 1
    else:
        gr[r] = 1
for i in range(1,n+1):
    r = uf.root(i)
    x = gr[r]-1
    for f in friend[i]:
        if uf.root(f)==r:
            x -= 1
    for f in blk[i]:
        if uf.root(f)==r:
            x -= 1
    printn(str(x)+' ')
print("")


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

using namespace std;

int main(){

  int n, x;
  cin>>n>>x;
  
  long long int ans=0;
  long long int a;
  cin>>a;
  for(int i=0; i<n-1; i++){
    long long int b;
    long long int eat=0;
    cin>>b;
    
    eat=max(a+b-x, eat);
    ans+=eat;

    if(b<=eat) b=0;
    else b=b-eat;
    a=b;
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 3632
from collections import defaultdict
from collections import deque
from collections import Counter
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

s = list(input())
k = readInt()

if len(Counter(s))==1:
	ans = k*len(s)//2
elif s[0]!=s[-1]:
	ans = 0
	i = 0
	l = 0
	tmp = s[:]+["!"]
	d = []
	while i<len(s):
		if tmp[i]==tmp[i+1]:
			i+=1
		else:
			d.append(tmp[l:i+1])
			l = i+1
			i+=1
	for i in d:
		ans+=len(i)//2
	ans*=k
else:
	ans = 0
	i = 0
	l = 0
	tmp = s[:]+["!"]
	d = []
	while i<len(s):
		if tmp[i]==tmp[i+1]:
			i+=1
		else:
			d.append(tmp[l:i+1])
			l = i+1
			i+=1
	for i in d[1:-1]:
		ans+=len(i)//2
	ans*=k
	ans+=len(d[0])//2
	ans+=len(d[-1])//2
	ans+=(len(d[0])+len(d[-1]))//2*(k-1)


print(ans)

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

using namespace std;

int main(){

int a,b,c,d,sum;

cin>>a>>b>>c>>d;

sum=a+b+c+d;

int m=sum/60;
int s=sum%60;

cout<<m<<endl;
cout<<s<<endl;

return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <utility>
#include <map>
#include <climits>

using std::cout;
using std::cin;
using std::endl;
using std::vector;
using std::string;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {

	for(typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";

    return out;

}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n, k;
	cin >> n >> k;

	if(n % k == 0)
		cout << 0 << "\n";
	else
		cout << 1 << "\n";	

	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef queue<int> qi;
typedef queue<ll> ql;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define pq priority_queue
#define rep(i,n) for (int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define INF 2000000009
int fa[55];
inline void init(){
	for (int i=0;i<55;i++) fa[i]=i;
}
int f(int x){
	return fa[x]==x? x:fa[x]=f(fa[x]);
}
inline void u(int x,int y){
	x=f(x);y=f(y);
	if (x==y) return;
	fa[x]=y;
}
pii e[55];
int ans=0;
int main ()
{
	ios::sync_with_stdio(false);
	int n,m;
	cin>>n>>m;
	rep(i,m){
		cin>>e[i].first>>e[i].second;
	}
	rep(i,m){
		init();
		rep(j,m){
			if (i==j) continue;
			u(e[j].first,e[j].second);
		}
		bool fl=0;
		for (int j=1;j<=n;j++) for (int k=1;k<=n;k++) if ( f(j) != f(k) ){
			fl=1;
			break;
		}
		ans+=fl;
	}
	cout<<ans;
}


Measured memory_bytes: 256
MAX = 2 ** 15
s = [1] * MAX
s[0] = 0
s[1] = 0

start = 2
while True:
   pmb = 0
   for i in range(start, MAX):
      if s[i] == 1:
         pmb = i
         break
   if pmb == 0:
      break
   
   #篩
   for i in range(pmb ** 2, MAX, pmb):
      s[i] = 0

   start += 1

#print(s)

while True:
   n = int(input())
   if n == 0: break

   c = 0 #ペア数
   for i in range(2, n // 2 + 1):
      if s[i] == 1 and s[n - i] == 1:
         c += 1

   print(c)


Measured memory_bytes: 5716
a,b,c,d = map(int, input().split())
ans = "No"
if (max(c, a) - min(c, a)) <= d:
    ans = "Yes"
elif (max(a, b) - min(a, b)) <= d:
    if (max(b, c) - min(b, c)) <= d:
        ans = "Yes"
print(ans)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int work = int.Parse(Console.ReadLine());
            int h = work / 3600;
            work = work % 3600;
            int m = work / 60;
            work = work % 60;
            Console.WriteLine("{0}:{1}:{2}", h, m, work);
           
        }
    }
}

Measured memory_bytes: 5624
import math
N=int(input())
dis=N-1

for i in range(2,int(math.sqrt(N))+1):
    if N%i==0:
        if ((N/i)-1)+(i-1)<dis:
            dis=((N/i)-1)+(i-1)
        else:
            pass
    else:
        pass
print(int(dis))
        
        


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
signed main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,x; cin>>a>>b>>x;
    if(a <= x && a + b >= x){
        cout<<"YES"<<endl;
    }else cout<<"NO"<<endl;
}


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

int main(){
  int n;
  cin >> n;
  vector<long long> xpy(n),xmy(n);
  for (int i = 0; i < n; i++)
  {
    long long x,y;
    cin >> x >> y;

    xpy[i] = x+y;
    xmy[i] = x-y;
  }
  sort(xpy.begin(),xpy.end());
  sort(xmy.begin(),xmy.end());

  long long ans = max(abs(xpy[0]-xpy[n-1]), abs(xmy[0]-xmy[n-1]));
  cout << ans << endl;
}

Measured memory_bytes: 6384
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b) {a = b; return true;}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b) {a = b; return true;}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

int main(){
    ll n; cin >> n;
    vl num(n+1,0);
    vl a(n);
    rep(i,n) cin >> a[i], num[a[i]]++;
    vl num2 = num;
    sort(rall(num));
    sort(all(num2));
    vl sum(n+1,0);
    rep(i,n) sum[i+1] += sum[i] + num[i];
    REP(i,1,n+1){
        ll ok = 0, ng = n/i+1;
        while(ng-ok>1){
            ll mid = (ng+ok)/2;
            auto itr = upper_bound(all(num2),mid);
            ll d = num2.end() - itr;
            ll rest = sum[d] - d*mid;
            //print3(i,d,rest);
            if((n-rest) >= i*mid) ok = mid;
            else ng = mid;
        }
        printf("%lld\n",ok);
    }
}

Measured memory_bytes: 10240
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int a, b; cin >> a >> b;
  cout << (a % 3 and b % 3 and (a + b) % 3 ? "Imp" : "P") << "ossible\n";
}

Measured memory_bytes: 256
//Zory-2019
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pr;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define Debug printf("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define debug(x) cerr<<#x<<'='<<x<<endl
namespace mine
{
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

    const int INF=0x3f3f3f3f;
    const int MOD=998244353;
    int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
    ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=1e6+10;

    char str[N];
    void main()
    {
        int n=qread();scanf("%s",str+1);int ans=0;
        fo(i,0,9) fo(j,0,9) fo(k,0,9)
        {
            int cur=1;
            while(cur<=n and str[cur]-'0'!=i) cur++;if(cur>n)continue;cur++;
            while(cur<=n and str[cur]-'0'!=j) cur++;if(cur>n)continue;cur++;
            while(cur<=n and str[cur]-'0'!=k) cur++;if(cur>n)continue;
            ans++;
        }
        write(ans);
    }
};//(ans+MOD)%MOD
signed main()
{
    srand(time(0));
    mine::main();
}


Measured memory_bytes: 256
use std::io;
use std::collections::HashMap;

fn read_line() -> String {
    let mut line = String::new();

    io::stdin().read_line(&mut line)
        .expect("Failed to read line");
    return line;
}
fn to_i(s: &str) -> i64 {
    return s.trim().parse()
        .expect("Please type a number!");
}
fn read_nums() -> Vec<i64>
{
    let line = read_line();
    let items: Vec<&str> = line.split(' ').collect();

    let mut nums: Vec<i64> = Vec::new();

    for item in items {
        nums.push(to_i(item));
    }
    return nums;
}


fn main() {
    //println!("start");
    let nn = read_nums();
    let n = nn[0];
    let aa = read_nums();
    let mut count = 0;
    for i in 0..n {
        let a = aa[i as usize];
        if a!=(i+1) {
            count +=1;
        }
    }


    if count ==0 || count ==2 {
        print!("YES");
    }else {
        print!("NO");
    }
    
    
}   

Measured memory_bytes: 4352
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
using namespace std;
ll INF = 1000000007;

// 0 false, 1 true


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

    rep(i,s.size()){
        if(s.at(i) + n > 90){
            printf("%c", s.at(i)+n-26);
        }else{
            printf("%c", s.at(i)+n);
        }
    }

    printf("\n");


}


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

using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const long long inf = 1e9+7;
const long long mod = 1e9+7;

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

    int cnt=0;

    vector<int>d1(n),d2(n);
    rep(i,n)cin>>d1[i]>>d2[i];

    rep(i,n){
        if(d1[i]==d2[i]){
            cnt++;
            if(cnt==3){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
        else {
            cnt=0;
        }

    }

    cout<<"No"<<endl;
}


Measured memory_bytes: 3636
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main(){

    input!{
        a: usize,
        b: usize,
    }

    if (a+b)%2 != 0 {
        println!("IMPOSSIBLE");
    } else {
        let k = (a+b) / 2;
        println!("{}", k);
    }
    
}

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

int main(){
    int A,B,C;
    cin >> A >> B >> C;
    bool flag=false;
    if( A==B ){
        if(A!=C){
            flag=true;
        }
    }else if( B==C ){
        if(A!=C){
            flag=true;
        }
    }else if( A==C ){
        if(B!=C){
            flag=true;
        }
    }

    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll N=4005,p=998244353;
ll n,k,ans[N],inv[N],fac[N],inv_fac[N];
ll c(ll a,ll b){if(a<b)return 0;return fac[a]*(inv_fac[a-b]*inv_fac[b]%p)%p;}
ll solve(ll a,ll n,ll k){
    ll ans=0;
    for(ll i=0;i<=min(a>>1,k>>1);i++){
        ll cal=c(a>>1,i)*c(n+k-i-i-1,n-1)%p;
        if(i&1)ans=(ans-cal+p)%p;
        else ans=(ans+cal)%p;
    }
    return ans;
}
int main(){
    scanf("%lld%lld",&n,&k);
    fac[0]=inv_fac[0]=inv[1]=fac[1]=inv_fac[1]=1;
    for(ll i=2;i<N;i++){
        inv[i]=(p-p/i)*inv[p%i]%p;
        fac[i]=fac[i-1]*i%p;
        inv_fac[i]=inv_fac[i-1]*inv[i]%p;
    }
   for(ll i=1;i<=n;i++){
        if(i&1)ans[i]=(solve(i,n-1,k)+solve(i,n-1,k-1))%p;
        else ans[i]=solve(i,n,k);
    }
   /* for(int i=2;i<=n+1;++i){
    	if(i&1)ans[i]=solve(i,n,k);
    	else ans[i]=solve(i-1,n-1,k)+solve(i-1,n-1,k-1)%p;
    }*/
    for(ll i=1;i<=n;i++)printf("%lld\n",ans[i]);
    for(ll i=n-1;i;i--)printf("%lld\n",ans[i]);
    /*for(int i=2;i<=n+1;++i){
    	printf("%lld\n",ans[i]);
    }
    for(int i=n;i>=2;--i){
    	printf("%lld\n",ans[i]);
    }*/
    return 0;
}

Measured memory_bytes: 384
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

n, k = map(int, input().split())

if 1==1:
    for i in range(k):
        if i<=n-k:
            mazu=cmb(n-k+1, i+1)
            mazu=mazu%(10**9+7)
            tugi=cmb(k-1, i)
            tugi=tugi%(10**9+7)
            kotae=mazu*tugi
            print(kotae%(10**9+7))
        else:
            print(0)

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  
  int count = 0; // 聞ける回数
  
  while(true) {
    // ループ終了条件
    if(A > B) break; // 所持金がA円より少ない
    else if(count == C) break; // 満足できる回数(C回)聞いた
    
    B -= A;
    count++;
  }
  
  cout << count << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int n,m;
  cin >> n >> m;
  vector<int> a(m);
  vector<string> b(m);
  int i;
  for(i=0;i<m;i++){
    cin >> a.at(i) >> b.at(i);
  }
  int count_1=0,count_2=0;
  vector<pair<bool,int>> is(n);
  rep(i,m){
    if(b.at(i)=="AC"){
      is.at(a.at(i)-1).first=true;
    }
    if(b.at(i)=="WA" && is.at(a.at(i)-1).first==false){
      is.at(a.at(i)-1).second++;
    }
  }
  rep(i,n){
    if(is.at(i).first){
      count_1++;
      count_2+= is.at(i).second;
    }
  }
  cout << count_1  << " " << count_2;
}
    

Measured memory_bytes: 6912
n,k=map(int,input().split())
d=[]
a=[]
for i in range(k):
    d.append(int(input()))
    a.append(list(map(int,input().split())))
    
aa=[0]*n

for j in a:
    for k in j:
        aa[k-1]+=1
        
ans=0

for x in aa:
    if x==0:
        ans+=1

print(ans)

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const ll INF=1e9;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a, b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n, m, arr) rep(i,n){rep(j,n){cout<<arr[i][j]<<" ";}cout<<endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

ll dp[102][4][4][4];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    //A0 C1 G2 T3
    //NG ACG AGC GAC A_GC AG_C

    rep(k,4){
        rep(l,4){
            rep(m,4){
                //j k l m
                if(k==0&&l==1&&m==2)continue;
                if(k==0&&l==2&&m==1)continue;
                if(k==2&&l==0&&m==1)continue;
                dp[3][k][l][m] ++;
            }
        }
    }

    REP(i,3,101){
        rep(j,4){
            rep(k,4){
                rep(l,4){
                   rep(m,4){
                       //j k l m
                       if(k==0&&l==1&&m==2)continue;
                       if(k==0&&l==2&&m==1)continue;
                       if(k==2&&l==0&&m==1)continue;
                       if(j==0&&l==2&&m==1)continue;
                       if(j==0&&k==2&&m==1)continue;
                           dp[i+1][k][l][m] += dp[i][j][k][l];
                           dp[i+1][k][l][m] %= MOD;
                   }
                }
            }
        }
    }
    ll ans=0;
    rep(j,4){
        rep(k,4){
            rep(l,4){
                //j k l m
                ans = (ans+dp[n][j][k][l])%MOD;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
a = gets.to_i
b = gets.to_i
c = gets.to_i
d = gets.to_i
e = gets.to_i
arr = [a, b, c, d, e].sort_by {|i| (i - 1) % 10 }

puts arr[0] + arr[1].ceil(-1) + arr[2].ceil(-1) + arr[3].ceil(-1) + arr[4].ceil(-1)

Measured memory_bytes: 14292
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iterator>
#include <algorithm>
#include <functional>
#include <utility>
#include <vector>
const int maxn = 200005;
const int maxno = maxn << 2;
int maxv[maxno], addv[maxno];
void maintain(int o) {
  maxv[o] = std::max(maxv[o << 1], maxv[o << 1 | 1]);
}
void paint(int o, int v) {
  maxv[o] += v; addv[o] += v;
}
void pushdown(int o) {
  if(addv[o] != 0) {
    paint(o << 1, addv[o]);
    paint(o << 1 | 1, addv[o]);
    addv[o] = 0;
  }
}
void build_tree(int o, int L, int R) {
  addv[o] = 0;
  if(L == R) {
    maxv[o] = -L + 1;
  } else {
    int M = (L + R) / 2;
    build_tree(o << 1, L, M);
    build_tree(o << 1 | 1, M + 1, R);
    maintain(o);
  }
}
void update(int o, int L, int R, const int &ql, const int &qr, const int &v) {
  if(ql <= L && R <= qr) {
    paint(o, v);
  } else {
    int M = (L + R) / 2;
    pushdown(o);
    if(ql <= M) update(o << 1, L, M, ql, qr, v);
    if(qr > M) update(o << 1 | 1, M + 1, R, ql, qr, v);
    maintain(o);
  }
}
int query(int o, int L, int R, const int &ql, const int &qr) {
  if(ql <= L && R <= qr) {
    return maxv[o];
  } else {
    pushdown(o);
    int M = (L + R) / 2, ans = -0x7fffffff;
    if(ql <= M) ans = std::max(ans, query(o << 1, L, M, ql, qr));
    if(qr > M) ans = std::max(ans, query(o << 1 | 1, M + 1, R, ql, qr));
    return ans;
  }
}

std::vector<int> V[maxn];
int main() {
  int n, m; scanf("%d%d", &n, &m);
  build_tree(1, 1, m + 1);
  for(int i = 1; i <= n; i ++) {
    int L, R; scanf("%d%d", &L, &R);
    V[R].push_back(L);
  }
  int ans = n - m;
  for(int i = m + 1; i >= 1; i --) {
    int bs = -(m - i + 1);
    for(int p : V[i]) {
      update(1, 1, m + 1, p + 1, m + 1, 1);
    }
    bs += query(1, 1, m + 1, 1, i - 1 + 1);
    ans = std::max(ans, bs);
  }
  printf("%d\n", ans);
  return 0;
}

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

using namespace std;

int n;
int ans[200010];
int main(){
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		int x;
		scanf("%d",&x);
		ans[x]++;
	}
	for(int i=1;i<=n;i++){
		printf("%d\n",ans[i]);
	}
	return 0;
}

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

struct UnionFind
{
    vector<int> par;
    UnionFind(int n) : par(n, -1){ }
    int root(int x){
        if(par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    bool issame(int x, int y){
        return root(x) == root(y);
    }
    bool merge(int x, int y){
        x = root(x); y = root(y);
        if(x == y) return false;
        if(par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    int size(int x){
        return -par[root(x)];
    }
};

int main() {
    int N; cin >> N;
    vector<long long> x(N), y(N);
    for (int i = 0; i < N; i++)
    {
        cin >> x[i] >> y[i];
    }

    using pint = pair<int, int>;
    using Edge = pair<long long, pint>;
    vector<Edge> edges;

    vector<int> ids(N);
    iota(ids.begin(), ids.end(), 0);
    sort(ids.begin(), ids.end(), [&](int i, int j) { return x[i] < x[j]; });
    for (int i = 0; i+1 < ids.size(); i++)
    {
        int u = ids[i], v = ids[i+1];
        edges.push_back(Edge(x[v] - x[u], pint(u, v)));
    }

    sort(ids.begin(), ids.end(), [&](int i, int j) { return y[i] < y[j]; });
    for (int i = 0; i+1 < ids.size(); i++)
    {
        int u = ids[i], v = ids[i+1];
        edges.push_back(Edge(y[v] - y[u], pint(u, v)));
    }

    sort(edges.begin(), edges.end());
    UnionFind uf(N);
    long long res = 0;
    for (auto e : edges)
    {
        int u = e.second.first, v = e.second.second;
        long long cost = e.first;
        if(uf.issame(u, v)) continue;
        uf.merge(u, v);
        res += cost;
    }
    cout << res << endl;
}

Measured memory_bytes: 8432
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
long n,m,a,b,c,d0[101][101],d1[101][101],t,p,q,r,i,j,k;
while(cin>>n>>m,n*n+m*m){
for(i=1;i<=m;i++)
for(j=1;j<=m;j++)d0[i][j]=d1[i][j]=3000000;
for(i=1;i<=m;i++)d0[i][i]=d1[i][i]=0;
for(i=0;i<n;i++){
cin>>a>>b>>c>>t;
d0[a][b]=d0[b][a]=c;
d1[a][b]=d1[b][a]=t;
}
for(k=1;k<=m;k++)
for(i=1;i<=m;i++)
for(j=1;j<=m;j++){
d0[i][j]=min(d0[i][j],d0[i][k]+d0[k][j]);
d1[i][j]=min(d1[i][j],d1[i][k]+d1[k][j]);
}
cin>>k;
for(i=0;i<k;i++){
cin>>p>>q>>r;
if(r==0)cout<<d0[p][q]<<endl;
else cout<<d1[p][q]<<endl;
}
}
return 0;
}

Measured memory_bytes: 1316
a, v = map(int,input().split())
b, w = map(int,input().split())
t = int(input())
if a == b:
    print('YES')
elif a > b:
    if b - t*w >= a- t*v:
        print('YES')
    else:
        print('NO')
else:
    if b + t*w <= a + t*v:
        print('YES')
    else:
        print('NO')

Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define test() int t;cin>>t;loop(test,1,t+1)
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define nl cout<<"\n"
#define sp cout<<" "
#define F first
#define S second
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define prsp(v) loop(i,0,v.size())cout<<v[i],sp;nl;
#define prpsp(v) loop(i,0,v.size())cout<<v[i].F<<" "<<v[i].S<<" , ";nl;
#define prnl(v) loop(i,0,v.size())cout<<v[i],nl;nl;
#define prpnl(v) loop(i,0,v.size())cout<<v[i].F<<" "<<v[i].S,nl;nl;
#define MOD 1000000007
#define mod(n) (((n%MOD)+MOD)%MOD)
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

const int MAXN = 1e5+5;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

int main() 
{
    fastio();

    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    for(int i=0;i<n;i++)
    {
        if( i == k-1 )
        {
            s[i] = tolower(s[i]);
        }
        cout<<s[i];
    }

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
const long long NR=210;
long long n,m,ans,a[NR];
int main()
{
	scanf("%lld%lld",&n,&m);
	for(long long i=1;i<=n;i++)
	{
		a[i]=2;
	}
	for(long long i=n+1;i<=n+m;i++)
	{
		a[i]=1;
	}
	for(long long i=1;i<n+m;i++)
	{
		for(long long j=i+1;j<=n+m;j++)
		{
			if((a[i]+a[j])%2==0)
			{
				ans++;
			}
		}
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <stack>
#include <cstdlib>
using namespace std;

stack<int> s;

int func(string str){
    int b = s.top();
    s.pop();
    int a = s.top();
    s.pop();

    if(str == "+") return (a + b);
    else if(str == "-") return (a - b);
    else if(str == "*") return (a * b);
    else return (a / b);
}

int main(void){
    string str;
    while(cin >> str){ //スペースが入力されたらループを繰り返す
        if(str == "+" || str == "-" || str == "*" || str == "/") s.push(func(str));
        else{
            int num = atoi(str.c_str()); //atoi()はstring型からint型に変換する関数
            s.push(num);
        }
        if(getchar() == '\n'){ //改行コードが入力されたら処理を終了して結果を出力する
            cout << s.top() << endl;
            break;
        }
    }
}



Measured memory_bytes: 3172
#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;
typedef pair<lint,pint> tint;
#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とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
ostream &operator<<(ostream &os, const vector<int> &a) {
	os<<"[";
	rep(i,a.size()){
		os<<a[i];
		if(i<a.size()-1) os<<",";
	}
	os<<"]";
	return os; 
}
vector<int> v,v2;
#define N 5010
int main()
{
	int n;cin>>n;string s,t;cin>>s;cin>>t;
	rep(i,N+(s[0]-'0')) v.pb(0);
	rep(i,N+(t[0]-'0')) v2.pb(0);
	rep(i,n-1){
		if(s[i]!=s[i+1]) v.pb(i+1);
		if(t[i]!=t[i+1]) v2.pb(i+1);
	}
	//cout<<v<<endl;cout<<v2<<endl;
	int out=1001001001;
	rep(i,N) v.pb(n),v2.pb(n);
	for(int i=0;i<N-2;i+=2){
		int sum=0;
		rep(j,v.size()){
			if(i+j<v2.size()) sum+=abs(v[j]-v2[i+j]);
			else sum+=abs(v[j]-n);
		}
		out=min(out,sum);
	}
	for(int i=0;i<N-2;i+=2){
		int sum=0;
		rep(j,v2.size()){
			if(i+j<v.size()) sum+=abs(v2[j]-v[i+j]);
			else sum+=abs(v2[j]-n);
		}
		out=min(out,sum);
	}
	cout<<out<<endl;
}


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

class Main{
	public static void main(String args[]) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String po[] = br.readLine().split(" ",0);
		long[] d = new long[3];
		for(int i = 0; i < 3; i++){
			d[i] = Long.parseLong(po[i]);
		}
		if(d[0]%2 == 0 || d[1]%2 == 0 || d[2]%2 ==  0){
			System.out.println("0");
		}else if(d[0] > d[1]){
			if(d[0] > d[2]){
				System.out.println(d[1]*d[2]);
			} else {
				System.out.println(d[1]*d[0]);	
			}
		} else {
			if(d[1] > d[2]) {
				System.out.println(d[0]*d[2]);
			} else {
				System.out.println(d[0]*d[1]);
			}
		}
	}
}

Measured memory_bytes: 8016