akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s = "";
    cin >> s;
    int q;
    cin >> q;
    string query[q];
    vector<int> be;
    vector<int> af;
    getline(cin, query[0]);
    for (int i = 0; i < q; i++)
    {
        getline(cin, query[i]);
    }

    int beg = 0; //0 first 1 last

    for (int i = 0; i < q; i++)
    {
        if (query[i][0] == '1')
        {
            beg = beg == 0 ? 1 : 0;
        }
        else
        {
            if (query[i][2] == '1')
            {
                if (beg == 0)
                {
                    be.push_back(i);
                }
                else
                {
                    af.push_back(i);
                }
            }
            else
            {
                if (beg == 0)
                {
                    af.push_back(i);
                }
                else
                {
                    be.push_back(i);
                }
            }
        }
    }

    if (beg == 0)
    {
        for (vector<int>::reverse_iterator i = be.rbegin(); i != be.rend(); ++i)
        {
            cout << query[*i][4];
        }
        cout << s;
        for (int i : af)
        {
            cout << query[i][4];
        }
    }
    else
    {
        for (vector<int>::reverse_iterator i = af.rbegin(); i != af.rend(); ++i)
        {
            cout << query[*i][4];
        }
        reverse(s.begin(), s.end());
        cout << s;
        for (int i : be)
        {
            cout << query[i][4];
        }
    }

    return 0;
}

Measured memory_bytes: 12604
#include <iostream>
#include <cmath>
#include <string>

using namespace std;

typedef long long ll;

void solve(ll a, ll b, ll v[], int m) {
    for (int i = 0; i < m; i++) {
        if ( a + b >= 0 && a - b >= 0 ) {
            cout << "R";
            a -= v[i];
        } else if ( a + b >= 0 && a - b < 0 ) {
            cout << "U";
            b -= v[i];
        } else if ( a + b < 0 && a - b >= 0 ) {
            cout << "D";
            b += v[i];
        } else {
            cout << "L";
            a += v[i];
        }
    }
    cout << endl;
    return;
}

int main() {
    int N, m = 34;
    ll X[1003], Y[1003];
    ll d[34];
    ll  t = 1;
    for (int i = 0; i < 33; i++) {
        d[32-i] = t;
        t *= 2;
    }
    d[33] = 1;

    cin >> N;

    int even = 0, odd = 0;
    for (int i = 0; i < N; i++) {
        cin >> X[i] >> Y[i];
        if ( ( abs(X[i]) + abs(Y[i])) % 2 == 0) {
            even++;
        } else {
            odd++;
        }
    }
    if (even && odd) {
        cout << -1 << endl;
        return 0;
    }
    if (odd) { m -= 1; }
    cout << m << endl;

    for (int i = 0; i < m; i++) {
        cout << d[i];
        if (i == m-1) { cout << endl; }
        else { cout << " "; }
    }

    for (int i = 0; i < N; i++) {
        solve(X[i], Y[i], d, m);
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define all(x) x.begin(),x.end()
#define gll greater<ll>()


void solve(){
  double r;
  cin >> r;

  cout << setprecision(12) << 2.0*acos(-1.0)*r << endl; 
  
}

int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}  

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

using namespace std;

int main(){
  int N, max, next;
  cin >> N;
  int A[N], B[N];
  for(int i=0; i<N; i++)
    cin >> A[i];
    
  for(int i=0; i<N; i++) B[i] = A[i];
  sort(B, B+N);
  
  max = B[N-1]; next = B[N-2];
  
  for(int i=0; i<N; i++){
    if(A[i] == max) cout << next << endl;
    else cout << max << endl;
  }
 
  return 0;
}

Measured memory_bytes: 3200
using System;

namespace arc065_a
{
    class Program
    {
        static void Main(string[] args)
        {
            char[] a = Console.ReadLine().ToCharArray();
            Array.Reverse(a);
            string s = new string(a);
            bool ret = true;
            while (s.Length != 0 && ret)
            {
                string x = s.Substring(0, 5);
                if (x == "maerd") s = s.Substring(5, s.Length - 5);
                else if (x == "esare") s = s.Substring(5, s.Length - 5);
                else if (x + s[5] == "resare") s = s.Substring(6, s.Length - 6);
                else if (x + s[5] + s[6] == "remaerd") s = s.Substring(7, s.Length - 7);
                else ret = false;
            }
            Console.WriteLine(ret ? "YES" : "NO");
        }
    }
}

Measured memory_bytes: 29180
import math
A, B, H, M = map(int, input().split()) 

kaku = math.fabs(H/6 - 11*M/360) * 180
c_2 = A ** 2 + B ** 2 - 2 * A * B *  math.cos(math.radians(kaku))
print(c_2 ** 0.5)

Measured memory_bytes: 9492
use std::io::*;
use std::str::FromStr;

//https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn gcd (x:u64,y:u64) -> u64 {
    if x == 0 {
        return y;
    }else{
        return gcd(y%x,x);
    }
}

fn main(){
    let n: usize = read();
    let a: Vec<u64> = (0..n).map(|_| read()).collect();

    let mut l = 1;
    for i in a.iter(){
        let g = gcd(l,*i);
        l = l * ((*i)/g);
    }

    println!("{}",l);

}


