akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define for_(i,a,b) for(int i=(a);i<(b);++i)

void dfs(int v, const vector< set< int > >& childlen, vector< int >& step) {
	for (int u : childlen[v]) {
		step[u] = step[v] + 1;
		dfs(u, childlen, step);
	}
}

void solve(const int n, const int k, const vector< int >& a) {
	vector< set< int > > childlen(n);
	for_(i,1,n) childlen[a[i]].insert(i);
	
	vector< int > step(n, 0);
	dfs(0, childlen, step);
	
	if (k == 1) {
		int ans = (a[0] != 0 ? 1 : 0);
		for_(i,1,n) ans += (step[i] > k);
		cout << ans << endl;
	} else {
		vector< int > sorted_id(n);
		for_(i,0,n) sorted_id[i] = i;
		sort(sorted_id.begin(), sorted_id.end(), [&](int i, int j) { return step[i] > step[j]; });
		
		int ans = (a[0] != 0 ? 1 : 0);
		
		for_(i,0,n) {
			int v = sorted_id[i];
			
			if (step[v] <= k) continue;
			
			int kk = k - 1;
			
			while (kk) {
				v = a[v];
				--kk;
			}
			
			step[v] = 1;
			dfs(v, childlen, step);
			childlen[a[v]].erase(v);
			++ans;
		}
		
		cout << ans << endl;
	}
}

int main() {
	int n, k;
	cin >> n >> k;
	
	vector< int > a(n);
	for_(i,0,n) {
		cin >> a[i];
		--a[i];
	}
	
	solve(n, k, a);
}

Measured memory_bytes: 15488
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int S=0,T;
int p[100005],q[100005],idp[100005],idq[100005],tot;
struct edge{
	int s,t,cap,nxt;
}e[200005];
int last[200005],e_cnt;
inline void add(int a,int b,int c){
	e[e_cnt]=(edge){a,b,c,last[a]};
	last[a]=e_cnt++;
}
int d[200005];
int Q[200005],h,t;
bool bfs(){
	memset(d,63,sizeof(d));
	d[S]=0;
	h=t=0;
	Q[++t]=S;
	while(h<t){
		h++;
		for(int i=last[Q[h]];i!=-1;i=e[i].nxt)if(e[i].cap>0&&d[e[i].t]>d[Q[h]]+1){
			d[e[i].t]=d[Q[h]]+1;
			Q[++t]=e[i].t;
		}
	}
	return d[T]<1e8;
}
int cur[200005];
int dfs(int x,int Cap){
	if(x==T)return Cap;
	int res=0;
	for(int &i=cur[x];i!=-1;i=e[i].nxt)if(e[i].cap&&d[e[i].t]==d[x]+1){
		int t=dfs(e[i].t,min(Cap,e[i].cap));
		e[i].cap-=t;
		e[i^1].cap+=t;
		Cap-=t;
		res+=t;
		if(Cap<=0)break;
	}
	return res;
}
int dinic(){
	int res=0;
	while(bfs()){
		for(int i=0;i<=T;i++)cur[i]=last[i];
		res+=dfs(S,1e9);
		// printf("%d\n",res);
		// return res;
	}
	return res;
}
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",&p[i]);
	for(int i=0;i<n;i++)scanf("%d",&q[i]);
	for(int i=0;i<n;i++)if(!idp[i]){
		idp[i]=++tot;
		int j=p[i];
		while(j!=i)idp[j]=tot,j=p[j];
	}
	for(int i=0;i<n;i++)if(!idq[i]){
		idq[i]=++tot;
		int j=q[i];
		while(j!=i)idq[j]=tot,j=q[j];
	}
	T=tot+1;
	int ans=n;
	memset(last,-1,sizeof(last));
	for(int i=0;i<n;i++)
		if(p[i]==i)
			if(q[i]==i)ans--;
			else add(idq[i],T,1),add(T,idq[i],0);
		else
			if(q[i]==i)add(S,idp[i],1),add(idp[i],S,0);
			else if(p[i]==q[i])add(idp[i],idq[i],1),add(idq[i],idp[i],1);
				 else add(idq[i],idp[i],1),add(idp[i],idq[i],0);
	printf("%d\n",ans-dinic());
	return 0;
}

Measured memory_bytes: 8960
k = [x for x in input()]
n = int(input())
for _ in range(n):
    command = [_ for _ in input().split()]
    if command[0] == "replace":
        del k[int(command[1]):int(command[2])+1]
        for i in range(len(command[3])):
            k.insert(int(command[1]),command[3][len(command[3])-i-1])
    elif command[0] == "reverse":
        b = k[int(command[1]):int(command[2])+1]
        del k[int(command[1]):int(command[2])+1]
        for i in range(len(b)):
            k.insert(int(command[1]),b[i])
    elif command[0] == "print":
        a = k[:]
        for u in range(int(command[1]),int(command[2])+1):
            print(a[u],end ="")
        else:
            print()


Measured memory_bytes: 5760
import numpy as np
h,w = [int(i) for i in input().split()]
maximum = h+w
value = []
for i in range(h):
  value.append([0 if i == "#" else maximum for i in list(input())])
values = np.array(value)
for x in range(w-1):
  values[:,x+1] = np.minimum(values[:,x]+1,values[:,x+1])
for x in range(w-1,0,-1):
  values[:,x-1] = np.minimum(values[:,x]+1,values[:,x-1])
