akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int n; cin >> n;
  vector<int> a(n); for(int i=0;i<n;i++) cin >> a[i];
  sort(a.begin(),a.end());
  int r = a[n-1];
  int idx = upper_bound(a.begin(),a.end(),r/2) - a.begin();
  int l, dif = INT_MAX;
  for(int i=0;i<n-1;i++){
  	if(abs(2 * a[i] - r) < dif){dif = abs(2*a[i] - r); l = a[i];}
  }
  cout << r << " " << l << endl; 
  return 0;
}
  

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

int main() {
  int x,y,z;cin>>x>>y>>z;
  int ans=x/(y+z);
  int a=x%(y+z);
  if(a==z)cout<<ans<<endl;
  else cout<<ans-1<<endl;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
int a,b,c;
int main(){
	ios::sync_with_stdio(0);
	cin>>a>>b>>c;
	swap(a,b);
	swap(a,c);
	cout<<a<<" "<<b<<" "<<c;
	re 0;
}

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

typedef struct
{
    int parent;
    vector<int> children;
    int length;
    int depth;
} NODE;

NODE nodes[200004];
vector<int> connection[200004];

int maketree(int index, int parent, int d)
{
    nodes[index].parent = parent;
    nodes[index].depth = d;
    int ml = 0;
    for( int j = 0; j < (int)connection[index].size(); j++ )
    {
        if( connection[index][j] != parent )
        {
            int tl = maketree( connection[index][j], index, d + 1 );
            nodes[index].children.push_back(connection[index][j]);
            ml = max(ml, tl);
        }
    }
    nodes[index].length = ml + 1;
    return nodes[index].length;
}

int main()
{
    int n, u, v;
    cin >> n >> u >> v;
    u--;
    v--;
    for( int i = 0; i < n - 1; i++ )
    {
        int a, b;
        cin >> a;
        cin >> b;
        a--;
        b--;
        connection[a].push_back(b);
        connection[b].push_back(a);
    }

    maketree(v, -1, 0);
    int dl = 0;
    int current = u;
    for( int b = 0; b <= (nodes[u].depth - 1) / 2; b++ )
    {
        int tdl = nodes[current].depth + nodes[current].length - 1;
        dl = max(dl, tdl);
        current = nodes[current].parent;
    }
    cout << dl - 1;   
}

Measured memory_bytes: 29728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int main(){
  ll N,M; cin >> N >> M;
  vector<ll> a(M), b(M);
  vector<vector<ll>> c(M, vector<ll>(N,0));
  REP(i,M){
    cin >> a[i] >> b[i];
    REP(j, b[i]){
      ll x; cin >> x;
      x--;
      c[i][x] = 1;
    }
  }
  ll K = 1<<N;
  const ll INF = 1e18;
  vector<ll> dp(K, INF);
  dp[0] = 0;
  REP(i,K){
    REP(j,M){
      ll t = i;
      //tにbit演算
      REP(k,N){
        t = t | (c[j][k]<<k);
      }
      chmin(dp[t],dp[i] + a[j]);
    }
  }
  // REP(i,K){
  //   DUMP(i);
  //   DUMP(dp[i]);
  // }
  if(dp[K-1] == INF) cout << -1 << endl;
  else cout << dp[K-1] << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){string s;cin>>s;s='0'+s;
int n=s.size(),x=s[n-1]-'0',d[n+1][2];d[1][0]=x;d[1][1]=10-x;
for(int i=1;i<n;i++){x=s[n-1-i]-'0';d[i+1][0]=min(d[i][0]+x,d[i][1]+x+1);d[i+1][1]=min(d[i][0]+10-x,d[i][1]+9-x);}
cout<<min(d[n][0],d[n][1]);}


Measured memory_bytes: 9136
//g++ -std=c++17 -Wshadow -Wall -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -g PROGRAM -o OUTPUT -DLOCAL -lasan -lubsan
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define alli(a, n, k) (a + k), (a + n + k)
#define FP(i, a, b, k) for (__typeof(a) i = a; i < b; i += k)
#define FS(i, a, b, k) for (__typeof(a) i = a; i > b; i -= k)
#define IT(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
using namespace __gnu_pbds;

template <class T>
inline T gcd(T x, T y)
{
    if (!y)
        return x;
    return gcd(y, x % y);
}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector<pair<int, int>> VPII;
typedef vector<pair<int, PII>> VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;


inline ll modulo(ll a, ll m)
{
    return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
    assert(__gcd(a, m) == 1);
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
        return 0;

    while (a > 1)
    {
        ll q = a / m;
        ll t = m;

        m = a % m, a = t;
        t = y;

        y = x - q * y;
        x = t;
    }

    if (x < 0)
        x += m0;

    return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
    if (y == 0)
        return 1LL;
    else if (y == 1)
        return x;
    else
    {
        ll ans = modPow(x, y / 2, m) % m;
        if (y & 1)
        {
            return (((ans * ans) % m) * x) % m;
        }
        else
        {
            return (ans * ans) % m;
        }
    }
}

vector<string> split(char d,string s)
{
    stringstream ss(s);
    string t;
    vector<string> words;
    while(getline(ss,t,d))
    {
        words.pb(t);
    }

    return words;
}
ll findDivisors(int n)
{
    ll ans = 0;
    VLL div(n+1,0);

    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j * i <= n; j++)
            div[i * j]++;
    }

    for (int i = 1; i <= n; i++)
        ans = ans + i * div[i] * 1LL;

    return ans;
}
int main(int argc, char *argv[])
{
#ifdef LOCAL
    auto start = chrono::high_resolution_clock::now();
#endif
    
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    

    cout << findDivisors(n);

#ifdef LOCAL
    auto end = chrono::high_resolution_clock::now();
    double time_taken =
        chrono::duration_cast<chrono::nanoseconds>(end - start).count();

    time_taken *= 1e-9;

    cerr << "\nTime taken by program is : " << fixed
         << time_taken << setprecision(9);
    cerr << " sec" << endl;
#endif
    return 0;
}


