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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main()
{
    int h,w,k; cin >> h >> w >> k;
    vector<string> masu(h);
    rep(i,h)
    {
        cin >> masu[i];
    }
    vector<int> gyou_kuro(h, 0);
    vector<int> retsu_kuro(w, 0);
    int goukei = 0;
    rep(i,h)
    {
        int counter = 0;
        rep(j,w)
        {
            if(masu[i][j]=='#')counter++;
        }
        goukei += counter;
        gyou_kuro[i] = counter;
    }
    rep(i, w)
    {
        int counter = 0;
        rep(j, h)
        {
            if (masu[j][i] == '#')counter++;
        }
        retsu_kuro[i] = counter;
    }
    ll ans = 0;
    rep(i,1 << h)
    {
        
        rep(j, 1 << w)
        {
            int hiku = 0;
            vector<int> r;
            vector<int> g;
            rep(l, h)
            {
                if (i & (1 << l))
                {
                    g.push_back(l);
                    hiku += gyou_kuro[l];
                }
            }
            rep(m, w)
            {
                if (j & (1 << m))
                {
                    r.push_back(m);
                    hiku += retsu_kuro[m];
                }
            }
            for (auto &&n : g)
            {
                for (auto &&o : r)
                {
                    if(masu[n][o]=='#')hiku--;
                }
                
            }
            if (goukei - hiku == k)
            {
                ans++;
            }
        }
        
        
    }
    cout << ans << endl;
}

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

namespace ConsoleApp61 {
    class Program {
        static void Main(string[] args) {
            int N = int.Parse(Console.ReadLine());

            var L = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int sum = L.Sum();
            
            if (L.Max() < sum - L.Max()) {
                Console.WriteLine("Yes");
            } else {
                Console.WriteLine("No");
            }

        }
    }
}


Measured memory_bytes: 13396
# -*- coding: utf-8 -*-
from collections import Counter, defaultdict


import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(H, W, M, HW):
    g = defaultdict(dict)
    for h, w in HW:
        g[h][w] = 1
    h = Counter(h for h, w in HW)
    w = Counter(w for h, w in HW)
    h = list(h.items())
    h.sort(reverse=True, key=lambda x: x[1])
    w = list(w.items())
    w.sort(reverse=True, key=lambda x: x[1])

    ans = 0
    mh = h[0][1]
    mw = w[0][1]
    for k, v in h:
        if v != mh:
            break
        for kk, vv in w:
            if vv != mw:
                break
            if k in g and kk in g[k]:
                ans = max(ans, v + vv - 1)
            else:
                return v + vv

    return ans


def main():
    H, W, M = read_int_n()
    HW = [read_int_n() for _ in range(M)]
    print(slv(H, W, M, HW))


if __name__ == '__main__':
    main()


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

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define mp make_pair
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define MOD 1000000007

char str[202020],DM[202020];
int dr[202020],ch[202020];
int n,m;

bool left(int p){
  for(int i = 0; i < m; i++){
    if(str[p]-'A' == ch[i]){
      p+=dr[i];
      if(p<0) return true;
      if(p>=n) return false;
    }
  }
  return false;
}

bool right(int p){
  for(int i = 0; i < m; i++){
    if(str[p]-'A' == ch[i]){
      p+=dr[i];
      if(p<0) return false;
      if(p>=n) return true;
    }
  }
  return false;
}

int main(){
  scanf("%d %d",&n,&m);
  scanf("%s",&str);
  for(int i = 0;i < m; i++){
    scanf("%s",&DM);
    ch[i] = DM[0]-'A';
    scanf("%s",&DM);
    if(DM[0] == 'L') dr[i] = -1;
    else dr[i] = 1;
  }

  int ret = n;
  int l = -1,r = n;
  while(r-l>1){
    int d = (l+r)/2;
    if(left(d)) l = d;
    else r = d;
  }
  ret -= r;
  l = -1,r = n;
  while(r-l>1){
    int d = (l+r) / 2;
    if(right(d)) r = d;
    else l = d;
  }
  ret -= n-r;
  printf("%d\n",ret);
  return 0;
}

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

int main(){
    ll n,k;
    cin>>n>>k;
    vector<ll> h(n);
    rep(i,n) cin>>h[i];
    sort(all(h));
    ll sum=0;
    rep(i,n-k) sum+=h[i];
    cout<<sum<<endl;
    return 0;
}

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

using P = pair<int, int>;

struct edge {
    int to, weight;
};

constexpr int INF = 1e9;

int main() {
    int N, M, K;
    cin >> N >> M >> K;
    vector<vector<edge>> g(N);
    for(int i=0; i<M; ++i) {
        int a, b, l;
        cin >> a >> b >> l;
        a--; b--;
        g[a].push_back((edge){b, l});
        g[b].push_back((edge){a, l});
    }

    priority_queue<P, vector<P>, greater<P>> que;
    vector<int> d(N, INF);
    for(int i=0; i<K; ++i) {
        int s;
        cin >> s;
        s--;
        que.push(make_pair(0, s));
        d[s] = 0;
    }

    while(!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if(d[v] < p.first) {
            continue;
        }
        for(auto& e : g[v]) {
            if(d[e.to] > d[v] + e.weight) {
                d[e.to] = d[v] + e.weight;
                que.push(make_pair(d[e.to], e.to));
            }
        }
    }

    double res = 0;
    for(int i=0; i<N; ++i) {
        res = max(res, (double)d[i]);
        for(int j=0; j<g[i].size(); ++j) {
            res = max(res, (d[i] + d[g[i][j].to] + g[i][j].weight) / 2.0);
        }
    }
    cout << (int)floor(res + 0.5) << endl;
}

