akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, N) for (int i = 0; i < (N); ++i)

int main(){
  int a,b;
  cin>>a>>b;
  for(int i=-a+1;i<a;i++) cout<<b+i<<" ";
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
n=int(input())
a_list=list(map(int,input().split()))
if n%2==0:
    c=n//2
    x=n
    for i in range(c):
        print(a_list[x-1],end='')
        print(' ',end='')
        x-=2
    x=1
    for i in range(c):
        print(a_list[x-1],end='')
        print(' ',end='')
        x+=2
else:
    c=n//2
    x=n
    for i in range(c+1):
        print(a_list[x-1],end='')
        print(' ',end='')
        x-=2
    x=2
    for i in range(c):
        print(a_list[x-1],end='')
        print(' ',end='')
        x+=2


Measured memory_bytes: 96212
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0071
{
    public class Program

    {

        const int WIDTH = 8;
        const int SENTINEL = 3;
        static int[,] map;

        public static void Main(string[] args)
        {
            int n = RInt();
            for (int k = 0 ; k < n ; k++)
            {

                RSt();//空行の読み飛ばし

                map = new int[WIDTH + SENTINEL * 2, WIDTH + SENTINEL * 2];
                for (int i = SENTINEL ; i < WIDTH + SENTINEL ; i++)
                {
                    string line = RSt();
                    for (int j = SENTINEL ; j < WIDTH + SENTINEL ; j++)
                    {
                        map[i, j] = int.Parse(line[j - SENTINEL].ToString());
                    }
                }

                int x = RInt();
                int y = RInt();
                Explosion(x - 1 + SENTINEL, y - 1 + SENTINEL);

                Console.WriteLine("Data {0}:", k + 1);
                for (int i = SENTINEL ; i < WIDTH + SENTINEL ; i++)
                {
                    for (int j = SENTINEL ; j < WIDTH + SENTINEL ; j++)
                    {
                        Console.Write(map[i, j]);
                    }
                    Console.Write(Environment.NewLine);
                }
            }
        }

        private static void Explosion(int x, int y)
        {
            int[] dx = new int[] { -3, -2, -1, 1, 2, 3, 0, 0, 0, 0, 0, 0 };
            int[] dy = new int[] { 0, 0, 0, 0, 0, 0, -3, -2, -1, 1, 2, 3 };

            map[y, x] = 0;
            for (int i = 0 ; i < dx.Length ; i++)
            {
                if (map[y + dy[i], x + dx[i]] == 1) Explosion(x + dx[i], y + dy[i]);
            }
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}



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

using lli=long long;
int main(){
  int N;
  std::cin >> N;

  std::vector<lli> A_arr(N);
  for(int i = 0; i < N; i++) std::cin >> A_arr[i];

  lli rx = A_arr[0], l = 0;
  lli ans = 0;
  for(int i = 1; i < N; i++){
    while((rx^A_arr[i]) != (rx+A_arr[i])){
      rx ^= A_arr[l];
      ans += i-l;
      l++;
    }
    rx ^= A_arr[i];
  }
  while(l < N){
    ans += N-l;
    l++;
  }

  std::cout << ans << std::endl;

  return 0;
}



Measured memory_bytes: 1792
import java.util.*
 
fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val a = sc.nextInt()
    val b = sc.nextInt()
    var passed = 0
    var passedB = 0
    sc.next().map {
        if (passed < a + b && (it == 'a' || it == 'b' && passedB < b)) {
            println("Yes")
            passed++
            if (it == 'b') passedB++
        } else {
            println("No")
        }
    }
}

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

int main(){
    ll n;
    cin >> n;
    vector<ll> vec(n);
    ll ans=0;
    rep(i,n){
        cin >> vec[i];
    }
    ll now=30000000;
    rep(i,n){
        if(now>=vec[i]){
            ans++;
            now=vec[i];
        }
    }
    
    cout << ans << endl;
    

    return 0;
}






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

#define INFTY 1000000001

struct card{
	int w;
};

void swap(card &a, card &b){
	card x = a;
	a = b;
	b = x;
	return;
}

int partition(vector<card> &A, int p, int r){
	int x = A[r].w;
	int i = p - 1;
	for (int j = p; j < r; j++){
		if (A[j].w <= x){
			i++;
			swap(A[i], A[j]);
		}
	}
	swap(A[i + 1], A[r]);
	return i + 1;
}

void quicksort(vector<card> &A, int p, int r){
	if (p < r){
		int q = partition(A, p, r);
		quicksort(A, p, q - 1);
		quicksort(A, q + 1, r);
	}
	return;
}

int main(){

	int n;
	cin >> n;
	vector<card> A(n), A_old(n);
	for (int j = 0; j < n; j++){
		cin >> A[j].w;
		A_old[j] = A[j];
	}

	quicksort(A, 0, n - 1);

	vector<int> pair(n, 0);
	int curpair = 0;
	int cur;
	int min = A[0].w;
	for (int j = 0; j < n; j++){
		if (pair[j] == 0){
			curpair++;
			cur = j;
			while (true){
				for (int k = 0; k < n; k++){
					if (A[k].w == A_old[cur].w){
						cur = k;
						break;
					}
				}
				pair[cur] = curpair;
				if (cur == j) break;
			}
		}
		if (min > A[j].w) min = A[j].w;
	}

	bool isFirstCurpair;
	int firstcurpairw, curpairnum, curpairw;
	int cost = 0;
	for (int j = 1; j < curpair + 1; j++){
		isFirstCurpair = true;
		firstcurpairw = 0;
		curpairnum = 0;
		curpairw = 0;
		for (int k = 0; k < n; k++){
			if (pair[k] == j){
				if (isFirstCurpair){
					firstcurpairw = A[k].w;
					isFirstCurpair = false;
				}
				curpairw += A[k].w;
				curpairnum++;
			}
		}
		if (curpairnum >= 2){
			if (firstcurpairw + min * (curpairnum + 1) < (curpairnum - 2) * firstcurpairw){
				cost += curpairw + firstcurpairw + min * (curpairnum + 1);
			}
			else{
				cost += curpairw + (curpairnum - 2) * firstcurpairw;

			}
		}
	}

	cout << cost << endl;
		
	return 0;
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
#define rep(src,dst)    for(int i=src; i<dst;  i++)
#define rep2(src,dst)   for(int j=src; j<dst;  j++)
#define INF 1000000000000 //1e+12
#define MOD 10000007 //1e9+7
#define PI  acos(-1)
#define ll long long
template<typename T> inline void ChMin(T* a, T* b) {if(*a>*b) *a=*b;}
template<typename T> inline void ChMax(T* a, T* b) {if(*a<*b) *a=*b;}
template<typename T> inline int  DivUp(T a, T b)   {return ((a+b-1)/b);}

int main(){
    ll a, b; cin >> a >> b;
    cout << lcm(a,b) << endl;
}
/*

*/


Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <unordered_set>
#include <cmath>
#include <climits>
#include <cstdlib>
#define endl '\n'
#define ll long long
#define mod 1000000007
#define NCONS 100001
#define PLUS 0
#define MINUS 1

using namespace std;

int main(void)
{
	cin.tie(NULL); ios_base::sync_with_stdio(false);
	int a, b; cin >> a >> b;
	int ret = (a + b) / 2;
	if ((a + b) % 2 != 0) ret += 1;
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
p = [int(x) for x in input().split()]
moji = input()
x = [moji[i:i+1] for i in range(len(moji))]
n = p[0]
a = p[1]
b = p[2]
c = p[3]
d = p[4]
y = x[1:]
z = x[2:]

lista = []
for s,t,u in zip(x,y,range(len(y))):
	if s == '#' and t == '#':
		lista.append(u+1)
listb = []
for s,t,u,v in zip(x,y,z,range(len(z))):
	if s == '.' and t == '.' and u == '.':
		listb.append(v+1)

if any((a < elem and elem < c) or (b < elem and elem < d)  for elem in lista):
	print('No')
elif c < d:
	print('Yes')
elif any(b-1 <= elem and elem < d  for elem in listb):
	print('Yes')
else:
	print('No')

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()

using ll = long long;
using P = pair<int,int>;


int main()
{
    int n;
    cin >> n;
    vector<int> p(n), q(n), v(n);
    rep(i, n){
        cin >> p[i];
    }

    rep(i, n){
        cin >> q[i];
    }
    rep(i, n) v[i] = i + 1;

    int cnt = 0;
    int x, y;
    do
    {
        cnt++;
        if(v == p) x = cnt;
        if(v == q) y = cnt;
    } while (next_permutation(all(v)));
    
    cout << abs(x - y) << "\n";


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<bitset>
using namespace std;
#define M 1000000007
#define p pair<int, int >
const int N = 5e5 +10;


bool comp(p A, p B)
{
	if(A.first == B.first) return A.second > B.second;
	return A.first < B.first;
}

int main()
{
	int n, m;
	cin>>n>>m;
	vector<p> v;
	for(int i=0; i<n;i++)
	{
		int a, b;
		cin>>a>>b;
		v.push_back({a, b});
	}
	sort(v.begin(), v.end(), comp);
	unsigned long long int total = 0;
	int i = 0;
	while(m > 0)
	{
		unsigned long long int curA = v[i].first;
		unsigned long long int curB = v[i].second;
		if(curB <= m)
		{
			total += (curB*curA);
			m -= curB;
		}
		else
		{
			total += (m * curA);
			m = 0;
		}
		i++;
		
	}
	cout<<total<<endl;
	
	return 0;
}

Measured memory_bytes: 1400
n = int(input())
cif = [[0]*10 for i in range(10)]

for i in range(1, n+1):
    s = str(i)
    f = int(s[0])
    r = int(s[-1])
    cif[f][r] += 1
res = 0

for i in range(10):
    for j in range(10):
        res += cif[i][j]*cif[j][i]
print(res)

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

int main(){
  int a;
  cin >>a;
  
  if(a <105){
    cout << "0" << endl;
  }
  else if(a<135){
    cout <<"1"<<endl;
  }
  else if(a<165){
    cout <<"2"<<endl;
  }
else if(a<189){
  cout << "3" <<endl;
}
  else  if(a<195){
    cout <<"4" << endl;
  }
  else{
    cout <<"5"<<endl;
  }
}
    


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int i;
	int A[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	scanf("%d",&i);
	
	
	
	
	
	printf("%d",A[i-1]);
	
	return 0;
}

Measured memory_bytes: 128
class UnionFind:
    def __init__(self, n): # 初期化。1スタートで設計
        self.par = [i for i in range(n+1)] #親
        self.rank = [0]*(n+1) # 高さ

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

    # 全ての親の検索（一括での経路圧縮）
    def all_find(self):
        for n in range(len(self.par)):
            self.find(n)

n,m = map(int, input().split())
p = list(map(int, input().split()))
pab = [list(map(int, input().split())) for i in range(m)]

uf = UnionFind(n)
for x,y in pab:
    uf.union(x,y)

uf.all_find()

cnt = 0
for i,k in enumerate(p):
    if k == i+1: # そもそもカウントできる場所にいる場合
        cnt += 1
    else:
        if uf.same_check(i+1,k):
            cnt += 1
print(cnt)


Measured memory_bytes: 35628
#include<bits/stdc++.h>
#include<atcoder/all>

using namespace std;
using namespace atcoder;
using ll = long long;



int main()
{
	int n, m; cin >> n >> m;
	scc_graph scc(n);
	for(int i = 0; i < m; i++) {
		int a, b; cin >> a >> b;
		scc.add_edge(a, b);
	}
	auto v = scc.scc();
	cout << v.size() << endl;
	for(auto i : v) {
		cout << i.size() << " ";
		for(int j = 0; j < (int)i.size(); j++)cout << i[j] << (j == (int)i.size()-1 ? '\n' : ' ');
	}
}

Measured memory_bytes: 40088
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>

using namespace std;

int main() {

    int N;
    cin>>N;

    vector<int> A;
    vector<int> cof1;
    vector<int> cof2;
    long long int diff1=0;
    long long int diff2=0;

    A.resize(N);
    cof1.resize(N);
    cof2.resize(N);

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

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

    cof1[0] = -1;
    if(N%2==0)
        cof1[N-1] = 1;
    else
        cof1[N-1] = -1;

    for(int i=1; i<N-1; ++i)
    {
        if(i%2==0)
            cof1[i] = -2;
        else
            cof1[i] = 2;
    }

    std::sort(cof1.begin(), cof1.end());
    for(int i=0; i<N; ++i)
        diff1 += cof1[i] * A[i];

    cof2[0] = 1;
    if(N%2==0)
        cof2[N-1] = -1;
    else
        cof2[N-1] = 1;

    for(int i=1; i<N-1; ++i)
    {
        if(i%2==0)
            cof2[i] = 2;
        else
            cof2[i] = -2;
    }

    std::sort(cof2.begin(), cof2.end());
    for(int i=0; i<N; ++i)
        diff2 += cof2[i] * A[i];

    cout<<max(diff1, diff2)<<endl;

    return 0;
}

Measured memory_bytes: 1408
a[99],b[99];main(i,n){for(;scanf("%d",&n),n;){
    for(i=0;i<=n;i++)scanf("%d",a+i);
    for(i=1;i<=n;i++)b[i]=a[i]-a[i-1];
    if(b[1]==b[2]&&b[2]==b[3]&&b[3]==b[4]){
        for(i=5;i<=n;i++)if(b[i]!=b[1])break;
        printf("%d\n",a[i]);
    }
    else if(b[2]==b[3]&&b[3]==b[4])printf("%d\n",a[0]);
    else if(b[1]==b[2]&&b[2]==b[3])printf("%d\n",a[4]);
    else if(a[2]-a[0]==b[3]&&b[3]==b[4])printf("%d\n",a[1]);
    else if(b[1]==b[2]&&b[2]==a[4]-a[2])printf("%d\n",a[3]);
    else if(b[1]==a[3]-a[1]&&b[1]==b[4])printf("%d\n",a[2]);
    else exit(1);
}exit(0);}

Measured memory_bytes: 600
#include <iostream>

using namespace std;

int main() {
  int N;
  cin >> N;
  bool ok = true;
  int X;
  for (int i = 0; i < N; i++) {
    cin >> X;
    if (X % 2 == 0 && (X % 3 != 0 && X % 5 != 0)) {
      ok = false;
      break;
    }
  }
  cout << (ok ? "APPROVED" : "DENIED") << endl;
  return 0;
}



Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

    void solve(Scanner in, PrintWriter out) {
        int n = in.nextInt();
        int cpt = 0;
        for (int c = 1; c < n; ++c) {
            cpt += nbFactors(n - c);
        }
        out.println(cpt);
    }

    public static int nbFactors(int n) {
        int cpt = 0;
        for(int i = 1; i <= (int) Math.sqrt(n); i++)
        {
            if(n % i == 0 && i * i != n)
            {
                cpt += 2;
            }
            else if (i * i == n)
            {
                cpt++;
            }
        }
        return cpt;
    }

    public static void main(String[] args) {
        try(Scanner in = new Scanner(System.in);
            PrintWriter out = new PrintWriter(System.out)) {
            new Main().solve(in, out);
        }
    }
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N;
    cin >> N;
    int X[N];

    rep(i, N){cin >> X[i];}
    ll ans = INF;
    rep2(x, 1, 101){
        ll tmp = 0;
        rep(j, N){
            tmp = tmp + ((X[j] - x) * (X[j] - x));
        }
        if (ans > tmp){ans = tmp;}
    }
    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {

  int N;
  do {
    scanf("%d", &N);
  } while (N < 1 || N > 20);

  int V[N], C[N];
  for (int i = 0; i < N; i++) {
    do {
      scanf("%d", &V[i]);
    } while (V[i] < 1 || V[i] > 50);
  }
  for (int i = 0; i < N; i++) {
    do {
      scanf("%d", &C[i]);
    } while (C[i] < 1 || C[i] > 50);
  }

  int vc_difference[N];
  int xy_difference = 0;
  for (int i = 0; i < N; i++) {
    vc_difference[i] = V[i] - C[i];
    if (vc_difference[i] > 0) {
      xy_difference += vc_difference[i];
    }
  }

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

  return 0;
}

Measured memory_bytes: 128
N = list(map(int, input().split(' ')))

W = N[0]
H = N[1]
x = N[2]
y = N[3]
r = N[4]

if r <= x < W and (x + r) <= W and r <= y < W and (y + r) <= H:
	print('Yes')
else:
	print('No')

Measured memory_bytes: 7688
count = int(input())
numList = list(map(int, input().split()))
numList.insert(0, numList[0])

dp = [0] * (count + 1)

for i in range(1, count + 1):
    val1 = abs(numList[i] - numList[i - 1])
    val2 = abs(numList[i] - numList[i - 2]) if i > 1 else val1

    dp[i] = min(dp[i -1] + val1, dp[i - 2] + val2)

print(dp[count])


Measured memory_bytes: 13928
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    int m1, d1, m2, d2;
    cin >> m1 >> d1 >> m2 >> d2;

    if(m1 != m2)
        cout << 1 << endl;
    else
        cout << 0 << endl;

    return 0;
}


Measured memory_bytes: 256
q?d=(q`div`d)*d;u=getLine;main=u>>fmap(map read.words)u>>=putStrLn.maybe"-1"h.foldr(\s->(>>=i s))(Just(2,2));h(a,b)=show a++" "++show b;i d(a,b)=if-l>u then Nothing else Just(-l,u+d-1)where l=(-a)?d;u=b?d

Measured memory_bytes: 61820
#include <stdio.h>

int main(void)
{
  int one = 0, two = 0, three = 0, height, i;

  for (i = 0; i < 10; i++) {
    scanf("%d", &height);
    if (height > one) {
      three = two;
      two = one;
      one = height;
    } else if (height > two) {
      three = two;
      two = height;
    } else if (height > three)
      three = height;
  }

  printf("%d\n", one);
  printf("%d\n", two);
  printf("%d\n", three);

  return 0;
}

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

int main() {
    int a, b;
    cin >> a >> b;
    if(a < b){
        rep(i, b){
            cout << a;
        }
    }
    else if(a > b){
        rep(i, a){
            cout << b;
        }
    }
    else if(a == b){
        rep(i, a){
            cout << b;
        }
    }
}

Measured memory_bytes: 256
Scanf.scanf "%d %d %d" (fun a b k ->
    let rec loop i l =
        if i = 0 then l else
            let l = if a mod i = 0 && b mod i = 0 then i :: l else l in
            loop (i - 1) l
    in
    let l = loop (max a b) [] in
    Printf.printf "%d\n" (Array.of_list (List.rev l)).(k - 1)
)

Measured memory_bytes: 3816
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=1e18;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll n,m,a,dp[100005]={};
  cin >> n >> m;
  map<int,int> mp;
  for(int i=0; i<m; i++) {
    cin >> a;
    mp[a]++;
  }
  dp[0]=1;
  for(int i=1; i<=n; i++) {
    if(!mp[i-1]) {
      dp[i]+=dp[i-1];
      dp[i]%=MOD;
    }
    if(i!=1&&!mp[i-2]) {
      dp[i]+=dp[i-2];
      dp[i]%=MOD;
    }
  }
  cout << dp[n] << endl;
}

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

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)

typedef long long ll;
using namespace std;
 
int main (){
  double w,a,b;
  cin >> w >> a >> b;

  double c = a+w;
  double d = b+w;

  if(c < b){
    printf ("%.f\n", b-c);
  }
  else if(d < a){
    printf ("%.f\n", a-d);
  }
  else printf("0\n");
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 300 + 5
#define M 90000 + 5
#define Mod 998244353
#define rep(i, l, r) for(int i = l; i <= r; ++i)
int n, ans, a[N], sum[N], dp[N][M];
int read(){
    char c; int x = 0, f = 1;
    c = getchar();
    while(c > '9' || c < '0'){ if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
int Inc(int a, int b){ return (a += b) >= Mod ? a - Mod : a;}
int Dec(int a, int b){ return (a -= b) < 0 ? a + Mod : a;}
int Mul(int a, int b){ return 1ll * a * b % Mod;}
int Qpow(int a, int b){
    int ans = 1;
    while(b){
        if(b & 1) ans = Mul(ans, a);
        a = Mul(a, a), b >>= 1;
    }
    return ans;
}
int main(){
    n = read();
    rep(i, 1, n) a[i] = read(), sum[i] = sum[i - 1] + a[i];
    ans = Qpow(3, n);
    dp[0][0] = 1;
    rep(i, 1, n) rep(j, 0, sum[i]){
        dp[i][j] = Inc(dp[i][j], Mul(dp[i - 1][j], 2));
        if(j >= a[i]) dp[i][j] = Inc(dp[i][j], dp[i - 1][j - a[i]]);
    }
    if(sum[n] & 1){
    	rep(i, (sum[n] + 1) / 2, sum[n]) ans = Dec(ans, Mul(dp[n][i], 3));
    	printf("%d", ans);
    }
    else{
    	rep(i, sum[n] / 2, sum[n]) ans = Dec(ans, Mul(dp[n][i], 3));
    	memset(dp, 0, sizeof(dp));
    	dp[0][0] = 1;
    	rep(i, 1, n) rep(j, 0, sum[i]){
        	dp[i][j] = Inc(dp[i][j], dp[i - 1][j]);
        	if(j >= a[i]) dp[i][j] = Inc(dp[i][j], dp[i - 1][j - a[i]]);
    	}
    	ans = Inc(ans, Mul(dp[n][sum[n] / 2], 3));
    	printf("%d", ans);
    }
    return 0;
}

Measured memory_bytes: 107520
//header{{{
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/math/common_factor_rt.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
  
using namespace std;
//using namespace boost;
//using namespace multiprecision;  

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

template <class A, class B> inline int Max(const A &a, const B &b){ return (a < b ? b : a); }
template <class A, class B> inline int Min(const A &a, const B &b){ return (a > b ? b : a); }

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


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

    int x, y;
    cin >> x >> y;

    for(int i = 0; i <= x; ++i){
        if(i * 2 + (x-i) * 4 == y){
            cout << "Yes\n";
            return 0;
        }
    }

    cout << "No\n";

    return (0);
}


Measured memory_bytes: 3652
N, K = map(int, input().split())

ans = 0

i = K + 1

if K == 0:
    ans = N * N
else:
    while i <= N:
        div = N // i
        ans += max(N % i - K + 1, 0)
        ans += div * (i - K)
        i += 1


print(ans)



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

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

#define F 						first
#define PB 						push_back
#define MP 						make_pair
#define f(i,a,b) 				for(ll i=a; i<b; i++)
#define rep(i,n) 				f(i,0,n)
#define w(t)					ll t; cin>>t; while(t--)
#define epsilon					1e-9

constexpr ll int_pow(ll b, ll e) {
    return (e == 0) ? 1 : b * int_pow(b, e - 1);
}

void doublade() {
	ios::sync_with_stdio(false); cin.tie(0); cout.precision(10);
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
}

int main()
{
	doublade();
	// w(t) {
		ll n;
		cin >> n;		
		ll temp = ceil((float)n/1000);
		ll ans = temp*1000 - n;
		cout<<ans<<"\n";
	// }
	return 0;
}

Measured memory_bytes: 3552
str = gets.chomp
if str == "SUN"
  puts 7
elsif str == "MON"
  puts 6
elsif str == "TUE"
  puts 5
elsif str == "WED"
  puts 4
elsif str == "THU"
  puts 3
elsif str == "FRI"
  puts 2
else 
  puts 1
end


Measured memory_bytes: 1788
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
ll a,b;
int main(){
	cin >> a >> b;

	cout << (a + b) % 24 << endl;
	return 0;
}


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

using namespace std;

// MACROS

#define ll long long
#define ull unsigned long long
#define ld long double

#define vi vector<int>
#define vll vector<ll>
#define vld vector<ld>
#define u_s unordered_set

#define pii pair<int,int>
#define pll pair<ll,ll>

#define FOR(i, n) for (ll (i) = 0; i < n; i++)
#define FORN(i, a, b) for (ll (i) = a; i < b; i++)
#define FORE(i, l) for (auto (i) : l)

#define pb push_back
#define pob pop_back
#define emp emplace
#define fi first
#define se second

#define all(n) (n).begin(), (n).end()
#define in(n) cin >> (n);
#define debug(n) cout << #n << ": " << n << '\n';

// FUNCTIONS

template< typename T >
inline T gcd(T a, T b) { if (b) return gcd(b, a % b); return a; }

template< typename T >
inline T ext_gcd(T a, T b, T & x, T & y) { if (a == 0) { x = 0; y = 1; return b; } T x1, y1; T g = ext_gcd(b % a, a, x1, y1); x = y1 - (b / a) * x1; y = x1; return g; }

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);	
    //cout << setprecision(15);
    ll n, a, b;
    cin >> n >> a >> b;
    ll x = a + b;
    ll y = n / x;
    ll z = n % x;
    cout << (y * a + min(a, z)) << '\n';
}



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

using namespace std;
using ll = long long;

#pragma region Macros
#define FOR(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) FOR(i, 0, n)

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

template <class T> string join(const T &v, const string delim = ",")
{
    if (v.empty())
        return "";

    ostringstream res;
    res << v[0];
    for (int i = 1; i < v.size(); i++)
    {
        res << delim << v[i];
    }
    return res.str();
}

#pragma endregion Macros

vector<int> c(26);
vector<vector<int>> s;

ll score(vector<int> a, int dd){
    vector<int> last(26);
    ll res = 0;

    rep(d,dd){
        res += s.at(d).at(a.at(d));

        last.at(a.at(d)) = d + 1;
        rep(j,26){
            res -= (c.at(j) * (d + 1 - last.at(j)));
        }
    }
    return res;
}

int main()
{
    auto start = chrono::system_clock::now();

    int D;
    cin >> D;

    c = vector<int>(26);
    rep(i,26){
        cin >> c.at(i);
    }

    s = vector<vector<int>>(D, vector<int>(26));
    rep(i,D){
        rep(j,26){
            cin >> s.at(i).at(j);
        }
    }

    vector<int> ans(D);


    rep(d,D){
        ll max = score(ans, d + 1);

        rep(i,26){
            int t = ans.at(d);
            ans.at(d) = i;
        
            if(!chmax(max, score(ans, d+1))){
                ans.at(d) = t;
            }
        }
    }

    random_device rnd;
    mt19937 mt(rnd());
    uniform_int_distribution<> randD(0, D-1);
    uniform_int_distribution<> rand26(0, 25);

    ll max = score(ans, D);

    while(true){
        auto end = chrono::system_clock::now();
        if (chrono::duration_cast<chrono::milliseconds>(end - start).count() > 1900) break;

        int d = randD(mt);
        int i = rand26(mt);

        int t = ans.at(d);
        if (t == i) continue;
        ans.at(d) = i;

        if(!chmax(max, score(ans,D))){
            ans.at(d) = t;
        }
    }

    rep(i,D){
        cout << ans.at(i) + 1 << endl;
    }
}


Measured memory_bytes: 3712
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cassert>
#include <complex>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <sstream>
#include <ctime>
#include <cctype>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <deque>
#include <stack>
#include <memory.h>
using namespace std;
typedef long long ll;
#define mp make_pair
const ll INF=1e9+7;
ll ans;
ll n;
ll dat[100005];
ll tmp[100005];
ll pre[100005];
void merge(ll a[],ll l,ll r){
	if(l==r){
		return;
	}
	ll mid=(l+r)/2;
	merge(a,l,mid);
	merge(a,mid+1,r);
	ll x=l;
	ll y=mid+1;
	ll id=l;
	while(x<=mid && y<=r){
		if(a[x]>a[y]){
			tmp[id++]=a[y];
			ans+=mid-x+1;
			y++;
		}
		else{
			tmp[id++]=a[x];
			x++;
		}
	}
	while(x<=mid){
		tmp[id++]=a[x++];
	}
	while(y<=r){
		tmp[id++]=a[y++];
	}
	for(ll i=l;i<=r;i++){
		a[i]=tmp[i];
	}
}
bool check(ll mid){
	ans=0;
	for(ll i=1;i<=n;i++){
		if(dat[i]<mid){
			pre[i]=pre[i-1]-1;
		}
		else{
			pre[i]=pre[i-1]+1;
		}
		if(pre[i]<0){
			ans++;
		}
	}
	merge(pre,1,n);
	return (n*(n+1))/2>=2*ans;
}
int main(){
	cin>>n;
	for(ll i=1;i<=n;i++){
		cin>>dat[i];
	}
	ll l=1;
	ll r=INF;
	while(l+1<r){
		ll mid=(l+r)/2;
		if(check(mid)){
			l=mid;
		}
		else{
			r=mid;
		}
	}
	if(check(l+1)){
		l++;
	}
	cout<<l<<endl;
	return 0;
}

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

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

// chmax, chmin
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;
}

void solve(std::string S) {
  for( auto &c : S){
    if( c == '/') c = ' ';
  }
  stringstream ss(S);
  int y,m,d;
  ss >> y >> m >> d;
  if( m >= 5 ){
    cout << "TBD" << endl;
  }else{
    cout << "Heisei" << endl;
  }
}

int main() {
  std::string S;
  std::cin >> S;
  solve(S);
  return 0;
}


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

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

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

const llong inf = 1100100100100100ll;
const llong mod = 1e9+7;

int main(){
	llong N;
	string S;

	cin >> N >> S;
	vector<vector<llong> > dp(2, vector<llong>(N,0));
	// . : 0白, # : 1黒
	dp[0][0] = S[0] == '#';
	dp[1][0] = S[0] == '.';
	for (int i = 1; i < N; i++) {
		if (S[i] == '.') {
			dp[0][i] = dp[0][i-1];
			dp[1][i] = min(dp[0][i-1], dp[1][i-1]) + 1;
		} else {
			dp[0][i] = dp[0][i-1] + 1;
			dp[1][i] = min(dp[0][i-1], dp[1][i-1]);
		}
	}

	cout << min(dp[0][N-1], dp[1][N-1]) << endl;

	return 0;
}

Measured memory_bytes: 5252
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect, fractions
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = count = 0

def counting(A):
    memo=[0]*2501
    memo[0]=1
    n=len(A)
    for ai in A:
        for i in range(2500,0,-1):
            if i-ai<0:continue
            memo[i]+=memo[i-ai]
    return memo


    

n,X=map(int,input().split())
A,B=[],[]
lis=list(map(int,input().split()))
for li in lis:
    li-=X
    if li<0:
        B.append(-li)
    elif li==0:
        count+=1
    else:
        A.append(li)
count=2**count
A.sort();B.sort()
A=counting(A)
B=counting(B)
for i in range(1,len(A)):
    ans+=A[i]*B[i]*count
ans+=count-1

print(ans)

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

using namespace std;

using ll = long long;

int main() {
  const int sqrtN = 512;
  int n, q;
  cin >> n >> q;
  int bucket_sz = (n+sqrtN-1)/sqrtN;
  vector<ll> a(n, 0);
  vector<ll> bucketSum(bucket_sz, 0);
  auto update = [&](int k, int x) {
    a[k] += x;
    k /= sqrtN;
    int l = k*sqrtN, r = (k+1)*sqrtN;
    ll sum = 0;
    for(int i = l; i < r; ++i) sum += a[i];
    bucketSum[k] = sum;
  };
  auto query = [&](int s, int t)->ll{
    ll res = 0;
    for(int i = 0; i < bucket_sz; ++i) {
      int l = i*sqrtN, r = (i+1)*sqrtN;
      if(r <= s || t <= l) continue;
      if(s <= l && r <= t) res += bucketSum[i];
      else {
	for(int j = max(s, l); j < min(t, r); ++j) {
	  res += a[j];
	}
      }
    }
    return res;
  };
  while(q--) {
    ll t, x, y;
    cin >> t >> x >> y;
    if(t == 0) update(x-1, y);
    else cout << query(x-1, y) << endl;
  }

  return 0;
}



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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

string s;
int n, m;

void solve() {
  cin >> n >> m;
  cin >> s;
  vector<int> ans;
  for (int i = n; i > 0;) {
    int cur = 0, j = min(m, i);
    for (; j >= 0; --j) {
      if (s[i-j] == '1') continue;
      cur = j;
      break;
    }
    if (cur == 0) {
      cout << -1;
      return;
    }
    i -= j;
    ans.push_back(cur);
  }
  for (int i = (int)ans.size()-1; i >= 0; --i)
    cout << ans[i] << ' ';
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 4072
function Main(input){
  let data = input.split('\n');
  let arr, row, col;
  for (let i = 0; i < data.length; i++){
    arr = data[i].split(' ');
    row = arr[0];
    col = arr[1];
    if (row === '0' && col === '0'){
      break;
    }
    let s ='';
    for (let j = 0; j < col; j++){
      s += "#";
    }
    for (let k = 0; k < row; k++){
      console.log(s);
    }
    console.log('');
    }
  }

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 17668
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int MAX = -101;
  int MIN = 101;
  for(int i = 0;i< a;i++){
    int e;
    cin >> e;
    MAX = max(e,MAX);
  }
  for(int i = 0;i< b;i++){
    int f;
    cin >> f;
    MIN = min(f,MIN);
  }
  int key = 0;
  for(int i = -100;i<101;i++){
    if( c < i && i <= d && MAX < i && i <= MIN){
      cout << "No War" << endl;
      key = 1;
      break;
    }
  }
  if(key == 0)
    cout << "War" << endl;
}
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
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; }
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
    string s; cin>>s;
    int ans=0;
    rep(i,0,4){
        if(s[i]=='+') ans++;
        else ans--;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
// 　　＿＿
// 　／　<＠ﾌ
//  ｜(ﾉﾉハ))
//  ﾉ从ﾟヮﾟ从
// 　ﾉ｜ｿﾉГ|つ author:hotarunx
// 〈_ﾉ^^^ヽ|
// 　~~tｧtｧ~
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

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

    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];

    deque<int> dq;
    bool is_reversed = false;

    for (auto &&i : a) {
        if (!is_reversed) {
            dq.emplace_back(i);
        } else {
            dq.emplace_front(i);
        }
        is_reversed = !is_reversed;
    }

    vector<int> ans;
    for (auto &&i : dq) {
        ans.emplace_back(i);
    }

    if (is_reversed) reverse(ans.begin(), ans.end());

    for (auto i = ans.begin(); i != prev(ans.end()); i++) {
        cout << *i << " ";
    }
    cout << *prev(ans.end()) << endl;
}