Measured memory_bytes: 81348
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <cmath>
#include <iomanip>
#include <tuple>
#include <map>
using namespace std;
typedef long long ll;

vector<char> f = {'R','G','B'};

int main() {
    int n; cin >> n;
    string s; cin >> s;
    int size = s.size();
    int sum_r,sum_g,sum_b;
    sum_r = sum_g = sum_b = 0;
    vector<int> rs(size),gs(size),bs(size);
    for (int i = 0; i < size; i++) {
        if (i != 0) rs[i] += rs[i-1], gs[i] += gs[i-1], bs[i] += bs[i-1];
        if (s[i] == 'R') rs[i]++;
        else if (s[i] == 'G') gs[i]++;
        else bs[i]++;
    }
    for (int i = 0; i < size; i++) rs[i] = rs[size-1] - rs[i], gs[i] = gs[size-1] - gs[i], bs[i] = bs[size-1] -bs[i];
    ll ans = 0;
    for (int i = 0; i < size; i++) {
        map<char,int> mp;
        mp['R'] = mp['G'] = mp['B'] = 0;
        mp[s[i]] = 1;
        for (int j = i + 1; j < size; j++) {
            if (mp[s[j]]) continue;
            mp[s[j]] = 1;
            if (mp['R'] == 0) {
                ans += rs[j];
                if (rs[j] > 0 && 2 * j - i < size && s[2 * j - i] == 'R') ans--;
            } else if (mp['G'] == 0) {
                ans += gs[j];
                if (gs[j] > 0 && 2 * j - i < size && s[2 * j - i] == 'G') ans--; 
            } else {
                ans += bs[j];
                if (bs[j] > 0 && 2 * j - i < size && s[2 * j - i] == 'B') ans--;
            }
            mp[s[j]] = 0;
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3696
#include<bits/stdc++.h>
#define ld double
#define ull unsigned long long
#define ll long long
#define pii pair<int,int >
#define iiii pair<int,pii >
#define mp make_pair
#define INF 1000000000
#define MOD 1000000007
#define rep(i,x) for(int (i)=0;(i)<(x);(i)++)
inline int getint(){
	int x=0,p=1;char c=getchar();
	while (c<=32)c=getchar();
	if(c==45)p=-p,c=getchar();
	while (c>32)x=x*10+c-48,c=getchar();
	return x*p;
}
using namespace std;
//ruogu
const int N=1e5+5;
int n,res[N];
vector<pii >a;
//
int main(){
	n=getint();
	rep(i,n)a.push_back(mp(getint(),i));
	sort(a.begin(),a.end());
	rep(i,n)res[i]=a[i].second;
	rep(i,n)cout<<res[i]+1<<" ";
	return 0;
}


Measured memory_bytes: 2164
import math
n=int(input())
sn=int(math.sqrt(n))
tl=list(range(1,sn+1))
ans=0
for i in range(1,sn+1):
    a=n/tl[-i]
    if a.is_integer():
        ans=int(a)
        break
b=int(n/ans)
print(ans-1+b-1)

Measured memory_bytes: 43508
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;


int main(int argc, char* argv[])
{
    ll n;
    scanf("%lld", &n);

    if(n%2) {
        printf("0\n"); return 0;
    }

    ll ans=0;
    ll m=n/2;
    ll curr=1;
    int i;
    for(i=1; i<40; i++) {
        curr*=5;
        if(curr>m) break;
        ans+=(m/curr);
    }
    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 128
'use strict'

function Main(input){
	const b = input.trim();

	const answer = new Array(b.length);
	for(let i=0,l=b.length;i<l;i++){
		switch(b[i]){
			case 'A': answer[i] = 'T'; break;
			case 'T': answer[i] = 'A'; break;
			case 'C': answer[i] = 'G'; break;
			case 'G': answer[i] = 'C'; break;
		}
	}
	console.log(answer.join(''));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
int main(void){
    ll x, k, d;
    cin >> x >> k >> d;
    x = abs(x);
    ll ans = 0;
    if(x / d >= k){
        ans = x - k * d;
    } else {
        ll rest = k - x / d;
        if(rest % 2 == 0){
            if(x % d == 0){
                ans = 0;
            } else {
                ans = x % d;
            }
        } else {
            if(x % d == 0){
                ans = d;
            } else {
                ans = d - (x % d);
            }
        }
    }
    cout << ans << endl;
}

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

int main()
{
    int a,b,c,d,i,s;
    while(~scanf("%d%d%d%d",&a,&b,&c,&d))
    {
        i=1,s=0;
        while(i<=a)
        {
            if(i>b)
            {
                c=d;
            }
            s+=c;
            i++;
        }
        printf("%d\n",s);
    }
}


Measured memory_bytes: 128
#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<ll,pll> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

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

ll a,b;

int main(){
	cin>>a>>b;
	ll g=gcd(a,b),t=1;
	for(ll i=2;i*i<=g;i++) if(g%i==0){
		t++;
		while(g%i==0) g/=i;
	}
	if(g>1) t++;
	cout<<t<<endl;
}

Measured memory_bytes: 256
/*{{{*/
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB emplace_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    string s;
    R(s);
    W((s[2]==s[3]&&s[4]==s[5])?"Yes":"No");
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    static Scanner sc = new Scanner(System.in);
    static StringBuffer sb = new StringBuffer();
    public static void main(String args[]){
        int N=sc.nextInt();
        String s=sc.next(),t=sc.next();
        for(int i=0;i<=N;i++){
            String S=s.substring(i),T=t.substring(0,N-i);
            if(S.equals(T)){
                sb.append(s.substring(0,i));
                sb.append(t);
                break;
            }
        }
        int res=sb.toString().length();
        System.out.println(res);
    }
}


Measured memory_bytes: 35600
'use strict'

const main = input => {
	const c = input.trim()
	if (c === 'a') console.log('vowel')
	else if (c === 'e') console.log('vowel')
	else if (c === 'i') console.log('vowel')
	else if (c === 'o') console.log('vowel')
	else if (c === 'u') console.log('vowel')
	else console.log('consonant')
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 21064
#include<stdio.h>
int main(){
    int A,B,N;
    int train = 0,taxi = 0;
    scanf("%d %d %d",&N,&A,&B);
    train = N * A;
    taxi = B;
    if(train <= taxi){
        printf("%d",train);
    }else{
        printf("%d",taxi);
    }
    return 0;
}


Measured memory_bytes: 128
n = gets.to_i
a = gets.split.map!(&:to_i).sort!

m = 10 ** 18

if a[0] == 0
  puts 0
  exit
end

prod = 1
z = a.reverse_each do |x|
  prod *= x
  break if prod > m
end

puts (z ? prod : -1)


Measured memory_bytes: 21776
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  int i;
  int cnt = 0;
  for(i=0;i<n;i++) cin >> a[i];
  for(i=0;i<n;i++){
    while(1){
      if(a[i]%2==0){
        a[i] /= 2;
        cnt++;
      }
      else break;
    }
  }
  cout << cnt << "\n";
  return 0;
}

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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;

int main()
{
  int N, K;
  cin >> N >> K;
  vector<int> h(N);
  for (int i = 0; i < N; i++)
    cin >> h[i];
  int ans = 0;
  for (int i = 0; i < N; i++)
    if (h[i] >= K)
      ans++;
  cout << ans << endl;
}


Measured memory_bytes: 640
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      String s = sc.next();
      int cnt = 0;
      for(char i = '0'; i <= '9'; i++) {
        for(char j = '0'; j <= '9'; j++) {
          for(char k = '0'; k <= '9'; k++) {
              StringBuilder sb = new StringBuilder();
              sb.append(i); sb.append(j); sb.append(k);
            if(isValid(s, sb.toString()))
              cnt++;
          }
        }
      }
      System.out.println(cnt);
  }
  private static boolean isValid(String s, String t) {
    for(int i = 0, j = 0; i < s.length() && j < t.length(); i++) {
      if(t.charAt(j) == s.charAt(i)) {
        j++;
        if(j == t.length())
          return true;
      }
    }

    return false;
  }
}

Measured memory_bytes: 22228
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define db(x) cout<<#x<<"="<<x<<endl
#define deb(x) each(x.begin(),x.end(),(int& y){cout << y <<" ";})
template<class T>bool maxi(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool mini(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF2 4000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;

void Main(){

  int N,M; cin>>N>>M;
  int s[N],t[M]; //sとtの最長共通部分列

  rep(i,N){
    cin>>s[i];
  }
  rep(i,M){
    cin>>t[i];
  }

  ll dp[N+1][M+1]={};
  rep(i,N+1){
    rep(j,M+1){
      if(i==0 or j==0) dp[i][j]=1;
    }
  }

  dp[0][0]=1;

  reps(i,1,N+1){
    reps(j,1,M+1){
      if(s[i-1]==t[j-1]) dp[i][j] += dp[i-1][j-1];
      dp[i][j]+=dp[i][j-1]+dp[i-1][j]-dp[i-1][j-1];
      dp[i][j]+=MOD;
      dp[i][j]%=MOD;
      //cout<< i <<" "<<j <<"\n";
      //db(dp[i][j]);
    }
  }
  cout<< dp[N][M] <<"\n";

}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 31616
#include<bits/stdc++.h>
#define fo(i, x, y) for(int i = x, B = y; i <= B; i ++)
#define ff(i, x, y) for(int i = x, B = y; i <  B; i ++)
#define fd(i, x, y) for(int i = x, B = y; i >= B; i --)
#define ll long long
#define pp printf
#define hh pp("\n")
using namespace std;

const int mo = 1e9 + 7;

ll ksm(ll x, ll y) {
	ll s = 1;
	for(; y; y /= 2, x = x * x % mo)
		if(y & 1) s = s * x % mo;
	return s;
}

const int N = (1 << 16) + 5;

int a2[20];
int n, m, a[20];
ll fac[N], nf[N];
ll f[2][N]; int o;

void build(int n) {
	fac[0] = 1; fo(i, 1, n) fac[i] = fac[i - 1] * i % mo;
	nf[n] = ksm(fac[n], mo - 2); fd(i, n, 1) nf[i - 1] = nf[i] * i % mo;
}

ll C(int n, int m) {
	if(n < m || m < 0) return 0;
	return fac[n] * nf[n - m] % mo * nf[m] % mo;
}

int main() {
	a2[0] = 1; fo(i, 1, 16) a2[i] = a2[i - 1] * 2;
	scanf("%d %d", &n, &m);
	build(1 << n);
	fo(i, 1, m) scanf("%d", &a[i]);
	sort(a + 1, a + m + 1);
	f[0][0] = 1;
	fd(i, m, 1) {
		memcpy(f[!o], f[o], sizeof f[o]);
		ff(j, 0, a2[n]) if(f[o][j]) {
			fo(u, 0, n - 1)  if(!(j >> u & 1)) {
				int nj = j | a2[u];
				f[!o][nj] = (f[!o][nj] - f[o][j] * C(a2[n] - a[i] - j, a2[u] - 1) % mo * fac[a2[u]]) % mo;
			}
		}
		o = !o;
	}
	ll ans = 0;
	ff(j, 0, a2[n]) if(f[o][j]) {
		ans = (ans + f[o][j] * fac[a2[n] - 1 - j]) % mo;
	}
	ans = (ans % mo + mo) * a2[n] % mo;
	pp("%lld\n", ans);
}

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

int main() {
    int n, a, b;
    scanf("%d%d%d", &n, &a, &b);
    int ans = n;
    while(n--) {
        int x;
        scanf("%d", &x);
        if(x >= a && x < b) ans--;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;


bool operator<(const vector<int>&l, const vector<int>&r) {
	for (int i = 0; i < l.size(); ++i) {
		if(l[i]<r[i])return true;
		else if(l[i]==r[i])continue;
		else return false;
	}
	return false;
}

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

	map<vector<int>,int>mp;
	map<int,vector<int>>rev_mp;
	vector<int>v(3);
	iota(v.begin(),v.end(),0);
	{
		for (int i = 0; i < 3; ++i) {
			rotate(v.begin(),v.begin()+1,v.end());
			for (int j = 0; j < 2; ++j) {
				mp[v]=i*2+j;
				rev_mp[i*2+j]=v;
				swap(v[0],v[1]);
			}
		}
	}

	vector<int>nums(6);
	for (int i = 0; i < N; ++i) {
		vector<int>perms(3);
		iota(perms.begin(),perms.end(),0);

		int w;cin>>w;
		for (int j = 0; j < w; ++j) {
			int k;cin>>k;
			swap(perms[k],perms[k+1]);
		}
		nums[mp[perms]]++;
	}

	for (int i = 0; i < 6; ++i) {
		nums[i]=min(3,nums[i]);
	}

	set<pair<int,vector<int>>>memo;
	memo.emplace(mp[vector<int>{0, 1, 2}],nums);

	queue<pair<int,vector<int>>>que;
	que.emplace(mp[vector<int>{0, 1, 2}],nums);

	bool aok=false;
	while (!que.empty()) {
		auto p(que.front());
		que.pop();
		int status_id=p.first;
		vector<int> rest=p.second;

		for (int use_id = 0; use_id < 6; ++use_id) {
			if (rest[use_id]) {
				rest[use_id]--;

				vector<int>now_status(rev_mp[status_id]);
				vector<int>next_status(now_status);
				for (int i = 0; i < 3; ++i) {
					auto next_change(rev_mp[use_id]);

					next_status[next_change[i]]= now_status[i];

				}
				int next_status_id = mp[next_status];
				if(next_status_id==4)aok=true;
				if (memo.find(make_pair(next_status_id, rest)) == memo.end()) {
					memo.emplace(next_status_id, rest);
					que.emplace(next_status_id, rest);
				}

				rest[use_id]++;
			}
		}
	}

	bool ok=memo.find(make_pair(4,vector<int>(6,0)))!=memo.end();
	if(aok)cout<<"yes"<<endl;
	else cout<<"no"<<endl;
	return 0;
}


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

int bfs(vector<int> u , vector<int> v, int s, int t, int n, int m)
{
  vector<bool> visit(3*n+1, false);
  vector<bool> check(3*n+1, false);
  queue<int> que;
  int i;
  que.push(s);
  check.at(s) = true;
  que.push(0);
  int count = 0;
  vector<vector<int>> route(n*3+1, vector<int>(0));
  for(i = 0; i < m*3; i++)
  {
    route.at(u.at(i)).push_back(v.at(i));
  }
  while(que.size() > 1 && !visit.at(t))
  {
    int a = que.front();
    visit.at(a) = true;
    for(i = 0; i < route.at(a).size(); i++)
    {
      if(!check.at(route.at(a).at(i)))
      {
        que.push(route.at(a).at(i));
        check.at(route.at(a).at(i)) = true;
      }
    }
    if(a == 0)
    {
      count++;
      que.push(0);
    }
    que.pop();
  }
  if(!visit.at(t))count = -1;
  return count;
}

int main()
{
  int n, m;
  cin >> n >> m;
  int i, j;
  vector<int> u(m*3);
  vector<int> v(m*3);
  for(i = 0; i < m; i++)cin>>u.at(i)>>v.at(i);
  for(i = 0; i < m*3; i++)
  {
    u.at(i) = u.at(i%m) + n*(i/m);
    v.at(i) = v.at(i%m);
  }
  for(i = 0; i < m*3; i++)v.at(i) += n*(((i/m)+1)%3);
  int s,t;
  cin>>s>>t;
  int count = bfs(u,v,s,t,n,m);
  if(count == -1)cout << "-1" << endl;
  else cout << count/3 << endl;
}


Measured memory_bytes: 21376
//============================================================================
// Name        : JOI.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cctype>
#include <string>
#include<algorithm>

using namespace std;
typedef long long ll;

int main() {

	int w;

	cin>>w;

	cout<<32*w<<endl;




}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define Would
#define you
#define please
#define mp make_pair
#define pb push_back
#define INF 1000000000000
#define modulo 1000000007
#define ii pair<int,int>
#define int long long int
using namespace std;
map<int,int> performans;
int32_t main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	//freopen("q.gir","r",stdin);
	//freopen("q.cik","w",stdout);
	int a,b,c;
	vector<int> data;
	cin >> a >> b;
	for(int i=0;i<a;i++){
		cin >> c;
		data.pb(c);
	}
	int res=0;
	sort(data.begin(),data.end());
	reverse(data.begin(),data.end());
	for(int i=0;i<data.size();i++){
		if(b>0){
			b--;
			data[i]=0;
		}
		res+=data[i];
	}
	cout << res;
	Would you please return 0;
}

Measured memory_bytes: 2420
#include<bits/stdc++.h>
#define _LIBCPP_DEBUG 0
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;
int INF = 1 << 30;


int main(void){

    int N,K,C; cin>>N>>K>>C;
    string S; cin>>S;
    vector<int> SMAP(N,0);
	vector<int>SMAP2(N,0);
    int cnt=K;
	for (int i = N-1; i >= 0; i--) {
        if(S[i]=='o'){
            SMAP[i] = cnt;
            i -= C;
            cnt--;
        }
        if(cnt<=0) break;
    }
	/*
	for(int i = 0; i < N; i++){
		cout<<SMAP[i]<<endl;
	}
	cout<<"\n"<<endl;
	*/
	cnt = 1;
    for (int i = 0; i < N; ++i) {
        if(S[i]=='o'){
        	if(SMAP[i] == cnt) cout<<i+1<<endl;
        	SMAP2[i] = cnt;
            i += C;
            cnt++;
        }
        if(cnt>K) break;
    }
	/*
	for(int i = 0; i < N; i++){
		cout<<SMAP2[i]<<endl;
	}
	*/
    /*
    for (int i = 0; i < N; ++i) {
        if(SMAP[i]==2) cout<<i+1<<endl;
    }
    cout<<endl;
	*/

    return 0;
}


Measured memory_bytes: 3332
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
	int x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(int a){
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
	write(a); puts("");
}
ll a[200010];
map<ll,ll> ma;
ll n,ans;
int main(){
	n=read();++ma[0];
	for(int i=1;i<=n;i++){
		a[i]=read()+a[i-1];
		ans+=ma[a[i]]++;
	}cout<<ans<<endl;
}

Measured memory_bytes: 14336
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}


fn main() {
    input! {
        s: chars, t: chars,
        a: i32, b: i32,
        u: chars,
    }

    let mut a = a;
    let mut b = b;

    if s == u {
        a -= 1
    }

    if t == u {
        b -= 1
    }

    println!("{} {}", a, b)
}


Measured memory_bytes: 4352
import java.util.*;

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

    long X = in.nextLong();
    boolean shouldContinue = true;

    for (long a = -300L; a <= 300L && shouldContinue; a++) {
      for (long b = -300L; b <= 300L && shouldContinue; b++) {
        if (Math.pow(a, 5) - Math.pow(b, 5) == X) {
          System.out.printf("%d %d\n", a, b);
          shouldContinue = false;
        }
      }
    }
  }
}


Measured memory_bytes: 35704
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef long double llf;
typedef pair<int, int> pi;
const int MAXN = 500005;
const int mod = 1e9 + 7;
#define sz(v) ((int)v.size())

int n, a[MAXN];

int main(){
	scanf("%d",&n);
	for(int i=1; i<=n; i++) scanf("%d",&a[i]);
	vector<int> v;
	for(int i=1; i<=n; i++){
		if(a[i] != i) v.push_back(i);
	}
	for(int i=0; i<v.size(); ){
		int e = i + 1;
		while(e < v.size() && v[e] - v[e - 1] == 2) e++;
		if(e - i == 1){
			puts("No");
			return 0;
		}
		vector<int> toLeft, toRight;
		for(int j=v[i]; j<=v[e-1]; j++){
			if(a[j] < j) toLeft.push_back(a[j]);
			if(a[j] > j) toRight.push_back(a[j]);
		}
		if(!is_sorted(toLeft.begin(), toLeft.end()) ||
		   !is_sorted(toRight.begin(), toRight.end())){
		   	puts("No");
		   	return 0;
		}
		sort(a + v[i], a + v[e-1] + 1);
		for(int j=v[i]; j<=v[e-1]; j++){
			if(a[j] != j){
				puts("No");
				return 0;
			}
		}
		i = e;
	}
	puts("Yes");
}


Measured memory_bytes: 3572
import numpy as np
import math

def resolve():
    N, K = map(int, input().split())
    P = list(map(int, input().split()))

    def calc(p):
        if p % 2 == 0:
            return p/2 + 0.5
        else:
            return math.ceil(p/2)

    E = [calc(pi) for pi in P]
    #print(E)

    best_idx = 0
    best_sum = 0

    cs = np.cumsum(E)
    cs = np.insert(cs, 0, 0)
    #print(cs)

    for i in range(K-1, N):
        #print(i)
        s = cs[i+1] - cs[i-K+1]
        #print(s)
        if s > best_sum:
            best_sum = s
            best_idx = i

    print(best_sum)

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 33976
#include <bits/stdc++.h>
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define debug(var) std::cout << #var << ": " << var << "\n"
using ll = long long;
using ull = unsigned long long;
ull mod = 1e9 + 7;
using namespace std;

int main(){

  int N; cin >> N;
  string S; cin >> S;
  bool flag = true;
  int half = 0;
  if(N % 2 == 1){
    cout << "No" << endl;
    return 0;
  }else{
    half = N / 2;
  }

  for(int i = 0; i < half; ++i){
    if(S[i] != S[i + half])flag = false;
  }

  if(flag)cout << "Yes";
  else cout << "No";

}

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

using namespace std;

using ll = long long;

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

    string s;
    cin >> s;

    const int n = s.size();
    pair<int, int> res = {-1, -1};
    for (int i = 0; i + 1 < n; ++i) {
        if (s[i] == s[i + 1]) {
            res = make_pair(i + 1, i + 2);
            break;
        }
        else if (i + 2 < n && s[i] == s[i + 2]) {
            res = make_pair(i + 1, i + 3);
            break;
        }
    }

    cout << res.first << " " << res.second << endl;

    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<iomanip>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;



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

	int A, B;
	cin >> A >> B;
	int res = A + B;
	res = max(res, A - B);
	res = max(res, A * B);
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = 1; i <= (int)(n); i++)
#define drep(i, n) for(int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
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; }

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

