akhauriyash/Code-Regression huggingface dataset:
import math


N, D = map(int, input().split())
X = [None] * N

for i in range(N):
    X[i] = list(map(int, input().split()))

ans = 0
for i in range(N):
    for j in range(i + 1, N):
        total = 0
        for k in range(D):
            total += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k])
        distance = math.sqrt(total)
        if distance.is_integer():
            ans += 1

print(ans)


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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    string s, t; cin >> s >> t;
    string u = "";
    for (int i = 0; i < n; i++) {
        u += s[i]; u += t[i];
    }
    cout << u << "\n";
    return 0;
}

Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#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>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#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>
#endif


using namespace std;

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

const int MOD = 1e9 + 7;
const int INF = INT_MAX;

signed main() {
    Fast();

    string s;
    cin >> s;
    cout << "ABC" << s << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp make_pair
#define pr(num) cout << num << "\n"
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 200010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;

ll N;
vector<ll> g[MAX];
ll memoB[MAX], memoW[MAX];

//どの頂点から来たのかを引数に持たせる。がメモするときはその情報はいらない(感覚的にしかまだわかってない)
ll White(ll s, ll from);

ll Black(ll s, ll from) {
    if(memoB[s]!=-1) return memoB[s];
    
    ll res=1;
    for(ll i=0; i<g[s].size(); i++) {
        if(g[s][i]==from) continue;
        res*=White(g[s][i], s);
        res%=MOD;
    }
    
    return memoB[s]=res;
}

ll White(ll s, ll from) {
    if(memoW[s]!=-1) return memoW[s];
    
    ll res=1;
    for(ll i=0; i<g[s].size(); i++) {
        if(g[s][i]==from) continue;
        res*=(Black(g[s][i], s)+White(g[s][i], s))%MOD;
        res%=MOD;
    }
    
    return memoW[s]=res;
}

int main(void) {
    ll i;
    cin >> N;
    for(i=0; i<N-1; i++) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    
    memset(memoB, -1, sizeof(memoB));
    memset(memoW, -1, sizeof(memoW));
    
    pr((Black(0, -1)+White(0, -1))%MOD);
    
}
















Measured memory_bytes: 18176
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define FASTIO cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define ll long long int
#define F first
#define S second
#define pll pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vpii vector<pair<int,int> >
#define vvpii vector<vpii >
#define vpll vector<pair<ll,ll> >
#define vvpll vector<vpll >
#define pb push_back
#define MOD 1000000007
#define brk cout<<"\n"

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;

struct compare {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		if ((a.S - a.F) != (b.S - b.F)) return ((a.S - a.F) > (b.S - b.F));
		else return (a.F < b.F);
	}
};

int main() {
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	FASTIO;
	ll n; cin >> n;
	vl h(n), v(n), dp(n + 1);
	ll base = 1;
	while (base <= n) base *= 2;
	vl segtree(2 * base);
	for (ll i = 0; i < n; i++) cin >> h[i];
	for (ll i = 0; i < n; i++)cin >> v[i];

	for (ll i = 0; i < n; i++) {
		ll best = 0;
		ll x = h[i] + base;
		while (x > 1) {
			if (x % 2 == 1) {
				best = max(best, segtree[x - 1]);
			}
			x /= 2;
		}
		dp[h[i]] = best + v[i];
		for (ll j = base + h[i]; j >= 1; j /= 2) {
			segtree[j] = max(segtree[j], dp[h[i]]);
		}
		//cout << dp[h[i]] << endl;
	}

	ll ans = 0;
	for (ll i = 1; i < n + 1; i++)ans = max(ans, dp[i]);
	cout << ans; brk;



}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;


string ans = "CODEFESTIVAL2016";

