akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
using namespace std;
const int INF = 1001001001;
const int MOD = 1e9+7;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  ll h,w; cin >> h >> w;
  if(h%3==0 || w%3==0){
    cout << 0;
    return 0;
  }
  ll ans = INF;
  if(h%2 == 0){
    rep(i,w){
      ll mn = min(i*h,(w-i)*(h/2));
      ll mx = max(i*h,(w-i)*(h/2));
      chmin(ans,mx-mn);
    }
  }else{
    rep(i,w){
      ll mn = min({i*h,(w-i)*(h/2),(w-i)*(h/2+1)});
      ll mx = max({i*h,(w-i)*(h/2),(w-i)*(h/2+1)});
      chmin(ans,mx-mn);
    }
  }
  if(w%2 == 0){
    rep(i,h){
      ll mn = min(i*w,(h-i)*(w/2));
      ll mx = max(i*w,(h-i)*(w/2));
      chmin(ans,mx-mn);
    }
  }else{
    rep(i,h){
      ll mn = min({i*w,(h-i)*(w/2),(h-i)*(w/2+1)});
      ll mx = max({i*w,(h-i)*(w/2),(h-i)*(w/2+1)});
      chmin(ans,mx-mn);
    }
  }
  chmin(ans,w*((h+3)/3)-w*(h/3));
  chmin(ans,h*((w+3)/3)-h*(w/3));
  cout << ans;
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3620
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

X = int(read())

x = np.arange(-300, 300, dtype=np.int64)

x5 = x**5
diff = np.subtract.outer(x5, x5)

i = np.where(diff == X)

x, y = i[0][0], i[1][0]
x -= 300
y -= 300

assert x**5 - y**5 == X
print(x, y)

Measured memory_bytes: 30208
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define ll __int64
//#define ll long long
#define P pair<ll,ll>
int n;
string s;

bool che(int l,int r){
	string t=s;
	rep(i,l)t="("+t;
	rep(i,r)t=t+")";

	stack<char>sta;
	while(!sta.empty())sta.pop();

	int ns=t.size();

	
	rep(i,ns){
		if(t[i]=='(')sta.push('(');
		else{
			if(sta.empty())return 0;
			else sta.pop();
		}
	}
	if(sta.empty())return 1;
	return 0;
}

int main(){
	int num=200,tmp,tl,tr;

	cin>>n>>s;

	rep(l,101){
		rep(r,101){
			tmp=che(l,r);
			if(tmp&&num>l+r){
				tl=l,tr=r;
				num=l+r;
			}
		}
	}
	rep(i,tl)cout<<"(";
	cout<<s;
	rep(i,tr)cout<<")";
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <math.h>
#include <deque>
#include <queue>
#include <assert.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

constexpr ll mod=998244353;

ll mod_pow(ll a,ll b){
    a%=mod;
    if(b==0)return 1;
    if(b==1)return a;
    ll res=mod_pow(a,b/2)%mod;
    res*=res; res%=mod;
    if(b%2)res*=a;
    return res%mod;
}

ll dp[3030][3030];

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll a,b,c,d; cin >> a >> b >> c >> d;
    if(a==c){
        cout << mod_pow(a,d-b) << endl;
    }
    else if(b==d){
        cout << mod_pow(b,c-a) << endl;
    }
    else{
        dp[a][b]=1LL;
        for(ll i=a;i<=c;i++){
            for(ll j=b;j<=d;j++){
                (dp[i+1][j]+=dp[i][j]*j%mod)%=mod;
                (dp[i][j+1]+=dp[i][j]*i%mod)%=mod;
                (dp[i+1][j+1]-=dp[i][j]*i*j%mod)%=mod;
                (dp[i+1][j+1]+=mod)%=mod;
            }
        }
        cout << dp[c][d] << endl;
    }
}

Measured memory_bytes: 74652
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)

int main(){
    int n;
    cin >> n;
    vector<pair<int,int> > res;
    vector<vector<int> > a;
    for(int i=0;i<n/2;i++){
        vector<int>p;
        p.push_back(i+1);
        if(n%2==1){
            p.push_back(n-i-1);
        }else{
            p.push_back(n-i);
        }
        a.push_back(p);
    }
    if(n%2==1){
        vector<int>p;
        p.push_back(n);
        a.push_back(p);
    }
    int m = a.size();
    for(int i=0;i<m;i++){
        for(int j=i+1;j<m;j++){
            for(auto x:a[i]){
                for(auto y:a[j]){
                    res.push_back(MP(x,y));
                }
            }
        }
    }
    cout << res.size() << endl;
    for(auto x:res){
        cout << x.first << " " << x.second << endl;
    }
    return 0;
}

Measured memory_bytes: 384
'use strict';(function(input){
  input=input.trim().split(/\n+/);
  const N=input[0]-0,
        p=input[1].split(/\s+/).map(x=>x-0);
  let ans=0;
  for(let i=1;i<N-1;i++){
    if(((p[i+1]-p[i])*(p[i]-p[i-1]))>0){
      ans++;
    }
  }
  console.log(ans);
})(require('fs').readFileSync('/dev/stdin','utf8'));


Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
   // string test(9,'n');
   // cout<<test<<endl;
    string il1;//scanf("%s",il1);
    cin>>il1;
    int l=il1.length();
    string ol1(l,'x');
    cout<<ol1<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;

