akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define For(i, l, r) for(int i = (l), _end_ = (int)(r); i <= _end_; ++i)
#define Fordown(i, r, l) for(int i = (r), _end_ = (int)(l); i >= _end_; --i)
#define Set(a, v) memset(a, v, sizeof(a))
using namespace std;

bool chkmin(int &a, int b) {return b < a ? a = b, 1 : 0;}
bool chkmax(int &a, int b) {return b > a ? a = b, 1 : 0;}

inline int read() {
 int x = 0, fh = 1; char ch = getchar();
    for (; !isdigit(ch); ch = getchar() ) if (ch == '-') fh = -1;
    for (; isdigit(ch); ch = getchar() ) x = (x<<1) + (x<<3) + (ch ^ '0');
    return x * fh;
}

char str[100100];
char now[100100];
int cnt = -1;
int tot[100100];
int res[100100];
int Last;
int main () {
	scanf ("%s", str + 1);
	int len = strlen(str + 1);
	For (i, 1, len)
		if (str[i] != 'x') {
			tot[i] = tot[i - 1];
			now[++cnt] = str[i];
			res[cnt] = tot[i] - tot[Last];
			Last = i;
		}
		else
			tot[i] = tot[i - 1] + 1;

	bool flag = true;
	For (i, 0, cnt / 2)
		if (now[i] != now[cnt - i])
			flag = false;
	if (!flag) {
		puts("-1");
		return 0;
	}
	res[++cnt] = tot[len] - tot[Last];
	
	int ans = 0;
	For (i, 0, cnt / 2)
		ans += abs(res[i] - res[cnt - i]);
	printf ("%d\n", ans);
    return 0;
}


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

int main() {

  int N;
  cin >> N;

  vector<int> a(N);
  vector<int> b(N);

  for ( int i = 0; i < N; i++ ){
    cin >> a.at(i);
    b.at(i) = a.at(i) - 1;
  }

  if ( b.at(0) == 0 ){
    cout << -1 << endl;
  } else if ( b.at(0) == 1 ){
    cout << 1 << endl;
  } else {
    int counter = 2;
    int d = b.at(0);
    int e;

    while ( counter < N ){
      e = d;
      d = b.at(e);

      if ( d == 1 ){
        break;
      }

      counter += 1;
    }
    if ( d == 1 ){
      cout << counter << endl;
    } else {
      cout << -1 << endl;
    }
    
  }
  
}

Measured memory_bytes: 4056
#include <bits/stdc++.h>
#include <cctype>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 300'000;
const int LOGN = 19;

int n, m, k;

void solve(int) {
  string s, t;
  cin >> s >> t;
  t.pop_back();
  if (s == t) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}




Measured memory_bytes: 3656
#include<iostream>
#include<cstring>
using namespace std;
int main(){
  int h,w;
  cin >> h >> w;
  int mas[w+1];
  memset(mas,0,sizeof(mas));
  for(int i=0,sum=0,a;i<h;i++,sum=0){
    for(int j=0;j<w;j++){
      cin >> a;
      cout << (j!=0?" ":"") << a;
      sum += a;
      mas[j]+=a;
    }
    cout << " " << sum << endl;
    mas[w] += sum;
  }
  for(int i=0;i<=w;i++){
    cout << (i!=0?" ":"") << mas[i];
  }
  cout << endl;
}

Measured memory_bytes: 1172
# coding: utf-8
# Your code here!


n, m = map(int, input().split())
A = [[0 for j in range(m)] for i in range(n)]
B = [0 for i in range(m)]

for i in range(n):
   A[i] = list(map(int, input().split()))
   
for i in range(m):
   B[i] = int(input())

#print(A)
#print(B)

sum = 0
for i in range(n):
   for j in range(m):
      sum += A[i][j] * B[j]
   print(sum)
   sum = 0



Measured memory_bytes: 6024
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = []
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', (line) => {
  lines.push(line);
});

reader.on('close', () => {
 var n = lines[0].split('');
 var len = n.length;
 var ans = "";
 n = Number(n[len-1]);

 if (n == 2 || n == 7 || n == 4 || n == 5 || n == 9) {
   ans = 'hon';
 }else if(n == 0 || n == 1 || n == 6 || n == 8){
   ans = 'pon';
 }else if(n == 3){
   ans = "bon";
 }

 console.log(ans);
});

Measured memory_bytes: 30072
using namespace std;
#include<bits/stdc++.h>
#define int long long
#define pb push_back 
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define repa(i,a,b) for (int i=a; i<=b; i++)
#define repd(i,b,a) for (int i=b; i>=a; i--)
#define endl "\n"
//debugging
#define debug1(a) cout<<#a<<" = "<<(a)<<endl;
#define debug2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define debug3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
#define debug4(a,b,c,d) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<", "<<#d<<" = "<<(d)<<endl;

const int N = 1e+6+5;
int big = 1e+18+3;
int mod = 1e+9+7;

