akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
#define REP(i, x, y) for(ll i = x; i < y; i++)
#define PER(i, x, y) for(ll i = x; i > y; i--)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

ll dp[2][2010][2010];

int main() {
    ll L, N;
    cin >> L >> N;
    ll X[N];
    REP(i, 0, N) {
        cin >> X[i];
    }
    ll sum[N + 1];
    sum[0] = 0;
    REP(i, 1, N + 1) {
        sum[i] = sum[i - 1] + X[i - 1];
    }
    ll invsum[N + 1];
    invsum[0] = 0;
    REP(i, 1, N + 1) {
        invsum[i] = invsum[i - 1] + (L - X[N - i]);
    }
    // REP(i, 0, N + 1) {
    //     cout << sum[i] << " ";
    // }
    // cout << endl;
    // REP(i, 0, N + 1) {
    //     cout << invsum[i] << " ";
    // }
    // cout << endl;
    ll ans = max(X[N - 1], L - X[0]);
    REP(i, 1, N) {
        ll suf = N - i;
        if (suf % 2 == 0) {
            ll lp = suf / 2;
            ll num = sum[lp + i] - sum[i - 1] + sum[lp + i - 1] - sum[i - 1] + invsum[lp] * 2;
            //cout << num << endl;
            ans = max(ans, num);
            num = invsum[lp + i] - invsum[i - 1] + invsum[lp + i - 1] - invsum[i - 1] + sum[lp] * 2;
            //cout << num << endl;
            ans = max(ans, num);
        } else {
            ll lp = suf / 2;
            ll num = (sum[lp + i] - sum[i - 1]) * 2 + invsum[lp + 1] + invsum[lp];
            //cout << num << endl;
            ans = max(ans, num);
            num = (invsum[lp + i] - invsum[i - 1]) * 2 + sum[lp + 1] + sum[lp];
            //cout << num << endl;
            ans = max(ans, num);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 4992
n = int(input())
fib = [0]*(n+1)
fib[0] = 1
fib[1] = 1

if n<=1:
  print(fib[n])
  exit()
for i in range(2,n+1):
    fib[i] = fib[i-1]+fib[i-2]

print(fib[n])



Measured memory_bytes: 5600
N = int(input())

group_sum = N if N % 2 == 1 else N + 1

ans = []
for i in range(1, N + 1):
    for j in range(i + 1, N + 1):
        if i + j != group_sum:
            ans.append([i, j])

print(len(ans))
for edge in ans:
    print(" ".join(map(str, edge)))


Measured memory_bytes: 41968
import java.util.Arrays;
import java.util.Scanner;

public class Main {

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

		int h = sc.nextInt();
		int w = sc.nextInt();

		char border[] = new char[w + 2];
		Arrays.fill(border, '#');

		System.out.println(border);
		for(int i = 0; i < h; i++){
			System.out.println('#'+sc.next()+'#');
		}
		System.out.println(border);
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<(n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) (s.substr(f-1,t-f+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
struct Grid{ll x,y,t;};
struct Edge{ll to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=201010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(ll from,ll to,ll cost){E[from].pb({to,cost});}
};
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  ll ans=2;
  for(int i=0;i<n;i++){
    ans=ans*2+2;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
import math
a,b=map(int,input().split())
left=math.ceil((a+b)/0.18)
right=math.floor((a+b+2)/0.18)
for i in range(left,right+1):
  if int(i*0.08)==a and int(i*0.1)==b:
    print(i)
    exit()
print(-1)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define maxn 505
using namespace std;
typedef long long ll;
int a[maxn][maxn];
inline int in()
{
    int res=0;
    char c=getchar();
    if (c>='0'&&c<='9') res=c-48;
    while((c=getchar())>='0'&&c<='9') res=res*10+c-48;
    return res;
}
int main()
{
    ios::sync_with_stdio(0); cin.tie(0);
    int n, m, q;
    n = in(), m = in(), q = in();
    while (m--){
        int l, r;
        l = in(), r = in();
        ++a[l][r];
    }
    for (int i = n; i >= 1; --i){
        for (int j = 1; j <= n; ++j){
            a[i][j] += a[i + 1][j] + a[i][j - 1] - a[i + 1][j - 1];
        }
    }
    while (q--){
        int l, r;
        l = in(), r = in();
        cout << a[l][r] << endl;
    }
    return 0;
}


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


int a, b;
int main(){
    while(cin >> a >> b, a || b){
        int c = b-a;
        int cnt1, cnt2, cnt3;
        cnt1 = cnt2 = cnt3 = 0;
        while(c/1000){
            c -= 1000;
            cnt1++;
        }
        while(c/500){
            c -= 500;
            cnt2++;
        }
        while(c/100){
            c -= 100;
            cnt3++;
        }
        cout << cnt3 << " " << cnt2 << " " << cnt1 << endl;
    }
    
}

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

int main(){
    int n;
    cin >> n;
    if(n<1000){
        cout << "ABC";
    }else{
        cout << "ABD";
    }
}

Measured memory_bytes: 256
using System;

namespace MinMaxandSum
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			//????°????
			int intMin = 0;
			//?????§???
			int intMax = 0;
			//????¨?
			double sum = 0;

			//1???????????\??????
			string n = Console.ReadLine ();
			int cnt = int.Parse (n); 

			//2???????????\??????
			string[] a = Console.ReadLine().Split(' ');

			//2????????§??\????????????1???????????????????°?????????\??????
			intMin = int.Parse(a[0]);
			//?????§?????????????°???????????????\??????
			intMax = intMin;
			//?????°???????????????
			sum += (double)intMin;

			//2????????\???
			for(int i = 1; i < cnt; i++){

				int intNum = int.Parse(a[i]);

				//????°???????????°???????
				if(intNum < intMin) {
					intMin = intNum;
				}
				//?????§???????????§??????
				if(intMax < intNum) {
					intMax = intNum;
				}
				//?????°???????????????
				sum += (double)intNum;	
			}
			Console.WriteLine(intMin + " " + intMax + " " + sum);
		}
	}
}

Measured memory_bytes: 19956
#include<iostream>

using namespace std;

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

char board[1000][1000];
int memo[1000][1000];

#define SOUTH 0
#define EAST  1

int main(){
  int h,w,n;
  while(scanf("%d%d%d",&h,&w,&n),h+w+n){
    REP(i,h) REP(j,w){
      scanf("%d",&board[i][j]);
    }

    memo[0][0] = n - 1;
    REP(i,h) REP(j,w){
      if(i == 0 && j == 0) continue;

      int tmp = 0;
      if(i != 0){
	int b =(int)board[i-1][j];
	if(b == SOUTH){
	  tmp += (memo[i-1][j]+1) / 2;
	}else{
	  tmp += memo[i-1][j] / 2;
	}
      }
      if(j != 0){
	int b =(int)board[i][j-1];
	if(b == EAST){
	  tmp += (memo[i][j-1]+1) / 2;
	}else{
	  tmp += memo[i][j-1] / 2;
	}
      }

      memo[i][j] = tmp;
    }

    int x = 0;
    int y = 0;

    while(x != w && y != h){
      int b = ((int)board[y][x] + memo[y][x]) % 2;
      if(b == SOUTH) ++y;
      else ++x;
    }

    printf("%d %d\n",y+1,x+1);
  }
}

Measured memory_bytes: 2720
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define rrep(i,n) for(int (i)=1;i<=(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define MOD 1000000007
#define INF 1e18
#define int long long
#define endl "\n"
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



signed main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
	
	int n;
	cin >> n;
	int ans[1000010];
	rrep(i, 105) {
		rrep(j, 105) {
			rrep(k, 105) {
				int val = i*i + j*j + k*k + i*j + j*k + k*i;
				if(val <= n) ans[val]++;
			}
		}
	}
	rrep(i, n) cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 3620
#include<iostream>
using namespace std;
int main(){
  int a,b,i,x,length=0, ans=0;
  cin>>a>>b;
  x=b-a;
  for(i=1; i<=x; i++){
    length+=i;
  }
  ans=length-b;
  cout<<ans<<endl;
  return 0;
}


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


//料金2次元配列
const int wh_data[7][7] =	{{0 , 300 , 500 , 600 , 700 , 1350 , 1650},
							{6 , 0 , 350 , 450 , 600 , 1150 , 1500},
							{13 , 7 , 0 , 250 , 400 , 1000 , 1350},
							{18 , 12 , 5 , 0 , 250 , 850 , 1300},
							{23 , 17 , 10 , 5 , 0 , 600 , 1150},
							{43 , 37 , 30 , 25 , 20 , 0 , 500},
							{58 , 52 , 45 , 40 , 35 , 15 , 0}};

//時間入力構造体
typedef struct struct_time_input
{
	int number;
	int h;
	int m;
}S_time_input;

//半額時間
typedef struct struct_price
{
	int price_start;
	int price_end;
}S_price;

int main(void)
{
	//安い時間を宣言
	const S_price s_price = {60 * 17 + 30 , 60 * 19 + 30};

	while (true)
	{
		//入力変数
		S_time_input s_start = {0};
		S_time_input s_end = {0};
		//金
		int money = 0;
		//距離
		int length = 0;

		cin >> s_start.number;
		if (s_start.number == 0)	{	return 0;	};
		cin >> s_start.h >> s_start.m;

		cin >> s_end.number >> s_end.h >> s_end.m;

		money = wh_data[s_start.number - 1][s_end.number - 1];
		length = wh_data[s_end.number - 1][s_start.number - 1];

		//まず距離が40km以内
		if (length <= 40)
		{
			//それぞれの時間を計測
			int start_time = s_start.h * 60 + s_start.m;
			int end_time = s_end.h * 60 + s_end.m;

			//まずは範囲内
			if (start_time <= s_price.price_end && end_time >= s_price.price_start)
			{
				//両方範囲から外れているのならOUT
				if (start_time < s_price.price_start && end_time > s_price.price_end)
				{
					;
				}
				else
				{
					money /= 2;
					if (money % 50 != 0)
					{
						int sa = 0;
						sa = money % 50;
						money -= sa;
						money += 50;
					}
				}
			}
		}

		cout << money << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<cstdio>

int sq[30];
int ind=0,n;

void solve(int sum, int m){
	if(sum==n){
		printf("%d",sq[0]);
		for(int i=1;i<ind;i++){
			printf(" %d",sq[i]);
		}
		printf("\n");
		return;
	}
	for(int i=m;i>=1;i--){
		if(sum+i<=n){
			sq[ind]=i;
			ind++;
			solve(sum+i,i);
			ind--;
		}
	}
	return;
}

int main(){
	while(scanf("%d",&n)){
		if(n==0)
		break;
		solve(0,n);
	}
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S, T;
const ll MOD = 998244353;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;
const ll MAX_N = 100010;
mat bit(2, vec(MAX_N,0));
ll sum(ll ifb, ll i){
    ll s = 0;
    while(i > 0){
        s += bit[ifb][i];
        i -= i & -i;
    }
    return s;
}
void add(ll ifb, ll i, ll x){
    while(i < MAX_N){
        bit[ifb][i] += x;
        i += i & -i;
    }
}
int main() {
    cin>>N;
    vec a(N), b(N), p(N);
    rep(i,N) cin>>A, p[i] = A;
    rep(i,N) a[i] = b[i] = i + 1;
    rep(i,N) add(0, p[i], i + 1), add(1, N - p[i] + 1, i + 1);
    rep(i,N){
        a[i] += sum(0, i + 1);
        b[i] += sum(1, i + 1);
        //cout<<sum(1, N - p[i])<<endl;
    }
    reverse(ALL(b));
    rep(i,N){
        cout<<a[i];
        i == N - 1 ? cout<<endl : cout<<' ';
    }
    rep(i,N){
        cout<<b[i];
        i == N - 1 ? cout<<endl : cout<<' ';
    }
}

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

using namespace std;
typedef long long ll;

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

    int p[n],q[n];
    int count=0,res=0;

    for(int i=0;i<n;i++){
        cin>>p[i]>>q[i];
        if(p[i]==q[i]){
            count++;
            if(count>=3) res=count;
        }
        else count=0;

    }

    if(res>=3) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

return 0;
}


Measured memory_bytes: 3636
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
##############################

W, a, b = map(int, input().split())
aw = a+W

if (aw <= b):
    print(b-aw)
elif a<=b and b < aw:
    print(0)
elif b <= a:
    print(a-(b+W))



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

int main() {
  string S;
  cin>>S;
  if(S[0]=='7' or S[1]=='7' or S[2]=='7'){
    cout<<"Yes";
  }
  else{
    cout<<"No";
  }
}


Measured memory_bytes: 3628
## coding: UTF-8
X, N = map(int,input().split())
if(N > 0):
    P = list(map(int,input().split()))
else:
    p = input()


fresh = [True] * 102 #0~101
if(N > 0):
    for i in range(N):
        fresh[P[i]] = False #1-index

#print(fresh)

min_diff = 1000
ans = 0
l = []

for i in range(102):
    if(fresh[i]):
        l.append(abs(X-i))
    else:
        l.append(10000)
print(l.index(min(l)))



'''
for i in range(100):
    if(fresh[i]):
        #fresh[i] == True -> i+1が使われていないことを示す
        diff = abs(X - (i+1))
        if(min_diff )
'''
    

Measured memory_bytes: 9204
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,b) FOR(i,0,b)
#define PB push_back
#define ALL(c) c.begin(),c.end()
using namespace std;
typedef long long LL;
typedef int ut;
typedef pair<ut,ut> pr;
typedef vector<ut> VI;
typedef vector<pr> Vpr;
const int SIZE=100;
Vpr ab;
int a[SIZE],b[SIZE];
int N,M,K;
int solve(int now,int able,int m){
	int ans=0;
	if(now==N) return m;
	if(able){
		int used=min(m,ab[now].second);
	    int getP=used*ab[now].first;
		ans=solve(now+1,able-1,m-used)+getP;
	//	cout << getP << endl;
	}
	return max(solve(now+1,able,m),ans);
}
int main(){
	
	cin >> N >> M >> K;
	REP(i,N){
		cin >> a[i];
	}
	REP(i,N){
		cin >> b[i];
	}
	REP(i,N){
		ab.PB(pr(a[i],b[i]));
	}
	sort(ALL(ab),greater<pr>());
	cout << solve(0,K,M) << endl;
	return 0;
}

Measured memory_bytes: 3096
n = gets.to_i
sum = 0;i = 1
while i <= n
  require "prime"
  a = Prime.prime_division(i)
  b = 1
  a.length.times do |j|
    b = b*(a[j][1]+1)
  end
  if b == 8
    sum += 1
  end
  i += 2
end
puts sum


Measured memory_bytes: 2044
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define INF 0x3f3f3f3f
using namespace std;
int n;
ll ans;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	vector<int> l(n+1,0),r(n+1,0);
	for (int i=1;i<=n;++i) cin>>l[i]>>r[i];
	sort(l.begin(),l.end());
	sort(r.begin(),r.end());
	reverse(l.begin(),l.end());
	for (int i=0;i<n;++i)
	{
		int d=l[i]-r[i];
		if (d<=0) break;
		ans+=2*d;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
multiset<int,greater<int> > S,T;
int n,tmp[1<<18];
int main(){
	scanf("%d",&n);
	for(int i=0,x;i<(1<<n);++i){
		scanf("%d",&x);
		S.insert(x);
	}
	T.insert(*S.begin());
	S.erase(S.begin());
	for(int i=0,t=0;i<n;++i){
		auto itr=S.begin();
		for(int x: T){
			while(itr!=S.end()&&*itr==x)++itr;
			if(itr==S.end())
				puts("No"),exit(0);
			tmp[t++]=*itr;
			itr=S.erase(itr);
		}
		if(i!=n-1)T.insert(tmp,tmp+t),t=0;
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 13056
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int  N =sc.nextInt();
    int L =sc.nextInt();
    int s =Math.max(1-L,1);
    int t =Math.min(s,N);
    int x =0;
    for(int i=1;i<=N;i++){
      if(i==t){continue;}
      else{x=x+L-1+i;}}
    System.out.println(x);
  }
}

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

int selectionSort(int A[], int N){
    int i, minj, j;
    int n = 0;
    for(i = 0; i < N; i++){
        minj = i;
        for(j = i; j < N; j++){
            if(A[j] < A[minj]){
                minj = j;
            }
        }
        swap(A[i],A[minj]);
        if(minj != i)n++;
    }
    return n;
}

void trace(int A[], int N){
    int i;
    for(i=0;i < N ;i++){
        if(i > 0) cout << " ";
        cout << A[i];
    }
    cout << endl;
}

int main(){
    int N, i;
    cin >> N;
    int A[100];
    for(i = 0; i < N; i++){
        cin >> A[i];
    }
    int n;
    n = selectionSort(A, N);
    trace(A, N);
    cout << n << endl;
    return 0;
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
int pow(int n)
{
    int ans=1;
    for(int i=0; i<3; i++)
    {
        ans *= n;
    }
    return ans;
}
int main()
{
    int n;
    cin >> n;
    cout << pow(n) <<endl;
}

Measured memory_bytes: 256
m = 10 ** 9 + 7
n = int(input())
s = input()

r = 1
for i in range(2, n + 1):
    r = (r * i) % m
p = 0
for i, c in enumerate(s):
    if int(c == 'W') == i % 2:
        p += 1
    else:
        r = (r * p) % m
        p -= 1
print(r if p == 0 else 0)


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

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int k;
  cin >> k;
  if(k % 2 == 0) cout << (k/2) * (k/2) << endl;
  else cout << (k/2) * ((k/2)+1) << endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
class P
{
    public static void Main()
    {
        Console.WriteLine(50);
        long n = long.Parse(Console.ReadLine());
        long[] a = new long[50];
        long baseNum = n / 50 + 49;
        long decr = n % 50;
        for (int i = 0; i < 50; i++)
        {
            if (i < decr)
            {
                a[i] = baseNum + 50 - decr + 1;
            }
            else
            {
                a[i] = baseNum - decr;
            }
        }
        Console.WriteLine(string.Join(" ", a));
    }
}


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

using namespace std;

void solve() {
  int64_t h, w;
  cin >> h >> w;

  if (h == 1 || w == 1) {
    cout << 1 << endl;
  } else {
    auto even_row = h / 2;
    auto odd_row = h - even_row;
    auto even_row_cnt = w / 2;
    auto odd_row_cnt = (w + 1) / 2;
    cout << (even_row * even_row_cnt + odd_row * odd_row_cnt) << endl;
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  solve();
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n,n2,n3,count=0,count2,number,number2,ans[100]={0};
	while(1){
		cin>>number>>number2;
		if(number==0&&number2==0){break;}
		for(n=1;n<=number;n++){
			for(n2=n+1;n2<=number;n2++){
				for(n3=n2+1;n3<=number;n3++){
					if((n+n2+n3)==number2){ans[count]++;}
				}
			}
		}
		count++;	
	}
	for(count2=0;count2<count;count2++){
		cout<<ans[count2]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
main(){
    int x,y,i,a;
    for(i = 0 ; 1 ; i++){
        scanf("%d%d",&x,&y);
        if(x == 0 && y == 0)break;

        if(x > y){
            a = x;
            x = y;
            y = a;
        }
        printf("%d %d\n",x,y);
    }







    return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<long,long>
#define INF 1000000000000000000
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; }
const long long MOD = 1000000007;
using namespace std;
typedef long long ll;
map<int, int> mp;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
class Union_Find {
private:
	vector<int> par;
	vector<int> rank;
public:
	Union_Find(int n) {
		rep(i, n) {
			par.push_back(i);
			rank.push_back(0);
		}
	}
	int find(int x) {
		if (par.at(x) == x) return x;
		else return par.at(x) = find(par.at(x));
	}
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return;
		if (rank.at(x) < rank.at(y)) {
			par.at(x) = y;
		}
		else {
			par.at(y) = x;
			if (rank.at(x) == rank.at(y)) rank.at(x)++;
		}
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
};

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	if (n == 1 && m == 1) {
		cout << 1 << endl;
	}
	else if (n == 1 && m != 1) {
		cout << m - 2 << endl;
	}
	else if (m != 1) {
		cout << (n - 2) * (m - 2) << endl;
	}
	else {
		cout << n - 2 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

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

    int res = 0;
    if (s[0] == '1') { res++; }
    if (s[1] == '1') { res++; }
    if (s[2] == '1') { res++; }

    cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n, count=0, a;
    cin >> n;
    deque<int> q;
    for(int i=0; i<n; i++) {
        cin >> a;
        count++;
        if(count%2==0) q.push_back(a);
        else q.push_front(a);
    }
    for(int i=0; i<n; i++) {
        if(count%2==0) {
            cout<< q.back() << " ";
            q.pop_back();    
        }
        else {
            cout<< q.front() << " ";
            q.pop_front();    
        }
    }
}  

Measured memory_bytes: 2944
// --https://kenkoooo.com/atcoder/#/table/soma62jp
#include <iostream>
#include <string>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstring>

#define	MOD	1000000007

using namespace std;

int main(int argc, char* argv[]) {

	int N;
	int cnt = 0;
	int ans = 0;
	string s;

	cin >> N;
	cin >> s;

	for (long i = 0; i < s.length(); i++) {
		if (s[i] == 'I') {
			cnt++;
		}else if (s[i] == 'D') {
			cnt--;
		}

		ans = max(ans,cnt);
	}

	cout << ans << endl;

	return 0;

}

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

typedef tuple<int,int,int> ti;

const int N = 100000; 
int arr[4][N]; 
int dp[N][4]; 
int n ; 

int find(int index, int type)
{     
    
	if( index == n ) return 0 ;

	if(dp[index][type] != -1 ) return dp[index][type];
    
    int res = 0; 
	
   	//cout << " okk " << endl; 
	for(int i = 1;  i <= 3 ; i ++)
	{
		if( i == type ) continue ;

		res = max(res, arr[i][index] + find(index+1,i));
	}

	return dp[index][type] = res; 
}


void solve()
{
       cin >> n ; 
       

       for(int i = 0 ; i < n ; i ++)
          for(int j = 1 ; j < 4 ; j ++)
             cin >> arr[j][i];
       
       for(int i =  0 ; i < n ; i ++)
          for(int j = 0 ; j < 4 ; j ++)
             dp[i][j] = -1; 
       
       cout << find(0,0) << endl; 


}

int main()
{

	 ios_base::sync_with_stdio(false);
	 cin.tie(NULL);

	
	 int t = 1 ; 
	 for(int i = 0 ; i < t ; i ++)
	 {
         solve(); 
	 }

	return 0;
}

Measured memory_bytes: 14192
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <fstream>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  int n;
  cin>>n;
  int a[n + 1];
  rep(i,n) cin>>a[i];
  a[n] = MOD;
  sort(a, a + n + 1);
  int ans = 0;
  if(n == 1) ans = 1;
  int tmp = 1;
  FOR(i, 0, n) {
    if(a[i + 1] == a[i]) {
      tmp++;
    } else {
      ans += tmp % 2;
      tmp = 1;
    }
  }
  cout << ans << endl;

  return 0;
}


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

int main(){
  map<string,int> p;
  int n;
  string s;
  cin >> n ;
  for (int i;i<n;i++){
    cin >> s;
    p[s] ++;
  }
  if (p.size() == 4) s = "Four";
  else s = "Three";
  cout << s << endl;  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string a;
int b;
int main()
{
    cin>>b>>a;
    for(int i=0;i<a.size();i++)
    {
        a[i]+=b;
        if(a[i]>'Z') a[i]-=26;
    }
    cout<<a;
    return 0;
}

Measured memory_bytes: 256
var n,i,t,c,o:longint;
a,b:array[0..100000]of longint;
begin
readln(n);
for i:=1 to n do
  begin
  read(t,c,o);
  if t<c+o then
    begin
    writeln('No');
    halt;
    end;
  if((t-c-o)mod 2=1)then
    begin
    writeln('No');
    halt;
    end;
  end;   writeln('Yes');
end.

Measured memory_bytes: 128
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
typedef long long ll;

int main() {
	int n, q; cin >> n >> q;
	fenwick_tree<ll> fw(n);
	for (int i = 0; i < n; ++i) {
		int x; cin >> x;
		fw.add(i, x);
	}
	for (int i = 0; i < q; ++i) {
		int a, b, c; cin >> a >> b >> c;
		if (a == 0) fw.add(b, c);
		else cout << fw.sum(b, c) << endl;
	}
	return 0;
}

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

int main() {

	 char s[4];

	cin >> s;

	if (s[0] == 'A'&& s[1] == 'A' && s[2] == 'A') cout << "No\n";
	else if (s[0] == 'B'&& s[1] == 'B' && s[2] == 'B') cout << "No\n";
	else cout << "Yes\n";

	return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n), cum(n + 1, 0);
    rep(i, n) cin >> a[i];
    rep(i, n) cum[i + 1] = cum[i] + a[i];

    ll res = 0;
    map<ll, ll> mp;
    rep(i, n + 1) mp[cum[i]]++;
    for (auto itr = mp.begin(); itr != mp.end(); itr++)
    {
        ll n = itr->second;
        res += n * (n - 1) / 2;
    }

    cout << res << '\n';
    return 0;
}


Measured memory_bytes: 18796
#include<bits/stdc++.h>
#define ll long long int
using namespace std;

const int mod=1e9+7;
int main()
{
	//#ifndef ONLINE_JUDGE
		//freopen("input.txt","r",stdin);
	//	freopen("output.txt","w",stdout);
	//#endif
	int n;
	cin>>n;
	vector<long double> in(n);
	for(int i=0;i<n;i++)
		cin>>in[i];
	vector<long double> dp(n+1);
	// dp[i] is the probability with i heads
	dp[0]=1;
	for(int i=0;i<n;i++)
	{	
		for(int j=i+1;j>=0;j--)
		{
			dp[j]=(j==0?0:dp[j-1]*in[i])+dp[j]*(1-in[i]);
		}
	}
	long double ans=0;
	for(int i=0;i<=n;i++)
	{
		if(i>n-i)
			ans+=dp[i];
	}
	cout<<setprecision(10)<<ans<<'\n';

	return 0;
}

Measured memory_bytes: 384
(* Vicfred
 * https://atcoder.jp/contests/abc148/tasks/abc148_b
 * string manipulation
 * *)
open Printf
open Scanf

let main =
    scanf"%d %s %s" (fun n s t ->
    for i = 0 to n-1 do
        printf "%c%c" s.[i] t.[i]
    done
    );
    printf "\n"
    


Measured memory_bytes: 3652
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    ll h, w;
    cin >> h >> w;
    if (h % 3 == 0 || w % 3 == 0) {
        cout << 0 << "\n";
        return 0;
    }
    ll ret = INF;
    for (int i = 1; i < h; ++i) {
        ll s1 = w * i;
        ll s2 = w * ((h - i) / 2);
        ll s3 = h * w - s1 - s2;
        ll temp = abs(s1 - s2);
        chmax(temp, abs(s2 - s3));
        chmax(temp, abs(s3 - s1));
        chmin(ret, temp);
    }
    for (int i = 1; i < h; ++i) {
        ll s1 = w * i;
        ll s2 = (w / 2) * (h - i);
        ll s3 = h * w - s1 - s2;
        ll temp = abs(s1 - s2);
        chmax(temp, abs(s2 - s3));
        chmax(temp, abs(s3 - s1));
        chmin(ret, temp);
    }
    for (int i = 1; i < w; ++i) {
        ll s1 = i * h;
        ll s2 = h * ((w - i) / 2);
        ll s3 = h * w - s1 - s2;
        ll temp = abs(s1 - s2);
        chmax(temp, abs(s2 - s3));
        chmax(temp, abs(s3 - s1));
        chmin(ret, temp);
    }
    for (int i = 1; i < w; ++i) {
        ll s1 = i * h;
        ll s2 = (h / 2) * (w - i);
        ll s3 = h * w - s1 - s2;
        ll temp = abs(s1 - s2);
        chmax(temp, abs(s2 - s3));
        chmax(temp, abs(s3 - s1));
        chmin(ret, temp);
    }
    cout << ret << "\n";
    return 0;
}

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

vector<int> sieve(int n) {
  vector<int> prime(n);
  for(int i=2; i<n; i++) prime[i]=i;
  for(int i=2; i*i<n; i++) {
    if(prime[i]) {
      for(int j=i*i; j<n; j+=i) prime[j]=0;
    }
  }
  prime.erase(remove(prime.begin(),prime.end(),0),prime.end());
  return prime;
}

int main() {
  vector<int> prime=sieve(1000000);
  int n;
  while(cin >> n && n!=0) {
    vector<int>::iterator it=prime.begin();
    int sum=0;
    for(int i=0; i<n; i++) {
      sum+=*it;
      it++;
    }
    cout << sum << endl;
  }
  return 0;
}


Measured memory_bytes: 4900
n = int(input())
p = list(map(int, input().split(" ")))
ccc = 0

for i in range(n-2):
    li = [p[i], p[i+1], p[i+2]]
    if (max(li) != li[1]) and (min(li) != li[1]):
        ccc += 1
        
print(ccc)

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

int main(){
  int N, tmpW, total=0,S1,res;
  scanf("%d\n",&N);
  vector<int> W;
  for(int i=0;i<N;i++){
    scanf("%d",&tmpW);
    W.push_back(tmpW);
    total+=tmpW;
  }
  
  S1=total;
  int j;
  for(j=0;j<N-1;j++){
    S1-=(W[j]+W[j]);
//    printf("%d %d\n",j,S1);
    if(S1<0)
      break;
  }
  res=min(abs(S1),S1+W[j]+W[j]);
  printf("%d\n",res);
  return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#define inf (int)(1e9 + 1)

int max(int a, int b){
	if(a > b){
		return a;
	}
	else{
		return b;
	}
}

int min(int a, int b){
	if(a < b){
		return a;
	}
	else{
		return b;
	}
}

typedef struct {
	int x;
	int y;
}pair;

#define datatype pair

int compare(datatype a, datatype b){
	if(a.y < b.y){
		return 1;
	}
	else if(a.y > b.y){
		return -1;
	}
	else{
		return 0;
	}
}

datatype *sort_sub(datatype *origin, int N){
	datatype *ans = (datatype *)malloc(sizeof(datatype) * N);
	if(N == 1){
		ans[0] = origin[0];
	}
	else{
		int N1 = N / 2;
		int N2 = (N + 1) / 2;
		datatype *sub1 = sort_sub(&origin[0] , N1);
		datatype *sub2 = sort_sub(&origin[N1], N2);
		int i, j, k;
		for(i = 0, j = 0, k = 0; i < N; i++){
			if((compare(sub1[j], sub2[k]) == 1 && j != N1) || (k == N2)){
				ans[i] = sub1[j];
				j++;
			}
			else{
				ans[i] = sub2[k];
				k++;
			}
		}
		free(sub1);
		free(sub2);
	}
	return ans;
}

datatype *sort(datatype *origin, int N){
	datatype *ans = sort_sub(origin, N);
	free(origin);
	return ans;
}

int main(){
	int N, i, tmp, xmax = 0, xmin = inf, ymax = 0, ymin = inf;
	scanf("%d", &N);
	pair *ball = (pair *)malloc(sizeof(pair) * N);
	for(i = 0; i < N; i++){
		scanf("%d%d", &ball[i].x, &ball[i].y);
		if(ball[i].x < ball[i].y){
			tmp = ball[i].x;
			ball[i].x = ball[i].y;
			ball[i].y = tmp;
		}
		if(ball[i].x > xmax){
			xmax = ball[i].x;
		}
		if(ball[i].x < xmin){
			xmin = ball[i].x;
		}
		if(ball[i].y > ymax){
			ymax = ball[i].y;
		}
		if(ball[i].y < ymin){
			ymin = ball[i].y;
		}
	}
	long long int ans1, ans2;
	ans1 = (long long int)(xmax - xmin) * (ymax - ymin);
	ball = sort(ball, N);
	int dy = ball[N - 1].y - ball[0].y, _ymax = ball[N - 1].y, _ymin = inf;
	for(i = 0; ball[i].y < _ymin && ball[i].x != xmax; i++){
		_ymax = max(ball[i].x, _ymax);
		_ymin = min(ball[i].x, _ymin);
		dy = min(_ymax - min(ball[i + 1].y, _ymin), dy);
	}
	ans2 = (long long int)(xmax - ymin) * dy;
	if(ans1 < ans2){
		printf("%lld\n", ans1);
	}
	else{
		printf("%lld\n", ans2);
	}
	return 0;
}

Measured memory_bytes: 5020
//
// Created by yamunaku on 2020/06/13.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main(){
    //CFS;
    string s;
    cin >> s;
    cout << s.substr(0, 3) << endl;
    return 0;
}

Measured memory_bytes: 3600
#include<cstdio>
#include<cstring>
using namespace std;
char c[100005];
int ans,len;
int main()
{
  scanf("%s",c);len=strlen(c);
  for(int i=1;i<len;i++)  if(c[i]!=c[i-1])  ans++;
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  int total;
  cin >> s;
  if (s[0] == '1') total++;
  if (s[1] == '1') total++;
  if (s[2] == '1') total++;
  
  cout << total << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long int min(long long int a, long long int b)
{
    return a<b?a:b;
}
long long int max(long long int a, long long int b)
{
    return a>b?a:b;
}
int main()
{
	long long int n,k,x,y,s=0;
	cin>>n>>k>>x>>y;
	cout<<min(n,k)*x + max(0,n-k)*y;
	return 0;
}

Measured memory_bytes: 256
/*
 _     _                             
| |__ | |__   __ _  __ _ _   _  __ _ 
| '_ \| '_ \ / _` |/ _` | | | |/ _` |
| |_) | | | | (_| | (_| | |_| | (_| |
|_.__/|_| |_|\__,_|\__, |\__, |\__,_|
                   |___/ |___/       
*/
#include<bits/stdc++.h>

#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define BigInt      __int128
#define endl        '\n'
#define mii         map<ll int,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define sim         template < class c
#define ris         return * this
#define dor         > debug & operator <<
#define eni(x)      sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {

using namespace std;

sim > struct rge {c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug 
{
	~debug() 
	{ 
		cerr<<endl; 
	}
	eni(!=) cerr << boolalpha << i; ris; }
	eni(==) ris << range(begin(i), end(i)); }
	sim, class b dor(pair < b, c > d) 
	{
		ris << "(" << d.first << ", " << d.second << ")";
	}
	sim dor(rge<c> d) 
	{
	  	*this << "[";
	  	for (auto it = d.b; it != d.e; ++it)
	    	*this << ", " + 2 * (it == d.b) << *it;
	  	ris << "]";
	}
};
#define fuck(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define N  100005

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{
		ll int n, d;
		ll int cnt = 0;
		cin >> n >> d;
		while(n--)
		{
			ll int x, y;
			cin >> x >> y;
			if(x * x + y * y <= d * d) cnt++;
		}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 3652
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let mut s=0;
    let mut m=0;
    for _ in 0..5{
        let a=read::<i32>();
        let t=(a+9)/10*10;
        s+=t;
        if m<t-a{m=t-a}
    }
    println!("{}",s-m);
}

Measured memory_bytes: 4352
from collections import defaultdict
N = int(input())
A = sorted(map(int, input().split()))
mod = 10 ** 9 + 7
if (N == 1 and A[0] != 0):
    print(0)
    exit()

d = defaultdict(int)
for i in range(N):
    if (N % 2 == 0):
        if (A[0] != 1):
            print(0)
            exit()
        else:
            if (d[A[i]] == 0):
                d[A[i]] = 1
            elif (d[A[i]] == 1):
                d[A[i]] += 1

    else:
        if (A[0] != 0):
            print(0)
            exit()
        else:
            if (d[A[i]] == 0):
                d[A[i]] = 1
            elif (d[A[i]] == 1):
                d[A[i]] += 1

for i, v in d.items():
    if not (N % 2 == 1 and i == 0):
        if v != 2:
            print(0)
            exit()

dic = sorted(d)
for i in range(len(dic)):
    if (i == len(dic) - 1):
        break
    if abs(dic[i] - dic[i + 1]) == 2:
        continue
    else:
        print(0)
        exit()

print((2 ** (N // 2)) % mod)


Measured memory_bytes: 93816
#include <fstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
using namespace std;

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

using ll = long long;
using vl = vector<ll>;
int main() {
#ifdef CIN_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(5);
	ll l, n;
	cin >> l >> n;
	vl x(n), w(n);
	REP(i, n) cin >> x[i] >> w[i];
	
	ll sum = 0;
	REP(i, n) sum += x[i] * w[i];
	if (sum == 0){
		cout << 0 << endl;
		return 0;
	}

	cout << 1 << endl;
	cout << (sum > 0 ? -1 : 1) << " " << abs(sum) << endl;

}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define lb(s,x) (lower_bound(all(s),x)-s.begin())
#define ub(s,x) (upper_bound(all(s),x)-s.begin())
#define uniq(a) a.erase(unique(all(a)),a.end())
#define bit(k) (1LL<<(k))
const int INF = 1e9;

#define debug(x) cerr<<(#x)<<": "<<(x)<<endl
template<class T,class U>
ostream& operator<<(ostream& o, const pair<T,U> &p){
    o<<"("<<p.first<<", "<<p.second<<")";
    return o;
}
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }


int main(void){
    int n,m;
    cin >> n >> m;
    map<ll, ll> mp;
    rep(i,n) {
        ll a;
        cin >> a;
        mp[a]++;
    }
    rep(i,m){
        ll b,c;
        cin >> b >> c;
        mp[c] += b;
    }
    ll sum = 0;
    for(auto itr = mp.rbegin(); itr != mp.rend(); ++itr) {
        ll num = itr->first;
        ll cnt = itr->second;
        if (cnt > n) {
            sum += num * n;
            break;
        }
        sum += num * cnt;
        n -= cnt;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 12800
#include<bits/stdc++.h>
#define LL long long
const int N=505;
using namespace std;

int a[N][N],u,v,n,m,q;

int main(){
	scanf("%d%d%d",&n,&m,&q);
	for(int i=1;i<=m;i++){
		scanf("%d%d",&u,&v);
		a[u][v]++;
	}
	for(int i=n;i>=1;i--){
		for(int j=i;j<=n;j++){
			a[i][j]+=a[i+1][j];
		}
	}
	while(q--){
		scanf("%d%d",&u,&v);
		int now=0;
		for(int i=u;i<=v;i++){
			now+=a[u][i];
		}
		printf("%d\n",now);
	}
	return 0;
}

Measured memory_bytes: 1920
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<complex>
#include<stack>
#include<cmath>

using namespace std;

#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)

int main(){
	int a,b,c;
	while(cin>>a>>b>>c){
		
		int used[11]={0};
		used[a]=1;
		used[b]=1;
		used[c]=1;
		
		int all = 7;
		int okcont = 0;
		
		reps(i,1,11){
			if(used[i]==0 && a+b+i<=20)okcont++;
		}
		
		if((double)okcont/all>=0.5)puts("YES");
		else puts("NO");
	}
}

Measured memory_bytes: 1108
#include <stdio.h>
int main(void){
    int n,min=1001,max=-1,i,tmp;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&tmp);
        if(tmp>=max){
            max=tmp;
        }
        if(tmp<=min){
            min=tmp;
        }
    }
    printf("%d\n",max-min);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

int main(){
  ll n,a,b;
  cin >> n  >> a >> b;
  ll ans=0;
  ans =(n-2)*(b-a)+1LL;
  cout << max(ans,0LL) << endl;
  



  return 0;

}


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



int main() {

	int A,B,C,D;
	cin >> A >> B >> C >> D;

	int n = 0;

	while (n != 1) {
		A -= D;
		C -= B;

		if (A <= 0 || C <= 0)
			n = 1;

	}

	if (C <= 0) {
		cout << "Yes";
	}
	else if (A <= 0) {
		cout << "No";
	}
	
}

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

using namespace std;

typedef long long ll;

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

int main() {
  int N;
  cin >> N;
  int res = 0;
  for (int i = 0; i < N; ++i) {
    int a;
    cin >> a;
    while (a % 2 == 0) a /= 2, res++;
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<array>

int main(){

    std::array<size_t, 26> ar = {};

    std::string s;
    while(std::cin){
        std::string tmp;
        std::getline(std::cin, tmp);
        s += tmp;
    }

    for(const auto& e : s){
        if(e >= 'A' && e <= 'Z'){
            ar[e - 'A']++;
        }else if(e >= 'a' && e <= 'z'){
            ar[e - 'a']++;
        }
    }

    for(size_t i = 0; i < ar.size(); i++){
        std::printf("%c : %zd\n", static_cast<char>('a' + i), ar[i]);
    }

    return 0;
}



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

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

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int MAX_N = 200010;
ll INF = 1LL<<60;
vector<vector<P>> edges(MAX_N);
vector<ll> dist(MAX_N,INF);

void dijkstra(int s) {
    priority_queue<P,vector<P>,greater<P>> que;
    dist[s] = 0;
    que.push(P(0,s));
    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v =  p.second;
        if (dist[v] < p.first) continue;
        for (int i = 0;i < edges[v].size();++i) {
            P e = edges[v][i];
            if (dist[e.first] > dist[v]+e.second) {
                dist[e.first] = dist[v]+e.second;
                que.push(P(dist[e.first],e.first));
            }
        }
    }
}

int main() {
    string s;
    cin >> s;
    int n = s.size();
    unordered_map<int,int> mp;
    mp.reserve(200010);
    int t = 0;
    mp[0] = 0;
    for (int i = 0;i < n;++i) {
        t ^= (1<<(s[i]-'a'));
        for (int j = 0;j < 26;++j) if (mp.find(t^(1<<j)) != mp.end()) {
            edges[mp[t^(1<<j)]].push_back((P(i+1,1)));
        }
        if (mp.find(t) != mp.end()) edges[mp[t]].push_back(P(i+1,0));
        mp[t] = i+1;
    }
    for (int i = 0;i < n;++i) if (edges[i].empty()) edges[i].push_back(P(i+1,1));
    dijkstra(0);
    cout << max(1LL,dist[n]) << endl;
    /*
    for (int i = 0;i < n;++i) {
        for (P p : edges[i]) cout << p.first << " ";
        cout << endl;
    }
    p_ary(dist,0,n+1,i);
    */
    return 0;
}

Measured memory_bytes: 67328
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(15); //"for float-base
  // problem"
  string T;
  cin >> T;
  bool N = false, W = false, E = false, S = false;
  bool X = false, Y = false;
  for (auto c : T) {
    if (c == 'N') {
      N = true;
      Y = true;
    } else if (c == 'S') {
      S = true;
      Y = true;
    } else if (c == 'W') {
      W = true;
      X = true;
    } else {
      E = true;
      X = true;
    }
  }
  if (Y)
    if (!N || !S) {
      cout << "No" << endl;
      return 0;
    }
  if (X)
    if (!E || !W) {
      cout << "No" << endl;
      return 0;
    }
  cout << "Yes" << endl;
}

Measured memory_bytes: 3612