akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
//increase stack size
#pragma comment(linker, "/STACK:16777216")

ll mxm() {return LLONG_MIN;}
template<typename... Args>
ll mxm(ll a, Args... args) { return max(a,mxm(args...)); }

ll mnm() {return LLONG_MAX;}
template<typename... Args>
ll mnm(ll a, Args... args) { return min(a,mnm(args...)); }

template<class T> ostream& operator<<(ostream& os,vector<T> V){
	os<<"[ ";for(auto v:V)os<<v<<" ";return os<<"]";
}
template<class L,class R> ostream& operator<<(ostream& os,pair<L,R> P){
	return os<<"("<<P.first<<","<<P.second<<")";
}

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__,__VA_ARGS__)
template<typename Arg1>
void __f(const char* name,Arg1&& arg1){
	cout<<name<<" : "<<arg1<<endl;
}
template <typename Arg1,typename... Args>
void __f(const char* names,Arg1&& arg1,Args&&... args){
	const char* comma=strchr(names+1,',');cout.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1,args...);
}
#else
#define trace(...) 1
#endif

#define ld long double
#define pll pair<ll,ll>
#define ii pair<int,int>
#define vll vector<ll>
#define vii vector<ii>
#define vi vector<int>
#define vpll vector<pll>
#define vld vector<ld>
#define vvld vector<vld>
#define vvi vector<vi>
#define vvll vector<vll>
#define vvpll vector<vpll>
#define vvii vector<vii>
#define I insert
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define all(x)	x.begin(),x.end()

const int mod=1e9+7;
// 128 bit: __int128
inline int add(int a,int b){a+=b;if(a>=mod)a-=mod;return a;}
inline int sub(int a,int b){a-=b;if(a<0)a+=mod;return a;}
inline int mul(int a,int b){return (a*1ll*b)%mod;}
inline int power(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline int inv(int a){return power(a,mod-2);}

struct compare{
	bool operator() (const int &a,const int &b) const{
		return a>b;
	}
};

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	int a, b, c;
	cin >> a >> b >> c;
	swap(a, b);swap(a, c);
	cout << a << ' ' << b << ' ' << c << endl;		
}

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


int main()
{
	int n ;  cin >> n;
	int a[n+1],g = 0;
	int i = 1;
	while(i<=n)
	{
		cin >> a[i] ;
		i ++ ;
	}
	
	
	
	int dp[n+1] = {0};
	dp[1] = a[1];
	dp[2] = abs(a[2] - a[1]);
	dp[3] = min(abs(a[3] - a[2])+dp[2],abs(a[3]-a[1]));

	i = 4;
	while(i<=n )
	{
		dp[i] = min(abs(a[i] - a[i-1])+dp[i-1],abs(a[i]-a[i-2])+dp[i-2]);
		i++;
	}
	cout<< dp[n];
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int long long
#define vin vector<int>
#define vcn vector<char>
#define ver pair<int,int>
#define ld long double
#define pb push_back
#define x first
#define y second
#define blush fflush(stdout);fflush(stdin);
#define $(a) (int)a.size()
#define scanf ;
#define printf ;
using namespace std;
void i_love_misaka_mikoto();
int32_t main(){
    #ifdef RNS
        freopen("input.txt","r",stdin);
        #ifndef DBG
        freopen("output.txt","w",stdout);
        #endif
    #else
        ios_base::sync_with_stdio(false);
    #endif
    i_love_misaka_mikoto();
    #ifdef RNS
        cout<<'\n'<<(ld)clock()/CLOCKS_PER_SEC<<" セクンド\n";
    #endif
    return 0;
}
int buf[1000];
void i_love_misaka_mikoto(){
    int n, m;
    cin>>n>>m;
    for(int i=0;i<n;i++){
        int b;
        cin>>b;
        for(int j=0;j<b;j++){
            int r;
            cin>>r;
            buf[r]++;
        }
    }
    int ans=0;
    for(int i=0;i<=m;i++)
        if(buf[i]==n)
            ans++;
    cout<<ans;
}

Measured memory_bytes: 256
#import<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long LL;
LL c,i,j,k,m,n,p,a[200040]={-999999},b[200040],x[200040],y[200040];
string s="x",t;
queue<LL>Q;
main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>k>>c>>t;
	s+=t;
	for(i=0,p=c;i++<n;)
	{
		p++;
		if(s[i]&1&&p>c)
		{
			a[i]=i;
			x[i]=x[i-1]+1;
			p=0;
		}
		else
		{
			a[i]=a[i-1];
			x[i]=x[i-1];
		}
	}
	b[n+1]=999999;
	for(i=n,p=c;i;i--)
	{
		p++;
		if(s[i]&1&&p>c)
		{
			b[i]=i;
			y[i]=y[i+1]+1;
			p=0;
		}
		else
		{
			b[i]=b[i+1];
			y[i]=y[i+1];
		}
	}
	for(i=0;i++<n;)
	{
		if(s[i]&1&&x[i-1]+y[i+1]-(b[i+1]-a[i-1]<=c)<k)cout<<i<<'\n';
	}
}

Measured memory_bytes: 8340
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
using namespace std;

int n;
int p[20101];
int a[20101], b[20101];

int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i)
		scanf("%d", &p[i]);
	for(int i = 1; i <= n; ++i)
	{
		a[i] = i * 25000;
		b[i] = (n - i + 1) * 25000;
	}
	for(int i = 1; i <= n; ++i)
	{
		b[p[i]] += i;
	}
	for(int i = 1; i <= n; ++i)
		printf("%d ", a[i]);
	printf("\n");
	for(int i= 1; i <= n; ++i)
		printf("%d ", b[i]);

	return 0;
}

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

