akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1001001001;
const int MOD = 1000000007;
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 (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

vector<string> mat;

int count(int sh, int gh, int w) {
    int ret = 0;
    FOR(i, sh, gh+1) FOR(j, w, w+1) {
        if (mat[i][j]=='1') ret++;
    }
    return ret;
}

int main() {
    int h, w, k; cin >> h >> w >> k;
    mat.resize(h);
    rep(i, h) {
        cin >> mat[i];
    }
    int ans = INF;
    rep(bit, 1<<(h-1)) {
        vector<int> vec;
        int cnt = 0;
        rep(i, h-1) {
            if (bit & 1<<i) {
                vec.push_back(i);
                cnt++;
            }
        }
        vector<pair<P, int>> tmp;
        if (sz(vec)) {
            int pos = 0;
            int left = -1, right = -1;
            rep(i, h) {
                if (left == -1) left = i;
                if (i>vec[pos]) {
                    right = i-1;
                    tmp.push_back({{left, right}, 0});
                    left = i;
                    if (pos<(sz(vec)-1)) {
                        pos++;
                    } else break;
                }
            }
            tmp.push_back({{left, h-1}, 0});
        } else {
            tmp.push_back({{0, h-1}, 0});
        }
        int x = 0;
        while (x<w) {
            // 各tmpのseがkを超えるまで、xを増やす
            // kを超えた時、その1つ前で切ったことにする
            bool over = false;
            bool possible = true;
            for(auto& t: tmp) {
                t.se += count(t.fi.fi, t.fi.se, x);
                if (t.se>k) over = true;
            }
            if (over) {
                cnt++;
                for(auto& t: tmp) {
                    t.se = count(t.fi.fi, t.fi.se, x);
                    if (t.se>k) { // そもそもhの切り方がNGの場合
                        possible = false;
                        cnt += INF;
                        break;
                    }
                }
            }
            x++;
            if (!possible) break;
        }
        debug(cnt);
        chmin(ans, cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<string>
#include<algorithm>
#include<map>
#include<iostream>
using namespace std;
int main(){
	map<string,int> s; 
	int n;
	char t[12];
	scanf("%d",&n);
	while(n--){
		scanf("%s",&t);
		if(s[t]==0) s[t]=1;
		else s[t]=0;
	}
	map<string,int>::iterator it;
	int ans=0;
	for(it=s.begin();it!=s.end();it++){
		if(it->second==1){
			ans++;
		}
	}
	printf("%d\n",ans);
	return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  int a, b;
  cin >> a;// >> b;
  //cout << a;
  cout << (a >= 30 ? "Yes" : "No");
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3652
#include<stdio.h>
int main (void)
{
  int a=0,b=0,d=0,r=0;
  double f=0;
  scanf("%d%d",&a,&b);
  d=a/b;
  r=a%b;
  f=(double)a/(double)b;
  printf("%d %d %f\n",d,r,f);
  return 0;
}

Measured memory_bytes: 636
#pragma GCC optimize("O2,Ofast,inline,unroll-all-loops,-ffast-math")
#include <bits/stdc++.h>
#define pb(X) push_back(X)
#define x first
#define y second
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
using namespace std;

typedef pair<int, int> pii;

int n, a, b, c, d, q, ans;

int main() {
	INIT
	int A[5];
	for (int i = 0; i < 5; ++i) {
		cin >> A[i];
	}
	cin >> d;
	
	b = *min_element(A, A + 5);
	c = *max_element(A, A + 5);
	if (c - b <= d) cout << "Yay!\n";
	else cout <<":(\n";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int k, s;
  int x, y, z;
  int ans = 0;
  scanf("%d %d", &k, &s);

  for (x = 0; x <= k; x++) {
    for (y = 0; y <= k; y++) {
      if (x + y <= s && s - (x + y) <= k) ans++;
    }
  }

  printf("%d\n", ans);

  return (0);
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include <numeric>
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;


int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[8] = { 0,0,1,1,1,-1,-1,-1 };
int dyy[8] = { 1,-1,0,1,-1,0,1,-1 };





ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll X[301][4];
int main() {
	ll T; cin >> T;
	REP(i, T) {
		REP(j, 4)cin >> X[i][j];
	}
	REP(i, T) {
		ll A=X[i][0], B=X[i][1], C=X[i][2], D=X[i][3];
		ll g = gcd(B, D);
		if (A < B) {
			cout << "No" << endl;
			continue;
		}
		if (D < B) {
			cout << "No" << endl;
			continue;
		}
		if ((B - g + A % g) > C) {
			cout << "No" << endl;
		}
		else cout << "Yes" << endl;
	}
}

Measured memory_bytes: 256
//Catchharsh
    //I Luv Kunj017
    #include<bits/stdc++.h>
    #define ll long long int 
    #define ld long double
    #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
    #define F first
    #define S second
    #define pb push_back
    #define endl '\n'
    const ll MOD = 1e9+7;
    const ll INF = 1011111111;
    const ll LLINF = 1000111000111000111LL;
    const ld EPS = 1e-10;
    const ld PI = 3.14159265358979323;
    using namespace std;
    ll power (ll x,ll n)
    {
        if(n==0)
        return 1;
        else if(n%2==0)
        return power((x*x),n/2);
        else
        return x*power((x*x),(n-1)/2); 
    }
    int main()
    {   
         IOS;
         ll n,m,i,j,k;
         cin>>n;
         vector<string> v(n);
         string s;
         map<string,ll> mp;
         for(i=0;i<n;i++)
         {
            cin>>s;
            sort(s.begin(),s.end());
            v[i]=s;
            mp[s]++;
         }  
         ll ans=0;
         for(auto it=mp.begin();it!=mp.end();it++)
          {
             ans+= ((it->S-1)*(it->S))/2;
          }
        cout<<ans;

         
    }

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

int main(){
  int N;
  string S;
  cin >> N >> S;
  string al = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  for (int i=0; i<S.size(); i++) {
    for (int j=0; j<26; j++) {
      if (S.at(i) == al.at(j)) {
        if (j+N > 25)
          S.at(i) = al.at(j+N-26);
        else
          S.at(i) = al.at(j+N);
        break;
      }
    }
  }
  cout << S << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

enum { Wed, Thu, Fri, Sat, Sun, Mon, Tue };

int main(void)
{
	int month_ld[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	
	while (1){
		int now_month;
		int now_day;
		int day = 0;
		int i;
		
		scanf("%d %d", &now_month, &now_day);
		if (now_month == 0) break;
		
		for (i = 1; i < now_month; i++) day += month_ld[i - 1];
		day += now_day;
		
		switch (day % 7){
		  case Mon:
		  	puts("Monday");
			break;
			
		  case Tue:
		  	puts("Tuesday");
			break;
			
		  case Wed:
		  	puts("Wednesday");
			break;
			
		  case Thu:
		  	puts("Thursday");
			break;
			
		  case Fri:
		  	puts("Friday");
			break;
			
		  case Sat:
		  	puts("Saturday");
			break;
			
		  case Sun:
		  	puts("Sunday");
			break;
		}
	}
	
	return (0);
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T> void operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) cin >> e; }

typedef long long ll;
int const inf = 1<<29;

int main() {

  int N; cin >> N;
  vector<ll> a(N);
  rep(i, N) cin >> a[i];

  std::deque<ll> b;
  rep(i, N) {
    if (i % 2 == 0) {
      b.push_back(a[i]);
    } else {
      b.push_front(a[i]);
    }
  }

  if (N % 2) {
    std::reverse(b.begin(), b.end());
  }

  for (int i= 0 ; i< N; ++i) {
    if (i) cout << " ";
    cout << b[i];
  }cout << endl;
  
  return 0;
}

Measured memory_bytes: 5376
#include <iostream>

using namespace std;

int main()
{
	long long i, j, k, W, a, b;

	cin >> W >> a >> b;

	if (b > a + W)
		cout << b - a - W << endl;
	else if (a > b + W)
		cout << a - b - W << endl;
	else
		cout << 0 << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(){
	int n;
	int a[100000];
	int s;
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	for (int i = 0; i < n; i++){
		if (a[a[i] - 1] == i+1)s++;
	}
	s = s / 2;
	printf("%d\n", s);
	return 0;
}

Measured memory_bytes: 512
s = list(input())
t = list(input())
b = 0
for i in range(len(s)-len(t)+1):
  a = 0
  for j in range(len(t)):
    if t[j] == s[i:i+len(t)][j]:
      a += 1
  if b < a:
    b = a
print(len(t)-b)

Measured memory_bytes: 9064
#include <stdio.h>
#include <vector>
std::pair<int, long long int> period[5010];
int x[5010],y[5010];
int check[5010];

int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=1;i<=a;i++) scanf("%d",&x[i]);
	for(int i=1;i<=a;i++) scanf("%d",&y[i]);
	
	for(int i=1;i<=a;i++)
	{
		for(int j=1;j<=a;j++) check[j] = 0;
		
		int C = i;
		long long int S = 0;
		
		for(int j=0;j<=a;j++)
		{
			if(check[C]==1)
			{
				period[i] = std::make_pair(j,S);
				break;
			}
			check[C] = 1;
			C = x[C];
			S += y[C];
		}
	}
	
	long long int ans = -1;
	for(int i=1;i<=18;i++) ans*=10;
	
	for(int i=1;i<=a;i++)
	{
		int C = i;
		long long int S = 0;
		
		for(int j=1;j<=period[i].first;j++)
		{
			if(j>b) break;
			C = x[C];
			S += y[C];
			int t = (b-j)/period[i].first;
			long long int s1 = S;
			long long int s2 = S + t*period[i].second;
			ans = ans>s1?ans:s1;
			ans = ans>s2?ans:s2;
			
		}
	}
	printf("%lld",ans);
}

Measured memory_bytes: 1864
#include <iostream> 
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <map>
using namespace std;
long long x,y,n,d;
int ans = 0;
int main() {
	scanf("%lld%lld",&n,&d);
	for (int i = 1;i <= n; i++) {
		scanf("%lld%lld",&x,&y);
		if (x*x+y*y <= d*d)
			ans++;
	}
	printf("%d\n",ans);
	return 0;
}
/*
4
8 3
2 3 2 1 3 3 2 1
6 3
2 3 2 3 2 3
8 3
2 3 2 1 3 3 2 1
12 4
1 2 3 4 4 3 2 1 2 4 1 3

*/

Measured memory_bytes: 3232
#include <stdio.h>

int main()
{
    char b,c,d;
    scanf("%c",&b);
    scanf("%c",&c);
    scanf("%c",&d);
    if((b=='A'||b=='B')&&(c=='A'||c=='B')&&(d=='A'||d=='B')){
        if(b==c&&c==d){
            printf("No");
        }
        else printf("Yes");
        }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <functional>
#include <numeric>
#include <algorithm>
#include <cstdio>

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

using namespace std;

inline int getInt(){
  int s; scanf("%d", &s); return s;
}

int main(){
  while(true){
    int n = getInt();
    int d = getInt();

    if(n + d == 0) break;

    vector< vector<int> > c(n);
    vector<int> ptr(n);
    vector<int> sum(n);

    REP(i,n){
      int m = getInt();
      c[i] = vector<int>(m);
      REP(j,m) c[i][j] = getInt();
    }

    bool flag = true;
    while(flag){
      flag = false;

      REP(i,n) if(ptr[i] != c[i].size()){
        sum[i] += c[i][ptr[i]];
        if(*max_element(sum.begin(), sum.end()) - *min_element(sum.begin(), sum.end()) <= d){
          ptr[i]++;
          flag = true;
        }else{
          sum[i] -= c[i][ptr[i]];
        }
      }
    }

    bool ans = true;
    REP(i,n) if(ptr[i] != c[i].size())
      ans = false;

    puts(ans ? "Yes" : "No");
  }

  return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#define DEBUG(x) std::cout << '>' << #x << ':' << x << '\n';
#define PRINTVEC(x) for (int i = 0; i < (int)x.size(); i++) std::cout << x[i] << ' '; std::cout << '\n';
#define PRINTP(x) for (int i = 0; i < (int)x.size(); i++) std::cout << x[i].first << ' ' << x[i].second << '\n'; std::cout << '\n';
#define io std::ios_base::sync_with_stdio(false);std::cin.tie(NULL);   
const int INF = 1<<29;
typedef long long ll;



int main()
{
	io;
    #ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);  
    #endif

    std::string s;
    std::cin >> s;
    int a = 0, b = 0;
    for (int i = 0; i < s.size(); i++)
        if (s[i] == 'A') a++;
        else b++;
    std::cout << (a == 0 || b == 0 ? "No" : "Yes");

    #ifndef ONLINE_JUDGE   
    //std::cout << '\n' << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    #endif
    return 0;
}


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

int k;
string a = "1";

string G(string a) {
	int g = -1;
	for(int i = 0; i < a.size(); ++i) {
		if(a[i] != '9' && (i == 0 || a[i] - a[i - 1] != 1)) g = i;
	}
	if(g == -1) {
		g = a.size();
		a = "1";
		for(int i = 0; i < g; ++i) a += '0';
		return a;
	}
	++a[g];
	for(int i = g + 1; i < a.size(); ++i) {
		if(a[i - 1] == '0') a[i] = '0';
		else a[i] = a[i - 1] - 1;
	}
	return a;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> k;
	for(int i = 1; i < k; ++i) {
		a = G(a);
	}
	cout << a << endl;
	return 0;
}


Measured memory_bytes: 256
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <vector>
#include <string>
#include <cctype>
#include <bitset>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <iostream>
#include <algorithm>
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define PER(i,a,b) for(int i=(a);i>=(b);i--)
#define RVC(i,S) for(int i=0;i<(S).size();i++)
#define RAL(i,u) for(int i=fr[u];i!=-1;i=e[i].next)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
     
template<class T> inline
void read(T& num) {
    bool start=false,neg=false;
    char c;
    num=0;
    while((c=getchar())!=EOF) {
        if(c=='-') start=neg=true;
        else if(c>='0' && c<='9') {
            start=true;
            num=num*10+c-'0';
        } else if(start) break;
    }
    if(neg) num=-num;
}
/*============ Header Template ============*/

int main() {
    int a,b;
    read(a);read(b);
    if(a<=0 && b>=0) printf("Zero\n");
    else if(a>0) printf("Positive\n");
    else if(b<0) {
        if((b-a+1)&1) printf("Negative\n");
        else printf("Positive\n");
    }
    return 0;
}

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

int main() {
  ll n,k; cin >> n >> k;
  ll x,ans;
  for(ll i = 0; i<n; i++){
    cin >> x;
    if(x>=k) ans++;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  int N;
  cin >> N;
  int ans1 = 1;
  int ans2 = 1;
  for (int i = 0; i < N; i++)
  {
    int A;
    cin >> A;
    ans1 *= 3;
    if (A % 2 == 0)
      ans2 *= 2;
  }
  cout << ans1 - ans2 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl "\n"
#define ll long long
#define sz(x) ((int)(x).size())
using namespace std;
ll getmul(ll n){
    int m1=10,m2=0;
    while(n>0){
        int k=n%10;
        m2=max(m2,k);
        m1=min(m1,k);
        n=n/10;
    }
    return m1*m2;
}
int main(){
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     ll int t;
     cin>>t;
     ll int j=t%10;
     if(j==2||j==4||j==5||j==7||j==9)
         cout<<"hon"<<endl;
     else if(j==0||j==1||j==6||j==8)
         cout<<"pon"<<endl;
     else
         cout<<"bon"<<endl;
 return 0;
}

Measured memory_bytes: 3640
#include<stdio.h>
int fib(int);
int F[46];
int main(){
  int n,i;
  scanf("%d",&n);
  for(i=1;i<=n;i++)F[i]=-1;
  printf("%d\n",fib(n));
  return 0;
}

int fib(int n){
  
  if(n==0||n==1)F[n]=1;
  if(F[n]!=-1)return F[n];
  return F[n]=fib(n-1)+fib(n-2);
}



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

int main() {
	int A, B, C, D;
  	cin >> A >> B >> C >> D;
	int L = A + B, R = C + D;
  	cout << (L == R ? "Balanced" : L < R ? "Right" : "Left") << endl;
  	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstring>

using namespace std;
const int MAX_PRIME=2000;
int prime[MAX_PRIME+1];
bool isPrime[MAX_PRIME+1];
int p;
void erats(){
	// primeツδ環スツトツづーツ渉可甘コツ可サ
	fill(isPrime,isPrime+MAX_PRIME,true);
	p = 0;
	isPrime[0] = isPrime[1] = false;

	for(int i = 2; i <= MAX_PRIME; i++){
		if(isPrime[i]){
			prime[p++] = i;
		}
		else
			continue;

		// ツづ督づゥツつ「ツづ可つゥツつッツづゥ
		for(int j = 2*i; j <= MAX_PRIME; j+=i){
			isPrime[j] = false;
		}
		cout << flush;
	}
}

int n,k;
int dp[15][1200][305];
int dfs(int cnt,int left,int tail){
    if(dp[cnt][left][tail]!=-1)return dp[cnt][left][tail];
    int res=0;
    if(cnt==k){
        if(left==0)
            return 1;
        else
            return 0;
    }
    for(int i = tail; prime[i] <= left; i++){
        res+=dfs(cnt+1,left-prime[i],i+1);
    }
    return dp[cnt][left][tail]=res;
}

int main(){
    erats();
    while(cin>>n>>k&&!(n==0&&k==0)){
        memset(dp,-1,sizeof(dp));
        int res=dfs(0,n,0);
        cout<<res<<endl;
    }
    return 0;
}

Measured memory_bytes: 21000
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
	int n;
	while (cin >> n, n) {
		vector<int> ts(n);
		for (int i = 0; i < n; i++) {
			cin >> ts[i];
		}
		sort(ts.begin(), ts.end());
		long long sum = 0, ans = 0;
		for (int i = 0; i < n; i++) {
			ans += sum;
			sum += ts[i];
		}
		cout << ans << endl;
	}
}

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


void solve () {
    long long n, m;
    cin >> n >> m;
    long long f = min (n, m/2);
    m -= f * 2;
    long long s = m/4;
    cout << f + s;


}

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


Measured memory_bytes: 3608
# import sys
# sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]


def solve():
    n = II()

    ans = 0
    for i in range(1, n+1):
        if i % 3 == 0 or i % 5 == 0:
            continue
        else:
            ans = ans + i
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
int n;
V<pair<int, bool>> e[N];
bool ans[N];
void dfs(int a, int p, bool z){
  ans[a] = z;
  for(pair<int, bool>&t:e[a]){
    int b = t.fi;
    if(b==p) continue;
    dfs(b, a, z^t.se);
  }
}
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(i, 1, n){
    int u, v, w;
    cin >> u >> v >> w;
    u--; v--;
    w &= 1;
    e[u].pb(mp(v, w));
    e[v].pb(mp(u, w));
  }
  dfs(0, -1, false);
  FOR(i, 0, n) cout << ans[i] << endl;
}

Measured memory_bytes: 8064
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <climits>
#include <functional>
#include <algorithm>

using namespace std;

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

int main(){
  string S;
  cin >> S;
  for(auto& it: S){
    it = 'x';
  }

  cout << S << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using tiii = tuple<int,int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
const ll DIV =1e9+7;
//const double PI = M_PI;
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}
#define chmax(a,b) a=max(a,b)

/*Coding Space*/
int main(){
  ll n;  cin >> n;
  double ans = 0.0;
  rep(i,n)if((i+1)%2 == 1)ans += double(1)/n;
  cout << fixed << setprecision(10) << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
int main(){
  long N;
  cin>>N;
  double a;
  a=sqrt(N);
  int A=a;
  string s;
    for(int i=A;i>0;i--){
      if(N%i==0){
        s=to_string(N/i);
        cout<<s.size();
        break;
      }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    vl a(A),  b(B), c(C);
    rep(i, A) cin >> a[i];
    rep(i, B) cin >> b[i];
    rep(i, C) cin >> c[i];
    sort(all(a), greater<ll>()), sort(all(b), greater<ll>()), sort(all(c), greater<ll>());

    ll ai = X - 1, bi = Y - 1, ci = 0;
    ll ans = 0;
    rep(i, X) ans += a[i];
    rep(i, Y) ans += b[i];
    
    while(ci<C){
        if (ai < 0 && bi < 0) break;
        else if(ai<0){
            if (c[ci] <= b[bi]) break;
            ans += c[ci] - b[bi];
            bi--, ci++;
            continue;
        }
        else if(bi<0){
            if (c[ci] <= a[ai]) break;
            ans += c[ci] - a[ai];
            ai--, ci++;
            continue;
        }
        
        if (c[ci] < a[ai] and c[ci] < b[bi]) break;
        if(a[ai]<b[bi]){
            ans += c[ci] - a[ai];
            ai--, ci++;
        }
        else {
            ans += c[ci] - b[bi];
            bi--, ci++;
        }

    }
    cout << ans << endl;
}


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

int main(){
  string S;
  cin >> S;
  string T = S;
  int N = S.size();
  int count1=0;
  int count2=0;
  for(int i = 0; i<N-1;i++){

    if(S.at(i) == S.at(i+1)){
      count1++;
      if(S.at(i) == '0'){
        S.at(i+1) = '1';
      }
      else if(S.at(i) == '1'){
        S.at(i+1) = '0';
      }
    }
  }
  for(int i = 0; i<N-1;i++){

    if(T.at(N-i-1) == T.at(N-i-2)){
      count2++;
      if(T.at(N-i-1) == '0'){
        T.at(N-i-2) = '1';
      }
      else{
        T.at(N-i-2) = '0';
      }
    }
  } 
  if(count1 >= count2){
    count1 = count2;
  }
  cout << count1<< endl;

  return 0;

}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int INF = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;
using P = pair<int, int>;


int main() {
    u32 n, m;
    cin >> n >> m;
    vector<vector<int> > d(n, vector<int>(n, INF));

    for (int i = 0; i < m; ++i) {
        int a, b, c;
        cin >> a >> b >> c;
        d[a-1][b-1] = d[b-1][a-1] = c;
    }
    vector<vector<int> > d2 = d;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            for (int k = 0; k < n; ++k) {
                d[j][k] = min(d[j][k], d[j][i]+ d[i][k]);
            }
        }
    }
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if(d2[i][j] != INF && d2[i][j] != d[i][j]) cnt++;
        }
    }
    cout << cnt/2 << "\n";
    return 0;
}


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

using namespace std;

class Tree {
  public:
    Tree(int size):
        m_edges(size),
        m_down(size, 1),
        m_up(size, 1) {}

    void add_edge(int x, int y) {
        m_edges[x].push_back(y);
        m_edges[y].push_back(x);
    }

    void count_independent_sets(int modulo) {
        dfs_down(0, modulo);
        m_up[0] = 1;
        dfs_up(0, modulo);
    }

    int independent_sets_with(int node, int modulo) const {
        return 1LL * m_down[node] * m_up[node] % modulo;
    }

  private:
    void dfs_down(int node, int modulo, int father = -1) {
        m_down[node] = 1;
        for (auto &x : m_edges[node]) {
            if (x == father)
                continue;
            dfs_down(x, modulo, node);
            m_down[node] = 1LL * m_down[node] * (1 + m_down[x]) % modulo;
        }
    }

    void dfs_up(int node, int modulo, int father = -1) {
        int ways = 1;
        auto add = [&](int x) {
            if (x == father)
                return;
            m_up[x] = 1LL * m_up[x] * ways % modulo;
            ways = 1LL * ways * (m_down[x] + 1) % modulo;
        };

        for_each(m_edges[node].begin(), m_edges[node].end(), add);
        ways = m_up[node];
        for_each(m_edges[node].rbegin(), m_edges[node].rend(), add);

        for (auto &x: m_edges[node])
            if (x != father) {
                m_up[x] = (m_up[x] + 1) % modulo;
                dfs_up(x, modulo, node);
            }
    }

    vector< vector<int> > m_edges;
    vector<int> m_down, m_up;
};

int main() {
    ios::sync_with_stdio(false);

    int N, M; cin >> N >> M;
    Tree T(N);
    for (int i = 1; i < N; ++i) {
        int x, y; cin >> x >> y;
        T.add_edge(x - 1, y - 1);
    }

    T.count_independent_sets(M);

    for (int i = 0; i < N; ++i)
        cout << T.independent_sets_with(i, M) << "\n";
}


Measured memory_bytes: 11904
import bisect
primes = [0, 0] + [1]*999999
for i in range(2, 1001):
    if primes[i]:
        for j in range(i*i, 1000001, i):
            primes[j] = 0

primes = [i for i, v in enumerate(primes) if v]
while True:
    try:
        n = int(input())
    except:
        break
    print(bisect.bisect(primes, n))

Measured memory_bytes: 23044
import itertools
num = list(map(int, input().split()))
result = 0
tmp_1 = 0
tmp  =0
tmp_2 = 0
if num[0] == num[1]:
    tmp  = num[0] +  num[0]
else:
    tmp = num[0] + num[1]
    tmp_1 = num[0] + num[0] -1
    tmp_2 = num[1] + num[1] -1
print(max(tmp,tmp_1,tmp_2))

Measured memory_bytes: 3064
/**
  @file b.cpp
  @title B - Resistors in Parallel
  @url https://atcoder.jp/contests/abc138/tasks/abc138_b
**/

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, N) for (int i = 0; i < (N); ++i)

int main() {
  int N;
  cin >> N;
  vector<int> A(N, 0);

  double sum = 0;
  REP(i, N) {
    cin >> A[i];
    sum += (1 / (double)A[i]);
  }

  cout << fixed << 1 / sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void){
	
	int i, flag = 1;
	char s[100];
	
	scanf("%s", s);
	
	for(i=1; i<strlen(s); i+=2){
		if(s[i] == 'R')
		flag = 0;
	}
		
	for(i=0; i<strlen(s); i+=2){
		if(s[i] == 'L')
		flag = 0;
	}
		if(flag == 0){
		printf("No\n");
		}else printf("Yes\n");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<math.h>
#include <stdio.h>
#include<vector>
#include<deque>
#include<stdlib.h>
//#include <algorithm>
#include <limits>
#include<string>
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define ll long long
#define d_5 100000
int main(void){
  int N,K;
  cin >> N >> K;
  ll tmpv;
  deque<ll> v;
  rep(i,N){
    cin >> tmpv;
    v.push_front(tmpv);
  }
  deque<ll> holding;
  ll maxsum=0;
  rep(i,N+1){
    rep(j,N+1){
      if(i+j<=K && i-1<N-1-(j-1)){
        //cout << i << " " << j << endl;
        holding.clear();
        rep(l,i){
          holding.push_front(v[l]);
        }
        rep(r,j){
          holding.push_front(v[N-1-r]);
        }
        sort(holding.begin(),holding.end());
        /*rep(t,holding.size()){
          cout << holding[t] << " ";
        }cout<<endl;*/
        rep(k,K-(i+j)){
          if(holding.size()>=1 && holding[0]<0){
            //cout<<"zero"<<holding[0]<<endl;
            holding.pop_front();
          }else{
            break;
          }
        }
        ll tmpsum=0;
        rep(k,holding.size()){
          tmpsum+=holding[k];
        }
        //cout << "tmpsum" << tmpsum << endl;
        maxsum=max(maxsum,tmpsum);
      }else{
        break;
      }
    }
  }
  cout << maxsum << endl;
	return 0;
}

Measured memory_bytes: 256
class Node(object):
    def __init__(self, num, prv = None, nxt = None):
        self.num = num
        self.prv = prv
        self.nxt = nxt
 
 
class DoublyLinkedList(object):
    def __init__(self):
        self.start = self.last = None
 
    def insert(self, num):
        new_elem = Node(num)
 
        if self.start is None:
            self.start = self.last = new_elem
        else:
            new_elem.nxt = self.start
            self.start.prv = new_elem
            self.start = new_elem
 
    def delete_num(self, target):
        it = self.start
        while it is not None:
            if it.num == target:
                if it.prv is None and it.nxt is None:
                    self.start = self.last = None
                else:
                    if it.prv is not None:
                        it.prv.nxt = it.nxt
                    else:
                        self.start = self.start.nxt
 
                    if it.nxt is not None:
                        it.nxt.prv = it.prv
                    else:
                        self.last = self.last.prv
                break
            it = it.nxt
 
    def delete_start(self):
        if self.start is self.last:
            self.start = self.last = None
        else:
            self.start.nxt.prv = None
            self.start = self.start.nxt
 
    def delete_last(self):
        if self.start is self.last:
            self.start = self.last = None
        else:
            self.last.prv.nxt = None
            self.last = self.last.prv
 
    def get_content(self):
        ret = []
        it = self.start
 
        while it is not None:
            ret.append(it.num)
            it = it.nxt
 
        return ' '.join(ret)
 
 
def _main():
    from sys import stdin
 
    n = int(input())
 
    lst = DoublyLinkedList()
     
    for _ in range(n):
        cmd = stdin.readline().strip().split()
        if cmd[0] == 'insert':
            lst.insert(cmd[1])
        elif cmd[0] == 'delete':
            lst.delete_num(cmd[1])
        elif cmd[0] == 'deleteFirst':
            lst.delete_start()
        elif cmd[0] == 'deleteLast':
            lst.delete_last()
 
    print(lst.get_content())
 
 
if __name__ == '__main__':
    _main()

Measured memory_bytes: 229152
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
// const ll INF = 1e18;
# define rep(i, n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((int)(n)); i>0; --i)
# define all(x) (x).begin(), (x).end()
 
ll X,Y,A,B,C;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> X >> Y >> A >> B >> C;
    
    vector<ll> p(A);
    rep(i,A) {
        cin >> p[i];
    }
    vector<ll> q(B);
    rep(i,B) {
        cin >> q[i];
    }
    vector<ll> r(C);
    rep(i,C) {
        cin >> r[i];
    }

    sort(all(p), greater<ll>());
    sort(all(q), greater<ll>());
    sort(all(r), greater<ll>());
    
    priority_queue<ll> pq;
    rep(i,X) {
        pq.push(p[i]);
    }
    rep(i,Y) {
        pq.push(q[i]);
    }
    rep(i,C) {
        pq.push(r[i]);
    }
    
    ll ans = 0;
    rep(i,X+Y) {
        ans += pq.top();
        pq.pop();
    }
    
    cout << ans << endl;

    return 0;
}


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

typedef long long ll;

int main() {
    int N, a, ans = 0;
    cin >> N;
    map<int, int> m;
    rep(i, N) {
        cin >> a;
        m[a]++;
    }
    for (auto i : m) {
        if (i.second >= i.first) ans += i.second - i.first;
        else ans += i.second;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 8036
#include <iostream>
#include <cstdio>
#include <algorithm>
#define ll long long
#define println(S) (cout << S << endl)
using namespace std;


int main() {
	ll N,x;

	cin >> N >> x;

	ll a[N];
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}
	sort(a,a+N);
	for (int i = 0; i < N; ++i) {
		if(x >= a[i]){
			x -= a[i];
		}else{
			println(i);
			return 0;
		}
	}
	if(x!=0){
		println(N-1);
	}else{
		println(N);
	}
	return 0;


	return 0;
}


Measured memory_bytes: 256
/**

    ___         ___           ____        __      __        ____         ___        _    _     ____
   / __ \      / __ \        / __ \       \ \    / /       / __ \       |  _ \     | |  | |  _/  _/
  | |  \ \    / /  | |      / /  \ \       \ \  / /       / /  \ \      | | \ \    | |  | |_/  _/
  | |   \ \  / /   | |     / /____\ \       \ \/ /       / /____\ \     | |  \ \   | |  |    _/
  | |    \ \/ /    | |    / /______\ \       \  /       / /______\ \    | |   \ \  | |  |  _ \__
  | |     \__/     | |   / /        \ \       | |      / /        \ \   | |    \ \_| |  | | \__ \__
  |_|              |_|  /_/          \_\  .   |_|     /_/          \_\  |_|     \ ___|  |_|    \___\


   ________         ____         _________   ___________    __________      ___________     _________ 
  |  ____  \       / __ \       | _______/  |____  _____|  /  ______  \    / _________/    |___   ___|     
  | |____|  \     / /  \ \      | |______        | |      /  /       \ \   | /                 | |
  |    ____ /    / /____\ \     |______  |       | |     /  /         \ \  | |  _________      | |
  | |\_\        / /______\ \           | |       | |     \  \         / /  | | |_______  |     | |
  | |  \_\     / /        \ \   _______| |       | |      \  \_______/ /   | |_________| |  ___| |___
  |_|    \_\  /_/          \_\  \________|       |_|       \__________/    \_____________| |_________|


**/
                                                   
#include<bits/stdc++.h>
using namespace std;
int main(){
	char c;
	cin>>c;
	cout<<(char)(c+1)<<'\n';
	return 0;
}

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

#define ll long long
#define vl vector<ll>
#define fo(i,a,b) for(ll i=a; i<b; i++)

int main(){
    ll a, b, c, k;
    ll ans;
    cin >> a >> b >> c >> k;

    if(k <= a){
        ans = k * 1;
    }else{
        k -= a;
        if(k <= b){
            ans = a * 1;
        }else{
            ans = a*1 - (k-b);
        }
    }

    cout << ans << endl;
       
}

/*
　 ◇　　　　 ミ ◇
　◇◇　 /￣|　 ◇◇
◇◇＼　 L＿| ◇◇
　　彡Ｏ(・＿・)/
　 　　ヽ Ｐ`Ｏ
　　 ／彡#_|ミ＼
　　　 </LL凵>
　　　　∪ ∪
pass system test !!
*/

Measured memory_bytes: 3636
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
using namespace std;

int main()
{
	int R,G,h;
	while(~scanf("%d %d",&R,&G))
	{
		if(R>=0 && R<=4500 && G>=0 && G<=4500)
		     h=2*G-R;
		printf("%d\n", h);
	}
	return 0;
}



Measured memory_bytes: 256
n = gets.to_i
nums = gets.chomp.split.map(&:to_i)

elLtZero = 0
elLtOne  = 0
ans = 0

nums.each do |e|
    elLtZero += 1 if e<0
    elLtOne  += 1 if e<1
    ans += e.abs
end

if (elLtOne%2===0 || elLtZero%2===0) then
    puts ans
else
    idx = nums.index{|e| e<0}
    puts ans - 2 * nums.map{|e| e.abs}.min
end


Measured memory_bytes: 10372
import java.util.*;


public class Main {
    public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while (true) {
		    int m = sc.nextInt();
		    int f = sc.nextInt();
		    int r = sc.nextInt();
		    if (m == -1 && f == -1 && r == -1)
		        break;
		    if (m == -1 || f == -1)
		        System.out.println("F");
		    else if (m + f >= 80)
		        System.out.println("A");
		    else if (m + f >= 65)
		        System.out.println("B");
		    else if (m + f >= 50)
		        System.out.println("C");
		    else if (m + f >= 30)
		        if (r >= 50)
		            System.out.println("C");
		        else 
		            System.out.println("D");
		    else 
		        System.out.println("F");
		}
    }
}



Measured memory_bytes: 26324
#include<stdio.h>
int main(){
int a,b,c,d=1;
scanf("%d %d",&a,&b);
if(a<b){
c=a;
a=b;
b=c;
}
c=1;
while(b>=c){
if(a%c==0 && b%c==0){
d=c;
}
c++;
}
d--;
printf("%d\n",a+b-d);
return 0;
}


Measured memory_bytes: 1996
W,H,N = (int(i) for i in input().split())

X1 = []
X2 = []
Y3 = []
Y4 = []

for i in range(N):
    x,y,a = (int(j) for j in input().split())
    
    if a == 1:
        X1.append(x)
    elif a == 2:
        X2.append(x)
    elif a == 3:
        Y3.append(y)
    elif a == 4:
        Y4.append(y)
        
if X1 == []:
    A1 = 0
else:
    A1 = max(X1)
        
if X2 == []:
    A2 = W
else:
    A2 = min(X2)

        
if Y3 == []:
    A3 = 0
else:
    A3 = max(Y3)
    
if Y4 == []:
    A4 = H
else:
    A4 = min(Y4)
    
    
if A2 - A1 < 0:
    X_ans = 0
else:
    X_ans = A2 - A1
    
    
if A4 - A3 < 0:
    Y_ans = 0
else:
    Y_ans = A4 - A3
    
ans = X_ans * Y_ans
print(ans)

        
        

Measured memory_bytes: 3064
import std.stdio, std.string, std.array, std.conv, std.algorithm;

void main() {
    int[] tmp = readln.chomp.split.to!(int[]);
    int r = tmp[0], c = tmp[1];
    int[][] mat = new int[][](r, c);
    foreach (i; 0 .. r) {
        int[] row = readln.chomp.split.to!(int[]);
        foreach(j; 0 .. c) {
            mat[i][j] = row[j];
        }
    }
    int[] vec = new int[c+1];
    foreach (j; 0 .. c) {
        foreach (i; 0 .. r) {
            vec[j] += mat[i][j];
        }
    }
    foreach (i; 0 .. r) {
        vec[c] += mat[i].sum;
    }
    foreach (i; 0 .. r) {
        foreach (j; 0 .. c) {
            write(mat[i][j], " ");
        }
        mat[i].sum.writeln;
    }
    foreach (j; 0 .. c) {
        write(vec[j], " ");
    }
    vec[c].writeln;
}


Measured memory_bytes: 2904
N, K = map(int, input().split())
number = [ i for i in range(0, N + 1)]


left = number[K - 1]
right = number[-K]
s_min = sum(number[0:K])
s_max = sum(number[-K:])
count = s_max - s_min + 1
for i in range(K + 1, N + 2):
    left += 1
    right -= 1
    s_min += left
    s_max += right
    count += s_max - s_min + 1
print(count % 1000000007)


Measured memory_bytes: 81108
#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.at(i);

    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());

    int Alice = 0;
    int Bob = 0;
    for(int i = 0; i < N; i++){
        if(i % 2 == 0) Alice += a.at(i);
        else Bob += a.at(i);
    }
    cout << Alice - Bob << endl;
}

Measured memory_bytes: 3588
#include "bits/stdc++.h"
using namespace std;

struct Solver {
	void solve() {
		string S;
		cin >> S;
		cout << (S[1] == 'B' ? "ARC" : "ABC") << endl;
	}
};

int main() {
	ios::sync_with_stdio( false );
	cout << fixed << setprecision( 10 );
	Solver().solve();

	return 0;
}


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

int main() {
  int N, count, res;
  cin >> N;
  count = 0;
  
  vector<int> button(N);
  for (int i = 0; i < N; i++) {
    cin >> button.at(i);
  }
  int i = 0;
  while (count < N) {
    if (button.at(i) == i + 1) {
      break;
    }
    i = button.at(i) - 1;
    count++;
    if (i + 1 == 2) {
      cout << count << endl;
      break;
    }
  }
  if (i + 1 != 2) cout << -1 << endl;
}


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

LL wari = 1e9 + 7;

LL kaijo(LL n){
	if(n == 0) return 1;
	return n*kaijo(n-1)%wari;
}

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

int main(){
	// sengen
	LL x,y;
	cin >> x >> y;
	if((x+y)%3 != 0){
		cout << '0' << endl;
      return 0;
	}
	// nyuryoku
	LL n,m;
	m = (2*x - y)/3;
	n = (2*y - x)/3;
	if(n < 0 || m < 0){
		cout << '0' << endl;
      return 0;
	}
	// keisan
	cout << kaijo(n+m)*modinv(kaijo(n),wari)%wari*modinv(kaijo(m),wari)%wari << endl;
	// syutsuryoku
}

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

long long N, M;
vector<long long> tree[100005];
// cur       , parent
map<long long, long long> memo;

int main(){
	cin >> N >> M;
	for(long long i = 0; i < M; i++) {
		long long a, b;
		cin >> a >> b;
		a--;b--;
		tree[a].push_back(b);
		tree[b].push_back(a);
	}

	//           cur, parent
	queue<pair<long long, long long> >q;

	q.push(make_pair(0, -1));

	while(!q.empty()) {
		long long cur = q.front().first;
		long long parent = q.front().second;
		q.pop();

		if(memo.count(cur) > 0){
			continue;
		}
		memo[cur] = parent;

		for(long long i = 0; i < tree[cur].size(); i++) {
			long long next = tree[cur][i];
			if(memo.count(next) > 0){
				continue;
			}
			q.push(make_pair(next, cur));
		}
	}

	bool ng = false;
	for(long long i = 1; i < N; i++) {
		if(memo.count(i) == 0) {
			ng = true;
		}
	}

	if(ng) {
		cout << "No" << endl;

	} else {
		cout << "Yes" << endl;
	for(long long i = 1; i < N; i++) {
		cout << memo[i] + 1 << endl;
	}

	}



}


Measured memory_bytes: 18964
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int i=0;i<n;i++)
const long long MOD = 1000000007;
const long long INF = MOD*MOD;
typedef pair<int,int> P;
typedef long long ll;
ll n,m,k,ans;
string s;

int main(){
  double n; cin >> n;
  int x1 = n/1.08;
  int x2 = (n+1)/1.08;
  if(x1 == x2) cout << ":(\n";
  else cout << x2 << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
signed main(void){
    int n; cin>>n; vector <int> a(n); 
    rep(i,n) cin>>a[i];
    int now = 0;
    int cnt = 0;
    int ans = -1;
    rep(i,n-1){
        if(a[i]>=a[i+1]) cnt++;
        else {ans = max(ans, cnt); cnt=0;}
    }
    ans = max(ans, cnt);
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

LL K, A, B;

void MAIN() {
    scanf("%lld%lld%lld", &K, &A, &B);
    LL ans = K+1;

    if (A < B && A-1 <= K) {
	LL cur = A;
	K -= A-1;
	LL g = K/2;
	cur += (B - A) * g;
	if (K%2) cur++;
	amax(ans, cur);
    }
    printf("%lld\n", ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS 
#include <stdio.h>

int main()
{
	int S,h,m,s;
	scanf("%d",&S);
	h=S/3600;
	m=S%3600/60;
	s=S%3600%60;
	printf("%d:%d:%d\n",h,m,s);
}


Measured memory_bytes: 2744