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

using namespace std;

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;

constexpr int MAXN = 10000;

int dp[MAXN + 2][6];
int cost[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
int pos[10];
int ns[6];
int lpos = 0;

bool cmpstate(int a[], int b[]) {
	int as = 0, bs = 0;
	for(int i = 0; i < lpos; i++) {
		as += a[i];
		bs += b[i];
	}
	if(as > bs)
		return true;
	if(as < bs)
		return false;
	for(int i = 0; i < lpos; i++) {
		if(a[i] > b[i])
			return true;
		if(a[i] < b[i])
			return false;
	}
	return false;
}

int main() {
	int N, M;
	cin >> N >> M;
	for(int i = 0; i < M; i++) {
		int A;
		cin >> A;
		if(pos[cost[A]] < A)
			pos[cost[A]] = A;
	}
	for(int i = 0; i < 10; i++) {
		if(pos[i]) {
			pos[lpos++] = pos[i];
		}
	}
	sort(pos, pos + lpos);
	reverse(pos, pos + lpos);
	for(int i = 0; i <= N; i++)
		dp[i][0] = -1;
	for(int i = 0; i < lpos; i++) {
		dp[cost[pos[i]]][0] = 0;
		dp[cost[pos[i]]][i] = 1;
	}
	for(int i = 0; i <= N; i++) {
		for(int j = 0; j <= i / 2; j++) {
			if(dp[j][0] == -1 || dp[i - j][0] == -1)
				continue;
			for(int k = 0; k < lpos; k++)
				ns[k] = dp[j][k] + dp[i - j][k];
			if(cmpstate(ns, dp[i])) {
				// cout << j << ' ' << i - j << " -> " << i << endl;
				for(int k = 0; k < lpos; k++)
					dp[i][k] = ns[k];
			}
		}
	}
	for(int i = 0; i < lpos; i++) {
		for(int j = 0; j < dp[N][i]; j++)
			cout << pos[i];
	}
	cout << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  if(a == b){
    cout << "Draw" << endl;
  }else if(a == 1){
    cout << "Alice" << endl;
  }else if(b == 1){
    cout << "Bob" << endl;
  }else if(a > b){
    cout << "Alice" << endl;
  }else{
    cout << "Bob" << endl;
  }
}

Measured memory_bytes: 256
//#include "debug.h"
#include <string.h>
#include <limits.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

#define MAXN 100000
typedef long long i64;

int n;
int a[MAXN], b[MAXN], c[MAXN], d[MAXN], e[MAXN];

int input() {
	if (scanf("%d", &n) < 0) return 0;
	for (int i=0; i<n; i++) scanf("%d", &a[i]);
	for (int i=0; i<n; i++) scanf("%d", &b[i]);
	return 1;
}

void init() {
}

int permutation_cycle_len(int *a, int n, int i) {
	int j = a[i], c = 1;
	while (j!=i) j = a[j], c++;
	return c;
}

void permutation_mul(int *a, int *b, int *c, int n) {
	for (int i=0; i<n; i++)
		c[i] = b[a[i]];
}

void permutation_inv(int *a, int *b, int n) {
	for (int i=0; i<n; i++) b[i] = i;
	sort(b, b+n, [&](auto &x, auto &y) {
		return a[x] < a[y];
	});
}

int solve() {
	permutation_inv(b, c, n);
	permutation_inv(a, d, n);

	sort(a, a+n);
	sort(b, b+n);
	for (int i=0; i<n; i++)
		if (a[i]>b[i]) return 0;
	for (int i=1; i<n; i++)
		if (a[i]<=b[i-1]) return 1;

	permutation_inv(c, e, n);
	permutation_mul(e, d, c, n); //c=c'*d
	int one = permutation_cycle_len(c, n, 0)==n;
	if (!one) return 1;

	return 0;
}

void output(int ans) {
	printf("%s\n", ans? "Yes":"No");
}

void cleanup() {
}

int main() {
	//precalc();
	//int ca; scanf("%d", &ca);
	while (input()) {
		init();
		output(solve());
		cleanup();
		//break;
	}
}




Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
template<typename T>inline void read(T &x)
{
	x=0;
	static int p;p=1;
	static char c;c=getchar();
	while(!isdigit(c)){if(c=='-')p=-1;c=getchar();}
	while(isdigit(c)) {x=(x<<1)+(x<<3)+(c-'0');c=getchar();}
	x*=p;
}
int n;
int a[110];
int main()
{
//	freopen("ARC059C.in","r",stdin);
//	freopen("ARC059C.out","w",stdout);
	read(n);
	int tot=0;
	for(int i=1;i<=n;i++) 
		read(a[i]),tot+=a[i];
	int tobe1=tot/n,tobe2=tot/n+1,tobe3=tot/n-1;
	int ans1=0,ans2=0,ans3;
	for(int i=1;i<=n;i++)
		ans1+=(a[i]-tobe1)*(a[i]-tobe1),
		ans2+=(a[i]-tobe2)*(a[i]-tobe2),
		ans3+=(a[i]-tobe3)*(a[i]-tobe3);
	printf("%d\n",min(ans1,min(ans2,ans3)));
	return 0;
}

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

const int MOD = 1e9 + 7;

map<long long, int> mmp;

int f( long long x ) {
    if( x <= 1 )
        return x + 1;
    if( mmp[x] > 0 )
        return mmp[x];
    
    mmp[x] = ( 0LL + f(x / 2) + f((x - 1) / 2) + f((x - 2) / 2) ) % MOD;
    return mmp[x];
}

int main( void ) {
    
    long long n;
    
    cin >> n;
    cout << f(n) << endl;
    
    return 0;
}

Measured memory_bytes: 256
q=int(input())
n=10**5

work=[1 if i%2==1 else 0 for i in range(n+1)]
primes=[2]
lst=[0]*(n+1)
work[1]==0

for i in range(3,n,2):
    if not work[i]: continue
    primes.append(i)
    index=1
    while i*index<=n:
        work[i*index]=0
        index+=1

for i in primes[1:]:
    if (i+1)//2 in primes:
        lst[i]=1

for i in range(3,n+1):
    lst[i]+=lst[i-1]

for _ in range(q):
    left,right=map(int,input().split())
    print(lst[right]-lst[left-1])


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

const int N = 0;
int n;

int main()
{
	string z;
	cin >> z;
	if(z.size() < 4) cout << "No";
	else if(z[0] == 'Y' && z[1] == 'A' && z[2] == 'K' && z[3] == 'I') cout << "Yes";
	else cout << "No";
}

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

int D[30][30];
int c[500][500];
int SumColorD[3][30];
int TopThC[3][3] = { {-1,-1,-1},{-1,-1,-1},{-1,-1,-1} };

int main(){
	int N, C;
	cin >> N >> C;
	for(int i=0;i<C;i++)for(int j=0;j<C;j++)cin >> D[i][j];
	for(int i=0;i<N;i++)for(int j=0;j<N;j++)cin >> c[i][j];
	for(int i=0;i<C;i++)for(int j=0;j<N;j++)for(int k=0;k<N;k++)SumColorD[(j+k+2)%3][i]+=D[c[j][k]-1][i];

	for(int color=0;color<3;color++){
		for(int i=0;i<3;i++){
			int min_num = 0;
			int min_sum = INF;
			for(int j=0;j<C;j++){
				int flag = 0;
				for(int k=0;k<3;k++)if(j==TopThC[color][k]){flag++;break;}
				if(flag)continue;
				if(min_sum>SumColorD[color][j]){min_num = j; min_sum = SumColorD[color][j];}
			}
			TopThC[color][i] = min_num;
		}
	}
	
	int MIN = INF;
	for(int i=0;i<3;i++)for(int j=0;j<3;j++)for(int k=0;k<3;k++){
		if(TopThC[0][i]==TopThC[1][j] || TopThC[0][i]==TopThC[2][k] || TopThC[1][j]==TopThC[2][k])continue;
		int sumD = SumColorD[0][TopThC[0][i]] + SumColorD[1][TopThC[1][j]] + SumColorD[2][TopThC[2][k]];
		if(MIN > sumD)MIN = sumD;
	}
	cout << MIN << endl;
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    string s;
    cin >> n >> s;
    vector<ll> v(26, 0);
    REP(i, n) v[s[i] - 'a']++;
    ll ans = 1;
    REP(i, sz(v)) ans = (ans * (v[i] + 1)) % MOD;
    cout << ans - 1 << endl;
}



Measured memory_bytes: 512
// https://atcoder.jp/contests/abc063/tasks/abc063_b
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    unordered_set<char> st;
    for (auto &x : s) {
        st.insert(x);
    }
    if (s.length() != st.size()) {
        cout << "no\n";
    } else {
        cout << "yes\n";
    }

    return 0;
}


