akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define sint int32_t
#define int long long int
#define all(v) v.begin() , v.end()
#define vii vector<int>
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define MAXN   1000001

// stores smallest prime factor for every number
int spf[MAXN];

// Calculating SPF (Smallest Prime Factor) for every
// number till MAXN.
// Time Complexity : O(nloglogn)
void sieve()
{
    spf[1] = 1;
    for (int i=2; i<MAXN; i++)

        // marking smallest prime factor for every
        // number to be itself.
        spf[i] = i;

    // separately marking spf for every even
    // number as 2
    for (int i=4; i<MAXN; i+=2)
        spf[i] = 2;

    for (int i=3; i*i<MAXN; i++)
    {
        // checking if i is prime
        if (spf[i] == i)
        {
            // marking SPF for all numbers divisible by i
            for (int j=i*i; j<MAXN; j+=i)

                // marking spf[j] if it is not
                // previously marked
                if (spf[j]==j)
                    spf[j] = i;
        }
    }
}

// A O(log n) function returning primefactorization
// by dividing by smallest prime factor at every step
unordered_set<int> getFactorization(int x)
{
    unordered_set<int> ret;
    while (x != 1)
    {
        ret.insert(spf[x]);
        x = x / spf[x];
    }
    return ret;
}


int32_t main()
{
    sieve();
    int n;
    cin>>n;
    int arr[n];
    for(int i = 0; i<n; i++)
        cin>>arr[i];
    map<int , int>mp;
    for(int i = 0; i<n; i++) {
        unordered_set<int>p=getFactorization(arr[i]);
        for(auto x:p) mp[x]++;
    }
    int fl = 0;
    for(auto x:mp)
    {
        if(x.S>1) {
            fl=1;
            break;
        }
    }
    if(!fl) {
        cout<<"pairwise coprime\n";
        return 0;
    }
    if(fl)
    {
        int g = arr[0];
        for(auto x:arr) g = __gcd(x , g);
        if(g == 1) {
            cout<<"setwise coprime\n";
            return 0;
        }
        else {
            cout<<"not coprime\n";
        }
    }

}


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

const int MOD = 1000000007;

typedef pair<int, int> pint;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a%b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

