akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

#define X first
#define Y second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define rep(i, a, b) for (long i = (a); i <= (b); ++i)
#define per(i, a, b) for (long i = (a); i >= (b); --i)

using namespace std;

using I = int;
using L = long;
using F = float;
using S = string;
using SS = stringstream;
using C = char;
using LL = long long;
using VI = vector<int>;
using VL = vector<long>;
using VF = vector<float>;
using VS = vector<string>;
using VVI = vector<vector<int>>;
using VVL = vector<vector<long>>;
using PLL = pair<long, long>;
using PLF = pair<long, float>;
using PLS = pair<long, string>;
using PSL = pair<string, long>;
using PSF = pair<string, float>;
using PSS = pair<string, string>;
using MLL = map<long, long>;
using MLF = map<long, float>;
using MLS = map<long, string>;
using MSL = map<string, long>;
using MSF = map<string, float>;
using MSS = map<string, string>;

const long kMax2 = 109;
const long kMax3 = 1009;
const long kMax4 = 10009;
const long kMax5 = 100009;
const long kMax6 = 1000009;
const long kInfI = 0x3F3F3F3F;
const float kInfF = 1e15;

template <class T>
void PrintVector(const vector<T> & v) {
  for (const auto & e: v) {
    cout << e << endl;
  }
}

template <class T>
void PrintVector(const vector<T> & v, unsigned n) {
  rep(i, 0, n - 1) {
    cout << v[i] << endl;
  }
}

int main(int argc, char const *argv[]) {
  const int kMax = 8010;
  S s;
  int n, m;
  cin >> n >> m;
  SS ss;
  ss << n << m;
  int k = stoi(ss.str());
  int j = sqrt(k);
  if (j * j == k) cout << "Yes\n";
  else cout << "No\n";

  return 0;
}


Measured memory_bytes: 256
X, Y, Z, K = [int(x) for x in input().split()]
A = sorted([int(x) for x in input().split()], reverse=True)
B = sorted([int(x) for x in input().split()], reverse=True)
C = sorted([int(x) for x in input().split()], reverse=True)
lst = []
for i in range(X):
    for j in range(Y):
        for k in range(Z):
            if ((i+1)*(j+1)*(k+1)<=K):
                lst.append(A[i]+B[j]+C[k])
            else:
                break
for l in sorted(lst, reverse=True)[:K]:
    print(l)


Measured memory_bytes: 48984
#include<bits/stdc++.h>
#define ll long long
#define REP(i, n) for (int i=0; i<n; ++i)
#define print(x) cout << x << endl;

using namespace std;

void solve() {
    int X;
    cin >> X;

    if (X == 7 || X == 5 || X == 3) {
        print("YES");
    } else {
        print("NO");
    }
}