Measured memory_bytes: 6000
#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 100005
#define F first
#define S second
using namespace std;

typedef long long ll;
#define PI pair<ll, ll>
ll n, cnt, k, sz, mx, g, g2, s[N], c[N];
bool v[N];
pair<ll, ll> a[N], b[N];
void f(ll p, ll q) {
	s[p] += q;
	if (q == 1 && s[p] == 1) cnt++;
	else if (q == -1 && s[p] == 0) cnt--;
}
int main()
{
	ll i, j;
	cin >> n >> k;
	for (i = 0; i < n; i++) {
		scanf ("%lld %lld", &a[i].S, &a[i].F);
	}
	sort(a, a + n);
	for (i = n - 1; i >= n - k; i--) {
		b[sz] = PI(a[i].F, a[i].S);
		g += a[i].F;
		if (s[a[i].S] == 0) v[sz] = 1;
		sz++;
		f(a[i].S, 1);
	}
	g += cnt * cnt;
	mx = g;
	j = sz - 1;
	for (i = n - k - 1; i >= 0; i--) {
		if (s[a[i].S] >= 1) continue;
		for (; j >= 0; j--) {
			if (v[j]) continue;
			g = g - b[j].F + a[i].F + (cnt + 1) * (cnt + 1) - cnt * cnt;
			f(b[j].S, -1);
			f(a[i].S, 1);
			b[j] = a[i];
			mx = max(mx, g);
			break;
		}
		j--;
	}
    cout << mx;
    return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#define mkp(a,b) make_pair(a, b)
#define pi pair < int , int >
#define N 100005

using namespace std;

int n;
int fa[N];

set < int > s[N];
map < pi, int> p;
queue < pi > Q;

int find(int);
int read();

int main(){
	n = read();
	for(int i = 3; i <= (n << 1); ++i){
		int u = read(), v = read();
		++p[mkp(u, v)];++p[mkp(v, u)];
		s[u].insert(v);s[v].insert(u);
		if(p[mkp(u, v)] == 2) Q.push(mkp(u, v));
	}
	for(int i = 1; i <= n; ++i)
		fa[i] = i;
	while(!Q.empty()){
		int u = Q.front().first, v = Q.front().second; Q.pop();
		u = find(u), v = find(v);
		s[u].erase(v);s[v].erase(u);
		if(s[u].size() > s[v].size()) swap(u, v);
		set < int > :: iterator it;
		it = s[u].begin();v = find(v);
		while(it != s[u].end()){
			int to = *it;
			p[mkp(to, u)] = p[mkp(u, to)] = 0;
			s[v].insert(to);s[to].erase(u);s[to].insert(v);
			++p[mkp(v, to)];++p[mkp(to, v)];
			if(p[mkp(v, to)] == 2) Q.push(mkp(to, v));
			++it;
		}
		s[u].clear();fa[u] = v;
	}
	int cnt = 0;
	for(int i = 1; i <= n; ++i) cnt += (fa[i] == i);
	if(cnt == 1) puts("YES");
	else puts("NO");
	return 0;
}

int read(){
	int x = 0;char ch = getchar();
	while(!isdigit(ch)) ch = getchar();
	while(isdigit(ch)) x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
	return x;
}

int find(int x){
	if(fa[x] == x) return x;
	return fa[x] = find(fa[x]);
}

Measured memory_bytes: 56192
#include <stdio.h>

int SIZEMAX = 100;

int main (void) {
  int  i, j, n, m, a[SIZEMAX][SIZEMAX], b[SIZEMAX], ans[SIZEMAX]; /* n: 縦 m:横(ベクトルの長さ) */
  scanf("%d %d\n", &n, &m);
  for (i = 0; i < n; i++){
    for (j = 0; j < m; j++){
      scanf("%d", &a[i][j]);
    }
  }
  for (j = 0; j < m; j++){
    scanf("%d\n", &b[j]);
  }
  for (j = 0; j < m; j++){
    *(ans + j) = 0;
  }
  for (j = 0; j < m; j++){
    for (i = 0; i < n; i++){
      *(ans + i) += a[i][j] * b[j];
    }
  }
  for (i = 0; i < n; i++){
    printf("%d\n", *(ans+i));
  }
  return 0;
}



Measured memory_bytes: 2112
n = int(input())

c = []
s = []
f = []

for i in range(n-1):
    p, q, r = map(int, input().split())
    c.append(p)
    s.append(q)
    f.append(r)

for i in range(n-1):
    ans = s[i]+c[i]
    for j in range(i+1, n-1):
        if ans <= s[j]:
            ans = s[j]+c[j]
        else:
            ans += (f[j]-ans%f[j])%f[j] + c[j]
    print(ans)
print(0)



Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	int N, K;
	cin >> N >> K;
	string s;
	cin >> s;

	int cnt = 0;
	for (int i = 0; i + 1 < s.size(); ++i) {
		if (s[i] == s[i + 1]) { ++cnt; }
	}

	int ans = min(cnt + 2*K, N - 1);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N;
        public long MOD = 1000000007;
        public string S;

        public void Run()
        {
            S = Console.ReadLine();
            N = S.Length;

            if (S[0] == '0' || S[S.Length - 1] == '1')
            {
                Console.WriteLine(-1);
                return;
            }

            for (int i = 0; i < N - 1; i++)
            {
                if (S[i] != S[N - 2 - i])
                {
                    Console.WriteLine(-1);
                    return;
                }
            }

            int x = 1;
            for (int i = 0; i < N - 1; i++)
            {
                if (S[i] == '1')
                {
                    Console.WriteLine("{0} {1}", x, i + 2);
                    x = i + 2;
                }
                else
                {
                    Console.WriteLine("{0} {1}", x, i + 2);
                }
            }
        }
    }

    // libs ----------
    

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 18636
#include <stdio.h>
#include <math.h>
#define N 1000001

