akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define PP pair<P,P>
using namespace std;

//const int mod = 998244353;
const int mod=1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

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

// 出力は.xで！！！！

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main(){
    int n,k; cin >> n >> k;
    vector<ll> pos,neg;
    rep(i,n){
        ll a; cin >> a;
        if(a<0) neg.push_back(a);
        else pos.push_back(a);
    }
    sort(all(pos));
    sort(all(neg));
    reverse(all(neg));
    int pl=pos.size();
    int nl=neg.size();
    mint ans=1;
    if(n==k){
        rep(i,pl){
            ans*=pos[i];
        }
        rep(i,nl){
            ans*=neg[i];
        }
        cout << ans.x << endl;
        return 0;
    }
    if(nl==n && k%2==1){
        rep(i,k){
            ans*=neg[i];
        }
        cout << ans.x << endl;
        return 0;
    }
    int posp=pl-1;
    int negp=nl-1;
    while(k){
        if(k==1){
            ans*=pos[posp];
            break;
        }
        if(posp<0){
            ans*=neg[negp--];
            ans*=neg[negp--];
            k-=2;
            continue;
        }
        if(negp<1){
            ans*=pos[posp--];
            k--;
            continue;
        }
        if(posp==0 && k%2==1){
          ans*=pos[posp--];
          k--;
          continue;
        }
        if(posp==0 && k%2==0){
          ans*=neg[negp--];
          ans*=neg[negp--];
          k-=2;
        }
        ll can1=pos[posp]*pos[posp-1];
        ll can2=neg[negp]*neg[negp-1];
        if(can1>can2){
            ans*=pos[posp--];
            k--;
        }
        else{
            ans*=neg[negp--];
            ans*=neg[negp--];
            k-=2;
        }
    }

    cout << ans.x << endl;

    return 0;
}

Measured memory_bytes: 5568
#include <iostream>
using namespace std;
int main ()
{
	string a;
	int signal{0};
	cin>>a;
	for (int i=0; a[i]!='\0'; i++)
	{
		if ((i+1)%2==1)
		{
			if (a[i]!='R' &&a[i]!='U'&&a[i]!='D')
			{
				signal = 1;
				break;
			}
		}
		else 
		{
			if (a[i]!='L'&&a[i]!='U'&& a[i]!='D')
			{
				signal=1;
				break;
			}
		}
	}
	if (signal==1) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define sort_1(v) sort(v.begin(),v.end())
#define sort_2(v) sort(v.begin(),v.end(),greater<ll>())
#define reverse(v) reverse(v.begin(),v.end())
typedef long long ll;
typedef long double la;
using namespace std;

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

    rep(i,0,k){
        if(a >= b){
            b *= 2;
            continue;
        }else{
            c *= 2;
            continue;
        }
    }

    if(a < b && b < c){
        cout << "Yes" << endl;
        return 0;
    }else{
        cout << "No" << endl;
        return 0;
    }
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    for (int i = 0; i < n; i++) cin >> c[i];
    sort(a.begin(), a.end());
    //sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    long long cnt = 0;
    for (int i = 0; i < n; i++) {
        auto Iter1 = lower_bound(a.begin(), a.end(), b[i]);
        auto Iter2 = upper_bound(c.begin(), c.end(), b[i]);
        cnt += (Iter1 - a.begin()) * (c.end() - Iter2);
    }
    cout << cnt << '\n';
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;

//定数
//円周率
const double pi = 3.141592653589793238462643383279;
//天井
const int INF = 1000000000; // = 10^9
const ll LINF = 100000000000000000; // = 10^17
//ABC文字列
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZABC";
const string abc = "abcdefghijklmnopqrstuvwxyzabc";
//よくあるmodくん
const ll MOD = 1000000007; // = 10^9 + 7
//前処理テーブルの大きさ指定
const int MAX = 1200000; // = 10^6 + 2*(10^5)
//ちなみに、1024MBで持てる最大長の配列は10^8程度

//データ構造
//隣接リスト用構造体（有向グラフ向け）
struct edge {
  ll to; // E.toでその辺の終点へアクセスできる。
  ll cost; // e.costでその辺の重みにアクセスできる。
};
//Union_Find木
struct UnionFind {
  vector<int> UF; // UF.at(i) : iの親の番号
  vector<int> SIZE; // SIZE.at(root(i)) : iと連結されてる要素の数
  UnionFind(int N) : UF(N), SIZE(N, 1) { // 最初は全てが根であるとして初期化
    for(int i = 0; i < N; i++) {
      UF.at(i) = i;
    }
  }
  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (UF.at(x) == x) {
      return x;
    }
    return UF.at(x) = root(UF.at(x));
  }
  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); // xの根をrx
    int ry = root(y); // yの根をry
    if (rx == ry) {
      return; // xとyの根が同じ(=同じ木にある)時はそのまま
    }
    // xとyの根が同じでない(=同じ木にない)時：小さい方の根を大きい方の根につける。
    if (SIZE.at(rx) < SIZE.at(ry)) {
      UF.at(rx) = ry;
      SIZE.at(ry) += SIZE.at(rx);
      SIZE.at(rx) = 0;
    }
    else {
      UF.at(ry) = rx;
      SIZE.at(rx) += SIZE.at(ry);
      SIZE.at(ry) = 0;
    }
  }
  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す。
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
  int size(int x) { // xと連結されてる要素の数を返す。
    return SIZE.at(root(x));
  }
};

