akhauriyash/Code-Regression huggingface dataset:
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++)
    scanf("%*d");
  printf("%d\n", n <= k ? 1 : ((int)ceil((float)(n - k) / (float)(k - 1)) + 1));
}

Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    map<int,bool>isouted;

    int a, b, k;
    cin >> a >> b >> k;
    for (int i=a; i<=min(a+k-1,b); i++){
        isouted[i] = true;
        cout << i << endl;
    }

    for (int i=max(b-k+1,a); i <= b; i++){
        if (isouted[i])continue;
        else cout << i << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		while (true) {
			int H = sc.nextInt();
			int W = sc.nextInt();

			if (H == 0 && W == 0) {
				sc.close();
				text.deleteCharAt(text.lastIndexOf("\n"));
				System.out.println(text.toString());
				break;
			} else {
				for (int i = 0; i < H; i++) {
					for (int t = 0; t < W; t++) {
						text.append("#");
					}
					text.append("\n");
				}
				text.append("\n");
			}

		}
	}

}



Measured memory_bytes: 27800
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<time.h>
#include<vector>
using namespace std;
int main()
{
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);
    int x;
    cin>>x;
    if(x==1)
        cout<<"0"<<endl;
    else
        cout<<"1"<<endl;
    return 0;
}



Measured memory_bytes: 3536
# https://atcoder.jp/contests/agc018/tasks/agc018_a

n, k = map(int, input().split())
nums = [int(i) for i in input().split()]

def gcd(x, y): #GCD
    # greatest_common_divisor
    if x < y:
        x, y = y, x
    if y == 0:
        return 0
    if x % y == 0:
        return y
    return gcd(y, x % y)

MAX = max(nums)
GCD = nums[0]
for num in nums:
    GCD = gcd(GCD, num)

if k <= MAX and k % GCD == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Measured memory_bytes: 62704
#include<stdio.h>
#include<string.h>
int main()
{
	char a[1005];
	int N, W, S, E,i,l,ok;
	while (scanf("%s", a) != EOF)
	{
		N = W = E = S = 0;
		l = strlen(a);
		ok = 1;
		for (i = 0; i < l; i++)
		{
			if (a[i] == 'N')
			{
				N++;
			}
			else if (a[i] == 'S')
			{
				S++;
			}
			else if (a[i] == 'W')
			{
				W++;
			}
			else
			{
				E++;
			}
		}
		if ((N&&S&&W&&E) || (N&&S&&!W&&!E) || (!N&&!S&&W&&E))
		{
			printf("Yes\n");
		}
		else
		{
			printf("No\n");
		}
	}
	return 0;
}

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

int main()
{
  unsigned N, M;
  std::cin >> N >> M;
  
  std::vector<unsigned> edge = std::vector<unsigned>(N, 0);
  
  for (unsigned m = 0; m < M; ++m) {
    unsigned a, b;
    std::cin >> a >> b;
    
    ++edge[a - 1];
    ++edge[b - 1];
  }
  
  for (unsigned n = 0; n < N; ++n) {
    std::cout << edge[n] << std::endl;
  }
  
  return 0;
}

Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define YY puts("Yes")
#define NN puts("No")
const int INF = 1000000007;
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll fac(ll a) { return a > 1 ? fac(a - 1) * a : 1; }
int solve(){
  int n;
  cin >> n;
  int a = 0,b = 0,c = 0;
  rep(i,n){
    int tmp;
    cin >> tmp;
    if(tmp % 4 == 0)a++;
    else if(tmp % 2 == 0)b++;
    else c++;
  }
  if(c == a + 1){
    if(b == 0)YY;
    else NN;
  }
  else{
    if(a >= c)YY;
    else NN;
  }
  return 0;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16) << endl; 
  solve();
  return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	In := readLine()
	if ReverseCheck(In) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

/////////////////////////////////////////

//func readLineInt() []int {
//	result := make([]int, 0)
//	for _, v := range strings.Split(readLine(), " ") {
//		i, _ := strconv.Atoi(v)
//		result = append(result, i)
//	}
//	return result
//}

var reader = bufio.NewReaderSize(os.Stdin, 1e6)

func readLine() string {
	result := make([]byte, 0, 1e6)
	for {
		line, remains, e := reader.ReadLine()
		if e != nil {
			panic(e)
		}
		result = append(result, line...)
		if !remains {
			break
		}
	}
	return string(result)
}