for y in range(h-1):
  values[y+1,:] = np.minimum(values[y,:]+1,values[y+1,:])
for y in range(h-1,0,-1):
  values[y-1,:] = np.minimum(values[y,:]+1,values[y-1,:])
print(values.max())

Measured memory_bytes: 29008
a=list(input())
k=int(input())
ans=0
if len(a)==1:
  print(k//2)
elif len(list(set(a)))==1:
  print((len(a)*k)//2)
else:  
  tmp=a[0]
  count1=0
  count2=0
  l=0
  while a[l]==tmp:
    count1+=1
    l+=1
  j=-1
  while a[j]==tmp:
    count2+=1
    j-=1
    
  for i in range(len(a)-1):
    if a[i]==a[i+1]:
      a[i+1]='1'
      ans+=1
  if a[0]==a[-1]:
    if count1%2==0:
      print(ans*k)
    else:
      print(ans*k+k-1)
  else:
    print(ans*k)

Measured memory_bytes: 3064
#include<iostream>

typedef long long ll;

int N;
ll a[100];
ll dp[100][21];

int main()
{
	std::cin >> N;
	for( int i = 0; i != N; ++i )
		std::cin >> a[i];

	dp[0][a[0]] = 1;

	for( int i = 0; i != N - 2; ++i )
	{
		for( int j = 0; j <= 20; ++j )
		{
			if( j + a[i+1] <= 20 )
				dp[i+1][j+a[i+1]] += dp[i][j];

			if( j - a[i+1] >= 0 )
				dp[i+1][j-a[i+1]] += dp[i][j];
		}
	}

	std::cout << dp[N-2][a[N-1]] << std::endl;

	return 0;
}

Measured memory_bytes: 1180
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] L = new int[N];
		Arrays.setAll(L, i -> sc.nextInt());
		int ans = 0;
		for(int i = 0; i < N; i++)
			for(int j = i+1; j < N; j++)
				for(int k = j+1; k < N; k++)
					if(L[i] != L[j] && L[j] != L[k] && L[i] != L[k] && L[i]+L[j]>L[k] && L[i]+L[k]>L[j] &&L[k]+L[j]>L[i])
						ans++;
		System.out.println(ans);
	}

}


Measured memory_bytes: 36996
#include <bits/stdc++.h>
using namespace std;
 
int main(){
        int N;
        cin >> N;
        vector<int> H(N);

        for(int i = 0; i < N; i++){
                cin >> H.at(i);
        }

        string ans = "Yes";

        for(int i = N-1; i > 1; i--){
                if(H.at(i) >= H.at(i-1)){

                }else if((H.at(i-1) - H.at(i)) == 1){
                        H.at(i-1)--;
                }else{
                        ans = "No";
                        break;
                }
        }
        cout << ans;
}

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

stack <int> st;

void enter(int car) {
  st.push(car);
}

void exit() {
  cout << st.top() << endl;
  st.pop();
}

int main() {
  int car;
  while (cin >> car) {
    if (car == 0) {
      exit();
    } else {
      enter(car);
    }
  }
}

Measured memory_bytes: 1200
import collections

def f(myList):
    ans = ''
    if len(myList)%2==0:
        for i in range(len(myList)):
            ans += str(myList[i]) + ' '
    else:
        for i in range(len(myList)):
            ans += str(myList[-(i+1)]) + ' '
    return ans[:-1]

n = int(input())
a = list(map(int,input().split()))
b = collections.deque()
for i in range(n):
    if i%2==0:
        b.append(a[i])
    else:
        b.appendleft(a[i])
print(f(b))


Measured memory_bytes: 31504
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

