akhauriyash/Code-Regression huggingface dataset:
n, w = map(int, raw_input().split())
oo = w + 1
items = []
v = 0
for _ in range(n):
    wi, vi = map(int, raw_input().split())
    items.append((wi, vi))
    v += vi

dp = [[oo] * (v + 1) for _ in range(n + 1)]
for i in xrange(n + 1):
    dp[i][0] = 0
for i in xrange(1, n + 1):
    wi, vi = items[i - 1]

    for j in range(1, vi):
        dp[i][j] = dp[i - 1][j]

    for j in range(vi, v + 1):
        if j >= vi:
            dp[i][j] = min(dp[i - 1][j], wi + dp[i - 1][j - vi])
for i in xrange(v, -1, -1):
    if dp[n][i] <= w:
        print(i)
        break


Measured memory_bytes: 110956
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define rusha scanf("%d",&n);rep(i,1,n)scanf("%d",&a[i]);
#define rushb scanf("%d",&t);while(t--)
#define debug(x) cout<<" L-B-W-- "<<x<<" --N-B\n"
#define pb push_back
//#define pii pair<int,int>
#define vii vector<int>
#define fi first
#define se second
#define mem(a,b) memset(a,b,sizeof a)
#define all(x) (x.begin(),x.end())
#define judgef printf("%s\n",f?"Yes":"No")
#define Judgef printf("%s\n",f?"YES":"NO")
#define sz(x) ((int)(x).size())
#define sf(x) (sizeof(x))
using namespace std;
typedef long long ll;
typedef double db;
const double pai = acos(-1.0);
const double eps = 1e-8;
const int mod=998244353;
//const int mod=1e9+7;
const int inf=1e9+7;
//const ll inf=0x7f7f7f7f1234abcd;
const int maxn=1e5+10;
inline ll ksm(ll x,ll y){ ll res=1; while(y){if(y&1) res=res*x%mod;x=x*x%mod; y>>=1;} return res; }
inline ll inv(ll a,ll p){if(a==1)return 1;return (p-p/a)*inv(p%a,p)%p;}
ll lcm(ll a, ll b) { return a * b / __gcd(a, b); }

int t,n,m,k;

int a[maxn];

int main(){
    scanf("%d%d",&n,&k);
    rep(i,1,k){
        scanf("%d",&m);
        rep(j,1,m){
            scanf("%d",&t);
            a[t]++;
        }
    }
    int s=0;
    rep(i,1,n) if(a[i]) s++;
    printf("%d\n",n-s);
    return 0;
}


Measured memory_bytes: 3828
n=int(input())
ans=0;BA,BB,AA=0,0,0
for i in range(n):
  s=input()
  for i in range(len(s)-1):
    if s[i]+s[i+1]=="AB":ans+=1
  if s[0]+s[-1]=="BA":BA+=1
  elif s[-1]=="A":AA+=1
  elif s[0]=="B":BB+=1
if BA==0:print(ans+min(AA,BB))
else:
  ans+=BA-1
  BA=1
  if AA!=0:AA-=1;ans+=1
  if BB!=0:BB-=1;ans+=1
  print(ans+min(AA,BB))

Measured memory_bytes: 3064
<?php
$hoge = explode(' ',trim(fgets(STDIN)));

$piyo = intval(substr($hoge[0],0,2));
$i=0;$s=0;$a = 0;
while(true){
    $n = intval($piyo.$i.substr($piyo,1).substr($piyo,0,1));
    if($n >= $hoge[0] && $n <= $hoge[1]){
        $s++;
    }else if($n > $hoge[1]){
        echo $s;
        exit;
    }
    if($i === 9){
        $piyo++;
        $i = 0;
    }else{
        $i++;
    }
}
?>

