akhauriyash/Code-Regression huggingface dataset:
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

static class P
{
    static void Main()
    {
        var nm = Console.ReadLine().Split().Select(int.Parse).ToArray();
        HashSet<int> broken = new HashSet<int>(Enumerable.Repeat(0, nm[1]).Select(_ => int.Parse(Console.ReadLine().Trim())).ToArray());
        ModInt prev2 = 0;
        ModInt prev = 1;
        for (int i = 1; i <= nm[0]; i++)
        {
            ModInt current = 0;
            if (broken.Contains(i))
            {
                current = 0;
            }
            else
            {
                current = prev + prev2;
            }
            prev2 = prev;
            prev = current;
        }
        Console.WriteLine(prev);
    }
}


struct ModInt
{
    const int MOD = 1000000007;
    long Data;
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public ModInt(long data) { if ((Data = data % MOD) < 0) Data += MOD; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static implicit operator long(ModInt modInt) => modInt.Data;
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static implicit operator ModInt(long val) => new ModInt(val);
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator +(ModInt a, ModInt b)
    {
        long res = a.Data + b.Data;
        return new ModInt() { Data = res >= MOD ? res - MOD : res };
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator +(ModInt a, long b) => a.Data + b;
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator -(ModInt a, ModInt b)
    {
        long res = a.Data - b.Data;
        return new ModInt() { Data = res < 0 ? res + MOD : res };
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator -(ModInt a, long b) => a.Data - b;
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator *(ModInt a, ModInt b) => new ModInt() { Data = a.Data * b.Data % MOD };
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator /(ModInt a, ModInt b) => a.Data * GetInverse(b);

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public override string ToString() => Data.ToString();

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    static long GetInverse(long a)
    {
        long div;
        long p = MOD;
        long x1 = 1, y1 = 0, x2 = 0, y2 = 1;
        while (true)
        {
            if (p == 1) return x2;
            div = a / p;
            x1 -= x2 * div;
            y1 -= y2 * div;
            a %= p;
            if (a == 1) return x1;
            div = p / a;
            x2 -= x1 * div;
            y2 -= y1 * div;
            p %= a;
        }
    }
}


Measured memory_bytes: 16096
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
using namespace std;

int main() {
	const long long int mod = 1000000007;
	map<long long int, long long int>mp;
	long long int  s[200][200];
	//cout << fixed << setprecision(10);
	long long int n, m, a[200005],res=0;
	cin >> n >> m;
	while (1) {
		res = 0;
		if (n == 0 && m == 0) { return 0; }
		for(int i=0;i<n;i++){
			cin >> a[i];
		}
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				if (a[i] + a[j] <= m && a[i] + a[j] > res) {
					res = a[i] + a[j];
				}
			}
		}
		if (res == 0) { cout << "NONE" << endl; }
		else { cout << res << endl; }
		cin >> n >> m;
	}

}



Measured memory_bytes: 3056
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

char s[20];
char t[20];
int szS;

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

	printf("Yes\n");

	return 0;
}


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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;

class CPyramid {
public:
void solve(std::istream& cin, std::ostream& cout) {
    int n;
    cin >> n;
    vector<int> X(n), Y(n), H(n);
    for (int i = 0; i < n; i++)
        cin >> X[i] >> Y[i] >> H[i];

    int x = 0, y = 0, h = 0;

    for (int i = 0; i < n; i++){
        if (H[i] > 0){
            x = X[i];
            y = Y[i];
            h = H[i];
            break;
        }
    }

    for (int cx = 0; cx <= 100; cx++){
        for (int cy = 0; cy <= 100; cy++){
            bool flag = true;
            int height = h + abs(x - cx) + abs(y - cy);
            for (int i = 0; i < n and flag; i++){
                flag = H[i] == max(height - abs(X[i] - cx) - abs(Y[i] - cy), 0);
            }
            if (flag) {
                cout << cx << " " << cy << " " << height << endl;
                return;
            }
        }
    }
}
};

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define MIN(a,b) ((a) <= (b) ? (a) : (b))
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort( ALL(v) )

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

vector<vector<int>> adjList;
int arr[21000]{};
ll N,X,Y;


vector<int> bfs(int node){

    queue<int> qu;
    vector<int> d(N+1, -1);
    d[node]=0;
    qu.push(node);
    bool ok = true;

    while(!qu.empty()){
    node = qu.front();
    qu.pop();
    for(auto x : adjList[node]){

        if(d[x]==-1)
        {
           d[x] = d[node]+1;
           qu.push(x);
        }
    }
}
return d;
}


int main()
{

    cin>>N>>X>>Y;
    adjList = vector<vector<int>>(N);

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

        adjList[i].push_back(i+1);
        adjList[i+1].push_back(i);
    }
    adjList[X-1].push_back(Y-1);
    adjList[Y-1].push_back(X-1);

    for(int from = 0; from<N ; from++)
    {
        vector<int> DEP = bfs(from);
        for(int k = 0 ; k<N; k++)
        {
           arr[DEP[k]]++;
        }
    }

    for(int i = 1 ;i<N ; i++)
        cout<<arr[i]/2<<endl;

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

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; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define RES(a,i,j) a.resize(i);rep(ii,i)a[ii].resize(j); 
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout<<a<<" "<<b<<" "<<c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 
#define gre(n) greater<n>()