Measured memory_bytes: 8508
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces



n = ni()
m0 = -inf
s0 = inf
m1 = -inf
s1 = inf
for i in range(n):
    xi, yi = na()
    diff = xi - yi
    summ = xi + yi
    m0 = max(diff, m0)
    s0 = min(diff, s0)
    m1 = max(summ, m1)
    s1 = min(summ, s1)

print(max(m0-s0, m1-s1))




Measured memory_bytes: 10784
#include <iostream>

using namespace std;

int main() {

  int n, x, t;
  long long ans = 0;
  char ch;
  while(cin >> ch){
    ans += ch - '0';
  }
  if(ans % 9 == 0){
    cout << "Yes";
  }else{
    cout << "No";
  }
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
int a[125252];

int main(){
  scanf("%d",&n);
  REP(i,n)scanf("%d",a+i);
  int turn = 0;
  while(true){
    int c1 = 0;
    int even = 0, odd = 0, oddid = 0;
    REP(i,n){
      if(a[i]==1)c1++;
      if(a[i]%2==0)even++;
      else{
        odd++;
        oddid = i;
      }
    }
    if(c1==n)break;
    if(even%2==1){
      turn ^= 1;
      break;
    }
    if(odd>=2 || c1>=1)break;
    a[oddid]--;
    int gd = 0;
    REP(i,n)gd=__gcd(gd,a[i]);
    REP(i,n)a[i]/=gd;
    turn ^= 1;
  }
  puts(turn==1?"First":"Second");
  return 0;
}


Measured memory_bytes: 768
#include <stdio.h>

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

	scanf("%d%d%d", &a, &b, &c);
	printf((a == b && a != c) || (a == c && a != b) || (b == c && b != a) ? "Yes\n" : "No\n");
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

int main() {
	string a, b;
	cin >> a >> b;
	if (a.size() > b.size()) {
		cout << "GREATER" << endl;
		return 0;
	}
	else if (a.size() < b.size()) {
		cout << "LESS" << endl;
		return 0;
	}
	else {
		for (int i = 0; i < a.size(); i++) {
			if (a[i] > b[i]) {
				cout << "GREATER" << endl;
				return 0;
			}
			else if (a[i] < b[i]) {
				cout << "LESS" << endl;
				return 0;
			}
		}
	}
	cout << "EQUAL" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
using namespace std ;

typedef long long ll ;
#define rep (i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int N;
	
	cin >> N;

	ll a[N];

	int count = 0;

	
	for (int i = 0; i < N; i++)
	{
		cin >> a[i];
		/*
		if (i != 0)
		{
			if ( (a[i] ^ a[i-1]) == (a[i] + a[i-1]))
			{
				count++;
			}
		}
		*/
	}

	for (int i = 0; i < N;i++)
	{
		ll value = a[i];
		int j = i + 1;
		//cout << j << endl;
		for (; j < N; j++)
		{
			if ( (value & a[j]) == 0 )
			{
				value |= a[j];
			}
			else
			{
				break;
			}
		}

		/*
		if (j < N)
		{
			count += sum_(j-i-1);
			i = j;
		}
		else
		{
			i = j;
			count++;
		}
		*/
		//count += sum_(j-i-1);
		count += j - i;
		//i = j;
		
	}

	cout << count << endl;
	return 0;
}
#endif

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

	int N;
	
	cin >> N;

	ll a[N];

	ll count = 0;

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

	// しゃくとり法(尺取り法)
	ll now = 0, pre_now = 0;
	int left = 0;
	int back_idx = 0;

	for (int i = 0; i < N; i++)
	{
		if ( i != 0)
		{
			now = pre_now - a[i - 1];
			count += left - i + 1;
		}
		else
		{
			now = a[i];
			count++;
		}
		
		for (int j = left + 1; j < N;j++)
		{
			if ( (now ^ a[j]) == (now + a[j]) )
			{
				count++;
				now ^= a[j];
			}
			else
			{
				break;
			}
			back_idx = j;
		}

		left = back_idx;
		pre_now = now;
	}
	
	cout << count << endl;

	return 0;
}

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

