akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

long long arr[200000];
long long sum[200001];

constexpr long long K = 1000000007;

int main(void) {
  ios_base::sync_with_stdio(false);

  int n;
  cin >> n;

  for (auto i = 0; i < n; i++) {
    cin >> arr[i];
  }

  for (auto i = 0; i < n; i++) {
    sum[i + 1] = sum[i] + arr[i];
  }

  auto result = 0LL;
  for (auto i = 0; i < n; i++) {
    result += arr[i] * ((sum[n] - sum[i + 1]) % K) % K;
    result %= K;
  }

  cout << result << '\n';

  return 0;
}


Measured memory_bytes: 6272
N = int(input())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    # divisors.sort()
    return divisors
ans = 0
divisors = make_divisors(N)

for d in divisors:
    m = (d - 1)
    if m and (N//m == N % m):
        ans += m
print(ans)

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


int main(){
	int n,a;
	int k[101];
	string s,moji = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
	char c;
	while(1){
		cin >> n;
		if(n == 0)break;
		for(int i = 0;i < n;i++){
			cin >> k[i];
		}
		cin >> s;
		for(int i = 0;i < s.size();i++){
			c =  s[i];
			for(int j = 0;j < moji.size();j++){
				if(c == moji[j]){
					a = j - k[i%n];
					if(a < 0)a+=52;
					cout << moji[a];
					break;
				}
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  int i;int sum=0;
  cin>>s;
  for(i=0;i<4;i++){
    if(s[i]==s[i+1])sum++;
  }
  if(sum==0)cout<<"Good"<<endl;
  else if(sum>=1)cout<<"Bad"<<endl;
  return 0;
}

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

bool f(int n){
	int a=0;
	while (n){
		++a;
		n /= 10;
	}
	if (a%2 == 0) return false;
	return true;
}

int main(){
	int n,cnt=0;
	cin >> n;
	for (int i=1; i<=n; ++i){
		if (f(i)) ++cnt;
	}
	cout  << cnt;
}


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

// using namespace std;

// const int T = 100;

// int main() {
// 	int n, m;
// 	cin >> n >> m;
	
// 	int sum = 0;
// 	vector<int> t(n), count(T + 1, 0);
// 	for (int i = 0; i < n; i++) {
// 		cin >> t[i];
// 	}
	
// 	for (int i = 0; i < n; i++) {
// 		int d = sum + t[i] - m, k = 0;
//         cout<<d<<" "<<sum<<"    ";
// 		if (d > 0) {
// 		    for (int j = T; j > 0; j--) {
// 				int x = j * count[j];
// 				if (d <= x) {
// 					k += (d + j - 1) / j;
// 					break;
// 				}
// 				k += count[j];
// 				d -= x;
// 			}
// 		}
// 		sum += t[i];
// 		count[t[i]]++;
// 		cout << k << " "<<endl;
// 	}
// }
#include<bits/stdc++.h>

// @author : sam000013

#define int long long
#define PI 3.14159265
#define fi(i,start,end) for(int i=0; i<n; i++)
#define pb(x) push_back(x)
#define int long long
#define PI 3.14159265
#define all(v) v.begin(), v.end()
#define endl cout<<"\n" 
#define ll long long
#define dbg(x) cout<<#x<<" "<<x;endl;
#define bye endl;return
using namespace std;
int mod = 1000000007;
template<typename T>

void debug(vector<T> x){
    for(auto e:x){
        cout<<e<<" ";
    }
    cout<<"\n";
}
/*
1
8 6
1 2 4 1 2 4 1 2

*/

void solve(){
    int n;
    cin>>n;
    vector<int> v(n);
    vector<int> suffix(n,0); 
    for(int i=0; i<n; i++){
        cin>>v[i];
    }
    int ans = 0;
    // suffix[n-1] = v[n-1];
    for(int i = n-1; i>=0; i--){
        if(i < n-1)
        suffix[i] = suffix[i+1] + v[i];
        else{
            suffix[n-1] = v[n-1];
        }
        if(i==n-1)
            continue;
        ans = (ans%mod + ((suffix[i+1]%mod)*(v[i]%mod))%mod)%mod;
    }
    cout<<ans;bye;
    
}

signed main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    // int t = 1;
    //cin>>t;
    for(int i=1; i<=1; i++){
        solve();
    }
    return 0;
}

Measured memory_bytes: 6352
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb(x) push_back(x)
#define f(i,st,n) for(i=st;i<n;i++)
#define vec vector
#define mst(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
#define sfl(x) scanf("%lld",&x)
#define pfl(x) printf("%lld\n",x)
#define pf(x) printf("%lld",x)
#define mpr make_pair
#define fs first
#define se second
#define inf LLONG_MAX
#define nnf LLONG_MIN
 
 
 
 
ll gcd(ll a,ll b){
    if(a==0){
        return b;
    }                     
    return gcd(b%a,a);
}
ll power(ll x,ll y){            
    ll res=1;
    while(y>0){
        if(y%2==1){
            res=(res*x);
        }
        x=(x*x);
        y=y/2;
    }
    return res;
}
  
  vec<ll>v[100002],vis(100002),ans(100002),lv(100002,500000000);



int main(){
 
 /*#ifndef ONLINE_JUDGE
    
    freopen("input.txt", "r", stdin);
   
   freopen("output.txt", "w", stdout);
   #endif*/

   ll n,m,i,j,x,y;
   sfl(n);sfl(m);
   f(i,0,m){
      sfl(x);sfl(y);
      v[x].pb(y);
      v[y].pb(x);

   }
   lv[1]=0;
    queue<ll>q;
    q.push(1);
    vis[1]=1;

    while(!q.empty()){

          ll x=q.front();
          q.pop();

          for(auto z:v[x]){

              if(!vis[z]){
                  vis[z]=1;
                  lv[z]=lv[x]+1;
                  ans[z]=x;
                  q.push(z);

              }
          }
    }
    cout<<"Yes\n";

    f(i,2,n+1)pfl(ans[i]);

   
 
 
 
 
 
   return 0;
 }

Measured memory_bytes: 14552
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		int m = sc.nextInt();

		List<City> citys = new ArrayList<>();
		int[] cityInPre = new int[n+1];
		for(int i=0;i<n+1;i++) {
			cityInPre[i]=0;
		}

		//double temp =0;
		//List<Double> list = new ArrayList<>();
		for(int i=0;i<m;i++) {
			City city = new City(i,sc.nextInt(),sc.nextInt());
			citys.add(city);
		}

		citys.sort((a,b) -> a.year-b.year);


		for(int i = 0;i<citys.size();i++) {
			citys.get(i).number = cityInPre[citys.get(i).prefecture]+1;
			cityInPre[citys.get(i).prefecture]++;
		}

		citys.sort((a,b) -> a.order-b.order);

		for(int i = 0;i<citys.size();i++) {
			String s = "";
			for(int j=0;j<5-Math.floor(Math.log10(citys.get(i).prefecture));j++) {
				s = s+"0";
			}
			s = s + Integer.toString(citys.get(i).prefecture);
			for(int j=0;j<5-Math.floor(Math.log10(citys.get(i).number));j++) {
				s = s+"0";
			}
			s = s + Integer.toString(citys.get(i).number);
			System.out.println(s);
		}


	}

}

class City{
	int order;
	int prefecture;
	int year;
	int number;
	City(int order,int prefecture, int year){
		this.order = order;
		this.prefecture = prefecture;
		this.year = year;
	}
}

Measured memory_bytes: 117772
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdio>
#include <list>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define vec vector<int>
#define vecll vector<ll>
#define vecstr vector<string>
#define vecch vector<char>
#define vecpii vector<pii>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
string strin(){string s;cin>>s;return s;}
char chin(){char c;cin>>c;return c;}
ll lin(){ll x;scanf("%lld",&x);return x;}


void makeP(vecll& v,ll ma){
    v.pb(2);
    for(ll k=3;k<=ma;k+=2){
        bool bl=true;
        REP(x,v){
            if(k%x==0){
                bl=false;
                break;
            }
            if(x*x>k)break;
        }
        if(bl)v.pb(k);
    }
}


int main(){
    int n=in();
    ll mod=1000000007,ans=1;
    vecll p;
    makeP(p,n);
    REP(x,p){
        int cnt=0,y=n;
        while(y>0){
            cnt+=y/x;
            y/=x;
        }
        ans*=cnt+1;
        ans%=mod;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
# 多分union-find
n, m = map(int, input().split())

ab = [list(map(int, input().split())) for _ in range(m)]

#adlist=[[i] for i in range(1,n+1)]


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}


adlist = UnionFind(n+1)
# print(adlist.same(1,2))

for i in range(m):
    a = ab[i][0]
    b = ab[i][1]
    if adlist.same(a, b) == False:
        adlist.union(a, b)
ans=0
for i in range(1,n+1):
    ans=max(ans,adlist.size(i))
print(ans)

"""
for i in range(m):
    x=ab[i][0]
    y=ab[i][1]
    adlist[x-1].append(y)
    adlist[y-1].append(x)
print(adlist)
for i in range()"""

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

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

  vector<ll> A;
  A.reserve(N);
  int count_minus = 0;
  for (int i = 0; i < N; i++) {
    ll a;
    cin >> a;
    if (a < 0) count_minus++;
    A.emplace_back(a);
  }

  ll result = 0;
  if(count_minus % 2 == 1) {
    vector<ll> B;
    B.reserve(N);
    for (int i = 0; i < N; i++) {
      B.emplace_back(abs(A[i]));
    }
    sort(B.begin(), B.end());
    B[0] *= -1;
    result = B[0];
    for (int i = 1; i < N; i++) {
      result += B[i];
    }
  } else {
    for (int i = 0; i < N; i++) {
      result += abs(A[i]);
    }
  }

  cout << result << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#define MAX 100000

int A[MAX], n;

int partition(int p, int r) {
	int x, i, j, t;
	x = A[r];
	i = p - 1;
	for (j = p; j < r; j++) {
		if (A[j] <= x) {
			i++;
			t = A[i]; A[i] = A[j]; A[j] = t;
		}
	}
	t = A[i + 1]; A[i + 1] = A[r]; A[r] = t;
	return i + 1;
}

int main() {
	int i, q;
	scanf("%d", &n);
	for (i = 0; i < n; i++)scanf("%d", &A[i]);

	q = partition(0, n - 1);
	for (i = 0; i < n; i++) {
		if (i)printf(" ");
		if (i == q)printf("[");
		printf("%d", A[i]);
		if (i == q)printf("]");
	}
	printf("\n");

	return 0;
}


Measured memory_bytes: 2236
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] num = new int[n];
        double sum = 0;


        for(int i = 0;i<n;i++){
            num[i] = sc.nextInt();
            sum += (double)1/num[i];
        }
        //System.out.println(sum);

        System.out.println((double)1/sum);



    }
}


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