ll g1(ll n, int p) {
  if (n==0) return 0;
  return n/p + g1(n/p, p);
}

ll g2(ll n, int p) {
  if (n%2) return g1(n, p) - g2(n-1, p);
  ll res = g1(n/2, p);
  if (p==2) res += n/2;
  return res;
}

int main() {
  ll n;
  cin >> n;
  ll ans = min(g2(n, 2), g2(n, 5));
  cout << ans << endl;
}

Measured memory_bytes: 3612
#include<stdio.h>
int main(void){
  	int a;
  long long sum = 0;
  scanf("%d",&a);
  for(int i = 1; i <= a; i++){
    	if(i % 3 != 0 && i % 5 != 0){
          	sum += i;
        }
  }
  printf("%lld",sum);
  return 0;
}


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

const int MAXN = 1e5+5;

ll n, ans;
vector<int> g[MAXN];
int dp1[MAXN], dp2[MAXN];

void dfs(int v, int f = -1) {
	int ct0 = 0;
	int ct = 0;

	for (int u : g[v]) {
		if (u == f)
			continue;
		dfs(u, v);
		ct++;
		ct0 += (dp1[u] == 0);
	}

	if (ct == 1) {
		for (int u : g[v]) {
			if (u == f)
				continue;
			dp1[v] = dp1[u];
			dp2[v] = dp2[u];
		}
	} else {
		for (int u : g[v]) {
			if (u == f)
				continue;
			dp1[v] += dp1[u];
		}

		if (ct0 == 0)
			dp2[v] = dp1[v];
		else {
			dp1[v] += (ct0 - 1);
			dp2[v] = dp1[v] + 1;
		}
	}

	if (v == 0 && ct == 2 && ct0 == 1)
		ans = dp2[v];
	else if (v == 0 && ct == 1)
		ans = dp2[v];
	else
		ans = dp1[v];
	// cout << dp1[v] << ' ' << dp2[v] << endl;
}