signed main()
{
    IOS;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    #endif
    int x,k,d;
    cin>>x>>k>>d;

    x = abs(x);

    if ( x>k*d && k*d>0 )
        cout<< x - k*d <<endl;
    
    else
    {
        int moves = x/d;
        int pos = x - moves*d;
        int rem = k - moves;
        int ans = 1e17;

        for (int i=0; i<3; i++)
        {
            int nowRem = rem - i;
            int nowPos = pos - i*d;

            if (nowRem%2==0)
                ans = min(ans,abs(nowPos));
        }
        cout<< ans <<endl;

    }
        
}

Measured memory_bytes: 3656
package main

import (
	"fmt"
	"log"
)

func main() {
	var length int
	if n, err := fmt.Scanf("%d", &length); n != 1 || err != nil {
		log.Fatalln(n, err)
	}

	array := make([]int, length)
	for i := 0; i < length; i++ {
		if n, err := fmt.Scanf("%d", &array[i]); n != 1 || err != nil {
			log.Fatalln(n, err)
		}
	}

	swap := bubbleSort(array, length)
	printArray(array, length)
	fmt.Println(swap)
}

func bubbleSort(array []int, length int) int {
	count := 0
	for i := 0; i < length; i++ {
		flag := false
		for j := length - 1; j > i; j-- {
			if array[j] < array[j-1] {
				array[j], array[j-1] = array[j-1], array[j]
				count++
				flag = true
			}
		}
		if !flag {
			break
		}
	}

	return count
}

func printArray(array []int, length int) {
	fmt.Print(array[0])
	for i := 1; i < length; i++ {
		fmt.Printf(" %d", array[i])
	}
	fmt.Print("\n")
}


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

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  LL n; cin>>n;
  vector <LL> cnt(n+1);
  vector<LL> v(n);
  LL an = 0;
  for(int i=0;i<n;i++){
    cin>>v[i];
    cnt[v[i]]++;
  }
  for(auto i:cnt){
    an += i*(i-1)/2;
  }
  for(int i=0;i<n;i++){
    if(cnt[v[i]]>1){
      LL kk = an - (cnt[v[i]])*(cnt[v[i]] - 1)/2 + (cnt[v[i]]-1)*(cnt[v[i]]-2)/2;
      cout<<kk<<" ";
      }
    else
      cout<<an<<" ";
    }
    cout<<endl;
    return 0;
  }


Measured memory_bytes: 5760
N = int(input())
S = []
for i in range(N):
    S.append(input())
AC = S.count("AC")
WA = S.count("WA")
TLE = S.count("TLE")
RE = S.count("RE")

print("AC x {}".format(AC))
print("WA x {}".format(WA))
print("TLE x {}".format(TLE))
print("RE x {}".format(RE))

Measured memory_bytes: 16292
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

macro_rules! read_value {
    ($next:expr, [graph1; $len:expr]) => {{
        let mut g = vec![vec![]; $len];
        let ab = read_value!($next, [(usize1, usize1)]);
        for (a, b) in ab {
            g[a].push(b);
            g[b].push(a);
        }
        g
    }};
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => (read_value!($next, usize) - 1);
    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        read_value!($next, [$t; len])
    }};
    ($next:expr, $t:ty) => ($next().parse::<$t>().expect("Parse error"));
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input! {
        a: i64, b: i64, c: i64, d: i64,
    }
    let mut ma = max(a * c, a * d);
    ma = max(ma, max(b * c, b * d));
    puts!("{}\n", ma);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 2204
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
  int cnt[26] = {};
  char str[5];
  cin >> str;
  
  for(int i=0; i<4; i++)
  {
    cnt[str[i] - 'A'] += 1;
  }
  for(int i=0; i<26; i++)
  {
    if(cnt[i] == 0 || cnt[i] == 2)
      continue;
    cout << "No" << endl;
    return 0;
  }
  
  
    cout << "Yes" << endl;
    return 0;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
signed main(){
  int m,n;
  while(cin>>m,m){
    P s[m];
    for(int i=0;i<m;i++) cin>>s[i].first>>s[i].second;
    cin>>n;
    P t[n];
    for(int i=0;i<n;i++) cin>>t[i].first>>t[i].second;
    set<P> sp;
    for(int i=0;i<n;i++) sp.insert(t[i]);
    for(int i=0;i<n;i++){
      int dx=t[i].first-s[0].first;
      int dy=t[i].second-s[0].second;
      bool f=1;
      for(int j=0;j<m;j++)
	f&=sp.count(P(s[j].first+dx,s[j].second+dy));
      if(f){
	cout<<dx<<" "<<dy<<endl;
	break;
      }
    }
  }
  return 0;
}

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

using namespace std;

char s[1010];
int w;

int main()
{
    cin>>s;
    cin>>w;
    int len;
    len=strlen(s);
    for(int i=0;i<len;i++){
        if(i%w==0){
            cout<<s[i];
        }
    }
                return 0;
}


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

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

