akhauriyash/Code-Regression huggingface dataset:
N = int(input())
a = list(map(int, input().split()))

if N % 2 == 0:
    k = N // 2
    x = [0] * k + a[k:]
    start = k
else:
    k = (N + 1) // 2
    x = [0] * (k - 1) + a[k - 1:]
    start = k - 1

for i in range(start, 0, -1):
    x[i - 1] = (sum(x[2 * i - 1::i]) + a[i - 1]) % 2

M = 0
b = []
for i in range(N):
    if x[i] == 1:
        M += 1
        b.append(str(i + 1))
print(M)
print(' '.join(b))


Measured memory_bytes: 73692
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n = I()
    a = LI()
    b = LI()
    ans = 0

    for i in range(n):
        tem = a[i]
        a[i] = max(0,a[i]-b[i])
        attack = tem-a[i]
        b[i] -= attack
        ans += attack

        tem = a[i+1]
        a[i+1] = max(0,a[i+1]-b[i])
        attack = tem-a[i+1]
        ans += attack
    
    print(ans)


main()


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

class mylist {
	list<int> m_data;
	list<int>::iterator m_cur;

public:
	mylist():
		m_data(),
		m_cur( m_data.end() )
	{}

	void insert( int x ) {
		m_cur = m_data.insert( m_cur, x );
	}

	void move( int d ) {
		advance( m_cur, d );
	}

	void erase() {
		m_cur = m_data.erase( m_cur );
	}

	void print() const {
		for( auto v: m_data ) {
			cout << v << '\n';
		}
	}
};

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

	int q;
	cin >> q;

	mylist ml;
	for( int i = 0; i < q; ++i ) {
		int cmd, xd;
		cin >> cmd;

		if( cmd == 0 ) {
			cin >> xd;
			ml.insert( xd );
		}
		else if( cmd == 1 ) {
			cin >> xd;
			ml.move( xd );
		}
		else if( cmd == 2 ) {
			ml.erase();
		}
	}

	ml.print();
}



Measured memory_bytes: 18636
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;

//#define int long long
//using ll = boost::multiprecision::cpp_int;
using ll = long long;
//constexpr int INF = 1e9;//INT_MAX=(1<<31)-1=2147483647
constexpr ll INF = (ll)1e18;//(1LL<<63)-1=9223372036854775807
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-9;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var) std::cout<<var<<std::endl
#define rep(i, n)   for(ll i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(ll i=1, i##_length=(n); i<=i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define PI (acos(-1))
template<typename T> inline T power(T x, T n){ return n ? power(x*x%MOD,n/2)*(n%2?x:1)%MOD : 1; }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/

constexpr ll N_MAX = 200000;
constexpr ll A_I_MAX = 200000;

ll N;
vector<ll> a,b;

void input() {
	ll t;
	scanf("%lld", &N);
	a.assign(N,0);b.assign(N,0);
	rep(i, N) {cin>>t;a[i]=t;b[i]=t;};
	sort(all(a),greater<ll>());
}

void solve() {
	rep(i,N){
		if(b[i]==a[0]){
			p(a[1]);
		}else {
			p(a[0]);
		}


	}
}


signed main() {
	input();
	solve();
	return 0;
}


Measured memory_bytes: 4736
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n=scan.nextInt();
		int b=scan.nextInt();
		if(n*b%2==1) System.out.println("Yes");
		else System.out.println("No");

	}

}


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

int n;
ll ans = -1;

void dfs(int i, ll leaf, vector<ll> &node, vector<int> &a) {
    if(i == n-1) {
        if(node.at(i) != a.at(i)) return;
        ll tot = 0;
        rep(i, n) {
            tot += node.at(i);
        }
        ans = max(ans, tot);
        return;
    }

    ll root = node.at(i) - a.at(i);
    leaf -= a.at(i);
    if(root <= 0) return;
    node.at(i+1) = min(root * 2, leaf);
    dfs(i+1, leaf, node, a);
}

