akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main(void) {
  int n;
  int k;
  vector<int> h;

  cin >> n;
  cin >> k;

  if (k >= n) {
    cout << 0 << endl;
    return 0;
  }

  for (int i = 0; i < n; i++) {
     int tmp;
     cin >> tmp;
     h.push_back(tmp);
  }

  sort(h.begin(), h.end());

  unsigned long long r;
  for (int i = 0; i < n - k; i++) {
    r += h[i];
  }

  cout << r << endl;
 
  return 0;
}


Measured memory_bytes: 1400
import sys

N = int(input())
H = [int(n) for n in input().split()][::-1]


for i in range(N-1):
    if H[i+1] - H[i] > 1:
        print('No')
        sys.exit(0)
        break
    elif H[i+1] - H[i] == 1:
        H[i+1] -= 1
    else:
        continue

print('Yes')

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

typedef long long ll;
const long long LINF = 1LL << 60;
const long long LMINF = 1LL << 63;
const int INF = 1 << 30;

#define REP(i,n) for(int i = 0;i < n;++i)
#define REPS(i,x) for(int i = 1;i <= (int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i >= 0;i--)
#define RREPS(i,x) for(int i=((int)(x));i > 0;i--)
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << ": " << x << "\n"

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



int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    int n;
    cin >> n;
    while(n > 1000){
        n -= 1000;
    }
    cout << 1000 - n << endl;
    return 0;
}

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

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

  int c = a*b;
  if(c %2 == 0) //％であまりをだす。==の形式に注意！
  cout<< "Even"<< endl;
  else cout <<"Odd"<< endl;
}




Measured memory_bytes: 3576
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int[] a = new int[n + 1];
		int[] b = new int[n];

		for (int i = 0; i < n + 1; i++) {
			a[i] = sc.nextInt();
		}
		for (int i = 0; i < n; i++) {
			b[i] = sc.nextInt();
		}

		long sum = 0;

		for (int i = 0; i < n; i++) {
			int tmp = b[i];
			sum += Math.min(a[i], b[i]);
			b[i] = Math.max(b[i] - a[i], 0);
			a[i] = Math.max(a[i] - tmp, 0);

//			System.out.println(i + "->" + i + ", a:" + a[i] + ", b:" + b[i]);

			sum += Math.min(a[i + 1], b[i]);
			a[i + 1] = Math.max(a[i + 1] - b[i], 0);
//			System.out.println(i + "->" + (i + 1) + ", a+1:" + a[i + 1]);
		}
		System.out.println(sum);
		sc.close();
	}
}

Measured memory_bytes: 86552
#include"bits/stdc++.h"
using namespace std;

