akhauriyash/Code-Regression huggingface dataset:
//package Contest081;

import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String []args)
    {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
            int n = sc.nextInt();
            int arr []=new int [n];
            for(int i=0;i<n;i++)
                arr[i]=sc.nextInt();
            int cnt =0;
            boolean flag = true;
            while(true)
            {
                for(int i=0;i<n;i++)
                {
                    if(arr[i]%2!=0)
                    {
                        flag = false;
                        break;
                    }
                    else
                        arr[i] = arr[i]/2;
                }
                if(flag==true)
                    cnt++;
                else
                    break;
            }
                out.println(cnt);
        out.flush();
    }
}


Measured memory_bytes: 21844
#include<iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    int a[n];
    int x[n][n],y[n][n];
    for(int i = 0;i < n;i++){
        cin >> a[i];
        for(int j = 0;j < a[i];j++){
            cin >> x[i][j] >> y[i][j];
        }
    }
    int ans = 0;
    for(int i = 1;i < (1<<n);i++){
        bool flag = true;//trueの時仮定が正しい.
        for(int j = 0;j < n;j++){
            if(!(i&(1<<(j)))) continue;
            for(int k = 0;k < a[j];k++){
                if(((i >> (x[j][k]-1)&1)^y[j][k])) flag= false;
            }
        }
        //仮定が正しい時更新する.
        if(flag) {
            int tmp = 0;
            int bit = i;
            while(bit > 0){
                if(bit&1) tmp++;
                bit = (bit >> 1);
            }

            ans = max(ans, tmp);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.TreeSet;

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());
		String[] sa = br.readLine().split(" ");
		Obj[] arr = new Obj[n];
		for (int i = 0; i < n; i++) {
			Obj o = new Obj();
			o.i = i;
			o.p = Integer.parseInt(sa[i]);
			arr[i] = o;
		}
		br.close();

		Arrays.parallelSort(arr);

		long ans = 0;
		TreeSet<Integer> set = new TreeSet<>();
		for (Obj o : arr) {
			int i = o.i;
			Integer l1 = set.lower(i);
			if (l1 == null) {
				l1 = -1;
			}
			Integer l2 = set.lower(l1);
			if (l2 == null) {
				l2 = -1;
			}

			Integer r1 = set.higher(i);
			if (r1 == null) {
				r1 = n;
			}
			Integer r2 = set.higher(r1);
			if (r2 == null) {
				r2 = n;
			}

			long val = (long) (l1 - l2) * (r1 - i) + (long) (i - l1) * (r2 - r1);
			ans += val * o.p;
			set.add(i);
		}
		System.out.println(ans);
	}

	static class Obj implements Comparable<Obj> {
		int i, p;

		@Override
		public int compareTo(Obj o) {
			return o.p - p;
		}
	}
}


Measured memory_bytes: 46204
#include<bits/stdc++.h>
using namespace std;
int main(){
int64_t X;
  cin>>X;
  int ans=0;
  int64_t Y=100;
  for(int i=0; ;i++){
  double x=(double)Y;
    x*=1.01;
    Y=(int64_t)x;
    if(X<=Y){ans=(1+i); break;}
  
  }cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>
#include <functional>

using namespace std;
#define ALL(x)              (x).begin(),(x).end()
typedef long long           ll;
#define REP(i, n)           for (ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)       for (ll i = m ; i < (ll)n ; ++i)
#define INF                 (ll)1e9
#define MOD                 (1000 * 1000 * 1000 + 7)
#define Ceil(x, n)          (((((x))+((n)-1))/n))
#define CeilN(x, n)         (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)        ((x)-(x)%(n))
#define IsOdd(x)            (((x)&0x01UL) == 0x01UL)
#define IsEven(x)           (!IsOdd((x)))
#define M_PI                3.14159265358979323846
typedef pair<ll, ll>	    P;

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
int main()
{
	auto myCin = [](ll &a){cin >> a;};
	ll N;
	cin >> N;
	vector<ll> a(N), b(N);
	for_each(ALL(a), myCin);
	for_each(ALL(b), myCin);

	string ans = "No";

	ll amari = 0;
	ll fusoku = 0;
	REP(i, N) {
		ll diff = abs(a[i] - b[i]);
		if (a[i] < b[i]) {
			amari += diff / 2;
		} else {
			fusoku += diff;	
		}
	}

	if (fusoku <= amari) {
		ans = "Yes";
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
from collections import Counter
N = int(input())
S = [input() for _ in range(N)]
cntr = Counter(S)
mc = cntr.most_common()
n = mc[0][1]
ans = []
for k, v in mc:
    if n!=v:
        break
    ans.append(k)
ans.sort()
print("\n".join(ans))


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

using ll = long long;
using namespace std;
const int INFint = 2e9+1;
const ll INFll = 2e18+1;
ll MOD=1e9+7;

struct UnionFind{
  vector<int> par;
  vector<int> siz;

  UnionFind(int N){
    par.resize(N);siz.resize(N);
    for(int i=0;i<N;i++) par[i]=i;
    for(int i=0;i<N;i++) siz[i]=1;
  }

  int root(int x){
    if(par[x]==x) return x;
    else return par[x]=root(par[x]);
  }

  bool unite(int x,int y){
    int rx=root(x);
    int ry=root(y);
    if (rx == ry) return false;
    if(siz[rx] < siz[ry]) swap(rx,ry);
    siz[rx] += siz[ry];
    par[ry] = rx;
    return true;
  }

  bool sameroot(int x,int y){
    return root(x)==root(y);
  }
  
  int size(int x){
    return siz[root(x)];
  }
};

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

  vector<ll> ans;
  ll cnt(0);
  for(int i(M-1);i>=0;i--){
    ans.push_back(cnt);
    if (!u.sameroot(A[i],B[i])){
      if(u.size(A[i]) != 1 && u.size(B[i]) != 1){
        cnt += (ll)u.size(A[i])*u.size(B[i]);
        u.unite(A[i],B[i]);
      }else{
        u.unite(A[i],B[i]);
        cnt += (u.size(A[i])-1);
      }
    }
  }
  ll tmp(N*(ll)(N-1)/2);
  for(int i(0);i<M;i++){
    cout << tmp - ans[M - i - 1] << endl;
  }
  return 0;
}


Measured memory_bytes: 3828
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int n = Integer.parseInt(scan.nextLine());
			if(n == 0){
				break;
			}
			String[] str[] = new String[n+1][];
			for(int i = 0;i < n+1;i++){
				str[i] = scan.nextLine().split(" ");
			}
			int[] lim = new int[4];
			for(int i = 0;i < 4;i++){
				lim[i] = Integer.parseInt(str[n][i]);
			}
			int[] a = {4,9,4};
			boolean sw = true;
			int ca;
			int j;
			for(int i = 0;i < n;i++){
				ca = 0;
				for(j = 1;j < 4;j++){
					int t = Integer.parseInt(str[i][j]);
					if(t > lim[j-1]){
						break;
					}
					ca += t*a[j-1];
				}
				if(j == 4 && ca <= lim[3]){
					System.out.println(str[i][0]);
					sw = false;
				}
			}
			if(sw){
				System.out.println("NA");
			}
		}
	}
}

