akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define MAX 200000
#define rep(i, n) for(int i=0; i<n; i++)
typedef unsigned int ui;
typedef unsigned long long ull;

using namespace std;

int n, b;
ull cnt=0;
ui A[MAX],B[MAX];
priority_queue<pair<int, int> > S;

/*
void prnt(multiset<pair<int, int> > S){
  cout << S.size() << endl;
  for(multiset<pair<int, int> >::iterator it=S.begin(); it!=S.end(); it++){
    cout << " " << it->first;
  }
  cout << endl;
}
*/

int main(){
  scanf("%d", &n);
  rep(i, n) scanf("%ud", &A[i]);
  rep(i, n){
    scanf("%ud", &b);
    B[i]=b;
    if(A[i]<b){
      S.push(make_pair(b, i));
    } else if(A[i]>b){
      puts("-1");
      return 0;
    }
  }
  while(S.size()!=0){
    pair<int, int> mx=S.top();
    S.pop();
    int i=mx.second;
    int im=i-1, ip=i+1;
    if(im==-1)im=n-1;
    if(ip==n)ip=0;
    ui x=(B[im]+B[ip]);
    ui y=max(B[im], B[ip]);
    ui cntp=min((B[i]-A[i])/x, (B[i]-y)/x+1);
    if(cntp==0){
      puts("-1");
      return 0;
    }
    cnt+=cntp;
    B[i]-=cntp*x;
    if(B[i]>A[i]){
      S.push(make_pair(B[i], i));
    }

  }

  printf("%lld\n", cnt);
  return 0;
}


Measured memory_bytes: 3700
#coding: utf-8

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        # xの根を探索
        if self.parents[x] < 0:
            return x
        else:
            # 再帰的に根を探索して経路圧縮
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        # 2つの木をマージする。
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        
        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x
    
    def size(self, x):
        # xの根の所属するグループの要素数を返す
        return -self.parents[self.find(x)]

    def are_same(self, x, y):
        # 2つの要素の根が同じかどうかを調べる
        return self.find(x) == self.find(y)

    def members(self, x):
        # xと同じ根の要素をリストで出力
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == self.n]

    def roots(self):
        # 根である要素をリストで出力
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return "\n".join("{} {}".format(r, self.members(r)) for r in self.roots())

N, M = map(int, input().split())
uf = UnionFind(N)
A, B = [], []
for i in range(M):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
A = A[::-1]
B = B[::-1]
ans = [N*(N-1)//2]
for a, b in zip(A, B):
    if not uf.are_same(a-1, b-1):
        ans.append(ans[-1] - uf.size(a-1) * uf.size(b-1))
    else:
        # もともと連結なら不便度は変わらない
        ans.append(ans[-1])
    uf.union(a-1, b-1)
print(*ans[::-1][1:], sep="\n")

Measured memory_bytes: 20452
#include <bits/stdc++.h>
//#include <atcoder/all>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007; //998244353;

template<class _T> static void get(_T& a) {
	std::cin >> a;
}
template<class _T> static void get(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void get(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}
template <class _T> static _T tp_abs(_T a) {
	if (a < (_T)0) {
		a *= (_T)-1;
	}
	return a;
}

static void A();

int main()
{
	A();
	fflush(stdout);
	return 0;
}

static void A()
{
	int x;
	get(x);

	if (x) x = 0;
	else x = 1;
	printf("%d\n", x);
}


Measured memory_bytes: 3756
n = input()
rates = list(map(int, input().split()))
colors = [0, 0, 0, 0, 0, 0, 0, 0]
n_overrate = 0
n_colors = 0

for rate in rates:
    if 1 <= rate <= 399:
        colors[0] = 1
    elif 400 <= rate <= 799:
        colors[1] = 1
    elif 800 <= rate <= 1199:
        colors[2] = 1
    elif 1200 <= rate <= 1599:
        colors[3] = 1
    elif 1600 <= rate <= 1999:
        colors[4] = 1
    elif 2000 <= rate <= 2399:
        colors[5] = 1
    elif 2400 <= rate <= 2799:
        colors[6] = 1
    elif 2800 <= rate <= 3199:
        colors[7] = 1
    else:
        n_overrate += 1

sum_color = sum(colors)
if sum_color == 0:
    n_min_colors = 1
    n_max_colors = n_overrate
else:
    n_min_colors = sum_color
    n_max_colors = n_min_colors + n_overrate
print('{} {}'.format(n_min_colors, n_max_colors))


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

int main() {
    int n,k;
    int now = 1;
    cin>>n>>k;
    while (now * 2 - now < k && n) {
        now *= 2;
        n--;
    }
    while (n) {
        now += k;
        n--;
    }
    cout<<now<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define moca(a, s, b) a=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
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;}
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;


//for(i=0; i<N; i++) cin >> a[i];


int main(void) {
  ll i, j, k;
  
  ll N;
  cin >> N;
  
  k=0;
  while(N>26*(pow(26, k+1)-1)/25) k++;
  N-=26*(pow(26, k)-1)/25;
  N--;
  
  string s="";
  while(N>0) {
    s=(char)(N%26+'a')+s;
    N/=26;
  }
  
  s=string(k+1-s.size(), 'a')+s;
  pt(s);
  
}


Measured memory_bytes: 4084
#include <bits/stdc++.h>
#define max 1000010
#define ina(n) for(i = 0; i < n; i++) cin >> a[i]
#define oua(n) for(i = 0; i < n; i++) cout << a[i] << " "
using namespace std;

int a[max];
int i, j, k;

int main()
{
	string s;
	cin >> s;
	if(s[2] == s[3] && s[4] == s[5]) cout << "Yes";
	else cout << "No";
	return 0;
}



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

const int N = 3e3 + 3;

int n,a[N];

long long dp[N][N];

int main(){
    cin >> n;
    for(int i = 1; i <= n; i++){
    	cin >> a[i];	
    }
    for(int l = n; l >= 1; l--){
    	for(int r = l; r <= n; r++){
    		dp[l][r] = max(a[l] - dp[l + 1][r],a[r] - dp[l][r - 1]);
    	}
    }
    cout << dp[1][n];
	return 0;
}

Measured memory_bytes: 70144
// B - AtCoDeerくんとボール色塗り
// https://atcoder.jp/contests/abc046/tasks/abc046_b
#include <bits/stdc++.h>
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007      //10^9+7
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define Vec(K, L, N, S) vector<L> K(N, S)
#define rt sqrt
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  uli a, b, c, h, k, n, w, ans = 0, count = 0;
  string s, t;
  cin >> n >> k;
  ans = k * pow(k - 1, n - 1);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using 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 a(n);
    rep(i, n) cin >> a[i];
    map<int, int> mp;
    rep(i, n) {
        mp[a[i]-1]++;
        mp[a[i]]++;
        mp[a[i]+1]++;
    }
    int ans = 0;
    for (auto p : mp) {
        chmax(ans, p.second);
    }
    cout << ans << endl;
}

Measured memory_bytes: 5120
import heapq as pq
inf = float("inf")
n = int(input())
M = [[] for i in range(n)]

for i in range(n-1):
    s,t,d = map(int, input().split())
    M[s].append([t,d])
    M[t].append([s,d])
  
def dijkstra(s):
    color = [0] * n
    d = [inf] * n
    d[s] = 0
    
    H =[]
    pq.heappush(H, [0, s])
    while len(H) != 0:
        u2,u1 = pq.heappop(H)
        color[u1] = 1
        if d[u1] < u2:
            continue
        for v1,v2 in M[u1]:
            if color[v1] == 1: continue

            if d[u1] + v2 < d[v1]:
                d[v1] = d[u1] + v2
                pq.heappush(H, [d[v1], v1])
    return d
  
d = dijkstra(0)
r = d.index(max(d))
d = dijkstra(r)
print(max(d))

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))
#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)
#define All(x) (x).begin(),(x).end()
#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))
#define End '\n'
#define Out(x) cout<<(x)<<End
template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair
#define X first
#define Y second

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

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

    string s;

    cin >> s;

    long ans = 0;
    long left = 0;

    long i, len = s.size();

    rep(i, len) {
        if (s[i] == 'W') {
            ans += i - left;
            left++;
        }
    }

    Out(ans);

    return 0;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string S, T;
    int A, B;
    cin >> S >> T;
    cin >> A >> B;

    string U;
    cin >> U;
    if ( U == S) A -= 1;
    if ( U == T) B -= 1;

    cout << A << " " << B << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())