int c[N] = {0}, p[100001], pc = 0;
char f[N];

int read()
{
	char c;
	while((c = getchar()) < 48 || c > 57);
	int x = c - 48;
	while((c = getchar()) > 47 && c < 58) x = x * 10 + c - 48;
	return x;
}

int main()
{		
	int n, i, x, m = 0, j, k, cs, ct;
		
	n = read();
	for(i = 0; i < n; i++){
		c[x = read()]++;
		if(x > m) m = x;
	}
	for(f[0] = f[1] = 1, i = 2; i <= m; i++) f[i] = 0;
	for(i = 2, k = sqrt(m); i <= k; i++){
		if(f[i]) continue;
		for(j = i * i; j <= m; j += i) f[j] = 1;
	}
	for(i = 2; i <= m; i++){
		if(!f[i]) p[pc++] = i;
	}
	
	for(i = ct = 0; i < pc; i++){
		x = p[i];
		for(cs = 0, j = x; j <= m; j += x) cs += c[j];
		if(cs == n) break;
		if(cs <= 1) ct++;
	}
	if(i < pc) puts("not coprime");
	else if(ct == pc) puts("pairwise coprime");
	else puts("setwise coprime");
				
	return 0;
}

Measured memory_bytes: 7100
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <cmath>

using namespace std;

int main() {
    float A, T;
    int B;
    cin >> A >> B >> T;

    int ans = (int)((T+0.5) / A) * B;

    cout << ans << endl;

    return 0;
}


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

