akhauriyash/Code-Regression huggingface dataset:
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

const ll INF = 1LL << 50;

const ll mod = 1000000007;
ll fact[200200];
ll invfact[200200];

inline ll take_mod(ll a) { return (a % mod + mod) % mod; }

inline ll add(ll a, ll b) { return take_mod(a + b); }

inline ll sub(ll a, ll b) { return take_mod(a - b); }

inline ll mul(ll a, ll b) { return take_mod(a * b); }

inline ll pow(ll x, ll n) {
  ll res = 1LL;
  while (n > 0) {
    if (n & 1) res = mul(res, x);
    x = mul(x, x);
    n >>= 1;
  }
  return res;
}

ll mod_inv(ll x) { return pow(x, mod - 2); }

void make_fact(ll n) {
  fact[0] = 1;
  ll res = 1;
  for (int i = 1; i <= n; i++) {
    fact[i] = res;
    res = mul(res, i + 1);
  }
}

void make_invfact(ll n) {
  invfact[0] = 1;
  invfact[n] = mod_inv(fact[n]);
  for (int i = n - 1; i >= 1; i--) {
    invfact[i] = mul(invfact[i + 1], i + 1);
  }
}

ll perm(ll n, ll k) { return mul(fact[n], invfact[n - k]); }

ll comb(ll n, ll k) { return mul(mul(fact[n], invfact[n - k]), invfact[k]); }

int main() {
  ll n, a, b;
  cin >> n >> a >> b;

  ll ttn = pow(2LL, n);
  ll npa = 1LL;
  ll afc = 1LL;
  rep(i, a) {
    npa = mul(n - i, npa);
    afc = mul(a - i, afc);
  }
  ll afcinv = mod_inv(afc);
  ll nca = mul(npa, afcinv);

  ll npb = 1LL;
  ll bfc = 1LL;
  rep(i, b) {
    npb = mul(n - i, npb);
    bfc = mul(b - i, bfc);
  }
  ll bfcinv = mod_inv(bfc);
  ll ncb = mul(npb, bfcinv);

  ll ans = sub(ttn, 1LL);
  ans = sub(ans, nca);
  ans = sub(ans, ncb);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <string>
#include <utility>
using namespace std;
int mp[1010][1010] = {},ans[1010][1010],h,w;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,1,0,-1};
queue<pair<pair<int,int>,int>> que;
void bfs(){
	while(que.size()){
		pair<pair<int,int>,int> p = que.front();
		que.pop();
		int x = p.first.first,y = p.first.second,d = p.second,i;
		if(mp[x][y]==1 && d>=1) continue;
		mp[x][y]=1; ans[x][y] = d;
		for(i=0;i<4;i++){
			int nx = x + dx[i],ny = y + dy[i];
			if(nx>h || ny>w || nx<0 || ny<0) continue;
			if(mp[nx][ny]==0){
				que.push({{nx,ny},d + 1});
			}
		}
	}
}

int main(){
	int i,j;
	cin >> h >> w;
	for(i=0;i<h;i++){
		string s; cin >> s;
		for(j=0;j<w;j++){
			if(s[j]=='#'){
				que.push({{i,j},0});
				mp[i][j] = 1;
			}
		}
	}
	bfs();
	int mx = 0;
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			mx = max(mx,ans[i][j]);
		}
	}
	cout << mx << endl;
}

Measured memory_bytes: 20368
# coding: utf-8
A = []
for i in range(3):
    a = list(map(int, input().split()))
    A.append(a[:])
N = int(input())
F = [[False for _ in range(3)] for _ in range(3)]
for i in range(N):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if A[j][k] == b:
                F[j][k] = True
flag = False
for i in range(3):
    # if F[i][0] == F[i][1] == F[i][2] == True:
    if sum(F[i]) == 3:
        flag = True
for i in range(3):
    if F[0][i] == F[1][i] == F[2][i] == True:
        flag = True
if F[0][0] == F[1][1] == F[2][2] == True or F[2][0] == F[1][1] == F[0][2] == True:
    flag = True
print("Yes" if flag else "No")

Measured memory_bytes: 3064
arr = input().split(' ')
A = int(arr[0])
B = int(arr[1])
C = int(arr[2])
D = int(arr[3])

while True:
    C = C - B
    A = A - D
    
    if C < 1:
        print('Yes')
        break
    
    elif A < 1:
        print('No')
        break

Measured memory_bytes: 9180
#!/usr/bin/perl
#abc081_c.pl
#Thu Feb  8 23:35:00 2018
#

use warnings;
use strict;

my $temp = <STDIN>;
chomp $temp;

my @temps = split(" ",$temp);

my $n = $temps[0];
my $k = $temps[1];

my $tempss = <STDIN>;
my @a = split(" ",$tempss);

my %numhash;

foreach (@a){
	$numhash{$_}++;
}

my @factor = values(%numhash);
@factor = sort{$b<=>$a} @factor;

my $answer = 0;

while ($k<=$#factor){
	$answer = $answer+$factor[$k];
	$k++;
}

print $answer,"\n";

Measured memory_bytes: 53156
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <limits.h>
#include <algorithm>
#include <iomanip>
using namespace std;

int main(){
  int N,  ans = 0 ;
  cin >> N ;
  if((N%10) == 7){
    ans = 1 ;
  }
  N /= 10 ;
  if((N%10) == 7){
    ans = 1 ;
  }
  N /= 10 ;
  if(N == 7){
    ans = 1 ;
  }
  if(ans){
    cout << "Yes" << endl ;
  }
  else{
    cout << "No" << endl ;
  }
  return 0 ;
}  

Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>

int dsc(const void *a, const void *b){
  return *(int *)b - *(int *)a;
}

