akhauriyash/Code-Regression huggingface dataset:
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで
// -fsanitize=undefinedでオーバーフロー検出
#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};


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

    ll a,b,c,d,m,n,maxi=0,f=0,g=0,mini=INF,sum=0;
    ll k;
    string str,stra;
    
    cin>>a>>b>>c;
    if(a<c&&c<b) Yes;
  else if(a>c&&c>b) Yes;
  else No;

    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())

const int mod = 1e9 + 7;

vector<vector<int>> mul(vector<vector<int>> a, vector<vector<int>> b) {
    int n = sz(a), m = sz(a[0]), k = sz(b[0]);
    vector<vector<int>> c(n, vector<int>(k, 0));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < k; j++) {
            for (int x = 0; x < m; x++) {
                c[i][j] += a[i][x] * b[x][j];
                c[i][j] %= mod;
            }
        }
    }
    return c;
}

vector<vector<int>> mat_mod(vector<vector<int>> a, int b) {
    if (b == 0) {
        vector<vector<int>> v(sz(a), vector<int>(sz(a[0]), 0));
        for (int i = 0; i < sz(v); i++) {
            v[i][i] = 1;
        }
        return v;
    }
    auto nesf = mat_mod(a, b / 2);
    if (b % 2) {
        return mul(nesf, mul(nesf, a));
    } 
    return mul(nesf, nesf);
}

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n, k;
    cin >> n >> k;
    vector<vector<int>> a(n, vector<int> (n, 0));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> a[i][j];
        }
    }
    auto res = mat_mod(a, k);
    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            ans += res[i][j];
            ans %= mod;
        }
    }
    cout << ans << "\n";
}

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

int main() {
  int N;
  string S;
  cin >> N >> S;
  int cnt=0;
  for(int i=0;i<N-2;i++){
    if(S.at(i) == 'A' && S.at(i+1) == 'B' && S.at(i+2) == 'C'){
      cnt++;
    }
  }
  
  cout << cnt << 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;

  if (A + B == C + D ) {
    cout << "Balanced" << endl;
  }
  if (A +  B < C + D){
    cout << "Right" << endl;
  }
  if (A +  B > C + D){
    cout << "Left" << endl;
  }
   
  
}

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

start_x, start_y = (0, 0)
isReachAble = False
for n in range(N):
    t, x, y = map(int, input().split())
    dist = abs(x-start_x) + abs(y-start_y)
    if (dist > t):
        print('No')
        exit()
    isTimeEven = t % 2 == 0
    isDestEven = (x + y) % 2 == 0
    if (isTimeEven and isDestEven) or (not isTimeEven and not isDestEven):
        isReachAble = True
    else:
        print('No')
        exit()

print('Yes' if isReachAble else 'No')


Measured memory_bytes: 3064
#include <stdio.h>
#define N 100000
#define Q 50000

int main()
{
  int n,s[N],q,t[Q],i,left,right,mid,result;
  int cnt=0;

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

  scanf("%d",&q);
  for(i=0 ; i<q ; i++)
    {
      scanf("%d",&t[i]);
    }

  for(i=0 ; i<q ; i++)
    {
      left = 0;
      right = n;
      while(left < right)
	{
	  mid = (left + right) / 2;
	  if(s[mid] == t[i])
	    {
	      cnt++;
	      break;
	    }
	  else if(t[i] < s[mid]) right = mid;
	  else left = mid + 1;
	}
    }

  printf("%d\n",cnt);

}



