akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<chrono>
#include<random>
#include<cstdio>
#include<set>
#include<map>
#include <functional>
#define MAX_N 100
#define MAX_M 100
#define INF 10000000
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

vector<pair<int,int>>a(8);
double dp[8][8];
int N;
double sum=0;

int main(){
    cin>>N;
    REP(i,N){
        cin>>a[i].first>>a[i].second;
    }
    REP(i,N){
        REP(j,N){
            dp[i][j]=sqrt(pow(a[i].first-a[j].first,2.0)+pow(a[i].second-a[j].second,2.0));
            dp[j][i]=dp[i][j];
        }
    }
    vector<int>data(N);
    REP(i,N){
        data[i]=i;
    }
    int d=0;
    do{
        double temp=0;
        REP(i,N-1){
            temp+=dp[data[i]][data[i+1]];
        }
        d++;
        sum+=temp;
    }while(next_permutation(data.begin(),data.end()));
    printf("%f",sum/d);
}


Measured memory_bytes: 888
def main():

    S = input()
    K = int(input())
    count = []

    ct = 1
    for i in range(1, len(S)):
        if(S[i] == S[i-1]): ct += 1
        else:
            count.append(ct)
            ct = 1
    count.append(ct)

    v = 0
    for c in count:
        v += c // 2

    if(len(count) == 1):
        return K*len(S) // 2
    elif S[0] == S[-1]:
        return K*v + (K-1)*((count[0]+count[-1])//2 - count[0]//2 - count[-1]//2)
    else:
        return K*v

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		char[] a = br.readLine().toCharArray();
		char[] b = br.readLine().toCharArray();
		String x;

			if (a[0] == b[2]&&a[1]==b[1]&&a[2]==b[0]) {
				x="YES";
			}else {
				x="NO";
			}
			System.out.println(x);
		}
	}

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

int main()
{
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i += 2)
  {
    int sum = 0;
    for (int j = 1; j <= i; j += 2)
    {
      if (i % j == 0)
        sum++;
    }
    if (sum == 8)
      ans++;
  }
  cout << ans << endl;

  return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))

#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s))
#define repiins(x, y, z, s) for ((x) = (z); (x) <= (y); (x) += (s))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)

#define All(x) (x).begin(),(x).end()

#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))

#define Unique(v) v.resize(unique(All(v)) - v.begin())

#define peq(p0, p1)(p0.first == p1.first && p0.second == p1.second)

#define End '\n'
#define Out(x) cout<<(x)<<End
#define OutP(p, sep, end) cout<<p.first<<sep<<p.second<<end

template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lb std::lower_bound
#define ub std::upper_bound

#define lbi(v, x) lb(All(v), (x))-v.begin()
#define ubi(v, x) ub(All(v), (x))-v.begin()

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);
	//std::cout.precision(18);

    int a, b, k;

	cin >> a >> b >> k;

  	V<int> v;
  
    int i;

	repiin(i, min(a, b), 1) if (a % i == 0 && b % i == 0) v.pb(i);
	
  	std::reverse(All(v));
  
  	k--;
  
  	Out(v[k]);
	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

void swap (int *x, int *y) {
  int temp;    // 値を一時保存する変数

  temp = *x;
  *x = *y;
  *y = temp;
}

int partition (int array[], int left, int right) {
  int i, j, pivot;
  i = left;
  j = right + 1;
  pivot = left;   // 先頭要素をpivotとする

  do {
    do { i++; } while (array[i] < array[pivot]);
    do { j--; } while (array[pivot] < array[j]);
    // pivotより小さいものを左へ、大きいものを右へ
    if (i < j) { swap(&array[i], &array[j]); }
  } while (i < j);

  swap(&array[pivot], &array[j]);   //pivotを更新

  return j;
}

void quick_sort (int array[], int left, int right) {
  int pivot;

  if (left < right) {
    pivot = partition(array, left, right);
    quick_sort(array, left, pivot-1);   // pivotを境に再帰的にクイックソート
    quick_sort(array, pivot+1, right);
  }
}

int main()
{
  int n, i;
  scanf("%d", &n);

  int v[n];
  for (i = 0; i < n; i++) {
    scanf("%d", &v[i]);
  }
  float ans;

 quick_sort(v, 0, n - 1);
  ans = ((float)v[0] + (float)v[1]) / 2;
 for (i = 2; i < n; i++) {
   ans = ((float)v[i] + ans) / 2;
 }


 printf("%f\n", ans);

 return 0;
}


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

int  main()
{
	int a,b;
	cin >> a >> b;
	set <int> st;
	st.insert(a);
	st.insert(b);
	rep1(i, 3)
	{
		if (!st.count(i))
			cout << i << endl;
	}
	return (0);
}

Measured memory_bytes: 256
from heapq import heappush, heappop
import sys
input = sys.stdin.buffer.readline

N, Q = map(int, input().split())
E = []

for i in range(N):
    s, t, x = map(int, input().split())
    E.append((0, t - x, x, i))
    E.append((1, s - x, x, i))

D = [int(input()) for _ in range(Q)]

E.sort(key=lambda a: a[1], reverse=True)

ans = []
que = [(10**18, -1)]
V = set()
for d in D:
    while E and E[-1][1] <= d:
        f, _, x, i = E.pop()
        if f == 0:
            V.add(i)
        else:
            heappush(que, (x, i))
    while que[0][1] in V:
        heappop(que)
    ans.append(que[0][0])

ans = [a if a < 10**18 else -1 for a in ans]
print(*ans, sep='\n')


Measured memory_bytes: 98176
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