typedef long long ll;
//
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
const int INF = 1000000000;
const double dINF = 1000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
//const ll MOD = 67280421310721ll;
const dou pi=3.141592653589793;
//メモ
//二次元配列のresizeのしかた
//vv.resize(n);
//for(size_t i=0; i<n; i++){
// vv[i].resize(n);
//}

//メモ
//負の辺を持つ最短経路問題では到達不可経路でも初期化値より小さくなりうるので注意しよう！
int main(){
    int n,m;
    std::cin >> n>>m;
    dou c=0;
    VEC(int,a,n);
    rep(i,n)c+=a[i];
    int cc=0;
    rep(i,n){
        if(c<=a[i]*4*m)cc++;
    }
    if(cc>=m)std::cout << Yes << std::endl;
    else std::cout << No << std::endl;
}


Measured memory_bytes: 256
//
//  main.cpp
//  HelloWorld
//
//  Created by purple on 2020/04/13.
//  Copyright © 2020 Purple. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <cmath>

using namespace std;

int main(int argc, const char * argv[]) {


    int n;
    
    cin >> n;
    
    string a[n+1];
    
    for(int i=1; i<=n; i++)
        cin >> a[i];
    a[0] ="";
    
    sort(a,a+n+1);
    
    
   
    int cnt=0;
    
    for(int i=1; i<=n; i++){
        if(a[i-1]==a[i])
            cnt++;
    }
        
    cout << n-cnt << endl;
 
    
    

    return 0;
}


Measured memory_bytes: 9848
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	int n;
	cin>>n;
	for(int i=1;i<10;i++){
		for(int j=1;j<10;j++){
			if(n==i*j){
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}



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


// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3") 
// #pragma GCC optimization ("unroll-loops")
 
#define ll  long long int
#define all(v) v.begin(),v.end()
#define pb push_back
#define S second
#define F first
#define die() return 0;
 
#define MD          1000000007
#define M           1000011
#define N 			20
long long  md=MD;
ll F[M],dp[M];
ll s[M],s2[M];
int mu[M];
int pr[M];

ll exp(ll a,ll b){
	ll r=1;
	while(b){
		if(b&1)r=r*a%md,r%=md;
		a=a*a;a%=md;
		b/=2;
	}return r;
}
int solve(){
	ll n,i,j,k,m;
	cin>>n;
	ll t1=0,t2=0;
		ll x;
		vector<ll> v;
	for(i=0;i<n;++i){
		cin>>x;
		v.pb(x);
		F[x]++;
		t1=t1+x;if(t1>md)t1-=md;
		t2=t2+x*x%md;t2%=md;
	}
	s[1]=t1;
	s2[1]=t2;
	for(i=2;i<M;++i){
		for(j=i;j<M;j+=i){
			if(!F[j])continue;

			t1=j;
			t2=j*j;t2%=md;
			t1*=F[j];t1%=md;
			t2*=F[j];t2%=md;
			s[i]+=t1;s[i]%=md;
			s2[i]+=t2;s2[i]%=md;

		}
	}
	ll p=0;
	ll i2=exp(2,md-2)%md;

	// map<int,int> sa,sb;
	// for(i=0;i<n;++i){
	// 	for(j=i+1;j<n;++j){
	// 		int g=__gcd(v[i],v[j]);
	// 		for(k=1;k<=g;++k){
	// 			if(g%k==0){
	// 				sa[k]+=v[i];
	// 				sa[k]+=
	// 			}
	// 		}

	// 	}
	// }
	for(int d=1;d<M;++d){
		s[d]*=s[d];
		s[d]%=md;
		F[d]=(s[d]-s2[d]+md)%md;
		F[d]=F[d]*i2%md;F[d]%=md;
	}
	p=0;
	for(i=M-1;i>=1;--i){
		ll x=F[i];
		if(x==0)continue;
		for(j=2*i;j<M;j+=i){
			x-=dp[j];x=(x+md)%md;

		}
		dp[i]=x;
		x=x*exp(i,md-2)%md;
		p=p+x%md;
		p%=md;
	}cout<<p<<"\n";







}


int main(){

 
     
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t;
    t=1;
    // cin>>t;
    md=998244353;
    while(t--){
    	solve();
    }
    die();



    

}



Measured memory_bytes: 34928
i = raw_input()
N, A, B = i.split()

N = int(N)
A = int(A)
B = int(B)

if abs(A-B)%2 == 0:
  print int(abs(A-B)/2)
else:
  e = int(min(A-1, N-B))
  d = (B-A+1) // 2
  print e + d

Measured memory_bytes: 2568
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <algorithm>
#include <functional>
#include <utility>
#include <string>
#define typeof(x) __typeof__(x)
#define int long long int
#define mod(x) ((x % MOD) + MOD) % MOD
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);--i)

#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SZ(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin())
#define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin())
#define COUNT(c,x) UB(c,x)-LB(c,x)
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (s).find(e)!=(s).end()
#define PB push_back
#define MP make_pair
#define vec vector

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

using namespace std;

typedef pair<int,int> P;
struct edge { int to, cost; };

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

template<typename T> ostream& operator << (ostream& s, const vector<T>& v) {
  int len = v.size();
  s << "[";
  for (int i = 0; i < len; i++) {
    s << v[i]; if (i < len - 1) s << " ";
  }
  s << "]";
  return s;
}