int main() {
	cin >> n;

	for (int i = 0; i < n-1; ++i) {
		int a, b;
		cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	dfs(0, -1);
	cout << max(ans, 1LL) << endl;
}

Measured memory_bytes: 15744
#include <bits/stdc++.h>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/assoc_container.hpp>

using namespace std;
// using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<double,double> pd;
typedef priority_queue<int, vector<int>, greater<int>> min_heap;

// template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const double PI = 4*atan(1);
const ll INF = 1e18;
const int MX = 100001;

map<int, int> occ;

int N;
string st;



void solve(int len) {
    if (len == N) {
        cout << st << "\n";
        return;
    }
    for (int i = 0; i < N; i++) {
        if (occ[i] != 0) {
            occ[i]++;
            st.push_back(i + 'a');
            solve(len + 1);
            st.pop_back();
            occ[i]--;
        } else if (occ[i] == 0) {
            occ[i]++;
            st.push_back(i + 'a');
            solve(len + 1);
            st.pop_back();
            occ[i]--;
            break;
        }
    }
}


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> N;
    solve(0);
}

Measured memory_bytes: 1536
##!/usr/bin/env python3
w,h,n = map(int,input().split())
hl = 0
hu = w
wl = 0
wu = h
for i in range(n):
  x,y,a = map(int,input().split())
  if a == 1: hl = max(x,hl)
  if a == 2: hu = min(x,hu)
  if a == 3: wl = max(y,wl)
  if a == 4: wu = min(y,wu)