func ReverseCheck(s string) bool {
	sa := strings.Split(s, "")

	for i := 0; i < len(sa); i++ {
		if sa[i] != sa[len(sa)-i-1] {
			return false
		}
	}
	return true
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;

bool is_integer(double A){
    if(floor(A) == A){
        return true;
    }
    else{
        return false;
    }
}
//15:14
int main()
{
    string s, t;
    cin >> s >> t;
    int count = 0;
    for (int i = 0; i < 3; i++)
    {
        if(s[i] == t[i]){
            count++;
        }
    }
    cout << count << endl;
}

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


int main(){
  int AB, BC, CA;
  cin >> AB >> BC >> CA;
  if (AB < CA && BC < CA) cout << AB * BC / 2 << endl;
  else if (BC < AB && CA < AB) cout << BC * CA / 2 << endl;
  else cout << CA * AB / 2 << endl;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int a, b, c;
  cin >> a >> b >> c;

  if (a + b + c >= 22) cout << "bust" << endl;
  else cout << "win" << endl;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include <utility>
#include<algorithm>

using namespace std;
int main()
{
	int n;cin>>n;
	if(n<=1000)
		cout<<1000-n<<endl;
	else if(n%1000 ==0) cout<<n%1000<<endl;
	else
	{
		cout<<1000 - n%1000<<endl;
	}


	return 0;
}



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

int main(int argc, const char * argv[]) {
    
    double r;
    cin >> r;
    
    printf("%.5f %.5f",M_PI * r * r,2 * M_PI * r);
    
    return 0;
}

Measured memory_bytes: 1240
package main
import "fmt"
func main(){
    // Your code here!
    var n, m int
    fmt.Scan(&n, &m)
    
    t := make([]int, m)
    for i := 0; i < m; i++ {
         fmt.Scan(&t[i])
    }

    var tmp int
    for i := 0; i<m; i++{
        if i == 0{
            tmp = t[m-1] - t[i]
        }else{
            if tmp > (t[m-1] - t[i] + n - t[m-1] + t[i-1]){
                tmp = t[m-1] - t[i] + n - t[m-1] + t[i-1]
            }
        }
    }
    fmt.Println(tmp)
}


Measured memory_bytes: 6016
#include<stdio.h>
#define NUM 5
int main(){
  int i,data[NUM];
  scanf("%d %d %d %d %d",&data[0],&data[1],&data[2],&data[3],&data[4]);
  for(i=0;i<NUM;i++){
    if(data[i]==0){
      printf("%d",i+1);
      break;
    }
  }
}

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

//  https://ja.wikipedia.org/wiki/Xorshift
int xor64(void) {
	static unsigned long long x = 88172645463325252ULL;
	x ^= x << 13;
	x ^= x >> 7;
	x ^= x << 17;
	return int(x & 0x7fffffff);
}

int main()
{
	//  入力
	int D;
	cin >> D;
	vector<int> C(26);
	for (int &c : C)
		cin >> c;
	vector<vector<int>> S(D, vector<int>(26));
	for (auto &s : S)
		for (auto &x : s)
			cin >> x;

	auto start = system_clock::now();

	//  選んだコンテスト
	vector<int> T(D, -1);

	int score = 0;
	for (int t = 0; t < 26; t++)
		score -= C[t] * D*(D + 1) / 2;

	//  d日目にコンテストtを開く
	auto add = [&](int d, int t)
	{
		int d0 = d;
		while (d0 >= 0 && T[d0] != t)
			d0--;
		int d1 = d;
		while (d1 < D && T[d1] != t)
			d1++;
		score += C[t] * (d - d0)*(d1 - d);
		score += S[d][t];
		T[d] = t;
	};

	//  d日目のコンテストを止める
	auto remove = [&](int d)
	{
		int t = T[d];
		T[d] = -1;
		int d0 = d;
		while (d0 >= 0 && T[d0] != t)
			d0--;
		int d1 = d;
		while (d1 < D && T[d1] != t)
			d1++;
		score -= C[t] * (d - d0)*(d1 - d);
		score -= S[d][t];
	};

	for (int d = 0; d < D; d++)
		add(d, d % 26);

	double time = 0.0;
	double limit = 1.8;

	int step;
	for (step = 0; time < limit; step++)
	{
		if (step % 10000 == 0)
			time = duration_cast<microseconds>(system_clock::now() - start).count() * 1e-6;

		//  1日のコンテストの種類を変えてみる
		int d = xor64() % D;
		int t = xor64() % 26;
		int old_score = score;
		int old_t = T[d];
		remove(d);
		add(d, t);

		//  悪くなったら戻す
		if (score < old_score)
		{
			remove(d);
			add(d, old_t);
		}
	}

	for (int t : T)
		cout << t + 1 << endl;

	cerr << "score: " << max(0, score + 1000000) << endl;
	cerr << "step: " << step << endl;
}


Measured memory_bytes: 3668
#include <stdio.h>
#include <iostream>
#include <vector>
#include<algorithm>
using namespace std;


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

	if (b-a==c-b)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}

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

using namespace std;

int main() {
  int N;
  vector<int> list;
  
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    int in;
    
    cin >> in;
    
    list.push_back(in);
  }
  
  sort(list.begin(), list.end());
  
  long min_sum = 0x7fffffff;
  long sum = 0;
  
  for (int j = *list.rbegin(); j > 0; j--) {
    sum = 0;
    
    for (int i = 0; i < N; i++) {
      sum += (list[i] - j) * (list[i] - j);
    }
    
    min_sum = min(min_sum, sum);
  }
  
  cout << min_sum << endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Sparsh Sanchorawala
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ALucky7 solver = new ALucky7();
        solver.solve(1, in, out);
        out.close();
    }

    static class ALucky7 {
        public void solve(int testNumber, InputReader s, PrintWriter w) {
            int n = s.nextInt();
            int flag = 0;
            while (n > 0) {
                if (n % 10 == 7)
                    flag = 1;
                n /= 10;
            }
            if (flag == 1)
                w.println("Yes");
            else
                w.println("No");
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 32472
#include <cstdio>
#include <algorithm>

int main(){
    int n, q, com, x, y, *tree;
    std::scanf("%d%d", &n, &q);

    tree = new int[2 * n];
    for(x = 1; x < 2 * n; ++x) tree[x] = (1U << 31) - 1;

    while(q--){
        std::scanf("%d%d%d", &com, &x, &y);
        if(com == 0){
            tree[n + x] = y;
            for(x = (n + x) >> 1; x > 0; x >>= 1){
                tree[x] = std::min(tree[x << 1], tree[x << 1 | 1]);
            }
        }else{
            x += n;
            y += n+1;
            int v = (1U << 31) - 1;
            while(x < y){
                if(x & 1) v = std::min(v, tree[x++]);
                if(y & 1) v = std::min(tree[y - 1], v);
                x >>= 1;
                y >>= 1;
            }
            std::printf("%d\n", v);
        }
    }
    delete[] tree;

    return 0;
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define rep(i,a,b) for (int i = a; i < b; i++)
#define repn(i,a,b) for (int i = a; i >=b ;i--)
#define MOD 1000000007


int main(){
ios::sync_with_stdio(0);
cin.tie(0);
    string s;cin>>s;
    int ma=0,cnt=0;
    rep(i,0,3){
        if(s[i]=='R')cnt++;
        if(s[i]=='S'||i==2){
            if(ma<cnt)ma=cnt;
            cnt=0;
        }
        
    }
    cout<<ma;
 
return 0;
}

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

#define FOR(i,a,b) for (int i = (int)(a); i < (int)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define pb push_back
#define x first
#define y second

#define TRACE(x) cerr << #x << " = " << x << endl
#define _ << " _ " <<

using namespace std;

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

int n;
ll l, t;
pii x[100005];

ll f(ll a){
  a %= l;
  if (a < 0) return a+l;
  return a;
}

set<pii> Sn, Sp;

pii location(int dir, ll loc, ll tm){

  while (true){
    loc = f(loc);
    int nxt;
    if (dir == 1)
      nxt = Sn.lower_bound({f(loc+tm), 1e9})->y;
    else
      nxt = (--Sp.lower_bound({f(loc-tm), -1}))->y;
    ll loc2 = f(x[nxt].x + tm * x[nxt].y);

    if (dir == 1){
      if (loc2 <= loc) loc2 += l;
      loc2 = (loc+loc2) / 2;
    } else {
      if (loc2 >= loc) loc2 -= l;
      loc2 = (loc+loc2) / 2;
    }

    ll del = abs(loc-loc2);
    if (tm+del > t) break;
    tm += del;
    loc = loc2;
    dir = -dir;
    
  }

  return {f(loc + (t-tm) * dir), dir};
  
}

pii location(pii a, ll tm){
  return location(a.y, a.x, tm);
}

ll location(int id){
  return location(x[id], 0).x;
}

int main(){
  ios_base::sync_with_stdio(false);

  cin >> n >> l >> t;
  REP(i,n) cin >> x[i].x >> x[i].y, x[i].y = x[i].y == 1 ? 1 : -1;

  {
    bool check = true;
    REP(i,n) if (x[i].y != x[0].y) check = false;
    if (check){
      REP(i,n) cout << f(x[i].x + t * x[i].y) << endl;
      return 0;
    }
  }

  l *= 2;
  t *= 2;
  REP(i,n) x[i].x *= 2;

  REP(i,n){
    if (x[i].y == 1)
      Sp.insert({x[i].x, i}),
	Sp.insert({x[i].x+l, i}),
	Sp.insert({x[i].x-l, i});
    else
      Sn.insert({x[i].x, i}),
	Sn.insert({x[i].x+l, i}),
	Sn.insert({x[i].x-l, i});
  }

  ll a = t/l;
  ll b = t%l;

  t = l;
  ll p = location(0);
  ll q = location(1);

  vector<ll> all;
  REP(i,n) all.pb(f(x[i].x + x[i].y * t));
  sort(all.begin(), all.end());

  ll id = -1;
  if (all.back() == p && all.front() == q)
    id = n-1;
  REP(i,n-1) if (all[i] == p && all[i+1] == q) id = i;
  assert(id != -1);

  id = a*id%n;
  t = a*l+b;
  p = location(x[id], a*l).x;
  q = location(x[(id+1)%n], a*l).x;

  all.clear();
  REP(i,n) all.pb(f(x[i].x + x[i].y * t));
  sort(all.begin(), all.end());

  id = -1;
  if (all.back() == p && all.front() == q)
    all.insert(all.begin(), p), all.pop_back();
  REP(i,n-1) if (all[i] == p && all[i+1] == q) id = i;

  assert(id != -1);
  
  FOR(i,id,n) cout << all[i]/2 << endl;
  FOR(i,0,id) cout << all[i]/2 << endl;

  return 0;
}


Measured memory_bytes: 22388
#include<bits/stdc++.h>
#define ll long long int
#define endl '\n'
#define M 1000000007
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define f first
#define s second
#define b begin
#define e end
#define pb push_back
#define mp make_pair
#define FOR(i,a,b) for(i=a;i<b;i++)
#define RFOR(i,a,b) for(i=a;i>=b;i--)
#define all(x) x.begin(),x.end()
#define itfr(it,x) for(it=x.begin();it!=x.end();it++)
#define flash ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;

int main()
{
    flash;
    //sieve();
    ll T=1,t,n,m,q,k,i,j;
    // cin>>T;
    while(T--)
    {
        cin>>n;
        ll a[n];
        FOR(i,0,n)  cin>>a[i];
        ll pr[n],suf[n],gd[n];
        pr[0] = a[0];
        suf[n-1] = a[n-1];
        FOR(i,1,n)
            pr[i] = __gcd(pr[i-1],a[i]);
        RFOR(i,n-2,0)
            suf[i] = __gcd(suf[i+1],a[i]);
        gd[0] = suf[1];
        gd[n-1] = pr[n-2];
        FOR(i,1,n-1)
            gd[i] = __gcd(pr[i-1],suf[i+1]);
        sort(gd,gd+n);
        cout<<gd[n-1]<<endl;
    }
}

Measured memory_bytes: 6744
#include <iostream>
using namespace std;
int main() {
    int N, K, X, Y;
    cin >> N >> K >> X >> Y;

    int ans;
    if (N<=K)
    {
        ans = N * X;
    }
    else
    {
        ans = K * X + (N-K) * Y;
    }
    
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: chars,
    }
    let mut res = 0;
    for bit in 0..(1 << (s.len() - 1)) {
        let mut tmp: std::vec::Vec<char> = std::vec::Vec::with_capacity(s.len());
        for (i, c) in s.iter().enumerate() {
            tmp.push(c.clone());
            if bit & 1 << i != 0 || i == s.len() - 1 {
                res += tmp.into_iter().collect::<String>().parse::<u64>().unwrap();
                tmp = std::vec::Vec::with_capacity(s.len());
            }
        }
    }
    println!("{:?}", res);
}

Measured memory_bytes: 4352
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    a = []
    for i in range(4):
        a.append(f()[0])
    
    print(min(a[:2]) + min(a[2:]))

solve()


Measured memory_bytes: 2940
# -*- coding: utf-8 -*-
"""
Created on Sat Jun 23 20:51:56 2018
ABC101B
@author: maezawa
"""

s = input()
n= 0
for c in s:
    n += int(c)
    
if int(s) % n == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 2940
N, K = map(int, input().split())
*x, = map(int, input().split())
ans = float('inf')
for i in range(N-K+1):
    chk = 0
    left = x[i]
    right = x[i+K-1]
    left_to_right = abs(left - right) + abs(left)
    right_to_left = abs(right-left) + abs(right)
    chk = min(left_to_right, right_to_left)
    ans = min(ans, chk)
print(ans)

Measured memory_bytes: 14568
#include <stdio.h>
#include <string.h>

int main() {
    char s[27],ans[4]="yes";
    scanf("%s",s);
    for(int i=0;i<strlen(s);i++){
        for(int m=1;m<strlen(s)-i;m++){
            strcpy(ans,s[i]==s[i+m]?"no":ans);
        }
    }
    printf("%s\n",ans);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
int n;
std::vector<int> g[100005];
int dfs(int u,int fa){
	int sg=0;
	for(int v:g[u])if(v!=fa)sg^=dfs(v,u)+1;
	return sg;
}
int main(){
	scanf("%d",&n);
	for(int i=1,x,y;i<n;i++){
		scanf("%d%d",&x,&y);
		g[x].push_back(y),g[y].push_back(x);
	}
	puts(dfs(1,0)?"Alice":"Bob");
}


Measured memory_bytes: 10368
#include<cstdio>

inline int RD() {
	int m=0,k=1; char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar()) if(ch=='-') k=-1;
	for(;ch>='0'&&ch<='9';ch=getchar()) m=(m<<1)+(m<<3)+ch-48;
	return m*k;
}

int book[200005];
int main() {
	int N,M;
	N=RD(); M=RD();
	for(int t,x,y,i=1;i<=M;i++) {
		x=RD(); y=RD();
		if(x>y) {t=x;x=y;y=t;}
		if(x==1&&y!=N) book[y]++;
		if(x!=1&&y==N) book[x]++;
	}
	for(int i=2;i<N;i++)
		if(book[i]==2) {
			printf("POSSIBLE");
			return 0;
		}
	printf("IMPOSSIBLE");
	return 0;
}


Measured memory_bytes: 896
/**
  @date Time-stamp: <2019-05-26 13:19:58 tagashira>
  @file d.cpp
  @title D - Integer Cards
  @brief https://atcoder.jp/contests/abc127/tasks/abc127_d
**/

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

typedef pair<uint, long unsigned int> P;
bool pairCompare(const P& firstElof, const P& secondElof) {
  return firstElof.second > secondElof.second;
}

template <class T>
void show(vector<T>& v) {
  for (uint i = 0; i < v.size(); i++) {
    cout << v[i] << " ";
  }
  cout << "\n";
}

template <class T1, class T2>
void show(vector<pair<T1, T2>>& v, int x) {
  if (x == 1) {
    for (uint i = 0; i < v.size(); i++) {
      cout << v[i].first << " ";
    }
  } else if (x == 2) {
    for (uint i = 0; i < v.size(); i++) {
      cout << v[i].second << " ";
    }
  } else {
    cout << "Wrong Argument";
  }
  cout << "\n";
}

int main(int argc, char* argv[]) {
  uint N, M;
  cin >> N >> M;

  vector<long unsigned int> A(N, 0);
  for (uint i = 0; i < N; i++) {
    cin >> A[i];
  }

  vector<pair<uint, long unsigned int>> BC(M);
  for (uint i = 0; i < M; i++) {
    cin >> BC[i].first >> BC[i].second;
  }

  for (uint i = 0; i < N; i++) {
    pair<uint, long unsigned int> tmpPair = make_pair(1, A[i]);
    BC.push_back(tmpPair);
  }

  // sort(A.begin(), A.end(), greater<vector<long unsigned int>::value_type>());
  sort(BC.begin(), BC.end(), pairCompare);

  long unsigned int ans = 0;
  for (uint count = 0; N > 0; count++) {
    ans += BC[count].second * min(BC[count].first, N);
    N -= min(BC[count].first, N);
    // cout << "count:" << count << "\nans: " << ans << " N: " << N << endl;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 7684
#include<bits/stdc++.h>
using namespace std;
double po(int  a,int b){
int sum=1;
for(int i=1;i<=b;i++){
    sum=sum*a;
}
return sum;
}

int main(){
int a,b;
cin>>a>>b;
int sum1=0;
for(int i=0;i<b;i++){
    sum1=sum1+a*po(10,i);
}
int sum2=0;
for(int i=0;i<a;i++){
    sum2=sum2+b*po(10,i);
}
if(sum1>=sum2){
    printf("%d",sum1);
}
else{
    printf("%d",sum2);
}
}


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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}

debug dbg;

class ABA {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int a, b;
	    in >> a >> b;
	    if(b%a == 0) out << a+b << endl;
	    else out << b-a << endl;
	}
};


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


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())



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

	int p;
	cin >> p;
	cout << p / 500 * 500 << endl;

	return 0;
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    map<ll, ll> mp;
    for(ll i=2;i<=n;i++){
    	ll maki = i;
    	ll num = ll(sqrt(maki));
    	for(ll j=2;j<=num;j++){
    		while(maki % j == 0){
    			maki /= j;
    			mp[j]++;
    		}
    	}
    	if(maki > 1LL) mp[maki]++;
    }
    ll ans = 1;
    for(auto& i: mp){
    	ans *= (i.second + 1);
    	ans %= mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int m, k; readV(m, k);

  if (m == 1) {
    writeln(k == 0 ? "0 0 1 1" : "-1");
    return;
  }

  if (k >= 2^^m) {
    writeln(-1);
    return;
  }

  foreach (i; 0..2^^m)
    if (i != k) write(i, " ");
  write(k, " ");
  foreach_reverse (i; 0..2^^m)
    if (i != k) write(i, " ");
  writeln(k);
}


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define showmap(is, js, x) {rep(i, is){rep(j, js){cout << x[i][j] << " ";}cout << endl;}}
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> llP;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}

