akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcount
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
const int N = 1e5 + 7;
int n, m, q;
vector <ii> ed;
const int K = 11;
int dp[N][K], color[N];
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    cin >> n >> m;
    while (m--) {
        int u, v; cin >> u >> v;
        ed.app({u, v}); ed.app({v, u});
    }   
    cin >> q;
    for (int i = 1; i <= q; ++i) {
        int u, d, c;
        cin >> u >> d >> color[i];
        dp[u][d] = i;
    }   
    for (int t = 0; t < K * 2; ++t) {
        for (auto e : ed) {
            for (int d = 1; d < K; ++d) {
                dp[e.s][d - 1] = max(dp[e.s][d - 1], dp[e.f][d]);
            }   
        }   
    }   
    for (int i = 1; i <= n; ++i) {
        int ans = 0;
        for (int j = 0; j < K; ++j) ans = max(ans, dp[i][j]);
        cout << color[ans] << '\n';
    }   
}   

Measured memory_bytes: 13676
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define mod 1000000007
#define exp pow(10,-9)
#define F first
#define S second
#define PB push_back 
#define MP make_pair
#define daman ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define lowercase(str) transform(str.begin(), str.end(), str.begin(), ::tolower);
#define uppercase(str) transform(str.begin(), str.end(), str.begin(), ::toupper);
main()
{
	int n;
	cin>>n;
	if(n >= 30)
		cout<<"Yes\n";
	else
		cout<<"No\n";
	
}

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

using namespace std;

bool f(int a, int b, int c, int d) {
  if(abs(b-a)<=d && abs(c-b)<=d) return true;
  return abs(c-a)<=d;
}

int main() {
  int a, b, c, d; cin>>a>>b>>c>>d;
  cout << (f(a,b,c,d) ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#define all(c) (c).begin(),(c).end()
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; q > i; i++)
using namespace std; 
int waru_kiriage(int a, int b){//切り上げ割り算をする
  return (a % b == 0 ? a / b : a / b + 1);
}
int abss(int a){//absと一緒
    return (a < 0 ? a * -1 : a);
}
int bai(int k){//引数の数だけ10倍する
  int ans = 1;
  for(int i = 0;k>i;i++){
    ans *= 10;
  }
  return ans;
}
int int_length(int k){//引数の桁数を調べる
  int ans = 0;
  for(int i = 1; k > i; i=i*10)ans++;
  return ans;
}
/*
確認ポイント
to_string() はC++11以降の実装;
length(),size()に括弧をつけ忘れてないか;
*/

int main() { 
    int a,b;
    cin >> a >> b;
    cout << ((a * b) % 2 == 0 ? "No" : "Yes") << endl;
    return 0; 
} 

Measured memory_bytes: 764
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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; }


int main(){
    string s; cin >> s;
    s.replace(5, 1, " ");
    s.replace(13, 1, " ");
    cout << s << ln;
}


Measured memory_bytes: 3620
import math
#import bisect
#import numpy as np
#import itertools
#import copy
import sys
from collections import deque

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    n = int(input())
    a = [0] * 5
    for i in range(5):
        a[i] = int(input())

    city = [0] * 6
    city[0] = n

    amin = INF
    for i in range(5):
        if amin > a[i]:
           amin = a[i]
           idx = i

    ans = math.ceil(n/amin) + 4
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38576
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <limits>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <fstream>
#include <iterator>
#include <random>
#include <chrono>


#define forr(i,start,count) for (int i = (start); i < (start)+(count); ++i)
#define set_map_includes(set, elt) (set.find((elt)) != set.end())
#define readint(i) int i; cin >> i
#define readll(i) ll i; cin >> i
#define readdouble(i) double i; cin >> i
#define readstring(s) string s; cin >> s

typedef long long ll;

using namespace std;

ll modd = 1000 * 1000 * 1000 + 7;

void process(ll hordim, ll vertdim, vector<pair<int,ll>>& q, set<pair<ll,int>>& v, set<pair<ll,int>>& h, ll& ret_erased, int& i) {
    if ((hordim<=2) || (vertdim<=2)) {return;}
    while (q[i].first==0) {  ++i; if (i==q.size()) {break;}  }
    if (i==q.size()) {return;}
    if (q[i].first==1) {
        ll hh = q[i].second;
        auto it = v.find(make_pair(q[i].second, i));
        while (it!=v.end()) {
            q[it->second].first = 0;
            it = v.erase(it);
            ret_erased += vertdim-2;
        }
        ++i;
        process(hh, vertdim, q, v, h, ret_erased, i);
    } else {
        ll vv = q[i].second;
        auto it = h.find(make_pair(q[i].second, i));
        while (it!=h.end()) {
            q[it->second].first = 0;
            it = h.erase(it);
            ret_erased += hordim-2;
        }
        ++i;
        process(hordim, vv, q, v, h, ret_erased, i);
    }
}

int main()   {

      ios_base::sync_with_stdio(false);

      cout.precision(17);
      mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
      uniform_int_distribution<int> rand_gen(0, modd);   // rand_gen(rng) gets the rand no

//    readint(test_cases);
    int test_cases = 1;
    forr(t, 1, test_cases) {
        readll(n); readll(q);

        vector<pair<int,ll>> queries;
        set<pair<ll,int>> vertical;
        set<pair<ll,int>> horizontal;
        ll ret_erased = 0;
        forr(i,0,q) {
            readint(aa); readint(bb);
            if (aa==1) {
                queries.push_back(make_pair(1,bb));
                vertical.insert(make_pair(bb,queries.size()-1));
            }
            if (aa==2) {
                queries.push_back(make_pair(2,bb));
                horizontal.insert(make_pair(bb,queries.size()-1));
            }
        }
        int i = 0;
        if (q>0) {
        process(n, n, queries, vertical, horizontal, ret_erased, i); }

        cout << (n-2)*(n-2) - ret_erased << endl;

    }
    return 0;
}