Measured memory_bytes: 75012
import sys
input = sys.stdin.readline
from bisect import *
from heapq import *

N, D, A = map(int, input().split())
XH = [tuple(map(int, input().split())) for _ in range(N)]
XH.sort(key=lambda k: k[0])
pq = []
ans = 0
S = 0

for i in range(N):
    X, H = XH[i]
    
    while len(pq)>0:
        if pq[0][0]<X:
            t = heappop(pq)
            S -= t[1]
        else:
            break
        
    H -= S
    
    if H<=0:
        continue
    
    cnt = (H+A-1)//A
    ans += cnt
    heappush(pq, (X+2*D, cnt*A))
    S += cnt*A

print(ans)

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

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

	std::vector<int> v;
	for( int i = 0; i < n; i++ ) {
		int m;
		 std::cin >> m;
		v.push_back( m );
	}

	std::sort( v.begin(), v.end() );

	int cnt = 0;
	for( int i = 0; i < v.size(); i++ ) {
		x = x - v[ i ];
		cnt += 1;
	}
	if( x > 0 ) {
		cnt += x / v[ 0 ];
	}

	std::cout << cnt << std::endl;
	return 0;
}


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

int N, M;
vector<vector<int>> edges;

bool is_all_visited(vector<bool> visited_list){
  for(int i=0;i<N;++i){
    if(!visited_list[i]){
      return false;
    }
  }
  return true;
}

int move(int current_point, vector<bool> visited_list, int count){
  visited_list[current_point-1] = true;
  if(is_all_visited(visited_list)){
    return count+1;
  }
  for(int i=0;i<M;++i){
    if(edges[i][0] == current_point && !visited_list[edges[i][1]-1]){
      count = move(edges[i][1], visited_list, count);
    }
    else if(edges[i][1] == current_point && !visited_list[edges[i][0]-1]){
      count = move(edges[i][0], visited_list, count);
    }
  }
  return count;
}


int main(void){
  cin >> N >> M;
  edges = vector<vector<int>>(M);
  vector<bool> visited_list = vector<bool>(N, false);
  for(int i=0;i < M;++i){
    edges[i] = vector<int>(2);
    cin >> edges[i][0] >> edges[i][1];
  }
  cout << move(1, visited_list, 0) << endl;
}


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

int main() {
    while(true) {
        string S;
        cin >>S;
        if ("-" == S)
            break;
        int N;
        cin >>N;
        for (int i=0; i<N; i++) {
            int h;
            cin >>h;
            S=S.substr(h)+S.substr(0, h);
        }
        cout <<S <<endl;
    }
    return 0;
}


Measured memory_bytes: 3172
#include <stdio.h>
#define MXSZ 100010
char s[MXSZ],t[MXSZ];
int P[27][MXSZ],C[27];
void init(){
}
int bSearch(int *ar,int l,int r,int v){
    int ret = -1;
    while(l<=r){
        int m = (l+r)/2;
        if(ar[m]>=v){
            ret = ar[m];
            r = m-1;
        }
        else l = m+1;
    }
    return ret;
}
void MRoy(){
    init();
    scanf("%s%s",s,t);
    long long L = 0;
    for(int i = 0;s[i]!='\0';i++){
        int T = s[i]-'a';
        P[T][C[T]++] = i;
        L++;
    }
    long long int Loop = 0;int pos = -1;
    for(int i = 0;t[i]!='\0';i++){
        int T = t[i]-'a';
        if(C[T]==0) {
            printf("-1\n");
            return;
        }
        int res = bSearch(P[T],0,C[T]-1,pos+1);
        if(res==-1) {
            Loop++;
            pos = P[T][0];
        }
        else pos = res;
    }
    printf("%lld\n",Loop*L+pos+1ll);
    return;
}
int main(){
    MRoy();
    return 0;
}

Measured memory_bytes: 8960
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		if(n % 1000 == 0){
			System.out.println(0);
		}
		else {
			System.out.println(1000 - (n % 1000));
		}
	}

}