Measured memory_bytes: 256
import collections
n = int(raw_input())
a = map(int,raw_input().split())
a1 = []
a2 = []
for i in range(1,n+1,2):
  a1.append(a[i-1])
for i in range(2,n+2,2):
  a2.append(a[i-1])
c = collections.Counter(a1)
d = collections.Counter(a2)
b1 = c.most_common()
b2 = d.most_common()
x = b1[0]
x1 = x[1]
y = b2[0]
y1 = y[1]
if x1==n/2 and y1==n/2 and x[0]==y[0]:
  print n/2
elif x1==n/2 and x[0]==y[0]:
  w = b2[1]
  w1 = w[1]
  print n/2-w1
elif x1==n/2:
  print n/2-y1
elif y1==n/2 and x[0]==y[0]:
  z = b1[1]
  z1 = z[1]
  print n/2-z1
elif y1==n/2:
  print n/2-x1
else:
  z = b1[1]
  z1 = z[1]
  w = b2[1]
  w1 = w[1]
  if x[0]==y[0]:
    if x1+w1 >= y1+z1:
      print n-x1-w1
    else:
      print n-y1-z1
  else:
    print n-x1-y1

Measured memory_bytes: 24008
//Robs Code
/***********HEADER***************/
#include<bits/stdc++.h>
/***********MACROS***************/
#define int long long int
#define fri(l,k) for (i=l;i<=k;i++)
#define frj(l,k) for (j=l;j>=k;j--)
#define fij(a,b,l,k) for(i=a;i<=b;i++) for(j=l;j<=k;j++)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define mxsz 1000000007
#define mxval 1e9 + 7
#define grt [](auto x,auto y){return x>y;}
#define pii pair<int,int>
/*********VARIABLE****************/
using namespace std;
int i,j,n,m,k,l,q,t,a,b,sum[3],tot[3],cnt[3];
/*********FUNCTIONS**************/
int powom(int a,int b) {
    int result = 1;
    while (b > 0) {
        if (b & 1)
            result = result * a;
        a = a * a;
        b >>= 1;
    }
    return result;
}
int powwm(int a, int b) {
    a %= mxsz;
    int result = 1;
    while (b > 0) {
        if (b & 1)
            result = result * a % mxsz;
        a = a * a % mxsz;
        b >>= 1;
    }
    return result;
}
int mod(int a){
    return a%mxsz;
}
int sub(int a,int b){
    return ((a%mxsz)-(b%mxsz)+mxsz)%mxsz;
}
int mul(int a,int b){
    return ((a%mxsz)*(b%mxsz))%mxsz;
}
int add(int a,int b){
    return ((a%mxsz)+(b%mxsz))%mxsz;
}
int div(int a,int b){
    return ((a%mxsz)*(powwm(b,mxsz-b)%mxsz))%mxsz;
}
/***********MAIN**************/
void solve(){
    cin>>n>>m;
    map<int,bool> mp;
    for(i=0;i<m;i++){
        cin>>a;
        mp[a]=1;
    }
    vector<int> dp(n+1);
    dp[0]=1;
    if(mp[1]){
        dp[1]=0;
    }else{
        dp[1]=1;
    }
    for(i=2;i<=n;i++){
        dp[i] = add(dp[i-1],dp[i-2]);
        if(mp[i]) dp[i]=0;
    }
    cout<<dp[n];
}
signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	// cin>>t;
    t = 1;
	while(t--){
		solve();
	}
	return 0;
}
//.........

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