#define LL long long
#define LD long double
#define INF 1000000000
#define PR pair<int,int>
#define Min(a,b) a=min(a,b)
#define Max(a,b) a=max(a,b)
#define pb push_back
#define mp make_pair

int n;
int a[100005], b[100005], c[100005];
int dp[100005][3];

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

	dp[0][0] = 0; dp[0][1] = 0; dp[0][2] = 0;
	for (int i = 1; i <= n; i++) {
		dp[i][0] = a[i] + max(dp[i-1][1], dp[i-1][2]);
		dp[i][1] = b[i] + max(dp[i-1][0], dp[i-1][2]);
		dp[i][2] = c[i] + max(dp[i-1][1], dp[i-1][0]);
	}

	cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << endl;
}

Measured memory_bytes: 2560
from itertools import accumulate
from math import*
from collections import deque
from collections import defaultdict
from itertools import permutations
import heapq
import bisect
from collections import Counter
from itertools import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = 10**10
from functools import reduce

class UnionFind:
  def __init__(self, n):
    self.tree = [-1] * n

  def union(self, a, b):
    a = self.root(a)
    b = self.root(b)
    if(a == b):
      return
    if(self.size(a) < self.size(b)):
      a, b = b, a
    self.tree[a] += self.tree[b]
    self.tree[b] = a

  def root(self, a):
    if(self.tree[a] < 0):
      return a
    res = self.root(self.tree[a])
    self.tree[a] = res
    return res

  def size(self, a):
    return -self.tree[self.root(a)]