signed main()
{
  int N, A, B; cin >> N >> A >> B;
  vec<int> X(N);
  rep(i, 0, N) {
    cin >> X[i];
  }

  int ans = 0;
  rep(i, 0, N-1) {
    ans += min(A * (X[i+1]-X[i]), B);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
import fractions
import sys
n,X=map(int,input().split())
x=list(map(int,input().split()))
y=[]
if n==1:
  print(abs(x[0]-X))
  sys.exit()
for i in range(n):
  y.append(abs(x[i]-X))
G=100000000000
for j in range(n-1):
  G=min(G,fractions.gcd(y[j],y[j+1]))
print(G)
  



Measured memory_bytes: 16296
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn=1e5+10;
LL a[maxn],b[maxn];
int n,ans;
map<LL,LL>mp;
LL sqr(LL x){return x*x;}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		LL x,y=1;
		scanf("%lld",&x);
		for(LL j=2;j*j*j<=x;j++) for(;x%(j*j*j)==0;x/=j*j*j);
		mp[a[i]=x]++;
		for(LL j=2;j*j*j<=x;j++) if(x%j==0)	for(y*=(x%(j*j)==0)?j:j*j;x%j==0;x/=j);
		b[i]=y*=sqr((LL)sqrt(x))==x?(LL)sqrt(x):x*x;
	}
	if(mp[1]) mp[1]=0,ans++;
	for(int i=1;i<=n;i++){
		ans+=max(mp[a[i]],mp[b[i]]);
		mp[a[i]]=mp[b[i]]=0;
	}
	printf("%d",ans);
	return 0;
}
/*
8
1
2
3
4
5
6
7
8
*/

Measured memory_bytes: 14336
# include <bits/stdc++.h>
# define INF 1e9
using namespace std;

int main(){

  string s;
  cin >> s;
  string t = "";
  for(int i=0; i< s.size();i++){
    if(s[i] == '1'){
      t += '9';
    } else if(s[i] == '9'){
      t += '1';
    } else {
      t += s[i];
    }
  }

  cout << t << endl;

}

Measured memory_bytes: 256
#include<cstdio>

#define ran 555

int n, m;
int a[ran][ran];
int s, v[ran*ran][4];

void o(int a, int b, int c, int d) {
	v[s][0] = a; v[s][1] = b; v[s][2] = c; v[s][3] = d;
	s++;
}

int main() {
	scanf("%d%d", &n, &m);
	for(int i=1;i<=n;i++)
	for(int j=1;j<=m;j++) 
		scanf("%d", &a[i][j]);
	
	s = 0;
	for(int i=1;i<n;i++) 
	for(int j=1;j<=m;j++)
		if (a[i][j]%2) {
			a[i][j]--; a[i+1][j]++;
			o(i, j, i+1, j);
		}
	for(int j=1;j<m;j++)
		if (a[n][j]%2) {
			a[n][j]--; a[n][j+1]++;
			o(n, j, n, j+1);
		}
	printf("%d\n", s);
	for(int i=0;i<s;i++) 
		printf("%d %d %d %d\n", v[i][0], v[i][1], v[i][2], v[i][3]);
	
	return 0;
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;


template<typename F>
struct FixPoint : F{
  FixPoint(F&& f):F(forward<F>(f)){}
  template<typename... Args>
  decltype(auto) operator()(Args&&... args) const{
    return F::operator()(*this,forward<Args>(args)...);
  }
};

template<typename F>
inline decltype(auto) MFP(F&& f){
  return FixPoint<F>{forward<F>(f)};
}

template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}

//INSERT ABOVE HERE
struct Edge{
  Int to,cost,weight;
  Edge(Int to,Int cost):to(to),cost(cost),weight(cost){}
  bool operator<(const Edge a)const{
    return weight<a.weight;
  }
};
signed main(){
  Int n,T,S,E;
  cin>>n>>T>>S>>E;

  S--;E--;
  //assert(S!=E);

  vector< vector<Edge> > G(n);
  for(Int i=1;i<n;i++){
    Int a,b,w;
    cin>>a>>b>>w;
    a--;b--;
    G[a].emplace_back(b,w);
    G[b].emplace_back(a,w);
  }

  for(Int i=0;i<n;i++)
    for(auto &e:G[i])
      e.weight-=T*G[e.to].size();

  for(Int i=0;i<n;i++)
    sort(G[i].begin(),G[i].end());

  vector<Int> ato(n);
  MFP([&](auto dfs,Int v,Int p)->Int{
        Int &res=ato[v];
        if(v==E) res=1;
        for(Edge e:G[v]){
          if(e.to==p) continue;
          res|=dfs(e.to,v);
        }
        return res;
      })(S,-1);

  vector<Int> cnt(n,0);
  MFP([&](auto dfs,Int v,Int p)->void{
        Int nxt=-1,wei=0;
        for(Edge e:G[v]){
          if(e.to==p) continue;
          if(ato[e.to]){
            nxt=e.to;
            wei=e.cost;
            continue;
          }
          if(e.cost-(cnt[v]+cnt[e.to])*T<=0) drop("No");
          cnt[e.to]++;
          dfs(e.to,v);
          if(e.cost-(cnt[v]+cnt[e.to])*T<=0) drop("No");
          cnt[v]++;
        }
        if(nxt<0) return;
        if(wei-(cnt[v]+cnt[nxt])*T<=0) drop("No");
        cnt[nxt]++;
        dfs(nxt,v);
      })(S,-1);

  cout<<"Yes"<<endl;
  return 0;
}



