akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
using namespace std;

int main(){
        int a, b;
        cin >> a >> b;
        int d = a/b;
        int r = a % b;
        double f =(double) a/(double)b;
        cout << d << " " << r <<" "<<fixed<<setprecision(8)<< f << endl;
        return 0;
}


Measured memory_bytes: 3280
import Data.List

elemCount [] = []
elemCount (x:xs) = (length $ filter (== x) xs) + 1 : elemCount (filter (/= x) xs)

main::IO()
main=do
    a<-getLine
    b<-getLine
    putStrLn$ if sort (elemCount a) == sort (elemCount b) then "Yes" else "No"

    

Measured memory_bytes: 29052
import itertools

N, M = map(int, input().split(" "))
edge = [[False]*N for _ in range(N)]

for _ in range(M):
    a, b = map(int, input().split(" "))
    edge[a-1][b-1] = True
    edge[b-1][a-1] = True

ans = 0

for i in itertools.permutations(range(1,N)):
    P = (0,) + i
    flag = True
    for j in range(len(P)-1):
        if edge[P[j]][P[j+1]] == False:
            flag = False
            break
    if flag:
        ans += 1

print(ans)

Measured memory_bytes: 3064
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	string S=in<string>();
	int K=in();
	int N=S.size();
	REP(i,N){
		int V=('z'-S[i]+1)%26;
		if(V<=K){
			K -= V;
			S[i]='a';
		}
	}
	if(K){
		char ch = S.back();
		ch += K%26;
		while(ch>'z'){
			ch -= 'a';
		}
		S.back() = (char)(ch);
	}
	out(S);
	return 0;
}


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

int m[12][12];

bool valid(int y, int x){
  if(0 <= y && y < 12){
    if(0 <= x && x < 12){
        if(m[y][x] == 1) return true;
    }
  }
  return false;
}

void remove_island(int y, int x) {
  int nx, ny;
  int dx[4] = {1, 0, -1,  0};
  int dy[4] = {0, 1,  0, -1};

  m[y][x] = 0;
  for(int i = 0; i < 4; i++){
    ny = y + dy[i];
    nx = x + dx[i];
    if(valid(ny, nx)) remove_island(ny, nx);
  }
}