#print(hl,hu,wl,wu)
print(max(0,(hu-hl))*max(0,wu-wl))

Measured memory_bytes: 38256
#include <stdio.h>
#include <string.h>
#define HASHTABLE_SIZE 2000
#define NAME_LENGTH 15

/* グループ */
typedef struct {
	char name[NAME_LENGTH + 1];
	int members[10];
	int count;
} Group;

Group groups[HASHTABLE_SIZE]; /* グループおよびメンバー */
int flag[HASHTABLE_SIZE];

/* 文字列のハッシュ値を求める */
int hash(char* s) {
	int i, h = 0, a = 3141, b = 2718;
	for (i = 0; s[i] != '\0'; i++, a = a * b % (HASHTABLE_SIZE - 1)) h = (a * h + s[i]) % HASHTABLE_SIZE;
	return h;
}

/* 指定された名前のグループの番号を返す */
#define CAN_NOT_FIND -1
int search(char* name) {
	int i;
	for (i = hash(name); flag[i]; i++) {
		if (strcmp(name, groups[i].name) == 0) return i;
	}
	return CAN_NOT_FIND;
}

/* 指定された名前のグループを配列に追加し、グループに割り当てられた番号を返す。 */
int addGroup(char* name) {
	int i = search(name);
	if (i == CAN_NOT_FIND) {
		/* 新しいグループを作成する */
		for (i = hash(name); flag[i]; i++); /* 挿入可能な番号を探す */
		flag[i] = 1;
		strncpy(groups[i].name, name, NAME_LENGTH + 1);
		groups[i].count = 0;
	}
	return i;
}