Measured memory_bytes: 2284
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[200010];
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
void init_fact(int n){
	kaijo[0]=1;
	for(int i=1;i<=n;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	if(b>a)return 0;
	if(a==b)return 1;
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int g(int x){
	x=modpow(x,MOD-2);
	return x;
}
int n,a[100010],cnt[32];
signed main(){
	cin>>n;
	int sum=0;
	rep(i,n){
		cin>>a[i];
		sum^=a[i];
		int r=a[i]^(a[i]-1);
		for(int j=1;j<=30;j++){
			if(r==(1<<j)-1)cnt[j-1]++;
		}
	}
	int ans=0;
	for(int i=30;i>=0;i--){
		if(sum>=(1<<i)){
			if(cnt[i]==0){
				puts("-1");
				return 0;
			}
			sum^=(1<<(i+1))-1;
			ans++;
		}
	}
	if(sum==0)cout<<ans<<endl;
	else puts("-1");
	return 0;
}


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

int main() {
  
  int N,M;
  cin >> N >> M;
  
  vector<int> vec(M);
  int sum =0;
    for(int i=0;i<M;i++){
      cin >> vec.at(i);
      sum += vec.at(i);
    }
  
  if(sum <= N){
    cout << N - sum <<endl;
  }else{
    cout << "-1" <<endl;
  }
  
}


Measured memory_bytes: 3648
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM

--for Primitive
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM

-- import qualified Data.Foldable                 as F

-- Basic
import qualified Data.ByteString.Char8 as BS
import Control.Monad
import Data.List
import Data.Maybe
import Data.Char
import Data.Ord

main :: IO ()
main = do
    k <- fst . fromJust <$> ( BS.readInt <$> BS.getLine ) :: IO Int
    s <- getLine
    putStr $ cut k s
    where
        cut k s 
            | (length s) <= k = s
            | otherwise = (take k s) ++ "..."

Measured memory_bytes: 3704
#include <iostream>
#include <cstdint>

const uint32_t MOD = 998244353;
const uint32_t MAX_N = 3e5 + 12;

uint32_t fast_pow(uint32_t a, uint32_t b) {
	if (b == 0) {
		return 1;
	}
	uint64_t ans = fast_pow(a, b / 2);
	ans = ans * ans % MOD;
	if (b % 2) {
		ans = ans * a % MOD;
	}
	return ans;
}

uint64_t fact[MAX_N];
uint64_t iFact[MAX_N];

void precalc() {
	fact[0] = 1;
	for (uint32_t i = 1;i < MAX_N;i++) {
		fact[i] = fact[i - 1] * i % MOD;
	}
	iFact[MAX_N - 1] = fast_pow(fact[MAX_N - 1], MOD - 2);
	for (uint32_t i = MAX_N - 2;i < MAX_N;i--) {
		iFact[i] = iFact[i + 1] * (i + 1) % MOD;
	}
}

uint64_t comb(uint32_t a, uint32_t b) {
	return fact[a] * iFact[a - b] % MOD * iFact[b] % MOD;
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	precalc();

	uint64_t n, a, b, k;
	std::cin >> n >> a >> b >> k;
	uint64_t ans = 0;

	for (uint32_t i = 0;i <= n;i++) {
		uint64_t sA = a * i;
		if (sA > k) {
			break;
		}
		uint64_t sB = k - sA;
		if (sB % b) {
			continue;
		}
		uint32_t bCnt = sB / b;
		if (bCnt > n) {
			continue;
		}

		ans += comb(n, i) * comb(n, bCnt) % MOD;
		ans %= MOD;
	}
	std::cout << ans << "\n";
}


Measured memory_bytes: 4992
use proconio::input;

fn cube(n: u64) -> u64 {
    n * n * n
}

fn main() {
    input!(n: u64, k: u64);
    println!(
        "{}",
        match k % 2 {
            0 => cube(n / k) + cube((n + k / 2) / k),
            _ => cube(n / k),
        }
    );
}


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

struct Edge {
	int to, flow, rev;
	Edge(int to, int flow, int rev) {
		this->to = to;
		this->flow = flow;
		this->rev = rev;
	}
};

typedef vector<int> Array;
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph &g, int from, int to, int flow) {
	g[from].push_back(Edge(to, flow, g[to].size()));
	g[to].push_back(Edge(from, 0, g[from].size() - 1));
}

int dfs(Graph &g, int s, int t, int f, Array &dist, Array &iter) {
	if (s == t) return f;
	
	for (int &i = iter[s]; i < g[s].size(); i++) {
		int ns = g[s][i].to;
		if (g[s][i].flow == 0 || dist[ns] != dist[s] + 1) continue;
		
		int res = dfs(g, ns, t, min(f, g[s][i].flow), dist, iter);
		if (res > 0) {
			g[s][i].flow -= res;
			g[ns][g[s][i].rev].flow += res;
			return res;
		}
	}
	return 0;
}

int maxflow(Graph g, int s, int t) {
	int n = g.size();
	int i, sumFlow = 0;
	
	while (true) {
		Array dist(n, -1);
		queue<int> que;
		que.push(s); dist[s] = 0;
		while (!que.empty()) {
			int pos = que.front(); que.pop();
			for (i = 0; i < g[pos].size(); i++) {
				int npos = g[pos][i].to;
				if (dist[npos] == -1 && g[pos][i].flow > 0) {
					dist[npos] = dist[pos] + 1;
					que.push(npos);
				}
			}
		}
		if (dist[t] == -1) break;

		Array iter(n, 0);
		while (true) {
			int f = dfs(g, s, t, 1e+9, dist, iter);
			if (f == 0) break;
			sumFlow += f;
		}
	}
	return sumFlow;
}

int n, m;
int u, v, c;
Graph g;

int main() {
	int i;
	
	cin >> n >> m;
	g.resize(n);
	for (i = 0; i < m; i++) {
		cin >> u >> v >> c;
		add_edge(g, u, v, c);
	}
	
	cout << maxflow(g, 0, n - 1) << endl;
	return 0;
}


Measured memory_bytes: 3204
#include<stdio.h>
#define M 10001
int main(){
  int i,j;
  char s[1001];
  while(scanf("%s",s)!=EOF){
    for(i=0;s[i];i++){
      if(s[i]=='@'){
	for(j=0;j<s[i+1]-'0';j++)printf("%c",s[i+2]);
	i+=2;
      }
      else printf("%c",s[i]);
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    string t = s;
    reverse(t.begin(), t.end());
    if (s == t) {
        int n = (int)s.length();
        string a = s.substr(0, n / 2);
        string b = s.substr(n / 2 + 1, n / 2);
        string c = a, d = b;
        reverse(c.begin(), c.end());
        reverse(d.begin(), d.end());
        if (a == c && b == d) cout << "Yes";
        else cout << "No";
    } else cout << "No";
}


Measured memory_bytes: 3660
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

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

void output(bool flag ){
    if(flag){
        cout <<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

class ARegistration {
public:
	void solve(std::istream& cin, std::ostream& cout) {
        string s;
        string t;
        cin >>s;
        cin >>t;
        int x =s.length();
        bool flag = true;
        rep(i,x){
            if(s[i]!=t[i]){
                flag = false;
            }
        }
        output(flag);

	}
};


int main() {
	ARegistration solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3612
import sys
H, W = map(int, sys.stdin.readline().split())
L = ['.' + sys.stdin.readline().rstrip() +'.' for _ in range(H)]
L.insert(0, '.'*(W+2))
L.append('.'*(W+2))
#print(L)
f = 'Yes'
for i in range(1, H+1):
    for j in range(1, W+1):
        if L[i][j] =='#':
            if not '#' in [L[i-1][j], L[i][j-1], L[i][j+1], L[i+1][j]]:
                f = 'No'
                break

print(f)

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

int main(){
  int s,i,rlPlace;
  std::string d;
  std::cin >> d;
  s=d.length();
  bool k;
  int ans[100000];
  for (i = 0; i < s; i++) {
    ans[i]=0;
  }
  for (i = 1; i < s; i++) {
    k=0;
    while (d[i]=='R')++i;
    rlPlace=i;
    while (d[i]=='L' && i < s){
      ans[rlPlace-k]++;
      k = !k;
      i++;
    }
  }
  for (i = s-2; i >=0; --i) {
    k=0;
    while (d[i]=='L')--i;
    rlPlace=i;
    while (d[i]=='R' && i >=0){
      ans[rlPlace+k]++;
      k = !k;
      --i;
    }
  }
  for (i = 0; i < s; i++) {
    if (i!=0)std::cout << " ";
    std::cout << ans[i];
  }
  std::cout << '\n';

}


Measured memory_bytes: 1088
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define pb push_back
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

int main(){
  int n,a,b[9]={},c=0;
  cin>>n;
  fr(i,n){cin>>a;b[min(a/400,8)]++;}
  fr(i,8) if(b[i]>0) c++;
  cout<<max(c,1)<<" "<<c+b[8];
}

Measured memory_bytes: 256
import sys
from collections import OrderedDict
input = sys.stdin.readline
sys.setrecursionlimit(2 * 10**6)


def inpl():
    return list(map(int, input().split()))


def main():
    MOD = 998244353
    N, S = inpl()
    A = sorted(inpl())
    dp = {}
    dp[0] = 1
    for i, a in enumerate(A):
        # print(i, dp)
        ks = sorted(dp.keys())
        for k in ks[::-1]:
            # print(k)
            if k + a <= S:
                if k + a in dp:
                    dp[k + a] = (dp[k] + dp[k + a]) % MOD
                else:
                    dp[k + a] = dp[k]
            dp[k] = (dp[k] * 2) % MOD
    # print(dp)
    print(0 if S not in dp else dp[S])
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 76732
import java.util.Scanner;

class Main {
	@SuppressWarnings("resource")
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		//?????????
		StringBuilder out = new StringBuilder();
		int n = scan.nextInt();
		
		//??????
		for(int i = 1; i <= n ; i++){
			if(i % 3 == 0){
				out.append(" " + i);
			}//if 
			else {
				int num = i;
				while (num != 0){
					if(num % 10 == 3){
						out.append(" " + i);
						break;
					}else{
						num = num / 10;
					}//else
				}//while
			}//else
		}//for
		//??????
		System.out.println(out);
	}
}

Measured memory_bytes: 28396
#include<bits/stdc++.h>
using namespace std;
int main(){
  char s[15];
  cin >> s;
  int w=0;
  char t[15];
  for(int i=0;i<strlen(s);i++){
    if(s[i]=='0'){
      t[w]='0';
      w++;
    }
    if(s[i]=='1'){
      t[w]='1';
      w++;
    }
    if(s[i]=='B'){
      t[w-1]='\0';
      if(w!=0)w--;
    }
  }
  t[w]='\0';
  cout << t << endl;

}


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

int per[101][101];
int count1,count2;
int w,h,pw,ph;

int search(){
  count1=0;
  for(int i=0;i<=h-ph;i++){
    for(int j=0;j<=w-pw;j++){
      for(int k=0;k<ph;k++){
	for(int l=0;l<pw;l++){
	  if(per[i+k][j+l]==1){
	    count2++;
	  }
	}
      }
      if(count1<count2)count1=count2;
      count2=0;
    }
  }
  return count1;
}
    
void init(){
  for(int i=0;i<101;i++){
    for(int j=0;j<101;j++){
      per[i][j]=0;
    }
  }  
}


int main(){
  int n;
  int i,j;
  int x,y;
  int estate;

  while(1){
    init();
    cin >> n;
    if(n==0)break;
    cin >> w >> h;
    for(i=0;i<n;i++){
      cin >> x >> y;
      per[y-1][x-1]=1;
    }

    cin >> pw >> ph;
    estate=search();
    cout << estate << endl;
  }
}

Measured memory_bytes: 1200
#include <cstdio>
int n, a[25], b[25], c[25], sum;
int main(){
	scanf("%d", &n);
	for (register int i = 1; i <= n; ++i) scanf("%d", a + i);
	for (register int i = 1; i <= n; ++i) scanf("%d", b + i);
	for (register int i = 1; i < n; ++i) scanf("%d", c + i);
	for (register int i = 1; i <= n; ++i){
		sum += b[i];
		if (i < n && a[i + 1] == a[i] + 1) sum += c[a[i]];
	}
	printf("%d\n", sum);
}

Measured memory_bytes: 128
import sys,collections
c=[tuple([i,j]) for i in range(10) for j in range(10)]
d=[list(map(int,text.split(","))) for text in sys.stdin]
o=[]
for b in d:
    if b[2]==1:
        t=[tuple([b[0]+i,b[1]+j]) for i in range(-1,2) for j in range(-1,2) if (i==0 or j==0) and 0<=b[0]+i<=9 and 0<=b[1]+j<=9]
    elif b[2]==2:
        t=[tuple([b[0]+i,b[1]+j]) for i in range(-1,2) for j in range(-1,2) if 0<=b[0]+i<=9 and 0<=b[1]+j<=9]
    elif b[2]==3:
        t=[tuple([b[0]+i,b[1]+j]) for i in range(-2,3) for j in range(-2,3) if abs(i)+abs(j)<=2 and 0<=b[0]+i<=9 and 0<=b[1]+j<=9]
    o+=t
print(len(set(c)-set(o)))
print(sorted(collections.Counter(o).values())[-1])



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

#define rep(i,n) for(ll i=0;i<(n);++i)
#define reps(i,n) for(ll i=1;i<=(n);++i)
using ll = long long;
using str = string;
constexpr long long INF = (1LL<<60);
constexpr long long MOD = (1e9+7);
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;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
inline void dump(){cout<<endl;}
template<class Head,class... Tail>inline void dump(Head&& head, Tail&&... tail){cout<<head<<", ";dump(forward<Tail>(tail)...);}
template<typename T>inline istream &operator>>(istream&input,vector<T>&v){for(auto &elemnt:v)input>>elemnt;return input;}

template<typename T>
class Union_Find {
private:
  T n;
  vector<T> parent;

public:
  Union_Find(T v){
    n=v;
    parent.resize(n,-1);
  }

  T root(T v){
    if(parent[v]<0)return v;
    return parent[v]=root(parent[v]);
  }
  T size(T v){
    return -parent[root(v)];
  }
  bool connect(T a,T b){
    a=root(a);
    b=root(b);
    if(a==b)return false;
    if(size(a)<size(b)) swap(a,b);
    parent[a]+=parent[b];
    parent[b]=a;
    return true;
  }
  bool same(T a,T b){
    return root(a)==root(b);
  }

};

main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout<<fixed<<setprecision(10);
  
  ll n,k;
  cin>>n>>k;
  string s;
  cin>>s;

  vector<pair<char,ll>> a;
  ll tmp=1;
  char now=s[0];
  for(ll i=1;i<n;++i){
    if(s[i]!=s[i-1]){
      a.emplace_back(now,tmp);
      tmp=1;
      now=s[i];
    }
    else{
      tmp++;
    }
  }
  a.emplace_back(now,tmp);

  //for(auto x:a)cout<<x.first<<" ";cout<<endl;
  //for(auto x:a)cout<<x.second<<" ";cout<<endl;

  ll m=a.size();
  vector<ll> asum(m+1);
  reps(i,m)asum[i]=asum[i-1]+a[i-1].second;
  vector<ll> b(m);
  rep(i,m)b[i]=a[i].second-1;
  vector<ll> bsum(m+1);
  reps(i,m)bsum[i]=bsum[i-1]+b[i-1];

  rep(i,2*k)bsum.push_back(bsum[m]);
  rep(i,2*k)asum.push_back(asum[m]);

//for(auto x:asum)cout<<x<<" ";cout<<endl;
//for(auto x:bsum)cout<<x<<" ";cout<<endl;

  ll ans=0;
  rep(i,m){
    ll x=0,y=0,z=0;
    x=bsum[i]-bsum[0];
    y=asum[i+2*k+1]-asum[i]-1;
    z=bsum[m]-bsum[i+2*k+1];
    //dump(x,y,z);
    chmax(ans,x+y+z);
  }
  cout<<(ans)<<endl;
  


}


Measured memory_bytes: 8728
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll GCD(ll a, ll b){ return a ? GCD(b % a, a) : b; }
int main(){
    string s,t;
    cin>>s>>t;
    bool ok=true;
    for(int i=0; i<s.size(); i++){
        if(s[i]!=t[i]) ok=false;
    }
    if(ok) cout<<"Yes";
    else cout<<"No";
    
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
//#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n; cin >> n;
    for (int a = 1;; a <<= 1) {
        if (n < (a << 1)) {
            cout << a << "\n";
            return 0;
        }
    }
}


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

#define pb push_back
#define fi first
#define se second
#define ll long long
#define ld long double
#define pii pair < int , int >
#define pll pair < long long, long long >

const int N = 200005;


int main()
{
    #ifdef Estb_probitie
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif

    int n, w;
    cin >> n >> w;

    ll dp[2][100005] = {};

    fill(dp[0],dp[0] + 100002, 1e18);
    fill(dp[1],dp[1] + 100002, 1e18);

    ll ma = -1;
    bool now = 0;
    dp[0][0] = dp[1][0] = 0;


    for (int i = 0; i < n; ++i)
    {
        int we, us;
        cin >> we >> us;
        for (int j = 0; j <= 100000 - us; ++j)
            dp[!now][j + us] = min(dp[!now][j + us], dp[now][j] + we);

        for (int j = 0; j <= 100000; ++j)
            dp[now][j] = dp[!now][j] = min(dp[now][j], dp[!now][j]);
        now = !now;
    }

    for (int i = 0; i <= 100000; ++i)
        if (dp[0][i] <= w)
          ma = max(ma, i*1LL);

    cout << ma;
}


Measured memory_bytes: 1792
import fractions
A,B,C,D = map(int,input().split())

ans = B-A+1

LCM = (C*D) // fractions.gcd(C,D)

ans -= B//C

ans -= B//D

ans += B//LCM

ans += (A-1)//C

ans += (A-1)//D

ans -= (A-1)//LCM
print(ans)

Measured memory_bytes: 5048
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define P pair<ll, ll>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 




////////////////////////////////////////////////////////

int main() {
    ll h, w, a, b; cin >> h >> w >> a >> b;
    rep(i, 0, b){
        rep(j, 0, a) cout << 0;
        rep(j, a, w) cout << 1;
        coel;
    }
    rep(i, b, h){
        rep(j, 0, a) cout << 1;
        rep(j, a, w) cout << 0;
        coel;
    }

    return 0;
}


Measured memory_bytes: 1280
import math
p, c = [2], 3
while len(p) < 10000:
    m = int(math.sqrt(c))
    r = True
    for i in p:
        if i > m:
            break
        if c % i == 0:
            r = False
            break
    if r:
        p.append(c)
    c += 2
  
while True:
    n = int(raw_input())
    if n == 0:
        break
    print sum(p[:n])

Measured memory_bytes: 6756
#include<bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define SFOR(i,a,b) for(int i=a;i<b;i++)
#define F first
#define S second
#define INF INT_MAX
#define endl '\n'
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
int main(){
   cin.tie(0);
   ios::sync_with_stdio(false);
   int n,k;
   char s[1001];
   cin>>n>>s>>k;
   FOR(i,n){
     if(s[i]!=s[k-1]) s[i]='*';
   }
   cout<<s<<endl;
   return 0;
}


Measured memory_bytes: 256
def bubbleSort( nums )
	cnt = 0
	0.upto( nums.length-1 ) { |i|
		( nums.length-1 ).downto( i+1 ) { |j|
			if nums[j] < nums[ j-1 ]
				nums[j], nums[ j-1 ] = nums[ j-1 ], nums[j]
				cnt += 1
			end
		}
	}
	puts( nums.join( " " ) )
	puts( cnt )
end

n = gets.to_i
nums = gets.split( " " ).map { |val| val.to_i }
bubbleSort( nums )

Measured memory_bytes: 6104
#include <iostream>
#include <set>
#include <vector>
#include <iomanip>

#include <cfenv>
#include <cmath>
typedef long long int ll;

using namespace std;

int main()
{

    int N, K;

    cin >> N >> K;

    vector<int> A(N,0);

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

        int d;

        cin >> d;

        for (int j = 0; j < d; j++)
        {

            int p;

            cin >> p;

            A[p-1]++;
        }
    }


    int count =0;

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


        if(A[i]==0){


            count++;
        }


        


    }




    cout << count << endl;




    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

const int M = 1e6 + 5;

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

    vector<int> checker(M, 0);
    int x;
    for (int i = 0; i < N; i++)
    {
        x = A[i];
        if (checker[x] != 0)
        {
            checker[x] = 2;
            continue;
        }
        for (int j = x; j < M; j += x)
        {
            checker[j]++;
        }
    }
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        x = A[i];
        if (checker[x] == 1)
        {
            ans++;
        }
    }
    cout << ans << endl;
    return (0);
}

Measured memory_bytes: 7956
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (ll)(1E9+7)
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}