Measured memory_bytes: 4352
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
const int L = 101010;
int n, q;
vector<vector<pair<int, int>>> query;
vector<int> ans, v, w;
vector<vector<int>> dp;
vector<int> vals, weights;
void dfs (int cur, int d) {
  if (cur > n) return;
  if (d <= 9) {
    vector<int> nxt(L);
    for (int i = 0; i < L; i++) {
      if (i - w[cur] >= 0) nxt[i] = max(nxt[i], dp.back()[i - w[cur]] + v[cur]);
      nxt[i] = max(nxt[i], dp.back()[i]);
      if (i > 0) nxt[i] = max(nxt[i], nxt[i - 1]);
    }
    dp.push_back(nxt);
    for (auto& p : query[cur]) {
      auto& id = p.second;
      auto& l = p.first;
      ans[id] = max(ans[id], dp.back()[l]);
    }
    dfs (cur * 2 + 1, d + 1);
    dfs (cur * 2, d + 1);
    dp.pop_back();
  } else {
    vals.push_back(v[cur]);
    weights.push_back(w[cur]);
    int k = vals.size();
    for (auto& p : query[cur]) {
      auto& id = p.second;
      auto& l = p.first;
      for (int mask = 0; mask < (1 << k); mask++) {
        int ww = 0;
        int vv = 0;
        for (int i = 0; i < k; i++) if ((1 << i) & mask) {
          ww += weights[i];
          vv += vals[i];
        }
        int rem = l - ww;
        if (rem < 0) continue;
        ans[id] = max(ans[id], dp.back()[rem] + vv);
      }
    }
    dfs(cur * 2 + 1, d + 1);
    dfs(cur * 2, d + 1);
    vals.pop_back();
    weights.pop_back();
  }
}
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> n;
  query = vector<vector<pair<int, int>>>(n + 1);
  v = vector<int>(n + 1);
  w = v;
  for (int i = 1; i <= n; i++) {
    cin >> v[i] >> w[i];
  }
  cin >> q;
  ans = vector<int>(q + 1);
  dp.push_back(vector<int>(L));
  for (int i = 1; i <= q; i++) {
    int v, l;
    cin >> v >> l;
    query[v].emplace_back(l, i);
  }
  dfs(1, 1);
  for (int i = 1; i <= q; i++) {
    cout << ans[i] << '\n';
  }
  return 0;
}


Measured memory_bytes: 22448
#include <stdio.h>

void bubblesort1(int A[], int N){
    int i,j ;
    int a;
    for(i=0;i<N;i++){
        for(j=0;j<N-1;j++){
            if(A[j] > A[j+1]){
                a = A[j] ;
                A[j] =  A[j+1] ;
                A[j+1] = a ;
            }
        }
    }
}

int main(){
    int N,i;
    double ans;
    int A[50];
    scanf("%d",&N);
    for(i=0;i<N;i++){
        scanf("%d",&A[i]);
    }
    bubblesort1(A,N);
    ans = A[0] ;
    for (i=1;i<N;i++){
        ans = (ans + A[i]) / 2 ;
    }
    printf("%lf\n",ans);
    return 0;
}

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

