akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll n, x, y;
  cin >> n >> x >> y;
  x--; y--;
  vector<ll> ans(n);

  rep(i, n) {
    queue<ll> q;
    vector<ll> dist(n, INF);
    auto push = [&](ll v, ll d) {
      if (dist[v] != INF) return;
      dist[v] = d;
      q.push(v);
    };
    push(i, 0);
    while(!q.empty()) {
      ll pos = q.front(); q.pop();
      ll d = dist[pos];
      if (pos-1 >= 0) push(pos-1, d+1);
      if (pos+1 <= n-1) push(pos+1, d+1);
      if (pos == x) push(y, d+1);
      if (pos == y) push(x, d+1);
    }
    rep(j, n) ans[dist[j]]++;
  }

  reps1(i, n) {
    cout << ans[i] / 2 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<sstream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdio>
using namespace std;

int main() {
	int a, l;
	while (cin >> a >> l, l) {
		bool flag=false;
		int ans = 0;
		vector<int>v = { a };
		while (!flag) {
			ostringstream ostr;
			ostr << setfill('0') << setw(l) << a;
			string s = ostr.str();
			sort(s.begin(), s.end());
			string s1 = s;
			reverse(s1.begin(), s1.end());
			a = stoi(s1) - stoi(s);
			for (int i = 0; i < (int)v.size(); i++) {
				if (v[i] == a) {
					flag = true;
					ans = i;
					break;
				}
			}
			v.push_back(a);
		}
		printf("%d %d %d\n", ans, v[ans], (int)v.size() - ans - 1);
	}
}

Measured memory_bytes: 3352
N,K = map(int,input().split())
l = [0]*N
for _ in range(K):
  D = int(input())
  A = list(map(int,input().split()))
  for i in range(D):
    l[A[i]-1] = 1
count = 0
for i in range(N):
  if l[i] == 0:
    count += 1
print(count)

Measured memory_bytes: 9196
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }

    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int K = scan.nextInt();
        int N = scan.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = scan.nextInt();
        }
        long ans = Long.MAX_VALUE;
        for (int i = 0; i < N; i++) {
            ans = Math.min(ans, tokei(N, K, A, i));
            ans = Math.min(ans, reverse(N, K, A, i));
        }
        System.out.println(ans);
    }
    private long tokei(int N, int K, int[] A, int start) {
        if (start == 0) {
            return A[N-1] - A[0];
        }
        return K - A[start] + A[start-1];
    }
    private long reverse(int N, int K, int[] A, int start) {
        if (start == N-1) {
            return A[N-1] - A[0];
        }
        return A[start] + K - A[start+1];
    }
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))

#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s))
#define repiins(x, y, z, s) for ((x) = (z); (x) <= (y); (x) += (s))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)

#define All(x) (x).begin(),(x).end()

#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))

#define Unique(v) v.resize(unique(All(v)) - v.begin())

#define peq(p0, p1)(p0.first == p1.first && p0.second == p1.second)

#define End '\n'
#define Out(x) cout<<(x)<<End
#define OutP(p, sep, end) cout<<p.first<<sep<<p.second<<end

template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lb std::lower_bound
#define ub std::upper_bound

#define lbi(v, x) lb(All(v), (x))-v.begin()
#define ubi(v, x) ub(All(v), (x))-v.begin()

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);
	//std::cout.precision(18);

    ll a, b;

	cin >> a >> b;

	ll c = b - a;
	ll d = 0;

	ll i;
	
	nep(i, c) d += i;

	Out(d - a);
	
	return 0;
}


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

#define lp(i,n) for(int i=0;i<n;i++)
#define lpin(a,i,n) for(int i=0;i<n;i++){cin>>a[i];}
using namespace std;
int main(){
  list<int> l;
  list<int>::iterator it;
  it = l.end();
  int n;
  cin>>n;
  lp(i,n){
    int a,b;
    cin>>a;
    if(a==0){
      cin>>b;
      it=l.insert(it, b);
    }
    if(a==1){
      cin>>b;
      if(b>=0){
	lp(j,b){
	  it++;
	}
      }
      else{
	lp(j,-b){
	  it--;
	}
      }
    }
    if(a==2){
      it=l.erase(it);
    }
  }
  it=l.begin();
  while(it!=l.end()){
    cout<<*it<<endl;
    it++;
  }
  return 0;
}