#define MAX_V 100

struct edge {
	edge(int a, int b) {
		cost = a;
		to = b;
	}
	int cost;
	int to;
};

int n;
vector<vector<edge>> G;
vector<int> d;

void dijkstra(int s) {
	priority_queue<pii, vector<pii>, greater<pii>> que;
	d[s] = 0;
	que.push(pii(0, s));

	while (!que.empty()) {
		pii p = que.top();
		que.pop();
		int v = p.second;
		if (d[v] < p.first) continue;
		for (int i = 0; i < G[v].size(); i++) {
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(pii(d[e.to], e.to));
			}
		}
	}

}

int main() {
	int n,u,k,tmpp,tmpw;
	cin >> n;
	d = vector<int>(n, INF);
	G = vector<vector<edge>>(n);
	rep (i,n) {
		cin >> u >> k;
		rep(j, k) {
			cin >> tmpp>>tmpw;
			G[u].emplace_back(tmpw, tmpp);
		}
	}
	dijkstra(0);
	rep(i, n) {
		cout << i << " " << d[i] << endl;
	}
}



Measured memory_bytes: 3116
#include <cstdio>
#include <vector>

using namespace std;

int sum_till(int n)
{
    return (n*(n + 1))/2;
}

int main()
{
    int left, right;
    scanf("%d %d", &left, &right);

    int n = right - left;
    int snow_cover = sum_till(n) - right;

    printf("%d\n", snow_cover);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <sstream>
#include <complex>
#include <ctime>
#include <cassert>
#include <functional>

using namespace std;

typedef long long ll;
typedef vector<int> VI;
typedef pair<int,int> PII;

#define REP(i,s,t) for(int i=(s);i<(t);i++)
#define FILL(x,v) memset(x,v,sizeof(x))

const int INF = (int)1E9;
#define MAXN 200005

int N, a[MAXN], b[MAXN];
int main() {
  cin >> N;
  REP(i,0,N) scanf("%d", a+i);
  int fi = 0, bi = N-1;
  for (int i=N-1;i>=0;i--) {
    if ((N-1-i)&1) b[bi--] = a[i];
    else b[fi++] = a[i];
  }
  REP(i,0,N) printf("%d ", b[i]);
  return 0;
}


Measured memory_bytes: 3712
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n = f()[0]
    h = f()
    maxh = 0
    ans = 0
    for i in range(n):
        if(h[i]>=maxh):
             ans +=1
        maxh = max(h[i], maxh)
    print(ans)

solve()


Measured memory_bytes: 3060
#include <stdio.h>
int main(void){
	int W,H,x,y,r;
scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if((x-r<0 || x+r>W)||(y-r<0||y+r>H))
	{printf("No\n");}
	if(x-r>=0&&x+r<=W&&y-r>=0&&y+r<=H)
		{printf("Yes\n");}

	return 0;}


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

int main(){
	string s;
	cin >> s;
	int a[4];
	rep(i,4) a[i] = s[i] - '0';
	
	rep(i,8) {
		int result = a[0];
		rep(j,3) {
			result += pow(-1,i>>j&1)*a[j+1];
		}

		if (result == 7) {
			cout << a[0];
			rep(j,3) {
				if (!(i>>j&1)) cout << '+';
				else cout << '-';
				cout << a[j+1];
			}
			cout << "=7" << endl;
			return 0;
		}
	}

	return 0;
}


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

long long h, w, ans = LLONG_MAX;
int main() {
	cin >> h >> w;
	for(long long i = 1; i < w; i++) {
		multiset<long long> st;
		st.insert(h*i);
		st.insert((h/2)*(w-i));
		st.insert(((h+1)/2)*(w-i));
		if(st.size() == 3) ans = min(*st.rbegin()-*st.begin(), ans);
		st.clear();
		st.insert(h*i);
		st.insert(((w-i)/2)*h);
		st.insert(((w-i+1)/2)*h);
		if(st.size() == 3) ans = min(*st.rbegin()-*st.begin(), ans);
	}
	for(long long i = 1; i < h; i++) {
		multiset<long long> st;
		st.insert(w*i);
		st.insert((w/2)*(h-i));
		st.insert(((w+1)/2)*(h-i));
		if(st.size() == 3) ans = min(*st.rbegin()-*st.begin(), ans);
		st.clear();
		st.insert(w*i);
		st.insert(((h-i)/2)*w);
		st.insert(((h-i+1)/2)*w);
		if(st.size() == 3) ans = min(*st.rbegin()-*st.begin(), ans);
	}
	cout << ans;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  long long N;
  scanf("%lld", &N);
  std::vector<long long> P(N);
  for (int i = 0; i < N; i++)
  {
    scanf("%lld", &P[i]);
  }
  std::vector<long long> Q(N);
  for (int i = 0; i < N; i++)
  {
    scanf("%lld", &Q[i]);
  }
  vector<int> v(N, 0);
  for (int i = 0; i < N; ++i)
    v[i] = i + 1;
  int p_itr = 0, q_itr = 0;
  int cnt = 0;
  do
  {
    cnt++;
    bool _p = true, _q = true;
    for (int i = 0; i < N; ++i)
    {
      if (v[i] != P[i])
      {
        _p = false;
      }
      if (v[i] != Q[i])
      {
        _q = false;
      }
    }
    if (_p)
      p_itr = cnt;
    if (_q)
      q_itr = cnt;
  } while (next_permutation(v.begin(), v.end()));
  cout << abs(p_itr - q_itr) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include<bits/stdc++.h>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  cin >> s;
  int n=s.size();
  REP(i,n){
    if(s[i]==s[i+1]){
      cout << i+1 << " " << i+2 << endl;
      return 0;
    }elif(s[i]==s[i+2]){
      cout << i+1 << " " << i+3 << endl;
      return 0;
    }
  }
  cout << -1 << " " << -1 << endl;
  return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<string.h>

long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}

int main(void){
  long long i,j,n,m,k,a,b,c,h,w,r=0,l,t,g;
  long long mem[64][64]={0};
  char s[64];
  scanf("%lld",&n);
  for(i=0;i<n;i++){
    scanf("%s",s);
    l=strlen(s);
    t=0;w=0;a=0;
    for(j=0;j<l;j++){
      if(s[j]=='.'){t=1;continue;}
      a*=10;
      a+=(s[j]-'0');
      if(t){w++;}
    }
    for(j=w+1;j<=9;j++){a*=10;}
    g=a;
    h=0;w=0;
    while(g%2==0){g/=2;h++;}
    while(g%5==0){g/=5;w++;}
    //printf("%lld %lld\n",h,w);
    mem[h][w]++;
  }
  for(i=0;i<64;i++){
    for(j=0;j<64;j++){
      for(k=0;k<64;k++){
        for(l=0;l<64;l++){
          if((i+k)<18 || (j+l)<18){continue;}
          if(i==k&&j==l){
            if(mem[i][j]>=2){
              r+=(mem[i][j]*(mem[i][j]-1));
            }
          }
          else{
            r+=(mem[i][j]*mem[k][l]);
          }
        }
      }
    }
  }
  printf("%lld\n",r/2);
  return 0;
}


Measured memory_bytes: 1760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))