//関数 (計算量)
//ctoi (O(1))
int ctoi(char c){
  if (c == '0') return 0;
  if (c == '1') return 1;
  if (c == '2') return 2;
  if (c == '3') return 3;
  if (c == '4') return 4;
  if (c == '5') return 5; 
  if (c == '6') return 6;
  if (c == '7') return 7;
  if (c == '8') return 8;
  if (c == '9') return 9;
  return -1;  
}
//to_char (O(1))
char to_char(int i){
  if (i == 0) return '0';
  if (i == 1) return '1';
  if (i == 2) return '2';
  if (i == 3) return '3';
  if (i == 4) return '4';
  if (i == 5) return '5';
  if (i == 6) return '6';
  if (i == 7) return '7';
  if (i == 8) return '8'; 
  if (i == 9) return '9';
  return ' ';  
}

// A^N mod M を計算する。modしたくなかったらM = LINFとかにすればよい。(O(√N))
ll modpow(ll A, ll N, ll M) {
  ll ans = 1;
  while (N > 0) {
    if (N & 1) ans = ans * A % M;
      A = A * A % M;
      N >>= 1;
   }
  return ans;
}

//メイン処理
int main() {
  cout << fixed << setprecision(16); //精度向上
  //ここまでテンプレ
  int N;
  cin >> N;
  ll ans = 1;
  for (int i = 1; i <= N; i++) {
    ans *= i;
    ans %= MOD;
  }
  cout << ans << endl;
}


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

ll dp[100010];

void solve() {
    ll N;
    cin >> N;

    fill_n(&dp[0], sizeof(dp) / sizeof(dp[0]), L_INF);

    dp[0] = 0;
    for (ll i = 0; i <= N; i++) {
        ll p = 1;
        if (i - p >= 0 && dp[i - p] != L_INF)
            dp[i] = min(dp[i], dp[i - p] + 1);

        p = 6;
        while (i - p >= 0) {
            if (dp[i - p] != L_INF)
                dp[i] = min(dp[i], dp[i - p] + 1);
            p *= 6;
        }

        p = 9;
        while (i - p >= 0) {
            if (dp[i - p] != L_INF)
                dp[i] = min(dp[i], dp[i - p] + 1);
            p *= 9;
        }
    }

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

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

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

    int sumIsEven = N * (N - 1) / 2 + M * (M - 1) / 2;

    cout << sumIsEven << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC146_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var s = Console.ReadLine();

            var news = string.Empty;
            foreach (var c in s)
            {
                news += (char)(c + n > 90 ? c + n - 26 : c + n);
            }

            Console.WriteLine(news);
        }
    }
}


Measured memory_bytes: 34772
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60

bool dpx[8009][16009];
bool dpy[8009][16009]; // dp[i][k] : i回目の移動後にk-8000にいるかどうか



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

	string S; cin >> S;
	int x, y; cin >> x >> y;


	vector<int> xpath, ypath;
	bool way = true; // 1 : x軸方向
					 // 0 : y軸方向
	int lpath = 0;

	for (int i = 0; i < S.size(); i++) {
		if (S[i] == 'F') lpath++;
		else { // S[i] == 'T'
			if (way) xpath.push_back(lpath);
			else ypath.push_back(lpath);
			lpath = 0;
			
			way = !way; // 回転
		}
	}
	if (way) xpath.push_back(lpath);
	else ypath.push_back(lpath);
	lpath = 0;
	
	

	/*
	// 確認
	cout << "x  : ";
	for (int i = 0; i < xpath.size(); i++) cout << xpath[i] << " ";
	cout << endl;
	cout << "y  : ";
	for (int i = 0; i < ypath.size(); i++) cout << ypath[i] << " ";
	cout << endl;
	*/


	
	// x,yを構成できるか
	dpx[0][8000] = dpy[0][8000] = true;

	dpx[1][8000 + xpath[0]] = true;
	for (int i = 2; i <= xpath.size(); i++) {
		int d = xpath[i - 1];
		for (int j = 0; j <= 16000; j++) {
			if (dpx[i - 1][j]) {
				dpx[i][j - d] = true;
				dpx[i][j + d] = true;
			}
		}
	}

	for (int i = 1; i <= ypath.size(); i++) {
		int d = ypath[i - 1];
		for (int j = 0; j <= 16000; j++) {
			if (dpy[i - 1][j]) {
				dpy[i][j - d] = true;
				dpy[i][j + d] = true;
			}
		}
	}

	if (dpx[xpath.size()][x + 8000] && dpy[ypath.size()][y + 8000]) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 125824
from collections import defaultdict