N, M = list(map(int, sys.stdin.buffer.readline().split()))
AB = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(M)]

graph = [[] for _ in range(N)]
for a, b in AB:
    graph[a - 1].append(b - 1)
    graph[b - 1].append(a - 1)


# 二部グラフならマッチングの全パターン数
# そうじゃないなら全ての頂点間に辺を張れる

def bipartite():
    dist = [INF] * N
    que = deque([0])
    dist[0] = 0
    while que:
        v = que.pop()
        d = dist[v]
        for u in graph[v]:
            if dist[u] < INF and dist[u] % 2 == d % 2:
                # 二部グラフじゃない
                return 0, 0
            if dist[u] == INF:
                que.appendleft(u)
                dist[u] = d + 1
    evens = len([v for v in range(N) if dist[v] % 2 == 0])
    odds = len([v for v in range(N) if dist[v] % 2 == 1])
    return evens, odds


evens, odds = bipartite()
if evens == odds == 0:
    # 作れる辺の数
    count = N * (N - 1) // 2
else:
    count = evens * odds
ans = count - M
print(ans)


Measured memory_bytes: 54868
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		
		Scanner in = new Scanner(System.in);
		
		String S = in.next();
		String T = in.next();
		
		if (T.substring(0,T.length()-1).equals(S)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		
	}
}


Measured memory_bytes: 26856
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

s = STR()
t = STR()
l = len(s)
tmp = [[], []]
for i in range(len(s)):
    if not s[i] in tmp[0] and not t[i] in tmp[1]:
        tmp[0].append(s[i])
        tmp[1].append(t[i])
    else:
        if s[i] in tmp[0] and t[i] in tmp[1]:
            if tmp[0].index(s[i]) != tmp[1].index(t[i]):
                print('No')
                exit()
        else:
            print('No')
            exit()
print('Yes')



Measured memory_bytes: 63212
N = int(input())
A = [int(input()) for _ in range(N)]
max_num0 = max(A)
temp = A.index(max_num0)
A[temp] = 0
max_num1 = max(A)
A[temp] = max_num0

for i in range(N):
    if A[i] != max_num0:
        print(max_num0)
    else:
        print(max_num1)

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

int main()
{
	int H, W;
	while(cin >> H >> W && H != 0 || W != 0)
	{
		for(int i = 0; i < H; ++i)
		{
			for(int j = 0; j < W; ++j)
			{
				cout << ((i + j) % 2 == 0 ? "#" : ".");
			}
			cout << endl;
		}
		cout << endl;
	}

    return 0;
}



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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}




int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, m;
	cin >>n >>m;
	vector<VI> r(n);
	rep(i, m){
		int a, b; cin >>a >>b;
		r[a-1].push_back(b-1);
		r[b-1].push_back(a-1);
	}
	
	auto rec=[&](auto rec, int c, int zm)->ll{
		zm |= 1<<c;
		if(zm == (1<<n) -1) return 1;
		ll rt = 0;
		for(auto v: r[c]){
			if(zm >>v &1) continue;
			rt += rec(rec, v, zm);
		}
		return rt;
	};
	
	cout << rec(rec, 0, 0) <<"\n";
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize "03"
#include "bits/stdc++.h"
using namespace std;
 
#define int long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;

int dp[N][2];
vector<int> g[N];

void dfs(int u, int p){
	dp[u][0] = dp[u][1] = 1;
	for(int i: g[u]){
		if(i == p)	continue;
		dfs(i, u);
		dp[u][1] *= dp[i][0];
		dp[u][0] *= (dp[i][0] + dp[i][1]);	
		dp[u][1] %= mod;
		dp[u][0] %= mod;
	}
}
 
signed main() {
	IOS;
	#ifdef LOCAL
		freopen("input.txt","r", stdin);
		freopen("output.txt","w",stdout);
	#endif
	int n;	cin >> n;
	for(int i = 1; i <= n-1; i++){
		int u, v;
		cin >> u >> v;
		g[u].push_back(v);
		g[v].push_back(u);
	}	
	dfs(1, 0);
	cout << (dp[1][0] + dp[1][1]) % mod;
	return 0;
}


Measured memory_bytes: 10496
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<tuple>
#include<map>
#include<set>
#include<algorithm>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define MOD 1000000007
#define MAX 1000000001
#define INF 1410065408
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
struct edge{int from, to; ll cost;};

map< ll, vector<ll> > children;
ll dfs(ll d){
	vector<ll> d_children;
	for(ll child : children[d]){
		d_children.emplace_back(dfs(child));
	}
	if(d_children.size() == 0) return 0;
	else{
		sort(rall(d_children));
		rep((int)d_children.size()){
			d_children[i]+=i+1;
		}
		return *max_element(all(d_children));
	}
}

signed main(){
	int N;
	ll tmp;
	cin >> N;
	rep(N-1){
		cin >> tmp;
		children[tmp].emplace_back(i+2);
	}
	cout << dfs(1);
}