int main(){
	int a,b;
	cin >> a >> b;
	string s,t;
	FOR(i,0,a){
		s += '0'+b;
	}
	FOR(i,0,b){
		t += '0'+a;
	}
	cout << min(s,t) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c;
  cin>>a>>b>>c;
  vector<int> vec={a,b,c};
  sort(vec.begin(), vec.end()); 
  int d,e,f;
  d=vec.at(0);
  e=vec.at(1);
  f=vec.at(2);
  int g=0;
  while(f>e){
    if((f-e)%2!=0){
      e++;
      d++;
      g++;
    }
    else if((f-e)%2==0){
      e+=2;
      g++;
    }
   else if(f==e){
      break;
    }
  }
  while(true){
    if(f>d){
      d+=2;
      g++;
    }
  else if(d>f){
    e++;
    f++;
    g++;
  }
  else if(d==f){
   break;
  }
  }
 cout<<g<<endl;
}
    


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

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

func readInt64() int64 {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return int64(i)
}

func readfloat64() float64 {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return float64(i)
}

func abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}

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

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

func main() {
	sc.Split(bufio.ScanWords)

	a, b := readInt(), readInt()

	ans := a - (b * 2)
	if ans >= 0 {
		fmt.Println(ans)
	} else {
		fmt.Println(0)
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;   //あられの数
  int p,y,w,g;  //色のカウンター。
  p=0;
  y=0;
  w=0;
  g=0;
  string color;
  for(int i = 0;i < n;i ++){
    cin >> color;
    if (color == "P"){
      p += 1;
    }
    if (color == "Y"){
      y += 1;
    }
    if (color == "W"){
      w +=1;
    }
    if (color == "G"){
      g += 1;
    }
  }
  if (p * y * w * g ==0){
    cout << "Three" << endl;
  }
  else{
    cout << "Four" << endl;
  }
}

Measured memory_bytes: 256
import math
import itertools
N, D = map(int ,input().split())
X = []
num = []
ans = 0
for i in range(N):
        X.append(list(map(int, input().split())))
        num.append(i)

# for i in range(N):


num_l = list(itertools.combinations(num, 2))

for num in num_l:
        # print(num)
        left = num[0]
        right = num[1]
        wa = 0
        for i in range(D):
                wa += (X[left][i] - X[right][i]) ** 2
        dist = math.sqrt(wa)
        if dist-int(dist) == 0:
                ans += 1

print(ans)

                
        #dist = math.sqrt(left)




Measured memory_bytes: 3064
//#include <bits/stdc++.h>
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define IO(x) freopen(x".in", "r", stdin); freopen(x".out", "w", stdout);
const int inf = 0x3f3f3f3f;
const int maxn=55;
char str[maxn][maxn];
int dx[]={1,-1,0,0, 1,-1,1,-1};
int dy[]={0, 0,1,-1,1,-1,-1,1};
int m,n;
bool isok(int xx,int yy)
{
  if(xx>=1&&xx<=m&&yy>=1&&yy<=n) return true;
  return false;
}
int solve(int x,int y)
{
  int cnt=0;
  for(int i=0;i<8;i++)
  {
    int xx=x+dx[i];
    int yy=y+dy[i];
    if(isok(xx,yy)&&str[xx][yy]=='#') cnt++;
  }
  //cout<<endl;
  //cout<<x<<" "<<y<<endl;
  return cnt;
}
int main()
{
  memset(str,0,sizeof(str));
  cin>>m>>n;
  getchar();
  for(int i=1;i<=m;i++)
  {
   for(int j=1;j<=n;j++) {
    scanf("%c",&str[i][j]);
   }
   getchar();
  }
  for(int i=1;i<=m;i++)
  {
   for(int j=1;j<=n;j++) {
    if(str[i][j]=='#') printf("#");
    else printf("%d",solve(i,j));
   }
   puts("");
  }
  return 0;
}


Measured memory_bytes: 256
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));