Measured memory_bytes: 27072
S = list(input().strip())
f = True
if S[0] == "A":
    S[0] = "a"
else:
    S[0] = "X"
if S[2:-1].count("C") == 1:
    S[S.index("C")] = "c"
else:
    S[0] = "X"
if "".join(S) == "".join(S).lower():
    print("AC")
else:
    print("WA")


Measured memory_bytes: 8964
//REPEAT ACL ATCODER BEGINNER CONTEST
#include <bits/stdc++.h>
using namespace std;
#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
int main()
{
  	IOS
    int k;
    cin >> k;
    string s = "ACL";
    int i;
    for (i = 1; i < k; i++)
    {
        s += "ACL";
    }
    cout << s;
    return 0;
}

Measured memory_bytes: 3528
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<unordered_set>
#include<unordered_map>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod;
ll gcd(ll a,ll b){
  return (b?gcd(b,a%b):a);
}
int main(){
  ll a,b,c,d;cin>>a>>b>>c>>d; a--;
  ll ans=b-a; //cout<<ans<<endl;
  ans-=b/c-a/c; //cout<<ans<<endl;
  ans-=b/d-a/d; //cout<<ans<<endl;
  ll t=c*d/gcd(c,d);
  ans+=b/t-a/t;
  cout<<ans<<endl;
  return 0;
}


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

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


Measured memory_bytes: 3628
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};

fn main() {
    input! {
        x: usize,
        n: usize,
        pp: [usize; n]
    };
    let mut diff = 0;
    loop {
        let left = x - diff;
        if !pp.contains(&(left)) {
            println!("{}", left);
            return;
        }
        let right = x + diff;
        if !pp.contains(&(right)) {
            println!("{}", right);
            return;
        }
        diff += 1;
    }
}


Measured memory_bytes: 2128
// https://atcoder.jp/contests/abc084/tasks/abc084_d
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

// constexprな素数列挙(エラトステネスの篩)
// https://259-momone.hatenablog.com/entry/2018/05/06/015026
template <int_fast64_t max_N> struct Prime {
    bool sieve[max_N];
    constexpr Prime() : sieve() {
        for (int_fast64_t i = 0; i < max_N; ++i)
            sieve[i] = true;
        sieve[0] = sieve[1] = false;
        for (int_fast64_t i = 2; i < max_N; ++i) {
            for (int_fast64_t j = i * i; j < max_N; j += i)
                sieve[j] = false;
        }
    }
};

const int SZ = 1e5 + 1;
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    constexpr auto p = Prime<SZ>();
    vector<int> cnt(SZ + 1);
    cnt[0] = 0;
    for (int i = 1; i < SZ; i++) {
        cnt[i] = cnt[i - 1];
        if (p.sieve[i] && p.sieve[(i + 1) / 2]) {
            cnt[i]++;
        }
    }
    int Q;
    cin >> Q;
    while (Q--) {
        int l, r;
        cin >> l >> r;
        cout << cnt[r] - cnt[l - 1] << "\n";
    }

    return 0;
}


Measured memory_bytes: 4300
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		long target = sc.nextLong();

		//		long l =100000*100000;
		//		System.out.println(l);
		HashSet<Integer> A = new HashSet<Integer>();
		HashSet<Integer> B = new HashSet<Integer>();
		for (int i = -10000; i < 10000; i++) {
			A.add(i);
			B.add(i);
		}

		for (long i : A) {
			for (long j : B) {
				long tmp = (i * i * i * i * i) - (j * j * j * j * j);
				if (tmp == target) {
					System.out.println(i + " " + j);
					return;
				}
			}
		}

		System.out.println();

	}
}


Measured memory_bytes: 42088
#include<iostream>
#include<cstring>
using namespace std;
typedef long long int LL;
LL sum[1005];
LL t[1000005];
bool con[1000005];//concern

int main(){
	LL n,m,p;
	int i,j,k;
	LL s=0;
	LL a,b;
	memset(con,true,sizeof(con));
	cin>>n>>m;
	p=n*(n+1)/2;
	for(i=0;i<n;i++){
		cin>>a;
		sum[i+1]=sum[i]+a;
	}
	for(i=0,k=0;i<n;i++){
		for(j=i;j<n;j++){
			t[k++]=sum[j+1]-sum[i];
		}
	}
	for(i=40;i>=0;i--){
		a=(LL)1<<i;
		for(j=0,k=0;j<p;j++){
			if(con[j] && (t[j]&a)){
				k++;
			}
		}
		if(k>=m){
			s+=a;
			for(j=0;j<p;j++){
				if((t[j]&a)==0)con[j]=false;
			}
		}
	}
	cout<<s<<endl;
}


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


using namespace std;

#define fastio() ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define ll long long
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()


unordered_map<ll,ll> dp;
ll cal(int n) {
	if(n==0) return 2;
	else if(n==1) return 1;
	else if(dp.count(n)) return dp[n];
	else {
		dp[n]=cal(n-1)+cal(n-2);
	}
	return dp[n];
}
void go(){
	ll n;cin>>n;
	//dp[0]=2;
	//dp[1]=1;
	//for(int i=2;i<=n;i++) {
		//dp[i]=dp[i-1]+dp[i-2];
	//}
	//cout << dp[n];
	ll ans=cal(n);
	cout << ans;
}
int main(){
   
   fastio();
   cin.tie(0);
   cout.tie(0);

   go();

   return 0;
}




Measured memory_bytes: 3600
H,W=map(int,input().split())
A=[]
for i in range(H):
    A.append([int(j)%2 for j in input().split()])