int main() {
    string s;
    cin >> s;
    li res = 0;
    rep(i, sz(s)) {
        if (s[i] != ans[i])res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<set>
#include<map>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<math.h>
#include<time.h>
#include<vector>
#include<bitset>
#include<memory>
#include<utility>
#include<fstream>
#include<stdio.h>
#include<sstream>
#include<iostream>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
using namespace std;
int dp[2005][2005];
int a[2005],b[2005];
int c[2005][2005];
int d[2005][2005];
int val[1<<15];
void change(int num,int l,int r,int x,int k)
{
    if (l==r-1)
    {
        val[num]=k;
        return;
    }
    int mid=(l+r)/2;
    if (x<mid)
    {
        change(num*2+1,l,mid,x,k);
    }
    else
    {
        change(num*2+2,mid,r,x,k);
    }
    val[num]=val[num*2+1]+val[num*2+2];
}
int query(int num,int l,int r,int l0,int r0)
{
    if ((l0<=l)&&(r<=r0))
    {
        return val[num];
    }
    int mid=(l+r)/2;
    int ans=0;
    if (l0<mid)
    {
        ans+=query(num*2+1,l,mid,l0,r0);
    }
    if (mid<r0)
    {
        ans+=query(num*2+2,mid,r,l0,r0);
    }
    return ans;
}
int main()
{
    #ifdef absi2011
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int n;
    scanf("%d",&n);
    int i;
    for (i=0;i<2*n;i++)
    {
        static char t[15];
        scanf("%s",t);
        int x;
        scanf("%d",&x);
        if (t[0]=='B')
        {
            a[x-1]=i;
        }
        else
        {
            b[x-1]=i;
        }
    }
    for (i=0;i<2*n;i++)
    {
        change(0,0,2*n,i,1);
    }
    int j;
    for (i=0;i<=n;i++)
    {
        for (j=0;j<=n;j++)
        {
            if (i!=n)
            {
                d[i][j]=query(0,0,2*n,0,b[i]+1)-1;
            }
            if (j!=n)
            {
                c[i][j]=query(0,0,2*n,0,a[j]+1)-1;
                change(0,0,2*n,a[j],0);
            }
        }
        for (j=0;j<n;j++)
        {
            change(0,0,2*n,a[j],1);
        }
        if (i!=n)
        {
            change(0,0,2*n,b[i],0);
        }
    }
    dp[0][0]=0;
    for (i=0;i<=n;i++)
    {
        for (j=0;j<=n;j++)
        {
            if ((i==0)&&(j==0)) continue;
            dp[i][j]=1000000000;
            if (i!=0)
            {
                dp[i][j]=min(dp[i][j],dp[i-1][j]+d[i-1][j]);
            }
            if (j!=0)
            {
                dp[i][j]=min(dp[i][j],dp[i][j-1]+c[i][j-1]);
            }
        }
    }
    printf("%d\n",dp[n][n]);
    return 0;
}


Measured memory_bytes: 47360
n = int(input())
*a, = map(int,input().split())
*b, = map(int,input().split())
#print(a)
#print(b)
cnt = 0
for i in range(n):
  for j in range(i,i+1):
    x = b[j] - a[i]
    if x >= 0:
      b[j] = x
      cnt += a[i]
      y = b[j] - a[i+1]
      if y > 0:
        cnt += a[i+1]
        a[i+1] = 0
      elif y <= 0:
        cnt += b[j]
        a[i+1] = a[i+1] - b[j]
    elif x < 0:
      cnt += b[j]
      continue
print(cnt)


Measured memory_bytes: 18624
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;

int main() {
  int r,g,b;
  cin >> r >> g >> b;
  if((10*g+b)%4==0){
    cout << "YES";
  }else{
    cout << "NO";
  }
  cout << endl;
  return 0;
}

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

int main()
{
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int sum1 = a+b;
    int sum2 = c+d;
    if(sum1>sum2) cout << "Left" << endl;
    else if( sum1<sum2) cout << "Right" << endl;
    else cout << "Balanced" << endl;
    return 0;
}

Measured memory_bytes: 3596
import math

x = 0
y = 0
angle = math.pi / 2

while(1):
    d, a = map(int, input().split(","))
    if d == 0 and a == 0:
        break

    x += math.cos(angle) * d
    y += math.sin(angle) * d
    angle -= a * math.pi / 180

print(int(x))
print(int(y))



Measured memory_bytes: 5720
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 998244353;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
int N;
struct Bit {
  int bit[1000010];
  void add(int a, int w) {
    while(a <= N) {
      bit[a] += w;
      a += a & -a;
    }
  }
  int sum(int a) {
    int s = 0;
    while(a > 0) {
      s += bit[a];
      a -= a & -a;
    }
  return s;
  }
};
lint power(lint x, lint n, lint mod) {
  lint ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= mod;
    (x *= x) %= mod;
    n >>= 1;
  }
  return ret;
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> N;
  vector<P> p(N);
  REP(i, N) {
    lint X, Y;
    cin >> X >> Y;
    //X = i ; Y = i;
    p[i] = make_pair(X, Y);
  }
  sort(ALL(p), [](auto const &a, auto const &b) { return a.second < b.second; });
  map<lint, lint> ymap;
  REP(i, N) ymap[p[i].second] = i;
  sort(ALL(p));
  vector<lint> y(N);
  REP(i, N) y[i] = ymap[p[i].second];
  vector<lint> cnt(N);
  Bit bitleft;
  Bit bitright;
  FOR(i, 1, N+1) bitright.add(i, 1);
  REP(i, N) {
    cnt[i] = (cnt[i] + power(2, i, MOD) - 1 + MOD) % MOD;
    cnt[i] = (cnt[i] + power(2, N-1-i, MOD) - 1 + MOD) % MOD;
    cnt[i] = (cnt[i] + power(2, y[i], MOD) - 1 + MOD) % MOD;
    cnt[i] = (cnt[i] + power(2, N-1-y[i], MOD) - 1 + MOD) % MOD;
    bitright.add(y[i]+1, -1);
    cnt[i] = (cnt[i] - power(2, bitleft.sum(y[i]+1), MOD) + 1 + MOD) % MOD;
    cnt[i] = (cnt[i] - power(2, bitleft.sum(N) - bitleft.sum(y[i]+1), MOD) + 1 + MOD) % MOD;
    cnt[i] = (cnt[i] - power(2, bitright.sum(y[i]+1), MOD) + 1 + MOD) % MOD;
    cnt[i] = (cnt[i] - power(2, bitright.sum(N) - bitright.sum(y[i]+1), MOD) + 1 + MOD) % MOD;
    bitleft.add(y[i]+1, 1);
  }
  lint ans = 0;
  REP(i, N) ans = (ans + power(2, N, MOD) - 1 - cnt[i] + MOD) % MOD;
  cout << ans << endl;
}

Measured memory_bytes: 22044
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;


public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.testScoreCalculation();
		return;
	}
	
	//テストの点数を比較し、表示する
	private void testScoreCalculation() {
		
		BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in)); //標準入力
		
		try {
			
			LinkedList<Integer> testScoreAList = new LinkedList<Integer>();
			LinkedList<Integer> testScoreBList = new LinkedList<Integer>();
			
			//Aの得点を入力
			String inputStr = bufferedReader.readLine();
			String[] inputStrs = inputStr.split(" ");
			
			for (int i = 0; i < 4; i++) {
				testScoreAList.add(Integer.parseInt(inputStrs[i]));
			}
			
			//Bの得点を入力
			String inputStr2 = bufferedReader.readLine();
			String[] inputStrs2 = inputStr2.split(" ");
			
			for (int i = 0; i < 4; i++) {
				testScoreBList.add(Integer.parseInt(inputStrs2[i]));
			}
			
			int scoreA = 0;
			int scoreB = 0;
			
			for (int i : testScoreAList) {
				scoreA += i; 
			}
			
			for (int i : testScoreBList) {
				scoreB += i; 
			}
			
			if (scoreA == scoreB) {
				System.out.println(scoreA);
			} else if (scoreA > scoreB) {
				System.out.println(scoreA);
			} else if (scoreA < scoreB) {
				System.out.println(scoreB);
			}
			
		} catch (IOException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}
		
	}
}