/*
[check]
桁dp系かと思いきや数列生成


*/


int main()
{
    string s;
    int k;
    cin >> s >> k;

    set<int> num;
    rep(i, 10){num.insert(i);}
    rep(i, k){ int tmp; cin >> tmp; num.erase(tmp);}
    vector<int> num_box;
    for (auto itr = num.begin(); itr != num.end(); itr++)
    {
        num_box.push_back(*itr);
    }
    //show(num_box);
    queue<string> q;
    vector<int> box;
    bool iszero = false;
    for (int i = 0; i < num_box.size(); i++)
    {
        if (num_box[i] == 0) iszero = true;
        q.push(to_string(num_box[i]));
    }
    if (!iszero) q.push("0");
    while(!q.empty()){
        auto now = q.front(); q.pop();
        if (now.size() == s.size()+1) {
            box.push_back(stol(now));
            continue;
        }
        for(auto x: num_box){
            string next = now + to_string(x);
            q.push(next);
        }
        if(stol(now)==0 && !iszero){
            q.push(now+"0");
        }
    }

    sort(box.begin(), box.end());
    //show(box);
    cout << *lower_bound(box.begin(), box.end(), stol(s)) << endl; 

}


Measured memory_bytes: 3968
//agrawal117
//chahatagrawal117
#include<bits/stdc++.h>
#define endl '\n'
#define mod 1000000007
typedef long long int ll;
using namespace std;
#define MAX 100005
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n; cin>>n;
    ll ans=0;
    for(int i=1;i<=n;i++){
        ll x=n/i;
        ll last=n-(n%i);
        ll sum=i+last;
        ll val=(x*sum)/2;
        ans+=val;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "
int main(){
    ll n;cin>>n;
    ll ans = 0;
    for(int i=1;i<=n;i++){
        //n以下の最大のiの倍数
        ll last_term = (n/i)*i;
        ll num_term = (last_term-i)/i+1;
        ans += (i+last_term) * num_term / 2;
    }
    co(ans);
}

Measured memory_bytes: 3532
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,t;
    cin>>s>>t;
    int n=s.size();
    int m=t.size();
    int dp[n+1][m+1];
    for(int i=0;i<=n;i++)
     dp[i][0]=0;
    for(int i=0;i<=m;i++)
     dp[0][i]=0;
    for(int i=1;i<=n;i++)
     for(int j=1;j<=m;j++)
     {
         if(s[i-1]==t[j-1])
          dp[i][j]=1+dp[i-1][j-1];
         else
          dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
     }
     int i=n,j=m;
     string ans="";
     while(i>0 && j>0)
     {
         if(s[i-1]==t[j-1])
         {
             ans.push_back(s[i-1]);
             i--;j--;
         }
         else if(dp[i-1][j]>dp[i][j-1])
          i--;
        else
         j--;
     }
     reverse(ans.begin(),ans.end());
     cout<<ans<<endl;
}