x_list = []
y_list = []
z_list = []

for _ in range(N):
   x, y, z =  map(int, input().split())
   x_list.append(x)
   y_list.append(y)
   z_list.append(z)

ans = 0
for i in range(2):
    for j in range(2):
        for k in range(2):
            ans = max(sum(sorted([ (-1)**i*x + (-1)**j*y + (-1)**k*z for x,y,z in zip(x_list, y_list, z_list)], reverse=True)[:M]), ans)
print(ans)

Measured memory_bytes: 3188
#include <stdio.h>

int main(){
  int num, v, win[2] = {}, n, i;
  scanf("%d", &n);
  for(i = 0;i < n;i++){
    scanf("%d%d", &num, &v);
    if(v > win[1]){
      win[1] = v;
      win[0] = num;
    }
    else if(v == win[1]){
      if(win[0] == 0) win[0] = num;
      win[0] = num > win[0] ? win[0] : num;
    }
  }
  printf("%d %d\n", win[0], win[1]);
  return 0;
}

Measured memory_bytes: 600
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var t = long.Parse(line[0]);
        var a = long.Parse(line[1]);
        for (int i = 1; i < n; i++)
        {
            line = Console.ReadLine().Trim().Split(' ');
            var nt = long.Parse(line[0]);
            var na = long.Parse(line[1]);
            if (IsGood(t, a, nt, na)) { t = nt; a = na; }
            else
            {
                var w = getAns(t, a, nt, na);
                t = nt * w;
                a = na * w;
            }
        }
        Console.WriteLine(t + a);
    }
    public static bool IsGood(long t, long a, long nt, long na) => nt >= t &&  na >=  a;
    public static long getAns(long t, long a, long nt, long na)
    {
        var r1 = 0L;  var r2 = 0L;
        if (nt < t) r1 = (t + nt - 1) / nt;
        if (na < a) r2 = (a + na - 1) / na;
        return r1 > r2 ? r1 : r2;
    }
}

Measured memory_bytes: 13140
# coding: utf-8
# Your code here!
import numpy as np
d= int(input())
 
C = list(map(int,input().split()))
CB = [0 for i in range(len(C))]
 
c = sum(C)
 
total = 0
 
#print(c,C,CB)
L = []
 
for i in range(d):
    L.append(list(map(int,input().split())))
 
#print(L)
 
 
#print(T)
 