Measured memory_bytes: 18516
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int   //used int to avoid mle
#define ulli unsigned long long int 
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define initialize(array,size,value) for(lli i=0;i<size;i++) array[i]=value
#define couta(array,size) for(lli i=0;i<size;i++) cout<<array[i]<<" "
#define vl vector<lli>
#define vp vector< pair <lli,lli> >
#define sl set<lli>
#define spl set<pll>
#define msl multiset <lli>
#define msp multiset <pll>
#define pll pair<lli, lli>
#define mll map<lli, lli>              //for( map<lli, lli>::iterator i=temp.begin();i!=temp.end();i++)cout<<i->fi<<" "<<i->se<<endl;
#define mvl map<lli, vl>
#define umll unordered_map<lli, lli>
#define vt vector<pair<lli, pll >  >
#define vf vector<pair<pll,pll > >
#define qu queue<lli>
#define pq priority_queue<lli>
#define dq deque <lli>
#define ptr vector<lli>::iterator
#define bs(array,x) binary_search(array.begin(),array.end(),x)
#define lb(array,x) lower_bound(array.begin(),array.end(),x)
#define ub(array,x) upper_bound(array.begin(),array.end(),x)
#define nobw(array,i,j) upper_bound(array.begin(), array.end(), j)-lower_bound(array.begin(), array.end(), i) //number of numbers between i & j
#define vc clear()
#define endl '\n'
#define sp system("pause");
#define INF 9223372036854775807
#define MINF -9223372036854775808
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
lli mod=1000000007;
//string s=bitset<32>(n).to_string();
int main()
{
 	ios::sync_with_stdio(0);
    cin.tie(0);
    
    string s;
    cin>>s;
    lli n=s.size();
    lli c=0;
    for(lli i=0;i<n/2;i++)if(s[i]!=s[n-i-1])c++;
    	cout<<c;



return 0;
}

Measured memory_bytes: 256
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N = int(input())

cnt = 0
for i in range(N + 1):
    if i % 2 == 1:
        c = 0
        for j in range(1, i + 1):
            if i % j == 0:
                c += 1

        if c == 8:
            cnt += 1

print(cnt)

Measured memory_bytes: 9420
#include <bits/stdc++.h>
using namespace std;
int main() {
    int k, x; cin >> k >> x;
    int l = x - k + 1; int r = 2 * k - 1;
    //cout << l << endl;
    while(r--) {
        cout << l << " ";
        l++;
    } cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector<int>
#define vll vector<ll>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pb  push_back
#define ppb pop_back
#define mp  make_pair
int main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	char c;
	cin>>c;
	cout<<(char)(c+1)<<endl;
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	tmp = input[1].split(" ");
	//文字列から10進数に変換するときはparseIntを使います
  for(var i=0; i<input.length; i++){
    tmp = input[i].split(" ");
    for(j =0; j<tmp.length; j++){
      tmp[j] = parseInt(tmp[j], 10);
    }
    input[i] = tmp;
  }

  var N = input[0][0];
  var M = input[0][1];
  var h = [];

  for(i=1; i<=N; i++){
    h[i] = input[1][i-1];
  }

  var cand = [];
  for(i=1; i<=N; i++){
    cand[i] = 0;
  }

  for(i=2; i<input.length; i++){
    var a = input[i][0];
    var b = input[i][1];

    // console.log(a,b);

    if(h[a] > h[b]) cand[b]++;
    else cand[a]++;
    if(h[a] == h[b]) cand[b]++;
  }

  var ans = 0;
  for(i=1; i<cand.length; i++){
    if(cand[i] == 0) ans++;
  }

  // console.log(N, M, h, cand, ans);

	//出力
	console.log('%d', ans);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 68584
#include<stdio.h>

int main(void){
    double min=0,max=0;
    double i;
    
    if(scanf("%lf",&i)!=EOF){
        min=i;
        max=i;
    }
    else{
        puts("0.0");
        return 0;
    }
    while(scanf("%lf",&i)!=EOF){
        if(min>i)
            min=i;
        if(max<i)
            max=i;
    }
    printf("%lf",max-min);
    return 0;
}

Measured memory_bytes: 648
#include <bits/stdc++.h>
#include <set>
#define rep(i,n) for (int i=0; i < (n); ++i)
#define all(a) a.begin(), a.end()
using ll = long long;
using namespace std;
 
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }


// const double PI = acos(-1);