/* 指定された名前のメンバーを、グループのメンバーとして追加し、メンバーに割り当てられた番号を返す。 */
int addMember(int i, char* name) {
	int j = addGroup(name);
	groups[i].members[groups[i].count++] = j;
	return j;
}

/* 指定されたグループに含まれるメンバーの総数を返す */
int isCounted[HASHTABLE_SIZE];
int countMemberR(int i) {
	int n = 0, j;
	for (j = 0; j < groups[i].count; j++) {
		int m = groups[i].members[j];
		if (isCounted[m]) continue; /* 探索済みなら無視する */
		isCounted[m] = 1;

		if (groups[m].count == 0) n++;
		else n += countMemberR(m);
	}
	return n;
}
int countMember(int i) {
	int j;
	for (j = 0; j < HASHTABLE_SIZE; j++) isCounted[j] = 0;
	return countMemberR(i);
}

int main(void) {
	int n; /* グループの数 */
	int head; /* 最初のグループの番号 */

	/* データセット毎の処理 */
	while (scanf("%d", &n) == 1 && n > 0 && n <= 100) {
		char s[NAME_LENGTH + 1];
		int i;

		/* 初期化 */
		for (i = 0; i < HASHTABLE_SIZE; i++) flag[i] = 0;
		head = CAN_NOT_FIND;

		/* 各グループに含まれるメンバーを読み込む */
		for (; n > 0; n--) {
			/* グループ */
			scanf("%*[^a-z]%[a-z]:", s);
			i = addGroup(s);
			if (head == CAN_NOT_FIND) head = i;

			/* メンバー */
			while (scanf("%[a-z],", s) == 1) addMember(i, s);
		}
		scanf("%*[^0-9]"); /* 残った文字を読み捨てる */

		/* 最初のグループに含まれるメンバーを数える */
		/* 出力 */
		printf("%d\n", countMember(head));
	}

	return 0;
}