trump = {
    'S': set(range(1, 14)),
    'H': set(range(1, 14)),
    'C': set(range(1, 14)),
    'D': set(range(1, 14)),
}
taro_trump = defaultdict(set)

n = int(input())
for i in range(n):
    (mark, num) = tuple(input().split(' '))
    num = int(num)
    taro_trump[mark].add(num)

no_taro_trump = defaultdict(set)
no_taro_trump['S'] = trump['S']
no_taro_trump['H'] = trump['H']
no_taro_trump['C'] = trump['C']
no_taro_trump['D'] = trump['D']

if 'S' in taro_trump:
    no_taro_trump['S'] = trump['S'] - taro_trump['S']
if 'H' in taro_trump:
    no_taro_trump['H'] = trump['H'] - taro_trump['H']
if 'C' in taro_trump:
    no_taro_trump['C'] = trump['C'] - taro_trump['C']
if 'D' in taro_trump:
    no_taro_trump['D'] = trump['D'] - taro_trump['D']

for mark in ['S', 'H', 'C', 'D']:
    for num in list(no_taro_trump[mark]):
        print(mark, num)

Measured memory_bytes: 7972
from collections import Counter
from itertools import product
import numpy as np


def timeGap(D):
    day = []
    candidate = []
    c = Counter(D)

    for k, v in c.items():
        # 0, 12は2つある時点で答えは0
        if k == 0 or k == 12:
            if v >= 2:
                return 0
            else:
                day.append(k)
            continue

        # 1~11も3以上ある時点で答えは0
        if v >= 3:
            return 0
        # 2つの場合は反対にして配置
        elif v == 2:
            day.append(k)
            day.append(24-k)
        else:
            candidate.append(k)

    # candidate は10個以下なので、全探索
    res = 0
    n = len(candidate)
    for pair in product(range(2), repeat=n):
        tmp = day[::]
        for i in range(n):
            if pair[i]:
                tmp.append(candidate[i])
            else:
                tmp.append(24 - candidate[i])
        tmp.sort()
        tmp.append(tmp[0]+24)
        res = max(res, np.diff(tmp).min())
    return res


if __name__ == "__main__":
    N = int(input())
    D = list(map(int, input().split()))
    D.append(0)
    ans = timeGap(D)
    print(ans)


Measured memory_bytes: 12520
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int[] num = new int[6];
		for (int i=0; i<6; i++) {
			num[i] = stdIn.nextInt();
		}
		Dice dice = new Dice();
		int n = stdIn.nextInt();
		for (int i=0; i<n; i++) {
			int t = stdIn.nextInt();
			int f = stdIn.nextInt();
			int top = 0;
			int front = 0;
			for(int j=0; j<6; j++){
				if(t == num[j]){
					top = j+1;
				}else if(f == num[j]){
					front = j+1;
				}
			}
			System.out.println(num[dice.solve(top,front)-1]);
		}
	}

	static class Dice {

		private int top = 1;
		private int front = 2;
		private int right = 3;
		private int left = 4;
		private int back = 5;
		private int bottom = 6;

		Dice(){
		}

		void change(char dir) {
			int temp = 0;
			switch(dir){
				case 'N': moveN(); break;
				case 'S': moveS(); break;
				case 'E': moveE(); break;
				case 'W': moveW(); break;
			}
		}

		void moveN(){
			int temp = top;
			top = front;
			front = bottom;
			bottom = back;
			back = temp;
		}

		void moveS(){
			int temp = top;
			top = back;
			back = bottom;
			bottom = front;
			front = temp;
		}

		void moveE(){
			int temp = top;
			top = left;
			left = bottom;
			bottom = right;
			right = temp;
		}

		void moveW(){
			int temp = top;
			top = right;
			right = bottom;
			bottom = left;
			left = temp;
		}

		int isTop(){
			return top;
		}

		int isRight(){
			return right;
		}

		int solve(int top,int front){
			boolean flag = false;
			for (int i=0; i<4; i++) {
				moveN();
				if(this.top == top){
					flag = true;
					break;
				}
			}
			if(!flag){
				while(this.top != top){
					moveE();
				}
			}
			while(this.front != front){
				turn();
			}
			return this.right;
		}

		void turn(){
			int temp = front;
			front = right;
			right = back;
			back = left;
			left = temp;
		}
	}
}

Measured memory_bytes: 17332
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(int i =(a);i<(n);i++)
#define urep(i,a,n) for(int i = (a);i>(n);i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;

ll N, M, K;
ll sum(ll num) {
	ll ans = 0;
	ll copy = num;
	while (copy != 0) {
		ans += copy % 10;
		copy /= 10;
	}
	return ans;
}
int main() {
	cin >> K;
	cout << 1 << endl;
	ll n = 1, d = 1;
	for (int i = 1; i < K; i++) {
		if (sum(n + d) * (n + 10 * d) < sum(n + 10 * d) * (n + d)) d *= 10;
		n += d;
		cout << n << endl;
	}
	cin >> N;
	return 0;
}

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