int main() {
    string s;
    cin >> s;
    int n = s.size(), ans = 0;
    for(int i = 0; i < n / 2; i++) {
        ans += s[i] != s[n - i - 1];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;
using pll=pair<ll,ll>;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define MOD 1000000007

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
	ll a,b,x;
	cin >> a >> b >> x;
	if(a == 0) cout << b/x+1 << endl;
	else cout << b/x - (a-1)/x << endl;


  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int n, k, div, remainder, a;
	cin >> n >> k;
	div = n / k;
	remainder = n % k;
	a = (div + remainder) - div;
	if (k > n) a = 1;
	if (remainder > div || remainder == div) a = 1;
	cout << a;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int M = 2e5 + 10;
const int mod = 1e9 + 7;
ll a[M];
int main(){
    int n, k;
    scanf("%d%d", &n, &k);
    for(int i = 0; i <= n; i++) a[i] = (i + a[i - 1]) % mod;
    ll ans = 0;
    for(int i = k - 1; i <= n; i++) {
        ans = (ans + a[n] - a[n - (i + 1)] - a[i] + 1 + mod) % mod;
        //printf("%lld\n", ans);
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 5372
#include <iostream>
#include <string>
#include <map>
using namespace std;
typedef long long ll;

int main() {
	ll a, b, c;
	cin >> a >> b >> c;
	for (int i = 1; i <= b; i++) {
		if ((a*i) % b == c) {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	return 0;
}

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

int main() {
  int A,B,C,D,E,F;
  cin >> A >> B >>C >> D >> E >> F;
  if(B-A<=F&&C-A<=F&&D-A<=F&&E-A<=F&&C-B<=F&&D-B<=F&&E-B<=F&&D-C<=F&&E-C<=F&&E-D<=F){
    cout << "Yay!" << endl;
  }
  else{
	cout << ":(" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, r;
  cin >> a >> b;
  r = a * b - a * b / 2 * 2; 
   if (r == 0){ 
  cout << "Even" << endl;
   }
   else 
   {cout << "Odd" << endl; 
   }
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i=0;i<(n);++i)
#define RANGE(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(n)-1;i>= 0;--i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.141592653589793238
#define dcout cout<<fixed<<setprecision(50)

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

// typedef long long ll;
#define int long long
#define double long double

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

signed main(void){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N, P[200000]; cin >> N;
  int mn = VERYBIG, ans = 0;
  REP(i, N){
    cin >> P[i];
    if(mn == P[i] or chmin(mn, P[i])) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N = int(input())
    K = int(input())
    X = list(map(int, input().split()))
    result = 0
    for x in X:
        result += min(2 * x, 2 * (K - x))
    print(result)


if __name__ == "__main__":
    main()


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

int main() {
    int64_t v[4], n;
    for (int i = 0; i < 4; i++) {
        cin >> v[4 - 1 - i];
    }
    cin >> n;
    n *= 4;

    for (int i = 0; i < 4; i++) {
        for (int j = i + 1; j < 4; j++) {
            if (v[i] >= v[j] * (1LL << (j - i))) {
                v[i] = 0;
                break;
            }
        }
    }

    int64_t m = 16, r = 0;
    for (int i = 0; i < 4; i++) {
        m /= 2;
        if (v[i] == 0) continue;
        r += n / m * v[i];
        n %= m;
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>                                                                                 
using namespace std;                                                                                
int main(){                                                                                         
  int n, x;                                                                                         
  cin >> n;                                                                                         
  for(int i=1; i<=n; i++){                                                                          
    x = i +0;                                                                                       
    if (x%3==0 or x%10==3){                                                                         
      cout << " " << i;                                                                             
    } else {                                                                                        
      while(x % 10 != 3 and x != 0){                                                                
        x/=10;                                                                                      
      }                                                                                             
      if(x%10==3){                                                                                  
        cout << " " << i;                                                                           
      }                                                                                             
    }                                                                                               
                                                                                                    
  }                                                                                                 
  cout << endl;                                                                                     
}                                                                                                   
                                                                                                    
                                                                                                    
                                                                                                    
                     


Measured memory_bytes: 3088
/*
 * @Author: AsilenceBTF
 * @Buff: ︿(￣︶￣)︿  芜湖塔台 起飞
 * @Date: 2019-06-20 09:22:24
 * @LastEditTime: 2020-08-30 15:14:27
 */
// #include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
using namespace std;

#define sz(x) int(x.size())
#define ALL(x) x.begin(), x.end()
#define INF 0x3f3f3f3f
typedef long long ll;

const int MOD = 1e9 + 7;
const int N = 2e5 + 105;
int pre[N], sum[N];
int finds(int x){
    if(pre[x] == x) return x;
    return pre[x] = finds(pre[x]);
}
void join(int x, int y){
    int fx = finds(x), fy = finds(y);
    if(fx != fy){
        pre[fx] = fy;
        sum[fy] += sum[fx];
    }
}
int main(){
    ios::sync_with_stdio(0), cin.tie(0);
    int n, m; cin >> n >> m;
    for(int i = 1; i <= n; ++i) pre[i] = i, sum[i] = 1;
    int ans = 1;
    for(int i = 1; i <= m; ++i){
        int u, v; cin >> u >> v;
        join(u, v);
        ans = max(ans, sum[finds(u)]);
    }   
    cout << ans << endl;
    // system("pause");    
}

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

int main() {
  string S;
  cin >> S;
  
  bool ans = true;
  
  for (int i = 0; i < S.size(); i++) {
    if ( i%2 == 0 ) {
      if ( S.at(i) == 'L') {
        ans = false;
      }
    }    
    else {
      if ( S.at(i) == 'R') {
        ans = false;
      }
    }
  }
 
  if (ans) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL) ;
#define MOD 1000000007
#define int long long
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vpii vector<pair<int,int>>
#define ff first
#define ss second
#define INF (1LL<<61)

using namespace std;


int n ;
int a[3010];
int dp[3010][3010][2];

int solve(int i , int j , int t ) {

	if (i > j)return 0;

	if (dp[i][j][t] != -1)return dp[i][j][t];

	if (t == 1)return dp[i][j][t] = max(a[i] + solve(i + 1 , j , 0) , a[j] + solve(i , j - 1 , 0));

	if (t == 0)return dp[i][j][t] = min(solve(i + 1 , j , 1) , solve(i , j - 1 , 1));

}

int32_t main() {

	fastio
// #ifndef ONLINE_JUDGE
// freopen("input.txt", "r", stdin);
// freopen("output.txt","w", stdout);
// #endif

	memset(dp , -1 , sizeof(dp));
	cin >> n;
	for (int i = 1 ; i <= n ; i++)cin >> a[i];

	int x = solve(1, n , 1);
	int sum = 0;
	for (int i = 1 ; i <= n  ; i++)sum += a[i];

	int y = sum - x;

	cout << x - y;



	return 0;
}


Measured memory_bytes: 145380
#include <iostream>
using namespace std;
typedef long long ll;
int main( void )
{
  ios::sync_with_stdio(false);
  ll K;
  cin >> K;
    ll d[50];
    ll a = (K+49)/50;
    ll b = 50 + a - 1;
    ll c = 50 * a - K;
    for( int i=0; i<50; i++ ) d[i] = b;
    for( int i=0; i<c; i++ ){
      ll m = -100000;
      ll mi = -1;
      for( int j=0;j<50; j++ ){
        if( d[i] > m ){
          m = d[j];
          mi = j;
        }
      }
      for( int j=0; j<50; j++ ){
        if( mi == j ) d[j] -= 50;
        else d[j] ++;
      }
    }
    cout << 50 << endl;
    cout << d[0];
    for( int i=1; i<50; i++ ){
      cout << ' ' << d[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define dll(x) scanf("%I64d",&x)
#define xll(x) printf("%I64d\n",x)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll powmod(ll a,ll b,ll MOD){ll ans=1ll;while(b){if(b&1)ans=ans*a%MOD;a=a*a%MOD;b>>=1;}return ans;}
inline void getInt(int* p);
const int maxn=100010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
bool noprime[maxn];
std::vector<int> p;
ll pf[122][3];
int init()
{
	MS0(noprime);
	p.clear();
	int m=(int)(sqrt(maxn+0.5));
	repd(i,2,m)
	{
		if(!noprime[i])
		{
			for(int j=i*i;j<=maxn;j+=i)
			{
				noprime[j]=1;
			}
		}
	}
	repd(i,2,maxn)
	{
		if(!noprime[i])
		{
			p.pb(i);
		}
	}
	return p.size();
}
int getprifac(ll n,int len)
{
	int pos=0;
	for(int i=0;p[i]*p[i]<=n&&i<len;i++)
	{
		if(n%p[i]==0)
		{
			pf[++pos][0]=p[i];
			pf[pos][1]=0;
			while(n%p[i]==0)
			{
				pf[pos][1]++;
				n/=p[i];
			}
		}
	}
	if(n>1)
	{
		pf[++pos][0]=n;
		pf[pos][1]=1;
	}
	return pos;
}
ll getnum(ll num,ll x)
{
	if(!num)
	{
		return 0;
	}else
	{
		return num/x+getnum(num/x,x);
	}
}
const ll mod = 1e9+7ll;
int main()
{
	//    freopen("C:\\Users\\DH_M\\Desktop\\code_io\\in.txt.txt","r",stdin);
	//    freopen("C:\\Users\\DH_M\\Desktop\\code_io\\out.txt.txt","w",stdout);
	ll n;
	cin>>n;
	int len=init();
	ll ans=1ll;
	rep(i,0,len)
	{
		if(p[i]>n)
			break;

		ll cnt=getnum(n,p[i]);
		ans*=(cnt+1ll);
		ans=(ans+mod)%mod;
	}
	cout<<ans<<endl;
	
	
    return 0;
}

inline void getInt(int* p) {char ch;do {ch = getchar();} 
while (ch == ' ' || ch == '\n');if (ch == '-') {*p = -(getchar() - '0');
while ((ch = getchar()) >= '0' && ch <= '9') {*p = *p * 10 - ch + '0';}}
else {*p = ch - '0';while ((ch = getchar()) >= '0' && ch <= '9') 
{*p = *p * 10 + ch - '0';}}}

Measured memory_bytes: 512
#include <stdio.h>
int main()
{
  unsigned int N;
  int A, B;
  
  scanf ("%d\n%d\n%d", &N, &A, &B);
  
  if (N==1){
    printf ("Hello World");
  }
  
  else if (N==2){
    printf ("%d", A+B);
  }
  
  return 0;
}

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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();
        int[] h = sc.IntArray();

        int answer = 0;

        while (true)
        {
            bool water = false;
            for (int i = 0; i < n; i++)
            {
                if (h[i] == 0)
                {
                    continue;
                }
                else
                {
                    water = true;
                    answer++;
                    int height = h[i];
                    for (int j = i; j < n; j++)
                    {
                        if (h[j] >= height)
                        {
                            h[j]--;
                        }
                        else
                        {
                            break;
                        }
                    }
                    break;
                }
            }
            if (water == false)
            {
                break;
            }
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


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

using namespace std;

int main() {
	int N, K;
	cin >> N >> K;

	vector<int> A(N);

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

	for(int i = 1; i <= N-K; i++) {
		if(A[K+i-1] > A[i-1]) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 4044
N,M,K=map(int,input().split())
isYes=False
for n in range(N+1):
    for m in range(M+1):
        if(N*m+M*n-2*n*m==K and not isYes):
            print('Yes')
            isYes=True
if(not isYes):
    print('No')

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

using namespace std;
using ll = long long;

ll f(ll a, ll b, ll x) {
	return a * x / b - a * (x / b);
}

int main() {
	ll a, b, n;
	scanf("%lld %lld %lld", &a, &b, &n);

	ll ans = f(a, b, n);

	ans = max(ans, f(a, b, n / b * b - 1));

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


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI pair<int,int>
#define ff first
#define ss second
#define endl '\n'
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL)

const int M=1e9+7;
int mod(int n){
    n%=M;
    return (n+M)%M;
}

int modInv(int a) //extended euclid
{
    int m=M;
    int m0 = m;
    int y = 0, x = 1;

    if (m == 1)
      return 0;

    while (a > 1)
    {
        int q = a / m;
        int t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;
    return x;
}
const int N=1e6;

int power(int x,int y)
{
    int res = 1;
    x = mod(x);
    while (y > 0)
    {
        if (y & 1)
            res =mod(res*x);
        y = y>>1;
        x = mod(x*x);
    }
    return mod(res);
}

int32_t main()
{
    boost;
    int n,a,b;
    cin>>n>>a>>b;

    int f1[N],f2[N];
    f1[0]=1;
    f2[0]=1;
    for(int i=1;i<=min(n,N-1);i++){
        f1[i]=mod(f1[i-1]*(n-i+1));
        f2[i]=mod(f2[i-1]*i);
    }

    int ans=power(2,n);
    ans=mod(ans-1);
    ans=mod(ans-mod(f1[a]*modInv(f2[a])));
    ans=mod(ans-mod(f1[b]*modInv(f2[b])));    
    cout<<ans<<endl;
}

Measured memory_bytes: 15872
#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 vi = vector<int>;
using vc = vector<char>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vi p(n);
    rep(i, n) cin >> p[i];
    
    int ans = 0;
    int cnt = 0;
    rep(i, n) {
        if (p[i] == i+1) {
            cnt++;
        } else {
            ans += (cnt+1)/2;
            cnt = 0;
        }
    }
    ans += (cnt+1)/2;
    cout << ans << endl;
}

Measured memory_bytes: 640
#%%
n = list(input())
n = n[::-1]
if n.count('1') == len(n):
    n = list('0' * len(n) + '1')
else:
    for i in range(len(n)):
        if n[i] == '0':
            n[i] = '1'
            point = i
            break
    for i in range(point):
        n[i] = '0'

n = n[::-1]

count = 0
ans = 0
mod = 10 ** 9 + 7

for i in range(len(n)):
    a = pow(2, count, mod)
    b = pow(3, len(n)-i-1, mod) 
    tmp = (a * b) % mod
    if n[i] == '1':
        count += 1
        ans += tmp
        ans %= mod

print(ans)

Measured memory_bytes: 56816
#include<stdio.h>
int main(){
 int M[3000],F[3000],R[3000];
 int i,j;
 char G[3000];

 for(i=0;i<3000;i++){
  scanf("%d %d %d",&M[i],&F[i],&R[i]);
  
  if(M[i]==-1 && R[i]==-1 && F[i]==-1){
   j=i;
   break;
  }
  }

 for(i=0;i<=j-1;i++){

  if(M[i]==-1 || F[i]==-1 || M[i]+F[i]<30){
   G[i]='F';
  }else if(M[i]+F[i]>=80){
   G[i]='A';
  }else if(M[i]+F[i]>=65 && M[i]+F[i]<80){
   G[i]='B';
  }else if(M[i]+F[i]>=50 && M[i]+F[i]<65){
   G[i]='C';
  }else if(M[i]+F[i]>=30 && M[i]+F[i]<50 && R[i]<50){
   G[i]='D';
  }else if(M[i]+F[i]>=30 && M[i]+F[i]<50 && R[i]>=50){
   G[i]='C';
  }

 }

 for(i=0;i<j;i++){
  printf("%c\n",G[i]);
 }

return 0;
}

  
  

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

using namespace std;

#define ll long long
#define mx 0
#define mn 1e9
#define v(dt) vector<dt>
#define pr(x, y) pair<x,y>
#define loop(x, s, n) for(int x = s; x < n; ++x)
#define in_arr(n) loop(i,0,n){cin>>a[i];}
#define out_arr(n) loop(i,0,n){cout<<a[i];}

const int N = 1e5 + 7;

inline void boost() {
    cin.tie(0), cout.tie(0), cin.sync_with_stdio(0), cout.sync_with_stdio(0);
}

int a[N];

int main() {
    boost();
    ll a,b;
    cin >>a>>b;
    ll res = a*b / __gcd(a,b);
    cout<<res;

}

Measured memory_bytes: 256
<?php
$input = fgets(STDIN);
$input = explode(' ', $input);
$a = (int)$input[0];
$b = (int)$input[1];
$ab = $a * $b;

if ($ab%2 != 0 || ($ab*2)%2 != 0 || ($ab*3)%2 != 0)
{
    echo 'Yes';
} else {
    echo 'No';
}

echo "\n";
?>


Measured memory_bytes: 3828
import sys
import itertools
input = sys.stdin.readline

def func(n, d, x):
    count = 0
    terms = 0.0
    index = [i for i in range(n)]
    for i, k in itertools.combinations(index, 2):
        for j in range(d):        
            j_term = abs(x[i][j]-x[k][j])
            j_term **= 2      
            terms += j_term
        terms **= 0.5
        if terms.is_integer():
            count += 1
        terms = 0.0
    print(count)
    pass


def main():
    n,d = [int(i) for i in input().split()] 
    x = [[0]*d for i in range(n)]
    #x = []
    for i in range(n):
        xd = [int(j) for j in input().split()] 
        x[i] = xd
    #for _ in range(n):
    #    xd = [int(i) for i in input().split()] 
    #    x.
    func(n, d, x)
    
# main関数呼び出し
if __name__ == "__main__":
    main() 

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);i++)
#define REP(i,n) rep(i,0,n)
#define ll long long
#define ull unsigned long long
int main()
{
  ll N;
  cin >> N;
  if((N % 10 == 7) || (N / 100 == 7) || ((N / 10) % 10 == 7)) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
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;
}

int main() {
  ll N;
  cin >> N;
  vector<ll> T(N), A(N);
  rep(i, N) cin >> T[i] >> A[i];

  repp(i, 1, N - 1) {
    ll mul = max((T[i - 1] + T[i] - 1) / T[i], (A[i - 1] + A[i] - 1) / A[i]);
    T[i] *= mul;
    A[i] *= mul;
  }
  cout << T[N - 1] + A[N - 1] << endl;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a=list(map(int,input().split()))

def dividable_with_2(x):
  cnt=0
  while x%2==0:
    x//=2
    cnt+=1
  return cnt

eg=dividable_with_2(a[0])

for q in a:
  if dividable_with_2(q) != eg:
    print(0)
    exit()

def gcd(x,y):
  if y>x:
    y,x=x,y    
  while y!=0:
    x,y=y,x%y
  return x

def lcm(x,y):
  return x*y//gcd(x,y)

d=[i//2 for i in a]
L=d[0]
for i in range(n):
  L=lcm(L,d[i])

ans=(m//L+1)//2

print(ans)

  
  

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

int main()
{
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;

  cout << (char)(s1[0] - 0x20) << (char)(s2[0] - 0x20) << (char)(s3[0] - 0x20) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
const int N=2e5+5;
const int mod=1e9+7;
int a[N],b[N];

int main(){
    int n;
    cin>>n;
    for(int i=2;i<=n;i++){cin>>a[i];b[a[i]]++;}
    for(int i=1;i<=n;i++) cout<<b[i]<<endl;
return 0;
}


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

int main(void) {
  int H, W, A, B;

  //入力
  cin >> H >> W >> A >> B;

  int matrix[H][W];

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if ((i < B and j < A) or (i >= B and j >= A))
	matrix[i][j] = 1;
      else
	matrix[i][j] = 0;
    }
  }

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cout << matrix[i][j];
    }
    cout << endl;
  }
    
  return 0;

}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
const int maxN = 3e5 + 5;

int n, m;
int cntR[maxN], cntC[maxN];
vector<int> row[maxN], col[maxN];
set<pair<int, int>, greater<pair<int, int> > > seR, seC;

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

    int q;
    cin >> n >> m >> q;

    while(q--) {
        int x, y;   cin >> x >> y;

        row[x].push_back(y);
        col[y].push_back(x);

        cntR[x]++;
        cntC[y]++;
    }

    for(int i = 1; i <= n; i++) {
        seR.insert({cntR[i], i});
    }

    for(int i = 1; i <= m; i++) {
        seC.insert({cntC[i], i});
    }

    int ans = 0;
    for(int currentRow = 1; currentRow <= n; currentRow++) {
        for(int currentCol : row[currentRow]) {
            seC.erase({cntC[currentCol], currentCol});
            cntC[currentCol]--;
            seC.insert({cntC[currentCol], currentCol});
        }

        ans = max(ans, cntR[currentRow] + seC.begin()->first);

        for(int currentCol : row[currentRow]) {
            seC.erase({cntC[currentCol], currentCol});
            cntC[currentCol]++;
            seC.insert({cntC[currentCol], currentCol});
        }
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 66868
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder(sc.nextLine());
		int q = Integer.parseInt(sc.nextLine());
		for (int i = 0; i < q; ++i) {
			String o = sc.next();
			int a = sc.nextInt(), b = sc.nextInt();
			switch (o) {
			case "print":
				for (int j = a; j <= b; ++j) {
					System.out.print(sb.charAt(j));
				}
				System.out.println();
				break;
			case "reverse":
				StringBuilder rv = new StringBuilder(sb.substring(a, b + 1));
				rv.reverse();
				sb.replace(a, b + 1, rv.toString());
				break;
			case "replace":
				String p = sc.next();
				sb.replace(a, b + 1, p);
				break;
			}
		}
		sc.close();
	}
}


Measured memory_bytes: 30092
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

typedef pair< int, int > pii;
typedef long long ll;

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> N;
	vector< int > A(N);
	rep(i, N) cin >> A[i];
	int l = 0, r = 0;
	int ans = 0;
	int tmp = 0;
	while (l < N) {
		while (r < N && (tmp ^ A[r]) == tmp + A[r]) {
			tmp += A[r];
			r++;
			ans++;
		}
		tmp ^= A[l++];
		ans += r - l;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=2000010;
const ll mod=1e9+7;


int main(){
  string s;
  cin >> s;
  int n=s.size();
  string ans;
  rep(i,n){
    if(s[i]=='0') ans.push_back('0');
    if(s[i]=='1') ans.push_back('1');
    if(s[i]=='B' &&ans.size()!=0) ans.pop_back();
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
char x[300000+5];
int a[300000+5],b[300000+5];
int main()
{
    int n,i,sum;
    sum=0;
    scanf("%d%s",&n,&x[1]);
    for(i=1; i<=n; i++)
    {

        if(x[i]=='W')
        sum++;

        a[i]=sum;
         if(x[i]=='W')
        a[i]--;
    }
    sum=0;
    for(i=n; i>=1; i--)
    {

        if(x[i]=='E')
        sum++;

        b[i]=sum;
         if(x[i]=='E')
        b[i]--;
    }
        int minn=n;
        for(i=1;i<=n;i++)
                if(a[i]+b[i]<minn)
                minn=a[i]+b[i];

   /* for(i=1; i<=n; i++)
        printf("%d",a[i]);
    putchar('\n');
    for(i=1; i<=n; i++)
        printf("%d",b[i]);
    putchar('\n');*/
    printf("%d",minn);
    return 0;
}


Measured memory_bytes: 2816
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<iostream>

using namespace std;

int main()
{
	int h,a;
	scanf("%d%d",&h,&a);
	if(h%a==0)
	{
		printf("%d",h/a);
	}
	else  printf("%d",h/a+1);
	return 0;
} 

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


func nextLine() string {
    sc.Scan()
    return sc.Text()
}


func main() {
	c := nextLine()
	ans := ""
	if c == "a" || c == "i" || c == "u"|| c == "e"|| c == "o" {
		ans = "vowel"
	} else {
		ans = "consonant"
	}

	fmt.Println(ans)
}


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

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int a = Integer.parseInt(br.readLine());

		if (a % 2 != 0) {
			a = 2 * a;
		}

		System.out.println(a);

	}
}

Measured memory_bytes: 21204
#include <stdio.h>
#include <algorithm>
using namespace std;

int main()
{
	int w[10], k[10], ans1, ans2;
	
	for (int i = 0; i < 10; i++){
		scanf("%d", &w[i]);
	}
	for (int i = 0; i < 10; i++){
		scanf("%d", &k[i]);
	}
	
	sort(w, w+10);
	sort(k, k+10);
	
	ans1 =  w[9] + w[8] + w[7];
	ans2 =  k[9] + k[8] + k[7];
	
	
	printf("%d %d\n", ans1, ans2);
	
	return (0);
}

Measured memory_bytes: 1040
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

type Edge struct {
	to, cost int
}

// 辺のリストで表現されるグラフ
type Graph struct {
	Edges    [][]Edge // Edge[i][j]: 頂点iのj番目の辺
	Cost     [][3]int // 始点からの最小コスト
	RouteNum []int    // 始点から各頂点への最短経路数
}

// 頂点数nのリスト型グラフを返す
func NewGraph(n int) *Graph {
	g := &Graph{
		Edges:    make([][]Edge, n),
		Cost:     make([][3]int, n),
		RouteNum: make([]int, n),
	}
	for i := 0; i < n; i++ {
		g.Edges[i] = make([]Edge, 0)
		g.Cost[i] = [3]int{-1, -1, -1}
		g.RouteNum[i] = 0
	}
	return g
}

// 辺の追加
func (g *Graph) AddEdge(from, to, cost int) {
	g.Edges[from] = append(g.Edges[from], Edge{to, cost})
}

func bfs(g *Graph, s, t int) {
	que := make([][2]int, 0)
	g.Cost[s][0] = 0
	que = append(que, [2]int{s, 0})
	for len(que) > 0 {
		cur, parity := que[0][0], que[0][1]
		for _, e := range g.Edges[cur] {
			nextParity := (parity + 1) % 3
			if g.Cost[e.to][nextParity] == -1 {
				g.Cost[e.to][nextParity] = g.Cost[cur][parity] + 1
				que = append(que, [2]int{e.to, nextParity})
			}
		}
		que = que[1:]
	}
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n, m := nextInt(), nextInt()
	g := NewGraph(n)
	for i := 0; i < m; i++ {
		u, v := nextInt()-1, nextInt()-1
		g.AddEdge(u, v, 1)
	}
	s, t := nextInt()-1, nextInt()-1

	bfs(g, s, t)

	if g.Cost[t][0] == -1 {
		puts(-1)
	} else {
		puts(g.Cost[t][0] / 3)
	}
}


Measured memory_bytes: 16512
n,d=map(int,input().split())
x=[]
cnt=0
for i in range(n):
  tmp=list(map(int,input().split()))
  x.append(tmp)
for i in range(n-1):
  for j in range(i+1,n):
    tmp=0
    for k in range(d):
      tmp+=(abs(x[i][k]-x[j][k]))**2
    if tmp**0.5==int(tmp**0.5):
      cnt+=1
print(cnt)

Measured memory_bytes: 62596
function main(arg) {
  const lines = arg.trim().split('\n');
  const N = Number(lines[0]);
  const H = lines[1].split(' ').map(Number);
  let ans = 1;
  let maxHeight = H[0];
  for (const hi of H.slice(1)) {
    if (hi >= maxHeight) ans++;
    maxHeight = Math.max(hi, maxHeight);
  }
  console.log(ans);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

using namespace std;

typedef long long ll;

struct UnionFind {
    vector<int> par; // par[i]:i�̐e�̔ԍ��@(��) par[3] = 2 : 3�̐e��2

    UnionFind(int N) : par(N) { //�ŏ��͑S�Ă����ł���Ƃ��ď�����
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // �f�[�^x��������؂̍����ċA�œ���Froot(x) = {x�̖؂̍�}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // x��y�̖؂𕹍�
        int rx = root(x); //x�̍���rx
        int ry = root(y); //y�̍���ry
        if (rx == ry) return; //x��y�̍�������(=�����؂ɂ���)���͂��̂܂�
        par[rx] = ry; //x��y�̍��������łȂ�(=�����؂ɂȂ�)���Fx�̍�rx��y�̍�ry�ɂ���
    }

    bool same(int x, int y) { // 2�̃f�[�^x, y��������؂������Ȃ�true��Ԃ�
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(int, char**)
{
	ll n, m, ans = 0;
	cin >> n >> m;

	ans = n;
    UnionFind al(n);
	for(ll i = 0; i < m; ++i) {
		int x, y, z;
		cin >> x >> y >> z;
		--x; --y;

		if (al.root(x) != al.root(y))
			ans--;

		al.unite(x, y);
	}

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


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <limits.h>
int main()
{
	long n,l;
	std::vector<long> tp;
	std::cin >> n;
	long min = LONG_MAX;
	for (int i = 0; i < 5; i++)
	{
		std::cin >> l;
		tp.push_back(l);
		if (min > l)
		{
			min = l;
		}
	}
	long big_time = 0;
	if (n % min != 0)
	{
		big_time = (n / min) + 1;
	}
	else
	{
		big_time = n / min;
	}
	long result = big_time + 4;
	std::cout << result << "\n";
    return 0;
}



Measured memory_bytes: 256
/* Manish Pant - insider_pants */

#include <bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#include "debug.h"
#endif

#define F first
#define S second
#define endl "\n"
#define pb push_back
typedef long long ll;
typedef long double ldob;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

const int INF = 1e9 + 9;

int main()
{
    fast();
    ll n, m, k;
    cin >> n >> m >> k;
    vector<ll> a(n), b(m);
    for(auto &i : a)
        cin >> i;

    for(auto &i : b)
        cin >> i;

    for(int i = 1; i < m; i++)
        b[i] += b[i - 1];

    ll ans = upper_bound(b.begin(), b.end(), k) - b.begin();
    for(int i = 0; i < n; i++)
    {
        k -= a[i];
        if(k < 0)
            break;
        ll temp = upper_bound(b.begin(), b.end(), k) - b.begin();
        temp += i + 1;
        ans = max(ans, temp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6352
N,M = map(int,input().split())
AB = [list(map(int,input().split())) for _ in [0]*M]

E = [[] for _ in [0]*N]
for a,b in AB:
    a -= 1
    b -= 1
    E[a].append(b)
    E[b].append(a)

def dist_bfs(N,E,start):
    d = [-1]*N
    d[start] = 0
    q = [start]
    while q:
        qq = []
        for i in q:
            di = d[i]
            for j in E[i]:
                if d[j]!=-1:continue
                d[j] = di+1
                q.append(j)
        q = qq
    return d

d = dist_bfs(N,E,0)

ans = [None]*N

for i in range(1,N):
    di = d[i]
    for j in E[i]:
        if d[j] == di-1:
            ans[i] = j+1
            break
print("Yes")
for out in ans[1:]:
    print(out)

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

int nexts(int n,int max,int t[]){
	for(int i=max+1;i<=n*2;i++){
		if(t[i]) return i;
	}
	return -1;
}

int main(void){
	int n;
	
	while(cin>>n && n){
		int taro[2*n+1], hanako[2*n+1];
		fill(taro,taro+2*n+1,0);

		for(int i=0;i<n;i++){
			int x;
			cin>>x;
			taro[x] = 1;
		}
		
		for(int i=1;i<=2*n;i++){
			hanako[i] = !taro[i];
		}

		int taroRem=n, hanakoRem=n;
		int max = 0;
		int turn = 0; //0:taro 1:hanako
		while(taroRem!=0 && hanakoRem!=0){
			int nextCard = nexts(n,max,turn?hanako:taro);
			if(nextCard == -1){
				max = 0;
			}
			else{
				max = nextCard;
				if(turn){
					hanako[nextCard] = 0;
					hanakoRem--;
				}
				else{
					taro[nextCard] = 0;
					taroRem--;
				}
			}
			turn = !turn;
		}
		
		cout<<hanakoRem<<endl;
		cout<<taroRem<<endl;
	}
	
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

ll mod_pow(ll a,ll n){
  ll res=1;
  while(n>0){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll fac[100010],finv[100010];

ll comb(ll n,ll r){
  if(n<0||r<0||n<r)return 0;
  return (fac[n]*finv[r]%mod)*finv[n-r]%mod;
}

ll n,m;
ll a[22];
ll dp[20][1<<16];

int main(){
  fac[0]=1;
  rep(i,100000)fac[i+1]=fac[i]*(i+1)%mod;
  rep(i,100001)finv[i]=mod_pow(fac[i],mod-2);

  cin>>n>>m;
  ll tot=1<<n;
  rep(i,m)cin>>a[i];
  sort(a,a+m);
  reverse(a,a+m);
  dp[0][0]=1;
  rep(i,m){
    rep(S,1<<n){
      ll sz=0;
      rep(j,n)if((S>>j)&1)sz+=(1<<j);
      rep(j,n){
        if((S>>j)&1)continue;
        (dp[i+1][S|(1<<j)]+=((dp[i][S]*comb(tot-a[i]-sz,(1<<j)-1))%mod)*fac[(1<<j)]%mod)%=mod;
      }
      (dp[i+1][S]+=dp[i][S])%=mod;
    }
  }
  ll res=0;
  rep(S,1<<n){
    ll sgn=(bcnt(S)%2==0?+1:-1);
    ll sz=0;
    rep(i,n){
      if((S>>i)&1)continue;
      sz+=(1<<i);
    }
    (dp[m][S]*=fac[sz])%=mod;
    (res+=sgn*dp[m][S]+mod)%=mod;
  }
  cout<<res*mod_pow(2,n)%mod<<endl;
  return 0;
}


Measured memory_bytes: 11520