const int MOD = 1000000007;

const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    int n;
    cin >> n;
    pair<pair<string, int>, int> res[n];
    for (int i = 0; i < n; i++) {
        string s;
        int p;
        cin >> s >> p;
        res[i] = make_pair(make_pair(s, -p), i);
    }

    sort(res, res + n);
    rep(i, n)
    {
        cout << res[i].second + 1 << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include <cmath>

using namespace std;

char S[100];

int i,j,k,N;

int main()
{
  cin >>S;
  
  N=strlen(S);
  
  for(i=0;i<N;i++)
  {
    cout << "x";
  }
  
  
}



Measured memory_bytes: 256
//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 <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>


//Hang in there!

using namespace std;


int main() {
	vector<int>data(123);
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		data[(int)s[i]]++;
	}
	for (int i = 97; i <= 122; i++) {
		if (data[i] % 2 != 0) {
			cout << "No" << endl;
				return 0;
		}
	}
	cout << "Yes" << endl;
}

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

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

template<class T> using v = std::vector<T>;
template<class T> using vv = v<v<T>>;

const int mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
//const int mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


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

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

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

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

    int n, k, q; cin >> n >> k >> q;
    v<int> a(n);
    rep(i,q) {
        int p; cin >> p;
        p--;
        a[p]++;
    }
    rep(i,n) {
        if (q-a[i] < k) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
/**
 *
 * AtCoder Beginner Contest 108 - Problema X: Pari (https://beta.atcoder.jp/contests/abc108/tasks/abc108_a)
 *
 * Abridge version.
 *
 * Solution: text
 */
#include <iostream>

#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstring>
#include <algorithm>

using namespace std;

using ll = long long;
using ii = pair<ll, ll>;

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

#define LOG(var, sep) (cerr << #var << " = " << (var) << (sep))
#define LOGM(msg) (cerr << (msg))
#define LOGV(vec, sep) { cerr << #vec << " ="; for (const auto& v : (vec)) cerr << " " << v; cerr << (sep); }
#define LOGA(arr, N, sep) { cerr << #arr << " ="; for (int i = 0; i < N; ++i) cerr << " " << (arr)[i]; cerr << (sep); }
#define LOGA2(arr, N, M, sep) { cerr << #arr << " =\n"; for (int i = 0; i < N; ++i) { for (int j = 0; j < M; ++j) cerr << (arr)[i][j] << " "; cerr << endl; } cerr << (sep); }

void solve(int K)
{
    int even = K / 2, odd = (K + 1)/2;

    cout << even * odd << endl;
}

int main()
{
    ios::sync_with_stdio(false);

    int K;
    cin >> K;

    solve(K);

    return 0;
}

Measured memory_bytes: 256
"use strict";
function Main(input) {
  input = input.split("\n");
  input[0] = parseInt(input[0]);
  input[1] = parseInt(input[1]);
  input[2] = parseInt(input[2]);
  let money = [];
  let a = 0;
  for (let i = 0; i <= input[2]; i++) {
    for (let n = 0; n <= input[1]; n++) {
      for (let m = 0; m <= input[0]; m++) {
        money[a] = i * 50 + n * 100 + m * 500;
        a++;
      }
    }
  }
  let result = 0;
  for (const item of money) {
    if (item === parseInt(input[3])) {
      result++;
    }
  }
  console.log(result);
}

Main(require("fs").readFileSync("/dev/stdin", "utf-8"));


Measured memory_bytes: 14888
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String str = in.readLine();
		
		System.out.println(has7(str) ? "Yes" : "No");
	}
	public static boolean has7(String str) {
		for (int i = 0; i < str.length(); i++) {
			if (str.charAt(i) == '7')
				return true;
		}
		return false;
	}
}


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