int main() {
    int N;
    cin >> N;
    vector<int> X(N), L(N);
    rep(i, N) {
        int x, l;
        cin >> x >> l;
        X[i] = x;
        L[i] = l;
    }

    vector<pint> LR(N);
    rep(i, N) {
        LR[i] = pint(X[i] + L[i], X[i] - L[i]);
    }

    sort(LR.begin(), LR.end());

    int res = 0;
    int cur = -1000000001;

    rep(i, N) {
        if (LR[i].second >= cur) {
            cur = LR[i].first;
            ++res;
        }
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#pragma GCC optimize("-O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#define fi first
#define se second
#define p_b push_back
#define pll pair<ll,ll>
#define pii pair<int,int>
#define m_p make_pair
#define all(x) x.begin(),x.end()
#define sset ordered_set
#define sqr(x) (x)*(x)
#define pw(x) (1ll << x)

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
const ll MAXN = 1123456;
const ll N = 2e5;
mt19937_64 rnd(chrono::system_clock::now().time_since_epoch().count());

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template <typename T> void vout(T s){cout << s << endl;exit(0);}


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

    ll n;
    cin >> n;
    vector <ll> a(n + 1), b(n + 1), c(n);

    for(int i = 1; i <= n; i++)cin >> a[i];
    for(int i = 1; i <= n; i++)cin >> b[i];
    for(int i = 1; i < n; i++)cin >> c[i];

    ll ans = 0;

    for(int i = 1; i <= n; i++)ans += b[i];

    for(int i = 1; i < n; i++)if(a[i] + 1 == a[i + 1])ans += c[a[i]];

    cout << ans << "\n";



    return 0;
}


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

int main(){
    ll n;
    cin >> n;
    ll ans = 1e15;
    for(ll i = 1; i*i <= n; i++){
        if(n % i == 0){
            ans = min(ans, i+(ll)(n/i)-2);
        }
    }
    cout << ans << endl;
    return 0;
}

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

values=list(map(int,input().split()))

keys=[i for i in range(1,N+1)]

keys_values_dict=dict(zip(keys,values))

keys_values_dict_sorted_as_list=sorted(keys_values_dict.items(),key=lambda x:x[1])

ans=[str(keys_values_dict_sorted_as_list[i][0]) for i in range(N)]
ans=' '.join(ans)
print(ans)

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

#define ll long long

void solve(void) {
  ll D, G;
  ll res = 10000000;
  cin >> D >> G;
  vector<ll> p(D), c(D);
  for (ll di = 0; di < D; di++) {
    cin >> p[di] >> c[di];
  }

  for (ll bit = 0; bit < (1 << D); bit++) {
    ll t_score = 0;
    ll solved_n = 0;
    for (ll i = 0; i < D; i++) {
      if (bit & (1 << i)) {
        t_score += 100 * (i+1) * p[i] + c[i];
        solved_n += p[i];
      }
    }
    if (t_score >= G) res = min(res, solved_n);
    else {
      for (ll di = D-1; di >= 0; di--) {
        if (bit & (1 << di)) continue;
        for (ll dj = 0; dj < p[di]; dj++) {
          if (t_score >= G) break;
          t_score += 100 * (di+1);
          solved_n++;
        }
      }

      res = min(res, solved_n);
    }
  }

  cout << res << endl;
}

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

Measured memory_bytes: 256
n,m=map(int,input().split())

if n==1 or m==1:
    if n==1 and m==1:
        print(1)
    elif n==1 and m!=1:
        print(m-2)
    elif n!=1 and m==1:
        print(n-2)
else:
    print((n-2)*(m-2))


Measured memory_bytes: 3060
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    string A,B,C; cin >> A >> B >> C;
    cout << ((A[A.size()-1] == B[0] && B[B.size()-1] == C[0]) ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;
 
class Main
{
	//  W <= 300
	private static
	char[] sh = "##############################################################################################################################################################################################################################################################################################################"
		.toCharArray();
	private static
	char[] dt = ".............................................................................................................................................................................................................................................................................................................."
		.toCharArray();
	private static 
	char[] nl = System.getProperty("line.separator").toCharArray();
    public static void main (String[] args) throws java.lang.Exception
    {
    	char[] sh = Main.sh;
    	char[] dt = Main.dt;
    	char[] nl = Main.nl;
        StringBuilder
            p = new StringBuilder(1000),
            k = new StringBuilder(100);
        Scanner r = new Scanner(System.in);
        int h, w;
        while (0 != ((h = r.nextInt()) | (w = r.nextInt()))) {
            p.append(sh, 0, w).append(nl);
            k.setLength(0);
            k.append('#').append(dt, 0, w - 2).append('#').append(nl);
            while (2 != h--) {
                p.append(k);
            }
            p.append(sh, 0, w).append(nl).append(nl);
        }
        System.out.print(p);
    }
}

Measured memory_bytes: 18368
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
static const ll mod=1000000007;
ll N,H,D;
ll dp[2][1000005];
ll fac[1000005];
int main(){
  cin>>N>>H>>D;
  fac[0]=1;ll sum=0;
  for(ll i=1;i<=N;i++){
    fac[i]=(fac[i-1]*i)%mod;
    sum=(sum+fac[i])%mod;
  }dp[1][0]=fac[N];
  for(ll i=1;i<H;i++){
  dp[1][i]=(sum*(dp[0][i-1]+dp[1][i-1]))%mod;
    dp[0][i]=(dp[0][i-1]+dp[1][i-1])%mod;
    if(0<=i-D)
      dp[0][i]=(dp[0][i]-dp[1][i-D]+mod)%mod;
  }ll ans=(dp[0][H-1]+dp[1][H-1])%mod;
  cout<<ans<<endl;
    
  return 0;
}

Measured memory_bytes: 27032
class UnionFind:
    def __init__(self, n=1):
        self.parent = [i for i in range(n)]
        self.rank = [0] * n
    
    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]
    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.parent[y] = x
    
    def is_same(self, x, y):
        return self.find(x) == self.find(y)


N, M = map(int, input().split())
A = list(map(int, input().split()))
uf = UnionFind(N)
for i in range(M):
  x, y = map(int, input().split())
  uf.union(x, y)

for i in range(N):
  uf.find(i)

par = [uf.find(i) for i in range(N)]
d = {}
for i, p in enumerate(par):
  if p in d:
    d[p].append(A[i])
  else:
    d[p] = [A[i]]

num = len(d)
if num == 1:
  print(0)
  quit()

a = []
ans = 0
for p in d:
  d[p].sort(reverse=True)
  ans += d[p].pop()
  a += d[p]

a.sort()
n = 2*(N - M - 1) - num
if len(a) < n:
  print('Impossible')
else:
  print(sum(a[:n]) + ans)

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

double n;
int a[4] = {};
double e[310][310][310] = {};
double f(double i, double j, double k) {
    int s = i, t = j, u = k;
    if (s + t + u == 0)
        return 0.0;
    if (e[s][t][u] != 0.0)
        return e[s][t][u];
    e[s][t][u] = 1.0;
    if (i)
        e[s][t][u] += f(i - 1, j, k) * i / n;
    if (j)
        e[s][t][u] += f(i + 1, j - 1, k) * j / n;
    if (k)
        e[s][t][u] += f(i, j + 1, k - 1) * k / n;
    if (i + j + k)
        e[s][t][u] /= (i + j + k) / n;
    return e[s][t][u];
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cin >> n;
    rep(i, 0, (int)n) {
        int d;
        cin >> d;
        a[d]++;
    }

    cout << f(a[1], a[2], a[3]) << endl;
    return 0;
}


Measured memory_bytes: 225536
#include <iostream>

using namespace std;

int main() {
    string S;
    cin >> S;
    int ans = 0;
    int cnt = 0;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] == 'A' || S[i] == 'T' || S[i] == 'G' || S[i] == 'C') {
            cnt++;
            if (ans < cnt) {
                ans = cnt;
            }
        } else {
            cnt = 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
const ll MOD = (ll)1e9+7;
const int INF = (ll)2e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

int main(){
	int n, m;
	cin >> n >> m;
	vvector<int> roads(n+1);
	vvector<int> rev(n+1);
	int parent = -1;
	for(int i=1;i<=m;++i){
		int a, b;
		cin >> a >> b;
		roads[a].push_back(b);
		rev[b].push_back(a);
	}
	function<vector<int>(int)> func = [&](int start){
		vector<int> fast(n+1, INF);
		queue<int> que;
		fast[start] = 0;
		que.push(start);
		while(que.size()){
			int d = que.front();
			que.pop();
			foreach(i, roads[d]){
				int nt = fast[d] + 1;
				if(fast[i] > nt){
					fast[i] = nt;
					if(i!=start)
						que.push(i);
				}
			}
			if(d==start)fast[start] = INF;
		}
		if(fast[start]==INF)return vector<int>(0);
		int np = start;
		vector<int> res;
		while(true){
			res.push_back(np);
			foreach(i, rev[np]){
				if(i==start)return res;
				if(fast[i]<fast[np]){
					np = i;
					break;
				}
			}
		}
	};
	vector<int> ans;
	for(int i=1;i<=n;++i){
		vector<int> d = func(i);
		if(ans.size()==0||d.size()>0&&ans.size()>d.size()){
			ans = d;
		}
	}
	if(ans.size()){
		cout << ans.size() << endl;
		foreach(i, ans)cout << i << endl;
	}else{
		cout << -1 << endl;
	}

	return 0;
}


Measured memory_bytes: 512
# coding: utf-8

LIMIT = 999999

prime = [0, 1] + [0 if i % 2 == 0 else 1 for i in range(3, LIMIT + 1)]

for i in range(3, int(LIMIT ** 0.5) + 1):
    if prime[i - 1]:
        for j in range(i ** 2, LIMIT + 1, i):
            prime[j - 1] = 0

while True:
    try:
        n = int(input())
    except EOFError:
        break

    print(sum(prime[:n]))


Measured memory_bytes: 21248
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<queue>
#define _USE_MATH_DEFINES
#include<math.h>
#include<cmath>
#include<ctime>
#include<map>
#include<typeinfo>
#define R(i, n) for(int i = 0;i < n; i++)
#define R1(i, n) for(int i = 1; i <= n; i++)
#define S(a) scanf("%d", &a)
#define S2(a, b) scanf("%d%d", &a, &b)
#define S3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define SL(a) scanf("%lld", &a)
#define SL2(a, b) scanf("%lld%lld", &a, &b)
#define SL3(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
#define SC(a) scanf("%c", &a)
#define P(a) printf("%d", a)
#define PL(a) printf("%lld", a)
#define PY printf("YES")
#define PN printf("NO")
#define Py printf("Yes")
#define Pn printf("No")
using namespace std;
using ll = long long;
using PR = pair<int, int>;
const ll MOD = 1e+9 + 7;
const int INF = 1e+9;
const double PI = acos(-1);

int main() {
	ll a, b , x;
	SL3(a, b, x);
	if (a == 0 && b == 0) P(1);
	else if (a == 0) PL(b / x + 1);
	else PL(b / x - (a - 1) / x);
}

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

int main()
{
  string S;
  cin >> S;
  
  if(S == "ABC")
  {
    cout << "ARC" << endl;
  }
  
  if(S == "ARC")
  {
    cout << "ABC" << endl;
  }
  return 0;
}


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

const int INF = (1<<30);

vector<int> g[225816],q[2];
int dist[225816];
bool done[225816],memo[225816];

bool solve(int r){
	if(done[r]){
		return memo[r];
	}
	done[r] = true;
	if(r==0){
		memo[r] = true;
	}else if(r==1){
		memo[r] = false;
	}else{
		memo[r] = (!(solve(r-1)&&solve(r-2)));
	}
	return memo[r];
}

int main(void){
	int N,a,b,i,j,k;
	cin >> N;
	for(i=1; i<N; ++i){
		cin >> a >> b;
		--a; --b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	a = 0;
	for(k=0; k<2; ++k){
		fill(dist,dist+N,INF);
		q[k].push_back(a);
		dist[a] = 0;
		for(i=0; i<q[k].size(); ++i){
			a = q[k][i];
			for(j=0; j<g[a].size(); ++j){
				b = g[a][j];
				if(dist[b] > dist[a]+1){
					dist[b] = dist[a]+1;
					q[k].push_back(b);
				}
			}
		}
	}
	cout << ((solve(dist[a]))?"First":"Second") << endl;
	return 0;
}


Measured memory_bytes: 20856
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int N;
  cin>>N;
  vector<int> A(N),B(N),C(N,10000000000);
  vector<bool> D(N,true);
  for(int &i:A)
    cin>>i;
  for(int &i:B)
    cin>>i;
  C[0]=A[0],C[N-1]=B[N-1];
  D[0]=false,D[N-1]=false;
  int mx=A[0];
  for(int i=1;i<N;i++){
    mx=max(mx,A[i]);
    if(A[i-1]!=A[i])
      D[i]=false;
    C[i]=min(mx,C[i]);
  }
  mx=B[N-1];
  for(int i=N-2;i>=0;i--){
    mx=max(mx,B[i]);
    if(B[i+1]!=B[i])
      D[i]=false;
    C[i]=min(mx,C[i]);
  }
  mx=C[0];
  for(int i=0;i<N;i++){
    if(!D[i])
      mx=max(mx,C[i]);
    if(mx!=A[i]){
      puts("0");
      return 0;
    }
  }
  mx=C[N-1];
  for(int i=N-1;i>=0;i--){
    if(!D[i])
      mx=max(mx,C[i]);
    if(mx!=B[i]){
      puts("0");
      return 0;
    }
  }
  int ans=1;
  for(int i=0;i<N;i++)
    if(D[i])
      ans=ans*C[i]%1000000007;
  cout<<ans<<endl;
}

Measured memory_bytes: 5644
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<stdio.h>
using namespace std;

int main() {
	int n;
	cin >> n;
	cout << 3*n*n << endl;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto &it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vl vector<long>
#define P pair<int,int>
using namespace std;

main()
{
        int k; cin>>k;
        if(k%2==0)cout<<pow(k/2,2)<<endl;
        else cout<<(k/2)*(k/2+1)<<endl;
}


Measured memory_bytes: 256
#include <cmath>
#include <map>
#include<fstream>
#include<algorithm>
#include <iostream>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
#include <cassert>
#include <stack>
#include <ctime>
#include <vector>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <string>
#include <ctime>
#include <queue>
#include <vector>
#include <iterator>
#include <math.h>
#include<cstring>
#include <cmath>
#include <sstream>
#include<cstring>
#include<cstdlib>
#include <set>
#include <cstdio>
#include<map>
#define all(v)              ((v).begin()), ((v).end())
#define sz(v)               ((int)((v).size()))
#define REP(i, v)       for(int i=0;i<sz(v);i++)
#define dbg(a) cerr << #a << ": " << (a) << endl
#define ll long long
#define endl "\n"
#define getBit(num,idx) ((num >> idx) & 1)
#define setBit(num,idx) num|((1 << idx))
using namespace std;
typedef vector<vector<int> > vvi;
typedef vector<int> vi;


int main()
{
	int n;

	scanf("%d",&n);
    vector<int> v;
    v.resize(2*n);
    for(int i = 0 ; i < 2*n ; i++)
    {
    	scanf("%d",&v[i]);
    }
    sort(all(v));
    bool taken[501];
    memset(taken,0,sizeof(taken));
    int res = 0;
    for(int i = 0 ; i < (2*n) - 1  ; i ++)
    {

    	if(taken[i]) continue;
    	res += v[i];
    	taken[i] = 1;
    	taken[i+1] = 1;
    }
    printf("%d",res);
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
d = 0
for i in range(n - 1):
    if a[i] + 1 == a[i + 1]:
        d += c[a[i] - 1]
print(d + sum(b))

Measured memory_bytes: 9196
import math

n = int(input())
a = []
for i in range(n):
	array = list(map(int, input().split()))
	a.append(array)
	
c = 0

for i in range(n):
	for ii in range(n):
		c += math.sqrt((a[i][0] -a[ii][0])**2 + (a[i][1] -a[ii][1])**2 )

d = c / n

print(d)


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

int compare_int(const void *a, const void *b)
{
    return *(int*)b - *(int*)a;
}

int main()
{
  int n;
  int a[200000] = {};
  int b[200000] = {};

  scanf("%d", &n);

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

  qsort(a, 200000, sizeof(int), compare_int);

  int ler = a[n/2 - 1];
  int mini = a[n/2];

  for(int i = 0; i < n; i++){
    if(b[i] < ler){
      printf("%d\n", ler);
    }else{
      printf("%d\n", mini);
    }
  }

  return 0;
 }

Measured memory_bytes: 3704
#include<stdio.h>
#define min(a,b) ((a)<(b)?(a):(b))
int main(void){
    int n,i;
    int x,y,b,p;
    int ans;

    scanf("%d",&n);
    for(i=0;i<n;i++){
	scanf("%d%d%d%d",&x,&y,&b,&p);
	if(b>=5 && p>=2) ans=0.8*(x*b+y*p);
	else if(b<5 && p>=2) ans=min(x*b+y*p,0.8*(x*5+y*p));
	else if(b>=5 && p<2) ans=min(x*b+y*p,0.8*(x*b+y*2));
	else ans=min(x*b+y*p,0.8*(x*5+y*2));
	printf("%d\n",ans);
    }

    return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> ans(n,0);
    rep(i, n){
        int a;
        cin >> a;
        ans.at(a-1)=i+1;
    }

    rep(i, n-1){
        cout << ans.at(i) << ' ';
    }
    cout << ans.at(n-1) << endl;

    return 0;
}

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

using namespace std;

int main() {
    string S;
    cin >> S;
    int ans1 = -1;
    int ans2 = -1;
    for (int i=0; i<S.length()-1; i++) {
        if (S[i]==S[i+1]) {
            ans1 = i+1;
            ans2 = i+2;
        }
    }
    for (int i=0; i<S.length()-2; i++) {
        if (S[i]==S[i+2]) {
            ans1 = i+1;
            ans2 = i+3;
        }
    }
    cout << ans1 << " " << ans2 << endl;
}

Measured memory_bytes: 512
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	D
# CreatedDate:  2020-09-13 21:21:42 +0900
# LastModified: 2020-09-14 01:25:53 +0900
#


import os
import sys
import math
# import numpy as np
# import pandas as pd


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


def main():
    amari = 1000000007
    S = int(input())
    i = 1
    ans = 0
    while S / i >= 3:
        if i == 1:
            ans += 1
            i += 1
        else:
            ans += combinations_count(S - 3*i+i-1, i-1)
            ans = ans % amari
            i += 1
    print(ans)
            





if __name__ == "__main__":
    main()


Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+10;
ll a[N], b[N], c[N];
int main()
{
    ll n;
    cin >> n;
    for(ll i=1; i<=n+1; i++)
    {
        cin >> a[i];
    }
    for(ll i=1; i<=n; i++)
    {
        cin >> b[i];
    }
    ll sum = 0;
    for(ll i=1; i<=n; i++)
    {
        ll x = min(a[i], b[i]);
        sum += x;
        b[i] -= x;
        ll y = min(a[i+1], b[i]);
        sum += y;
        a[i+1] -= y;
    }
    cout << sum << endl;
    return 0;
}


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


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


Measured memory_bytes: 256
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//                       _oo0oo_                         //
//                      o8888888o                        //
//                      88" . "88      ------ hzt1       //
//                      (| -_- |)                        //
//                      0\  =  /0                        //
//                    ___/`---'\___                      //
//                  .' \|     |// '.                     //
//                 / \|||  :  |||// \                    //
//                / _||||| -:- |||||- \                  //
//               |   | \  -  /// |     |                 //
//               | \_|  ''\---/''  |_/ |                 //
//               \  .-\__  '-'  ___/-. /                 //
//             ___'. .'  /--.--\  `. .'___               //
//          ."" '<  `.___\_<|>_/___.' >' "".             //
//         | | :  `- \`.;`\ _ /`;.`/ - ` : | |           //
//         \  \ `_.   \_ __\ /__ _/   .-` /  /           //
//     =====`-.____`.___ \_____/___.-`___.-'=====        //
//                       `=---='                         //
//                                                       //
//                                                       //
//     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~       //
//                                                       //
//                 God-He Bless All.                     //
//           This Code Will Never Explode.               //
//                                                       //
//                                                       //
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
#include<cstdio>
#include<cstring>
#include<cctype>
#include<bitset>
#include<algorithm>
#include<vector>
#define pb push_back
#define mp make_pair
#define xx first
#define yy second
#define rep(i,a,b) for(int i=(a),i##_end_=(b);i<=i##_end_;i++)
#define dwn(i,a,b) for(int i=(a),i##_end_=(b);i>=i##_end_;i--)
using namespace std;
const int Size=1<<16;
char buffer[Size],*head,*tail;
inline char Getchar() {
    if(head==tail) {
        int l=fread(buffer,1,Size,stdin);
        tail=(head=buffer)+l;
    }
    if(head==tail) return -1;
    return *head++;
}
inline int read() {
    int x=0,f=1;char c=Getchar();
    for(;!isdigit(c);c=Getchar()) if(c=='-') f=-1;
    for(;isdigit(c);c=Getchar()) x=x*10+c-'0';
    return x*f;
}
typedef long long ll;
typedef pair<int,int> pii;
const int maxn=410;
const int maxm=100010;
int n,m,u[maxm],v[maxm],len[maxn];
bitset<maxn>S[maxn];
int main() {
	n=read();m=read();
	rep(i,1,m) u[i]=read(),v[i]=read();
	rep(i,1,n) {
		S[i][i]=1;
		dwn(j,m,1) {
			int x=u[j],y=v[j];
			if(S[i][x]&&S[i][y]) {S[i]=0;break;}
			else if((!S[i][x])&&(!S[i][y])) continue;
			else if(S[i][x]) S[i][y]=1;
			else S[i][x]=1;
		}
		len[i]=S[i].count();
	}
	int ans=0;
	rep(i,1,n) if(len[i]) {
		rep(j,i+1,n) if(len[j]) {
			if(!(S[i]&S[j]).count()) ans++;
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1024
a, b, c, d = map(int,input().split())
 
while a > 0 and c > 0:
  if c > 0:
    c = c - b
    if 0 >= c:
      print("Yes")
      exit()
    if a > 0:
      a = a - d
      if 0>= a:
        print("No")   

Measured memory_bytes: 9044
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <array>
#include <cmath>
#include <queue>
#include <stack>
#include <numeric>

using namespace std;


int main() {
	double n,cnt=0;
	cin >> n;

	for (int i = 0; i < n; i++) {
		if (i % 2 == 0) {
			cnt++;
		}
	}
	double ans = cnt / n;

	cout << ans;
}

Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define pb                      push_back
#define MOD                     1000000007
#define inf                     3e18
#define ld                      long double
//#define mp                      make_pair
#define vpll                    vector<pair<ll,ll>>
#define sll                     set<ll>
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define umcl                    um<char,ll>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define test                    ll Testcases;cin>>Testcases;while(Testcases--)
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

void inp_out()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
    #endif
}

int main()
{
	fastIO
	//inp_out();
	ll k,n;
	cin>>k>>n;
	vll a(n+1);

	for(ll i=1;i<=n;++i)
	{
		cin>>a[i];
	}

	a[0]=a[n];

	ll ans=inf;

	for(ll i=1;i<=n;++i)
	{
		ans=min(ans,(a[i-1]-a[i]+k)%k);
	//	db(ans);
	}

	cout<<ans;

	return 0;
}

Measured memory_bytes: 1792
W, H, N = map(int, input().split())
l, t, r, b = 0, 0, W, H
for _ in range(N):
  x, y, a = map(int, input().split())
  if a == 1: l = min(max(l, x), r)
  if a == 2: r = max(min(r, x), l)
  if a == 3: t = min(max(t, y), b)
  if a == 4: b = max(min(b, y), t)

print((r-l)*(b-t))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define X first
#define Y second
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;

inline P operator+(const P &a, const P &b) { return P(a.X+b.X,a.Y+b.Y);}
inline P operator-(const P &a, const P &b) { return P(a.X-b.X,a.Y-b.Y);}
inline LL dot  (P a, P b){return a.X*b.X+a.Y*b.Y;}
inline LL cross(P a, P b){return a.X*b.Y-a.Y*b.X;}

vector<LL> convex(vector<P> v){
	int n = v.size(), k = 0;
	vector<LL> area(n+1,0);
	vector<P> a(n);
	FOR(i,n){
		area[i+1] = area[i];
		while(k>1 && cross(a[k-1]-a[k-2], v[i]-a[k-1]) < 0){
			if(k >= 3) area[i+1] -= cross(a[k-2]-a[0], a[k-1]-a[0]);
			k--;
		}
		a[k++] = v[i];
		if(k >= 3) area[i+1] += cross(a[k-2]-a[0], a[k-1]-a[0]);
	}

	//for(auto i:area)cout<<i<<endl;

	return area;
}

vector<LL>CH[4];

int main(){
	int n;
	scanf("%d",&n);
	vector<P>p(n);
	FOR(i,n)scanf("%lld%lld",&p[i].X,&p[i].Y);

	sort(p.begin(),p.end());
	CH[0] = convex(p);
	FOR(i,n) p[i].Y *= -1;
	CH[2] = convex(p);
	FOR(i,n) p[i].X *= -1;
	sort(p.begin(),p.end());
	CH[3] = convex(p);
	FOR(i,n) p[i].Y *= -1;
	CH[1] = convex(p);
	FOR(i,n) p[i].X *= -1;
	sort(p.begin(),p.end());

	LL ans = CH[0][n] + CH[2][n] + CH[1][0] + CH[3][0];
	for(int i=1;i<n;i++)
		if(p[i].X!=p[i-1].X)
			ans = min(ans, CH[0][i] + CH[2][i] + CH[1][n-i] + CH[3][n-i]);
	printf("%lld\n",ans+1>>1);
	return 0;
}

Measured memory_bytes: 10556
#include <stdio.h>

static const int N=100;

int min(int a, int b){
  //return a<b?a:b;
  if(a<b) return a;
  else return b;
}

int main(){
  int n, p[N+1], m[N+1][N+1], i, j, k, l;

  scanf("%d", &n);

  for(i=1; i<=n; i++) scanf("%d%d", &p[i-1], &p[i]);

  for(i=1; i<=n; i++) m[i][i]=0;

  for(l=2; l<=n; l++){
    for(i=1; i<=n-l+1; i++){
      j = i+l-1;
      m[i][j] = (1<<21);
      for(k=i; k<=j-1; k++) m[i][j]=min(m[i][j], m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
    }
  }

  printf("%d\n", m[1][n]);
  
  return 0;
}



Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll dp[2001][2001];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	#ifndef ONLINE_JUDGE
	    // for getting input from input.txt
	    freopen("input.txt", "r", stdin);
	    // for writing output to output.txt
	    freopen("output.txt", "w", stdout);
	#endif
	    ll n;
	    cin>>n;
	    ll a[n+1];
	    vector<pair<ll,ll>>v;
	    for(ll i=1;i<=n;i++)
	    {	
	    	cin>>a[i];
	    	v.push_back(make_pair(a[i],i));
	    }
	    sort(v.begin(),v.end());
	    reverse(v.begin(),v.end());
	    for(ll i=1;i<=n;i++)
	    {
	    	//cout<<v[i-1].first<<" "<<v[i-1].second<<endl;
	    	dp[i][0]=dp[i-1][0]+(v[i-1].first)*(abs(v[i-1].second-i));
	    	dp[0][i]=dp[0][i-1]+(v[i-1].first)*(abs(v[i-1].second-(n-i+1)));
	    	for(ll j=1;j<i;j++)
	    	{
	    		dp[i-j][j]=max(dp[i-j-1][j]+v[i-1].first*abs(v[i-1].second-(i-j)),dp[i-j][j-1]+v[i-1].first*abs(v[i-1].second-(n-j+1)));
	    	}
	    }
	    //cout<<dp[1][0]<<endl;
	    //cout<<dp[1][1]<<endl;
	    ll maxi=0;
	    //cout<<dp[n][0]<<endl;
	    //cout<<dp[0][n]<<endl;
	    for(ll j=0;j<=n;j++)
	    {
	    	//cout<<dp[n-j][j]<<endl;
	    	maxi=max(maxi,dp[n-j][j]);
	    }
	    cout<<maxi;
}

Measured memory_bytes: 26256
import java.util.*;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n, m, x;
    n = sc.nextInt();
    m = sc.nextInt();
    x = sc.nextInt();

    int start = 0;
    int fin = 0;
    for (int i = 0; i < m; i++) {
      int num = sc.nextInt();
      if (num < x) {
        start++;
      } else if (num > x) {
        fin++;
      }
    }
    System.out.println(Math.min(start, fin));
  }
}


Measured memory_bytes: 20948
#include<bits/stdc++.h>
using namespace std;
#define EPS 1e-14
int stringintoint(string s){
	int res=0;
	int X=1;
	for(int i=(int)s.length()-1;i>=0;i--){
		res+=(s[i]-'0')*X;
		X*=10;
	}
	return res;
}
int main()
{
	while(true){
		int M,N;
		scanf("%d%d",&M,&N);
		if(M==0&&N==0)break;
		vector<int>ans;
		for(int i=0;i<M;i++)ans.push_back(i);
		int x=0;
		for(int i=1;i<=N;i++){
			string S;
			cin >> S;
			if(i%15==0){
				if(S!="FizzBuzz"){
					ans.erase(ans.begin()+x);
					x--;
				}
				x++;
			}
			else if(i%3==0){
				if(S!="Fizz"){
					ans.erase(ans.begin()+x);
					x--;
				}
				x++;
			}
			else if(i%5==0){
				if(S!="Buzz"){
					ans.erase(ans.begin()+x);
					x--;
				}
				x++;
			}
			else{
				if(stringintoint(S)!=i){
					ans.erase(ans.begin()+x);
					x--;
				}
				x++;
			}
			if(x>=(int)ans.size()){
				x=0;
			}
		}
		
		printf("%d",ans[0]+1);
		for(int i=1;i<(int)ans.size();i++){
			printf(" %d",ans[i]+1);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1296
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; i++)
#define all(a) (a).begin(), (a).end()

int p;
int MOD;

struct mint {
  long long val;
  mint(long long v = 0) noexcept : val(v % MOD) {
    if (val < 0) v += MOD;
  }
  int getmod() { return MOD; }
  mint operator - () const noexcept {
    return val ? MOD - val : 0;
  }
  mint operator + (const mint& r) const noexcept { return mint(*this) += r; }
  mint operator - (const mint& r) const noexcept { return mint(*this) -= r; }
  mint operator * (const mint& r) const noexcept { return mint(*this) *= r; }
  mint operator / (const mint& r) const noexcept { return mint(*this) /= r; }
  mint& operator += (const mint& r) noexcept {
    val += r.val;
    if (val >= MOD) val -= MOD;
    if (val < 0) val += MOD;
    return *this;
  }
  mint& operator -= (const mint& r) noexcept {
    val -= r.val;
    if (val >= MOD) val -= MOD;
    if (val < 0) val += MOD;
    return *this;
  }
  mint& operator *= (const mint& r) noexcept {
    val = val * r.val % MOD;
    return *this;
  }
  mint& operator /= (const mint& r) noexcept {
    long long a = r.val, b = MOD, u = 1, v = 0;
    while (b) {
      long long t = a / b;
      a -= t * b; swap(a, b);
      u -= t * v; swap(u, v);
    }
    val = val * u % MOD;
    if (val < 0) val += MOD;
    return *this;
  }
  bool operator == (const mint& r) const noexcept {
    return this->val == r.val;
  }
  bool operator != (const mint& r) const noexcept {
    return this->val != r.val;
  }
  friend ostream& operator << (ostream &os, const mint& x) noexcept {
    return os << x.val;
  }
  friend istream& operator >> (istream &is, mint& x) noexcept {
    return is >> x.val;
  }
  friend mint modpow(const mint &a, long long n) noexcept {
    if (n == 0) return 1;
    auto t = modpow(a, n / 2);
    t = t * t;
    if (n & 1) t = t * a;
    return t;
  }
  friend mint modinv(const mint &a) noexcept {
    return modpow(a, MOD - 2);
  }
};

int main () {
  cin >> p;
  MOD = p;

  vector<mint> b(p, 0);
  int a;

  vector<mint> fact(p), ifact(p);
  fact[0] = 1;
  rep(i,p) {
    if(i + 1 < p) fact[i+1] = fact[i] * (i+1);
    ifact[i] = modinv(fact[i]);
  }

  rep(i,p) {
    cin >> a;
    if(a) {
      b[0] += 1;
      mint k = 1;
      for(int j = p-1; j >= 0; --j) {
        b[j] -= fact[p-1] * ifact[p-1-j] * ifact[j] * k;
        k *= -i;
      }
    }
  }

  rep(i,p) {
    if(i != 0) cout << " ";
    cout << b[i];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

int main(){
	int x, a, b, d1, d2;
	
	scanf("%d %d %d", &x, &a, &b);

	if(a>x)
		d1 = a-x;
	else 
		d1 = x-a;
	
	if(b>x)
		d2 = b-x;
	else
	 	d2 = x-b;
	 	
	if(d1>d2)
		printf("B");
	else
		printf("A");
	
	return 0;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1000000007;
const int INF = 1e+9;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

const int MAX_N = 110000;

int dp[MAX_N];

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

  for ( int i = 0; i < MAX_N; i++) dp[i] = N;
  dp[0] = 0;

  for (int n = 1; n < MAX_N; n++) {
    for (int pow6 = 1; pow6 <= n; pow6 *= 6) {
      dp[n] = min(dp[n], dp[n-pow6]+1);
    }
    for (int pow9 = 1; pow9 <= n; pow9 *= 9) {
      dp[n] = min(dp[n], dp[n-pow9]+1);
    }
  }

  cout << dp[N] << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <unordered_map>
#include <vector>
#include <set>
#include <string.h>
#include <algorithm>
#define mod 1000000007
#define inf 1LL<<61
#define ll long long
#define pr pair<int,int>
#define all vec.begin(),vec.end()
#define REP(i,a,b) for (int i = a; i < b; i++)
#define fi first
#define se second
#define pushb push_back
#define makep make_pair

using namespace std;

int main(){
	string a;
	cin >> a;
	int arr[26];
	memset(arr, 0, sizeof(arr)); 
	REP(i,0,a.size()){
		arr[a[i] - 'a'] = arr[a[i] - 'a'] + 1;
		if(arr[a[i] - 'a'] > 1){
			cout << "no"; return 0;
		}
	}
	cout << "yes";

	
	return 0;
}



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

#define sz(x) int(x.size())
#define pii pair<int, int>
#define Task "abc"
#define For(i, a, b) for(int i = (a), _b = (b); i <= b; ++i)
#define Debug(X) cout << #X << " = " << X << '\n'
#define All(x) (x).begin(), (x).end()
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;

const int maxn = 1e5 + 10;
const int inf = 0x3f3f3f3f;

char s[maxn], s1[maxn], s2[maxn];

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
//  freopen(Task".inp", "r", stdin);
    cin >> s;
    int n = strlen(s);
    for (int i = 0; i < n; ++i){
      s1[i] = (i % 2 ? '1' : '0');
      s2[i] = (i % 2 ? '0' : '1');
    }
    int cnt1 = 0, cnt2 = 0;
    for (int i = 0; i < n; ++i){
      cnt1 += (s[i] != s1[i]);
      cnt2 += (s[i] != s2[i]);
    }
    cout << min(cnt1, cnt2) << '\n';
return 0;
}



Measured memory_bytes: 512
// https://atcoder.jp/contests/abc175/tasks/abc175_c
#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()
#define CEIL(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int X, K, D;
    cin >> X >> K >> D;
    int ans = 0;
    if (K >= abs(X) / D) {
        int a = abs(X);
        int cnt = 0;
        while (a > 0) {
            a -= D;
            cnt++;
        }
        if ((K - cnt) % 2 == 0) {
            ans = min(abs(a), abs(a + D * 2));
        } else {
            ans = min(abs(a + D), abs(a - D));
        }
    } else {
        ans = abs(X) - K * D;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
typedef long long ll;

#define pll pair<ll,ll>
#define ff first
#define snd second
#define pb push_back
#define vll vector<ll>
#define vpll vector<pll>
#define endl "\n"
#define MOD 1000000007
using namespace std;

ll const N = 1e5+1;


void solve()
{
   ll L;
   cin>>L;
   double k = double(L)/3.0;
   double ans = pow(k,3);
   cout<<std::setprecision(12)<<std::fixed;
   cout<<ans;
}
 
int main() {
            ios_base::sync_with_stdio(false);
            cin.tie(NULL);
	    int t=1;
	    //cin>>t;
	    while(t--)
	    {
	            solve();
	    }
	    return 0;
}

Measured memory_bytes: 256
char M[7][7][7],m[7][7][7];A,a[99],B,b[99],T;
main(n,s,i,j,k,I,J,K){for(;scanf("%d",&n),n;){
	if(T)puts("");
	for(i=1;i<6;i++)for(j=1;j<6;j++)for(scanf("%s",M[i][j]+1),k=1;k<6;k++)M[i][j][k]-='0';
	for(scanf("%d",&A),i=0;i<A;i++)scanf("%d",a+i);
	for(scanf("%d",&B),i=0;i<B;i++)scanf("%d",b+i);
	for(;n--;memcpy(M,m,sizeof(M))){
		for(i=1;i<6;i++)for(j=1;j<6;j++)for(k=1;k<6;k++){
			m[i][j][k]=M[i][j][k];
			for(s=0,I=-1;I<2;I++)for(J=-1;J<2;J++)for(K=-1;K<2;K++)if((I||J||K)&&M[i+I][j+J][k+K])s++;
			if(m[i][j][k]){
				for(I=0;I<B;I++)if(s==b[I])break;
				if(I==B)m[i][j][k]=0;
			}else{
				for(I=0;I<A;I++)if(s==a[I])break;
				if(I<A)m[i][j][k]=1;
			}
		}
	}
	printf("Case %d:\n",++T);
	for(i=1;i<6;printf(i<5?"\n":""),i++)for(j=1;j<6;puts(""),j++)for(k=1;k<6;k++)putchar(M[i][j][k]+'0');
}exit(0);}

Measured memory_bytes: 616
n = int(input())
a = [int(i) for i in input().split()]
mod = 10 ** 9 + 7
ans = 0
i = 1
for _ in range(60):
    b = 0
    c = 0
    for j in a:
        if j & i != 0:
            b += 1
        else:
            c += 1
    ans += b * c * i % mod
    i *= 2
print(ans%mod)

Measured memory_bytes: 122808
N = str(input())
if N[len(N)-1] == "0" or N[len(N)-1] == "1" or N[len(N)-1] == "6" or N[len(N)-1] == "8":
  print("pon")
elif N[len(N)-1] == "3":
  print("bon")
else:
  print("hon")

Measured memory_bytes: 61620
#include <bits/stdc++.h>
using namespace std;
#define MIN INT_MIN
#define MAX INT_MAX
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define E "\n"
#define frep(i,j,k,inc) for(int i=j;i<k;i+=inc)
#define rrep(i,j,k,dec) for(int i=j;i>k;i-=dec)
#define arep(elm,obj) for(auto elm:obj)
#define all(x) x.begin(),x.end()
#define revT greater<int>()
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int>pii;
const ll mod=1000000007;
void solve();
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
//    int t;
//    cin>>t;
//    while(t--)
    	solve();

    return 0; 
}

int mima(vi vec,int f){
	int mi=vec[0],ma=vec[0];
	frep(i,1,vec.size(),1){
		mi=min(mi,vec[i]);
		ma=max(ma,vec[i]);
	}
	if(f){return ma;}
	else{return mi;}
}


void solve(){
	int n;
	cin>>n;
	if(n%1000 ==0){cout<<0<<E;}
	else{
		cout<<((n/1000)+1)*1000-n<<E;
	}
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;


int main(){
    ll n;
    ll cnt=0;
    cin>>n;
    REP(i, 0, n){
        ll a;
        cin>>a;
        if(a%2==0) cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 3124
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        string[] str = Console.ReadLine().Split(' ');
        int N = int.Parse(str[0]);
        int M = int.Parse(str[1]);
        int[] f = new int[M];
        int[] t = new int[M];
        long[] c = new long[M];
        for(int i=0;i<M;i++){
            str = Console.ReadLine().Split(' ');
            f[i] = int.Parse(str[0]) - 1;
            t[i] = int.Parse(str[1]) - 1;
            c[i] = int.Parse(str[2]);
        }
        BellmanFord B = new BellmanFord(f,t,c,N,0,100000000000000,N-1);
        if(B.NegativeCycle()){
            sb.Append("inf\n");
        }
        else{
            sb.Append(B.GetCost(N-1)+"\n");
        }
    }
}
class BellmanFord{
    bool NEGATIVECYCLE;
    long[] cost;
    public BellmanFord(int[] f,int[] t,long[] c,int n,int s,long INF,int G){
        cost = new long[n];
        int e = f.Length;
        for(int i=0;i<n;i++){
            cost[i] = -INF;
        }
        cost[s] = 0;
        for(int i=0;i<n-1;i++){
            for(int j=0;j<e;j++){
                if(cost[f[j]] != -INF){
                    cost[t[j]] = Math.Max(cost[t[j]],cost[f[j]]+c[j]);
                }
            }
        }
        long GC = cost[G];
        for(int i=0;i<n;i++){
            for(int j=0;j<e;j++){
                if(cost[f[j]] != -INF){
                    cost[t[j]] = Math.Max(cost[t[j]],cost[f[j]]+c[j]);
                }
            }
        }
        NEGATIVECYCLE = cost[G] != GC;
    }
    public bool NegativeCycle(){
        return NEGATIVECYCLE;
    }
    public long GetCost(int v){
        return cost[v];
    }
}

Measured memory_bytes: 13268
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	//          0  1  2  3  4  5  6  7  8  9  10 11 12
	int a[] = { 0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1 };
	int x, y;
	cin >> x >> y;
	if (a[x] == a[y]) cout << "Yes" << endl;
	else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))

if all(v>=0 for v in A):
    print(N-1)
    for i in range(1,N):
        print(i,i+1)
elif all(v<0 for v in A):
    print(N-1)
    for i in reversed(range(1,N)):
        print(i+1,i)
else:
    max_ind=A.index(max(A))+1
    min_ind = A.index(min(A))+1
    if abs(max(A))>=abs(min(A)):
        print(2*N-1)
        for i in range(1,N+1):
            print(max_ind,i)
        for i in range(1,N):
            print(i,i+1)
    else:
        print(2*N-1)
        for i in range(1,N+1):
            print(min_ind,i)
        for i in reversed(range(1,N)):
            print(i+1,i)



Measured memory_bytes: 3064