Measured memory_bytes: 16216
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cmath>
using namespace std;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
    long long N;
    cin >> N;
    vector<vector<long long>> xy(2, vector<long long>(N)), sorted_xy(2, vector<long long>(N));
    vector<vector<long long>> sorted_index_xy(2, vector<long long>(N));
    iota(sorted_index_xy[0].begin(), sorted_index_xy[0].end(), 0);
    iota(sorted_index_xy[1].begin(), sorted_index_xy[1].end(), 0);
    
    for(int i = 0; i < N; i++){
        long long x, y;
        cin >> x >> y;
        xy[0][i] = x; xy[1][i] = y;
    }
    
    sort(sorted_index_xy[0].begin(), sorted_index_xy[0].end(), [&xy](size_t i1, size_t i2) {
        return xy[0][i1] < xy[0][i2];
    });
    sort(sorted_index_xy[1].begin(), sorted_index_xy[1].end(), [&xy](size_t i1, size_t i2) {
        return xy[1][i1] < xy[1][i2];
    });
    
    vector<vector<long long>> edges(2*N-2, vector<long long>(3, 0));
    for(int i = 0; i < N-1; i++){
        for(int j = 0; j < 2; j++){
            edges[2*i+j][0] = sorted_index_xy[j][i];
            edges[2*i+j][1] = sorted_index_xy[j][i+1];
            edges[2*i+j][2] = abs(xy[j][sorted_index_xy[j][i]] - xy[j][sorted_index_xy[j][i+1]]);
        }
    }
    
    sort(edges.begin(), edges.end(), [](vector<long long> i1, vector<long long> i2) {
        return i1[2] < i2[2];
    });
    
    UnionFind tree(N);
    long long cost = 0;
    for(auto edge:edges){
        if(!tree.same(edge[0], edge[1])){
            tree.unite(edge[0], edge[1]);
            cost += edge[2];
        }
    }
    
    cout << cost << endl;
}


Measured memory_bytes: 17904
#include<bits/stdc++.h>
 
#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9+7;
const int vx[6] = {0,1,0,-1,1,-1};
const int vy[6] = {1,0,-1,0,1,1};




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

    ll n,q;
    string s;
    cin >> n >> q >> s;
    vector<ll> ac(n,0);
    ll a = 0;
    rep(i,s.length()){
        if(i == s.length()-1) {
            ac[i] = a;
            break;
        }
        if(s[i] == 'A' && s[i+1] == 'C'){
            ac[i] = a;
            a++;
        }else {
            ac[i] = a;
        }
    }
    rep(i,q){
        ll l,r;
        cin >> l >> r;
        ll t,tt;
        t = ac[l-1];
        tt = ac[r-1];
        int ans = tt-t;
        cout << ans << endl;
    }

    cout << endl;
    return 0;
}


Measured memory_bytes: 1872
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *A = map(int, read().split())

    B = [False] * (N + 1)

    for i, a in reversed(list(enumerate(A, 1))):
        tmp = 0
        for j in range(2 * i, N + 1, i):
            tmp += B[j]
        B[i] = tmp % 2 != a

    ans = [i for i in range(1, N + 1) if B[i]]
    print(len(ans))
    if len(ans) > 0:
        print(' '.join(map(str, ans)))

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 33700
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	
	final static int UP_OK = 1;
	final static int RIGHT_OK = 2;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		final int n = sc.nextInt();
		
		for(int i = 0; i < n; i++){
			final int gx = sc.nextInt();
			final int gy = sc.nextInt();
			
			long[][] dp = new long[gy+1][gx+1];
			dp[0][0] = 1;
			
			int[][] path = new int[gy+1][gx+1];
			
			for(int j = 0; j <= gy; j++){
				for(int k = 0; k <= gx; k++){
					if(j != gy){
						path[j][k] |= UP_OK;
					}
					if(k != gx){
						path[j][k] |= RIGHT_OK;
					}
				}
			}
			
			final int p = sc.nextInt();
			
			for(int j = 0; j < p; j++){
				final int fx = sc.nextInt();
				final int fy = sc.nextInt();
				final int tx = sc.nextInt();
				final int ty = sc.nextInt();
				
				if(fx == tx){
					path[Math.min(fy, ty)][fx] &= ~UP_OK;
				}else{
					path[fy][Math.min(fx, tx)] &= ~RIGHT_OK;
				}
			}
			
			for(int j = 0; j <= gy; j++){
				for(int k = 0; k <= gx; k++){
					//System.out.println(j + " " + k + " " + dp[j][k] + " " + path[j][k]);
					
					if((path[j][k] & UP_OK) != 0){
						dp[j+1][k] += dp[j][k];
					}
					
					if((path[j][k] & RIGHT_OK) != 0){
						dp[j][k+1] += dp[j][k];
					}
				}
			}
			
			if(dp[gy][gx] == 0){
				System.out.println("Miserable Hokusai!");
			}else{
				System.out.println(dp[gy][gx]);
			}
			
		}
	}

}

Measured memory_bytes: 12000
#include <stdio.h>
#include <algorithm>
using namespace std;
using ll = long long;

int n, h, mh, cnt = 0;
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &h);
		if (mh <= h)
			cnt++;
		mh = max(mh, h);
	}
	printf("%d\n", cnt);
}

Measured memory_bytes: 128
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int gcd(int a, int b) {
	int c;
	while (a != 0) {
		c = a; a = b % a;  b = c;
	}
	return b;
}

int main() {
	int n, x;
	cin >> n >> x;
	vector<int> xs;
	for (int i = 0; i < n; ++i) {
		int t;
		cin >> t;
		int dif = abs(t - x);
		xs.push_back(dif);
	}
	int cy = xs[0];
	for (int i = 1; i < xs.size(); ++i) {
		cy = gcd(cy, xs[i]);
	}
	cout << cy << endl;
	return 0;
}