int main() {
  int n; cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int M_ans = a[0], m_ans =a[0];
  rep(i,n) {
    M_ans = max(M_ans, a[i]);
    m_ans = min(m_ans, a[i]);
  } 
  cout << abs(M_ans - m_ans) << endl;
  return 0;
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main()
    {
        string n = Console.ReadLine();
        char[] nn = new char[3];
        for (int i = 0; i < 3; i++)
        {
            nn[i] = n[i];
            if (nn[i] == '1') nn[i] = '9';
            else if (nn[i] == '9') nn[i] = '1';
        }
        Console.WriteLine(nn);
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
using namespace std;

int q;
vector<int> p(100010,0);
vector<int> p2(100010,0);
vector<int> s(100010,0);
vector<int> a(10000);
const int n = 100000;

int main() {
    cin >> q;
    vector<int> l(q);
    vector<int> r(q);
    REP(i,q){
        cin >> l[i] >> r[i];
    }
    p[2] = 1;
    a[0] = 2;
    int cnt= 1;
    FOR(i,3,n){
        bool flag = true;
        REP(j,cnt){
            if(i%a[j]==0){
                flag = false;
                break;
            }
        }
        if(flag){
            a[cnt++] = i;
            p[i] = 1;
        }
    }
    for(int i=1;i<n;i+=2){
        if(p[i]&&p[(i+1)/2]){
            p2[i]=1;
        }
    }
    s[0] = 0;
    REP(i, n){
        s[i+1] = s[i] + p2[i+1];
    }
    REP(i,q){
        put(s[r[i]]-s[l[i]-1]);
    }
    return 0;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h> 
using namespace std;
///////////////////////////////////////////
const long long int INF = 100000000000;
const long long int Mod = 1000000007;
using ll = long long int; //long long int は64bit
using vi = vector<int>; using Vi = vector<long long int>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(long long int i=0;i<N;i++)
#define np nullptr
template<class T>bool chmax(T &former, const T &b) { if (former<=b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define fill(x,num) memset(x,num,sizeof(x));
typedef vector<vector<ll> > matrix;
typedef pair<ll,ll> Pair;
bool p_compare(const Pair& firstP, const Pair& secondP){ 
    return firstP.second < secondP.second; 
}//sort(all(v),p_compare)で昇順ソート
//////////////////////////^^ *Emile ^^^//////////////////////////////////////////////////////
//Snipet -> Caps Lock
 
ll n;
Vi v;
ll ma[6]={0};
 
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>n;ll xxx;
    fill(ma,0);
    ll minm=INT64_MAX;
    rep(i,5){
        cin>>xxx;
        chmin(minm,xxx);
    }
    if(n%minm==0)cout<<n/minm+4<<endl;
    if(n%minm!=0)cout<<(n/minm)+5<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}


int d[3] = {-1,0,1};
int main(){
    VEC(int,a,3);
    sort(ALL(a));
    cout<<(a[2]==a[0]+a[1]?"Yes":"No");
}



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

using namespace std;

int countSpace(int h, int w){
  return 0;
}

struct Stat{
  bool rowDone, colDone = {false};
  int rowNum, colNum = {0};
};

int main(){
  int ans = 0;
  int H,W;
  cin >> H >> W;
  vector<vector<Stat>> grid(H, vector<Stat>(W));
  vector<string> S(H);
  for(int i=0; i<H; i++){
    cin >> S[i];
  }
  // set counts for each row
  for(int i=0; i<H; i++){
    int tmpCnt = 0;
    for(int j=0; j<W; j++){
      if(!grid[i][j].rowDone){
        tmpCnt = 0;
      }
      if(S[i][j] == '#'){
        tmpCnt = 0;
        continue;
      }
      if(grid[i][j].rowDone){
        grid[i][j].rowNum = tmpCnt;
        continue;
      }
      for(int k=j; k<W; k++){
        if(S[i][k] == '#') break;
        grid[i][k].rowDone = true;
        tmpCnt++;
      }
      grid[i][j].rowNum = tmpCnt;
    }
  }
  // set counts for each column
  for(int i=0; i<W; i++){
    int tmpCnt = 0;
    for(int j=0; j<H; j++){
      if(!grid[j][i].colDone){
        tmpCnt = 0;
      }
      if(S[j][i] == '#'){
        tmpCnt = 0;
        continue;
      }
      if(grid[j][i].colDone){
        grid[j][i].colNum = tmpCnt;
        continue;
      }
      for(int k=j; k<H; k++){
        if(S[k][i] == '#') break;
        grid[k][i].colDone = true;
        tmpCnt++;
      }
      grid[j][i].colNum = tmpCnt;
    }
  }
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      ans = max(ans, grid[i][j].colNum + grid[i][j].rowNum - 1);
    }
  }
  cout << ans << endl;

  // cout << grid[0][3].colNum << endl;
  // cout << grid[1][3].colNum << endl;
  // cout << grid[2][3].colNum << endl;
  // cout << grid[3][3].colNum << endl;

  return 0;
}


Measured memory_bytes: 51328
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n),b(n),c(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = 0; i < n; i++){
        cin >> b[i];
    }
    for(int i = 0; i < n; i++){
        cin >> c[i];
    }

    sort(all(a)),sort(all(c));

    ll ans = 0;
    for(int i = 0; i < n; i++){
        ll A = lower_bound(all(a),b[i]) - a.begin();
        ll C =  n - (upper_bound(all(c),b[i])-c.begin());

        ans += A * C;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2560
# ediitorialを参考にした
N, M = map(int, input().split())
X = [int(x) for x in input().split()]
X = sorted(X)
sa = [0] * (M - 1)
for i in range(M - 1):
    sa[i] = X[i + 1] - X[i]
sa = sorted(sa)
numofmove = 0
if N >= M:
    numofmove = 0
else:
    for j in range(M - N):
        numofmove += sa[j]

print(numofmove)


Measured memory_bytes: 13832
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

const int INF = 1LL << 60;
int N, M;
vector<int> a, b, mask;
vector<vector<int>> c, dp;

void _main() {
    cin >> N >> M;
    a.resize(M);
    b.resize(M);
    c.resize(M);
    mask.resize(M, 0);
    REP (i, M) {
        cin >> a[i] >> b[i];
        c[i].resize(b[i]);
        REP (j, b[i]) {
            cin >> c[i][j], c[i][j]--;
            mask[i] |= 1 << c[i][j];
        }
    }
    dp.resize(M + 1, vector<int>(1 << N, INF));
    dp[0][0] = 0;
    REP (i, M) REP (bit, 1 << N) if (dp[i][bit] != INF) {
        dp[i + 1][bit] = min(dp[i + 1][bit], dp[i][bit]);
        dp[i + 1][bit | mask[i]] = min(dp[i + 1][bit | mask[i]], dp[i][bit] + a[i]);
    }
    int ans = dp[M][(1 << N) - 1];
    cout << (ans == INF ? -1 : ans) << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

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

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    string s;
    cin >> s;
    
    int x = (s[0] - '0')*10 + (s[1] - '0');
    int y = (s[2] - '0')*10 + (s[3] - '0');
    
    if(x <= 12 && x >= 1 && y <= 12 && y >= 1) {cout << "AMBIGUOUS"; return 0;}
    
    if((x > 12 || x < 1) && (y > 12 || y < 1)) {cout << "NA"; return 0;} 
    
    if(x <= 12 && x >= 1) cout << "MMYY";
    else cout << "YYMM";
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define maxn 200005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
const int mod = 1e9+7;

int main(){
	int n,m;
	cin >> n >> m;
	int l=1,r=n;
	f(m){
		int add1,add2;
		cin >> add1 >> add2;
		l = max(l,add1);
		r = min(r,add2);
	}
	cout << max(r-l+1,0) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define INF 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define req(i, j, n) for(int i = j; i <= (int)(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
 
int main() {
  int n;
  cin>>n;
  int cnt=0;
  for(int i=1;i<=n;i++){
      string s;
      cin>>s;
      if(s=="E869120"){
          cnt++;
      }
  }
  
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 3172
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <cstring>
#include <queue>
#include <math.h>
#include <iterator>
using namespace std;

int main() {
	int c[12] = { 31,29,31,30,31,30,31,31,30,31,30,31 };
	while (true) {
		int a, b,d = 0;
		scanf("%d%d", &a, &b);
		if (a == 0) goto end;
		d = b;
		for (int i = 0;i < a-1;++i) {
			d += c[i];
		}
		if (d%7 == 6) {
			printf("Tuesday\n");
		}
		else if (d % 7 == 0) {
			printf("Wednesday\n");
		}
		else if (d % 7 == 1) {
			printf("Thursday\n");
		}
		else if (d % 7 == 2) {
			printf("Friday\n");
		}
		else if (d % 7 == 3) {
			printf("Saturday\n");
		}
		else if (d % 7 == 4) {
			printf("Sunday\n");
		}
		else if (d % 7 == 5) {
			printf("Monday\n");
		}
	}
end:;
}


Measured memory_bytes: 1008
#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const int INF = 100100100;
const double PI = 3.14159265358979323846;
typedef long long ll;
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) for (ll i = 0; i < (n); ++i)

int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  int i, ans = 0;
  if (a >= k) {
    ans = k;
  } else if (a < k) {
    ans = a;
    int card = k - a;
    if (b >= card) {
    } else if (b < card) {
      card -= b;
      ans -= card;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<vector>
using namespace std;
int n;
vector < int > G[105];
int st[105] = {};
int et[105];
int t = 1;

void dfs(int v)
{
    if (st[v] != 0) return;
    st[v] = t;
    t++;
    for (auto& x : G[v]) {
        dfs(x);
    }
    et[v] = t;
    t++;
}

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++) {
        int u, k;
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            int v;
            cin >> v;
            G[u].push_back(v);
        }
    }
    for (int i = 1; i <= n; i++) dfs(i);
    for (int i = 1; i <= n; i++) {
        cout << i << " " << st[i] << " " << et[i] << endl;
    }
}


Measured memory_bytes: 3180
#include <iostream>
#include <algorithm>

#include <string.h>

#define INT_INF 11

int a[10];

int memo[10+1][10+1][10+1];

int search(int i, int j, int k)
{
  if (memo[i][j][k] >= 0)
    return memo[i][j][k];
  
  if (i == 10)
    return memo[i][j][k] = INT_INF;

  int r = 0;

  if (a[i] > j)
    r = std::max(search(i + 1, a[i], k), r);
		 
  if (a[i] > k)
    r = std::max(search(i + 1, j, a[i]), r);
  
  return memo[i][j][k] = r;
}

int main(int argc, char** argv)
{
  int N;

  std::cin >> N;

  while (N --) {
    for (int i = 0; i < 10; i ++)
      std::cin >> a[i];

    memset(memo, -1, sizeof(memo));

    std::cout << (search(0, 0, 0) ? "YES" : "NO") << std::endl;
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <climits>

using namespace std;

int main() {
  char X, Y;
  cin >> X >> Y;

  char ans;
  if (X < Y) {
    ans = '<';
  } else if (X > Y) {
    ans = '>';
  } else {
    ans = '=';
  }

  cout << ans << endl;

  return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  int ans = 1e9;
  repc(i, 100000) {
    int a_rest = max(0, x - i);
    int b_rest = max(0, y - i);
    amin(ans, a_rest * a + b_rest * b + i * c * 2);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>
#include <random>
//#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using pil = std::pair<int, long long>;
using pli = std::pair<long long, int>;
using plpii = std::pair<long long, std::pair<int, int>>;
using pdd = std::pair<double, double>;
using pis = std::pair<int, std::string>;
using pci = std::pair<char, int>;

const long long INF = 1000000000000000001;
const long long _MOD_ = 1000000000000000009;
const long long _MOD = 1000000007;
const long long MOD = 998244353;
const int ALPHABET = 27;
const double pi = 3.14159265358979;

using namespace std;
//namespace mp = boost::multiprecision;

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

	string s;
	cin >> s;

	cout << s;
	if (s[s.length() - 1] == 's') {
		cout << "es" << "\n";
	}
	else {
		cout << "s" << "\n";
	}

	return 0;
}


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

using namespace std;

long long int util[100005];
int cst [100005];
unordered_set<int> bits[32];
unordered_set<int> not_use;
int bin_k [33];

long long int recurse(int pos, long long int ans, vector<int> curr_set){
	if(pos < 0){
		for(int i : curr_set) ans+=util[i];
		return ans;
	}
	vector<int> next_set;
	for(int i : curr_set){
		if(bin_k[pos] == 0){
			if(bits[pos].find(i) == bits[pos].end()){
				next_set.push_back(i);
			}
		}
		else{
			if(bits[pos].find(i) == bits[pos].end()){
				ans += util[i];
			}
			next_set.push_back(i);
		}
	}
	return max(recurse(pos - 1, 0, next_set), ans);
}

int main(){
	int n, k;
	cin>>n>>k;
	for(int i = 0; i<n; i++){
		cin>>cst[i]>>util[i];
	}
	int al_k = k;
	int c = 0;
	int high = 0;
	while(al_k > 0){
		bin_k [c] = al_k%2;
		al_k /= 2;
		if(al_k == 0) high = c;
		c++;
	}
	for(int i = 0; i<n; i++){
		int alias = cst[i];
		int count = 0;
		while(alias>0) {
			if(alias%2 == 1)
				bits[count].insert(i);
			alias = alias/2;
			count++;
		}
	}
	for(int i = high+1; i<32; i++){
		for(int k : bits[i]){
			not_use.insert(k);
		}
	}
	vector<int> curr_set;
	for(int i = 0; i<n; i++){
		if(not_use.find(i) == not_use.end()) curr_set.push_back(i);
	}
	cout<<recurse(high, 0, curr_set)<<endl;
	return 0;
}

Measured memory_bytes: 90756
n=int(input())
h=[int(x) for x in input().split()]
cost=[0]
cost.append(abs(h[0]-h[1]))
for p in range(2,n):
    cost.append(min(cost[p-1]+abs(h[p]-h[p-1]),abs(h[p]-h[p-2])+cost[p-2]))
print(cost[n-1])

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

int main()
{
    string s,t;
    cin>>s>>t;
    vector<vector<int>> dp(s.size()+1,vector<int>(t.size()+1,0));
    for(int i=1;i<=s.size();i++)
    {
        for(int j=1;j<=t.size();j++)
        {
            if(s[i-1]==t[j-1])
                dp[i][j]=dp[i-1][j-1]+1;
            else
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    //cout<<dp[s.size()][t.size()];
    int i=s.size();
    int j=t.size();
    string str="";
    while(i>0&&j>0)
    {
        if(s[i-1]==t[j-1]){
            str=str+s[i-1];
            i--;j--;
        }
        else
        {
            if(dp[i-1][j]>dp[i][j-1])
                i--;
            else
                j--;
        }
    }
    /*while(i>0)
    {
        str=str+s[i-1];
        i--;
    }
    while(j>0)
    {
        str=str+t[j-1];
        j--;
    }*/
    reverse(str.begin(),str.end());
    cout<<str;
    return 0;
}


Measured memory_bytes: 35584
def main():
    N = int(input())

    Ai_to_num = {}
    for _ in range(N):
        Ai = input()
        if Ai in Ai_to_num.keys():
            Ai_to_num[Ai] += 1
        else:
            Ai_to_num[Ai] = 1
    ct = 0
    for num_i in Ai_to_num.values():
        if num_i % 2:
            ct += 1
    
    print(ct)

main()


Measured memory_bytes: 17892
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();
    int xg =group(x);
    int yg =group(y);
    if(xg==yg){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }


  }
  
  static int group(int t){
    if(t==1||t==3||t==5||t==7||t==8||t==10||t==12){
      return 1;
    }else if(t==2){
      return 3;
    }else{
      return 2;
    }
  }
  

  
}


Measured memory_bytes: 21844
# -*- coding: utf-8 -*-
data = input().split()

count = int(data[0])
popular = int(data[1])

datas = input().split()

vote_total = 0

for vote in datas:
    vote_total += int(vote)
    
popular_count = 0

for vote in datas:
    if int(vote) >= vote_total / (4 * popular):
        popular_count += 1

if popular_count >= popular:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#include <vector>
#include <array>
#include <algorithm>
#include <iostream>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <math.h>
#include <assert.h>
#include <queue>
#include <deque>
#include <iomanip>
#include <numeric>
#include <fstream>

using namespace std;

typedef long long ll;
typedef long double ld;

#define fi first
#define se second

#define mp make_pair
#define pb push_back
#define sz(x) ((int)(x).size())

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<ld>> vvd;
typedef vector<string> vs;
typedef vector<bool> vb;

typedef pair <int, int> pii;
typedef pair <ll, ll> pll;


ll n, k, sum;
ll a[530];
ll b[530];

bool check(ll x) {
    ll suml = 0;
    for (int i = 0; i < n; ++i) {
        ll l = a[i] / x * x;
        ll r = l + (a[i] == l ? 0 : x);
        b[i] = a[i] - l;
        suml += l;
    }
    ll kek = n - (sum - suml) / x;
    sort(b, b + n);
    ll lol = 0;
    for (int i = 0; i < kek; ++i) lol += b[i];
    return lol <= k;
}

int main() {
    cout << setprecision(30);
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        sum += a[i];
    }

    ll ans = 1;
    for (ll d = 1; d * d <= sum; ++d) {
        if (sum % d) continue;
        if (check(d)) ans = max(ans, d);
        if (check(sum / d)) ans = max(ans, sum / d);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL<<60;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP2(i,j,n) for(int i=j;i<n;i++)
int V=100100;

//オーダ数に着目　重みと価値を逆転
int main(){
    
    int N,W;
    cin >> N >> W;
    int w[N+1],v[N+1];
    REP2(i,0,N+1){
        cin >> w[i]>>v[i];
    }

   long long dp[N+1][V];
   REP(i,N+1){
       REP(j,V){
           dp[i][j]= {INF};
       }
   }
   dp[0][0] =0;
    REP2(i,0,N){
        // REP(j,W+1){
        //     //i番目の品物を入れた場合(dp[i-1][j-w[i]]+v[i])と入れない(dp[i-1][j])
        //     if(w[i] <= j){
        //         dp[i][j] = max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
        //     }else{
        //         dp[i][j] = dp[i-1][j];
        //     }
            
        // }
        REP(j,V){
            if(j-v[i]>=0){
                dp[i+1][j] = min(dp[i][j],dp[i][j-v[i]]+w[i]);
            }else{
                dp[i+1][j] = dp[i][j];
            }
        }
    }
    int ans=0;
    REP(j,V){
        if(dp[N][j]<=W ){
            ans = j;
        }
    }
    cout << ans<<endl;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  deque<char> deq;
  string s;
  cin >> s;
  rep(i, s.size()) deq.push_back(s[i]);
  int Q;
  cin >> Q;
  bool reverse = false;
  rep(_, Q) {
    int t;
    cin >> t;
    if (t == 1) {
      reverse = !reverse;
    } else {
      int f;
      char c;
      cin >> f >> c;
      if ((f == 1) == (!reverse)) {
        deq.push_front(c);
      } else {
        deq.push_back(c);
      }
    }
  }
  while (deq.size()) {
    if (!reverse) {
      cout << deq.front();
      deq.pop_front();
    } else {
      cout << deq.back();
      deq.pop_back();
    }
  }
  cout << endl;
}


Measured memory_bytes: 976
#if defined(_WIN32)
#include "stdc++.h"
#else
#include <bits/stdc++.h>
#endif

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

using namespace std;

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

	string s;
	cin >> s;

	ull res = (s.length() + 1) / 2;
	while (s[res] == s[res - 1] && s[res] == s[s.length() - (res + 1)]) res++;

	cout << res << endl;
	return 0;
}


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

int main() {

  char ch;
  int n, i, s, t, rank;
  int card[4][14]={};  //??????????????????
  
  cin >> n;

  for(i=0; i<n; i++){
      cin >> ch >> rank;
      if(ch == 'S') card[0][rank] = 1;
      if(ch == 'H') card[1][rank] = 1;
      if(ch == 'C') card[2][rank] = 1;
      if(ch == 'D') card[3][rank] = 1;
  }

  for(s=0; s<4; s++){
    for(t=1; t<14; t++){
      if(card[s][t]) continue; //?????????????????¨????????°???????????????
      if(s==0) ch = 'S';
      if(s==1) ch = 'H';
      if(s==2) ch = 'C';
      if(s==3) ch = 'D';
      cout << ch << " " << t << endl;
    }
  }

  return 0;
  
}

Measured memory_bytes: 1160
package main

import "fmt"

var (
	a int
)


func main() {
	fmt.Scanf("%d\n",&a)
	n := a/4
	x :=n+1
	for i:=0;i<=n;i++{
		if (a-i*4)%7!=0 {
			x--
		}
	}
	if x!=0{
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

Measured memory_bytes: 512
from collections import deque

H, W = map(int, input().split())
grid = [input() for i in range(H)]


def bfs0(white_cells, black_cells):

    while white_cells:
        h, w = white_cells.popleft()
        if h==0 and w==0 and grid[h][w] == "#":
            black_cells.append((h, w))
            return black_cells

        for dy, dx in ((1, 0), (0, 1)):
            new_h = h + dy
            new_w = w + dx
            if new_h < 0 or H <= new_h or new_w < 0 or W <= new_w:
                continue
            if grid[new_h][new_w] == ".":
                if (new_h, new_w) not in white_cells:
                    white_cells.append((new_h, new_w))
            else:
                if (new_h, new_w) not in black_cells:
                    black_cells.append((new_h, new_w))
            if new_h == H-1 and new_w == W-1:
                if grid[new_h][new_w] == ".":
                    return 1
                else:
                    return 0

    return black_cells


def bfs1(black_cells, white_cells):

    while black_cells:
        h, w = black_cells.popleft()
        for dy, dx in ((1, 0), (0, 1)):
            new_h = h + dy
            new_w = w + dx
            if new_h < 0 or H <= new_h or new_w < 0 or W <= new_w:
                continue
            if grid[new_h][new_w] == "#":
                if (new_h, new_w) not in black_cells:
                    black_cells.append((new_h, new_w))
            else:
                if (new_h, new_w) not in white_cells:
                    white_cells.append((new_h, new_w))
            if new_h == H-1 and new_w == W-1:
                if grid[new_h][new_w] == "#":
                    return 1
                else:
                    return 0

    return white_cells

count = 0
ans = 0

if count == 0:
    white_cells = deque()
    white_cells.append((0, 0))
    black_cells = deque()

while black_cells != 1 and white_cells != 1 and black_cells != 0 and white_cells != 0:
    if count % 2 == 0:
        a = 1
        temp_black_cells = bfs0(white_cells, black_cells)
        black_cells = temp_black_cells
        ans += 1
    else:
        a = 0
        temp_white_cells = bfs1(black_cells, white_cells)
        white_cells = temp_white_cells
    count += 1

if black_cells == 1:
    ans -=1

print(ans)


Measured memory_bytes: 47864
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;

public class Main {
    int h, w;
    boolean hOdd, wOdd;
    char[] cs;
    int[] counts;

    public static void main(String[] args) {
        Main m = new Main();
        m.read();
        m.solve();
    }

    private void read() {
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String[] elems = br.readLine().split(" ");
            h = Integer.parseInt(elems[0]);
            w = Integer.parseInt(elems[1]);
            hOdd = h % 2 == 1;
            wOdd = w % 2 == 1;
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < h; i++) {
                String line = br.readLine();
                sb.append(line);
            }
            cs = sb.toString().toCharArray();
            counts = new int['z'-'a'+1];
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private void solve() {
        int[] count = new int[3];
        for (char c: cs) {
            counts[c - 'a']++;
        }
        for (int i = 0; i < counts.length; i++) {
            if (counts[i] == 0)
                continue;
            int tmp = counts[i];
            int _4 = tmp / 4;
            tmp %= 4;
            int _2 = tmp / 2;
            tmp %= 2;
            int _1 = tmp;
            count[0] += _1;
            count[1] += _2;
            count[2] += _4;
        }
        boolean flg = true;
        int _4, _2, _1;
        int w2 = (w+1)/2, h2 = (h+1)/2;
        if (hOdd && wOdd) {
            _4 = (w2-1) * (h2-1);
            _2 = h2 - 1 + w2 - 1;
            _1 = 1;
        }
        else if (hOdd) {
            _4 = (h2 - 1) * w2;
            _2 = w2;
            _1 = 0;
        }
        else if (wOdd) {
            _4 = (w2 - 1) * h2;
            _2 = h2;
            _1 = 0;
        }
        else {
            _4 = w2 * h2;
            _2 = 0;
            _1 = 0;
        }
        count[2] -= _4;
        if (count[2] >= 0) {
            count[1] += count[2] * 2;
            count[1] -= _2;
            count[0] -= _1;
            if (count[1] == 0 && count[0] == 0)
                System.out.println("Yes");
            else
                System.out.println("No");
        }
        else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 23252
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <cstring>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <bitset>
using namespace std;
using ll=long long;
#define MOD  1000000007

int main(int argc, char const *argv[]) {
  unsigned long long a,b,x;
  std::cin >> a >> b >> x;
  unsigned long long ans;
  if(a==0) ans=b/x +1;
  else ans= b/x -(a-1)/x;
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
A = gets.to_i
B = gets.to_i
C = gets.to_i
X = gets.to_i

cnt = 0

(0..A).each do |a|
  (0..B).each do |b|
    (0..C).each do |c|
      if 500 * a + 100 * b + 50 * c == X
        cnt += 1
      end
    end
  end
end

puts cnt


Measured memory_bytes: 3836
from itertools import combinations

import numpy as np


def run():
    n, m, x = map(int, input().split())
    data = [list(map(int, input().split())) for _ in range(n)]
    c = np.array([d[0] for d in data])
    a = np.array([d[1:] for d in data])

    candidates = []
    for buy_num in range(1, n + 1):
        for comb in combinations(range(n), buy_num):
            temp_a = a[comb, :]

            sum_a = np.sum(temp_a, axis=0)

            if np.all(sum_a >= x):
                sum_c = np.sum(c[list(comb)])
                candidates.append(sum_c)

    if not candidates:
        print(-1)
    else:
        print(min(candidates))


if __name__ == '__main__':
    run()


Measured memory_bytes: 27428
#include <stdio.h>

void max_heapify(int *heap, int i, int heap_size) {
	int L, R, largest, tmp;

	L = 2*i;
	R = 2*i + 1;
	if (L <= heap_size && heap[L] > heap[i]) {
		largest = L;
	} else {
		largest = i;
	}
	if (R <= heap_size && heap[R] > heap[largest]) {
		largest = R;
	}
	if (largest != i) {
		tmp = heap[i];
		heap[i] = heap[largest];
		heap[largest] = tmp;
		max_heapify(heap, largest, heap_size);
	}
}

void build_max_heap(int *heap, int heap_size) {
	int i;

	for (i = heap_size/2; i > 0; i--) {
		max_heapify(heap, i, heap_size);
	}
}

int main(void) {
	int heap[500001], heap_size, i;

	scanf("%d", &heap_size);
	for (i = 1; i <= heap_size; i++) {
		scanf("%d", heap+i);
	}

	build_max_heap(heap, heap_size);
	for (i = 1; i <= heap_size; i++) {
		printf(" %d", heap[i]);
	}
	putchar('\n');
	return 0;
}


Measured memory_bytes: 3808
#include <iostream>
using namespace std;
typedef long long int ll;
int main(){
  int n;cin>>n;
  ll a[n] , ma =0 , ans =0;
  for (int i=0;i<n;++i){cin>>a[i];ans+=max(0ll,ma-a[i]);ma = max(ma,a[i]);}
  cout<<ans;
  
}

Measured memory_bytes: 5160
#include<stdio.h>

int main()
{
	int i, x, y;
	
	while(1) {
		scanf("%d %d", &x ,&y);
		if (x == 0 && y ==0) break;
		else if (x >= y) printf("%d %d\n",y ,x);
		else printf("%d %d\n",x ,y);
	}
	
	return 0;
}

Measured memory_bytes: 600
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include<limits>
#include<iomanip>

using namespace std;

#define debug(x) cout << #x << ": " << x << endl;
#define ll long long
// #define mod 1000000007
#define mod 998244353
// #define COMMENT

/*   nCr % mod

const int N = 2000099;
ll fact[N];
ll finv[N];
ll inv[N];

void inverse_modulao() {
  fact[0] = fact[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;

  for(int i = 2;i < N;i++) {
    fact[i] = fact[i-1]*i%mod;
    inv[i] = mod-mod/i*inv[mod%i]%mod;
    finv[i] = finv[i-1]*inv[i]%mod;
  }
}

ll nCr(int n, int r) {
  return fact[n]*finv[r]%mod*finv[n-r]%mod;
}

*/

int N, S, A[3090], dp[3090];

int main() {

//  freopen("input.in","r",stdin);
  //freopen("output.out","w",stdout);

  cin >> N >> S;
  for(int i = 0;i < N;i++) {
    cin >> A[i];
  }

  ll ans = 0;
  for(int i = 0;i < N;i++) {
    dp[0] += 1;
    for(int j = S;j >= 0;j--) {
      if(j+A[i] <= S) {
        (dp[j+A[i]] += dp[j]) %= mod;
      }
    }

    (ans += dp[S]) %= mod;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mods 1000000007
#define pb push_back
#define mp make_pair
#define st first
#define nd second
typedef long long int lint;
typedef unsigned long long int ulint;
lint n,cev=0;
string s;
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	lint i,j,k;
	cin>>s;
	n=s.size();
	for(i=0;i<n;){
		lint kuc=0,buy=0,a,b;
		while(s[i]=='<' && i<n) kuc++,i++;
		while(s[i]=='>' && i<n) buy++,i++;
		a=fmax(buy,kuc);
		b=fmin(buy,kuc);
		//if(b==0) b++;
		cev+=(a*(a+1))/2;
		cev+=(b*(b-1))/2;
	}
	cout<<cev;
	
	
	return 0;
}

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

int main(int, char**) {
    ios_base::sync_with_stdio(0); cin.tie(NULL);
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
#define debug(...) cout<<"["<<#__VA_ARGS__<<": "<<__VA_ARGS__<<"]\n"
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn = 1e5 + 100;
const int mod = 1e9 + 7;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int n;
vector<int>adj[maxn];
ll dp[maxn][2];
void dfs(int v, int p = -1)
{
    ll p0 = 1, p01 = 1, ch = 0;
    for(int to : adj[v])
    {
        if(to != p)
        {
            ++ch;
            dfs(to, v);
            p0 = p0 * dp[to][0] % mod;
            p01 = p01 * (dp[to][0] + dp[to][1]) % mod;
        }
    }
    dp[v][0] = p01;
    dp[v][1] = p0;
    if(!ch) dp[v][0] = dp[v][1] = 1;
}
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0);
    cin >> n;
    for(int i = 0; i < n - 1; i++)
    {
        int a, b;
        cin >> a >> b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    dfs(1);
    cout << (dp[1][0] + dp[1][1]) % mod << "\n";
    return 0;
}


Measured memory_bytes: 14208