class modint {
	static constexpr std::int_fast64_t Modulus = 1e9 + 7;
	using u64 = std::int_fast64_t;

public:
	u64 a;
	constexpr modint(const u64 x = 0) noexcept : a(x% Modulus) {}
	constexpr u64& value() noexcept { return a; }
	constexpr const u64& value() const noexcept { return a; }
	constexpr modint operator+(const modint rhs) const noexcept {
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const noexcept {
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const ll rhs) const noexcept {
		return modint(*this) *= modint(rhs);
	}
	constexpr modint operator*(const modint rhs) const noexcept {
		return modint(*this) *= rhs;
	}
	constexpr modint& operator+=(const modint rhs) noexcept {
		a += rhs.a;
		if (a >= Modulus) {
			a -= Modulus;
		}
		return *this;
	}
	constexpr modint& operator-=(const modint rhs) noexcept {
		if (a < rhs.a) {
			a += Modulus;
		}
		a -= rhs.a;
		return *this;
	}
	constexpr modint& operator*=(const modint rhs) noexcept {
		a = a * rhs.a % Modulus;
		return *this;
	}
	constexpr operator u64() const { return a; }
};

int main() {
	ll n, m, k;
	cin >> n >> m >> k;
	rep(i, n+1) {
		ll b = n - i;
		rep(j, m+1) {
			auto s = b* j + i * (m - j);
			if (s == k) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF (1<<29)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
#define fr first
#define sc second
const int dx[] = {-1,0,0,1},dy[] = {0,1,-1,0};

typedef long long int ll;

using namespace std;

void saiki(vector<int> v,vector<bool> u){
}

int main(){

    while(true){
	vector<int> p(8);
	vector<int> ans(8,4);
	vector<int> m;
	m.clear();
	REP(i,8){
	    cin >> p[i];
	    if(cin.eof()) break;
	}
	if(cin.eof()) break;
	m.PB(1);
	m.PB(2);
	m.PB(1);
	m.PB(2);
	m.PB(1);
	m.PB(4);
	m.PB(1);
	m.PB(4);
	int mini = 100000;
	int c = 0;
	REP(j,8){
	    c++;
	    int temp = 0;
	    REP(i,8){
		temp += max(p[i]-m[(i+j)%8],0);
	    }
	    if(mini == temp){
		mini = temp;
		ll sum = 0;
		ll sum1 = 0;
		REP(k,8){
		    sum += (ll)pow(10,7-k) * (ll)m[(j+k)%8];
		    sum1 += (ll)pow(10,7-k) * (ll)ans[k];
		}

		if(sum < sum1){
		    REP(i,8){
			    ans[i] = m[(i+j)%8];
		    }
		}

	    }else if(mini > temp){
		mini = temp;
		REP(i,8){
		    ans[i] = m[(i+j)%8];
		}
	    }
	}
	cout << ans[0];
	REP(i,7){
	    cout << " " << ans[i+1];
	}
	cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1260
n,m,x = map(int,input().split())
C = [list(map(int,input().split())) for _ in range(n)]
#print(C)

ans = 10**10
for bit in range(1<<n):
    s = [0]*m
    now = 0
    for i in range(n):
        if bit & 1<<i:
            for j in range(m):
                s[j] += C[i][j+1]
            now += C[i][0]
    if all(y >= x for y in s):
        #print(s)
        ans = min(ans,now)
if ans == 10**10:
    print(-1)
    exit()
print(ans)

Measured memory_bytes: 69052
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    string s; cin >> s;
    long long ans = 0, stack = 0;
    bool a_flag=false, ab_flag=false;
    for(int i=0; i < s.size(); i++) {
        if(s.at(i) == 'A') {
            if(!a_flag) stack = 0;
            stack++;
            a_flag = true;
            ab_flag = false;
        } else if(s.at(i) == 'B') {
            if(a_flag) {
                a_flag = false;
                ab_flag = true;
            } else {
                a_flag = false;
                ab_flag = false;
                stack = 0;
            }
        } else {
            if(ab_flag) {
                // 発火
                ans += stack;
                // 現在のイテレータがAになるので、a_flagは立てたままにしておく
                // stackも積んだまま
                a_flag = true;
                ab_flag = false;
            } else {
                a_flag = false;
                ab_flag = false;
                stack = 0;
            }
        }
    }

    cout << ans << endl;

}

/**
AABCBABC -> 3
 **/

Measured memory_bytes: 640
import bisect
N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))

ans = 0
for b in B:
    i_a = bisect.bisect_left(A, b)
    i_c = bisect.bisect_right(C, b)
    ans += i_a * (N-i_c)
print(ans)

Measured memory_bytes: 22720
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<'\n';}}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}