Measured memory_bytes: 23680
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i,j,k;
  int x[51][10],y[51][10],l[51],m,n,w,h;
  while(cin>>n&&n){
    cin>>m;
    for(i=0;i<m;i++)
      cin>>x[0][i]>>y[0][i];
    for(i=1;i<n+1;i++){
      cin>>l[i];
      for(j=0;j<l[i];j++)
	cin>>x[i][j]>>y[i][j];
    }
    for(i=1;i<n+1;i++){
      if(l[i]==m){
	w=x[0][0]-x[i][0];
	h=y[0][0]-y[i][0];
	for(j=0;j<m;j++){
	  x[0][j]-=w;
	  y[0][j]-=h;
	}
	for(j=0;j<4;j++){
	  for(k=0;k<m;k++){
	    if(x[0][k]!=x[i][k]||y[0][k]!=y[i][k])
	      break;
	  }
	  if(k==m){
	    cout<<i<<endl;
	    break;
	  }
	  for(k=1;k<m;k++){
	    swap(x[0][k],y[0][k]);
	    x[0][k]=y[0][0]-x[0][k]+x[0][0];
	    y[0][k]=y[0][k]-x[0][0]+y[0][0];
	  }
	}
	if(j==4){
	  w=x[0][0]-x[i][m-1];
	  h=y[0][0]-y[i][m-1];
	  for(j=0;j<m;j++){
	    x[0][j]-=w;
	    y[0][j]-=h;
	  }
	  for(j=0;j<4;j++){
	    for(k=0;k<m;k++){
	      if(x[0][k]!=x[i][m-k-1]||y[0][k]!=y[i][m-k-1])
		break;
	    }
	    if(k==m){
	      cout<<i<<endl;
	      break;
	    }
	    for(k=1;k<m;k++){
	      swap(x[0][k],y[0][k]);
	      x[0][k]=y[0][0]-x[0][k]+x[0][0];
	      y[0][k]=y[0][k]-x[0][0]+y[0][0];
	    }
	  }
	}
      }
    }
    cout<<"+++++"<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll mod=1e9+7;

int main(){
    ll d;
    cin >> d;
    vector<ll> c(26);
    rep(i,26){
        cin >> c[i];
    }
    vector<vector<pll>> s(d);
    rep(i,d){
        rep(j,26){
            ll v;
            cin >> v;
            s[i].push_back(make_pair(v,j+1));
        }
        sort(s[i].rbegin(),s[i].rend());
    }
    vector<ll> ans(d),used(26);
    ll tot=d;
    ll cnt=0;
    while(tot){
        rep(i,26){
            if(used[s[tot-1][i].se-1]==0){
                used[s[tot-1][i].se-1]=1;
                ans[tot-1]=s[tot-1][i].se;
                tot--;
                cnt++;
                break;
            }
        }
        if(cnt==26){
            for(ll i=d-27;i>=0;i--){
                ans[i]=s[i][0].se;
                tot--;
            }
            break;
        }
    }
    rep(i,d){
        cout << ans[i] << endl;
    }
    return 0;
} 

Measured memory_bytes: 3828
# Problem - D Partition

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

N, M = map(int, input().split())
gcd_max = 0 # 最大公約数の最大値
a_list = [[0]*N]
# 約数の列挙
divisor_list = make_divisors(M)

for d in divisor_list:
    check_sum = N * d
    if check_sum<=M:
        gcd_max = max(gcd_max, d)

print(gcd_max)


Measured memory_bytes: 3828
#include<stdio.h>
int Prime(int x){
  int h;
  if ( x < 2 ) return 0;
  else if ( x == 2 ) return 1;
  if ( x % 2 == 0 ) return 0;
  for ( h = 3; h*h <= x; h+=2 ){
    if ( x % h == 0 ) return 0;
  }
  return 1;
}
int main(){
  int n, x, f;
  int count = 0;
  scanf("%d", &n);
  for ( f = 0; f < n; f++ ){
    scanf("%d", &x);
    if ( Prime(x) ) count++;
  }
  printf("%d\n", count);  
  return 0;
}



Measured memory_bytes: 2052
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
sys.setrecursionlimit(10**7)
from pprint import pprint as pp
from pprint import pformat as pf
# @pysnooper.snoop()
#import pysnooper # debug

import math
#from sortedcontainers import SortedList, SortedDict, SortedSet # no in atcoder
import bisect

# a^2=b^2+c^2−2bc * cosA

if __name__ == '__main__':
    b, c, h, m = list(map(int, input().split()))
    angle_h = (h * 60 + m) / (12 * 60)
    anble_m = m / 60
    angle = abs(angle_h - anble_m) * 360

    #print('angle') # debug
    #print(angle) # debug
    angle = math.radians(angle)
    a2 = b ** 2 + c ** 2 -2 * b * c * math.cos(angle)
    a = math.sqrt(a2)
    #print('a') # debug
    print(a)

    #print('\33[32m' + 'end' + '\033[0m') # debug


Measured memory_bytes: 69068
#include <stdio.h>

int main(void)
{
	int a, b;		//Value a, b.
	double f;		//one of Answer.

	scanf("%d %d", &a, &b);

	printf("%d ", a / b);
	printf("%d ", a % b);
	f = (double)a / (double)b;
	printf("%f\n", f);

	return (0);
}



Measured memory_bytes: 2076
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
void chmin(int &a,int b){if(a>b) a=b;}

int main()
{
    string s,t;
    cin>>s;
    cin>>t;
    int N=s.length();
    for(int i=0;i<N;i++)
    {
        string temp=s.substr(N-1);
        s=temp+s.substr(0,N-1);
        if(s==t)
        {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
import sys
from math import pi, atan

a,b,x = [ int(x) for x in sys.stdin.readline().strip().split() ]
vh = a**2 * b / 2
if x>=vh: th = atan(2*(2*vh-x)/a**3)
else: th = pi / 2. - atan(2*x/a/b**2)
#
print(th*180/pi)


Measured memory_bytes: 38256
#include <iostream>
// cmath ではない
#include <math.h>
#include <iomanip> // for setprecision

using namespace std;

int main()
{
    double a, b, c;
    cin >> a >> b >> c;

    // c++ でのパイの作り方
    const double PI = acos(-1);
    double h = b * sin(c*PI/180);
    double S = h * a / 2;
    double L = a + b + sqrt( pow(a, 2) + pow(b, 2) - 2*a*b*cos(c*PI/180) );

    // +fixed で小数点下の桁数を指定
    cout << fixed << setprecision(6) << S << endl;
    cout << fixed << setprecision(6) << L << endl;
    cout << fixed << setprecision(6) << h << endl;

    return 0;
}


Measured memory_bytes: 3456
#include <iostream>
#include <vector>
#include <numeric>
using i64 = long long;

int main() {
    int n;
    std::cin >> n;
    std::vector<int> a(n);
    for (auto &e : a) std::cin >> e;

    const int x = std::accumulate(a.begin(), a.end(), 0, std::bit_xor<>());
    for (const int e : a) {
        std::cout << (x ^ e) << ' ';
    }
    std::cout << std::endl;

    return 0;
}


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

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(x) (x).begin(),(x).end()
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int , null_type , less<int> , rb_tree_tag , tree_order_statistics_node_update> ordered_set;

const int mod = 1e9+7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;

int p[109];
void solve()
{
	int n,x,i;
	cin>>x>>n;
	int ans=0;
	for(i=1;i<=n;i++)
	{
		int t;
		cin>>t;
		p[t]=1;
	}
	for(i=1;i<=101;i++)
	if(!p[i] && abs(x-ans)>abs(x-i)) ans=i;
	cout<<ans<<'\n';
}

int main()
{
	IOS
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 3692
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std;

const int N = 105;

int n, a[N];

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", a + i);
	sort(a + 1, a + n + 1);
	printf("%d\n", a[n] - a[1]);
	return 0;
}

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

int main() {
    int n;
    cin>>n;
    ll sump=0,summ=0;
    vector<pair<ll,ll>> bi;
    for (int i = 0; i < n; ++i) {
        string s;
        cin>>s;
        int nowkakko=0;
        stack<int> kakko,out;
        for (int j = 0; j < s.length(); ++j) {
            if(s[j]=='('){
                kakko.push(1);
            }
            else{
                if(!kakko.empty()){
                    kakko.pop();
                }
                else{
                    out.push(1);
                }
            }
        }
        int o=out.size();
        int ok=kakko.size();
        if(o==0)sump+=ok;//((
        else{
            if(ok==0)summ+=o;//))
            else{//)(
                bi.push_back(make_pair(o-ok,o));
            }
        }
    }
    sort(bi.begin(),bi.end());
    for (int k = 0; k < bi.size(); ++k) {
        if(sump<bi[k].second){
            cout<<"No"<<endl;
            return 0;
        }
        sump-=bi[k].first;
    }
    if(sump!=summ)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 7352
#include <iostream>
using namespace std;
const int c = 1e9 + 7;
int b[100005] = {0};
int main()
{
	int n;
	cin >> n;
	int a[100005] = {0};
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
		b[a[i]]++;
	}
	if(n % 2 == 1)//奇数情况 
	{
		if(b[0] != 1)
		{
			cout << "0" << endl;
			return 0;
		}
		for(int i = 2; i < n; i += 2)
		{
			if(b[i] != 2)
			{
				cout << "0" << endl;
				return 0;
			}
		}
	}
	else{//偶数 
		for(int i = 1; i < n; i += 2)
		{
			if(b[i] != 2)
			{
				cout << "0" << endl;
				return 0;
			}
		}
	}
	long long sum = 1;
	for(int i = 0; i < n / 2; i++)
	{
		sum = ((sum % c) * 2) % c;
	}
	cout << sum;
	return 0;
} 

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

#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a << " "; }); cout << endl;

const int INF = INT_MAX;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};

using PII = pair<int, int>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;
template<class T, int W=255> using A = array<T, W>;
template<class T, int W=255, int H=255> using A2 = array<array<T, W>, W>;

int H, W;
int h, w;

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cin >> H;
    cin >> W;
    cin >> h;
    cin >> w;

    cout << H * W - (H*w + W*h - (w * h)) << "\n";
}

Measured memory_bytes: 256
N = int(input())
A = [int(input()) for _ in range(N)]
A_max = 0
for i in range(N):
  A_max = max(A_max,A[i])
cnt = 0
for j in range(N):
  if A_max == A[j]:
    cnt += 1
  if cnt == 2:
    for _ in range(N):
      print(A_max)
    exit()
A[A.index(A_max)] = 0
A_second = 0
for l in range(N):
  A_second = max(A_second,A[l])
for m in range(N):
  print(A_second if A[m] == 0 else A_max)

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

#define print(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 
int main()
{
    int N, R;
    cin >> N >> R;
    if (N >= 10){
        cout << R;
    } else {
        cout << R + (100 * (10 - N));
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a1,b1,a2,b2;
	cin>>a1>>a2>>b1>>b2;
	a1=a1+a2;
	b1=b1+b2;
	if (a1>b1)
	cout<<"Left";
	if (a1<b1)
	cout<<"Right";
	if (a1==b1)
	cout<<"Balanced";
	cout<<endl;
    return 0;
}


Measured memory_bytes: 256
import Control.Monad
import Data.Char

main = do
  li <- getLine
  let [n,m] = map read $ words li
  scs <- forM [1..m] (\_ -> do
    li <- getLine
    let [s,c] = map read $ words li
    return (s,c)
    )
  let ans = compute n scs
  print ans

compute :: Int -> [(Int,Int)] -> Int
compute n scs = head (cans ++ [-1])
  where
    ds 1 = [0..9]
    ds 2 = [10..99]
    ds 3 = [100..999]
    cans = [ x | x <- ds n, check x scs ]

check x scs = all p scs
  where
    ds = map digitToInt $ show x
    p (s,c) = ds !! pred s == c

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

int main() {
    int h,w;
    string s;
    scanf("%d %d",&h,&w);
    for(int i=0;i<h;++i) {
        cin>>s;
        cout<<s<<'\n'<<s<<'\n';
    }
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Wed Mar 25 18:54:16 2020

@author: Kanaru Sato
"""

n = int(input())
Dict = {}
ans = 0

for i in range(n):
    s = list(input())
    s.sort()
    s = "".join(s)
    if s in Dict:
        ans += Dict[s]
        Dict[s] += 1
    else:
        Dict[s] = 1

print(ans)  

Measured memory_bytes: 17808
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <stack>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;

int n, ans, len;
string s;

inline int read() {
    int s = 0, f = 0;
    char ch = getchar();
    while (!isdigit(ch)) f |= ch == '-', ch = getchar();
    while (isdigit(ch)) s = (s<<3) + (s<<1) + (ch^48), ch = getchar();
    return f ? -s : s;
}

int main() {
    cin >> s;
    len = s.size();
    for(int i = 0; i < len; i++) {
        if(s[i] == 'C') {
            for(int j = i + 1; j < len; j++) {
                if(s[j] == 'F') {
                    printf("Yes\n");
                    return 0;
                }
            }
        }
    }
    printf("No\n");
    return 0;
}

Measured memory_bytes: 256
/**
 * @author yuzining
**/
#ifdef local
#include "D:\vscode\acm\local.hpp"
#else
#include<bits/stdc++.h>
using namespace std;
#define debug(...) do { } while(false)
void Main();
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  Main();
  return 0;
}
#endif

void Main() {
  int n; cin >> n;
  map<string, int> mp;
  for(int i = 0; i < n; i++) {
    string s; cin >> s;
    mp[s]++;
  }
  cout << "AC x " << mp["AC"] << "\n";
  cout << "WA x " << mp["WA"] << "\n";
  cout << "TLE x " << mp["TLE"] << "\n";
  cout << "RE x " << mp["RE"] << "\n";
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

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

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

using namespace std;

static const int INF = 1e9 + 7;

template<typename T>
using Vec = vector<T>;

template<typename T, typename T2>
using P = pair<T, T2>;

template<typename... Args>
using Tup = tuple<Args...>;

using llong = long long;
using ullong = unsigned long long;
using uint = unsigned int;

void hawawa()
{
  int n;
  int time = 0, nowx = 0, nowy = 0;
  cin >> n;
  while (n--) {
    int t, x, y;
    cin >> t >> x >> y;
    if (t - time < abs(x - nowx) + abs(y - nowy)) {
      cout << "No\n";
      return;
    }
    int c = abs(x - nowx) + abs(y - nowy) - (t - time);
    if (c % 2) {
      cout << "No\n";
      return;
    }
    time = t;
    nowx = x;
    nowy = y;
  }
  cout << "Yes\n";
}

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

Measured memory_bytes: 256
# AGC011B - Colorful Creatures
def main():
    N = int(input())
    A = sorted(map(int, input().split()))
    total, ng = 0, 0
    for i, a in enumerate(A):
        if a > total * 2:
            ng = i
        total += a
    ans = N - ng
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 14320
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;

int main()
{
   int N,M;
   scanf("%d%d",&N,&M);
   int a[N+1],b[N+1]={0},sum=N;
   int i;
   for(i=1;i<=N;i++)
    scanf("%d",&a[i]);
    for(i=0;i<M;i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        if(a[x]>=a[y]) {if(!b[y]) sum--;b[y]++;}
        if(a[x]<=a[y]) {if(!b[x]) sum--;b[x]++;}
    }
    cout<<sum<<endl;
    return 0;
}

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

int main(){

	double r;
	cin >> r;

	double men = r * r * 3.141592653589;
	double shu = r * 2 * 3.141592653589;
	cout << fixed << men << " " << fixed << shu << endl;

return 0;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int N;
vector<vector<pair<ll, ll>>> G;
vector<int> ans(N);

void get_ans(int i){

  for(int j = 0; j < G[i].size(); j++){
    if(ans[G[i][j].first] >= 0) continue;
    else{
      ans[G[i][j].first] = ans[i] ^ G[i][j].second;
      get_ans(G[i][j].first);
    }
  }
}

int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    
    cin >> N;
    G.assign(N, vector<pair<ll, ll>>());

    ll u, v, w;
    for(int i = 0; i < N-1; i++){
      cin >> u >> v >> w;
      u--;
      v--;
      G[u].push_back(make_pair(v, w%2));
      G[v].push_back(make_pair(u, w%2));
    }


    ans.assign(N, -1);

    ans[0] = 0;

    for(int i = 0; i < N ; i++){
      get_ans(i);
    }

    for(int i = 0; i < N; i++){
      if(ans[i] == 1){
        cout << '1' << endl;
      }else if(ans[i] == 0){
        cout << '0' << endl;
      }else{
        cout << "error" << endl;
      }
    }


    return 0;
}


Measured memory_bytes: 8960
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll zero = 0;
const ll INF = 10000000000000000; //10^16
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    ll A, B;
    cin >> A >> B;
    ll ans = 0;
    for (ll i = (A-1)/4 * 4; i < A; i++)
    {
        ans = ans ^ i;
    }
    for (ll i = B/4 * 4; i < B+1; i++) {
        ans = ans ^ i;
    }
    

    printf("%lld\n", ans);

}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
#define coutfix(i) cout << fixed << setprecision(i)		//coutの浮動小数出力の桁数設定
using namespace std;

int main()
{
	int64 nn, mai = 0, sum = 0, tmp, mina = 100000000000000;
	cin >> nn;
	vector<int64> aa(nn);
	for(int64 ii = 0;ii < nn;ii++)
	{
		cin >> aa[ii];
		tmp = aa[ii];
		if(tmp < 0)
		{
			mai++;
			tmp *= (-1);
		}
		sum += tmp;
		mina = min(mina, tmp);
	}
	if(mai % 2 == 0)
	{
		cout << sum << endl;
	}
	else
	{
		cout << (sum - 2 * mina) << endl;
	}
	return 0;
}

Measured memory_bytes: 4032
import sys
mod = 1000000007
N, M = map(int, input().split())
A = [int(s) for s in input().split()]
B = [int(s) for s in input().split()]
A.sort()
B.sort()
i = N
j = M
ans = 1
for n in range(N*M, 0, -1):
    if A[i-1] == n and B[j-1] == n:
        i -= 1
        j -= 1
    elif A[i-1] == n:
        i -= 1
        ans *= M - j
        ans %= mod
    elif B[j-1] == n:
        j -= 1
        ans *= N - i
        ans %= mod
    else:
        ans *= ((N - i) * (M - j) - (N*M - n)) % mod
        ans %= mod
print(ans % mod)


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

int main() {
  // input
  string S;
  cin >> S;
  
  // judge
  if (S[0] != 'A') {  // "A"
    cout << "WA" << endl;
    return 0;
  } else {
    S.erase(S.begin());
  }
  int C_pos = S.find("C", 1);
  if (C_pos == string::npos || C_pos == S.size() - 1) {  // "C"
    cout << "WA" << endl;
    return 0;
  } else {
    S.erase(S.begin() + C_pos);
  }
  for (int i = 0; i < S.size(); i++) {  // letter
    if (isupper(S[i])) {
      cout << "WA" << endl;
      return 0;
    }
  }
  
  // output
  cout << "AC" << endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] args) throws Exception{
		Scanner scan = new Scanner(System.in);
		int K = scan.nextInt();
		int S = scan.nextInt();

		int answer = 0;
		for(int x = 0; x <= K; x++) {
			for(int y = 0; y <= K; y++) {
				if(S-x-y<=K && S-x-y>=0) {
					answer++;
					//System.out.printf("%d,%d,%d\n",x,y,S-x-y);
				}
			}
		}
		System.out.println(answer);
	}
}


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

int main()
{
  long double A,B;
  cin >> A >> B;
  ll ans = A*B;;

  cout << ans << endl;
}

Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
int n,a[200010],b[200010];
long long ans=0;
bool w=false;
struct node{
	int pos,val;
	bool operator <(const node &b)const{
		return val<b.val;
	}
};
priority_queue<node>q;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++){
		scanf("%d",&b[i]);
		node tmp={i,b[i]};
		q.push(tmp);
	}
	while(q.size()){
		node now=q.top();q.pop();
		int l=(now.pos-2+n)%n+1,r=now.pos%n+1;
		if(b[now.pos]==a[now.pos]) continue;
		if(b[now.pos]-b[l]-b[r]<a[now.pos]){
			puts("-1");
			return 0;
		}
		int d=b[now.pos]-a[now.pos];
		ans+=d/(b[l]+b[r]);
		b[now.pos]=d%(b[l]+b[r])+a[now.pos];
		if(b[now.pos]==a[now.pos]) continue;
		node tmp={now.pos,b[now.pos]};
		q.push(tmp);
	}
	printf("%lld\n",ans); 
}

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
int const maxv = 1e5;
int n,m,w,v,res = 0;
long long dp[maxv+1];
int main(){
    ios::sync_with_stdio(0);cin.tie(0);
    cin>>n>>m;
    
    for(int i=0;i<=maxv;i++)
        dp[i]= 1e11;

    for(int i = 1;i<=n;i++){
        cin>>w>>v;
        for(int j=maxv;j>=v;j--) {
             dp[j] = min( dp[j] , dp[j-v] + w);
             if (dp[j]<=m) res = max(res,j);
        }
        dp[v] = min( 1LL*w , dp[v] );
        if (dp[v]<=m) res = max(res,v);
    }
    cout<<res;
}



Measured memory_bytes: 4432
#include <stdio.h>

int main(void){
int a[3][10][4] = {0};
int i, j, k;
int n, p;
int b, f, r, v; /* b棟f階r番目の部屋にv人 [階][部屋][棟] */

scanf("%d", &n);
for(i=0; i<n; i++){
scanf("%d%d%d%d", &b, &f, &r, &v);

a[f-1][r-1][b-1] += v;
}

for(k=0; k<4; k++){
for(i=0; i<3; i++){
for(j=0; j<10; j++){
if(a[i][j][k] == 0){
printf(" 0");
}else{
printf(" %d", a[i][j][k]);
}
}
printf("\n");
}
if(k != 3){
printf("####################\n");
}
}

return 0;
}


Measured memory_bytes: 2680
#include<iostream>
using namespace std;
#include<vector>
#include<functional>
template<typename T>
struct lazysegtree{
	function<T(T,T)>calcfn,lazycalcfn;
	function<T(T,T,unsigned int)>updatefn;
	int n;
	T defvalue,lazydefvalue;
	vector<T>dat,lazy;
	vector<bool>lazyflag;
	lazysegtree(int n_=0,T defvalue_=0,
		function<T(T,T)>calcfn_=[](T a,T b){return a+b;},
		function<T(T,T)>lazycalcfn_=[](T a,T b){return a+b;},
		function<T(T,T,unsigned int)>updatefn_=[](T a,T b,unsigned int width){return a+b*width;},
		T lazydefvalue_=0
	):defvalue(defvalue_),lazydefvalue(lazydefvalue_),
		calcfn(calcfn_),lazycalcfn(lazycalcfn_),updatefn(updatefn_)
	{
		n=1;
		while(n<n_)n<<=1;
		dat.assign(2*n-1,defvalue);
		lazy.assign(2*n-1,lazydefvalue);
		lazyflag.assign(2*n-1,false);
	}
	void copy(vector<T>v)
	{
		for(int i=0;i<v.size();i++)dat[i+n-1]=v[i];
		for(int i=n-2;i>=0;i--)dat[i]=calcfn(dat[2*i+1],dat[2*i+2]);
	}
	void eval(int i,int l,int r)
	{
		if(lazyflag[i])
		{
			dat[i]=updatefn(dat[i],lazy[i],r-l);
			if(r-l>1)
			{
				lazy[2*i+1]=lazycalcfn(lazy[2*i+1],lazy[i]);
				lazy[2*i+2]=lazycalcfn(lazy[2*i+2],lazy[i]);
				lazyflag[2*i+1]=lazyflag[2*i+2]=true;
			}
			lazy[i]=lazydefvalue;
			lazyflag[i]=false;
		}
	}
	void update(int a,int b,T x,int k=0,int l=0,int r=-1)
	{
		if(r<0)r=n;
		eval(k,l,r);
		if(b<=l||r<=a)return;
		else if(a<=l&&r<=b)
		{
			lazy[k]=lazycalcfn(lazy[k],x);
			lazyflag[k]=true;
			eval(k,l,r);
		}
		else
		{
			update(a,b,x,2*k+1,l,(l+r)/2);
			update(a,b,x,2*k+2,(l+r)/2,r);
			dat[k]=calcfn(dat[2*k+1],dat[2*k+2]);
		}
	}
	T query(int a,int b,int k=0,int l=0,int r=-1)
	{
		if(r<0)r=n;
		eval(k,l,r);
		if(b<=l||r<=a)return defvalue;
		else if(a<=l&&r<=b)return dat[k];
		else return calcfn(
			query(a,b,2*k+1,l,(l+r)/2),
			query(a,b,2*k+2,(l+r)/2,r)
		);
	}
};
int n,q;
main()
{
	cin>>n>>q;
	lazysegtree<int>P(n,(1LL<<31)-1,[](int a,int b){return a<b?a:b;},[](int a,int b){return b;},[](int a,int b,unsigned int width){return b;});
	for(int i=0;i<q;i++)
	{
		int c;cin>>c;
		if(c)
		{
			int s,t;cin>>s>>t;
			cout<<P.query(s,t+1)<<endl;
		}
		else
		{
			int s,t,x;cin>>s>>t>>x;
			P.update(s,t+1,x);
		}
	}
}


Measured memory_bytes: 4964
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long lint;
lint n, i, x, sumx, sumx2, ans = 0x3f3f3f3f, now;

lint getsum(int i) {
    return sumx2 + n * i * i - 2 * i * sumx;
}

lint bs() {
    lint r = -20000, p = 1LL << 15;
    while(p > 0) {
        if(getsum(r + p) > getsum(r + p + 1)) {
            r += p;
        }
        p >>= 1;
    }
    return r + 1;
}

int main()
{
    //freopen("f.in", "r", stdin);
    //freopen("f.out", "w", stdout);
    cin >> n;
    for(i = 1; i <= n; i ++) {
        cin >> x;
        sumx += x;
        sumx2 += x * x;
    }
    for(i = -20000; i <= 10000; i ++) {
        now = sumx2 + n * i * i - 2 * i * sumx;
        if(now < ans) { ans = now; }
    }
    //ans = bs();
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
import sys

n = int(input())
a = map(int, input().split())

# ans = sys.maxsize
# for an in a:
#   cnt = 0
#   while an % 2 == 0:
#     an /= 2
#     cnt += 1
#   if cnt < ans:
#     ans = cnt

ans = 0
isEven = True

while isEven:
  list_tmp = []
  for an in a:
    if an % 2 ==0:
      list_tmp.append(an / 2)
    else:
      isEven = False
      break;
  a = list_tmp
  ans += 1

print(ans - 1)


Measured memory_bytes: 64016
#include<bits/stdc++.h>
#include<vector>
#define N 100005
using namespace std;
vector<int> G[N];
int n,f[N];
void dfs(int t,int fa)
{
	int i;
	for(i=0;i<G[t].size();i++)
		if(G[t][i]!=fa)
			dfs(G[t][i],t),f[t]^=(f[G[t][i]]+1);
}
int main()
{
	int i,x,y;
	scanf("%d",&n);
	for(i=1;i<n;i++){
		scanf("%d %d",&x,&y);
		G[x].push_back(y);
		G[y].push_back(x);
	  }
	dfs(1,0);
	printf(f[1] ? "Alice" : "Bob");
	return 0;
}


Measured memory_bytes: 12288
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

int main()
{
	string s,c;
	int q,t,f;
	bool flag=true;
	cin>>s;
	cin>>q;
	for(int i=0;i<q;i++)
	{
		cin>>t;
		if(t==1)
		{
			if(flag)flag=false;
			else flag=true;
		}
		else
		{
			cin>>f>>c;
			if(f==1)
			{
				if(flag)s.insert(0,c);
				else s+=c;
			}
			else
			{
				if(flag)s+=c;
				else s.insert(0,c);
			}
		}
	}
	if(flag)cout<<s<<endl;
	else
	{
		reverse(s.begin(),s.end());
		cout<<s<<endl;
	}
	return 0;
}


Measured memory_bytes: 900
#include <bits/stdc++.h>
#define rep(i,s,e) for(int i = s; i < e; i++)
#define test(t) int t; cin >> t; while(t--) 
#define iterate(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define MOD 1000000007

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef set<int> si;
typedef long long ll;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  int a[n],b[n],c[n];
  int h[n][3];
  rep(i,0,n) {
    cin >> a[i] >> b[i] >> c[i];
  }
  h[0][0] = a[0];
  h[0][1] = b[0];
  h[0][2] = c[0];

  rep(i,1,n) {
    h[i][0] = max(h[i-1][1],h[i-1][2]) + a[i];
    h[i][1] = max(h[i-1][0],h[i-1][2]) + b[i];
    h[i][2] = max(h[i-1][0],h[i-1][1]) + c[i];
  }
  cout << max(max(h[n-1][0],h[n-1][1]),h[n-1][2]) << endl;
  return 0;
}


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

using namespace std;


using int64 = long long;
const int mod = 1e9 + 7;
// const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

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

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

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

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

int main() {
  int64 T1, T2, A1, A2, B1, B2;
  cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;

  if(A1 < B1) {
    swap(A1, B1);
    swap(A2, B2);
  }

  if(T1 * A1 + T2 * A2 == T1 * B1 + T2 * B2) {
    cout << "infinity" << endl;
    return 0;
  }

  //A1>B1

  if(T1 * A1 + T2 * A2 > T1 * B1 + T2 * B2) {
    cout << 0 << endl;
    return 0;
  }

  auto check = [&](__int128_t x) {
    auto latte = A1 * T1 * x + A2 * T2 * (x - 1);
    auto malta = B1 * T1 * x + B2 * T2 * (x - 1);
    return latte >= malta;
  };

  __int128_t ok = 0, ng = infll;
  while(ng - ok > 1) {
    auto mid = (ok + ng) / 2;
    if(check(mid)) ok = mid;
    else ng = mid;
  }


  auto check2 = [&](__int128_t x) {
    auto latte = A1 * T1 * x + A2 * T2 * (x - 1);
    auto malta = B1 * T1 * x + B2 * T2 * (x - 1);
    return latte == malta;
  };
  if(check2(ok)) cout << max(0LL, (int64) ok * 2 - 2) << endl;
  else cout << max(0LL, (int64) ok * 2 - 1) << endl;
}




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

using namespace std;
const int N = 100010;
int arr[N];
int main()
{
    int n;
    scanf("%d",&n);
    int ans = 0;
    for(int i = 0;i<n;i++) {
        int x;
        scanf("%d",&x);
        arr[x]++, arr[x+1]++, arr[x+2]++;
        ans = max(ans,max(max(arr[x],arr[x+1]),arr[x+2]));
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 640
def slove():
    import sys
    import collections
    input = sys.stdin.readline
    ls = list("abcdefghijklmnopqrstuvwxyz")
    d = collections.defaultdict(int)
    for v in ls:
        d[v]
    s = str(input().rstrip('\n'))
    for i in range(len(s)):
        d[s[i]] = 1
    for k, v in d.items():
        if v == 0:
            print(k)
            exit()
    print("None")


if __name__ == '__main__':
    slove()


Measured memory_bytes: 39280
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e18 + 3)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int n;
    cin >> n;
    int A[n];
    REP(i,n) cin >> A[i];
    int ans = 0;
    int check[n] = {};
    FOR(i,1,n){
        int tmp = 0;
        int migi = n - 1;
        int hidari = 0;
        while(1){
            if( migi - i <= 0 or   check[migi - i] == i) break;
            migi -= i;
            check[migi] =  i;
            if(hidari +i >= n - 1 or check[hidari + i] == i) break;
            hidari += i;
            check[hidari] = i;
            int a = migi;
            int b = a - i;
            if( a<= 0 or b <= 0) break;

            tmp += A[migi];
            tmp += A[hidari];
            chmax(ans,tmp);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define N 200003
#define LL long long
#define mod 998244353

int n,Q,nedge;
int head[N],ans[N],val[N];
struct Edge{
	int to,next;
}edge[2*N];

inline int read(){
	int X=0,w=0;
	char ch=0;
	while (ch<'0' || ch>'9')
	  w|=ch=='-',ch=getchar();
	while (ch>='0' && ch<='9')
	  X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
	return w ? -X : X;
}

inline void addedge(int a,int b){
	edge[nedge].to=b;
	edge[nedge].next=head[a];
	head[a]=nedge++;
}	

inline void dfs(int u,int fa,int sum){
	ans[u]=val[u]+sum;
	for (int i=head[u];i!=-1;i=edge[i].next){
		int v=edge[i].to;
		if (v==fa) continue;
		dfs(v,u,sum+val[u]);	
	}
}

int main(){
	n=read();Q=read();
	memset(head,-1,sizeof(head));
	for (int i=1;i<n;i++){
		int u=read(),v=read();
		addedge(u,v);
		addedge(v,u);	
	}
	for (int i=1;i<=Q;i++){
		int p=read(),x=read();
		val[p]+=x;	
	}
	dfs(1,0,0);
	for (int i=1;i<=n;i++)
	  printf("%d ",ans[i]);
	return 0;
}

Measured memory_bytes: 13440