int main() {
  char c[12];
  int ans;
  while(1){
    for(int i = 0; i < 12; i++){
      if(!(cin >> c)) return 0;
      for(int j = 0; j < 12; j++){
        m[i][j] = (int)(c[j] - '0');
      }
    }

    ans = 0;
    for(int i = 0; i < 12; i++){
      for(int j = 0; j < 12; j++){
        if(valid(i, j)){
          remove_island(i, j);
          ans++;
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1148
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
      
      //入力
      int N = sc.nextInt();//文字列の長さ
      String S = sc.next();//文字列
      
      //文字列の前半と後半
      String first = S.substring(0,(N/2));
      String last = S.substring((N/2),N);
      
      //前半と後半が同じ文字列か比較
      if(first.equals(last)){
       System.out.println("Yes");
      }
      else{
       System.out.println("No");
      }
    }
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 1e5+23;
const int mod = 1e9+7;

int n, k;
vector<int> g[N];
long long f[N];

long long binpow(long long b, long long e) {
  long long ret = 1;
  while (e) {
    if (e&1) {
      ret = ret * b % mod;
      --e;
    } else {
      b = b * b % mod;
      e /= 2;
    }
  }
  return ret;
}

long long dfs(int u, int r, int p) {
  long long rank = g[u].size();
  if (p != -1) --rank;
  if (k-r < rank) return 0;
  long long ret = f[k-r]*binpow(f[(k-r)-rank], mod-2)%mod;
  for (int v: g[u]) {
    if (v == p) continue;
    ret = ret * dfs(v, 2, u) % mod;
  }
  return ret;
}

void solve() {
  scanf("%d%d", &n, &k);
  f[0] = 1;
  for (int i = 1; i < N; ++i) f[i] = f[i-1] * i % mod;
  for (int u, v, i = 0; i < n-1; ++i) {
    scanf("%d%d", &u, &v);
    g[--u].push_back(--v);
    g[v].push_back(u);
  }
  printf("%lld", dfs(0, 1, -1)*k%mod);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 14660
# -*- coding: utf-8 -*-
import math
N=int(input())
P=list(map(int,input().split()))
Q=list(map(int,input().split()))
a=0
b=0
maxlist=[]
for i in range(N):
    maxlist.append(P[i])
    maxlist.sort()
    temp=maxlist.index(P[i])-1
    a=a+math.factorial(N-1-i)*(P[i]-1-temp)
maxlist=[]
for i in range(N):
    maxlist.append(Q[i])
    maxlist.sort()
    temp=maxlist.index(Q[i])-1
    b=b+math.factorial(N-1-i)*(Q[i]-1-temp)
print(max(a-b,b-a))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

class Prime
{
	ll i, iLimit;
public:
	bool isPrime(ll a);
};

bool Prime::isPrime(ll a)
{
	if (a == 1) return false;
	iLimit = (int)sqrt(a);
	for (i = 2; i <= iLimit; i++) if (a % i == 0) break;
	return (i == iLimit + 1 ? true : false);
}


int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll a, b;
	cin >> a >> b;
	vector<ll> resa;
	vector<ll> resb;
	for (ll i = 1; i * i <= a; ++i) {
		if (a % i == 0 && i * i != a) {
			resa.emplace_back(i);
			resa.emplace_back(a / i);
		}
	}
	for (ll i = 1; i * i <= b; ++i) {
		if (b % i == 0 && i * i != b) {
			resb.emplace_back(i);
			resb.emplace_back(b / i);
		}
	}
	vector<ll> res;
	for (auto& c : resa) {
		for (auto& d : resb) {
			if (c == d) res.emplace_back(c);
		}
	}
	Prime p;
	set<ll> st;
	for (auto& c : res) {
		bool elf = p.isPrime(c);
		if (elf) st.insert(c);
	}
	st.insert(1);
	dunk(st.size());
	return 0;
}


Measured memory_bytes: 512
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

#define TR ","
#define fi first
#define se second
#define rep(i,N) for(int i=0;i<(int)N;++i)
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

ll waz = 76543217;

ll inv(ll x) {
    if (x == 1) { return 1; }
    if (x == 0) { return 0; }
    else {
        ll a = (waz - inv(waz % x) * (waz / x)) % waz;
        if (a >= 0) { return a; }
        else { return waz + a; }
    }
}

void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

vector<ll> p;

ll phi(ll x) {
    ll a = x;
    ll b = x;
    for (ll k = 0; k != p.size(); ++k) {
        if (a % p[k] == 0) {
            while (a % p[k] == 0) {
                a /= p[k];
            }
            b = b / p[k] * (p[k] - 1);
        }
        if (a == 1) { break; }
    }
    return b;
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

int main()
{
    IO;

    int L = 200000;

    int N; cin >> N;
    vector<int> P(N);
    rep(i, N) cin >> P[i];

    int jj = 0;

    rep(i, N) {
        if (P[i] <= L) { ++jj; }
        L = min(L, P[i]);
    }

    cout << jj << endl;

}

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

Measured memory_bytes: 17028
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define out(a) debg(a);
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
// template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
// template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
// template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
bool is_palindrome(string s){return s == string(s.rbegin(),s.rend());}
#define popcount __builtin_popcount
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) { a = b; return true; }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) { a = b; return true; }
    return false;
}




int main(){
    std::string S;
    std::cin >> S;
    if(S[S.length()-1] == 's'){
        cout << S+"es" << endl;
    }else{
        cout << S+'s' << endl;
    }
    return 0;
}


Measured memory_bytes: 3624
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    token.parse().ok().unwrap()
}

fn main() {
    let n = input::<usize>();
    let m = input::<i64>();
    let a = (0..n).map(|_| input()).collect::<Vec<i64>>();

    let mut sum = vec![0; n + 1];
    for i in 0..n {
        sum[i + 1] = (sum[i] + a[i]) % m;
    }

    let mut map = std::collections::HashMap::new();
    let mut ans = 0i64;
    for i in 0..n + 1 {
        let x = map.entry(sum[i]).or_insert(0);
        ans += *x;
        *x += 1;
    }
    println!("{}", ans);
}


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

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

  long double root = sqrt(N);
  if (ceil(root) == root) {
    cout << ((long long)root * 2) - 2 << endl;
    return 0;
  }

  long long delta;
  long long from = (long long)ceil(root);

  if (N % 2 == 0) {
    delta = 1;
  }
  else {
    delta = 2;

    if (from % 2 == 0)
        from--;
  }

  long long a, b;
  for (long long i = from; i > 0; i = i - delta) {
    if (N % i == 0) {
      a = i;
      b = N / a;
      break;
    }
  }

  cout << a + b - 2 << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int s = sc.nextInt();

        int l = Math.min(s, k);
        int total = 0;
        for (int i = l; i >= 0; i--) {
            int m = Math.min(s - i, k);
            if (s - i < k) {
                total += m + 1;
            } else {
                total += Math.max(k - (s - i - m) + 1, 0);
            }
        }
        System.out.println(total);
    }
}


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

const int N = 110, oo = 1e5;

int n, a[N];

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; ++ i) scanf("%d", &a[i]);
	int sum = 0;
	for (int i = 1; i <= n; ++ i) sum += a[i];
	int d = oo, pos;
	for (int i = 1; i <= n; ++ i)
	{
		if (abs(sum - a[i] * n) < d)
		{
			d = abs(sum - a[i] * n);
			pos = i - 1;
		}
	}
	printf("%d\n", pos);
}

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

#ifdef LOCAL
	#define de(x) cout<<#x<<"="<<x<<endl
	#define rff freopen("input.txt","r",stdin)
	#include "Debug.h"
#else
	#define de(x)
	#define rff
#endif

#define itr(x) for(__typeof((x).begin()) it=(x).begin();it!=(x).end();it++)
#define For(i,n) for (int i=1;i<=(int)(n);i++)
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define all(x) (x).begin(),(x).end()
#define PQ priority_queue
#define pii pair<int,int>
#define vi vector <int>
#define ll long long
#define pb push_back
#define mp make_pair
#define re return
#define se second
#define fi first
const int INF=0x7fffffff;
const int MAXN=+3;