Measured memory_bytes: 16896
# This was written by chizuchizu
import sys
# import collections

# import bisect
# import math
import numpy as np

"""Template"""


class IP:
    """
    入力を取得するクラス
    """

    def __init__(self):
        self.input = sys.stdin.readline

    def I(self):
        """
        1文字の取得に使います
        :return: int
        """
        return int(self.input())

    def S(self):
        """
        1文字の取得(str
        :return: str
        """
        return self.input()

    def IL(self):
        """
        1行を空白で区切りリストにします(int
        :return: リスト
        """
        return list(map(int, self.input().split()))

    def SL(self):
        """
        1行の文字列を空白区切りでリストにします
        :return: リスト
        """
        return list(map(str, self.input().split()))

    def ILS(self, n):
        """
        1列丸々取得します(int
        :param n: 行数
        :return: リスト
        """
        return [int(self.input()) for _ in range(n)]

    def SLS(self, n):
        """
        1列丸々取得します（str
        :param n: 行数
        :return: リスト
        """
        return [self.input() for _ in range(n)]

    def SILS(self, n):
        """
        Some Int LineS
        横に複数、縦にも複数
        :param n: 行数
        :return: list
        """
        return [self.IL() for _ in range(n)]

    def SSLS(self, n):
        """
        Some String LineS
        :param n: 行数
        :return: list
        """
        return [self.SL() for _ in range(n)]


"""ここからメインコード"""


def main():
    # 1文字に省略
    r, e = range, enumerate
    ip = IP()

    """この下から書いてね"""
    # n, m = ip.IL()
    # a = np.array(ip.IL())
    # for _ in range(m):
    #     a[np.argmax(a)] //= 2
    # print(np.sum(a))
    s = input()
    if s == "ABC":
        print("ARC")
    if s =="ARC":
        print("ABC")

main()

Measured memory_bytes: 27108
import bisect
q=int(input())
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]
P=primes(10**5+3)
p=set(P)
A=[]
for i in range(len(P)):
  if (P[i]+1)//2 in p:
    A.append(P[i])
for i in range(q):
  a,b=map(int,input().split())
  print(bisect.bisect_right(A,b+1,lo=0,hi=len(A))-bisect.bisect_right(A,a-1,lo=0,hi=len(A)))

Measured memory_bytes: 55384
#include<bits/stdc++.h>
#define Imposter ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;
#define f(n) for(ll i=0;i<n;i++)
#define rep(i,a,b) for(i=a;i<b;i++)
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define vll vector<ll>
#define vlll vector<vll>
#define all(x) x.begin(),x.end()
ll power(ll x, ll y, ll p) { 
    ll res = 1;    x = x % p;  
    while(y > 0) {
        if(y & 1) res = (res*x) % p; 
        y = y>>1;    x = (x*x) % p; 
    } return res; 
}
int main()
{
    Imposter
    
    int t=1;
    //cin>>t;
    while(t--)
    {
       ll n,k;
       cin>>n>>k;
       ll a[n];
       input(a,n);
       deque<ll>ans;
       f(k)
       {
           ans.push_back(a[i]);
       }
       for(int i=k;i<n;i++)
       {
           if(ans.front()>=a[i])
           cout<<"No"<<endl;
           else
           cout<<"Yes"<<endl;
           ans.pop_front();
           ans.push_back(a[i]);
       }
       
        
    }
    return 0;
}

