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

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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素


int main(){
    int n;
    cin>>n;
    ll ans=0;
    for(int i=1;i<=n;i++){
        int v=i;
        while(v<=n){
            ans+=v;
            v+=i;
        }
    }
    cout<<ans<<endl;
   return 0;
}

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

XY = []
for _ in range(N):
    x, y = map(int, input().split())
    XY.append((x, y))
    
# BITの定義
class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    # index 1からiの値の和を返す
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    # index iの値にxを加算する
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

#######################
# 開始
from operator import itemgetter
def solve():
    p_list = XY[:]

    # y座標の圧縮
    p_list = sorted(p_list, key=itemgetter(1))
    p_list = [ (x, y, i+1) for i, (x, y) in enumerate(p_list)]

    # xでソート
    p_list= sorted(p_list)

    # ある点が四角に含まれる場合の総数を求めるメソッド
    power = [1] * N
    for i in range(1, N):
        power[i] = power[i-1] * 2 % 998244353

    # a,bを求める
    bit = Bit(N)
    ans = 0
    for i, (x, y, r) in enumerate(p_list):
        tmp = bit.sum(r)
        a = tmp
        b = i-tmp
        c = r-tmp-1
        d = (N-r+1)-(i-tmp)-1
        bit.add(r, 1)
        _a = power[a] - 1
        _b = power[b] - 1
        _c = power[c] - 1
        _d = power[d] - 1

        ret = (_a+1) * (_d+1) * _c * _b
        ret += (_b+1) * (_c+1) * _a * _d
        ret -= _a*_b*_c*_d
        ret += power[N-1]
        ans += ret % 998244353

    print(ans % 998244353)
    
solve()


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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    ll r;
    cin >> r;
    cout <<  3 * r * r << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);
		int n;
		n = scan.nextInt();

		if (n % 2 == 0) {
			System.out.println(n / 2);
		} else {
			System.out.println(n / 2 + 1);
		}

	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。ｓ
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param a 基数
	 * @param n 乗数
	 * @param primeNumMod 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myModPow(long a, long n, long primeNumMod) {

		long ans = 1;

		//乗数が0の場合→1
		if (n == 0)
			return 1;

		if (primeNumMod == 0) {
			//modを使わないとき

			while (n > 0) {

				if (n % 2 == 0) {
					//累乗が偶数の時

					a *= a;
					n = n / 2;
				} else {
					//累乗が奇数の時
					ans *= a;
					n--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			//初めに桁を落とす
			a = myMod(a, primeNumMod);

			while (n > 0) {

				if (n % 2 == 0) {
					//累乗が偶数の時

					a *= myMod(a, primeNumMod);
					n = n / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(a, primeNumMod);
					n--;

				}
			}

			return myMod(ans, primeNumMod);

		}

	}

}


Measured memory_bytes: 21844
n = int(input())
aList = list(map(int, input().split()))
aList = filter(lambda n:n%2==0, aList)   

for a in aList:
  if a % 3 == 0 or a % 5 == 0:
    continue;
  print('DENIED')
  exit()
print('APPROVED')
  

Measured memory_bytes: 2940
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<cmath>

using namespace std;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;


int main() {
	ll N, K;
	cin >> N >> K;

	vector<ll> A(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}

	if (N <= K) cout << 1 << endl;
	else {
		int result = (N - 1) / (K - 1);
		if (result * (K - 1) != (N - 1)) ++result;
		cout << result << endl;
	}

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
int X;


template <typename T>
T gcd(T a, T b) {
	if (a < b) swap(a, b);
		while (b != 0) {
			T tmp = b;
			b = a % b;
			a = tmp;
		}
	return a;
}

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


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> X;
    int l = lcm<int>(X, 360);
    cout << l/X << endl;
}

Measured memory_bytes: 3648
<?php
	fscanf(STDIN,'%d%d',$h,$w);
	for($i=0;$i<$h;$i++)$s[]=fgets(STDIN);
	for($i=0;$i<$h;$i++)
	{
		$f=0;
		for($j=0;$j<$w;$j++)$f|=$s[$i][$j]=='#';
		$a[]=$f;
	}
	for($j=0;$j<$w;$j++)
	{
		$f=0;
		for($i=0;$i<$h;$i++)$f|=$s[$i][$j]=='#';
		$b[]=$f;
	}
	for($i=0;$i<$h;$i++)
	{
		if(!$a[$i])continue;
		for($j=0;$j<$w;$j++)if($b[$j])echo $s[$i][$j];
		echo "\n";
	}


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

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

    int h;
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> h;
        if (h >= K)
        {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <stack>
#include <queue>

#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define vsort(v) sort(v.begin(),v.end())
#define asort(a,n) sort(a, a + n)
#define vi vector<int>
#define vd vector<double>

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    double a;
    cin >> a;
    int ans;
    cin >> ans;
    cout << (ans - (a / 2.0)) * 2.0 << "\n";

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
int mod = 1000000007;

int main()
{
    IOS
    int t = 1;
    //cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        vector<int> a(n);
        for (int i = 0; i < n; i++)
            cin >> a[i];
        sort(a.begin(), a.end());
        ll res = (1ll)*a[n-1];
        int cnt = n - 2, i = n - 2;
        while (cnt >= 2)
        {
            res += 2*(1ll)* a[i];
            cnt -= 2;
            i--;
        }
        if (cnt == 1)
            res += a[i];
        cout << res;
    }
    return 0;
}

Measured memory_bytes: 3912
require 'matrix'
loop do
  s = gets.chomp.chop
  break if s == ''
  
  s.gsub!(/([A-Z\)])(?![a-z\d])/, '\11')
  s.gsub!(/([A-Z][a-z])(?!\d)/, '\11')
  s.gsub!(/\((.+?)\)(\d*)/){
    as, n = $1, $2
    as.gsub(/([a-zA-Z])(\d+)/){"#{$1}#{$2.to_i * n.to_i}"}
  }
  atoms = s.scan(/[A-Z][a-z]?/).uniq
  l = s.split('->')[0].count('+') + 1
  molecules = s.split(/\->|\+/)
  m = molecules.size - 1
  n = atoms.size
  
  a = Matrix.build(n, m){|y, x|
    sum = 0
    molecules[x].scan(/#{atoms[y]}(\d+)/).each{ |d|
      x < l ? sum += d[0].to_i : sum -= d[0].to_i
    }
    sum.to_r
  }.to_a
  
  b = [0] * n
  atoms.each do |atom|
    molecules[-1].scan(/(#{atom})(\d+)/).each{ |a, k|
      b[atoms.index(a)] = k.to_r
    }
  end

  ans = Matrix[*a].lup.solve(b).to_a[0,m] + [1.to_r]
  lcm = ans.map(&:denominator).reduce(&:lcm)
  puts ans.map{|x| (x * lcm).to_i} * ' '
end

Measured memory_bytes: 10184
#!/usr/bin/env python3

import sys


def read_int_list(sep=" "):
    return [int(s) for s in sys.stdin.readline().rstrip().split(sep)]


def dprint(*args, **kwargs):
    return
    print(*args, **kwargs)


facto = None
ifacto = None

def precompute_facto(n, mod):
    global facto, ifacto
    facto = [1] * (n + 1)
    for i in range(1, n + 1):
        facto[i] = (facto[i - 1] * i) % mod
    ifacto = [1] * (n + 1)
    ifacto[n] = mod_inv(1, facto[n], mod)
    for i in range(0, n):
        p = n - i
        ifacto[p - 1] = ifacto[p] * p % mod


def mod_inv(a, b, mod):
    return (a * pow(b, mod - 2, mod)) % mod


def choose(a, b, mod):
    return facto[a] * ifacto[a - b] % mod * ifacto[b] % mod


def multi_choose(a, b, mod):
    return choose(a + b - 1, b, mod)


def main():
    mod = 1000000007
    n, k = read_int_list()
    precompute_facto(n, mod)
    ans = 0
    for i in range(0, min(k, n - 1) + 1):
        ans = (ans + choose(n, i, mod) * multi_choose(n - i, i, mod)) % mod
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 18804
#include <bits/stdc++.h>
//\\//\\//\\//\\//\\//\\//\\//
#define fio ios::sync_with_stdio(false); cin.tie(nullptr)
#define all(x) (x).begin(),(x).end()
#define dlog(x) cerr<<#x<<'='<<x<<'\n'
#define endl '\n'
#define eb emplace_back
#define f first
#define s second
//\\//\\//\\//\\//\\//\\//\\//
using namespace::std;
using ll=long long;
using pii=pair<int,int>;
const int inf=INT_MAX,mod=1e9+7;
//\\//\\//\\//\\//\\//\\//\\//

using namespace std;

signed main() {
      string s,t; cin>>s>>t;
      int a,b; cin>>a>>b;
      string u; cin>>u;
      if(u==s)a--;
      else b--;
      cout<<a<<' '<<b;
      return 0;
}

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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

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; }

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