int main() {
  string s;
  cin >> s;
  
  vector<int> cnt(3);
  for(int i = 0; i < 3; i++){
    cnt.at(i) = s.at(i) - 'a';
  }
  sort(cnt.begin(), cnt.end());
  bool ok = true;
  for(int i = 0; i < 3; i++){
    if(cnt.at(i) != i) ok = false;
  }
  
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3632
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  str s; cin >> s;
  if(s=="abc"||s=="acb"||s=="bac"||s=="bca"||s=="cab"||s=="cba"){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
program abc131c
  use,intrinsic :: iso_fortran_env
  implicit none
  integer(int64) :: a, b, c, d, x, y
  read *, a, b, c, d
  a = a - 1
  x = a - a/c - a/d + a/lcm(c,d)
  y = b - b/c - b/d + b/lcm(c,d)
  print *, y-x
contains
  recursive function gcd(a,b) result(res)
    integer(int64),intent(in) :: a, b
    integer(int64) :: res
    if (b==0) then
       res = a
    else
       res = gcd(b,mod(a,b))
    end if
  end function gcd
  function lcm(a,b)
    integer(int64),intent(in) :: a, b
    integer(int64) :: lcm
    lcm = a/gcd(a,b)*b
  end function lcm
end program abc131c


Measured memory_bytes: 256
import           Control.Monad
import           Data.List

main :: IO ()
main = do
    [n, m] <- readInts
    abs    <- replicateM m readInts
    print $ solve n abs

readInts :: IO [Int]
readInts = map read . words <$> getLine

solve :: Int -> [[Int]] -> Int
solve n abs = length $ filter (isPath abs) $ map (1 :) $ permutations [2 .. n]

isPath :: [[Int]] -> [Int] -> Bool
isPath abs [_] = True
isPath abs (x : y : zs) | [a, b] `elem` abs = isPath abs (y : zs)
                        | otherwise         = False
    where [a, b] = sort [x, y]

Measured memory_bytes: 1788
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
const long long  mod = 1e9+7;
map<long long ,long long>dp;
#define bug cout<<88888888<<endl;
#define debug(x) cout << #x" = " << x << endl;
long long Dp(long long x)
{
    if(dp[x])return dp[x];
    else
    {
        return dp[x] = ((Dp(x/2)+Dp((x-1)/2)+Dp((x-2)/2)) )%mod;
    }
}
int main()
{
    dp[0] = 1;
    dp[1] = 2;
    long long n;
    cin>>n;
    cout<<Dp(n);
    return 0;
}


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

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> A(N), B(N-1);
    for(int i=0;i<N-1;i++){
        cin >> B[i];
    }

    A[0] = B[0];
    for(int i=1;i<N-1;i++){
        A[i] = min(B[i-1], B[i]);
    }
    A[N-1] = B[N-2];

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

    cout << sum << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<set>
#include<algorithm>

using namespace std;

int main(){
    int num_query,command,val;
    scanf("%d",&num_query);
    set<int> int_set;
    set<int>::iterator itr;
    
    for(int i = 0;i < num_query;i++){
        scanf("%d %d",&command,&val);
        if(command == 0){
            int_set.insert(val);
            printf("%d\n",int_set.size());
        }else if(command == 1){
            itr = int_set.find(val);
            if(int_set.end() == itr) printf("0\n");
            else printf("1\n");
        }else if(command == 2){
            itr = int_set.find(val);
            if(int_set.end() != itr) int_set.erase(itr);
        }
    }
    
    return 0;
}


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

int main(){
    int x, y;
    cin >> x >> y;
    int gx=0, gy=0;
    switch (x) {
        case 2:
            gx = 28;
            break;
        case 4:
        case 6:
        case 9:
        case 11:
            gx = 30;
            break;
        default:
            gx = 31;
            break;
    }
    switch (y) {
        case 2:
            gy = 28;
            break;
        case 4:
        case 6:
        case 9:
        case 11:
            gy = 30;
            break;
        default:
            gy = 31;
            break;
    }

    if(gx!=gy)cout<<"No\n";
    else cout<<"Yes\n";

    return 0;
}


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

typedef long long ll;

ll r,d,x;

int main(){
	cin>>r>>d>>x;
  ll res=x;  
	REP1(i,10){
		res=r*res-d;
		cout<<res<<endl;
	}
    return 0;

}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
using namespace std;

const int MX=200005;
char s[MX],t[MX];

int main()
{
    scanf("%s %s",s,t);
    int n=strlen(s),m=0;
    for(int i=0;i<n;i++) m+=(s[i]!=t[i]);
    printf("%d\n",m);
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()%
//#define int long long

signed main(){
    int n; cin >> n;
    vector<int> a(n+1,0), b(n+1,0);
    reps(i,1,n) cin >> a[i];

    for(int i=n; i>=1; i--){
        int front = 0;
        for(int j=i*2; j<=n; j+=i){
            front += b[j];
        }
        if((front % 2) != a[i]) b[i] = 1;
    }
    
    string ans = "";
    int size = 0;
    for(int i=1; i<=n; i++){
        if(b[i]==1){
            size++;
            ans += to_string(i) + " ";
        }
    }
    
    cout << size << endl;
    if(size != 0){
        ans.pop_back();
        cout << ans << endl;
    }
}

Measured memory_bytes: 3460
#include <cstdio>

int main(){
	while(1){
		int n, x;
		long ans=0;
		scanf(" %d %d", &n, &x);
		if(n==0) break;
		
		for(int i=1; i<=n-2; ++i){
			for(int j=i+1; j<=n-1; ++j){
				for(int k=j+1; k<=n; ++k){
					if(i+j+k==x) {
						++ans;
						break;
					}
				}
			}
		}
	
		printf("%ld\n", ans);
	}

	return 0;
}

Measured memory_bytes: 1028
#include <cstdio>
#include <cstring>
#include <vector>
#define MAX 200005
using namespace std;

char s[MAX], t[MAX];

int main() {
    scanf("%s", s);
    scanf("%s", t);
    int n = strlen(s);
    int ans;

    vector<int> m[30];
    for (int i = 0; i < n; i++) {
        m[s[i] - 'a'].push_back(i);
    }
    int i = 0;
    for (; i < 26; i++) {
        if (m[i].size() == 0) continue;

        char tmp = t[m[i][0]];
        int j = 0;
        for (; j < m[i].size(); j++) {
            if (tmp != t[m[i][j]]) break;
        }
        if (j != m[i].size()) break;
    }
    if (i == 26) ans = 1;
    else ans = 0;

    vector<int> mm[30];
    for (int i = 0; i < n; i++) {
        mm[t[i] - 'a'].push_back(i);
    }
    i = 0;
    for (; i < 26; i++) {
        if (mm[i].size() == 0) continue;

        char tmp = s[mm[i][0]];
        int j = 0;
        for (; j < mm[i].size(); j++) {
            if (tmp != s[mm[i][j]]) break;
        }
        if (j != mm[i].size()) break;
    }
    if (i == 26) ans *= 1;
    else ans *= 0;

    printf("%s\n", (ans==1) ? "Yes" : "No");

    return 0;
}


Measured memory_bytes: 2816
/*
AOJ - ITP1_7_a
Date: 20180928
Author: Mikoron
 */

#include<stdio.h>

#define MAX 50

typedef struct {
        short mid;
        short fin;
        short mup;
        char grade;
} grade_info_t;

int main(void) {
        short i, count = 0, fin_mid;
        grade_info_t grade_t[MAX];

        //input
        while(1) {
                scanf("%hd %hd %hd", &grade_t[count].mid, &grade_t[count].fin, &grade_t[count].mup);
                fin_mid = grade_t[count].mid + grade_t[count].fin;
                if(fin_mid == -2 && grade_t[count].mup == -1) break;

                else if(grade_t[count].mid == -1 || grade_t[count].fin == -1 || fin_mid < 30 ) {
                        grade_t[count].grade = 'F';
                }
                else if(fin_mid < 50) {
                        if(grade_t[count].mup >= 50) grade_t[count].grade = 'C';
                        else grade_t[count].grade = 'D';
                }
                else if(fin_mid < 65) grade_t[count].grade = 'C';
                else if(fin_mid < 80) grade_t[count].grade = 'B';
                else if(fin_mid >= 80) grade_t[count].grade = 'A';

                count++;
        }

        //output
        for(i = 0; i < count; i++) printf("%c\n", grade_t[i].grade);

        return 0;
}



Measured memory_bytes: 2052
n = int(input())
a = [int(input()) for _ in range(n)]
cnt = a[0] - 1
a[0] = 1
t = 1
for x in a:
  if x == t: t += 1
  if x < t: continue
  if x%t == 0:
    x -= t+1
    cnt += 1
  cnt += x//t
print(cnt)

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

struct edge{
  int to;
  int cost;
};
vector<edge> G[100001];
int INF=1e9+1;
vector<int> x(1e5+1,INF);
bool ans=true;
vector<bool> used(1e5+1,false);

void dfs(int p){
  for(int i=0;i<G[p].size();i++){
    if(x[G[p][i].to]!=INF){
      if(x[G[p][i].to]!=x[p]+G[p][i].cost)ans=false;
    }else if(used[G[p][i].to]==false&&x[G[p][i].to]==INF){
      used[G[p][i].to]==true;
      x[G[p][i].to]=x[p]+G[p][i].cost;
      dfs(G[p][i].to);
      used[G[p][i].to]==false;
    }
  }
}

int main(){
  int n,m;
  cin>>n>>m;
  for(int i=0;i<m;i++){
    int l,r,d;
    cin>>l>>r>>d;
    l--;
    r--;
    G[l].push_back(edge{r,d});
    G[r].push_back(edge{l,-1*d});
  }
  for(int i=0;i<n;i++){
    if(x[i]==INF){
      x[i]=0;
      dfs(i);
    }
  }
  if(ans){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


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

using ll = long long;
using namespace std;

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

	int r; cin >> r;

	if(r < 1200) cout << "ABC" << endl;
	else if(r < 2800)cout << "ARC" << endl;
	else cout << "AGC" << endl;	

	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
  ll a[10];
  for (int i= 0; i < 5; i++) {
    cin >> a[i];
  }
  for (int i=0 ; i< 5; i++) {
    if (a[i] == 0) {
      cout << i + 1 << "\n";
      break;
    }
  }
  return 0;
}


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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

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

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

inline bool inside(ll y, ll x, ll H, ll W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

char G[55][55];

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll h,w; cin>>h>>w;
  rep(i,h) rep(j,w) cin>>G[i][j];
  
  rep(i,h){
    rep(j,w){
      if(G[i][j]=='#'){
        bool ok=false;
        rep(k,4){
          ll ny=i+dy[k], nx=j+dx[k];
          if(inside(ny,nx,h,w)&&G[ny][nx]=='#'){
            ok=true;
          }
        }
        if(!ok){
          cout<<"No"<<endl;
          return 0;
        }
      }
    }
  }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1'000'000'007;
template <class T> bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0; }
template <class T> bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0; }

int main() {
    string s;
    cin >> s;
    string s1 = s.substr(0, 2);
    string s2 = s.substr(2, 2);
    bool ok1 = true;
    bool ok2 = true;
    if (s1 == "00" || s1 > "12")
        ok1 = false;
    if (s2 == "00" || s2 > "12")
        ok2 = false;

    if (ok1 && ok2)
        cout << "AMBIGUOUS" << endl;
    else if (ok1 && !ok2)
        cout << "MMYY" << endl;
    else if (!ok1 && ok2)
        cout << "YYMM" << endl;
    else
        cout << "NA" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;

class edge{
public:
  int l, r, w;
  bool operator<(const edge &another) const{
    return w < another.w;
  }
};

class disjointset{
public:
  vector<int> rank, p;
  disjointset(){}
  disjointset(int size){
    rank.resize(size, 0);
    p.resize(size, 0);
    for(int i = 0; i < size; i++) makeset(i);
  }
  void makeset(int x){
    p[x] = x;
    rank[x] = 0;
  }
  bool same(int x, int y){
    return findset(x) == findset(y);
  }
  void unite(int x, int y){
    link(findset(x), findset(y));
  }
  void link(int x, int y){
    if(rank[x] > rank[y]){
      p[y] = x;
    }
    else{
      p[x] = y;
      if(rank[x] == rank[y]) rank[y]++;
    }
  }
  int findset(int x){
    if(x != p[x]){
      p[x] = findset(p[x]);
    }
    return p[x];
  }
};

void solve(){
  int v, e; cin >> v >> e;
  vector<edge> eg(e);
  vector<set<int> > st(v);
  for(int i = 0; i < e; i++){
    cin >> eg[i].l >> eg[i].r >> eg[i].w;
  }
  for(int i = 0; i < v; i++) st[i].insert(i);
  sort(eg.begin(), eg.end());
  long long ans = 0;
  disjointset dset = disjointset(v + 1);
  for(int i = 0; i < v; i++) dset.makeset(i);
  for(int i = 0; i < e; i++){
    if(dset.same(eg[i].l, eg[i].r) == false){
      ans += eg[i].w;
      dset.unite(eg[i].l, eg[i].r);
    }
  }

  cout << ans << endl;
  return;
}

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



Measured memory_bytes: 5196
#include <bits/stdc++.h>
using namespace std;
int dp[1000010][2];
int main() {
    string N; cin >> N;
    N = '0' + N;
    for (int i = 0; i < N.size(); i++) {
        if (i == 0) {
            dp[i][0] = 0;
            dp[i][1] = 1;
        } else {
            dp[i][0] = min(dp[i - 1][0] + N[i] - '0', dp[i - 1][1] + 10 - (N[i] - '0'));
            dp[i][1] = min(dp[i - 1][0] + N[i] - '0' + 1, dp[i - 1][1] + 9 - (N[i] - '0'));
        }
    }
    cout << dp[N.size() - 1][0] << endl;
    return 0;
}


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

int main(void) {

    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    double dist = sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) );
    printf("%.10lf\n", dist);

    return 0;
}

Measured memory_bytes: 3200
#include <cstdio>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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

using ll = long long;

ll N;
ll D[60];
ll ans = 0;
ll used[30];
std::map<ll, ll> mp;
std::vector<ll> vs;

ll diff()
{
  ll ret = 30;

  rep( i, 25 ) rep( j, 25 ) if( used[i] && used[j] && i != j )
  {
    ll d1 = llabs(i-j);
    ll d2 = 24-d1;

    chmin( ret, std::min( d1, d2 ) );
  }

  return ret;
}

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

  rep( i, N )
    std::cin >> D[i], ++mp[D[i]];

  if( mp[0] )
  {
    puts("0");

    return 0;
  }

  used[0] = true;

  repi( i, 1, 12 )
  {
    if( mp[i] == 1 )
      vs.emplace_back( i );
    else if( mp[i] == 2 )
      used[i] = used[24-i] = true;
    else if( mp[i] > 2 )
    {
      puts("0");
      
      return 0;
    }
  }

  if( mp[12] == 1 )
    used[12] = true;
  else if ( mp[12] >= 2 )
  {
    puts("0");

    return 0;
  }

  ll M = vs.size();

  if( !M )
  {
    std::cout << diff() << std::endl;

    return 0;
  }

  rep( bit, 1<<M )
  {
    rep( i, M )
    {
      if( bit>>i&1 )
      {
        used[vs[i]] = true;
        used[24-vs[i]] = false;
      }
      else
      {
        used[vs[i]] = false;
        used[24-vs[i]] = true;
      }
    }

    ans = std::max( ans, diff() );
  }

  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 256
/* Bismillahir Rahmanir Rahim */

#include <bits/stdc++.h>

#define rep(i, n)	for(int i=0;i<n;i++)
#define repn(i, n)	for(int i=1;i<=n;i++)
#define set(i, n)	memset(i, n, sizeof(i))

#define mx		1007
#define pb		push_back
#define oo		1e9

#define f	first
#define s 	second

using namespace std;

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

struct Edge {
  int u, v;
  LL cap, flow;
  Edge() {}
  Edge(int u, int v, LL cap): u(u), v(v), cap(cap), flow(0) {}
};

struct Dinic {
  int N;
  vector<Edge> E;
  vector<vector<int>> g;
  vector<int> d, pt;
  
  Dinic(int N): N(N), E(0), g(N), d(N), pt(N) {}

  void AddEdge(int u, int v, LL cap) {
    if (u != v) {
      E.emplace_back(Edge(u, v, cap));
      g[u].emplace_back(E.size() - 1);
      E.emplace_back(Edge(v, u, 0));
      g[v].emplace_back(E.size() - 1);
    }
  }

  bool BFS(int S, int T) {
    queue<int> q({S});
    fill(d.begin(), d.end(), N + 1);
    d[S] = 0;
    while(!q.empty()) {
      int u = q.front(); q.pop();
      if (u == T) break;
      for (int k: g[u]) {
        Edge &e = E[k];
        if (e.flow < e.cap && d[e.v] > d[e.u] + 1) {
          d[e.v] = d[e.u] + 1;
          q.emplace(e.v);
        }
      }
    }
    return d[T] != N + 1;
  }

  LL DFS(int u, int T, LL flow = -1) {
    if (u == T || flow == 0) return flow;
    for (int &i = pt[u]; i < g[u].size(); ++i) {
      Edge &e = E[g[u][i]];
      Edge &oe = E[g[u][i]^1];
      if (d[e.v] == d[e.u] + 1) {
        LL amt = e.cap - e.flow;
        if (flow != -1 && amt > flow) amt = flow;
        if (LL pushed = DFS(e.v, T, amt)) {
          e.flow += pushed;
          oe.flow -= pushed;
          return pushed;
        }
      }
    }
    return 0;
  }

  LL MaxFlow(int S, int T) {
    LL total = 0;
    while (BFS(S, T)) {
      fill(pt.begin(), pt.end(), 0);
      while (LL flow = DFS(S, T))
        total += flow;
    }
    return total;
  }
};

int n, m;
string grid[mx];
int fx[] = {0, 0, +1, -1};
int fy[] = {+1, -1, 0, 0};

int in(int x, int y){
	return m * x + y;
}

int out(int x, int y){
	return m * x + y + n * m;
}

bool valid(int x, int y){
	if(x < 0 || y < 0 || x >= n || y >= m) return false;
	return true;
}

int main(){
	ios::sync_with_stdio(false);
	cin >> n >> m;
	rep(i, n) cin >> grid[i];
	Dinic flow(n*m*2 + 3);
	rep(i, n){
		rep(j, m){
			if(grid[i][j] == 'X') flow.AddEdge(in(i, j), out(i, j), oo);
			else flow.AddEdge(in(i, j), out(i, j), 1);
		}
	}
	rep(i, n){
		rep(j, m){
			rep(f, 4){
				int x = i + fx[f], y = j + fy[f];
				if(valid(x, y)) flow.AddEdge(out(i, j), in(x, y), oo);
			}
		}
	}
	int source = n * m * 2 + 1, sink = source + 1;
	rep(i, m){
		flow.AddEdge(source, in(0, i), oo);
		flow.AddEdge(source, in(n-1, i), oo);
	}
	for(int i=2;i<n-1;i++){
		flow.AddEdge(source, in(i, 0), oo);
		flow.AddEdge(source, in(i, m-1), oo);
	}
	rep(i, n){
		rep(j, m){
			if(grid[i][j] == 'X'){
				flow.AddEdge(out(i, j), sink, oo);
				if(i==0||i==n-1||j==0||j==m-1){
					printf("-1\n");
					return 0;
				}
			}
		}
	}
	cout << flow.MaxFlow(source, sink) << endl;
	return 0;
}

Measured memory_bytes: 4788
#include <iostream>
#include <stdio.h>

#include <bits/stdc++.h>
using namespace std;

int main()
{
string x;
cin>>x;
if(x=="Sunny")
    cout<<"Cloudy";
else if (x=="Cloudy")
    cout<<"Rainy";
else if (x=="Rainy")
    cout<<"Sunny";
  return 0;

}


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

int main() {
  int N;//データの数
  int D;//次元の数
  int count;//何通りあるかを計算
  
  //データ入力部
  cin >> N >> D;
  
  //それぞれの位置を入れる配列を用意
  vector<vector <int>> X(N,vector <int> (D));
  
  //データ入力部2
  for (int i=0; i<N;i++){
    for(int j=0; j<D; j++){
      cin >> X.at(i).at(j);
    }
  }
  
  //距離の計算と判定
  for (int i=0; i<N-1;i++){
    for (int j=i+1;j<N;j++){
      int Dis =0;
      //距離の計算
      for (int k=0;k<D;k++){
      	Dis += pow((X.at(i).at(k) -X.at(j).at(k)),2);
      }
      //整数になるかどうかの判定
      for (int k=0;pow(k,2) <= Dis;k++){
        if (Dis == pow(k,2))
          count++;
      }
    }
  }
  
  //結果を出力
  cout << count <<endl;

}
    
  
  

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    const ll r_lim = 1e9;
    ll s; cin >> s;
    ll a1 = (s/r_lim)*r_lim, a2 = s%r_lim;
    ll x1,x2,y1,y2;
    if(a1 == 0){
        x1 = 0; y2 = 1;
        x2 = a2; y1 = 1;
    }else if(a2 == 0){
        x1 = r_lim; y2 = s/r_lim;
        x2 = 0; y1 = 1;
    }else{
        x1 = r_lim;
        y2 = s/r_lim+1;
        a2 = (s/r_lim+1)*r_lim-s;
        x2 = a2; y1 = 1LL;
    }

    cout << "0 0 " << x1 << " " << y1 << " " << x2 << " " << y2 << endl; 
}


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

struct Node {
  int key;
  struct Node *right, *left, *parent;
};
typedef struct Node Node;

Node *root, *NIL;

Node * treeMinimum(Node *x) {
  while(x->left != NIL)
    x = x->left;
  return x;
}

Node * find(Node *u, int k) {
  while(u != NIL && k != u->key) {
    if(k < u->key) u = u->left;
    else u = u->right;
  }
  return u;
}

Node * treeSuccessor(Node *x) {
  if(x->right != NIL) return treeMinimum(x->right);
  Node *y = x->parent;
  while(y != NIL && x == y->right) {
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node *z) {
  Node *y; // 削除する対象
  Node *x; // yの子

  // 削除する節点を決める
  if(z->left == NIL || z->right == NIL) y = z;
  else y = treeSuccessor(z);

  // yの子xを決める
  if(y->left != NIL) {
    x = y->left;
  } else {
    x = y->right;
  }

  if(x != NIL) {
    x->parent = y->parent;
  }

  if(y->parent == NIL) {
    root = x;
  } else {
    if(y == y->parent->left) {
      y->parent->left = x;
    } else {
      y->parent->right = x;
    }
  }

  if(y != z) {
    z->key = y->key;
  }
}

void insert(int k) {
  Node *y = NIL;
  Node *x = root;
  Node *z;
  
  z = (Node *)malloc(sizeof(Node));
  z->key   = k;
  z->left  = NIL;
  z->right = NIL;
  
  while(x != NIL) {
    y = x;
    if(z->key < x->key) {
      x = x->left;
    } else {
      x = x->right;
    }
  }
  
  z->parent = y;
  if(y == NIL) {
    root = z;
  } else {
    if( z->key < y->key) {
      y->left = z;
    } else {
      y->right = z;
    }
  }
}

void inorder(Node *u) {
  if(u == NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node *u) {
  if(u == NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}
  
int main(void) {
  int n, i, x;
  char com[16];
  scanf("%d",&n);
  
  for(i=0;i<n;i++) {
    scanf("%s",com);
    if(!strcmp(com,"find")) {
      scanf("%d",&x);
      Node *t = find(root,x);
      if(t != NIL) printf("yes\n");
      else printf("no\n");
    } else if(!strcmp(com,"insert")) {
      scanf("%d",&x);
      insert(x);
    } else if(!strcmp(com,"print")) {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if(!strcmp(com,"delete")) {
      scanf("%d",&x);
      treeDelete(find(root,x));
    }
  }

  return 0;
}


Measured memory_bytes: 20440
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int,int> P;

int main(){
  int n;
  cin >> n;
  VI x(n),l(n);
  vector<P> r(n,P(0,0));
  
  rep(i,n){
    cin >> x[i] >> l[i];
    r[i].first = x[i] + l[i];
    r[i].second = x[i] - l[i];
  }
  
  sort(r.begin(), r.end());

  int cur = 0;
  int ans = 0;
  bool flag=true;
  
  while(flag){
    ans++;
    int border = r[cur].first;
    rep2(i, cur, n){
      if( r[i].second >= border ){
        cur = i;
        flag = true;
        break;
      }else{
        flag = false;
      }
    }
  }
    
  cout << ans << endl;
  
  return 0;
}

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

#define gcd(a,b)		__gcd(a,b)
#define lcm(a,b)		(a*b)/gcd(a,b)
#define ff              first
#define ss              second
#define int             long long
#define pb              emplace_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             INT_MAX
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(x)			x.begin(),x.end()
#define digits(x)		floor(log10(x))+1
#define FIO				ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

class dsu {
private:
	int *id;
	int* sz;

	int root(int i) {
		while (i != id[i]) {
			id[i] = id[id[i]];
			i = id[i];
		}
		return i;
	}
public:
	int n;
	dsu(int v) {
		n = v;
		id = new int[n];
		sz = new int[n];

		for (int i = 0; i < n; i++) {
			id[i] = i;
			sz[i] = 0;
		}
	}

	bool find(int p , int q) {
		return root(p) == root(q);
	}

	void join(int p , int q) {
		int i = root(p);
		int j = root(q);
		if (i == j) {
			return;
		}
		if (sz[i] < sz[j]) {
			id[i] = j ;
			sz[j] += sz[i];
		}
		else {
			id[j] = i;
			sz[i] += sz[j];
		}
	}
};

int nCr(int n , int r ) {
	int p = 1, k = 1;

	if (n - r < r ) {
		r = n - r;
	}
	if (r != 0) {
		while (r != 0) {
			p *= n ;
			k *= r ;
			int m = __gcd(p, k);
			p /= m;
			k /= m;
			n--;
			r--;
		}
	}
	else {
		p = 1;
	}
	return p ;
}

int modPower(int x, int y , int p) {
	//Used to calculate (x^y)%p
	int res = 1;
	if (y == 0) {
		return 1;
	}

	x = x % p;
	if (x == 0) {
		return 0  ;
	}

	while (y > 0) {
		if (y & 1) {
			res = (res * x) % p;
		}

		y >>= 1;
		x = (x * x) % p;
	}
	return res ;

}


int32_t main() {
	FIO;


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

	if (a <= 8 and b <= 8) {
		cout << "Yay!";
	}
	else {
		cout << ":(";
	}




	return 0;
}


Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

	static Scanner scan = new Scanner(System.in);

	public static void main(String[] args) {
		int n = scan.nextInt();
		int sum = 0;

		for(int i = 0; i < n; i++) {
			sum += a(scan.nextInt());
		}

		System.out.println(sum);
	}

	static int a(int n) {
		int re = 0;
		while(n % 2 == 0) {
			n /= 2;
			re++;
		}
		return re;
	}

}


Measured memory_bytes: 35164
#include <algorithm>
#include <iostream>
#include <vector>

namespace multiset
{

class multiset
{
  private:
    std::vector<int> tree;
    int MSB;

    void add(int i, int x)
    {
        for (; i < tree.size(); i += i & -i) {
            tree[i] += x;
        }
    }

    int sum(int i)
    {
        int res = 0;
        for (; i > 0; i -= i & -i) {
            res += tree[i];
        }
        return res;
    }

    int bisect(int w)
    {
        if (w <= 0) {
            return 0;
        }

        int i = 0;
        for (int k = MSB; k > 0; k /= 2) {
            if (i + k < tree.size() && tree[i + k] < w) {
                w -= tree[i + k];
                i += k;
            }
        }
        return i + 1;
    }

    uint32_t get_MSB(uint32_t x) { return 0x80000000 >> __builtin_clz(x); }

  public:
    multiset(int N) : tree(N + 1), MSB(get_MSB(N)) {}
    void insert(int x) { add(x, 1); }
    void erase(int x) { add(x, -1); }
    int lower_bound(int x) { return bisect(sum(x)); }

    size_t size() { return sum(tree.size() - 1); }
};

} // namespace multiset

int main()
{
    // https://atcoder.jp/contests/abc134/tasks/abc134_e

    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int N;
    std::cin >> N;

    std::vector<int> A(N);
    for (auto &&a : A) {
        std::cin >> a;
    }

    std::vector<int> B = A;
    std::sort(begin(B), end(B));
    B.erase(std::unique(begin(B), end(B)), end(B));

    std::transform(begin(A), end(A), begin(A), [&](int val) -> int {
        return std::lower_bound(begin(B), end(B), val) - begin(B) + 1;
    });

    multiset::multiset ms(B.size());
    for (auto a : A) {
        auto i = ms.lower_bound(a - 1);
        if (i != 0) {
            ms.erase(i);
        }
        ms.insert(a);
    }

    std::cout << ms.size() << '\n';
}


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

using namespace std;
typedef long long ll;
int main() {
    ll n, t, x;
    cin >> n >> t;
    vector<ll>v;
    for (ll i = 0; i < n; i++) {
        cin >> x;
        v.push_back(x);
    }

    ll s = t;
    ll ans = 0;
    for (ll i = 0; i < n - 1; i++) {
            ll z = abs(v[i+1]- v[i]);
        if(z < t) {
            ans += z;
        }
        else {
            ans += t;
        }

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


Measured memory_bytes: 2420