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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

int main(void) {
  int64 n;
  while (cin >> n && n) {
    vector<string> vv(n), v;
    REP(i, n) cin >> vv[i]; 
    v = vv;
    int64 l = -INF_LL, r = INF_LL;
    REP(i, n) {
      if (i < n-1 && v[i] == v[i+1] && v[i] == "x") { r = -INF_LL-1; break; }
      if (i < n-1 && v[i] != "x" && v[i+1] != "x") {
        if ((i % 2 == 0 && stoi(v[i]) >= stoi(v[i+1])) || (i%2 && stoi(v[i]) <= stoi(v[i+1]))) {
          r = -INF_LL-1;
          break;
        }
      }
      if (i % 2 == 0) {
        if (v[i] == "x") {
          if (i < n-1)
            chmin(r, stoi(v[i+1])-1);
          if (i > 0)
            chmin(r, stoi(v[i-1])-1);
        }
      } else {
        if (v[i] == "x") {
          if (i < n-1)
            chmax(l, stoi(v[i+1])+1);
          if (i > 0)
            chmax(l, stoi(v[i-1])+1);
        }
      }
    }
    if (l == r) {
      cout << l << endl;
    } else if (l < r) {
      cout << "ambiguous" << endl;
    } else {
      cout << "none" << endl;
    }
  }
}


Measured memory_bytes: 3248
#include <stdio.h>

