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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

const ll mod = 1000000007;

static const ll INF = 1e15;

int main(void)	
{
	ll grid[3][3];
	bool ok[3][3];
	rep(i, 3) rep(j, 3) cin >> grid[i][j];
	rep(i, 3) rep(j, 3) ok[i][j] = false;
	ll n;
	cin >> n;
	rep(a, n) {
		ll b;
		cin >> b;
		rep(i, 3) rep(j, 3) {
			if (grid[i][j] == b) ok[i][j] = true;
		}
	}
	bool bingo = false;
	rep(i, 3)
	{
		bool o = true;
		rep(j, 3) {
			if (!ok[i][j]) o = false;
		}
		if (o) {
			bingo = true;
		}
	}
	rep(j, 3)
	{
		bool o = true;
		rep(i, 3) {
			if (!ok[i][j]) o = false;
		}
		if (o) {
			bingo = true;
		}
	}
	{
		if (ok[0][0] && ok[1][1] && ok[2][2]) bingo = true;
		if (ok[2][0] && ok[1][1] && ok[0][2]) bingo = true;
	}
	if (bingo) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
map<int,int>ma;
#define ss second
#define ff first
typedef pair<int,int>pii;

char s[100010];
int main() {
	scanf("%s",s+1);
	int len=strlen(s+1),p=0,ans=0;
	for(int i=1; i<=len; i++)
		if(s[i]=='0') {
			if(p<0)ans+=2;
			p++;
		} else {
			if(p>0)ans+=2;
			p--;
		}
	printf("%d\n",ans);
}

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

int main() {
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;

    bool ok = false;
    for (int i = 0; i < n; i++) {
        long long mi1 = 1ll * c * i, ma1 = 1ll * d * i;
        long long mi2 = 1ll * c * (n - 1 - i), ma2 = 1ll * d * (n - 1 - i);
        long long ma = ma2 - mi1;
        long long mi = mi2 - ma1;
        if (mi <= b - a && b - a <= ma) ok = true;
        
    }
    cout << (ok ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int C = sc.nextInt();
        int B[] = new int[M];
        for(int i = 0; i < M; i++){
            B[i] = sc.nextInt();
        }

        int res = 0;
        for(int i = 0; i < N; i++){
            int tmp = 0;
            for(int j = 0; j < M; j++){
               int src = sc.nextInt();
               tmp += src * B[j];
            }
            if((tmp + C) > 0){
               res++;
            }
        }

        System.out.println(res);
    }

}

Measured memory_bytes: 22996
//2017-10-10
//miaomiao
//
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>

using namespace std;

#define For(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define N (200+5)

int len[N];

int main(){
	int n;

	scanf("%d", &n); n <<= 1;
	For(i, 1, n) scanf("%d", &len[i]);

	sort(len+1, len+n+1);
	
	int ans = 0;
	For(i, 1, n) ans += (i&1)? len[i]: 0;
	
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}


int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	if(n%100 ==0 || n%100>12)
	{
		n/=100;
		if(n%100 == 0||n%100>12)
			cout<<"NA";
		else
			cout<<"MMYY";
	}
	else{
		n/=100;
		if(n%100==0||n%100>12){
			cout<<"YYMM";
		}
		else cout<<"AMBIGUOUS";
	}
	return 0;
}

Measured memory_bytes: 3652
n = int(input())
lis = list(map(int,input().split()))
m = 0
b = True
while(b):
  for index,l in enumerate(lis):
    if l % 2 == 1:
      b = False
      m -= 1
      break
    else:
      lis[index] = l / 2
  m += 1
print(m)


Measured memory_bytes: 2940
#include<iostream>
#include<cmath>
#include<set>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(ui,n)  REP(i,0,n)
#define double long double
const double r = 1./sqrt(3);
const double pi=acos(-1);
const double eps = 1e-10;

double CONVERT(double r){
  return r*pi/180.;
}

double solve(int n,double theta){
  double npolygon=0,minus=0;
  double l =2*r*sin(CONVERT(theta/2));
  npolygon=n*r*r*cos(CONVERT(theta/2))*sin(CONVERT(theta/2));
  minus=n*l*tan(CONVERT(60-theta/2))*l/4.;
  return npolygon-minus;
}

double calc(double a){
  while(a > 360-eps)a-=360;
  return a;
}

main(){
  int n;
  while(cin>>n && n){
    double now=0;
    set<double> S;
    rep(i,n){
      S.insert(calc(now));
      S.insert(calc(now+120));
      S.insert(calc(now+240));
      now+=360./n;
    }
    //printf("%.6lf\n",solve((int)S.size(),360./S.size()));

    if (n%3 == 0){
      //if (S.size()%3 != 0)cout <<"h"<<endl,exit(1);
      printf("%.6Lf\n",solve((int)n,360./n));
    }else {
      printf("%.6Lf\n",solve((int)3*n,120./n));      
    }
  }
  return false;
}

Measured memory_bytes: 1044
#include<bits/stdc++.h>
using namespace std;
main(){int h,w,d,q,a,l,r,i,j,sum[90001]={};map<int,pair<int,int>>v;cin>>h>>w>>d;for(i=0;i<h;i++)for(j=0;j<w;j++)cin>>a,v[a]=make_pair(i,j);for(i=d+1;i<=h*w;i++)sum[i]=sum[i-d]+abs(v[i].first-v[i-d].first)+abs(v[i].second-v[i-d].second);cin>>q;while(q--)cin>>l>>r,cout<<sum[r]-sum[l]<<'\n';}


