akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

bitset<11> bs;

bool solve(string s, int a, int b)
{
    if(s[a] == '-')
        return !solve(s, a+1, b);

    if(a == b){
        if(s[a] == 'T')
            return true;
        else if(s[a] == 'F')
            return false;
        else
            return bs[s[a] - 'a'];
    }

    int i = a+1;
    int bracket = 0;
    while(bracket != 0 || (s[i] != '*' && s[i] != '+' && s.substr(i, 2) != "->")){
        if(s[i] == '(')
            ++ bracket;
        else if(s[i] == ')')
            -- bracket;
        ++ i;
    }

    if(s[i] == '*')
        return solve(s, a+1, i-1) && solve(s, i+1, b-1);
    else if(s[i] == '+')
        return solve(s, a+1, i-1) || solve(s, i+1, b-1);
    else
        return !solve(s, a+1, i-1) || solve(s, i+2, b-1);
}

int main()
{
    for(;;){
        string s;
        cin >> s;
        if(s == "#")
            return 0;

        int j = s.find('=');
        bool ret = true;
        for(int i=0; i<(1<<11); ++i){
            bs = i;
            if(solve(s, 0, j-1) != solve(s, j+1, s.size()-1))
                ret = false;
        }

        if(ret)
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
}

Measured memory_bytes: 2008
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int a;
    cin >> a;
    vint x(n);
    REP(i,n){
        cin >> x[i];
    }
    ll ans = 0;
    vvll dp(2501,vll(n+1,0LL));
    dp[0][0]=1LL;
    REP(i,n){
        for(int j=2500;j>=x[i];--j){
            for(int k=0;k<=i;k++){
                dp[j][k+1]+=dp[j-x[i]][k];    
            }
        }
    }
    for(int k=1;k<=n;k++){
        int t = a*k;
        //cout << dp[t][k] << endl;
        ans+=dp[t][k];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1280
a,b,k=map(int,input().split())
c=[]
if k<=b-a+1:
    for i in range(k):
        c.append(a+i)
    for i in range(b-k+1,b+1):
        c.append(i)
    c=set(c)
    c=list(c)
    c.sort()

    for i in range(len(c)):
        print(c[i])
else:
    for i in range(a,b+1):
        print(i)


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


void bubbleSort(int A[],int N)
{
	int count=0;
	bool flag = true;
	while(flag)
	{
		flag = false;
		for(int j=N-1;j>0;j--)
		{
			if(A[j]<A[j-1])
			{
				int swap;
				swap=A[j];
				A[j]=A[j-1];
				A[j-1]=swap;
				flag=true;
				count++;
			}
		}
	}
	for(int i=0;i<N;i++)
	{
		if(i>0)cout<<" ";
		cout<<A[i];
	}
	cout<<endl<<count<<endl;
}

int main()
{
	int N;cin>>N;
	int A[100];for(int i=0;i<N;i++)cin>>A[i];
	bubbleSort(A,N);
	return 0;
}


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

int main(){
	
	int n,cnt{}; cin>>n;
	vector<int>l(n);
	for(int i=0; i<n; i++){
		int a; cin >> a;
		l.at(i)=a;
	}
	sort(l.begin(),l.end());
	for(int i=0; i<n; i++){
		for(int j=i+1; j<n; j++){
			auto it1 = upper_bound(l.begin()+j+1,l.end(),abs(l.at(i)-l.at(j)));
			auto it2 = lower_bound(l.begin()+j+1,l.end(),l.at(i)+l.at(j));
			cnt += it2 - it1;
		}
	}
	cout << cnt << endl;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
#define x first
#define y second
#define mp make_pair
#define pb push_back
template <typename TYPE> inline void chkmax(TYPE &x,TYPE y){x<y?x=y:0;}
template <typename TYPE> inline void chkmin(TYPE &x,TYPE y){y<x?x=y:0;}
template <typename TYPE> void readint(TYPE &x)
{
    x=0;int f=1;char c;
    for(c=getchar();!isdigit(c);c=getchar())if(c=='-')f=-1;
    for(;isdigit(c);c=getchar())x=x*10+c-'0';
    x*=f;
}
const int MAXN=191;

int n,m,a[MAXN][MAXN];
char str[MAXN];
int f[MAXN][MAXN][MAXN],laf[MAXN][MAXN][MAXN];

int main()
{
	#ifndef ONLINE_JUDGE
//	freopen("code.in","r",stdin);
//	freopen("code.out","w",stdout);
	#endif
	readint(n),readint(m);
	for(int i=1;i<=n;++i)
	{
		scanf("%s",str+1);
		for(int j=1;j<=m;++j)a[i][j]=(str[j]=='#');
	}
	for(int l=1;l<=m;++l)
		for(int r=1;r<=m;++r)
			f[n+1][l][r]=n+1;
	for(int i=n;i;--i)
		for(int l=1;l<=m;++l)
		{
			int sum=0;
			for(int r=l;r<=m;++r)
			{
				sum+=a[i][r];
				if(sum && sum<r-l+1)f[i][l][r]=0;
				else if(f[i+1][l][r] && a[i+1][l]==a[i][l])f[i][l][r]=f[i+1][l][r];
				else f[i][l][r]=i+1;
			}
		}
	memcpy(laf,f,sizeof(laf));
	if(f[1][1][m]>n)return 0*printf("%d\n",0);
	for(int res=1;;++res)
	{
		for(int i=1;i<=n;++i)
			for(int l=1;l<=m;++l)
				for(int r=l;r<=m;++r)
				{
					f[i][l][r]=laf[laf[i][l][r]][l][r];
					int L=l,R=r-1,mid,ans=r;
					while(L<=R)
					{
						mid=(L+R)>>1;
						if(laf[i][mid+1][r]>=laf[i][l][mid])ans=mid,R=mid-1;
						else L=mid+1;
					}
					chkmax(f[i][l][r],min(laf[i][l][ans],laf[i][ans+1][r]));
					chkmax(f[i][l][r],min(laf[i][l][ans-1],laf[i][ans][r]));
				}
		memcpy(laf,f,sizeof(laf));
		if(f[1][1][m]>n)return 0*printf("%d\n",res);
	}
	return 0;
}

Measured memory_bytes: 54400
#include<iostream>
using namespace std;
int main(){
	int N=0;
	cin>>N;
	for(int i=0;i<N;i++){
		int a=0;
		int k=0;
		int p=0;
		cin>>k>>p;
		a=k%p;
		if(a==0){
			a=p;
		}
		cout<<a<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    int n,r;cin >> n >> r;
    if (n>=10) cout << r << endl;
    else cout << 100*(10-n)+r << endl;
}


Measured memory_bytes: 256
import numpy as np

w = input()
anal = np.array([])

for i in range(ord('a'),ord('z')+1):
    anal = np.append(anal,w.count(chr(i)))
if np.all(anal % 2 == 0):
    #ans = np.sum(anal)
    print("Yes")
else:
    print("No")

Measured memory_bytes: 17816
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 20;
struct number
{
	int f,s;
}a[1<<MAXN];
int n;
int main()
{
	scanf("%d", &n);
	for(int i=0;i<1<<n;i++)
	{	
		int x;
		scanf("%d", &x);
		a[i].f=x; 
	}
	for(int j=0;j<n;j++)
		for(int i=0;i<1<<n;i++)
			if(i>>j & 1) 
			{
				int x=i^(1<<j); 
				number ans;
				ans.f=max(a[i].f,a[x].f); 
				if(a[i].f>a[x].f) 
					ans.s=max(a[i].s,a[x].f); 
				else
					ans.s=max(a[i].f,a[x].s);
				a[i]=ans;
			}
	int ans=0;
	for(int i=1;i<1<<n;i++)
	{
		ans=max(ans,a[i].f+a[i].s); 
		cout<<ans<<endl;
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 5712
package main

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

const mod = 1000000007

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

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

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

func main() {
	s := next()
	x := ""

	for i := 0; i < len(s); i++ {
		x += "x"
	}
	fmt.Println(x)
}

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

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

int main()
{
    unsigned long long m, n;
    cin >> m >> n;
    cout << mod_pow(m, n, 1000000007) << endl;
    return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int count = 0;
  for (int j = 1; j <= n; j++) {
  for (int i = 1; i <= m; i++) {
   int a = i/10;
   int b = i%10;
    if (a >= 2 && b >= 2 && a*b==j) {
      count++;
    }
  }
  }
  cout << count << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long int
#define fi first
#define se second
#define pub push_back
#define pi pair<int,int>
#define all(v) (v).begin(), (v).end()
#define rep(i, l, r) for(int i=(int)(l);i<(int)(r);i++)
#define repd(i, l, r) for (int i=(int)(l);i>=(int)(r);i--)
#define clrg(i, l, r) for(int i=(int)(l);i<(int)(r);i++)vis[i]=0,v[i].clear();
int power(int x, unsigned int y){int res = 1;while (y > 0){ if (y & 1){res = res*x;} y = y>>1;x = x*x;}return res;}
int powermod(int x, unsigned int y, int p){int res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1; x = (x*x) % p;}return res;}
#define print2d(mat,n,m){for(int i=0;i<(int)(n);i++){for(int j=0;j<(m);j++){cout<<mat[i][j]<<" ";}cout<< endl;}}
#define clr(a,x) memset(a,x,sizeof(a))
#define rr(v) for(auto &val:v)
#define print(v) for (const auto itr : v){cout<<itr<<' ';}cout<<"\n";
#define ln length()
#define sz size()
#define mod 1000000007
#define elif else if
int32_t main(){
   int n,m; cin>>n>>m;
   vector<int> v(n,-1);
   int ok=1;
   while(m--){
      int s,c; 
      cin>>s>>c;
      if(s==1 and c==0 and n>1)ok=0;
      if(v[s-1]!=c and v[s-1]!=-1)ok=0;
      v[s-1]=c;
   }
   if(v[0]==-1 and n>1)v[0]=1;
   if(ok)rep(i,0,n)cout<<(v[i]==-1?0:v[i]);
   else cout<<-1<<"\n";
   return 0;
}
/*
Edge cases? n=1? a[i]<=0?
long vs int? 1LL? 64bits?
Re-read problem. Is it as easy as it seems?
KEEP CORRECTING AND SUBMITTING!
*/


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);


int main(void)
{
    string s;
    ll n,k; cin>>n>>s>>k;
    rep(i,n) if(s[i]!=s[k-1]) s[i]='*';
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 3492
<?php
// D
fscanf(STDIN, '%d %d', $h, $w);
for ($i = 0; $i < $h; $i++) $a[] = array_map('intval', explode(' ', trim(fgets(STDIN))));
$moving = false;
$his = [];
for ($i = 0; $i < $h; $i++) {
    if ($i % 2 === 0) {
        $s = 0;
        $e = $w - 1;
        $p = 1;
    } else {
        $s = $w - 1;
        $e = 0;
        $p = -1;
    }
    for ($j = $s; $j != $e + $p; $j += $p) {
        if (!($a[$i][$j] & 1)) {
            if ($moving) {
                $his[] = implode(' ', [$pi + 1, $pj + 1, $i + 1, $j + 1]);
                list($pi, $pj) = [$i, $j];
            }
            continue;
        }
        if ($moving) {
            $his[] = implode(' ', [$pi + 1, $pj + 1, $i + 1, $j + 1]);
            $moving = false;
        } else {
            list($pi, $pj) = [$i, $j];
            $moving = true;
        }
    }
}
echo count($his) . PHP_EOL;
echo implode(PHP_EOL, $his);

Measured memory_bytes: 27124
#!/usr/bin/python3
# -*- coding:utf-8 -*-

import numpy
from math import floor

def main():
  A, B = map(int, input().split())
  A -= 1
  ans = 0
  for i in range(64):
    ca, cb = 0, 0
    if A >= 2**i:
      x = A - 2**i
      ca = (2**i) * (floor(x/(2**(i+1)))) + min(x % (2**(i+1)) + 1, 2**i)
    if B >= 2**i:
      x = B - 2**i
      cb =  (2**i) * (floor(x/(2**(i+1)))) + min(x % (2**(i+1)) + 1, 2**i)
    ans += (2**i) * ((cb - ca) % 2)
  print(ans)
  
if __name__=='__main__':
  main()



Measured memory_bytes: 18712
n = int(input())
l = list(input())
ans = 0
for i in range(1,n):
    a = set(l[:i])
    b = set(l[i:])
    count = 0
    for j in a:
        if  j in b:
            count += 1
    ans = max(ans,count)
print(ans)

Measured memory_bytes: 39280
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int d[]=new int [N];
		for(int i=0;i<N;i++) {
			d[i]=sc.nextInt();
		}
		int a=0;
		for(int i=0;i<N-1;i++) {
			for(int k=i+1;k<N;k++) {
				if((d[i]>0)&&(d[i]==d[k])){
					d[k]=0;
					a=a+1;
				}
			}
		}
		System.out.println(N-a);
	}
}

Measured memory_bytes: 23380
import java.util.*;
 
public class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	String S = sc.next();
    	int count = 0;
    	int keep = 0;
    	for (char c : S.toCharArray()) {
    		if (c == 'A' || c == 'C' || c == 'G' || c == 'T') {
    			count++;
    		} else {
    			if (keep < count) {
    				keep = count;
    			}
    			count = 0;
    		}
    	}
    	System.out.println(keep < count ? count : keep);
    }
}

Measured memory_bytes: 21844
//g++ -std=gnu++14 a.cpp
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main() {
  string S,T;
  cin >> S >> T;
  string ans = "";
  ans += T;
  ans += S;
  cout << ans << endl;
}


Measured memory_bytes: 256
/**
	If you only do what you can do, 
	You will never be more than you are now!
	----------------------------------------
	We must all suffer from one of two pains: the pain of discipline or the pain of regret. 
	The difference is discipline weighs grams while regret weighs tons.
**/
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <iomanip>
#include <stack>
#include <queue>
#include <deque>

using namespace std;

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

#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define pb push_back
#define ppb pop_back
#define mkp make_pair
#define F first
#define S second
#define show(a) cerr << #a <<" -> "<< a <<"\n"
#define fo(a, b, c, d) for(int (a) = (b); (a) <= (c); (a) += (d))
#define foo(a, b, c ,d) for(int (a) = (b); (a) >= (c); (a) -= (d))
//#define int ll

const int N = 3e5;
const int INF = 1e9;

int n, q;
vector <int> g[N];
int ans[N];

void dfs(int v, int pr, int val) {
	ans[v] += val;
	for(int to : g[v]) {
		if(to != pr) {
			dfs(to, v, ans[v]);
		}
	}
}

int main () {
	ios_base::sync_with_stdio(false);
	cin >> n >> q;
	fo(i, 1, n - 1, 1) {
		int a, b;
		cin >> a >> b;
		g[a].pb(b);
		g[b].pb(a);
	}	
	fo(i, 1, q, 1) {
		int p, x;
		cin >> p >> x;
		ans[p] += x;
	}
	dfs(1, -1, 0);
	fo(i, 1, n, 1)
		cout << ans[i] <<' ';
	return 0;
}

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

using namespace std;

main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	string s;
	cin >> s;
	
	int n = s.size();
	
	s = ' ' + s;
	
	int res = 0;
	
	for(int l = 1, r = n; l < r; l++, r--)
		if(s[l] != s[r])
			res++;
	
	cout << res;
}

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

int main(void){
  int n,k;
  cin >> n >> k;
  int x[n+10];
  for(int i=0;i<n;i++) cin >> x[i];
  int total=0;
  for(int i=0;i<n;i++){
    int m = min(x[i],k-x[i]);
    total+=m*2;
  }
  cout << total << endl;
  return 0;
}


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

using namespace std;

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

#define sz(c) int((c).size())
#define all(c) (c).begin(), (c).end()
#define pb push_back

#define INF int(1e9)
#define EPS 1e-9
#define MOD int(1e9 + 7)

inline bool odd(int n) {
	int cnt = 0;
	while(n > 0) {
		cnt++;
		n /= 10;
	}
	return cnt % 2 == 1;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	int cnt = 0;
	for(int i = 1; i <= n; i++) {
		if(odd(i)) {
			cnt++;
		}
	}
	cout << cnt << '\n';
	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int a , b, c, d,x,y,z;

    scanf("%d %d %d %d", &a, &b, &c, &d);

    if(a > c)
        z = a - c;
    else
        z = c - a;
    if(a > b)
       x = a - b;
    else
        x = b - a;
    if(b > c)
        y = (b - c);
    else
        y = c - b;


    if(z <= d || (x <= d && y<= d))
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  for (int i = 0; i < 30; i++) {
    for (int j = 0; j < 20; j++) {
      if (i * 4 + j * 7 == N) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
typedef long long ll;
typedef long l;

int main(void){
  // ll i;
  ll ans;
  ll c_c, d_c, cd_c;//c,d,cdの最小公倍数の倍数
  ll count;//cまたはdの倍数
  ll a, b;
  l c, d;
  ll cd;//ｃｄの最小公倍数
  ll r;//あまり
  l t;

  scanf("%lld %lld %ld %ld", &a,&b,&c,&d);

  cd=c*d;

  //cの倍数
  r=a%c;
  c_c=((b-a)+r)/c;
  if(r==0) c_c++;
  r=a%d;
  d_c=((b-a)+r)/d;
  if(r==0) d_c++;

  // for(i=max2(c, d); i<=c*d; i++){
  //   if(i%c==0 && i%d==0){
  //     cd=i;
  //     break;
  //   }
  // }
  if(c<d){
    t=d;
    d=c;
    c=t;
  }

  t=c%d;
  while(t!=0){
    c=d;
    d=t;
    t=c%d;
  }

  cd=cd/d;
  //cdの個数
  r=a%cd;
  cd_c=((b-a)+r)/cd;
  if(r==0) cd_c++;


  // printf("c=%lld d=%lld cd=%lld\n", c_c, d_c, cd_c);
  count=c_c+d_c-cd_c;
  ans=(b-a+1)-count;

  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 128
// AOJ ITP 1_5_A
#include<cstdio>
#define rep(i,a) for( int i = 0; i != (a); ++i )

int main()
{
	int H, W;
	
	while( scanf( "%d%d", &H, &W ), H|W )
	{
		rep( i, H )
		{
			rep( j, W )
				putchar( '#' );
			puts("");
		}
		puts("");
	}

	return 0;
}

Measured memory_bytes: 1016
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
using namespace std;

long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; }return x; }
long lcm(long x, long y) { return(x / gcd(x, y)) * y; }
void indexsort(long* first, long* last ,long* func) { sort(first, last, [&](long a, long b) {return func[a] < func[b]; }); }
//--------------------

int main() {

	long N, M; cin >> N >> M;
	long P[100009], Y[100009]; for (int i = 1; i <= M; i++) cin >> P[i] >> Y[i];
	string res[100009]; //M
	long index[100009], Tindex[100009]; for (int i = 1; i <= M; i++) { index[i] = i; Tindex[i] = i; }
	
	//改良。Y[i]を1000000未満にする。

	indexsort(Tindex + 1,Tindex + M + 1,Y);

	for (int i = 1; i <= M; i++) Y[Tindex[i]] = i;

	//自然数列indexをT[i]が昇順になるようにソートする。
	for (int i = 1; i <= M; i++) Y[i] = 1000000 * P[i] + Y[i]; //出力の原型。

	indexsort(index + 1, index + M + 1, Y);

	long x = 1; //下六ケタ
	
	for (int i = 1; i <= M; i++) {//年からIDへ
		Y[index[i]] -= (Y[index[i]] % 1000000);
		Y[index[i]] += x;
		x++;
		if (i == M) break;
		if (Y[index[i]] / 1000000 != Y[index[i + 1]] / 1000000) x = 1;

	}

	for (int i = 1; i <= M; i++) { //成型
		res[i] = to_string(Y[i]);

		while (res[i].length() != 12) {
			res[i] = "0" + res[i];
		}

	}

	for (int i = 1; i <= M; i++) cout << res[i] << endl;

}

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

int main() {
    string line;
    cin >> line;
    string a, b;
    for (int i =0 ;i < (line.size()); i+=2) {
        a = line.substr(i, 2);
        if(a!="hi") {
            cout << "No" << endl;
            return 0;
        }
    }
       cout << "Yes" << endl;
       return 0;
}

Measured memory_bytes: 256
n = int(input())
for i in range(1, 3501):
  for j in range(1, 3501):
    seed = 4 * i * j - n * i - n * j 
    if seed > 0:
      k = n * i * j / seed 
      if k % 1 == 0:
        print(i, j, int(k))
        exit()

Measured memory_bytes: 40668
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;

template <typename T, typename Add = std::plus<T>, typename Minus = std::minus<T>>
class CumulativeSum1D{
public:
  std::vector<T> data;
  const Add add;
  const Minus minus;
 
  CumulativeSum1D(const std::vector<T> &v, const T &e = 0, const Add &add = Add(), const Minus &minus = Minus()):
    add(add), minus(minus)
  {
    const int n = v.size();
    data.assign(n+1, e);
    for(int i = 0; i < n; ++i) data[i+1] = add(data[i], v[i]);
  }
 
  inline T sum(int i, int j) const { //[i,j)
    return minus(data[j], data[i]);
  }
};
 

int main(){
  LLI N, M;
  while(cin >> N >> M){
    vector<LLI> A(N); cin >> A;
    sort(ALL(A));

    auto c = CumulativeSum1D<LLI>(A);

    auto f =
      [&](LLI x){
        LLI c = 0;

        REP(i,N){
          int k = lower_bound(ALL(A), x-A[i]) - A.begin();
          c += N-k;
        }
        
        return c;        
      };
    

    LLI lb = 0, ub = 300000;
    while(abs(lb-ub) > 1){
      auto mid = (lb + ub) / 2;

      if(f(mid) >= M){
        lb = mid;
      }else{
        ub = mid;
      }
    }

    dump(lb);
    LLI x = lb;

    LLI ans = 0;

    REP(i,N){
      int k = lower_bound(ALL(A), x-A[i]) - A.begin();
      ans += c.sum(k, N) + A[i] * (N - k);
    }

    ans -= (f(x) - M) * x;

    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 1792
a, b = map(int, input().split())
A = []
for i in range(a):
    array = list(map(int, input().split()))
    A.append(array)
A.sort()
ans = 0
buy = 0
for i in A:
    buy = min(b, i[1])
    ans += i[0]*buy
    b -= buy
    if b == 0:
        break
print(ans)

Measured memory_bytes: 27760
#include<bits/stdc++.h>
using namespace std;
#define  vi vector<long long int>
#define  set1 set<long long int>
#define  pb push_back
#define  map1 map<long long int,long long int>
#define  ll    long long int
#define  mp make_pair
#define  inf 1e17
#define  minf INT_MIN
#define  setbits(x) __builtin_popcountll(x)
#define  pres(x,y) fixed<<setprecision(y)<<x
#define  pair1 pair<long long int,long long int>
#define  mk(arr,n,type) type *arr=new type[n];
#define  mod 1000000007
#define  pi  3.1415926535897932384626433832
#define  ins insert
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
//find_by_order() --> returns an iterator to the k-th largest element (counting from zero)
//order_of_key()  --> the number of items in a set that are strictly smaller than our item.
#define  w(t) long long int t;t=1;while(t--)

void solve() {

	string a, b;
	cin >> a >> b;
	ll n = a.length(), m = b.length();

	ll dp[n + 1][m + 1];
	memset(dp, 0, sizeof(dp));

	for (ll i = 1; i <= n; i++) {
		for (ll j = 1; j <= m; j++) {
			if (a[i - 1] == b[j - 1]) {
				dp[i][j] = 1 + dp[i - 1][j - 1];
			}
			else {
				dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);

			}
		}
	}

	vector<char> v;

	ll i = n, j = m;
	while (i >= 1 && j >= 1) {
		if (a[i - 1] == b[j - 1]) {
			v.pb(char(a[i - 1]));
			i--;
			j--;
		}
		else {

			if (dp[i - 1][j] >= dp[i][j - 1]) {
				i--;
			}
			else {
				j--;
			}

		}
	}
	reverse(v.begin(), v.end());
	for (auto x : v) {
		cout << char(x);
	}


}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("inp.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	w(t) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 73948
#include <stdio.h>

int main(){
  int n,a[100],i,j,count=0,x,min;
  scanf("%d",&n);
 
  for(i=0;i<n;i++) scanf("%d",&a[i]);
 for(j=0;j<n;j++){
   min=j;   
for(i=j;i<n;i++){
     if(a[i]<a[min])
       min=i;
	
}   
 if(min!=j){
x=a[j];
	 a[j]=a[min];
  a[min]=x;
count++;
 }
}
for(i=0;i<n-1;i++) printf("%d ",a[i]);
 printf("%d\n",a[n-1]);
printf("%d\n",count);
return 0;
}

Measured memory_bytes: 600
n = int(input())

# maxH - |Cx - x| - |Cy - y| = H
# maxH = H + |Cx - x| + |Cy - y|

xyh = []
for i in range(n):
    px, py, h = list(map(int, input().split()))
    d = {
        'px': px,
        'py': py,
        'h': h
    }
    xyh.append(d)

# 高さ0でない情報を探す
t = {}
for d in xyh:
    if d['h'] >= 1:
        t = d
        break

# 全座標を探索
for cx in range(101):
    for cy in range(101):
        # 仮決めした中心座標で頂点の高さを出す
        max_h = (
            abs(t['px'] - cx) + abs(t['py'] - cy) + t['h']
        )
        # 全ての条件でこの頂点が適切かチェック
        is_ok = True
        for d in xyh:
            if d['h'] != max(
                max_h - abs(d['px'] - cx) - abs(d['py'] - cy), 0
            ):
                is_ok = False
                break
        if is_ok:
            print(cx, cy, max_h)

Measured memory_bytes: 3064
#include<iostream>

int comparingDice(int dice3, int dice4, int dice5, int dice6, int dice2_1, int dice2_2, int dice2_3, int dice2_4, int dice2_5, int dice2_6, int diceTopFace, int diceFront);
void goNorth(int& dice2_1, int& dice2_2, int& dice2_3, int& dice2_4, int& dice2_5, int& dice2_6);
void goEast(int& dice2_1, int& dice2_2, int& dice2_3, int& dice2_4, int& dice2_5, int& dice2_6);

int main(){

	int dice1;
	int dice2;
	int dice3;
	int dice4;
	int dice5;
	int dice6;

	int dice2_1;
	int dice2_2;
	int dice2_3;
	int dice2_4;
	int dice2_5;
	int dice2_6;

	std::cin >> dice1 >> dice2 >> dice3 >> dice4 >> dice5 >> dice6;
	std::cin >> dice2_1 >> dice2_2 >> dice2_3 >> dice2_4 >> dice2_5 >> dice2_6;

	int diceTopFace = dice1;
	int diceFront = dice2;

	int ans;
	ans = comparingDice(dice3, dice4, dice5, dice6, dice2_1, dice2_2, dice2_3, dice2_4, dice2_5, dice2_6, diceTopFace, diceFront);
	
	bool isSame=false;

	if (ans == 1){
		isSame = true;
		
	}
	else{
		for (int i = 0; i < 77; ++i){
			char command[] = "NESNESNESNESENESNESNESNESNNESNESNESNESNNESNESNESNESNNESNESNESNESENESNESNESNES";
			if (command[i] == 'N'){
				goNorth(dice2_1, dice2_2, dice2_3, dice2_4, dice2_5, dice2_6);
			}
			else if (command[i] == 'E'){
				goEast(dice2_1, dice2_2, dice2_3, dice2_4, dice2_5, dice2_6);
			}
			else if (command[i] == 'S'){
				for (int j = 0; j < 3; ++j){
					goNorth(dice2_1, dice2_2, dice2_3, dice2_4, dice2_5, dice2_6);
				}
			}
			ans = comparingDice(dice3, dice4, dice5, dice6, dice2_1, dice2_2, dice2_3, dice2_4, dice2_5, dice2_6, diceTopFace, diceFront);
			if (ans == 1){
				isSame = true;
			}
		}
	}
	if (isSame == true){
		std::cout << "Yes" << std::endl;
	}
	else{
		std::cout << "No" << std::endl;
	}

	return 0;
}
int comparingDice(int dice3, int dice4, int dice5, int dice6, int dice2_1, int dice2_2, int dice2_3, int dice2_4, int dice2_5, int dice2_6, int diceTopFace, int diceFront){


	if (diceTopFace == dice2_1 && diceFront == dice2_2){
		
			if (dice3 == dice2_3&&dice4 == dice2_4&&dice5 == dice2_5&&dice6 == dice2_6){
				return 1;
			}
			else{
				return 0;
			}
	}
	else{
		return 0;
	}
}

void goNorth(int& dice2_1, int& dice2_2, int& dice2_3, int& dice2_4, int& dice2_5, int& dice2_6){
	int tmp = dice2_1;
	dice2_1 = dice2_2;
	dice2_2 = dice2_6;
	dice2_6 = dice2_5;
	dice2_5 = tmp;
}
void goEast(int& dice2_1, int& dice2_2, int& dice2_3, int& dice2_4, int& dice2_5, int& dice2_6){
	int tmp = dice2_1;
	dice2_1 = dice2_4;
	dice2_4 = dice2_6;
	dice2_6 = dice2_3;
	dice2_3 = tmp;
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll n,a,m=1000000000000000000;
  cin>>n>>a;
  ll dp[n];
  dp[0]=a;
  for(int i=1;i<n;i++){
    cin>>a;
    dp[i]=dp[i-1]+a;
  }
  for(int i=0;i<n-1;i++){
    m=min(m,abs((dp[n-1]-dp[i])-dp[i]));
  }
  cout<<m;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int A,B,C,D;
    cin >> A;
    cin >> B;
    cin >> C;
    cin >> D;
    
    while(1){
        if(C-B <= 0) {
            cout << "Yes";
            break;
        }
        C = C-B;
        
        if(A-D <= 0) {
            cout << "No";
            break;
        }
        A = A-D;
    }
}


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

int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	string s;
	cin >> s;
	if (s[1] == 'R')
		s[1] = 'B';
	else
		s[1] = 'R';
	cout << s;
	return 0;

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,i,j,c;
  while(cin>>n,n!=0){
  int a[n][5],sum=0;;
  for(i=0;i<n;i++)for(j=0;j<5;j++)cin>>a[i][j];
    while(1){
      c=0;
      for(i=0;i<n;i++){
        if(a[i][0]!=0&&a[i][0]==a[i][1]&&a[i][1]==a[i][2]&&a[i][2]==a[i][3]&&a[i][3]==a[i][4]){
          sum+=a[i][0]*5;c++;
          a[i][0]=0;a[i][1]=0;a[i][2]=0;a[i][3]=0;a[i][4]=0;
        }
         if(a[i][0]!=0&&a[i][0]==a[i][1]&&a[i][1]==a[i][2]&&a[i][2]==a[i][3]){
          sum+=a[i][0]*4;c++;
          a[i][0]=0;a[i][1]=0;a[i][2]=0;a[i][3]=0;
        }
         if(a[i][4]!=0&&a[i][3]==a[i][4]&&a[i][1]==a[i][2]&&a[i][2]==a[i][3]){
          sum+=a[i][1]*4;c++;
          a[i][4]=0;a[i][1]=0;a[i][2]=0;a[i][3]=0;
        }
         if(a[i][2]!=0&&a[i][0]==a[i][1]&&a[i][1]==a[i][2]){
          sum+=a[i][0]*3;c++;
          a[i][0]=0;a[i][1]=0;a[i][2]=0;
        }
         if(a[i][2]!=0&&a[i][3]==a[i][1]&&a[i][1]==a[i][2]){
          sum+=a[i][1]*3;c++;
          a[i][3]=0;a[i][1]=0;a[i][2]=0;
        }
         if(a[i][2]!=0&&a[i][3]==a[i][4]&&a[i][3]==a[i][2]){
          sum+=a[i][2]*3;c++;
          a[i][3]=0;a[i][4]=0;a[i][2]=0;
        }
      }
      if(c==0)break;
      for(int h=0;h<n;h++)for(i=n-1;i>0;i--)for(j=0;j<5;j++){
        if(a[i][j]==0){
          a[i][j]=a[i-1][j];
          a[i-1][j]=0;
        }
      }    
    }
    cout<<sum<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
#define f2(i,j,k) for(int i=j;i>k;i--)
using namespace std;
int main(){
    long long a[3],n,ans=0;
    cin>>a[0]>>a[1]>>a[2]>>n;
    sort(a,a+3);
    f(i,0,n/a[0]+1){
        f(j,0,(n-a[0]*i)/a[1]+1){
            if((n-a[0]*i-a[1]*j)%a[2]==0){
                ans++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3556
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        string[] str = Console.ReadLine().Split(' ');
        int N = int.Parse(str[0]);
        int M = int.Parse(str[1]);
        int[] c = new int[N];
        for(int i=0;i<M;i++){
            str = Console.ReadLine().Split(' ');
            c[int.Parse(str[0])-1]++;
            c[int.Parse(str[1])-1]++;
        }
        for(int i=0;i<N;i++){
            sb.Append(c[i]+"\n");
        }
    }
}

Measured memory_bytes: 11092
from itertools import product

n, m = map(int, input().split())
masks = [0] * n
for i in range(m):
    _, *ss = map(int, input().split())
    for s in ss:
        masks[s - 1] |= 1 << i
init = int(''.join(input().strip().split())[::-1], base=2)

def gray(n):
    if n == 1:
        yield 0
    else:
        yield from gray(n-1)
        yield n - 1
        yield from gray(n-1)

v = init
cnt = int(not v)
for i in gray(n):
    v ^= masks[i]
    if not v:
        cnt += 1
print(cnt)


Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
    private static final BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

    public static void main(String[] args) {
        exec(args);
    }

    public static void exec(String[] args) {
        String str = readLineStandardInput();
        int N = Integer.parseInt(str);
        str = readLineStandardInput();
        String[] Astr = str.split(" ");
        int[] Ami = new int[N];
        for(int i = 0; i < Ami.length; i++){
            int tmp = Integer.parseInt(Astr[i]);
            Ami[i] = tmp - (i + 1);
        }
        Arrays.sort(Ami);
        int median = Ami[N / 2];
        long sum = 0;
        for(int i = 0; i < Ami.length; i++) {
            if(Ami[i] < median) {
                sum += median - Ami[i];
            }
            else {
                sum += Ami[i] - median;
            }
        }
        System.out.println(sum);
    }

    private static String readLineStandardInput() {
        String str;
        try {
            str = input.readLine();
        } catch(IOException e){
            str = null;
            System.out.println(e);
        }
        return str;
    }
}


Measured memory_bytes: 48596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using stkll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll x, y, z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
typedef long long ll;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define forn(i,a,b) for(int i=a;i<(int)b;i++)
int main()
{
    int n,m;
    cin>>n>>m;
    if(n==m)
    cout<<"Yes\n";
    else
    cout<<"No\n";
    return 0;
}

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

int main(){

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

if(a > b){
cout << "a > b" << endl;
}else if(a < b){
cout << "a < b" << endl;
}else{
cout << "a == b" << endl;
}

return 0;
}




Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
  cin>>n;int sum=0;
  int a[n];
  for(int i=0;i<n;i++)
  {
  cin>>a[i];
  }
  for(int i=0;i<n;i++)
  { for(int j=i+1;j<n;j++)
  { int k= a[i]*a[j];
    sum=sum+k; }
  }cout<<sum;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

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

	ans = a - b * 2;
	if (ans < 0) {
		ans = 0;
	}

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

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<bool> SUR(N);

  rep(i, N) SUR.at(i) = false;

  rep(i, K){
    int d;
    cin >> d;
    rep(j, d){
      int A;
      cin >> A;
      SUR.at(A-1) = true;
    }
  }

  int ans = 0;
  rep(i, N){
    if(SUR.at(i) == false) ans++;
  }

    cout << ans << endl;
}


Measured memory_bytes: 3628
package main

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

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	// Code for A - Biscuits
	var N, P int
	fmt.Scan(&N, &P)

	sc.Split(bufio.ScanWords)
	A := make([]int, N)
	var count int
	for i := 0; i < N; i++ {
		A[i] = nextInt()
		if A[i]%2 != 0 {
			count++
		}
	}

	if count == 0 {
		if P == 0 {
			fmt.Println(int(math.Pow(2, float64(N))))
		} else {
			fmt.Println("0")
		}
	} else {
		fmt.Println(int(math.Pow(2, float64(N-1))))
	}
}


Measured memory_bytes: 1844
## coding: UTF-8
#import random
A, B, N = map(int,input().split())
'''
A = random.randint(1, 10**4)
B = random.randint(1, 10**4)
N = random.randint(1, 10**4)
#A, B, N = 1041, 6612, 695
#print('A:{}, B:{}, N:{}'.format(A, B, N))
'''
'''
maxi = -1
for x in range(1, N+1):
    p = int(A*x/B)
    m = A * int(x/B)
    #print('x:{}, p:{}, m:{}, p-m:{}'.format(x, p, m, p-m))
    if(p-m>maxi):
        maxi = p-m
        max_index = x
print(max_index)
print(maxi)
'''

if(N>=B-1):
    x = B-1
else:
    x = N 

p = int(A*x/B)
m = A * int(x/B)
ans = p-m
print(ans)

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


class Piece {
public:
  string s;

  string getTurnR(int n) {
    string tmp = s;
    for(int i = 0; i < n; i++) {
      for(int j = 0; j < 4; j++) {
        tmp[j] = s[(j+3)%4];
      }
    }
    return tmp;
  }

  //n=0123:trdl
  char getS(int n) {
    return s[n];
  }
};

Piece p[9];
Piece now[3][3];
int pflag[9];
int num;

void rec1(int);
void rec2(int);

void rec1(int cnt) {
  static int d[4][2] = {{1,0},{2,1},{1,2},{0,1}};
  if(cnt == 4) {
    rec2(0);
    return;
  }
  for(int i = 0; i < 9; i++) {
    if(pflag[i] != 0) continue;
    pflag[i] = 1;
    Piece tp = p[i];
    for(int j = 0; j < 4; j++) {
      if(abs(now[1][1].getS(cnt)-tp.getS((cnt+2)%4)) == 32) {
	now[d[cnt][1]][d[cnt][0]] = tp;
	rec1(cnt+1);
      }
      tp.s = tp.getTurnR(1);
    }
    pflag[i] = 0;
  }
}

void rec2(int cnt) {
  static int d1[4][2] = {{1,0},{2,1},{1,2},{0,1}};
  static int d2[4][2] = {{2,0},{2,2},{0,2},{0,0}};
  if(cnt == 4) {
    num += 4;
    return;
  }

  for(int i = 0; i < 9; i++) {
    if(pflag[i] != 0) continue;
    pflag[i] = 1;
    Piece tp = p[i];
    for(int j = 0; j < 4; j++) {
      if(abs(now[d1[cnt][1]][d1[cnt][0]].getS((cnt+1)%4)
	     -tp.getS((cnt+3)%4)) == 32 &&
	 abs(now[d1[(cnt+1)%4][1]][d1[(cnt+1)%4][0]].getS(cnt)
	     -tp.getS((cnt+2)%4)) == 32) {
	now[d2[cnt][1]][d2[cnt][0]] = tp;
	rec2(cnt+1);
      }
      tp.s = tp.getTurnR(1);
    }
    pflag[i] = 0;
  }
}

int main() {
  int n;
  cin >> n;
  for(int t = 0; t < n; t++) {
    for(int i = 0; i < 9; i++) {
      cin >> p[i].s;
    }
    num = 0;
    for(int i = 0; i < 9; i++) {
      now[1][1] = p[i];
      fill(&pflag[0], &pflag[9], 0);
      pflag[i] = 1;
      rec1(0);
    }
    cout << num << endl;
  }
  return 0;
}

Measured memory_bytes: 928
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		while(true) {
			int a  = sc.nextInt();
			String op = sc.next();
			int b  = sc.nextInt();
			if(op.equals("?")) break;
			switch(op) {
			case "+":
				System.out.println(a + b);
				break;
			case "-":
				System.out.println(a - b);
				break;
			case "*":
				System.out.println(a * b);
				break;
			case "/":
				System.out.println(a / b);
				break;			
			}
		}
		sc.close();
	}	
}


Measured memory_bytes: 26332
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
ll a[10010], mod=1e9+7, b[10010];
ll pwr(ll x, ll e){
    if(e==0){
        return 1;
    }
    ll tmp=pwr(x, e/2);
    tmp=(tmp*tmp)%mod;
    if(e%2){
        tmp*=x;
        tmp%=mod;
    }
    return tmp;
}
int mp[1000010];
int main(){
    int n;
    while(cin>>n){
        ll ans=0;
        ll x=1;
        ll tmp=2, tmp1;
        for(int i=0; i<n; ++i){
            scanf("%lld",b+i);
            a[i]=b[i];
            tmp1=sqrt(a[i])+10;
            for(int j=2; j<tmp1; ++j){
                int tmp2=0;
                while(a[i]%j==0){
                    a[i]/=j;
                    ++tmp2;
                }
//                cout<<b[i]<<" "<<j<<" "<<tmp2<<" "<<a[i]<<endl;
                mp[j]=max(mp[j], tmp2);
            }
            if(a[i]>1){
                mp[a[i]]=max(mp[a[i]], 1);
            }
        }
        for(int i=2; i<1000010; ++i){
            x*=pwr(i, mp[i]);
            x%=mod;
        }
//        cout<<x<<endl;
        for(int i=0; i<n; ++i){
            ans+=x*pwr(b[i], mod-2);
            ans%=mod;
        }
        cout<<ans<<endl;
    }
  return 0;
}




Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;

int main(){
    int n;
    scanf("%d", &n);
    string s[n];
    rep(i, n) cin >> s[i];
    int cnt = 0;
    string t[n];
    rep(i, n){
        rep(j, n) t[j] = s[(i+j)%n];
        rep(j, n)rep(k, n){
            if(t[j][k] != t[k][j]) goto con;
        }
        ++cnt;
        con:
            continue;
    }
    printf("%d\n", cnt*n);
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

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

	ll n;
	vector<ll> v(3);
	cin >> n >> v[0] >> v[1] >> v[2];
	vector<string> str(n+1);
	REP(i, n)cin >> str[i];
	str[n] = "ABC";

	map<char, ll> mp;
	mp['A'] = 0, mp['B'] = 1, mp['C'] = 2;
	vector<char> ans;
	REP(i, n){
		ll a = mp[str[i][0]], b = mp[str[i][1]];
		ll na = mp[str[i+1][0]], nb = mp[str[i+1][1]];
		bool flag = true;
		v[a]++;v[b]--;
		if(v[a] < 0 || v[b] < 0)flag = false;
		if(i != n-1 && v[na] <= 0 && v[nb] <= 0)flag = false;
		if(flag){
			ans.EB(str[i][0]);
			continue;
		}
		v[a]--;v[b]++;

		flag = true;
		v[a]--;v[b]++;
		if(v[a] < 0 || v[b] < 0)flag = false;
		if(i != n-1 && v[na] <= 0 && v[nb] <= 0)flag = false;
		if(flag){
			ans.EB(str[i][1]);
			continue;
		}

		cout << "No" << endl;
		return 0;
	}

	cout << "Yes" << endl;
	REP(i, n)cout << ans[i] << endl;

	return 0;
}


Measured memory_bytes: 6692
#include <bits/stdc++.h>
#define FI first
#define SE second
#define PB push_back
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define co(i) cout<<(i)<<endl
#define fcout cout<<fixed<<setprecision(10)
#define uni(i) i.erase(unique(i.begin(), i.end()), i.end());
#define all(i) i.begin(),i.end()
using namespace std;

const int INF=1e9+7;
const int MOD=1e9+7;

int n,m;
string s;
vector<int> G[200001];
bool deleted[200001];
int num[2][200001];

void add_edge(int a,int b){
	a--; b--;
	G[a].PB(b);
	if(a!=b) G[b].PB(a);
}

void dfs(int k){
	if((num[0][k]==0||num[1][k]==0)&&(!deleted[k])){
		deleted[k]=true;
		FOR(i,0,G[k].size()){
			if(!deleted[G[k][i]]){
				num[s[k]-'A'][G[k][i]]--;
				dfs(G[k][i]);
			}
		}
	}
}

int main(){
	cin>>n>>m>>s;
	FOR(i,0,m){
		int a,b; cin>>a>>b;
		add_edge(a,b);
	}
	FOR(i,0,n){
		FOR(j,0,G[i].size()){
			num[s[G[i][j]]-'A'][i]++;
		}
	}
	FOR(i,0,n){
		dfs(i);
	}
	bool flag=false;
	FOR(i,0,n){
		if(!deleted[i]) flag=true;
	}
	Yes(flag);
}


Measured memory_bytes: 15492
/* In the name of Allah */
#include<bits/stdc++.h>
using namespace std;
 
const int N = 300 + 5;
double dp[N][N][N];
int n, a[3];
 
inline void readInput() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		int c;
		cin >> c;
		a[--c]++;
	}
}
 
inline void solve() {
	for (int len = 1; len <= n; len++)
		for (int i = len; ~i; i--)
			for (int j = len - i; ~j; j--) {
				int k = len - i - j;
				dp[i][j][k] += (i? dp[i - 1][j][k] * i / n: 0);
				dp[i][j][k] += (j? dp[i + 1][j - 1][k] * j / n: 0);
				dp[i][j][k] += (k? dp[i][j + 1][k - 1] * k / n: 0);
				++dp[i][j][k] *= 1. * n / (i + j + k);
			}
	cout << fixed << setprecision(10) << dp[a[0]][a[1]][a[2]] << endl;
}
 
int main() {
	ios:: sync_with_stdio(0), cin.tie(0), cout.tie(0);
	readInput(), solve();
	return 0;
}


Measured memory_bytes: 219392
N, K = map(int, input().split())
V = list(map(int, input().split()))

ans = 0
for i in range(K+1):
    for j in range(i+1):
        having = []
        having += V[:j]
        if j < i and i < N:
        	having += V[-(i-j):]
        having.sort()
        for k in range(K-i):
            if len(having) == 0: break
            if having[0] < 0:
                having.remove(having[0])
            else:
                break
        ans = max(sum(having), ans)

print(ans)


Measured memory_bytes: 3188