int main() {
    cin >> n;
    n++;
    vector<int> a(n);
    ll leaf = 0;
    rep(i, n) {
        cin >> a.at(i);
        leaf += a.at(i);
    }

    vector<ll> node(n);
    node.at(0) = 1;
    dfs(0, leaf, node, a);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4580
#include<stdio.h>
#include<ctype.h>

int main(void){
	
	char a;
		
	while(1){
		scanf("%c",&a);
	
		if(a=='\n'){
			printf("\n");
			break;
		}
		if(islower(a)){
			a=toupper(a);
		}else{
			a=tolower(a);
		}
		printf("%c",a);
	}
	return 0;
}

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

int main(){
  string s;
  cin >> s;
  int ans = 0;
  int cnt = 0;
  for(int i = 0; i < s.size(); i++){
    if(s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C') cnt++;
    else{
      ans = max(cnt,ans);
      cnt = 0;
    }
  }
  ans = max(ans,cnt);
  cout << ans << endl;
}

Measured memory_bytes: 3612
{
echo APPROVED;
for n in $(cat - | tail -n1); do
        if [ $((${n} - $((${n} / 2)) * 2)) -eq 0 ] ; then
                #echo gu
                if [ $(($((${n} - $((${n} / 3)) * 3)) * $((${n} - $((${n} / 5)) * 5)))) -eq 0 ] ; then
                        echo APPROVED
                else
                        echo DENIED
                fi
        fi
done
} | sort | tail -n1

Measured memory_bytes: 1908
package main

import (
	"fmt"
)

func main() {
	var n, d int
	fmt.Scan(&n, &d)

	x := make([][]int, n)
	for i := range x {
		x[i] = make([]int, d)
		for j := range x[i] {
			fmt.Scan(&x[i][j])
		}
	}

	cnt := 0
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			sum := 0
			for k := 0; k < d; k++ {
				sum += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k])
			}
			for k := 0; k <= sum; k++ {
				if v := k * k; v == sum {
					cnt++
				} else if v > sum {
					break
				}
			}
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 512
import sys
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7

li = LI()

# 制約があやふやなくそ問題な気もする

print(15-sum(li))


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

int main(){
    double w, h, x, y;
    cin >> w >> h >> x >> y;

    double ans = w*h/2.0;
    int t;

    cout << ans << "\t" << (2*x==w && 2*y==h);
    return 0;
}

Measured memory_bytes: 256
#include  <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 1000000007
//P pa(114,514);   ,vector<P>vec(N,0);
//vector<vector<int>> vec(縦, vector<int>(横));
#define REP(i,N) for(int i=0;i<N;i++)
int gcd(int a, int b) {
    if(a>b){
        swap(a,b);
        }
    while(b%a!=0){
        b%=a;
        swap(a,b);
    }
    return a;
}
int kaijou(int n){
    int a=1;
  if(n==0){
    return 1;
  }
    REP(i,n){
        a*=i+1;
    }
    return a;
}
int ncr(int n,int r){
  int a;
  if(n<0||r<0||n<r){
    return 0;
  }
  a=kaijou(n)/kaijou(r)/kaijou(n-r);
  return a;
}
//cout << setprecision(123);
int main(){
  int x,a;
  cin>>x>>a;
  if(x<a)cout<<0<<endl;
  else cout<<10<<endl;
}

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

#define pb push_back
#define mp make_pair
#define mod 1000000007
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

typedef long long ll;
typedef long double ld;
class Task
{
public:
	void solve(istream& in,ostream& out)
	{
		int a,b,c;
		in>>a>>b>>c;
		int five=0,seven=0;

		if(a==5)
		{
			five++;
		}
		if(b==5)
		{
			five++;
		}
		if(c==5)
		{
			five++;
		}

		if(five==2)
		{
			if(a==7)
			{
				seven++;
			}
			if(b==7)
			{
				seven++;
			}
			if(c==7)
			{
				seven++;
			}

			if(seven==1)
				out<<"YES"<<endl;
			else
				out<<"NO"<<endl;
		}
		else
		{
			out<<"NO"<<endl;
		}
	}
};

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	std::istream& in(std::cin);
	std::ostream& out(std::cout);

	Task solver;
	solver.solve(in,out);	
	out.flush();
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long T[] = new long[N];
		long A[] = new long[N];
		for(int i = 0; i < N; i++) {
			T[i] = sc.nextLong();
			A[i] = sc.nextLong();
		}
		
		long t = 1;
		long a = 1;
		for(int i = 0; i < N; i++) {
			long n = Math.max(t / T[i], a / A[i]);
			while(T[i] * n < t || A[i] * n < a) n++;
			t = T[i] * n;
			a = A[i] * n;
		}
		System.out.println(t + a);
	}
}


Measured memory_bytes: 25700
class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parent = [i for i in range(n)]  # 親
        self.rank = [1] * n  # 木の高さ
        self.size = [1] * n  # size[i] は i を根とするグループのサイズ

    def find(self, x):  # x の根を返す
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])  # 経路圧縮
            return self.parent[x]

    def unite(self, x, y):  # x, y の属する集合を併合する
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                self.parent[x] = y
                self.size[y] += self.size[x]
            else:
                self.parent[y] = x
                self.size[x] += self.size[y]
                if self.rank[x] == self.rank[y]:
                    self.rank[x] += 1

    def is_same(self, x, y):  # x, y が同じ集合に属するか判定する
        return self.find(x) == self.find(y)

    def group_size(self, x):  # x が属する集合の大きさを返す
        return self.size[self.find(x)]

n, m = map(int, input().split())
uf = UnionFind(n)
for i in range(m):
    a, b = map(int, input().split())
    a -= 1; b -= 1
    uf.unite(a, b)
x = 0
for i in range(n):
    x = max(x, uf.group_size(i))
print(x)

Measured memory_bytes: 20120
N = gets.chomp.to_i

require "prime"

i = 105

result = 0

def calcDivisionNum(i)
  return Prime.prime_division(i).reduce(1) {|result, array|
    result * (array[1] + 1)
  }
end

while i <= N do
  result += 1 if calcDivisionNum(i) == 8
  i += 2
end

puts result


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

using namespace std;

#define ll long long

int abs_i(int a){
    if(a > -1){
        return a;
    }else{
        return -a;
    }
}