Measured memory_bytes: 38756
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

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

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    char a[2], b[2];
    
    scanf("%s%s", a, b);
    
    if (a[0]=='H'&&b[0]=='H') {
        printf("H");
    } else if (a[0]=='H'&&b[0]=='D') {
        printf("D");
    } else if (a[0]=='D'&&b[0]=='H') {
        printf("D");
    } else if (a[0]=='D'&&b[0]=='D'){
        printf("H");
    }
    
    return 0;
}



Measured memory_bytes: 1588
package main

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

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024

var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	n, m := nextInt(), nextInt()

	likes := map[int]bool{}
	for i := 0; i < m; i++ {
		likes[i] = true
	}

	for i := 0; i < n; i++ {
		k := nextInt()
		ilikes := map[int]bool{}

		for j := 0; j < k; j++ {
			ilikes[nextInt()-1] = true
		}
		for j := 0; j < m; j++ {
			likes[j] = likes[j] && ilikes[j]
		}
	}

	c := 0
	for i := 0; i < m; i++ {
		if likes[i] {
			c++
		}
	}
	fmt.Println(c)
}


Measured memory_bytes: 640
from collections import Counter
S = input()[::-1]
MOD = 2019

X = [0]
for i, s in enumerate(S):
    X.append((X[-1] + int(s) * pow(10, i, MOD)) % MOD)