int modpow(int x, int n, int mod) {
    int res = 1;
    while (n > 0) {
        if (n & 1) {  // nが奇数のとき
            res *= x;
            res %= mod;
        }
        x *= x;
        x %= mod;
        n >>= 1;
    }
    return res;
}

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

    int N;
    cin >> N;
    int A[N];
    rep(i,N) cin >> A[i];
    sort(A, A+N);
    reverse(A, A+N);
    int ans = 0;
    rep(i,N){
        int num = (((A[i] * modpow(4, N-1, MOD) ) % MOD) * (i+2) ) % MOD;
        ans += num;
        ans %= MOD;
    }
    cout << ans << endl;
}

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

#define ll long long int
#define rep(i, a, n) for (ll i = a; i < n; i++)
#define repm(i, a, n) for (ll i = a; i >= n; i--)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define mod (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vd vector<double>
#define vb vector<bool>
#define vs vector<string>
#define vii vector<vector<int>>
#define vllll vector<vector<ll>>
#define ALL(a) (a).begin(), (a).end()

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

void print(bool f)
{
    cout << (f ? "Yes" : "No") << endl;
}

void Print(bool f)
{
    cout << (f ? "YES" : "NO") << endl;
}

int main(void)
{
    ll a, b, n;
    cin >> a >> b >> n;
    ll x;
    x = (n < b) ? n : b - 1;
    cout << floor(a * x / b) - a * floor(x / b) << endl;
}

Measured memory_bytes: 3772
import sys
def input(): return sys.stdin.readline().rstrip()

N = int(input())
A = list(map(int, input().split()))

A.sort(reverse=True)
N -= 2
ans = A[0]
A.pop(0)
if N % 2 == 0:
    for i in range(N//2):
        ans += A[i] * 2
else:
    for i in range(N//2):
        ans += A[i] * 2
    ans += A[N//2]

print(ans)

Measured memory_bytes: 105180
R, G, B, N = map(int, input().split())
r = N // R + 2
g = N // G + 2
ans = 0
for x in range(r):
  for y in range(g):
    Bz = N - R * x - G * y
    if Bz >= 0 and Bz % B == 0:
      ans += 1
    elif Bz < 0:
      break
print(ans)

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

int main(void){
	int n, m;
	int time[2] = { 1900, 100 };
	double tmp, x;
	double prob;

	cin >> n >> m;

	prob = pow(0.5, m);

	tmp = (n - m) * time[1];
	tmp += m * time[0];

	x = tmp / prob;

	cout << x << endl;

	return 0;
}

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

int cmp(const void* x, const void* y) {
	return strcmp(x, y);
}

int N;
char S[222222][12];

int main(void) {
	int i;
	int count = 1;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%11s", S[i]) != 1) return 1;
	}
	qsort(S, N, sizeof(*S), cmp);
	for (i = 1; i < N; i++) {
		if (strcmp(S[i - 1], S[i]) != 0) count++;
	}
	printf("%d\n", count);
	return 0;
}


Measured memory_bytes: 6264
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	aa := make([]int, n)
	m := map[int]int{}
	for i := 0; i < n; i++ {
		aa[i] = getNextInt(scanner)
		m[aa[i]]++
	}
	sort.Ints(aa)
	for i := aa[n-1]; i > aa[n-1]>>1; i-- {
		if m[i] < 2 {
			fmt.Fprintln(writer, "Impossible")
			return
		}
	}
	if aa[n-1]&1 == 1 {
		if m[aa[n-1]>>1+1] > 2 {
			fmt.Fprintln(writer, "Impossible")
			return
		}
		for i := aa[n-1] >> 1; i >= 0; i-- {
			if m[i] > 0 {
				fmt.Fprintln(writer, "Impossible")
				return
			}
		}
		fmt.Fprintln(writer, "Possible")
		return
	}
	if m[aa[n-1]>>1] != 1 {
		fmt.Fprintln(writer, "Impossible")
		return
	}
	for i := aa[n-1]>>1 - 1; i >= 0; i-- {
		if m[i] > 0 {
			fmt.Fprintln(writer, "Impossible")
			return
		}
	}
	fmt.Fprintln(writer, "Possible")
}


Measured memory_bytes: 1832
import itertools
N = int(input())
a = [0]+[int(x) for x in input().split()]
b = list(itertools.accumulate(a))
b = sorted(b)
ans = 0
for key,group in itertools.groupby(b):
  c = len(list(group))
  if 1<c:
    ans+=(c*(c-1))//2
print(ans)

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

using namespace std;

#define int long long

signed main() {
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int n, k;
  cin >> n >> k;
  int h[n+1] = {};
  while (k--) {
    int x;
    cin >> x;
    while (x--) {
      int num;
      cin >> num;
      h[num]++;
    }
  }
  cout << count(h+1,h+1+n, 0) << '\n';
  return 0;
}

Measured memory_bytes: 3648
s = sorted(input())
t=[]
tf = [False]*(97+26+1)


for i in range(len(s)):
  t.append(ord(s[i]))
x=97
for i in set(t):
  tf[i]=True

for i in range(97,97+26):
  if not tf[i]:
    print(chr(i))
    exit()
print("None")
  
  

Measured memory_bytes: 5184
import java.util.Scanner;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    while(true){
      int n =sc.nextInt();
      int x =sc.nextInt();
      int count=0;
      if(n==0&&x==0) break;
      for(int i=n;i>0;i--){
        for(int j=i-1;j>0;j--){
          for(int k=j-1;k>0;k--){
            if(i+j+k==x) count++;
          }
        }
      }
    System.out.println(count);
    }
    sc.close();
  }
}