Measured memory_bytes: 764
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int x = scanner.nextInt();
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		
		int xa = Math.abs(a-x);
		int xb = Math.abs(b-x);
		
		String ans = "B";
		if (xa<xb) {
			ans="A";
		}
		System.out.println(ans);
		
		scanner.close();
	}

}


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

using namespace std;
#define ll long long
#define int long long

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
	#define lcout(a) cout << a;
	#define lcoutln(a) cout << a << endl;
	#define lcerr(a) cerr << a;
	#define lcerrln(a) cerr << a << endl;
#else
	#define lcout(a) 
	#define lcoutln(a) 
	#define lcerr(a) 
	#define lcerrln(a) 
#endif

int c[100];

signed main()
{
    int N, M;
    cin >> N >> M;
    rep(i, M) {
        CIN(int, t);
        CIN(int, tt);
        c[t-1]++;
        c[tt-1]++;
    }
    rep(i, N) cout << c[i] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  if(N % 10 == 7 || (N / 10) % 10 == 7 || N / 100 == 7)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3596
#include <stdio.h>

int main() {
  int n, min;
  scanf("%d", &n);
  int a[n];
  int i, j;
  int count = 0;

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

  for (i = 0; i < n; i++) {
    int temp;
    min = i;
    for (j = i; j < n; j++) {
      if (a[j] < a[min]) {
        min = j;
      }
    }
    temp = a[i];
    a[i] = a[min];
    a[min] = temp;
    if (i != min)
      ++count;
  }

  for (i = 0; i < n; i++) {
    if (i == n - 1) {
      printf("%d\n", a[i]);
    } else {
      printf("%d ", a[i]);
    }
  }
  printf("%d\n",count);

  return 0;
}



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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 998244353;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

const ll N_MAX = 5050505;

ll inv[N_MAX],fac[N_MAX],finv[N_MAX];
void make(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<N_MAX;i++){
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        fac[i]=fac[i-1]*(ll) i%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
}

ll Combination(ll C, ll D){
    if(C<D||C<0) return 0;
    return fac[C]*(finv[D]*finv[C-D]%mod)%mod;
}

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

    ll N, M;
    cin >> N >> M;

    ll term1=0, term2=0, term3=0;

    term1 = Combination(3*M+N-1, N-1);

    for(ll L=M+1;L<=min(3*M, N);L++){
    	if((3*M-L)%2==1) continue;
    	ll X = (3*M-L)/2;
    	ll tmp = Combination(X+N-1, N-1);
    	tmp *= Combination(N, L);
    	tmp %= mod;
    	term2 += tmp;
    	term2 %= mod;
    }

    for(ll Y=2*M+1;Y<=3*M;Y++){
    	ll Z = 3*M-Y;
    	ll tmp = Combination(Z+N-2, N-2);
    	tmp *= N;
    	tmp %= mod;
    	term3 += tmp;
    	term3 %= mod;
    }

    //dump(term1)
    //dump(term2)
    //dump(term3)

    ll res=0;
    res += term1;
    res = (res + mod - term2)%mod;
    res = (res + mod - term3)%mod;
    cout << res << endl;
    return 0;
}

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