C = Counter(X)
ans = 0
for v in C.values():
    ans += v * (v - 1) // 2
print(ans)


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

class UnionFind
{
  public:
    vector<long long> root;

    UnionFind(long long N)
    {
        root = vector<long long>(N + 1, -1);
    }

    long long find_root(long long A)
    {
        if (root[A] < 0)
        {
            return A;
        }
        else
        {
            root[A] = find_root(root[A]);
        }
        return root[A];
    }

    long long size(long long A)
    {
        return -root[find_root(A)];
    }

    bool unite(long long A, long long B)
    {
        A = find_root(A);
        B = find_root(B);
        if (A == B)
        {
            return false;
        }

        if (size(A) < size(B))
        {
            swap(A, B);
        }

        root[A] += root[B];
        root[B] = A;

        return true;
    }
};

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

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

    UnionFind unionfind(N);
    long long ans[M + 1] = {};
    ans[M] = N * (N - 1) / 2;
    for (int i = M - 1; i > 0; i--)
    {
        ans[i] = ans[i + 1];
        if (unionfind.find_root(A[i]) != unionfind.find_root(B[i]))
        {
            ans[i] -= unionfind.size(A[i]) * unionfind.size(B[i]);
            unionfind.unite(A[i], B[i]);
        }
    }

    for (int i = 1; i <= M; i++)
    {
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 4480
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   

using namespace std;


int main() {

	string t;
	int f = 0;
	int l = 0;

	cin >> t;
	
	for (int i = 0; i < t.size(); i++) {
		if (t[i] == 'A') {
			f = i + 1;
			break;
		}
	}

	for (int i = t.size()-1; i > 0 ; i--) {
		if (t[i] == 'Z') {
			l = i + 1;
			break;
		}
	}

	cout << l - f + 1 << endl;
	return 0;
	
	
}

Measured memory_bytes: 640
main :: IO ()
main = do
  [a, b, c, x, y] <- map read . words <$> getLine :: IO [Int]
  let c' = 2 * c
  if a + b <= c'
    then print $ a * x + b * y
    else
      let d = if x > y then a else b
          z = abs $ x - y
      in print $ 2 * min x y * c + min d c' * z


Measured memory_bytes: 508
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
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;}

