akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <atcoder/all>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
template <class T>
inline bool chmin(T &a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}

ll gcd(ll n, ll m)
{
	ll tmp;
	while (m != 0)
	{
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;
//using namespace atcoder;

void solve(){
	int n;
	cin>>n;
	vector<ll>a(n);
	rep(i,n)cin>>a[i];
	vector<ll>sum(n+1);
	rep(i,n)sum[i+1]=sum[i]+a[i];
	map<ll,ll>mp;
	ll ans=0;
	rep(i,n+1){
		ans+=mp[sum[i]];
		mp[sum[i]]++;
	}
	cout<<ans;
}


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 18608
#include <iostream>
#include <set>

void problem_B() {
	bool flag = false;
	int s, m, i = 2;
	std::set<int> ss;
	std::cin >> s;
	ss.insert(s);
	while (!flag) {
		if (s % 2 == 0) {
			s /= 2;
		}
		else {
			s = 3*s+1;
		}
		if (!ss.count(s)) {
			ss.insert(s);
		}
		else {
			flag = true;
			m = i;
		}
		i++;
	}
	std::cout << m;
}

int main() {
	problem_B();
	return 0;
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30


int main() {
    ll n; cin >> n;
    V<P<ll, ll> > v(n);
    for(int i = 0; i < n; i++){
        ll a, b; cin >> a >> b;
        v[i] = make_pair(b, a);
    }

    sort(ALL(v));
    ll t = 0;
    for(int i = 0; i < n; i++){
        t += v[i].second;
        if(t <= v[i].first) continue;
        else{
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 3328
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <vector>
#include <fstream>
#include <list>
#include <iomanip>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ms(s) memset(s, 0, sizeof(s))
const int INF = 1e9;
inline int read(){
	int X = 0,w = 0 ;
	char ch = 0;
	while(!isdigit(ch)) {w |= ch == '-';ch = getchar();}
	while(isdigit(ch)) X = (X<<3) + (X<<1) + (ch ^ 48),ch = getchar();
	return w ? -X : X;
}

int cnt[1005];
int main() 
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	cnt[a]++;
	cnt[b]++;
	cnt[c]++;
	cnt[d]++;
	if(cnt[1]==1 and cnt[9]==1 and cnt[7]==1 and cnt[4]==1)
	{
		cout<<"YES";
	}
	else
	{
		cout<<"NO";
	}
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <cmath>
#include <queue>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = true;

int main(){

    ll x;
    cin >> x;

    for(ll a = -1000; a <= 1000; a++ ){
        for(ll b = -1000; b <= 1000; b++){
            if( a*a*a*a*a - b*b*b*b*b == x ){
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }



    return 0;
}

Measured memory_bytes: 3636
import std.stdio, std.string, std.array, std.conv, std.algorithm.iteration, std.functional;

void main()
{
    int tol(string n) {
        auto r = n.to!int;
        if (r == 1) r = 14;
        return r;
    }

    auto ab = readln.split;
    auto a = tol(ab[0]);
    auto b = tol(ab[1]);
    writeln(
        a > b ? "Alice" : a < b ? "Bob" : "Draw"
    );
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <vector>
#include <queue>
#include <map>
 
using namespace std;
 
typedef long long ll;
const int maxn=1e5+7;
const ll mod= 998244353;

struct node
{
	ll x,y;
}a[1110];

bool cmp(node a,node b)
{
	return atan2(a.y,a.x)<atan2(b.y,b.x);
}
 
int main()
{
//	freopen("input.txt","r",stdin);
	
	ll n;
	cin>>n;
	for(ll i=0;i<n;i++) cin>>a[i].x>>a[i].y;
	sort(a,a+n,cmp);
	ll ans=0;
	for(ll i=0;i<n;i++)
	{
		ll x=a[i].x,y=a[i].y;
		ans=max(ans,x*x+y*y);
		for(ll j=(i+1)%n;j!=i;j=(j+1)%n)
		{
			x+=a[j].x,y+=a[j].y;
			ans=max(ans,x*x+y*y);
		}
	}
	double res=sqrt(ans);
	printf("%.13f\n",res);
    
    return 0;
}


// 结构体外面只能进行定义变量，不能进行赋值，也不能进行表达式的计算 














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

using namespace std;
typedef long long ll;
#define tr(container, it) \
    for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define ill(_x)  ll _x;scanf("%lld",&_x);
#define idb(_x)  double _x;scanf("%lf",&_x);
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define sll set<ll>
#define vs vector<string>
#define in0(x, a, b)((x)>=a && (x)<=b    )
#define in1(x, a, b)((x)>a && (x)<b)
#define  rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

//#define len(array)  (sizeof(array)/sizeof((array)[0]))
#define endl '\n'
#define int ll

const double PI = 3.14159265358979323846;
const int INF = 0x3f3f3f3f;
const int MOD = (int) (1e9) + 7;
const int MX = 777777 + 5;
const int mod = 1777777777;
const double EPS = 1e-10;
const ll MXP = 8999251775770639633;

inline int len(string s){return s.size();}
inline int len(int* A){return (sizeof(A))/sizeof(A[0]);}
template <typename T>inline int len(vector<T> v){return v.size();}
template <typename T>inline int len(set<T> v){return v.size();}
template <typename T,typename S>inline int len(map<T,S> v){return v.size();}

int fac[MX+5];
int power(int x, int y, int p)
{
    int res = 1;

    x = x % p;

    while (y)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}

// Returns n^(-1) mod p
int modInverse(int n, int p)
{
    return power(n, p-2, p);
}

int C(int n, int r, int p)
{
    if (r==0)
        return 1;

    return (fac[n]* modInverse(fac[r], p) % p *
            modInverse(fac[n-r], p) % p) % p;
}

void init(int mod){
    fac[0] = 1;
    for (int i=1 ; i<=MX; i++)
        fac[i] = fac[i-1]*i%mod;
}

int CC(int a, int b){
    int res = 1;
    rep(i,a+1,a-b+1)res *= i,res/=a-i+1;
//    rep(i,1,b+1)res /= i;
    return res;
}

string S[16];
double win[16][16];
double P[16][5];
void _() {
    int n;
    cin >> n;
    double sum = 0;
    double m;
    string s;
    for (int i = 0; i < n; ++i) {
            cin >> m >> s;
            if(s[0] == 'B')sum += m*380000.0;
            else sum += m;
    }
    cout << fixed << sum << endl;


};

#undef int
int main() {
#if __MINGW32__
    freopen("C:\\Users\\hiroo\\CLionProjects\\competitive\\Input.txt", "r", stdin);
    freopen("C:\\Users\\hiroo\\CLionProjects\\competitive\\Output.txt", "w", stdout);

#endif

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


}

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

int main(){
  int n;
  string str;

  while(cin >> n , n != -1){
    str = "";
    if(!n) cout << '0' << endl;
    else{
      while(n){
	str += n % 4 + '0';
	n /= 4;
      }
      reverse(str.begin(),str.end());
      cout << str << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define lb(a, b) lower_bound(a.begin(), a.end(), b)
#define ub(a, b) upper_bound(a.begin(), a.end(), b)

#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n, m, q;std::cin >> n >> m;
  vll v(n), S(n, 0), S_back(n+1, 0);
  re(i, n) {std::cin >> v[i];v[i] *= 2;}
  re(i, n){
    S_back[i+1] = S_back[i] + v[n-1-i];
    if(i%2==n%2) S[i] = (i==0?0:S[i-1]);
    else S[i] = (i==0?0:S[i-1]) + v[i];
  }

  re(i, m){
    std::cin >> q;
    ll l = -1, r = v[n-1];
    ll left, right, mid, t;
    while(r-l>1){
      mid = (l+r)/2;
      left = lb(v, 2*q-mid) - v.begin();
      right = ub(v, 2*q+mid-1) - v.begin();
      t = right - left;
      if((n-t)-(right-1)>2) l = mid;
      else r = mid;
    }
    left = lb(v, 2*q-r) - v.begin();
    right = ub(v, 2*q+r-1) - v.begin();
    t = right - left;
    if((n-t)-(right-1)==2) t++;
    ll ans = S_back[t];
    if(n-2*t-1>=0) ans += S[n-1-2*t];
    std::cout << ans/2 << '\n';
  }
  return 0;
}


Measured memory_bytes: 4096
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int dp[60][2][2][2][2][2];
string A,B;
int f(int x,int y,int e){
	if(!e)
		return (!x and y);
	return !(x and !y);		
}
int rec(int pos,int a,int b,int c,int d,int e){//a-y,b-x,y-x
	if(pos==60)
		return (!a and !b and !c and !f(e,0,d));
	int &ret=dp[pos][a][b][c][d][e];
	if(~ret)
		return ret;ret=0;
	for(int i=0;i<2;i++)//y
		for(int j=0;j<2;j++)//x
			if(!c){
				ret+=rec(pos+1,f(A[pos]-'0',i,a),f(B[pos]-'0',j,b),f(i,j,c),
					f(e,i,d),j);
				if(ret>=INF)
					ret-=INF;	
			}
	return ret;		
}
string men(ll x){
	string res;
	while(x>0){
		res+=(x%2)+'0';
		x/=2;
	}
	while(res.size()<60)
		res+='0';
	return res;
}
int f(ll a,ll b){
	memset(dp,-1,sizeof dp);
	A=men(a);B=men(b);
	return rec(0,0,0,0,0,0);	
}
int main(){
    //freopen("file.in", "r", stdin);
    ll l,r;
    scanf("%lld%lld",&l,&r);
	int ans=f(r,r)-f(r,l-1);
	if(ans<0)
		ans+=INF;	
    printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <queue>
#include <cstdlib>

struct Interval{
  int right;
  int val;
  Interval(int right,int val):right(right),val(val){
  }
  bool operator<(struct Interval other)const{
    return right>other.right;
  }
};


int xs[501];
int ans[500*500+1];
std::vector<struct Interval> here[500*500+1];

void fail(){
  printf("No\n");
  exit(0);
}

int main(){
  int N;
  scanf("%d",&N);
  for(int i=1;i<=N;i++){
    scanf("%d",&xs[i]);
    for(int k=1;k<i;k++){
      here[1].emplace_back(xs[i]-1,i);
    }
    here[xs[i]].emplace_back(xs[i],i);
    for(int k=i+1;k<=N;k++){
      here[xs[i]+1].emplace_back(N*N,i);
    }
  }
  std::priority_queue<struct Interval> active;
  for(int i=1;i<=N*N;i++){
    for(auto add:here[i]){
      active.push(add);
    }
    if(active.empty()) fail();
    if(active.top().right<i) fail();
    ans[i]=active.top().val;
    active.pop();
  }
  printf("Yes\n");
  for(int i=1;i<=N*N;i++){
    if(i>1) printf(" ");
    printf("%d",ans[i]);
  }
  printf("\n");
  return 0;
}


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

int main(){
//     input
    int N;
    int a[110];
    cin >> N;

    for (int i = 0; i < N; ++i) cin >> a[i];

    sort(a, a + N, greater<int>());;

    int Alice = 0;
    int Bob = 0;

    for (int i = 0; i < N; ++i){
        if (i % 2 == 0){
            Alice += a[i];
        }
        else {
            Bob += a[i];
        }
    }

    cout << Alice - Bob << endl;

}

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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;


int main(int argc, const char * argv[]) {
    // source code
    int n, m;
    cin >> n >> m;
    priority_queue<double> q;
    rep (i, n) {
        double a;
        cin >> a;
        q.push(a);
    }
    rep (i, m) {
        double d = q.top();q.pop();
        q.push(d/2);
    }
    long total = 0;
    while (!q.empty()) {
        double d = q.top(); q.pop();
        total += (int) d;
    }
    cout << total << endl;
    
    return 0;
}


Measured memory_bytes: 1400
# coding: utf-8

import sys
import math
import collections
import itertools
import bisect
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def lcm(x, y) : return (x * y) // math.gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

def ncr(n, r, p=MOD):
    a = 1
    b = 1
    for i in range(r):
        a = (a * (n - i) % p)
        b = (b * (r - i) % p)

    return a * pow(b, p - 2, p) % p

N, M = LI()

i = 1
ans = 1
while i * i <= M:
    i += 1

    if M % i == 0:
        cnt = 0
        while M % i == 0:
            cnt += 1
            M //= i
        
        ans = ans * ncr(cnt+(N-1), (N-1)) % MOD

if M != 1:
    ans = ans * ncr(1+(N-1), (N-1)) % MOD

print(ans)


Measured memory_bytes: 38640
<?php

fscanf(STDIN, "%d %d %d", $n, $a, $b);

if ($a === 0) {
    echo 0;
} else {
    if ($n < $a) {
        echo $n;
    } elseif ($n < ($a + $b)) {
        echo $a;
    } else {
        echo ((int) ($n / ($a + $b))) * $a + min($n % ($a + $b), $a);
    }
}


Measured memory_bytes: 4728
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

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

    vector<string> s(3);
    for (auto &&i : s) {
        cin >> i;
    }

    char nxt = 'a';
    while (true) {
        int now = nxt - 'a';
        if (s[now].empty()) {
            char ans = now + 'A';
            std::cout << ans << '\n';
            return 0;
        }
        nxt = s[now][0];

        s[now].erase(s[now].begin());
    }

    return 0;
}

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

using namespace std;

#define ll long long

ll a[110], t;
bool s[100010], r[100010];

ll f(ll n)
{
    ll i;
    if(n==0) return 0;
    if(n<0) return 1;

    if(s[n]==1) return r[n];

    for(i=0; i<t; i++)
    {
        if(f(n-a[i])==0) r[n]=1;
    }
    s[n]=1;
    return r[n];
}

main()
{
    ll i, j, n, k, ans;

    cin>>t>>k;

    for(i=0; i<t; i++) cin>>a[i];

    ans=f(k);

    if(ans==0) cout<<"Second"<<endl;
    else cout<<"First"<<endl;
    
}


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

int main() {
  int N; cin >> N;
  while(N--) {
    int a[3];
    for(int i = 0; i < 3; i++) cin >> a[i];
    sort(a, a + 3);
    if(a[2]*a[2] == a[0]*a[0] + a[1]*a[1]) {
      cout << "YES" << endl;
    }
    else {
      cout << "NO" << endl;
    }
  }
}

Measured memory_bytes: 1164
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(a) (a).begin(),(a).end()
#define PI 3.141592653589793238
#define INF 1050000000

using vi = vector<int>;


int main() {

	int X, Y, Z;

	cin >> X>>Y>>Z;

	int temp;

	temp = X;
	X = Y;
	Y = temp;

	temp=X;
	X = Z;
	Z = temp;

	cout << X << ' ' << Y << ' ' << Z <<endl;

	return 0;
}

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


int main() {
  int n;
  cin >> n;
  vector<vector<int> > g(n, vector<int>(n, -1));//iさんがxさんのことをなんと証言したか
  rep(i, n){
    int a;
    cin >> a;
    rep(j, a){
      int x, y;
      cin >> x >> y;
      g.at(i).at(x-1) = y;
    }
  }

  int ans = 0;
  rep(i, 1 << n){
    vector<int> s(n);
    rep(j, n){
      if(i >> j & 1)
	s.at(j) = 1;
    }
    bool flag = true;
    rep(k, n){
      if(s.at(k)){
	rep(l, n){
	  if(g.at(k).at(l) == -1) continue;
	  if(g.at(k).at(l) != s.at(l)) flag = false;
	}
      }
    }
    if(flag) ans = max(ans, __builtin_popcount(i));
  }
  
  cout << ans << endl;
  return 0;
}


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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(int i = x ; i < n ; ++i)
#define rep(i, n) for(int i = 0 ; i < n ; ++i)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; --i)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort((x).begin(), (x).end())

const int IINF = 1e9 + 10;
const long long LLINF = (long long)1e18 + 10;
const long long MOD = (long long)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

int main(){
    lint n, x;
    cin >> n >> x;
    vector<lint> layer(n + 1), patty(n + 1);
    layer[0] = 1;
    patty[0] = 1;
    REP(i, 1, n + 1){
        layer[i] = layer[i - 1] * 2LL + 3LL;
        patty[i] = patty[i - 1] * 2LL + 1LL;
    }
    lint ans = 0;
    repr(i, n + 1){
        x = min(x, layer[i]);
        if(x > layer[i] / 2LL){
            ans += patty[i] / 2LL + 1LL;
            x -= layer[i] / 2LL + 1LL;
        }else{
            --x;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    int A, B, C, X;
    cin >> A >> B >> C >> X;

    int ans = 0;
    rep(a, A) rep(b, B) rep(c, C) {
        if (a * 500 + b * 100 + c * 50 == X && a + b + c >= 1) ans++;
    }

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


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

int main() {
  int N,M,n,m,l;
  bool b=true;
  cin >> N >> M;
  vector<int>s(M);
  vector<int>c(M);
  for(int i=0;i<M;i++){
    cin >> s.at(i) >> c.at(i);
  }
  if(N==1){
    n=0;
  }else{
    n=pow(10,N-1);
  }
  for(int i=0;n<pow(10,N);i++){
    b=true;
    for(int j=0;j<M;j++){
      m=pow(10,N-s.at(j));
      l=n/m;
      if(l%10==c.at(j)){}else{
        b=false;
        break;
      }
    }
    if(b){
      break;
    }
    n++;
  }
  if(b){
    cout << n << endl;
  }else{
    cout << -1 << endl;
  }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  if(k <= a)
    cout << k;
  else if(k <= a+b)
    cout << a;
  else
    cout << a-(k-a-b);
}

Measured memory_bytes: 3644
N,K = map(int,input().split())
A = list(map(int,input().split()))

for i in range(1,K+1):
  B = [0]*N
  for j in range(N):
    l = max(0, j-A[j])
    r = min(N-1, j+A[j])
    B[l] += 1
    if r+1<N:
      B[r+1] -= 1
    
  if B[0]==N:
    x = 1
  else:
    x = 0
  for i in range(1,N):
    B[i] += B[i-1]
    if B[i]==N:
      x += 1
  A = B.copy()
  if (x==N)or(i==K):
    break
    
print(' '.join(list(map(str,A))))

Measured memory_bytes: 169744
////////////////////////////////////////////////////////////////////
// This source code is for Visual Studio
////////////////////////////////////////////////////////////////////
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <stack>
#include <functional>
#include <iomanip>
#include <string>
#include <cstring>
#include <deque>
#include <math.h>
#include <assert.h>

#define	numberof(a)	(sizeof(a) / sizeof(a[0]))
#define	INF		UINT64_MAX
#define Rep(i,n) for(int i = 0; i < (n); ++i )

using namespace std;

typedef vector< vector<int> > MAT;
typedef pair<int, int> PINT;
typedef long long ll;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int32_t s32;
typedef int64_t s64;

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int main()
{	
	ll N = 0;
        char c = 0;
	string ret = "Three";

	cin >> N;

	Rep(i, N) {
		cin >> c;
		if ('Y' == c ) ret = "Four";
	}

	cout << ret << endl;

	return 0;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
const ll mo=1000000007;
ll ans=0;
ll dp[0][0];
bool prime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
int main()
{ 
ll n;
cin >> n; 
ll co=0;
rep(i,1000){
    if(prime((i+1)*10+1)){
        cout << (i+1)*10+1 << ' ';
        co++;
        if(co==n)break;
        }

}
cout <<  endl;
return 0;
} 

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

int main(){
  int h,w,n;
  cin>>h>>w>>n;
  int a[n];
  rep(i,0,n) cin>>a[i];
  int b[h][w];
  int k=0;
  rep(i,0,h){
    rep(j,0,w){
      if(i%2==0){
        b[i][j]=k+1;
      }
      else{
        b[i][w-1-j]=k+1;
      }
      a[k]--;
      if(a[k]==0){
        k++;
      }
    }
  }
  rep(i,0,h){
    rep(j,0,w){
      cout<<b[i][j];
      if(j==w-1) cout<<endl;
      else cout<<' ';
    }
  }
}

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

int main() {

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

  for(;;){
    C = C - B;
    if(C<=0){
      cout << "Yes" << endl;
      break;
    }
    A = A - D;
    if(A<=0){
      cout << "No" << endl;
      break;
    }
  }
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FSP(x) fixed << setprecision(x)
using namespace std;
using ll = long long;
constexpr ll INF = LLONG_MAX;
constexpr long double PI = acosl(-1);
void Yes() {cout << "Yes\n";}
void No() {cout << "No\n";}
void YES() {cout << "YES\n";}
void NO() {cout << "NO\n";}

#include <vector>
#include <cmath>

/*	verified : 2020/07/17
		AtCoder, Disjoint Set of Common Divisors
		https://atcoder.jp/contests/abc142/tasks/abc142_d
*/

std::vector<long long> common_divisors(long long a, long long b) {
	auto divisors = [] (long long n) {
		std::vector<long long> ret(1, 1);
		long long m = sqrt(n);
		for (long long i = 2; i <= m; i++) {
			if (n % i == 0) ret.push_back(i);
		}
		for (long long i = ret.size() - 1; i >= 0; i--) {
			if (n / ret[i] != ret[i]) ret.push_back(n / ret[i]);
		}
		return ret;
	};
    if (a > b) std::swap(a, b);
    std::vector<long long> v = divisors(a);
    std::vector<long long> ret(1, 1);
    for (long long i = 1; i < v.size(); i++) {
        if (b % v[i] == 0) ret.push_back(v[i]);
    }
    return ret;
}

#include <cmath>

/*	verified : 2020/07/17
		AtCoder, Disjoint Set of Common Divisors
		https://atcoder.jp/contests/abc142/tasks/abc142_d
*/

bool is_prime(long long n) {
    if (n == 1) return false;
    if (n == 2) return true;
    if (n % 2 == 0) return false;
	long long m = sqrt(n);
    for (long long i = 3; i <= m; i += 2) {
        if (n % i == 0) return false;
    }
    return true;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//constexpr ll P = 1e9 + 7;
	//constexpr ll P = 998244353;

	ll a, b;
	cin >> a >> b;
	vector<ll> v = common_divisors(a, b);
	ll cnt = 0;
	for (auto i : v) {
		if (is_prime(i)) cnt++;
	}
	cout << cnt + 1 << endl;
}

Measured memory_bytes: 3704
use std::io;

fn read<T: std::str::FromStr>() -> Vec<T> {
    let mut te = String::new();
    io::stdin().read_line(&mut te).unwrap();
    te.trim().split_whitespace().map(|x| x.parse().ok().unwrap()).collect()
}

fn main() {
    let input1 : Vec<i32> = read();
    let input2 : Vec<i32> = read();

    let mul1 = (input1[0] - input2[0]) * (input1[1] - input2[1]);
    println!("{}", mul1);
}



Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a<b?a:b
#define REP(i,x,n) for(int i=x;i<n;i++)
#define REPR(i,x,n) for(int i=n-1;i>=x;i--)
#define pb  push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLr(obj) (obj).rbegin(), (obj).rend()
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


int main(){
   ll n,a[101010],ans[101010]={},sum=0,max=0,mn;
   
   vector<ll> v;
   cin>>n;

   rep(i,n){
      cin>>a[i];sum+=a[i];
      if(a[i]>max){
         v.pb(i);
         max=a[i];
      }
   }
   ll f=0;
   ll z[101010]={},x=0,y,q=v.size()-1,sum2=0;
   repr(i,n){
      if(q==0)break;
      if(a[i]<a[v[q]]){
         z[x]=a[i];
         x++;
      }else {
         y++;
      }
      if(v[q]==i){
         ll nx=0,ny=0;
         rep(j,x){
            if(a[v[q-1]]<z[j]){
               ans[i]+=z[j]-a[v[q-1]];
               ny++;
            }else{
              z[nx]=z[j];
              nx++; 
            }
         }
         x=nx;
         ans[i]+=(a[v[q]]-a[v[q-1]])*y;
         y+=ny;
         sum2+=ans[i];
         q--;
      }
      
      
   }
   ans[0]=sum-sum2;
   rep(i,n)cout<<ans[i]<<endl;

   
}


Measured memory_bytes: 4340
def resolve():
    N = int(input())
    S = [list(input()) for _ in range(2)]
    i = 0
    ans = 1
    prev_color = 0
    while i < N:
        if S[0][i] == S[1][i]:
            ans *= 3 - prev_color
            prev_color = 1
            i += 1
        else:
            if prev_color == 0:
                ans *= 6
            elif prev_color == 1:
                ans *= 2
            else:
                ans *= 3 
            prev_color = 2
            i += 2
    print(ans%(10**9+7))
    


        

if '__main__' == __name__:
    resolve()

Measured memory_bytes: 3064
N, M = map(int, input().split())
a = set()
d = {}
penalty = 0
for i in range(M):
    p, S = input().split()
    if S == 'AC' and int(p) not in a:
        a.add(int(p))
        if p in d:
            penalty += d.pop(p)
    else:
        if p in d:
            d[p] += 1
        else:
            d[p] = 1
print(len(a), penalty)

Measured memory_bytes: 11884
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

K, A, B = MAP()

if A+2 >= B or K < A+1:
	print(K+1)
	exit()

k = K - (A-1)  #ちょうどA枚になった時の残りの回数
ans = A + k//2*(B-A) + k%2
print(ans)

Measured memory_bytes: 5148
#include <cstdint>
#include <iostream>
#include <vector>
#include <algorithm>

int main(void)
{
    uint32_t N;

    std::cin >> N;

    std::vector<uint32_t> a_list;

    for (uint32_t idx = 0; idx < N; ++idx) {
        uint32_t a;
        std::cin >> a; 
        a_list.push_back(a);
    }

    std::sort(a_list.rbegin(), a_list.rend());

    uint32_t a_sum = 0;
    uint32_t b_sum = 0;

    for (uint32_t idx = 0; idx < a_list.size(); ++idx) {
        if (idx % 2 == 0) a_sum += a_list.at(idx);
        else b_sum += a_list.at(idx);
    }

    std::cout << a_sum - b_sum << std::endl;

    return 0;
}

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

#define Q int t; scanf("%d", &t); for(int q=1; q<=t; q++)
typedef long long int lli;
typedef pair<int, int> pi;
typedef pair<lli, lli> pii;


int main()
{
    int po[6];
    po[0] = 1;
    po[1] = 10;
    po[2] = 100;
    po[3] = 1000;
    po[4] = 10000;
    po[5] = 100000;
    lli cnt[10][10];
    memset(cnt, 0, sizeof(cnt));
    int n;
    cin >> n;
    for(int i=1; i<=n; i++){
        int x = i%10;
        int y=i;
        while(y/10 != 0){
            y /= 10;
        }
        cnt[x][y]++;
    }
    lli ans = 0;
    for(int i=1; i<=n; i++){
        int x = i%10;
        int y=i;
        while(y/10 != 0){
            y /= 10;
        }
        if(x&&y)ans += cnt[y][x];
    }
    cout << ans;

    return 0;
}


Measured memory_bytes: 3604
#include<iostream>
#include<vector>
#include<climits>
#include<cmath>
using namespace std;
long int frog_jump(vector<int>arr,long int k)
{
	int n=arr.size();
	long int myvalue;
	vector<int>value(n);
	value[0]=0;
	value[1]=abs(arr[1]-arr[0]);
	for(int i=2;i<n;i++)
	{
	//	value[i]=min(value[i-1]+abs(arr[i]-arr[i-1]),value[i-2]+abs(arr[i]-arr[i-2]));
	   int j=i-1;
	   value[i]=INT_MAX;
	   while(j>=i-k && j>=0)
	   {
	   	 myvalue=value[j]+abs(arr[i]-arr[j]);
	   	 if(myvalue<value[i])
	   	 value[i]=myvalue;
	   	 j--;
	   	 
	   }
	}
	return value[n-1];
}
int main()
{
	long int n,k;
	cin>>n>>k;
	vector<int>arr(n);
	for(int i=0;i<n;i++)
	cin>>arr[i];
	cout<<frog_jump(arr,k);
	return 0;
}



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

using namespace std;

typedef pair<int, int> P;

int main() {
	int N;
	while ( cin >> N, N ) {
		int m[502][502] = {0};
		int ans = 0;
		int W, H; cin >> W >> H;
		for (int i = 0; i < N; ++i) {
			int x, y; cin >> x >> y;
			++m[y][x];
		}
		for (int y = 0; y < H+1; ++y) for (int x = 0; x < W+1; ++x) {
			m[y][x+1] += m[y][x];
		}
		for (int y = 0; y < H+1; ++y) for (int x = 0; x < W+1; ++x) {
			m[y+1][x] += m[y][x];
		}
		int w, h; cin >> w >> h;
		for (int y = 1; y <= H-(h-1); ++y) {
			for (int x = 1; x <= W-(w-1); ++x) {
				ans = max(ans, m[y+h-1][x+w-1] - m[y+h-1][x-1] - m[y-1][x+w-1] + m[y-1][x-1]);
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 2152
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
#define lint long long
typedef pair<int,int> P;
const lint inf=1e18+7;
const int MOD=1000000007;
signed main(){
  int n;cin>>n;
  int buf=n%10;
  if(buf==3){
    cout<<"bon"<<endl;
  }
  else if(buf==0||buf==1){
    cout<<"pon"<<"\n";
  }
  else if(buf==6||buf==8){
    cout<<"pon"<<"\n";
  }
  else{
    cout<<"hon"<<"\n";
  }
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, l, r) for(register int i = l; i < r; i++)
#define hrp(i, l, r) for(register int i = l; i <= r; i++)
#define rev(i, r, l) for(register int i = r; i >= l; i--)
#define ms(n, t) memset(n, t, sizeof(n))
#define U 10050
#define pb push_back
#define int unsigned long long
#ifndef JOEON
#define D(...)
#define R(x, l)
#define sp
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
const double eps = 1e-5;
signed main(void)
{
	#ifdef JOEON
//		freopen("C:\\Users\\Joeon\\Desktop\\IN.txt", "r", stdin);
//		freopen("C:\\Users\\Joeon\\Desktop\\OUT.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a;
	float b;
	cin>>a>>b;
	int c = (int)((b+eps)*100);
	cout<<a*c/100<<endl;
	return 0;
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	rep(i, 0, v.size()) os<<v[i]<<' ';
	return os;
}

Measured memory_bytes: 3740
#include <stdio.h>

int main(void)
{
 int H,N,i,total=0;
 int tmp;
 scanf("%d %d",&H,&N);

  for(i=0;i<N;i++)
  {
    scanf("%d ",&tmp);
    H -= tmp;
  }
  
  if(H <=0) printf("Yes\n"); 
  else printf("No\n");
  
 return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define min(X, Y) ((X) < (Y) ? (X) : (Y))

typedef long long ll;

ll main()
{
	ll q, h, s, d;
	ll n;
	ll two = 1e9;
	ll one = 1e9;

	scanf("%lld %lld %lld %lld", &q, &h, &s, &d);
	scanf("%lld", &n);

	two = min(d, min(s * 2, min(h * 4, q * 8)));
	one = min(s, min(h * 2, q * 4));

	printf("%lld\n", (n / 2 * two) + (n % 2 * one));

	return 0;
}


Measured memory_bytes: 128
N=int(input())
pdic={2:0}
for i in range(3,50,2):
    for j in pdic.keys():
        if i%j==0:
            break
    else:
        pdic[i]=0
for i in range(2,N+1):
    for p in pdic.keys():
        while i%p==0:
            pdic[p]+=1
            i//=p
ge={i:sum(x>=i-1 for x in pdic.values()) for i in (3,5,15,25,75)}
if ge[5]<2 and ge[3]<3:
    print(0)
else:
    print(ge[5]*(ge[5]-1)//2*(ge[3]-2)+ge[25]*(ge[3]-1)+ge[15]*(ge[5]-1)+ge[75])

Measured memory_bytes: 3188
data class RGB(
  var r: Int = 0,
  var g: Int = 0,
  var b: Int = 0
)

const val MOD = 1000000007

fun main(args: Array<String>) {
  val N = readInt()
  val A = readInts()

  var rgbMap = mutableMapOf<RGB, Int>()
  rgbMap[RGB()] = 1
  A.forEach { a ->
    var tmpMap = mutableMapOf<RGB, Int>()
    for ((rgb, count) in rgbMap) {
      if (rgb.r == a) {
        val key = rgb.copy(r = a + 1)
        val v = tmpMap[key]
        if (v == null) {
          tmpMap[key] = count
        } else {
          tmpMap[key] = (v + count) % MOD
        }
      }
      if (rgb.g == a) {
        val key = rgb.copy(g = a + 1)
        val v = tmpMap[key]
        if (v == null) {
          tmpMap[key] = count
        } else {
          tmpMap[key] = (v + count) % MOD
        }
      }
      if (rgb.b == a) {
        val key = rgb.copy(b = a + 1)
        val v = tmpMap[key]
        if (v == null) {
          tmpMap[key] = count
        } else {
          tmpMap[key] = (v + count) % MOD
        }
      }
    }
    rgbMap = tmpMap
  }
  var result = 0
  rgbMap.values.forEach {
    result = (result + it) % MOD
  }
  println(result)
}

fun readString() = readLine()!!
fun readStrings() = readString().split(' ')
fun readInt() = readString().toInt()
fun readInts() = readStrings().map { it.toInt() }


Measured memory_bytes: 80352
# ABC128D - equeue
# exhaustive search
def main():
    N, K = tuple(map(int, input().rstrip().split()))
    V = tuple(map(int, input().rstrip().split()))
    lim = min(N, K)
    ans = set()
    for l in range(N + 1):
        for r in range(N + 1):
            if l + r > lim:
                break
            # picked jewels (l from left, r from right)
            cur = sorted(V[:l] + V[-r:]) if r != 0 else sorted(V[:l])
            neg = sum(i < 0 for i in cur)
            rest = K - (l + r)
            # return unworthy ones as much as possible
            if neg > rest:
                ans |= {sum(cur[rest:])}
            else:
                ans |= {sum(i for i in cur if i >= 0)}
    print(max(ans))


if __name__ == "__main__":
    main()

Measured memory_bytes: 3192
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};
use std::cmp::Ordering;

fn main() {
    input! {
        x: char,
        y: char
    };
    let s = match x.cmp(&y) {
        Ordering::Less => "<",
        Ordering::Equal => "=",
        Ordering::Greater => ">",
    };
    println!("{}", s);
}


Measured memory_bytes: 2052
#include <cstdio>

double w;

int main()
{
    while (scanf("%lf\n", &w) != EOF)
    {
        if (w <= 48)
        {
            printf("%s", "light fly\n");
        }
        else if (w <= 51.00)
        {
            printf("%s", "fly\n" );
        }
        else if (w <= 54.00)
        {
            printf("%s", "bantam\n" );
        }
        else if (w <= 57.00)
        {
            printf("%s", "feather\n" );
        }
        else if (w <= 60.00)
        {
            printf("%s", "light\n" );
        }
        else if (w <= 64.00)
        {
            printf("%s", "light welter\n" );
        }
        else if (w <= 69.00)
        {
            printf("%s", "welter\n" );
        }
        else if (w <= 75.00)
        {
            printf("%s", "light middle\n" );
        }
        else if (w <= 81.00)
        {
            printf("%s", "middle\n" );
        }
        else if (w <= 91.00)
        {
            printf("%s", "light heavy\n" );
        }
        else
        {
            printf("%s", "heavy\n" );
        }
    }
    return 0;
}


Measured memory_bytes: 2660
x = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

i = int(input())
print(x[i-1])

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define re(i,a,b) for(int i=(a);i<(b);i++)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define clr(a) memset(a,0,sizeof(a));
#define il inline
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back 
#define w1 first
#define w2 second
#define adm(a,b,c) {a=a+b;if(a>=c)a-=c;else if(a<0)a+=c;}
typedef double db;
typedef long long ll;typedef long double ld;typedef unsigned long long ull;
typedef pair<ll,ll> pa;
const int N=4e6+5,M=1e7+5,INF=1e9,mod=1e9+7;
const ll linf=1e18;const double eps=1e-8,pi=acos(-1);
il int gmin(int &a,int b){if(a>b)a=b;}il ll gmin(ll &a,ll b){if(a>b)a=b;}il int gmax(int &a,int b){if(a<b)a=b;}il ll gmax(ll &a,ll b){if(a<b)a=b;}
il void read(ll&x){ll f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il ll read(ll&x,ll&y){read(x);read(y);}
il void read(int&x){int f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il int read(int&x,int&y){read(x);read(y);}
il void read(int&a,int&b,int&c){read(a);read(b);read(c);}il void read(ll&a,ll&b,ll&c){read(a);read(b);read(c);}
il int read(){int x;read(x);return x;}
il ll qpow(ll a,ll b,ll p){ll ret=1;for(;b;b>>=1,a=a*a%p)if(b&1)ret=ret*a%p;return ret;}il ll qpow(ll a,ll b){ll ret=1;for(;b;b>>=1,a=a*a%mod)if(b&1)ret=ret*a%mod;return ret;}
il ll qmul(ll a,ll b,ll p){ll ret=0;for(;b;b>>=1,a=(a<<1)%p)if(b&1)adm(ret,a,p);return ret;}il ll qmul(ll a,ll b){ll ret=0;for(;b;b>>=1,a=(a<<1)%mod)if(b&1)adm(ret,a,mod);return ret;}
il void judge(){
	freopen("data.in","r",stdin);
	freopen("data.out","w",stdout);
}void ad(ll&a,ll b){a+=b;a%=mod;if(a<0)a+=mod;}
struct gao{
	
ll ans,x1,x2,x3,x4,x5,x6,y1,y2,y3,y4,y5,y6;
ll fac[N],ifac[N];
ll F(ll n,ll m){return fac[n+m]*ifac[n]%mod*ifac[m]%mod;}
ll calc(int ix,int iy,int ox,int oy){
	return 1ll*
	(F(ix-x1+1,iy-y1+1)-F(ix-x2,iy-y1+1)-F(ix-x1+1,iy-y2)+F(ix-x2,iy-y2))*
	(F(x6-ox+1,y6-oy+1)-F(x5-ox,y6-oy+1)-F(x6-ox+1,y5-oy)+F(x5-ox,y5-oy))%mod;
}
void solve(){
	int lim=2e6;ans=0;
	fac[0]=1;rep(i,1,lim)fac[i]=fac[i-1]*i%mod;
	ifac[lim]=qpow(fac[lim],mod-2,mod);repd(i,lim-1,0)ifac[i]=ifac[i+1]*(i+1)%mod;
	read(x1,x2);read(x3,x4);read(x5,x6);
	read(y1,y2);read(y3,y4);read(y5,y6);   
	rep(i,x3,x4)ad(ans,calc(i,y4,i,y4+1)*(i+y4+1)),ad(ans,-calc(i,y3-1,i,y3)*(i+y3));
	rep(i,y3,y4)ad(ans,calc(x4,i,x4+1,i)*(i+x4+1)),ad(ans,-calc(x3-1,i,x3,i)*(i+x3));
	cout<<ans<<endl;
}
}qaq;
int main(){
	qaq.solve();
}

Measured memory_bytes: 33024
#include<bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
ll MM = 1000000000; ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
int dh[4] = {-1, 0, 0, 1};
int dw[4] = {0, -1, 1, 0}; 
using P = pair<int, int>;
const double pi = acos(-1.0);

using Graph = vector<vector<ll>>;

int main(){
  int n;
  cin>>n;
  vector<int>a(n);
  rep(i,n)cin>>a[i];
  ll ans=1;
  ll rem=1;
  rep(i,n){
    ans=ans*3;
    if(a[i]%2==0)rem=rem*2;
  }

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


Measured memory_bytes: 3560
#include<iostream>
#include<string>
using namespace std;
const int maxn = 200010;
//定义链表结构体
struct At {
	char c;		//该位置字符
	At* last;   //上一个节点
	At* next;   //下一个节点
}	c[maxn];
//主函数
int main() {
	//使用cin>>string以方便读入
	string s;
	cin >> s;

	//转存到链表中
	int size = s.size();
	///第一个节点和最后一个节点需要单独处理
	c[0] = { s[0],NULL,&c[1] };						///第一个节点的前一个节点为空
	///遍历中间的size-2个节点
	for (int i = 1; i < size - 1; i++) {
		c[i] = { s[i],&c[i - 1],&c[i + 1] };
	}
	c[size - 1] = { s[size - 1],&c[size - 2],NULL };///最后一个节点的后一个节点为空

	//开始循环删除ST子串
	///now记录当前访问到的节点
	At* now = &c[0];
	while (true) {
		At* i = now;
		for (; i->next != NULL; i = i->next) {
			///判断是否有当前位置开始的ST子串
			if (i->c == 'S'&&i->next->c == 'T') {
				///如果发现ST子串，则记录要删除的两个节点的前一个、后一个节点
				At* lastNode = i->last;			///要删除的两个节点的前一个节点
				At* nextNode = i->next->next;	///要删除的两个节点的后一个节点
				if (lastNode != NULL) {
					now = lastNode;
					lastNode->next = nextNode;
					if (nextNode != NULL)
						nextNode->last = now;
				}
				else {
					now = nextNode;
					if (nextNode != NULL)
						nextNode->last = NULL;
				}
				size -= 2;
				break;
			}
		}
		if (size == 0 || i->next == NULL || now == NULL)
			break;
	}
	cout << size << endl;
	return 0;
}


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

int main(void) {
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  
  int x3, y3, x4, y4;
  x3 = x2 - (y2 - y1);
  y3 = y2 + (x2 - x1);
  x4 = x3 - (x2 - x1);
  y4 = y3 - (y2 - y1);
  
  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
  return 0;
}

Measured memory_bytes: 3604
def uneven(number):
    result = []
    for x in range(1, number + 1):
        numberOfDigits = 1
        y = x

        if(y >= 100000):
            numberOfDigits = numberOfDigits + 5
            y = y / 100000

        if(y >= 10000):
            numberOfDigits = numberOfDigits + 4
            y = y / 10000

        if(y >= 1000):
            numberOfDigits = numberOfDigits + 3
            y = y / 1000

        if(y >= 100):
            numberOfDigits = numberOfDigits + 2
            y = y / 100

        if(y >= 10):
            numberOfDigits = numberOfDigits + 1

        if (numberOfDigits % 2 != 0):
            result.append(x)

    print(len(result))
    return len(result)
  
uneven(int(input()))

Measured memory_bytes: 6636
import kotlin.math.*
import java.util.*

const val MOD = 1_000_000_007L

fun readI() = readLine()!!.toInt()
fun readL() = readLine()!!.toLong()
fun readD() = readLine()!!.toDouble()
fun readIs() = readLine()!!.split(' ').map(String::toInt)
fun readLs() = readLine()!!.split(' ').map(String::toLong)
fun readDs() = readLine()!!.split(' ').map(String::toDouble)

fun main() {
    println(if (readLine()!![0].isUpperCase()) "A" else "a")
}


Measured memory_bytes: 34428
#include<iostream>
#include<vector>
#include<set>
using namespace std;
#include<vector>
struct UF{
	int n;
	vector<int>parent,rank;
	UF(int n_=0):n(n_),parent(n_),rank(n_,1)
	{
		for(int i=0;i<n_;i++)parent[i]=i;
	}
	int find(int a){return parent[a]!=a?parent[a]=find(parent[a]):a;}
	bool same(int a,int b){return find(a)==find(b);}
	bool unite(int a,int b)
	{
		a=find(a),b=find(b);
		if(a==b)return false;
		if(rank[a]<rank[b])
		{
			parent[a]=b;
			rank[b]+=rank[a];
		}
		else
		{
			parent[b]=a;
			rank[a]+=rank[b];
		}
		return true;
	}
	int size(int a){return rank[find(a)];}
};
int N;
int x[1<<17],y[1<<17];
vector<int>Y[1<<17],X[1<<17];
main()
{
	cin>>N;
	for(int i=0;i<N;i++)
	{
		cin>>x[i]>>y[i];
		Y[x[i]].push_back(y[i]);
		X[y[i]].push_back(x[i]);
	}
	UF ufx(1<<17),ufy(1<<17);
	for(int i=0;i<1<<17;i++)
	{
		for(int j=1;j<Y[i].size();j++)ufy.unite(Y[i][j-1],Y[i][j]);
		for(int j=1;j<X[i].size();j++)ufx.unite(X[i][j-1],X[i][j]);
	}
	set<pair<int,int> >S;
	long ans=-N;
	for(int i=0;i<N;i++)
	{
		int tx=ufx.find(x[i]),ty=ufy.find(y[i]);
		if(S.find(make_pair(tx,ty))==S.end())
		{
			S.insert(make_pair(tx,ty));
			ans+=(long)ufx.size(tx)*ufy.size(ty);
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 12416
#include<stdio.h>
int plus(int);

int main(void){
    int number, sum, ans=100000;
    scanf("%d", &number);
    for(int i=1; i<number; i++){
        sum=plus(i)+plus(number-i);
        if(sum<ans) ans=sum;
    }
    printf("%d\n", ans);
}

int plus(int n){
    int result=0;
    while(n){
        result+=n%10;
        n/=10;
    }
    return result;
}

Measured memory_bytes: 128
## coding: UTF-8
N = int(input())
a = []

a.append([0,0,0])
for i in range(N):
    a.append([int(x) for x in input().split()])

#print(a)
#[[0, 0, 0], [3, 1, 2], [6, 1, 1]]こんな感じ[t,x,y]

def hantei(l1, l2): #チェックポイント間の最短距離と時間を比較して到達できるか判定する
    if( (abs(l2[1] - l1[1]) + abs(l2[2] - l1[2]))  <= (l2[0] - l1[0])  ): #チェックポイント間の最短距離<=時間　ならOK　だめならNG
        #print(l1)
        #print(l2)
        return 'OK'
    else:
        return 'NG'

def evenoddhantei(l): #偶奇判定。時間と偶奇が一致していないとダメ
    if(l[0] % 2 == (l[1]+l[2]) % 2):
        return 'OK'
    else:
        return 'NG'

#print(hantei(a[0], a[1]))
#print(hantei(a[1], a[2]))
#print(evenoddhantei(a[0]))
#print(evenoddhantei(a[1]))
#print(evenoddhantei(a[2]))

answer = 'Yes'
for i in range(N):
    if(  hantei(a[i], a[i+1]) == 'NG'  ):
        answer = 'No'

for i in range(N+1):
    if(evenoddhantei(a[i]) == 'NG'):
        answer = 'No'

print(answer)

Measured memory_bytes: 21180