n,k,l = map(int,input().split())
uf1 = UnionFind(n)
uf2 = UnionFind(n)
for i in range(k):
    p,q = map(int,input().split())
    p -= 1
    q -= 1
    uf1.union(p,q)
for i in range(l):
    r,s = map(int,input().split())
    r -= 1
    s -= 1
    uf2.union(r,s)
ab = [(uf1.root(i),uf2.root(i)) for i in range(n)]
c = Counter(ab)
print(" ".join(map(str,[c[i] for i in ab])))

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

void insertionSort(int a[], int n); //don't forget int

int main(){
    int a[100];
    int n;
    cin >> n;
    for ( int i = 0; i < n; i++ ){
        cin >> a[i];
    }
    insertionSort(a, n);
    return 0;
}

void insertionSort(int a[], int n){
    for ( int i = 0; i < n; i++ ){
        int key = a[i]; 
        int j = i - 1;
        while ( j >= 0 && a[j] > key ) {
            a[j + 1] = a[j];
            j--;
        }
        a[j + 1] = key;
        
        for ( int k = 0; k < n; k++ ) { //i < nとかになってた
            cout << a[k];
            if (k != n - 1) cout << " ";
        }
        cout << endl;
            
    }
}


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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
#if loc||local
template<class T>void dump(T&& t){cerr<<t<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

signed main(){

  ll n;
  cin>>n;

  ll tmp = 0;
  ll digit = 0;
  while(tmp<n){
    digit++;
    tmp += pow(26,digit);
  }
  string ans = "";
  ll s = tmp-pow(26,digit);
  ll t = tmp;
  while(digit>0){
    ll r = pow(26,digit-1);
    int x=-1;
    for(ll i=0;i<26;++i){
      if(s+i*r<n && n<=s+(i+1)*r){
        dump(s+i*r,s+(i+1)*r);
        x=i;
      }
    }
    assert(x!=-1);
    dump(s,t,r,x);
    ans += ('a'+x);
    s = s+x*pow(26,digit-1);
    t = s+pow(26,digit-1);
    digit--;
  }
  cout<<(ans)<<endl;

}

Measured memory_bytes: 4104
def insert_sort(n, nums):
    for i in range(1, n):
        key = nums[i]
        j = i - 1
        while j >= 0 and nums[j] > key:
            nums[j+1] = nums[j]
            j -= 1
        nums[j+1] = key
        print(' '.join(map(str, nums)))


n = int(input())
nums = list(map(int, input().split()))

print(' '.join(map(str, nums)))
insert_sort(n, nums)




Measured memory_bytes: 5600
from heapq import heappop, heappush
from operator import itemgetter


def branchAndBound(N: int, M: int, V: list, W: list, R: list) -> int:
    def upperbound(w, v, i):
        rest = M - w
        _v = v
        for j in range(i + 1, N):
            if W[j] >= rest:
                rest -= W[j]
                v += V[j]
                _v = v
            else:
                _v += R[j] * rest
                break
        return v, _v

    prov, tmp = upperbound(0, 0, -1)
    h = [(tmp, W[0], V[0] * (W[0] >= M), 0), (upperbound(0, 0, 0)[1], 0, 0, 0)]
    while h:
        _v, w, v, cur = heappop(h)
        if _v > prov or cur == N - 1:
            continue
        nxtw, nxtv = w + W[cur + 1], v + V[cur + 1]
        if nxtw >= M:
            heappush(h, (_v, nxtw, nxtv, cur + 1))
        _prov, ub = upperbound(w, v, cur)
        if _prov < prov:
            prov = _prov
        if ub < prov:
            heappush(h, (ub, w, v, cur + 1))
    return -prov


def main():
    N, M, *L = map(int, open(0).read().split())
    t = [(v, w, v / w) for w, v in zip(*[iter(L)] * 2)]
    t.sort(key=itemgetter(2), reverse=True)
    V, W, R = [], [], []
    for v, w, r in t:
        V += [-v]
        W += [-w]
        R += [r]
    ans = branchAndBound(N, -M, V, W, R)
    print(ans)
    
if __name__=="__main__":main()

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(long long (i)=0;(i)<(n);++(i))
#define ref(i,a,b) for (long long (i)=(a); (i)<=(b); ++(i))
#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define mp make_pair
const int mx=2e7+5;
long long p[mx];
long long d[mx];

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	/*freopen(".in", "r", stdin);
	freopen(".out", "w", stdout); 
    */
    int n;cin >> n;
    ref(i,1,n)d[i]=1;
	p[1]=1;p[2]=0;
	d[1]=1;
	int div,count;
	for(int i=2;i<=n;++i){
		if(p[i]==0){
			d[i]=2;
			for(int j=i*2;j<=n;j+=i){
				p[j]=1;
				div=j;
				count=0;
				while(div%i==0){++count;div=div/i;}
				d[j]=d[j]*(count+1);
			}

		}
	}
	ll sum=0;
	ref(i,1,n)sum+=i*d[i];
	cout << sum << endl;
}
	