Measured memory_bytes: 892
using System;

namespace ConsoleApp11
{
    class MainClass
    {
        public static void Main()
        {
            string[] S = Console.ReadLine().Split();
            long A = long.Parse(S[0]);
            long B = long.Parse(S[1]);
            long K = long.Parse(S[2]);

                if (A > K)
                    A -= K;
                else if (B > K-A)
                {
                    K -= A;
                    A = 0;
                    B -= K;
                }
                else
                {
                    A = 0;
                    B = 0;
                }
            Console.WriteLine("{0} {1}",A,B);
        }
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
#define ld long double
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
#define ld double
const int N=200005;
int n,p[N],tong[N][2],father[N];
ll ans;
priority_queue<pair<ld,int> > q;
inline int gf(int x){
	return father[x]==x?x:father[x]=gf(father[x]);
}
void insert(int x){
	if(x!=1)q.push(mp((ld)tong[x][0]/(tong[x][0]+tong[x][1]),x));
}
void merge(int x,int y){
	father[y]=x; //cout<<x<<" "<<tong[x][1]<<" "<<tong[y][0]<<endl;
	ans+=(ll)tong[x][1]*tong[y][0];
	tong[x][0]+=tong[y][0]; tong[x][1]+=tong[y][1];
	if(x!=1)insert(x);
}
signed main(){
	n=read();
	for(int i=2;i<=n;i++)p[i]=read();
	for(int i=1;i<=n;i++){tong[i][read()]++; insert(i); father[i]=i;}
	while(q.size()){
		int t=q.top().second; q.pop();
		if(father[t]!=t)continue;
		int x=gf(p[t]);
		merge(x,t);
	}
	cout<<ans<<endl;
}
/*
x->y

*/

Measured memory_bytes: 8688
from collections import deque
n,m = map(int,input().split())
tree=[[] for _ in range(n+1)]
ans=[0]*n 
for _ in range(m):
    a,b=map(int,input().split())
    tree[a].append(b)
    tree[b].append(a)
    
checked=[False]*(n+1)
checked[1]=True
stack=deque([1])
while stack:
    p=stack.popleft()
    for i in tree[p]:
        if checked[i]:
            continue
        ans[i-1]=p
        checked[i]=True
        stack.append(i)

print('Yes')
for i in ans[1:]:
    print(i)

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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll K, A, B;
    cin >> K >> A >> B;
    if (A + 2 >= B || K <= A) {
        cout << K + 1 << endl;
    } else {
        K -= (A - 1);
        cout << B + (B - A) * (K / 2 - 1) + K % 2 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
nm = [int(i) for i in input().split()]
n = nm[0]
m = nm[1]
slist = []
clist = []

for i in range(m):
  sc = [int(i) for i in input().split()]
  slist.append(sc[0])
  clist.append(sc[1])

fl = 0
if (n == 1):
  if m != 0:
    if (slist[0] == 1 and clist[0] == 0):
      print('0')
      fl = 1
      exit()

answerlist = ['-1' for i in range(n)]
for (i,s), c in zip(enumerate(slist),clist):
  if (c == 0 and s == 1):
    print('-1')
    fl = 1
    exit()
  if (answerlist[s-1] != '-1' and answerlist[s-1] != str(c)):
    print('-1')
    fl = 1
    exit()
  answerlist[s-1] = str(c)
for i in range(n):
  if (answerlist[i]) == '-1':
    if (i == 0):
      if (n == 1):
        answerlist[i] = '0'
      else:
        answerlist[i] = '1'
    else:
      answerlist[i] = '0'
if fl == 0:
	print("".join(answerlist))

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef set<int> si;
typedef string str;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MOD=1e+9+7;
int N;
int a[200010];
int b[200010];
void solve(){
  vi res;
  fill(b,0);
  for(int i=N;i>0;i--){
    if(a[i-1]==1){
      if(b[i]==0){
	res.pb(i);
	for(int j=1;j*j<=i;j++){
	  if(i%j==0){
	    b[j]=(b[j]+1)%2;
	    if(j!=i/j) b[i/j]=(b[i/j]+1)%2;
	  }
	}
      }
    }
    else{
      if(b[i]==1){
	res.pb(i);
	for(int j=1;j*j<=i;j++){
	  if(i%j==0){
	    b[j]=(b[j]+1)%2;
	    if(j!=i/j) b[i/j]=(b[i/j]+1)%2;
	  }
	}
      }
    }
  }
  int rs=res.size();
  prin(rs);
  if(rs==0) return;
  rep(i,rs){
    cout<<res[i]<<" ";
  }
  cout<<"\n";
}
int main(){
  cin>>N;
  rep(i,N) cin>>a[i];
  solve();
  return 0;
}


Measured memory_bytes: 3192
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();
		int l = s.length();
		System.out.println(s.charAt(0) + "" + (l - 2) + "" + s.charAt(l - 1));
	}
}

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


int main(){
    ll h,w;cin>>h>>w;
    char c[1001][1010];
    rep(i,0,h)rep(j,0,w)cin>>c[i][j];
    vector<vector<ll> > num(1010,vector<ll>(1010));
    rep(i,0,h){
        rep(j,0,w){
            num[i][j]=999999999999;
            if(c[i][j]=='#')num[i][j]=0;
        }
    }
    rep(i,0,h){
        rep(j,0,w){
            ll nr=min((ll)j+1,w-1);
            ll nd=min((ll)i+1,h-1);
            num[i][nr]=min(num[i][j]+1,num[i][nr]);
            num[nd][j]=min(num[i][j]+1,num[nd][j]);
        }
    }
    for(int i=h-1;i>=0;i--){
        for(int j=w-1;j>=0;j--){
            ll nl=max(j-1,0);
            ll nu=max(i-1,0);
            num[i][nl]=min(num[i][j]+1,num[i][nl]);
            num[nu][j]=min(num[i][j]+1,num[nu][j]);
            
        }
    }
    ll maxXX=-1;
    rep(i,0,h)rep(j,0,w)maxXX=max(maxXX,num[i][j]);
    cout<<maxXX<<endl;
}







Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
int main(){
	cin.tie(0);
	int n,mean;
	cin>>n;
	long int stamina1,stamina2,stamina3;
	vector<int> X(n);
	
	for(auto& i:X)
		cin>>i;
	
	mean=0;
	for(auto& i:X)
		mean+=i;
	
	mean/=n;

	stamina2=0;
	stamina1=0;
	stamina3=0;
	for(auto& i:X){
		stamina1+=pow(i-mean,2);
		stamina2+=pow(i-mean-1,2);
	}
	
	stamina3=(stamina1<stamina2?stamina1:stamina2);

	cout<<stamina3;

	return 0;

}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define spn setprecision
using namespace std;
ll multiply(ll num1, ll num2, ll mod) { // with mod > 1e9
	ll ans = 0;
	num1 %= mod;
	num2 %= mod;
	while (num2) {
		if (num2&1) {
			ans += num1;
			ans %= mod;
		}
		num1 *= 2;
		num1 %= mod;
		num2 /= 2;
	}
	return ans;
}
ll powmod2(ll base,ll exponent,ll mod){ // with mod > 1e9
	ll ans = 1;
	while (exponent) {
		if (exponent&1) {
			ans = multiply(ans, base, mod);
		}
		base = multiply(base, base, mod);
		exponent /= 2;
	}
	return ans;
}
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
struct data
{
	int ind,val;
};
bool cmp(data &a,data &b){
	return(a.val<b.val);
}
const int upperlimit = 1e5;
const int limit = 2e5;
char arr[52][52];
int main() {
	int h,w;
	cin >> h >> w;
	for(int i = 1; i <= h; i++){
		for(int j = 1; j <= w; j++){
			cin >> arr[i][j];
		}
	}
	bool check=true;
	for(int i = 1; i <= h; i++){
		for(int j = 1; j <= w; j++){
			if(arr[i][j]=='#'){
				if((arr[i-1][j]!='#')&&(arr[i+1][j]!='#')&&(arr[i][j-1]!='#')&&(arr[i][j+1]!='#')){
					check=false;
					break;
				}
			}
		}
		if(! check){
			break;
		}
	}
	if(check){
		cout << "Yes";
	}
	else{
		cout << "No";
	}
	return 0;
} 

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline LL read()
{
	LL f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
const int MAXN=200005;
priority_queue<pii> hp;
int a[MAXN],b[MAXN],vi[MAXN],n;
int main()
{
//	freopen("a.in","r",stdin);
	n=read();
	for(int i=1;i<=n;i++)a[i]=read();
	for(int i=1;i<=n;i++)b[i]=read(),hp.push(mp(b[i],i));
	LL ans=0;int cnt=n;
	for(int i=1;i<=n;i++)if(a[i]==b[i])--cnt,vi[i]=1;
	int t=cnt;LL kk=0;
	while(cnt)
	{
		
		pii temp=hp.top();hp.pop();t=cnt;
		if(vi[temp.second])continue;
		int ls=temp.second-1,rs=temp.second+1;
		if(!ls)ls=n;if(rs>n)rs=1;
		int g=max(b[ls],b[rs]);
		int k=ceil(double(temp.first-g)/(b[ls]+b[rs]));
		if(temp.first-k*(b[ls]+b[rs])>a[temp.second])
		{
			b[temp.second]-=k*(b[ls]+b[rs]);ans+=k;
			hp.push(mp(b[temp.second],temp.second));
		}
		else
		{
			if((temp.first-a[temp.second])%(b[ls]+b[rs]))break;
			ans+=(temp.first-a[temp.second])/(b[ls]+b[rs]);--cnt;
			
			b[temp.second]=a[temp.second];vi[temp.second]=1;
			if(b[temp.second]>=g)
			{
				if(b[ls]!=a[ls])break;if(b[rs]!=a[rs])break;
				if(!vi[ls])--cnt,vi[ls]=1;if(!vi[rs])--cnt,vi[rs]=1;
			}
		}
	}
	if(cnt)puts("-1");
	else pr2(ans);
	return 0;
}


Measured memory_bytes: 4208
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y)
{
    ll r;
    if(x < y)
        swap(x, y);
    while(y > 0)
    {
        r = x % y;
        x = y;
        y = r;
    }
    return x;
}
int main() {
    ll a, b;
    cin >> a >> b;
    ll ans = a * b / gcd(a, b);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
// bool operator<(const pair<int, int> &a, const pair<int, int> &b)
// {
//     if (a.first == b.first)
//         return a.second < b.second;
//     return a.first < b.first;
// };

/*unsigned int xor128(void)
{
    static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned int t = (x ^ (x << 11));
    x = y;
    y = z;
    z = w;
    return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
unsigned int xor128rnd(unsigned int m)
{
    return xor128() % m;
}*/

/*bool operator<(const pair<int, int> &a, const pair<int, int> &b)
{
    if (a.first == b.first)
    {
        return a.second < b.second;
    }
    return a.first < b.first;
}*/
int dp[100010];
int h[100010];
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;
    for (int i = 0; i < N; ++i)
    {
        dp[i] = 1e9;
        cin >> h[i];
    }
    dp[0] = 0;
    for (int i = 0; i < N; ++i)
    {
        if (i + 1 < N)
            dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]));
        if (i + 2 < N)
            dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]));
    }
    cout << dp[N - 1] << endl;
    return 0;
}