console.log(main());
function main(){
  var n = o.a();
  var m = o.a();
  var x = Array(m).fill(0);
  ans = 0;
  for(var i = 0; i < n; i++){
    var t = o.l();
    for(var j = 1; j <= t[0]; j++){
      x[t[j]-1]++;
    }
  }
  for(i = 0; i < m; i++)if(x[i] === n)ans++;
  return ans;
}

Measured memory_bytes: 11468
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#include <functional>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi   vector<int> 
#define   co(x)  cout << x << '\n' 
#define   dbg(x)  cerr << #x << " = " << x << '\n' 
#define   bitcount(x)  (int)__builtin_popcount(x) 
#define   sz(x)  (int)x.size()
#define   all(a) a.begin(),a.end() 
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    string  s;
    cin >> s;
    vi cnt(26, 0) ; 
    int n = sz(s) , ans = 0 ;
    for (int  i = 0 ; i < n ;i++ ) cnt[s[i]-'a']++ ; 
    ans = 1 + (n*(n-1)/2) ; 
    for (int i=0;i<26;i++){
    	if (cnt[i] > 0){
    		ans -= ( cnt[i] * ( cnt[i]-1 ) / 2) ; 
    	}
    }
    co ( ans ) ; 
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3732
#define	_USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cctype>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <set>
#include <complex>
#include <utility>
#include <numeric>
#define  rep(i,n) for(int i=0;i<(n);i++)
#define  REP(i,a,n) for(int i=a;i<(n);i++)
#define  rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define  VI	vector<int>
#define	 VS vector<string>
#define  all(a) (a).begin(),(a).end()
#define  debug(x) cout<<#x<<": "<<x<<endl