int main(){
	int n;
	cin >> n;
	int f[110][10];
	for (int i = 0;i < n;i++) {
		for (int j = 0;j < 10;j++) {
			cin >> f[i][j];
		}
	}
	int p[110][11];
	for (int i = 0;i < n;i++) {
		for (int j = 0;j <= 10;j++) {
			cin >> p[i][j];
		}
	}

	int ans = -1e9;
	for (int i = 1;i <= 10;i++) {
		vector<int>v;
		for (int j = 0;j < 10 - i;j++) {
			v.push_back(0);
		}
		for (int j = 0;j < i;j++) {
			v.push_back(1);
		}
		do {
			int sum = 0;
			for (int j = 0;j < n;j++) {
				int count = 0;
				for (int k = 0;k < 10;k++) {
					if (v[k] && f[j][k]) {
						count++;
					}
				}
				sum += p[j][count];
			}
			ans = max(ans, sum);
		} while (next_permutation(v.begin(), v.end()));
	}
	cout << ans << endl;

	return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

bool DEBUG = 0;
template<class T> void dprint(T s){
  if(DEBUG){ cout << s << "\n"; }
}


class BIT{
  ll size;
  vector<ll> bit;

  public:
    BIT(ll size):size(size),bit(size+1,0){}

  
    void add(ll i,ll x){
      if(i==0){ return;}
      for(ll k=i;k<=size;k+=(k & -k)){
        bit[k] += x;
      }
    }

    ll sum(ll i){
      ll s = 0;
      if(i==0){ return s;}
      for(ll k=i;k>0;k-=(k & -k)){
        s += bit[k];
      }
      return s;
    }

    ll sum(ll i, ll j){
      return sum(j-1) - sum(i-1);
    }
};



int main(int argc, char *argv[]){
  if(argc>1 && argv[1][0]=='D'){ DEBUG = 1;}

  ll N; cin>>N;
  ll a[N]; CINA(a,N);
  ll b[N];
  ll cumu[N];
  ll low = 0LL;
  ll high = MOD;
  ll x = N+1;
  while(high-low>1){
    ll mid = (high+low)/2;
    dprint(mid);
    ll num = 0LL;
    BIT bit(N*2+10);
    ll sum = 0LL;
    bit.add(sum+x,1);
    REP(i,N){
      int v;
      if(a[i]<mid){ v=1;}
      else{ v= -1;}
      sum += v;
      num += bit.sum(1,sum+x);
      bit.add(sum+x,1);
    }

    if(num > (N+1)*N/2/2){
      high = mid;
    }else{
      low = mid;
    }
  }
  cout << low << "\n";
}

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

using namespace std;

#define pb push_back
#define SZ(x) int(x.size())
typedef long long LL;
typedef unsigned long long ULL;

const LL mod=1e9+7;
const double PI=acos(-1);
const double EPS=1e-6;
const int INF=0x3f3f3f3f;
inline int readint(){int sum=0;char c=getchar();bool f=0;while(c<'0'||c>'9'){if(c=='-') f=1;c=getchar();}while(c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}if(f) return -sum;return sum;}
inline LL readLL(){LL sum=0;char c=getchar();bool f=0;while(c<'0'||c>'9'){if(c=='-') f=1;c=getchar();}while(c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}if(f) return -sum;return sum;}

int s[4]={1,2,4,8};
LL a[4],b[4];
LL mians;

void dfs(LL left,int i,LL ret){
    if(!left){
        mians=min(mians,ret);
        return;
    }
    for(int j=i;j>=0;j--){
        if(left<s[j]) continue;
        dfs(left-s[j],j,ret+a[j]);
    }
}

int main(){//ios_base::sync_with_stdio(0);cin.tie(0);
    for(int i=0;i<4;i++) a[i]=readLL();
    int n=readint();
    b[0]=a[0]*8;b[1]=a[1]*4;b[2]=a[2]*2;b[3]=a[3];
    sort(b,b+4);
    LL t=(n-2)/2;
    if(t<0) t=0;
    LL ans=t*b[0];
    n=n-t*2;
    n=n*4;
    mians=INF;
    dfs(n,3,0);
    ans+=mians;
    printf("%lld\n",ans);
    return 0;
}

//cout.setf(ios::fixed);
//cout<<fixed<<setprecision(10)<<s<<endl;


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

L = ii()

print((L/3)**3)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1<<30;
  
int main(){
  int n;ll k;cin>>n>>k;
  map<int, ll> mp;
  for(int i=0;i<n;i++){
  	int a;ll b;cin>>a>>b;
    mp[a] += b;
  }
  ll count=0;int ans;
  for(auto itr=mp.begin();itr!=mp.end();itr++){
  	count += itr->second;
    // cout<< itr->first << ": " << itr->second << endl;
    if(k<=count){ans=itr->first;break;}
  }
  cout << ans<< endl;
}


Measured memory_bytes: 4224
def resolve():
    import sys
    input = sys.stdin.readline
    
    H, N = map(int, input().split())

    INF = 1001001001
    dp = [INF]*(H+1)

    dp[0] = 0
    for i in range(N):
        a, b = map(int, input().split())
        for j in range(H):
            nj = min(j+a, H)
            dp[nj] = min(dp[nj], dp[j] + b)

    print(dp[H])


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 40176
#include<bits/stdc++.h>
using namespace std;
#define int long long
struct segt
{
	int l,r,maxv;
}tree[2400010];
int a[300010],dp[300010];
void build(int le,int ri,int i)
{
	tree[i].l=le;
	tree[i].r=ri;
	tree[i].maxv=0;
	if(le==ri)
		return;
	int mid=(le+ri)>>1;
	build(le,mid,i<<1);
	build(mid+1,ri,i<<1|1);
}
void change(int p,int x,int i)
{
	if(tree[i].l==tree[i].r)
	{
		tree[i].maxv=max(tree[i].maxv,x);
		return;
	}
	if(tree[i<<1].r>=p)
		change(p,x,i<<1);
	else
		change(p,x,i<<1|1);
	tree[i].maxv=max(tree[i<<1].maxv,tree[i<<1|1].maxv);
}
int ask(int le,int ri,int i)
{
	if(le<=tree[i].l&&tree[i].r<=ri)
		return tree[i].maxv;
	int cnt=0;
	if(tree[i<<1].r>=le)
		cnt=ask(le,ri,i<<1);
	if(tree[i<<1|1].l<=ri)
		cnt=max(cnt,ask(le,ri,i<<1|1));
	return cnt;
}
signed main()
{
	int n,k,i,ans=1;
	cin>>n>>k;
	for(i=1;i<=n;i++)
		cin>>a[i];
	build(1,300002,1);
	//dp[1]=1;
	//change(2,1,1);
	for(i=1;i<=n;i++)
	{
		dp[i]=max(1ll,ask(max(0ll,a[i]-k)+1,min(300000ll,a[i]+k)+1,1)+1);
		change(a[i]+1,dp[i],1);
		ans=max(ans,dp[i]);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 32896
#include <iostream>
#define MAX 1000000

using namespace std;

bool prime[MAX];

void isPrime(void){

  fill( prime, prime + MAX , true );
  prime[0] = prime[1] = false;

  for( int i = 2 ; i*i < MAX ; i++ ){
    if( prime[i] ){
      for( int j = 2*i ; j < MAX ; j += i ){
	prime[j] = false;
      }
    }
  }

}

int main(void){

  isPrime();

  int x,y;
  while( cin >> x >> y , x || y ){
    int a,b;
    for( int i = x ; i >= 2 ; i-- ){
      if( prime[i] && x % i == 0 ){
	a = i;
	for( int j = i - 1 ; j >= 2 ; j-- ){
	  if( prime[j] && x % j == 0 ){
	    a -= j;
	  }
	}
	break;
      }
    }
    for( int i = y ; y >= 2 ; i-- ){
      if( prime[i] && y % i == 0 ){
	b = i;
	for( int j = i - 1 ; j >= 2 ; j-- ){
	  if( prime[j] && y % j == 0 ){
	    b -= j;
	  }
	}
	break;
      }
    }
    if( a < b ) cout << "b" << endl;
    else cout << "a" << endl;
  }
  return 0;
}

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

using namespace std;

long long inf=1000000007;

int main(){
	long long n;
	cin>>n;
	string s="";

	while(n>0){
		char hoge='a'+n%26-1;
		if(hoge=='`'){
			hoge='z';
			n--;
		}
		s.push_back(hoge);
		if(n<=26) break;

		n/=26;
	}

	reverse(s.begin(),s.end());
	cout<<s<<endl;

	return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D;

  cin >> A >> B >> C >> D;
 
  if ( (A + B) > ( C + D ) ) {
    cout << "Left" << endl;
  }
  else if ( (A + B) == ( C + D ) ) {
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }    
}

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

int main()
{

    string s;
    cin>>s;

    int q;
    cin>>q;

    for(int i=0;i<q;i++){
        string command;
        cin>>command;

        if(command=="replace"){
            int wk1,wk2;
            cin>>wk1>>wk2;
            string swk;
            cin>>swk;
            s.replace(wk1,wk2-wk1+1,swk);
        }
        else if(command=="reverse"){
            int wk1,wk2;
            cin>>wk1>>wk2;
            reverse(s.begin()+wk1,s.begin()+wk2+1);
        }
        else if(command=="print"){
            int wk1,wk2;
            cin>>wk1>>wk2;
            string swk;
            swk=s.substr(wk1,wk2-wk1+1);
            cout<<swk<<endl;
        }
    }

    return 0;
}  


Measured memory_bytes: 3236
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
using namespace std;
using ll = long long;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int cnt=0;
  rep(i,n){
    if (a[i]==i+1) continue;
    else if ((a[a[i]-1] ==i+1)&&(cnt==0)){
      a[a[i]-1]=a[i];
      a[i]=i+1;
      cnt +=1;
    }
    else {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }





int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
   
    
    int N, M;
    cin >> N >> M;
    
    vector<vector<pii> > v(N);
    rep(i, M) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        v[a].eb(pii{b, -c});
    }
    
    queue<pair<int, ll> > q;
    q.push(pii{0, 0});
    
    ll table[1001];
    const ll INF = 1e18;
    fill_n(table, 1001, INF);
    table[0] = 0;
    
    rep(i, 2 * N + 7) { // N小さいと2 * Nでは...
        
        rep(from, N) {
            if (table[from] == INF) continue;
            
            if (sz(q) == 0) break;
            int now = q.front().F;
            ll cost = q.front().S;
            q.pop();
            
            for (pii nxt : v[now]) {
                if (table[nxt.F] <= cost + nxt.S) continue;
                table[nxt.F] = cost + nxt.S;
                if (i > N) {
                    table[nxt.F] = -INF;
                    if (i == N - 1) { out("inf"); return 0; }
                }
                q.push({nxt.F, table[nxt.F]});
            }
        }
    
    }
    
    if (table[N - 1] <= -INF) out("inf");
    else out(-table[N - 1]);
}




Measured memory_bytes: 768
import sys

n = sys.stdin.readline()
l = list(map(int, sys.stdin.readline().split()))
tmp = 1000000000000000000

if 0 in l:
    print(0)
else:
    ans = 1
    for i in l:
        ans *= i
        if 1000000000000000000 < ans:
            break
    if ans <= 1000000000000000000:
        print(ans)
    else:
        print(-1)


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

int main() {
  int N;
  cin >> N;
  vector<int> ds(N);
  for(int i = 0; i < N; ++i) {
    cin >> ds[i];
  }
  sort(ds.begin(), ds.end());
  int prev = -1;
  int ans = 0;
  for(auto d : ds) {
    if(prev != d) {
      ans++;
    }
    prev = d;
  }
  cout << ans << endl;
  return 0;
}

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

int main()
{
    ll n, m, ans = -1;
    cin >> n >> m;
    vector<ll> a(m);
    for (int i = 0; i < m; i++)
    {
        cin >> a.at(i);
    }
    ll sum = 0;
    for (int i = 0; i < m; i++)
    {
        sum += a.at(i);
    }

    if (n >= sum)
    {
        ans = n - sum;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int n,r;
int main()
{
    ios::sync_with_stdio(false);
    cin>>n>>r;
    if(n>=10)
    cout<<r<<endl;
    else 
    cout<<(100*(10-n)+r)<<endl;
    return 0;
}

Measured memory_bytes: 256
#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;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define endl '\n'

int const N = 3001;
long long n, m, k, a[N][N], dp[N][N][4];

long long solve(int i, int j, int cnt){
    long long * cur = &dp[i][j][cnt];
    if (*cur != -1) return *cur;
    if (i == n && j == m){
        if (a[i][j] && cnt < 3) return *cur = a[i][j];
        return *cur = 0;
    }
    if (cnt == 3){
        if (i == n) return *cur = solve(i, j+1, cnt);
        if (j == m) return *cur = solve(i+1, j, 0);
        return *cur = max(solve(i, j+1, cnt), solve(i+1, j, 0));
    }
    if (a[i][j]){
        long long temp = 0;
        if (i != n) temp = a[i][j] + solve(i+1, j, 0);
        if (j != m) temp = max({temp, a[i][j] + solve(i, j+1, cnt+1), solve(i, j+1, cnt)});
        return *cur = temp;
    }
    long long temp = 0;
    if (i != n) temp = solve(i+1, j, 0);
    if (j != m) temp = max(temp, solve(i, j+1, cnt));
    return *cur = temp;
}

void solvetask(){
    cin >> n >> m >> k;
    while(k--){
        int i,j,v; cin >> i >> j >> v;
        a[i][j] = v;
    }
    for (int i=1; i<=n; i++) for (int j=1; j<=m; j++) for (int k=0; k<4; k++) dp[i][j][k]=-1;
    cout << solve(1, 1, 0) << endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t=1; //cin >> t;
    while(t--) solvetask();
}

Measured memory_bytes: 355756
#include <iostream>
#include<algorithm>
using namespace std;
int main(){

	int a[10],b[10];
	for(int i=0;i<10;i++)cin>>a[i];
	for(int i=0;i<10;i++)cin>>b[i];
	sort(a,a+10);sort(b,b+10);
	cout<<a[9]+a[8]+a[7]<<" "<<b[9]+b[8]+b[7]<<endl;


return 0;
}

Measured memory_bytes: 1180
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(true){
        c-=b;
        if(c<=0){
            cout<<"Yes"<<endl;
            break;
        }
        a-=d;
        if(a<=0){
            cout<<"No"<<endl;
            break;
        }
    }
    
    return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>
int cmpint(const void *a, const void *b) { return *(int *)b - *(int *)a; }
int min(int x, int y) { return x < y ? x : y; }
int main() {
	int n, a[100000], ans = 0, max = 0, num = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	qsort(a, n, sizeof(int), cmpint);
	for (int i = 1; i < n; i++) {
		ans = min(a[i], a[0] - a[i]);
		if (ans >= max) {
			max = ans;
			num = i;
		}
	}
	printf("%d %d\n", a[0], a[num]);
	return 0;
}

Measured memory_bytes: 892
import java.text.DecimalFormat;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        int a = sc.nextInt();
        int p = sc.nextInt();
        out.println((a * 3 + p) / 2);

        out.flush();
    }

}

// https://qiita.com/p_shiki37/items/a0f6aac33bf60f5f65e4
class FastScanner {

    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 22740
object Main extends App {
	val pw = new java.io.PrintWriter(System.out)

	@scala.annotation.tailrec
	def loop(start: Int, end: Int)(f: Int => Unit): Unit =
		if (start < end) {
			f(start)
			loop(start + 1, end)(f)
		}

	val n = Scanner.next.last

	pw.println(if (n == '3') "bon" else if (Seq('0','1','6','8') contains n) "pon" else "hon")
	pw.flush()
}

object Scanner {
	private val buf = new Array[Byte](1024); private var ptr = 0; private var len = 0

	@inline private def isPrintableChar(c: Int): Boolean = 33 <= c && c <= 126
	@inline private def hasNextByte(): Boolean = if (ptr >= len) { ptr = 0; len = System.in.read(buf); len > 0 } else true
	@inline private def hasNext(): Boolean = {
		while (hasNextByte() && !isPrintableChar(buf(ptr))) ptr += 1
		hasNextByte()
	}
	@inline private def readByte(): Byte = if (hasNextByte()) { val res = buf(ptr); ptr += 1; res } else -1

	def next(): String = {
		if(!hasNext()) ???
		val sb = new StringBuilder; var b = readByte()
		while (isPrintableChar(b)) { sb.append(b.toChar); b = readByte() }
		sb.toString
	}

	def nextInt(): Int = {
		val n = nextLong()
		if (n < Int.MinValue || Int.MaxValue < n) ???
		n.toInt
	}

	def nextLong(): Long = {
		if(!hasNext()) ???
		var minus = false; var b = readByte()
		if (b == '-') { minus = true; b = readByte() }

		@scala.annotation.tailrec
		def go (b: Byte, n: Long = 0): Long = if ('0' <= b && b <= '9') go(readByte(), n * 10 + b - '0') else if (minus) -n else n

		go(b)
	}

	def nextDouble(): Double = next().toDouble
}


Measured memory_bytes: 54500
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

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

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int blood[120]={0};
int data[120][120];
int N,K;
int main(){
	while(cin>>N>>K,N||K){
		rep(i,K+1)blood[i]=0;

		rep(i,N+1)rep(j,K)data[i][j]=0;
		for(int i =1;i <=K;i++){
			cin>>blood[i];
		}
		bool flag =true;
		for(int i =1;i <=N;i++){
			for(int j =1;j <=K;j++){
				cin>>data[i][j];
				blood[j]-=data[i][j];
				if(blood[j]<0){
					flag =false;
				}
			}
		}
		if(flag){
			cout <<"Yes"<<endl;
		}else{
			cout <<"No"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1204
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cstdio>
#include<cmath>
#include<map>
#include<set>
using namespace std;
using lint=long long;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
int MOD=1000000007;
signed main(){
    int n;cin>>n;
    multiset<int> rem;
    int mx=0;
    int d=(1ull<<n);
    rep(i,d){
        int buf;cin>>buf;
        rem.insert(buf);
        mx=max(mx,buf);
    }
    multiset<int> bef;
    bef.insert(mx);
    if(rem.count(mx)!=1){
        cout<<"No"<<endl;
        return 0;
    }
    rem.erase(rem.find(mx));
    int cur=1;

    rep(i,n){
        vector<int> use;
        for(const auto& it:bef){
            auto it2=rem.lower_bound(it);
            if(*it2==it||true){
                if(it2!=rem.begin())--it2;
                else{
                    if(*it2>=it){
                        cout<<"No"<<endl;
                        return 0;
                    }
                }
            }
            use.push_back(*it2);
            rem.erase(rem.find(*it2));
        }
        for(const auto& val:use){
            bef.insert(val);
        }
        cur*=2;
    }
    for(auto it:rem){
        cout<<it<<endl;
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 13304
#include <iostream>
#include <string>

#define LIGHT_FLY	48.00
#define FLY		 	51.00
#define BANTAM		54.00
#define FEATHER		57.00
#define LIGHT		60.00
#define LIGHT_WELTER 64.00
#define WELTER		69.00
#define LIGHT_MIDDLE 75.00
#define MIDDLE		81.00
#define LIGHT_HEAVY	91.00

using namespace std;

int main() {
	double weight;
	string strWeight;
	while(cin>>weight, !cin.eof()){
		strWeight = "";
		if(weight <= LIGHT_FLY) strWeight = "light fly";
		else if(weight <= FLY) strWeight = "fly";
		else if(weight <= BANTAM) strWeight = "bantam";
		else if(weight <= FEATHER) strWeight = "feather";
		else if(weight <= LIGHT) strWeight = "light";
		else if(weight <= LIGHT_WELTER) strWeight = "light welter";
		else if(weight <= WELTER) strWeight = "welter";
		else if(weight <= LIGHT_MIDDLE) strWeight = "light middle";
		else if(weight <= MIDDLE) strWeight = "middle";
		else if(weight <= LIGHT_HEAVY) strWeight = "light heavy";
		else strWeight = "heavy";
		cout<<strWeight<<endl;
	}
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  long acc[n + 1];
  acc[0] = 0;
  unordered_map<long, int> counter;
  counter[0]++;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    acc[i + 1] = acc[i] + a;
    counter[acc[i + 1]]++;
  }
  long ans2 = 0;
  for (long x: acc) {
    ans2 += counter[x] - 1;
  }
  cout << (ans2 >> 1) << endl;
  return 0;
}

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

int main(){
	int N, K;
	cin >> N >> K;
	ll h[N];
	rep(i,N) cin >> h[i];
	sort(h,h+N);
	ll minh = h[N-1] - h[0];
	rep(i, N-K+1){
		ll dh = h[i+K-1] - h[i];
		minh = min(minh, dh);
	}
	cout << minh << endl;
	return 0;
}


Measured memory_bytes: 4360
A=[]

for i in range(3):
    A.append(list(map(int,input().split())))

B=[[0]*3 for i in range(3)]

N=int(input())
for k in range(N):
    n=int(input())
    for i in range(3):
        for j in range(3):
            if A[i][j]==n:
                B[i][j]=1


if B[0][0]==B[0][1]==B[0][2]==1:
    f=True
elif B[1][0]==B[1][1]==B[1][2]==1:
    f=True
elif B[2][0]==B[2][1]==B[2][2]==1:
    f=True
elif B[0][0]==B[1][0]==B[2][0]==1:
    f=True
elif B[0][1]==B[1][1]==B[2][1]==1:
    f=True
elif B[0][2]==B[1][2]==B[2][2]==1:
    f=True
elif B[0][0]==B[1][1]==B[2][2]==1:
    f=True
elif B[2][0]==B[1][1]==B[0][2]==1:
    f=True
else:
    f=False

if f:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
import sys
import copy

def solve(n, a, b, c, d, s):
    if c < d:
        if b < c:
            width = [(a-1, d-1)]
        else:
            width = [(a-1, c-1), (b-1, d-1)]

        for left, right in width:
            for i in range(left, right):
                if s[i] == "#" and s[i+1] == "#":
                    return "No"
        return "Yes"
    else:
        flag = False
        for i in range(a-1, c-1):
            if s[i] == "#" and s[i+1] == "#":
                return "No"
            if b - 2 <= i <= d - 2 and s[i] == "." and s[i+1] == "." and  s[i+2] == "." :
                flag = True
        return "Yes" if flag else "No"


if __name__ == '__main__':

    n, a, b, c, d = map(int, sys.stdin.readline().strip().split(" "))
    s = sys.stdin.readline().strip()
    print solve(n, a, b, c, d, s)

Measured memory_bytes: 9020
#include<bits/stdc++.h>
using namespace std;
int n,ans=121212;
int main()
{
	cin>>n;
	for(int i=1;i<=n/2+1;i++)
	{
		int x=i,y=n-i,sum=0;
		while(x)
		{
//			printf("%d\n",x);
			sum+=x%10;
			x/=10;
		}
		while(y)
		{
			sum+=y%10;
			y/=10;
		}
		ans=min(ans,sum);
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
def dfs():
  stack = [K]
  while len(stack) > 0:
    i = stack.pop()
    for k,v in E[i].items():
      if visited[k]:
        continue
      visited[k] = True
      distd[k] = distd[i] + v
      stack.append(k)

# input
N = int(input())
E = {}

for i in range(N-1):
  a, b, c = map(int, input().split())
  if a in E:
    E[a].setdefault(b,c)
  else:
    E[a] = {b:c}

  if b in E:
    E[b].setdefault(a,c)
  else:
    E[b] = {a:c}

#print(E)

Q, K = map(int, input().split())

# 1-indexedでとる
visited = [False] * (N+1)
distd = [1e15] * (N+1)

visited[K] = True
distd[K] = 0

dfs()

for i in range(Q):
  x, y = map(int, input().split())
  print(distd[x] + distd[y])

Measured memory_bytes: 58760
#include <iostream>
#include <vector>
#include <stack>
#include <queue>

using namespace std;

static const int N = 100;
static const int WHITE = 0;
static const int GREY = 1;
static const int BLACK = 2;

int n, m[N][N], color[N], nxtNei[N];
int t, t1[N], t2[N];

int nxt(int u){
	for (int v = nxtNei[u]; v < n; ++v) {
		nxtNei[u] = v + 1;
		if (color[v] == WHITE && m[u][v] == 1) {
			return v;
		}
	}
	return -1;
}

void dfs(int r){
	for (int i = 0; i < n; ++i) nxtNei[i] = 0;
	stack<int> s;
	color[r] = GREY;
	s.push(r);
	t1[r] = t++;
	while (!s.empty()) {
		int u = s.top();
		int v = nxt(u);
		if (-1 == v){
			color[u] = BLACK;
			s.pop();
			t2[u] = t++;
			continue;
		}

		color[v] = GREY;
		s.push(v);
		t1[v] = t++;
	}
}

void search(){
	t = 1;
	for (int i = 0; i < n; ++i){
		color[i] = WHITE;
		nxtNei[i] = 0;
	}
	for (int i = 0; i < n; ++i) {
		if (color[i] == WHITE) dfs(i);
	}
	for (int i = 0; i < n; ++i){
		cout << i + 1 << " " << t1[i] << " " << t2[i] << endl;
	}
}


int main()
{
	cin >> n;

	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) m[i][j] = 0;
	}

	for (int i = 0; i < n; ++i) {
		int u, d; cin >> u >> d;
		for (int j = 0; j < d; ++j) {
			int v; cin >> v;
			m[u - 1][v - 1] = 1;
		}
	}

	search();

	return 0;
}

Measured memory_bytes: 3116
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const double PI = acos(-1);
const ll MOD = 1000000007;
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;
}
///////////////////////////////////////////////////////////////

template< typename T >
vector< vector< T > > binomial_table(int N) {
  vector< vector< T > > mat(N + 1, vector< T >(N + 1));
  for(int i = 0; i <= N; i++) {
    for(int j = 0; j <= i; j++) {
      if(j == 0 || j == i) mat[i][j] = 1;
      else mat[i][j] = mat[i - 1][j - 1] + mat[i - 1][j];
    }
  }
  return mat;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
	int N,P; cin >> N >> P;
	vector<ll> A(2);
	rep(i,N) {
		int a; cin >> a;
		if (a & 1) A[1]++;
		else A[0]++;
	}

	auto mat = binomial_table<ll> (A[1]);
	ll ans = 0;
	if (P == 1) {
		for (int i = 1; i <= A[1]; i += 2) {
            ans += mat[A[1]][i];
		}
	} else {
		for (int i = 0; i <= A[1]; i += 2) {
            ans += mat[A[1]][i];
		}
	}

	ans *= pow(2LL,A[0]);

	cout << ans << endl;

}


Measured memory_bytes: 256
<?php
        // put your code here
//        $fp = fopen("input.txt", "r");
        $fp = fopen("php://stdin", "r");
        while(true) {
            $n = fgets($fp);
            if($n == 0) break;
            
            $data = new Data();
            for($i = 0; $i < $n; $i++) {
                $buf = fgets($fp);
                $splited = explode(" ", $buf);
                $data->update($splited[0], $splited[1]*$splited[2]);
            }
            $data->countGoodEmployee();
        }
        
        Class Data {
            private $_employee;
            
            public function __construct() {
                $this->_employee = array();
            }
            
            public function update($id, $sales) {
                for($i = 0; $i < count($this->_employee); $i++) {
                    if( $this->_employee[$i]->getId() == $id ) {
                        $this->_employee[$i]->addSales($sales);
                        return;
                    }
                }
                $new_employee = new Employee($id, $sales);
                array_push($this->_employee, $new_employee);
            }
            
            public function countGoodEmployee() {
                $flg = true;
                for($i = 0; $i < count($this->_employee); $i++) {
                    if( $this->_employee[$i]->getSales() >= 1000000 ) {
                        echo $this->_employee[$i]->getId()."\n";
                        $flg = false;
                    }
                }
                if($flg) echo "NA\n";
            }
        }
        
        Class Employee {
            private $_id;
            private $_sales;
            
            public function __construct($id, $sales) {
                $this->_id = $id;
                $this->_sales = $sales;
            }
            
            public function addSales($sales) {
                $this->_sales += $sales;
            }
            
            public function getId() {
                return $this->_id;
            }  
            
            public function getSales() {
                return $this->_sales;
            }  
            
            public function printEmployee() {
                echo "id: ".$this->_id.", sales: ".$this->_sales."\n";
            }
        }
        ?>

Measured memory_bytes: 7484