Measured memory_bytes: 3828
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	aorg := nextStr()
	borg := nextStr()

	a := fmt.Sprintf("%0101s", aorg)
	b := fmt.Sprintf("%0101s", borg)

	for i := 0; i < len(a); i++ {
		if a[i] > b[i] {
			fmt.Println("GREATER")
			return
		}
		if a[i] < b[i] {
			fmt.Println("LESS")
			return
		}
	}
	fmt.Println("EQUAL")
}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // Default=64
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1796
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


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

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)


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

    cout << ((n & 1)? n * 2 : n) << '\n';
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
def A():
    x,y = LI()
    print(x+y//2)
    return

#B
def B():
    n = I()
    t,a = LI()
    h = LI()
    x = 1
    ans = abs(a-t+h[0]*0.006)
    for i in range(1,n):
        if ans > abs(a-t+h[i]*0.006):
            ans = abs(a-t+h[i]*0.006)
            x = i+1
    print(x)
    return

#C
def C():
    n,m = LI()
    v = LIR(m)
    for i in range(m):
        v[i] = [v[i][0],v[i][1],i]
    v.sort(key = lambda x:x[1])
    f = [0 for i in range(n+1)]
    ans = [None for i in range(m)]
    for p,y,i in v:
        f[p] += 1
        s = "{:0>6}".format(p)
        t = "{:0>6}".format(f[p])
        ans[i] = s+t
    for i in ans:
        print(i)
#D
def D():
    h,w,k = LI()
    dp = [[0 for i in range(w)] for j in range(h+1)]
    dp[0][0] = 1
    p = [1 for i in range(w+1)]
    for i in range(w):
        p[i+1] = p[i]*2
    l = [i for i in range(p[w-1])]
    i = 0
    while i < len(l):
        a = l[i]
        for j in range(w):
            if a&p[j] and a&p[j+1]:
                l.pop(i)
                i -= 1
                break
        i += 1
    d = [[0 for i in range(3)] for j in range(w)]
    for j in range(w):
        for s in l:
            if 0 < j < w-1:
                if p[j]&s:
                    d[j][2] += 1
                elif p[j-1]&s:
                    d[j][0] += 1
                else:
                    d[j][1] += 1
            elif j == 0:
                if p[j]&s:
                    d[j][2] += 1
                else:
                    d[j][1] += 1
            else:
                if p[j-1]&s:
                    d[j][0] += 1
                else:
                    d[j][1] += 1
    for i in range(h):
        for j in range(w):
            dp[i+1][j] += d[j][1]*dp[i][j]
            dp[i+1][j] %= mod
            if j > 0:
                dp[i+1][j-1] += d[j][0]*dp[i][j]
                dp[i+1][j-1] %= mod
            if j < w-1:
                dp[i+1][j+1] += d[j][2]*dp[i][j]
                dp[i+1][j+1] %= mod
    print(dp[h][k-1])
#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    B()


Measured memory_bytes: 39920
#include <cstdio>
#include <cctype>
#include <utility>
#include <algorithm>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;
	while (isspace(c)) {c = gcu();}
	if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(bool b) {pcu('0'+b);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	for (int t = in(); t; t--) {
		int u = 0, d = 0, n = in() - 1, p = in();
		for (; n; n--) {
			int c = in(), t = c - p;
			if (t > 0)
				u = max(u, t);
			else
				d = max(d, -t);
			p = c;
		}
		outl(u, ' ', d);
	}
}


Measured memory_bytes: 2448
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int K,T; cin>>K>>T;
  int memo=-1;
  priority_queue<pii> Q;
  rep(i,0,T){
    int X; cin>>X;
    Q.push(mp(X,i));
  }
  int ans=0;
  while(Q.size()>0){
    int X=Q.top().first,Y=Q.top().second;
    Q.pop();
    if(Y==memo){
      if(Q.size()==0){
        ans++;
        memo=Y;
        if(X>1) Q.push(mp(X-1,Y));
      }
      else{
        int P=Q.top().first,R=Q.top().second;
        Q.pop();
        memo=R;
        if(P>1) Q.push(mp(P-1,R));
        Q.push(mp(X,Y));
      }
    }
    else{
      memo=Y;
      if(X>1) Q.push(mp(X-1,Y));
    }
  }
  cout<<ans<<endl;
  }



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

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

    int n;
    cin>>n;
    vector<int> l;
    for(int i=0;i<n;i++){
        int num;
        cin>>num;
        l.push_back(num);
    }
    for(int i=0;i<n-1;i++){
        cout<<l[n-i-1]<<" ";
    }
    cout<<l[0]<<endl;
    return 0;
}


Measured memory_bytes: 3092
#include <cstdio>
#include <cstring>
#include <cctype>
#include <algorithm>
using namespace std;
inline int read(int f = 1, int x = 0, char ch = ' ')
{
   while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
   while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
   return f*x;
}
const int N = 50+5;
struct Int
{
    int n, bit[N];
    int& operator [] (const int i) { return bit[i]; }
    Int operator + (Int &_) const 
    {
        _.n = max(_.n, n);
        for(int i = 0; i < n; ++i)
        {
            _[i] += bit[i];
            if(_[i] >= 10) _[i] -= 10, ++_[i+1];
        }
        _.n += _[_.n] != 0;
        return _;
    }
    void set(int inter)
    {
        memset(bit, 0, sizeof(int)*n), n = 0;
        while(inter) bit[n++] = inter%10, inter /= 10;
    }
    void print() { if(!n) puts("0"); for(int i = n-1; ~i; --i) putchar('0'+bit[i]); puts(""); }
}f[2], u, w;
int n, p;
int main()
{
    n = read(), p = read(), f[0].set(1);
    for(int i = 1; i <= n; ++i)
    {
        int v = read()&1; u = f[0], w = f[1];
        f[v] = f[v]+u, f[v^1] = f[v^1]+w;
    }
    f[p].print();
    return 0;
}

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