using namespace std;
typedef long long int ll;
typedef string::const_iterator State;
typedef pair<int,int> P;
class ParseError {};
const ll INF=1LL<<50;
char fi[101][101];
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
double EPS = 1e-14;
const int MAX_V=100;
const int MAX_N=100;
char o[3]={'+','-','*'};
#define md 1000003



int bow[353][353]={0};
double add(double a,double b){
	if(abs(a+b)<EPS*(abs(a)+abs(b)))
	return 0;
	return a+b;
}

/*struct P{
	double x,y;
	P(){}
		P(double x,double y):x(x),y(y){
		}
		P operator + (P p){
			return P(add(x,p.x),add(y,p.y));
		}
		P operator - (P p){
			return P(add(x,-p.x),add(y,-p.y));
		}
		P operator *(double d){
			return P(x*d,y*d);
		}
		double dot(P p){
			return add(x*p.x,y*p.y);
		}
		double det(P p){
			return add(x*p.y,-y*p.x);
		}
};

bool cmp_x(const P& p,const P& q){
	if(p.x!=q.x) return p.x<q.x;
	return p.y<q.y;
}

vector<P> convex_hull(P* ps, int n){
	sort(ps,ps+n,cmp_x);
	int k=0;
	vector<P> 	qs(n*2);
	
	rep(i,n){
		while(k>1&&(qs[k-1]-qs[k-2]).det(ps[i]-qs[k-1])<=0)
			k--;
		qs[k++]=ps[i];
	}
	for(int i=n-2,t=k;i>=0;i--){
		while(k>t&&(qs[k-1]-qs[k-2]).det(ps[i]-qs[k-1])<=0)
		k--;
		qs[k++]=ps[i];
	}
	qs.resize(k-1);
	return qs;
}

int n,m;
vector<double> p;
P ps[101];
*/
//char c[520][520];
long long mod=1000000007;
long long pow(ll i,ll j){
	ll tmp=1;
	while(j){
		if(j%2) tmp=tmp*i%mod;
		i=i*i%mod;
		j/=2;
	}
	return tmp;
}