template<typename T>
void inputArray(T* p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

template<typename T>
void inputVector(vector<T> * p, int a){
    rep(i, a){
        T input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision = 0) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

int A, B;

int is_palindrome(int n) {
    auto ns = to_string(n);
    int res = 1;
    rep(i, ns.length()) {
        if (ns[i] != ns[ns.length() - i - 1]) {
            res = 0;
        }
    }
    return res;
}

int main(int argc, const char * argv[]) {
    A = inputValue();
    B = inputValue();

    int count = 0;
    repd(n, A, B+1) {
        count += is_palindrome(n);
    }

    output(count);

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include<iostream>
#include<algorithm>
#include<map>
#include<cstring>
using namespace std;
char s[200005];
int dp[200005][2];
int main()
{
    scanf("%s",s+1);
    int l=strlen(s+1);
    dp[1][0]=1;
    dp[2][1]=1;
    for(int i=1;s[i]!='\0';i++)
    {
        if(i>1)
            dp[i][0]=max(s[i-1]==s[i]?0:dp[i-1][0]+1,dp[i-1][1]+1);
        if(i>2)
            dp[i][1]=max(dp[i][1],dp[i-2][0]+1);
        if(i>3&&(s[i-3]!=s[i-1]||s[i-2]!=s[i]))
            dp[i][1]=max(dp[i][1],dp[i-2][1]);
    }
    printf("%d\n",max(dp[l][0],dp[l][1]));
}


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

using namespace std;

using i64 = long;

const i64 MOD = 998244353;
const i64 INF = 1e18 + 7;

auto mpow = [](auto x, i64 y){
    auto z = x;
    decltype(x) val = y & 1 ? x : decltype(x)(1);
    while(z *= z, y >>= 1)
        if(y & 1)
            val *= z;
    return val;
};



/*
void grundy(i64 def, i64 size){
    vector<int> v(size + 1, -1);
    v[size] = 0;
    function<int(int)> f = [&](int x){
        if(v[x] != -1)
            return v[x];
        set<int> s;
        if(x * 2 <= size)
            s.emplace(f(x * 2));
        s.emplace(f(x + 1));
        for(int i = 0;; ++i)
            if(s.find(i) == s.end())
                return v[x] = i;
    };
    for(int i = 1; i <= size; ++i){
        f(i);
        printf("%3ld : %ld\n", i ^ (size - 1), 1L * v[i]);
    }
}
*/


template <i64 mod = MOD>
struct ModInt{
    i64 p;

    ModInt() : p(0){}
    ModInt(i64 x){p = x >= 0 ? x % mod : x + (-x + mod - 1) / mod * mod;}

    ModInt& operator+=(const ModInt& y){p = p + *y - ((p + *y) >= mod ? mod : 0); return *this;}
    ModInt& operator-=(const ModInt& y){p = p - *y + (p - *y < 0 ? mod : 0); return *this;}
    ModInt& operator*=(const ModInt& y){p = (p * *y) % mod; return *this;}
    ModInt& operator%=(const ModInt& y){if(y)p %= *y; return *this;}

    ModInt operator+(const ModInt& y) const{ModInt x = *this; return x += y;}
    ModInt operator-(const ModInt& y) const{ModInt x = *this; return x -= y;}
    ModInt operator*(const ModInt& y) const{ModInt x = *this; return x *= y;}
    ModInt operator%(const ModInt& y) const{ModInt x = *this; return x %= y;}

    friend ostream& operator<<(ostream& stream, const ModInt<mod>& x){
        stream << *x;
        return stream;
    }

    friend ostream& operator>>(ostream& stream, const ModInt<mod>& x){
        stream >> *x;
        return stream;
    }

    ModInt& operator++(){p = (p + 1) % mod; return *this;}
    ModInt& operator--(){p = (p - 1 + mod) % mod; return *this;}

    bool operator==(const ModInt& y) const{return p == *y;}
    bool operator!=(const ModInt& y) const{return p != *y;}

    const i64& operator*() const{return p;}
    i64& operator*(){return p;}

};

using mint = ModInt<>;


signed main(){

    int n;
    cin >> n;

    vector<int> a(n);
    for(auto& x : a)
        cin >> x;
    mint ans = 0;
    for(int i = 1; i <= n; ++i){
        mint x(a[i - 1]);
        ans += x * mpow(x + 1, i - 1) * mpow(mint(2), n - i);
    }
    cout << ans << endl;

    /*
    vector<i64> a(n), b(n);
    for(int i = 0; i < n; ++i)
        cin >> a[i] >> b[i];
    grundy(10, rand() % 15 + 15);
    */
}



Measured memory_bytes: 6684
#include "bits/stdc++.h"

using namespace std;
int main() {
	int K,N;
	cin >> K >> N;
	vector<int>A(N+1);
	for (int n = 0;n<N;++n) {
		cin >> A[n];
	}
	A[N] = A[0] + K;
	int num = 0;
	for (int n = 0;n<N;++n) {
		num = max(num, A[n + 1] - A[n]);
	}

	cout <<K-num<<endl;

	return 0;
}

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

int main(){

    string s;
    cin >> s;

    for(int i = 0; i < (int)s.size(); i++){
        if((i+1)%2 == 1) cout << s[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,0,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int MOD=1e9+7;
const int INF=1e18;
const int MAX=3000;


signed main(){
    int A,B,C;cin>>A>>B>>C;
    if(A<=C&&C<=B)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n = readline() |> parseInt
	e = [Int[] for i in 1:n]
	for i in 1:n-1
		a,b = readline() |> split |> parseMap
		push!(e[a],b)
		push!(e[b],a)
	end
	chk = -ones(Int,n)
	chk[1] = 0
	stack = Int[1]
	while !isempty(stack)
		now = pop!(stack)
		for i in e[now]
			if chk[i] == -1
				push!(stack,i)
				chk[i]=(chk[now]+1)%2
			end
		end
	end
	ans = zeros(Int,n)
	z = sum(chk)
	sx = 1
	sy = 2
	sz = 3
	if sum(chk)<=div(n,3)
		for i in 1:n
			if chk[i]==1
				ans[i] = sz
				sz += 3
			else
				if sy<=n
					ans[i] = sy
					sy += 3
				elseif sx<=n
					ans[i] = sx
					sx += 3
				else
					ans[i] = sz
					sz += 3
				end
			end
		end
	elseif sum(chk)>2*div(n,3)
		for i in 1:n
			if chk[i]==0
				ans[i] = sz
				sz += 3
			else
				if sy<=n
					ans[i] = sy
					sy += 3
				elseif sx<=n
					ans[i] = sx
					sx += 3
				else
					ans[i] = sz
					sz += 3
				end
			end
		end
	else
		for i in 1:n
			if chk[i]==0
				if sx<=n
					ans[i] = sx
					sx += 3
				else
					ans[i] = sz
					sz += 3
				end
			else
				if sy<=n
					ans[i] = sy
					sy += 3
				else
					ans[i] = sz
					sz += 3
				end
			end
		end
	end
	if n == 2
		println("1 2")
	else
		for i in 1:n-1
			print(ans[i], " ")
		end
		println(ans[n])
	end
end

main()

Measured memory_bytes: 173728
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <cinttypes>

#define INF 1000000000000

using namespace std;

typedef long long int ll;
typedef vector<ll> V;
typedef vector<V> VV;

int main() {
  // Happy hacking!
  ll a, b, q;
  V s, t;
  V t_nearest, s_nearest;

  cin >> a >> b >> q;
  for(int i=0; i<a; i++) {
    ll temp;
    cin >> temp;
    s.push_back(temp);
  }
  for(int i=0; i<b; i++) {
    ll temp;
    cin >> temp;
    t.push_back(temp);
  }

  // update nearests
  for(int i=0; i<a; i++) {
    ll east_ldist, west_ldist;
    auto n_east = lower_bound(t.begin(), t.end(), s[i]);
    if(n_east == t.end() && *n_east < s[i]) {
      // no east nearest
      east_ldist = INF;
    } else {
      east_ldist = *n_east - s[i];
    }
    if(n_east == t.begin()) {
      // no west nearest
      west_ldist = INF;
    } else {
      west_ldist = s[i] - *(prev(n_east));
    }
    t_nearest.push_back(min(east_ldist, west_ldist));
  }
  for(int i=0; i<b; i++) {
    ll east_ldist, west_ldist;
    auto n_east = lower_bound(s.begin(), s.end(), t[i]);
    if(n_east == s.end() && *n_east < t[i]) {
      // no east nearest
      east_ldist = INF;
    } else {
      east_ldist = *n_east - t[i];
    }
    if(n_east == s.begin()) {
      // no west nearest
      west_ldist = INF;
    } else {
      west_ldist = t[i] - *(prev(n_east));
    }
    s_nearest.push_back(min(east_ldist, west_ldist));
  }
  
  for(int i=0; i<q; i++) {
    ll x;
    cin >> x;
    ll s_lcost;
    ll t_east_lcost, t_west_lcost;
    ll t_lcost;
    auto ns_east = lower_bound(s.begin(), s.end(), x);
    
    if(ns_east == s.end()) {
      s_lcost = x - *(prev(ns_east)) + t_nearest[distance(s.begin(), prev(ns_east))];
    } else if(ns_east == s.begin()) {
      s_lcost = *ns_east - x + t_nearest[distance(s.begin(), ns_east)];
    } else {
      ll s_east_lcost, s_west_lcost;
      s_east_lcost = *ns_east - x + t_nearest[distance(s.begin(), ns_east)];
      s_west_lcost = x - *(prev(ns_east)) + t_nearest[distance(s.begin(), prev(ns_east))];
      s_lcost = min(s_east_lcost, s_west_lcost);
    }
    auto nt_east = lower_bound(t.begin(), t.end(), x);
    
    if(nt_east == t.end()) {
      t_lcost = x - *(prev(nt_east)) + s_nearest[distance(t.begin(), prev(nt_east))];
    } else if(nt_east == t.begin()) {
      t_lcost = *nt_east - x + s_nearest[distance(t.begin(), nt_east)];
    } else {
      ll t_east_lcost, t_west_lcost;
      t_east_lcost = *nt_east - x + s_nearest[distance(t.begin(), nt_east)];
      t_west_lcost = x - *(prev(nt_east)) + s_nearest[distance(t.begin(), prev(nt_east))];
      t_lcost = min(t_east_lcost, t_west_lcost);
    }
    cout << min(s_lcost, t_lcost) << endl;
  }
    
  return 0;
}


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

int main(){
	int a,b,c,d,e,a_,b_,c_,d_,e_,mi=0;
	cin>>a>>b>>c>>d>>e;
	a_=(a+9)/10;
	b_=(b+9)/10;
	c_=(c+9)/10;
	d_=(d+9)/10;
	e_=(e+9)/10;
	mi = max(a_*10-a,mi);
	mi = max(b_*10-b,mi);
	mi = max(c_*10-c,mi);
	mi = max(d_*10-d,mi);
	mi = max(e_*10-e,mi);
	cout << (a_+b_+c_+d_+e_)*10-mi<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int H, W, i;

	while (1) {
		scanf("%d %d", &H, &W);

		if (H == 0 && W == 0) break;

		char el[W + 1];
		char ol[W + 1];

		for (i = 0; i < W; i++) {
			if (i % 2 == 0) {
				el[i] = '#';
				ol[i] = '.';
			} else {
				el[i] = '.';
				ol[i] = '#';
			}
		}

		el[W] = '\0';
		ol[W] = '\0';

		for (i = 0; i < H; i++) {
			if (i % 2 == 0) printf("%s\n", el);
			else printf("%s\n", ol);
		}

		printf("\n");

	}

	return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
int main() {
	string s, t; cin >> s >> t;
	int ans = 10000;
	for (int i = 0; i < s.size() - t.size() + 1; i++)
	{
		int cnt = 0;
		for (int j = 0; j < t.size(); j++)
		{
			if(s[i + j] != t[j]) cnt++;
		}
		ans = min(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3624
#include "bits/stdc++.h"

using namespace std;

int main() {
   int a,b,k;
   cin >> a >> b >> k;
   int i=max(a,b);
   int co=0;
   while(i>0){
       if(a%i==0&&b%i==0){
           co++;
           if(co==k){
               cout << i << endl;
           }
       }
       i--;
   }
   return 0;
}

Measured memory_bytes: 256
from networkx.utils import UnionFind as UF
n,m=map(int, input().split())
uf=UF()
for _ in range(m):
    a,b=map(int, input().split())
    uf.union(a, b)
ans=1
for i in uf.to_sets():
    ans=max(ans,len(i))
print(ans)

Measured memory_bytes: 103564
import Data.Char

main = getLine >>= putStrLn . compute

compute :: String -> String
compute (c:s) = reverse $ ("7=" ++) $ fst $ head $ filter ((7 ==).snd) $ foldl step [([c],digitToInt c)] s

step sns c =
  [ (c:o:s,n+d) 
  | (s,n) <- sns
  , (o,d) <- [('+', digitToInt c), ('-', - digitToInt c)]
  ]


Measured memory_bytes: 380
// 基本テンプレート

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

typedef pair<int, int> pii;
typedef long long ll;

int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

char board[60][60], ans[60][60];

signed main() {
    int H, W; cin >> H >> W;
    rep(i,0,H) rep(j,0,W) {
        cin >> board[i][j];
    }
    rep(i,0,H) rep(j,0,W) {
        if(board[i][j] == '#') {
            ans[i][j] = '#';
            continue;
        }
        int cnt = 0;
        rep(k,0,8) {
            int nx = i + dx[k], ny = j + dy[k];
            if(nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
            if(board[nx][ny] == '#') cnt++;
        }
        ans[i][j] = (char)('0' + cnt);
    }

    rep(i,0,H) {
        rep(j,0,W) cout << ans[i][j];
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
// #pragma GCC optimize("unroll-loops", "omit-frame-pointer", "inline")
// #pragma GCC option("arch=native", "tune=native", "no-zero-upper")
// #pragma GCC
// target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("tree-vectorize","openmp","predictive-commoning")
// #pragma GCC option("D_GLIBCXX_PARALLEL","openmp")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  int N;
  cin >> N;
  vector<int> ans(N, 0);
  for (int i = 1; i < N; i++) {
    int v;
    cin >> v;
    v--;
    ans[v]++;
  }
  for (int i = 0; i < N; i++) { cout << ans[i] << endl; }
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();

  // int t; cin >> t;
  // for(int i=1;i<=t;i++){
  //   cout << "Case #" << i << ": ";
  //   solve();
  // }
  return 0;
}


Measured memory_bytes: 3972
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N;
	static long long A[200000] = {}, count = 0, ans = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	int L = 0, R = 0;
	while (R < N) {
		if (count + A[R] == (count ^ A[R])) {
			count += A[R];
			R++;
			ans += (R - L);
		}
		else {
			count -= A[L];
			L++;
		}
	}
	cout << ans;
}

Measured memory_bytes: 1792
N, C = map(int, input().split())
programs = [[0 for _ in range(C)] for _ in range(10**5)]
for _ in range(N):
    s, t, c = map(int, input().split())
    for i in range(s-1, t):
        programs[i][c-1] = 1
ret = 0
for i in range(10**5):
    ret = max(ret, sum(programs[i]))
print(ret)


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

int main()
{
    int i,j,k;
	int M,N;
	cin>>N>>M;
	int A[N];
	double V=0;
	for(i=0;i<N;i++){
		cin>>A[i];
		V=V+A[i];
	}
	int C=0;
	double S;
	S=V/(4*M);
	for(i=0;i<N;i++){
		if(A[i]>=S){C++;}	
	}
	if(C>=M){cout<<"Yes";}
	else{cout<<"No";}
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

ll N;

int main() {
	cin >> N;
	rep(i, 3500) {
		rep(j, 3500) {
			ll w = i + 1, n = j + 1;
			if (4 * w*n - N*w - N*n > 0 && (N*n*w) % (4 * w*n - N*w - N*n) == 0) {
				cout << w << " " << n << " " << (N*n*w) / (4 * w*n - N*w - N*n) << endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 256
//
//  main.cpp
//  Study
//
//  Created by 佐々木勇星 on 2020/03/12.
//  Copyright © 2020 佐々木勇星. All rights reserved.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <algorithm>

using namespace std;


int main(int argc, const char * argv[]) {
    
    int h, a, ans = 0;
    
    cin >> h >> a;
    
    ans = h / a;
    
    if(h % a != 0) ans++;
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
typedef long long ll;
const int INF = 100000000, mod = 1000000007;
const ll LLINF = 1LL << 50;
using namespace std;

int main() {
    int n, d[105], count=0, under=INF;
    cin >> n;
    for (int i = 0; i < n; i++)cin >> d[i];
    sort(d,d+n, greater<int>());
    for (int i = 0; i < n; i++) {
        if (d[i] != under) {
            count++;
            under = d[i];
        }
    }
    cout << count << endl;
    return 0;
}


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

using namespace std;

const int MAXN = 200000;
int A[MAXN+1],B[MAXN+1];
int C[MAXN+1];

int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",&A[i]);
    if(A[1]){printf("-1"); return 0;}
    for(int i=2;i<=n;i++)
    if(A[i]-A[i-1]>=2){
        printf("-1"); return 0;
    }

    long long int sum = 0;

    for(int i=n;i>=1;i--){

            if(A[i]<=A[i-1])sum+=(long long int)A[i];
            else sum+=1LL;
    }

    printf("%lld",sum);

    return 0;
}


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

signed main() {
	int N,M,a;
	cin >> N>>M;
	priority_queue<int> A;
	for(int i=0;i<N;i++){
		cin>>a;
		A.push(a);
	}
	
	for(int i=0;i<M;i++){
		a=A.top();
		A.pop();
		a/=2;
		A.push(a);
	}
	
	int ans =0;
	
	while(!A.empty()){
		a=A.top();
		A.pop();
		ans+=a;
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 1400
using System;
using System.Collections.Generic;
namespace ITP1_4_D
{
    class Problem
    {

        public static List<string[]> getinputdata (){

            List<string[]> list_temp = new List<string[]>();
            string strdata = Console.ReadLine ();

            while (strdata!=null) {

                string[] s_temp = strdata.Split (' ');

                list_temp.Add (s_temp);

                strdata = Console.ReadLine ();

            }

            return list_temp;
        }

        public static void Main (string[] args)
        {
            List<string[]> list_result = new List<string[]>();
            list_result = getinputdata ();

                int n = int.Parse(list_result[0][0]);
                string[] a  = list_result[1];

            int maxdata = -1000000;
            int mindata = 1000000;
            long mysum = 0;
            for (int i = 0; i < n; i++)
            {
                mysum += int.Parse(a[i]);

                if (maxdata < int.Parse(a[i]))
                {
                    maxdata = int.Parse(a[i]);
                }

                if (mindata > int.Parse(a[i]))
                {
                    mindata = int.Parse(a[i]);
                }

            }

            Console.WriteLine("{0} {1} {2}", mindata, maxdata, mysum);


        }
    }
}

Measured memory_bytes: 9904
def hum(n):
  x = [0]*(n+1)
  x[1] = 1
  for e in [2, 3, 5]:
    for i in range(n/e+1):
      if x[i]: x[i*e] = 1
  return x

M = []
N = []
while 1:
  try: m,n = map(int, raw_input().split())
  except: break
  M.append(m)
  N.append(n)
H = hum(max(N))
for m, n in zip(M,N):
  print sum(H[m:n+1])

Measured memory_bytes: 34428
#include<iostream>
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>

using namespace std;

vector<long long> a, res;
vector<vector<long long>> mp;
vector<vector<long long >> dp;//[色][i回魔法を唱えたときの最小]
long long n, x;

int main() {
	cin >> n;
	cin >> x;
	a.resize(n);
	mp.resize(n);
	res.resize(n);
	dp.resize(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		dp[i].resize(n);
		dp[i][0] = a[i];
	}
	for (int i = 1; i < n; i++) {
		for (int j = 0; j < n; j++) {
			dp[j][i] = a[j] > dp[(n + j - 1) % n][(n + i - 1) % n] ? dp[(n + j - 1) % n][(n + i - 1) % n] : a[j];
		}
	}
	for (int i = 0; i < n; i++) {
		res[i] += i*x;
		for (int j = 0; j < n; j++) {
			res[i] += dp[j][i];
		}
	}
	sort(res.begin(), res.end());

	cout << res[0] << endl;
	//cin >> n;
	return 0;
}

Measured memory_bytes: 31616
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define P pair<ll, ll>
using ll = int64_t;
using namespace std;
#define ketasuu(n) fixed << setprecision(n)
#define btoe(p) p.begin(), p.end()
#define etob(p) p.rbegin(), p.rend()

//define gcd and lcm (using 64bit)
ll gcd(ll a, ll b)
{
    if (a < b)
    {
        //^はxor(bitwise operator)。以下三行でswap(a,b)を行っている。
        a ^= b;
        b ^= a;
        a ^= b;
    }
    //only when b==0,this program finds that b means false and returns a.
    return b ? gcd(b, a % b) : a;
}

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

int main(){
    ll n, m;
    cin >> n >> m;
    bool ok=true;
    vector<ll> p(n);
    ll l=1;
    rep(i,n) cin>>p[i];
    rep(i,n){
        p[i]/=2;
        l=lcm(l,p[i]);
        if(l>m){
            ok=false;
            l=1;
        }
    }
    rep(i,n){
        if((l/p[i])%2==0) ok=false;
    }
    if(!ok){
        cout<<0<<endl;
        return 0;
    }
    ll ans=(m+l)/(2*l);
    cout<<ans<<endl;
    return 0;
}

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

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

using namespace std;

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

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 (b<a) { a=b; return 1; } return 0; }

int main()
{
  int A, B, C, D;
  int tmp;
  cin  >> tmp;
  A = tmp/1000;
  B = (tmp/100)%10;
  C = (tmp/10)%10;
  D = tmp%10;

  
  for(int bit=0; bit<(1<<4); bit++)
    {
      for(int i=0; i<4; i++)
	{
	  ll tmp = 0;
	  char a[4];
	  tmp+=A;
	  if(bit&(1<<2))
	     {
	      tmp+=B;
	      a[1]='+';
	    }
	  else
	     {
	      tmp-=B;
	      a[1]='-';
	    }
	  if(bit&(1<<1))
	     {
	      tmp+=C;
	      a[2]='+';
	    }
	  else
	     {
	      tmp-=C;
	      a[2]='-';
	    }
	  if(bit&(1<<0))
	     {
	      tmp+=D;
	      a[3]='+';
	    }
	  else
	     {
	      tmp-=D;
	      a[3]='-';
	    }

	  if(tmp==7)
	    {
	      cout << A << a[1] << B << a[2] << C << a[3] << D  << "=7" <<endl;
	      return 0;
	    }
	}
    }


  return 0;
}


//cout << setprecision(13);
//next_permutation();
//__gcd();
//reverse();
//set ,tuple ,pair;
//bitset
//vector.find
//vector.count



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

int main() {
    int n;
    cin >> n;
    vector<pair<int, int> > tasks;
    for(int i = 0; i < n; i++){
        int a,b;
        cin >> a >> b;
        tasks.push_back(make_pair(b,a));
    }
    sort(tasks.begin(), tasks.end());
    int done = 0;
    bool able = true;
    for(int i = 0; i < n; i++){
        done += tasks[i].second;
        if(done > tasks[i].first) able = false;
    }
    cout << (able ? "Yes" : "No") << endl;
}

Measured memory_bytes: 2420
import java.util.Scanner;

class Main{

    static int selectionSort(int[] a, int n){
        int count = 0;
        for(int i = 0; i < n - 1; i++){
            int minj = i;
            for(int j = i; j < n; j++){
                if(a[j] < a[minj])
                    minj = j;
            }
                int tmp = a[i];
                a[i] = a[minj];
                a[minj] = tmp;    
                if(i != minj)
                count++;   
        }
        return count;
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int n = Integer.parseInt(sc.next());
        int[] a = new int[n];
        for(int i = 0; i < n; i++)
        a[i] = Integer.parseInt(sc.next());

        int counter = selectionSort(a, n);

        for(int i = 0; i < n - 1; i++)
        System.out.print(a[i] + " ");
        System.out.println(a[n - 1]);
        System.out.println(counter);
        
    }
}


Measured memory_bytes: 26184
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <bitset>
#include <ctime>
#include <random>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <sstream>
#pragma comment(linker, "/STACK:256000000")
using namespace std;

#define in(s) freopen(s, "r", stdin)
#define out(s) freopen(s, "w", stdout)
#define forn(i, n) for (int i = 0; i < n; i++)
#define endl '\n'
#define mp make_pair

typedef long long ll;
typedef long double ld;

const ll mod = (ll)1e+9 + 7ll;
const int MAXS = (int)1e+6 + 3;

int cnt[MAXS];

inline ll bin_pow(ll a, ll n) {
	ll u = a, res = 1ll;
	while (n) {
		if (n % 2ll == 1ll)
			res = (res * u) % mod;
		u = (u * u) % mod;
		n /= 2ll;
	}
	return res;
}

inline ll div_mod(ll a, ll b) {
	return a * bin_pow(b, mod - 2ll) % mod;
}

int main()
{
	//in("input.txt");
	//out("output.txt");
	srand(1373737);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int n;
	cin >> n;

	vector <ll> arr(n);
	forn(i, n)
		cin >> arr[i];

	forn(i, n) {
		ll x = arr[i];
		vector < pair<ll, int> > p;
		for (ll i = 2ll; i * i <= x; i++) {
			if (x % i == 0ll) {
				p.push_back(mp(i, 0));
				while (x % i == 0ll) {
					p.back().second++;
					x /= i;
				}
			}
		}
		if (x > 1ll)
			p.push_back(mp(x, 1));
		forn(j, (int)p.size())
			cnt[p[j].first] = max(cnt[p[j].first], p[j].second);
	}

	ll lcm = 1ll;
	for (int i = 1; i < MAXS; i++)
		lcm = lcm * bin_pow((ll)i, (ll)cnt[i]) % mod;

	ll ans = 0ll;
	forn(i, n)
		ans = (ans + div_mod(lcm, arr[i])) % mod;
	cout << ans;

	return 0;
}

Measured memory_bytes: 2944
#include <stdio.h>

int main( void ) {
	int i, j, n, data[ 100 ], cnt, tmp;

	for ( ; scanf( "%d", &n ), n; printf( "%d\n", cnt ) ) {
		for ( i = n; i--; scanf( "%d", data + i ) );

		cnt = 0;
		for ( i = 0; i < n - 1; i++ )
			for ( j = n - 1; j > i; j-- )
				if ( data[ j - 1 ] < data[ j ] ) {
					tmp = data[ j - 1 ];
					data[ j - 1 ] = data[ j ];
					data[ j ] = tmp;

					cnt++;
				}
	}

	return 0;
}

Measured memory_bytes: 600
s = gets.chomp

def check_even_str(str)
  if str[0...str.length/2] == str[str.length/2...str.length] then
    return true
  else
    return false
  end
end

i = 1
until check_even_str(s[0...(s.length - i)])
  i += 1
end

puts s.length - i

Measured memory_bytes: 1788
// failed to generate code

#include <bits/stdc++.h>
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 1000000000
#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())
vector<pair<string,P> >vec;

int main(){	
	ll N;
	cin >> N;
	vector<ll> a(N),b(3);
	map<ll,ll> m;
	ll k = 0;
	rep(i,N) {
		cin >> a[i];
		if (m[a[i]] == 0) {
			if (k == 0) b[0] = a[i];
			if (k == 1) b[1] = a[i];
			if (k == 2) b[2] = a[i];
			k++;
		}
		m[a[i]]++;
	}
	if ( (k == 3 && (b[0] ^ b[1]) == b[2] && m[b[0]] == m[b[1]] && m[b[0]] == m[b[2]]) 
		|| (k == 2 && ((b[0] == 0 && 2*m[b[0]] == m[b[1]]) || (b[1] == 0 && 2*m[b[1]] == m[b[0]])))
		|| (k == 1 && b[0] == 0) ) cout << "Yes" << endl; else cout << "No" << endl;
}


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


int main(){
  int N,K;
  cin >> N >> K;
  ll ans = 0;

  if (N == 1) {
    ans = K;
    printf("%ld\n", ans);
  }else{
    ans = K*pow(K-1,N-1);
    printf("%ld\n", ans);
  }

  return 0;
}


Measured memory_bytes: 512
import sys
readline = sys.stdin.readline
N = int(readline())
X = list(map(int, readline().split()))
X.sort()

INF = 10**9+7
ans = INF
for p in range(0, 102):
    res = 0
    for x in X:
        res += (p-x)**2
    ans = min(ans, res)
print(ans)


Measured memory_bytes: 9112
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ 666666
int n; pii ps[SZ];
int main()
{
	scanf("%d",&n);
	int mi=1e9,mx=0;
	#define rec(g) if(g<mi) mi=g; if(g>mx) mx=g;
	for(int i=1;i<=n;++i)
	{
		scanf("%d%d",&ps[i].fi,&ps[i].se);
		if(ps[i].fi>ps[i].se) swap(ps[i].fi,ps[i].se);
		rec(ps[i].fi) rec(ps[i].se)
	}
	#undef rec
	ll ans=1e18;
	int ma=-1e9,mb=1e9;
	for(int i=1;i<=n;++i)
		ma=max(ma,ps[i].fi),mb=min(mb,ps[i].se);
	ans=min(ans,(ma-mi)*ll(mx-mb));
	sort(ps+1,ps+1+n);
	ma=ps[n].fi; int lm=1e9;
	for(int i=1;i<=n;++i)
		ans=min(ans,(mx-mi)*ll(ma-min(ps[i].fi,lm))),
		ma=max(ma,ps[i].se),lm=min(lm,ps[i].se);
	printf("%lld\n",ans);
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>


using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<pair<int,int>> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i].first;
		a[i].second = i + 1;
	}

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

	for (int i = 0; i < n; i++) {
		cout << a[i].second;
		if (i < n - 1) cout << " ";
	}
	cout << endl;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
int main() {
	vector<vector<int> > a;
	vector<vector<int> > c;
	a.resize(3);
	c.resize(3);
	for(int i = 0; i < 3; ++i) {
		a[i].resize(3);
		c[i].resize(3);
	}
	for(int i = 0; i < 3; ++i) {
		for(int j = 0; j < 3; ++j) {
			cin >> a[i][j];
		}
	}
	int n;
	cin >> n;
	vector<int> b;
	b.resize(n);
	for(int i = 0; i < n; ++i) {
		cin >> b[i];
	}
	for(int i = 0; i < 3; ++i) {
		for(int j = 0; j < 3; ++j) {
			for(int k = 0; k < n; ++k) {
				if(a[i][j] == b[k]) {
					c[i][j] = 1;
				}
			}
		}
	}
	for(int i = 0; i < 3; ++i) {
		bool f = 1;
		for(int j = 0; j < 3; ++j) {
			if(c[i][j] == 0) {
				f = 0;
			}
		}
		if(f == 1) {
			cout << "Yes" << '\n';
			return 0;
		}
		f = 1;
		for(int j = 0; j < 3; ++j) {
			if(c[j][i] == 0) {
				f = 0;
			}
		}
		if(f == 1) {
			cout << "Yes" << '\n';
			return 0;
		}
	}
	bool f = 1;
	for(int i = 0; i < 3; ++i) {
		if(c[i][i] == 0) {
			f = 0;
		}
	}
	if(f == 1) {
		cout << "Yes" << '\n';
		return 0;
	}
	f = 1;
	for(int i = 0; i < 3; ++i) {
		if(c[i][2 - i] == 0) {
			f = 0;
		}
	}
	if(f == 1) {
		cout << "Yes" << '\n';
		return 0;
	}
	cout << "No" << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<60);
const ld pi=acosl((ld)1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};

bool solve(){
  ll ans=700;
  string s;cin>>s;
  if(s[0]=='o')ans+=100;
  if(s[1]=='o')ans+=100;
  if(s[2]=='o')ans+=100;
  cout<<ans<<endl;

  return false;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
	cout<<setprecision(30);
	return solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;


char inv(char c){
    if(c == 'S') return 'W';
    if(c == 'W') return 'S';
    return 0;
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string s, row;
    cin >> n >> s;
    s += s[0];
    s += s[1];
    vector<string> patterns = {"SS", "SW", "WS", "WW"};
    for(auto &p : patterns){
        row = p;
        FOR(i, 1, n){
            if(s[i] == 'o'){
                if(row[i] == 'S') row += row[i-1];
                if(row[i] == 'W') row += inv(row[i-1]);
            }else if(s[i] == 'x'){
                if(row[i] == 'S') row += inv(row[i-1]);
                if(row[i] == 'W') row += row[i-1];
            }
        }
        if(row[0] == row[n] && row[1] == row[n + 1]){
            row.pop_back();
            row.pop_back();
            cout << row << "\n";
            return 0;
        }
    }
    cout << -1 << "\n";
    return 0;
}


Measured memory_bytes: 712