int main(){
	int A,B,C;  
	cin >>A>>B;
  	C=-1000;
  	if(C<A+B)C=A+B;
  	if(C<A*B)C=A*B;
  	if(C<A-B)C=A-B;
  	cout << C << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}

	return d;
}



int main(void) {

	double a, b, x;
	cin >> a >> b >> x;

	double pi = atan(1) * 4;

	if (a * a * b / 2 == x) {
		cout << setprecision(10) << atan(b / a) / pi * 180 << endl;
	}
	else if (a * a * b / 2 < x) {
		cout << setprecision(10) << atan(2 * (a * a * b - x) / (a * a * a)) / pi * 180 << endl;
	}
	else {
		cout << setprecision(10) << (pi / 2 - atan(2 * x / (a * b * b))) / pi * 180 << endl;
	}




	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void)
{
    int n,i,max,min;
    int a,j,b;
     
    while(scanf("%d",&n)&&n!=0){
        max=0;
        min=500;
        for(i=0;i<n;i++){
            a=0;
            for(j=0;j<5;j++){
                scanf("%d",&b);
                a+=b;
            }
                a<max?(max=max):(max=a);
                min<a?(min=min):(min=a);
        }
        printf("%d %d\n",max,min);
    }
    return 0 ;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

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

Measured memory_bytes: 3596
unittest
{
	assert( [ "ABCABC" ].parse.expand.solve == 3 );
	assert( [ "C" ].parse.expand.solve == 0 );
	assert( [ "ABCACCBABCBCAABCB" ].parse.expand.solve == 6 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto s = input.front.to!( dchar[] );
	return tuple( s );
}

auto solve( dchar[] s )
{
	s = ' ' ~ s;
	
	auto ans = 0L;
	auto bc = 0L;
	for( auto i = s.length.signed - 1; 0 < i; i-- )
	{
		if( s[ i - 1 ] == 'B' && s[ i ] == 'C' )
		{
			bc++;
			i--;
		}
		else if( s[ i ] == 'A' )
		{
			ans += bc;
		}
		else
		{
			bc = 0;
		}
	}
	return ans;
}


Measured memory_bytes: 4152
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <iomanip>
#include <deque>

#define sz(c) (int)(c).size()
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define left left228
#define right right228
#define next next228
#define rank rank228
#define prev prev228
#define y1 y1228                                                         
#define read(FILENAME) freopen((FILENAME + ".in").c_str(), "r", stdin)
#define write(FILENAME) freopen((FILENAME + ".out").c_str(), "w", stdout)
#define files(FILENAME) read(FILENAME), write(FILENAME)
#define pb push_back
#define x first
#define y second

using namespace std;

const string FILENAME = "input";

int main(int argc, char const *argv[])
{
	int n; cin >> n;
	int mn = 1e9 + 1, mx = 0;
	for (int i = 0; i < n; i++)
	{
		int x; cin >> x;
		mn = min(mn, x);
		mx = max(mx, x);
	}
	cout << mx - mn << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int a[100005];
int main(int argc, char** argv) {
	int h,n;
	scanf("%d%d",&h,&n);
	int sum=0;
	for(int i=1;i<=n;i++)
	scanf("%d",&a[i]),sum+=a[i];
	if(sum>=h)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	int a,b,c,d;
	cin >> a >> b >>c >> d;
	if (abs(a-c) <= d || (abs(a-b) <=d && abs(b-c) <= d)) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;

void main() {
	auto s = readln.chomp;
	auto y = new int[s.length];
	int begin, i;
	char mode = 'R';
	foreach(c; s) {
		if (c != mode && mode == 'R') {
			y[i-1] += (i-begin+1)/2;
			y[i] += (i-begin+1)/2 + (i-begin+1)%2;
			begin = i;
			mode = 'L';
		}
		else if (c != mode) {
			y[begin-1] += (i-begin-1)/2 + (i-begin-1)%2;
			y[begin] += (i-begin-1)/2;
			begin = i;
			mode = 'R';
		}
		++i;
	}
	y[begin-1] += (i-begin-1)/2 + (i-begin-1)%2;
	y[begin] += (i-begin-1)/2;
	y.map!(i => i.to!string).join(' ').write;
}


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

int main()
{
  char s[101],t[101];
  int mx=-1,mi=1000000;
  cin>>s>>t;
  for(int i=0; s[i]; i++)
  {
    mi=min(mi,(int)s[i]);
  }
  for(int i=0; t[i]; i++)
  {
    mx=max(mx,(int)t[i]);
  }
  if(mi<mx)
  {
    cout<<"Yes\n";
  }
  else if(mi==mx)
  {
    int i=0;
    for(; s[i]&&t[i]&&s[i]==t[i]; i++);
    if(s[i]||t[i]=='\0')cout<<"No\n";
    else cout<<"Yes\n";
  }
  else
  {
    cout<<"No\n";
  }
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  int a[1010];

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

  float result = 0.0;
  for (int i = 0; i < n; i++) {
    result += 1.0 / a[i];
  }

  cout << 1.0 / result << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;
int A[3][3];
int N;
int b;
bool a = false;

int main() {
    for (int i = 0;i<3;i++)
        for (int j= 0;j<3;j++)
            cin >> A[i][j];
    cin >> N;
    for (int i = 0;i<N;i++){
        cin >> b;
        for (int k = 0;k<3;k++){
            for (int j= 0;j<3;j++){
                if (b == A[k][j]){
                    A[k][j] = 0;
                }
            }
        }
    }
    for (int i = 0;i<3;i++){
        if (A[i][0] == 0 && A[i][1] == 0 && A[i][2] == 0){
            a = true;
        }
    }
    for (int i = 0;i<3;i++){
        if (A[0][i] == 0 && A[1][i] == 0 && A[2][i] == 0){
            a = true;
        }
    }
    if ( A[0][0] == 0 && A[1][1] == 0 && A[2][2] == 0){
        a = true;
    }
    if (A[2][0] == 0 && A[1][1] == 0 && A[0][2] == 0){
        a = true;
    }
    if (a){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}



Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        pp: [usize;n]
    }
    let mut pp = pp;
    pp.push(0);
    let mut cnt = 0;
    let mut i = 0;
    while i < n {
        if i+1 == pp[i] {
            let t = pp[i];
            pp[i] = pp[i+1];
            pp[i+1] = t;
            cnt += 1;
            i += 2;
        } else {
            i += 1;
        }
    }
    println!("{}", cnt);
}


Measured memory_bytes: 6396
#include <stdio.h>
#define rep(i,n) for(int i=0;i<n;++i)
int a[200010],v[200010][2],l[200010],n,m,q,c;
int main(void){
	scanf("%d %d %d",&n,&m,&q);
	rep(i,n)rep(j,2) v[i][j]=(i+n+1-2*j)%n;
	rep(i,m){
		scanf("%d",a+i);
		rep(j,a[i]) c=v[c][a[i]&1];
		l[c]=1;
		rep(j,2) v[v[c][j^1]][j]=v[c][j];
		c=v[c][0];
	}
	rep(i,q) scanf("%d",&c), printf("%d\n",1-l[c]);
	return 0;
}

Measured memory_bytes: 4152
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define R cin>>
#define C cout<<
const int INF = 1000000007;
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int>v(n);
  rep(i,n)cin >> v[i];
  ll ans = pow(3,n);
  ll tmp = 1;
  rep(i,n){
    if(v[i] % 2 == 0)tmp *= 2;
  }
  cout << ans - tmp << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
inline int read(){
	int f=1,ans=0;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){ans=ans*10+c-'0';c=getchar();}
	return f*ans;
}
const int MAXN=110;
int len;
char str1[MAXN],str2[MAXN];
int maxn;
bool check(int ps){
	for(int i=1;i<=ps;i++)
		if(str1[len-ps+i]!=str2[i]) return 0;
	return 1;
}
int main(){
	len=read();
	scanf("%s%s",str1+1,str2+1);
	for(int i=1;i<=len;i++){
		if(check(i)) maxn=max(maxn,i);
	}printf("%d\n",2*len-maxn);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("-1"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define bn(x) ((1<<x)-1)
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 200005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;

// Mod int
const int mod = 1000000007;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
typedef vector<mint> vm;
//



int main() {
  int n,k;
  scanf("%d%d",&n,&k);
  vm dp(1,1);
  for (int i = n; i >= 1; --i) {
    int m = sz(dp);
    vm p(m+(m-1+k)/i); swap(dp,p);
    rep(j,m)rep(s,k+1) {
      if (s > i) dp[j] += p[j];
      else dp[j+(j+s)/i] += p[j];
    }
  }
  mint sum = 0;
  rep(i,sz(dp)) sum += dp[i]*i;
  mint ans = k*(k+1)/2;
  rep(i,n-1) ans *= k+1;
  ans *= n;
  ans -= sum;
  cout<<ans<<endl;
  return 0;
}






















Measured memory_bytes: 384
#include <stdio.h>
#include <math.h>

int main(void)
{
    int n,i,t,x[100],y[100];

    double d1=0,d2=0,d3=0,di=0;
    scanf("%d",&n);

    for(i=0;i<n;i++){
        scanf("%d",&x[i]);
    }

    for(i=0;i<n;i++){
        scanf("%d",&y[i]);
    }

    for(i=0;i<n;i++){
        t=x[i]-y[i];
        if(t<0)
            t=-t;
        d1+=t;
        d2+=t*t;
        d3+=t*t*t;
        if(di<t) di=t;
    }

    d2=pow(d2,1./2);
    d3=pow(d3,1./3);

    printf("%.6f\n%.6f\n%.6f\n%.6f\n",d1,d2,d3,di);
    return 0;
}


Measured memory_bytes: 2056
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string s;
    cin >> s;
    string ans;
    if(s=="Sunny") ans="Cloudy";
    if(s=="Cloudy") ans="Rainy";
    if(s=="Rainy") ans ="Sunny";
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int n,amari,anx = 0;
    int cake = 4;
    int donut = 7;
    bool flag = false;
    cin >> n;
    for (int i = 0; i < 100; ++i) {
        for (int j = 0; j < 100; ++j) {
            anx = cake * j + donut * i;
            if (anx == n) {
                flag = true;
                break;
            }
        }
        if (anx == n)break;
    }
    if (flag == true){
        cout  <<"Yes"  << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
g1=[1,3,5,7,8,10,12]
g2=[4,6,9,11]
g3=[2]

x, y =map(int,input().split())
if ((x in g1) and (y in g1)) or ((x in g2) and (y in g2)) or ((x in g3) and (y in g3)):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <math.h>
#include <bits/stdc++.h>
#include <queue>
#include <map>

using namespace std;

#define INF (1ll<<60)
#define INFint (1<<30)
#define MOD 1000000007
#define BOUND 27182818284

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

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

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

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

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

// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm( T m, T n ){
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;
    return ((m/gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}


int dx[5]={1,0,-1,0};
int dy[5]={0,1,0,-1};
// v.front() = -BOUND;
// v.back() = BOUND;

struct edge{
    int cost, to;

    edge(int in_cost, int in_to){
        cost=in_cost;
        to=in_to;
    }
    bool operator<(const edge &a) const
    {
        return cost > a.cost;
    }
};


int money[410][410];
bool used[410][410];
int main() {
    int N; cin>>N;
    vector<int>a(N),b(N),c(N);
    int Ma,Mb; cin>>Ma>>Mb;
    rep(i,N){
        cin >> a[i] >> b[i] >> c[i];
    }
    Fill(money, 1<<20);
    money[0][0]=0;
    for(int i=0; i<N; i++){

        Fill(used, false);
        for(int j=0; j<=400; j++){
            for(int k=0; k<=400; k++){
                if(j-a[i]>=0 && k-b[i]>=0){
                    if(!used[j-a[i]][k-b[i]] && (money[j][k] > money[j - a[i]][k - b[i]] + c[i])) {
                        money[j][k] = money[j - a[i]][k - b[i]] + c[i];
                        used[j][k]=true;
                    }
                }
            }
        }
    }

    int minimum=1<<20;
    for(int i=1; i<=400/max(Ma,Mb); i++){
        minimum=min(minimum, money[Ma*i][Mb*i]);
    }

    if(minimum==1<<20){
        cout << -1 << endl;
    }else{
        cout << minimum << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if x == 500*i + 100*j + 50*k:
                ans += 1
print(ans)

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

int main(){
    int N;
    string s;
    cin >> N;
    cin >> s;
    int red = 0, blue = 0;
    for (int i = 0; i < N; i++){
        if (s[i] == 'R'){
            red++;
        } else if (s[i] == 'B'){
            blue++;
        }
    }
    if (red > blue) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#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 FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_queue<int> pque;//これは大きい順
//typedef priority_queue<int, vector<int>, greater<int>> pque;//これは小さい順
//factorizeは、素因数分解用の関数

int main(){
	int n;
	cin >> n;
	priority_queue<double,vector<double>,greater<double>> q;
	rep(i,n) {
		double v;
		cin >> v;
		q.push(v);
	}

	rep(i,n-1){
		double x = q.top();q.pop();
		double y = q.top();q.pop();
		double z = 1.0*(x+y)/2;
		q.push(z);
	}

	double ans=0;
	while(!q.empty()){
		ans += q.top();q.pop();
	}

	printf("%.10f",ans);
  return 0;
}


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

#define INF 100100100
#define MOD 1000000007

using namespace std;
using ll = long long;
using ull = unsigned long long ;
int main(int argc, char const* argv[]){
   ios::sync_with_stdio(false);
   cin.tie(0);

   int N;
   cin>>N;
   vector<ll>A(3*N);
   for(ll i=0;i<3*N;i++)cin>>A[i];
   sort(A.begin(),A.end());

   ull ans = 0;
   for(ll i=N;i<3*N;i++){
      if(i%2==3*N%2)ans+=A[i];
   }

   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 2560
n=int(input())
l=[[[0 for R in range(10)] for F in range(3)] for B in range(4)]
for N in range(n):
    b,f,r,v=map(int,input().split())
    l[b-1][f-1][r-1]+=v
for i in range(4):
    for j in range(3):
        for k in range(10):
            print(' ',l[i][j][k],sep='',end='')
        print()
    if i!=3:
        print('#'*20)


Measured memory_bytes: 5636
#include <stdio.h>
int main(void)
{
    int a, b, c, d;
    scanf("%d %d %d %d", &a, &b, &c, &d);
    while (1)
    {
        c = c - b;
        if (c <= 0)
        {
            printf("Yes\n");
            break;
        }
        a = a - d;
        if (a <= 0)
        {
            printf("No\n");
            break;
        }
    }
    return 0;
}

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

int main() {
    int n,m; cin>>n;
    vector<string> s(n);
    rep(i,n) cin >> s[i];
    cin>>m;
    vector<string> t(m);
    rep(i,m) cin >> t[i];
    
    int ans=0;
    rep(i,n) {
        int score=0;
        rep(j,n) {
            if(s[i]==s[j]) score++;
        }
        rep(j,m) {
            if(s[i]==t[j]) score--;
        }
        ans=max(score,ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  
  int n;
  cin >> n;
  int w[n];
  int min = 100000;
  int s1;
  int s2;
  for(int i=0;i<n;i++){
	cin >> w[i];
  }
  
  for(int i=0;i<n;i++){
    	for(int j=0;j<i;j++){
          	s1 += w[j];
        }
    	for(int h=i;h<n;h++){
          	s2 += w[h];
        }
    if(min >= abs(s1-s2)){
		min = abs(s1-s2);
    }
    s1 = 0;
    s2 = 0;
  }
  
 cout << min << endl; 
  
}

Measured memory_bytes: 256
from collections import deque

N = int(input())
G = [[] for i in range(N)]
for i in range(N-1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    G[u].append((v, w))
    G[v].append((u, w))


color = [-1 for i in range(N)]

q = deque([0])
color[0] = 0
flag = 1
while len(q) != 0:
    u = q.popleft()
    for v, w in G[u]:
        if color[v] != -1: #訪問済みの時
            if w % 2 == 1 and color[v] == color[u]:
                flag = 0
            continue
        if w % 2 == 0:
            color[v] = color[u]
            q.append(v)
        else:
            color[v] = 1 - color[u]
            q.append(v)

if flag:
    for i in range(N):
        print(color[i])

Measured memory_bytes: 39160
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
#define mkpr make_pair
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>;
using vc = vector<char>; using vvc = vector<vc>;
using vb = vector<bool>; using vvb = vector<vb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using psl = pair<string, ll>;


ll dfs(ll h) {
  if (h<=0) return 0;

  return dfs(h/2) * 2 + 1;
}

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


  ll H; cin>>H;
  
  ll ans = dfs(H);
  
  cout << ans << endl;


  return 0;
}

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

int n,m,ok[100005],h[100005],s,visit[100005];

inline int read(){
	int s=0,t=1;
	char c=getchar();
	while((c<'0'||c>'9')&&c!='-')c=getchar();
	if(c=='-')c=getchar(),t=-1;
	while(c>='0'&&c<='9')s=(s<<1)+(s<<3)+(c^48),c=getchar();
	return s*t;
}

int main(void){
	n=read();
	m=read();
	for(int i=1;i<=n;i++){
		h[i]=read();
	}
	for(int i=1;i<=m;i++){
		int x,y;
		x=read();
		y=read();
		visit[x]=visit[y]=1;
		if(h[x]>h[y]){
			if(ok[y]==0)s++;
			ok[y]=1;
		}
		else
		if(h[x]<h[y]){
			if(ok[x]==0)s++;
			ok[x]=1;
		}
		else{
			if(ok[x]==0)s++;
			ok[x]=1;
			if(ok[y]==0)s++;
			ok[y]=1;
		}		
	}
	printf("%d\n",n-s);
}

Measured memory_bytes: 2748
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    string S;
    cin >> S;
    
    // *KIH*B*R*
    vector<string> vec;
    vec.push_back("KIHBR");     // 0000
    vec.push_back("KIHBRA");    // 0001
    vec.push_back("KIHBAR");     // 0010
    vec.push_back("KIHBARA");     // 0011
    vec.push_back("KIHABR");     // 0100
    vec.push_back("KIHABRA");     // 0101
    vec.push_back("KIHABAR");     // 0110
    vec.push_back("KIHABARA");     // 0111
    vec.push_back("AKIHBR");     // 1000
    vec.push_back("AKIHBRA");    // 1001
    vec.push_back("AKIHBAR");     // 1010
    vec.push_back("AKIHBARA");     // 1011
    vec.push_back("AKIHABR");     // 1100
    vec.push_back("AKIHABRA");     // 1101
    vec.push_back("AKIHABAR");     // 1110
    vec.push_back("AKIHABARA");     // 1111

    for(int i=0;i<vec.size();i++){
        if(S == vec[i]){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;

}

Measured memory_bytes: 256
/*

*/
#include<iostream>
#include<iomanip>
#include<ios>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>
#include<cstdlib>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)
#define MAX_N 100000

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

const int INF = 1<<30;
const ll MOD = ll(1e9+7);

vector<int> edges[MAX_N];
int n;

bool dfs(vector<bool> &used, int v){
  if(v==n-1)return used[v]=true;
  for(auto &e: edges[v]){
    if(used[e])continue;
    used[e]=true;
    if(dfs(used, e))return true;
    used[e]=false;
  }
  return false;
}

int main(){
  cin>>n;
  rep(i, n-1){
    int a, b;cin>>a>>b;
    a--;b--;
    edges[a].push_back(b);
    edges[b].push_back(a);
  }
  vector<int> fennec(n, -1), snuke(n, -1);
  queue<P> que;
  que.push(P(0, 0));fennec[0]=0;
  while(que.size()){
    P p=que.front();que.pop();
    for(auto &e: edges[p.first]){
      if(fennec[e]!=-1)continue;
      fennec[e]=p.second+1;
      que.push(P(e, p.second+1));
    }
  }
  que.push(P(n-1, 0));snuke[n-1]=0;
  while(que.size()){
    P p=que.front();que.pop();
    for(auto &e: edges[p.first]){
      if(snuke[e]!=-1)continue;
      snuke[e]=p.second+1;
      que.push(P(e, p.second+1));
    }
  }
  int fcnt=0, scnt=0;
  rep(i, n){
    if(fennec[i]<=snuke[i])fcnt++;
    else scnt++;
  }
  cout<<(fcnt>scnt?"Fennec":"Snuke")<<endl;
  // system("read -n 1 -s -p \"Press any key to continue...\"");
}


Measured memory_bytes: 6784
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;

public class Main {

	static PrintWriter out;
	static InputReader ir;

	static void solve() {
		ir.nextInt();
		out.println((ir.nextInt()*2+ir.nextInt())%4==0?"YES":"NO");
	}

	public static void main(String[] args) throws Exception {
		ir = new InputReader(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.flush();
	}

	static class InputReader {

		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;

		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}

		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}

		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}

		public boolean hasNext() {
			skip();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

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

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

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

		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}
}


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

using ll = long long int;
constexpr int INF = 1<<30;

ll n ,k;
string s;

int dp[2005][2005];  // dp[l][r]: 文字列Sの区間[l,r]を部分列に含む回文の最小長さ
ll dp2[2005][2005];  // dp[l][r]: 文字列Sの区間[l,r]を部分列に含む最小長の回文の個数

// 回文の最小長さを求める [l,r]
int rec(int l, int r){
    if(l == r) return dp[l][r] = 1;
    if(l > r) return 0;
    if(dp[l][r] > 0) return dp[l][r];
    int res = INF;
    if(s[l] == s[r]) res = min(res, rec(l+1,r-1)+2);
    else{
        res = min(res, rec(l,r-1)+2);
        res = min(res, rec(l+1,r)+2);
    }
    return dp[l][r] = res;
}

// 回文の個数を数える [l,r]
ll rec2(int l, int r){
    if(l >= r) return dp2[l][r] = 1;
    if(dp2[l][r] >= 0) return dp2[l][r];
    ll res = 0;
    if(s[l] == s[r]){
        res += rec2(l+1,r-1);
    }else{
        if(dp[l][r] == dp[l][r-1]+2) res += rec2(l,r-1);
        if(dp[l][r] == dp[l+1][r]+2) res += rec2(l+1,r);
    }
    return dp2[l][r] = min(res, k+10);
}

// 辞書順でk番目を求める
string rec3(int l, int r, ll m){
    if(l == r) return s.substr(l,1);
    if(l > r) return "";
    string res;
    if(s[l] == s[r]){
        res = rec3(l+1,r-1, m);
        res.insert(res.begin(),s[l]);
        res.push_back(s[r]);
    }else{
        if(s[l] < s[r]){
            if(dp[l][r] != dp[l+1][r]+2 || dp2[l+1][r] <= m){
                res = rec3(l,r-1,m-(dp[l][r] != dp[l+1][r]+2 ? 0 : dp2[l+1][r]));
                res.insert(res.begin(),s[r]);
                res.push_back(s[r]);
            }else{
                res = rec3(l+1,r,m);
                res.insert(res.begin(),s[l]);
                res.push_back(s[l]);
            }
        }else{
            if(dp[l][r] != dp[l][r-1]+2 || dp2[l][r-1] <= m){
                res = rec3(l+1,r,m-(dp[l][r] != dp[l][r-1]+2 ? 0 : dp2[l][r-1]));
                res.insert(res.begin(),s[l]);
                res.push_back(s[l]);
            }else{
                res = rec3(l,r-1,m);
                res.insert(res.begin(),s[r]);
                res.push_back(s[r]);
            }
        }
    }
    return res;
}

int main(){
    cin >> s >> k;
    n = s.size();
    rec(0,n-1);
    for(int i=0;i<n;i++) fill(dp2[i], dp2[i]+n, -1);
    if(rec2(0,n-1) < k){
        cout << "NONE\n";
    }else{
        cout << rec3(0,n-1,k-1) << "\n";
    }
    return 0;
}


Measured memory_bytes: 48108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll x, k, d; cin >> x >> k >> d;
    ll cnt;
    x = abs(x);
    cnt = min(k, x/d);
    x -= d*cnt;// cout << x << "," << d-x << endl;
    if(cnt==k){
        //if(abs(x)<=d){cout << min(abs(x), abs(x-d));  return 0;}
        cout << x << endl; return 0;}
    else{
        k -= cnt;
        if(k%2==0){cout << abs(x) << endl; return 0;}
        else{cout << abs(x-d) << endl; return 0;}
    }
    return 0;
}

Measured memory_bytes: 3684
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  if(n&1){
    cout<<"No";
    return 0;
  }
  if(s.substr(0,n/2)==s.substr(n/2,n/2)){
    cout<<"Yes";
  }
  else{
    cout<<"No";
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define rep(i,n) for(int i=0;i<n;i++)
#define INF (1<<30)
#define LLINF (1LL<<60)
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
    string s,t;
    cin>>s>>t;
    rep(i,s.length()){
        if(s[i]!=t[i]){
            No;
            return 0;
        }
    }
    Yes;
    return 0;
}


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

string s[9];
int x,y,t;

bool R()
{
	if(x < 4 && s[y][x] == '1'){
		cout << 'R'; t = 0;
		x++; return true;
	}
	return false;
}

bool L()
{
	if(0 < x && s[y][x-1] == '1'){
		cout << 'L'; t = 2;
		x--; return true;
	}
	return false;
}

bool U()
{
	if(1 < y && s[y-1][x] == '1'){
		cout << 'U'; t = 3;
		y -= 2; return true;
	}
	return false;
}

bool D()
{
	if(y < 7 && s[y+1][x] == '1'){
		cout << 'D'; t = 1;
		y += 2; return true;
	}
	return false;
}

int main()
{
	bool (*move[])() = {U,R,D,L};
	for(int i = 0; i < 9; ++i){
		cin >> s[i];
	}
	cout << 'R'; x = 1;
	while(!(x == 0 &&y == 0)){
		for(int i =0; i < 4; ++i){
			if(move[(t+i)%4]())break;
		}
	}
	cout << endl;
}
	

Measured memory_bytes: 1176
import java.util.*;


import java.io.*;



public class Main 
{   
	
	static long dp[][];
	static long mod=1000000007;
	public static void main(String[] args) throws IOException 
	{ 
		 
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw=new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		StringTokenizer s=new StringTokenizer(br.readLine());
		int r=Integer.parseInt(s.nextToken());
		int c=Integer.parseInt(s.nextToken());
		char arr[][]=new char[r][c];
		for(int i=0;i<r;i++) {
			s=new StringTokenizer(br.readLine());
			String st=s.nextToken();
			for(int j=0;j<c;j++) {
				arr[i][j]=st.charAt(j);
			}
		}
//		for(int i=0;i<r;i++) {
//			
//			for(int j=0;j<c;j++) {
//				System.out.print(arr[i][j]+" ");
//			}
//			System.out.println();
//		}
		dp=new long[r][c];
		for(int i=0;i<r;i++) {
			for(int j=0;j<c;j++)
				dp[i][j]=-1;
		}
		long ans=grid(arr,0,0,r,c)%mod;
		pw.println(ans);
		
		pw.close();
	}
	private static long grid(char[][] arr, int i, int j, int r, int c) {
		// TODO Auto-generated method stub
		if(i==r-1 && j==c-1) {
			
			return 1;
		}
		
		
		if(i>=r || j>=c || arr[i][j]=='#')
			return 0;
		
		if(dp[i][j]!=-1)
			return dp[i][j];
		
		long op1=grid(arr,i+1, j, r, c);
		long op2=grid(arr,i, j+1, r, c);
		
		return dp[i][j]= (op1+op2)%mod;
	}
	
	
	
	
}

Measured memory_bytes: 38164