Measured memory_bytes: 7040
package main

import "fmt"

func main() {
	var n, d, x int
	fmt.Scan(&n)
	fmt.Scan(&d)
	fmt.Scan(&x)

	a := make([]int, n, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}

	choco := 0
	for i := 1; i <= d; i++ {
		for j := 0; j < n; j++ {
			eat := false
			if i == 1 {
				eat = true
			} else if (i-1)%a[j] == 0 {
				eat = true
			}
			if eat {
				choco = choco + 1
			}
		}
	}
	choco = choco + x

	fmt.Printf("%d\n", choco)
}


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

using namespace std;
const int inf = 1e9+7;

int main()
{
    int n,t;
    while(~scanf("%d%d",&n,&t)){
        int ans = 0,last = -inf;
        for(int i=0;i<n;++i){
            int u; scanf("%d",&u);
            if(u > last + t) ans += t;
            else ans += u - last;
            last = u;
        }
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <stack>
#include <bitset>
#define maxn 100009
using namespace std;
const int MOD=1e9+7;
int p[maxn];
long long bin[maxn];
int findset(int x)
{
	return x==p[x]?x:p[x]=findset(p[x]);
}
void unionset(int x,int y)
{
	 p[findset(x)]=findset(y);
}
int main()
{
	int n,m,x,y;
	bin[0]=1;
	for(int i=1;i<maxn;i++)
		bin[i]=2*bin[i-1]%MOD;
	while(scanf("%d%d",&n,&m)!=EOF&&n+m)
	{
		for(int i=0;i<=n;i++)
			p[i]=i;
		for(int i=0;i<m;i++)
		{
			scanf("%d%d",&x,&y);
			unionset(x,y);
		}
		int cnt=0;
		for(int i=1;i<=n;i++)
		{
			if(p[i]==i)
			{
				cnt++;
			}
		}
		int ans=bin[cnt];
		if(cnt!=n)
			ans=(ans+1)%MOD;
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 2360
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

int a[1000001];
int f[1000001];
int n;
ll k;
bool fillable(ll val){
    vector<double> thresh(n);
    //dump(val)
    for(int i=0;i<n;++i)
    {
        thresh[i] = val * 1.0 / f[i];
        //dump(thresh[i])
    }
    sort(thresh.begin(), thresh.end());
    double diff = 0;
    for(int i=0;i<n;++i)
    {
        diff += max(0.0, ceil(a[i] - thresh[i]));
        //dump(diff)
    }
    return diff <= k;
}

int main(){
    std::ios::sync_with_stdio(false);
    ll l = -1;
    ll r = 1000000000001ll;
    cin >> n >> k;
    for(int i=0;i<n;++i) cin >> a[i];
    for(int i=0;i<n;++i) cin >> f[i];
    sort(a, a + n);
    while((r-l) > 1)
    {
        ll mid = (l + r) / 2;
        if(fillable(mid))
        {
            r = mid;
        } else {
            l = mid;
        }
    }
    cout << r << endl;
}

Measured memory_bytes: 6756
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    string s; cin >> s;
    int n = SZ(s);
    vector<vector<ll>> dp(n + 10, vector<ll>(15, 0ll));
    for (int i = 0; i < 10; i++) {
        dp[0][i] = (s[0] == '?' || (s[0] - '0') == i);
    }
    const ll mod = (ll) 1e9 + 7;
    for (int i = 1; i < n; i++) {
        if (s[i] == '?') {
            for (int j = 0; j < 13; j++) {
                for (int k = 0; k < 10; k++) {
                    dp[i][(10 * j + k) % 13] += dp[i - 1][j];
                    dp[i][(10 * j + k) % 13] %= mod;
                }
            }
        } else {
            for (int j = 0; j < 13; j++) {
                int k = s[i] - '0';
                dp[i][(10 * j + k) % 13] += dp[i - 1][j];
                dp[i][(10 * j + k) % 13] %= mod;
            }
        }
    }
    cout << dp[n - 1][5] << "\n";
}


Measured memory_bytes: 15184
#include<bits/stdc++.h>
using namespace std;
int main(){
    int arr[5]={};
    for(int i=0;i<5;i++){
        cin>>arr[i];
    }
    for(int i=0;i<5;i++){
        if(arr[i]==0){
            cout<<i+1<<'\n';
            break;
        }
    }




return 0;
}


//      *   *  *****  *   *  *   *   ****  ****    ****     **  ***
//     *   *  *      **  *  *   *  *      *   *  *        * *  *  *
//    *****  *****  * * *  *   *  *      ****   *       *  *    *
//   *   *      *  *  **  *   *  *      *  *   *       *****  *
//  *   *  *****  *   *   ***    ****  *   *    ****     *   ****

//     ****  *   *  *   *   ***   *   *  *****  *   *
//    *     *   *  *   *  *   *  *   *  *      *   *
//    ***  *****  *   *  *****  * * *  ****   *   *
//      *   *    *   *  *   *  * * *  *      *   *
//  ****   *     ***   *   *   * *   *****   ***


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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++ i)
#define ALL(r) r.begin(), r.end()
#define DUP(x, y) (((x) + (y) - 1) / (y))
#define YES puts("YES")
#define NO puts("NO")
#define Yes puts("Yes")
#define No puts("No")

using ll = std::int64_t;
using vint = std::vector<int>;
using vll = std::vector<ll>;
using pint = std::pair<int, int>;

constexpr std::int32_t INF = 1001001001;

void Main() {
    int n, t, a;
    cin >> n >> t >> a;
    vint h(n);
    rep(i, n)cin >> h[i];
    int ans = 0;
    double val = INF;
    rep(i, n) {
        double b = t - h[i] * 0.006;
        if (abs(a - b) < val) {
            ans = i + 1;
            val = abs(a - b);
        }
    }
    cout << ans << endl;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}



Measured memory_bytes: 256
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
const ll MOD = 1e9+7;
// https://qiita.com/asksaito/items/76b71602dd956b79dbf7
bool IsPrime(int num)
{
   if (num < 2) return false;
   else if (num == 2) return true;
   else if (num % 2 == 0) return false; // 偶数はあらかじめ除く
 
   double sqrtNum = sqrt(num);
   for (int i = 3; i <= sqrtNum; i += 2)
   {
       if (num % i == 0)
       {
           // 素数ではない
           return false;
       }
   }
 
   // 素数である
   return true;
}
int main(){
    ll n;
    std::cin >> n;
    map<ll,ll> sosu;
 
    for (int i = 2; i <= 1000; i++) {
        if(!IsPrime(i))continue;
        ll how = 1;
        while( n/(ll)pow(i,how)>0 ){
            // std::cout << n/(ll)pow(i,how)<< std::endl;
            sosu[i]+= n/(ll)pow(i,how);
            how++;
        }
    }
    ll result = 1;
    for (auto e : sosu) {
        // std::cout << e.first <<" "<<e.second << std::endl;
        result %= MOD;
        result *= (e.second+1)%MOD;
    }
    std::cout << result%MOD<< std::endl;
    
}

Measured memory_bytes: 640
N=int(input())
AB=list(sorted([list(map(int, input().split())) for _ in range(N)], key=lambda x: x[1]))

r=0
for i in range(N):
    d=AB[i][1]
    r+=AB[i][0]
    if r>d:
        print('No')
        exit(0)
print('Yes')



Measured memory_bytes: 55264
#include <iostream>

using namespace std;

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

    bool res = false;
    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            if (i * j == n) {
                res = true;
            }
        }
    }

    cout << (res ? "Yes" : "No") << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