Measured memory_bytes: 6360
n, d = gets.chomp.split(' ').map(&:to_i)
arr = []

count = 0

n.times do |i|
  pair = gets.chomp.split(' ').map(&:to_i)
  arr << pair
end

target = arr.combination(2).to_a

target.each do |pair|  
  sum = 0
  d.times do |j|
    sum = sum + ((pair[0][j] - pair[1][j])**2)
  end
  distance = sum**(1/2.0)
  count = count + 1 if distance.to_i == distance
end
puts count

Measured memory_bytes: 1788
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<cstdlib>
using namespace std;

int main()
{
	int q;
	long long a, b, s, ans;
	cin >> q;
	while(q--) {
		cin >> a >> b;
		s = sqrt(a * b);
		if(s * (s + 1) < a * b)
			ans = 2 * s - 1;
		else if(s * s == a * b){
			if(a == b)
				ans = 2*(s - 1);
			else 
				ans = 2 * (s - 1) -1;
		}
		else
			ans = 2 * (s - 1);
		cout << ans << '\n';
	}
}

Measured memory_bytes: 256
// tested by Hightail: https://github.com/dj3500/hightail
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <stack>
#include <cstring>
#include <iomanip>
#include <ctime>
#include <cassert>
using namespace std;
#define pb push_back
#define INF 1001001001
#define FOR(i,n) for(int (i)=0;(i)<(n);++(i))
#define FORI(i,n) for(int (i)=1;(i)<=(n);++(i))
#define mp make_pair
#define pii pair<int,int>
#define ll long long
#define vi vector<int>
#define SZ(x) ((int)((x).size()))
#define fi first
#define se second
#define wez(n) int (n); scanf("%d",&(n));
#define wez2(n,m) int (n),(m); scanf("%d %d",&(n),&(m));
#define wez3(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k));
inline void pisz(int n) { printf("%d\n",n); }
template<typename T,typename TT> ostream& operator<<(ostream &s,pair<T,TT> t) {return s<<"("<<t.first<<","<<t.second<<")";}
template<typename T> ostream& operator<<(ostream &s,vector<T> t){FOR(i,SZ(t))s<<t[i]<<" ";return s; }
#define DBG(vari) cout<<"["<<__LINE__<<"] "<<#vari<<" = "<<(vari)<<endl;
#define ALL(t) t.begin(),t.end()
#define FOREACH(i,t) for (__typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define TESTS wez(testow)while(testow--)
#define REP(i,a,b) for(int (i)=(a);(i)<=(b);++i)
#define REPD(i,a,b) for(int (i)=(a); (i)>=(b);--i)
#define REMAX(a,b) (a)=max((a),(b));
#define REMIN(a,b) (a)=min((a),(b));
#define IOS ios_base::sync_with_stdio(0);

int main () {
   int odd = 0, even = 0;
   TESTS {
      wez(x);
      if (x % 2 == 1) ++odd;
      else ++even;
   }
   if ((odd == 1 && even == 0) || (odd % 2 == 0)) printf("YES"); else printf("NO");
}

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

#define ALL(a)  (a).begin(),(a).end()
 
int main(){
    int N;
    cin >> N;
    vector<ll> A(N), B(N), C(N);
    for(int i=0;i<N;i++)
        cin >> A[i];
    for(int i=0;i<N;i++)
        cin >> B[i];
    for(int i=0;i<N;i++)
        cin >> C[i];

    // 昇順ソート
    sort(ALL(A));
    sort(ALL(B));
    sort(ALL(C));

    ll ans = 0, num[N], sum[N];
    for(int i=0;i<N;i++){
        auto Iter1 = upper_bound(ALL(C), B[i]);
        num[i] = C.end() - Iter1;
    }
    sum[N-1] = num[N-1];
    for(int i=N-2;i>=0;i--){
        sum[i] = sum[i+1] + num[i];
    }
    for(int i=0;i<N;i++){
        auto Iter1 = upper_bound(ALL(B), A[i]);
        if(Iter1 - B.begin() < N)   // ここでWAになった
            ans += sum[Iter1 - B.begin()];
    }

    cout << ans << endl;

}

Measured memory_bytes: 4224
#include <iostream>
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 << " ";
    printf("%lf\n",f);
    return 0;
}


Measured memory_bytes: 3232
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

const ll MOD = 1000000007;

struct mint {
    ll x;
    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 {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t/2);
        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 {
        mint res(*this);
        return res /= a;
    }
};

ostream &operator<<(ostream &os, const mint &a) {
    return os << a.x;
}


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];
    }
    mint nPk(int n, int k){
        return fact[n]*ifact[n-k];
    }
};

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

    combination nCk(1000009);
    mint ans = 0;
    for(int i=0;i<=N;++i){
        mint now = nCk.nPk(M,N); // Aの配列の順列
        now *= nCk(N,i); // Bの配列のうち、どこをAと一致させるか
        now *= nCk.nPk(M-i,N-i); // Aと一致しないものを自由に並べる方法
        if(i&1) now = -now; // 包除原理
        ans += now;
    }
    cout << ans << endl;
}


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