#define NL '\n'
#define C char
#define D double
#define F float
#define S string
#define PI (2.0*acos(0.0))
#define sfi(x) scanf("%d",&x)
#define sfl(x) scanf("%I64d",&x)
#define sfd(x) scanf("%lf",&x)
#define sfs(x) scanf("%s",x)
#define READ freopen("input.txt","r",stdin)
#define WRITE freopen("output.txt","w",stdout)
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;


int main()
{
    long long a,b;
    cin>>a>>b;
    long long g = __gcd(a,b);
    //a/=g;
    //b/=g;
    cout<<a*b/g<<NL;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
 
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vpi;
typedef vector<pair<ll, ll> > vpl;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  vi l(n);
  rep(i, n) cin >> l[i];
  sort(l.rbegin(), l.rend());
  int ans = 0;
  rep(i, k) ans += l[i];
  cout << ans << endl;
	
	return 0;
}



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

int main(){
int s1,s2,s3,s4,S=0,M=0;
cin>>s1;cin>>s2;cin>>s3;cin>>s4;
S=s1+s2+s3+s4;
M=S/60;S=S%60;
cout<<M<<endl<<S<<endl;
return 0;
}

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

typedef pair<ll,ll> P;
const ll MO = 1000000007;

int main(){
    int n,m;
    cin >> n>>m;
    cout << pow(2,m) * (1900*m+100*(n-m)) << endl;
    return 0;
}

Measured memory_bytes: 256