int main(void){
    int n;
    cin >> n;
    vector<int> p(n), q(n), num(n);
    for(int i = 0;i < n;++i)    cin >> p[i];
    for(int i = 0;i < n;++i)    cin >> q[i];
    for(int i = 0;i < n;++i)    num[i] = i+1;

    int i = 1;
    int a, b;
    do{
        if(num == p)    a = i;
        if(num == q)    b = i;
        i += 1;
    }while(next_permutation(num.begin(), num.end()));

    cout << abs_i(a-b) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:

};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> H(n, 0);
    vector<int> U(n, 0);

    for (int i = 0; i < n; ++i) {
        int m;
        cin >> m;
        for (int j = 0; j < m; ++j) {
            int x;
            int y;
            cin >> x >> y;
            --x;
            if (y == 1) {
                H[i] |= 1 << x;
            } else {
                U[i] |= 1 << x;
            }
        }
    }

    int N = 1 << n;
    int res = 0;
    for (int i = 0; i < N; ++i) {
        int cnt = 0;
        int A = i;
        int B = A ^ (N - 1);

        int HH = 0;
        int UU = 0;
        for (int j = 0; j < n; ++j) {
            if (i & (1 << j)) {
                ++cnt;
                HH |= H[j];
                UU |= U[j];
            }
        }
        if ((HH & UU) == 0 && (HH & A) == HH && (UU & B) == UU) {
            res = max(res, cnt);
        }
    }

    cout << res << "\n";

    return 0;
}

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

