akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028L;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

template<typename T>
struct fenwick_tree {
    int n;
    T ZERO;
    std::vector<T> data;
    fenwick_tree(int n, T ZERO = T()) : n(n), ZERO(ZERO), data(n + 1, ZERO) {}
    void add(int i, T x) { for (i++; i <= n; i += i & -i) { data[i] += x; }}
    T get_sum(int i) const {
        if (i > n) { i = n; }
        T ret = ZERO;
        for (; i > 0; i -= i & -i) { ret += data[i]; }
        return ret;
    }
    T get_sum(int l, int r) const {
        if (l < r) { return get_sum(r) - get_sum(l); }
        else { return ZERO; }
    }
};

long long discrete_binary_search(long long ok, long long ng, const std::function<bool(long long)> &check) {
    while (abs(ok - ng) > 1) {
        long long mid = (ok + ng) / 2;
        (check(mid) ? ok : ng) = mid;
    }
    return ok;
}

int N;
int a[110000];
signed main() {
    cin >> N;
    reps(i, N) { cin >> a[i]; }
    cout << discrete_binary_search(0, 1e9 + 1, [&](int x) {
        fenwick_tree<int> ft(220000);
        vint v(N + 1);
        reps(i, N) {
            if (a[i] >= x) { v[i] = 1; }
            else { v[i] = -1; }
            v[i] += v[i - 1];
        }
        int k = 0;
        for (int i = 0; i <= N; i++) {
            v[i] += 110000;
            k += ft.get_sum(v[i] + 1);
            ft.add(v[i], 1);
        }
        return k * 2 >= (N * (N + 1)) / 2;
    }) << endl;
}


Measured memory_bytes: 3584
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<cmath>
#include<ctime>
#include<complex>

using namespace std;

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


int main(){

	int n,m,k;
	cin >> n >> m;

	vector<int>Cards;
	vector<int>v;
	rep(i,2*n) Cards.push_back(i+1);

	rep(i,m){
	cin >> k;
    if(k==0){
    rep(j,n){
    v.push_back(Cards[j]);
    v.push_back(Cards[n+j]);
    }
    Cards=v; v.clear();
    }
    else{
    rep(l,2*n-k) v.push_back(Cards[k+l]);
    rep(l,k) v.push_back(Cards[l]);
    Cards=v; v.clear();
    }
	}

    rep(i,2*n) cout << Cards[i] << endl;

    return 0;

}

Measured memory_bytes: 1220
#include <iostream>

using namespace std;

int fib(int n);

int main() {
int n;
int dp[45];

dp[0] = 1;
dp[1] = 1;

cin >> n;

for(int i = 2; i <= n; i++) {
dp[i] = dp[i-1] + dp[i-2];
}

cout << dp[n] << endl;
return 0;
}


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