typedef long long ll;
double f(int x){
        return (x-1)*0.5+1;
}

int main(){
        int n,k;
        cin>>n>>k;
        vector<int>p(n);
        for(int i=0;i<n;i++){
                cin>>p[i];
        }
        double ans=0;
        double sum=0;
        for(int i=0;i<k;i++){
                sum+=f(p[i]);
                ans=sum;
        }
        for(int j=k;j<n;j++){
                sum-=f(p[j-k]);
                sum+=f(p[j]);
                ans=max(sum,ans);
        }
        printf("%.15lf\n",ans);
        return 0;
}


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

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define FORD(i, a, b) for(int i = (a); i >= (b); i--)
#define A first
#define B second
#define MOD 1000000007

typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef long long ll;

int mulmd(ll a, ll b){
    ll ret = (a * b) % MOD;
    return (int)ret;
}

inline int power(ll x, ll y, int p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = mulmd(res, x);
        y = y >> 1;
        x = mulmd(x, x);
    }
    return (int)res;
}

int submd(ll a, ll b){
    ll ret = a - b;
    if(ret < 0){
        ret += MOD;
    }
    return (int)ret;
}

int addmd(ll a, ll b){
    ll ret = (a + b) % MOD;
    return (int)ret;
}

int invPow(ll a){
    return power(a, MOD - 2, MOD);
}