int expression(State&);
int term(State&);
int factor(State&);
int number(State&);
int expression(State &begin){
	int ret = term(begin);
	
	for(;;){
		if(*begin == '+'){
			begin++;
			ret += term(begin);
		}
		else if(*begin == '-'){
			begin++;
			ret -= term(begin);
		}
		else
			break;
	}
	return ret;
}

int term(State &begin){
	int ret = factor(begin);
	
	for(;;){
		if(*begin=='*'){
			begin++;
			ret *= factor(begin);
		}
		else if(*begin=='/'){
			begin++;
			ret /= factor(begin);
		}
		else
			break;
	}
	return ret;
}

int factor(State &begin){
	int ret;
	if(*begin == '('){
		begin++;
		ret = expression(begin);
		begin++;
	}
	else
	ret = number(begin);
	
	return ret;

}

int number(State &begin){
	int ret =0;
	
	while(isdigit(*begin)){
		ret*=10;
		ret+=*begin - '0';
		begin++;
	}
	return ret;
}



int main(void){
	
	int n;
	string s;
	
	cin>>n>>s;
	string d=s;
	int a=0,b=0;
	for(int i=0;i<n;i++){
		if(s[i]=='(')
			a++;
		else if(s[i]==')')
			b++;
		if(a<b){
			a++;
			d='('+d;
		}
	}
	
	if(a>b){
		for(;b<a;b++)
			d=d+')';
	}
		
	cout<<d<<endl;
}

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

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>
#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 10000000000000007ll;