int main() {
	int A, B, C, X;
	cin >> A >> B >> C >> X;
	int count = 0;
	for (int i = 0;i <= A;++i) {
		for (int j = 0;j <= B;++j) {
			int k = (X - 500 * i - 100 * j) / 50;
			if (0 <= k && k <= C)count++;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
var fs = require('fs')
var contents = fs.readFileSync('/dev/stdin', 'utf-8');

var watch = function(n) {
    var h = Math.floor(n / 3600);
    var m = Math.floor((n - 3600 * h) / 60);
    var s = n % 60;
    return h + ":" + m + ":" + s;
}

console.log(watch(parseInt(contents)));

Measured memory_bytes: 15568
import math

n,d=map(int,input().split())
x=[]

for i in range(n):
  a=list(map(int,input().split()))
  x.append(a)

cnt=0

for i in range(n-1):
  for j in range(i+1,n):

    dis=0
    for k in range(d):
      dis+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k])

    dis=math.sqrt(dis)
    if dis==int(dis):
      cnt+=1

print(cnt)

Measured memory_bytes: 38256
#include<cstdio>
using namespace std;
bool vis1[10000],vis2[10000];
int main(){
//	freopen("C.in","r",stdin);
	int A,B,C,D,E,F;
	scanf("%d%d%d%d%d%d",&A,&B,&C,&D,&E,&F);
	vis1[0]=1,vis2[0]=1;
	for(int i=1;i*100<=F;i++){
		if(i>=A&&vis1[i-A]) vis1[i]=1;
		if(i>=B&&vis1[i-B]) vis1[i]=1;
	}
	for(int i=1;i<=F;i++){
		if(i>=C&&vis2[i-C]) vis2[i]=1;
		if(i>=D&&vis2[i-D]) vis2[i]=1;
	}
	int ansx=0,ansy=0,x,y;
	for(int i=1;i*100<=F;i++){
		if(!vis1[i]) continue;
		for(int j=0;j<=i*E&&i*100+j<=F;j++){
			if(!vis2[j]) continue;
			x=j,y=i*100+j;
			if(x*ansy>=y*ansx)
				ansx=x,ansy=y;
		}
	}
	printf("%d %d",ansy,ansx);
	return 0;
}


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

using namespace std;

int main(int argc, char const *argv[])
{
    long long n;
    cin >> n;
    long long num = n;
    int cnt = 0;

    for (long long i = 2; i * i <= n; i++)
    {
        if(num == 1) break;
        if(num % i != 0) continue;
        long long j = i;
        while (num % j == 0)
        {
            num /= j;
            j *= i;
            cnt++;
        }
        while (num % i ==0)
        {
            num /= i;
        }
        
    }

    if (num != 1) cnt++;

    cout << cnt << endl;

    return 0;
}

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

int main() { 
	int k; 
	cin >> k;
	
	if (k%2==0)
	{
		cout << (k / 2)*(k / 2 ) << "\n";
	}
	else
	{
		cout << (k / 2)*(k / 2 + 1) << "\n";
	}
}

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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	int n;
	cin >> n;
	vector<ll> a(n);
	FOR(i,0,n)cin >> a[i];
	sort(ALL(a));
	int count = 0;
	int ans = 0;
	int last = a[0];
	FOR(i,0,n){
		if(a[i] != last){
			if(i!=0&&count<a[i-1])ans += count;
			last = a[i];
			count = 1;
		}else{
			count++;
			if(count > a[i])ans++;
		}
	}
	if(count<a[n-1])ans += count;
	ANS(ans);
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define pr pair<int,int>
#define mod 1000000007
#define endl "\n"

int power(int a,int b,int m=mod)
{
	if(b==0)	return 1;
	if(b==1)	return a;
	int res=power(a,b/2,m);
	res=(res*res)%m;
	if(b&1)	res=(res*a)%m;
	return res;
}
int modinv(int a,int m=mod){ return power(a,m-2,m);}
int add(int a,int b,int m=mod){	int c=(a+b);	if(c>=m)	c-=m;	return c;}
int sub(int a,int b,int m=mod){	int c=(a-b);	if(c<0)		c+=m;	return c;}
int mul(int a,int b,int m=mod){	return (a*b)%m;}
//	x<<1 => x*2		x>>1 => x/2;	cout<<flush;
//	cout<<fixed<<setprecision(10)<<ans<<endl;


void solve()
{
	int n;
	cin>>n;
	int cnt=0,val=0,x,y;
	while(n--)
	{
		cin>>x>>y;
		val+=(x==y);
		if(x!=y)
			val=0;
		cnt=max(cnt,val);
	}
	if(cnt>2)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}

int32_t main()
{
	ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
	int t=1;//cin>>t;
	for(int i=1;i<=t;i++){	solve();}
	return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
const int maxn = 1<<18;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	string s;
	cin >> s;
	int ans = 0;
	for(int i = 1; i < s.size(); i++) ans += s[i] != s[i-1];
	cout << ans;
}


Measured memory_bytes: 512
#include <stdio.h>

int main(){
    int i, c, m, max, min;
    long long sum = 0;
    scanf("%d%d", &m, &min);
    i = c = 0;
    sum = max = min;
    while(++i < m){
        scanf("%d", &c);
        if (c > max){max = c;}
        if (c < min){min = c;}
        sum += c;
    }
    printf("%d %d %lld\n", min, max, sum);
}


Measured memory_bytes: 2108
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define mod 1000000007
typedef long long ll;
using namespace std;

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


Measured memory_bytes: 256
N = gets.to_i
graph = Array.new(N) { [] }
(N - 1).times do
  a, b, c = gets.split.map(&:to_i)
  a -= 1
  b -= 1
  graph[a].push([b, c])
  graph[b].push([a, c])
end
Q, K = gets.split.map(&:to_i)
queries = Q.times.map do
  x, y = gets.split.map(&:to_i)
  [x - 1, y - 1]
end

def distance(graph, s)
  d = Array.new(N)
  d[s] = 0
  queue = [[s, nil]]
  while !queue.empty?
    u, parent = queue.shift
    distance = d[u]
    graph[u].each do |v, c|
      next if v == parent
      d[v] = distance + c
      queue.push([v, u])
    end
  end
  d
end

d = distance(graph, K - 1)
queries.each do |u, v|
  ans = d[u] + d[v]
  puts ans
end

Measured memory_bytes: 41980
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#endif

#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <vector>

using namespace std;

typedef long long LL;

#ifdef _DEBUG
const LL MAX_N = 10000;
#else
const LL MAX_N = 1000000;
#endif

LL gcd(LL a, LL b) { return b ? gcd(b, a % b) : a; }

void solve(long long N, std::vector<long long> &A) {
	vector<vector<int>> p(MAX_N + 1);
	vector<int> f(MAX_N + 1);
	LL g = 0;
	for (int i = 2; i <= MAX_N; ++i) {
		if (p[i].empty()) {
			for (int j = i; j <= MAX_N; j += i) {
				p[j].emplace_back(i);
			}
		}
	}
	for (int i = 0; i < N; ++i) {
		for (auto x : p[A[i]]) {
			f[x] += 1;
		}
		g = gcd(A[i], g);
	}
	string ans = "not coprime";
	if (*max_element(f.begin(), f.end()) <= 1) {
		ans = "pairwise coprime";
	} else if (g == 1) {
		ans = "setwise coprime";
	}
	cout << ans << endl;
}

int main() {
    long long N;
	scanf("%lld", &N);
	std::vector<long long> A(N);
	for (int i = 0; i < N; i++) {
		scanf("%lld", &A[i]);
	}
	solve(N, A);
	return 0;
}


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

class PotentialUnionFind {

private:
	vector<int> nums;
	vector<int> weights;
	vector<int> rank;

public:
	PotentialUnionFind(int n) : weights(vector<int>(n, 0)), rank(vector<int>(n, 0)) {
		for (int i = 0; i < n; ++i) {
			nums.push_back(i);
		}

	}

	int find(int x) {

		if (nums[x] == x)
			return x;

		int root = find(nums[x]);
		weights[x] += weights[nums[x]];
		return nums[x] = root;

	}

	bool isSame(int x, int y) {
		return find(x) == find(y);
	}

	void unit(int x, int y, int w) {

		int x_root = find(x);
		int y_root = find(y);

		w += weights[x];
		w -= weights[y];

		if (rank[x_root] < rank[y_root]) {
			swap(x_root, y_root);
			w *= -1;
		}
		else if (rank[x_root] == rank[y_root])
			++rank[x_root];

		nums[y_root] = x_root;
		weights[y_root] = w;

	}

	int diff(int x, int y) {
		return weights[y] - weights[x];
	}


	void print() {


		for (int i = 0; i < nums.size(); ++i) {
			cout << setw(4) << i << " ";

		}
		cout << endl;

		for (int i = 0; i < nums.size(); ++i) {
			cout << setw(4) << nums[i] << " ";
		}
		cout << endl;

		for (int i = 0; i < weights.size(); ++i) {
			cout << setw(4) << weights[i] << " ";
		}
		cout << endl << endl;
	}
};

int main() {

	int n, q;

	cin >> n >> q;

	PotentialUnionFind tree(n);

	for (int i = 0; i < q; ++i) {

		int com, x, y, z;
		cin >> com >> x >> y;

		switch (com) {

		case 0:
			cin >> z;
			tree.unit(x, y, z);
			break;

		case 1:
			if (tree.isSame(x, y))
				cout << tree.diff(x, y) << endl;
			else
				cout << "?" << endl;
			break;

		}

		// cout << x << " " << y << " " << z << endl;
		// tree.print();
	}

	return 0;

}



Measured memory_bytes: 4224
/// Be Kind :)
#include <bits/stdc++.h>
using namespace std;

#pragma GCC optimize("O2,no-stack-protector,unroll-loops,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("Os")

/*				So I ball So hard, muh'fuckas wanna find me					*/

/*				Bitch, where you when I was walkin'?
				Now I run the game, got the whole world talkin'				*/

/*				Niggas been counting me out
				I'm counting my bullets, I'm loading my clips
				I'm writing down names, I'm making a list					*/

/*				You never likes us anyway, fuck your friendship, I meant it */

/*				The Chanel or Balenciaga, Louis and Vuitton
				She know I got Fendi, Prada when I hit Milan				*/

/*				I ran away, I don't think I'm coming back home				*/

#define F first
#define S second
#define pb push_back
#define SZ(x) (ll)(x.size())
#define all(x) x.begin(),x.end()

typedef long long ll;
typedef pair<ll,ll> pll;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn=1e6+10, maxm=1e5+10, lg=23, mod=1e9+7, inf=1e18;

ll n,a[maxn],p;
bool mk[3];
char s[maxn];

int main(){
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	
	cin>>n; for(int i=1;i<=n;i++) cin>>s[i];
	for(int i=1;i<n;i++) a[i]=abs(s[i]-s[i+1]), mk[a[i]]=1;
	if(!mk[1])for(int i=1;i<n;i++) a[i]/=2;
	else      for(int i=1;i<n;i++) a[i]%=2;
	for(int i=0;i<n-1;i++)if(((n-2)&i)==i) p+=a[i+1];
	ll ans=p%2;
	if(!mk[1] && ans) ans=2;
	cout<<ans<<endl;
	
	return 0;
}



















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

int main(){
	
	string str;
	
	cin>>str;
	
	str[3]  = '8';
	str[0] = '2';
	str[1] = '0';
	str[2]  ='1';
	cout<<str<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int arr[n]={0};
    for(int i=0;i<n-1;i++){
        int num;
        cin>>num;
        arr[num-1]++;
    }
    for(auto i:arr)cout<<i<<" ";


}


Measured memory_bytes: 4424
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<stack>
#include<cstring>
using namespace std;
stack<int>s;//建造一个栈
int main(){
    char ch;//输入
    int ans=0;//记长
    while(cin>>ch){//输入
        ans++;//加长度
        if(ch=='S') s.push(1);//入栈
        else if(!s.empty()) s.pop(),ans-=2;//减“ST”
    }
    cout<<ans<<endl;//输出长度
    return 0;
}

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

signed main(){
    int N;
    cin >> N;
    int X[N];
    for(int i=0;i<N;i++){
        cin >> X[i];
    }
    
    int ans = MOD;
    int tmp = 0;
    for(int i=1;i<100;i++){
        for(int j=0;j<N;j++){
            tmp += pow(X[j]-i,2);
        }
        ans = min(ans,tmp);
        tmp = 0;
    }
    
    cout << ans << endl;
}



Measured memory_bytes: 256
from collections import deque
S = str(input())
Q = int(input())
d = deque()
reverse = 1
for i in S:
    d.append(i)
for j in range(Q):
  Query = input().split()
  if len(Query) == 1:
    reverse *= -1
  else:
    F = int(Query[1])
    C = str(Query[2])
    if reverse == 1:
      if F == 1:
        d.appendleft(C)
      elif F == 2:
        d.append(C)
    elif reverse == -1:
      if F == 1:
        d.append(C)
      elif F == 2:
        d.appendleft(C)
if reverse == -1:
    d.reverse()
ans = ''.join(d)
print(ans)

Measured memory_bytes: 8820
_ = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
l = [0,0]
c = 0
i = 0
while(i < len(a)-1):
    if(a[i] == a[i+1]):
        del l[0]
        l.append(a[i])
        i += 1
        c += 1
    if(c >= 2 or i == len(a)-2):
        i = len(a)-1
        print(l[0] * l[1])
    i += 1

Measured memory_bytes: 14252
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int main() {
	int N, M, Q;
	cin >> N >> M >> Q;
	vector<int> A(Q), B(Q), C(Q), D(Q);
	for (int i = 0; i < Q; ++i) {
		cin >> A[i] >> B[i] >> C[i] >> D[i];
		--A[i], --B[i];
	}
	string perm = string(N, 'o') + string(M - 1, 'x');
	int ans = 0;
	do {
		vector<int> arr(N);
		int cur = 0, pos = 0;
		for (char c : perm) {
			if (c == 'o') {
				arr[pos] = cur;
				++pos;
			}
			if (c == 'x') ++cur;
		}
		int score = 0;
		for (int i = 0; i < Q; ++i) {
			if (arr[B[i]] - arr[A[i]] == C[i]) {
				score += D[i];
			}
		}
		ans = max(ans, score);
	} while (next_permutation(perm.begin(), perm.end()));
	cout << ans << endl;
	return 0;
}

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

using namespace std;
#define intMax 2147483647
#define rep(i, a, b) for (long long i = a; i < b; i++)
#define repp(i, a, b) for (long long i = a; i >= b; i--)
#define be(a) (a.begin(), a.end())
#define rbe(p) (p.rbegin(), p.rend())
#define pb push_back

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long n;
    cin >> n;
    vector<vector<long long>> A(n + 1, vector<long long>(n, 0));
    vector<long long> B(n + 1, 0);
    rep(i, 1, n + 1)
    {
        rep(j, 1, n)
        {
            cin >> A[i][j];
        }
        B[i] = 1;
    }
    long long ans = 0;
    bool k = true;
    while (k)
    {
        k = false;
        set<long long> C;
        rep(i, 1, A.size())
        {
            if (B[i] >= n)
            {
                continue;
            }
            long long kk = A[i][B[i]];
            if (A[kk][B[kk]] == i && !C.count(i) && !C.count(kk))
            {
                //cout << i << " " << kk << endl;
                C.insert(i);
                C.insert(kk);
                k = true;
                B[kk]++;
                B[i]++;
            }
        }
        if (k)
        {
            ans++;
        }
        //cout << endl;
    }
    rep(i, 1, B.size())
    {
        if (B[i] != n)
        {
            cout << -1;
            return 0;
        }
    }
    cout << ans;
}