using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll fexp (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = fexp (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return fexp (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/gcd(num1,num2))*num2;}

// end of Template

int x,k;
vi ans;
int main(){

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

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>k>>x;
    for(int i=x-k+1;i<x;i++){
        ans.pb(i);
    }
    for(int i=x;i<=x+k-1;i++){
        ans.pb(i);
    }

    for(int i=0;i<ans.size();i++){
        cout<<ans[i];
        if(i<ans.size()-1){cout<<" ";}
        else{cout<<newl;}
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x,h,w) (y) < 0 || (h) <= (y) || (x) < 0 || (w) <= (x)
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }


int main() {
    init();

    int n; string s, t; cin >> n >> s >> t;
    int Max = 0;
    eFOR(i, 1, n)if (s.substr(n - i) == t.substr(0, i))Max = i;
    cout << 2 * n - Max << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	int n, m;
	cin >> n >> m;
	n--; m--;
	
	cout << n * m << endl;
	
	return 0;
}


Measured memory_bytes: 3544
#include <iostream>
using namespace std;
#define MAX 10000
#define NIL -1

struct Node { int p, l, r; };

Node T[MAX];
int n;

void pre(int u){
  if(u == NIL) return;
  cout << " " << u;
  pre(T[u].l);
  pre(T[u].r);
}

void in(int u){
  if(u == NIL) return;
  in(T[u].l);
  cout << " " << u;
  in(T[u].r);
}

void post(int u){
  if(u == NIL) return;
  post(T[u].l);
  post(T[u].r);
  cout << " " << u;
}

int main() {
  cin >> n;

  for (int i = 0; i < n; ++i) T[i].p =  NIL;

  int v, l, r;
  for (int i = 0; i < n; ++i) {
    cin >> v >> l >> r;
    T[v].l = l;
    T[v].r = r;
    if (l != NIL) T[l].p = v;
    if (r != NIL) T[r].p = v;
  }

  int root = 0;
  for (int i = 0; i < n; ++i)	if (T[i].p == NIL) root = i;

  cout << "Preorder" << endl;
  pre(root);
  cout << endl;
  cout << "Inorder" << endl;
  in(root);
  cout << endl;
  cout << "Postorder" << endl;
  post(root);
  cout << endl;
  
  
  
  return 0;
}




Measured memory_bytes: 3104
#include<cstdio>
#include<limits>

#define MAX 500000
#define INFINITE numeric_limits<int>::max()

using namespace std;

int S[MAX];
int cnt = 0;

void print(int A[], int n) {
  for (int i = 0; i < n; i++) {
    if (i != 0) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

void merge(int left, int mid, int right) {
  int n1 = mid - left;
  int n2 = right - mid;

  int L[n1], R[n2];
  for (int i = 0; i < n1; i++) L[i] = S[left + i];
  for (int i = 0; i < n2; i++) R[i] = S[mid + i];
  L[n1] = R[n2] = INFINITE;

  int i = 0, j = 0;
  for (int k = left; k < right; k++) {
    cnt++;
    if (L[i] <= R[j]) {
      S[k] = L[i];
      i++;
    } else {
      S[k] = R[j];
      j++;
    }
  }
}

void merge_sort(int left, int right) {
  if (left + 1 < right) {
    int mid = (left + right) / 2;
    merge_sort(left, mid);
    merge_sort(mid, right);
    merge(left, mid, right);
  }
}

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

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

  print(S, n);
  printf("%d\n", cnt);

  return 0;
}



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

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> out(N);
  //入力部
  for (int j=0;j<M;j++) {
    int x,y;
    cin >> x >> y;
    out.at(x-1)++;
    out.at(y-1)++;
  }
  //出力部
  for (int i=0;i<N;i++) {
    cout << out.at(i) << endl;
  }
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
import numpy as np
from scipy.sparse.csgraph import connected_components
from scipy.sparse import csr_matrix

N,M = map(int,input().split())
A = np.array(input().split(),dtype=np.int64)
XY = [[int(x) for x in input().split()] for _ in range(M)]

if M>0:
    X,Y = zip(*XY)
else:
    X,Y = [],[]
n_comp,comp = connected_components(csr_matrix(([1]*M,(X,Y)),(N,N)))

i = np.lexsort((A,comp))
A = A[i]; comp = comp[i]

i = np.concatenate([[0],np.where(comp[1:] != comp[:-1])[0]+1])

cost = A[i].sum()
A = np.delete(A,i)
rest = 2 * (n_comp-1) - len(i)
if n_comp == 1:
    print(0)
elif rest > len(A):
    print('Impossible')
else:
    A.sort()
    cost += A[:rest].sum()
    print(cost)

Measured memory_bytes: 41616
#include <iostream>

using namespace std;

int pr[100005];
int n, x;

int main()
{
    cin >> n;
    for(int i = 1; i < n+1; i++){
        cin >> x;
        pr[x]=i;
    }
    for(int i = 1; i < n+1; i++){
        cout << pr[i] << " ";
    }
    return 0;
}


Measured memory_bytes: 1152
N, M = map(int, input().split())
k = [0]*M
S = [0]*M

for m in range(M):
    S[m] = list(map(int, input().split()))
    k[m] = S[m].pop(0)

p = list(map(int, input().split()))

X = list(range(2**N))
for n in range(2**N):
    X[n] = bin(X[n])[2:]
    X[n] = '0' * (N - len(X[n])) + X[n]
    
ans = 0
for x in X:
    x_judge = 1
    for m in range(M):
        a = 0
        for s in S[m]:
            if x[s-1] == '1':
                a += 1
        if a%2 != p[m]:
            x_judge = 0
    ans += x_judge
    
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
      double i,j,n,m,x,y,w,h;
    cin>>w>>h>>x>>y;
    printf("%.6lf ",(w*h)/2);
    if(x==w/2&&y==h/2){
        cout<<1;
        return 0;
    }
    cout<<0;
}


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

typedef pair<int,int> p;
typedef long long ll;

int main(){
    int n, w;
    cin >> n >> w;
    vector<p> v(n);
    for(int i = 0; i < n; i++)  cin >> v[i].first >> v[i].second;
    sort(v.rbegin(), v.rend(), [](p a, p b){return (ll)a.first*b.second < (ll)b.first*a.second;});
    double ans = 0;
    for(int i = 0; i < n; i++){
        int take = min(w, v[i].second);
        ans += (double)take / v[i].second * v[i].first;
        w -= take;
    }
    cout << fixed << setprecision(12) << ans << endl;
    return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAX_V 111111
#define int long long
int V,E;
vector<int> G[MAX_V];
int used[MAX_V];
void add_edge(int a,int b){
  G[a].push_back(b);
  G[b].push_back(a);
}
int a[2];
bool dfs(int v,int c){
  if(~used[v]) return used[v]==c;
  bool f=1;
  a[c]++;used[v]=c;
  for(int i=0;i<(int)G[v].size();i++) f&=dfs(G[v][i],!c);
  return f;
}
typedef pair<int,int> P;
bool dp[2][MAX_V];
int solve(){
  int x=0;
  vector<P> v;
  memset(used,-1,sizeof(used));
  for(int i=0;i<V;i++){
    if(used[i]>=0) continue;
    a[0]=a[1]=0;
    if(dfs(i,0)){
      if(a[1]) v.push_back(P(a[1],a[0]));
      else x++;
    }else return -1;
  }
  int k=0,m=0;
  memset(dp[0],0,sizeof(dp[0]));
  dp[0][0]=1;
  for(int i=0;i<(int)v.size();i++){
    bool f=i%2;
    memset(dp[!f],0,sizeof(dp[!f]));
    for(int j=0;j<V;j++){
      if(dp[f][j])
	dp[!f][j+v[i].first]=dp[!f][j+v[i].second]=1,
	  m=max(m,j+max(v[i].first,v[i].second));
    }
  }
  for(int i=0;i<V;i++){
    if(dp[v.size()%2][i]){
      for(int j=0;j<=x&&i+j<V;j++){
	//cout<<i+j<<":"<<(V-(i+j))*(i+j)<<endl;
	if((V-k)*k<(V-(i+j))*(i+j)) k=i+j;
      }
    }
  }
  return (V-k)*k-E;
}
signed main(){
  cin>>V>>E;
  for(int i=0,a,b;i<E;i++) cin>>a>>b,add_edge(a-1,b-1);
  cout<<solve()<<endl;
  return 0;
}

Measured memory_bytes: 11176
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
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;
const ll MOD = 1e9+7; int INF=INT_MAX; ll LLINF = 1LL << 60;
const vector<int> d8x = {1, 0, -1, 0, 1, -1, -1, 1}; vector<int> d8y = {0, 1, 0, -1, 1, 1, -1, -1};
const vector<int> d4x = {1, 0, -1, 0}; vector<int> d4y = {0, 1, 0, -1};

//

int main(){
    int a,b; cin>>a>>b;
    cout<<max(a+b,max(a-b,a*b))<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 10000
#define NIL -1

struct Node{
  int s, t, u;
};

struct Node T[MAX];
int n;

void preParse(int u){
  if ( u == NIL ) return;
  printf(" %d", u);
  preParse(T[u].t);
  preParse(T[u].u);
}
void inParse(int u){
  if ( u == NIL ) return;
  inParse(T[u].t);
  printf(" %d", u);
  inParse(T[u].u);
}
void postParse(int u){
  if ( u == NIL ) return;
  postParse(T[u].t);
  postParse(T[u].u);
  printf(" %d", u);
}

main(){
  int i, s, t, u, root;
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ) {
    T[i].s = NIL;
  }

  for ( i = 0; i < n; i++ ){
    scanf("%d %d %d", &s, &t, &u);
    T[s].t = t;
    T[s].u = u;
    if ( t != NIL ) T[t].s = s;
    if ( u != NIL ) T[u].s = s;
  }

  for ( i = 0; i < n; i++ ) if ( T[i].s == NIL ) root = i;
  printf("Preorder\n");
  preParse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  postParse(root);
  printf("\n");

  return 0;
}



Measured memory_bytes: 2096
n = int(input())
water = [int(x) for x in input().split()]
sum1 = sum(water)
sum2 = sum([v for i, v in enumerate(water) if i%2==1])

ans = [0] * n
ans[0] = sum1 - 2 * sum2
for i in range(1, n ):
    ans[i] = (water[i - 1] - ans[i - 1]//2) * 2
print(*ans)    


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

int main() {
    int n;cin>>n;
    int a[n],b[n];
    rep(i,n)cin>>a[i];
    rep(i,n)b[i]=0;
    rep(i,n){
        b[a[i]-1]=i+1;
    }
    rep(i,n)cout<<b[i]<<' ';
}

Measured memory_bytes: 1536
#include <iostream>
#include <stdio.h>
#include <string>
#include <list>
#include <vector>
#include <algorithm>

#define rep(i,n) for(int i = 0;i < n;i++)
#define REP(i,n,k) for(int i = n;i < k;i++)
#define P(p) cout << (p) << endl;//print
typedef long long ll;
using namespace std;


int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    
    string s;
    cin >> s;
    if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I'){
        P("Yes");
    }else{
        P("No");
    }
}


Measured memory_bytes: 256
N = gets.to_i
A = gets.chomp.split(" ").map(&:to_i)

ans, i, bef, st = [0, 0, 0, 0]
while i < N do
  if bef ^ A[i] == bef + A[i] then
    bef ^= A[i]
  else
    ans += (i-st)
    bef ^= A[st]
    st += 1
    i -= 1
  end
  i += 1
end
ans += ((i-st) * (i-st+1)) / 2

puts ans


Measured memory_bytes: 16644
n, l = map(int, input().split())

a = []
flag = False
for i in range(n):
	if l + i == 0:
		flag = True
	a.append(l+i)

if flag == True:
	print(sum(a))
elif a[0] < 0:
	 print(sum(a[:-1]))
else:
	print(sum(a[1:]))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds ;
#define ll long long
#define ld long double
#define rep(i,a,b) for(ll i=a;i<b;i+=1)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define sz(a) int((a).size())
#define hell (ll)1000000007
#define f first
#define s second
#define sll(x) scanf("%lld",&x)
#define si(x) scanf("%d",&x)
typedef tree< ll , null_type , less<ll> , rb_tree_tag , tree_order_statistics_node_update > ordered_set ;
ll t = 1 ;
void solve()
{
	ll m , n , up , ans = 0 ;
    cin >> m >> n ;
    vector<ll> v[n+5] , p(n+5) ;
    rep( i , 0 , n ){
        ll cnt ;
        cin >> cnt ;
        while(cnt--){
            ll temp ;
            cin >> temp ;
            v[i].pb(temp-1);
        }
    }
    rep(i,0,n)cin>>p[i];
    up = (1LL<<m) ;
    rep( i , 0 , up ){
        ll temp = 0 ;
        rep( j , 0 , n ){
            ll cnt = 0 ;
            for( auto u : v[j] ){
                if( (1LL<<u)&i )
                    cnt++;
            }
            if(cnt%2==p[j]%2)
                temp++;
        }
        if(temp==n)ans++;
    }
    cout << ans << "\n" ;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //cin>>t;
    while(t--)
        solve() ;
    return 0 ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/numeric/ublas/matrix.hpp>
using i64 = long long;

constexpr auto pow(long long x, long long n, const long long mod) {
    long long ret = 1;
    while(n > 0) {
        if ((n & 1) == 1) ret = (ret * x) % mod;
        x = (x * x) % mod;
        n >>= 1;
    }
    return ret;
}

int main() {
    constexpr i64 mod = 998244353;
    int n, m;
    std::cin >> n >> m;
    std::vector<std::bitset<310>> b(n);
    for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) {
        int a;
        std::cin >> a;
        if (a) b[i].set(j);
    }

    int r = 0;
    for (int j = 0; j < m; j++) {
        int p = -1;
        for (int i = r; i < n; i++) {
            if (b[i][j]) {
                p = i;
                break;
            }
        }
        if (p == -1) continue;
        std::swap(b[p], b[r]);
        for (int i = 0; i < n; i++) if (i != r && b[i][j]) b[i] ^= b[r];
        ++r;
    }

    std::cout << (pow(2, n + m - 1, mod) + mod - pow(2, n + m - r - 1, mod)) % mod << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
//#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n, m;
    while (cin >> n >> m && n) {
        VI s(n), t(m); cin >> s >> t;
        int a = accumulate(all(s), 0), b = accumulate(all(t), 0);
        int x = 10000, y = 10000;
        FOR(i, 0, n)FOR(j, 0, m) {
            if (a - (s[i] - t[j]) * 2 == b) {
                if (s[i] + t[j] < x + y) {
                    x = s[i], y = t[j];
                }
            }
        }

        if (x == 10000)cout << "-1\n";
        else cout << x << " " << y << "\n";
    }
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
 
int main(){ 
    int a,b,c;
    cin>>a>>b>>c;
    int d[3];
    d[0]=abs(a-b);
    d[1]=abs(b-c);
    d[2]=abs(c-a);

    sort(d,d+3);

    cout<<d[0]+d[1];
 
    return 0;
}

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

#define INF 1000000000000

using namespace std;

long a[1001], b[1001];
int ability[1001];
long dp[1001][4096];

int main(void)
{
    int N, M;
    cin >> N >> M;
    int argmax = 0;
    for (int i = 0; i < N; i++)
    {
        argmax |= 1 << i;
    }
    for (int i = 0; i < M; i++)
    {
        cin >> a[i] >> b[i];
        ability[i] = 0;
        for (int j = 0; j < b[i]; j++)
        {
            int c;
            cin >> c;
            ability[i] = ability[i] | (1 << (c - 1));
        }
    }
    for (int i = 0; i < M; i++)
    {
        for (int j = 1; j <= argmax; j++)
        {
            dp[i][j] = INF;
        }
    }
    dp[0][ability[0]] = a[0];
    // write dp
    for (int i = 1; i < M; i++)
    {
        for (int j = 1; j <= argmax; j++)
        {
            dp[i][j] = dp[i-1][j];
        }
        if (a[i] < dp[i-1][ability[i]])
            dp[i][ability[i]] = a[i];
        for (int j = 1; j <= argmax; j++)
        {
            if (dp[i - 1][j] != INF)
            {
                if ((j != (j | ability[i])) && dp[i-1][j] + a[i] < dp[i][j | ability[i]])
                    dp[i][j | ability[i]] = dp[i-1][j] + a[i];
            }
        }
    }
    if (dp[M-1][argmax] == INF) dp[M-1][argmax] = -1;
    cout << dp[M-1][argmax] << endl;
    return 0;
}

Measured memory_bytes: 32256
#include <stdio.h>
#include <math.h>
struct color{
	int r,g,b;
	char name[20];
};
int hex(char a){
	if('a'<=a&&a<='f'){
		return (a-'a'+10);
	}
	else{
		return a-'0';
	}
}
int main(void){
	struct color c[8]={
		{0x00,0x00,0x00,"black"},
		{0x00,0x00,0xff,"blue"},
		{0x00,0xff,0x00,"lime"},
		{0x00,0xff,0xff,"aqua"},
		{0xff,0x00,0x00,"red"},
		{0xff,0x00,0xff,"fuchsia"},
		{0xff,0xff,0x00,"yellow"},
		{0xff,0xff,0xff,"white"}
	};
	double r,g,b,d,md;
	int i,mi;
	char s[20];
	while(1){
		scanf("%s",s);
		if(s[0]=='0'){
			break;
		}
		r=hex(s[1])*16+hex(s[2]);
		g=hex(s[3])*16+hex(s[4]);
		b=hex(s[5])*16+hex(s[6]);
		md=114514;
		for(i=0;i<8;i++){
			d=sqrt(pow(r-c[i].r,2)+pow(g-c[i].g,2)+pow(b-c[i].b,2));
			if(md>d){
				md=d;
				mi=i;
			}
		}
		printf("%s\n",c[mi].name);
	}
	return 0;
}

Measured memory_bytes: 524
n = int(input())
c=list(map(int, input().split()))

x = 0

for i in range(n):
    if c[i] % 2 == 0:
        if c[i] % 3 != 0 and c[i] % 5 != 0:
            x = 1
            break

if x == 0:
    print("APPROVED")
elif x == 1:
    print("DENIED")

Measured memory_bytes: 3060
#include<stdio.h>
#include<ctype.h>

int main(void){

	char s;

	while(1){

		scanf("%c",&s);

		if( s != '.' && s!= ' ' && (s<'a'||s>'z'))
			break;

		else if(s>='a'&&s<='z')
			printf("%c",toupper(s));

		else
			printf("%c",s);


	}

	puts("");

	return 0;
}

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

int main(){
    string s; cin >> s;
    int sum = 0;
    for(int i=0; i<s.length(); i++){
        sum += s.at(i) - '0';
    }
    if(sum%9 == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define show(x) for(auto i: x){cout << i << " ";}
#define showm(m) for(auto i: m){cout << m.x << " ";}
typedef long long ll;
typedef pair<int, int> P;

int step[300500] = {0};

void bfs(int s, vector<vector<int>>& line){

    queue<int> q;
    q.push(s);
    while(!q.empty()){
        int now = q.front();
        for (auto next: line[now])
        {
            if (step[next] != 0) continue;
            q.push(next);
            step[next] = step[now] + 1;
        }
        q.pop();
    }

}

int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<int>> line(3*n);
    rep(i, m){ 
        int tmp_u, tmp_v; 
        cin >> tmp_u >> tmp_v; 
        tmp_u--; tmp_v--;
        line[tmp_u].push_back(tmp_v + n);
        line[tmp_u + n].push_back(tmp_v + (n*2));
        line[tmp_u + (n*2)].push_back(tmp_v);

    }
    int s, t;
    cin >> s >> t;
    s--; t--;
    step[s] = 1;
    bfs(s, line);
    // rep(i, 3*n){
    //     cout << i << " " << step[i] << endl;
    // }
    if (step[t]%3 == 1){
        cout << step[t]/3 << endl;
    } else {
        cout << "-1" << endl;
    }
}

Measured memory_bytes: 17792
/*
            _           __                _      _____ _____ _____ 
  ___ _   _| |__   ___ / _|_ __ ___  __ _| | __ |___  |___  |___  |
 / __| | | | '_ \ / _ \ |_| '__/ _ \/ _` | |/ /    / /   / /   / / 
| (__| |_| | |_) |  __/  _| | |  __/ (_| |   <    / /   / /   / /  
 \___|\__,_|_.__/ \___|_| |_|  \___|\__,_|_|\_\  /_/   /_/   /_/   

*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vi;
typedef vector<pll> vpll;
typedef unordered_map <ll,ll> umap ; 
//#pragma GCC optimize "trapv"
#define loop(i,a,b) for(ll i=a ;i<b;i++)
#define For(i,n) for(int i=0;i<(ll)n;i++)
#define Rev(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,n) for(int i=1;i<=n;++i)
#define F first
#define S second
#define pb push_back
#define em emplace_back
#define all(v) (v).begin(),(v).end()
#define mems(x, y) memset(x, y, sizeof(x))
#define sz(v) (v).size()
#define mp(a,b) make_pair(a,b)
#define pf(n) cout<<n<<"\n"
#define pff(n) cout << n << " " ; 
#define ar array
#define endl "\n" 
#define int ll 
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
long const M=1e9+7;
const long mxN =1e5+2 ;
int n,dp[mxN],a[mxN] ;
void solve(){
  cin >> n ;
  For(i,n)
    cin >> a[i];
  dp[0]=0;
  dp[1]=abs(a[1]-a[0]) ;
  for(int i=2;i<n;i++)  
    dp[i]=min(abs(a[i]-a[i-1])+dp[i-1],abs(a[i]-a[i-2])+dp[i-2]) ;
  cout << dp[n-1] << endl ;
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //cout << setprecision(20) << fixed ;
    solve() ;
    //ll t ; cin >> t ; while(t--)solve();
	return 0;
}
  

Measured memory_bytes: 1792
#[allow(unused_imports)]
use std::cmp;

fn run() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let k: usize = sc.read();
    let mut p = sc.read_vec::<usize>(n);
    p.sort();
    let ans = p[..k].into_iter().sum::<usize>();
    println!("{}", ans);
}

fn main() {
    std::thread::Builder::new()
        .name("run".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(run)
        .unwrap()
        .join()
        .unwrap();
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn read_pairs<T: std::str::FromStr>(&mut self, n: usize) -> Vec<(T, T)> {
        (0..n).map(|_| (self.read(), self.read())).collect()
    }
    pub fn read_pairs_1_indexed(&mut self, n: usize) -> Vec<(usize, usize)> {
        (0..n)
            .map(|_| (self.read::<usize>() - 1, self.read::<usize>() - 1))
            .collect()
    }
    pub fn read_chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    pub fn read_char_grid(&mut self, n: usize) -> Vec<Vec<char>> {
        (0..n).map(|_| self.read_chars()).collect()
    }
    pub fn read_matrix<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n)
            .map(|_| (0..m).map(|_| self.read()).collect())
            .collect()
    }
}


Measured memory_bytes: 2208
n = int(input())
sp =[]
for i in range(n):
    a, b = input().split()
    sp.append([a, int(b), i + 1])
sp.sort()
s = 0
ans = []
for i in range(1, n):
    if sp[s][0] == sp[i][0]:
        continue
    else:
        ans.extend(sp[s:i:][::-1])
        s = i
ans.extend(sp[s::][::-1])
for i in ans:
    print(i[2])

Measured memory_bytes: 38384
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>
#define mod  1000000007

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

using namespace std;
using ll = long long;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  map<int, int> mp;
  int a, b;
  for(int i = 0; i < 3; i++){
    cin >> a >> b;
    mp[a]++; mp[b]++;
  }

  int data[4] = {};
  for(int i = 1; i <= 4; i++){
    data[mp[i]]++;
  }

  if(data[1] == 2 && data[2] == 2) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_B&lang=jp
class Process(object):
    def __init__(self, name, time):
        self.name = str(name)
        self.time = int(time)

from collections import deque

n,  q = map(int, input().split())
que = deque([Process(*(input().split())) for i in range(n)])

que_l = len(que)
time = 0
while que_l!=0:
    tmp = que.popleft()
    if tmp.time<=q:
        time += tmp.time
        que_l -= 1
        print(tmp.name, time)
    else:
        time += q
        tmp.time -= q
        que.append(tmp)


Measured memory_bytes: 17792
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007L;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static ArrayList<int[]> list = new ArrayList<>();
	public static void main(String[] args) throws Exception {

		int A = nextInt();
		int B = nextInt();
		int C = nextInt();

		boolean[] m = new boolean[B];
		Arrays.fill(m, true);
		int sum =A;
		String ans = "NO";
		while(m[sum%B]){
			if((sum%B)==C){
				ans="YES";
				break;
			}else{
				m[sum%B]=false;
				sum+=A;
			}
		}
		System.out.println(ans);
	}

	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


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

const int mod = 2019;
string s;
int main() {
  cin >> s;
  int n = s.size();
  
  map<int, int> mp;
  int curr = 0;
  int base = 1;
  mp[0] = 1;
  
  long sum = 0;
  for (int i = n - 1; i >= 0; --i) {
    curr = (curr + base * (long)(s[i] - '0')) % mod;
    base = base * 10 % mod;
    sum += mp[curr];
    ++mp[curr];
  }
  cout << sum << endl;
}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
#define deb(x) cout << #x": " << (x) << endl;

const int N = 55;
const int INF = 1e9;
const lli MOD = 1e9+7;


vi primes(1,2);
vector<vector<ld>>nk;
void sieve(){
	vi m(N+1,0);
	for(int i = 4; i<N; i+=2)m[i]=1;
	for(int i = 3; i*i<=N; i+=2)if(!m[i])for(int j = i*i; j<N; j+=i)m[j]=1;
	for(int i = 3; i<N; i+=2)if(!m[i])primes.pb(i);
}

void pascal(){
	nk =vector<vector<ld>>(N,vector<ld>(N,0.0));
	fore(i,0,N)nk[i][0]=nk[i][i]=1.0;
	fore(i,1,N)fore(j,1,i)nk[i][j]=nk[i-1][j-1]+nk[i-1][j];
}

lli gcd(lli a, lli b){return (b?gcd(b,a%b):a);}

lli lcm(lli a, lli b){
	if(a<b)swap(a,b);
	lli c = gcd(a,b);
	a/=c;
	return a*b;
}

int popcount(lli x) { return __builtin_popcountll(x); }

lli poww(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = res * a;
		a = a*a;
		b/=2;
	}
	return res;
}

lli powm(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = (res * a)%MOD;
		a = (a*a)%MOD;
		b/=2;
	}
	return res;
}

bool isPrime(lli x){
	if(x==1)return 0;
	for(auto i:primes){
		if(i*i>x)return 1;
		if(x%i==0)return 0;
	}
	return 1;
}

lli SUM(lli a, lli b, lli mod=MOD){
	return (a+b+mod)%mod;
}
lli PROD(lli a, lli b, lli mod=MOD){
	a%=mod; b%=mod;
	return a*b % mod;
}
int dx[4]={-1,0,0,1}, dy[4]={0,1,-1,0};

// ---- コーディングはここから！ ('-')7



void solve(){
	lli a,b,t; cin>>a>>b>>t;
	cout<<(a<=b*t?"Yes":"No")<<ENDL;

}

int main(){_
	//int t; cin>>t; while(t--)
	solve();
}


Measured memory_bytes: 3648
# -*- coding: utf-8 -*-
import numpy as np

def get_min_c(c, a, n, m, x, sum_c, sum_a, min_c, now_i):
    for i in range(now_i, n):
        if np.all(sum_a + a[i] >= x):
            if sum_c + c[i] < min_c or min_c == 0:
                min_c = sum_c + c[i]
        else:
            min_c = get_min_c(c, a, n, m, x, sum_c + c[i], sum_a + a[i], min_c, i + 1)

    return min_c


n, m, x = map(int, input().split())

c = np.empty((n), dtype='int')
a = np.empty((n, m), dtype='int')
for i in range(n):
    tmp = input().split()
    c[i] = int(tmp[0])
    a[i] = tmp[1:]

max_a = np.zeros((m), dtype='int')
max_c = 0
for i in range(n):
    max_a += a[i]
    max_c += c[i]

if np.any(max_a < x):
    min_c = -1
else:
    min_c = get_min_c(c, a, n, m, x, 0, 0, 0, 0)
    
print(min_c)


Measured memory_bytes: 27380
#include <bits/stdc++.h>
using namespace std;
vector<int> X(5);
vector<bool> used(5, false);
int res = 1000;

int ceil(int a, int b) {
    return (a + b - 1) / b;
}

void dst(int pos, int acc) {
    if (pos == 5) {
        res = min(res, acc);
    }
    for (int i = 0; i < 5; i++) {
        if (used[i]) {
            continue;
        }
        used[i] = true;
        if (pos != 4) {
            dst(pos + 1, acc + ceil(X[i], 10) * 10);
        } else {
            dst(pos + 1, acc + X[i]);
        }
        used[i] = false;
    }
}

int main() {
    for (int i = 0; i < 5; i++) {
        cin >> X[i];
    }
    dst(0, 0);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

int vector_finder(std::vector<string> vec, string number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

#include <sstream> 
std::vector<std::string> StringSplit(const std::string& str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a * b / gcd(a, b);
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}

int main() {
	int n,t,a; cin >> n>>t>>a;
	vector<int> h(n), c(n);
	
	Int temp = MOD;
	int ans;
	Int x = 0;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
		x = t*1000 - h[i] * 6;
		//cout << x << endl;
		if (abs(a*1000 - x) < temp) {
			ans = i;
			temp = abs(a*1000 - x);
		}
	}
	cout << ans+1;
	

	
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long a,b;
struct knife
{
	   long long x;
	   int f;
} c[200020];
int cmp(knife p,knife q)
{
	return p.x>q.x;
}
int main()
{
	long long h;
	int n,k=0,ans=0;
	cin>>n;
	cin>>h;
	for(int i=1;i<=n;i++)
	{
	   cin>>a>>b;
	   c[++k].x=a;
	   c[k].f=1;
	   c[++k].x=b;
	   c[k].f=2;
    }
    sort(c+1,c+k+1,cmp);
    int j=1;
    while(1)
    {
    	 if(c[j].f==2)
    	 {
    	   h-=c[j].x;
    	   j++;
    	   ans++;
    	   if(h<=0) break;
         }
         else
         {
         	 ans=ans+h/c[j].x;
         	 if(h%c[j].x!=0) ans++;
         	 break;
		 }
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3328
arr = [i + 1 for i in range(int(input()))]
m = int(input())
for i in range(m):
    inp = list(map(int, input().split(",")))
    tmp = arr[inp[0] - 1]
    arr[inp[0] - 1] = arr[inp[1] - 1]
    arr[inp[1] - 1] = tmp
for i in range(len(arr)):
    print(arr[i])



Measured memory_bytes: 5600
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int n = in.nextInt();
        int[] result = new int[n];
        for (int i = 0; i < n - 1; i++) {
            result[in.nextInt() - 1]++;
        }
        for (int i = 0; i < result.length; i++) {
            out.println(result[i]);
        }

        out.close();
    }
}

Measured memory_bytes: 50168
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
	if(was_output)cout << " ";
	cout << a;
	was_output = true;
}
void outendl(){
	was_output = false;
	cout << endl;
}

int main(){
	int n;
	cin >> n;
	vector<int> line(n, 0);
	int n_max = 0;
	rep(i, n){
		int d;
		cin >> d;
		chmax(n_max, d);
		++line[d];
		if(d==0){
			if(i!=0){
				cout << 0 << endl;
				return 0;
			}
		}
	}
	ll ans = 1;
	rep(i, n_max){
		if(line[i]==0){
			ans = 0;
			break;
		}
		ans = ans * modpow(line[i], line[i+1]);
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}



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

using namespace std;

#define li long long int

const int N 	= 1e5 + 5;
const li mod 	= 1e9 + 7;

int n;
vector <int> g[N];
int vis[N][2];
li dp[N][2];

void dfs(int u, int par, int color) {
	if (vis[u][color]) return ;
	vis[u][color] = 1;
	dp[u][color] = 1;
	for (auto v : g[u]) {
		if (v == par) continue ;
		if (color == 0) {
			dfs(v, u, 0);
			dfs(v, u, 1);
			dp[u][color] *= (dp[v][0] + dp[v][1]) % mod;
			dp[u][color] %= mod;
		} else {
			dfs(v, u, 0);
			dp[u][color] *= dp[v][0];
			dp[u][color] %= mod;
		}
	}
}

void solve() {
	cin >> n;
	for (int i = 1; i < n; i++) {
		int u, v;
		cin >> u >> v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs(1, 0, 0);
	dfs(1, 0, 1);
	li ans = dp[1][0] + dp[1][1];
	ans %= mod;
	cout << ans;
}

int main() {
	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 14976
#question B
a,b,c=map(int, input().split())
k=int(input())
if a>=b:
    if a>=c:
        a=a*(2**k)
    else:
        c=c*(2**k)
elif b>=c:
    b=b*(2**k)
else:
    c=c*(2**k)
print(a+b+c)


Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>

int main()
{
	char s[100001];
	char t[50001];
	int len;
	int i,j;

	scanf("%s",s);
	len=strlen(s);

	for(i=0,j=0;i<len;i=i+2){
		t[j]=s[i];
		j++;
	}
	t[j]='\0';

	printf("%s\n",t);

	return 0;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionD
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数配列の入力
            var abn = Console.ReadLine().Split(' ').Select(q => long.Parse(q)).ToArray();

            var a = abn[0];
            var b = abn[1];
            var n = abn[2];

            var max = long.MinValue;

            long j = 0; ;

            for(long i = 0; true; i++) {
                j = ((b * i) + a - 1) / a;
                if(j > n) {
                    break;
                }

                var z = (a * j) / b;
                var s = a * (j / b);
                max = Math.Max(z - s, max);

                if (max == a - 1 || max == ((a * (b - 1)) / b)) {
                    break;
                }
            }

            Console.WriteLine(max);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 28228