Measured memory_bytes: 159828
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const int mod = 1e9+7;
//const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n; cin>>n;
    map<P,ll> m;
    ll azero=0, bzero=0, bothzero=0;
    rep(i,n){
        ll a,b;cin>>a>>b;
        if(a==0&&b==0)bothzero++;
        else if(a==0)azero++;
        else if(b==0)bzero++;
        else{
            ll g = __gcd(a,b);
            a/=g;b/=g;
            //if(a<0){a*=-1;b*=-1;}
            m[{a,b}]++;
        }


    }
    mint ans = 1;
    map<P,int> used;
    for(pair<P,ll> p:m){
        if(used[p.first]==1)continue;
        ll a = p.first.first;
        ll b = p.first.second;
        P p1 = {a,b};
        P p2 = {-a,-b};


        P q1,q2;
        q1 = {b,-a};
        q2 ={-b,a};
        ans *= (mint(2).pow(m[p1]+m[p2])+mint(2).pow(m[q1]+m[q2])-1);
        used[p1]=1;
        used[p2]=1;
        used[q1]=1;
        used[q2]=1;

    }
    ans*=mint(2).pow(azero)+mint(2).pow(bzero)-1;
    
    cout<<(ans-1+bothzero).x<<endl;
    return 0;
}

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

int main(){
	int k,t;
	int a;
	cin >> k >> t;
	if(t == 1){
		cin >> a;
		cout << k - 1 << endl;
	}
	else{
		int maxi = 0;
		int sum = 0;
		for(int i = 0; i < t; i++){
			cin >> a;
			sum += a;
			maxi = max(maxi,a);
		}
		sum -= maxi;
		int ans = max(maxi - sum - 1,0);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

//C++14 (GCC 5.4.1)
int main() {
    vector<int> A=vector<int>(5,0);
    rep(i,5){
        cin>> A.at(i);
    }

    //-----------------------------------
    int Ans=0,minkire=10;
    rep(i,5){
        if(A.at(i)%10>0){
            chmin(minkire,A.at(i)%10);
            Ans+=(A.at(i)/10)*10+10;
        }else{
            Ans+=A.at(i);
        }
    }
    Ans=Ans-10+minkire;

    cout << Ans <<endl;
    return (0);
}

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

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

ll func(ll a, ll b){
  if(a==b){
    return a;
  } else if(b < a){
    swap(a, b);
  }
  if(b%a==0){
    return 2*a*(b/a)-a;
  } else {
    return 2*a*(b/a)+func(a, b%a);
  }
}

int main(){
  ll n, x;
  cin >> n >> x;
  cout << n+func(n-x, x) << endl;
  return 0;
}


Measured memory_bytes: 256
def main():
    _, *aa = map(int, open(0).read().split())
 
    bb = tuple(map(abs, aa))
    m = tuple(a for a in aa if a < 0)
    print(sum(bb) - min(bb)*2*(len(m)%2))
 
 
if __name__ == "__main__":
    main()

Measured memory_bytes: 14116
#include <iostream>
#include <string>
#include <cstring>


using namespace std;



int main(void){
	char s[27];
	int nagasa ;
	cin >> s;
	nagasa = strlen(s);
	//cout << nagasa;

	for(int i = 1; i < nagasa; i++){
		for(int j = 0; j < i; j++){
			if(s[j] == s[i]){
				cout << "no\n";
				return 0;
			}
		}
	}
	cout << "yes\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstdio>
using namespace std;
template<class Abel> struct UnionFind {
       vector<int> par;
       vector<int> rank;
       vector<Abel> diff_weight;
       UnionFind(int n = 1, Abel SUM_UNITY = 0) {
              init(n, SUM_UNITY);
       }
       void init(int n = 1, Abel SUM_UNITY = 0) {
              par.resize(n); rank.resize(n); diff_weight.resize(n);
              for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
       }
       int root(int x) {
              if (par[x] == x) {
                     return x;
              }
              else {
                     int r = root(par[x]);
                     diff_weight[x] += diff_weight[par[x]];
                     return par[x] = r;
              }
       }
       Abel weight(int x) {
              root(x);
              return diff_weight[x];
       }
       bool issame(int x, int y) {
              return root(x) == root(y);
       }
       bool merge(int x, int y, Abel w) {
              w += weight(x); w -= weight(y);
              x = root(x); y = root(y);
              if (x == y) return false;
              if (rank[x] < rank[y]) swap(x, y), w = -w;
              if (rank[x] == rank[y]) ++rank[x];
              par[y] = x;
              diff_weight[y] = w;
              return true;
       }
       Abel diff(int x, int y) {
              return weight(y) - weight(x);
       }
};
int main() {
       int N, M;
       while (cin >> N >> M) {
              if (N == 0) break;
              UnionFind<int> uf(N);
              for (int i = 0; i < M; ++i) {
                     char c; int a, b, w;
                     cin >> c;
                     if (c == '!') {
                           cin >> a >> b >> w; --a, --b;
                           uf.merge(a, b, w);
                     }
                     else {
                           cin >> a >> b; --a, --b;
                           if (!uf.issame(a, b)) puts("UNKNOWN");
                           else cout << uf.diff(a, b) << endl;
                     }
              }
       }
}


Measured memory_bytes: 3952
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    let vec: Vec<&str> = buf.split_whitespace().collect();
    let fst = vec[0].chars().nth(0);
    let snd = vec[0].chars().nth(1);
    let trd = vec[0].chars().nth(2);

    // if snd != fst && trd != fst && trd != fst {
    //     println!("Yes", );
    // }else{
    //     println!("No", );
    // }

    let mut contain_a: bool = false;
    let mut contain_b: bool = false;
    let mut contain_c: bool = false;

    if fst == "a".chars().nth(0){
        contain_a = true;
    }else if fst == "b".chars().nth(0){
        contain_b = true;
    }else if fst == "c".chars().nth(0){
        contain_c = true;
    }

    if snd == "a".chars().nth(0){
        contain_a = true;
    }else if snd == "b".chars().nth(0){
        contain_b = true;
    }else if snd == "c".chars().nth(0){
        contain_c = true;
    }

    if trd == "a".chars().nth(0){
        contain_a = true;
    }else if trd == "b".chars().nth(0){
        contain_b = true;
    }else if trd == "c".chars().nth(0){
        contain_c = true;
    }

    if contain_a && contain_b && contain_c{
        println!("Yes", );
    }else{
        println!("No", );
    }

}


Measured memory_bytes: 4352
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000LL
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
ll dp[(1<<15)],c[(1<<15)],mx[(1<<15)][15],chain[(1<<15)],dp2[(1<<15)][15],S;;
vector<P1>vi;
int n,m;
int main(){
	cin>>n>>m;
	rep(i,m){
		int a,b,c;cin>>a>>b>>c;a--;b--;
		vi.pb(mp(c,mp(a,b)));S+=c;
	}
	rep(i,(1<<n))chain[i]=-1e17;
	rep(i,(1<<n))rep(j,n)dp2[i][j]=-1e17;
	dp2[1][0] = 0;
	for(int i=0;i<(1<<n);i++){
		rep(j,vi.size()){
			int x = vi[j].sc.fi,y = vi[j].sc.sc;
			if(!((i>>x)&1)) continue;
			if(!((i>>y)&1)) continue;
			c[i] += vi[j].fi;
		}
		for(int k=0;k<n;k++){
			if(!((i>>k)&1)) continue;
			rep(j,vi.size()){
				int x = vi[j].sc.fi,y = vi[j].sc.sc;
				if(((i>>x)&1)+((i>>y)&1)<2)continue;
				//cout<<x<<y<<k<<endl;
				if(x == k){
					dp2[i][k] = max(dp2[i][k],dp2[i-(1<<k)][y]+vi[j].fi);
				}
				swap(x,y);
				if(x == k){
					dp2[i][k] = max(dp2[i][k],dp2[i-(1<<k)][y]+vi[j].fi);
				}
			}
		}
	}
	//cout << dp2[3][1] << endl;
	for(int i=0;i<(1<<n);i++){
		for(int v=0;v<n;v++){
			if(v == n-1) chain[i] = max(chain[i],dp2[i][v]);
			if(((i>>v)&1)) continue;
			rep(j,vi.size()){
				int x = vi[j].sc.fi,y = vi[j].sc.sc;
				if(x==v && ((i>>y)&1)){
					mx[i][v] += (1LL*vi[j].fi);
				}
				if(y==v && ((i>>x)&1)){
					mx[i][v] += (1LL*vi[j].fi);
				}
			}
		}
	}
	ll ans = 0;
	for(int i=0;i<(1<<n);i++){
		if( !((i>>0)&1) || !((i>>(n-1))&1)) continue;
		int mask = (1<<n)-1-i;
		for(int j=mask; j>=0; j--) {
			j&=mask;
			dp[j] = 0;
		}
		for(int j=mask; j>=0; j--) {
			j&=mask;
			int mask2 = mask-j;
			//dp[mask2] no keisan
			for(int k=mask2; k>=0; k--) {
				k&=mask2;
				if(k==mask2) continue;
				ll add=0;
				for(int x=0;x<n;x++){
					if( ((i>>x)&1)){
						add=max(add,mx[mask2-k][x]);
					}
				}
				dp[mask2] = max(dp[mask2],dp[k]+c[mask2-k]+add);
			}
		}
		ans = max(ans,dp[mask]+chain[i]);
	}
	cout << S-ans << endl;
}

Measured memory_bytes: 8576
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define MN 100005
#define Mod 1000000007
int ksm(int a,int x){
	LL ans=1,w=a;
	while(x){
		if(x&1) ans=ans*w%Mod;
		w=w*w%Mod;
		x>>=1;
	}
	return ans;
}
int n,k,a[MN],fac[MN],dfac[MN];
pair<int,int>v[MN];
int C(int n,int m){
	if(n>m)return 0;
	return (LL)fac[m]*dfac[n]%Mod*dfac[m-n]%Mod;
}
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;++i){
		scanf("%d",&a[i]);
		v[i]=make_pair(a[i],i);
	}
	fac[0]=1;
	for(int i=1;i<=n;++i)fac[i]=(LL)fac[i-1]*i%Mod;
	dfac[n]=ksm(fac[n],Mod-2);
	for(int i=n-1;i>=0;--i)dfac[i]=(LL)dfac[i+1]*(i+1)%Mod;
	sort(v+1,v+1+n);
	LL ans=0;
	for(int i=1;i<=n;++i){
		int p=upper_bound(v+1,v+1+n,make_pair(a[i],i))-v;
//		cerr<<i<<": "<<p<<" "<<C(k-1,n-p)<<endl;
		ans=(ans-(LL)C(k-1,n-p+1)*a[i]%Mod+Mod)%Mod;
		p=lower_bound(v+1,v+1+n,make_pair(a[i],i))-v;
//		cerr<<i<<": "<<p<<" "<<C(k-1,p-1)<<endl;
		ans=(ans+(LL)C(k-1,p-1)*a[i]%Mod)%Mod;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 2176
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int tmp = (int)(n / 1.08);
        int tmp2 = (int)(tmp * 1.08);
        if(n == (int)(tmp * 1.08)){
            System.out.println(tmp);
        } else if (n == (int)((tmp+1) * 1.08) ){
            System.out.println(tmp+1);
        } else if (n == (int)((tmp-1) * 1.08)){
            System.out.println(tmp-1);
        } else {
            System.out.println(":(");
        }
    }
}


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