int main(){
  int X,Y,A,B,C;
  int *p, *q, *r;
  scanf("%d %d %d %d %d", &X, &Y, &A, &B, &C);
  p = (int *)malloc(sizeof(int) * A);
  q = (int *)malloc(sizeof(int) * B);
  r = (int *)malloc(sizeof(int) * (C+X+Y));
  for(int i=0; i<A; i++) scanf("%d ", &p[i]);
  for(int i=0; i<B; i++) scanf("%d ", &q[i]);
  for(int i=0; i<C; i++) scanf("%d ", &r[i]);

  qsort(p, A, sizeof(int), dsc);
  qsort(q, B, sizeof(int), dsc);
  
  for(int i=0; i<X; i++) r[C+  i] = p[i];
  for(int i=0; i<Y; i++) r[C+X+i] = q[i];
  
  qsort(r, C+X+Y, sizeof(int), dsc);
  
  long s=0;
  for(int i=0; i<X+Y; i++){
    s += r[i];
  }
  
  printf("%ld\n", s);
}



Measured memory_bytes: 3572
void main() {
	auto S = rs.to!(dchar[]);
	dstring now, before;
	ulong res;
	foreach(i; 0..S.length) {
		now ~= S[i];
		if(now != before) {
			before = now;
			now = "";
			res++;
		}
	}
	res.writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 4280
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <math.h>
using namespace std;
typedef long long int ll;

int main(){
	int m,k; cin >> m >> k;
	if(pow(2,m)-1<k){
		cout << -1 << endl;
		return 0;
	}
	if(m==0){
		if(k==0){
			cout << 0 << " " << 0 << endl;
			return 0;
		}
		else{
			cout << -1 << endl;
			return 0;
		}
	}
	else if(m==1){
		if(k==0){
			cout << 0 << " " << 0 << " " << 1 << " " << 1 << endl;
			return 0;
		}
		else{
			cout << -1 << endl;
		}
	}
	else{
		for(int i=0;i<=pow(2,m)-1;i++){
			if(i!=k){
				cout << i << " ";
			}
		}
		cout << k << " ";
		for(int i=pow(2,m)-1;i>=0;i--){
			if(i!=k){
				cout << i << " ";
			}
		}
		cout << k << endl;
		return 0;
	}
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
string solve(int arr[],int k,int n)
{

     vector<bool>dp(k+1,0);
    for(int i=1;i<=k;i++)
    {

        for(int j=0;j<n;j++)
        {
            if(i>=arr[j])
            {if(dp[i-arr[j]]==0)
                dp[i]=1;

            }

        }
    }
    return dp[k]?"First":"Second";


}

int main() {
	//code


	    int n,k;
	    cin>>n>>k;
	    int arr[n];
	    for(int i=0;i<n;i++)
	    {
	        cin>>arr[i];
	    }
	    cout<<solve(arr,k,n)<<endl;

	}



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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmin(v) v.rbegin()->first
#define mapmax(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK cerr<<"OK\n"
#define OK1 cerr<<"OK1\n"
#define OK2 cerr<<"OK2\n"
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n
#define endl '\n'

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const ll mod=1000000007;
const ll mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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;}

void YES(bool b) {cout << ((b)?"YES\n":"NO\n");}
void Yes(bool b) {cout << ((b)?"Yes\n":"No\n");}
void yes(bool b) {cout << ((b)?"yes\n":"no\n");}
void Yay(bool b) {cout << ((b)?"Yay!\n":":(\n");}

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	string s;
	cin >> s;
	ll ans=1;
	map<char,ll> m;
	for(auto&& e:s) m[e]++;
	for(char c='a';c<='y';c++){
		for(char d=c+1;d<='z';d++){
			ans+=m[c]*m[d];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
let () =
  let hh = 3600 in
  let mm = 60 in
  let time_calc time =
      let hour = time / hh in
      let minu = (time-hour*hh)/mm in
      let scnd = (time-hour*hh-minu*mm) in
      print_int hour ;
      print_string ":" ;
      print_int minu ;
      print_string ":" ;
      print_int scnd ; 
      print_string "\n"
  in
    Scanf.scanf "%d" time_calc

Measured memory_bytes: 2408
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb                 push_back
#define bug(x)             cerr<<#x<<" "<<x<<endl;
#define T int time;        scanf("%d", &time); while(time--)

   int main(){
        ll n,m;
        cin>>n>>m;
        if(n!=m)cout<<"No"<<endl;
        else cout<<"Yes"<<endl;

     }
   

Measured memory_bytes: 3576
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
using namespace std;
int main()
{
	for(int i=1;i<=9;i++)
		for(int j=1;j<=9;j++){
			printf("%dx%d=%d\n",i,j,i*j);
		} 
	return 0;
}


Measured memory_bytes: 3200
#include <iostream>
#include <algorithm>

using namespace std;

constexpr auto N = 1000;

int main()
{
    int n;
    while( cin >> n, n != 0 ) {
        bool s[N+2][N+2] = {};
        for( int y=0; y<n; ++y ) {
            for( int x=0; x<n; ++x ) {
                char c;
                cin >> c;
                s[x+1][y+1] = c == '.';
            }
        }

        int dp[N+2][N+2] = {};
        int m = 0;
        for( int y=0; y<n; ++y ) {
            for( int x=0; x<n; ++x ) {
                if ( s[x+1][y+1] ) {
                    dp[x+1][y+1] = min( dp[x][y], min( dp[x][y+1], dp[x+1][y] ) ) + 1;
                    m = max( m, dp[x+1][y+1] );
                }
            }
        }

        cout << m << endl;
    }
}

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

using namespace std;

int main()
{
    int N;
    cin >> N;
    if (N == 1) {
        cout << 1.0 << endl;
        return 0;
    }
    if (N % 2 == 0) {
        cout << 0.5 << endl;
        return 0;
    }

    cout << static_cast<double>(N + 1) / 2.0 / N << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putln(x) cout << x << endl;
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;
typedef vector <int> vec;
typedef vector <ll> vecll;
typedef vector <double> vecd;
typedef vector <vec> mat;
typedef vector <vecll> matll;
typedef vector <vecd> matd;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 100010;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const ll INFL = 1e18;
const ll MOD = 1000000007;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

//********************************template END****************************************//

void solve(void){

	int N;
	cin >> N;
	string T;
	vector <string> yui, inori;

	rep(N, i)
	{
		string s;
		cin >> s;

		if (s.find("?") != string::npos)
		{
			string as = s, zs = s;
			replace(all(as), '?', 'a');
			replace(all(zs), '?', 'z');
			yui.pb(as);
			inori.pb(zs);
		}
		else
		{
			yui.pb(s);
			inori.pb(s);
		}
	}

	cin >> T;

	sort(all(yui));
	sort(all(inori));

	//cout << yui << endl << inori << endl;

	int q = upper_bound(all(yui), T) - yui.begin();
	int p = lower_bound(all(inori), T) - inori.begin();

	//cout << p << ' ' << q << endl;

	Rep(p, q, i)
	{
		cout << i+1 << (i == q ? '\n' : ' ');
	}


}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 1280
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;

struct Node {
  int key;
  Node *next,*prev;
};
Node *Nil;

Node* listSearch(int key){
  Node *cur = Nil->next;
  while(cur != Nil && cur->key != key){
    cur = cur->next;
  }
  return cur;
}
void init(){
  Nil = (Node *)malloc(sizeof(Node));
  Nil ->next = Nil;
  Nil ->prev = Nil;
}
void printList(){
  Node *cur = Nil->next;
  int isf = 0;
  while(1){
    if(cur == Nil)break;
    if(isf++>0)printf(" ");
    printf("%d",cur->key);
    cur = cur->next;
  }
  printf("\n");
}
void deleteNode(Node *t){
  if(t == Nil)return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
}
void deleteFirst(){
  deleteNode(Nil->next);
}
void deleteLast(){
  deleteNode(Nil->prev);
}
void deleteKey(int key){
  deleteNode(listSearch(key));
}
void insert(int key){
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = Nil -> next;
  x->prev = Nil;
  Nil -> next -> prev = x;
  Nil -> next = x;
  x->prev = Nil;
}
int main (){
  int key,n,i;
  int size = 0;
  char com[20];
  int np = 0,nd = 0;
  init();
  scanf("%d", &n);
  for(i = 0;i<n;i++){
    scanf("%s%d",com,&key);
    if(com[0] == 'i'){insert(key);np++;size++;}
    else if(com[0] == 'd'){
      if(strlen(com)>6){
        if(com[6] == 'F')deleteFirst();
        else if(com[6] == 'L')deleteLast();
        }
      else deleteKey(key);
      size--;
    }
  }
  printList();
  return 0;
}



Measured memory_bytes: 37072
K=int(input())
if K%2==0:
    print(-1)
    exit()
elif K==7:
    print(1)
    exit()
i=0
mod=0
while(i<K):
    mod=(mod+7*pow(10,i,K))%K
    if mod==0:
        print(i+1)
        exit()
    i+=1
print(-1)

Measured memory_bytes: 63388
N, M = map(int, input().split())
ball_count = [1 for _ in range(N)]
if_red_exists = [1] + [0 for _ in range(N-1)]
count = 1
for _ in range(M):
    x, y = map(int, input().split())
    if if_red_exists[x-1]:
        # 赤が存在する場合
        if_red_exists[y-1] = 1
        if ball_count[x-1] <= 1:
            if_red_exists[x-1] = 0
    ball_count[x-1] -= 1
    ball_count[y-1] += 1

count = 0
for e in if_red_exists:
    if e == 1:
        count += 1
print(count)


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

int cw[maxn],n;
ll ww[maxn],aw=0,ab=0,ca=0,wb=0,ans=0;
const ll p=1e9+7;
char s[maxn];
ll pw(ll a,ll b){
	if(b<0)
		return 0;
	ll ret=1;
	while(b){
		if(b&1)
			ret=ret*a%p;
		a=a*a%p;
		b>>=1;	
	}
	return ret;
}
int main(){
	scanf("%s",s+1),n=strlen(s+1);
	for(int i=1;i<=n;i++)
		cw[i]=cw[i-1]+(s[i]=='?'),ww[i]=ww[i-1]+(s[i]=='?'?cw[i-1]:0);
	for(int i=1;i<=n;i++){
		if(s[i]=='A')
			ca++;
		else if(s[i]=='B')
			ab=(ab+ca)%p,wb=(wb+cw[i])%p;
		else if(s[i]=='C'){
			ans=(ans+1LL*ab*pw(3,cw[n])%p)%p;
			ans=(ans+1LL*aw*pw(3,cw[n]-1)%p)%p;
			ans=(ans+1LL*wb*pw(3,cw[n]-1)%p)%p;
			ans=(ans+1LL*ww[i]*pw(3,cw[n]-2)%p)%p;
		}
		else{
			ans=(ans+1LL*ab*pw(3,cw[n]-1)%p)%p;
			ans=(ans+1LL*aw*pw(3,cw[n]-2)%p)%p;
			ans=(ans+1LL*wb*pw(3,cw[n]-2)%p)%p;
			ans=(ans+1LL*ww[i-1]*pw(3,cw[n]-3)%p)%p;
			aw=(aw+ca)%p;
		}
	}
	printf("%lld\n",ans);
	return 0;
} 

Measured memory_bytes: 1536
#include <stdio.h>
#include <algorithm>
int main(void){
    int n,m,p;
    scanf("%d%d%d",&n,&m,&p);
    int x[m];
    int y;
    for(int i=0;i<m;i++){
        scanf("%d",&y);
        x[i]=(y+n-p)%n;
    }
    std::sort(x,x+m);
    int ans;
    int a,b;
    ans=20000000;
    for(int i=0;i<m-1;i++){
        a=x[i];
        b=n-x[i+1];
        if(ans>a*2+b)ans=a*2+b;
        if(ans>a+b*2)ans=a+b*2;
    }
    if(ans>x[m-1])ans=x[m-1];
    if(ans>n-x[0])ans=n-x[0];
    printf("%d\n",ans*100);
}


Measured memory_bytes: 2804
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>

int main() {
  size_t N, W;
  scanf("%zu %zu", &N, &W);

  std::vector<uintmax_t> w(N), v(N);
  for (size_t i = 0; i < N; ++i)
    scanf("%ju %ju", &w[i], &v[i]);

  std::vector<std::vector<uintmax_t>> dp(N+1, std::vector<uintmax_t>(W+1));
  for (size_t i = 0; i < N; ++i) {
    for (size_t j = W; j >= w[i]; --j)
      dp[i+1][j] = std::max(dp[i][j], dp[i][j-w[i]]+v[i]);
    for (size_t j = w[i]; j--;)
      dp[i+1][j] = dp[i][j];
  }

  printf("%ju\n", *std::max_element(dp[N].begin(), dp[N].end()));
}


Measured memory_bytes: 80256
//Summer Vacation of 2018
//Atcoder Regular Contest 099_Problem C Minimization
//Author:Jimmy2017
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int ans=0;
    int n,k;
    int a[100005];
    cin>>n>>k;
    for(int i=0;i<n;i++){
		cin>>a[i];
    }
    n-=k;
    ans++;
	k--;
    while(n>0){
        n-=k;
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define x first
#define y second 
#define ll long long 
#define _for(i,j,k) for(int i=j;i<k;i++)
#define endl  '\n'
#define inf 1<<29-1 
const int mod=1e9+7;
const int MAX=105;
double a[MAX],b[MAX];
int main() {
 	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 	ll n,m;
	 double sum=0;
 	cin>>n>>m;
 	for(int i=0;i<n;i++)
 	{
 		cin>>a[i];
 		sum+=a[i];
	 }
	 sum=sum/(4*m);
	 ll ans=0;
	 for(int i=0;i<n;i++)
 	{
 		if(a[i]>=sum)
 		ans++;
	 }
	if(ans>=m)cout<<"Yes";
	else cout<<"No";
	 
}
		 

Measured memory_bytes: 256
import sys

def main():
    input = sys.stdin.readline
    MOD = 10**9 + 7
    N, M = map(int, input().split())
    A = [int(input()) for _ in range(M)]
    is_safe = [True] * (N+1)
    for a in A:
        is_safe[a] = False

    dp = [0] * (N+2)
    dp[1] = 1
    for i in range(N):
        step = i+2
        if is_safe[i+1]:
            dp[step] = dp[step-1] + dp[step-2]
            dp[step] %= MOD
        else:
            dp[step] = 0

    return dp[N+1]


if __name__ == '__main__':
    print(main())


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

#define all(v) v.begin(), v.end()
#define mp make_pair
#define EPS (int)1e-9
#define PI acos(-1)
#define endl '\n'
#define pb push_back
#define fi first
#define se second

using namespace std;
using ld = long double;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;

const int mod = 1000000007;


int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int x, t;
	cin >> x >> t;

	cout << max(x-t, 0) << endl;
	return 0;	
}

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

using namespace std;
typedef long long ll;

ll N,K;
ll A[200001];
unordered_map<ll,vector<ll>> um;

ll sh(vector<ll> &v){
    if(v.size() <= 1) return 0;
    ll sp = 0;
    ll ep = 1;
    ll ans = 0;
    while(ep < v.size()){
        while(v[ep] - v[sp] >= K) sp++;
        ans += (ep - sp);
        ep++;
    }
    return ans;
}

int main(){
    cin >> N >> K;
    for(int i=0;i<N;i++) cin >> A[i];
    A[0] += K-1;
    A[0] %= K;
    for(int i=1;i<N;i++){
        A[i] += A[i-1] + K - 1;
        A[i] %= K;
    }
    um[0].push_back(-1);
    for(int i=0;i<N;i++){
        um[A[i]].push_back(i);
    }
    ll count = 0;
    for(auto p=um.begin(); p!=um.end(); p++){
        ll k = p->first;
        vector<ll> v = p->second;
        count += sh(v);
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 19528
#include <bits/stdc++.h>
 
using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
long long mod = 1000000007;
 
long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}
 
/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  
 
double eps = .000000001;

int main(){
  prep();
  int n;
  cin >> n;
  string graph[n];
  for (int i=0; i<n; i++){
      cin >> graph[i];
  }
  int colsums[n] = {0};
  int rowsums[n] = {0};
  bool black = false;
  for (int i=0; i<n;i ++){
      for (int j=0; j<n; j++){
          if (graph[i][j] == '#'){
              black = true;
              colsums[j]++;
              rowsums[i]++;
          }
      }
  }
  if (!black){
      cout << -1;
      return 0;
  }
  bool exists = false;
  int many = 0;
  for (int i=0; i<n; i++){
      if (rowsums[i] == n){
          exists = true;
          break;
      }
  }
  for (int i=0; i<n; i++){
      if (colsums[i] == n){
          many++;
      }
  }
  if (exists){
      cout << n-many;
      return 0;
  }
 
  int minnest = 1000000000;
  for (int i=0; i<n; i++){
      int tofill = n-many+n-rowsums[i];
      if (colsums[i]){
          minnest = min(minnest, tofill);
      }else{
          minnest = min(minnest, tofill+1);
      }
  }
  cout << minnest;
  // for a row, if none in a col, try to get a square in the same column as it
 
  return 0; 
}

Measured memory_bytes: 512
#sub f{my$x=$_;$p=0;$p=$M[$x]+=$-=($M[$_]||&f)+1-$M[$x]for@$x;$p}
#sub f{my$x=$_;$M[$x]+=$-=($M[$_]||&f)+1-$M[$x]for@$x;$M[$x]}
sub f{my$m=\$M[$_];$$m+=$-=($M[$_]||&f)+1-$$m for@$_;$$m}

;
map{/ /,push@{$`},$'+0for<>;$a[&f]=1}1..<>;print$#a


Measured memory_bytes: 115712
import scala.io.StdIn.readInt

object Main {
  def formatTime(int: Int): Unit = {
    val h: Int = int / 3600
    val m: Int = int % 3600 / 60
    val s: Int = int % 3600 % 60

    println(h+":"+m+":"+s)
  }

  def main(args: Array[String]): Unit = {

    val sec: Int = readInt

    formatTime(sec)
  }
}

Measured memory_bytes: 43600
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vstr> vvstr;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int n;
    cin >> n;
    vint b(n);
    rep(i, n) {
        cin >> b[i];
        if (b[i] > i + 1) {
            puts("-1");
            return 0;
        }
    }
    vint ans;
    rrep(i, n) {
        rrep(j, i+1) {
            if (b[j] == j+1) {
                b.erase(b.begin() + j);
                ans.insert(ans.begin(), j+1);
                break;
            }
        }
    }
    out_ary(ans);
    return 0;
}

Measured memory_bytes: 256
from sys import stdin
n = int(input())
a = list(map(int, stdin.readline().split()))
a.sort()
amax = max(a)+1
e = [True]*amax
Alice = set()
Bob = set()
ans = 0

for i in range(n):
    if e[a[i]] == True:
        Alice.add(a[i])
        for j in range(a[i], amax, a[i]):
            e[j] = False
    else:
        if a[i] in Alice:
            Bob.add(a[i])

print(len(Alice - Bob))

Measured memory_bytes: 42956
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int q , n = 0 ;
    cin >> q;
    int l[q] , r[q] , a[100005] = {0} , c[100005] = {0};
    for( int i = 0 ; i < q ; i++ ) cin >> l[i] >> r[i];
    for( int i = 2 ; i <= 100005 ; i++ ) {
        int b = 1;
        for ( int j = 2 ; j * j <= i ; j++ ) {
            if ( i % j == 0 ) b = 0;
        }
        for ( int j = 2 ; j * j <= ( i + 1 ) / 2 ; j++ ) {
            if ( ( ( i + 1 ) / 2 ) % j == 0 ) b = 0;
        }
        a[i] = b;
    }
    a[2]=0;
    for( int i = 1 ; i <= 100005 ; i++ ) {
        n += a[i];
        c[i] = n;
    }
    n = 0;
    for( int i = 0 ; i < q ; i++ ) {
        n = 0;
        n += c[r[i]] - c[l[i] - 1];
        cout << n << endl;
    }
}

Measured memory_bytes: 5196
def main():
  N = int(input())

  dic = {
    "AC": 0,
    "WA": 0,
    "TLE": 0,
    "RE": 0
  }

  for _ in range(N):
    S = input()

    if S in dic:
      dic[S] += 1

  print("AC x {0}".format(dic["AC"]))
  print("WA x {0}".format(dic["WA"]))
  print("TLE x {0}".format(dic["TLE"]))
  print("RE x {0}".format(dic["RE"]))

if __name__ == "__main__":
  main()

Measured memory_bytes: 69860
#include <bits/stdc++.h>
using namespace std;
const int N = 200003;
int n, k;
int a[N];
inline bool check(int x)
{
	long long tot = 0;
	for (int i = 1; i <= n; i+=1)
		tot += a[i] / x + (a[i] % x != 0) - 1;
	return tot <= k;
}
int main()
{
	cin >> n >> k;
	for (int i = 1; i <= n; i+=1) cin >> a[i];
	int l = 1, r = 1000000001, ans = 0;
	while (l <= r)
	{
		int mid = (l + r) >> 1;
		if (check(mid)) ans = mid, r = mid - 1;
		else l = mid + 1;
	}
	cout << ans << endl;
}


Measured memory_bytes: 4304
#include <stdio.h>
int F[45];
void makeFib(int n){
  
  F[n]=F[n-1]+F[n-2];
}
int main(){

  int n, i;
  F[0]=F[1]=1;
  scanf("%d", &n);
  for(i=2; i<=n; i++) makeFib(i);
  printf("%d\n", F[n]);

  return 0;
}



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

bool prime(int n){
  if (n ==2){
    return true;
  }
  else{
    int x=2;
    while(x*x<n){
      if(n%x == 0){
        return false;
        break;
      }
      x += 1;
    }
    return true;
  }
}

int main(){
  int X;
  cin >>X;
  bool TF =true;
  while(TF){
    if(prime(X)){
      TF = false;
      break;
    }
    X +=1;
  }
  cout<<X<<endl;
}

Measured memory_bytes: 768
// Max Heap
class Heap<T : Comparable<T>> {
    private var heap: MutableList<T> = mutableListOf()
    val size: Int
        get() = this.heap.size

    fun push(elem: T) {
        var i = heap.size  // My node index
        heap.add(elem)    // Add element as last child

        while (i > 0) {
            val p = (i - 1) / 2   // My parent node
            if (heap[p] >= elem) break   // There is no reversal

            // Move parent to child
            heap[i] = heap[p]
            i = p
        }
        heap[i] = elem
    }

    fun pop(): T? {
        if (heap.size == 0) return null

        val ret = heap[0]   // Maximum
        val x = heap.last()  // Move last child to root
        heap.removeAt(heap.lastIndex)

        if(heap.size == 0) return ret

        var i = 0
        while (i * 2 + 1 < heap.size) {
            var a = i * 2 + 1   // Left child
            val b = i * 2 + 2   // Right child if exists

            if (b < heap.size && heap[b] > heap[a]) a = b  // Move bigger to left

            if (heap[a] <= x) break   // There is no reversal

            // Move child to parent
            heap[i] = heap[a]
            i = a
        }
        heap[i] = x

        return ret
    }
}

fun main(args: Array<String>){
    val(n, m) = readLine()!!.split(' ').map { it.toInt() }
    val items = Heap<Int>()
    readLine()!!.split(' ').map { items.push(it.toInt()) }

    repeat(m){
        items.push(Math.floor(items.pop()!! / 2.0).toInt())
    }

    var ans: Long = 0
    repeat(items.size){
        ans += items.pop()!!
    }

    println(ans)
}

Measured memory_bytes: 71732
n = int(input())
if n>=64:
  print(64)
elif n >=32:
  print(32)
elif n >=16:
  print(16)
elif n >=8:
  print(8)
elif n >=4:
  print(4)
elif n >=2:
  print(2)
else:
  print(1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
char s[200005];
int cnt[200005];
int main(){
    int n;
    scanf("%d",&n);
    scanf("%s",s+1);
    for(int i = 1; i <= n; i++){
        cnt[i] = cnt[i-1] + (s[i] == '#' ? 1 : 0);
    }
    int mn = min(n - cnt[n], cnt[n]);
    for(int i = 1; i <= n; i++){
        mn = min(mn, 2*cnt[i] + n - i - cnt[n]);
    }
    printf("%d\n",mn);
    return 0;
}

Measured memory_bytes: 1280
use proconio::{fastout, input};

fn main() {
    input! {
        x: i128
    };

    for i in 0.. {
        let i = i as i128;
        let a = (i).pow(5) - (i - 1).pow(5);
        if a == x {
            println!("{} {}", i, i - 1);
            return;
        }

        if a > x && (i - 1) > 0 {
            break;
        }
    }

    for i in 0.. {
        let i = i as i128;
        let a = (-i).pow(5) - (-i - 1).pow(5);
        if a == x {
            println!("{} {}", -i, -i - 1);
            return;
        }

        if a > x {
            break;
        }
    }

    let mut s = vec![true; 40000];

    for i in 2.. {
        if i >= s.len() {
            break;
        }

        let i = i as i128;

        if x % i == 0 {
            for k in 0.. {
                let k = k as i128;
                let a = i
                    * (k.pow(4)
                        + k.pow(3) * (k - i)
                        + k.pow(2) * (k - i).pow(2)
                        + k * (k - i).pow(3)
                        + (k - i).pow(4));
                if a == x {
                    println!("{} {}", k, k - i);
                    return;
                }

                if a > x && (k - i) > 0 {
                    break;
                }
            }

            for k in 0.. {
                let k = k as i128;
                let a = i
                    * ((-k).pow(4)
                        + (-k).pow(3) * (-k - i)
                        + (-k).pow(2) * (-k - i).pow(2)
                        + -k * (-k - i).pow(3)
                        + (-k - i).pow(4));
                if a == x {
                    println!("{} {}", -k, -k - i);
                    return;
                }

                if a > x {
                    break;
                }
            }
        }

        for j in 2.. {
            if j * i >= s.len() as i128 {
                break;
            }

            s[(j * i) as usize] = false;
        }
    }

    unreachable!();
}


Measured memory_bytes: 2228
// 2011/08/01 Tazoe

#include <iostream>
#include <string>
using namespace std;

void roll01(int c[6])
{
	int tmp = c[0];
	c[0] = c[1];
	c[1] = c[5];
	c[5] = c[4];
	c[4] = tmp;
}

void roll02(int c[6])
{
	int tmp = c[0];
	c[0] = c[2];
	c[2] = c[5];
	c[5] = c[3];
	c[3] = tmp;
}

void roll12(int c[6])
{
	int tmp = c[1];
	c[1] = c[2];
	c[2] = c[4];
	c[4] = c[3];
	c[3] = tmp;
}

void rotate(int c[6])
{
	if(c[0]==1){
		;
	}
	else if(c[1]==1){
		roll01(c);
	}
	else if(c[2]==1){
		roll02(c);
	}
	else if(c[3]==1){
		roll02(c);
		roll02(c);
		roll02(c);
	}
	else if(c[4]==1){
		roll01(c);
		roll01(c);
		roll01(c);
	}
	else if(c[5]==1){
		roll02(c);
		roll02(c);
	}

	if(c[1]==2){
		;
	}
	else if(c[2]==2){
		roll12(c);
	}
	else if(c[4]==2){
		roll12(c);
		roll12(c);
	}
	else if(c[3]==2){
		roll12(c);
		roll12(c);
		roll12(c);
	}
	else if(c[1]==3){
		;
	}
	else if(c[2]==3){
		roll12(c);
	}
	else if(c[4]==3){
		roll12(c);
		roll12(c);
	}
	else if(c[3]==3){
		roll12(c);
		roll12(c);
		roll12(c);
	}
}

int main()
{
	while(true){
		int n;
		cin >> n;
		if(n==0)
			break;

		int C[30][6];
		for(int i=0; i<n; i++){
			for(int j=0; j<6; j++){
				string str;
				cin >> str;
				if(str=="Red")
					C[i][j] = 1;
				else if(str=="Yellow")
					C[i][j] = 2;
				else if(str=="Blue")
					C[i][j] = 3;
				else if(str=="Magenta")
					C[i][j] = 4;
				else if(str=="Green")
					C[i][j] = 5;
				else if(str=="Cyan")
					C[i][j] = 6;
			}
		}

		for(int i=0; i<n; i++)
			rotate(C[i]);

		for(int i=0; i<n-1; i++)
			for(int j=i+1; j<n; j++)
				if(C[i][1]>C[j][1]
				 ||(C[i][1]==C[j][1]&&C[i][2]>C[j][2])
				 ||(C[i][1]==C[j][1]&&C[i][2]==C[j][2]&&C[i][3]>C[j][3])
				 ||(C[i][1]==C[j][1]&&C[i][2]==C[j][2]&&C[i][3]==C[j][3]&&C[i][4]>C[j][4])
				 ||(C[i][1]==C[j][1]&&C[i][2]==C[j][2]&&C[i][3]==C[j][3]&&C[i][4]==C[j][4]&&C[i][5]>C[j][5]))
					for(int k=0; k<6; k++){
						int tmp = C[i][k];
						C[i][k] = C[j][k];
						C[j][k] = tmp;
					}

		int m = n;
		for(int i=0; i<n-1; i++){
			bool flg = true;
			for(int j=0; j<6; j++)
				if(C[i][j]!=C[i+1][j]){
					flg = false;
					break;
				}
			if(flg)
				m--;
		}
		cout << n-m << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstring>
#include<string.h>
using namespace std;
int n,m,i,j,k,a,b,c,g,x,cc[500000];
long long gcd(long long x,long long y){
    if (x>y) swap(x,y);
    long long z;
    while (y%x!=0){
        z=y%x;
        y=x;
        x=z;
    }
    return x;
}
int main(){
	scanf("%d %d",&n,&x);
	for (int i=1;i<=n;i++){
		scanf("%d",&cc[i]);
	}
	cc[0]=x;
	sort(cc,cc+n+1);
	for (int i=0;i<n;i++){
		if (a!=0) a=gcd(cc[i+1]-cc[i],a);
		else a=cc[i+1]-cc[i];
	}
	printf("%d\n",a);
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 28;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

string s;
int k;

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

	for (int i = 0; i < s.size()-1; i++) {
		if (s[i]=='a') {
			cout << s[i];
			continue;
		}
		if (k < 1) {
			cout << s[i];
			continue;
		}
		if (k < ('z' - s[i] + 1)) {
			cout << s[i];
			continue;
		}
		else {
			cout << 'a';
			k = k - (('z' - s[i] + 1));
		}
	}

	int last = (s[s.size() - 1] + (k % 26));
	if (last <= 'z') {
		cout << (char)last << endl;
	}
	else {
		last -= 26;
		cout << (char)last << endl;
	}

	return 0;
}


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

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

int main(int argc, char **argv) {
#ifdef LOCAL
  freopen("in.txt", "r", stdin);
#endif

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

  int a, b; cin >> a >> b;
  if(a >= 10 || b >= 10) cout << -1 << endl;
  else cout <<  a*b << endl;


  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int w, h, x, y;

  cin >> w >> h >> x >> y;
  double area = ((double)w * (double)h) / 2.0;

  if (w % 2 == 1 || h % 2 == 1) {
    cout << area << " " << 0 << endl;
  } else if (w / 2 == x && h / 2 == y) {
    cout << area << " " << 1 << endl;
  } else {
    cout << area << " " << 0 << endl;
  }

  // cout << area << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
//#include "graph.cpp"
#define ll long long
#define loop(i,n) for(int i=0 ; i<n ; ++i)
#define rep(i,x,n) for(int i=x ; i<=n ; ++i)
#define iteloop(type,data,name,it) for(type<data>::iterator it=name.begin() ;it!=name.end() ; ++it)
using namespace std;
using namespace __gnu_pbds;
const int N=2e5 + 5;
pair<int,int> arr[N];
int n;
int main(){
    cin.sync_with_stdio(false), cin.tie(0) , cout.tie(0);
  ///  freopen("in.txt","rt",stdin);
    cin>>n;
    loop(i,n){
        cin>>arr[i].second>>arr[i].first;
    }
    sort(arr,arr+n);
    bool ok=true;
    ll com=0;
    loop(i,n){
        com+=arr[i].second;
        if(com>arr[i].first){
            ok=false;
            break;
        }
    }
    if(ok){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <time.h>
#define INF 1000000009
#define LINF 1000000000000000009
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T> bool chmax(T &a, const T&b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T&b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }
ll mod = 1000000007;

ll fac[2000010];

ll modinv(ll a) {
	ll b = mod, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= mod;
	if (u < 0) u += mod;
	return u;
}

void modfac() {
	fac[0] = 1;
	for (ll i = 1; i < 2000010; i++) {
		fac[i] = (fac[i - 1] * i) % mod;
	}
}

ll modperm(ll n, ll k) {
	if (n < 0 || k < 0 || n < k) return 0;
	else return (fac[n] * modinv(fac[n - k])) % mod;
}

ll modcomb(ll n, ll k) {
	if (n < 0 || k < 0 || n < k) return 0;
	else return ((fac[n] * modinv(fac[k])) % mod*modinv(fac[n - k])) % mod;
}

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	set<int> st;
	for (int i = 0; i < n; i++) st.insert(a[i]);
	if (st.size() == n) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
#define dbg(x) cout << #x << ": " << (x) << '\n'
#define ff first
#define ss second
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;

int main() {
#ifndef ONLINE_JUDGE
   freopen("inp.txt", "r", stdin);      freopen("outp.txt", "w", stdout);
#endif
   ios::sync_with_stdio(false);   cin.tie(NULL);   cout.tie(NULL);

   int a, b;
   cin >> a >> b;
   cout << a * b << endl;


   return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1LL << 60;
constexpr int INF = 3000000007;
const double INFD = 1e100;
const int mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// ----------------------------------------------------------------------------

int main(){
  int X,Y,Z,K;
  cin >> X >> Y >> Z >> K;
  vector<ll> A(X);
  for(int i=0; i<X; i++){
    cin >> A[i];
  }
  vector<ll> B(Y);
  for(int i=0; i<Y; i++){
    cin >> B[i];
  }
  vector<ll> C(Z);
  for(int i=0; i<Z; i++){
    cin >> C[i];
  }
  vector<ll> AB;
  for(int i=0; i<X; i++){
    for(int j=0; j<Y; j++){
      AB.push_back(A[i]+B[j]);
    }
  }
  sort(AB.begin(),AB.end(),greater<ll>());
  vector<ll> ABC;
  for(int i=0; i<=min(K,(int)AB.size()-1); i++){
    for(int j=0; j<Z; j++){
      ABC.push_back(AB[i]+C[j]);
    }
  }
  sort(ABC.begin(),ABC.end(),greater<ll>());
  for(int i=0; i<K; i++){
    cout << ABC[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 43240
using System;
using static System.Console;

class main{
    public static void Main(){
        int n = int.Parse(ReadLine());
        int k = int.Parse(ReadLine());
        int x = int.Parse(ReadLine());
        int y = int.Parse(ReadLine());
        int sum=0;

        sum += n*x;

        if(n>k){
            sum -=(n-k)*(x-y);
        }
        WriteLine(sum);
    }
}

Measured memory_bytes: 11092
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
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; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    ll k;
    cin >> n >> k;
    vector<ll> sum(n+1, 0);
    rep(i,n){
        cin >> sum[i+1];
        (sum[i+1] += sum[i]) %= k;
    }
    for(int i = 1; i <= n; ++i){
        sum[i] = (sum[i] + k - i % k) % k;
    }
    map<ll, ll> cnt;
    ll ans = 0;
    rep(i,n+1){
        if(i >= k) cnt[sum[i-k]]--;
        ans += cnt[sum[i]]++;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  int a,b=1,c=1,d;
  cin>>a;
  for(int i=0;i<a;i++){
    b*=3;
  }
  for(int i=0;i<a;i++){
    cin>>d;
    if(d%2==0){
      c*=2;
    }
  }
  cout<<b-c<<endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Scanner;
import java.util.HashSet;
import java.util.Iterator;

class Main {

    static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        sc.close();
        for(int i=1;i<=s.length();i++){
            if(i%2!=0){
                if(s.charAt(i-1)=='R'||s.charAt(i-1)=='U'||s.charAt(i-1)=='D'){

                }else{
                    System.out.println("No");
                    return;
                }
            }else{                
                if(s.charAt(i-1)=='L'||s.charAt(i-1)=='U'||s.charAt(i-1)=='D'){

                }else{
                    System.out.println("No");
                    return;
                }
            }
        }
        System.out.println("Yes");
    }
}

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


int main() {
	ll N, K;
	cin >> N >> K;

	vector<ll> A(N);
	for(auto& e : A) {
		cin >> e;
	}

	ll ans = 0;
	bool bit_free = false;
	for(int i=60;i>=0;i--) {
		ll top_bit = 1LL << i;
		int cnt = 0;
		for (int j = 0; j<N; j++) {
			if (A[j] & top_bit) {
				cnt++;
			}
		}
		if (bit_free || (K&top_bit)) {
			if(cnt >= N - cnt) {
				// use zero
				bit_free = true;
				ans += top_bit * cnt;
			}else {
				// use one
				ans += top_bit * (N - cnt);
			}
		}else {
			// use zero
			ans += top_bit * cnt;
		}
	}
	cout << ans << endl;
	

	return 0;
}


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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

bool isPrime(long long int n){
	if(n < 2) return false;
	else if(n == 2) return true;

	long long int sqrtN = sqrt(n);

	for(int i = 3; i < sqrtN; i += 2){
		if(n % i == 0) return false;
	}

	return true;
}

int main(){
	long long int n;
	cin >> n;
	int ans = 0;

	if(n < 2){
		cout << 0;
		return false;
	}
	else if(n == 2){
		cout << 1;
		return false;
	}

	if(n % 2 == 0){
		int c = 0;

		while(n % 2 == 0){
			n /= 2;
			c++;
		}

		for(int i = 1; i <= c; i++){
			ans++;
			c -= i;
		}
	}

	long long int sqrtNum = sqrt(n);

	for(int i = 3; i <= sqrtNum; i += 2){
		// 約数である
		if(n % i == 0){
			int c = 0;

			while(n % i == 0){
				n /= i;
				c++;
			}

			for(int i = 1; i <= c; i++){
				ans++;
				c -= i;
			}
		}
	}

	if(n != 1) ans++;
	
	cout << ans;

	return 0;
}

Measured memory_bytes: 3640