ok_count = 0
for i in range(1, N + 1, 2):
    # 約数を8個もつものの数
    count = 0
    for j in range(1, i + 1):
        # print("{}".format(j))
        if i % j == 0:
            count += 1
    if count == 8:
        ok_count += 1
print(ok_count)


Measured memory_bytes: 2940
### constant

MAX_N = 300
MAX_C = 17

COINS = (1..MAX_C).map{|c| c * c}

### subroutines

def count_rec(c, n)
  return $cache[c][n] if $cache[c][n]
  return ($cache[c][n] = 1) if c == 1

  sum = 0
  c2 = c * c
  n0 = n
  while n0 >= 0
    sum += count_rec(c - 1, n0)
    n0 -= c2
  end

  $cache[c][n] = sum
end

### main

$cache = (MAX_C + 1).times.map{(MAX_N + 1).times.map{nil}}
  
loop do
  n = gets.to_i
  break if n == 0

  puts count_rec(MAX_C, n)
end

Measured memory_bytes: 6168
package main

import (
  "bufio"
  "fmt"
  "os"
  "strconv"
  "strings"
)

var n,m,x,y int
var v,e []int
var g [701][701]bool

func main() {
  input := Input{bufio.NewReaderSize(os.Stdin,1000000)}
  n,m = input.NextInts()
  for i:=0;i<m;i++ {
    a,b := input.NextInts()
    g[a][b] = true
    g[b][a] = true
  }
  v = make([]int,n+1)
  e = make([]int,2*n+1)
  dp := make([]int,n+1)
  dp[0] = 1
  for i:=1;i<n+1;i++ {
    if v[i] > 0 { continue }
    x,y = 0,0
    dfs(i,0)
    for j:=0;j<2*n+1;j++ { e[j] = 0 }
    for j:=n;j>-1;j-- {
      e[j+x] |= dp[j]
      e[j+y] |= dp[j]
    }
    for j:=0;j<n+1;j++ { dp[j] = e[j] }
  }
  for i:=n/2;i>0;i-- {
    if dp[i] > 0 || dp[n-i] > 0 {
      fmt.Println((i*(i-1)+(n-i)*(n-i-1))/2)
      return
    }
  }
  fmt.Println(-1)
}

func dfs(p,t int) {
  if v[p] > 0 && v[p] != t+1 { fmt.Println(-1);os.Exit(0) }
  if v[p] > 0 { return }
  v[p] = t+1
  if t > 0 {
    x++
  } else {
    y++
  }
  for i:=1;i<n+1;i++ {
    if i != p && !g[i][p] { dfs(i,t^1) }
  }
}