int main(){
	int a,b;
	cin>>a>>b;
	cout<<a+b/2;
	re 0;
}

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

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define prints(x, y) cout<<(x)<<" "<<(y)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define r_rep(i, n) for(int i = n; i >= 0; i--)
#define ll long long int
#define pb push_back

const long long INF = 1LL << 60;

int main() {
  ll a, b, x;
  cin >> a >> b >> x;
  ll ans = b/x - a/x;
  if (a%x == 0) ans++;
  print(ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
const int N=1000;
int n,vis[N+10][N+10];
char s[N+10][N+10];
int main() {
    scanf("%d",&n);
    for (int i=1;i<=n;i++)
	scanf("%s",s[i]+1);
    for (int i=1;i<=n;i++)
	for (int j=1;j<=n;j++)
	    s[i+n][j]=s[i][j+n]=s[i+n][j+n]=s[i][j];
    for (int i=1;i<=n;i++)
	for (int j=1;j<=n;j++) {
	    if (vis[i][j]) continue;
	    int judge=1;
	    for (int k1=0;k1<n;k1++)
		for (int k2=0;k2<n;k2++)
		    if (s[i+k1][j+k2]!=s[i+k2][j+k1]) {
			judge=0;
			break;
		    }
	    for (int nowi=i,nowj=j;nowi<=n&&nowj<=n;nowi++,nowj++)
		vis[nowi][nowj]=judge+1;
	}
    int cnt=0;
    for (int i=1;i<=n;i++)
	for (int j=1;j<=n;j++)
	    if (vis[i][j]==2) cnt++;
    printf("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 3968
import numpy as np
N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
cnt = 0
for i in range(N):
    for j in range(i+1, N):
        if np.linalg.norm(np.array(X[i])-np.array(X[j])).is_integer():
            cnt += 1
print(cnt)

Measured memory_bytes: 26732
#include <bits/stdc++.h>
	#define maxn 100086
	
	using namespace std;
	
	typedef __int128 ll;
	
	int n;
	int p[maxn], cnt;
	bool tag[maxn];
	ll x;
	int ans;
	
	map<ll, ll> mp1, mp2;
	map<ll, int> mp3;
	
	int main(){
		for(int i = 2;i < maxn;i++){
			if(!tag[i]) p[++cnt] = i;
			for(int j = 1;j <= cnt && p[j] * i < maxn;j++){
				tag[p[j] * i] = true;
				if(i % p[j] == 0) break;
			}
		}
		for(int i = 1;i <= cnt;i++) mp1[p[i]] = 1ll * p[i] * p[i], mp1[1ll * p[i] * p[i]] = p[i];
		scanf("%d", &n);
		for(int i = 1;i <= n;i++){
			scanf("%lld", &x);
			ll sum1 = 1, sum2 = 1;
			for(int j = 1;p[j] <= 2200;j++){
				int cnt = 0;
				while(x % p[j] == 0) x /= p[j], cnt++;
				cnt %= 3;
				if(cnt){
					for(int k = 1;k <= cnt;k++) sum1 *= p[j];
					for(int k = 1;k <= 3 - cnt;k++) sum2 *= p[j];
				}
			}
			if(x != 1){
				if(mp1[x]) sum1 *= x, sum2 *= mp1[x];
				else{
					ans++;
					continue;
				}	
			}
			mp2[sum1] = sum2, mp2[sum2] = sum1;
			mp3[sum1]++;
		}
		if(mp3[1]) ans++, mp3[1] = 0;
		for(map<ll, int>::iterator it = mp3.begin();it != mp3.end();++it){
			ll x = it->first, y = mp2[x];
			ans += max(mp3[x], mp3[y]);
			mp3[x] = mp3[y] = 0;
		}
		printf("%d", ans);
	}

Measured memory_bytes: 30940
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
int main()	{
    ll n,a,b;
    cin>>n>>a>>b;
    ll c=a+b;
    ll L=n/c;
    ll R=n%c;
    ll ans;
    if(R<a){
        ans=a*L+R;
    }
    else{
        ans=a*(L+1);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main()
{
    int N;
    cin >> N;
    vector<int> T(N);
    int total_time = 0;
    for (int i = 0; i < N; i++) {
        cin >> T[i];
        total_time += T[i];
    }
    int M;
    cin >> M;
    vector<int> P(M), X(M);
    for (int i = 0; i < M; i++) {
        cin >> P[i] >> X[i];
        P[i]--;
    }
    for (int i = 0; i < M; i++) {
        cout << total_time - T[P[i]] + X[i] << endl;
    }
    return 0;
}


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

using namespace std;

int main()
{
	string a, b;
	cin >> a >> b;
	int c = stoi(a+b);
	int d = (int)sqrt(c);
	if (d * d == c) cout << "Yes";
	else cout << "No";
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
/**
 * C - To Infinity
 * https://atcoder.jp/contests/abc106/tasks/abc106_c
 **/
#include<iostream>
#include<string.h>

using namespace std;

int main() {
    string S;
    long long K;
    cin >> S;
    cin >> K;
    char ans;
    for(long long i=0; i<S.length(); i++) {
        if(S[i]=='1') {
            if(K==i+1) {
                ans = '1';
                break;
            }
        } else {
            ans = S[i];
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<string> S(N);
    rep(i, N){
        cin >> S.at(i);
    }
    sort(S.begin(), S.end());
    int ans = 1;
    rep(i, N - 1){
        if(S.at(i) != S.at(i + 1)){
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 9532
def main():
    N = int(input())
    S = input()
    cnt = {
        'R': [0] * N,
        'G': [0] * N,
        'B': [0] * N
    }

    for i in range(N):
        if i >= 1:
            for c in cnt:
                cnt[c][i] = cnt[c][i-1]
        c = S[i]
        cnt[c][i] += 1
    ans = 0
    for i in range(N):
        for k in range(i+2, N):
            if S[i] != S[k]:
                c1 = S[i]
                c2 = S[k]
                ans += (k-i) - (cnt[c1][k] - cnt[c1][i]) \
                             - (cnt[c2][k] - cnt[c2][i])
                if (k-i) % 2 == 0:
                    j = i + (k-i) // 2
                    if S[i] != S[j] and S[j] != S[k]:
                        ans -= 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 68592
#include <bits/stdc++.h>
using namespace std;
#define sz(x) (int)x.size()
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
const int maxn = 2005;
const int maxm = 250005;
const int mod =  10009;
const int inf = 1e9 + 7;
//head
int n, T, a;
double h[maxn];
int main() {
    cin >> n >> T >> a;
    double d = inf;
    int p;
    for(int i = 0; i < n; ++i) {
        cin >> h[i];
        h[i] = T - 0.006*h[i];
        if(fabs(h[i]-a) < d) {
            d = fabs(h[i]-a);
            p = i;
        }
    }
    cout << p + 1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, s, n)    for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...)  type __VA_ARGS__; read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream& operator>> (istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x): x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

i64 sigma(i64 n) { return n * (n + 1) / 2; }

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    var(int, N);
    vector<int> a(N);
    read(a);

    vector<i64> cnt(N + 5);
    rep(i, 0, N) {
        cnt[a[i]] += 1;
    }

    vector<i64> cum(N + 6);
    rep(i, 0, N+3) {
        cum[i+1] = cum[i] + sigma(cnt[i] - 1);
    }

    rep(k, 0, N) {
        const int v = a[k];
        i64 ans = 0;
        ans += cum[v] - cum[0];
        ans += cum[N+2] - cum[v+1];
        ans += sigma(cnt[v] - 2);
        print(ans);
    }

    return 0;
}


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

using namespace std;

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

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

typedef long long           ll;

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

	int N;
	cin >> N;

	vector<ll> a(N);
	for (auto& v : a) cin >> v;

	vector<ll> b(a);
	FOR (i, 1, N) b[i] += b[i - 1];
	ll s = b[N - 1];

	REP (i, N - 1) b[i] = abs(s - (b[i] * 2));
	b.resize(N -1);

	ll minimum = *min_element(ALL(b));
	cout << minimum << endl;
}

Measured memory_bytes: 3456
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <map>

using namespace std;

typedef long long ll;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(min(b, d) - max(a, c), 0) << endl;
}


Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0 
for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            if x == (i * 500 + j * 100 + k * 50):
                count += 1

print(count)

Measured memory_bytes: 3060
// use std::cmp;
// use std::collections::HashMap;
// use std::collections::HashSet;
// use std::collections::VecDeque;


// const INF: i64 = 1_000_000_000;

fn f(a: i64) -> i64 {
    if a > 0 {
        a % 10 + f(a / 10)
    } else {
        0
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    let n = sc.read();
    let mut ans = Vec::new();
    for a in 1..n {
        let b = n - a;
        ans.push(f(a) + f(b));
    }
    let ans = ans.iter().min().unwrap();
    println!("{}", ans);
}

// thanks, ir5
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}


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

int main()
{
    string S;
    cin >> S;

    string alphabet = "abcdefghijklmnopqrstuvwxyz";

    int a_n = alphabet.size();
    int s_n = S.size();
    string c;
    int allExist = 0;

    for (int i = 0; i < a_n; i++)
    {
        bool isExist = false;
        for (int j = 0; j < s_n; j++)
        {
            if (alphabet.at(i) == S.at(j))
            {
                isExist = true;
                allExist++;
                break;
            }
        }
        if (!isExist)
        {
            c = alphabet.at(i);
            break;
        }
    }

    if (allExist == a_n)
    {
        cout << "None" << endl;
    }
    else
    {
        cout << c << endl;
    }

    return 0;
}

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

int main(){ 
 int a,b;
 cin>>a>>b;
 
if ( a < b ) cout<<"a < b"<<endl;
if ( a > b ) cout<<"a > b"<<endl;
if ( a == b ) cout<<"a == b"<<endl;

return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define REP(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

int N;
double p[3010];

// dp[i+1][j]: i番目までコイン(i枚のコイン)を投げて，表がj枚出る確率
double dp[3010][3010];  // 0に初期化

int main()
{
  cin >> N;
  REP(i,0,N) cin >> p[i];

  // Init:
  dp[0][0] = 1;

  // Update:
  REP(i,0,N) REP(j,0,N) {
    // (i,j) から辿る (配る)
    // i番目のコインを投げる状況
    // 表が出る場合
    dp[i+1][j+1] += dp[i][j] * p[i];
    // 裏が出る場合
    dp[i+1][j] += dp[i][j] * (1 - p[i]);
  }

  // 表の個数が裏の個数を上回る確率
  double res = 0.0;
  REP(j,0,N+1) {
    if (j > N - j) res += dp[N][j];
  }
  cout << fixed << setprecision(10) << res << endl;

  return 0;
}


Measured memory_bytes: 70784
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

#define REP(i,n) for(int i = 0; i < n; i++)
#define ll long long
#define PI M_PI
#define bf printf("\n");

int main(void){
    int A, B;
    scanf("%d""%d",&A,&B);

    if(A <= 2*B) printf("0");
    else printf("%d",A-2*B);
    
    return 0;
}

Measured memory_bytes: 128
<?php
$max = trim(fgets(STDIN));
if ($max == 1) {
  echo $max."\n";
} else {
  for ($i=$max; $i >= 2; $i--) {
    if  (($i & ($i - 1)) == 0) {
      echo $i."\n";
      break;
    }
  }
}


Measured memory_bytes: 3828
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string.h>
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%I64d",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
#define INF                         (int)1e9
#define EPS                         1e-9
#define bitcount                    __builtin_popcount
#define gcd                         __gcd
#define forall(i,a,b)               for(int i=a;i<b;i++)
#define foreach(v, c)               for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define all(a)                      a.begin(), a.end()
#define in(a,b)                     ( (b).find(a) != (b).end())
#define pb                          push_back
#define fill(a,v)                    memset(a, v, sizeof a)
#define sz(a)                       ((int)(a.size()))
#define mp                          make_pair
#define MOD                         1000000007
typedef long long ll;
/*For you see , each day i love you
 more.Today more than yesterday
  less than tomorrow.*/
using namespace std;
\
int main()
{
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	
	cout<<max(a*c , max(a*d , max(b*c , b*d)))<<endl;
	return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> x(m);
  rep(i, m) cin >> x[i];

  sort(x.begin(), x.end());
  vector<int> g(m-1);
  rep(i, m-1) g[i] = x[i+1] - x[i];
  sort(g.begin(), g.end());
  int ans = 0;
  rep(i, m-n) ans += g[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3960
n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
p = [pow(2, i, mod) for i in range(60)]
ans = 0
for i in range(60):
    c = 0
    for j in a:
        if (j >> i) & 1:
            c += 1
    ans += (c * (n - c) * p[i]) % mod
    ans %= mod
print(ans)

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

int main() {
  int k;
  cin >> k;
  int x = 7%k;
  set<int> s;
  int i = 1;
  while(s.count(x) == 0) {
  	if(x == 0) {
      cout << i << endl;
      return 0;
    }
    s.insert(x);
    x = (x*10+7)%k;
    i++; 
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 50512
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = new int[n];
            int[] b = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }
            for (int i = 0; i < n; i++) {
                b[i] = in.nextInt();
            }
            long sumpos = 0;
            long sumneg = 0;

            for (int i = 0; i < n; i++) {
                if (a[i] < b[i]) {
                    sumneg += (b[i] - a[i]) / 2;
                }
                if (b[i] < a[i]) {
                    sumpos += a[i] - b[i];
                }
            }

            if (sumneg < sumpos) {
                out.println("No");
            } else {
                out.println("Yes");
            }
        }

    }
}



Measured memory_bytes: 43828
count = int(input())

pls_flg = False
mns_flg = False
srt_flg = True
tmp = input().split()
num = []
work_max = 0
work_min = 0
index_max = 0
index_min = 0

for i in range(count):
    if int(tmp[i])>0:
        num.append(int(tmp[i]))
        pls_flg = True
        if work_max < num[i]:
            work_max = num[i]
            index_max = i
    elif int(tmp[i])<0:
        num.append(int(tmp[i]))
        mns_flg = True
        if abs(work_min) < abs(num[i]):
            work_min = num[i]
            index_min = i
    else:
        num.append(int(tmp[i]))
    
    if srt_flg and i > 0:
        if num[i-1] > num[i]:
            srt_flg = False

if srt_flg:
    print(0)
else:
    if pls_flg and not mns_flg:
        print(count-1)
        for j in range(count-1):
            print(str(j+1)+" "+str(j+2))
    elif not pls_flg and mns_flg:
        print(count-1)
        for j in range(count-1):
            print(str(count-j)+" "+str(count-1-j))
    elif pls_flg and mns_flg:
        print(2*count-1)
        if work_max >= abs(work_min):
            for x in range(count):
                print(str(index_max+1)+" "+str(x+1))
            for y in range(count-1):
                print(str(y+1)+" "+str(y+2))
        else:
            for x in range(count):
                print(str(index_min+1)+" "+str(x+1))
            for y in range(count-1):
                print(str(count-y)+" "+str(count-y-1))
    else:
        print(0)

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

using namespace std;
int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    if(a<c && c <b)
    {
        cout << "Yes" << endl;
    }else if(a>c && c>b)
    {
        cout << "Yes" << endl;
    }else
    {
        cout << "No" << endl;
    }

}

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

int main()
{
    ll n,k;
    cin>>n>>k;
    ll h[100006];
    vector <long long ll> min(100006,1000000000006);
    min[0]=0;

    for(ll i=0;i<n;i++)
        cin>>h[i];

    ll minm=-1;
        for(ll i=1;i<n;i++)
    {
        for(ll j=1;j<=k && i-j>=0;j++)
        {
            minm = (abs(h[i]-h[i-j]) + min[i-j]);
            if(min[i]>minm){
                min[i]=minm;
            }
        }
    }
    cout<<min[n-1]<<endl;
}

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

int main(){

    int n;
    cin >> n;
    vector<int> p(n);
    int ma=0;
    int su=0;
    rep(i,n){
        cin >> p[i];
        ma=max(ma,p[i]);
        su+=p[i];
    }

    cout << su-(ma/2) <<endl;


    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)


def solve(c: str):
    if c in 'aeiou':
        ret = 'vowel'
    else:
        ret = 'consonant'
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    c = next(tokens)  # type: str
    solve(c)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<cstdio>
#include<cstring>
#include<iostream>
#include<map>
#include<queue>
#include<cstdlib>
#include<algorithm>
#include<stack>
#include<cmath>
using namespace std;

int vis[200005],x[200005],y[200005];

int main(){
	int n,m;
	cin >> n >> m;
	for(int i = 1;i <= m;i++){
		cin >> x[i] >> y[i];
		if(x[i] == 1) vis[y[i]] = 1;
		else if(y[i] == 1) vis[x[i]] = 1;
	}
	int flag = 0;
	for(int i = 1;i <= m;i++){
		if(x[i] == n && vis[y[i]] == 1){
			flag = 1;
			break;
		}
		else if(y[i] == n && vis[x[i]] == 1){
			flag = 1;
			break;
		}
	}
	if(flag) cout << "POSSIBLE";
	else cout << "IMPOSSIBLE";
}

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

int main () {
  int n;
  cin >> n;
  
  while(n) {
    if (n % 10 == 7) {
      cout << "Yes";
      return 0;
    }
    n /= 10;
  }
  cout << "No";
}


Measured memory_bytes: 3580
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<cmath>
using namespace std;

vector<pair<int, int>> P;

int main()
{
  int n, d = 1000000000;
  cin >> n;
  for(int i = 0; i < n; i++)
  {
    int a, b;
    cin >> a >> b;
    P.push_back(make_pair(a, b));
  }
  sort(P.begin(), P.end());
  
  for(int i = 0; i < P.size(); i++)
  {
    for(int j = i + 1; j < P.size(); j++)
    {
      if(pow(P[i].first - P[j].first, 2) > d)
        break;
      d = min((int)(pow(P[i].first - P[j].first, 2) + pow(P[i].second - P[j].second, 2)), d);
    }
  }
  cout << d << endl;
}

Measured memory_bytes: 5644
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

int n;
int sum[2000];

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		int Ia;
		scanf("%d",&Ia);
		sum[Ia]++;
	}
	for(int i=1;i<=2000;i++) sum[i]+=sum[i-1];
	long long ans=0;
	for(int i=1;i<=1000;i++)
		for(int j=i;j<=1000;j++){
			int L=max(j-i+1,j),R=i+j-1;
			if(L>R) continue;
			long long tot=sum[R]-sum[L-1],ni=sum[i]-sum[i-1],nj=sum[j]-sum[j-1];
			if(i==j){
				tot-=ni;
				ans+=tot*ni*(ni-1)/2;
				ans+=ni*(ni-1)*(ni-2)/6;
			}
			else{
				if(L==j){
					tot-=nj;
					ans+=tot*ni*nj;
					ans+=ni*nj*(nj-1)/2;
				}
				else{
					ans+=ni*nj*tot;
				}
			}
		}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
//xtwakioi! xtwddYnoi(双重含义)!
#include <bits/stdc++.h>
#define ri register
#define int long long
#define E (n+1)
using namespace std; const int N=1010; const double eps=1e-5;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
signed main()
{
    int a,b;
    cin>>a>>b;
    printf("%lld\n",(a+b)%24);
    return 0;
}

Measured memory_bytes: 3644
from math import gcd

def main():
    k = int(input())
    ans = 0

    for i in range(k):
        for j in range(k):
            for ii in range(k):
                ans += gcd(i+1,gcd(j+1,ii+1))

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9200
S=input()
N=len(S)
ans='Yes'

for i in range((N-1)//2):
    if S[i] != S[N-i-1]:
        ans='No'

if int((N-1)/2)%2==1:
    for i in range((N-3)//4):
        if S[i] != S[((N-3)//2)-i] or S[((N+1)//2)+i] != S[N-i-1]:
            ans='No'
else:
    for i in range((N-1)//4):
        if S[i] != S[((N-3)//2)-i] or S[((N+1)//2)+i] != S[N-i-1]:
            ans='No'
 
print(ans)


Measured memory_bytes: 3064
import bisect

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort()
B.sort()
C.sort()
ans = 0

for b in B:
    cnt_a = bisect.bisect_left(A, b)
    cnt_c = N - bisect.bisect_right(C, b)
    ans += cnt_a * cnt_c

print(ans)


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

int main(){
  int n, m;
  cin >> n;
  map<string,int> mp;
  rep(i,n) {
    string s;
    cin >> s;
    mp[s]++;
  }
  cin >> m;
  rep(i,m) {
    string t;
    cin >> t;
    mp[t]--;
  }
  int ans = 0;
  for(auto x : mp) ans = max(ans,x.second);
  cout << ans << endl;
  return 0;
}

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

using namespace std;
using ll = long long;
using ii = pair<int, int>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

bool is_square(ll N)
{
    ll a = 1, b = N;

    while (a <= b)
    {
        ll m = a + (b - a)/2;
        ll m2 = m*m;

        if (m2 == N)
            return true;
        else if (m2 > N)
            b = m - 1;
        else
            a = m + 1;
    }

    return false;
}

int solve(int N, int D, const vector<vector<ll>>& xs)
{
    int ans = 0;

    for (int i = 0; i < N; ++i)
    { 
        for (int j = i + 1; j < N; ++j)
        {
            ll d2 = 0;

            for (int k = 0; k < D; ++k)
                d2 += (xs[i][k] - xs[j][k])*(xs[i][k] - xs[j][k]);

            ans += (is_square(d2) ? 1 : 0);
        }
    }

    return ans;
}

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

    int N, D;
    cin >> N >> D;

    vector<vector<ll>> xs(N, vector<ll>(D));

    for (int i = 0; i < N; ++i)
        for (int j = 0; j < D; ++j)
            cin >> xs[i][j];

    auto ans = solve(N, D, xs);

    cout << ans << '\n';

    return 0;
}


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

double dist(int table[][3],int k,int rk,int gk,int bk) {

  return sqrt((table[k][0]-rk)*(table[k][0]-rk)+(table[k][1]-gk)*(table[k][1]-gk)+(table[k][2]-bk)*(table[k][2]-bk));

}

int main(void) {

  int rk,gk,bk;

  int table[8][3]={{0,0,0},{0,0,255},{0,255,0},{0,255,255},{255,0,0},{255,0,255},{255,255,0},{255,255,255}};

  char buf[10];
  int color[10];

  double min;
  int ans;

  int i,k;


  while(1) {

    fgets(buf,sizeof(buf),stdin);

    buf[strlen(buf)-1]='\0';

    if(strcmp(buf,"0")==0) break;

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

      if(buf[i+1]>='0' && buf[i+1]<='9') color[i]=buf[i+1]-'0';

      else if(buf[i+1]=='a') color[i]=10;

      else if(buf[i+1]=='b') color[i]=11;

      else if(buf[i+1]=='c') color[i]=12;

      else if(buf[i+1]=='d') color[i]=13;
      
      else if(buf[i+1]=='e') color[i]=14;

      else if(buf[i+1]=='f') color[i]=15;

    }

    rk=16*color[0]+color[1];

    gk=16*color[2]+color[3];

    bk=16*color[4]+color[5];

    min=256.0;

    //printf("%d %d %d\n",rk,gk,bk);

    for(k=0;k<8;k++) {

      double temp;

      temp=dist(table,k,rk,gk,bk);

      if(min>temp) {

	min=temp;
	ans=k;

      }

    }

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

    switch(ans) {

    case 0:
      puts("black");
      break;

    case 1:
      puts("blue");
      break;

    case 2:
      puts("lime");
      break;

    case 3:
      puts("aqua");
      break;

    case 4:
      puts("red");
      break;

    case 5:
      puts("fuchsia");
      break;

    case 6:
      puts("yellow");
      break;
      
    case 7: 
      puts("white");
      break;

    }

  }

  return 0;

}

Measured memory_bytes: 0
def read_field()
  field = Array.new(8)
  8.times do |idx|
    field[idx] = gets.split('').to_a
  end
  return field
end

def check_field(field)
  #File top left corner
  topX = -1
  topY = -1
  field.each_with_index do |row, y|
    row.each_with_index do |cell, x|
      if cell == "1"
        topX = x
        topY = y
        break
      end
    end
    if topX != -1 && topY != -1
      break
    end
  end
  #Check A
  if topX <= 6 && topY <= 6 &&
    field[topY][topX + 1] == "1" &&
    field[topY + 1][topX] == "1" &&
    field[topY + 1][topX + 1] == "1"
    puts "A"
  elsif topY <= 4 &&
    field[topY + 1][topX] == "1" &&
    field[topY + 2][topX] == "1" &&
    field[topY + 3][topX] == "1"
    puts "B"
  elsif topX <= 4 &&
    field[topY][topX + 1] == "1" &&
    field[topY][topX + 2] == "1" &&
    field[topY][topX + 3] == "1"
    puts "C"
  elsif 1 <= topX  && topY <= 5 &&
    field[topY + 1][topX] == "1" &&
    field[topY + 1][topX - 1] == "1" &&
    field[topY + 2][topX - 1] == "1"
    puts "D"
  elsif topX <= 5 && topY <= 6 &&
    field[topY][topX + 1] == "1" &&
    field[topY + 1][topX + 1] == "1" &&
    field[topY + 1][topX + 2] == "1"
    puts "E"
  elsif topX <= 6 && topY <= 5 &&
    field[topY + 1][topX] == "1" &&
    field[topY + 1][topX + 1] == "1" &&
    field[topY + 2][topX + 1] == "1"
    puts "F"
  elsif 1 <= topX && topX <= 6 && topY <= 6 &&
    field[topY][topX + 1] == "1" &&
    field[topY + 1][topX] == "1" &&
    field[topY + 1][topX - 1] == "1"
    puts "G"
  else
    raise "Unknown shape"
  end
end

if __FILE__ == $0
  while true
    field = read_field()
    check_field(field)
    unless gets 
      break
    end
  end
end

Measured memory_bytes: 6164
#include<bits/stdc++.h>
using namespace std;
const int N=2010;
int n,x,y,l;
int a[N];
int main(){
	scanf("%d%d%d",&n,&x,&y);
	l=y-x+1;
	for(int i=1;i<x;++i){
		for(int j=y+1;j<=n;++j){
			++a[j-y+x-i+1];
		}
	}
	for(int i=1;i<x;++i){
		++a[x-i];
		for(int k=1;k<=(l>>1);++k){
			a[x-i+k]+=2;
		}
		if(!(l&1)) --a[x-i+(l>>1)];
	}
	for(int j=y+1;j<=n;++j){
		++a[j-y];
		for(int k=1;k<=(l>>1);++k){
			a[j-y+k]+=2;
		}
		if(!(l&1)) --a[j-y+(l>>1)];
	}
	for(int k=1;k<=(l>>1);++k){
		a[k]+=l;
	}
	if(!(l&1)) a[(l>>1)]-=(l>>1);
	for(int i=1;i<x;++i){
		for(int j=i+1;j<x;++j){
			++a[j-i];
		}
	}
	for(int i=y+1;i<=n;++i){
		for(int j=i+1;j<=n;++j){
			++a[j-i];
		}
	}
	for(int i=1;i<n;++i) printf("%d\n",a[i]);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int n;
	scanf("%d",&n);
	int tall[n];
	for(int i=0;i<n;i++){
		scanf("%d",&tall[i]);
	}

	int maxtall=0;
	long sum=0;
	for(int j=0;j<n;j++){
		if(tall[j] < maxtall){
			sum +=(maxtall - tall[j]);
			//printf("this %d \n",maxtall-tall[j]);
		}else{
			maxtall = tall[j];
		}
	}

	printf("%ld\n",sum);


	return 0;
}

Measured memory_bytes: 2460
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <unordered_map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll N, Q, l[100001], r[100001], i, j, ac[100001], cnt=0, a;
    string S;

    cin >> N >> Q >> S;

    for(i=0; i<N-1; i++){
        ac[i] = 0;
    }

    for(i=1; i<=Q; i++){
        cin >> l[i] >> r[i];
    }

    for(i=0; i<N; i++){
        if(i>=1){
            ac[i] = ac[i-1];
        }

        if(i<N-1 && S[i]=='A'&&S[i+1]=='C'){
            ac[i]++;
        }
    }

    for(i=1; i<=Q; i++){
        cout << ac[r[i]-2]-ac[l[i]-2] << endl;
    }

    return 0;
}

Measured memory_bytes: 3456
#include <stdio.h>
 
int main(void){
  int i = 0,min = 1,dmax = 0;
  int N,A[100] = {'0'};
  scanf("%d",&N);
  for(i = 0;i < N; ++i){
    scanf(" %d",&A[i]);
  }
  
  //prove min
  i = 0;	min = A[0];
  while(i < N){
	if(min > A[i])	min = A[i];
	++i;
  }
  
  //prove dmax
  for(i = 0;i < N; ++i){
    if(A[i] - min > dmax)	dmax = A[i] - min;
  }
  printf("%d\n",dmax);
  
  return 0;
}


Measured memory_bytes: 128
n,m=map(int,input().split())
light=[list(map(int,input().split())) for _ in range(m)]
p=list(map(int,input().split()))
ans=0
for i in range(2**n):
    state=[0]*n
    for j in range(n):
        if (i>>j&1):
            state[j]=1
    light_num=0
    for k in range(m):
        switch_num=0
        for l in range(1,light[k][0]+1):
            if state[light[k][l]-1]==1:
                switch_num+=1
        if switch_num%2==p[k]:
            light_num+=1
    if light_num==m:
        ans+=1
print(ans)

Measured memory_bytes: 9228
isLeapYear :: Int -> Bool
isLeapYear n
  | rem n 4   /= 0 = False
  | rem n 400 == 0 = True
  | rem n 100 == 0 = False
  | otherwise      = True

listLY :: [Int] -> String
listLY [x,y]
  | listLY' [x,y] == [] = "NA\n"
  | otherwise           = unlines $ map show  $ listLY' [x,y]       
  where
    listLY' [x,y] = filter isLeapYear [x..y]

test = do
  s <- getLine
  if s == "0 0" then return ()
  else do
    putStrLn ""
    putStr $ listLY (map read (words s))
    test

main = do
  s <- getLine
  if s == "0 0" then return ()
  else do
    putStr $ listLY (map read (words s))
    test

Measured memory_bytes: 4044