Measured memory_bytes: 26776
n = int(input())
s = input()

lsw = [0] * n
cntw = 0

lse = [0] * n
cnte = 0

for i in range(n):
    lsw[i] = cntw
    lse[n - 1 - i] = cnte

    if s[i] == "W":
        cntw += 1
    
    if s[n - 1 - i] == "E":
        cnte += 1

min = 3 * (10 ** 5)

for i in range(n):
    wa = lsw[i] + lse[i]
    if wa < min:
        min = wa

print(min)

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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).OrderByDescending(i => i).ToArray();
            int Alice = 0, Bob = 0;
            var Aturn = true;
            for(var i = 0; i < A.Length; i++)
            {
                if (Aturn)
                {
                    Alice += A[i];
                    Aturn = false;
                }
                else
                {
                    Bob += A[i];
                    Aturn = true;
                }
            }

            Console.WriteLine(Alice - Bob);
        }
    }
}

Measured memory_bytes: 13396
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<long long, long long>;
const int INF = numeric_limits<int>::max();
const ll INFL = numeric_limits<ll>::max();
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

bool fn_is_prime(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return n != 1;
}

bool isOK(int index, int key, vector<ll>& a) {
    if (a[index] >= key) return true;
    else return false;
}

int binary_search(int key, vector<ll>& a) {
    int ng = -1;
    int ok = a.size();

    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key, a)) ok = mid;
        else ng = mid;
    }
    return ok;
}

struct UnionFind {
    vector<int> r;

    UnionFind(int N) {
        r = vector<int>(N, -1);
    }

    int root(int x) {
        if (r[x] < 0) return x;
        return r[x] = root(r[x]);
    }

    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (r[x] > r[y]) swap(x, y);
        r[x] += r[y];
        r[y] = x;
        return true;
    }

    int size(int x) {
        return -r[root(x)];
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }
};

int main()
{
    int a;
    set<int> s;
    rep(i,3) {
        cin >> a;
        s.insert(a);
    }
    cout << s.size() << endl;
}


Measured memory_bytes: 3568
import copy
n,m = map(int,input().split())
lst = [[] for _ in range(m)]
for i in range(m):
    a = list(map(int,input().split()))
    a.pop(0)
    lst[i] = copy.copy(a)
p = list(map(int,input().split()))
count = 0
for i in range(2**n):
    switch = [0 for _ in range(n)]
    for j in range(n):
        if i >> j & 1:
            switch[j] = 1
    for j in range(m):
        light = 0
        for k in range(len(lst[j])):
            if switch[lst[j][k]-1] == 1:
                light += 1
        if light % 2 != p[j]:
            break
    else:
        count += 1
print(count)

Measured memory_bytes: 3572
#include <bits/stdc++.h>
    using namespace std;
    
    int main(){
        string  str;
        cin >> str;
        long ans;
        ans = 0;
        long g = 0 , p = 0;
        for(int i = 0 ; i < str.length() ; i++){
            if(str[i] == 'g'){
                if(g > 0){
                    ans += 1;
                    g -= 1;
                }else{
                    g += 1;
                }
            }else{
                if(g <= 0){
                    ans -= 1;
                    g += 1;
                }else{
                    g -= 1;
                }
            }
            //cout << "i:" << i << " ans: " << ans << " g:" << g << endl;
        }
        cout << ans << endl;
        
        return 0;
    }

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

typedef long long ll;