def cnt(CB,t):
    for i in range(len(CB)):
        if i != t:
            CB[i] += 1
        else:
            CB[i] = 0
    
    return CB
 
def sumA(C,CB):
    a = 0
    for i in range(len(CB)):
        a += CB[i]*C[i]
    return a

def check(L,C,CB):
    a = L[0]+CB[0]*C[0]
    r = 0
    for i in range(len(CB)):
        if a < L[i]+CB[i]*C[i]:
            r = i
    return r
 
for i in range(d):
#    ## 最大値で更新
#    ind = np.argmax(L[i])
#    CB = cnt(CB,ind)
#    total += L[i][ind] - sumA(C,CB)

    ind = check(L[i],C,CB)    
    CB = cnt(CB,ind)
    total += L[i][ind] - sumA(C,CB)
    print(ind+1)
 
 

Measured memory_bytes: 27560
#include<bits/stdc++.h>
    using namespace std;
     
    int main(){
    	int h,w,k;
    	cin>>h>>w>>k;
    	
    	vector<int>b(8,1);
    	for(int i=1;i<8;i++)b[i]=2*b[i-1];
     
    	int grid[h][w];
    	for(int i=0;i<h;i++){
    		for(int j=0;j<w;j++){
    			char c;
    			cin>>c;
    			if(c=='.')grid[i][j]=0;
    			else grid[i][j]=1;
    		}
    	}
     
     
     
    	vector<bool>ma_h(h),ma_w(w);	
    	
    	int ans=0;
    	for(int i=0;i<(1<<h);i++){
    		
    		for(int a=0;a<h;a++){
    			ma_h[a]=0;
    			ma_h[a]=(b[a] & i);
    		}
    		for(int j=0;j<(1<<w);j++){
    		
    			for(int a=0;a<w;a++){
    				ma_w[a]=0;
    				ma_w[a]=(b[a] & j);
    			}
     
     
    			int cgrid[h][w];
    			for(int x=0;x<h;x++){
    				for(int y=0;y<w;y++){
    					cgrid[x][y]=grid[x][y];
     
    					if(ma_h[x] || ma_w[y])cgrid[x][y]=2;
    				}
    			}
    			int qtd=0;
    			for(int x=0;x<h;x++){
    				for(int y=0;y<w;y++){
    					qtd+=(cgrid[x][y]==1);
    				}
    			}
     
    			ans+=(qtd==k);
     
    		}
     
     
    	}
     
    	cout<<ans;
     
    	return 0;
    }

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define all(A) A.begin(),A.end()
typedef long long ll;

int main(){
  
  int n,p;
  cin >> n >> p;
  vector<vector<ll>> dp(n+1,vector<ll>(2));
  dp[0][0] = 1;
  dp[0][1] = 0;
  rep1(i,n){
    int x;
    cin >> x;
    if(x%2 == 0){
      dp[i][0] = dp[i-1][0]*2;
      dp[i][1] = dp[i-1][1]*2;
    }
    if(x%2 == 1){
      dp[i][0] = dp[i-1][0]+dp[i-1][1];
      dp[i][1] = dp[i-1][0]+dp[i-1][1];
    }
  }
  cout << dp[n][p] << endl;
}

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

using namespace std;

struct pkt
{
    double x, l, r;
    int nr;
};

bool por(pkt a, pkt b)
{
    if (a.x < b.x)
        return true;
    if (a.x > b.x)
        return false;
    if(a.nr < b.nr)
        return true;
    return false;
}

int main()
{
    ios_base::sync_with_stdio(0);
    int n, q;
    cin >> n >> q;
    vector<pkt> p(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> p[i].l >> p[i].r >> p[i].x;
        p[i].nr = i;
        p[i].l -= 0.5;
        p[i].r -= 0.5;
    }
    sort(p.begin(), p.end(), por);
    vector<int> a(q);
    set< pair<double, int> > S;
    for (int i = 0; i < q; ++i)
    {
        cin >> a[i];
        S.insert(make_pair(a[i], i));
    }
    vector<int> odp(q, -1);
    for (int i = 0; i < n; ++i)
    {
        double L = p[i].l - p[i].x;
        double R = p[i].r - p[i].x;
        while (true)
        {
            if (S.size() == 0)
                break;
            set< pair<double, int> >::iterator it = S.lower_bound(make_pair(L, -1));
            if (it == S.end())
                break;
            pair<double, int> x = *it;
            if (x.first <= R)
            {
                S.erase(it);
                odp[x.second] = p[i].x;
            }
            else
                break;
        }
    }
    for (int i = 0; i < q; ++i)
        cout << odp[i] << endl;
    return 0;
}


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

using namespace std;

int main()
{
  int n, x;
  cin >> n >> x;
  if (1 == x || x == 2 * n - 1) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  int N = 2 * n - 1;
  int cnt = 1;
  for (int i = 0; i < n-2; i++) {
    while (cnt >= x-1 && cnt <= x+1) cnt++;
    cout << cnt << " ";
    cnt++;
  }
  cout << x - 1 << " " << x << " " << x + 1;
  if (n == 2) {
    cout << endl;
    return 0;
  }
  else cout << " ";
  for (int i = n + 1; i < N-1; i++) {
    while (cnt >= x-1 && cnt <= x+1) cnt++;
    cout << cnt << " ";
    cnt++;
  }
  while (cnt >= x-1 && cnt <= x+1) cnt++;
  cout << cnt << endl;
}


Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
	vector<int> a(3);
	cin >> a[0] >> a[1] >> a[2];
	
	int k;
	cin >> k;
	
	sort(a.begin(), a.end());
	
	for(int i = 0; i < k; i++)
	{
		a[2] *= 2;
	}
	
	cout << a[0] + a[1] + a[2] << endl;
	return 0;
}