reached=[[0]*W for i in range(H)]
L=[]
for i in range(H):
    for j in range(W-1):
        if A[i][j]==1:
            L.append([i+1,j+1,i+1,j+2])
            A[i][j]-=1
            A[i][j+1]=A[i][j+1]^1
for i in range(H-1):
    if A[i][W-1]==1:
        L.append([i+1,W,i+2,W])
        A[i][W-1]-=1
        A[i+1][W-1]=A[i+1][W-1]^1
print(len(L))
for i in range(len(L)):
    print(L[i][0],L[i][1],L[i][2],L[i][3])


Measured memory_bytes: 72284
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    //brakeはH,W＝０
    while(1)
    {
        int H,W;
        int i;
        cin>>H>>W;
        if(H==0) break;
        if(W==0) break;
        for(i=0;i<H;i++)
        {
            int v;
            for(v=0;v<W;v++)
            {
                cout<<"#";
            }
            cout<<endl;
        }
        cout<<endl;
    }
}



Measured memory_bytes: 3076
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        abc: [u32;3],
        k: u32,
    }
    let mx = abc.iter().max().unwrap();
    println!("{}",
        abc.iter().sum::<u32>() - mx + mx * 2u32.pow(k));
}


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

using namespace std;

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

	int N, T;
	cin >> N >> T;

	vector<int>t(N);
	for (auto &x : t)
		cin >> x;

	int time = 0, now = t[0], stop = t[0]+T;

	for (int i = 1; i < N; i++) {
		if (t[i] <= stop) {
			time += t[i]-t[i-1];
		}
		else {
			time += T;
		}
			stop = t[i] + T;
	}
	time += T;

	cout << time << endl;

	return 0;

}

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

using lint = long long;