#define NFOR(i,a,b) for(int i = (int)(a); i >= (int)(b); --i)
#define endl "\n"
#define mp make_pair
#define X first
#define Y second
#define inf 1e9
#define mod 1000000007
#define mod1 998244353
#define pb push_back
#define Case cout<<"Case #"<<++cas<<": ";
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(v) v.begin(),v.end()
#define sz(x) int(x.size())
// #define lli int
typedef long long int lli;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef pair<lli,lli> pll;
typedef vector<lli> vl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef complex <long double> complex_t;
const long double PI = acos((long double)-1.0);

#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}

vector<pair<pii,int >> edges;
int arr[310][310];
int parent1[310];
int child1[310];
ll distMat[310][310];

int getParent(int u) {
    while ( u != parent1[u]) u = parent1[u];
    return u;
}

bool union1(int u, int v) {
    u = getParent(u), v = getParent(v);
    if ( u == v) return false;
    if (child1[u] > child1[v]) {
        child1[u] += child1[v], parent1[v] = parent1[u];
    } else {
        child1[v] += child1[u], parent1[u] = parent1[v];
    }
    return true;
}

int main() {
    int n;
    cin >> n;
    FOR(i, 1, n) {
        FOR(j, 1, n) {
            int temp; cin >> temp;
            arr[i][j] = temp;
        }
    }
    ll totalAnswer = 0;
    bool poss = true;
    FOR(i, 1, n) {
        FOR(j, 1, n) {
            bool counter = true;
            FOR(k, 1, n) {
                if (arr[i][j] > arr[i][k] + arr[k][j] && k!= i && k != j && i != j) {
                    poss = false;
                    // pr(arr[i][j], arr[i][k], arr[k][j], i, j, k);
                }
                if (arr[i][j] == arr[i][k] + arr[k][j] && k != i && k != j) counter = false;
            }
            if (counter) totalAnswer += (ll)arr[i][j];
        }
    }
    if (!poss) {
        cout << "-1\n";
    } else {
        cout << totalAnswer/2 << endl;
    }
return 0;}


Measured memory_bytes: 640
import java.util.Scanner;
public class Main{
 
	public static void main(String[] args) {
 
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
      	int k = sc.nextInt();
      
      	int s = sc.nextInt();
      	int p = sc.nextInt();
      	int r = sc.nextInt();
      
      String jan = sc.next();
      int[] check = new int[100000];
      
      int sum = 0;
      
      for(int i = 0;i<n;i++){
        if(i>=k)
        {
          if(jan.charAt(i)==jan.charAt(i-k)&&check[i-k]!=2){
            check[i]=2;
            continue;
          }
        }
        
        if(jan.charAt(i)=='p')
          sum+=p;
        else if(jan.charAt(i)=='r')
          sum+=r;
        else
          sum+=s;
        
      }
      

      System.out.println(sum);
 

 
      
 
 
 
      
      
 
 
 
		
		
	}
 
}