int main(){
    int A, B, K;
    cin >> A >> B >> K;
    vector<int> Ks(max(A,B));
    int i = 1;
    while (i <= max(A,B) ){
        if (A%i == 0 && B%i == 0){
            Ks.push_back(i);
        }
        i += 1;
    }
    reverse(Ks.begin(), Ks.end());
    cout << Ks.at(K-1) << endl;
}

Measured memory_bytes: 3604
<?php
  $n = trim(fgets(STDIN));
  $a = explode(" ", trim(fgets(STDIN)));
  $cnt = [];
  for($i=0; $i<$n; $i++){
      $cnt[$a[$i]]++;
  }
  
  function s($k){
      return ($k*($k+1))/2;
  }
  $total = 0;
  foreach($cnt as $d){
      $total += s($d-1);
  }
//   echo $total;
  
  for($i=0; $i<$n; $i++){
      echo $total-($cnt[$a[$i]]-1);
      echo "\n";
  }
  
  

Measured memory_bytes: 34912
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	long long x;
	cin >> x;
	int ans = 0;
	long long n = 100;
	while(n < x)
	{
		n *= 1.01;
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

int main()
{
    char a[3][3];
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++)
            scanf("%c",&a[i][j]);
        getchar();
    }
    printf("%c%c%c",a[0][0],a[1][1],a[2][2]);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){fastio
    ll n,k;cin>>n>>k;
    ll l[n];rep(i,0,n-1)cin>>l[i];
    sort(l,l+n,greater<ll>());
    ll ans=0;
    rep(i,0,k-1)ans+=l[i];
    cout<<ans<<endl;
    
    return 0;
}




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

int main(int argc, char const *argv[])
{
	
	int n,a,b,c,x,y,z,ax,bx,cx;
  
	cin>>n>>a>>b>>c;
	for(int i=1;i<n;i++){
		cin>>x>>y>>z;
		ax = x+max(b,c);
		bx = y+max(a,c); 
		cx = z+max(a,b);
		a=ax,b=bx,c=cx;
	}	

	cout << max(a,max(b,c)) <<endl;
	
	return 0;
}

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

long long dp[100][8];

long long f(std::vector<std::vector<long long>>& ss, long long i) {
    if (i <= 0) return 1;
    else return ss[i][0] + ss[i][1];
}

int main() {
    long long h, w, k;
    const auto mod = 1000000007ll;
    std::cin >> h >> w >> k;
    if (w == 1) {
        std::cout << 1 << std::endl;
        return 0;
    }
    std::vector<std::vector<long long>> ss(w + 10, std::vector<long long>(2));
    ss[1][0] = 1;
    ss[1][1] = 1;
    for (int i = 2; i < w; i++) {
        ss[i][0] = ss[i - 1][0] + ss[i - 1][1];
        ss[i][1] = ss[i - 1][0];
    }

    std::vector<std::vector<long long>> sw(w + 10, std::vector<long long>(2));
    for (int i = 0; i < w; i++) {
        sw[i][0] = f(ss, i) * f(ss, w - 2 - i) % mod;
        sw[i][1] = f(ss, i - 1) * f(ss, w - 3 - i) % mod;
    }

    // for (int i = 0; i < w; i++) std::cout << sw[i][0] << " " << sw[i][1] << std::endl;

    dp[0][0] = 1;
    auto t = (sw[0][0] + sw[0][1]) % mod;

    for (int i = 1; i <= h; i++) {
        dp[i][0] = (sw[0][0] * dp[i - 1][0] % mod + sw[0][1] * dp[i - 1][1] % mod) % mod;
        dp[i][w - 1] = (sw[w - 2][0] * dp[i - 1][w - 1] % mod + sw[w - 2][1] * dp[i - 1][w - 2] % mod) % mod;
        for (int j = 1; j < w - 1; j++) {
            dp[i][j] += sw[j - 1][1] * dp[i - 1][j - 1] % mod;
            dp[i][j] += sw[j][1] * dp[i - 1][j + 1] % mod;
            dp[i][j] += (t - sw[j - 1][1] - sw[j][1]) * dp[i - 1][j] % mod;
            dp[i][j] %= mod;
        }
    }

    std::cout << dp[h][k - 1] << std::endl;

    return 0;
}

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

int main(void){
    int n;cin>>n;
    string s;cin>>s;
    int res = 0;
    for(int i=0;i<1000;i++){
        int a[3]={i/100,(i%100)/10,i%10};
        //cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<endl;
        int l=0;
        
        for(int j=0;j<n;j++){
            if(s[j]==('0'+a[l]))l++;
            if(l==3)break;
        }
        if(l==3)res++;
    }
    cout<<res<<endl;
}


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

int main() {
  
  string S,T;
  cin >>S>>T;
  T.pop_back();
  if (S==T){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" <<endl;
  }
}



Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