const double eps = 1e-10;


const i64 MAXN = 300005;

i64 n;
i64 a[MAXN];
int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    i64 n, m;
    cin >> n  >> m;

    stringstream ss;

    for (i64 i = 0; i < n; i++) {
        ss << m;
    }

    stringstream ts;
    for (i64 i = 0; i < m; i++) {
        ts << n;
    }

    string s = ss.str();
    string t = ts.str();

    if (s < t) {
        cout << s << endl;
    }
    else {
        cout << t << endl;

    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n'
#define int long long
#define eps 1e-9
#define oo 1e7+5

using namespace std;

typedef unsigned long long ull;
typedef vector<pair<int,pair<int,int>>> dirgraph;
typedef vector<vector<int>> graph;

int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);

	int a,b;
	cin>>a>>b;
	int r=a*b;
	cout<<r<<endl;
	
	return 0;
}

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

int main() {
    int r, c;
    cin >> r >> c;
    vector<vector<int>> v(r+1, vector<int>(c+1, 0));
    for(int i=0; i<r; ++i) {
        int sum = 0;
        for(int j=0; j<c; ++j) {
            cin >> v[i][j];
            sum += v[i][j];
        }
        v[i][c] = sum;
    }
    for(int j=0; j<c+1; ++j) {
        int sum = 0;
        for(int i=0; i<r+1; ++i) {
            sum += v[i][j];
        }
        v[r][j] = sum;
    }
    
    for(int i=0; i<r+1; ++i) {
        for(int j=0; j<c+1; ++j) {
            cout << v[i][j];
            if(j != c) cout << ' ';
        }
        cout << endl;
    }
}


Measured memory_bytes: 3204
#include<iostream>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  int c[b];
  for(int i=0;i<b;i++){
    cin>>c[i];
    a-=c[i];
  }
  if(a<=0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 640