Measured memory_bytes: 50060
#include<stdio.h>

int main(void)
{
	int a[5], i,b;

	b = 0;

	for (i = 0; i < 5; i++)
	{
		scanf("%d", &a[i]);

		if (a[i] < 40)
		{
			a[i] = 40;
		}

		b += a[i];
	}
	
	printf("%d\n", b / 5);

	return 0;

}

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

long long MOD = 1e9 + 7;


int main(){
    int N, M; cin >> N >> M;
    vector<bool> broken(N+1, false); 
     for (int i = 0; i < M; i++) {
        int b; cin >> b;
        broken[b] = true;
    }
 
    vector<long long > dp(N+1, 0);
    dp[0] = 1;
    dp[1] = 1;
    bool is_solvable = true;
    for (int i = 2; i <= N; ++i) {
        if (broken[i - 1] == false) dp[i] += dp[i-1];
        if (broken[i - 2] == false) dp[i] += dp[i-2];
        if (broken[i - 1] == true && broken[i - 2] == true) is_solvable = false;
        dp[i] %= MOD;
    }
 
    if (!is_solvable) cout << 0 << endl;
    else cout << dp[N] << endl;
 
    return 0;
}

Measured memory_bytes: 1024
import sys

if sys.platform == 'ios':
	sys.stdin=open('input_file.txt')
	
while True:
	H,W=map(int,input().split())
	
	if H+W==0:
		break
	for i in range(H):
		for j in range(W):
			print("#."[(i+j)%2],end="")
		print()
	print()


Measured memory_bytes: 7004
s = input()
n = len(s)