Measured memory_bytes: 27680
N, x = map(int, input().split())
a = list(map(int, input().split()))

m = min(a)
ans = 0
if a[0] > x:
    ans += a[0] - x
    a[0] = x
for i in range(1, N):
    if a[i] + a[i-1] > x:
        tmp = x - a[i - 1]
        ans += a[i] - tmp
        a[i] = tmp

print(ans)


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

int main() {
  int N, D, result = 0;
  double x, y, d;
  cin >> N >> D;
  for (int i = 0; i < N; i++) {
    cin >> x >> y;
    double d = sqrt(x*x + y*y);
    if (d <= D) result++;
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3840
import copy

N, M = [int(_) for _ in input().split()]

k_lis = []

for m in range(M):
  sw =  [int(_) - 1 for _ in input().split()][1:]

  k_lis.append(sw)

p_lis = [int(_) for _ in input().split()]

on_off = [[0], [1]]
tmp = []

for j in range(N-1):
  for t in on_off:
    tmp.append(t + [0])
    tmp.append(t + [1])
  on_off = tmp
  tmp = []

solved = 0
  
for t in on_off:
  flag = True
  for m in range(M):
    total = 0
    for k in k_lis[m]:
      total += t[k]
    if not total % 2 == p_lis[m]:
      flag = False
      break
  if flag:
    solved += 1
      
print(solved)

Measured memory_bytes: 3700
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();

        int num = check(A,B)+check(B,C)+check(C,A);

        if(num == 0 || num == 3) {
            System.out.println("No");
        }
        if(num == 1) {
            System.out.println("Yes");
        }
        sc.close();
    }
    public static int check(int a, int b) {
        if(a == b) {
            return 1;
        } else {
            return 0;
        }
    }

}


Measured memory_bytes: 35736
// 2013/06/20 Tazoe

#include <iostream>
#include <string>
#include <stack>
using namespace std;

int main()
{
	while(true){
		string S;
		getline(cin, S);

		if(S==".")
			break;

		stack<char> stk;

		bool flg = true;
		for(int i=0; i<S.size(); i++){
			if(S[i]=='('||S[i]=='['){
				stk.push(S[i]);
			}
			else if(S[i]==')'){
				if(!stk.empty()&&stk.top()=='('){
					stk.pop();
				}
				else{
					flg = false;
				}
			}
			else if(S[i]==']'){
				if(!stk.empty()&&stk.top()=='['){
					stk.pop();
				}
				else{
					flg = false;
				}
			}

			if(!flg)
				break;
		}

		if(flg&&stk.empty()){
			cout << "yes" << endl;
		}
		else{
			cout << "no" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1180
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,p;
  cin>>n>>p;
  int o=0;
  int e=0;
  for(int _=0;_<n;_++){
    int a;
    cin>>a;
    if(a%2==1)
      o++;
    else
      e++;
  }
  vector<vector<int64_t>> c(o+1,vector<int64_t>(o+1,1));
  for(int i=1;i<=o;i++)
    for(int j=1;j<i;j++)
      c[i][j]=c[i-1][j-1]+c[i-1][j];
  int64_t s=0;
  for(int i=0;i<=o;i++)
    s+=(i%2==p?c[o][i]:0);
  for(int i=0;i<e;i++)
    s*=2;
  cout<<s<<endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    int d,l; cin >> d >> l;
    int ans = 0;
    while(d >= l){
        ans++;
        d-=l;
    }
    cout << ans + d << endl;
}





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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const long long MOD = 1000000007LL;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

    int a, b;
    cin >> a >> b;

    if(a < 6){
        cout << 0 << endl;
    }else if(a < 13){
        cout << b / 2 << endl;
    }else{
        cout << b << endl;
    }

    return 0;
}

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

int main() {
  char word[11];
  char current[20];

  scanf("%s", &word);

  int n = 0, i, wordNum = 0;

  while (1) {
    scanf("%s", &current);

    if (!strcmp(current, "END_OF_TEXT"))
      break;

    for (i = 0; i < strlen(word); i++) {
      if (word[i] != current[i] && word[i] + 32 != current[i] && word[i] - 32 != current[i])
        break;
      if (i == strlen(word) - 1 && strlen(word) == strlen(current)) {
        n++;
      }
    }
    wordNum++;
  }

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

  return 0;
}



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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;


int main() {
    int n, a, b; cin >> n >> a >> b;
    int c = 0, d = 0, e = 0;
    for(int i = 0; i < n; i++){
        int x; cin >> x;
        if(x <= a) c++;
        if(a < x && x <= b) d++;
        if(b < x) e++;
    }
    cout << min({c, d, e}) << endl;
    return 0;
}


Measured memory_bytes: 3568
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <ctime>
#include <vector>
#include <set>
#include <queue>
using namespace std;
typedef long long ll;

#define PI 3.14159265358979323846264338327950L

ll res;

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

    ll N,Q,sum;
    sum = 0;
    cin >> N;
    vector<ll> A(N);
    vector<ll> count(100000, 0);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        sum += A[i];
        count[A[i] - 1]++;
    }
    cin >> Q;
    vector<pair<ll, ll>> BC(Q);
    for (int i = 0; i < Q; i++)
    {
        cin >> BC[i].first >> BC[i].second;
    }
    for(int i = 0; i < Q; i++ )
    {
        sum += count[BC[i].first - 1] * (BC[i].second - BC[i].first);
        count[BC[i].second - 1] += count[BC[i].first - 1];
        count[BC[i].first - 1] = 0;
        cout << sum << endl;
    }
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define step(i,s,n,c) for(int i=(s);i<(n);i+=(c))
#define REP(i,s,n) for(int i=(s);i<(n);++i)
#define each(i,vec) for(auto i:vec)
#define cinv(n,vec) VL vec(n);for(auto&v:vec)cin>>v;
#define int long long
#define itn int
#define pb push_back
#define eb emplace_back
#define m_p make_pair
#define m_t make_tuple
#define p_p(a,b) pb(m_p(a,b))
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a),greater<>())
#define UNIQUE(a) a.erase(unique(all(a)),a.end())
#define SZ(a) (signed)(a.size())
#define debg(a) cout<<#a<<" "<<a<<endl;
#define debgp(a) cout<<#a<<" "<<a.fi<<" : "<<a.se<<endl
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define callp(a) for(auto [k,v]:a)cout<<k<<":"<<v<<endl
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define out(a) cout<<(a)<<endl
#define ENDL cout<<endl
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define fi first
#define se second
#define V vector
#define P pair
#define T tuple
#define PQ priority_queue
#define cont const auto
#define VV(type,name,y,x,a) vector<vector<type>> name = vector<vector<type>>(y,vector<type>(x,a))
typedef long long ll;
typedef double D;
typedef long double LD;
typedef string str;
typedef vector<ll> VL;
typedef pair<ll,ll> PL;
typedef vector<pair<ll,ll>> VP;
typedef tuple<ll,ll,ll> T3;
typedef tuple<ll,ll,ll,ll> T4;
const signed INF = (1LL<<30);
const long long MOD = (1e9+7);
const long long LINF = (1LL<<60);
const long long LMAX = LLONG_MAX;
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

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

  int n;
  cin>>n;
  set<ll>a;
  rep(i,n){
    int A;cin>>A;
    a.insert(A);
  }
  ll dif=n-SZ(a);
  if(dif&1)dif++;
  out(n-dif);
  
  
  
  
  return 0;
}