Measured memory_bytes: 1024
MAX_S = 1_000_000_000
N, K, S = list(map(int, input().split()))
for _ in range(K):
    print(S, '', end='')
if S == MAX_S:
    for _ in range(K, N):
        print(1, '', end='')
else:
    for _ in range(K, N):
        print(MAX_S, '', end='')
print()


Measured memory_bytes: 9436
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        //MyDebugger.MakeTestCase("../TextFile2.txt"); return;
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var h = int.Parse(input.ReadLine());
        var w = int.Parse(input.ReadLine());
        var n = int.Parse(input.ReadLine());
        
        if (h < w) {
            return n / w + (n%w!=0 ? 1 : 0);
        } else {
            return n / h + (n%h!=0 ? 1 : 0);
        }
    }
}


Measured memory_bytes: 11092
n,d=map(int,input().split())
s=[]
for i in range(n):
    s.append(list(map(int,input().split())))
dis=[]
for i in range(n):
    for j in range(i+1,n):
        D=0
        for k in range(d):
            D+=(s[i][k]-s[j][k])**2
        dis.append(D**(1/2))
cnt=0
for i in range(len(dis)):
    if dis[i]%1==0:
        cnt+=1
print(cnt)


Measured memory_bytes: 3188
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

main()
{
  char S[100];
  unsigned long int K;
  int i=0;
  scanf("%s",&S);
  scanf("%lu",&K);
  while(S[i]=='1')
    i++;
  if(K<=i)
    printf("1\n");
  else
    printf("%c\n",S[i]);
  return 0;
}