int main() {
    int A1, A2, A3;
    cin >> A1 >> A2 >> A3;
    if  (A1+A2+A3 >=22) cout << "bust" << endl;
    else cout << "win" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main (void){
    int a,b,c,i;
    int count=0;
    scanf("%d %d %d",&a,&b,&c);
    for(i=a;i<=b;i++){
        if(c%i==0){
            count++;
        }
    }
    printf("%d\n",count);
    return 0;
}


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

int main() {
  long double a, b, h, m;
  cin >> a >> b >> h >> m;

  long double angle = abs(30*h + 0.5*m - 6*m);
  if(angle > 180) angle = 360 - angle;

  long double ans = sqrt(a*a + b*b - 2*a*b*cos(angle * M_PI / 180));

  cout << fixed << setprecision(20) << ans << endl;

  return 0;
}

Measured memory_bytes: 4128
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define nl n<<1
#define nr (n<<1)|1
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int>P;
const int INF=0x3f3f3f3f;
const ll INFF=0x3f3f3f3f3f3f3f3f;
const double pi=acos(-1.0);
const double eps=1e-9;
const ll mod=1e9+7;
int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0' | ch>'9') {if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0' && ch<='9') {x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
void Out(int aa)
{
    if(aa>9)
        Out(aa/10);
    putchar(aa%10+'0');
}
int main()
{
    char str[100];
    scanf("%s",str);
    for(int i=0;i<strlen(str);i++)
    {
        if(str[i]=='9')
        {
            printf("Yes\n");
            return 0;
        }
    }
printf("No\n");
    return 0;
}


Measured memory_bytes: 256
while True:
    H,W=map(int,input().split())
    if H==0:
        break
    else:
        print('#'*W)
        for i in range(1,H-1):
            print('#',end="")
            print('.'*(W-2),end="")
            print('#')
        print('#'*W)
        print()
                


Measured memory_bytes: 5628
let id x = x

let n = Scanf.scanf "%d\n" id

let a = Array.init n (fun _ -> Scanf.scanf "%d " id)
        |> Array.to_list |> List.fast_sort compare

let m = 1000000007

let rec f = function
  | [] -> true
  | a :: b :: tl when a = b -> f tl
  | _ -> false


let calc n =
  let rec f i tmp = 
    if i = 0 then tmp else f (i - 1) (2 * tmp mod m)
  in
  f n 1


let () =
  (if f (if n mod 2 == 1 then List.tl a else a) then calc (n / 2) else 0)
  |> Printf.printf "%d\n"

Measured memory_bytes: 8448
import sys
s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2sss = lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    A = i2nn()
    B = [0] * N
    B[0] = min(A[0], A[-1]) * 2
    for i in range(1, N):
        B[i] = (A[i-1] - B[i-1] // 2) * 2
    #print(B)
    d = (A[-1] - (B[0] + B[-1]) // 2)
    #print(d)
    for i in range(N):
        if (i & 1) == 0:
            B[i] += d
        else:
            B[i] -= d
    print(' '.join([str(n) for n in B]))

main()


Measured memory_bytes: 75168
N,*as=`dd`.split.map(&:to_i)
as.sort!
def r(as)
  bs = (0...N).map{|i| as[i%2 == 0 ? i/2 : -(i+1)/2] }
  cs = (0...N).map{ |i| (bs[(i+1)%N] - bs[i]).abs }
  s = cs.inject(:+)
  cs.map{ |c| s - c }.max
end

p [r(as), r(as.reverse)].max

Measured memory_bytes: 14836
fun main(args: Array<String>) {
    val (X, N) = readLine()!!.split(" ").map(String::toInt)
    val inputs = if (N == 0) IntArray(0) else readLine()!!.split(" ").map(String::toInt).toIntArray()

    fun solve(target: Int, inputs: IntArray, diff: Int): Int {
        val under = target - diff
        if (!inputs.contains(under)) {
            return under
        }

        val over = target + diff
        if (!inputs.contains(over)) {
            return over
        }

        return solve(target, inputs, diff + 1)
    }

    println(solve(X, inputs, 0))
}


Measured memory_bytes: 40084
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;//998244353;

template<class _T> static void getval(_T& a) {
	std::cin >> a;
}
template<class _T> static void getval(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void getval(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}

static void exec();

int main()
{
	exec();
	fflush(stdout);
	return 0;
}

static void exec()
{
	LLONG S;
	getval(S);

	LLONG x0 = 0, x1, x2;
	LLONG y0 = 0, y1, y2;

	int digit = 0;
	LLONG tmp = S;
	while (tmp /= 10) {
		digit++;
	}
	if (digit < 9) {
		x1 = S;
		y1 = 0;
		x2 = 0;
		y2 = 1;
	}
	else {
		x1 = 1e9;
		if (S % x1 == 0) {
			y2 = S / x1;
			x2 = 0;
		}
		else {
			LLONG tmps = S + x1;
			y2 = tmps - tmps % x1;
			y2 /= x1;
			x2 = x1 - (tmps % x1);
		}
		y1 = 1;
	}
	printf("%lld %lld %lld %lld %lld %lld\n", x0, y0, x1, y1, x2, y2);
}


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

typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define MP make_pair
#define F first
#define S second
#define PB push_back
#define dump(x)  cout << #x << " = " << (x) << endl;	// debug
#define SZ(x) ((ll)(x).size())
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, left, right)  (a).begin()+(left),(a).begin()+(right)	// left to (right-1)


int main() {
	int n;
	cin >> n;
	int res=0;
	FOR(i, 1, n) {
		int a;
		cin >> a;
		if (i % 2 == 1 && a % 2 == 1) {
			res++;
		}
	}
	pv(res)
	return 0;
}

Measured memory_bytes: 3604
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<list>
#include<map>
#include<vector>

using namespace std;


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


int main(){
    int x[3];
    rep(i, 3)
        scanf("%d", &x[i]);
    sort(x, x+3);
    int ans = x[2]*10 + x[1] + x[0];
    printf("%d", ans);



    return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
#include <queue>
#include <iomanip>
#include <iterator>

#define MOD 1000000007
#define INF 1000000001

using namespace std;
typedef unsigned long long ull;
typedef long long ll;


template <class T>
ostream &operator<<(ostream &o, const vector<T>&obj) {
    o << "["; for (int i = 0; i < (int)obj.size(); ++i) o << (i > 0 ? ", " : "") << obj[i]; o << "]"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const pair<T, U>&obj) {
    o << "(" << obj.first << ", " << obj.second << ")"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const map<T, U>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const set<T>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const queue<T>&obj) {
    queue<T> obj_cp = obj;
    bool first = true;
    o << "{";
    while (!obj_cp.empty()) { o << (!first ? ", " : "") << obj_cp.front(); obj_cp.pop(); first = false; }
    o << "}"; return o;
}

void print() {
    cout << "\n";
}
template<class Head, class... Body>
void print(Head head, Body... body) {
    cout << head << " ";
    print(body...);
}


int main(int argc, char const *argv[]) {
    int K, A, B;
    cin >> K >> A >> B;
    int a = (A + K - 1) / K;
    int b = B / K;
    // print(a, b);
    if (a <= b) {
        cout << "OK" << endl;
    } else {
        cout << "NG" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>
int main (){
	int n,check = 1;
	scanf("%d", &n);
	char s[n+1];
	scanf("%s", s);
	if(n%2 == 1){
		check = 0;
	}else{
		int temp = (n/2) + 1;
		for(int i = 0; i < n/2;i++){
			if(s[i] != s[i + (n/2)]){
				check = 0;
				break;
			}
		}
	}
	if(check == 1){
		puts("Yes");
	}else{
		puts("No");
	}
	return 0;
}

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

using namespace std;

typedef long long int li;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}
    
int main()
{    
    ios_base::sync_with_stdio(false);
        cin.tie(NULL);

        li a,b;

        cin>>a>>b;

        if(a<10 && b<10)
        {
            cout<<a*b;
        }
        else
        {
            cout<<-1;
        }

    return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    int n; std::cin >> n;
    std::vector<long long> a(n), b(n);
    for (int i = 0; i < n; i++) std::cin >> a[i] >> b[i];
    std::vector<int> id(n);
    std::iota(id.begin(), id.end(), 0);
    sort(id.begin(), id.end(), [&](int i, int j) {
        return b[i] > b[j];
    });
    long long cur = 1e18;
    for (int i : id) {
        cur = std::min(cur, b[i]) - a[i];
    }
    std::cout << (cur >= 0 ? "Yes" : "No") << std::endl;
    return 0;
}


Measured memory_bytes: 4096
import bisect

n = int(input())
xs = list(map(int,input().split()))
xs.sort()
ans = 0

for i in range(n-2):
  for j in range(i+1,n-1):
    k = bisect.bisect_left(xs[j+1:], xs[i]+xs[j])
    #print(xs[j+1:], k, xs[i]+xs[j])
    ans += k
print(ans)



Measured memory_bytes: 51532
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author TM
 */


#include <bits/stdc++.h>

using namespace std;

class CSugarWater {
public:
    void solve(std::istream &cin, std::ostream &cout) {
        int64_t a, b, c, d, e, f;
        cin >> a >> b >> c >> d >> e >> f;
        double ans = 0;
        int res_water = 0, res_sugar = 0;
        for (int i = 0; i < 31; ++i) {
            for (int j = 0; j < 31; ++j) {
                int water = 100 * a * i + 100 * b * j;
                if (water == 0) continue;
                if (water > f) continue;
                for (int k = 0; k <= (f / c); ++k) {
                    for (int l = 0; l <= (f / d); ++l) {
                        int sugar = c * k + d * l;
                        if (sugar == 0) continue;
                        if (water + sugar > f) continue;
                        if (water * (e * 1.0 / 100) < sugar) continue;
                        if (sugar * 1.0 / (sugar + water) > ans) {
                            res_sugar = sugar;
                            res_water = water;
                            ans = max(sugar * 1.0 / (sugar + water), ans);
                        }
                    }
                }
            }
        }
        cout << (res_water + res_sugar == 0 ? 100 * a : res_water + res_sugar) << " " << res_sugar << endl;
    }
};


int main() {
    CSugarWater solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn prime_factorize(n: u128) -> Vec<(u128, usize)> {
    let mut m = n;
    let mut r = vec![];
    for x in 2..n + 1 {
        if m == 1 {
            break;
        }
        if x * x > n {
            r.push((m, 1));
            break;
        }
        if n % x != 0 {
            continue;
        }
        let mut c = 0;
        while m % x == 0 {
            m /= x;
            c += 1;
        }
        r.push((x, c));
    }
    r
}

fn main() {
    let mut sc = Scanner::new();
    let n: u128 = sc.cin();
    let mut ans = 0;
    for (_, e) in prime_factorize(n).iter() {
        let mut k = *e;
        for i in 0..*e {
            if k < i + 1 {
                break;
            }
            k -= i + 1;
            ans += 1;
        }
    }
    put!(ans);
}

use std::collections::VecDeque;
use std::io::{self, Write};
use std::str::FromStr;

struct Scanner {
    stdin: io::Stdin,
    buffer: VecDeque<String>,
}
impl Scanner {
    fn new() -> Self {
        Scanner {
            stdin: io::stdin(),
            buffer: VecDeque::new(),
        }
    }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.is_empty() {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.cin::<String>().chars().collect()
    }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.cin()).collect()
    }
}


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

int main() {
  int K, A, B;
  cin >> K;
  cin >> A >> B;
  
  int i = A;
  while(i <= B){
    if( i % K == 0){
      cout << "OK" << endl;
      break;
    }else{
      i++;  
    }
  }  
  if(i > B){
    cout << "NG" << endl;
  }
  return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;

int main() {
    int N; cin >> N;
    vector<vector<int>> G(N, vector<int>(N, -1));
    for (int i = 0; i < N; i++) {
        int u, k; cin >> u >> k;
        for (int j = 0; j < k; j++) {
            int v, c; cin >> v >> c;
            G[u][v] = c;
        }
    }
    vector<bool> checked(N, false);
    vector<int> d(N, MAX);
    vector<int> p(N);
    d[0] = 0;
    p[0] = -1;

    while (true) {
        int MIN = MAX;
        int u;
        for (int v = 0; v < N; v++) {
            if (!checked[v] && chmin(MIN, d[v])) u = v;
        }

        if (MIN == MAX) break;
        checked[u] = true;

        for (int v = 0; v < N; v++) {
            if (!checked[v] && G[u][v] != -1) {
                chmin(d[v], d[u] + G[u][v]);
                p[v] = u;
            }
        }
    }

    for (int v = 0; v < N; v++) {
        cout << v << " " << d[v] << "\n";
    }
    return 0;
}


Measured memory_bytes: 3172
// C - Half and Half

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int main() {
	ll A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;

	ll ans = INF;
	for (int c=0; c <= max(X * 2, Y * 2); c++) {
		int a = max(0LL, X - (c / 2));
		int b = max(0LL, Y - (c / 2));

		ll cost = A * a + B * b + C * c;
		ans = min(ans, cost);
	}

	cout << ans << endl;

	return 0;
}

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

int main() {
  int n,t; cin >>n >>t;
  int bufc, buft;
  int ans = 9999;
  for (int i=0; i<n; i++){
    cin >>bufc >>buft;
    if (buft <= t && bufc < ans) ans = bufc;
  }
  if (ans != 9999)
  cout <<ans;
  else cout <<"TLE";
  cout <<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <queue>
#include <cstring>
using namespace std;

int main() {
	int n,ans=0; cin >> n;
	vector<int> p(n);
	for (int i = 0; i < n; i++)cin >> p[i];
	for (int i = 1; i < n - 1; i++) {
		if (p[i - 1] < p[i] && p[i + 1] < p[i])continue;
		else if (p[i - 1] > p[i] && p[i + 1] > p[i])continue;
		else ans++;
	}


	cout << ans << endl;
}



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

#define chmax(a, b) (a) = max(a, b)
#define chmin(a, b) (a) = min(a, b)

#include <cstdint>

using std::int64_t;

template <int64_t MOD>
class Modint {
  using Self = Modint<MOD>;

  int64_t m_value;

 public:
  Modint() : m_value(0) {}
  Modint(int64_t value) : m_value((value % MOD + MOD) % MOD) {}
  Self pow(int64_t e) const {
    if (e == 0) {
      return (Self)1;
    } else if (e % 2 == 0) {
      return ((*this) * (*this)).pow(e / 2);
    } else {
      return (*this).pow(e - 1) * (*this);
    }
  }
  Self inv() const { return pow(MOD - 2); }
  Self& operator=(const Self& rh) {
    m_value = rh.m_value;
    return *this;
  }
  Self operator-() const { return Self(-m_value); }
  Self operator+(const Self& other) const {
    return Self(m_value + other.m_value);
  }
  Self operator-(const Self& other) const {
    return Self(m_value - other.m_value);
  }
  Self operator*(const Self& other) const {
    return Self(m_value * other.m_value);
  }
  Self operator/(const Self& other) const { return (*this) * other.inv(); }
  Self& operator+=(const Self& rh) { return (*this) = (*this) + rh; }
  Self& operator-=(const Self& rh) { return (*this) = (*this) - rh; }
  Self& operator*=(const Self& rh) { return (*this) = (*this) * rh; }
  Self& operator/=(const Self& rh) { return (*this) = (*this) / rh; }
  int64_t value() const { return m_value; }
};

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

  vector<int64_t> a(N);
  for (auto& elm : a) {
    cin >> elm;
  }

  using Mint = Modint<1'000'000'007>;
  vector<Mint> b(N + 1);
  b[0] = 0;
  rep(i, N) { b[i + 1] = b[i] + a[i]; }

  Mint result = 0;
  rep(i, N) { result += b[i] * a[i]; }
  cout << result.value() << endl;

  return 0;
}

Measured memory_bytes: 6372
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

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

func count(a int) int {
	c := 0
	for a%2 == 0 {
		a /= 2
		c++
	}
	return c
}

func main() {
	defer stdout.Flush()

	n := readInt()
	x := 2
	for ; x <= 128; x *= 2 {
		if n < x {
			println(x / 2)
			return
		}
	}
}

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


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define EPS 1e-6
using namespace std;

double add(double a,double b){
	if(abs(a+b)<EPS*(abs(a)+abs(b)))return 0.0;
	return a+b;
}

class Point{
public:
	double x,y;
	Point(){}
	Point (double xx,double yy){
		x=xx;
		y=yy;
	}

	Point operator+(Point p){
		return Point(x+p.x,y+p.y);
	}

	Point operator-(Point p){
		return Point(x-p.x,y-p.y);
	}

	Point operator *(double a){
		return Point(a*x,a*y);
	}
	Point operator/(double a){
		return Point(x/a,y/a);
	}

	double abs(){
		return sqrt(norm());
	}

	double norm(){
		return x*x+y*y;
	}

	bool operator<(const Point &p)const{
		return x!=p.x?x<p.x:y<p.y;
	}

	bool operator==(const Point &p)const{
		return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
	}
};

typedef Point Vector;

struct Segment{
	Point p1,p2;
	Segment(){}
	Segment(Point pp1,Point pp2){
		p1=pp1;
		p2=pp2;
	}
};

typedef Segment Line;

double norm(Vector v){
	return v.x*v.x+v.y*v.y;
}

double abs(Vector v){
	return sqrt(norm(v));
}

double dot(Vector a,Vector b){
	return a.x*b.x+a.y*b.y;
}

double cross(Vector a,Vector b){
	return a.x*b.y-a.y*b.x;
}

static const int COUNTER_CLOCKWISE=1;
static const int CLOCKWISE=-1;
static const int ONLINE_BACK=2;
static const int ONLINE_FRONT=-2;
static const int ON_SEGMENT=0;

int ccw(Point p0,Point p1,Point p2){
	Vector a=p1-p0;
	Vector b=p2-p0;
	if(cross(a,b)>EPS)return COUNTER_CLOCKWISE;
	if(cross(a,b)<-EPS)return CLOCKWISE;
	if(dot(a,b)<-EPS)return ONLINE_BACK;
	if(a.norm()<b.norm())return ONLINE_FRONT;
	return ON_SEGMENT;
}

bool intersect(Point p1,Point p2,Point p3,Point p4){
	return (ccw(p1,p2,p3)*ccw(p1,p2,p4)<=0 && ccw(p3,p4,p1)*ccw(p3,p4,p2)<=0);
}

bool intersect(Segment s1,Segment s2){
	return intersect(s1.p1,s1.p2,s2.p1,s2.p2);
}

Point project(Segment s,Point p){
	Vector base=s.p2-s.p1;
	double r=dot(p-s.p1,base)/norm(base);
	return s.p1+base*r;
}

Point reflect(Segment s,Point p){
	return p+(project(s,p)-p)*2.0;
}


int n;
Point s;
Point p[10][8];
int ord[8];

double getdir(Vector v){
	double dir=atan2(v.y,v.x);
	if(dir<0.0){
		dir+=M_PI*2.0;
	}
	return dir;
}

bool check(){
	for(int i=0;i<n;i++){
		int v=ord[i];
		for(int j=0;j<n;j++){
			p[i+1][j]=reflect(Segment(p[i][v],p[i][(v+1)%n]),p[i][j]);
		}
	}
	Vector l=p[0][ord[0]]-s;
	Vector r=p[0][(ord[0]+1)%n]-s;
	//printf("%.10f %.10f\n",getdir(l)/M_PI*180.0,getdir(r)/M_PI*180.0);
	for(int i=1;i<n;i++){
		Vector l2=p[i][ord[i]]-s;
		Vector r2=p[i][(ord[i]+1)%n]-s;
		if(cross(l2,r2)<0.0){
			swap(l2,r2);
		}
		//printf("%.5f %.5f %.5f\n",l2.x,l2.y,r2.x,r2.y);
		//printf("%.10f %.10f\n",getdir(l2)/M_PI*180.0,getdir(r2)/M_PI*180.0);
		if(cross(l,l2)>0.0)swap(l,l2);
		if(cross(r,r2)<0.0){
			swap(r,r2);
		}
		//printf("%.10f %.10f\n",getdir(l)/M_PI*180.0,getdir(r)/M_PI*180.0);
		if(cross(l,r)<EPS)return false;
	}
	return true;
}

void solve(){
	scanf("%lf%lf",&s.x,&s.y);
	for(int i=0;i<n;i++){
		ord[i]=i;
		scanf("%lf%lf",&p[0][i].x,&p[0][i].y);
	}
	int ans=0;
	do{
		if(check())ans++;
	}while(next_permutation(ord,ord+n));
	printf("%d\n",ans);
	return;
} 

int main(void){
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		solve();
	}
}


Measured memory_bytes: 3140
#line 2 "../../library/template.hpp"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pl = pair<ll, ll>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define rep3(i, l, r) for(ll i = l; i < (ll)r; i++)
#define per(i, n) for(ll i = (ll)n-1; i >= 0; i--)
#define per3(i, l, r) for(ll i = (ll)r-1; i >= (ll)l; i--)
#define all(v) begin(v), end(v)
template<class T, class U> inline void cmax(T& a, U b) { if (a < b) a = b; }
template<class T, class U> inline void cmin(T& a, U b) { if (a > b) a = b; }
constexpr char el = '\n';
template<class T, class U> ostream &operator<<(ostream &os, const pair<T, U>& p) { os << p.first << " " << p.second; return os; }
template<class T, class U> istream &operator>>(istream &is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<class T> ostream &operator<<(ostream &os, const vector< T > &v) { rep(i, v.size()) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }
template<class T> istream &operator>>(istream &is, vector< T > &v) { for(T &in : v) is >> in; return is; }
struct IoSetup {
  IoSetup() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15); }
} io_setup;
#line 2 "d.cpp"

vl gen_primes(ll n) {
  vector<bool> is_prime(n+1, true);
  is_prime[0] = is_prime[1] = false;
  rep(i, n+1) {
    if (is_prime[i]) {
      for (ll j = 2*i; j <= n+1; j += i) {
        is_prime[j] = false;
      }
    }
  }
  vl res;
  rep(i, n+1) {
    if (is_prime[i])
      res.push_back(i);
  }
  return res;
}

int main() {
  auto vec = gen_primes(55'555);
  ll n;
  cin >> n;
  for (auto&& i : vec) {
    if (n and i%5 == 1) {
      n--;
      cout << i << " ";
    }
  }
  cout << el;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

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

    int h_min = 0;
    bool flag = true;
    for (int i = 0; i < n; i++) {
        int h;
        cin >> h;

        if (h_min < h - 1) {
            h_min = h - 1;
        } else if (h_min > h) {
            flag = false;
        }
    }

    cout << (flag ? "Yes" : "No") << endl;
}


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

void solve()
{
	ll n,k;
	cin>>n>>k;

	ll arr[n];

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

	bool dp[k+1]={false};

	for(ll stones=1;stones<=k;stones++)
	{
		for(ll i=0;i<n;i++)
			{
				if(stones>=arr[i] && !dp[stones-arr[i]])
					dp[stones]=true; 	
		}
	} 
  if(dp[k])
		cout<<"First"<<endl;
	else cout<<"Second"<<endl;

}


int main()
{
	solve();
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  for(int i = 0; i < n; i++){
    int a;
    cin >> a;
    if(a-1 == i) p.at(i) = 1;
  }
  
  int ans = 0;
  for(int i = 0; i < n; i++){
    if(p.at(i) == 1){
      ans++;
      if(i < n-1) p.at(i+1) = 0;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3792
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair

const int A = 26;
const int N = 100100;
char s[N];
int a[N];
int n;
int L;
vector<int> g[N];
int SUM = 0;
bool used[N];

void dfs(int v) {
	used[v] = 1;
	SUM += a[v];
	for (int u : g[v]) {
		if (!used[u])
			dfs(u);
	}
}

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf(" %s ", s);
	n = strlen(s);
	L = n / 2;
	for (int i = 0; i < L; i++) {
		a[i] = (int)s[i] - (int)s[n - 1 - i];
		if (a[i] < 0) a[i] += A;
	}
	for (int i = L; i > 0; i--) {
		a[i] -= a[i - 1];
		if (a[i] < 0) a[i] += A;
	}
	L++;
	/*
	for (int i = 0; i < L; i++)
		printf("%d ", a[i]);
	printf("\n");
	*/
	int m;
	scanf("%d", &m);
	while(m--) {
		int l, r;
		scanf("%d%d", &l, &r);
		l--;
		if (l + r > n) {
			swap(l, r);
			l = n - l;
			r = n - r;
		}
		if (r > n - r)
			r = n - r;
		//printf("edge %d %d\n", l, r);
		g[l].push_back(r);
		g[r].push_back(l);
	}
	for (int v = 0; v < L; v++) {
		if (used[v]) continue;
		dfs(v);
		if (SUM % A != 0) {
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");

	return 0;
}


Measured memory_bytes: 6016
def q2():
    K, X = (int(i) for i in input().split())
    min_pos = X - K + 1
    max_pos = X + K
    ans = map(lambda x: str(x), range(min_pos, max_pos))
    print(' '.join(list(ans)))


if __name__ == '__main__':
    q2()


Measured memory_bytes: 2940
def resolve():
    from collections import defaultdict
    n = int(input())
    d = defaultdict(int)
    for i in range(n):
        d[input()] += 1
    print("AC x " + str(d["AC"]))
    print("WA x " + str(d["WA"]))
    print("TLE x " + str(d["TLE"]))
    print("RE x " + str(d["RE"]))


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9476
w=gets.to_i
n=gets.to_i
a=[]
w.times{|i|a[i]=i}
n.times{b,c=gets.chomp.split(',').map(&:to_i);a[b-1],a[c-1]=a[c-1],a[b-1]}
a.map{|i|p i+1}

Measured memory_bytes: 8568
#include <iostream>
#include <vector>
#include <list>
#include <math.h>
#include <algorithm>
#include <functional>
#include <string>
#include <iomanip>
#include <queue>
#include <map>
#include <unordered_map>
typedef long long ll;
using namespace std;

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

	vector<int> A(N);

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

//	sort(A.begin(), A.end());

	int count=0;
	while(1){
		for(int i=0; i<N; i++){
			if(A[i]%2==1){
				cout << count << endl;
				return 0;
			}else{
				A[i] = A[i] / 2;
			}
		}
		count++;
	}
}

Measured memory_bytes: 256