int main() {

    solve();
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;
using ll = long long;

int search(const ll n[], int len, ll comp) {
  int i = 0;
  int j = len;
  while (i < j) {
    int h = (i + j) >> 1;
    if (n[h] < comp) i = h + 1;
    else j = h;
  }
  return i;
}

int main() {
  int n;
  scanf("%d", &n);

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

  ll ans = 0;
  for (int bit = 0; bit < 29; bit++) {
    ll t = 1 << bit;
    ll a[n], b[n];
    for (int i = 0; i < n; i++) {
      a[i] = tmpa[i] % (2 * t);
      b[i] = tmpb[i] % (2 * t);
    }
    sort(b, b + n);

    int c = 0;
    for (int i = 0; i < n; i++) {
      int c1 = search(b, n, t - a[i]);
      int c2 = search(b, n, 2 * t - a[i]);
      int c3 = search(b, n, 3 * t - a[i]);
      int c4 = search(b, n, 4 * t - a[i]);
      c = (c + c2 - c1 + c4 - c3) % 2;
    }

    if (c == 1) ans += t;
  }

  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9+5;

int main(){
	string s,t;
	cin>>s>>t;
	vector<vector<pair<int,pair<int,int>>>> dp((int)s.length()+1, vector<pair<int,pair<int,int>>>((int)t.length()+1, {0, {INF,INF}}));
	dp[0][0] = {0,{0,0}};
	for(int i = 0; i <= s.length(); i++){
		for(int j = 0; j <= t.length(); j++){
			if(s[i] == t[j] && i < s.length() && j < t.length()){
				dp[i+1][j+1].first = max(dp[i+1][j+1].first, dp[i][j].first + 1);
				dp[i+1][j+1].second = {i,j};
			}
			if(j < t.length())
			dp[i][j+1].first = max(dp[i][j+1].first, dp[i][j].first);

			if(i < s.length())
			dp[i+1][j].first = max(dp[i+1][j].first, dp[i][j].first);
		}
	}
	
	int i = s.length(), j = t.length();
	string answer = "";
	while(i > 0){
		if(i == 0)
			break;
		
		if(dp[i][j].first == dp[i][j-1].first){
			j--;
		}
		else if(dp[i][j].first == dp[i-1][j].first){
			i--;
		}
		else{
			if(dp[i][j].second.first == INF){
				cout<<i<<j;
				break;
			}
			answer += s[dp[i][j].second.first];
			i = i-1;
			j = j-1;

		}
	}
	reverse(answer.begin(), answer.end());
	cout<<answer<<endl;
	return 0;
}

Measured memory_bytes: 105984
#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;
  cin >> n;
  
  vector<tuple<string, int, int>> a(n);
  string s;
  int p;
  REP(i,n) {
    cin >> s >> p;
    a[i] = make_tuple(s, -p, i+1);
  }
  
  sort(a.begin(), a.end());
                      
  REP(i,n) {
    cout << get<2>(a[i]) << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ri rd<int>
#define rep(i, a, b) for (int i = (a), _ = (b); i <= _; ++i)
#define per(i, a, b) for (int i = (a), _ = (b); i >= _; --i)
#define For(i, a, b) for (int i = (a), _ = (b); i < _; ++i)
const int maxN = 2e5 + 7;
typedef long long LL;

template<class T> T rd() {
	bool f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
	T x = 0; for (; isdigit(c); c = getchar()) x = x * 10 + c - '0'; return f ? x : -x;
}

int n;

struct pii {
	int a[2];
	int id;

	inline bool operator < (const pii &v) const {
		if (a[0] == 0) return true;
		if (v.a[0] == 0) return false;
		return (LL)a[1] * v.a[0] > (LL)a[0] * v.a[1];
	}

	inline bool operator != (const pii &v) const {
		return a[0] != v.a[0] || a[1] != v.a[1];
	}
}a[maxN];

int pre[maxN];
int dsu[maxN];
list<int> lis[maxN];
priority_queue<pii> q;

int find(int x) {
	return dsu[x] != x ? dsu[x] = find(dsu[x]) : x;
}

int main() {
#ifndef ONLINE_JUDGE
#endif

	n = ri();
	rep (i, 2, n) pre[i] = ri();
	rep (i, 1, n) {
		int x = ri();
		if (x == 1) ++a[i].a[1];
		else ++a[i].a[0];
		a[i].id = i;
		lis[i].push_back(x);
		q.push(a[i]);
		dsu[i] = i;
	}

	while (!q.empty()) {
		int x = q.top().id; 
		if (a[x] != q.top()) { 
			q.pop();
			continue;
		}
		q.pop();
		int y = find(pre[x]);
		lis[y].splice(lis[y].end(), lis[x]);
		a[y].a[0] += a[x].a[0];
		a[y].a[1] += a[x].a[1];
		if (y) q.push(a[y]);
		dsu[x] = pre[x];
	}

	LL cnt = 0, res = 0;
	for (list<int>::reverse_iterator it = lis[0].rbegin(); it != lis[0].rend(); ++it) {
		if (*it == 0) ++cnt;
		else res += cnt;
	}
	printf("%lld\n", res);

	return 0;
}


Measured memory_bytes: 16560
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

template<typename T>
istream& operator>> (istream& is, vector<T> &vec){
    for(T& x: vec) is >> x;
    return is;
}

int main(){
    ll n; cin >> n;
    ll maxx = 1000000000, x = (maxx-n%maxx)%maxx, y = (n+x)/maxx;
    printf("%lld %lld %lld %lld %lld %lld\n", 0LL, 0LL, maxx, 1LL, x, y);
    return 0;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; i--)
#define loop(i, r, n) for (int i = (r); i < (n); i++)
#define pb push_back
#define all(in) in.begin(),in.end()

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

using ll = long long;
using ull = unsigned long long;
using namespace std;

vector<vector<int>> G;
vector<bool> used;

int dfs(int v){
    int res = 1;
    used[v] = true;
    for(auto nv : G[v]) if(!used[nv]) res += dfs(nv);
    return res;
}

int main(){
    int n, m; cin >> n >> m;
    G.resize(n);
    rep(i,m){
        int a, b; cin >> a >> b; a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    used.assign(n,false);
    int ans = 0;
    rep(i,n) if(!used[i]) chmax(ans,dfs(i));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 23516
def dfs(v, visited):

  for u in edges[v]:
    if u in visited:
      continue
    visited.add(u)
    if matched[u] == -1 or dfs(matched[u], visited):
      matched[u] = v
      return True
  return False

n=int(input())
edges = [set() for _ in range(n)]
matched = [-1] * n
a=[]
b=[]
c=[]
d=[]
for _ in range(n):
  x, y = map(int, input().split())
  a.append(x)
  b.append(y)
for _ in range(n):
  x, y = map(int, input().split())
  c.append(x)
  d.append(y)
for i in range(n):
  for j in range(n):
    if(a[i]<c[j] and b[i]<d[j]):
      edges[i].add(j)
print(sum(dfs(s, set()) for s in range(n)))

Measured memory_bytes: 3188
import math
A,B,N= map(int,input().split())

max=0
if N>B:
  N=B-1
  y=math.floor(A*N/B)-A*math.floor(N/B)
  print(int(y))
elif N==B:
  N=B-1
  y=math.floor(A*N/B)-A*math.floor(N/B)
  print(int(y))
else:
	y=math.floor(A*N/B)-A*math.floor(N/B)
	print(int(y))
  

Measured memory_bytes: 9200
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846


using namespace std;

//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(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)

const int N = 1005;
int x[N];
int def = 0x7f7f7f7f;

int dfs(const VVI &g, int u) {
	VI dp(x[u] + 1, def);
	dp[0] = 0;
	for (auto v : g[u]) {
		int ret = dfs(g, v);
		if (ret == -1)return -1;
		for (int i = x[u]; i >= 0; i--) {
			int tmp = dp[i];
			dp[i] = def;
			if (i + ret <= x[u]) dp[i + ret] = min(dp[i + ret], tmp + x[v]);
			if (i + x[v] <= x[u]) dp[i + x[v]] = min(dp[i + x[v]], tmp + ret);
		}
	}
	int ret = def;
	REP(i, x[u] + 1) {
		ret = min(ret, dp[i]);
	}
	if (ret == def)return -1;
	return ret;
}

int main() {
	int n;
	scanf("%d", &n);
	VVI g(n);
	REP(i, n - 1) {
		int p;
		scanf("%d", &p);
		p--;
		g[p].PB(i + 1);
	}
	REP(i, n)scanf("%d", &x[i]);
	if (dfs(g, 0) == -1)printf("IMPOSSIBLE\n");
	else printf("POSSIBLE\n");
	return 0;
}

Measured memory_bytes: 5760
n = input()
s = input()

alphabet = list("abcdefghijklmnopqrstuvwxyz")

def clear_dict(dict, keys):    
    for char in keys:
        dict[char] = 0

max_cnt = 0
for char_n in range(1, len(s)):
    cnt_left = dict()
    cnt_right = dict()
    clear_dict(cnt_left, alphabet)
    clear_dict(cnt_right, alphabet)

    str_left = s[:char_n]
    str_right = s[char_n:]
    for char in str_left:
        cnt_left[char] += 1
    for char in str_right:
        cnt_right[char] += 1
    
    cnt = 0
    for char in alphabet:
        if cnt_left[char] != 0 and cnt_right[char] != 0:
            cnt += 1
    
    max_cnt = max(cnt, max_cnt)

print(max_cnt)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
  private static List<String> solve(int n, int a, int b, char[] cs) {
    List<String> answers = new ArrayList<>();
    int total = 0;
    int international = 0;
    for (char c : cs) {
      switch (c) {
        case 'a':
          if (total < a + b) {
            answers.add("Yes");
            total++;
          } else {
            answers.add("No");
          }
          break;
        case 'b':
          if (total < a + b && international < b) {
            answers.add("Yes");
            total++;
            international++;
          } else {
            answers.add("No");
          }
          break;
        default:
          answers.add("No");
          break;
      }
    }
    return answers;
  }

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

    int n = s.nextInt();
    int a = s.nextInt();
    int b = s.nextInt();
    char[] cs = s.next().toCharArray();
    for (String answer : solve(n, a, b, cs)) {
      System.out.println(answer);
    }
  }
}


Measured memory_bytes: 51964
#include <iostream>
#include <algorithm>
#include <string>
#include <climits>
#include <vector>
#include <map>
using namespace std;

 
int main()
{
    int cnt = 0, rec[2020] = {0};
    string s;
    cin >> s;
    vector<int> a(s.size());
    int now = 1;
    for (int i = a.size()-1; i >= 0; --i) {
        a[i] = now * (s[i] - '0') % 2019;
        now = now * 10 % 2019;
    }
    now = 0; rec[0] = 1;
    for (int i = a.size()-1; i >= 0; --i) {
        now = (now+a[i])%2019;
        cnt += rec[now];
        rec[now]++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 4248
h=int(input())
if h==1:
    print(1)
else:
    count=0
    ans=1
    if h%2==1:
        h-=1
    while h>1:
        h//=2
        count+=1
    for i in range(count):
        ans*=2
    print(ans*2 - 1)

Measured memory_bytes: 3060
from collections import Counter
S=list(map(int,input()))
P=2019
N=len(S)
if P not in [2,5]:
  pt = [1]
  for i in range(N):
    pt.append(pt[-1]*10%P)
  dp = [(S[0]*pt[N-1])%P]
  for i in range(1,N):
    dp.append((dp[-1]+S[i]*pt[N-1-i])%P)

  c = Counter(dp)
  ans = sum(u*(u-1)//2 for u in c.values())
  print(ans+c[0])
elif P==2:
  S = [int(c) for c in input()]
  ans = 0
  for i in range(N):
    if S[i]%2==0:
      ans += i+1
  print(ans)
else:
  ans = 0
  S = [int(c) for c in input()]
  for i in range(N):
    if S[i]%5==0:
      ans += i+1
  print(ans)


Measured memory_bytes: 98932
#include<cstdio>
#include<queue>
#include<iostream>
#include<algorithm>
#include<list>
#include<vector>
using namespace std;
int a[2000];
int main() {
	int t;
	scanf("%d", &t);
	for (int i = 0; i < t; i++)
	{
		scanf("%d", &a[i]);
	}
	int temp[2000];
	int n;
	scanf("%d", &n);
	while (n--)
	{
		int choose,begin,end,i=0;
		scanf("%d%d%d", &choose,&begin,&end);
		for (int k=begin; begin < end; begin++)
		{
			temp[i++] = a[begin];
		}
		sort(temp, temp + i);
		switch (choose)
		{
		case 0:
			printf("%d\n", temp[0]);
			break;
		case 1:
			printf("%d\n", temp[i-1]);
		default:
			break;
		}
	}
}




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

#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define ll long long
#define bit __builtin_popcountll
#define sqr(x) (x) * (x)
#define forit(it,S) for(__typeof((S).begin()) it = (S).begin(); it != (S).end(); it++)
#define debug(x) cout << #x <<" = " << x << endl
#define forn(i, n) for(int i = 0 ; (i) < (n) ; ++i)
#define printvpair(v) for(int i = 0 ; (i) < (v.size()) ; ++i) cout << v[i].first  <<" " << v[i].second << endl;
#define printv(v) for(int i = 0 ; (i) < (v.size()) ; ++i) cout << v[i] << " "; cout << endl;

using namespace std;

typedef pair<int, int> pii;

const double eps = 1e-9;
const double pi = acos(-1.0);
const ll INF = 1000000000;

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

const int N = 55;
ll n;
ll d(ll n){
	if (n < 10)
		return 1;
	return d(n / 10) + 1;
}
int main() {
	ios_base::sync_with_stdio(0);
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin >> n;
	ll ans = INF;
	for(ll i = 1; i <= sqrt(n); i++){
		if (n % i == 0){
			ll x = i;
			ll y = n / i;
			ans = min(ans,max(d(x),d(y)));
		}
	}
	cout << ans << endl;
  	return 0;
}


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

using namespace std;

int main()
{
    int i, j;
    string s, s_rev, s_sub;

    cin >> s;
    s_rev = s;
    reverse(s_rev.begin(), s_rev.end());
    if (s_rev != s) {
        cout << "No" << endl;
        return 0;
    }

    s_sub = s_rev = s.substr(0, (s.size()-1)/2);
    reverse(s_rev.begin(), s_rev.end());
    if (s_rev != s_sub) {
        cout << "No" << endl;
        return 0;
    }

    s_sub = s_rev = s.substr((s.size()+3)/2-1);
    reverse(s_rev.begin(), s_rev.end());
    if (s_rev != s_sub) {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
inf = 10**18
mod = 10**9+7

a,v = map(int, input().split())
b,w = map(int, input().split())
t = int(input())
if v-w <= 0:
    print('NO')
else:
    if t >= abs(a-b)/(v-w):
        print('YES')
    else:
        print('NO')

Measured memory_bytes: 61628
n,k = map(int, input().split())
a = sorted(list(map(int, input().split())))
a_reverse = a[::-1]
mod = 10**9+7
 
factorial = [1]
inverse = [1]
for i in range(1, n+2):
    factorial.append(factorial[-1] * i % mod)
    inverse.append(pow(factorial[-1], mod - 2, mod))
 
def comb(n, r, mod):
    if n < r or r < 0:
        return 0
    elif r == 0:
        return 1
    return factorial[n] * inverse[r] * inverse[n - r] % mod

plus = 0
minus = 0
cnt = 0
ind = 0
for i in range(n-k+1):
    kaisu = comb(n-i-1, k-1, mod)
    plus = (plus + (kaisu * a_reverse[ind]) % mod) % mod
    minus = (minus + (kaisu * a[ind]) % mod) % mod
    ind += 1

print((plus-minus) % mod)

Measured memory_bytes: 72104
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s-1);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
    int n,m;cin>>n>>m;
    bool e[n][n];
    fill(e[0], e[n], false);
    REP(i, m) {
        int a,b;cin>>a>>b;
        a--;b--;
        e[a][b] = e[b][a] = true;
    }

    vector<int> v;
    REP2(i, 1, n) v.push_back(i);

    int ans = 0;

    do {
        int node = 0;
        bool f = true;
        FOR(i, v) {
            f &= e[node][*i];
            node = *i;
        }

        if (f) ans++;
    } while( next_permutation(ALL(v)) );

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
  int h,w,a,b; cin>>h>>w>>a>>b;
  rep(i,b){
    rep(j,a) cout<<0;
    rep(j,w-a) cout<<1;
    cout<<endl;
  }
  rep(i,h-b){
    rep(j,a) cout<<1;
    rep(j,w-a) cout<<0;
    cout<<endl;
  }
  return 0;
}


Measured memory_bytes: 1280
n=input()
ed=[[] for i in range(n+1)]
for i in range(n-1):
    c,d=map(int,raw_input().split())
    ed[c].append(d)
    ed[d].append(c)
a=[0 for i in range(n+1)]
b=[0 for j in range(n+1)]
visited=[0 for i in range(n+1)]
k=[1]
a[1]=1
visited[1]=1
while k!=[]:
    m=k.pop()
    for i in range(len(ed[m])):
        if visited[ed[m][i]]==0:
            k.append(ed[m][i])
            a[ed[m][i]]=a[m]+1
            visited[ed[m][i]]=1
k=[n]
b[n]=1
visited=[0 for i in range(n+1)]
visited[n]=1
while k!=[]:
    m=k.pop()
    for i in range(len(ed[m])):
        if visited[ed[m][i]]==0:
            k.append(ed[m][i])
            b[ed[m][i]]=b[m]+1
            visited[ed[m][i]]=1
cnt1=0
cnt2=0
for i in range(1,n+1):
    if a[i]<=b[i]: cnt1=cnt1+1
    if a[i]>b[i]: cnt2=cnt2+1
print "Fennec" if cnt1>cnt2 else "Snuke"


Measured memory_bytes: 30308
program atcoder
    implicit none
    integer(8) :: i,j,n,maxw
    integer(8),allocatable,dimension(:,:) :: dp
    integer(8),allocatable,dimension(:) :: v,w
    read*,n,maxw
    allocate(dp(0:n,0:maxw))
    allocate(v(n))
    allocate(w(n))

    dp = 0
    do i = 1,n
        read*,w(i),v(i)
    enddo

    do i = 0,n-1
        do j = 0,maxw
            if( j<w(i+1) )then
                dp(i+1,j) = dp(i,j)
            else
                dp(i+1,j) = max( dp(i,j) , dp(i,j-w(i+1))+v(i+1) )
            endif
        enddo
    enddo
    write(*,'(I0)')dp(n,maxw)

    stop 
contains
end program atcoder


Measured memory_bytes: 79104
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(a){return a?cin[cid++]:+cin[cid++];}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var n = next();
  var a = nexts(n-1);
  var ans = xArray(0,n);
  for(var i = 0; i < n-1; i++){
    ans[a[i]-1]++
  }
  return ans.join("\n");
}

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

typedef long long ll;

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,l,n) for(int i=(l);i<(n);i++)

template<class T>
using vt = vector<T>;
template<class T>
using vvt = vector<vector<T>>;


int group1[] = {1,3,5,7,8,10,12};
int group2[] = {4,6,9,11};
int main(){
    int x,y;
    cin >> x >> y;
    for(int temp : group1){
        if(temp == x){
            for(int temp2 : group1){
                if(temp2 == y){
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }   
    }
    for(int temp : group2){
        if(temp == x){
            for(int temp2 : group2){
                if(temp2 == y){
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }   
    }
    cout << "No" << endl;
    return 0;  
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)

int main(){

    // 1. 入力情報.
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    
    // 2. B で割った余りが, C とできるか？
    bool ok = false;
    repex(i, a, a * b, a){
        if(i % b == c){
            ok = true;
            break;
        }
    }
    
    // 3. 出力.
    printf("%s\n", ok ? "YES" : "NO");
    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
#define ll long long
using namespace std;
const int INF = 1e9+7;

bool isPerfectSquare(ll x){ ll s = sqrt(x); return (s*s == x);}

int main(){
	ios::sync_with_stdio(false);
	int n,d;
	cin>>n>>d;
	int ans = 0;
	for(int i=0;i<n;++i){
		ll x,y;
		cin>>x>>y;
		ll xx = (ll)(x*x);
		ll yy = (ll)(y*y);
		ll ss = sqrt(xx+yy);
		if(isPerfectSquare(xx+yy)){
			if(ss<=d){
				++ans;
			}
		}
		else{
			if(ss<d){
				++ans;
			}
		}
		//cout<<ss<<' ';
	}
	cout<<ans<<'\n';
}

Measured memory_bytes: 3664
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 100000
#define fir first
#define foreach(it,X) for(__typeof((X).begin()) it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)x.size())

using namespace std;

typedef istringstream iss;
typedef long long ll;
typedef pair<int,int> pi;
typedef stringstream sst;
typedef vector<int> vi;

int M,N;
int dp[2][2][1<<20];
string s[22];
int q[22][22];
ll p3[444]={1};

void out2(int x){
	rep(i,N){
		cout<<(x&1);
		x>>=1;
	}
	cout<<endl;
}

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cin>>M>>N;
	rep(i,M*N)p3[i+1]=p3[i]*3%MOD;
	rep(i,M)cin>>s[i];
	int Q=0;
	for(int y=M-1;y>=0;y--)for(int x=N-1;x>=0;x--){
		q[y][x]=Q;
		Q+=s[y][x]=='?';
	}
	dp[0][0][0]=1;
	int cur=1,pre=0;
	ll ans=0;
	rep(y,M)rep(x,N+1){
		rep(J,2)rep(mask,1<<N)dp[cur][J][mask]=0;
		if(x==N){
			rep(J,2)rep(mask,1<<N)if(dp[pre][J][mask]){
				dp[cur][0][mask] += dp[pre][J][mask];
			}
		}
		else{
			rep(J,2)rep(mask,1<<N)if(dp[pre][J][mask]){
				if(s[y][x]=='J' || s[y][x]=='?'){
					dp[cur][1][mask&~(1<<x)] += dp[pre][J][mask];
				}
				if(s[y][x]=='O' || s[y][x]=='?'){
					if(J==1){
						dp[cur][0][mask&~(1<<x)|1<<(x-1)] += dp[pre][J][mask];
					}else{
						dp[cur][0][mask&~(1<<x)] += dp[pre][J][mask];
					}
				}
				if(s[y][x]=='I' || s[y][x]=='?'){
					if(mask>>x&1){
						ans+=dp[pre][J][mask] * p3[q[y][x]];
					}else{
						dp[cur][0][mask&~(1<<x)] += dp[pre][J][mask];
					}
				}
			}
		}
		rep(J,2)rep(mask,1<<N)if(dp[cur][J][mask]){
			dp[cur][J][mask]%=MOD;
		}
		ans%=MOD;
		cur^=1,pre^=1;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 17596
N, K = $stdin.gets.chomp.split(' ').map(&:to_i)

sum = 0
((K+1)..N).each do |b|
    q = N / b
    r = N % b
    sum += q * (b - K)
    sum += r - [K, 1].max + 1 if r >= K
end

print sum

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

#define FAST_INP  ios_base::sync_with_stdio(false);cin.tie(NULL)
int main()  
{ 
    FAST_INP;
    int a,b,c,d,e; 
    cin >> a >> b >> c >> d >> e;
    if(a==0) cout << 1 << endl;
    else if(b==0) cout << 2 << endl;
    else if(c==0) cout << 3 << endl;
    else if(d==0) cout << 4 << endl;
    else if(e==0) cout << 5 << endl; 
    return 0;
} 

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<bool> cnt(1000005,false);
    sort(a.begin(),a.end());
    int ans = 0;
    rep(i,n){
        bool res = true;
        if(cnt[a[i]]) continue;
        if(i<n-1 && a[i]==a[i+1]) res = false;

        if(res) ++ ans;

        for(int j=a[i];j<1000005;j+=a[i]){
            cnt[j] = true;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4316
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	int k;
	int x;
	int y;
	cin >>n>>k>>x>>y;
	int sum = 0;
	if(n>k){
		sum+=y*(n-k)+x*k;		
	}else{
		sum+=x*n;
	}
	cout << sum <<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();
        int len = Math.max(a,b);
        int cnt = 0;
        for(int i = len; i >= 1; i--){
            if(a % i == 0 && b % i == 0){
                cnt++;
                if(cnt == k){
                    System.out.println(i);
                    return;
                }
            }
        }
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
            return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }
    
    public int nextInt() {
        return Integer.parseInt(next());
    }
    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 22868
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)
 
def fact(n):
    b = 2
    li = []
    li.insert(0,1)
    while b*b<=n:
        while n%b == 0:
            n = n//b
            li.append(b)
        b+=1
    if n>1:
        li.append(n)
 
    return li
a,b = map(int,input().split())
c = gcd(a,b)
ans = set(fact(c))
print(len(ans))


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

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

using namespace std;

class mint{
	static const int MOD=998244353;
	int x;
public:
	mint():x(0){}
	mint(long long y){ x=y%MOD; if(x<0) x+=MOD; }

	mint& operator+=(const mint& m){ x+=m.x; if(x>=MOD) x-=MOD; return *this; }
	mint& operator-=(const mint& m){ x-=m.x; if(x<   0) x+=MOD; return *this; }
	mint& operator*=(const mint& m){ x=1LL*x*m.x%MOD; return *this; }
	mint& operator/=(const mint& m){ return *this*=m.inverse(); }
	mint operator+(const mint& m)const{ return mint(*this)+=m; }
	mint operator-(const mint& m)const{ return mint(*this)-=m; }
	mint operator*(const mint& m)const{ return mint(*this)*=m; }
	mint operator/(const mint& m)const{ return mint(*this)/=m; }

	mint inverse()const{
		int a=x,b=MOD,u=1,v=0;
		while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
		return u;
	}

	friend istream& operator>>(istream& is,mint& m){ long long t; is>>t; m=mint(t); return is; }
	friend ostream& operator<<(ostream& os,const mint& m){ return os<<m.x; }
	int to_int()const{ return x; }
};

mint pow(mint m,long long k){
	mint res=1;
	for(;k>0;k>>=1,m*=m) if(k&1) res*=m;
	return res;
}

int main(){
	int n; cin>>n;
	vector<int> a(n);
	rep(i,n) cin>>a[i];

	if(a[0]!=0 || count(a.begin(),a.end(),0)!=1){
		cout<<"0\n";
		return 0;
	}

	vector<int> hist(n+1);
	rep(i,n) hist[a[i]]++;

	mint ans=1;
	rep(i,n){
		ans*=pow(mint(hist[i]),hist[i+1]);
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<numeric>
#include<iomanip>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define ll long long

using namespace std;

//最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

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

	ll ans = 0;

	if (k >= a) {
		ans += a * 1;
		k -= a;
		if (k >= b) {
			ans += b * 0;
			k -= b;
			if (k >= c) {
				ans -= c;
				k -= c;
			}
			else ans += k * -1;
		}
		else ans += k * 0;
	}
	else ans += k * 1;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3616
#include <stdio.h>


int		main(void)
{
	unsigned long long X;
	int i;
	unsigned long long yokin = 100;

	scanf("%lld", &X);
	for (i = 0; ; yokin *= 1.01, i++)
	{
		if (yokin >= X)
		{
			printf("%d", i);
			return (0);
		}
	}

	return (0);
}

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

#ifdef LOCAL
#include "../lib/dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("temp.1", "r", stdin);

  int N, M;
  cin >> N >> M;
  vector<int> p(M); // 市 -> 県
  vector<int> y(M); // 市 -> 年
  vector<int> n(M); // 市 -> 順番
  vector<vector<P>> q(N); // 県 -> vector(年、市)
  for (int i = 0; i < M; i++) {
    cin >> p[i] >> y[i];
    q[p[i] - 1].push_back(P(y[i], i));
  }
  for (int i = 0; i < N; i++) {
    sort(q[i].begin(), q[i].end());
    for (int j = 0; j < q[i].size(); j++) {
      n[q[i][j].second] = j;
    }
  }
  for (int i = 0; i < M; i++) {
    printf("%06d%06d\n", p[i], n[i] + 1);
  }
  return 0;
}

Measured memory_bytes: 8192
#include <stdio.h>

int main(void)
{
	double v, y;
	
	while(scanf("%lf", &v)!=EOF) {
		int N;
		
		y=v*v/19.6;
		for(N=0; 5*N-5<y; N++) ;
		printf("%d\n", N);
	}
	
	return 0;
}


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

template<size_t max_sz,size_t num>
struct primes{
  using i64 = int_fast64_t;
  i64 is_p[max_sz];
  i64 p[num];
  size_t cnt = 0;
  constexpr primes():is_p(),p(){
    for(i64 i=2;i<max_sz;++i){
      if(is_p[i]==0){
        is_p[i] = 1;
        p[cnt++] = i;
      }
      if(cnt>=num)break;
      for(i64 x=i*i;x<max_sz;x+=i){
        is_p[x] = 2;
      }
    }
  }
};

signed main(){

  constexpr auto prime = primes<250000,22044>();

  int n;
  cin>>n;
  //cout<< *lower_bound(begin(prime.p),end(prime.p),n) <<endl;
  for(int i=n;;++i){
    if(prime.is_p[i]==1){
      cout<<i<<endl;
      return 0;
    }
  }

}

Measured memory_bytes: 2432
#include <iostream>
#include <cstdlib>
#include <cstdio>
using namespace std;
inline int read()
{
	int f = 1, x = 0;
	char ch;

	do{
		ch = getchar();
		if (ch == '-')
			f = -1;
	}while(ch < '0' || ch > '9');
	do{
		x = x * 10 + ch - '0';
		ch = getchar();
	}while(ch >= '0' && ch <= '9');
	return f * x;
}
const int N = 2e5;

int n, stx, sty;
struct Edge {
	int to, next;
} edge[(N << 1) + 1];
int start[N + 1], tot;
int depa[N + 1], depb[N + 1], up[21][N + 1];
int xx[N + 1], yy[N + 1];
int ans;

inline void addedge(int u, int v)
{
	edge[++tot] = Edge{ v, start[u] };
	start[u] = tot;
	edge[++tot] = Edge{ u, start[v] };
	start[v] = tot;
	return;
}
inline void dfs1(int u, int fa)
{
	depa[u] = depa[fa] + 1;
	for (int i = start[u]; i; i = edge[i].next) {
		int v = edge[i].to;
		if (v != fa && depb[v] > depa[u] + 1)
			dfs1(v, u);
	}
	return;
}
inline void dfs2(int u, int fa)
{
	depb[u] = depb[fa] + 1;
	for (int i = 1; i <= 20; i++)
		up[i][u] = up[i - 1][up[i - 1][u]];
	for (int i = start[u]; i; i = edge[i].next) {
		int v = edge[i].to;
		if (v != fa) {
			up[0][v] = u;
			dfs2(v, u);
		}
	}
	return;
}
inline int lca(int x, int y)
{
	if (depb[x] > depb[y])
		swap(x, y);
	for (int i = 20; i >= 0; i--) {
		if (up[i][y] && depb[up[i][y]] >= depb[x])
			y = up[i][y];
		if (x == y)
			return x;
	}
	for (int i = 20; i >= 0; i--) {
		if (up[i][x] && up[i][x] != up[i][y]) {
			x = up[i][x];
			y = up[i][y];
		}
	}
	return up[0][x];
}
inline int dis(int x, int y)
{
	int llca = lca(x, y);

	return depb[x] + depb[y] - (depb[llca] << 1);
}
int main()
{
	n = read();
	stx = read();
	sty = read();
	for (int i = 1; i < n; i++) {
		xx[i] = read();
		yy[i] = read();
	}

	for (int i = 1; i < n; i++) {
		int a = read(), b = read();
		addedge(a, b);
	}
	dfs2(sty, 0);
	tot = 0;
	for (int i = 1; i <= n; i++)
		start[i] = 0;
	for (int i = 1; i < n; i++)
		addedge(xx[i], yy[i]);
	dfs1(stx, 0);

	for (int i = 1; i < n; i++) {
		if (dis(xx[i], yy[i]) > 2 && ((depa[xx[i]] < depb[xx[i]] && depa[xx[i]]) || (depa[yy[i]] < depb[yy[i]] && depa[yy[i]]))) {
			printf("-1\n");
			return 0;
		}
	}
	for (int i = 1; i <= n; i++)
		if (depa[i] < depb[i] && depa[i])
			ans = max(ans, depb[i] - 1);
	printf("%d\n", ans << 1);
	return 0;
}


Measured memory_bytes: 35256
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
//for gcc (未test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
// for Debug.
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}
// 入力をpush_back(d)やarray[d]に使う時に1行で書ける
// int INPUT_INT() {int d;cin>>d;return d;}
template<class T>T IN() { T d; cin >> d; return d; }
// 最大公約数（Greatest Common Divisor）
LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; }
// 最小公倍数（Least Common Multiple）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
// Y年はうるう年か否か
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); }

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

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------

int main() {
	FAST_IO;
	// for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;
	bool dbgF = true;

	//コードはここから書く.

	int K, S;
	LL ans = 0;
	cin >> K >> S;

	FOR(i, 0, K + 1) {
		FOR(j, 0, K + 1) {
			if (i + j <= S && S - (i + j) <= K)
				ans++;
		}
	}
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
#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 d_5 100000
#define d9_7 1000000007
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define pf push_front
#define ld long double

struct datas{
  ll sumd;
  set<int> ts;
};
ll max(ll a,ll b){
  if(a<b){
    return b;
    
  }else{
    return a;
  }
}
ll gcd(int a,int b){//最大公約数
  if (a%b==0){
		return(b);
    }
	else{
		return(gcd(b,a%b));
    }
}
int main(void){
  int n;
  cin>>n;
  string s,t;
  cin>>s>>t;
  string ans="";
  rep(i,n){
    ans+=s[i];
    ans+=t[i];
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define in insert
#define pb emplace_back
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define Rev(i,a,b) for(ll i=a;i>=b;i--)
#define FOR(m) Rep(i,1,m)
#define For(m) Rep(i,0,m-1)
#define Rbl(x,a) for(auto &x : a)
#define FIO ios::sync_with_stdio(0);   cin.tie(0);
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define vpii vector<pii>
#define vpll vector<pll>
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()
const ll INF = 0x3f3f3f3f3f3f3f3fll;
#define mod 1000000007


int main()
{
FIO

    ll x, y;
    cin >> x >> y;
    if(y <= 4*x && y >= 2*x && y % 2 == 0)
        cout << "Yes\n";
    else
        cout << "No\n";
    
    return 0;
}

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


int main() {
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int result = 0;
  for (int i = 0; i <= A; ++i) {
    for (int j = 0; j <= B; ++j) {
      for (int k = 0; k <= C; ++k) {
        int total = 500 * i + 100 * j + 50 * k;
        if (total == X) {
          ++result;
          break;
        } else if (X < total) {
          break;
        }
      }
    }
  }
  cout << result << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n,tmp,x=0,ans=0,i,l,r,s;
char a[201];
int main() 
{
	cin>>n>>a;r=n;
	for(r=n;a[r-1]=='(';r--)s++;
	for(i=0;i<r;i++)
	{
		if(a[i]=='(')ans--;
		else if(a[i]==')')
		{
			if(ans==0)cout << "(";
			else ans++;
		}
	}
	if(ans<0)s=s-ans;
	cout << a;
	while(s--)cout << ")";
}

Measured memory_bytes: 256
n = int(input())
s = list(input())
result = [s[1:].count("E")]
for i in range(n-1):
    if s[i:i+2] == ["W","W"]:
        result.append(result[-1]+1)
    elif s[i:i+2] == ["E","E"]:
        result.append(result[-1]-1)
    else:
        continue
print(min(result))

Measured memory_bytes: 21200
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main(){
    string s;cin>>s;
    int n;cin>>n;
    for(int i=0;i<s.size();i++){
        if(i%n==0)cout<<s[i];
    }
    cout<<endl;
}


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

using namespace std;

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

int rev(int cur, const vector<vector<int>> &G, vector<int> &dp) {
  if (dp.at(cur) != -1) return dp.at(cur);
  
  int res = 0;
  for (int x : G.at(cur)) {
    chmax(res, rev(x, G, dp) + 1);
  }
  dp.at(cur) = res;
  
  return res;
}

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> G(n);
  for (int i=0; i<m; i++) {
    int a, b;
    cin >> a >> b;
    G.at(a-1).push_back(b-1);
  }
  
  vector<int> dp(n, -1);
  int res = 0;
  for (int i=0; i<n; i++) {
    chmax(res, rev(i, G, dp));
  }
  
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 9472
<?php

fscanf(STDIN, "%d", $n);
$x_list = explode(' ', trim(fgets(STDIN)));

$avg = array_sum($x_list) / count($x_list);

$ans1 = array_sum(array_map(function ($x) use ($avg) {
    return ($x - (int)floor($avg)) ** 2;
}, $x_list));

$ans2 = array_sum(array_map(function ($x) use ($avg) {
    return ($x - (int)ceil($avg)) ** 2;
}, $x_list));

echo min($ans1, $ans2);


Measured memory_bytes: 16208
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
int gcd(int a,int b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

//最小公倍数
int lcm(int a,int b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}




#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;


  


int main() {
    string s;
    cin >> s;
    for (int bit = 0; bit < (1 << 3); bit++){
        int tmp = s.at(0) - '0';
        string ans = "";
        ans += s.at(0);
        rep(i, 3){
        if (bit & (1 << i)){
            tmp += s.at(i + 1) - '0';
            ans += '+';
            ans += s.at(i + 1);
        }
        else{
            tmp -= s.at(i + 1) - '0';
            ans += '-';
            ans += s.at(i + 1);
        }
        }
        if (tmp == 7) {
            cout << ans << "=7" << endl;
            return 0;
    }
    }
}



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


void solve(long long r){
    cout << r * r * 3 << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long r;
    scanf("%lld",&r);
    solve(r);
    return 0;
}


Measured memory_bytes: 256