int main() {
    int y,m,d;
    char c1,c2;
    cin >> y >> c1 >> m >> c2 >> d;
    if(m<=4) cout << "Heisei" << endl;
    else cout << "TBD" << endl;

}

Measured memory_bytes: 3580
#include <stdio.h>
#define M 100

void trace(int A[], int N){
  int i;
  for(i = 0; i < N; i++){
     if(i > 0)printf(" ");
  printf("%d", A[i]);
}
  printf("\n");
}

void insertionSort(int A[] , int N){
  int i,j,v; 
  for(i = 1; i < N; i++){
  v = A[i];
  j = i-1;
  
  while(j >= 0 && A[j] > v){
    A[j+1] = A[j];
    j--;}
    A[j+1] = v;
    trace(A,N);
  }}

int main(){
  int N,i,j;
  int A[M];
  scanf("%d", &N);
   for(i = 0 ; i < N; i++)scanf("%d", &A[i]);

   trace(A, N);
   insertionSort(A, N);
   
  return 0;  
}



Measured memory_bytes: 2048
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int v[] = new int[s.length()];
		for(int i=0; i<s.length(); i++){
			v[i] = Integer.parseInt(s.substring(i,i+1));
		}
		int ans=0;
		for(int i=1; i<v.length; i++) {
			if(v[i] == v[i-1]) {
				v[i] = (v[i]+1)%2;
				ans++;
			}
		}
		System.out.println(ans);
		sc.close();
	}

}