Measured memory_bytes: 4992
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
char s[200005],t[200005];
int main(){
	scanf("%s",s+1);
	scanf("%s",t+1);
	int d=0;
	for(int i=1;i<=200005;i++){
		if(s[i]==0) break;
		if(s[i]!=t[i]){
			d++;
		}
	}
	printf("%d",d);
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    n %=10;
    int ansn = 0;
    unordered_set<int> s[3];
    s[0] = {2,4,5,7,9};
    s[1] = {0,1,6,8};
    s[2] = {3};
    rep(i,3){
        auto it = s[i].find(n);
        if(it != s[i].end()){
            ansn = i;
        }
    }
    if(ansn == 0){
        cout << "hon";
    }else if(ansn == 1){
        cout << "pon";
    }else if(ansn == 2){
        cout << "bon";
    }
    cout << endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/

string S;
string weather[3] = {"Sunny", "Cloudy", "Rainy"};
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> S;
    rep(i, 0, 3) if(S == weather[i]) {
        string ans = weather[(i + 1) % 3];
        cout << ans << endl;
        return;
    }
}

Measured memory_bytes: 256
#include <cstdio>

const int N = 200000 + 10;

int n, a[N], cnt[N];
int ans;

int tag[N];

void add(int x) {
  int z = x - cnt[x]++;
  if (z > 0) ans += !tag[z]++;
}

void del(int x) {
  int z = x - --cnt[x];
  if (z > 0) ans -= --tag[z] == 0;
}

int main() {
  int m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]), add(a[i]);
  while (m--) {
    int x, y;
    scanf("%d%d", &x, &y);
    del(a[x]);
    add(a[x] = y);
    printf("%d\n", n - ans);
  }
  return 0;
}