int main(){
  string S;
  cin >> S;
  int n = S.size();
 
  ll sum = 0;
  for(int bit=0; bit < (1<<n-1);++bit){
      int l = 0;
      ll tmp = 0;
    int r;
    
    for(r=0; r<n-1; r++){
      if(bit & (1<<r)){
        string t = S.substr(l,r-l+1);
        ll num = stoll(t);
        tmp += num;
        l=r+1;
      }
    }
    string t= S.substr(l,r-l+1);
    ll num = stoll(t);
    tmp += num;
    sum += tmp;
        
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 384
# ABC 081 - B - Shift Only
n = STDIN.gets.to_i
numbers = STDIN.gets.chomp!.split(" ").map(&:to_i) # 8 12 40
max = 0
if numbers.size == n
	while true 
		odd_exists = false 
		numbers.size.times do |i|
		    odd_exists = true if numbers[i] % 2 != 0 
			numbers[i] = numbers[i] / 2
		end
		if odd_exists == true
			break
		else
			max += 1
		end
	end
	puts max
end

Measured memory_bytes: 1788
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"

using namespace std;

const int MOD = 1000000007;
//const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R;

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

	string s;
	cin >> s;
	map<char, int>m;
	for (auto i : s)m[i] = 1;
	if ((m['N'] ^ m['S'])|(m['W'] ^ m['E'])) {
		cout << "No\n";
		return 0;
	}
	cout << "Yes\n";
}

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

int main(){
  vector<vector<int>> c(3, vector<int>(3));
  rep(i,3)rep(j,3) cin >> c[i][j];
  vector<int> a(3), b(3);
  rep(i,3) a[i] = c[0][i] - b[0];
  rep(i,3) b[i] = c[i][0] - a[0];
  rep(i,3) rep(j,3)
      if(c[i][j] != b[i]+a[j]){
        puts("No");
        return 0;
      }
  puts("Yes");
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	ll a, v, b, w, t;
	cin >> a >> v >> b >> w >> t;
	if (v <= w) {
		cout << "NO" << endl;
		return 0;
	}
	if (a < 0 || b < 0) {
		a += 1e9;
		b += 1e9;
	}
	long double dist = abs(a - b);
	long double run = v - w;
	if ((dist/t) <= run) {
		cout << "YES" << endl;
		return 0;
	}
	else {
		cout << "NO" << endl;
		return 0;
	}
	return 0;
}



Measured memory_bytes: 3580
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<sstream>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1000000000+7
using namespace std;
typedef long long ll;

int main(){
  int H, W, h, w; cin >> H >> W >> h >> w;
  cout << (H*W - h*W - H*w + h*w) << endl;
  return 0;
}

Measured memory_bytes: 256
exp = input().split()

s = []
tmp = 0

for x in exp:
	if x == '+':
		tmp = int(s.pop()) + int(s.pop())
		s.append(tmp)
	elif x == '-':
		tmp = -1 * (int(s.pop()) - int(s.pop()))
		s.append(tmp)
	elif x == '*':
		tmp = int(s.pop()) * int(s.pop())
		s.append(tmp)
	else:
		s.append(int(x))

print(tmp)

Measured memory_bytes: 7672
<?php
fscanf(STDIN, '%d', $N);
$P = array_map('intval', explode(' ', trim(fgets(STDIN))));
$x = PHP_INT_MAX;
$ans = 0;
foreach ($P as $v) {
    if ($x > $v) {
        $ans++;
        $x = $v;
    }
}
printf('%d', $ans);


Measured memory_bytes: 27120
#include <stdio.h>

int main()
{
	int n,i,j;
	char s[101];
	scanf("%d",&n);
	scanf("%s",s);
	for (i=0,j=0;i<n;i++) {
		if (s[i]=='R') j++;
		else j--;
	}


	if (j>0) printf("Yes\n");
	else printf("No\n");
	return 0;	
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <vector>
#define ipair pair<int,int>
#define rep(I,N) for(int I=0; I<N; I++)
#define repj(i,j,n) for(int i=j;i<n;i++)

#define PB(a,i) (a).push_back(i)
#define ALL(a) (a).begin(),(a).end()

#define OK(i) cout<<"OK "<<i<<endl
#define Yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define NO cout<<"NO"<<endl

using namespace std;

typedef long long int lli;
typedef long long ll;
typedef vector<int> vi;
typedef vector< vector<int> > Matrix;

int gcd (int a, int b)
{
  int tmp, r;
  if (a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }

  return b;
}

int main ()
{
  int N;
  cin >> N;
  int x[100001];

  rep(i, N) {
    cin >> x[i];
  }

  int small_gcd = x[0];
  rep(i, N) {
    small_gcd = gcd(small_gcd, x[i]);
  }

  printf("%d\n", small_gcd);
}




Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
 
int gcd(int a, int b) { 
   if (b == 0) 
      return a; 
   if (a == 0)
     return b;
   return gcd(b, a % b);  
} 
 
int main() {
  int N;
  cin >> N;
  vector<int> A;
  for (int i=0; i<N; i++){
    int tmp;
    cin >> tmp;
    A.push_back(tmp);
  }
  vector<int> L;
  L.push_back(0);
  vector<int> R;
  R.push_back(0);
  int g = 0;
  int gr = 0;
  for (int i=0; i<N; i++){
    g = gcd(g, A[i]);
    L.push_back(g);
    gr = gcd(gr, A[N-1-i]);
    R.push_back(gr);
  }
  int res = 0;
  reverse(R.begin(), R.end());
  for (int i=0; i<N; i++){
    res = max(res, gcd(L[i], R[i+1]));
  }
  cout << res << endl;
}

Measured memory_bytes: 1912
import Control.Monad (replicateM)

main = do
    replicateM 3 $ do
        nums <- return . map read . words =<< getLine
        let hms1 = take 3 nums
        let hms2 = drop 3 nums
        let hmsd = secToHms ((hmsToSec hms2) - (hmsToSec hms1))
        (putStrLn . unwords . map show) hmsd
    
hmsToSec :: [Int] -> Int
hmsToSec [h,m,s] = h * 3600 + m * 60 + s

secToHms :: Int -> [Int]
secToHms ts = [ts `div` 3600, ts `mod` 3600 `div` 60, ts `mod` 60]

Measured memory_bytes: 3740
#include <bits/stdc++.h>
#define itn int
#define gI gi
#define int long long

using namespace std;

typedef long long ll;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

inline ll gl()
{
	ll f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

int a[200004], sum;

signed main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	int n = gi(), k = gi();
	for (int i = 1; i <= n; i+=1) a[i] = gi();
	if (k >= n) {puts("0"); return 0;}
	sort(a + 1, a + 1 + n);
	for (int i = 1; i <= n - k; i+=1) sum += a[i];
	cout << sum << endl;
	return 0;
}



Measured memory_bytes: 1792
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<iomanip>
#include<sstream>
#include<cmath>
#include<bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(long long int i = 1;i <=  n; i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
typedef long long int ll;
int main() {
    ll N; cin >> N;
    req(h, 3500) {
        req(n, 3500) {
            ll w = N * h * n, x = 4 * h * n - N * n - N * h;
            if (x!=0 && w%x==0 && w/x>0) {
                cout << h << " " << n << " " << w / x << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
from scipy.sparse.csgraph import floyd_warshall

# ダイクストラを二回行う
N, M, L = map(int, input().split())
graph = [[float('inf')]*N for _ in range(N)]
for _ in range(M):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    graph[a][b] = c
    graph[b][a] = c

graph = floyd_warshall(graph)
another = [[float('inf')]*N for _ in range(N)]
for i in range(N):
    for j in range(N):
        if graph[i][j] <= L:
            another[i][j] = 1
another = floyd_warshall(another)
Q = int(input())
for _ in range(Q):
    s, t = map(lambda x: int(x)-1, input().split())
    if another[s][t] == float('inf'):
        print(-1)
    else:
        print(int(another[s][t])-1)


Measured memory_bytes: 19000
#!/usr/bin/env python3
import sys
import numpy as np


def solve(N: int, A: "List[int]"):
    ans = A[0]

    if min(A)==0:
        print(0)
        return

    for i in range(1, N):
        ans *= A[i]
        if ans > 10**18:
            print(-1)
            return
    print(ans)

    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 42428
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[]={
        1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
    };
    int k;
    cin>>k;
    cout<<a[k-1];
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#define MAX 200000

int max(int,int);
int min(int,int);

int main(){
  int R[MAX],n,i,maxv,minv;

scanf("%d",&n);
for(i=0;i<n;i++){
  scanf("%d",&R[i]);
}
maxv=R[1]-R[0];
minv=R[0];

for(i=1;i<n;i++){
  maxv = max(maxv,R[i]-minv);
  minv = min(minv,R[i]);
}

printf("%d\n",maxv);
return 0;
}
int max(int x,int y){
  if(x>y){
    return x;
  }else{
    return y;
  }
}
int min(int x,int y){
  if(x<y){
    return x;
  }else{
    return y;
  }
}

Measured memory_bytes: 1376
d,g=map(int,input().split())
P=[0]*d
C=[0]*d
for i in range(d):
  P[i],C[i]=map(int,input().split())
dp=[[-10**10]*(sum(P)+111) for i in range(d+1)]
for i in range(sum(P)+1):
  dp[0][i]=0
for i in range(1,d+1):
  dp[i][0]=0
for i in range(1,d+1):
  for j in range(1,(sum(P)+1)):
    dp[i][j]=max(max(dp[i-1][j-k]+i*100*k for k in range(P[i-1])),dp[i-1][j-P[i-1]]+i*100*P[i-1]+C[i-1],dp[i][j-1])
i=-1
while dp[d][i]<g:
  i=i+1
print(i)

Measured memory_bytes: 43612
#include<stdio.h>
int main()
{
	int n,p,q;
	scanf("%d",&n);
	if(n%1000==0)
	{
		printf("0");
	}
	else
	{
		p=n%1000;
		q=1000-p;
		printf("%d",q);
	}
		
	
}

Measured memory_bytes: 1728
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long p=100;
    long double r=101/100;
    long double n;
    cin>>n;
    int c=1;
    int m=0;
    long double res=p;
    while(p<n)
    {
        p=p+p/100;
        m++;
    }
    cout<<m<<endl;
}

Measured memory_bytes: 3728
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>
#include <iomanip>
#include <tuple>

using namespace std;


int main(){
   bool ym=true;
   bool my=true;
   string s;
   cin>>s;

   if(s[0]-'0'==0 && s[1]-'0'==0)my=false;
   if(s[2]-'0'==0 && s[3]-'0'==0)ym=false;

   if(s[0]-'0'==1 && (int)(s[1]-'0')>=3)my=false;
   if(s[2]-'0'==1 && (int)(s[3]-'0')>=3)ym=false;

   if((int)(s[0]-'0')>=2)my=false;
   if((int)(s[2]-'0')>=2)ym=false;

   if(my && ym)cout<<"AMBIGUOUS"<<endl;
   else if(my && !ym)cout<<"MMYY"<<endl;
   else if(!my && ym)cout<<"YYMM"<<endl;
   else cout<<"NA"<<endl;

}

   


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

int main(){
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    int maxA, maxB, minA, minB;

    if( A<=C ){
        minA=A; minB=B; maxA=C; maxB=D;
    }else{
        minA=C; minB=D; maxA=A; maxB=B;        
    }

    if( maxB < minB){
        cout << maxB-maxA << endl;
    }else if( maxA < minB ){
        cout << minB-maxA << endl;
    }else{
        cout << 0 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;

class Dice{
private:
	int num[6];
public:
	Dice(int input[6]);
	~Dice(){};
	int getNum(int want);
	int getTop();
	void moveStep(char direction);
	int func1(int ue, int mae);
	bool func2(int in[6]);
};

Dice::Dice(int input[6]){
	for(int i = 0; i < 6; i++){
		num[i] = input[i];
	}
}

int Dice::getNum(int want){
	return num[want - 1];
}

int Dice::getTop(){
	return num[0];
}

void Dice::moveStep(char direction){
	int temp[6];
	for(int i = 0; i < 6; i++){
		temp[i] = num[i];
	}
	switch(direction){
	case 'N':
		num[0] = temp[1];
		num[1] = temp[5];
		num[5] = temp[4];
		num[4] = temp[0];
		break;
	case 'E':
		num[0] = temp[3];
		num[3] = temp[5];
		num[5] = temp[2];
		num[2] = temp[0];
		break;
	case 'S':
		num[0] = temp[4];
		num[4] = temp[5];
		num[5] = temp[1];
		num[1] = temp[0];
		break;
	case 'W':
		num[0] = temp[2];
		num[2] = temp[5];
		num[5] = temp[3];
		num[3] = temp[0];
		break;
	}
}

int Dice::func1(int ue, int mae){
	if(num[0] == ue && num[1] == mae) return num[2];

	string str("NNNNENNNNENNNNENNNNENENNNEENNN");//Gorioshi!
	for(unsigned int i = 0; i < str.length(); i++){
		moveStep(str[i]);
//		cout << num[0] << " " << num[1] << endl;
		if(num[0] == ue && num[1] == mae) return num[2];
	}

	return -1;
}

bool Dice::func2(int in[6]){
	if(num[0] == in[0] && num[1] == in[1] && num[2] == in[2] && num[3] == in[3] && num[4] == in[4] && num[5] == in[5]) return true;

	string str("NNNNENNNNENNNNENNNNENENNNEENNN");//Gorioshi!
	for(unsigned int i = 0; i < str.length(); i++){
		moveStep(str[i]);
		if(num[0] == in[0] && num[1] == in[1] && num[2] == in[2] && num[3] == in[3] && num[4] == in[4] && num[5] == in[5]) return true;
	}

	return false;
}

int main() {

	int n;
	cin >> n;

	int in[n][6];
	for(int i = 0; i < n; i++){
		for(int j = 0; j < 6; j++){
			cin >> in[i][j];
		}
	}
/*
	for(int i = 0; i < n; i++){
		for(int j = 0; j < 6; j++){
			cout << in[i][j] << " ";
		}
		cout << endl;
	}
*/
	int frag = 1;
	for(int i = 0; i < n - 1; i++){
		Dice dice1(in[i]);
		for(int j = i + 1; j < n; j ++){
			if(dice1.func2(in[j])) frag = 0;
		}
	}

	if(frag){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
#define LL long long
using namespace std;

string s;
int main()
{
    cin >> s;
    int head = 0,tail = s.size() - 1;
    int ans = 0;
    while(head < tail){
        if(s[head]!=s[tail]){
            if(s[head]!='x'&&s[tail]!='x'){
                printf("-1\n");
                return 0;
            }
            if(s[head]=='x'&&s[tail]!='x')
                ans++,head++;
            if(s[tail]=='x'&&s[head]!='x')
                ans++,tail--;
        }
        else
            head++,tail--;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 512
N, K = map(int, input().split())
A = list(map(int, input().split()))

def solve():
    visited = [-1]*N
    visited[0] = 0
    goto = 1
    counter = 0
    period = 0
    while 1:
        counter += 1 #counter 回ワープした
        goto = A[goto-1] #counter回目につく場所

        if counter == K:
            print(goto)
            return 0

        if visited[goto-1] == -1:
            visited[goto-1] = counter
        else:
            period = counter - visited[goto-1]
            break

    
    warp = 0
    here = 1
    while here != goto:
        warp += 1
        here = A[here-1]

    peri_and_rem = K - warp
    rem = peri_and_rem % period

    while rem > 0:
        rem -= 1
        here = A[here - 1]


    print(here)
    return 0
        



solve()



    

Measured memory_bytes: 32180
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {
	static int n, k;
	static List<List<Integer>> list;
	static int mod = 1000000007;

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		n = Integer.parseInt(sa[0]);
		k = Integer.parseInt(sa[1]);
		list = new ArrayList<>(n);
		for (int i = 0; i < n; i++) {
			list.add(new ArrayList<>());
		}
		for (int i = 0; i < n - 1; i++) {
			sa = br.readLine().split(" ");
			int a = Integer.parseInt(sa[0]) - 1;
			int b = Integer.parseInt(sa[1]) - 1;
			list.get(a).add(b);
			list.get(b).add(a);
		}
		br.close();

		long ans = dfs(0, -1, 0);
		ans *= k;
		ans %= mod;
		System.out.println(ans);
	}

	static long dfs(int x, int p, int dep) {
		long ret = 1;
		long s = k - 1;
		if (dep == 0) {
			s = k;
		}
		for (int c : list.get(x)) {
			if (c != p) {
				s--;
				if (s == 0) {
					return 0;
				}
				ret *= s;
				ret %= mod;
				ret *= dfs(c, x, dep + 1);
				ret %= mod;
			}
		}
		return ret;
	}
}


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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MOD 1000000007
#define INF 100100100

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


int main(){
  int n;
  cin >> n;
  vector<int> v(n);
  vector<int> d(n);
  ll sum = 0;
  ll tmp = 0;

  for (int i = 0; i < n; i++) {
    cin >> v[i];
    sum += v[i];
    tmp += i+1;
  }

  if(sum % tmp != 0){
    cout << "NO" << endl;
    return 0;
  }
  ll k = sum / tmp;

  for (int i = 0; i < n-1; i++) {
    d[i] = v[i+1] - v[i];
  }
  d[n-1] = v[0] - v[n-1];

  for (int i = 0; i < n; i++) {
    if(d[i] > k || (k - d[i]) % n != 0){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}


Measured memory_bytes: 1024
# # Make IO faster
# import sys
# input = sys.stdin.readline

# # get single (or) multiple str
# X = input()

# # get single int
# N = int(input())
# # get multiple int (e.g., 2)
# X, Y = map(int, input().split())
# # get multiple int (e.g., 2) for N lines
# XY = [list(map(int, input().split())) for _ in range(N)]

# from IPython import embed; embed(); exit();

# 全部入り
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

s = input()
if s[-1] == "s":
    s += "es"
else:
    s += "s"
print(s)


Measured memory_bytes: 27308
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;


int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


	void init(int n)
	{
		for (int i = 0; i < n; i++) par[i] = i;
		for (int i = 0; i < n; i++) r[i] = 0;
	}

	int find(int x)
	{
		if (par[x] == x)return x;
		else return find(par[x]);
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};



int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a, b;
	ll ans;

	cin >> a >> b;
	if (a == 1 && b == 1)ans = 1;

	if (a == 1 && b > 1) ans = b - 2;

	if (b == 1 && a > 1) ans = a - 2;

	if (a > 1 && b > 1)ans = (a - 2) * (b - 2);

	cout << ans << endl;

	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
using namespace std;
int main(){
    int N;
    cin >> N;
    int p[50] = {};
    int P[50] = {};
    for(int i=0;i<N;i++){
        cin >> p[i];
        P[i] = p[i];
    }
    
    sort(P,P+N);
    
    int cnt = 0;
    for(int i=0;i<N;i++){
        if(P[i]!=p[i]){
            cnt++;
        }
    }
    
    if(cnt>2 || cnt==1){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
        }
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long int
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define pci pair<char,int
#define mii map<int,int>
#define mll map<long long int,long long int>
#define mci map<char,int>
#define umii unordered_map<int,int>
#define umll unordered_map<long long int,long long int>
#define umci unordered_map<char,int>
#define F first
#define S second
#define pb push_back
#define endl '\n'
  
using namespace std;
bool sortinrev(const pair<ll,ll> &a,  
               const pair<ll,ll> &b) 
{
       if(a.first!=b.first) return(a.first > b.first);
       else return (a.second<b.second);
} 
ll power(ll x,int n)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x);
        x=(x*x);
        n=n/2;
    }
    return result;
}

int main(){
    IOS;ll n;
 cin>>n;
 cout<<n+(n*n)+(n*n*n); 
return 0;}


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

#define ll long long
const long long llINF = 1LL << 60;
const int iINF = 0x20000000;
template<class T> inline bool chmin(T& a, T b) { if (b < a) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void execute();
int main() 
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);// cin と scanfの併用禁止
    cout << fixed << setprecision(15);
    execute();
    return 0;
}

void execute()
{
    int N, M;
    cin >> N >> M;

    multimap<int, int> route;
    for(int i = 0; i < M; i++){
        int A, B;
        cin >> A >> B;
         route.insert(multimap<int, int>::value_type(A, B));
         route.insert(multimap<int, int>::value_type(B, A));
    }

    int frm[200001]={};
    queue<int> que;;

    int find_num = 1;
    frm[1] = 1;
    que.push(1);
    while (!que.empty()) {
        int v = que.front();
        que.pop();

        auto p = route.equal_range(v);
        for (auto it = p.first; it != p.second; ++it) 
        {
            int idx = it->second;
            if(frm[idx] == 0){
                frm[idx] = v;
                que.push(idx);
                if(++find_num == N) {
                    // 結果出力
                    cout << "Yes" << endl;
                    for(int i = 2; i <= N; i++){
                        cout << frm[i] << endl;
                    }
                    return;
                }
            }
        }
    }

    cout << "No" << endl;
}

Measured memory_bytes: 23296
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int ans = 0;

        if(13 <= A)    ans = B;
        else if(6 <= A && A < 13)    ans = B / 2;
        else    ans = 0;

        System.out.print(ans);
    }
}

Measured memory_bytes: 21844
N,Y = map(int, input().split())
 
for i in range(N+1):
	for j in range(0, N+1-i):
		k = N-i-j
		if 10000*i + 5000*j + 1000*k == Y:
			print(i, j, k)
			exit()
 
print(-1,-1,-1)

Measured memory_bytes: 3060
def gcd(x,y):
    if x<y:
        x,y=y,x
    if y==0:
        return x
    return gcd(y,x%y)
    
def main():
    k=int(input())
    ans=0
    for a in range(1,k+1):
        for b in range(1,k+1):
            for c in range(1,k+1):
                ans+=gcd(gcd(a,b),c)
    print(ans)
    
if __name__=='__main__':
    main()

Measured memory_bytes: 79676
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
const int mod = 1e9 + 7;
const int INF = 1e9;
const double pi = acos(-1.0);
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
int main(){
    int n; cin >> n;
    vll a(n);
    rep(i,n)cin >> a[i];
    
    bool ze = 0;
    rep(i,n)if(a[i] == 0)ze = 1;
    
    if(ze){
        cout << 0 << endl;
        return 0;
    }
    
    ll ans = 1;
    rep(i,n){
        if(a[i] <= 1000000000000000000 / ans)ans *= a[i];
        else {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
    
    return 0;
}  

Measured memory_bytes: 3964
n=int(input())
s=input()
ans=0
brute=[str(i)[1:] for i in range(1000,2000)]
for i in brute:
  flag=0
  for j in s:
    if j==i[0] and flag==0:
      flag+=1
      continue
    if flag==1 and j==i[1]:
      flag+=1
      continue
    if flag==2 and j==i[2]:
      ans+=1
      break
print(ans)


Measured memory_bytes: 42716
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class FastDivision {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int ans = -1;
            if (n == 0 || n == 2) {
                ans = 1;
            } else if (n == 1) {
                ans = 2;
            } else {
                ans = 0;
            }
            out.println(ans);
        }

    }
}

Measured memory_bytes: 26300
#include<bits/stdc++.h>
using namespace std;
const int Mod=1e9+7;
int n,a[25][25],f[3000010];
vector<int> v[25];
void upd(int &x,int v)
{
	x=(x+v)%Mod;
}
int main()
{
	scanf("%d",&n);
	for (int i=0;i<n;i++)
	{
		for (int j=0;j<n;j++)
		{
			scanf("%d",&a[i][j]);
		}
	}
	for (int mask=0;mask<(1<<n);mask++)
	{
		int s=0;
		for (int i=0;i<n;i++)
		{
			if (mask&(1<<i))
			{
				s++;
			}
		}
		v[s].push_back(mask);
	}
	f[0]=1;
	for (int i=0;i<n;i++)
	{
		for (int j=0;j<v[i].size();j++)
		{
			int mask=v[i][j];
			for (int k=0;k<n;k++)
			{
				if (!a[i][k] || mask&(1<<k))
				{
					continue;
				}
				upd(f[mask|(1<<k)],f[mask]);
			}
		}
	}
	cout<<f[(1<<n)-1]<<endl;
	return 0;
}


Measured memory_bytes: 19900
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin >> n;
  vector<P> v(n);
  rep(i,n){
      ll a,b; cin >> a >> b;
      if(a>b){
          cout << "No" << endl;
          return 0;
      }
      v[i] = mp(b,a);
  }
  sort(all(v));
  ll num = 0;
  rep(i,n){
      if(num+v[i].second>v[i].first){
          cout << "No" << endl;
          return 0;
      }
      num += v[i].second;
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 3456
package main

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

func sum(a []int) int {
	ret := 0
	for _, v := range a {
		ret += v
	}
	return ret
}

func min(nums []int) int {
	ret := nums[0]
	for _, v := range nums {
		if v < ret {
			ret = v
		}
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	x := nextInts(n)
	avr := sum(x) / len(x)

	ans := make([]int, 3)
	for i := range x {
		ans[0] += (x[i] - avr) * (x[i] - avr)
	}
	avr--
	for i := range x {
		ans[1] += (x[i] - avr) * (x[i] - avr)
	}
	avr += 2
	for i := range x {
		ans[2] += (x[i] - avr) * (x[i] - avr)
	}
	puts(min(ans))
	wt.Flush()
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

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

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

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

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func nextMega() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, _ := rdr.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
using namespace std;

int main(){
    int a, b, c, ans;
    cin >> a >> b >> c;
    if(a==b) ans = c;
    else if (b==c) ans = a;
    else ans = b;
    cout << ans << endl;
    return 0;
}


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

using namespace std;

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

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

int N;
string S, ans;

void solve() {
    cin >> N >> S;
    int c = 0;
    int x = 0;
    rep(i,N) {
        if (S[i] == '(') {
            c++;
        } else {
            if (c > 0) c--;
            else x++;
        }
    }
    rep(i,x) ans += '(';
    ans += S;
    rep(i,c) ans += ')';
    cout << ans << endl;
}

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


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int r, g, b;
    
    scanf("%d %d %d", &r, &g, &b);
    
    if((r*100 + g*10 + b) % 4 == 0){
        printf("YES\n");
    }else{
        printf("NO\n");
    }
    
}


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

using namespace std;

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

    vector<int> v;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        v.push_back(a);
    }
    sort(begin(v), end(v));

    vector<bool> mask(n);
    auto it = mask.rbegin();
    for (int i = 0; i < 2; ++i) {
        if (it != mask.rend()) {
            *it = true;
        }
        ++it;
    }

    auto check = [](int x) {
        auto s = to_string(x);
        for (size_t i = 0; i < s.size() - 1; ++i) {
            if (s[i] + 1 != s[i + 1]) {
                return false;
            }
        }
        return true;
    };
    int max_ = -1;
    do {
        int p = 1;
        for (size_t i = 0; i < mask.size(); ++i) {
            if (mask[i]) {
                p *= v[i];
            }
        }
        if (check(p)) {
            max_ = max(max_, p);
        }
    } while (next_permutation(begin(mask), end(mask)));
    cout << max_ << endl;
}


Measured memory_bytes: 3292
#include <bits/stdc++.h>
using namespace std;typedef long long ll;typedef vector<ll> vl;typedef vector<vl> vvl;typedef pair<ll,ll> pl;typedef vector<pl> vp;const ll INF=1001001001;const ll LINF=1001001001001001001;const ll D4[]={0,1,0,-1,0};const ll D8[]={0,1,1,0,-1,-1,1,-1,0};template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
#define fore(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()

void solve(long long N, long long K){
    ll p=N/K;
    ll ans=min(abs(N-p*K),abs(N-(p+1)*K));
    cout<<ans<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    solve(N, K);
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sun Sep 30 17:27:26 2018
KyotoE
@author: maezawa
"""

n = int(input())
parray = list(map(int, input().split()))
larray = [0]*n
rarray = [0]*n


def merge(a, n, left, mid, right):
    cnt = 0
    n1 = mid - left
    n2 = right -mid
    for i in range(n1):
        larray[i] = a[left+i]
    for i in range(n2):
        rarray[i] = a[mid+i]
    larray[n1] = 10**10
    rarray[n2] = 10**10
    i = 0
    j = 0
    for k in range(left,right):
        if larray[i] <= rarray[j]:
            a[k] = larray[i]
            i += 1
        else:
            a[k] =rarray[j]
            j += 1
            cnt += n1 - i
    return cnt

def mergesort(a, n, left, right):
    if left+1 < right:
        mid = (left+right)//2
        v1 = mergesort(a, n, left, mid)
        v2 = mergesort(a, n, mid, right)
        v3 = merge(a, n, left, mid, right)
        return v1+v2+v3
    else:
        return 0
    
ans = mergesort(parray, n, 0, n)
print(ans)


Measured memory_bytes: 27492