ll oneplus(ll cnt){return cnt*5+(cnt+1)*3+4*8;}
ll multiplus(ll cnt){
  ll ret=0;
  ll hoge=0;
  for(int i=0;i<cnt;i++){
    hoge++;
    hoge*=10;
  }  
  hoge*=9;
  ll minus=1;
  for(int i=0;i<cnt;i++){
    minus*=10;
  }
  minus+=5;
  hoge-=minus;
  return ((hoge)/15)*(4*8+(cnt+1)*8);
}
ll ret_hoge(ll cnt){
  ll ret=0;
  ll hoge=0;
  for(int i=0;i<cnt;i++){
    hoge++;
    hoge*=10;
  }  
  hoge*=9;
  ll minus=1;
  for(int i=0;i<cnt;i++){
    minus*=10;
  }
  return hoge-minus;
}
string tostr(ll num){
  string ret = "";
  while(num>0){
    ret+=(char)('0'+num%10);
    num/=10;
  }
  reverse(ALL(ret));
  return ret;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll s;cin>>s;s;
  ll now=1;
  ll cnt=1;
  while(now <= s){
    //cout<<now<<endl;
    ll plus=oneplus(cnt);
    //cout<<plus<<" "<<cnt<<endl;
    if(now<=s&&s<now+plus){
      string str="";
      ll start=0;
      for(int i=0;i<cnt-1;i++){
	start++;
	start*=10LL;
      }
      start*=9LL;start++;
      for(ll i=start;i<start+15;i++){
	ll num=i-start+1;
	if(num%15 == 0){
	  str+="FizzBuzz";
	}else if(num%5 == 0){
	  str+="Buzz";
	}else if(num%3 == 0){
	  str+="Fizz";
	}else{
	  str+=tostr(i);
	}
      }
      for(ll i=start+15;i<start+30;i++){
	ll num=i-start+1+15;
	if(num%15 == 0){
	  str+="FizzBuzz";
	}else if(num%5 == 0){
	  str+="Buzz";
	}else if(num%3 == 0){
	  str+="Fizz";
	}else{
	  str+=tostr(i);
	}
      }
      s-=now;
      for(ll i=s;i<s+20;i++)
	cout<<str[i];
      cout<<endl;
      break;
    }
    now+=plus;
    plus=multiplus(cnt);
    if(now<=s&&s<now+plus){
      string str="";
      s-=now;
      ll start=1;
      for(int i=0;i<cnt;i++){
	start*=10LL;
      }
      start+=6;
      ll waru=(cnt+1)*8+4*8;
      ll numm=s/waru;
      s=s%waru;
      start+=numm*15;
      for(ll i=start;i<start+15;i++){
	ll num=i-start+1;
	if(num%15 == 0){
	  str+="FizzBuzz";
	}else if(num%5 == 0){
	  str+="Buzz";
	}else if(num%3 == 0){
	  str+="Fizz";
	}else{
	  str+=tostr(i);
	}
      }
      for(ll i=start+15;i<start+30;i++){
	ll num=i-start+1+15;
	if(num%15 == 0){
	  str+="FizzBuzz";
	}else if(num%5 == 0){
	  str+="Buzz";
	}else if(num%3 == 0){
	  str+="Fizz";
	}else{
	  str+=tostr(i);
	}
      }
      for(ll i=s;i<s+20;i++){
	cout<<str[i];
      }
      cout<<endl;
      break;
    }
    now+=plus;
    cnt++;
  }
  return 0;
}



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

#define rep(i, N) for(int i = 0;i < N;i++)

typedef long long ll;

const int mod = 1e9 + 7;

using namespace std;

int sum(vector<int> v) {
	int res = 0;
	for (auto x : v)res += x;
	return res;
}

int main(void) {
	int N, M; cin >> N >> M;
	vector<int> ac(N, 0);
	vector<int> pen(N, 0);

	rep(unchi, M) {
		int p; string s; cin >> p >> s;
		p--;
		if (ac[p])continue;
		if (s == "AC")ac[p] = 1;
		else pen[p]++;
	}

	rep(i, N) {
		if (ac[i] == 0)pen[i] = 0;
	}

	cout << sum(ac) << " " << sum(pen) << endl;

	return 0;
}

Measured memory_bytes: 4776
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  vector<int>a(n,0);
  int d,val;
  for(int i=0;i<k;i++){
    cin>>d;
    for(int j=0;j<d;j++){
      cin>>val;
      a[val-1]+=1;
    }
  }
  int sum = 0;
  for(int i=0;i<n;i++){
    if(a[i]==0)sum++;
  }
  cout<<sum<<endl;
  
  return 0;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    long long int n,i,j,k,flag,count=0;
    cin>>n;
    long long int l[n];
    for(i=0;i<n;i++)
    {
       cin>>l[i]; 
    }
    sort(l,l+n);
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            for(k=j+1;k<n;k++)
            {
                if((l[i]+l[j]>l[k])&&(l[i]+l[k]>l[j])&&(l[k]+l[j]>l[i]))
                count++;
                
            }
        }
    }
    cout<<count;

     

  return 0;
    
}
    


Measured memory_bytes: 384
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func next(x, y, H, W int) (int, int) {
	if y%2 == 1 {
		x--
		if x < 0 {
			x = 0
			y++
		}
	} else {
		x++
		if x == W {
			x--
			y++
		}
	}
	return x, y
}