Measured memory_bytes: 3712
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
edge=[[] for i in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  edge[a-1].append(b-1)
  edge[b-1].append(a-1)
Chk=[0]*n
Odd=False
T=[0]
Chk[0]=1
while T:
  t=T.pop()
  for g in edge[t]:
    if not Chk[g]:
      Chk[g]=Chk[t]*(-1)
      T.append(g)
    elif Chk[g]*Chk[t]==1:
      Odd=True
if Odd:
  print(n*(n-1)//2-m)
else:
  c=Chk.count(1)
  print(c*(n-c)-m)




Measured memory_bytes: 22064
#include <iostream>
using namespace std;
int main()
{
    int N;
    cin >> N;
    long long int x,y,z;
    x = 2; 
    y = 1; 
    if(N==0)
    {
      cout << x << endl;
      return 0; 
    }
    else if(N==1)
    {
      cout << y << endl;
      return 0; 
    }
    else
    {
    	for(int i=0; i<N-1; i++)
        {
           z = x + y;
           x = y;
           y = z;
    }
    }
    cout << z << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

struct RMQ {
	int n;
	vector<ll> dat;

	RMQ(int n_) {
		n = 1;
		while(n < n_) n *= 2;

		dat.resize(n*4);
		rep(i,n*4) dat[i] = INF;
	}

	void update(int k,ll a) {
		int i = k+n-1;
		dat[i] = a;

		while(i > 0) {
			i = (i-1) / 2;
			dat[i] = min(dat[i*2+1],dat[i*2+2]);
		}
	}

	//[a,b)
	//query(a,b,0,0,n)
	ll _query(int a,int b,int k,int l,int r) {
		if(r <= a || b <= l) return INF;

		if(a <= l && r <= b) return dat[k];
		else { 
			ll vl = _query(a,b,k*2+1,l,(l+r)/2);
			ll vr = _query(a,b,k*2+2,(l+r)/2,r);
			return min(vl,vr);
		}
	}

	//[a,b)
	ll query(int a,int b) {
		return _query(a,b,0,0,n);
	}
};

ll dp[1005][1005], d[1005][1005];

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

	vector<ll> D(n), C(m);
	rep(i, n) cin >> D[i];
	rep(i, m) cin >> C[i];

	rep(i, n) {
		rep(j, m) dp[i][j] = INF;
	}

	rep(i, n) {
		rep(j, m) d[i][j] = D[i] * C[j];
	}

	rep(j, m) dp[0][j] = D[0] * C[j];

	REP(i, 1, n) {
		RMQ rmq(m);
		rep(j, m) rmq.update(j, dp[i-1][j]);

		rep(j, m) {
			dp[i][j] = rmq.query(0, j) + d[i][j];
		}
	}

	ll ans = INF;
	rep(j, m) {
		ans = min(ans, dp[n-1][j]);
	}

	cout << ans << endl;

	return 0;
}

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

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

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
int main(){
 ll n;
 cin>>n;
 V<ll> p(n);
 for(int i=0;i<n;i++){
     cin>>p[i];
     p[i]--;
 }
V<ll> b(n);
for(ll i=0;i<n;i++){
    b[i]=(n-i)*40000;
}
for(ll i=0;i<n;i++){
    b[p[i]]+=(i+1);
}
for(ll i=0;i<n;i++)cout<<40000*(i+1)<<" ";
cout<<"\n";
for(int i=0;i<n;i++)cout<<b[i]<<" ";
cout<<"\n";
}


Measured memory_bytes: 3660
#include <iostream>
#include <cstdio>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <vector>
#define REP(i,n) for(int i=0;i<n;i++)
#define CONS 1000000007
using namespace std;

int powmp(long long x,long long n){
	const long long p = 1000000007;
	if(n==0) return 1;
	long long y = x%p;
	if(n==1) return y;
	long long tmp = (powmp(y,n/2))%p;
	if(n%2==0) return (tmp*tmp)%p;
	else return (powmp(y,n-1)*y)%p;
}

int main(int argc, char const *argv[])
{
	int n,d;
	cin >> n;
	long long p[n+2];
	long long pinv[n+2];
	p[0] = 1;
	pinv[0] = 1;
	int a[n+1];
	fill(a,a+n+1,-1);
	REP(i,n+1) {
		int b;
		cin >> b;
		if(a[b]==-1) a[b] = i;
		else {
			d = i - a[b] + 1;
		}
	}
	for(int i=1;i<n+2;i++){
		p[i] = (p[i-1]*i)%CONS;
	}
	pinv[n+1] = powmp(p[n+1],CONS - 2);
	for(int i=n;i>0;i--){
		pinv[i] = ((i+1)*pinv[i+1])%CONS;
	}
	for(int l=1;l<=n+1;l++){
		if(l==1) cout << n << "\n";
		else if(l==n+1) cout << 1 << "\n";
		else if(n+1-d<l-1) cout << (((p[n+1]*pinv[n+1-l])%CONS)*pinv[l])%CONS << "\n";
		else cout << (((((p[n+1]*pinv[n+1-l])%CONS)*pinv[l])%CONS)+CONS - (((p[n+1-d]*pinv[n+1-d-l+1])%CONS)*pinv[l-1])%CONS)%CONS << "\n";
	}
	return 0;
}	

Measured memory_bytes: 3200
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    LL n,m;
    cin >> n >> m;
    VP p(n);
    REP(i,0,n) cin >> p[i].first >> p[i].second;
    sort(all(p));
    priority_queue<int> q;
    int index = 0;
    LL ans = 0;
    REP(i,1,m+1) {
        for (;index < n && p[index].first == i;++index) q.push(p[index].second);
        if (q.empty()) continue;
        ans += q.top();
        q.pop();
    }
    cout << ans << endl;
}

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

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

using namespace std;

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

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

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define LINF		((ll)1 << 63 -1)
#define INF 		(1<<29)
#define MINF		-2000000007
#define MAX 		205

const int MOD = 1e9+7;
// テンプレ終了
//====================================================================//


//
int main(){
	int N;cin>>N;
	vector<int> A(N);REP(i,N)cin>>A[i];

	sort(ALL(A),[&](int x,int y){
		return abs(x) < abs(y);
	});

	int cnt=0;
	for(int itr : A)if(itr<0)++cnt;

	ll suml = (cnt%2 ? -abs(A[0]) : abs(A[0]));
	REPS(i,1,N)suml += abs(A[i]);

	cout << suml << endl;

	return 0;
}




Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
bool b[55560];
int c[10000];
int main()
{
	int i,j,k=0,n;
	cin>>n;
	for(i=2;i<=55555;i++)
	if(!b[i])
	{
	c[k]=i;k++;
	for(j=i;j<=55555;j+=i)
	b[j]=1;
	}
	for(i=0;i<k&&n;i++)
		if(c[i]%10==1)
		{cout<<c[i]<<" ";
		n--;
		} 
	
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long MX = 1e6 + 10;;
unsigned long long fac[1000010];

#include <math.h>
#define PI 3.14159265358979323846264338327950L

long long gcd(long long a, long long b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
long long lcm(long long a, long long b) {
    return (a * b) / gcd(a, b);
}
long long digits(long long m) {
    long long cnt = 0;
    while (m) {
        cnt++;
        m /= 10;
    }
    return cnt;
}

unsigned long long power(unsigned long long x, unsigned long long y){
    unsigned long long res = 1;
    x = x % MOD;

    while (y > 0) {
        // If y is odd, multiply x with result 
        if (y & 1)
            res = (res * x) % MOD;

        // y must be even now 
        y = y >> 1; // y = y/2 
        x = (x * x) % MOD;
    }
    return res;
}
unsigned long long modInverse(unsigned long long n) {
    return power(n, MOD - 2);
}


int main() {
    int n, d;
    cin >> n >> d;
    vector<vector<int>> a(n, vector<int>(d));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < d; j++) {
            cin >> a[i][j];
        }
    }
    long long cnt = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            long double sum = 0;
            for (int ki = 0; ki < d; ki++) {
                sum += (abs(a[i][ki] - a[j][ki]) * abs(a[i][ki] - a[j][ki]));
            }
            sum = sqrt(sum);
            long long ans = (long long)sum;
            if (sum - ans == 0) cnt++;
        }
    }
    cout << cnt;

    return 0;
}

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

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var nxy = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var varN = nxy[0];
        var varX = nxy[1] - 1;
        var varY = nxy[2] - 1;

        var d = new int[varN][];
        for (int i = 0; i < d.Length; ++i)
        {
            d[i] = new int[varN];
            d[i][varX] = Math.Abs(varX - i);
            for (int j = i + 1; j < d[i].Length; ++j)
            {
                d[i][j] = j - i;
            }
            for (int j = varY; j < d[i].Length; ++j)
            {
                d[i][j] = Math.Min(d[i][j], d[i][varX] + 1 + j - varY);
            }
            for (int j = varX + 1; j < varY; ++j)
            {
                d[i][j] = Math.Min(d[i][j], d[i][varX] + j - varX);
                d[i][j] = Math.Min(d[i][j], d[i][varY] + varY - j);
            }
        }

        var ts = new int[varN - 1];
        for (int i = 0; i < d.Length; ++i)
        {
            for (int j = i + 1; j < d[i].Length; ++j)
            {
                ++ts[d[i][j] - 1];
            }
        }
        Console.WriteLine(string.Join(Environment.NewLine, ts));
    }
}


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