int main(){
    ll x,y,a,b,c;cin>>x>>y>>a>>b>>c;
    vi s(a),t(b),u(c);
    rep(i,a)cin>>s[i];
    rep(i,b)cin>>t[i];
    rep(i,c)cin>>u[i];
    sort(all(s));
    sort(all(t));
    PQ pq;
    for(ll k:u)pq.push(k);
    rep(i,x)pq.push(s[a-1-i]);
    rep(i,y)pq.push(t[b-1-i]);
    ll ans=0;
    rep(i,x+y){
        ans+=pq.top();pq.pop();
    }
    out(ans);
}

Measured memory_bytes: 8816
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> bool chmin(T&x,T y){if(x>y){x=y;return true;}return false;}
template<class T> bool chmax(T&x,T y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

struct tree{
    size_t n,r,md;
    vector<vector<int>> e;
    vector<int> pa,d,sz;
    explicit tree(int n):n(n),e(n){}
    explicit tree(string&s):n(s.length()/2+1),e(n),pa(n),d(n),sz(n,1){
        pa[0]=-1;
        int i{};
        stack<int> p;
        p.push(0);
        for(auto c:s){
            if(c=='('){
                pa[++i]=p.top();
                d[i]=p.size();
                e[p.top()].push_back(i);
                p.push(i);
            }
            else{
                sz[pa[p.top()]]+=sz[p.top()];
                p.pop();
            }
        }
        assert(i==n-1);
    }
    void built(bool f=true){
        static int a,b;
        fr(i,n-1){
            cin>>a>>b;
            if(f) --a,--b;
            add(a,b);
        }
    }
    void add(int a,int b){
        e[a].emplace_back(b);
        e[b].emplace_back(a);
    }
    template<class T>
    vector<T> rec(int i){
        vector<T> ans(3,1);
        ans[1]=2;
        for(auto j:e[i]){
            auto a=move(rec<T>(j));
            auto m0=ans.size(),m1=a.size();
            ans.resize(m0+m1-1,0);
            ifr(i0,m0){
                iFr(i1,m1-1) ans[i0+i1]+=ans[i0]*a[i1];
                ans[i0]*=a[0];
            }
        }
        return ans;
    }
    void r_dfs(int i,int p=-1){
        int c{};
        for(auto j:e[i]) if(j!=p) r_dfs(j,i),c+=!sz[j],sz[i]+=sz[j];
        sz[i]+=max(0,c-1);
    }
    int r_i(){
        size_t SZ{};
        fr(i,n) if(chmax(SZ,e[i].size())) r=i;
        if(SZ<3) return 1;
        sz.resize(n);
        r_dfs(r);
        return sz[r];
    }
};

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    int n;
    in>>n;
    tree tr(n);
    tr.built(false);
    cout<<tr.r_i()<<'\n';
}

Measured memory_bytes: 8832
import itertools
n = int(input())
P = int(input().replace(' ', ''))
Q = int(input().replace(' ', ''))
N = [i + 1 for i in range(n)]
per = list(itertools.permutations(N))
lis = []
for oc in per:
    lis.append(int(''.join(map(str, list(oc)))))
a = lis.index(P)
b = lis.index(Q)
print(abs(a - b))

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

const long long mod = 1000000007;
long long df[5050]={1,1};
vector<int> G[5050];

vector<long long> go(int x, int l)
{
	vector<long long> r(1,1);
	for (int y : G[x]) if (y != l){
		auto d = go(y,x);
		vector<long long> t(r.size()+d.size()-1,0);
		for (int i=0;i<r.size();i++) for (int j=0;j<d.size();j++) t[i+j] = (t[i+j] + r[i] * d[j]) % mod;
		r = move(t);
	}

	r.insert(r.begin(),0);
	for (int i=2;i<r.size();i+=2) r[0] = (r[0] + mod - r[i] * df[i-1] % mod) % mod;
	return move(r);
}

int main()
{
	for (int i=2;i<5050;i++) df[i] = df[i-2] * i % mod;

	int N; scanf ("%d",&N);
	for (int i=1;i<N;i++){
		int x,y; scanf ("%d %d",&x,&y);
		G[x].push_back(y);
		G[y].push_back(x);
	}

	auto p = go(1,0);
	printf ("%lld\n",(mod-p[0])%mod);
	return 0;
}

Measured memory_bytes: 1280
N=input()
N=int(N)
ls=[int(s) for s in input().split()]
flag=1
ans=0
while flag==1:
  count=0
  for i in range(N):
    if ls[i]%2==0: 
      count=count+1
  if count==N:
    ans=ans+1
    for i in range(N):
      ls[i]=ls[i]//2
  else:
    flag=flag-1
print(ans)

Measured memory_bytes: 9036
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn read_str() -> Vec<char> {
    return read::<String>().chars().collect();
}

pub fn main() {
    let a : Vec<char> = read_str();
    let result = match a[0] {
        'A' => 'T',
        'T' => 'A',
        'G' => 'C',
        'C' => 'G',
        _ => 'X'
    };
    println!("{}", result);
}


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

using namespace std;