int main() {
    int n;
    cin >> n;
    lint c;
    cin >> c;
    vector<lint> x(n + 1), v(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> x[i] >> v[i];
    }

    vector<lint> rpos(n + 1), rmax(n + 1), rmaxb(n + 1);
    // b は折り返すときの値
    lint rv_sum = 0;
    for (int i = 1; i <= n; i++) {
        rpos[i] = x[i];
        rv_sum += v[i];
        rmax[i] = max(rmax[i - 1], rv_sum - rpos[i]);
        rmaxb[i] = max(rmaxb[i - 1], rv_sum - 2 * rpos[i]);
    }
    vector<lint> lpos(n + 1), lmax(n + 1), lmaxb(n + 1);
    lint lv_sum = 0;
    for (int i = 1; i <= n; i++) {
        lpos[i] = c - x[n + 1 - i];
        lv_sum += v[n + 1 - i];
        lmax[i] = max(lmax[i - 1], lv_sum - lpos[i]);
        lmaxb[i] = max(lmaxb[i - 1], lv_sum - 2 * lpos[i]);
    }

    lint ans = 0;
    for (int i = 0; i <= n; i++) {
        // i だけ右に進む
        lint cand = max(rmax[i] + lmaxb[n - i], rmaxb[i] + lmax[n - i]);
        ans = max(ans, cand);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main(){

	int n,m,s=0;

	cin>>n>>m;

	int a[n+1][m+1];

	for(int i=1;i<=n;i++){

		for(int j=1;j<=m;j++){

			cin>>a[i][j];

		}

	} 

	for(int i=1;i<=n;i++){

		for(int j=i+1;j<=n;j++){

			int sum=0;

			for(int k=1;k<=m;k++){

				sum+=fabs(a[i][k]-a[j][k])*fabs(a[i][k]-a[j][k]);

			}

			if(int(sqrt(sum))==sqrt(sum)){

				s++;

			}

		}

	}

	cout<<s;

}

Measured memory_bytes: 384
using System;

public class Test
{
	public static void Main()
	{
		// your code goes here
		string[] s = Console.ReadLine().Split(' ');
		int[] n = new int[s.Length];
		
		for(int i = 0; i < s.Length; i++) {
			n[i] = int.Parse(s[i]);
		}
		
		Array.Sort(n);
		
		Console.WriteLine( string.Format("{0} {1} {2}", n[0], n[1], n[2]) );
	}
}

Measured memory_bytes: 9296
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <math.h>
using namespace std;

typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

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

int main() {
	int x, y, z;
	cin >> x >> y >> z;
	cout << (x - z) / (y + z) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    
    int a,b;
    scanf("%d %d",&a,&b);
    
    if(a>b){
    printf("a > b\n");
    }
    else if(a<b){
    printf("a < b\n");
    }
    else{
    printf("a == b\n");
    }
    return 0;
}


Measured memory_bytes: 2068
from collections import Counter
from itertools import permutations

def main():
    N, C = map(int, input().split())
    D = [list(map(int, input().split())) for _ in range(C)]

    cnt = [Counter() for _ in range(3)]

    for i in range(N):
        c = [int(x)-1 for x in input().split()]
        for j in range(3):
            cnt[j].update(c[(3-(i+2)+j)%3::3])

    ans = 1000*500*500+5
    for p in permutations(range(C), 3):
        s = 0
        for j in range(3):
            s += sum(D[k][p[j]] * v for k, v in cnt[j].items())
        ans = min(ans, s)
    print(ans)

main()


Measured memory_bytes: 3444
#include <stdio.h>

#define MAX 101

int main() {
  int G[MAX][MAX];
  int n, u, k, v, i, j;

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

  for (i = 0; i < n; i++) {
    scanf("%d%d", &u, &k);
    for (j = 0; j < k; j++) {
      scanf("%d", &v);
      G[u - 1][v - 1] = 1;
    }
  }

  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      printf("%d", G[i][j]);
      if (j != n - 1) {
	printf(" ");
      }
    }
    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2052
class LiChaoTree():
    """Convex Hull TrickをSegmentTree上で行う
    add_line: 直線集合に line = (傾きa, 切片b) の直線を追加する
    get_min: 座標xにおいて直線集合が取りうる最小値を求める
    """
    def __init__(self, x_coord_list):
        self.INF = 10**20
        self.n = len(x_coord_list)
        self.size = 2**(self.n-1).bit_length()
        self.to_ind = {x: ind for ind, x in enumerate(x_coord_list)}
        self.x_coord_list = x_coord_list + [self.INF] * (self.size - self.n)
        self.data = [None] * (2*self.size)

    def add_line(self, line):
        """直線の集合に line = (傾きa, 切片b) の直線を追加する"""
        left = 0
        right = self.size
        k = 1
        while True:
            if self.data[k] is None:
                self.data[k] = line
                return

            mid = (left + right) // 2
            lx = self.x_coord_list[left]
            mx = self.x_coord_list[mid]
            rx = self.x_coord_list[right - 1]

            need_l_update = (self.f(line, lx) < self.f(self.data[k], lx))
            need_m_update = (self.f(line, mx) < self.f(self.data[k], mx))
            need_r_update = (self.f(line, rx) < self.f(self.data[k], rx))

            if need_l_update and need_r_update:
                self.data[k] = line
                return

            if not need_l_update and not need_r_update:
                return

            if need_m_update:
                self.data[k], line = line, self.data[k]
            if need_l_update != need_m_update:
                right = mid
                k = 2*k
            else:
                left = mid
                k = 2*k + 1

    def f(self, line, x):
        """f(x)を求める"""
        a, b = line
        return a*x + b

    def get_min(self, x):
        """座標xにおいて直線集合が取りうる最小値を求める"""
        k = self.to_ind[x] + self.size 
        res = self.INF
        while k > 0:
            if self.data[k] is not None:
                res = min(res, self.f(self.data[k], x))
            k = k >> 1
        return res


n, c = map(int, input().split())
h = list(map(int, input().split()))
INF = 10**20

lct = LiChaoTree(h)
dp = [INF] * n
dp[0] = 0
lct.add_line((-2*h[0], h[0]**2 + dp[0]))

for i in range(1, n):
    dp[i] = lct.get_min(h[i]) + c + h[i]**2
    lct.add_line((-2*h[i], h[i]**2 + dp[i]))
print(dp[-1])


Measured memory_bytes: 114900
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // int64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_str(char *str, int size)
{
    char format[100];
    if (size == 0)
        return 0;
    snprintf(format, sizeof(format), "%%%ds", size);
    scanf(format, str);
    return 0;
}

#define NUM_MAX 100000

int main(void) {
    static char str[NUM_MAX];
    get_str(str, NUM_MAX);
    int len = strlen(str);

    char prev = str[0];
    int i;
    int cnt = 1;
    for(i = 1; i < len; i++) {
        if(prev != str[i]) cnt++;
        prev = str[i];
    }
    printf("%d\n", cnt-1);
    return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,H;
int A[101010],B[101010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>H;
	int ma=0;
	FOR(i,N) {
		cin>>A[i]>>B[i];
		ma=max(ma,A[i]);
	}
	
	sort(B,B+N);
	reverse(B,B+N);
	
	int mi=(H+ma-1)/ma;
	FOR(i,N) {
		H=max(0,H-B[i]);
		mi=min(mi,1+i+(H+ma-1)/ma);
	}
	cout<<mi<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define int long long
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define all(x) x.begin(), x.end()
using pii = pair<int, int>;
using ll = long long;

int dp[2][400][400];

struct Res {
    int l, r, c;
    Res(int l, int r, int c) : l(l), r(r), c(c) {}
    bool operator<(const Res &rhs) {
        if (r == rhs.r)
            return l < rhs.l;
        else
            return r < rhs.r;
    }
};

bool solve() {
    int N;
    cin >> N;
    if (N == 0) return false;
    vector<Res> v;
    REP(i, N) {
        int l, r, c;
        cin >> l >> r >> c;
        l--;
        v.push_back({l, r, c});
    }
    REP(i, 2) REP(j, 400) REP(k, 400) dp[i][j][k] = 0;
    sort(all(v));
    REP(i, N) {
        int now = i % 2;
        int nxt = (i + 1) % 2;
        REP(j, 400) REP(k, 400) dp[nxt][j][k] = 0;
        REP(j, 366) REP(k, 366) {
            dp[nxt][j][k] = max(dp[nxt][j][k], dp[now][j][k]);
            if (v[i].l >= j) {
                dp[nxt][v[i].r][k] = max(dp[nxt][v[i].r][k], dp[now][j][k] + v[i].c);
            }
            if (v[i].l >= k) {
                dp[nxt][j][v[i].r] = max(dp[nxt][j][v[i].r], dp[now][j][k] + v[i].c);
            }
        }
    }
    int ans = 0;
    REP(i, 2) REP(j, 400) REP(k, 400) ans = max(ans, dp[i][j][k]);
    cout << ans << endl;
    return true;
}

signed main() {
    while (solve())
        ;
}


Measured memory_bytes: 5556
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n , x;
ll f(ll x , ll y)//x < y
{
	//cout << x << " " << y << endl;
	if(!(y % x))
	{
		ll step = y / x;
		return 2 * step * x - x;
	}

	if(x == y)
		return y;
	ll step = y / x;
	return 2 * step * x + f(min(x , y - step * x) , max(y - step * x , x));
}

int main()
{
	//freopen("output.txt" , "w" , stdout);
	cin >> n >> x;
	ll ans = n;
	ans += f(min(x , n - x) , max(x, n - x));
	cout << ans;
}



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

template <class T, class F = multiplies<T>>
T power(T a, long long n, F op = multiplies<T>(), T e = {1}) {
  assert(n >= 0);
  while (n) {
    if (n & 1) e = op(e, a);
    if (n >>= 1) a = op(a, a);
  }
  return e;
}

template <unsigned M> struct modular {
  using m = modular;
  unsigned v;
  modular(long long a = 0) : v((a %= M) < 0 ? a + M : a) {}
  m operator-() const { return m() -= *this; }
  m& operator+=(m r) { if ((v += r.v) >= M) v -= M; return *this; }
  m& operator-=(m r) { if (v < r.v) v += M; v -= r.v; return *this; }
  m& operator*=(m r) { v = (uint64_t)v * r.v % M; return *this; }
  m& operator/=(m r) { return *this *= power(r, M - 2); }
  friend m operator+(m l, m r) { return l += r; }
  friend m operator-(m l, m r) { return l -= r; }
  friend m operator*(m l, m r) { return l *= r; }
  friend m operator/(m l, m r) { return l /= r; }
  friend bool operator==(m l, m r) { return l.v == r.v; }
  friend string to_string(m a) { return to_string(a.v); }
};

constexpr long long mod = 1e9 + 7;
using mint = modular<mod>;

vector<mint> fact, inv_fact, minv;
void prepare(int n) {
  fact.resize(n + 1), inv_fact.resize(n + 1), minv.resize(n + 1);
  for (int i = 0; i <= n; ++i) fact[i] = i ? i * fact[i - 1] : 1;
  inv_fact[n] = power(fact[n], mod - 2);
  for (int i = n; i; --i) inv_fact[i - 1] = i * inv_fact[i];
  for (int i = 1; i <= n; ++i) minv[i] = inv_fact[i] * fact[i - 1];
}
mint binom(int n, int k) {
  if (k < 0 or k > n) return 0;
  return fact[n] * inv_fact[k] * inv_fact[n - k];
}
template<> mint& mint::operator/=(mint r) {
  return *this *= r.v < minv.size() ? minv[r.v] : power(r, mod - 2);
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  vector<int> a(k);
  for (auto&& e : a) {
    cin >> e;
  }
  prepare(n);
  vector<mint> dp(n + 1);
  dp[0] = 1;
  for (int e : a) {
    vector<mint> ndp(n + 1);
    for (int x = 0; x <= n; ++x) {
      for (int y = x; y <= min(x + e, n); ++y) {
        ndp[y] += dp[x] * binom(n - x, y - x) * binom(n - (y - x), e - (y - x));
      }
    }
    swap(dp, ndp);
  }
  cout << dp[n].v << '\n';
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use itertools_num::ItertoolsNum;
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::iter;
#[allow(unused_imports)]
use superslice::*;

fn run() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let h1: usize = sc.read();
    let m1: usize = sc.read();
    let h2: usize = sc.read();
    let m2: usize = sc.read();
    let k: usize = sc.read();

    let minutes1 = h1 * 60 + m1;
    let minutes2 = h2 * 60 + m2;
    let ans = if minutes1 < minutes2 {
        minutes2 - minutes1
    } else {
        60 * 24 - minutes1 + minutes2
    } - k;
    println!("{}", ans);
}

fn main() {
    std::thread::Builder::new()
        .name("run".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(run)
        .unwrap()
        .join()
        .unwrap();
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn read_pairs<T: std::str::FromStr>(&mut self, n: usize) -> Vec<(T, T)> {
        (0..n).map(|_| (self.read(), self.read())).collect()
    }
    pub fn read_pairs_1_indexed(&mut self, n: usize) -> Vec<(usize, usize)> {
        (0..n)
            .map(|_| (self.read::<usize>() - 1, self.read::<usize>() - 1))
            .collect()
    }
    pub fn read_chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    pub fn read_char_grid(&mut self, n: usize) -> Vec<Vec<char>> {
        (0..n).map(|_| self.read_chars()).collect()
    }
    pub fn read_matrix<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n)
            .map(|_| (0..m).map(|_| self.read()).collect())
            .collect()
    }
}


Measured memory_bytes: 2212
import java.util.*;
import java.io.*;
public class Main {
    static int primes[],freq[];
    public static void main(String args[]) throws IOException {
        Scanner input=new Scanner(System.in);
        long n=input.nextLong();
        primes=new int[78498];
        sieve(1000001);
        int cnt[]=new int[primes.length+1];
        for(int i=0;i<primes.length;i++) {
            while(n%primes[i]==0) {
                n/=primes[i];
                cnt[i]++;
            }
        }
        if(n!=1) {
            cnt[cnt.length-1]++;
        }
        int count=0;
        for(int i=0;i<cnt.length;i++) {
            if(cnt[i]>0) {
                count++;
            }
        }
        freq=new int[count];
        int indx=0;
        for(int i=0;i<cnt.length;i++) {
           if(cnt[i]>0) {
               freq[indx]=cnt[i];
               indx++;
           } 
        }
        System.out.println(solve(0,1));
    }
    public static int solve(int indx,int curr) {
//        System.out.println(indx+" "+curr);
        if(indx==freq.length) {
            return 0;
        }
        int max=Integer.MIN_VALUE;
        max=Math.max(max,solve(indx+1,1));
        if(curr<freq[indx]) {
            max=Math.max(max,solve(indx,curr+1));
        }
        if(curr<=freq[indx]) {
            freq[indx]-=curr;
            max=Math.max(max,1+solve(indx,curr+1));
            freq[indx]+=curr;
        }
        return max;
    }
    //false for prime number and true for composite number
    public static void sieve(int n) {
        boolean sieve[]=new boolean[n];
        int indx=0;
        for(int i=2;i<n;i++) {
            if(!sieve[i]) {
                primes[indx]=i;
                indx++;
                for(int j=2*i;j<n;j=j+i) {
                    sieve[j]=true;
                } 
            }            
        }
//        System.out.println(indx);
    }
}


Measured memory_bytes: 38272
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N,x;
void input(){
    fast_io();
    cin >> N >> x;
}

int solve(){
    if(N==2){
        if(x==2){
            cout << "Yes" << endl;
            cout << 1 << endl;
            cout << 2 << endl;
            cout << 3 << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
    else if((2<=x) && (x<=(2*N-2))){
        vector<int> ans(2*N-1,0);
        if(x<2*N-2)ans[N-3] = x+2;
        ans[N-2] = x-1;
        ans[N-1] = x;
        ans[N] = x+1;
        if(x>2)ans[N+1] = x-2;
        vector<int> rest;
        for (int i = 1; i <= (2*N-1); i++)
        {
            if(((x-2)<=i) && (i<=(x+2))) continue;
            rest.push_back(i);
        }
        for (int i = 0; i < (2*N-1); i++)
        {
            if(ans[i]==0){
                ans[i] = rest.back();
                rest.pop_back();
            }
        }
        cout << "Yes" << endl;
        for(auto a:ans) cout << a << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}   

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

Measured memory_bytes: 5060
import sys
input = sys.stdin.readline

n,m,l = map(int,input().split())
A = [list(map(int,input().split())) for i in range(m)]
q = int(input())
S = [list(map(int,input().split())) for i in range(q)]

from scipy.sparse.csgraph import floyd_warshall

for i in range(m):  # ノード番号が1始まりで与えられている場合
    for j in range(2):
        A[i][j] -= 1

for i in range(q):  # ノード番号が1始まりで与えられている場合
    for j in range(2):
        S[i][j] -= 1

M = [[float("inf")] * n for i in range(n)]

for i in range(n):
    M[i][i] = 0

for i in range(m):
    M[A[i][0]][A[i][1]] = A[i][2]
    M[A[i][1]][A[i][0]] = A[i][2]

# for k in range(n):
#     for i in range(n):
#         for j in range(n):
#             M[i][j] = min(M[i][j], M[i][k] + M[k][j])

M = floyd_warshall(M)

for i in range(n):
    for j in range(n):
        M[i][j] = 1 if M[i][j] <= l else float("inf")

for i in range(n):
    M[i][i] = 0

# for k in range(n):
#     for i in range(n):
#         for j in range(n):
#             M[i][j] = min(M[i][j], M[i][k] + M[k][j])

M = floyd_warshall(M)

for i in range(q):
    ans = M[S[i][0]][S[i][1]]-1
    if ans == float("inf"):
        ans = -1
    print(int(ans))

Measured memory_bytes: 43916
def factorize(n):
    factor = []
    if n % 2 == 0:
        f = [2, 1]
        n //= 2
        while n % 2 == 0:
            n //= 2
            f[1] += 1
        factor.append(f)
    k = 3
    while k * k <= n:
        if n % k == 0:
            f = [k, 1]
            n //= k
            while n % k == 0:
                n //= k
                f[1] += 1
            factor.append(f)
        k += 2
    if n != 1:
        factor.append([n, 1])
    return factor

def factorial(n, mod):
    fac = [0] * (n + 1)
    inv = [0] * (n + 1)
    fac[0], inv[0] = 1, 1
    for i in range(1, n + 1):
        fac[i] = fac[i-1] * i % mod
        inv[i] = inverse(fac[i], mod)
    return fac, inv

def inverse(a, mod):
    a %= mod # 除数が正なら正になる
    p = mod
    x, y = 0, 1
    while a > 0:
        n = p // a
        p, a = a, p % a, 
        x, y = y, x - n * y
    return x % mod # 除数が正なら正になる

n, m = map(int, input().split())
if m == 1:
    print(1)
    quit()
mod = 10 ** 9 + 7
f = factorize(m)
max_k = max(i for _, i in f)
fac, inv = factorial(n + max_k - 1, mod)
ans = 1
for _, k in f:
    ans = ans * fac[n + k - 1] % mod * inv[n - 1] % mod * inv[k] % mod
print(ans)



Measured memory_bytes: 75112
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

int main(void){
	int a, b, c; cin >> a >> b >> c;
	int k; cin >> k;
	while (a >= b){
		b *= 2;
		k--;
	}
	while (b >= c){
		c *= 2;
		k--;
	}
	cout << (k >= 0 ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 3632
A, B, C, K = gets.split(' ').map(&:to_i)

k = K

count = 0;
[A, B, C].each.with_index do |num, index|
  if k < num
    count += (1-index) * k
    break
  else
    count += (1-index) * num
    k -= num
  end
end

puts count

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

using LL = long long;
using LD = long double;
using PII = pair<int,int>;
using PIII = pair<int,PII>;
using PLL = pair<LL, LL>;
using PSI = pair<string, int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VS = vector<string>;
using VVS = vector<VS>;
using VC = vector<char>;
using VVC = vector<VC>;
using VPII = vector<PII>;
#define endl		'\n'
#define X		first
#define Y		second
#define MP		make_pair
#define PB		push_back
#define MIN(a, b, c)	min((a), min((b), (c)))
#define SZ(a)		int(a.size())
#define SQR(a)		((a)*(a))
#define ALL(a)		a.begin(), a.end()
#define FORI(i, a, b)	for(int i = int(a); i < int(b); ++i)
#define FORD(i, a, b)	for(int i = int(b)-1; i >= int(a); --i)
#define FILL(a,v)	memset(a, v, sizeof (a))
struct _ { ios_base::Init i; _() { cin.sync_with_stdio(0); cin.tie(0); } } _;
const double EPS = (double)1e-8;
const int MOD = 1000000007;
const double PI = 3.14159265358979;
//
// Todo, make a template for "for each" loop.
// Template below has been copied from tourist.

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << __FILE__ << "][" << __FUNCTION__ << "][Line " << __LINE__ << "][" <<  #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif


int main()
{
    int n; cin >> n;
    string s; cin >> s;

    string ans = "Yes";
    if (n&1)
    {
	cout << "No" << endl;
	return 0;
    }

    for (int i=0, j=n/2; i < n/2; ++i, ++j)
    {
	if (s[i] != s[j])
	{
	    ans = "No";	break;
	}
    }

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


Measured memory_bytes: 256
import numpy as np
H, W = map(int, input().split())
a = np.array([list(input()) for _ in range(H)])
row = np.all(a == '.', axis=0)
col = np.all(a == '.', axis=1)
for i in range(H):
    if col[i]:
        continue
    for j in range(W):
        if row[j]:
            continue
        print(a[i][j], end='')
    print()

Measured memory_bytes: 13940
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
    string s;
    cin>>s;
    vector<char> ans(0);
    for(int i=0; i<s.size(); i++){
        if(s.at(i)=='1'){
            ans.push_back('1');
        }else if(s.at(i)=='0'){
            ans.push_back('0');
        }else if(s.at(i)=='B'){
            if(ans.size()>=1){
                ans.pop_back();
            }
        }
    }
    for(auto v:ans){
        cout<<v;
    }
    cout<<endl;
}


Measured memory_bytes: 3612
using System;

class Program
{
    static void Main(string[] args)
    {
        string[] aryInput = System.Console.ReadLine().Split(' ');
        int n = int.Parse(aryInput[0]);
        int m = int.Parse(aryInput[1]);

        int[,] A = new int[n, m];
        int[] b = new int[m];

        //配列Ａ代入
        for (int i = 0; i < n; i++)
        {
            string[] line2 = System.Console.ReadLine().Split(' ');
            for (int j = 0; j < m; j++)
            {
                A[i, j] = int.Parse(line2[j]);
            }
        }
        //配列b代入
        for (int i = 0; i < m; i++)
        {
            b[i] = int.Parse(System.Console.ReadLine());
        }
        //出力
        for (int i = 0; i < n; i++)
        {
            int c = 0;

            for (int j = 0; j < m; j++)
            {
                c += A[i, j] * b[j];
            }

            System.Console.WriteLine(c.ToString());

        }
    }
}

Measured memory_bytes: 9360
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <set>
#include <sstream>
#include <bitset>

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

typedef long long ll;

using namespace std;

int main() {

    string s;
    cin >> s;

    int k;
    cin >> k;

    int n = s.size();

    vector<string> vec;
    FOR(j, 1, min(n,5)+1){
        FOR(i, 0, n-j+1){
            vec.push_back(s.substr(i,j));
        }
    }

    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());

    cout << vec[k-1] << endl;

    return 0;
}

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

int x[100000];

int main() {
	int n;
	scanf("%d", &n);
	f(i, 0, n) {
		int t;
		scanf("%d", &t);
		x[i] = t - 1;
	}
	int an = 0;
	f(i, 0, n) {
		if (x[x[i]] == i)++an;
	}
	printf("%d\n", an / 2);
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int i,k;
    cin>>k;
    string s;
    cin>>s;
    if(s.size()<=k)
    cout<<s;
    else
    {
        for(i=0;i<k;i++)
        cout<<s[i];
        cout<<"...";
    }
    
    return 0;
}

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

using namespace std;

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

int main(){
	string s;
	string p;
	bool f=0;
	cin >> s >> p;
	s.insert(s.length(), s, 0, p.length());
	REP(i, s.length() - p.length()){
		if (s.substr(i, p.length()) == p)
			f = 1;
	}
	if (f)cout << "Yes" << '\n';
	else cout << "No" << '\n';

	return 0;
}

Measured memory_bytes: 1184
#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;
const long long INF = 1LL << 60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    int n ; cin>>n;
    vector<int> a(n);rep(i,n)cin>>a[i];
    int q;cin>>q;
    vector<int> b(q),c(q);rep(i,q)cin>>b[i]>>c[i];
    vector <int> x (100005);
    ll sum=0;
    rep(i,n){
        x[a[i]]++;
        sum+=a[i];
    }

    for(int i=0;i<q;i++){
        int count = x[b[i]];
        int dif = (c[i]-b[i])*count;
        x[b[i]]=0;
        x[c[i]]+=count;
        sum+=dif;
        cout<<sum<<endl;
    }

}

Measured memory_bytes: 4828
from math import sqrt
q = int(input())
for _ in range(q):
    a, b = map(int, input().split(" "))
    c = a * b
    d = int(sqrt(c))
    answer = 2 * d - 2
    if d * d == c:
        answer -= 1
    if d * (d + 1) < c:
        answer += 1
    if a == b:
        answer += 1
    print(answer)

Measured memory_bytes: 3064