func main() {
	sc.Split(bufio.ScanWords)
	H, W := getInt(), getInt()
	a := make([][]int, H)
	for i := 0; i < H; i++ {
		a[i] = make([]int, W)
		for j := 0; j < W; j++ {
			a[i][j] = getInt()
		}
	}

	x := 0
	y := 0
	rest := 0
	cnt := 0
	b := make([][4]int, 0)
	for i := 0; i < H*W-1; i++ {
		a[y][x] += rest
		// out(y, x)
		if a[y][x]%2 == 0 {
			rest = 0
		} else {
			rest = 1
			cnt++
			a[y][x]--
			xx, yy := next(x, y, H, W)
			b = append(b, [4]int{y + 1, x + 1, yy + 1, xx + 1})
		}
		x, y = next(x, y, H, W)
	}
	if rest == 1 {
		a[H-1][W-1]++
	}

	out(cnt)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()
	for _, v := range b {
		fmt.Fprintln(w, v[0], v[1], v[2], v[3])
	}

}


Measured memory_bytes: 23424
N=int(input())
A=[int(i) for i in input().split()]
B=[0 for _ in range(N)]
def f(a,N):
    l=[]
    m=2*a
    while m<=N:
        l.append(m)
        m+=a
    return l

for a in range(1,N+1)[::-1]:
    idx=f(a,N)
    b_sum=0
    for i in idx:
        b_sum += B[i-1]
    B[a-1] = (A[a-1] - b_sum) % 2
ans=[i+1 for i in range(N) if B[i] != 0]
print(len(ans))
if len(ans)!=0:
    print(*ans)

Measured memory_bytes: 98400
#include <bits/stdc++.h>
using namespace std;
#define int long long

int N, H[200005], A[200005], dp[200005], ft[200005];

inline int ls(int x) { return x & -x; }

int qry(int p) {
	int r = 0;
	for (; p; p -= ls(p)) r = max(r, ft[p]);
	return r;
}

void upd(int p, int v) {
	for (; p <= N; p += ls(p)) ft[p] = max(ft[p], v);
}

main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> N;
	for (int i = 1; i <= N; i++) cin >> H[i];
	for (int i = 1; i <= N; i++) cin >> A[i];
	for (int i = 1; i <= N; i++) {
		dp[i] = qry(H[i]) + A[i];
		upd(H[i], dp[i]);
	}
	cout << *max_element(dp + 1, dp + 1 + N) << '\n';
}


Measured memory_bytes: 6528
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		// 計算
		int result = 0;
		if(a*b == 2) result = 3;
		if(a*b == 3) result = 2;
		if(a*b == 6) result = 1;
		
		
		
		// 出力
		System.out.println(result);
	}
}




Measured memory_bytes: 21076
import sys
import math
import bisect

def main():
    s, t = input().split()
    A = list(map(int, input().split()))
    tmp = input()
    if tmp == s:
        A[0] -= 1
    elif tmp == t:
        A[1] -= 1
    print('%d %d' % (A[0], A[1]))

if __name__ == "__main__":
    main()


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

using namespace std;

#define int long long
#define MOD 1000000007

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}

//typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
//#define int long long

int N;
vector<int> a;

std::vector<int> enum_div(int n) //nの約数を列挙
{
    std::vector<int> ret;
    for (int i = 1; i * i <= n; ++i)
    {
        if (n % i == 0)
        {
            ret.push_back(i);
            if (i != 1 && i * i != n)
            {
                ret.push_back(n / i);
            }
        }
    }
    return ret;
}

signed main()
{
    cin >> N;
    a.resize(N + 1);
    rep(i, N)
    {
        cin >> a[i + 1];
    }

    int cnt = 0;
    vector<int> ans;

    for (int i = 0; i < N; i++)
    {

        if (a[N - i] == 0)
        {
            continue;
        }
        else if (a[N - i] == 1)
        {
            for (auto x : enum_div(N - i))
            {
                if (a[x] == 1)
                {
                    a[x]--;
                }
                else if (a[x] == 0)
                {
                    a[x]++;
                }
            }
            cnt++;
            ans.pb(N - i);
        }

        else
        {
            cout << -1 << endl;
        }
    }

    cout << cnt << endl;

    if (cnt > 0)
    {
        for (auto x : ans)
        {
            cout << x << endl;
        }
    }

    return 0;
}


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


int main(){
  int n, W; cin >> n >> W;
  vector<int> v(n);
  vector<int> w(n);
  for (int i = 0; i < n; i++) cin >> v.at(i) >> w.at(i);
  
  vector<vector<int>> dp(n + 1,vector<int>(W + 1));
  for (auto &&i : dp.at(0))
  {
    i = 0;
  }

  //cout << "a" << endl;
  for (int i = 0; i < n; i++)
  {
    //cout << "i = " << i << endl;
    for (int j = 0; j <= W; j++)
    {
      //cout << "    j = " << j << endl;
      if (j >= w.at(i))
      {
        dp.at(i + 1).at(j) = max(dp.at(i).at(j - w.at(i)) + v.at(i), dp.at(i).at(j));
      }
      else
      {
        dp.at(i + 1).at(j) = dp.at(i).at(j);
      }
      
    }
    
    //dp table output
    /*
    for (auto &&k: dp)
    {
      for (auto &&l : k)
      {
        cout << l << " \t";
      }
      cout << "\n";
    }
    */
    

  }
  cout << dp.at(n).at(W) <<endl;
  
}