Measured memory_bytes: 31684
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int N,K,a[100000];
int ans;
vector<int> G[100000];
int dfs(int v,int p,int dep){
	int mx=0;
	for(int u:G[v]) if(u!=p) chmax(mx,dfs(u,v,dep+1)+1);
	if(mx==K-1){
		if(dep>1) ans++;
		mx=-1;
	}
	return mx;
}
int main(){
	cin>>N>>K;
	rep(i,N){
		int a;
		cin>>a;
		a--;
		if(i==0&&a!=0) ans++;
		if(i>0) G[a].pb(i);
	}
	dfs(0,-1,0);
	cout<<ans<<endl;
}


Measured memory_bytes: 13568
n,l=map(int,input().split())
lis=[]

for i in range(n):
    lis.append(l+i)
som=0
for i in range(n):
    som+=lis[i]
a=abs(lis[0])
for i in range(n-1):
    if abs(lis[i+1])<abs(a):
        a=lis[i+1]

print(int(som-a))


Measured memory_bytes: 3060
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>

using namespace std;

int main()
{
	int N,K,X,Y,m;
	scanf("%d%d%d%d",&N,&K,&X,&Y);
	if(N <= K) m = X * N;
	else m = X * K + Y * (N - K);
	printf("%d\n",m);
	return 0;
}

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

void solve(long long N, vector<long long> A){
	long long g = 0;
  long long k = 0;
  for (long i = 0; i < A.size(); i++) {
    if (A[i] % 2 == 0) g++;
    else {
      k++;
      if (k >= 2) { g++; k -= 2; }
    }
  }
  g %= 2;
  if (g == 0 && k == 0) {
    cout << "YES" << endl;
    return;
  }

  if ((g == 1 && k == 0) || (g == 0 && k == 1)) {
    cout << "YES" << endl;
    return;
  }

  cout << "NO" << endl;
}

int main(){	
	long long N;
	scanf("%lld",&N);
	vector<long long> A(N-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&A[i]);
	}
	solve(N, A);
	return 0;
}



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

using ll = long long;

int main() {
    ll X, K, D;
    cin >> X >> K >> D;
    X = abs(X);

    ll t = min(K, X / D);
    K -= t;
    X -= t * D;

    if (K % 2 == 0) {
        cout << X << endl;
    }else {
        cout << D - X << endl;
    }
    return 0;
}

Measured memory_bytes: 3568
from collections import deque
n = int(input())
A = deque([])
for i in range(n):
    x = list(map(int, input().split()))
    if x[0] == 0:
        if x[1] == 0:
            A.appendleft(x[2])
        else:
            A.append(x[2])
    elif x[0] == 1:
        print(A[x[1]])
    elif x[0] == 2:
        if x[1] == 0:
            A.popleft()
        else:
            A.pop()


Measured memory_bytes: 21932
open System
let R T = stdin.ReadLine()|> T
let RS T = stdin.ReadLine().Split()|>Array.map T
let R2 T U = RS string|>fun c-> (c.[0]|>T),(c.[1]|>U)
let R3 T U V = RS string|>fun c-> (c.[0]|>T),(c.[1]|>U),(c.[2]|>V)
let R4 T U V W = RS string|>fun c-> (c.[0]|>T),(c.[1]|>U),(c.[2]|>V),(c.[3]|>W)
let R5 T U V W X = RS string|>fun c-> (c.[0]|>T),(c.[1]|>U),(c.[2]|>V),(c.[3]|>W),(c.[4]|>X)
let outl s = stdout.WriteLine(s|>string)
let outsep ls = stdout.WriteLine(String.concat " " (ls|>Array.map string))
let outsepl ls = stdout.WriteLine(String.concat "\n" (ls|>Array.map string))
let Mod = (1e9|>int64)+7L
[<EntryPoint>]
let main argv =
    let N=R int
    RS int
    |>Array.map(fun c-> if c%2=0 && c%3<>0 && c%5<>0 then 1 else 0)
    |>Array.sum
    |>fun c->if c>0 then "DENIED" else "APPROVED"
    |>outl
    0
    

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

typedef long long int ll;

using namespace std;

const ll MOD = 1e9 + 7;

ll sub(ll a, ll b)
{
    ll res = a - b;
    
    while (res < 0)
        res += MOD;
    
    return res;
}

ll mult(ll a, ll b)
{
    return (a * b) % MOD;
}

ll extendedGcd(ll n, ll m, ll& x, ll& y)
{
    if (m == 0)
    {
        x = 1;
        y = 0;
        return n;
    }
    
    ll tmpX, tmpY;
    ll gcd = extendedGcd(m, n % m, tmpX, tmpY);
    x = tmpY;
    y = tmpX - (n / m) * tmpY;
    return gcd;
}

ll inverse(ll n)
{
    ll x, y;
    extendedGcd(n, MOD, x, y);
    return x;
}

ll divi(ll a, ll b)
{
    a %= MOD;
    ll inv = inverse(b);
    ll res = mult(inv, a);
    while (res < 0)
        res += MOD;
    return res;
}