int main(){


    long long t;
    cin>>t;
    long long ac=0,tle=0,re=0,wa=0;
    while (t--){
        string s;
        cin>>s;
        if(s=="AC"){
            ac++;
        }
        if(s=="TLE"){
            tle++;
        }
        if(s=="RE"){
            re++;
        }
        if(s=="WA"){
            wa++;
        }

    }
    cout<<"AC x "<<ac<<endl;
    cout<<"WA x "<<wa<<endl;
    cout<<"TLE x "<<tle<<endl;
    cout<<"RE x "<<re<<endl;

    
}

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

int main(){
    int n, m, ans;
    cin >> n >> m;
    if(n<=1 && m<=1) ans =0;
    else if(n<=1 && m>=2) ans = m * (m-1) / 2;
    else if(n>=2 && m<=1) ans = n * (n-1) / 2;
    else ans = m * (m-1) / 2 + n * (n-1) / 2;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef pair<int, int> ipair;
typedef tuple<int, int, int> ituple;

const int INF = (int)2e9;
// const int MOD = (int)1e9 + 7;
// const double EPS = 1e-10;

#define MAX_N 500 + 2

void exec(){
  int n;
  string a[MAX_N];
  int allBlackRow = -1;
  bool isAllWhite = true;

  cin >> n;

  for (int i = 0; i < n; i++){
    bool isAllBlack = true;
    cin >> a[i];
    for (int j = 0; j < n; j++){
      if (a[i][j] != '#'){
        isAllBlack = false;
      }
      if (a[i][j] == '#'){
        isAllWhite = false;
      }
    }
    if (isAllBlack){
      allBlackRow = i;
    }
  }

  if (isAllWhite){
    cout << -1 << endl;
    return;
  }

  int result = 0;
  // 真っ黒な行を探す
  if (allBlackRow == -1){
    // 列に黒があるか？
    bool existsBlackInColumn[n];

    for (int i = 0; i < n; i++){
      existsBlackInColumn[i] = false;
      for (int j = 0; j < n; j++){
        if (a[j][i] == '#'){
          existsBlackInColumn[i] = true;
          break;
        }
      }
    }

    int minimumChangeRaw = INF;
    for (int i = 0; i < n; i++){
      int changeColumns = 0;
      int whiteNum = 0;
      for (int j = 0; j < n; j++){
        if (a[i][j] == '.'){
          whiteNum++;
        }
      }
      if (existsBlackInColumn[i]){
        changeColumns += whiteNum;
      }
      else{
        changeColumns += whiteNum + 1;
      }
      minimumChangeRaw = min(minimumChangeRaw, changeColumns);
    }

    result += minimumChangeRaw;
  }

  // 白がある列を探す
  for (int i = 0; i < n; i++){
    for (int j = 0; j < n; j++){
      if (a[j][i] == '.'){
        result++;
        break;
      }
    }
  }

  cout << result << endl;

}

void solve(){
  int t = 1;
  // scanf("%d", &t);
  for (int i = 0; i < t; i++){
    exec();
  }
}

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


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

int main(){
  string S;
  cin >>S;
  if(S == "SUN")
    cout << 7;
  else if(S == "MON")
    cout << 6;
  else if(S == "TUE")
    cout << 5;
  else if(S == "WED")
    cout << 4;
  else if(S == "THU")
    cout << 3;
  else if(S == "FRI")
    cout << 2;
  else if(S == "SAT")
    cout << 1;
}

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

#define vec                vector<int>
#define vecll              vector<ll>
#define vecd               vector<double>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>> var(n, vector<int>(m, 0))
#define vecll2(var, n, m)  vector<vector<ll>> var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "Yes" : "No");}
//----------------------------------------------------------------

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

  int ans = ((a-1)/1000 + 1)*1000 - a;
  prt(ans);
}


Measured memory_bytes: 3636
#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<int> a(n);
    rep(i,n) cin >> a[i];
    int cnt = 0;
    rep(i,n){
        if(a[i] == cnt + 1) cnt++;
    }
    if(cnt == 0) cout << -1 << endl;
    else cout << n - cnt << endl;
}

Measured memory_bytes: 4040
A,B = map(int,input().split())
if A == 0:
    A = 1
Blist = bin(B)[2:]
Alist = bin(A-1)[2:]

def sumxor(P):
    ans = 0
    L = len(P)
    for i in range(L):
        ans *= 2
        if i < L-1:
            if P[i] == '1' and P[-1] == '0':
                ans += 1
        else:
            k = int(P[-2:],2)
            if k == 1 or k == 2:
                ans += 1
    return ans

print(sumxor(Alist) ^ sumxor(Blist))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