Measured memory_bytes: 256
sub f{my($u,$t,$p)=@_;push@$t,$u;$_-$p&&f($_,$t^R,$u)for@$u}<>;map{push@$_,$u-$_+$;for($u,$;)=split}<>;@a=($,=$",(f 1,b)x$.);@b>$./3&@0>$./3?(map$a[$_]=$#x+=3,@b)+map$a[$_]=++$y*3-2,@0:map$a[$_]=$#x+=$#x%3,@b>@0?@b:@0;print map$_<=$.&&$_||3*++$z,@a

Measured memory_bytes: 291968
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int N;
  cin>>N;
  vector<pair<int,int>> A(N);
  for(pair<int,int> &p:A)cin>>p.first>>p.second;
  map<pair<int,int>,int> B;
  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++){
      if(i==j)continue;
      B[make_pair(A[i].first-A[j].first,A[i].second-A[j].second)]++;
    }
  int mx=0;
  for(pair<pair<int,int>,int> p:B)
    mx=max(mx,p.second);
  cout<<N-mx<<endl;
}

Measured memory_bytes: 3756
#include<cstdio>
#include<cstring>

using namespace std;

char s[100010];
int n, ans;

int main() {
	int i, j;
	scanf("%s", s+1); n = strlen(s+1);
	i = 1; j = n;
	while(i < j) {
		if(s[i] == s[j]) ++i, --j;
		else {
			if(s[i] == 'x') ++i, ++ans; else
			if(s[j] == 'x') --j, ++ans; else {puts("-1"); return 0;}
		}
	}
	printf("%d\n", ans);
	return 0;
}

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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rep1r(i, n) for (int i = ((int)(n)); i > 0; --i)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