ll n, c;
ll d[31][31];
ll col[3][31];
int main() {
    cin>>n>>c;
    REP(i, 0, c) REP(j, 0, c) cin>>d[i][j];
    REP(i, 0, n) REP(j, 0, n){
        ll x;
        cin>>x;
        x--;
        col[(i+j)%3][x]++;
    }

    ll ans=inf;
    REP(i, 0, c){
        REP(j, 0, c){
            REP(k, 0, c){
                if(i==j || j==k || k==i) continue;

                ll sum=0;
                REP(l, 0, c){
                    sum+=d[l][i]*col[0][l];
                }
                REP(l, 0, c){
                    sum+=d[l][j]*col[1][l];
                }
                REP(l, 0, c){
                    sum+=d[l][k]*col[2][l];
                }
                ans=min(ans, sum);
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main()
{
    for(int i=0; ;i++)
    {
        string str;
        cin>>str;
        if(str=="0")break;
        int ans=0;
        for(int u=0;u<str.size();u++)
        {
            ans+=str[u]-'0';
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3188
//Sequence.cpp (C)
#include <iostream>
using namespace std;

long long ans(int n, int*, int change);

int main(){
  int n;
  int a[110000];
  cin >> n;
  for(int i = 0; i < n; i++) cin >> a[i];
  long long pAns,nAns;
  pAns = ans(n,a,1);
  nAns = ans(n,a,-1);
  printf("%lld\n",min(pAns,nAns));
}

long long ans(int n, int *a, int change){
  long long Ans = 0;
  long long sum = 0;
  for(int i = 0; i < n; i++){
    sum += a[i];
    switch (change) {
      case -1:
      if(sum > -1) Ans += 1 + sum, sum = -1;
      change *= -1;
      break;

      case 1:
      if(sum < 1) Ans += 1 - sum, sum = 1;
      change *= -1;
      break;
    }
  }

  return Ans;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
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; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n,l;
  cin>>n>>l;
  vll a(n);
  rep(i,n)cin>>a[i];
  pll ma=mp(0,0);
  for(int i=1;i<n;i++){
    if(ma.F<a[i]+a[i-1]){
      ma.F=a[i]+a[i-1];
      ma.S=i;
    }
  }
  if(ma.F<l){
    COUT("Impossible");
  }
  else{
    COUT("Possible");
    for(int i=1;i<ma.S;i++){
      COUT(i);
    }
    for(int i=n-1;i>=ma.S;i--){
      COUT(i);
    }
    
  }
}


Measured memory_bytes: 1664
import sys
sys.setrecursionlimit(10**6)
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
def resolve():
    N, M, K = lr()
    MOD = 998244353
    SIZE = 4*10**5+1
    SIZE += 1
    inv = [0]*SIZE  # inv[j] = j^{-1} mod MOD
    fac = [0]*SIZE  # fac[j] = j! mod MOD
    finv = [0]*SIZE # finv[j] = (j!)^{-1} mod MOD
    inv[1] = 1
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    for i in range(2,SIZE):
        inv[i] = MOD - (MOD//i)*inv[MOD%i]%MOD
        fac[i] = fac[i-1]*i%MOD
        finv[i]= finv[i-1]*inv[i]%MOD
    def choose(n,r): # nCk mod MOD の計算
        if 0 <= r <= n:
            return (fac[n]*finv[r]%MOD)*finv[n-r]%MOD
        else:
            return 0
    ans = 0
    for i in range(K+1):
        ans += choose(N-1, i)*M*pow((M-1), N-1-i, MOD)%MOD
        ans %= MOD
    print(ans)
resolve()

Measured memory_bytes: 77600
#include<stdio.h>
int main(void)
{
	long long x[4],a,b,c,d,mx;
	scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
	x[0]=a*c; x[1]=a*d; x[2]=b*c; x[3]=b*d;
	mx=x[0];
	for(int i=0;i<4;i++) if(mx<x[i]) mx=x[i];
	printf("%lld\n",mx);
	return 0;
}

Measured memory_bytes: 1696
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>

using namespace std;

#define PB push_back
#define ALL(v) (v).begin(), (v).end()
#define SZ size()
#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define REP(i, n) FOR((i), 0, (n))
#define GET(a) cin >> (a)
#define GET2(a, b) cin >> (a) >> (b)
#define GET3(a, b, c) cin >> (a) >> (b) >> (c)
#define SHOW(v) cout << (v) << endl
#define SHOW2(a, b) cout << (a) << " " << (b) << endl
#define SHOW3(a, b, c) cout << (a) << " " << (b) << " " << (c) << endl
#define MOD 1000000007
template<class T> void GETV(T &v) { REP(i, v.size()) { GET(v[i]); } }
template<class T> void SHOWV(T &v) { REP(i, v.size()) { SHOW(v[i]); } }

typedef long long ll;


int main()
{
	int n;
	cin >> n;
	
	int a;
	cin >> a;
	
	int b;
	cin >> b;
	
	vector<int> v(n);
	for(int i = 0; i < n; i++) {
		cin >> v[i];
	}
	
	vector<int> low;
	vector<int> mid;
	vector<int> high;
	for(int i = 0; i < n; i++) {
		if(v[i] <= a) {
			low.PB(v[i]);
		}
		else if (v[i] > b){
			high.PB(v[i]);
		}
		else {
			mid.PB(v[i]);
		}
	}
	
	int min = low.size();
	if(min > high.size()) {
		min = high.size();
	}
	if(min > mid.size()) {
		min = mid.size();
	}
	
	cout << min << endl;
	
    return 0;
}

Measured memory_bytes: 256
import heapq
class Dijkstra:
    INF = 1 << 63

    def __init__(self, N):
        self.MAX_V = N + 1
        self.dist = [self.INF] * self.MAX_V
        self.G = [[] for _ in range(self.MAX_V)]

    def insert(self, X, Y, cost): self.G[X].append((cost << 31) + Y)

    def dijkstra(self, st):
        q = []
        heapq.heappush(q, st)
        self.dist[st] = 0

        while len(q):
            p = heapq.heappop(q)
            cost = p >> 31
            node = p - (cost << 31)
            if cost > self.dist[node]: continue
            for to in self.G[node]:
                to_cost = to >> 31
                to_node = to - (to_cost << 31)
                to_cost += self.dist[node]
                if self.dist[to_node] > to_cost:
                    self.dist[to_node] = to_cost
                    heapq.heappush(q, (to_cost << 31) + to_node)

h, w = map(int, input().split())
sh, sw = map(int, input().split())
eh, ew = map(int, input().split())

sh -= 1
sw -= 1
eh -= 1
ew -= 1

S = [input() for _ in range(h)]

di = Dijkstra(h*w)
for x in range(h):
    for y in range(w):
        if S[x][y] == '#': continue
        for i in range(-2, 3):
            for j in range(-2, 3):
                X = x + i
                Y = y + j
                if X < 0 or Y < 0 or X >= h or Y >= w or S[X][Y] == '#': continue
                D = abs(i) + abs(j)

                if D == 1: di.insert(x * w + y, X * w + Y, 0)
                if D >= 2: di.insert(x * w + y, X * w + Y, 1)

di.dijkstra(sh * w + sw)
ans = di.dist[eh * w + ew]
if ans == (1 << 63): print(-1)
else: print(ans)


Measured memory_bytes: 216908
#include<bits/stdc++.h>
#define pi 3.1415  
#define ll long long
#define pii pair<int,int>
#define debug(a) cout<<a<<'\n'
#define maxn 100009
#define MOD 1000000007
#define INF (int)3000009
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    cout<<fixed<<setprecision(8);
    if(n==1)cout<<(double)1;
    else cout<<((double)((n+1)/2))/n<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
    int day[12]={31,29,31,30,31,30,31,31,30,31,30,31};
    int m,d;
    while(cin>>m>>d,m,d){
        int da=0;
        for(int i=0;i<m-1;i++){
            da+=day[i];
        }
        da+=d;
        da%=7;
        if(da==1)
            cout<<"Thursday"<<endl;
        if(da==2)
            cout<<"Friday"<<endl;
        if(da==3)
            cout<<"Saturday"<<endl;
        if(da==4)
            cout<<"Sunday"<<endl;
        if(da==5)
            cout<<"Monday"<<endl;
        if(da==6)
            cout<<"Tuesday"<<endl;
        if(da==0)
            cout<<"Wednesday"<<endl;

    }
    return 0;
}

Measured memory_bytes: 1152
// 与えられた根付き木 T の各節点 u について、以下の情報を出力するプログラムを作成してください。
// - u の節点番号
// - u の親の節点番号
// - u の深さ
// - u の節点の種類（根、内部節点または葉）
// - u の子のリスト
// ここでは、与えられる木は n 個の節点を持ち、それぞれ 0 から n−1 の番号が割り当てられているものとします。 

#include<stdio.h>
#include<stdlib.h>

#define MAX 100005
#define NIL -1

struct Node{
  int parent;
  int degree;   
  int *children;
  int depth; // D is the depth
};

struct Node T[MAX];
int n, H;

// Find the depth of a given node by tracking back to the parents until the root
int getDepth(int u){
  int d = 0;

  for(; T[u].parent != NIL ;d++) u = T[u].parent;

  return d;
}

// Print the information for a given node
void print(int u){
  int i, c;

  printf("node %d: ", u);
  printf("parent = %d, ", T[u].parent);
  printf("depth = %d, ", T[u].depth);

  if ( T[u].parent == NIL ) printf("root, ");
  else if ( T[u].degree == 0 ) printf("leaf, ");
  else printf("internal node, ");

  printf("[");
  for(i = 0; i< T[u].degree; i++){
    if (i) printf(", ");
    printf("%d", T[u].children[i]);
  }
  printf("]\n");
}

int main(){
  int i, j, d, v, c, l;

// Reset all nodes
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ){
    T[i].parent = NIL;
    T[i].degree=0;
  }

// Build the tree based on the input data
  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &v, &d); // v and d are the ID and degree of the node
    T[v].degree=d;
    if(d==0) continue;

    T[v].children=(int *)malloc(d*sizeof(int));
    for ( j = 0; j < d; j++ ){
      scanf("%d", &c);
      T[v].children[j]=c;
      T[c].parent = v;
    }
  }
  
  H = 0;
  for ( i = 0; i < n; i++ ){
    T[i].depth = getDepth(i);
    if ( T[i].depth > H ) H = T[i].depth;
  }

// Print the tree
  for ( i = 0; i < n; i++ ) print(i);
  return 0;
}



Measured memory_bytes: 5404
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

namespace B_ABC164
{
    class MainClass
    {

        static int[] s;

        public static void Main(string[] args)
        {
            s = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            int a = s[0];
            int b = s[1];
            int c = s[2];
            int d = s[3];
            while (true)
            {
                c -=b;
                if(c<=0){
                    WriteLine("Yes");
                    return;
                }
                a-=d;
                if(a<=0){
                    WriteLine("No");
                    return;
                }

            }

        }
    }
}


Measured memory_bytes: 28016
L,R=map(int,input().split())
l=L%2019
r=R%2019
if l<r and L+2019>=R:
  c=2020
  a=list(range(l,r+1))
  for i in range(len(a)-1):
    for j in range(i+1,len(a)):
      s_=a[i]*a[j]
      s=s_%2019
      c=min(c,s)
elif l>=r and L+2019>=R:
  r+=2019
  c=2020
  a=list(range(l,r+1))
  for i in range(len(a)-1):
    for j in range(i+1,len(a)):
      s_=a[i]*a[j]
      s=s_%2019
      c=min(c,s)
else:
  c=0
print(c)      
  


Measured memory_bytes: 3064
/*
	Author: @himkha_100
*/
#include<bits/stdc++.h>
#define MOD 1000000007
#define ll long long int
#define s(t) scanf("%d",&t)
#define p(t) printf("%d\n",t)
#define pb push_back
using namespace std;
int main()
{
	long int a,b,c;
	ll k;
	cin>>a>>b>>c>>k;
	ll ans=b-a;
	if(abs(ans)>=pow(10,18))
	{
		cout<<"Unfair\n";
		return 0;
	}
	if(k%2==1)
	{
		cout<<ans<<endl;
	}
	else
	{
		cout<<-ans<<endl;
	}
	return 0;
}


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

int main(){
  int N;
  string S;
  cin >> N >> S;
  
  int count=1;
  
  for (int i; i<N-1; i++) {
    if (S.at(i) != S.at(i+1)) count++;
  }
  
  cout << count << endl;
}


Measured memory_bytes: 512
from sys import exit
from math import gcd

def eratosthenes(n):
    '''
    n以下の整数の素数判定/列挙 (n > 1)
    O(NloglogN)
    '''
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    judge = [i for i in range(n+1)]
    
    for i in range(2, int(n**0.5) + 1):
        if is_prime[i]:
            for j in range(i*2, n+1, i):
                is_prime[j] = False
                judge[j] = i

    return judge


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

l = eratosthenes(10**6+1)

flag = True
used = [False] * (10**6+1)
for v in a:
    while v > 1:
        d = l[v]

        if used[d]:
            flag = False
        else:
            used[d] = True
        
        while v % d == 0:
            v //= d

if flag:
    print('pairwise coprime')
    exit()

g = a[0]
for v in a:
    g = gcd(g, v)

print('setwise coprime' if g == 1 else 'not coprime')

Measured memory_bytes: 234836
#include <iostream>
#include <vector>

/*
find 2

1 2 3 4 5 6 7 8 9
l       m       r
1 2 3 4 5 6 7 8 9
l   m   r
1 2 3 4 5 6 7 8 9
l m r

find 6

1 2 3 4 5 6 7 8 9
l       m       r
1 2 3 4 5 6 7 8 9
          l m   r
1 2 3 4 5 6 7 8 9
          m r
*/

void printVector(std::vector<int> &a) {
  int n = (int)a.size();
  for (int i = 0; i < n; i++) {
    std::cout << a[i];
    if (i < n - 1)
      std::cout << " ";
    else
      std::cout << std::endl;
  }
}

void printMark(int l, int r, int m, int n) {
  if (l == m)
    l = -1;
  if (r == m)
    r = -1;
  for (int i = 0; i < n; i++) {
    if (i == l)
      std::cout << 'l';
    else if (i == r)
      std::cout << 'r';
    else if (i == m)
      std::cout << 'm';
    else
      std::cout << " ";
    std::cout << " ";
  }
  std::cout << std::endl;
}

int binarySearch(std::vector<int> s, int x) {
  int n = (int)s.size(), l = 0, r = n, m;
  // std::cout << "find: " << x << std::endl;
  while (l < r) {
    m = (l + r) / 2;
    // printVector(s);
    // printMark(l, r, m, n);
    if (s[m] == x) return m;
    else if (x < s[m]) r = m;
    else l = m + 1;
  }
  return -1;
}

std::vector<int> *read() {
  int n;
  std::cin >> n;
  auto *s = new std::vector<int>(n, 0);
  for (int i = 0; i < n; i++) {
    std::cin >> s->at(i);
  }
  return s;
}

int main() {
  auto s = *read(), t = *read();
  int count = 0;
  for (int i = 0; i < (int)t.size(); i++) {
    if (binarySearch(s, t[i]) >= 0) {
      count++;
    }
  }
  std::cout << count << std::endl;
}



Measured memory_bytes: 4376
#include <bits/stdc++.h>
using namespace std;
int main()
{
 int A,B,C,D;
  cin>>A>>B>>C>>D;
  int L=A+B;
  int R=C+D;
  if(L>R){
    cout<<"Left"<<endl;
  }
  else if(L==R){
    cout<<"Balanced"<<endl;
  }
  else if(L<R){
    cout<<"Right"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
def resolve():
    '''
    code here
    '''

    N = int(input())
    A_list = [int(item) for item in input().split()]

    is_flag = True
    temp_list = A_list[:]
    prev_list = A_list[:]
    while is_flag:
        temp_min = min(temp_list)
        for i in range(N):
            if temp_list[i] % temp_min >= 1:
                temp_list[i] = temp_list[i] % temp_min

        if prev_list == temp_list:
            is_flag = False

        prev_list = temp_list[:]

    print(temp_min)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 14252
<?php
$input = trim(fgets(STDIN));
List($h, $w) = explode(" ", $input);

while(($h+$w) > 0) {

  $s1 = str_repeat("#", $w);
  $s2 = "#".str_repeat(".", $w-2)."#";
  echo $s1.PHP_EOL;

  for ($i=1; $i<$h-1; $i++) {
    echo $s2.PHP_EOL;
  }

  echo $s1.PHP_EOL.PHP_EOL;

  $input = trim(fgets(STDIN));
  List($h, $w) = explode(" ", $input);
}

Measured memory_bytes: 15172
#include<bits/stdc++.h>
#define N 102
using namespace std;

int main(){
  int dp[N][4][4]={},n,k,d[N]={};
  cin>>n>>k;
  int a,b;
  for(int i=0;i<k;i++)cin>>a>>b,d[a]=b;
    
  if(d[1]>0 && d[2]>0) dp[3][d[2]][d[1]]=1;
  else if(d[1]>0)for(int i=1;i<4;i++)dp[3][i][d[1]]=1;
  else if(d[2]>0)for(int i=1;i<4;i++)dp[3][d[2]][i]=1;
  else{
    for(int i=1;i<4;i++)
      for(int j=1;j<4;j++)dp[3][j][i]=1;
  }
  
  for(int x=1;x<=n;x++){
    for(int d1=1;d1<4;d1++){
      for(int d2=1;d2<4;d2++){
	if(d[x]==d1 && d1==d2) continue;
	if(d[x]) dp[x+1][d[x]][d1]=(dp[x][d1][d2]+dp[x+1][d[x]][d1])%10000;
	else{
	  for(int i=1;i<4;i++){
	    if(d2==i && d2==d1)continue;
	    dp[x+1][i][d1]=(dp[x][d1][d2]+dp[x+1][i][d1])%10000;
	  }
	}
      }
    }
  }
  
  int ans=0;
    for(int i=1;i<4;i++)
      for(int j=1;j<4;j++)ans+=dp[n+1][i][j] ;
    
  cout<<ans%10000<<endl;
  
  return 0;
}

Measured memory_bytes: 1168
#include <iostream>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node { int p, l, r; };

Node t[MAX];
int n, d[MAX];

void print(int u){
  int i,c;
  cout << "node " << u << ": ";
  cout << "parent = " << t[u].p << ", ";
  cout << "depth = " << d[u] << ", ";

  if ( t[u].p == NIL ) cout << "root, ";
  else if ( t[u].l == NIL ) cout << "leaf, ";
  else cout << "internal node, ";

  cout << "[";

  for (i = 0,c = t[u].l; c != NIL ; i++, c = t[c].r) {
    if (i) cout << ", ";
    cout << c;
  }
  cout << "]" << endl;
}

int rec(int u, int p){
  d[u] = p;
  if (t[u].r != NIL) rec(t[u].r, p);
  if (t[u].l != NIL) rec(t[u].l, p+1);
  return p;
}

int main(){
  int i,j,d,v,c,l,r;
  cin >> n;
  for(i = 0; i < n; i++) t[i].p = t[i].l = t[i].r = NIL;

  for(i = 0; i < n; i++){
    cin >> v >> d;
    for(j = 0;j<d;j++){
      cin >> c;
      if (j == 0) t[v].l = c;
      else t[l].r = c;
      l = c;
      t[c].p = v;
    }
  }
  for (i = 0; i<n ; i++){
    if(t[i].p == NIL) r = i;
  }

  rec(r,0);

  for(i = 0;i<n;i++) print(i);

  return 0;
}
  



Measured memory_bytes: 7684
#include<iostream>
#include<vector>
#include<algorithm>
#include<tuple>
using namespace std;

int main(){
	int n;
	cin>>n;
	vector<tuple<string,int,int> >a;
	for(int i=1;i<=n;i++){
		string s;
		int p;
		cin>>s>>p;
		p=-p;
		a.push_back(tie(s,p,i));
	}
	sort(a.begin(),a.end());
	for(int i=0;i<=n-1;i++){
		cout<<get<2>(a[i])<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int n = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		for(int i = 0; i < n; i++) {
			String s = sc.next();
			String[] num = s.split(",");
			a[i] = Integer.parseInt(num[0]);
			b[i] = Integer.parseInt(num[1]);
		}
		sc.close();
		int[] ans = new int[w];
		for(int i = 1; i <= w; i++) {
			int k = i;
			for(int j = 0; j < n; j++) {
				if(a[j] == k) {
					k = b[j];
				}else if(b[j] == k) {
					k = a[j];
				}
			}
			ans[k-1] = i;
		}
		for(int i : ans) {
			System.out.println(i);
		}
	}
}


Measured memory_bytes: 26048
import sys
def input():
	return sys.stdin.readline().strip()

X, Y = list(map(int, input().split()))

total = 0
if X == 3:
	total += 100000
elif X == 2:
	total += 200000
elif X == 1:
	total += 300000

if Y == 3:
	total += 100000
elif Y == 2:
	total += 200000
elif Y == 1:
	total += 300000

if X == 1 and Y == 1:
	total += 400000

print(total)

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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl ;
#define Yes cout << "Yes" << endl ;
#define NO cout << "NO" << endl ;
#define No cout << "No" << endl ;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main ()
{
    fastio
    
    lli num ; cin >> num ;
    cout << num / 2 * ceil (num / 2.0) << endl ;

    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int n,i,a;
	bool flag = true;
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> a;
		if(a%2){
			continue;
		}
		if(a%3 && a%5){
			flag = false;
		}
	}
	cout << (flag?"APPROVED":"DENIED") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int mod=1e9+7;
const int N=2e5+100;
ll a[N];
int f[5];
bool cmp(int x,int y)
{
    return abs(x)<abs(y);
}
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++) {
        cin>>a[i];
        if(a[i]>=0) f[1]++;
        else f[2]++;
    }
    int l=1,r=n;
    ll ans=1;
     if(!f[1]&&m%2==1){
        sort(a+1,a+1+n,cmp);
        for(int i=1;i<=m;i++){
            ans=a[i]*ans%mod;
        }
    }
    else {
        sort(a+1,a+1+n,greater<int>());
    while(m>0){
        if(m%2) ans=ans*a[l]%mod,l++,m--;
        else if(m>=2){
           if(a[l]*a[l+1]>=a[r]*a[r-1]){
              ans=ans*a[l]%mod*a[l+1]%mod;
              l+=2;
              m-=2;
           }
           else{
            ans=ans*a[r-1]%mod*a[r]%mod;
            r-=2;
            m-=2;
           }
        }
    }
    }
    cout<<(ans%mod+mod)%mod<<endl;
    return 0;
}



Measured memory_bytes: 5224
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,Q;
  string S;
  cin>>N>>S>>Q;
  vector<int> K(Q);
  for(int i=0;i<Q;i++){
    cin>>K[i];
  }
  for(int q=0;q<Q;q++){
    long long D=0,M=0,C=0;
    long long A=0;
    for(int i=0;i<N;i++){
      if(S[i]=='D'){
        D++;
      }else if(S[i]=='M'){
        M++;
        C+=D;
      }else if(S[i]=='C'){
        A+=C;
      }
      if(i>=(K[q]-1)){
        if(S[i-K[q]+1]=='D'){
          D--;
          C-=M;
        }else if(S[i-K[q]+1]=='M'){
          M--;
        }
      }
    }
    cout<<A<<"\n";
  }
}

Measured memory_bytes: 5320
n = gets.to_i
hs1 = gets.split.map(&:to_i)
hs2 = hs1.dup

hs2.shift
hs1.pop

result = hs1
  .zip(hs2)
  .map{|h|
    if h[0] - h[1] >= 0
      "1"
    else
      "0"    
    end
  }.join("")
  .split("0")
  .map{|s| s.size}

if result.size == 0
  puts 0
else
  puts result.max
end


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

double Solve(int n, double a, double d) {
  if (n == 1) {
    return (a + (a + d)) / 2.0;
  }
  double l = a + d * (2.0 * n - 1.0);
  double a_new = ((2.0 * n + 2.0) * a + 5.0 * d) / (2.0 * n);
  double l_new = ((2.0 * n + 2.0) * l - 5.0 * d) / (2.0 * n);
  double d_new = (l_new - a_new) / (2.0 * n - 3.0);
  return (a + l) / 2.0 + Solve(n - 1, a_new, d_new);
} 

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

  cout << setprecision(10);

  int n;
  double a;
  double d;
  cin >> n >> a >> d;
  cout << Solve(n, a, d) << endl;
}

Measured memory_bytes: 10040
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD = 1000000007;
const int INF = 1e12;
using Graph = vector<vector<int>>;

signed main(){
  string S, T;
  cin >> S >> T;
  int N = (int)S.size();
  int M = (int)T.size();
  int ans = M;
  for( int i = 0; i <= N-M; i++ ){
    string subS = S.substr(i, M);
    int now = 0;
    for( int j = 0; j < M; j++ ){
      if( subS[j] != T[j] ) now++;
    }
    ans = min(ans, now);
  }
  cout << ans << endl;

}

Measured memory_bytes: 3628
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define reverse_array(type, a, n)         \
    do {                                  \
        for (int i = 0; i < n / 2; i++) { \
            type __t = a[i];              \
            a[i] = a[n - 1 - i];          \
            a[n - 1 - i] = __t;           \
        }                                 \
    } while (0)

int main(void)
{
    char s[100001];
    scanf("%s", s);

    int s_len = strlen(s);

    int* children_num = calloc(s_len, sizeof(int));

    for (int direction = 0; direction < 2; direction++) {
        int count = 0;
        for (int i = 0; i < s_len; i++) {
            if (s[i] == 'R') {
                count++;
            } else {
                children_num[i - 1] += (count + 1) / 2;
                children_num[i] += count / 2;
                count = 0;
            }
        }

        reverse_array(char, s, s_len);
        reverse_array(int, children_num, s_len);

        for (int i = 0; i < s_len; i++) {
            s[i] = (s[i] == 'R' ? 'L' : 'R');
        }
    }

    for (int i = 0; i < s_len; i++) {
        printf("%d ", children_num[i]);
    }
    putchar('\n');

    free(children_num);
    return 0;
}


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


int main() {
  ll n,k;
  cin>>n>>k;
  vector<ll> a(n);
  rep(i,n)cin>>a[i];
  ll l=0;
  ll r=1000000001;
  while(l+1<r){
    ll c=(l+r)/2;
    ll cnt=0;
    rep(i,n){
      ll now=(a[i]+c-1)/c;
      cnt+=now-1;
    }
    if (cnt>k){
      l=c;
    }
    else r=c;
    //cout<<"l"<<l<<"r"<<r<<endl;
  }
  cout<<r;
}


Measured memory_bytes: 4840
import collections
import math

def cmb_factorial(s):
    return math.factorial(s) // (math.factorial(2) * math.factorial(s - 2))

n = int(input())
a = list(map(int, input().split()))
c = collections.Counter(a)
f = {}

cmb = 0
for x in c.values():
    f[1] = 0
    f[2] = 1
    if x >= 3:
        f[x] = cmb_factorial(x)
        if x - 1 not in f:
            f[x - 1] = cmb_factorial(x - 1)
    cmb += f.get(x)

for z in a:
    y = c.get(z)
    ans = cmb
    if y >= 2:
        ans = cmb - f.get(y) + f.get(y - 1)
    print(ans)

Measured memory_bytes: 33920
#include<stdio.h>
int main(void)
{
	int s[100][100];
	int sum[100];
	int change;
	int n=1;
	int i, t,j;
	j = 0;
	while (n)
	{
		sum[j] = 0;
		scanf("%d", &n);
		for (i = 0; i < n; i++)
		{
			scanf("%d", &s[j][i]);
		}
		for (i = 0; i < n; i++)
		{
			for (t = i; t < n; t++)
			{
				if (s[j][i] < s[j][t])
				{
					change = s[j][i];
					s[j][i] = s[j][t];
					s[j][t]=change;
				}
			}
		}
		for (i = 1; i < n - 1; i++)
		{
			sum[j] += s[j][i];
		}
		sum[j] = sum[j] / (n - 2);
		j++;
	}
	for (i = 0; i < j-1; i++)
	{
		printf("%d\n", sum[i]);
	}
	return 0;
}


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

int main(){
  int X, N;
  cin >> X >> N;
  vector<int> P(200);
  for(int i = 0; i < N; ++i){
    int p;
    cin >> p;
    ++P[p];
  }
  int ans = -1, d = 200;
  for(int i = 0; i < 200; ++i){
    if(P[i]) continue;
    if(d > abs(i-X)){
      d = abs(i-X);
      ans = i;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define int long long int
using namespace std;
#define pb push_back
int32_t main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	string s,t;
	cin >> s >> t;
	int ans=1000000;
	int n=s.length();
	int m=t.length();
	for(int i=0;i<=n-m;i++){
		int l=i,h=0;
		int c=m;int count=0;
		while(c--){
			if(s[l]!=t[h]){
				count++;
			}
			l++;h++;
		}
		ans=min(ans,count);
	}
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
using namespace std;
long long a,b,c,s;
int main()
{
    cin>>a>>b>>c;
      for(int i=1;i<=b*1000;i++)
        {
            if (a*i % b==c) 
            {
                cout<<"YES";
                s=1;
                break;
            }
        }
        if (s!=1) cout<<"NO";
        return 0;
}

Measured memory_bytes: 256
#include <stdlib.h>
#include <iostream>
#include <stack>
#include <string>
using namespace std;

int main() {
	stack<int> S;
	string ch;
	int a, b;

	while (cin >> ch)
	{
		switch(ch[0])
		{
		case '+':
			a = S.top();
			S.pop();
			b = S.top();
			S.pop();
			S.push(a+b);
			break;
		case '-':
			a = S.top();
			S.pop();
			b = S.top();
			S.pop();
			S.push(b-a);
			break;
		case '*':
			a = S.top();
			S.pop();
			b = S.top();
			S.pop();
			S.push(a*b);
			break;
		default:
			S.push(atoi(ch.c_str()));
		}
	}

	cout << S.top() << endl;
	return 0;
}

Measured memory_bytes: 3184
x, n = map(int, input().split())
p = [int(i) for i in input().split()]

min = 1000
pre_i = 0
for i in range(102):
    if i in p:
        continue
    if min > abs(x - i):
        min = abs(x - i)
    else:
        break
    pre_i = i

print(pre_i)


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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

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

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	string s;
	cin >> s;
	for(auto x : s)
		if(x == ',')
			cout << " ";
		else
			cout << x;
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<vector>

using namespace std;

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

struct Num{
  Num() {}
  Num(int n) : n(n) {
    stringstream ss;
    ss << n;
    ss >> s;
  }
  int n;
  string s;
};

string ope[] = {"+", "-", "*"};

Num calc(Num a, Num b, int k) {
  Num num;
  switch (k) {
  case 0: num.n = a.n + b.n; break;
  case 1: num.n = a.n - b.n; break;
  case 2: num.n = a.n * b.n; break;
  }
  num.s = "(" + a.s + " " + ope[k] + " " +b.s + ")";
  return num;
}

bool solve(vector<Num> v) {
  if (v.size() == 1u) {
    if (v[0].n == 10) {
      cout << v[0].s << endl;
      return true;
    }
    return false;
  }
  rep (i, v.size()) rep (j, v.size()) if (i != j) rep (k, 3) {
      vector<Num> next;
      next.push_back(calc(v[i], v[j], k));
      rep (l, v.size()) if (i != l && j != l) next.push_back(v[l]);
      if (solve(next)) return true;
    }
  return false;
}

int main() {
  while (true) {
    int a[4];
    rep (i, 4) cin >> a[i];
    if (a[0] == 0) break;
    vector<Num> v;
    rep (i, 4) v.push_back(a[i]);
    if (!solve(v)) {
      cout << 0 << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1236
package main
 
import (
    "bufio"
    "fmt"
    "os"
    "strconv"
    "math"
)

func main(){
    
    N := nextInt()
    a := nextInts(N)
    ans := math.MaxInt32
 
	for i := -100; i < 101; i++ {
		var sum int
		for _, v := range a {
			sum += (v - i) * (v - i)
		}
		if sum < ans {
			ans = sum
		}
	}
 
	fmt.Println(ans)
}
 
/* templates */
 
func Max(a []int) int {
    r := a[0]
    for i := 0; i < len(a); i++ {
        if r < a[i] {
            r = a[i]
        }
    }
    return r
}
 
func Min(a []int) int {
    r := a[0]
    for i := 0; i < len(a); i++ {
        if r > a[i] {
            r = a[i]
        }
    }
    return r
}
 
func Sum(a []int) (r int) {
    for i := range a {
        r += a[i]
    }
    return r
}
 
func Abs(a float64) float64 {
    if a < 0 {
        return -a
    }
    return a
}
 
type Pair struct {
    a, b int
}
 
type Pairs []Pair
 
func (p Pairs) Len() int {
    return len(p)
}
 
func (p Pairs) Swap(i, j int) {
    p[i], p[j] = p[j], p[i]
}
 
func (p Pairs) Less(i, j int) bool {
    return p[i].b < p[j].b
}
 
var nextReader func() string
 
func init() {
    nextReader = NewScanner()
}
 
func NewScanner() func() string {
    r := bufio.NewScanner(os.Stdin)
    r.Buffer(make([]byte, 1024), int(1e+11))
    r.Split(bufio.ScanWords)
    return func() string {
        r.Scan()
        return r.Text()
    }
}

func nextString() string {
    return nextReader()
}
 
func nextInt64() int64 {
    v, _ := strconv.ParseInt(nextReader(), 10, 64)
    return v
}
 
func nextInt() int {
    v, _ := strconv.Atoi(nextReader())
    return v
}
 
func nextInts(n int) []int {
    r := make([]int, n)
    for i := 0; i < n; i++ {
        r[i] = nextInt()
    }
    return r
}

func nextStrings(n int) []string {
    r := make([]string, n)
    for i := 0; i < n; i++ {
        r[i] = nextString()
    }
    return r
}

func nextFloat64() float64 {
    f, _ := strconv.ParseFloat(nextReader(), 64)
    return f
}


Measured memory_bytes: 640
($N,$Q)=glob<>;
if($N==1){
	printf"%d\n",sort{$a-$b}split for<>
}else{
	for(<>){
		($v,$w)=split;
		@v=$v;push@v,$v=($v+$N-2)/$N|0while$v;
		@w=$v;push@w,$w=($w+$N-2)/$N|0while$w;
		while($v==$w){
			$v=pop@v;
			$w=pop@w;
			$v==$w&&($x=$v);
			@v&&@w||last
		}
		print$x,$/
	}
}


Measured memory_bytes: 17664
#include<bits/stdc++.h>
using namespace std;
main(){
  int n, m, s, k, c;
  while(cin>>n>>m, n){
    int a[10001]={}, b[10001]={}, ma=0, mi=100000;
    for(int i=0;i<m;i++){
      cin>>s>>k;
      if(k==1){
        cin>>c;
        a[c]+=s;
        b[c]+=s;
      }else{
        for(int i=0;i<k;i++){
          cin>>c;
          a[c]+=s;
        }
      }
    }
    int x;
    for(int i=1;i<=n;i++){
      if(a[i]>ma){
        ma=a[i];
        x=i;
      }
    }
    for(int i=1;i<=n;i++){
      if(i!=x){
        mi=min(mi, b[i]);
      }
    }
    cout<<ma-mi+1<<endl;
  }
}

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

int main(){
    int n;
    string s;
    cin >> n >> s;
    for (auto s_i:s){
        int idx = alpha.find(s_i) + n;
        if (idx >= 26) idx -= 26;
        cout << alpha[idx];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#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++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define foreach(i,n) for(auto &&i:n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define GSORT(x) sort(all(x), greater<int>())
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x) int x;cin >> x
#define cill(x) LL x;cin >> x
#define cis(x) string x;cin >> x
#define co(x) cout << x << endl
#define dump(x)  cout << #x << " = " << (x) << endl
#define truecheck assert
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef long long int64;
template<class T,class U>bool chmax(T &a, const U &b) { if (a<b) { a=b; return true; } return false; }
template<class T,class U>bool chmin(T &a, const U &b) { if (b<a) { a=b; return true; } return false; }
const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;

int main() {
    fastcin();
    cout << fixed << setprecision(10);
    cii(a);
    cii(b);
    int ans = max(max(a + b, a - b), a * b);
    co(ans);
    return 0;
}

Measured memory_bytes: 256
#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(){
  int n, k;
  cin >> n >> k;
  ll ans = 0;
  rep(i, n){
    if(i == 0) ans = k;
    else ans *= (k-1);
  }
  cout << ans << endl;
  return 0;
}

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        int num[] = new int[n];
        int total = 0;
        for (int i = 0; i < n; i++) {
            int m = sc.nextInt();
            num[i] = m;
            total += m;
        }

        int average = total / n;

        int ans1 = 0, ans2 = 0;
        for (int i = 0; i < n; i++) {
            if(num[i] != average) {
                ans1 += Math.pow(num[i] - average, 2);
            }
            if(num[i] != (average + 1)) {
                ans2 += Math.pow(num[i] - (average + 1), 2);
            }
        }

        System.out.println(Math.min(ans1, ans2));
    }
}

Measured memory_bytes: 9552
#include <bits/stdc++.h>
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VRSORT(v) sort(v.rbegin(), v.rend());//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

typedef tuple<ll, int, int> T;

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


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;cin>>n;
  vector<int> h(n);
  REP(i,n) cin>>h[i];
  int ans=0;
  for(int l=0;l<n;l++){
    while(h[l]>0){
      int r;
      for(r=l+1;r<n;r++){
        if(h[r]==0) break;
      }

      for(int i=l;i<r;i++) h[i]--;
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
X,Y =map(int,input().split())
 
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
 
for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
 
 
if (X+Y)%3 !=0:
  print(0)
  
else:
  n=(X+Y)//3
  r=(-2*X+Y)//(-3)
  ans=cmb(n,r,mod)
  print(ans)

Measured memory_bytes: 128076