using LL = long long;

#define ALL(a) begin((a)), end((a))
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define RFOR(i, a, b) for (int(i) = (a); (i) > (b); (i)--)
#define debug(x) cerr << #x << " : " << x << '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const LL LINF = 1e16;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  LL ans = -1;
  int N;
  cin >> N;

  vector<int> a(N + 1);
  FOR(i, 1, N + 1) { cin >> a[i]; }

  int now = 1;
  FOR(i, 1, N + 1) {
    now = a[now];

    if (now == 2) {
      ans = i;
      break;
    }
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
long long ans=1;
int m[1111];
vector<int>prime;
int N;
int main(){
    cin>>N;
    for(int i=2;i<=N;i++){
        if(!m[i]){
            prime.push_back(i);
            for(int j=2;i*j<=N;j++)
                m[i*j]++;
        }
    }
    long long ans=1;
    for(int p:prime){
        int temp=N,cnt=1;
        while(temp){
            cnt+=(temp/=p);
        }
        ans*=cnt;
        ans%=1'000'000'007;
    }
    cout<<ans<<endl;
}


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

struct Unionfind {
  // tree number
  vector<int> par;
  // constructor
  Unionfind(int n = 1) : par(n, -1) {}
  // search root
  int root(int x) {
    if (par[x] < 0) return x;
    return par[x] = root(par[x]);
  }
  // is same?
  bool issame(int x, int y) { return root(x) == root(y); }

  // add
  // already added, return 0
  bool uni(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return 0;
    if (par[x] > par[y]) swap(x, y);
    par[x] += par[y];
    par[y] = x;
    return 1;
  }
  int size(int x) { return -par[root(x)]; }
};

struct edge {
  long long r, c, a;
  edge(long long _r, long long _c, long long _a) : r(_r), c(_c), a(_a) {}
  bool operator<(const edge &re) const {
    if (a != re.a) return a < re.a;
    if (r != re.r) return r < re.r;
    return c < re.c;
  }
};

long long n, h, w, res = 0;
vector<int> cnt;
priority_queue<edge> pq;
Unionfind uf;

int main() {
  cin >> n >> h >> w;
  uf = Unionfind(h + w);
  for (int i = 0; i < n; ++i) {
    long long r, c, a;
    cin >> r >> c >> a;
    pq.push(edge(--r, h + (--c), a));
  }
  cnt.assign(h + w, 0);
  for (int i = 0; i < n; ++i) {
    edge e = pq.top();
    pq.pop();
    e.r = uf.root(e.r);
    e.c = uf.root(e.c);
    if (e.r != e.c) {
      uf.uni(e.r, e.c);
      cnt[uf.root(e.r)] = cnt[e.r] + cnt[e.c];
    }
    e.r = e.c = uf.root(e.r);
    if (cnt[e.r] < uf.size(e.r)) {
      ++cnt[e.r];
      res += e.a;
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 5748
#!/usr/local/gnu/bin/bash
read n
if((n==1))
then
    echo 0
    exit
fi
a=(`echo $n | factor | sed -r "s/^.*://"`)
l=(`echo ${a[@]} | tr ' ' '\n' | uniq -c | sed -r "s/([0-9]+) ([0-9]+)/\1/g"`)
s=0
for i in ${l[@]}
do
    q=1
    while((i>=q*(q+1)/2))
    do
        s=$((s+1))
        q=$((q+1))
    done
done
echo $s


Measured memory_bytes: 3816
D, N = [int(v) for v in input().strip().split(" ")]


def can_calc(val, d):
    cnt = 0
    while val % 100 == 0:
        val = val // 100
        cnt += 1
    return cnt == d


val = 0
vals = []
while True:
    val += 1
    if can_calc(val, D):
        vals.append(val)
    if len(vals) == N:
        break
print(vals[-1])

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

using namespace std;

#define MOD 1000000007
#define PI 3.1415926535897932384626433832795
#define INF (int)1e9
typedef long long int int64;

void print() {
    cout << endl;
}

void print(string s, bool endline = true) {
    cout << s;
    if (endline) print();
}

void print(int s, bool endline = true) {
    cout << s;
    if (endline) print();
}

template <typename T, typename T2>
void print(pair<T, T2>& p, bool endline = true) {
    print("(", false);
    print(p.first, false);
    print(", ", false);
    print(p.second, false);
    print(")", false);

    if (endline) print();
}

template <typename T, typename T2>
void print(map<T, T2>& m, bool endline = true) {
    print("{");
    for (auto& p : m) {
        print("  ", false);
        print(p);
    }
    print("}");

    if (endline) {}
}

template<typename T>
void print(vector<T>& v, bool endline = true) {
    print("[", false);
    for (size_t i = 0; i < v.size(); ++i) {
        print(v[i], false);
        if(i != v.size() - 1) print(",", false);
    }
    print("]", false);

    if(endline) print();
}

template <typename T>
vector<T> operator+(const vector<T> &a, const vector<T> &b)
{
    vector<T> ret;
    ret.reserve( a.size() + b.size() );                // preallocate memory
    ret.insert( ret.end(), a.begin(), a.end() );        // add A;
    ret.insert( ret.end(), b.begin(), b.end() );        // add B;

    return ret;
}

template <typename T>
vector<T> &operator+=(vector<T> &a, const vector<T> &b)
{
    a.reserve( a.size() + b.size() );                // preallocate memory without erase original data
    a.insert( a.end(), b.begin(), b.end() );         // add B;
    return a;
}

int main() {
    // g++ -Wall -Wextra -O2 -std=c++17 helloworld.cpp
    int n;
    cin >> n;
    unordered_map<int, vector<int>> tree;
    unordered_map<int, int> color;

    int k = 1;
    vector<int> ret;

    while(n -- > 1) {
        int a, b;

        cin >> a >> b;

        tree[a].push_back(b);
        tree[b].push_back(a);
        ret.push_back(b);
    }

    for(auto& p : tree) {
        k = max(((int) p.second.size()), k);
    }

    vector<int> children {1};
    color[1] = 0;

    while(!children.empty()) {
        vector<int> new_children;
        for(auto parent : children) {
            int i = 1;

            for (auto child : tree[parent]) {
                if (child > parent) {
                    if (i == color[parent]) i++;

                    color[child] = i;
                    i++;
                    new_children.push_back(child);
                }
            }
        }

        children = new_children;
    }

    print(k);
    for(auto c : ret) print(color[c]);

    return 0;
}

Measured memory_bytes: 13852
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>

using namespace std;

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

	int a;
	vector<int> ans(n, 0);
	for (int i = 2; i <= n; i++) {
		cin >> a;
		ans[a-1]++;
	}

	for (auto x: ans) {
		cout << x << endl;
	}
	return 0;
}


Measured memory_bytes: 3672
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
	string s;
	cin >> s;
	if(s[0]==s[s.size()-1]){
		if(s.size()%2==1){
			cout <<"Second" <<endl;
		}else{
			cout << "First" <<endl;
		}
	}else{
		if(s.size()%2==1)cout << "First" <<endl;
		else cout << "Second" <<endl;
	}
	return 0;
}

Measured memory_bytes: 512