bool is_prime(ll 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() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // cout << fixed << setprecision(5);

    int n;
    cin >> n;
    ll a[n];
    rep(i, n) { cin >> a[i]; }

    int ans = 0;
    rep(i, n) {
        if (is_prime(a[i])) {
            ans++;
        }
    }

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



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

typedef long long ll;

int main()
{
	ll n;
  	cin >> n;
  	ll ans = 0;
  	ll money = 100;
  	for(int i = 1; i < 100000; i++)
    {
    	ll res = money / 100;
      	money += res;
      	if(money >= n)
        {
        	ans = i;
          	break;
        }
    }
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include <stdio.h>

int main(){
  int H,W,i,j;
  
  while(-1){
  	scanf("%d %d",&H,&W);
    if(H == 0) break;
    else{
    	for(i=0;i<H;i++){
        	for(j=0;j<W;j++){
            	printf("#");
            }
          printf("\n");
        }
    } 
    printf("\n");
  }
  
  return 0;
}


Measured memory_bytes: 2056
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <queue>


using namespace std;
#define INF 0x3f3f3f3f3f
#define ll long long
#define pr(x) (cerr << #x << ' ' << x << ' ')
#define prln(x) (cerr << #x << ' ' << x << endl)


int main()
{
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
    #endif // LOCAL
    int n, k;
    cin >> n >> k;
    if (n % k == 0) {
        puts("0");
    }else {
        puts("1");
    }
    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<queue>
#define inf 2147483647
#define eps 1e-9
#define lb(x) (x&-x)
#define mod 1000000007
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int> pr;
int n,m,ans=1,tot=0,tmp,t1,t2,t[500001],a[100001],b[100001],h[100001];
pr p[100001];
bool cmp(pr a,pr b){
	return a.first==b.first?a.second>b.second:a.first<b.first;
}
void add(int u,int x){
	for(;u<=n;u+=lb(u)){
		t[u]=(t[u]+x)%mod;
	}
}
int query(int u){
	int ret=0;
	for(;u;u-=lb(u)){
		ret=(ret+t[u])%mod;
	}
	return ret;
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1;i<=m;i++)scanf("%d",&b[i]);
	for(int i=1;i<=n;i++){
		if(a[i]>b[1]&&a[i]<b[m]){
			tmp=lower_bound(b+1,b+m+1,a[i])-b;
			if(a[i]==b[tmp])continue;
			p[++tot]=pr(a[i]-b[tmp-1],b[tmp]-a[i]);
			h[tot]=b[tmp]-a[i];
		}
	}
	sort(h+1,h+tot+1);
	t1=unique(h+1,h+tot+1)-h-1;
	for(int i=1;i<=tot;i++){
		p[i].second=lower_bound(h+1,h+t1+1,p[i].second)-h;
	}
	sort(p+1,p+tot+1,cmp);
	t2=unique(p+1,p+tot+1)-p-1;
	for(int i=1;i<=t2;i++){
		tmp=query(p[i].second-1)+1;
		ans=(ans+tmp)%mod;
		add(p[i].second,tmp);
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 2304
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
#include <numeric>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repm(i, a, n) for (int i = a; i >= n; i--)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vs vector<string>
#define vii vector<vector<int>>
#define vll vector<ll>
#define vllll vector<vector<ll>>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define fi first
#define se second

void print(bool c)
{
    if (c)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

void Print(bool c)
{
    if (c)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

ll gcdll(ll a, ll b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

bool cmp(const pii &a, const pii &b)
{
    if (a.second != b.second)
        return a.second < b.second;
    return a.first < b.first;
}

int kaijo(int x)
{
    int ans = 1;
    rep(i, 1, x + 1) ans *= i;
    return ans;
}

string n_shin(int x, int n)
{
    string s;
    while (x > 0)
    {
        s += to_string(x % n + 1);
        x /= n;
    }
    while (s.size() < n)
    {
        s += '0';
    }
    s.reserve();
    //cout << s << endl;
    return s;
}

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

    int cnt = 0;
    int m;
    rep(i, 0, n)
    {
        int p;
        cin >> p;
        if (i == 0)
        {
            cnt++;
            m = p;
        }
        else
        {
            if (m > p)
                cnt++, m = p;
        }
    }
    cout << cnt << endl;
}


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

int main(){
  int n; cin >>n;
  vector<ll> a(n);
  rep(i,n) cin >>a[i];
  int ans = 0;
  int cnt = 0;
  for(int i = 1; i<n; i++){
    if(a[i]<=a[i-1]) {
      cnt++;
      ans = max(cnt, ans);
    }
    else cnt= 0;
  }
  cout << ans << endl;
  return 0; 
}

Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
#define VECIN(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
pair<double,double> dp[1005][1005];
int main(){
	int n,m;
    cin>>n>>m;
    vector<int> a(n);
    vector<pair<int,int>> p(m);
    REP(i,n){
        cin>>a[i];
    }
    REP(i,m){
        cin>>p[i].second>>p[i].first;
    }
    sort(ALL(a));
    sort(ALL(p));
    int t=m-1;
    int cnt=0;
    ll sum=0;
    REP(i,n){
        if(t>=0){
        if(p[t].first>a[i]){
            a[i]=p[t].first;
            cnt++;
        }
        if(cnt>=p[t].second){
            t--;
            cnt=0;
        }
        }
        sum+=a[i];
    }
    OUT(sum);
	return 0;
}

Measured memory_bytes: 1408
#include<iostream>
using namespace std;
int main() {
    int num, i, j, max_profit, min_val;
    cin >> num;
    int arr[num];
    for (i = 0; i < num; i++) {
        cin>>arr[i];
    }
    max_profit = arr[1] - arr[0];
    min_val = arr[0];
    for (i = 1; i < num; i++) {
        if (max_profit < arr[i] - min_val) {
            max_profit = arr[i] - min_val;
        }
        if (min_val > arr[i]) {
            min_val = arr[i];
        }
    }
    cout<<max_profit<<endl;
    return 0;
}

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

typedef long long int ll;
typedef vector<long long>lve;
typedef vector<pair<ll,ll> > lvp;

#define sp         ' '
#define endl       '\n'
#define F          first
#define S          second
#define pp         pop_back`
#define pb         push_back
#define mp         make_pair 
#define GCD(x,y)   __gcd(x,y)
#define PI         2*acos(0.0);
#define lb         lower_bound
#define bs         binary_search
#define all(x)     x.begin(),x.end()
#define LCM(x,y)   ((x*y)/__gcd(x,y))
#define btpc       __builtin_popcountll
#define spc(x)     cout<<fixed<<setprecision(x)

const   long long  cs=2e5+5;
const   long long  inf=1e18;
const   long long  mod=1e9+7;
void solve()
{
    int64_t t,n,m,a,b,d,e,i,j,k,x,y,cnt=1,cnt1=0;
    bool flag = false;

    cin>>n;
    x=n;
    string s;
    vector<string>v;
    while(n--)
    {
        cin>>s;
        sort(all(s));
        v.pb(s);
    }
    sort(all(v));
    lve v1;cnt=1;
    for(i=0;i<x-1;i++)
    {
        if(v[i]==v[i+1]) cnt++;
        else {
            v1.pb(cnt);
            cnt=1;
        }
    }
    v1.pb(cnt);
    cnt=0;
    for(ll ss:v1)
    {
        cnt+=(ss*(ss-1))/2;
    }
    cout<<cnt<<endl;

}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);    cout.tie(NULL);

    // freopen ("input.txt","r",stdin);
    // freopen ("output.txt","w",stdout);

    // ll tc;
    // cin>>tc;
    // while(tc--)
    solve();

    return 0;
}

Measured memory_bytes: 8176
#include <bits/stdc++.h>
using namespace std;
int main(){
    int K,S;
    int ans = 0;
    // freopen("in.txt","r",stdin);
    scanf("%d%d",&K,&S);
    //x+y+z = S x.y.z < K
    for (int x = 0; x <= K && x<=S; ++x) {
        for (int y = 0; y <=K && y+x<=S ; ++y)
        {
        	if(S-x-y<=K) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

void solve()
{
	int n;
	cin >> n;
	unsigned long long int sum = 1;
	for(int i = 1; i <= n; ++i)
	{
		sum *= i;
	}
	cout << sum << endl;
}

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

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

using namespace std;

void solve() {
    int k; cin >> k;
    string s; cin >> s;
    for (auto& c: s) {
        int x = c-'A';
        (x += k) %= 26;
        c = 'A' + x;
    }
    cout << s;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 1000;
const int MAX_M = 10000;

const int INF = 1 << 30;

/* typedef */

typedef pair<int,int> pii;

/* global variables */

int n, m;
int st, gl;
pii rds[MAX_M];
int rmtx[MAX_N][MAX_N], dmtx[MAX_N][MAX_N];
int dists[MAX_N];

/* subroutines */

int min_count() {
  for (int i = 0; i < n; i++) dists[i] = INF;
  dists[st] = 0;

  queue<int> q;
  q.push(st);

  while (! q.empty()) {
    int u = q.front(); q.pop();

    if (u == gl) break;
    int nvd = dists[u] + 1;
    
    for (int v = 0; v < n; v++)
      if (rmtx[u][v] && dists[v] >= INF) {
	dists[v] = nvd;
	q.push(v);
      }
  }

  return dists[gl];
}

/* main */

int main() {
  for (;;) {
    cin >> n;
    if (n == 0) break;

    cin >> st >> gl;
    st--, gl--;

    cin >> m;
    
    memset(rmtx, 0, sizeof(rmtx));
    
    for (int i = 0; i < m; i++) {
      int ai, bi;
      cin >> ai >> bi;
      ai--, bi--;
      rds[i] = pii(ai, bi);

      if (ai != bi) rmtx[ai][bi]++;
    }

    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) dmtx[i][j] = INF;
      dmtx[i][i] = 0;
      queue<int> q;
      q.push(i);

      while (! q.empty()) {
	int u = q.front(); q.pop();
	int nvd = dmtx[i][u] + 1;
	for (int v = 0; v < n; v++)
	  if (rmtx[u][v] && dmtx[i][v] >= INF) {
	    dmtx[i][v] = nvd;
	    q.push(v);
	  }
      }
    }
    
    int min_c = min_count();
    int min_ri = -1;
    //cout << min_c << endl;

    for (int ri = 0; ri < m; ri++) {
      int ai = rds[ri].first;
      int bi = rds[ri].second;
      if (rmtx[ai][bi] == 0) continue;

      if (min_c > dmtx[st][bi] + 1 + dmtx[ai][gl]) {
	rmtx[ai][bi]--;
	rmtx[bi][ai]++;

	int c = min_count();
	if (min_c > c) {
	  min_c = c;
	  min_ri = ri;
	}

	rmtx[bi][ai]--;
	rmtx[ai][bi]++;
      }
    }

    printf("%d %d\n", min_c, min_ri + 1);
  }

  return 0;
}

Measured memory_bytes: 9096
#include <stdio.h>

int main(){
	int N,max,min,sa;
	scanf("%d",&N);
	int A[N];
	for(int i=0;i<N;i++){
		scanf("%d",&A[i]);
	}
	
	max=A[0];
	min=A[0];
	
	for(int j=1;j<N;j++){
		if(A[j]>max){
			max=A[j];
		}
		if(A[j]<min){
			min=A[j];
		}
	}
	sa=max-min;
	printf("%d\n",sa);
	
	return 0;
}

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

int main(){
    int N, D;
    cin >> N >> D;
    vector<vector<short>> X(N, vector<short>(N,D));
    for(int i=0; i<N; i++){
        for(int j=0; j<D; j++){
            cin >> X[i][j];
        }
    }

    int cnt = 0;
    for(int i=0; i<N-1; i++){
        for(int k=i+1; k<N; k++){
            double sum = 0;
            for(int j=0; j<D; j++){
                sum += pow((X[i][j] - X[k][j]), 2);
            }
            /*
            if(ceil(sqrt(sum))==floor(sqrt(sum))){
                cnt++;
            }
            */
           if((int)(sqrt(sum))==sqrt(sum)) cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-9;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

bool Check(vector<string>&field, int y, int x, int d, char c) {
	if (c == 'C') {
		if (d == 0)return (field[y - 1][x] == '#');
		if (d == 1)return (field[y][x + 1] == '#');
		if (d == 2)return (field[y + 1][x] == '#');
		if (d == 3)return (field[y][x - 1] == '#');
	}
	if (c == 'N') {
		return d == 0;
	}
	if (c == 'W') {
		return d == 3;
	}
	if (c == 'S') {
		return d == 2;
	}
	if (c == 'E') {
		return d == 1;
	}
	return c == 'T';
}

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

	int dir[] = { -1,0,1,0,-1 };
	int cnt = 0;
	cin >> H >> W;
	vector<string>s(H);
	for (auto &i : s)cin >> i;
	string t;
	cin >> t;
	stack<int>st;
	int p = 0;
	int y, x, d = 0;
	int sy, sx, gy, gx;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (s[i][j] == 'g')gy = i, gx = j;
			if (s[i][j] == 's')sy = i, sx = j;
		}
	}
	y = sy, x = sx;
	vector<int>ed(t.size());
	int add = 0;
	while (p < t.size()) {
		if (t[p] == '{' || t[p] == '[') {
			st.push(p);
		}
		if (t[p] == '}' || t[p] == ']') {
			ed[st.top()] = p;
			st.pop();
		}
		p++;
	}
	p = 0;
	int step = 0;
	while (p < t.size() && cnt <= 10000000&&step<=10000000) {
		step++;
		if (t[p] == '{') {
			if(st.empty()||st.top()!=p)st.push(p);
			p++;
			bool flag = true;
			bool rev = false;
			if (t[p] == '~') {
				rev = true;
				p++;
			}
			if (rev)flag = !Check(s, y, x, d, t[p]);
			else flag = Check(s, y, x, d, t[p]);
			p++;
			if (!flag) {
				p = ed[st.top()] + 1;
				st.pop();
			}
		}
		else if (t[p] == '}') {
			p = st.top();
		}
		else if (t[p] == '[') {
			int l = p;
			p++;
			bool flag = true;
			bool rev = false;
			if (t[p] == '~') {
				rev = true;
				p++;
			}
			if (rev)flag = !Check(s, y, x, d, t[p]);
			else flag = Check(s, y, x, d, t[p]);
			p++;
			if (!flag) {
				p = ed[l] + 1;
			}
		}
		else if (t[p] == ']') {
			p++;
		}
		else if (t[p] == '^') {
			cnt++;
			p++;
			if (s[y + dir[d]][x + dir[d + 1]] != '#') {
				y += dir[d];
				x += dir[d + 1];
			}
		}
		else if (t[p] == 'v') {
			cnt++;
			p++;
			if (s[y - dir[d]][x - dir[d + 1]] != '#') {
				y -= dir[d];
				x -= dir[d + 1];
			}
		}
		else if (t[p] == '>') {
			cnt++;
			p++;
			d++;
			d %= 4;
		}
		else if (t[p] == '<') {
			cnt++;
			p++;
			d+=3;
			d %= 4;
		}
		if (y == gy && x == gx) {
			cout << cnt << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}


Measured memory_bytes: 3260
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Iterator;

public class Main {

    public static void main(String[] args) {
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String line = br.readLine();
            String[] strArray = new String[3];
            int[] intArray = new int[3];
            int count = 0;
            
            strArray = line.split("\\s");
            
            for (int i = 0; i < strArray.length; i++) {
				intArray[i] =Integer.parseInt(strArray[i]);
			}
            for (int i = intArray[0]; i < intArray[1] + 1; i++) {
				if(intArray[2] % i == 0)
					count++;
			}
            System.out.println(count);
            br.close();
        } catch (IOException e) {
            System.err.println(e);
        }
    }
}

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

using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define MP make_pair
#define PB push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	LL n;
	cin >> n;
	vector<LL> a(n), b(n);
	rep(i, n)cin >> a[i] >> b[i];

	LL plas = 0;
	for (LL i = n - 1; i >= 0; i--) {
		LL x = a[i], y = b[i];
		plas += (x + plas + y - 1) / y * y - (x + plas);
		//cout << i << " " << plas << endl;
	}
	cout << plas << endl;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main(){
	int n,m,i,j;
	int a[101],x[2019];
	scanf("%d",&n);
	for(i=0;i<n;i++)scanf("%d",&x[i]);
	scanf("%d",&m);
	for(j=0;j<m;j++)scanf("%d",&a[j]);
	for(j=0;j<m;j++){
		if(a[j]==n || x[a[j]]-x[a[j]-1]!=1){
			x[a[j]-1]++;
			if(x[a[j]-1]>=2019)x[a[j]-1]=2019;
		}
	}
	for(i=0;i<n;i++)printf("%d\n",x[i]);
	return 0;
}



Measured memory_bytes: 2000
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <bitset>
#include <iostream>
#include <deque>
#include <functional>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <string>
#include <vector>
#include <vector>

using namespace std;

#define int long long

#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

#define debug(x) cerr << #x << ": " << x << endl;

const int MOD = 1e9 + 7;

bool isSquare(int n) {
  for (int i = 0; i <= sqrt(n); ++i) {
    if (i * i == n) return true;
  }
  return false;
}

signed main(void)
{

  int num = 0;

  int n; cin >> n;
  int d; cin >> d;

  vector<vector<int>> x(n);
  for (int i = 0; i < n; ++i) {
    x[i] = vector<int>(d);
    for (int j = 0; j < d; ++j) {
      cin >> x[i][j];
    }
  }

  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      int dist = 0;
      for (int k = 0; k < d; ++k) {
        dist += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
      }
      if (isSquare(dist)) ++num;
    }
  }

  cout << num << endl;
}


Measured memory_bytes: 256
# D - Water Bottle
import math

a, b, x = map(int, input().split())

if (a**2)*b <= 2*x:
    tan_Theta = 2*((a**2)*b-x)/a**3
else:
    tan_Theta = (a*(b**2))/(2*x)

print(math.degrees(math.atan(tan_Theta)))

Measured memory_bytes: 3188
def solve():
    gx,gy = False, False
    if W/2 == x:
        gx = True
    if H/2 == y:
        gy = True
    ans = W*H/2
#    print(gx,gy)
    if gx and gy:
        print(ans, 1)
    else:
        print(ans, 0)

    

if __name__ == "__main__":
    W,H,x,y = list(map(float, input().split()))
    solve()  


Measured memory_bytes: 8940
N = int(input())
xy = [tuple(map(int, input().split())) for i in range(N)]

F = [0]*N

for i in range(N):
    F[i] = xy[i][0] - xy[i][1]
ans = max(F) - min(F)

for i in range(N):
    F[i] = xy[i][0] + xy[i][1]
ans2 = max(F) - min(F)

print(max(ans, ans2))


Measured memory_bytes: 43960
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i,a,n) for(ll i=a;i<(ll)(n);i++)

int main(){
   ll N; cin>>N;

   char s[] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

    string ans = "";
    bool flag = false;
   while(N > 0){
       int z = N%26;
       if(z == 0) z = 26;
       ans += {s[z-1]};
       N = (N-1)/26;
       //cout << z-1 << endl;
   }

    reverse(ans.begin(), ans.end());
   cout << ans << endl;
}


Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  sort(a.begin(), a.end());
  long long ans = 9999999999999;
  for (int i = a[0]; i <= a[n-1]; i++) {
    long long sum = 0;
    for (int j = 0; j < n; j++) {
      sum += (a[j] - i)*(a[j] - i);
    }
    if (ans > sum) {
      ans = sum;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1000000000000;
const ll mod=1000000007;


int main(){
  cout<<fixed<<setprecision(20);
  ld a,b,x;cin>>a>>b>>x;
  ld h = (2*x) / (a*a) - b;
  ld a1=atan((b-h) / a);
  ld a2=atan(a*b*b/x/2.0);
  if(a1<=atan(b/a)) cout<<a1*180.0/M_PI<<endl;
  else cout<<a2*180.0/M_PI<<endl;
}
  

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
const ll INF = LONG_LONG_MAX / 2;
const ll mod = 1000000000 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main() {
  int N, Q;
  cin >> N >> Q;
  dsu d(N);
  for (int i = 0; i < Q; i++) {
    int t, u, v;
    cin >> t >> u >> v;
    if (t == 0) {
      d.merge(u, v);
    } else if (t == 1) {
      if (d.same(u, v))
        cout << "1" << endl;
      else
        cout << "0" << endl;
    }
  }
}


Measured memory_bytes: 3856
#include <stdio.h>
 
int main(){
    int a,b;
    int c;
    int i;
    int cnt=0;
    scanf("%d%d%d",&a,&b,&c);
    for(i=a;i<=b;i++){
        if(c%i==0){
            cnt++;
        }
    }
    printf("%d\n",cnt);
    return 0;
}

Measured memory_bytes: 596
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Libraries --------------------------------//

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Dubug Functions ---------------------------//
inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}
//------------------------------- Solver ------------------------------------//

void solve()
{
    int n;
    cin >> n;
    akari<i64> as(n);
    i64 sum = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> as[i];
        sum += as[i];
    }
    i64 ans = 1e15, cur = 0;
    for (int i = 1; i < n; i++)
    {
        cur += as[i - 1];
        ans = min(ans, abs((sum - cur) - cur));
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
 
 
struct strint{
  string x;
  strint() {
    x = "";
  }
  int size()const{
    return x.size();
  }
  char operator[](int id) const {
    return x[id];
  }
  bool operator<(const strint &ot) const{
    if( size() < ot.size() ) return true;
    if( size() > ot.size() ) return false;
    for(int i=0;i<size();i++){
      if( x[i] < ot[i] ) return true;
      if( x[i] > ot[i] ) return false;
    }
    return false;
  }
  void operator+=(const string &s) {
    x+=s;
  }
  strint operator=(const string &s){
    x = s;
    return *this;
  }
  strint operator=(char s[]){
    x = s;
    return *this;
  }
};
 
 
char buf[111];
strint memo[55][55];
strint memn[55][55];
strint memr[55][55];
strint meml[55][55];
strint parse(int l,int r);
 
strint number(int l,int r){
  //cout << "number : "<< l <<" , " << r << endl;
  strint &ret = memn[l][r];
  if( ret.x != "" ) return ret;
  strint res;
  if( buf[l] == '0' ){
    if( l+1 == r ) return memn[l][r] = (string)"0";
    else return memn[l][r] = (string)"/";
  }
  while( l < r && (isdigit(buf[l]) || buf[l] == '?') ){
    if( buf[l] == '?' ) res += (string)"9";
    else res.x += buf[l];    
    l++;
  }
  ret = res;
  //cout << res << " " << l << "-"<< r << endl;
  if( l == r ) return ret;
  return ret = (string)"/";
}
 
strint parseR(int l,int r){
  strint &ret = memr[l][r];
  if( ret.x != "" ) return ret;
  ret = (string)"/";
  //cout << "R : "<< l <<" , " << r << endl;
  if( (buf[l] == 'R' || buf[l] == '?') && (buf[r-1] == ')' || buf[r-1] == '?' ) ){
    l++; r--;
    if( buf[l] == '(' || buf[l] == '?' ) {
      l++;
      for(int i=l+1;i+1<r;i++){       
        if( (buf[i] == ',' || buf[i] == '?') && parse(l,i).x != "/" ){
          //strint x = parse(i+1,r);
          //if( x != "/" ) return x;
          ret = max( ret, parse(i+1,r) );
        }
      }
    }
  } 
  return ret;
}
 
strint parseL(int l,int r){
  strint &ret = meml[l][r];
  if( ret.x != "" ) return ret;
  ret = (string)"/";
  //cout << "L : "<< l <<" , " << r << endl;
  if( (buf[l] == 'L' || buf[l] == '?') && (buf[r-1] == ')' || buf[r-1] == '?' ) ){
    l++; r--;
    if( buf[l] == '(' || buf[l] == '?' ) {
      l++;
      for(int i=l+1;i+1<r;i++){       
        if( (buf[i] == ',' || buf[i] == '?') && parse(i+1,r).x != "/" ){
          //ret = parse(l,i);
          //if( ret != "/" ) return ret;
          ret = max( ret, parse(l,i) );
        }
      }
    }
  } 
  return ret;
}
 
 
strint parse(int l,int r){
  //cout << l << ", " << r << endl;
  strint &ret = memo[l][r];
  if( ret.x != "" ) return ret;
  if( l >= r ) return ret = (string)"/";
  return ret = max( number(l,r), max( parseR(l,r) , parseL(l,r) ) );
}
 
int main(){
  cin >> buf;
  strint res = parse(0,strlen(buf));
  if( res.x == "/" ) cout << "invalid" << endl;
  else cout << res.x << endl;
 
}

Measured memory_bytes: 1384