Measured memory_bytes: 10240
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
vector<int>g[123456];
ll dp[2][123456];
ll mod = 1e9+7;
void dfs(int v,int p){
    dp[0][v] = dp[1][v] = 1;
    for(auto x:g[v]){
        if(x!= p){
            dfs(x,v);
            dp[0][v] *= (dp[0][x] + dp[1][x])%mod;
            dp[1][v] *= dp[0][x];
            dp[0][v] %= mod;
            dp[1][v] %= mod;
        }
    }
}
int main(){
    int n;
    cin >> n;
    n--;
    while(n--){
        int x,y;
        cin >> x >> y;
        x--,y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    dfs(0,-1);
    cout << (dp[0][0] + dp[1][0])%mod << endl;
}

Measured memory_bytes: 13440
#include <iostream>
using namespace std;
int main(void){
    
    int num, item_val;
    int max, sum;
    
    cin >> num;
    
    max = 0;
    sum = 0;
    
    for(int i = 0; i < num; i++){
        
        cin >> item_val;
        
        sum += item_val; 
        
        if(item_val > max) max = item_val;
        
    }
    
    sum = sum - max / 2;
    
    cout << sum << endl;
    
    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <vector>
/* 変数i を n回繰り返すマクロ */
#define rep(i,n) for (int i = 0;i < (n);i++)
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
/* map_for : mapでfor文を回す */
/* gcd_lcm : 最大公倍数 & 最小公約数 */
int main()
{
    cout << fixed << setprecision(10);//小数点以下10桁出力
    int n;
    cin >> n;
    vector<int> a(n,0);
    rep(i,n - 1){
        int in;
        cin >> in;
        in--;
        a[in] += 1;
    }
    rep(i,n){
        cout << a[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 4052
////=====BIsmillahir Rahmanir Rahim =====////

/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
         Comilla University

*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define fi 2*acos(0.0)
#define ee 2.71828
#define ll  long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define ff first
#define ss second
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define edl printf("\n")
#define infinity 1e16
#define mod 1000000007
#define cn continue
#define csprint1 printf("Case %lld: ", cs++)
#define csprint2 printf("Case %lld:\n", cs++)
#define sf(a) scanf("%lld", &a)
#define sff(a,b) scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define sffff(a,b,c,d) scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define all(v) v.begin(),v.end()
#define pfn(a) printf("%lld\n",a)
#define pfs(a) printf("%lld ",a)

using namespace __gnu_pbds;
using namespace std;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<pl> vpi;
typedef vector<pl> vpl;
typedef tree<pair<ll, int> , null_type, less<pair<ll, int> >, rb_tree_tag, tree_order_statistics_node_update> ost;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a <<","<< spc;
    err(++it, args...);
    cout<<edl;
}
///Bit manipulation

bool checkbit(int mask,int bit){return mask & (1<<bit);}
int setbit(int mask,int bit){ return mask | (1<<bit) ; }
int clearbit(int mask,int bit){return mask & ~(1<<bit);}
int togglebit(int mask,int bit){return mask ^ (1<<bit);}
int bitno(int mask) {return (int)__builtin_popcount(mask);}

/*----------------------Graph Moves----------------*/
const int fx[]={+1,-1,+0,+0};
const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

///=====================================///

const int maX = 1e5+10;
ll dp[maX];
int main(){
    ll n;sf(n);
    dp[0]=1;
    for(ll i=3;i<=n;i++){
        for(ll j=3;i-j>=0;j++){
            dp[i]+=dp[i-j];
            dp[i]%=mod;
        }
    }
    pfn(dp[n]);
return 0;
}
//4 3
//7 -1 3
//8 2 5
//3 -1 9
//1 7 4


Measured memory_bytes: 3716
#include <iostream>
#include <cstdio>
using namespace std;

int main(){
	while(1){
		int n, a;
		cin >> n;
		if(n==0) break;
		for(int i=0; i<9; ++i){
			scanf(" %d", &a);
			n-=a;
		}
	
		printf("%d\n", n);
	}
	return 0;
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;
string S,T;

int main()
{
	cin>>S>>T;
	int ls=S.size();
	int lt=T.size();
	int L=0,tmp,f=0;
	for(int i=0;i<ls-lt+1;i++)
	{
		tmp=0;
		f=0;
		for(int j=0;j<lt;j++)
		{
			if(T[j]==S[j+i])
			{
				tmp++;
				f=1;
			}
		}
		if(f)
		L=max(tmp,L);
	}
	cout<<lt-L<<endl;
	return 0;
}

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    string s = to_string(i);
    if (s.length() % 2 == 1) {
      ans++;
    }
  }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define f0(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define f2(i,a,b) for(int i=a;i>b;i--)
#define f3(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define int long long
#define fi first
#define se second
#define ncr(n,r) fact[n]*modInv(fact[r])*modInv(fact[n-r])
#define modInv(a) binExp(a,mod-2)
#define mod 1000000007
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define os_find(k) find_by_order(k)
#define os_order(k) order_of_key(k)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define make_graph(k) int x,y; f0(i,0,k){cin>>x>>y; adj[x].pb(y); adj[y].pb(x);}
#define test int t;cin>>t;while(t--)

signed main()
{
    fast

    #ifndef ONLINE_JUDGE
        freopen("inputf.in","r",stdin);
        freopen("outputf.in","w",stdout);
    #endif

    map<int,int> m;
    int n;
    cin>>n;

    int x;
    f0(i,0,n)
    {
        cin>>x;
        m[x]++;
    }
    vector<int> v;
    for(auto x : m) v.pb(x.fi);

    int ans = 0;
    f0(i,0,v.size()) f0(j,i+1,v.size()) f0(k,j+1,v.size())
    {
        if(v[i] + v[j] > v[k])
        ans += m[v[i]] * m[v[j]] * m[v[k]];
    }
    cout<<ans;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;

//#define int long long
//using ll = boost::multiprecision::cpp_int;
using ll = long long;
//const int INF = 1e9;//INT_MAX=1<<31-1=2147483647
const ll INF = (ll)1e18;//1<<63-1=9223372036854775807
const ll MOD = 1000003;
const double EPS = 1e-9;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var) std::cout<<var<<std::endl
#define PI (acos(-1))
#define rep(i, n)   for(ll i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(ll i=1, i##_length=(n); i<=i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define pb push_back
inline bool isnatural(double a) { return a>=0 && ceil(a)==floor(a); }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/

const ll Q_MAX = 100000;
const ll D_I_MAX = 1000002;
const ll N_I_MAX = 1000000000;

ll Q;


template<typename T> inline T power(T x,T n){	return n ? power(x*x%MOD,n/2)*(n%2?x:1)%MOD : 1;}


void input() {
	scanf("%lld", &Q);

}

void solve() {

	ll fac[MOD];
	fac[0]=1;
	for(int i=1;i<MOD;i++)fac[i]=fac[i-1]*i%MOD;		

	while(Q--){
		ll x,d,n;
		cin>>x>>d>>n;
		if(d==0){//公差０＝x^n
			cout<<power(x,n)%MOD<<endl;
			continue;
		}
		//x*d^(MOD-2) = x/d
		x=x*power(d,MOD-2)%MOD;
		if(x+n-1>=MOD){
			cout<<0<<endl;
		}else{
			// (x+n-1)!/(x-1)! d^n
			ll a=fac[x+n-1]*power(fac[x-1],MOD-2) * power(d,n)%MOD;
			cout<<a<<endl;
		}
	}

 }

signed main() {
	input();
	solve();
	return 0;
}


Measured memory_bytes: 8704
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
using namespace std;

#define ll long long

ll abc(ll a)
{
    if (a < 0)
        return -a;
    return a;
}

int main()
{
    ll N;
    scanf("%lld\n", &N);

    string s;
    cin >> s;

    vector<ll> r(N, -1), g(N, -1), b(N, -1);
    vector<ll> indexsum(N, 0);
    ll ri = 0, gi = 0, bi = 0;
    for (ll i = 0; i < N; i++)
    {
        char c = s[i];

        if (c == 'R')
            r[ri++] = i;
        else if (c == 'G')
            g[gi++] = i;
        else
            b[bi++] = i;
    }

    ll x = ri * gi * bi;
    for (ll i = 0; i < N - 2; i++)
    {
        for (ll j = i + 1; j < N - 1; j++)
        {
            ll k = j - i + j;
            if (k < N && s[i] != s[j] && s[j] != s[k] && s[k] != s[i])
                x--;
        }
    }

    printf("%lld", x);
}


Measured memory_bytes: 3864
#include<bits/stdc++.h>
using namespace std;
int main(){
    int h, w;
    while(1){
        cin >> h >> w;
        if(h == 0 && w == 0){
            return 0;
        }
        for(int i = 0;i < h;i++){
            for(int j = 0;j < w;j++){
                cout << "#";
                
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3096
# Contest No.: ABC171
# Problem No.: B
# Solver:      JEMINI
# Date:        20200621

import sys
import heapq

def main():
    n, k = map(int, input().split())
    nums = list(map(int, sys.stdin.readline().split()))
    nums.sort()
    print(sum(nums[:k]))
    return

if __name__ == "__main__":
    main()

Measured memory_bytes: 62764
n,q = map(int,input().split())
s = input()

csum = [0] * (n+1)
for i in range(1,n):
    if s[i-1]=='A' and s[i] == 'C':
        csum[i+1] = csum[i] + 1
    else:
        csum[i+1] = csum[i]

output_ls = [0] * q
for i in range(q):
    l, r = map(int,input().split())
    output_ls[i] = csum[r] - csum[l]

for i in range(q):
    print(output_ls[i])

Measured memory_bytes: 10324
a, b, c, k = map(int, input().split())
res = 0
if k == a:
    print(a)
elif k < a:
    print(k)
else:
    res += a
    k -= a
    if k > b:
        k -= b
        if k > c or k == c:
            res -= c
            print(res)
        else:
            res-= k
            print(res)
    else:
        print(res)

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

using namespace std;

int count_even(int start, int end) {
	int len = end - start;
	if (len % 2 == 0) {
		return len / 2;
	} else {
		if (start % 2 == 0) {
			return (len - 1) / 2;
		} else {
			return (len - 1) / 2 + 1;
		}
	}
}

int count_odd(int start, int end) {
	int len = end - start;
	if (len % 2 == 0) {
		return len / 2;
	} else {
		if (start % 2 == 0) {
			return (len - 1) / 2 + 1;
		} else {
			return (len - 1) / 2;
		}
	}
}

int main(){
	string s;
	cin >> s;
	
	// 0           6   8       12
	// |           |   |       |  mount
	//  R R L L L L R L R R L L
	//     |         |     |      valley
	//     1         6     9
	
	std::vector<int> mount;
	std::vector<int> valley;
	int str_size = (int)s.length();
	vector<int> result(str_size, 0);
	
	// count mount
	mount.push_back(0);
	int pos = s.find("LR");
	while (pos != std::string::npos) {
		mount.push_back(pos+1);
		pos = s.find("LR", pos + 2);
	}
	mount.push_back(str_size);
	
	// count valley
	pos = s.find("RL");
	while (pos != std::string::npos) {
		valley.push_back(pos);
		pos = s.find("RL", pos + 2);
	}
	
	int i = 0;
	int n_even, n_odd;
	for (auto val : valley) {
		n_even = count_even(mount.at(i), mount.at(i+1));
		n_odd = count_odd(mount.at(i), mount.at(i+1));
		
		if (val % 2 == 0) {
			result.at(val) = n_odd;
			result.at(val+1) = n_even;
		} else {
			result.at(val) = n_even;
			result.at(val+1) = n_odd;
		}
		++i;
	}
	
	for (int i = 0; i < str_size; ++i) {
		cout << result.at(i);
		if (i != str_size - 1) {
			cout << " ";
		} else {
			cout << endl;
		}
	}
	
	return 0;
}

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

#define MAX_N 100000
int par[MAX_N];//親の要素
int rank_[MAX_N];

//n要素で初期化
void init(int n)
{
	for (int i = 0; i < n; i++)
	{
		par[i] = i;
		rank_[i] = 0;
	}
}

//木の根を求める
int root(int x)
{
	if (par[x] == x)
	{
		return x;
	}
	else
	{
		return par[x] = root(par[x]);
	}
}

//xとyが同じ集合に属するか　否か
bool same(int x, int y)
{
	return root(x) == root(y);
}

//xとyの属する集合を併合
void unite(int x, int y)
{
	x = root(x);
	y = root(y);
	if (x == y)
	{
		return;
	}

	if (rank_[x] < rank_[y])
	{
		par[x] = y;
	}
	else
	{
		par[y] = x;
		if (rank_[x] == rank_[y])
		{
			rank_[x]++;
		}
	}


}

int main()
{
	int n;
	cin >> n;//頂点の数
	int m;
	cin >> m;//辺の数

	//初期化
	init(n);

	//木を作る
	for (int i = 0; i < m; i++)
	{
		int a, b;
		cin >> a >> b;
		if (same(a, b))
		{
			continue;
		}
		else
		{
			unite(a, b);
		}
	}

	int q;//クエリの数
	cin >> q;

	for (int i = 0; i < q; i++)
	{
		int a, b;
		cin >> a >> b;
		if (same(a, b))
		{
			cout << "yes" << endl;
		}
		else if(!same(a, b))
		{
			cout << "no" << endl;
		}
	}

	return 0;





}


Measured memory_bytes: 3872
from itertools import permutations

N, M = map(int, input().split())
G = [[0]*N for _ in range(N)]

for _ in range(M):
    a, b = map(int, input().split())
    G[a-1][b-1] = 1
    G[b-1][a-1] = 1

ans = 0

for p in permutations(range(N)):
    now = p[0]
    
    if now!=0:
        continue

    for i in range(1, N):
        if G[now][p[i]]==1:
            now = p[i]
        else:
            break
    else:
        ans += 1

print(ans)

Measured memory_bytes: 73592
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
long long n,p,ps,res;
vector<long long> divisor;
long long qp(long long a,int b){
	long long bb=1LL;
	while(b){
		if(b&1) bb*=a;
		a*=a,b>>=1;
	}
	return bb;
}
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>p;
	divisor.clear();
	res=1LL;
	for(long long i=2;i*i<=p;i++){
		int num=0;
		while(p%i==0){
			p/=i;
			num++;
		}
		res*=qp(i,num/n);
	}
	if(p!=1LL)
		res*=qp(p,1/n);
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define endl '\n'
#define f first
#define s second
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define debug(...) cout << " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] " << endl

using ld = long double;
using ll = long long;
using pii = pair <int,int>;
using pll = pair <ll,ll>;
using vi = vector <int>;
using vll = vector <ll>;
using vpii = vector <pii>;
using vpll = vector<pll>;
using vs = vector <string>;

const int nax = 2e5 + 5;
int parent[nax];
int qtd[nax];

int find(int x){
  if(x == parent[x])
    return x;

  return parent[x] = find(parent[x]);
}

void join(int x,int y){
  x = find(x);
  y = find(y);

  if(x != y){
    parent[x]=y; 
		qtd[y]+=qtd[x]; 
  }
}

int main(){
  fastio;

  int n,m;
  cin >> n >> m;

  for(int i=1;i<=n;i++)
    parent[i] = i,qtd[i] = 1;

  for(int i=0;i<m;i++){
    int a,b;
    cin >> a >> b;
    if(find(a) != find(b))
      join(a,b);
  }

  int ans = 1;

  for(int i=1;i<=n;i++)
    ans = max(qtd[i],ans);

  cout << ans << endl;


  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

typedef long long int ll;

int main() {

  ll n, m;
  cin >> n >> m;

  vector<ll> v(n);
  rep(i, n) { cin >> v[i]; }

  if (n <= m) {
    cout << "0" << endl;
    return 0;
  }
  sort(all(v));

  ll sum = 0;
  rep(i,n-m){
      sum += v[i];
  }
  cout << sum << endl;
}

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

double distance(pair<int, int> a, pair<int, int> b) {
    return  sqrt(pow(a.first - b.first, 2) + pow(a.second - b.second, 2));
}

int main() {

    int N;
    cin >> N;

    pair<int, int> P[N];
    vector<int> order;
    for (int i = 0; i < N ; ++i) {
        int x, y;
        cin >> x >> y;
        P[i] = make_pair(x, y);
        order.push_back(i);
    }

    double count = 0;
    double sum = 0;
    do {
        pair<int, int> f = P[*order.begin()];
        for (auto o = ++order.begin(); o!=order.end(); ++o) {
            pair<int, int> s = P[*o];
            sum += distance(f, s);
            f = s;
        }
        count++;

    } while (next_permutation(order.begin(), order.end()));

    cout << fixed << setprecision(10) << (sum / count) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;

int main(){
    int n,m;
    cin >> n >> m;
    vector<P> ans(m);
    int j = 1,k = m+1;
    int l = m+2,p = 2*m+1;
    rep(i,m){
        if(i%2 ==0){
            ans[i] = P(j,k);
            ++j;
            --k;
        }else{
            ans[i] = P(l,p);
            ++l;
            --p;
        }
    }
    rep(i,m){
        cout << ans[i].first << " "<< ans[i].second;
        cout << endl;
    }
    return 0;
}

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

#define NIL NULL
#define INF 1000000001

using namespace std;

int main(){
    int num_node;
    int node_ind,node_deg,adj_node;
    scanf("%d",&num_node);

    vector<vector<int> > adj(num_node,vector<int>(num_node,0));

    for(int i = 0; i < num_node;i++ ){
        scanf("%d %d",&node_ind,&node_deg);
        for(int j = 0;j < node_deg;j++){
            scanf("%d",&adj_node);
            adj[node_ind-1][adj_node-1] = 1;
        }
    }

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



Measured memory_bytes: 3272
def spaceinput():
    return list(map(int,input().split(" ")))

def gsum(l,r):
    return sum(V[l:(r)])
N,K=spaceinput()
V=spaceinput()

v_total=sum(V)
res=0
for nl in range(N):
    for nr in range(N-nl+1):
        if nl+nr>K:
            break
        l=nl
        r=N-nr-1
        if nl>0:
            temoto=V[:l]
        else:
            temoto=[]
        #print("temoto_l",temoto)
        if nr>0:
            temoto.extend(V[(r+1):])            
        temoto=sorted(temoto)
        #tmp=v_total-gsum(l,r)
        tmp=sum(temoto)
        #print(temoto,tmp,v_total,gsum(l,r),r)
        for ss in range(K-len(temoto)):
            #print(ss)
            if ss>len(temoto)-1:
                break
            if temoto[ss]<0:
                tmp-=temoto[ss]
            else:
                break

        if tmp>res:
            res=tmp
            #print("koksin",res)
            #print(nl,nr)
            #print(l,r)
        

print(res)

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <utility>
#include <typeinfo>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;

int main() 
{
	int a[183]={};
	REP(i,183)a[i]=i*i;
			
	int n;
	while(cin>>n&&n!=0)
	{
		int ans(0);
		for(int i=182;i*i>=n/4&&i>=0;i--)
		{
			int tmp1=n;
			if(a[i]>tmp1){continue;}
			else
			{
				int tmp2 = tmp1 - a[i];
				for(int j=i;j*j>=tmp2/3&&j>=0;j--)
				{
					if(a[j]>tmp2){continue;}
					else
					{
						int tmp3 = tmp2 - a[j];
						for(int k=j;k*k>=tmp3/2&&k>=0;k--)
						{
							if(a[k]>tmp3){continue;}
							else
							{
								int tmp4 = tmp3 - a[k];
								for(int l=k;l*l>=tmp4&&l>=0;l--)
								{
									if(tmp4==a[l])
									{
										ans++;
										break;
									}
								}
							}
						}
					}
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class T>
inline bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T>
inline bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N,K,C; cin >> N >> K >> C;
    string S; cin >> S;
    int A[K],B[K];
    int pos=0;
    rep(i,K) {
        while(S[pos]=='x'){
            pos++;
        }
        A[i]=pos;
        pos+=C+1;
    }
    pos=N-1;
    per(i,K) {
        while(S[pos]=='x'){
            pos--;
        }
        B[i]=pos;
        pos-=C+1;
    }
    rep(i,K){
        if(A[i]==B[i]) cout << A[i]+1 << endl;
    }
}

Measured memory_bytes: 5012
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    int n, ans = 0;
    cin >> n;
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        if(i%2==0 && a%2 == 1) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3188
#B
import math
mod = 10**9+7
m,n = map(int,input().split()) #m^n % mod
n2 = math.ceil(math.sqrt(n))

b = bin(n)
b = b.lstrip("0b")
blist = list(b)
blist = blist[::-1]
ans = 1
beki = [m]
for i in range(n2):
    m = (m**2)%mod
    beki.append(m)

blen = len(blist)
ans = 1
for i in range(blen):
    if blist[i] == "1":
        ans*=beki[i]
        ans%=mod
        
print(ans)



Measured memory_bytes: 6932
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		
		Scanner s = new Scanner(System.in);
		int a = s.nextInt();
		int b = s.nextInt();
		System.out.println((a*b)% 2 == 0 ? "Even" : "Odd");
	}

}


Measured memory_bytes: 20820
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>

using namespace std;

int d[10000];

int dp[100];
int dpw[100];

char w[1000];

int main()
{
	int n = 0;
	while(NULL != gets(w))
	{
		char* p = strtok(w,",");
		d[n] = atoi(p);
		n++;
		while(NULL != (p = strtok(NULL,",")))
		{
			d[n] = atoi(p);
			n++;
		}
	}
	int k;
	int now = 0;
	for(int i = 1; i <= 50; i++)
	{
		if(now + i == n)
		{
			k = i;
			break;
		}
		now += i * 2;
	}
	dp[0] = d[0];
	now = 1;
	for(int i = 2; i <= k; i++)
	{
		dpw[0] = dp[0] + d[now];
		for(int j = 1; j < i - 1; j++) dpw[j] = max(dp[j - 1] + d[now + j],dp[j] + d[now + j]);
		dpw[i - 1] = dp[i - 2] + d[now + i - 1];
		for(int j = 0; j < i; j++) dp[j] = dpw[j];
		now += i;
	}
	for(int i = k - 1; i > 0; i--)
	{
		for(int j = 0; j < i; j++) dpw[j] = max(dp[j] + d[now + j],dp[j + 1] + d[now + j]);
		for(int j = 0; j < i; j++) dp[j] = dpw[j];
		now += i;
	}
	printf("%d\n",dp[0]);
	return 0;
}

Measured memory_bytes: 1136
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<vector>
using namespace std;

#define EPS (1e-20)

class Point {
public:
    double x, y;
    Point(double x = 0, double y = 0): x(x), y(y) {}
    
    Point operator + (Point p) {return Point(x + p.x, y + p.y);}
    Point operator - (Point p) {return Point(x - p.x, y - p.y);}
    Point operator * (double a) {return Point(x * a, y * a);}
    Point operator / (double a) {return Point(x / a, y / a);}

    bool operator < (const Point &p) const {
        return x != p.x ? x<p.x : y<p.y;
    }
    bool operator == (const Point &p) const {
        return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
    }
};

double norm(Point p){return p.x*p.x + p.y*p.y;}
double abs(Point p) {return sqrt(norm(p));}

typedef Point Vector;

double dot(Vector a, Vector b){
    return a.x*b.x + a.y*b.y;
}

struct Segment {
    Point p1, p2;
};

Point project(Segment s, Point p){
    Vector base = s.p2 - s.p1;
    double r = dot(p-s.p1, base) / norm(base);
    return s.p1 + base * r;
}

Point reflect(Segment s, Point p) {
    return p + (project(s,p) - p) * 2.0;
}
int main(){
    double x1,y1,x2,y2,xq,yq;
    char c;
    while(cin>>x1>>c>>y1>>c>>x2>>c>>y2>>c>>xq>>c>>yq){
        Point P1(x1,y1);
        Point P2(x2,y2);
        Point q(xq,yq);
        Segment s;
        s.p1=P1,s.p2=P2;
        Point p=reflect(s,q);
        printf("%.6f %.6f\n",p.x,p.y);
    }
}

Measured memory_bytes: 1240
main = do
 s<-getLine
 let bi=f ((length s)-1)::[String]
 print $ sum.map sum.map (map read). map words $ formulae s bi
f 0 = [[]]
f n = (map ('0':) (f (n-1)) )++(map ('1':) (f (n-1)))
g (x:xs) (y:ys)
    |y=='0' = x:(g xs ys)
    |otherwise = x:' ':(g xs ys)
g [x] _ = [x]
g _ _ = []

formulae x ys= zipWith ($) (map (flip g) ys) (repeat x)

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

#define Q int t; scanf("%d", &t); for(int q=1; q<=t; q++)
typedef long long int lli;
typedef pair<lli, lli> pi;

#define N 200020
int fre[N];
int c[N];

int main()
{
    int n;
    cin >> n;
    lli a[n];
    for(auto &x: a) cin >> x;

    lli sum=0, rest=0;
    for(int i=0; i<n; i++){
        if(i%2) rest += (a[i]*2);
        sum += a[i];
    }

    lli x = sum-rest;
    cout << x;
    for(int i=0; i<n-1; i++){
        x = a[i]*2 - x;
        cout << " " << x;
    }
    printf("\n");


    return 0;
}


Measured memory_bytes: 2048
palabra = str(input()).upper()
x=0
if len(palabra)==4:
    for letras in palabra:
        if letras == palabra[0]:
            x+=1
        if letras == palabra[1]:
            x+=1
        if letras == palabra[2]:
            x+=1
        if letras == palabra[3]:
            x+=1
if x==8:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
/* ex 7_3
   アカウント名 */

#include <stdio.h>

int main(void){
    int i, j, k, row, column;
    scanf("%d %d\n", &row, &column);
    int row_flag[row], column_flag[column];
    for(i = 0; i < row; i++){
        row_flag[i] = 0;
    }
    for(i = 0; i < column; i++){
        column_flag[i] = 0;
    }
    char matrix[row][column];
    for(i = 0; i < row; i++){
        for(j = 0; j < column; j++){
            scanf(" %c", &matrix[i][j]);
            if(matrix[i][j] == '#'){
                row_flag[i] = 1;
                column_flag[j] = 1;
            }
        }
    }

    for(i = 0; i < row; i++){
        k = 0;
        for(j = 0; j < column; j++){
            if(row_flag[i] == 1 && column_flag[j] == 1){
                printf("%c", matrix[i][j]);
                k = 1;
            }
        }
        if(k == 1){
            printf("\n");
        }
    }

    return 0;
}

Measured memory_bytes: 1628
n, x = list(map(int, input().split()))
s = list(map(int,input().rstrip().split()))
s.sort()
list_sum = sum(s)
flg = True
if list_sum < x: # 多すぎ
    print(len(s) - 1)
elif list_sum == x: # ちょうど
    print(len(s))
else:
    s.reverse()
    c = len(s)
    for ss in s:
        list_sum -= ss
        c -= 1
        if list_sum <= x:
            print(c)
            flg = False
            break

    if(flg):
        print(0)

Measured memory_bytes: 3064
import java.util.Scanner;

//AtCoder Beginner Contest 154
//B	I miss you...
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		sc.close();

		StringBuilder ans = new StringBuilder();
		for (int i = 0; i < S.length(); i++) {
			ans.append("x");
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 22100