def func():
    if n == 3 and s[0] == s[2]:
        return"Yes"
    else:
        a = 0
        for i in range(n//2):
            if s[i] == s[n - 1 - i]:
                a += 1
                if a == n//2:
                    b = 0
                    for j in range((n-1)//4):
                        if s[j] == s[(n-1)//2 - 1 - j]:
                            b += 1
                            if b == (n-1)//4:
                                c = 0
                                for k in range((n - (n+3)//2 + 1)//2):
                                    if s[(n+3)//2 - 1 + k] == s[n - 1 - k]:
                                        c += 1
                                        if c == (n - (n+3)//2 + 1)//2:
                                            return "Yes"
                        else:
                            return "No"
            else:
                return "No"
        
print(func())

Measured memory_bytes: 9124
#include<bits/stdc++.h>
#define fi first
#define se second
#define LL long long
#define mp make_pair
#define pb push_back
#define pii pair<LL, LL>
using namespace std;
const int N = 1e5 + 10;

int n, m, top;
LL a[N], st[N], tr[N];
map<LL, LL, greater<LL> > Map;

void init() {
	cin >> n >> m;
	a[1] = n;
	for (int i = 2; i <= m + 1; ++i)
		scanf("%lld", &a[i]);
	st[top = 1] = a[1];
	for (int i = 2; i <= m + 1; ++i) {
		while (st[top] >= a[i] && top) --top;
		st[++top] = a[i];
	}
	m = top;
	for (int i = top; i >= 1; --i) {
		a[top - i + 1] = st[i];
	}
}

void Updata(int x, LL del) {
	for (int i = x; i <= n; i += i & -i) {
		tr[i] += del;
	}
}

LL Query(int x) {
	LL ans = 0;
	for (int i = x; i; i -= i & -i) {
		ans += tr[i];
	}
	return ans;
}

void Solve() {
	vector<pii> vec;
	map<LL,LL>::iterator it;
	Map[a[1]] = 1;
	for (int i = 2; i <= m; ++i) {
		vec.clear();
		for (it = Map.begin(); it != Map.end();) {
			if (it -> fi <= a[i]) break;
			vec.pb(mp(a[i], it -> fi / a[i] * it -> se));
			if (it -> fi % a[i])
				vec.pb(mp(it -> fi % a[i], it -> se));
			Map.erase(it++);
		}
		for (int j = 0; j < vec.size(); ++j) {
			Map[vec[j].fi] += vec[j].se;
		}
	}
	for (it = Map.begin(); it != Map.end(); ++it) {
		Updata(1, it -> se);
		Updata(it -> fi + 1, -it -> se);
	}
	for (int i = 1; i <= n; ++i) {
		LL tmp = Query(i);
		printf("%lld\n", tmp);
	}
}

int main() {
	init();
	Solve();
	return 0;
}


Measured memory_bytes: 13036
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define vi vector<ll>
#define vb vector<bool>
#define pii pair<ll,ll>
#define mod 1000000007
#define pll pair<ll,ll>
#define rep(i,n) for(ll i=0;i<n;i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per1(i,n) for(ll i=n;i>0;i--)
#define prll(a,n) for(ll i=0;i<n;i++){ cout<<a[i]<<" "; }
#define ain(a) for(auto &i:a) cin>>i
#define mms(a) memset(a,0,sizeof(a))
// cout << fixed << setprecision(0) << pi <<" "<<npi<<endl; 


ll max_ll(ll a,ll b,ll c){
	return max(a,max(b,c));
}

ll min_ll(ll a,ll b,ll c){
	return min(a,min(b,c));
}


bool sortBySec(pair<ll,ll> a,pair<ll,ll> b){
    if(a.second==b.second)
		return a.first<b.first;
    return (a.second < b.second); 
}

long long binexpmod(long long a, long long b){
    long long res =1;
    while(b>0){
        if(b&1){
            res = res * a % mod;
        }
        a = a * a % mod;
        b>>=1;
    }
    return(res);
}


ll lcm(ll a,ll b){
	ll x=__gcd(a,b);
	a/=x;
	b/=x;
	ll sum=a*b*x;
	return sum;
}
const int nix = 1005;
ll grid[nix][nix];
bool vis[nix];
ll dp[nix][nix];
int indegree[nix][nix];


ll a[2]={0,-1};
ll b[2]={-1,0};
ll H,W;
void dfs(ll x,ll y){
    if(x>H || y>W) return;
    // ll data = dp[x][y];
    rep(p,2){
        ll i = x+a[p];
        ll j = y+b[p];
        if(grid[i][j]==0) continue;
        dp[x][y] = (dp[x][y]+ dp[i][j])%mod;
    }
    // cout<<"dp["<<x<<"]["<<y<<"] "<<dp[x][y]<<" ans degree "<<indegree[x][y]<<endl;
    if(grid[x+1][y]==1 && indegree[x+1][y]<=1) {
        dfs(x+1,y);
    }
    else{
        indegree[x+1][y]--;
    }
    if(grid[x][y+1]==1 && indegree[x][y+1]<=1) {
        dfs(x,y+1);
    }
    else{
        indegree[x][y+1]--;
    }
}

void solve(){
    ll res=0;
	cin>>H>>W;
    grid[0][1]=1;
    grid[1][0]=1;
    indegree[1][1]=1;
    rep1(i,H){
        rep1(j,W){
            char c;
            cin>>c;
            if(c=='.') grid[i][j]=1;
            if(i==1 && j==1) continue;
            if(grid[i-1][j]==1) indegree[i][j] += indegree[i-1][j]>0? 1:0;
            if(grid[i][j-1]==1) indegree[i][j] += indegree[i][j-1]>0? 1:0;
        }
    }

    dp[0][1]=0;
    dp[1][0]=1;
    dfs(1,1);
	cout<<dp[H][W]<<endl;
	return;
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
	// cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 20096
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>

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

using namespace std;
typedef long long ll;

struct P {
    int w,h;

    P(int _w,int _h) {
        w = _w;
        h = _h;
    }

    bool operator<(const P& p) const {
        if(w*w + h*h == p.w*p.w + p.h*p.h) return h < p.h;
        return w*w + h*h < p.w*p.w + p.h*p.h;
    }
};

int main()
{
    vector<P> v;
    REP(i,1,151) {
        REP(j,i+1,151) {
            v.push_back(P(j,i));
        }
    }

    sort(v.begin(),v.end());
    
    int n,m;
    while(cin >> n >> m) {
        if(n == 0 && m == 0) break;
        
        rep(i,v.size()) {
            if(n == v[i].h && m == v[i].w) {
                cout << v[i+1].h << " " << v[i+1].w << endl;
                break;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 1332
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

const int MAX_V = 150000;
vector<int> es[MAX_V];
ld dp1[MAX_V], dp2[MAX_V];

ld dfs1(int now, int pre){
    dp1[now] = 0.0;
    ld cnt = 0.0;
    for(auto &e: es[now]){
        if(e == pre) continue;
        cnt += 1.0;
        dp1[now] += dfs1(e, now)+1.0;
    }
    if(cnt > EPS) dp1[now] /= cnt;
    return dp1[now];
}

void dfs2(int now, int pre){
    if(pre == -1) dp2[now] = 0.0;
    elif(pre == 0){
        ld n = sz(es[pre]);
        if(abs(n-1.0) < EPS) dp2[now] = 1.0;
        else dp2[now] = 2.0 + (dp1[pre]-dp1[now]/n-1.0)*n/(n-1);
    }
    else{
        ld n = sz(es[pre])-1;
        dp2[now] = 2.0 + (dp1[pre]-dp1[now]/n-1.0) + (dp2[pre]-1.0)/n;
    }
    for(auto &e: es[now]){
        if(e != pre) dfs2(e, now);
    }
}

int main(){
    int N;
    cin >> N;
    rep(i, N-1){
        int u, v; cin >> u >> v; u--, v--;
        es[u].pb(v), es[v].pb(u);
    }
    dfs1(0, -1), dfs2(0, -1);
    rep(i, N){
        ld ans;
        if(i == 0) ans = dp1[i];
        else{
            ld n = sz(es[i]);
            ans = ((n-1)*dp1[i]+dp2[i])/n;
        }
        cout << sp(10) << ans << endl;
    }
}

Measured memory_bytes: 23576
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

bool is753(int n){
    int ok=0;
    while(n>0){
        int a=n%10;
        if(a==3)ok|=1;
        if(a==5)ok|=2;
        if(a==7)ok|=4;
        n/=10;
    }
    return ok==7;
}

int main(){
    ll n;
    cin>>n;
    vector<ll> v,nv;
    v.push_back(3);
    v.push_back(5);
    v.push_back(7);
    int ans=0;
    rep(i,10){
        int m=v.size();
        nv.clear();
        rep(j,m){
            ll res=v[j];
            if(is753(res)&&res<=n){
                ans++;
            }
            nv.push_back(10*res+3);
            nv.push_back(10*res+5);
            nv.push_back(10*res+7);
        }
        nv.swap(v);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2884
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back
#define mm multimap<ll,ll>
#define mp make_pair
#define pii pair<ll,ll>

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
   
ll n;
cin>>n;
ll ar[n+1],dp[n+1];
dp[0]=0;ar[0]=0;
for(ll i=1;i<=n;i++)
{
    cin>>ar[i];
    
}dp[1]=0;
dp[2]=abs(ar[2]-ar[1]);
for(ll i=3;i<=n;i++)
{
    dp[i]=min(dp[i-2]+abs(ar[i-2]-ar[i]),dp[i-1]+abs(ar[i-1]-ar[i]));
    
}
cout<<dp[n];
  return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int compare(const void *a, const void *b)
{
  return *(int *)a - *(int *)b;
}

int main(int argc, char **argv)
{
  int i = 0;
  int n = 0;
  int *q = NULL;

  scanf("%d", &n);

  q = (int *)malloc(n * sizeof(int));

  for(i = 0; i < n; i++)
  {
    scanf("%d", q + i);
  }

  qsort(q, n, sizeof(int), compare);

  printf("%d\n", q[n / 2] - q[(n / 2) - 1]);

  return 0;
}


Measured memory_bytes: 892
import sys

inp = [int(x) for x in sys.stdin.read().split()]; ii = 0

class SegmentTree:
    def __init__(self, data, default=0, func=max):
        """initialize the segment tree with data"""
        self._default = default
        self._func = func
        self._len = len(data)
        self._size = _size = 1 << (self._len - 1).bit_length()

        self.data = [default] * (2 * _size)
        self.data[_size:_size + self._len] = data
        for i in reversed(range(_size)):
            self.data[i] = func(self.data[i + i], self.data[i + i + 1])

    def __delitem__(self, idx):
        self[idx] = self._default

    def __getitem__(self, idx):
        return self.data[idx + self._size]

    def __setitem__(self, idx, value):
        idx += self._size
        self.data[idx] = value
        idx >>= 1
        while idx:
            self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
            idx >>= 1

    def __len__(self):
        return self._len

    def query(self, start, stop):
        """func of data[start, stop)"""
        start += self._size
        stop += self._size

        res_left = res_right = self._default
        while start < stop:
            if start & 1:
                res_left = self._func(res_left, self.data[start])
                start += 1
            if stop & 1:
                stop -= 1
                res_right = self._func(self.data[stop], res_right)
            start >>= 1
            stop >>= 1

        return self._func(res_left, res_right)

    def __repr__(self):
        return "SegmentTree({0})".format(self.data)

shift = int(10**9 + 1)
rows, cols, k = inp[ii:ii+3]; ii += 3
items = [[] for _ in range(rows+1)]
best = [0]*(cols+1)
for _ in range(k):
	r, c, v = inp[ii:ii+3]; ii += 3
	items[r].append(c*shift+v)
for i in range(rows+1):
	items[i].sort()
S = SegmentTree(best)
ans = 0
for r in range(1, rows+1):
	dp = []
	best1, best2 = 0, 0
	Row = items[r]
	for X in Row:
		c, v = X//shift, X%shift
		v1 = S.query(1, c+1) + v
		v2 = best1 + v
		v3 = best2 + v
		V = v1
		if V < v2:
			V = v2
		if V < v3:
			V = v3
		dp.append(V)
		if v1 > best1:
			best1 = v1
		if v2 > best2:
			best2 = v2
		if ans < V:
			ans = V
	for j in range(len(dp)):
		c = Row[j]//shift
		if S[c] < dp[j]:
			S[c] = dp[j]
print(ans)


Measured memory_bytes: 127668
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 100010;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    if (n%2){
        PRINT((n-1)*(n-1)/2);
        rep(i,1,n){
            rep(j,i+1,n+1){
                if (j == n-i) continue;
                cout << i << " " << j << endl;
            }
        }
    }
    else{
        PRINT((n-2)*n/2);
        rep(i,1,n){
            rep(j,i+1,n+1){
                if (j == n+1-i) continue;
                cout << i << " " << j << endl;
            }
        }
    }
}


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

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

using P = pair<ll, ll>;

static const long long MOD = 1000000007;
static const long long LINF = (ll)(1e18+99);
static const int INF = 1e9+99;
const ll MAX = 1000005;

ll ans;
bool isprime[MAX];
vector<P> vv;



void prime_factrization(ll n) {

	for (ll i = 2; i*i<=n; i++) {
        ll c = 0;
		if (n % i == 0) {
			while (n % i == 0) {
				c++;
				n /= i;
			}
             vv.pb(mp(i,c));
		}
       
	}
	
	if (n > 1) vv.pb(mp(n, 1));
	return;
}

int main(void) {
    ll N;
    cin >> N;


      prime_factrization(N);

    for (auto x : vv) {

        ll xx = x.second;
        ll j = 1;
        while (xx-j>=0) {
            xx -= j;
            j++;
            ans++;
        }
    }

     



  
    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 3644
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		
		int n=sc.nextInt();
		int x=sc.nextInt();
		int p1,p2,p3;
		int cnt=0;
		while(n!=0 || x!=0){
			for(p1=1;p1<=n;p1++){
				for(p2=1;p2<=n;p2++){
					if(((p1+p2)>=x) ||(p1==p2)) break;
					for(p3=1;p3<=n;p3++){
						if(((p1+p2+p3)>x)||(p2==p3)){
							break;
						}else if((p1+p2+p3)==x){
							cnt++;
						}
					}//for	
				}//for
			}//for
			System.out.println(cnt);
			cnt=0;
			n=sc.nextInt();
			x=sc.nextInt();
		}//while
	}

}

Measured memory_bytes: 19740
import std.stdio;
import std.range;
import std.array;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.container;
import std.typecons;
import std.random;
import std.csv;
import std.regex;
import std.math;
import core.time;
import std.ascii;
import std.digest.sha;
import std.outbuffer;
import std.numeric;
import std.bigint;
import core.checkedint;
import core.bitop;
import std.digest.sha;

void main()
{
	int n, k;
	readln.chomp.split.tie(n, k);
	writeln = n % k != 0 ? 1 : 0;
}

void tie(R, Args...)(R arr, ref Args args)
		if (isRandomAccessRange!R || isArray!R)
in
{
	assert (arr.length == args.length);
}
body
{
	foreach (i, ref v; args) {
		alias T = typeof(v);
		v = arr[i].to!T;
	}
}

void verbose(Args...)(in Args args)
{
	stderr.write("[");
	foreach (i, ref v; args) {
		if (i) stderr.write(", ");
		stderr.write(v);
	}
	stderr.writeln("]");
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <algorithm>
#define R register
#define IN inline
#define W while
#define gc getchar()
#define MX 500500
#define ll long long
template <class T>
IN void in(T &x)
{
	x = 0; R char c = gc;
	for (; !isdigit(c); c = gc);
	for (;  isdigit(c); c = gc)
	x = (x << 1) + (x << 3) + c - 48;
}
template <class T> IN T max(T a, T b) {return a > b ? a : b;}
template <class T> IN T min(T a, T b) {return a < b ? a : b;}
template <class T> IN T abs(T a) {return a > 0 ? a : -a;}
int n, q, ini, pos;
int ans[MX], num[MX], dis[MX];
int main(void)
{
	in(n), in(ini); dis[0] = ini;
	for (R int i = 1; i <= n; ++i)
	{
		in(num[i]);
		dis[i] = min(dis[i - 1], abs(num[i] - dis[i - 1]));
	}
	ans[n + 1] = 1;
	for (R int i = n; i; --i)
	{
		if (num[i] >= ans[i + 1] * 2) ans[i] = ans[i + 1];
		else ans[i] = ans[i + 1] + num[i];
	}
	in(q);
	W (q--)
	{
		in(pos);
		puts(dis[pos - 1] < ans[pos + 1] ? "NO" : "YES");
	}
}

Measured memory_bytes: 7680
#include<iostream>
#include<string>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<queue>

using namespace std;


long long a,b,x;

int main(){
  cin>>a>>b>>x;

  if(b == 0){
    cout<<"1"<<endl;
  } else {
    if(a == 0){
      cout<<(b/x + 1)<<endl;
    } else {
      cout<<(b/x - (a-1LL)/x)<<endl;
    }
  }



  return 0;
}

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

using namespace std;
typedef long long ll;

int main(){
    int N;
    cin >> N;

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

    vector<ll> pos;
    vector<ll> neg;
    ll psum = 0;
    ll nsum = 0;
    for(int i=0;i<N;i++){
        if(A[i] > 0){
            pos.push_back(A[i]);
            psum += A[i];
        }else{
            neg.push_back(-A[i]);
            nsum -= A[i];
        }
    }
    sort(pos.begin(), pos.end());
    sort(neg.begin(), neg.end());
    int npos = pos.size();
    int nneg = neg.size();
    int nzero = N - pos.size() - neg.size();
    // cout << npos << " " << nneg << " " << nzero << endl;
    if(nzero > 0){
        cout << psum + nsum << endl;
        ll cur = 0;
        for(int i=0; i< nzero-1;i++){
            cout << "0 0" << endl;
        }
        for(int i=0;i<npos-1;i++){
            cout << cur << " " << pos[i] << endl;
            cur -= pos[i];
        }

    } else if (npos > 0 && nneg > 0) {
        cout << psum + nsum << endl;
        ll cur = 0;
        if(npos > 1){
            ll cur = -neg[0];
            for(int i=0;i<npos-1;i++){
                cout << cur << " " << pos[i] << endl;
                cur = cur - pos[i];
            }
            cout << pos[npos-1] << " " << cur << endl;
            cur = pos[npos - 1] - cur;
            for(int i=1;i<nneg;i++){
                cout << cur << " " << -neg[i] << endl;
                cur += neg[i];
            }
        } else if(npos == 1){
            ll cur = pos[0];
            for(int i=0;i<nneg; i++){
                cout << cur << " " << -neg[i] << endl;
                cur = cur + neg[i];
            }
        }
    } else {
        ll offset = 0;
        if(npos == 0){
            // all neg
            offset = 2*neg[0];
            cout << psum + nsum - offset << endl;
            ll cur = -neg[0];
            for(int i=1;i<nneg; i++){
                cout << cur << " " << -neg[i] << endl;
                cur += neg[i];
            }
        } else if (nneg == 0){
            // all pos
//            cout << "all pos " << npos << endl;
            offset = 2*pos[0];
            cout << psum + nsum - offset << endl;
            ll cur = pos[0];
            for(int i=1;i<npos-1;i++){
                cout << cur << " " << pos[i] << endl;
                cur -= pos[i];
            }
            cout << pos[npos-1] << " " << cur << endl;
        } 
    }

}


Measured memory_bytes: 3572
# AOJ ITP2_2_B: Queue
# Python3 2018.6.24 bal4u

from collections import deque
n, q = map(int, input().split())
Q = []
for i in range(n): Q.append(deque())
for i in range(q):
	a = input().split()
	t = int(a[1])
	if   a[0] == '0': Q[t].append(a[2])        # push
	elif a[0] == '1' and Q[t]: print(Q[t][0])  # front
	elif a[0] == '2' and Q[t]: Q[t].popleft()  # dequeue



Measured memory_bytes: 20828
#include <stdio.h>

int main()
{
	int i, j, k, N, L[101], count = 0;
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", &(L[i]));
	for (i = 1; i <= N - 2; i++) {
		for (j = i + 1; j <= N - 1; j++) {
			if (L[i] == L[j]) continue;
			for (k = j + 1; k <= N; k++) {
				if (L[k] != L[i] && L[k] != L[j] && L[i] + L[j] > L[k] && L[i] + L[k] > L[j] && L[j] + L[k] > L[i]) count++;
			}
		}
	}
	printf("%d\n", count);
	fflush(stdout);
	return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define ins insert

#define debug(a) cerr<<(a)<<endl
#define dbrep(a,n) rep(_i,n) cerr<<(a[_i])<<" "; cerr<<endl
#define dbrep2(a,n,m) rep(_i,n){rep(_j,m) cerr<<(a[_i][_j])<<" "; cerr<<endl;}

using namespace std;

template<class A, class B>
ostream &operator<<(ostream &os, const pair<A,B> &p){return os<<"("<<p.fi<<","<<p.se<<")";}
template<class A, class B>
istream &operator>>(istream &is, pair<A,B> &p){return is>>p.fi>>p.se;}

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin>>N;
    vll vec1,vec2;
    rep(i,N){
        ll x,y; cin>>x>>y;
        vec1.pb({x+y});
        vec2.pb({x-y});
    }
    ll s = *max_element(all(vec1))-*min_element(all(vec1));
    ll t = *max_element(all(vec2))-*min_element(all(vec2));
    cout<<max(s,t)<<endl;
    return 0;
}


Measured memory_bytes: 6696
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;

void Main() {
    // input
    string S;
    cin >> S;


    // translate


    // output
    if ((S[2] == S[3]) && (S[4] == S[5])) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
constexpr double pi=3.14159265358979;

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


void solve(){
    string s;
    cin>>s;
    string t="CODEFESTIVAL2016";
    int cnt=0;
    rep(i,s.size()){
        if(s[i]!=t[i])++cnt;
    }
    cout<<cnt<<"\n";
}

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


Measured memory_bytes: 256
using System;
using System.Linq;
 
class B
{
    static void Main()
    {
        string[] x = (Console.ReadLine()).Split(' ');
        //int X = int.Parse(Console.ReadLine());
        int A = int.Parse(x[0]);
        int B = int.Parse(x[1]);
        int C = int.Parse(x[2]);
        int K = int.Parse(Console.ReadLine());

        string result = "No";

        for (int i = 0; i <= K; i++)
        {
            if ((double)A < (double)B * Math.Pow(2.0, (double)i) 
                && (double)B * Math.Pow(2.0, (double)i) < (double)C * Math.Pow(2.0, (double)K - (double)i))
            {
                result = "Yes";
                break;
            }
            //Console.WriteLine(A.ToString());
            //Console.WriteLine(((double)B * Math.Pow(2, i)).ToString());
            //Console.WriteLine(((double)C * Math.Pow(2, K-i)).ToString());
        }

        Console.WriteLine(result);
    }
}

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

#define int long long
#define form2(i, a, b) for (int i = (a); i < (b); ++i)
#define ford2(i, a, b) for (int i = (a-1); i >= (b); --i)
#define form(i, n) form2(i, 0, n)
#define ford(i, n) ford2(i, n, 0)

#define chmax(x, v) x = max(x, (v))
#define chmin(x, v) x = min(x, (v))
#define fi first
#define se second

const long long BIG = 1000000000000000000LL;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

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

const int borne = 505;
vector<int> st;
int n, k, som;
int res = 1;

bool tester(int x)
{
	int op = 0;
	int balance = 0;
	vector<int> remonter, redescendre;
	form(i, n) {
		int bas = x*(st[i]/x);
		int haut = bas+x;
		if (abs(st[i] - bas) <= abs(st[i] - haut)) {
			op += abs(st[i] - bas);
			balance += st[i] - bas; // positif
			remonter.push_back(abs(st[i] - bas));
		} else {
			op += abs(st[i] - haut);
			balance += st[i] - haut; // négatif
			redescendre.push_back(abs(st[i] - haut));
		}
	}
	if (balance % x != 0) return false;
	sort(remonter.begin(), remonter.end());
	sort(redescendre.begin(), redescendre.end());
	while (balance > 0) { // On a trop descendu, on remonte
		op += x; balance -= x;
		if (!remonter.empty()) { op -= 2*remonter.back(); remonter.pop_back(); }
	}
	while (balance < 0) {
		op += x; balance += x;
		if (!redescendre.empty()) { op -= 2*redescendre.back(); redescendre.pop_back(); }
	}
	return (op <= 2*k);
}

void solve()
{
	cin >> n >> k; som = 0;
	st.resize(n);
	form(i, n) { cin >> st[i]; som += st[i]; }
	for (int div = 1; div*div <= som; ++div) {
		if (som % div == 0) {
			if (tester(div)) chmax(res, div);
			if (tester(som/div)) chmax(res, som/div);
		}
	}
	cout << res << "\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
int x[101][101]; vector<int>D;
int n, m, p, dp[100000];
queue<int>Q;
int main() {
	cin >> n >> m >> p;
	for (int i = 0; i < m; i++) { int r; cin >> r; D.push_back(r); }
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < p; j++)cin >> x[i][j];
	}
	for (int i = 1; i < 100000; i++)dp[i] = 998244353; Q.push(0);
	while (!Q.empty()) {
		int i = Q.front(); Q.pop();
		int bit[16]; for (int j = 0; j < m; j++)bit[j] = (i / (1 << j)) % 2;

		for (int o = 0; o < p; o++) {
			int bit2[16]; for (int k = 0; k < m; k++)bit2[k] = 1;
			for (int j = 0; j < m; j++)
			{
				if (bit[j] == 0) {
					int to = x[D[j]][o];
					for (int l = 0; l < m; l++) {
						if (D[l] == to)bit2[l] = 0;
					}
				}
			}
			int cnt = 0;
			for (int j = 0; j < m; j++)cnt += (1 << j)*bit2[j];
			if (dp[cnt] == 998244353) {
				dp[cnt] = min(dp[cnt], dp[i] + 1);
				Q.push(cnt);
			}
		}
	}
	cout << dp[(1 << m) - 1] << endl;
	return 0;
}

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

typedef struct{
	int x;
	int y;
}point;

int h, w;
char f[21][21];
point now;
int nowdir;

int dx[4]={1,0,-1,0};
int dy[4]={0,-1,0,1};
char car[5]=">^<v";

void move(char c){
	//????????¢???
	if(c=='R') nowdir=0;
	else if(c=='U') nowdir=1;
	else if(c=='L') nowdir=2;
	else if(c=='D') nowdir=3;
	f[now.y][now.x]=car[nowdir];
	
	//?¬????????????´???
	int nx=now.x+dx[nowdir];
	int ny=now.y+dy[nowdir];
	
	//?§?????????????????§????
	if(0<=nx && nx<w && 0<=ny && ny<h && f[ny][nx]=='.'){
		f[ny][nx]=car[nowdir];
		f[now.y][now.x]='.';
		now.x=nx;
		now.y=ny;
	}
}

void printField(){
	for(int i=0; i<h; ++i){
		for(int j=0; j<w; ++j){
			printf("%c", f[i][j]);
		}
		printf("\n");
	}	
}

void shoot(){
	int t=1; //???????????????

	while(1){
		int px=t*dx[nowdir]+now.x;	
		int py=t*dy[nowdir]+now.y;
		
		if(px<0 || w<=px || py<0 || h<=py) break;
		
		if(f[py][px]=='*'){
			f[py][px]='.';
			break;	
		}
		else if(f[py][px]=='#') break;	
			
		t++;			
	}
}

int main(){	
	int times;
	cin >> times;
	for(int t=0; t<times; ++t){
		if(t!=0) printf("\n");
		
		scanf(" %d %d", &h, &w);
		
		for(int i=0; i<h; ++i){
			for(int j=0; j<w; ++j){
				scanf(" %c", &f[i][j]);
				
				for(int k=0; k<4; ++k){
					if(f[i][j]==car[k]){	
						nowdir=k;
						now.x=j;
						now.y=i;		
					}
				}
			}
		}
		
		int n;
		string order;
		scanf(" %d", &n);
		cin >> order;
		
		for(int i=0; i<n; ++i){
			if(order[i]=='S') shoot();
			else move(order[i]);
			/*
			printf("nowdir=%d\n", nowdir);
			printField();
			printf("\n");
			*/
		}
		
		printField();
	
	}
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pld pair<long double, int>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define ff first
#define ss second
#define SZ(x) ((int)(x).size())
#define ld long double
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int K;

void read(){
    cin >> K;
}

void solve(){
    read();
    while(K--){
        cout << "ACL";
    }
}

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


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int dp[210][10010];
int main(){
    int M = 1000000007;
    while (true) {
        int n, ww, w[210];
        cin >> n >> ww;
        if (!n) break;
        
        for (int i = 0; i < n; ++i) {
            cin >> w[i];
        }
        sort(w, w + n);
        if (w[0] > ww) {
            cout << "1\n";
            return 0;
        }
        
        dp[n][0] = 1;
        for (int i = n - 1; i >= 0; --i) {
            for (int j = 0; j < w[i]; ++j) {
                dp[i][j] = dp[i + 1][j];
            }
            for (int j = w[i]; j <= ww; ++j) {
                dp[i][j] = (dp[i + 1][j] + dp[i + 1][j - w[i]]) % M;
            }
        }
        
        int pre = 0, sum = 0;
        long long ans = 0;
        for (int i = 0; i < n; ++i) {
            if (pre == w[i]){
                sum += w[i];
                continue;
            }
            if (sum > ww) break;
            
            for (int j = max(0, ww - w[i] + 1 - sum); j < ww - pre + 1 - sum; ++j) {
                ans = (ans + dp[i][j]) % M;
            }
            sum += w[i];
            pre = w[i];
        }
        cout << ans << "\n";
        
        return 0;
    }
    return 0;
}

Measured memory_bytes: 10916
N,K,Q = map(int, raw_input().split())
P = [K]*N
for i in range(Q):
    A = int(raw_input())
    P[A-1] += 1
    
P = [p-Q for p in P]

for p in P:
    if p > 0:
        print "Yes"
    else:
        print "No"

Measured memory_bytes: 36200
def run(a, b):
    if a > 8 or b > 8:
        return ':('
    else:
        return 'Yay!'


def read_line():
    a, b = input().split()
    a = int(a)
    b = int(b)
    return (a, b)


def main():
    a, b = read_line()
    print(run(a, b))


if __name__ == '__main__':
    main()


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

int main(void) {
    int N;
    cin >> N;
    vector<vector<bool>> F(N, vector<bool>(10));
    vector<vector<long long>> P(N, vector<long long>(11));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 10; j++) {
            int f;
            cin >> f;
            F[i][j] = f;
        }
    }
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 11; j++) {
            cin >> P[i][j];
        }
    }

    long long ans = LLONG_MIN;
    for (int bit = 1; bit < (1 << 10); bit++) {
        long long tmp = 0;
        for (int i = 0; i < N; i++) {
            int cnt = 0;
            for (int j = 0; j < 10; j++) {
                if (bit & (1 << j) && F[i][j]) {
                    cnt++;
                }
            }
            tmp += P[i][cnt];
        }
        ans = max(tmp, ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long int
 
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair
#define xx first
#define yy second
 
#define pii pair <int, int >
#define pll pair < ll, ll >
#define xx first
#define yy second
#define vi vector < int >
#define vl vector < ll >
#define vp vector < pii >
 
#define inf  100000000
 
#define f(i, c, n) for(int i = c; i < n; i++)
#define fe(i, c, n) for(int i = c; i <= n; i++)
#define fr(i, n, c) for(int i = n - 1; i >= c; i--)
 
#define be(a) a.begin(), a.end()
#define vsort(a) sort(a.begin(), a.end())
#define mem(a) memset(a, 0, sizeof(a))
#define memn(a) memset(a, -1, sizeof(a))
#define srti(a, n) sort(a, a + n)
#define srtd(a, n) sort(a, a + n, greater<int>())
#define LB(a, x) (lower_bound(vbe(a), x) - a.begin())
#define UB(a, x) (upper_bound(vbe(a), x) - a.begin())
#define S " "
#define N "\n"

//cout << "Case " << ++cs << ": " <<
#define fast ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define FILE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);


void solve() {
	int a, b;
	cin >> a >> b;
	a = a * b;
	if(a % 2) {
		cout << "Odd" << N;
	} else {
		cout << "Even" << N;
	}
}

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

Measured memory_bytes: 3528
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
//MACROS
#define _crt_secure_no_warnings
#define FREEELO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mp make_pair
#define INF 0x3F3F3F3F
#define MAX 200001
#define MOD 1000000007
#define ALPHABET 128
#define loop(i, n) for (int i = 1; i <= (n); i++)
#define loop0(i, n) for (int i = 0; i < (n); i++)
#define sz(x) (int)x.size()
#define all(v) v.begin(), v.end()
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll, ll> llll;
typedef pair<int, int> ii;
typedef unordered_map<int, int> umii;
typedef unordered_map<ll, ll> umll;
typedef unordered_set<int> usi;
typedef unordered_multiset<int> usmi;

int main(){
    FREEELO
    int n; cin >> n;
    ll prev = 0, ans = 0;
    loop(i, n) {
        ll val; cin >> val;
        if (val < prev) ans += (prev - val), val = prev;
        prev = val;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3144
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>

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

using namespace std;

int main()
{
	string s,s2;
	
	while(cin >> s >> s2)
	{
		if(s == "0" && s2 == "0") break;

		map<char,int> m;
		bool flag[4];
		int hit = 0,b = 0;
		rep(i,4)
		{
			if(s[i] == s2[i]) 
			{
				hit++;
				flag[i] = true;
			}
			else 
			{
				m[s[i]]++;
				flag[i] = false;
			}
		}

		rep(i,4)
		{
			if(!flag[i] && m[s2[i]] > 0)
			{
				b++;
			}
		}

		cout <<  hit << " " << b << endl;

	}
}

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

using namespace std;
typedef long long ll;
#define rep(i, n, s) for (int i = s; i < (int)(n); i++)

ll calcNumOfCombination(ll n, ll r) {
    ll num = 1;
    for (ll i = 1; i <= r; i++) {
        num = num * (n - i + 1) / i;
    }
    return num;
}

int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }

int sdig(int s) {
    int num = 0;
    int temp = 0;
    while (s) {
        temp = s % 10;
        num += temp;
        s = s / 10;
    }
    return num;
}

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    int ans = 0;
    int temp = 0;

    for (int i = 1; i <= n; i++) {
        temp = sdig(i);
        if (temp >= a && temp <= b) {
            ans += i;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
/*==============================================*\
Codeforces ID:    mdshihab
                                                  |
Name:     Md. Shihabul Minhaz                     |
Study:      CSE, JKKNIU                           |
Address:  Trishal, Mymensingh, Bangladesh         |
                                                  |
 mail:   mdshihabul20171@gmail.com                |
 FB  :   fb.com/mdshihabul.minhaz.7               |
 github: Shihabulminhaz                           |
stopstalk :  mdshihab                             |
                                                  |
@uthor   Md. Shihabul Minhaz (shihab)             |
\*===============================================*/


#include<bits/stdc++.h>
using namespace std;
#define fi(a) scanf("%d",&a);
#define fli(a) scanf("%ld",&a);
#define fll(a) scanf("%lld",&a);
#define pi(a) printf("%d\n",a);
#define ppi(i,a) printf("Case %d: %d\n",i,a);
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int shihab;
void FI()
{
#ifndef ONLINE_JUDGE
    freopen("C:\\Users\\SHIHAB\\Desktop\\input.in","r",stdin);
#endif // ONLINE_JUDGE
}

int main()
{
    fast
 //   FI(); /// skip this line for compile
    ll n,a,sum=0,mx;
    cin >> n;
    if(n==1)
    {
        cin >> a;
        cout << 0 << endl;
    }
    else
    {
        cin >> a;
        mx = a;
        for(int i=1; i<n; i++)
        {
            cin >> a;
            if(a<mx){
                sum+= (mx-a);
                mx = a + (mx-a);
            }
            else mx = a;
        }
        cout << sum << endl;
    }
    return 0;
    //code end
}
//okbye


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

using namespace std;

int main() {
	int n, m; scanf("%d %d", &n, &m);
	vector<vector<int>> graph(n);
	for (int i = 0; i < m; ++i) {
		int a, b; scanf("%d %d", &a, &b);
		--a; --b;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
	vector<int> onPath(n, false);
	onPath[0] = true;
	deque<int> path{0};
	while (true) {
		bool covered = true;
		for (int next : graph[path.front()]) {
			if (!onPath[next]) {
				// printf("%d not cov from %d\n", next, path.front());
				covered = false;
				path.push_front(next);
				onPath[next] = true;
				break;
			}
		}
		if (covered) break;
	}
	while (true) {
		bool covered = true;
		for (int next : graph[path.back()]) {
			if (!onPath[next]) {
				covered = false;
				path.push_back(next);
				onPath[next] = true;
				break;
			}
		}
		if (covered) break;
	}
	printf("%lu\n", path.size());
	for (int x : path) printf("%d ", x + 1);
	printf("\n");
	return 0;
}

Measured memory_bytes: 7040