type Input struct {
  reader *bufio.Reader
}
func(i *Input) NextLine() string {
  var buffer []byte
  for {
    line,isPrefix,err := i.reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func(i *Input) NextInts() (int,int) {
  s := strings.Split(i.NextLine()," ")
  x,_ := strconv.Atoi(s[0])
  y,_ := strconv.Atoi(s[1])
  return x,y
}

Measured memory_bytes: 6016
using System;

class Program
{
    static void Main()
    {
        string[] array = Console.ReadLine().Split(' ');
        int N = int.Parse(array[0]);
        int T = int.Parse(array[1]);

        array = Console.ReadLine().Split(' ');
        int[] t = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
            t[i] = int.Parse(array[i]);

        int tmp = T;
        int ans = T;
        for (int i = 1; i < N; i++)
        {
            if (t[i] < tmp)
            {
                tmp += (t[i] - t[i - 1]);
                ans += (t[i] - t[i - 1]);
            }
            else
            {
                tmp = t[i] + T;
                ans += T;
            }
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 28256
#include <iostream>
#include <vector>
#include <algorithm>
#include <limits>

using namespace std;

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

int simulate(const vector<int> &a, int N, int t)
{
	int cost = 0;
	for (int i = 0; i < N; ++i) {
		cost += square(a[i] - t);
	}
	return cost;
}

int main()
{
	int N;
	cin >> N;
	vector<int> a(N);
	for (auto &x : a) {
		cin >> x;
	}

	int ans = simulate(a, N, -100);
	for (int t = -100; t <= 100; ++t) {
		ans = min(ans, simulate(a, N, t));
	}
	cout << ans << endl;
}


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

using namespace std;

#define ll long long 
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mkp make_pair
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ff first
#define ss second
#define endl "\n"
#define MOD 1000000007
#define MOD1 998244353
#define inf 1e18

ll GCD(ll x,ll y){if(y==0)return x;return GCD(y,x%y);}
ll LCM(ll x,ll y){return (x*y)/(GCD(x,y));}
ll LOGK(ll x,ll k){if(x>=k)return 1+LOGK(x/k,k);return 0;}
ll MPOW( ll a, ll b, ll m) { if(b==0) return 1; ll x=MPOW(a,b/2,m); x=(x*x)%m; if(b%2==1) x=(x*a)%m; return x;}
ll MINV(ll a,ll m) {return MPOW(a,m-2,m);}

class pnc{
  ll FACT_MAX,MODU;
  vector<ll> fact;
public:
  pnc( ll n, ll m) { FACT_MAX = n; fact.resize(FACT_MAX); MODU = m; MFACT_INIT(MODU);}
  void MFACT_INIT( ll m) { fact[0]=1; for(ll i=1;i<FACT_MAX;++i) fact[i]=(i*fact[i-1])%MODU;}
  ll MFACT( ll n) { return fact[n];}
  ll PERM( ll n, ll r) { return (fact[n]*::MINV(fact[n-r],MODU))%MODU;}
  ll COMB( ll n , ll r) { return (PERM(n,r)*::MINV(fact[r],MODU))%MODU;}
};

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);    

    ll test=1;
    // cin>>test;
    while(test--)
    {
        ll n;
        cin>>n;

        ll ar[n];

        for(ll i=0;i<n;i++)
        cin>>ar[i];

        ll ans=0;

        for(ll i=1;i<n;i++)
        {
            if(ar[i]<ar[i-1])
            {
                ans+=ar[i-1]-ar[i];
                ar[i]=ar[i-1];
            }
        }

        cout<<ans;
    }
}

Measured memory_bytes: 5116
until(n,m=gets.split.map(&:to_i))==[0,0]do
r,p,a=[],[],[]
n.times{r.unshift(gets.gsub("?",".").split)}
m.times{p<<gets.split}
p.each{|p|r.each{|r|if p[0]=~/#{r[1]}/&&p[1]=~/#{r[2]}/
a<<p*" "if r[0]=~/p/
break
end}}
puts a.size,a
end

Measured memory_bytes: 9272
use std::process;
macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}
fn main() {
    let s = get!(String);
    
    match &s as &str {
        "SUN" => println!("7"),
        "MON" => println!("6"),
        "TUE" => println!("5"),
        "WED" => println!("4"),
        "THU" => println!("3"),
        "FRI" => println!("2"),
        "SAT" => println!("1"),
        _ => println!(""),
    }
}


Measured memory_bytes: 4352
#include <stdio.h>

int main(void) {
	int A, B, C;
	int K;
	int nyan = 0;
	if (scanf("%d%d%d", &A, &B, &C) != 3) return 1;
	if (scanf("%d", &K) != 1) return 1;
	while (A >= B) {
		B *= 2;
		nyan++;
	}
	while (B >= C) {
		C *= 2;
		nyan++;
	}
	puts(nyan <= K ? "Yes" : "No");
}


Measured memory_bytes: 1648
#include <bits/stdc++.h>
#include <algorithm>
#include <stdio.h>
#include <math.h>
using namespace std;

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

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

struct edge {
	int to, cost;
	edge(int t,int c):to(t),cost(c) {}
};

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

ll mypow(ll x,ll n,ll m) {	//xのn乗をmで割った余り
	if(n==0) return 1;
	if(n%2==0) return mypow(x*x%m,n/2,m);
	else return x*mypow(x,n-1,m)%m;
}

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

ll a,b;

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

	cin>>a>>b;
	ll ans=0;
	ll n=a;
	while (n<=b) {
		ans++;
		n*=2;
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define nax 1009
typedef  long long lld;


int main(){
	int h , w;
	long long mod= 1000000007LL;
	char grid[nax][nax];
	lld dp[nax][nax];
	scanf("%i%i",&h,&w);
	for(int i=0;i<h;i++){
		scanf(" %s",grid[i]);
	}

	if(grid[0][0]!='#'){
		dp[0][0] = 1LL;
	}else{
		dp[0][0] = 0LL;
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if((j-1>=0) || (i-1>=0)){
				if((j-1) >=0){
					if (grid[i][j] == '#'){
						continue;
					}
					dp[i][j]+= dp[i][j-1] % mod;
				}
				if((i-1) >=0){
					if(grid[i][j]=='#'){
						continue;
					}
					dp[i][j] = (dp[i][j] + dp[i-1][j]) %mod;
				}
			}
		}
	}
printf("%lld",dp[h-1][w-1]);

}



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

#define x first
#define y second
#define ndl '\n'
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define bit __builtin_popcount
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;
using namespace __gnu_pbds;

template<typename T> using indexed_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<int, ull> piu;
typedef vector<vector<int>> matrix;

const ll INF = 1e18 + 123;
const ld EPS = 1e-9;
const int inf = 1e9 + 123;
const int MOD = 1e9 + 7;
const int N = 5e5 + 13;
const int M = 1e6 + 123;
const double pi = acos(-1.0);
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0};

int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

void solve(){
    int k;
    cin >> k;
    cout << a[k-1];
}

int main(){
    #ifdef KAZAKH
        freopen("input.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    while (t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=1000005,INF=1<<30;
int dp[MAX][2];

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string S;cin>>S;
    int N=S.size();
    
    for(int i=0;i<MAX;i++){
        dp[i][0]=dp[i][1]=INF;
    }
    
    dp[N][0]=0;
    
    for(int i=N-1;i>=0;i--){
        for(int j=0;j<10;j++){
            if(j>=int(S[i]-'0')){
                dp[i][0]=min(dp[i][0],dp[i+1][0]+j+j-int(S[i]-'0'));
            }else{
                dp[i][1]=min(dp[i][1],dp[i+1][0]+j+10+j-int(S[i]-'0'));
            }
            
            if(j>=int(S[i]-'0')+1){
                dp[i][0]=min(dp[i][0],dp[i+1][1]+j+j-int(S[i]-'0')-1);
            }else{
                dp[i][1]=min(dp[i][1],dp[i+1][1]+j+10+j-int(S[i]-'0')-1);
            }
        }
    }
    
    dp[0][1]++;
    
    cout<<min(dp[0][0],dp[0][1])<<endl;
}



Measured memory_bytes: 9244
// {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
// }}}

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

static constexpr int mod = (int)1e9 + 7;
static constexpr int inf = 100100100;
static constexpr ll linf = 1e18;
static constexpr double eps = 1e-9;
static constexpr double pi = 3.14159265359;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rrep(i, n) for (ll i = n; i >= 0; --i)
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define pb push_back
#define ist insert
#define fst first
#define snd second


int main() {
    // cin.tie(0);
    // ios_base::sync_with_stdio(false);
    ll X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    vector<ll> A, B, C;
    rep (i, X) {
        ll v;
        cin >> v;
        A.pb(v);
    }
    rep (i, Y) {
        ll v;
        cin >> v;
        B.pb(v);
    }
    rep (i, Z) {
        ll v;
        cin >> v;
        C.pb(v);
    }
    vector<ll> AB;
    rep (i, X) {
        rep (j, Y) {
            AB.pb(A[i] + B[j]);
        }
    }
    sort(rall(AB));
    sort(rall(C));
    vector<ll> ABC;
    rep (i, min(K, (ll)AB.size())) {
        rep (j, Z) {
            ABC.pb(AB[i] + C[j]);
        }
    }
    sort(rall(ABC));
    rep (i, K) {
        cout << ABC[i] << endl;
    }
}


Measured memory_bytes: 43128
#include <iostream>

typedef unsigned long long ll;

int main(){
   ll A, B;
   std::cin >> A >> B;

   ll ones = (B - A)/2 % 2;
   
   if(A%2==0){
      if(B%2==0) std::cout << (B^ones) << std::endl;
      else std::cout << ((B - A)/2 + 1) % 2 << std::endl;
   }else{
      if(B%2==0) std::cout << (A^B^ones) << std::endl;
      else std::cout << (A^ones) << std::endl;
   }

   return 0;

}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
//tからsの参照方法を工夫してO(NlogN)まで高速化する。
//文字のポインタをMapを作ることでO(1)にするが、同じ文字を複数含むことがある。
//これはMapのValueをTreeSetで持たせることで、現在値から一番近い同文字のポインタをlogで得られる。
public class Main {
	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		String s = fs.next() , t = fs.next();
		
		Map<Character, TreeSet<Integer> > map = new HashMap<>();
		int slen = s.length();
		for(int i=0;i<slen;i++) {
			char c = s.charAt(i);
			if(!map.containsKey(c)) {
				TreeSet<Integer> ts = new TreeSet<>();
				ts.add(i);
				map.put(c, ts);
			}
			else {
				map.get(c).add(i);
			}
		}
		
		int now = -1;
		long cnt = 0;
		int tlen = t.length();
		for(int i=0;i<tlen;i++) {
			char c = t.charAt(i);
			if(map.get(c)==null) {
				System.out.println(-1);
				return;
			}
			if(map.get(c).higher(now)==null) {
				cnt ++;
				now = map.get(c).first();
			}
			else {
				now = map.get(c).higher(now);
			}
		}
		long ans = cnt * slen + now + 1;
		System.out.println(ans);
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}


Measured memory_bytes: 34592
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <queue>
#include <utility>
#include <vector>

using namespace std;

int main() {
  int k, n, a[200000], ans = 0;
  scanf("%d%d", &k, &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 0; i < n; i++) {
    ans = max(ans, (k + a[(i + 1) % n] - a[i]) % k);
  }
  if (n == 2) {
    printf("%d\n", min(k - ans, ans));
  } else {
    printf("%d\n", k - ans);
  }
}

Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589

using namespace std;

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

void solve_B(){
    int n;
    cin >> n;
    int x[n];
    REP(i,n) cin >> x[i];

    int ans = 10000000;
    for(int p = -100; p < 100; p++){
        int tmp = 0;
        REP(i,n){
            tmp += (x[i] - p) * (x[i] - p);
        }
        if(tmp <= ans) ans = tmp;
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 256
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        n: u32,
        m: u32,
    }
    let set_time = m * 1900 + (n - m) * 100;
    let try_cnt = 2_u32.pow(m);
    println!("{}", set_time * try_cnt);
}


Measured memory_bytes: 2136
#line 1 "/workspaces/compro/lib/template.hpp"


#line 1 "/workspaces/compro/lib/io/vector.hpp"
#include <iostream>
#include <vector>

#ifndef IO_VECTOR
#define IO_VECTOR

template <class T> std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
  int size = v.size();
  for (int i = 0; i < size; i++) {
    std::cout << v[i];
    if (i != size - 1)
      std::cout << " ";
  }
  return out;
}

template <class T> std::istream &operator>>(std::istream &in, std::vector<T> &v) {
  for (auto &el : v) {
    std::cin >> el;
  }
  return in;
}

#endif
#line 4 "/workspaces/compro/lib/template.hpp"
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes, T no) { cout << (val ? yes : no) << "\n"; }