using namespace std;


int main (void) 
{

  /* Variable_Proclamation */
  int H, W;    // input

  int i, j;    // subscript
  int k;
  int i_cnt, j_cnt; 


  /* Input, Array_Proclamation */
  cin >> H >> W;
  vector< vector<char> > a(H, vector<char>(W)); //input
  
  for(i=0; i<H; i++)
  {
    for(j=0; j<W; j++)
    {
      cin >> a.at(i).at(j);
    }
  }


  /* Initialize */
  i_cnt = 0;
  j_cnt = 0;


  /* Calculation */

  //j_cnt
  for(i=0; i<H; i++)
  {

    for(j=0; j<W; j++)
    {

      if(a.at(i).at(j) == '.')
      {
        j_cnt++;
      }

      if(j_cnt == W)
      {

        // swap( a.at(i), a.at(H-1) );
        // a.pop_back();
        a.erase(a.begin() +i);
        H--;

        // swap( a.at(i), a.at(H-1) );
        // for(k=0; k<H-1; k++)
        // {
        //   swap( a.at(k), a.at(k+1) );
        // }
        i--;



      }

    }

    j_cnt = 0;

  }

  // /* Output */
  // cout << endl; // delete

  // for(i=0; i<H; i++)
  // {

  //   for(j=0; j<W; j++)
  //   {
  //     cout << a.at(i).at(j);
  //   }

  //   cout << endl;

  // }


  // return 0;


  // Transposition
  vector< vector<char> > trans_a(W, vector<char>(H));
  
  for(i=0; i<H; i++)
  {
    for(j=0; j<W; j++)
    {
      trans_a.at(j).at(i) = a.at(i).at(j);
    }
  }



  //i_cnt
  for(j=0; j<W; j++)
  {

    for(i=0; i<H; i++)
    {

      if(trans_a.at(j).at(i) == '.')
      {
        i_cnt++;
      }

      if(i_cnt == H)
      {

        // swap( trans_a.at(j), trans_a.at(W-1) );
        // trans_a.pop_back();
        trans_a.erase(trans_a.begin() +j);
        W--;

        // for(k=0; k<W-1; k++)
        // {
        //   swap( trans_a.at(k), trans_a.at(k+1) );
        // }
        j--;

        // cout << "aaa\n";
      }
      // else
      // {
      //   cout << "bbb\n";
      // }

    }

    i_cnt = 0;

  }


  // Re:Transposition

  vector< vector<char> > ans_a(H, vector<char>(W)); //output

  for(j=0; j<W; j++)
  {
    for(i=0; i<H; i++)
    {
      ans_a.at(i).at(j) = trans_a.at(j).at(i);
    }
  }


  /* Output */
  cout << endl; // delete

  for(i=0; i<H; i++)
  {

    for(j=0; j<W; j++)
    {
      cout << ans_a.at(i).at(j);
    }

    cout << endl;

  }


  return 0;


}