const int N = 1e5 + 5;

int arr[N];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a, b, c;
    cin >> a >> b >> c;
    if(a + b + c >= 22) cout << "bust";
    else cout << "win";

}

/**
    Check out for boundary cases, (n = 1 or n = 0)
    check for integer overflow

**/


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<queue>
#include<stack>
#include<vector>
#include<algorithm>

using namespace std;
#define ll          long long
#define endl        "\n"
#define inf         10000000002
#define pb          push_back
#define pf          push_front
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(a)      a.begin(),a.end()
#define mp          make_pair
#define MAX         100
#define yes         cout<<"YES"<<endl
#define no          cout<<"NO"<<endl
#define bye         return 0

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

int main()
{
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      cout.tie(NULL);
      //freopen("inputNew.txt", "r", stdin);

      int a,b,c;
      cin>>a>>b>>c;

      int cnt=0;
      for(int i=c; i<=b; i+=c){
            if(i>=a && i<=b) cnt++;
      }
      cout<<cnt<<endl;

      bye;
}


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

typedef long long ll;
typedef pair<int, int> pi;
#define F first
#define S second
#define PB push_back

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

const int MOD = 1000000007;

// int max = *std::max_element(vec.begin(), vec.end());
// int sum = accumulate(list, list + size, 0);