void say(bool val, string yes = "Yes", string no = "No") { say<string>(val, yes, no); }

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

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

// C++ 17に完全移行したら消す
// 最大公約数を求める
template <class T> T gcd(T n, T m) { return n ? gcd(m % n, n) : m; }

// 最小公倍数を求める
template <class T> T lcm(T n, T m) {
  int g = gcd(n, m);
  return n * m / g;
}

// 重複を消す。計算量はO(NlogN)
template <class T> void unique(std::vector<T> &v) {
  std::sort(v.begin(), v.end());
  v.erase(std::unique(v.begin(), v.end()), v.end());
}


#line 2 "main.cpp"

long long solve(int N, std::vector<long long> &A) {
  ll ans = 0;
  FOR(i, 1, N) {
    ans += max(0LL, A[i - 1] - A[i]);
    A[i] += max(0LL, A[i - 1] - A[i]);
  }
  return ans;
}

// generated by online-judge-template-generator v4.4.0 (https://github.com/kmyk/online-judge-template-generator)
int main() {
  int N;
  std::cin >> N;
  std::vector<long long> A(N);
  for (int i = 0; i < N; ++i) {
    std::cin >> A[i];
  }
  auto ans = solve(N, A);
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 4780
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  int ans=0;
  for(int i=0;i<N;i++){
  int l,r;
    cin>>l>>r;
    ans+=(r-l+1);
  }cout<<ans<<endl;
    
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define db long double
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

using namespace std;

int matrix[507][507];
bool dlt[507][507];

int n;

void dfs(int a, int b) {
	int Q = 1e9;
	for (int dx = -1; dx <= 1; ++dx) {
		for (int dy = -1; dy <= 1; ++dy) {
			if (abs(dx) + abs(dy) != 1) continue;
			int c = a+dx, d = b+dy;
			if (c < 0 || c >= n || d < 0 || d >= n) continue;
			int val = matrix[a][b] + (!dlt[c][d]);
			if (val < matrix[c][d]) {
				//cout << c << " " << d << " " << val << endl;
				matrix[c][d] = val;
				dfs(c, d);
			}
		}
	}
}

int main(){
#ifdef LOCAL
	freopen("B_input.txt", "r", stdin);
	//freopen("B_output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	cin >> n;

	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			int moves = min({i+1, n-i, j+1, n-j});
			matrix[i][j] = moves;
		}
	}


	int ans = 0;
	for (int i = 0; i < n*n; ++i) {
		int x;
		cin >> x;
		x--;
		int a = x/n, b = x%n;

		dlt[a][b] = true;
		ans += max(0, matrix[a][b]-1);

		int Q = 1e9;
		for (int dx = -1; dx <= 1; ++dx) {
			for (int dy = -1; dy <= 1; ++dy) {
				if (abs(dx) + abs(dy) != 1) continue;
				int c = a+dx, d = b+dy;
				if (c < 0 || c >= n || d < 0 || d >= n) continue;
				Q = min(Q, matrix[c][d]);
			}
		}

		if (a == 0 || a == n-1 || b == 0 || b == n-1) Q = 0;

		matrix[a][b] = Q;
		dfs(a, b);

	}

	cout << ans;

}