int main() {
    ll n, x;
    cin >> n >> x;

    vector<ll> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    vector<vector<ll>> b(n,vector<ll>(n,0));
    for(int j = 0; j < n; j++){
        b[0][j] = a[j];
    }
    for(int i = 1; i < n; i++){
        for(int j = 0; j < n; j++){
            b[i][j] = min(b[i-1][j],b[0][(j-i+n)%n]);
        }
    }

    ll t = 0, ans = 99999999999999, ix, sum;
    for(int i = 0; i < n; i++){
        sum = 0;
        ix = i*x;
        for(int j = 0; j < n; j++){
            sum += b[i][j];
        }
        ans = min(ans, ix+sum);
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 31616
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#include <numeric>
#include <bitset>
#include <cassert>
#include <functional>
#include <unistd.h>

using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;
typedef pair<ll, ll> P;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(c) c.begin(), c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll MOD = 1000000007;
long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long mod)
{
    return modpow(a, mod - 2, mod);
}
ll comb(ll n, ll r)
{
    ll bunshi = 1;
    ll bunbo = 1;
    rep(i, r)
    {
        bunshi = bunshi * (n - i) % MOD;
        bunbo = bunbo * (r - i) % MOD;
    }
    return ((bunshi % MOD) * modinv(bunbo, MOD)) % MOD;
}
long long mod(long long val, long long m)
{
    long long res = val % m;
    if (res < 0)
        res += m;
    return res;
}
int main()
{
    ll n, a, b;
    cin >> n >> a >> b;
    ll miner = 1 + comb(n, a) + comb(n, b);
    cout << mod(modpow(2, n, MOD) - miner, MOD) << endl;
    return 0;
}


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

const int INF{1<<30};
struct Edge{
	int s,g,d;
	Edge(int a, int b, int c) : s(a), g(b), d(c) {}
	
	bool operator<(const Edge &b){
		if(d!=b.d) return d<b.d;
		if(s!=b.s) return s<b.s;
		return g < b.g;
	}
};
struct Point{
	int x,y,num;
	Point(int a, int b, int c) : x(a), y(b), num(c) {}
	Point():x(),y(),num(){}
};
bool comp1(const Point &a, const Point &b){
	if(a.x!=b.x) return a.x<b.x;
	if(a.y!=b.y) return a.y<b.y;
	return a.num < b.num;
}
bool comp2(const Point &a, const Point &b){
	if(a.y!=b.y) return a.y<b.y;
	if(a.x!=b.x) return a.x<b.x;
	return a.num < b.num;
}

struct Unionfind {
	vector< int > par;
	Unionfind(int N) : par(N,-1){
	}
	bool unite(int x, int y) {
		x = root(x), y = root(y);
		if(x == y) return 0;
		if(par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return 1;
	}
	int root(int k) {
		if(par[k] < 0) return (k);
		return (par[k] = root(par[k]));
	}
	bool same(int x, int y){
		x = root(x);
		y = root(y);
		return x==y;
	}
	int size(int k) {
		return (-par[root(k)]);
	}
};

int main() {
	int n; cin >> n;
	vector<Point>p(n);
	vector<Edge> g;
	for(int i=0; i<n; i++) {
		cin>>p.at(i).x>>p.at(i).y; 
		p.at(i).num = i;
	} 
	sort(p.begin(), p.end(),comp1);
	for(int i=0; i<n-1; i++){
		g.push_back({p.at(i).num,p.at(i+1).num,min(abs(p.at(i).x-p.at(i+1).x), abs(p.at(i).y-p.at(i+1).y))});
	}
	sort(p.begin(), p.end(),comp2);
	for(int i=0; i<n-1; i++){
		g.push_back({p.at(i).num,p.at(i+1).num,min(abs(p.at(i).x-p.at(i+1).x), abs(p.at(i).y-p.at(i+1).y))});
	}
	sort(g.begin(),g.end());
	int64_t sum{};
	Unionfind uf(n);
	for(auto i:g){
		if(!uf.same(i.s,i.g)){
			uf.unite(i.s,i.g);
			sum += i.d;
		}
	}
	cout << sum << endl;
}


Measured memory_bytes: 6132
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;

    vector<int> LIST(n);
    for (int i = 0; i < n; i++) {
        cin >> LIST[i];
    }

    sort(LIST.begin(), LIST.end());

    double prev = LIST[0];
    for (int i = 1; i < n; i++) {
        prev = (prev + LIST[i]) / 2;
    }

    cout << prev;

    return 0;
}

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

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  int N;
  cin >> N;
  VLL a(N);
  rep(i,N){
    cin >> a[i];
  }

  sort(all(a));

  VLL sum_array(N);

  rep(i,N) sum_array[i] = a[i];
  rep(i,N-1) sum_array[i+1] += sum_array[i];

  ll ans = 0;
  rep(i,N-1){
    if(a[i+1] <= 2*sum_array[i] ){
      ans++;
    }else{
      ans = 0;
    }
  }
  cout << ans + 1 << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    int d;
    while (scanf("%d", &d) != EOF) {
        int ans = 0;
        for (int i = 0; i < 600; i+=d) ans += i*i*d;
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    int N;LL W;cin >> N >> W;
    vector<LL> w(N);
    vector<LL> v(N);
    rep(i,N)cin >> w[i] >> v[i];
    LL dp[110][110000];
    rep(i,110) rep(j,110000)dp[i][j] = INF;  // 初期化
    dp[0][0] = 0;   // 初期条件
    
    rep(i,N){
        for(int sum_v = 0;sum_v <= 100000;sum_v++){ // i はアイテムの探索済み番号で、sum_vはカバン内の最低価値を示す。dpはその遷移時点にありうる最小の重さを記録。
            
            if(sum_v - v[i] >= 0){
                chmin(dp[i+1][sum_v],dp[i][sum_v - v[i]] + w[i]);
            }

            chmin(dp[i+1][sum_v],dp[i][sum_v]);
        }
    }

    LL ans = 0;
    rep(i,100001){
        if(dp[N][i] <= W)ans = i;
    }
    cout << ans << endl;
}



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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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 modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

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

    ll N;
    cin >> N;
    vector<ll> a(3 * N);
    for(ll i = 0; i < (3*N); i++){
        cin >> a[i];
    }

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

    ll ans = 0;
    for(ll i = N; i < (3*N); i += 2){
        ans += a[i];
    }

    cout << ans << endl;
    

    return 0;
}