Measured memory_bytes: 128
N = int(input())
H = list(map(int, input().split()))

num = [0]*N

for i in range(N - 2, -1, -1):
	if H[i] >= H[i + 1]:
		num[i] = num[i + 1] + 1
	else:
		num[i] = 0

print(max(num))

Measured memory_bytes: 63984
#include<iostream>
using namespace std;
int main() {
int N,X;
cin >> N >> X;
int L[N];
for(int i=0;i<N;i++){
    cin >> L[i];
    }
    int count =0;
    int sum = 0;
    for(int i=0;i<N;i++){
        sum += L[i];
        if(sum <= X ){
        count++;
        }
    }
    count++;
    cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int ,int> pi;
typedef pair<ll ,ll> pl;
typedef map<ll ,ll> ml;
#define modulo 1000000007
#define PI 3.14159265
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N=1e6+1;

void solve()
{ 
    ll n;
    cin >> n;
    cout << (1+n+n*n)*n << endl;
}

int main()
{
    //#ifndef ONLINE_JUDGE
    //    freopen("input.txt","r",stdin);
    //    freopen("output.txt","w",stdout);
    //#endif
    fast;
    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
 
 
int main(){
    int n,k; cin >> n >> k;
    vector<double> p(n+1);
    p[0]=0;
    for(int i=1; i<=n; i++){
        cin >> p[i];
        p[i]=1+(p[i]-1)*0.5;
        p[i]+=p[i-1];
    }
    double total=-1;
    for(int i=k; i<n+1; i++){
        total=max(total,p[i]-p[i-k]);
    }
    printf("%.20lf",total);
return 0;
}

Measured memory_bytes: 1792
let () =
  let n = Scanf.scanf "%d " (fun a -> a) in
  let t_a = Array.to_list @@ Array.init n (fun _ -> Scanf.scanf "%d %d " (fun a b -> a,b)) in

  let rec aux cur = function
    | [] -> cur 
    | (t,a) :: tl -> 
      let (rt,ra) = cur in
      if rt <= t && ra <= a 
      then 
        aux (t,a) tl
      else (
        let mul = max 
            (if ra mod a <> 0 then ra/a+1 else ra/a) 
            (if rt mod t <> 0 then rt/t+1 else rt/t) 
        in
        aux (t*mul,a*mul) tl

      )
  in

  let (rt, ra) = aux (0,0) t_a in
  Printf.printf "%d\n" (rt + ra)


Measured memory_bytes: 1024
while n = gets.to_i do
  break if n == 0
  s = gets.split(" ").map(&:to_i)
  m = s.inject(:+)/n.to_f
  s2 = 0
  s.each{|si|
    s2 += (si - m)**2
  }
  printf "%f\n", Math.sqrt(s2 / n)
end

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

using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    string s,k;
    cin>>s>>k;int sum=0;
    for(int i=0;i<s.size();i+=1){
        if(s[i]!=k[i])sum++;
    }
    cout<<sum<<endl;







    return 0;
}





Measured memory_bytes: 3788
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e5+10;
int n;
struct node{
    int x,y,id;
}e[N];
bool cmp1(node a,node b){
    return a.x<b.x;
}
bool cmp2(node a,node b){
    return a.y<b.y;
}
struct qnode{
    int from,to,w;
    qnode(int a=0,int b=0,int c=0){from=a,to=b,w=c;}
    bool operator < (const qnode &b)const{
        return w>b.w;
    }
};
priority_queue<qnode>q;int fa[N];
void init(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d%d",&e[i].x,&e[i].y),e[i].id=i;fa[i]=i;
    }
    sort(e+1,e+n+1,cmp1);
    for(int i=1;i<n;i++){
        q.push(qnode(e[i].id,e[i+1].id,e[i+1].x-e[i].x));
    }
    sort(e+1,e+1+n,cmp2);
    for(int i=1;i<n;i++){
        q.push(qnode(e[i].id,e[i+1].id,e[i+1].y-e[i].y));
    }
}