Measured memory_bytes: 23808
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define rt return 0
#define endln "\n"
#define all(v) v.begin(), v.end()
#define for1(i, a, b) for (long long int i = a; i < b; i++)
#define for2(i, a, b) for (long long int i = a; i > b; i--)
//  cout << fixed << setprecision(0) << pi <<" "<<npi<<endl;typedef long long int i;
typedef long long int lli;
typedef pair<lli, lli> pll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli t, a, b, c, k;
    cin >> a >> b >> c >> k;
    lli ans = 0;
    if (k <= a)
    {
        cout << k << endl;
        rt;
    }
    else
    {
        k -= a;
        ans += a;
        if (k <= b)
        {
            cout << ans << endl;
            rt;
        }
        else
        {
            k -= b;
            ans -= k;
            cout << ans << endl;
            rt;
        }
    }
}

Measured memory_bytes: 3648
<?php

class Transformer
{
    private $target;
    private $order;
    private $params;

    public function __construct($target)
    {
        $this->target = $target;
    }

    public function order($order)
    {
        $this->order = $order;
        return $this;
    }

    public function parameters($params)
    {
        $this->params = $params;
        return $this;
    }

    public function convert()
    {
        call_user_func([$this, '_'.$this->order], $this->params);
    }

    private function _replace($params)
    {
        list($start, $end, $replaceText) = $params;
        $this->target = substr_replace($this->target, $replaceText, $start, $end - $start + 1);
    }