int main()
{
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end(), greater<int>());

    int res = 0;
    rep(i, n) {
        if (i % 2 == 0) {
            res += a[i];
        } else {
            res -= a[i];
        }
    }
    cout << res << endl;
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 200010,md = (int)1e9 + 7;
int n, c[N], cnt[N];
long long sum[N], f[N];
vector<int> tmp;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> c[i];
  tmp.push_back(0);
  for (int i = 1; i <= n; ++i)
    if (c[i] != c[i - 1])
      tmp.push_back(c[i]);
  f[0] = 1;
  for (int i = 1; i < tmp.size(); ++i) {
    f[i] += f[i - 1];
    f[i] %= md; 
    f[i] += sum[tmp[i]];
    f[i] %= md;
    sum[tmp[i]] += f[i - 1];
    sum[tmp[i]] %= md;
  }
  cout << f[tmp.size() - 1];
  return 0;
}

Measured memory_bytes: 5876
#include<bits/stdc++.h>
using namespace std;
int main()
{

    long int a,b,c;
    cin>>a>>b;
    c=(a/((2*b)+1));
      if(a%((2*b+1))==0)
      {

          cout<<c;

      }
      else{
        cout<<c+1;
      }
}













Measured memory_bytes: 256
N = input()
parents = list(map(int,input().split(' ')))

res = []
count = 0
for i in range(int(N)):
    res.append(i+1)
for i,j in zip(res,parents):
    if not i==j:
        count += 1
if count > 2:
    print("NO")
else:
    print("YES")

Measured memory_bytes: 3060
N = int(input())
lst = [list(input().split()) for row in range(N)]

btc_to_jpy = 380000.0
total_value = 0
i = 0
while i < N:
	value = float(lst[i][0])
	if lst[i][1] == 'JPY':
		total_value += value
	else:
		total_value += value * btc_to_jpy
	i = i + 1
print(total_value)


Measured memory_bytes: 3060