Measured memory_bytes: 6772
def main():
    S = list(input())
    res = True
    if S[0] != "A" :
       res = False 
    count = S[2:len(S)-1].count("C")
    if count > 1 or count == 0:
        res = False
    else:
        S.remove("C")
    S.pop(0)
    for i in range(len(S)):
        if str(S[i]).isupper() :
            res = False
    if res :
        print("AC")
    else:
        print("WA")
main()

Measured memory_bytes: 3060
from scipy.special import comb
import numpy as np

N, P = map(int, input().split())
A = np.array(list(map(int, input().split())))

A = A % 2 != 0
odd = np.sum(A)
even = N - odd
# print(A, odd, even)

ans = 0
odd_num = 0
even_num = 0
if P == 1:
    for i in range(1, odd + 1, 2):
        odd_num += comb(odd, i, exact=True)
    even_num = pow(2, even)
    ans = odd_num * even_num
else:
    for i in range(0, odd + 1, 2):
        odd_num += comb(odd, i, exact=True)
    even_num = pow(2, even)
    ans = odd_num * even_num
    # print(odd_num, even_num)
print(ans)


Measured memory_bytes: 42524
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
typedef long double ld;
#define pb push_back
#define fi first
#define se second
const ll mod = 1e9+7;
void solve(){
	int x; 
	cin>>x; 
	cout<<1-x<<endl;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1; 
//	cin>>t; 
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

int main(){
    ll n,a,b;cin>>n>>a>>b;
    if(n==1) cout << "Hello World" << ednl;
  	else cout << a+b << ednl;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.awt.Point;


public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int[] nums = new int[n];
        String[] s = br.readLine().split(" ");
        
        for (int i = 0; i < n; i++) {
            nums[i] = Integer.parseInt(s[i]);
        }
        
        Arrays.sort(nums);
        int mid = nums.length/2;
        
        int ans = 0;
        if (nums[mid] != nums[mid-1]) {
            ans = nums[mid] - nums[mid-1];
        }
        
        System.out.println(ans);
    }
}





Measured memory_bytes: 35864
#include <iostream>
using namespace std;
int main(void){
    
    //変数：中間試験の点数 m、期末試験の点数 f、再試験の点数 r と置く
    int m, f, r;
    
    
    while(true){
        
        //入力：中間試験の点数 m、期末試験の点数 f、再試験の点数 r 
        cin >> m >> f >> r;
        
        //繰り返し条件：中間試験の点数 m = 1 、期末試験の点数 f = 1 、再試験の点数 r = 1 まで繰り返す
        if(m == -1 && f == -1 && r == -1) break;
        
        //以下に条件がある（問題の順番で書いている）
        else if(m == -1 || f == -1) cout << "F" << endl;
        else if(m + f >= 80) cout << "A" << endl;
        else if(m + f >= 65) cout << "B" << endl;
        else if(m + f >= 50) cout << "C" << endl;
        else if(m + f >= 30 ) cout << ((r < 50) ? "D" : "C") << endl;
        else if(m + f >= 30) cout << "D" << endl;
        else  cout << "F" << endl;
    }
    
    return 0;
}


/********************************************　　コメントなしコード　　************************************************
  
#include <iostream>
using namespace std;
int main(void){
    
    int m, f, r;
    
    
    while(true){
        
        cin >> m >> f >> r;
        
        if(m == -1 && f == -1 && r == -1) break;
        
        else if(m == -1 || f == -1) cout << "F" << endl;
        else if(m + f >= 80) cout << "A" << endl;
        else if(m + f >= 65) cout << "B" << endl;
        else if(m + f >= 50) cout << "C" << endl;
        else if(m + f >= 30 ) cout << ((r < 50) ? "D" : "C") << endl;
        else if(m + f >= 30) cout << "D" << endl;
        else  cout << "F" << endl;
    }
    
    return 0;
}
  
*******************************************************************************************************************/






Measured memory_bytes: 3092
//In The Name Of God
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define L(x) (2*(x))
#define R(x) ((2*(x))+1)
#define pii pair<int, int>
#define pb push_back
using namespace std;
const int N = 1e5 + 5, Mod = 1e9 + 7, P = 727, Lg = 22, TOF = 1900, Inf = 3e18 + 10;

int Dp[N], A[N];
int main(){
      ios_base::sync_with_stdio(0); cin.tie(0);
      int n, k; cin >> n >> k;
      for(int i = 1; i <= n; i++)
            cin >> A[i];
      for(int i = 0; i <= k; i++){
            Dp[i] = 2;
            for(int x = 1; x <= n; x++){
                  if(A[x] <= i && Dp[i - A[x]] == 2)
                        Dp[i] = 1;
            }
      }
      if(Dp[k] == 1)
            cout << "First";
      else
            cout << "Second";
      return 0;
}



Measured memory_bytes: 640