int main(void){
	int r, c, i, j;
	int elements[101][101] = { 0 };

	scanf("%d %d", &r, &c);
	for (j = 0; j < r; j++){
		for (i = 0; i < c; i++){
			scanf("%d", &elements[j][i]);
			elements[j][c] += elements[j][i];
			elements[r][i] += elements[j][i];
		}
	}
	for (i = 0; i < c; i++){
		elements[r][c] += elements[r][i];
	}
	for (j = 0; j <= r; j++){
		for (i = 0; i <= c; i++){
			printf("%d", elements[j][i]);
			if (i < c){
				printf(" ");
			}else{
				printf("\n");
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1080
//C
#include <cassert>
//#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//ここまで標準include

using namespace std;

long aCb(long a, long b) {
	long out = 1;
	for (long i = 1; i <= b; i++) {
		out = out * (a + 1 - i) / i;
	}
	return out;
}

long long gcd(long long a, long long b) {
	long long r = -1;
	if (a < b) {
		swap(a, b);
	}
	while (r != 0) {
		r = a % b;
		if (r == 0) {
			return b;
		}
		else {
			a = b;
			b = r;
		}
	}
}

long long lcm(long long a, long long b) {
	return a * b / gcd(a, b);
}

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


Measured memory_bytes: 256
class UnionFind:
  def __init__(self, size):
  # 負の値はルート (集合の代表) で集合の個数
  # 正の値は次の要素を表す
    self.table = [-1 for _ in range(size)]

  # 集合の代表を求める
  def find(self, x):
    if self.table[x] < 0:
      return x
    else:
      # 経路の圧縮
      self.table[x] = self.find(self.table[x])
      return self.table[x]

  # 併合
  def union(self, x, y):
    s1 = self.find(x)
    s2 = self.find(y)
    if s1 != s2:
      if self.table[s1] <= self.table[s2]:
        # 小さいほうが個数が多い
        self.table[s1] += self.table[s2]
        self.table[s2] = s1
      else:
        self.table[s2] += self.table[s1]
        self.table[s1] = s2
      return True
    return False

N = int(input())
ixy=[]
for i in range(N):
  x, y = map(int,input().split())
  ixy+=[[i,x,y]]
costs = []

ixy.sort(key=lambda x:x[1])
for j in range(N-1):
  costs += [(ixy[j][0], ixy[j+1][0], ixy[j+1][1]-ixy[j][1])]
  costs += [(ixy[j+1][0], ixy[j][0], ixy[j+1][1]-ixy[j][1])]
ixy.sort(key=lambda y:y[2])
for j in range(N-1):
  costs += [(ixy[j][0], ixy[j+1][0], ixy[j+1][2]-ixy[j][2])]
  costs += [(ixy[j+1][0], ixy[j][0], ixy[j+1][2]-ixy[j][2])]

costs.sort(key=lambda cost:cost[2])
ans = 0
roots = UnionFind(N)
for cost in costs:
  u, v, c = cost
  if roots.find(u)!=roots.find(v):
    roots.union(u, v)
    ans += c
    
print(ans)

Measured memory_bytes: 73892
import math
from collections import defaultdict,deque
import numpy as np
import heapq
INF=10**12+1
a=input()
a=int(a)
graph = defaultdict(list)
for i in range(a):
    graph[i].append((1,(i+1)%a))
    graph[i].append((0,(i*10)%a))
costs=[INF]*a
costs[1]=1
que = [] #後ろの方が優先度高いqueue
que.append((0,1))
while len(que)!=0:
    temp=heapq.heappop(que)
    now=temp[1]
    v_now=graph[now]
    for c,n in v_now: #v nowから出てる総てのノードについて操作する c→ノードのコスト n→行き先
        if costs[n]>c+costs[now]: #改善したのでそのvは走査の余地あり
            costs[n]=c+costs[now]
            heapq.heappush(que,(c,n))
            
print(costs[0])
        

Measured memory_bytes: 58696
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
vector<T> Dijkstra(int s, vector<vector<pair<int, T>>>& g) {
    priority_queue<pair<T, int>, vector<pair<T, int>>, greater<pair<T, int>>>
        que;
    int n = sz(g);
    vector<T> d(n);
    rep(i, n) d[i] = LINF;
    d[s] = 0;
    que.push(make_pair(0LL, s));
    while (!que.empty()) {
        pair<T, int> p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
        for (auto e : g[v]) {
            if (chmin(d[e.first], d[v] + e.second)) {
                que.push(make_pair(d[e.first], e.first));
            }
        }
    }
    return d;
}
int main() {
    int n;
    cin >> n;
    vector<vector<pair<int, ll>>> g(n);
    rep(i, n - 1) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].emplace_back(b, 1ll);
        g[b].emplace_back(a, 1ll);
    }
    auto d = Dijkstra(0, g);
    int v = max_element(all(d)) - d.begin();
    auto e = Dijkstra(v, g);
    ll x = *max_element(all(e)) + 1;
    vector<bool> dp(1001001, 0);
    dp[0] = 0;
    dp[1] = 1;
    dp[2] = 0;
    for (int i = 1; i < x; i++) {
        if (!dp[i]) {
            dp[i + 1] = 1;
            dp[i + 2] = 1;
        }
    }
    cout << (dp[x] ? "First" : "Second") << endl;
}

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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

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

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

// 最小公倍数
unsigned lcm(unsigned a, unsigned b){
    return a / gcd(a, b) * b; 
}

int main(){
    string S;
    cin >> S;
    int ans = 0;
    REP(i, 4) if(S.at(i) == '2') ans++;
    print(ans);
}






Measured memory_bytes: 256
n,w = map(int,input().split())

#d[i][j]:i→jへの距離
d = [[float("inf")]*n for i in range(n)]
for i in range(w):
   x,y,z = map(int,input().split())
   d[x][y] = z 


dp = [[-1] * n for i in range(1<<n)]


#訪れた集合がs、今いる点がvの時０に戻る最短経路
def rec(s,v,dp):
    if dp[s][v] >= 0:
        return dp[s][v]
        
    if s == (1<<n)-1 and v == 0:
        #全ての頂点を訪れた(s = 11...11 and v = 0)
        dp[s][v] = 0
        return 0
    
    res = float("inf")
    for u in range(n):
        if (s>>u&1) == 0:
            #uに訪れていない時(uの箇所が0の時),次はuとすると
            res = min(res,rec(s|(1<<u),u,dp)+d[v][u])
            
    dp[s][v] = res
    return res
if rec(0,0,dp) != float("inf"):
    ans = rec(0,0,dp)
else:
    ans = -1

print(ans)


Measured memory_bytes: 18784
#include <bits/stdc++.h>
using namespace std;
int main() {
  int H = 0, W = 0;
  cin >> H >> W;
   for (int i = 0; i < W+2; i++) {
     cout << '#';
     if (i == W+1)
       cout << endl;
   }
  vector<char> vec(W);
   for (int i = 0; i < H; i++) {
          cout << '#';
      for (int i = 0; i < W; i++) {
        cin >> vec.at(i);
       cout << vec.at(i);      
      }
          cout << '#' << endl;
   }
  for (int i = 0; i < W+2; i++) {
     cout << '#';
     if (i == W+1)
       cout << endl;
  }
}

Measured memory_bytes: 3592
n,m = map(int,input().split())
d = {i:set([]) for i in range(1,n+1)}
e={i:0 for i in range(1,n+1)}
s={i for i in range(1,n+1)}
for _ in range(m):
    a,b = map(int,input().split())
    d[a]|={b}
    d[b]|={a}
    s-={a,b}
if len(s)!=0:
    print("No")
else:
    print("Yes")
    s={1}
    while(n>0):
        t=set([])
        for i in s:
            for j in d[i]:
                if e[j]==0:
                    e[j]=i
                    t|={j}
                    n-=1
        s=t
    for k,v in e.items():
        if k>1:
            print(v)

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

int main() {
  int N,MAX = -5;
  cin >> N;
  int dan = 0;
  vector<int> v(N);
  for (int i = 0; i < N; i++){
     cin >> v.at(i);
  }
 for (int i = 0; i < N; i++){
    int MAX = -5;
   for (int b = 0; b < N; b++){
     if (v.at(b) > MAX){
          MAX = v.at(b);
     }
   }
   if (MAX != -1){
     dan++;
     for (int i = 0; i < N; i++){
       if (MAX == v.at(i)){
         v.at(i) = -1;
       }
     }
   }
  }

  cout << dan << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
    int N;
    cin >> N;
    int now_dollar=0;
    for(int i=0; i * 4 < 100; i++) {
        for(int j=0; j * 7 < 100; j++) {
            if(((4*i) + (7*j) == N)) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<long long> a(n);
    map<long long, long long> mp;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        mp[a[i]]++;
    }
    long long sum = 0;
    for (auto x : mp ) {
        sum += x.second * (x.second - 1) / 2;
    }
    for(int i = 0; i < n; i++) {
        cout << sum - mp[a[i]] + 1 << '\n';
    }
  
    return 0;
}

Measured memory_bytes: 11008
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m;
	string str;
	multiset<string> s;
	multiset<string> :: iterator it;
	cin>>n>>m;
	while(n--)
	{
		cin>>str;
		s.insert(str);
	}
	for(it=s.begin();it!=s.end();it++)
	{
		cout<<*it;
	}
	cout<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int d, t, s; cin >> d >> t >> s;
	if (d <= t * s) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 3648
#include<map>
#include<cctype>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
#define int i64
using namespace std;
using i64=long long;
i64 read(){i64 x=0;int c=getchar(),f=1;while(isspace(c))c=getchar();if(c=='-')f=-1,c=getchar();while(isdigit(c))(x*=10)+=c&15,c=getchar();return f*x;}
const int N=200007,P=1000000007;
struct frac{i64 x,y;}imp[N];
int operator<(frac a,frac b){return a.x<b.x||(a.x==b.x&&a.y<b.y);}
map<frac,int>mp;
int sz[N],vis[N],cnt,c1,c2,c3;
int pow(int a,int b){int r=1;for(;b;b>>=1,a=1ll*a*a%P)if(b&1)r=1ll*a*r%P;return r;}
void ins(i64 a,i64 b)
{
    frac f=frac{a,b};
    if(!mp.count(f)) mp[f]=++cnt,imp[cnt]=f,sz[cnt]=1; else ++sz[mp[f]];
}
signed main()
{
    int n=read();i64 ans;
    for(int i=1;i<=n;++i)
    {
	i64 a=read(),b=read(),d=__gcd(a,b);
	if(!a&&!b) {++c3;continue;}
	if(!a) {++c1;continue;}
	if(!b) {++c2;continue;}
	a/=d,b/=d;
	if(b<0) a*=-1,b*=-1;
	ins(a,b);
    }
    ans=(pow(2,c1)+pow(2,c2)-2)%P;
    for(int i=1;i<=cnt;++i)
    {
	if(vis[i]) continue;
	frac g=imp[i];int x=0;
	swap(g.x,g.y),g.x*=-1;
	if(g.y<0) g.x*=-1,g.y*=-1;
	if(mp.count(g)) x=mp[g];
	ans=((ans+1)*(pow(2,sz[i])+pow(2,sz[x])-1)-1)%P;
	vis[x]=vis[i]=1;
    }
    cout<<(ans+c3+P)%P;
}


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

int main(){
    int N;
    cin>>N;
    int first_place = N % 10;
    if(first_place == 2 || first_place == 4 || first_place == 5 || first_place == 7 || first_place == 9){
        cout<<"hon"<<endl;
    } else if(first_place == 0 || first_place == 1 || first_place == 6 || first_place == 8){
        cout<<"pon"<<endl;
    } else if(first_place == 3){
        cout<<"bon"<<endl;
    }

    return 0;
}

Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define cinf(x,n) for(int i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(int i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

int main(){
	char a;
	cin >> a;
	if(a>='A'&&a<='Z')
		cout << 'A' << endl;
	else 
		cout << 'a' << endl;
}

Measured memory_bytes: 3632
import sys
from bisect import bisect_right

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    N, *A = map(int, read().split())

    dp = [A.pop()]
    for a in reversed(A):
        if a >= dp[-1]:
            dp.append(a)
        else:
            dp[bisect_right(dp, a)] = a

    print(len(dp))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 14092
k = int(input())
s = input()
n = len(s)
mod = 10**9+7
def cmb(n,r,mod):
    r = min(r, n-r)
    return (fact[n] * factinv[r] * factinv[n-r]) % mod
def makefact(n,mod):
    fact = [1,1]
    factinv = [1,1]
    inv = [0,1]
    for i in range(2,n+1):
        fact.append((fact[-1]*i) % mod)
        inv.append(-inv[mod%i]*(mod//i)%mod)
        factinv.append((factinv[-1]*inv[-1])%mod)
    return fact,factinv
fact,factinv = makefact(2*10**6+5,mod)
ans = 0
for i in range(k+1):
    temp = pow(26,i,mod)
    c = cmb(n+k-i-1,n-1,mod)
    temp *= c*pow(25,k-i,mod)
    ans = (ans+temp)%mod
print(ans)

Measured memory_bytes: 197248
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = list(str(input()))

for i in range(len(t) - k):
    if t[i] == t[i+k]:
        t[i+k] = '-'


score = 0
for i in range(len(t)):
    if t[i] == 'r':
        score += p
    elif t[i] == 's':
        score += r
    elif t[i] == 'p':
        score += s


print(score)


Measured memory_bytes: 4084
#include <cstdio>
#include <algorithm>

using namespace std;

int n;
int x;
int a[200];

int main()
{
	scanf("%d%d", &n, &x);
	
	for (int i = 0 ; i < n ; i++)
		scanf("%d", &(a[i]));
		
	sort(a, a + n);
	int count = 0;
	int sum = 0;
	int remain = x;
	int p = 0;
	while (p < n && remain >= a[p])
	{
		remain = remain - a[p];
		p++;
	}
	
	if (p < n)
	{
		count = p;
	}
	else
	{
		if (remain == 0)
			count = n;
		else
			count = n - 1;
	}
	
	printf("%d\n", count);
	
	
	
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a;
    scanf("%d",&a);
    int t=0,i;
    //long int b[a],k=0;
    long int b[200000],k=0;
    //int b[1500000],k=0;
    for(i=0;i<a;i++){
        scanf("%ld",&b[i]);
        if(t<b[i]) t=b[i];
        else k+=t-b[i];
    }
    printf("%ld",k);
    return 0;
}


Measured memory_bytes: 3716
#include <cstdio>
int h, w, k, x[505][505];
int a[250005],b[250005],c[250005],d[250005];
int main() {
	int i, j;
	scanf("%d%d", &h, &w);
	for(i=1; i<=h; i++) for(j=1; j<=w; j++) scanf("%d", &x[i][j]);
	for(i=1; i<=h; i++) for(j=1; j<=w; j++) if(x[i][j]%2) {
		if(j!=w) x[i][j+1]++, a[k]=i, b[k]=j, c[k]=i, d[k]=j+1, k++;
		else if(i!=h) x[i+1][j]++, a[k]=i, b[k]=j, c[k]=i+1, d[k]=j, k++;
	}
	printf("%d\n", k);
	for(i=0; i<k; i++) printf("%d %d %d %d\n", a[i], b[i], c[i], d[i]);
	return 0;
}

Measured memory_bytes: 5888
package main

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

func main() {
	sc := NewScanner()
	N, D := sc.NextInt(), sc.NextInt()
	X := make([][]int, N)
	for i := 0; i < N; i++ {
		X[i] = sc.NextIntArray()
	}

	count := 0
	for i := 0; i < N; i++ {
		for j := i + 1; j < N; j++ {
			A := 0
			for k := 0; k < D; k++ {
				A += pow(X[i][k]-X[j][k], 2)
			}
			B := int(math.Sqrt(float64(A)))
			if B*B == A {
				count++
			}
		}
	}
	fmt.Println(count)

}

//aのb乗をします O(log b)
func pow(a int, b int) int {
	total := 1
	tmp := a
	for b > 0 {
		if b%2 == 1 {
			total *= tmp
		}
		b /= 2
		tmp *= tmp
	}
	return total
}

func min(a int, b int) int {
	if a < b {
		return a
	}
	return b
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


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

int main() {
	size_t N, W;
	cin >> N >> W;
	vector<size_t> w(N);
	vector<long> v(N);
	vector<vector<long>> dp(N, vector<long>(W));
	for (size_t i = 0; i < N; ++i) cin >> w.at(i) >> v.at(i);
	for (size_t i = 0; i < W; ++i) {
		if (w.at(0) <= i + 1) dp[0][i] = v.at(0);
	}
	for (size_t i = 1; i < N; ++i) {
		for (size_t j = 0; j < W; ++j) {
			if (w.at(i) <= j) dp[i][j] = max(v.at(i) + dp[i - 1][j - w.at(i)], dp[i - 1][j]);
			else dp[i][j] = dp[i - 1][j];
		}
	}
	cout << dp[N - 1][W - 1];
}

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

using namespace std;

#define int long long
#define INF 1e9
#define LINF 1e18

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;

typedef pair<P, P> PP;

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

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

map<Pi, bool> mp;

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

    int N;
    cin >> N;
    int res = 0;
    for(int i = 0; i < N; ++i) {
    	int p[3];
    	cin >> p[0] >> p[1] >> p[2];
    	sort(p, p + 3);
    	Pi tmp = Pi(P(p[0], p[1]), p[2]);
    	if(mp[tmp]) ++res;
    	mp[tmp] = true;
    }
    cout << res << endl;
	return 0;
}



Measured memory_bytes: 3244
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
#define MuhammedAly ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define popc(x) __builtin_popcount(x)
#define LLMX 1e18
#define NotinRange(n,m) i<0||i>=(n)||j<0||j>=(m)
#define mem(x,y) memset((x),(y),sizeof (x));
#define sz(a) (int)(a).size()
#define inFile(s) freopen((s),"r",stdin)
#define	outFile(s) freopen((s),"w",stdout)
#define biEdge(v, a, b) (v)[(a)].pb((b)), (v)[(b)].pb((a))
#define pi (2 * acos(0))
#define X real()
#define Y imag()
#define cross(a, b) ((conj(a) * (b)).Y)
#define dot(a, b) ((conj(a) * (b)).X)
#define vec(a,b) ((b) - (a))
#define ll long long
typedef long double ld;
typedef complex<double>point;
typedef tuple<int, int, int> line;
typedef pair<point, point>segment;
typedef vector<point>polygon;
const int N = 1e3 + 5, M = 50 + 5, OO = 0x3f3f3f3f, mod = 1e9 + 7, base = 131, mod2 = 1000136437, mod3 = 998244353;
const double EPS = 1e-9;
int n, m, memo[N][N];
char arr[N][N];
int solve(int i, int j)
{
    if(i > n || j > m || arr[i][j] == '#')
        return 0;
    if(i == n - 1 && j == m - 1)
        return 1;
    int &ret = memo[i][j];
    if(~ret)
        return ret;
    ret = (solve(i + 1, j) + solve(i, j + 1)) % mod;
    return ret;
}
int main()
{
    MuhammedAly
    cin >> n >> m;
    mem(memo, -1);
    for(int i = 0 ; i < n ; i++)
        for(int j = 0 ; j < m ; j++)
            cin >> arr[i][j];
    cout << solve(0, 0) % mod;
    return 0;
}

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

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  int c = 0, a = s.length();
  for (int i = 0; i < a; ++i){
	if ((int)s[i] - '0' != i % 2){
		++c;
	}
  }
  cout << min(c, a - c) << "\n";
return 0;
}

Measured memory_bytes: 512
#!/usr/bin/python
# -*- coding: utf-8 -*-

MOD = 998244353


############
l = raw_input()
N, A, B, K = [int(x) for x in l.split()]

Fac = [1] * (N+1)
invFac = [1] * (N+1)
for i in xrange(2, N+1):
	Fac[i] = (Fac[i-1] * i) % MOD
for i in xrange(2, N+1):
	invFac[i] = pow(Fac[i], MOD-2, MOD)

def C(n, m):
	return (((Fac[n] * invFac[m]) % MOD) * invFac[n-m]) % MOD

# print invFac[:20]

pl = []
for a in xrange(N+1):
	b = (K-A*a)//B
	if b < 0 or b > N:
		continue
	if A*a + B*b != K:
		continue
	pl.append((a, b))

# print pl

ans = 0
for a, b in pl:
	ans = (ans + (C(N, a) * C(N, b)) % MOD) % MOD
print ans

Measured memory_bytes: 57452
from itertools import groupby

S = input()
K = int(input())

A = [len(tuple(v)) for _, v in groupby(S)]
if len(A) == 1:
    print((len(S) * K) // 2)
    quit()

t = sum(a // 2 for a in A)
if S[0] == S[-1]:
    l, r = A[0], A[-1]
    m = t - l // 2 - r // 2
    print(K * m + (K - 1) * ((r + l) // 2) + r // 2 + l // 2)
else:
    print(t * K)


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

using namespace std;

int decode(string a);
string encode(int a);
int base(char a);

int main() {
	string str1, str2, ans; // 入力MCXI文字列2つ、答えのMCXI文字列
	int a, b, sum;
	int n;

	/*
	cin >> str1;
	cout << decode(str1) << endl;
	*/

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> str1 >> str2;
		a = decode(str1);
		b = decode(str2);
		sum = a + b;
		
		ans = encode(sum);
		//cout << a << " " << b << " " << sum << " " << ans << endl;
		cout << ans << endl;
	}

	return 0;
}

int decode(string a) {
	int n = 0;
	char c;
	for (unsigned int i = 0; i < a.size(); i++) {
		c = a.at(i);
		//cout << c << endl;
		if (!(c >= '2' && c <= '9')) {
			//cout << "0" << endl;
			if (i == 0) {
				//cout << "1" << endl;
				n += base(c);
			} else {
				//cout << "2" << endl;
				if (a.at(i - 1) >= '2' && a.at(i - 1) <= '9') {
					//cout << "3" << endl;
					n += base(c) * (a.at(i - 1) - '0');
				} else {
					//cout << "4" << endl;
					n += base(c);
				}
			}
		}
		//cout << "n = " << n << endl;
	}
	
	return n;
}

string encode(int a) {
	string str;
	int n = 0;
	string b = "mcxi";
	int mod;

	for (int i = 1000; i >= 1; i /= 10) {
		mod = a % i;
		a /= i;
		if (a >= 1) {
			if (a >= 2) {
				str += a + '0';
			}
			str += b[n];
		}
		n++;
		a = mod;
	}
	
	return str;
}

int base(char a) {
	if (a == 'm') {
		return 1000;
	} else if (a == 'c') {
		return 100;
	} else if (a == 'x') {
		return 10;
	} else if (a == 'i') {
		return 1;
	} else {
		return -1;
	}
}

Measured memory_bytes: 1208
import bisect
import numpy as np
N, M = map(int, input().split())
AB = []
for i in range(N):
  A, B = map(int, input().split())
  AB.append([A, B])
AB = np.array(AB)
arg_sort = np.argsort(AB[:, 0])
a = AB[arg_sort, 0]
b = AB[arg_sort, 1]
s = np.cumsum(b)
sect_id = bisect.bisect_left(s, M)
out = np.dot(a[:sect_id], b[:sect_id]) + (M - sum(b[:sect_id])) * a[sect_id]
out = int(out)
print(out)

Measured memory_bytes: 30080
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N;
  cin >> N;
  
  int f=0;
  
  for(int i=1 ; i<10 ; i++){
    
    if(N/i<10 && N%i==0){
      
      cout << "Yes" << endl;
      
      break;
    }
    
    else{
      f++; 
    }
    
  }
  
  if(f==9){
    
    cout << "No" << endl;
    
  }
  
  
  
}

Measured memory_bytes: 256
N, M = map(int, input().split())
shops = sorted([list(map(int, input().split())) for _ in range(N)])

total = 0
for shop in shops:
    if M != 0:
        if shop[1] <= M:
            total += shop[0] * shop[1]
            M -= shop[1]
        else:
            total += shop[0] * M
            M = 0
    else:
        break

print(total)

Measured memory_bytes: 28264
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>

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

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> P;
typedef std::pair<P, int> PP;
struct edge{ int to, time, cost; };
const double esp = 1e-9;
const int infi = (int)1e+9 + 10;
const ll infll = (ll)1e+17 + 10;

const int max = 21;
int cost[max];
std::vector<P> g[max];
int n, m;

void dijkstra(int k){
	std::priority_queue < P, std::vector<P>, std::greater<P> > que;
	for (int i = 0; i < n; ++i)cost[i] = infi;
	cost[k] = 0;
	que.push(P(0, k));
	while (!que.empty()){
		P p = que.top();
		que.pop();
		int v = p.second;
		if (cost[v] < p.first)continue;
		for (int i = 0; i < g[v].size(); ++i){
			P e = g[v][i];
			if (cost[e.first] > cost[v] + e.second){
				cost[e.first] = cost[v] + e.second;
				que.push(P(cost[e.first], e.first));
			}
		}
	}
}

int main(){
	std::cin >> n >> m;
	rep(i, m){
		int a, b, c, d;
		char ch;
		std::cin >> a >> ch >> b >> ch >> c >> ch >> d;
		--a, --b;
		P p(b, c), q(a, d);
		g[a].push_back(p);
		g[b].push_back(q);
	}
	int x1, x2, y1, y2;
	char ch;
	std::cin >> x1 >> ch >> x2 >> ch >> y1 >> ch >> y2;
	--x1, --x2;
	dijkstra(x1);
	y1 -= cost[x2];
	dijkstra(x2);
	y1 -= cost[x1];
	y1 -= y2;
	std::cout << y1 << std::endl;
	return 0;
}

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

using namespace std;

int main() {
	int d, t, s;
	cin >> d >> t >> s;

	double x = 1.0 * d / s;
	bool ok = x <= t;

	cout << (ok ? "Yes" : "No") << endl;
	return 0;
}


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

int main(){
	int a, b, c, d;
	scanf("%d %d %d %d", &a, &b, &c, &d);
	int t;
	t = a + b + c + d;
	int m, s;
	s = t % 60;
	m = (t - s) / 60;
	printf("%d\n%d\n", m, s);

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>

#define MAXN 1000

using namespace std;

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

    int h, w;
    cin >> h >> w;

    string g[h];
    int d[h][w];
    for(int i=0 ; i<h ; i++) cin >> g[i];

    // init
    d[0][0] = 1;
    for(int i=1 ; i<h ; i++)
        if(g[i][0] == '#') d[i][0] = 0;
        else d[i][0] = d[i-1][0];
    for(int i=1 ; i<w ; i++)
        if(g[0][i] == '#') d[0][i] = 0;
        else d[0][i] = d[0][i-1];

    for(int i=1 ; i<h ; i++)
    {
        for(int j=1 ; j<w ; j++)
            if(g[i][j] == '#') d[i][j] = 0;
            else d[i][j] = (d[i-1][j] + d[i][j-1]) % 1000000007;
    }
    cout << d[h-1][w-1];

    return 0;
}

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

int main() {
	int n, m, x, a[101];
	cin >> n >> m >> x;
	int l = 0, r = 0;
	for (int i = 0;i < m;i++) {
		cin >> a[i];
		if (a[i] < x) {
			l++;
		}
		else {
			r++;
		}
	}
	cout << min(l, r);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	void run() {
		Scanner sc = new Scanner(System.in);

		while (sc.hasNext()) {
			double a = sc.nextInt();
			double b = sc.nextInt();
			double c = sc.nextInt();
			double d = sc.nextInt();
			double e = sc.nextInt();
			double f = sc.nextInt();

			// 連立方程式の解
			double x = (b * f - c * e) / (b * d - a * e);
			double y = (c * d - a * f) / (b * d - a * e);

			if (x == 0)
				x = 0;
			if (y == 0)
				y = 0;

			System.out.printf("%.3f %.3f\n", x, y);

			// BigDecimal ax = new BigDecimal(x);
			// BigDecimal ay = new BigDecimal(y);
			//
			// // 小数第4位を四捨五入
			// ax = ax.setScale(3, BigDecimal.ROUND_HALF_UP);
			// ay = ay.setScale(3, BigDecimal.ROUND_HALF_UP);
			//
			// System.out.println(ax + " " + ay);
		}

		sc.close();
	}

	void run1() {
		Scanner sc = new Scanner(System.in);

		double[] a = new double[6];

		while (sc.hasNext()) {
			for (int i = 0; i < 6; i++) {
				a[i] = sc.nextDouble();
			}

			double d = a[0] * a[4] - a[1] * a[3];
			double x = (a[4] * a[2] - a[1] * a[5]) / d;
			double y = (a[0] * a[5] - a[3] * a[2]) / d;

			if (x == 0)
				x = 0;
			if (y == 0)
				y = 0;

			System.out.printf("%.3f %.3f\n", x, y);
		}

		sc.close();
	}

	public static void main(String[] args) {
		new Main().run1();
	}

}

Measured memory_bytes: 20468
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

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

	if( b+a >= x && x >= a ) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>

template<typename T, typename V>
bool exists(T ary, V v)
{
    return std::find(std::cbegin(ary), std::cend(ary), v) != std::cend(ary);
}

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

    int m = n % 10;
    std::array hon = { 2, 4, 5, 7, 9 };
    std::array pon = { 0, 1, 6, 8 };
    std::array bon = { 3 };

    if (exists(hon, m))
    {
        std::cout << "hon" << std::endl;
    }
    else if (exists(pon, m))
    {
        std::cout << "pon" << std::endl;
    }
    else
    {
        std::cout << "bon" << std::endl;
    }
}


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

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

int main()
{
    int N;
    cin >> N;
    char s = '0';
    int ans = 0;
    repeat(i, N) {
        char ss;
        cin >> ss;
        if (s != ss) {
            s = ss;
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
using namespace std;
priority_queue<int>p;
int n, x, ans;
int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> x;
		p.push(x);
		cin >> x;
		p.push(x);
	}
	for (int i = 1; i <= n; i++)
	{
		p.pop();
		ans += p.top();
		p.pop();
	}
	cout << ans;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
	class Program
	{
		static void Main(string[] args)
		{
			var temp = (Console.ReadLine().Split(' '));
			var height = int.Parse(temp[0]);
			var width = int.Parse(temp[1]);
			var data = new string[height];
			for (int i = 0; i < height; i++)
			{
				data[i] = Console.ReadLine();
			}
			for (int i = 0; i < width + 2; i++) Console.Write('#');
			Console.WriteLine();
			for (int i = 0; i < height; i++) Console.WriteLine("#" +data[i] + "#");
			for (int i = 0; i < width + 2; i++) Console.Write('#');
			Console.WriteLine();
		}
	}
}

Measured memory_bytes: 13140
//84104971101048411497 - Can you guess what does this mean?
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef complex<double> point;
#define mapii map<int, int>
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) fto(i, l, r) cout << a[i] << " "; cout << endl
#define fdto(i,  r, l) for(int i = (r); i >= (l); --i)
#define fto(i, l, r) for(int i = (l); i <= (r); ++i)
#define forit(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define forrit(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define X real()
#define Y imag()
#define maxN 100005
#define oo 2000000007
#define sz(a) (int)a.size()

const double PI = acos(-1.0);

double fRand(double fMin, double fMax)
{
    double f = (double)rand() / RAND_MAX;
    return fMin + f * (fMax - fMin);
}

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

int n, m, deg[maxN];


int main () {
    scanf("%d%d", &n, &m);
    fto(i, 1, m) {
        int u, v;
        scanf("%d%d", &u, &v);
        ++deg[u]; ++deg[v];
    }

    fto(i, 1, n) {
        if (deg[i]&1) {
            puts("NO");
            return 0;
        }
    }

    puts("YES");

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
typedef long long ll;
#define sz(a) int((a).size());
#define pb push_back;
#define all(c) c.begin(),c.end();
#define tr(c,i) for(typeof(c).begin() i = c.begin(); i != c.end(); i++);
#define present(c,x) (c.find(x) != c.end());
#define cpresent(c,x) (find(all(c),x) != c.end());


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    if(s[1]=='R'){
        cout<<"ABC\n";
    }
    else{
        cout<<"ARC\n";
    }
	return 0;
}


Measured memory_bytes: 3612
N = int(input())

min_ = N

for i in range(N+1):
  x = 0
  n = i
  while n > 0:
    x += n % 6
    n //= 6  
  n = N-i
  while n > 0:
    x += n % 9
    n //= 9
  
  min_ = min(min_, x)
print(min_)
    

Measured memory_bytes: 2940
#include <iostream>


using namespace std;

int main() {
	int A, B;
	cin >> A >> B;
	int start8 = A * 25/2 + A%2;
	int start10 = B * 10;
	int end8 = start8 + 12 - A%2;
	int end10 = start10 + 9;
	if (end10 < start8 || end8 < start10) cout << -1;
	else cout << (start8 > start10 ? start8 : start10);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define rep11(i, n) for (int i = 1; i < (int)(n); ++i)
#define repo(i, o, n) for (int i = o; i < (int)(n); ++i)
#define repm(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1002000007
#define INF LONG_LONG_MAX

typedef pair<long long, long long> P;
int main(){
    int n,m;
    cin>>n>>m;
    vector<int> v;
    vector<int> w;
    rep(i,m){
        int x;
        cin>>x;
        v.push_back(x);
    }
    int ans=0;
    sort(v.begin(),v.end());
    if(n>m){
        cout<<0<<endl;
    }
    
    else{
        rep(i,m-1){
            w.push_back(v[i+1]-v[i]);
        }
        sort(w.begin(),w.end());
        rep(i,m-n){
            ans+=w[i];
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 1400
using System;

class Program
{
    static void Main(string[] args)
    {
        var str = Console.ReadLine().Split();
        var A = int.Parse(str[0]);
        var B = int.Parse(str[1]);
        var C = int.Parse(str[2]);
        var D = int.Parse(str[3]);
        var E = int.Parse(str[4]);
        var F = int.Parse(str[5]);

        var max_s = 0;
        var max_w = 0;

        for (int a = 0; (A * a) * 100 <= F; a++)
        {
            for (int b = 0; (A * a + B * b) * 100 <= F; b++)
            {
                var w = A * a + B * b;
                for (int c = 0; C * c <= E * w; c++)
                {
                    for (int d = 0; C * c + D * d <= E * w; d++)
                    {
                        var s = C * c + D * d;
                        if (F < w * 100 + s) break;

                        if (p(max_s, max_w * 100) <= p(s, w * 100))
                        {
                            max_w = w;
                            max_s = s;
                        }
                    }
                }
            }
        }

        Console.WriteLine($"{max_w * 100 + max_s} {max_s}");
    }

    static double p(double s, double w)
    {
        if (s + w == 0) return 0;
        else return 100 * s / (s + w);
    }
}


Measured memory_bytes: 13140
n = int(input())
list = []

for i in range(n) :
	s,p = input().split()
	p = str(100-int(p))
	if (int(p) < 10) : p = '00' + p
	elif(int(p) < 100) : p = '0' + p
	index = str(i)
	if (i < 10) : index = '00' + index
	elif (i < 100) : index = '0' + index
	list.append(s+p+index)

list.sort()
for i in range(n) :
	print(int(list[i][-3:])+1)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
  int array[31]={0};
  int n;
  for(int i=0;i<28;i++){
    cin>>n;
    array[n]++;
  }
  for(int i=0;i<30;i++)
    if(array[i+1]==0) cout<<i+1<<endl;
  return 0;
}
   

Measured memory_bytes: 1160
N = raw_input()
V = raw_input()
C = raw_input()

Va = V.split(" ")
Ca = C.split(" ")

Va = map(lambda x: int(x), Va)
Ca = map(lambda x: int(x), Ca)


X = 0
Y = 0
for v, c in zip(Va, Ca):
  if v > c:
    X += v
    Y += c

print(X - Y)

Measured memory_bytes: 2568
var
  n,m,i,j,zrt:longint;
  p,y,a,b,c,o:array[0..1000000]of longint;
Procedure ch(var x,y:longint);
var
  t:longint;
begin
  t:=x;x:=y;y:=t;
end;
Procedure qs(l,r:longint);
var
  i,j,mid1,mid2:longint;
begin
  i:=l;j:=r;mid1:=p[(l+r)div 2];mid2:=y[(l+r)div 2];
  repeat
    while (p[i]<mid1)or((p[i]=mid1)and(y[i]<mid2)) do inc(i);
    while (p[j]>mid1)or((p[j]=mid1)and(y[j]>mid2)) do dec(j);
    if i<=j then
      begin
        ch(p[i],p[j]);
        ch(y[i],y[j]);
        ch(c[i],c[j]);
        inc(i);dec(j);
      end;
  until i>j;
  if l<j then qs(l,j);
  if i<r then qs(i,r);
end;


begin
  readln(n,m);
  for i:=1 to m do
    begin
      readln(p[i],y[i]);
      a[i]:=p[i];c[i]:=i;
    end;
  qs(1,m);
  for i:=1 to m do
    begin
      if (i=1)or(p[i]<>p[i-1]) then j:=1 else inc(j);
      o[c[i]]:=j;
    end;
  for i:=1 to m do
    begin
      zrt:=100000;
      for j:=1 to 6 do
        begin
          if a[i]<zrt then
            begin
              zrt:=zrt div 10;
              write(0);
            end else
          break;
       end;
      write(a[i]);
      zrt:=100000;
      for j:=1 to 6 do
        begin
          if o[i]<zrt then
            begin
              zrt:=zrt div 10;
              write(0);
            end else
          break;
        end;
      writeln(o[i]);
  end;
      end.


Measured memory_bytes: 14080
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int a, b;
    cin >> a >> b;
    if((a*b)%2 == 1) {
        cout << "Odd";
    }
    else {
        cout << "Even";
    }
    
    cout << endl;
    return 0;
}

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

int main() {
  int n,a,b;
  cin >> n >> a >> b;
  
  int c = n*a;
  
if(c<b){
  cout << c << endl;
}
  else if(c>b){
  cout << b << endl;
}
  else{
      cout << b << endl;
  }
}


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

int main() {
    int n; std::cin >> n;
    std::set<int> s;
    for (int i = 0; i < n; i++) {
        int a; std::cin >> a;
        s.insert(a);
    }
    std::cout << s.size() << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll, vl/*, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); ++i)
#define rep2(i, n) for(ll i = 1; i <= ll(n); ++i)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); ++i)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); ++i)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll n;
  string s;
  cin >> n >> s;
  
  rep(i, n) rep(j, s.size()) {
    if(s[j]=='Z') s[j]='A';
    else s[j]++;
  }
  
  cout << s << newl;
  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 repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

int main(){
    ll x, y;
    cin >> x >> y;
    ll ans = 0;
    while(x <= y){
        ans++;
        x *= 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define LINF 1e18
#define INF 1e9
using namespace std;

int main(){
    
    ll n,m;
    cin >> n >> m;
    char c[n];
    bool flag[n] = {false};
    rep(i,0,n) c[i] = (char)(max(0LL, 1-i) + '0');
    if(n == 1) c[0] = '0';

    rep(i,0,m){
        ll a,b;
        cin >> a >> b;

        if(flag[a-1] && ('0' + b) != c[a-1]){
            cout << -1 << endl;
            return 0;
        }
        else if(a == 1 && b == 0 && n != 1){
            cout << -1 << endl;
            return 0;
        }

        flag[a-1] = true;
        c[a-1] = '0' + b;
    }

    rep(i,0,n) cout << c[i];
    cout << endl;
    return 0;
}

Measured memory_bytes: 256