int fi(int x){
    if(fa[x]==x)return x;
    else return fa[x]=fi(fa[x]);
}
int main()
{
    init();
    ll ans=0;
    while(!q.empty()){
        int u=q.top().from,v=q.top().to,w=q.top().w;q.pop();
        int f1=fi(u),f2=fi(v);
        if(f1!=f2){
            ans+=w;
            fa[f1]=f2;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 6516
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int gcd(int a,int b)
{
	if(!b)return a;
	return gcd(b,a%b);
}
int main()
{
	int a,b;
	scanf("%d %d",&a,&b);
	printf("%lld",1ll*a*b/gcd(a,b));
	return 0;
}


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

using namespace std;

int main()
{
    int n;
    char tmp[32];
    
    while (scanf("%d", &n) && n){
        map<string, int> conv;
        bool ng[24 * 60 * 7] = {0};
        
        for (int i = 0; i < n; i++){
            int w, t;
            
            scanf("%s %d %d", tmp, &w, &t);
            conv[(string)tmp] = w * 24 * 60 + (t / 100 - 6) * 60 + t % 100;
        }
        
        int m;
        scanf("%d",  &m);
        bool able = true;
        for (int i = 0; i < m; i++){
            scanf("%s", tmp);
            
            for (int s = conv[(string)tmp], t = 0; t < 30; t++){
                if (ng[s + t]){
                    able = false;
                    break;
                }
                ng[s + t] = true;
            }
        }
        
        vector<pair<int, int> > v;
        for (auto it = conv.begin(); it != conv.end();){
            if (ng[it->second] || ng[it->second + 29]){
                auto tmp = it++;
                conv.erase(tmp);
            }
            else {
                v.push_back(make_pair(it->second + 29, it->second));
                it++;
            }
        }
        
        sort(v.begin(), v.end());
        int prev = -1000, cnt = 0;
        for (int i = 0; i < v.size(); i++){
            if (v[i].second > prev){
                prev = v[i].first;
                cnt++;
            }
        }
        
        printf("%d\n", able ? m + cnt : -1);
    }
    
    return (0);
}

Measured memory_bytes: 1308
import sys

# 関数 solve は，もちろん，問題に応じて書き換える
def solve(a,b,c):
    f = [a,b,c]
    f.sort()
    #print(f)
    x = 0
    y = 0

    if a == b and b == c :
        return 0
    else:
        x = f[1] - f[0]
        y = f[2] - f[1]
        return x+y
# ここから下は，入力・出力形式が同じであれば，変えなくて良い．
def readQuestion():
    line = sys.stdin.readline().rstrip()
    [str_a, str_b, str_c] = line.split(' ')
    return (int(str_a), int(str_b), int(str_c))

def main():
    a, b, c = readQuestion()
    answer = solve(a, b, c)
    print(answer)
    
if __name__ == '__main__':
    main()

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

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]) {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  vector<ll> nums{a * c, a * d, b * c, b * d};
  cout << *max_element(nums.begin(), nums.end()) << '\n';
  return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef vector<int> vi;
typedef pair<int, int> pi;
#define SQ(a) (a) * (a)
#define deb(x) cout << #x << " = " << x << '\n'
#define deb2(x, y) cout << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n"
 
 
int main(int argc, char const *argv[])
{
 
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string x,y;
    cin>>x;
    cin>>y;
    int n=x.length();
    int m=y.length();
    int dp[n+1][m+1];
    memset(dp,0,sizeof dp);
    for(int i=1;i<=n;i++){
    	for(int j=1;j<=m;j++){
    		if(x[i-1]==y[j-1]){
    			dp[i][j] = 1+dp[i-1][j-1];
    		}
    		else{
    			dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
    		}
    	}
    }
    string str;
    int i=n,j=m;
    while(i>0 && j>0){
    	if(x[i-1]==y[j-1]){
    		str.push_back(x[i-1]);
    		i--;j--;
    	}
    	else{
    		if(dp[i-1][j]>dp[i][j-1]){
    			i--;
    		}
    		else{
    			j--;
    		}
    	}
    }
    reverse(str.begin(),str.end());
    cout<<str;
    return 0;
}

Measured memory_bytes: 38820
from sys import setrecursionlimit
setrecursionlimit(10**7)

N, M = map(int, input().split())

graph = [[] for i in range(N)]
for i in range(M):
  x, y = map(int, input().split())
  graph[x-1].append(y-1)


dp = [-1] * N

def rec_calc_depth(i):
  global dp
  if dp[i] >= 0:
    return dp[i]
  else:
    children = graph[i]
    depth = 0
    for child in children:
      depth = max(depth, rec_calc_depth(child)+1)
    
    dp[i] = depth
    return depth

ans = 0
for i in range(N):
  ans = max(ans, rec_calc_depth(i))

print(ans)

Measured memory_bytes: 59060