Measured memory_bytes: 256
use v6;
my ($h, $w) = get().chomp.split(' ');
my @c;
loop (my $i = 0; $i < $h; $i++) {
	@c[$i] = get().chomp.split(' ');
}

loop ($i = 0; $i < $h; $i++) {
	for @c[$i] -> $k {
		print $k;
	}
	print "\n";
	for @c[$i] -> $k {
		print $k;
	}
	print "\n";

}

exit;

Measured memory_bytes: 69476
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;


int main(){
	int n;
	cin >> n;
	vector<ll> a(n);

	rep(i, n)	cin >> a[i];
	sort(a.begin(), a.end());
	cout << abs(a[0] - a[n - 1]) << endl;
}

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

int main()
{
	int a, b, c, d, e;

	cin >> a >> b >> c >> d >> e;

	if (a < 0)
		cout << - a * c + d + b * e << endl;
	else
		cout << (b - a) * e << endl;

	return 0;
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

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

	int h, w, n, sx, sy;cin >> h >> w >> n >> sy >> sx;
	string a, b;cin >> a >> b;

	int U = 1;
	int D = h;
	int L = 1;
	int R = w;

	REV(i, n){
		if(b[i] == 'U')D = min(h, D + 1);
		if(b[i] == 'D')U = max(1, U - 1);
		if(b[i] == 'R')L = max(1, L - 1);
		if(b[i] == 'L')R = min(w, R + 1);

		if(U > D || L > R){
			cout << "NO" << endl;
			return 0;
		}

		if(a[i] == 'U')U++;
		if(a[i] == 'D')D--;
		if(a[i] == 'R')R--;
		if(a[i] == 'L')L++;

		if(U > D || L > R){
			cout << "NO" << endl;
			return 0;
		}
	}

	if(sx >= L && sx <= R && sy >= U && sy <= D){
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}


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

int main() {
    int m1, d1, m2, d2;
    cin >> m1 >> d1 >> m2 >> d2;
    if (m1 != m2)
        cout << 1 << endl;
    else
        cout << 0 << endl;
    return 0;
}

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

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
const ll MOD = 1e9+7;

int main() {
    int N; cin >> N;
    vvi a(2, vi(N));
    rep(i, N){
        cin >> a[0][i];
    }
    rep(i, N){
        cin >> a[1][i];
    }

    int max_sum = 0;
    for(int i=0;i<N;i++){
        int sum=0;
        for(int j=0;j<N;j++){
            if(i>=j){
                sum += a[0][j];
            }else{
                sum += a[1][j];
            }
        }
        sum += a[1][i];
        max_sum = max(sum, max_sum);
    }

    cout<<max_sum<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class Main {
	static boolean bElapsed = false;
	StringBuilder sb = new StringBuilder();
	List<Integer> list = new ArrayList<>();
	Set<String> set = new HashSet<>();
	Map<String,String> map = new HashMap<>();

	void solve(BufferedReader br) throws Exception {
		String line = br.readLine();
		String[] flds = line.split(" ");
		int a = Integer.parseInt(flds[0]);
		int b = Integer.parseInt(flds[1]);
		int c = Integer.parseInt(flds[2]);
		list.add(a);
		list.add(b);
		list.add(c);
		Collections.sort(list);
		if (list.get(0) == 5 && list.get(1) == 5 && list.get(2) == 7) {
			pln("YES");
		} else {
			pln("NO");
		}
	}

	void p(char c) {
		System.out.print(c);
	}
	void pln(char c) {
		System.out.println(c);
	}
	void p(long l) {
		System.out.print(l);
	}
	void pln(long l) {
		System.out.println(l);
	}
	void p(String s) {
		System.out.print(s);
	}
	void pln(String s) {
		System.out.println(s);
	}
	public static void main(String[] args) throws Exception {
		long start = System.currentTimeMillis();
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		new Main().solve(br);
		long end = System.currentTimeMillis();
		if (bElapsed) {
			System.out.println((end-start) + "ms");
		}
	}
}


Measured memory_bytes: 8148
n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]

ab.sort(key=lambda x: x[1])

t = 0

can = False

for a, b in ab:
    t += a
    if t > b:
        break
else:
    can = True

print("Yes" if can else "No")


Measured memory_bytes: 53600
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<algorithm>
#include<math.h>

using namespace std;

int main() {
    long long N;
    cin >> N;
    long long sum = 0;
    for (long long i = 0; i < N; i++){
        sum += i;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
/**
 *      ABC 103 B
 *      author  : kyomukyomupurin
 *      created : 2018/08/20
**/

#include <bits/stdc++.h>
using namespace std;

string StringRotation(string S){
    S.insert(S.begin(), S.at(S.size() - 1));
    S.pop_back();
    return S;
}

int main(){
    string S, T;
    cin >> S >> T;
    bool flag = false;
    
    for (int i = 0; i < S.size(); ++i){
        if (S == T){
            flag = true; break;
        }
        else {
            S = StringRotation(S);
        }
    }

    if (flag){
        cout << "Yes";
    }
    else {
        cout << "No";
    }

    return 0;

}


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

using namespace std;

const int N = 200000 + 7;

typedef long long ll;
typedef pair<ll, ll> ii;

int sqr(int x) {
  return x * x;
}

int main() {
  int n, d;
  cin >> n >> d;

  vector<vector<int>> m(n, vector<int> (d, 0));
  for(int i = 0; i < n; ++i) {
    for(int j = 0; j < d; ++j) {
      cin >> m[i][j];
    }
  }

  int ans = 0;
  for(int i = 0; i < n; ++i) {
    for(int j = i + 1; j < n; ++j) {
      int dis = 0;
      for(int k = 0; k < d; ++k) {
        dis += sqr(m[i][k] - m[j][k]);
      }
      int root = sqrt(dis);
      if(root * root == dis) ++ans;
    }
  }

  cout << ans << endl;

  return 0;
}


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

ll T1,T2,A1,A2,B1,B2;

int main()
{
	cin>>T1>>T2>>A1>>A2>>B1>>B2;
	ll diff = abs((A1-B1)*T1+(A2-B2)*T2);
	ll gain = abs(A1-B1)*T1;
	if(diff==0){
		cout<<"infinity"<<endl;
		return 0;
	}
	if((A1*T1>B1*T1)==(A1*T1+A2*T2>B1*T1+B2*T2)){
		cout<<0<<endl;
		return 0;
	}
	cout<<2*(gain/diff+1)-1 - (gain%diff==0?1:0)<<endl;
	return 0;
}


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

#define PB push_back
#define MP make_pair
#define F first
#define S second

using namespace std;

typedef long long ll;

const int max_n = 100111, inf = 1000111222;

void wa() {
    cout << "WA";
    exit(0);
}

void ok() {
    cout << "AC";
    exit(0);
}

int main() {
    //ios_base::sync_with_stdio(0);
    //cin.tie(0);
    //cout.tie(0);
    string s;
    cin >> s;
    if (s[0] != 'A') wa();
    int cntup = 0;
    int cntc = 0;
    for (int i = 2; i + 1 < s.size(); ++i) {
        if (s[i] == 'C') cntc++;
    }
    for (char a : s) {
        if (a < 'a') cntup++;
    }
    if (cntc != 1) wa();
    if (cntup != 2) wa();
    ok();

    return 0;
}


Measured memory_bytes: 256
def factorial(x):
    if x == 0:
        return 1
    else:
        return factorial(x-1)*x

n = int(input())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
"""
2 3 1 4 5
1 2 5 4 3
Go from the lower to higher permutation
if it is starting from k then ord(p)
2 3 4 1 5
2 3 4 5 1
How to find the order of a permutation
new_lowest = 1
3
1 2 3 -- has to give me 1
1 3 2 -- has to give me 2
2 1 3 -- has to give me 3
2 3 1 -- has to give me 4
3 1 2 -- has to give me 5
3 2 1 -- has to give me 6
"""
total = n
order_p = 1
original = []
for i in range(1,n+1):
    original.append(i)
for term in p:
    order_p+=factorial(total-1)*(original.index(term))
    original.remove(term)
    total-=1

for i in range(1,n+1):
    original.append(i)
order_q=1
total=n
for term in q:
    order_q+=factorial(total-1)*(original.index(term))
    original.remove(term)
    total-=1
print(abs(order_p-order_q))



Measured memory_bytes: 3064
import math
N, D = map(int, input().split())
x = [[int(i) for i in input().split()] for i in range(N)] 
sum = 0
count = 0
for i in range(N):
    for j in range(N):
        sum = 0
        if i == j:
            break
        for k in range(D):
            sum += (x[i][k] - x[j][k])** 2
        dist = math.sqrt(sum)
        if dist.is_integer():
            count += 1

print(count)

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

//-------------------------------------------------
//--Sieve of Eratosthenes
//-------------------------------------------------
class Sieve
{
private:
    ::std::vector<bool> prime;
public:
    Sieve(int n):prime(n+1, true){
        prime[0] = prime[1] = false;
        for(int i=2; i*i<=n; i++){
            if (!prime[i]) continue;
            for(int j=i*2; j<=n; j+=i){
                prime[j] = false;
            }
        }
    }
    bool isprime(int x){return prime[x];}
};

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N; cin>>N;
    Sieve sieve(N);
    vll prime;
    rep(i,N+1)if(sieve.isprime(i)){
        prime.pb(i);
    }
    vll dp(N+1);
    ll ans=0;
    FOR(i,1,N){
        for(ll j=i; j<=N; j+=i){
            dp[j]++;
        }
        ans+=dp[i]*i;
    }
    cout<<ans<<endl;
    return 0;
}


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


//thanks to pyf ...
//thanks to qhl ...

int main()
{
	string s;
	while (cin >> s)
	{
		for (int i = 0; i < s.length(); i += 2)
			cout << s[i];
		cout << endl;
	}
}

Measured memory_bytes: 512
N = int(input())
A=list(input())
B=list(input())
C=list(input())

count = 0

for i in range(N):
    flg = A[i]
    if flg==B[i]:
        if flg==C[i]:
            continue
        else:
            count += 1
            continue
    else:
        if flg==C[i]:
            count+=1
        else:
            if B[i]==C[i]:
                count += 1
            else:
                count += 2
print(count)


Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>
int main()
{
    char s1[5],s2[5];
    int i,j,c=0,l1,l2;
    scanf("%s",s1);
    scanf("%s",s2);
    l1=strlen(s1);
    l2=strlen(s2);
    for(i=0,j=l2-1;i<l1,j>=0;i++,j--)
    {
        if(s1[i]==s2[j])
            c++;
    }
    if(c==3) printf("YES\n");
    else printf("NO\n");

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n; cout<<(n+1)/2<<endl;
	return 0;
}

Measured memory_bytes: 256
def solve():
  n = int(input())
  query  =[]
  for i in range(n):
    x,l = (int(i) for i in input().split())
    query.append((x+l,max(0,x-l)))
  query.sort()
  nowr = 0
  ans = 0
  for i in range(n):
    r,l = query[i]
    #print(nowr)
    if nowr <= l:
      nowr = r
      ans += 1
  print(ans)
solve()

Measured memory_bytes: 16996
//#pragma warning(disable:4996)
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>
//#include <stdio.h>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 10000;/// 1e9 + 7;
const long long INF = 1e9;
typedef long long LL;
typedef long double LD;
//typedef boost::multiprecision::cpp_int bigint;
typedef pair<LL, LL> PLL;
typedef pair<int, int> PI;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef unsigned long long ULL;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int K;
	cin >> K;
	vector<bool> check(K, false);
	int n = 1;
	int p = 7%K;
	check[p] = true;
	while (true) {
		if (p == 0) {
			cout << n << "\n";
			return 0;
		}
		n++;
		p = (10 * p + 7) % K;
		if (p == 0) {
			cout << n << "\n";
			return 0;
		}
		if (check[p]) {
			cout << -1 << "\n";
			return 0;
		}
		check[p] = true;
	}
	return 0;
}


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

int main(){
  vector<bool> P(1e5+1, false);
  P[2]=true;
  for(int i=3; i<=1e5; i+=2){
    bool f = true;
    for(int j=3; j<=sqrt(i); j+=2){
      if(i%j==0){
        f=false;
        break;
      }
    }
    if(f){
      P[i]=true;
    }
  }
  vector<int> N(1e5+1,0);
  for(int i=2; i<=1e5; i++){
    if(P[i] && P[(i+1)/2]) N[i]=N[i-1]+1;
    else N[i]=N[i-1];
  }
  int Q;
  cin >> Q;
  for(int i=0; i<Q; i++){
    int l, r; cin >> l >> r;
    cout << N[r]-N[l-1] << endl;
  }
  return 0;
}

Measured memory_bytes: 1024