Measured memory_bytes: 2560
#include<iostream>
#include<cstdio>
using namespace std;
int cnt;
int a,b,c;
void solve(){
    for(int i=a;i<=b;i++)
    {
        if(i>c)return ;
        if(c%i==0)cnt++;
    }
}
int main()
{
    cnt=0;
    cin>>a>>b>>c;
    solve();
    cout<<cnt<<endl;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000000000000002
#define N 400003
#define pb push_back
#define endl "\n"
using namespace std;
  ll m[3003][3005];
int main()
{      ios_base::sync_with_stdio(false);
  
    cin.tie(0);cout.tie(0);

    string a,b;
    cin>>a>>b;
    


    for(ll i=0;i<=a.length();i++)
    {
        for(ll j=0;j<=b.length();j++)
        {
            if(i==0||j==0)
            {m[i][j]=0;}
            
            else if(a[i-1]==b[j-1])
            {
                m[i][j]=m[i-1][j-1]+1;
            }
            else
            {
                m[i][j]=max(m[i-1][j],m[i][j-1]);
            }

        }
    };
    ll i=a.length();
    ll j=b.length();
    string dd="";
   
  
 while(i>0 && j>0 )
 {
     if(a[i-1]==b[j-1])
     {
         dd+=a[i-1];
      
         i--;j--;
     }
     else if(m[i][j-1]>m[i-1][j])
     {
              j--;
     }
     else
                 {
                 i--;
                 }
     
 }
    reverse(dd.begin(),dd.end());
    cout<<dd<<endl;
   
    return 0;
}


Measured memory_bytes: 70784
import math

sin = math.sin(math.pi/3)
cos = math.cos(math.pi/3)

n = int(input())
p1, p2 = (0, 0), (100, 0)
ans_ls = [p1, p2]

def koch(d, p1, p2):
    if d == n:
        return
    
    s = (2/3 * p1[0] + 1/3 * p2[0], 2/3 * p1[1] + 1/3 * p2[1])
    t = (1/3 * p1[0] + 2/3 * p2[0], 1/3 * p1[1] + 2/3 * p2[1])
    u = ((t[0] - s[0]) * cos - (t[1] - s[1]) * sin + s[0], (t[0] - s[0]) * sin + (t[1] - s[1]) * cos + s[1])
    ans_ls.extend([s, u, t])
    
    koch(d+1, p1, s)
    print(*s)
    koch(d+1, s, u)
    print(*u)
    koch(d+1, u, t)
    print(*t)
    koch(d+1, t, p2)
    
print(*p1)
koch(0, p1, p2)
print(*p2)


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

int main(){
    string s;
    cin >> s;
    int c = 0;
    for (int i = 0; i < s.size(); ++i) {
        if(s.at(i) == '1'){
            c++;
        }
    }
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int A,B,C,X;
  cin >> A >> B >> C >> X;
  int ans = 0;
  rep(a,A+1) {
    rep(b,B+1) {
      rep(c,C+1) {
        if(500*a+100*b+50*c==X) ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define PI 3.1415926535897932

int main()
{
  int a,b,x;
  double da,db,dx,full,theta;
  scanf("%d%d%d", &a, &b, &x);
  da=(double)a;
  db=(double)b;
  dx=(double)x;
  full=da*da*db;
  if(dx>=full/2){
    theta=atan2(2*(full-dx)/da/da,da);
  }else{
    theta=PI/2-atan2(2*dx/db/da,db);
  }
  printf("%.10f\n",theta/PI*180);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int MOD=1000000007;
using namespace std;
int main(){
    vector<ll> k(51,1);
    rep(i,0,50) k[i+1]=k[i]*(i+1);
    
    int n,p;
    cin>>n>>p;
    int od=0,ev=0;
    rep(i,0,n){
        int a;
        cin>>a;
        if(a%2==0) ev++;
        else od++;
    }
    
    ll ans=1;
    ans*=(ll)pow(2,ev);
    if(od==0){
        if(p==1) ans*=0;
        else ans*=1;
    }
    else ans*=(ll)pow(2,od-1);
    cout<<ans<<endl;
}


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

#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << a << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

const int N = 1e5 + 10;
vi d;
vi adj[N];

bool vis[N];
int dfs(int u) {
    if (vis[u]) return 0;
    vis[u] = 1;
    int res = d[u];
    for (int v : adj[u]) {
        res += dfs(v);
        if (res >= 26) res -= 26;
    }
    return res%26;
}


int main() {
    string s; cin >> s;
    int len = si(s);
    s = "a" + s + "a";
    d.resize(len+1);
    forn(i,len+1) d[i] = (int(s[i+1])-s[i]+26)%26;
    for (int i = 0, j = len; i < j; i++, j--) {
        adj[i].pb(j);
        adj[j].pb(i);
    }

    int n; cin >> n;
    while (n--) {
        int l,r; cin >> l >> r; l--;
        adj[l].pb(r);
        adj[r].pb(l);
    }

    bool ok = 1;
    forn(i,len+1) if (!vis[i]) {
        auto sum = dfs(i);
        ok &= sum == 0;
    }
    cout << (ok ? "YES" : "NO");

    return 0;
}


Measured memory_bytes: 8572
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <assert.h>
#include <cstdio>

// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

inline bool chmin(ll &a, ll b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

inline bool chmax(ll &a, ll b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

//桁数取得
template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}
//整数乗
ll llpow(ll a, ll n)
{
    if (n == 0)
    {
        return 1;
    }
    else
    {
        ll rep = a;
        for (ll i = 1; i < n; i++)
        {
            rep *= a;
        }
        return rep;
    }
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

template <typename T>
T amarinasi(T a, T b)
{
    if (a % b == 0)
    {
        return a / b;
    }
    else if (a % b > 0)
    {
        return a / b + 1;
    }
    else
    {
        return a / b - 1;
    }
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------
const double pi = 3.14159265358979323846264;

int main()
{
    string s;
    cin >> s;
    ll cnt = 0;
    for (ll i = 0; i < s.size(); i++)
    {
        cnt += s[i] - '0';
    }
    if (cnt % 9)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 3752
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

a, b, c = sorted(map(int, input().split()))

if a % 2 == 0 or b % 2 == 0 or c % 2 == 0:
    print(0)
else:
    print(a * b)


Measured memory_bytes: 61788
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int min = Integer.MAX_VALUE;
        int max = Integer.MIN_VALUE;
        long sum = 0;
        
        List<Integer> array = new ArrayList<Integer>();
        while (scan.hasNext()) {
             int i = scan.nextInt();
             array.add(i);
        }
        
        for(int j=0; j<array.size(); j++) {
            if(min > array.get(j)) min = array.get(j);
            if(max < array.get(j)) max = array.get(j);
            sum += array.get(j);
       }
       
       System.out.println(min +" "+ max +" "+ sum);
       scan.close();
    }
}

Measured memory_bytes: 43596
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <math.h>

int qsort_int(const void *a, const void *b)
{
    // 昇順
    return *(int *) a - *(int *) b;
}

int main(int argc, char *argv[])
{
    int n, m;
    int x[100000];
    int diff[100000];
    int i;
    int ans;

    scanf("%d %d", &n, &m);

    for (i = 0; i < m; i++) {
        scanf("%d", &x[i]);
    }

    qsort(x, m, sizeof(int), qsort_int);

    // 差分を出す
    for (i = 0; i < m - 1; i++) {
        diff[i] = x[i + 1] - x[i];
    }

    qsort(diff, m - 1, sizeof(int), qsort_int);

    // N = 1のとき，回数はxの(max - min)
    ans = x[m - 1] - x[0];

    for (i = 1; i < n && i <= m - 1; i++) {
        ans -= diff[m - 1 - i];
    }

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

    return 0;
}


Measured memory_bytes: 1396
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

int main(){
	int n;
	cin >> n;
	cout << (1000 - (n % 1000))%1000 << endl;
}

Measured memory_bytes: 3636
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, x, *a = map(int, read().split())
memo = [0] * n
ans = 0
if a[0] > x:
    ans += a[0] - x
    a[0] = x
for i in range(n - 1):
    memo[i] = a[i] + a[i + 1]
for i, check in enumerate(memo):
    if check > x:
        ans += check - x
        memo[i + 1] -= check - x
print(ans)


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

int main() {
  int n;
  cin >> n;
  vector<int> arr(n);
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
  }
  int cnt = 0;
  while (all_of(arr.begin(), arr.end(), [](auto value){return value % 2 == 0;})) {
    ++cnt;
    for (auto &value : arr) {
      value /= 2;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256