    private function _print($params)
    {
        list($start, $end) = $params;
        echo substr($this->target, $start, $end - $start + 1), PHP_EOL;
    }

    private function _reverse($params)
    {
        list($start, $end) = $params;

        $this->target = substr_replace(
            $this->target,
            strrev(substr($this->target, $start, $end - $start + 1)),
            $start, $end - $start + 1
        );
    }
}



$str = getStdin();
$q   = getStdin();

for ($i = 0; $i < $q; $i++) {
    $input[] = explode(' ', getStdin());
}

$transformer = new Transformer($str);

foreach ($input as $orders) {
    $transformer->order(first($orders))
        ->parameters(drop($orders, 1))
        ->convert();
}


function first($array)
{
    foreach ($array as $value) {
        return $value;
    }
}

function drop($array, $n)
{
    return array_slice($array, $n);
}

function getStdin()
{
    return trim(fgets(STDIN));
}

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

int main() {
  int AB, BC, CA;
  cin >> AB >> BC >> CA;

  cout << AB * BC / 2 << endl;
  return 0;
}

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

using namespace std;

int main(){
  int n;
  cin >> n;
  n=n%10;
  switch(n){
    case 2:

    case 4:
    case 5:

    case 7:
    case 9:
      cout<< "hon\n";
      break;
    case 0:
    case 1:
    case 6:
    case 8:
      cout<< "pon\n";
      break;
    case 3:
      cout<< "bon\n";
      break;
  }

  return 0;
}


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

using namespace std;

int main(void)
{
	int X,Y;
	cin >> X >> Y;
	
	int ans = 0;
	if(X == 1){
		ans += 300000;
	}
	else if(X == 2){
		ans += 200000;
	}
	else if(X == 3){
		ans += 100000;
	}
	
	if(Y == 1){
		ans += 300000;
	}
	else if(Y == 2){
		ans += 200000;
	}
	else if(Y == 3){
		ans += 100000;
	}
	
	if(X == 1 && Y == 1){
		ans += 400000;
	}
	cout << ans<<endl;
	
	return 0;
}






Measured memory_bytes: 256
n,m = map(int,input().split())
h = list(map(int,input().split()))
 
H = [0]*n
for p in range(n):
  H[p] = []
 
 
for _ in range(m):
  a,b = map(int,input().split())
 
  H[a-1].append(h[b-1])
  H[b-1].append(h[a-1])

ans = 0
i = 0
 
for one in H:
 
  i += 1
  if one == []:
    ans += 1
  else:
    for k in one:
      if k >= h[i-1]:
        break
    else:
      ans += 1
        
print(ans)


Measured memory_bytes: 92748
from scipy.sparse import*;f=lambda*z:map(int,raw_input().split());N,M,R=f();r=f();a,b,c=list(zip(*map(f,[0]*M)));a=csgraph.dijkstra(csr_matrix((c,(a,b)),[N+1]*2),0,r);print int(min(sum(a[e[i]][r[e[i+1]]]for i in range(R-1))for e in __import__('itertools').permutations(range(R))))

Measured memory_bytes: 20316
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, C: int, X: int, Y: int):
    if A+B < 2*C:
        print(X*A+Y*B)
    else:
        if X >= Y:
            print(min(Y*(2*C) + A*(X-Y),X*2*C))
        else:
            print(min(X*(2*C)+B*(Y-X), Y*2*C))

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(A, B, C, X, Y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
from sys import stdin
import heapq

n,m = [int(x) for x in stdin.readline().rstrip().split()]
li = list(map(int,stdin.readline().rstrip().split()))

li.sort()
sa = []

if n >= m:
    print(0)
    exit()

for i in range(1,m):
    sa.append(li[i]-li[i-1])

sa.sort()

for i in range(n-1):
    sa.pop()

print(sum(sa))

Measured memory_bytes: 13960
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

#define rep(i,a,b) for(int i=a;i<b;i++)

const int inf = 1001001000;
const int mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


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

    int ans = 0;
    while (n--){
        int t;
        cin >> t;
        ans += d/t + 1;
        if(d%t == 0) ans--;
    }
    cout << ans + x << endl;
}




Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	fcout(10)<<n*PI*2<<endl;
}


Measured memory_bytes: 3776
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;


int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int n; cin >> n;

    vll v(n + 1);
    v[0] = 1;
    v[1] = 1;

    FOR(i, 2, n + 1) {
        v[i] = v[i - 1] + v[i - 2];
    }

    print(v[n]);

}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
const int MAX = 1100000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
	ll x,y;
	cin>>x>>y;
	ll ans=0;
    COMinit();

    // 計算例
 //   cout << COM(100000, 50000) << endl;	
	for(ll i=0;i<=x;i++){
		ll nexy=x-i;
	//	cout <<ans<<i<<endl;
		if(nexy%2!=0){
			continue;
		}
		ll zany=y-i*2;
		if(zany<0){
			continue;
		}
		if(zany==nexy/2){
			ans+=COM(zany+i,i);
			ans%=inf;
		}
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 25984