using lli = long long int;

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

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

void foreach_permutation(int n, std::function<void(int *)> f) {
  int indexes[n];
  for (int i = 0; i < n; i++) indexes[i] = i;
  do {
    f(indexes);
  } while (std::next_permutation(indexes, indexes + n));
}

int main(void){
    int n;
    cin >> n;
    vector<pair<int, int>> p(n);
    for(auto& i : p){
        cin >> i.first >> i.second;
    }
    vector<vector<double>> dist(n, vector<double>(n));
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            int x1 = p.at(i).first;
            int y1 = p.at(i).second;
            int x2 = p.at(j).first;
            int y2 = p.at(j).second;
            dist.at(i).at(j) = sqrt(pow(x1-x2, 2)+pow(y1-y2, 2));
        }
    }
    //cout << dist << endl;
    int c = 0;
    double sum = 0;
    foreach_permutation(n, [&c, &sum, n, dist](int *indexes) {
        for(int i = 0; i < n-1; i++) sum += dist.at(indexes[i]).at(indexes[i+1]);
        c++;
    });
    cout << fixed << setprecision(10) << sum/c << endl;
    return 0;
}


Measured memory_bytes: 256
N = gets.to_i

def factional(number)
    (1..number).inject(1,:*)
end

require 'prime'

answer = 1

for i in 0..Prime.prime_division(factional(N)).size-1

    answer = (answer * (Prime.prime_division(factional(N))[i][1]+1)) % (10 ** 9 + 7)

end

puts answer 

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

int a[100001],f[100001];
int ff(int u){
	return f[u]==u?u:f[u]=ff(f[u]);
}
vector<int>g[100001];
int c[100001];
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]),
		f[i]=i;
	for(int i=1;i<=m;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		u++;v++;
		f[ff(u)]=ff(v);
	}
	for(int i=1;i<=n;i++)
		g[ff(i)].push_back(a[i]);
	long long ans=0;
	int z=0;
	for(int i=1;i<=n;i++)
		if(i==ff(i)){
			z++;
			sort(g[i].begin(),g[i].end());
			ans+=g[i][0];
			for(int j=1;j<g[i].size();j++)
				c[++c[0]]=g[i][j];
		}
	if(z==1){
		printf("0\n");
		return 0;
	}
	if(c[0]<z-2){
		printf("Impossible\n");
		return 0;
	}
	sort(c+1,c+c[0]+1);
	for(int i=1;i<=z-2;i++)
		ans+=c[i];
	printf("%lld\n",ans);
}


Measured memory_bytes: 6528
#include <iostream>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <deque>
#include <map>
#include <bits/stdc++.h>
using namespace std;