ll binomialCoefficient(ll n, ll k)
{
    if (n == k)
        return 1LL;
    
    ll res = 1LL;
    for (int i = 1; i <= k; ++i)
        res = mult(res, n + 1 - i);
    for (ll i = 2; i <= k; ++i)
        res = divi(res, (ll) i);
    return res;
}

ll exp(ll a, ll b)
{
    ll res = 1LL;
    
    a %= MOD;
    while (b > 0)
    {
        if (b & 1)
            res = (res * a) % MOD;
        
        b >>= 1;
        a = (a * a) % MOD;
    }
    
    return res;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll n, a, b;
    cin >> n >> a >> b;
    
    ll half = n / 2 + (n % 2 != 0);
    if (a > half)
        a = 2 * half - a - (n % 2 != 0);
    if (b > half)
        b = 2 * half - b - (n % 2 != 0);

    ll res = exp(2, n);    
    res = sub(res, binomialCoefficient(n, a));
    res = sub(res, binomialCoefficient(n, b));
    cout << sub(res, 1LL) << "\n";

    return 0;
}


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

using namespace std;

int main(){

	int n;

	scanf("%d", &n);

	int a = 1;

	while(a < n){
		a *= 10;
	}

	a /= 10;

	int b = n - a;

	int soma = 0;

	while(a){
		soma += a%10;
		a/= 10;
	}

	while(b){
		soma += b%10;
		b /= 10;
	}

	printf("%d\n",soma);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll h, w;
  cin >> h >> w;
  map<char, ll> mp;
  rep(i, h) rep(j, w) {
    char c;
    cin >> c;
    mp[c]++;
  }
  bool ans;
  if(h == 1 || w == 1) {
    ll cnt = 0;
    for(auto v : mp)
      if(v.second % 2) cnt++;
    if(cnt >= 2)
      ans = false;
    else if(h == 1)
      ans = cnt % 2 == w % 2;
    else
      ans = cnt % 2 == h % 2;
  } else {
    ll c = 0;
    if(h % 2) c += w;
    if(w % 2) c += h;
    bool odd = h % 2 && w % 2;
    if(odd) c -= 2;
    ll c2 = 0, c1 = 0;
    for(auto v : mp) {
      ll k = v.second;
      if(k % 4 == 0)
        continue;
      else if(k % 2 == 0)
        c2++;
      else
        c1++;
    }
    ans = true;
    if(c1 > odd || c2 * 2 > c) ans = false;
  }
  cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3564
#!/usr/bin/env ruby

MOD = (10 ** 9) + 7
nnn, kkk = gets.chomp.split.map(&:to_i)


$hoge = {}

def conbi(n, k)
  k=n-k if 2*k > n
  return 1 if k == 0
  return $hoge[[n,k]] if $hoge[[n,k]]
  $hoge[[n, k]] = ((n-k+1)..n).reduce(&:*)/((1..k).reduce(&:*))
end

kkk.times do |i|
  if (i+1) <= nnn-kkk+1
    puts ((conbi(kkk - 1, i)% MOD) * (conbi(nnn-kkk+1, i+1)%MOD))%MOD
  else
    puts 0
  end
end


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

// const long long MOD = 1000000007;
const ll MOD = 998244353;
const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

long long modpow(long long a, long long n, long long mod)
{
  long long res = 1;
  while (n > 0)
  {
    if (n & 1)
      res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<int> D(N), d(N);
  for (int i = 0; i < N; i++)
  {
    cin >> D[i];
    d[D[i]]++;
  }
  bool flag = false;
  for (int i = N - 1; i >= 1; i--)
  {
    if (D[i] != 0)
      flag = true;
    if (flag && D[i] == 0)
    {
      cerr << "a" << endl;
      cout << 0 << endl;
      return 0;
    }
  }
  ll ans = 1;
  if (d[0] != 1)
  {
    cerr << "b" << endl;
    cout << 0 << endl;
    return 0;
  }
  if (D[0] != 0)
  {
    cerr << "c" << endl;
    cout << 0 << endl;
    return 0;
  }
  for (int i = 1; i < N; i++)
  {
    ans *= modpow(d[i - 1], d[i], MOD);
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}


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

#define fr first
#define sc second
#define mk make_pair
#define pb push_back

using namespace std;

typedef long long ll;
const int N = 1e6 + 5;
const int inf = 1e9 + 7;

bool a[105];

bool check(int num) {
	bool f = false;
	while (num) {
		if (a[num % 10]) return false;
		num /= 10;
	}
	return true;
}

int main() {
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < k; i ++) {
		int d;
		cin >> d;
		a[d] = 1;
	}
	for (int i = n; ; i ++) {
		if (check(i)) {
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}






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

int main(){
  long long n, d, x, y;
  cin >> n >> d;
  int ans = 0;
  for(int i=0; i<n; ++i){
    cin >> x >> y;
    if(x*x + y*y <= d*d) ++ans;
  }
  cout << ans << endl;
}

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

int main() {

  string s;
  cin >> s;
  string ans;
  
  for(int i = 0; i < s.size(); i++){
    if(i%2 == 0){
      ans += s[i];
    }
  }
  
  cout << ans;

  return 0;
}




Measured memory_bytes: 512