int main(void){
    
    long int N;
    
    cin >> N;

    long int min_ = N+1;
    for(long int i=1; i<(int)sqrt(N)+1; i++){
        if(N%i == 0){
            long int B = N / i;
            long int dist = i+B;
            if(dist < min_){
                min_ = dist;
            }
        }
    }
    
    cout << (long int)(min_-2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int n, i, j, k, c = 0, a[100] = {};
	cin >> n;
	for(i = 0; i < n; ++i)
		cin >> a[i];

	for(i = 0; i < n; ++i){
		for(j = n-1; j > i; --j){
			if( a[j] < a[j-1] ){
				k = a[j];
				a[j] = a[j-1];
				a[j-1] = k;
				++c;				
			}
		}
	}

	for(i = 0; i < n; ++i){
		cout << a[i];
		if( i != n-1 )
			cout << " ";
	}
	cout << "\n" << c << "\n";

	return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
int N,k,s=0,i;
cin>>N;
vector<int>v;
  for(int i=0;i<N;i++)
  {
   	cin>>k;
    v.push_back(k);
  }
 for(i=0;i<N;i++)
 {
 	for(int j=i+1;j<N;j++)
    {
      s += (v[i]*v[j]);
    }
 }
cout<<s;
return 0;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
a = list(map(int,input().split()))
c = [[0]*n for i in range(3)]
c[0][0] = 1
town = 0
count = 0
while count <= n:
    count += 1
    town = a[town] -1
    c[0][town] += 1
    if c[0][town] == 2:
        c[2][town] = count
        roop_0 = town
        break
    else:
        c[1][town] = count
        
loop_size = c[2][roop_0] - c[1][roop_0]

if k < c[1][roop_0]:
    print(c[1].index(k)+1)
else:
    ans = c[1][roop_0]+((k-c[1][roop_0])%loop_size)
    print(c[1].index(ans)+1)

Measured memory_bytes: 32388
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const ll MOD = 1e9+7;
const bool debug = 0;
//-----------------------------------------------//

int H, W, D;
int cost[112345];
map<int, pii> conv;

int dfs(int x) {
	if (~cost[x]) return cost[x];
	if (x + D > H*W) return cost[x] = 0;
	else {
		pii p1 = conv[x];
		pii p2 = conv[x+D];
		return cost[x] = dfs(x + D) + abs(p1.fi - p2.fi) + abs(p1.se - p2.se);
	}
}

int main() {
	cin >> H >> W >> D;
	REP(i, H) REP(j, W) {
		int a; scanf("%d", &a);
		conv[a] = pii(i, j);
	}
	
	memset(cost, -1, sizeof(cost));
	int Q; cin >> Q;
	while (Q--) {
		int L, R;
		scanf("%d %d", &L, &R);
		printf("%d\n", dfs(L) - dfs(R));
		
	}
	
	return 0;
}


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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    int X,A;
    cin >> X >>A ;
    if (X<A) cout << 0 << endl;
    else cout << 10 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


int dp[2001][2001];
pii a[2001];
int n;

int calc(int l, int r)
{
	if (l > r)
		return 0;

	if (dp[l][r] != -1)
		return dp[l][r];

	int i = n + 1 - (r - l + 1);
	int id = a[i].ss;
	int ac = a[i].ff;

	return dp[l][r] = max(calc(l + 1, r) + ac * abs(l - id), calc(l, r - 1) + ac * abs(r - id));
}

int32_t main()
{
	FIO;
	cin >> n;
	memset(dp, -1, sizeof(dp));

	for (int i = 1; i <= n; ++i)
	{
		cin >> a[i].ff;
		a[i].ss = i;
	}

	sort(a + 1, a + n + 1, greater<pii>());

	cout << calc(1, n) << '\n';

	return 0;
}

Measured memory_bytes: 35108
#include <iostream>
#include <vector>

using namespace std;

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

    int ret = 0;

    if(a >= b)
    {
        ret+=a;
        a-=1;
    }else{
        ret+=b;
        b-=1;
    }
    if(a >= b)
    {
        ret+=a;
        a-=1;
    }else{
        ret+=b;
        b-=1;
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<utility>
#include<string.h>
using namespace std;
typedef pair<string,int> money;
int main()
{
int n,m,i,j,ans=-1,top=0;
string buf;
money e[210];
bool cn;
cin>>n;
for(i=0;i<n;i++)
{
cin>>buf;
cn=true;
for(j=0;j<top;j++)
{
if(strcmp(buf.c_str(),e[j].first.c_str())==0)
{e[j].second++;cn=false;}
}
if(cn)
{e[top].first=buf;e[top].second=1;top++;}
}
cin>>m;
for(i=0;i<m;i++)
{
cin>>buf;
cn=true;
for(j=0;j<top;j++)
{
if(strcmp(buf.c_str(),e[j].first.c_str())==0)
{e[j].second--;cn=false;}
}
if(cn)
{e[top].first=buf;e[top].second=-1;top++;}
}
for(i=0;i<top;i++)
if(e[i].second>ans)
ans=e[i].second;
if(ans==-1)ans=0;
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,fma,tune=native")
#include<bits/stdc++.h>
#define rall(x) x.rbegin(), x.rend()
#define all(x) x.begin(), x.end()
#define pb push_back
#include <x86intrin.h>
#define pb push_back
using namespace std;
using ll = long long;
using pi = pair<int, int>;
using vi = vector<ll>;
using vpi = vector<pi>;
using ld = long double;
const int maxn = 1e5 + 55, mod = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int fact[maxn], inv[maxn];
void setup() {
	fact[0] = fact[1] = inv[1] = inv[0] = 1;
	for(int i = 2; i < maxn; i++) inv[i] = mod - (mod/i)*1ll*inv[mod%i]%mod;
	for(int i = 2; i < maxn; i++) fact[i] = fact[i-1] * 1ll * i % mod, inv[i] = inv[i] * 1ll * inv[i-1] % mod;
}
int nck(int n, int k) {
	if(n<k) return 0;
	return (fact[n]*1ll*inv[k]%mod)*inv[n-k]%mod;
}
int G(int n, int k) {
	if(n <= 0 || k <= 0) return n==0&&k==0;
	return nck(n-1, k-1);
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	setup();
	int n, k, m;
	cin >> n >> k;
	m = n-k;
	for(int i = 1; i <= k; i++) {
		int t = (G(m, i-1) + 0ll + G(m, i)*2ll + G(m, i+1))%mod;
		t = t*1ll*nck(k-1, i-1)%mod;
		cout <<t  << '\n';
	}
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ALL(c) begin(c), end(c)
using namespace std;
using ll = long long;
using ld = long double;

const int N = 1111;


int u[N][N];

int main(){
	//freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout);
	ios::sync_with_stdio(0);cin.tie(0);//cout.precision(12);cout<<fixed;
	
	int n, m, sx, sy, tx, ty;
	
	cin>>n>>m>>sx>>sy>>tx>>ty;
	vector<string> a(n);
	for(auto &_ : a) cin>>_;
	
	--sx; --sy;
	--tx; --ty;
	
	
	int cn = 0;
	function<void(int,int)> go = [&](int i, int j){
		if(i<0 || j<0 || i>=n || j>=m || u[i][j] || a[i][j]=='#') return ;
		u[i][j] = cn;
		go(i+1,j);
		go(i-1,j);
		go(i,j+1);
		go(i,j-1);
	};
	
	for(int i=0;i<n;++i)
	for(int j=0;j<m;++j) if(a[i][j]=='.' && !u[i][j]){
		++cn;
		go(i,j);
	}
	
	
	vector<set<int>> g(cn+1);
	
	for(int i=0;i<n;++i)
	for(int j=0;j<m;++j) if(a[i][j]=='.'){
		int cur = u[i][j];
		for(int x=max(0,i-2); x<=min(n-1,i+2); ++x)
		for(int y=max(0,j-2); y<=min(m-1,j+2); ++y) if(a[x][y]=='.'){
			int v = u[x][y];
			if(v!=cur) g[cur].insert(v);
		}
	}
	
	vector<int> q = {u[sx][sy]};
	int inf = 1e9;
	vector<int> dist(cn+1, inf);
	dist[q[0]] = 0;
	
	for(int k=0;k<size(q);++k){
		int v = q[k];
		for(int i : g[v]) if(dist[i] > dist[v] + 1){
			dist[i] = dist[v] + 1;
			q.push_back(i);
		}
	}
	
	int ans = dist[u[tx][ty]];
	if(ans == inf) ans = -1;
	cout<<ans<<endl;
	
	
	
	return 0;
}


Measured memory_bytes: 33928
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from fractions import Fraction
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations, accumulate
from operator import add, mul, sub, itemgetter, attrgetter


import sys
# sys.setrecursionlimit(10**6)
# readline = sys.stdin.buffer.readline
readline = sys.stdin.readline

INF = 1 << 60


def read_int():
    return int(readline())


def read_int_n():
    return list(map(int, readline().split()))


def read_float():
    return float(readline())


def read_float_n():
    return list(map(float, readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()


def ep(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.perf_counter()
        ret = f(*args, **kwargs)
        e = time.perf_counter()

        ep(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, D):
    c  = 0
    for d1, d2 in D:
        if d1 == d2:
            c +=1
            if c >= 3:
                return 'Yes'
        else:
            c = 0
    return 'No'


def main():
    N = read_int()
    D = [read_int_n() for _ in range(N)]
    print(slv(N, D))


if __name__ == '__main__':
    main()


Measured memory_bytes: 78420
#include <iostream>

using namespace std;

int main(){
    string S;
    int ans=2;

    cin >>S;

    for(int i=0; i<S.size(); i++){
        if(S[i]==S.size()){
            break;
        }
        if (S[i]==S[i+1]){
            ans=1;
            break;
        }
    }
    if (ans==1){
        cout << "Bad";
    } else {
        cout << "Good";
    }
}




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

int n;

void dfs(string s, char c)
{
	if(s.size() == n)
	{
		puts(s.c_str());
		return;
	}
	for(char i='a'; i<c; i++) dfs(s + i, c);
	dfs(s + c, c + 1);
}

int main(int argc, char** argv)
{
	scanf("%d", &n);
	dfs(string(), 'a');
	return 0;
}

Measured memory_bytes: 1536
n = int(input())
sp = []
for i in range(n):
  s,p = input().split()
  sp.append([s, int(p), i+1])
sp.sort()

b = sp[0][0]
I = 0
ans = []
for s,p,i in sp:
  if b == s:
    ans.insert(I, i)
  else:
    ans.append(i)
    b = s
    I = len(ans)-1
print("\n".join(map(str, ans)))

Measured memory_bytes: 3064
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End


/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template

#define int long long

signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cini(N);
    Cins(A);
    Cins(B);
    Cins(C);
    int ans =0;
    rep(i,N){
        int maxNum = max(A[i],max(B[i],C[i]));
        int minNum = min(A[i],min(B[i],C[i]));
        int medNum = A[i]+B[i]+C[i]-maxNum-minNum;
        if(maxNum==minNum) continue;
        else if(maxNum != medNum && medNum != minNum){
            ans+=2;
        }else{
            ans++;
        }
    }
    cout << ans << nn;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9+7;
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};


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

    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n);
    rep(i,n){
        cin >> a[i] >> b[i] >> c[i];
    }
    vector<vector<int>> dp(n+1,vector<int> (3,0));
    rep(i,n){
        dp[i+1][0]=max(dp[i][1]+a[i],dp[i][2]+a[i]);
        dp[i+1][1]=max(dp[i][0]+b[i],dp[i][2]+b[i]);
        dp[i+1][2]=max(dp[i][0]+c[i],dp[i][1]+c[i]);
    }
    cout << max(dp[n][0],max(dp[n][1],dp[n][2])) << endl;


    cout << endl;
    return 0;
}


Measured memory_bytes: 6912
#include<stdio.h>

int main(void){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a<b){
        printf("a < b\n");
    }else if(a>b){
        printf("a > b\n");
    }else if(a==b){
        printf("a == b\n");
    }
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const ll INF = 1ll<<60;
const ll MAX_S = 2505;

struct Edge{
  ll to, a, b;
  Edge(ll to, ll a, ll b): to(to), a(a), b(b){}
};

struct Data{
  ll v, s, t;
  Data(ll v, ll s, ll t): v(v), s(s), t(t){}
  //小さい順なので逆向き  
  bool operator<(const Data& a) const{ return t > a.t; }
};


vector<Edge> g[50];
ll dp[50][MAX_S+5];

int main(void){
  ll n, m, s;
  cin >> n >> m >> s;

  REP(i, m){
    ll u, v, a, b;
    cin >> u >> v >> a >> b;
    u--; v--;
    g[u].emplace_back(v, a, b);
    g[v].emplace_back(u, a, b);
  }
  vector<ll> c(n), d(n);
  REP(i, n) cin >> c[i] >> d[i];

  REP(i, n) REP(j, MAX_S+5) dp[i][j] = INF;
  chmin(s, MAX_S);

  priority_queue<Data> q;
  auto push = [&](ll v, ll s, ll t){
    if(s < 0) return;
    if(dp[v][s] <= t) return;
    dp[v][s] = t;
    q.emplace(v, s, t);
  };
  push(0, s, 0);
  while(!q.empty()){
    Data data = q.top();
    q.pop();
    ll v = data.v;
    ll s = data.s;
    ll t = data.t;
    if(dp[v][s] != t) continue;
    //両替の場合
    ll ns = min(s+c[v], MAX_S);
    push(v, ns, t+d[v]);
    //移動の場合
    for(Edge e : g[v]){
      push(e.to, s-e.a, t+e.b);
    }
  }
  FOR(i, 1, n){
    ll ans = INF;
    REP(j, MAX_S+5) chmin(ans, dp[i][j]);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 7164
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#define debug(x)  cerr << #x << " = " << x << endl
using namespace std;
typedef long long ll;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

const int maxN = 50;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

ll gcd(ll a, ll b){return !b ? a : gcd(b, a % b);}
ll modP(ll a, ll b) {return (!b ? 1 : (modP(a, b / 2) * modP(a, b / 2) * (b % 2 ? a : 1)) % MOD);}

ll ans[maxN][maxN], dp[maxN][maxN], res[maxN][maxN];

void multiply(ll A[maxN][maxN], ll B[maxN][maxN]){
	memset(ans, 0, sizeof ans);
	for (int i = 0; i < maxN; i++){
		for (int j = 0; j < maxN; j++){
			for (int l = 0; l < maxN; l++){
				ans[i][j] = (ans[i][j] + A[i][l] * B[l][j]) % MOD;
			}
		}
	}
	memcpy(A, ans, sizeof ans);
}

void powmat(ll A[maxN][maxN], ll k){
	while (k != 0){
		if (k & 1){
			multiply(res, dp);
		}
		multiply(dp, dp);
		k >>= 1;
	}
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	ll k, sum = 0;
	cin >> k;
	memset(res, 0, sizeof res);
	for (int i = 0; i < n; i++){
		for (int j = 0; j < n; j++){
			cin >> dp[i][j];
		}
		res[i][i] = 1;
	}
	powmat(dp, k);
	for (int i = 0; i < n; i++){
		for (int j = 0; j < n; j++){
			sum = (sum + res[i][j]) % MOD;
		}
	}
	cout << sum << endl;
	return 0;
}



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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

struct Ford_Fulkerson {

    // 問題によって変わる
    static const int MAXV = 110;
    const int INF;

    Ford_Fulkerson() :INF(1e9+7) {}

    struct edge {
        int to, cap, rev;
        edge(int to, int cap, int rev) :to(to), cap(cap), rev(rev) {}
    };
    vector<edge> g[MAXV];
    bool used[MAXV];

    void add_edge(int from, int to, int cap) {
        g[from].emplace_back(to, cap, g[to].size());
        g[to].emplace_back(from, 0, g[from].size()-1);
    }

    // v -> tからの増加路を探す
    int dfs(int v, int t, int f) {
        if (v == t) return f;
        used[v] = 1;
        for (edge& e : g[v]) {
            if (used[e.to] or e.cap <= 0) continue;
            int d = dfs(e.to, t, min(f, e.cap));
            if (d > 0) {
                e.cap -= d;
                g[e.to][e.rev].cap += d;
                return d;
            }
        }
        return 0;
    }

    int max_flow(int s, int t) {
        int flow = 0;
        while (true) {
            fill(used, used+MAXV, false);
            int f = dfs(s, t, INF);
            if (f == 0) break;
            flow += f;
        }
        return flow;
    }
};

int main() {
    int V, E;
    cin >> V >> E;
    Ford_Fulkerson flow;
    rep(i, E) {
        int from, to, cap;
        cin >> from >> to >> cap;
        flow.add_edge(from, to, cap);
    }
    cout << flow.max_flow(0, V-1) << endl;
    return 0;
}



Measured memory_bytes: 3140
#pragma GCC optimize "-O3"
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx,avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx") 
#include"bits/stdc++.h"

using namespace std;

#define MAX 2000

int n;
int m;

vector<int> v[MAX];

queue<tuple<int, int, int> > q;

set<pair<int, int> > s;

bitset<MAX> con[MAX];

bitset<MAX>  child[MAX];
bitset<MAX> par[MAX];

bitset<MAX> stk;

inline void dfs(int b, int pr = -1) {
	auto &c = child[b];
	c.set(b, 1);
	for (int go : v[b]) {
		if (go == pr)continue;
		dfs(go, b);
		c |= child[go];
	}
}

int pat[MAX][MAX];
int lca[MAX][MAX];

int dep[MAX];


inline void dfs2(int b, int pr = -1, int star = 0) {
	pat[star][b] = pr;
	lca[star][b] = b;
	if (pr != -1) {
		if (lca[star][pr] != -1) {
			if (dep[lca[star][pr]] < dep[b]) {
				lca[star][b] = lca[star][pr];
			}
		}
	}
	for (int go : v[b]) {
		if (go == pr)continue;
		dfs2(go, b, star);
	}
}
inline void dfs3(int b, int pr = -1, int d = 0) {
	stk.set(b, 1);
	par[b] = stk;
	dep[b] = d;
	for (int go : v[b]) {
		if (go == pr)continue;
		dfs3(go, b, d + 1);
	}
	stk.set(b, 0);
}
bitset<MAX> ff;
int main() {
	cin >> n >> m;
	for (int i = 1; i < n; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		a--;
		b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	dfs3(0);
	dfs(0);
	for (int i = 0; i < n; i++) {
		dfs2(i, -1, i);
	}
	int edd = 0;
	for (int i = 0; i < m; i++) {
		int c, d;
		scanf("%d%d", &c, &d);
		c--;
		d--;
		con[c].set(d, 1);
		con[d].set(c, 1);
		q.push(make_tuple(0, c, d));
		edd++;
	}
	bitset<MAX> full;
	for (int i = 0; i < n; i++) {
		full.set(i);
	}
	while (!q.empty()) {
		int centre, lef, rig;
		tie(centre, lef, rig) = q.front();
		q.pop();
		int A = lef;
		int B = rig;
		ff.reset();
		if (lca[A][B] == B) {
			swap(A, B);
		}
		if (lca[A][B] == A) {
			ff = child[B] ^ full^child[pat[B][A]] ^ par[B] ^ par[A];
		}
		else {
			ff = child[B] ^ child[A] ^ par[A] ^ par[B];
			ff.set(lca[A][B]);
		}
		ff &= con[A] ^ con[B];
		//the node unconnected to node B
		//connected to A
		//the node is available at the pair(A,B)
		for (int i = (int)ff._Find_first(); i < n; i = (int)ff._Find_next(i)) {
			if (i == A || i == B)continue;
			if (con[B].test(i)) {
				swap(A, B);
			}
			q.push(make_tuple(A, i, B));
			con[i].set(B);
			con[B].set(i);
			edd++;
		}
	}
	cout << edd << endl;
	return 0;
}

Measured memory_bytes: 57396
#include <iostream>
#include <cmath>
#include <string>

using namespace std;

int main()
{
	string S;
	long long ans = 0;
	int N;
	cin >> S;

	N = pow(2, S.size() - 1);
	
	ans += atoll(S.c_str());
	for (int i = 1; i < N; i++)
	{
		int count = 1;
		int index = 0;
		for (int mask = 1; mask < N;mask <<= 1)
		{
			if (i & mask)
			{
				ans += atoll(S.substr(index, count).c_str());
				index += count;
				count = 1;
			}
			else
				count++;
		}

		ans += atoll(S.substr(index, count).c_str());
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 384
using System;

class Program
{
    static void Main(string[] args)
    {
        var ab = Console.ReadLine().Split();
        var a = long.Parse(ab[0]);
        var b = long.Parse(ab[1]);
        Console.WriteLine(f(a - 1) ^ f(b));
    }

    static long f(long n)
    {
        if (n <= 0) return 0;
        var ans = n;
        for (int i = 1; i <= n % 4; i++) ans ^= n - i;
        return ans;
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cctype>
#include <ctime>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define eps 1e-9
#define SZ(x) ((int)x.size())

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

int main() {
#ifdef __AiR_H
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif // __AiR_H
    scanf("%lld %lld", &x, &y);
    if (x > y) { swap(x, y); }
    if (y - x <= 1) { printf("Brown\n"); }
    else { printf("Alice\n"); }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	int N, M;
	cin >> N >> M;
	vector<int> H(N);
	for (auto i = 0; i < N; ++i)
	{
		cin >> H[i];
	}

	vector<bool> good(N, true);
	for (auto i = 0; i < M; ++i)
	{
		int A, B;
		cin >> A >> B;
		--A;
		--B;
		if (H[A] <= H[B])
		{
			good[A] = false;
		}
		if (H[B] <= H[A])
		{
			good[B] = false;
		}
	}

	auto ans = 0;
	for (auto i = 0; i < N; ++i)
	{
		if (good[i] != false)
		{
			++ans;
		}
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;

#define ll long long
#define PI 3.14159265358979323846264338327950L

ll r;

void solve(){

    cin >> r;
    cout << setprecision(20) << 2*PI*r << endl;
}





int main(){

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

    solve();

}

Measured memory_bytes: 3796
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  int n,m;
  cin>>n>>m;
  vector<int> h(n);
  for(auto&& e: h) 
  {
    cin>>e;
  }
  vector<bool> good(n,true);
  for (int i = 0; i < m; ++i)
  {
    int a,b;
    cin>>a>>b;
    a--;b--;
    if(h[a]>h[b]) good[b]=false;
    else if(h[a]<h[b]) good[a]=false;
    else
    {
      good[a]=false;
      good[b]=false;
    }
  }
  int cnt=0;
  for (int i = 0; i < n; ++i)
  {
    if(good[i]) cnt++;
  }
  cout<<cnt;
}

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




int main(){

  int n;
  cin >> n;
  vector<vector<int>> d(n,vector<int>(2));

  for(int i=0; i<n; i++){
    cin >> d.at(i).at(0) >> d.at(i).at(1);
  }

  int count = 0;
  for(int i=0; i<n; i++){
    if(d.at(i).at(0)==d.at(i).at(1)){
      count++;
    }
    else{
      count = 0;
    }
    if(count>=3){
      cout <<"Yes"<<endl;
      return 0;
    }
  }
  cout <<"No"<<endl;

}

Measured memory_bytes: 3628
q=int(input())
lr=[tuple(map(int,input().split())) for _ in range(q)]

n=10**5
ansl=[]
sieve=[1]*(n+1)
sieve[0],sieve[1]=0,0
for i in range(2,n):
  if sieve[i]:
    for j in range(2*i,n+1,i):
      sieve[j]=0
ans=[0]*(n+1)
for i in range(3,n):
  if sieve[i]==1 and sieve[(i+1)//2]==1:
    ans[i]=ans[i-1]+1
  else:
    ans[i]=ans[i-1]

for e in lr:
  print(ans[e[1]]-ans[e[0]-1])


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

using namespace std;

#pragma GCC optimize("O3")
static const auto __ = [] {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  return nullptr;
}();

int solve() {
  for (int i = 0; i < 5; ++i) {
    int x;
    cin >> x;
    if (x == 0) {
      return i + 1;
    }
  }
  return -1;
}

int main(int argc, char* argv[]) {
  cout << solve() << '\n';
  return 0;
}

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

int main(){
	int n, i, dt, dst;
	int t[100009], x[100009], y[100009];
	bool can=true;
	cin>>n;
	for(i=0; i<n; i++) cin>>t[i+1]>>x[i+1]>>y[i+1];
	for(i=0; i<n; i++){
		dt=t[i+1]-t[i];
		dst=abs(x[i+1]-x[i])+abs(y[i+1]-y[i]);
		if(dt<dst || dst%2!=dt%2) can=false;
	}
	can ? cout<<"Yes"<<endl : cout<<"No"<<endl;
	return 0;
}

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

int main(){
    int n;
    string s;
    cin >> n >> s;
    if(n%2!=0){
        cout << "No" << endl;
        return 0;
    }
    else{
    for(int i=0;i<n/2;i++){
        if(s[i]!=s[n/2+i]){
            cout << "No" << endl;
            return 0;
        }
    }
    }
    cout << "Yes" << endl;
}




Measured memory_bytes: 3592
#include <stdio.h>

int main(){
  int ret;
  int num = 0;
  char s,bin = '0';
  while(1){
    ret = scanf("%c",&s);
    if(ret == EOF || s == '\n') break;
    else if(s != bin) num++;
    bin = s;
  }
  num--;
  printf("%d\n",num);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
// typedef long int int32;
// typedef unsigned long int uint32;
// typedef long long int int64;
// typedef unsigned long long int  uint64;
////////////////////
bool isPal(const string &s1) {
    string s2(s1.rbegin(), s1.rend());
    return s1 == s2;
}
int main() {
    string S;
    cin >> S;
    // S = "akasaka";
    int n = S.size();
    
    if(isPal(S) && isPal(S.substr(0, (n-1)/2)) && isPal(S.substr((n+1)/2))) {
         cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int gcd(int a,int b){
	if(!b) return a;
	return gcd(b,a%b);
}

int x,y;

int main(){
	cin>>x>>y;
	int g=gcd(x,y);
	cout<<(x/g+y/g-1)*g+1<<endl;
}


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

int main(){
    float D,T,S;
    cin >> D >> T >> S;
    if(S==0){
        cout << "No" << endl;
    }else if(D/S <= T){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3716
n = int(input())
a = [[-1for _ in range(n)]for _ in range(n)]

ans = 0

for i in range(n):
  m = int(input())
  for j in range(m):
    x,y = map(int,input().split())
    a[i][x-1] = y

for i in range(2**n):
  #bit全探索
  #d:正直者と仮定してる人
  d = []
  p = len(bin(i))
  q = bin(i)
  for j in range(p-2):
    q = bin(i>>j)
    if int(q[len(q)-1]) == 1:
      d.append(j)
  #print(d)

  res = True
  for j in d:
    for k in range(n):
      #jさんがkさんの事を正直者だと思ってた時
      if a[j][k] == 1:
        if k not in d:
          res = False
      #jさんがkさんのことを不親切な人と思ってた時
      elif a[j][k] == 0:
        if k in d:
          res = False
  if res:
    ans = max(ans,len(d))

print(ans)


Measured memory_bytes: 3064
#include <stdio.h>

int l=0, r=100, b=0, u=100;
int mat[101][101]={0};  //0:black, 1:white

void left(int xx){
    if(l<xx){
        for(int i=b; i<=u; i++){
            for(int j=l; j<=xx; j++){
                mat[i][j]=0;
            }
        }
        l=xx;
    }
}
void right(int xx){
    if(xx<r){
        for(int i=b; i<=u; i++){
            for(int j=xx+1; j<=r; j++){
                mat[i][j]=0;
            }
        }
        r=xx;
    }
}
void bottom(int yy){
    if(b<yy){
        for(int i=b; i<=yy; i++){
            for(int j=l; j<=r; j++){
                mat[i][j]=0;
            }
        }
        b=yy;
    }
}
void up(int yy){
    if(yy<u){
        for(int i=yy+1; i<=u; i++){
            for(int j=l; j<=r; j++){
                mat[i][j]=0;
            }
        }
        u=yy;
    }
}

int main(){
    int w,h,n,x,y,a,i,j,cnt=0;
    scanf("%d %d %d", &w, &h, &n);
    for(i=1; i<=h; i++){
        for(j=1; j<=w; j++){
            mat[i][j]=1;
        }
    }
    
    for(i=1; i<=n; i++){
        scanf("%d %d %d", &x, &y, &a);
        switch (a){
            case 1: left(x); break;
            case 2: right(x); break;
            case 3: bottom(y); break;
            default: up(y);
        }
    }
    
    for(i=1; i<=h; i++) {
        for(j=1; j<=w; j++){
//            printf("%d ", mat[i][j]);
            if(mat[i][j]==1) cnt++;
        }
//        printf("\n");
    }
    printf("%d\n", cnt);
    return 0;
}


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

int main(void)
{
    int n, w, h;
    int koto_w[100005] = {};
    int koto_h[100005] = {};
    int i, j, k, l;
    int a, b, c;
    int flag1 = 1;
    int flag2 = 1;
    l = 1;
    cin >> n >> w >> h;
    for(i = 0; i < n; i++){
        cin >> a >> b >> c;
        if(koto_w[a] < c){ koto_w[a] = c;}
        if(koto_h[b] < c){ koto_h[b] = c;}
    }
    /*for(i = 0; i <= w; i++){
        cout << koto_w[i] << " ";
    }
    cout << endl;
    for(i = 0; i <= h; i++){
        cout << koto_h[i] << " ";
    }
    cout << endl;
    */
    i = 0;
    j = -1;
    while(1){
        if(koto_w[i] != 0){
            //????????§??????
            if(j >= koto_w[i]){
                i++;
                j++;
                if(i == w){
                    flag1 = 0;
                    break;
                }
                continue;
                } //????????£????????¨???
            if(j > -1-koto_w[i]){
                j = -1-koto_w[i];
            }
        }
        i++;
        j++;
        //cout << i << endl;
        //???????????§??????
        if(i == w){
            j = j - koto_w[i];
            if(j >= 0){
                flag1 = 0;
                break;
            }else{
                break;
            }
        }
    }

    i = 0;
    j = -1;
    while(1){
        if(koto_h[i] != 0){
            //????????§??????
            if(j >= koto_h[i]){
                i++;
                j++;
                if(i == h){
                    flag2 = 0;
                    break;
                }
                continue;
                } //????????£????????¨???
            if(j > -1-koto_h[i]){
                j = -1-koto_h[i];
            }
        }
        i++;
        j++;
        //???????????§??????
        if(i == h){
            j = j - koto_h[i];
            if(j >= 0){
                flag2 = 0;
                break;
            }else{
                break;
            }
        }
    }
    if(flag1 || flag2){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;

}

Measured memory_bytes: 3888
class Dice:
    def __init__(self, num_list):
        self.vertical_faces = [num_list[0], num_list[1], num_list[5], num_list[4]]
        self.horizonal_faces = [num_list[0], num_list[3], num_list[5], num_list[2]]

    def roll(self, direction):
        if direction == 'N':
            self.vertical_faces = self.vertical_faces[1:] + self.vertical_faces[:1]
            self.horizonal_faces[0] = self.vertical_faces[0]
            self.horizonal_faces[2] = self.vertical_faces[2]
        elif direction == 'S':
            self.vertical_faces = self.vertical_faces[3:] + self.vertical_faces[:3]
            self.horizonal_faces[0] = self.vertical_faces[0]
            self.horizonal_faces[2] = self.vertical_faces[2]
        elif direction == 'E':
            self.horizonal_faces = self.horizonal_faces[1:] + self.horizonal_faces[:1]
            self.vertical_faces[0] = self.horizonal_faces[0]
            self.vertical_faces[2] = self.horizonal_faces[2]
        else:
            self.horizonal_faces = self.horizonal_faces[3:] + self.horizonal_faces[:3]
            self.vertical_faces[0] = self.horizonal_faces[0]
            self.vertical_faces[2] = self.horizonal_faces[2]

num_list = list(map(int, input().split()))

dice = Dice(num_list)

directions = input()

for i in directions:
    dice.roll(i)

print(dice.vertical_faces[0])

Measured memory_bytes: 7800
from collections import Counter

N = int(input())
A = list(map(int,input().split()))

c = Counter(A)

t = 0
for a in A:
    t ^= a

if c[0] == N:
    print('Yes')
elif N % 3 == 0:
    if c[0] == int(N//3) and len(c) == 2:
        print('Yes')
    elif len(c) == 3 and t == 0:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Measured memory_bytes: 20840
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
 
int main()
{
int a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  
  if(a==0)
    cout<<1<<endl;
  else if(b==0)
    cout<<2<<endl;
  else if(c==0)
    cout<<3<<endl;
  else if(d==0)
    cout<<4<<endl;
  else if(e==0)
    cout<<5<<endl;

  return 0;
}


Measured memory_bytes: 3480
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main(){
	int a,b,sum=0,cnt=0,num=0;
	while(scanf("%d,%d",&a,&b)>0){
		sum+=(a*b);cnt++;num+=b;
	}
	double ave=(double)num/(double)cnt;
	int avei=round(ave);
	cout<<sum<<endl<<avei<<endl;
	return 0;
}

Measured memory_bytes: 3116
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.Math;

public class Main {
    public static void main(String[] args) {
        FS reader = new FS();
        // write reader
        int N = reader.nextInt();
        int M = reader.nextInt();
        PriorityQueue<Integer> pq = new PriorityQueue<Integer>(Collections.reverseOrder());
        for (int i=0; i<N; i++) {
            pq.add(reader.nextInt());
        }
        for (int i=0; i<M; i++) {
            int tmp = pq.poll();
            pq.add(tmp/2);
        }
        long ans = 0;
        while (!pq.isEmpty()) {
            ans += pq.poll();
        }
        System.out.println(ans);
    }
    
    public static void solver() {
        // write logic
    }
    
    // Read Class
    static class FS {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
    
        private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
        private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
        private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public int nextInt() {
            return (int)nextLong();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if(b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
    }
}



Measured memory_bytes: 27224
#include <bits/stdc++.h>
using namespace std;
#define ll long long
# define pi 3.141592
int main()
{
    int n;
    cin >> n;
    int arr[n-1];
    map<int,int>mp;
    for(int i = 1; i < n+1; i++) mp[i] = 0;
    for(int i = 0; i < n-1; i++)
    {
        cin >> arr[i];
        mp[arr[i]]++;
    }
    for(auto u:mp)
    {
        cout << u.second << endl;
    }
}


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

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    vector<int> a(n);
    vector<int> b(m);
    vector<long long> acc_a(n + 1, 0);
    vector<long long> acc_b(m + 1, 0);

    rep(i, n){
        cin >> a[i];
        acc_a[i + 1] = acc_a[i] + a[i];
    }
    rep(i, m){
        cin >> b[i];
        acc_b[i + 1] = acc_b[i] + b[i];
    }
    
    int res = 0;
    rep(i, n + 1){
        long long left = k - acc_a[i];
        if (left < 0) continue;
        auto upper = upper_bound(all(acc_b), left) - 1;
        int index = upper - acc_b.begin();
        int cand = i + index;
        //cout << "index:" << i << " left " << left << " cand " << cand << " res " << res << endl;
        if (res < cand) res = cand;
    }
    cout << res << endl;
}

Measured memory_bytes: 8012