akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}
 
const int maxn=200005;
//i_am_noob
int n,a[maxn];
set<int> st;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> n;
	rep(n) cin >> a[i];
	rep(n) st.insert(a[i]);
	print1(sz(st)==n?"YES":"NO");
	return 0;
}

Measured memory_bytes: 11136
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

D = n()

if D == 25:
    print('Christmas')
elif D == 24:
    print('Christmas Eve')
elif D == 23:
    print('Christmas Eve Eve')
elif D == 22:
    print('Christmas Eve Eve Eve')


Measured memory_bytes: 3060
fun fill(a: Array<Array<Int>>,xx : Int , yy : Int, f : Int, h :Int,w : Int) : Array<Array<Int>>{
        
        when(f){
            1 ->{
                 for(i in 0..h-1){
                     for(j in 0..xx-1){
                         a[i][j] = 1
                     }
                 }
             }
             2 ->{
                for(i in 0..h-1){
                     for(j in xx..w-1){
                         a[i][j] = 1
                     }
                 }
             }
             3 ->{
                 var yy_ = h - yy
                 for(i in yy_..h-1){
                     for(j in 0..w-1){
                         a[i][j] = 1
                     }
                 }
             }
             else ->{
                var yy_ = h - yy
                 for(i in 0..yy_-1){
                     for(j in 0..w-1){
                         a[i][j] = 1
                     }
                 }
             }
         }
         return a
}
fun main(args: Array<String>) {
    var (W,H,N) = readLine()!!.split(" ").map(String::toInt)
    var arr = Array(H, {Array(W, {0})})
    var sum = 0
    for(i in 0..N-1){
         var (x,y,a) = readLine()!!.split(" ").map(String::toInt)
         
         arr = fill(arr,x,y,a,H,W)
    }
    for(i in 0..H-1){
        sum += arr[i].sum()
    }
    print(H * W - sum)
}


Measured memory_bytes: 37900
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef  long long int ll;
typedef long double db;
#define pb push_back
#define mp make_pair
#define np(str) next_permutation(str.begin(),str.end())
#define ub(v,val) upper_bound(v.begin(),v.end(),val)
#define lb(v,val) lower_bound(v.begin(),v.end(),val)
#define sortv(vec) sort(vec.begin(),vec.end())
#define rev(p) reverse(p.begin(),p.end());
#define v vector
#define PI 3.1415926535
#define len length()
#define repc(i,s,e) for(ll i=s;i<e;i++)
#define fi first
#define se second
#define mset(a,val) memset(a,val,sizeof(a));
#define mt make_tuple
#define repr(i,n) for( i=n-1;i>=0;i--)
#define rep(i,n) for(i=0;i<n;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll mod = 1e9 + 7 ;
ll inf = 1e18;

ll n, m;

int main() {
	// your code goes here
	IOS;
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll i, j, k, x, y, z,  N;
	string s, t;
	cin >> s;
	cin >> t;
	ll ans = 0;
	for (i = 0; i <= s.len - t.len; i++) {
		ll cnt = 0;
		string dum = s.substr(i, t.len);
		rep(j, t.len) {
			if (t[j] == dum[j])
				cnt++;
		}
		ans = max(ans, cnt);
	}
	cout << t.len - ans;

	return 0;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
#define lowbit(x) ((x)&(-x))
typedef long long LL;

map<string, int> cache;

void run_case() {
    string S;
    cin >> S;
    int siz = S.size();
    for(int i = 0; i < siz; ++i)
        cout << "x";
}

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long dp[5][4001]; 
int main(void){
    int n;
    
    dp[0][0]=1;
    for(int i=0; i<4; i++){
        for(int j=0; j<4001; j++){
            if(dp[i][j]){
                for(int k=0; k<1001; k++){
                    dp[i+1][j+k]+=dp[i][j];
                }
            }
        }
    }
    while(cin>>n){
        cout<<dp[4][n]<<endl;
    }
}


Measured memory_bytes: 3196
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
#include <complex>
typedef complex<double> P;
double dot(P a, P b) {
	return (a.real() * b.real() + a.imag() * b.imag());
}
double cross(P a, P b) {
	return (a.real() * b.imag() - a.imag() * b.real());
}
int ccw(P a, P b,P c) {
	P e = b - a;
	P f = c - a;
	if (cross(e, f) > eps) {
		return 1;
	}
	if (cross(e, f) < -eps) {
		return -1;
	}
	if (dot(e, f) < -eps) return 2;
	if (abs(e) < abs(f)) return -2;
	return 0;
}
bool intersect(P a, P b, P c, P d) {
	if (ccw(a, b, c) * ccw(a, b, d) <= 0) {
		if (ccw(c, d, a) * ccw(c, d, b) <= 0){
			return 1;
		}
	}
	return 0;
}
double getDistanceLP(P a, P b, P c) {
	return abs(cross(b - a, c - a) / abs(b - a));
}
double getDistanceSP(P a, P b, P c) {
	if (dot(b - a, c - a) < 0.0) return abs(c - a);
	if (dot(a - b, c - b) < 0.0) return abs(c - b);
	return getDistanceLP(a, b, c);
}
double getDistance(P a, P b, P c, P d) {
	if (intersect(a, b, c, d)) return 0.0;
	return min({ getDistanceSP(a, b, c), getDistanceSP(a, b, d), getDistanceSP(c, d, a), getDistanceSP(c, d, b) });
}
long long input[300000] = {};
int removed[300000] = {};
long long cnt[300000][2] = {};
vector<int> vertexs[300000];
int main() {
	int n, m;
	cin >> n >> m;
	string s;
	cin >> s;
	REP(i, m) {
		int a, b;
		cin >> a >> b;
		vertexs[a].push_back(b);
		vertexs[b].push_back(a);
	}
	REP(i, n) {
		input[i + 1] = s[i] - 'A';
	}
	queue<int> next;
	for (int i = 1; i <= n; ++i) {
		for (int q = 0; q < vertexs[i].size(); ++q) {
			cnt[i][input[vertexs[i][q]]]++;
		}
		if (cnt[i][0] == 0 || cnt[i][1] == 0) {
			next.push(i);
		}
	}
	while (next.empty() == false) {
		int now = next.front();
		next.pop();
		if (removed[now] == false) {
			removed[now] = true;
			for (int q = 0; q < vertexs[now].size(); ++q) {
				cnt[vertexs[now][q]][input[now]]--;
				if (removed[vertexs[now][q]] == false&&cnt[vertexs[now][q]][input[now]] == 0) {
					next.push(vertexs[now][q]);
				}
			}
		}
	}
	REP(i, n) {
		if (removed[i+1] == 0) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 20928
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define dump(x)  cout << #x << " = " << (x) << endl;

#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
//             0123456789 - digits. check the limits, int vs long
const int MX = 100001;

double getDist(pi a, pi b) {
    double t = (a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second);
    return sqrt(t);
}


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(7);
    cout << std::fixed;
    // freopen("ex.in","r",stdin);
    // freopen("ex.out","w",stdout);
    int n;
    cin >> n;
    pi a[n];
    for (int i =0; i < n; i++) {
        cin >> a[i].first >> a[i].second;
    }
    double sum = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            sum += getDist(a[i], a[j]);
        }
    }
    cout << (double)(sum * 2) / n << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int num[105],ans[105];
bool in[105];
 
int main() {
  memset(in,1,sizeof(in));
  int n;
  scanf("%d",&n);
  for(int i=1;i<=n;i++) scanf("%d",&num[i]);
  for(int i=n;i>0;i--) {
  	int cur=0,s=0;
    for(int j=1;j<=n;j++)
      if (in[j]) {
      	s++;
      	if (num[j]==s) cur=j;
	  }
	if (cur&&num[cur]<=i) {
		ans[i]=num[cur];
		in[cur]=0;
	}
	else {
		puts("-1");
		return 0;
	}
  }
  for(int i=1;i<=n;i++) printf("%d\n",ans[i]);
  return 0;
}


Measured memory_bytes: 3732
main = do
    n <- getLine >>= return . read
    putStr $ f n

f n = if n < 27 
        then toAlp n
        else if y == 0
            then f (x - 1) ++ "z"
            else f x ++ toAlp y
                where
                    x = div n 26
                    y = mod n 26

toAlp 0 = "z"
toAlp x = [(['a'..'z'] !! (x-1))]

Measured memory_bytes: 3848
import numpy as np
import sys
input = sys.stdin.readline

N,K=map(int,input().split())
h=np.array(list(map(int,input().split())))

cost=np.array([-1]*N)


for i in range(N):
    if i==0:
        cost[i]=0
    else:
        siten=max(i-K,0)
        min_cost=np.min(cost[siten:i]+abs(h[siten:i]-h[i]))
        cost[i]=min_cost

print(cost[N-1])

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

using namespace std;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    int a, b;
    cin >> a >> b;
    if(a <= 9 && b <= 9) {
        cout << a * b << endl;
    } else
        cout << "-1\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
    int a,b;
    cin  >> a >> b;
    if (a*b % 2 == 0){
        cout << "Even" << endl;
    }
    else{
        cout << "Odd" << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
int n,i,f,c=0;long int a[200];
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%ld",&a[i]);
}f=1;
while(1)
{
for(i=0;i<n;i++)
{
if((a[i]%2)!=0)
{
f=0;
break;
}a[i]=a[i]/2;}
if(f==0)
break;
else
c++;
}
printf("%d",c);return 0;}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 100000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
// #define int long long
/* define/include */

int main(){
  int x,y,z;
  cin >> x >> y >> z;
  cout << ((x-z)/(y+z));
  return 0;
}


Measured memory_bytes: 256
h, w = map(int, input().split())
field = []
field.append(list("." * (w + 2)))
for _ in range(h):
    field.append(list("." + input() + "."))
field.append(list("." * (w + 2)))

for y in range(1, h + 1):
    for x in range(1, w + 1):
        if field[y][x] == "#":
                if("#" in [field[y + 1][x], field[y - 1][x], field[y][x + 1], field[y][x - 1]]):
                    pass
                else:
                    print("No")
                    quit()

print("Yes")


Measured memory_bytes: 3064
N = int(input())
A = sorted(map(int, input().split())) 

X = 0
Y = 0

B = []

for i in range(N-2):
    X = i + 1
    for j in range(X,N-1):
        Y = j + 1
        for k in range(Y, N):
            if A[k] < A[i] + A[j]:
                if A[k] != A[i] and A[i] != A[j] and A[k] != A[j]:
                    B.append((A[i],A[j],A[k]))

print(len(B))

Measured memory_bytes: 20144
/*
 *
 *   Author     : Amit Kumar
 *   Date 	: June 22, 2019
 * 
 */

#include <bits/stdc++.h>

//#define MORE_THAN_ONE_TESTCASE // COMMENT IT

#define vi vector<int>
#define vl vector<long long>
#define mii map<int , int>
#define mll map<long long , long long>
#define msi map<string , i>
#define msl map<string , long long>
#define si set<int>
#define sl set<long long>
#define pii pair<int , int >
#define psi pair<string,int>
#define psl pair<string , long > 
#define pll pair<long long , long long>
#define vpii vector<pii>
#define vpll vector<pll>
#define vpsi vector<psi>
#define vpsl vector<psl>
#define _ub upper_bound
#define _lb lower_bound
#define bint long long int
#define _in(x) scanf("%lld",&x)
#define _f first
#define _s second
#define _all(x) x.begin(),x.end()
#define _pb push_back
#define _eb emplace_back
#define _mp make_pair
#define _iv(v) for(auto &i:v){cin>>i;}
#define _ov(v) for(auto i:v){cout<<i<<" ";}cout<<endl;
#define _ovn(v) for(auto i:v){cout<<i<<endl;}
#define _euv(v) for(auto i:v){cerr<<i<<" ";}cerr<<endl;
#define _eovn(v) for(auto i:v){cerr<<i<<endl;}
#define _os(s) for(auto itr:s){cout<<itr<<" ";}cout<<endl;
#define _osn(s) for(auto itr:s){cout<<itr<<endl;}
#define _eos(s) for(auto itr:s){cerr<<itr<<" ";}cerr<<endl;
#define _eosn(s) for(auto itr:s){cerr<<itr<<endl;}
#define _rep(x) for(auto i=0 ; i<(x); ++i)
#define _repe(x) for(auto i=0; i<=(x); ++i)
#define _irep(a,b) for(auto i=(a); i<(b); ++i)
#define _irepe(a,b) for(auto i=(a); i<=(b); ++i)
#define _crep(a,b,c) for(auto i=(a); i<(b); i+=(c))
#define _crepe(a,b,c) for(auto i=(a); i<=(b); i+=(c))
#define _min(x,y) ((y) ^ (((x) ^ (y)) & (-((x) < (y)))))
#define _max(x,y) ((x) ^ (((x) ^ (y)) & (-((x) < (y)))))
#define endl '\n'
using namespace std;




auto SOLUTION_FUNCTION( void ) ->void {

    // your solution goes here 

    bint n , x;
    bint counter =1;
    cin>>n>>x;
    bint sum=0;
    while(n--){
        bint temp;
        cin>>temp;
        sum+=temp;
        if(sum<=x)
            counter++;
    }
    cout<<counter<<endl;

    return ;
}




int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout<<setprecision(10);
    cout<<fixed;
    cout<<boolalpha;
#ifdef MY_LOCAL_PROJECT
    freopen("input","r",stdin);
    freopen("output","w",stdout);
#endif
    int testcase = 1;


#ifdef MORE_THAN_ONE_TESTCASE
    cin>>testcase;
#endif
    
    while(testcase--){
        SOLUTION_FUNCTION();
    }

#ifdef MY_LOCAL_PROJECT
    cout<<"Time : "<<1.0*(double)clock()/CLOCKS_PER_SEC<<endl;
#endif
    return 0;
}


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

int main() {
    int N;
    cin >> N;
    int minv;
    int maxv;
    cin >> minv;
    maxv = minv;
    int j;

    for (int i = 0; i < N - 1; i++) {
        cin >> j;
        if (j < minv) {
            minv = j;
        }
        if (j > maxv) {
            maxv = j;

        }
    }
    
    cout << maxv - minv << endl;

    return 0;
}

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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a.at(i);
  int q;
  cin >> q;
  vector<P> bc(q);
  rep(i, q) {
    int b, c;
    cin >> b >> c;
    bc.at(i) = make_pair(b, c);
  }
  ll sum = 0;
  map<int, int> mp;
  rep(i, n) {
    sum += a.at(i);
    mp[a.at(i)]++;
  }
  rep(i, q) {
    P t = bc.at(i);
    int b = t.first;
    int c = t.second;
    sum -= (ll) b * mp[b];
    sum += (ll) c * mp[b];
    mp[c] += mp[b];
    mp[b] = 0;
    cout << sum << endl;
  }
  return 0;
}


Measured memory_bytes: 8728
#include <cstdio>
#include <cassert>
#include <queue>
#include <deque>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <set>
#include <cstdlib>
#include <string>
#include <unordered_map>
#include <sstream>
#include <bitset>
using namespace std;

typedef long long int lli;
typedef pair<int, int> pii;
typedef unsigned char byte;
typedef unsigned int uint;
typedef unsigned long long int ulli;

char m[101][101];
bool swapped;

const int p[2][4][4] = {
    {
        {1, 1, 1, 0},
        {1, 0, 1, 0},
        {1, 1, 1, 0},
        {0, 0, 0, 0}
    },
    {
        {0, 0, 0, 0},
        {0, 1, 0, 0},
        {0, 0, 0, 0},
        {0, 0, 0, 0},
    }
};

void pick(int x, int y, int k) {
    int i, j;
    for (i=0; i<4; ++i) {
        for (j=0; j<4; ++j) {
            m[x+i][y+j] = (p[k][i][j] ^ swapped) ? '#' : '.';
        }
    }
}

int main() {
    int w, b;
    int i, j;
    scanf("%d%d", &w, &b);
    if (b > w) {
        for (i=0; i<100; ++i) {
            for (j=0; j<100; ++j) {
                m[i][j] = '.';
            }
        }
        swapped = false;
    } else {
        for (i=0; i<100; ++i) {
            for (j=0; j<100; ++j) {
                m[i][j] = '#';
            }
        }
        swap(w, b);
        swapped = true;
    }
    for (i=0; i<w-1; ++i) {
        int x = (i / 25) * 4, y = (i % 25) * 4;
        pick(x, y, 0);
    }
    for (; i<b; ++i) {
        int x = (i / 25) * 4, y = (i % 25) * 4;
        pick(x, y, 1);
    }
    printf("100 100\n");
    for (i=0; i<100; ++i) {
        for (j=0; j<100; ++j) {
            putchar(m[i][j]);
        }
        putchar('\n');
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=3e5+10;
int32_t main()
{
	IOS;
	string s;
	cin>>s;
	int f=-1,f1=-1;
	for(auto it:s)
	{
		if(it=='B')
		{
			f=1;
		}
		if(it=='A')
			f1=1;
	}
	if(f==1&&f1==1)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;






}


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

int main() {
  string s;cin>>s;
  int cnt1=0,cnt2=0;
  int n=s.size();
  string a,b;
  rep(i,n){
    if(i%2==0){
      a+='0';
      b+='1';
    }
    else {
      a+='1';
      b+='0';
    }
  }
  rep(i,n){
    if(s[i]!=a[i])cnt1++;
    if(s[i]!=b[i])cnt2++;
  }
  cout<<min(cnt1,cnt2)<<endl;
}

Measured memory_bytes: 3992
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define MOD7 1000000007
#define LL_INF 9000000000000000000
#define LL_MINF -9000000000000000000
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
    int N;
    cin >> N;
    vector<int> H(N);
    for(int i = 0; i < N; i++) cin >> H[i];
    
    int count = 0;
    while(true){
        bool zero = true;
        bool all_zero = true;
        for(int &h : H){
            if(h > 0) {
                all_zero = false;
                if(zero){
                    count++;
                    zero = false;
                }
                h--;
            }else if(h == 0) {
                zero = true;
            }
        }
        if(all_zero) break;
    }
    cout << count << endl;
}

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

typedef long long int ll;

#define MAXN 100005
vector<int> adj[MAXN];
int prof[MAXN];
int haut[MAXN];
int parent[MAXN];

void initialiser(){
	for(int i=0;i<MAXN;i++){
		prof[i] = 0;
		haut[i] = 0;
		parent[i] = -1;
	}	
}
int N; 

void enraciner(int sommet){
	haut[sommet] = 1;
	for(int i=0;i<(int)adj[sommet].size();i++){
		int s = adj[sommet][i];
		if(s!=parent[sommet]){
			parent[s] = sommet;
			prof[s] = 1+prof[sommet];
			enraciner(s);
			haut[sommet] = max(haut[sommet], 1+haut[s]);
		}
	}
}


int main(){
	
	initialiser();
	int u, v; scanf("%d %d %d",&N,&u,&v);
	for(int i=0;i<N-1;i++){
		int a, b; scanf("%d %d",&a,&b);
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	
	enraciner(v);
	int ans = 0;
	int pu = prof[u];
	int pv = prof[v];
	int m = (pu-pv-1)/2;
	pu-=m;
	pv+=m;
	ans+=m;
	for(int i=0;i<m;i++) u = parent[u];
	int mx = 0;
	for(int i=0;i<(int)adj[u].size();i++){
		int s = adj[u][i];
		if(s!=parent[u]){mx = max(mx, haut[s]);}
	}
	ans += mx;
	int last = (pu-pv)/2;
	ans+=last;
	printf("%d",ans);
	
	
}


Measured memory_bytes: 13312
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;

  long ans = 0;
  if (K % 2 == 0) {
    long mod_0 = 0;
    long mod_half = 0;
    for (int i = 1; i <= N; ++i) {
      if (i % K == 0) {
        ++mod_0;
      }
      if (i % K == K / 2) {
        ++mod_half;
      }
    }
    ans += pow(mod_0, 3);
    ans += pow(mod_half, 3);
  } else {
    long mod_0 = 0;
    for (int i = 1; i <= N; ++i) {
      if (i % K == 0) {
        ++mod_0;
      }
    }
    ans += pow(mod_0, 3);
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <complex>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
#include <iterator>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;

template<class T, class F>
struct SegTree {
  size_t n;
  vector<T> a;
  F f;
  T zero;

  template<class U>
  static U ceil2(U x) {
    U y = 1;
    for (; y < x; y <<= 1);
    return y;
  }
  SegTree(size_t n, T zero, F f) 
    : n(ceil2(n)), a(2 * ceil2(n), zero), f(f), zero(zero) {}
  void set(size_t i, T x) {
    i += n;
    a[i] = x;
    while (i >>= 1) a[i] = f(a[2 * i], a[2 * i + 1]);
  }
  // [l, r)
  T seg(size_t l, size_t r) const {
    T x = zero, y = zero;
    for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
      if (l & 1) {
        x = f(x, a[l]);
        ++l;
      }
      if (r & 1) {
        --r;
        y = f(a[r], y);
      }
    }
    return f(x, y);
  }
  T operator[](size_t i) const { return a[n + i]; }
};

void solve() {
    int n, q;
    string s;
    cin >> n >> s >> q;
    auto plus = [](int x, int y) { return x + y; };
    using ST = SegTree<int, decltype(plus)>;
    vector<ST> sts;
    for (int i = 0; i < 26; ++i) {
        sts.push_back(ST(n, 0, plus));
    }
    for (int i = 0; i < n; ++i) {
        int c = s[i] - 'a';
        sts[c].set(i, 1);
    }
    while (q--) {
        int t;
        cin >> t;
        if (t == 1) {
            int i;
            char cc;
            cin >> i >> cc;
            --i;
            int c = cc - 'a';
            int pc = s[i] - 'a';
            sts[pc].set(i, 0);
            sts[c].set(i, 1);
            s[i] = cc;
        } else if (t == 2) {
            int l, r;
            cin >> l >> r;
            int res = 0;
            for (int c = 0; c < 26; ++c) {
                res += sts[c].seg(l - 1, r) > 0;
            }
            cout << res << '\n';
        }
    }
}

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

Measured memory_bytes: 109572
#!/bin/bash
''':'
docker run --rm -it -v $(cd $(dirname $0) && pwd):/vo:ro pypy:3-2.4.0 \
   /bin/bash -c "pypy3 /vo/$(basename $0) < /vo/input.txt"
exit $?
'''
import sys


def _ia(): return map(int, sys.stdin.readline().strip().split())


def main():
    mod = 10**9 + 7
    n, k = _ia()

    ret = 0
    for ki in range(k, n+2):
        mi = (ki * (ki-1))//2
        ma = ((2*n-ki+1)*ki)//2
        ret += (ma-mi+1)
        ret %= mod
    return ret


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 63304
n=int(input())
a=list(map(int,input().split()))
count=0
ans=1
color_lis=[0,0,0,0,0,0,0,0]
for i in range(n):
  if a[i]//400>=8:
    count+=1
  else:
    color_lis[a[i]//400]=1
ans=sum(color_lis)
if count>0:
  flag=1
else:
  flag=0
ans1 = max(flag,ans)
ans2 = ans+count
print(ans1,ans2)

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

using namespace std;

typedef long long ll;
#define mod 1000000007
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define repc(i, a, b, c) for (ll i = a; (c > 0 ? i < b : i > b) and c != 0; i += c)
#define mp make_pair
#define pb push_back
#define all(name) (name.begin(), name.end())
#define fact(n) rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod);
#define mod_in(a) power(a, mod-2)
#define ncr(n, r) ((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod)
#define deb(x) cout << #x << " " << x << endl;
ll dp[105][100005];
int main()
{
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	int t = 1;
	// cin >> t;
	while(t--)
	{
		ll n, m, in1, in2;
		cin >> n >> m;
		ll arr[n+1];
		rep(i, 0, n)cin >> arr[i+1];
		for(int i = 0; i <= arr[1]; i++)dp[1][i] = 1;
		rep(i, 1, n){
			rep(j, 0, m+1){
				dp[i+1][j] += dp[i][j], dp[i+1][j] %= mod;
				if(j+arr[i+1] < m)dp[i+1][j+arr[i+1]+1] = ((dp[i+1][j+arr[i+1]+1]%mod) - (dp[i][j]%mod) + mod)%mod;
			}
			rep(j, 1, m+1)dp[i+1][j] = (dp[i+1][j] + dp[i+1][j-1])%mod;
		}
		cout << dp[n][m]%mod << endl;
	}
}

Measured memory_bytes: 79360
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <functional>
#include <map>
#include <set>
#include <cmath>
#include <string>
#define SIZE 200005
#define INF 1000000005LL

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

int n;
ll K;

int main()
{
	scanf("%d",&n);
	int dp[50];
	for(int i=0;i<=n;i++){
		if(i==0||i==1){
			dp[i]=1;continue;
		}
		dp[i] = dp[i-1]+dp[i-2];
	}
	printf("%d\n",dp[n]);
	return 0;
}



Measured memory_bytes: 2760
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000 //1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
  cout << H << " ";
  debug_out(T...);
}

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;

// const
// 円周率
const double pi = M_PI;
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)

int main()
{
  // faster
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  ll n; cin >> n;
  map<string,ll> d;
  rep(i,n){
    string temp; cin >> temp;
    sort(ALL(temp));
    if(d.count(temp)==0)
      d[temp]=0;
    d[temp]++;
  }
  ll res=0;
  for(pair<string,ll> i:d){
    ll temp=i.second;
    res+=temp*(temp-1)/2;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 11264
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B
import Prelude hiding (readLn)

main :: IO ()
main = readLine >>= main'
    where
        main' (n : xs) = replicateM n readLn >>= print . solve xs

solve :: [Int] -> [Int] -> Int
solve [a, b, c] = check [] [] []
    where
        check xs ys zs (l : ls) = minimum [check (l : xs) ys zs ls, check xs (l : ys) zs ls, check xs ys (l : zs) ls, check xs ys zs ls]
        check xs@(_ : _) ys@(_ : _) zs@(_ : _) _ = 10 * (xl + yl + zl - 3) + abs (xn - a) + abs (yn - b) + abs (zn - c)
            where
                [(xn, xl), (yn, yl), (zn, zl)] = map (foldl' ff (0, 0)) [xs, ys, zs]
                ff (acc, len) x = (acc + x, len + 1)
        check _ _ _ _ = 10 ^ 10


readLn :: IO Int 
readLn = head <$> readLine

readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

Measured memory_bytes: 1020
#!/usr/bin/env python3

def main():
    N = int(input())
    T = list(map(int, input().split()))
    A = list(map(int, input().split()))

    if T[-1] != A[0]:
        print(0)
        exit()

    upper = T[:]
    flag = [0] * N

    # Tくんの目線で見る
    now = 0
    for i in range(N):
        if T[i] > now:
            flag[i] = 1
            now = T[i]

    # A君の目線で見る
    now = 0
    for i in range(N):
        if flag[N-1-i] and T[N-1-i] > A[N-1-i]:
            print(0)
            exit()

        if A[N-1-i] > now:
            flag[N-1-i] = 1
            now = A[N-1-i]

        upper[N-1-i] = min(upper[N-1-i],A[N-1-i])

    ans = 1
    m = 10**9+7
    for i in range(N):
        if flag[i]==0:
            ans *= upper[i]
            ans %= m
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 25668
#include <iostream>

using namespace std;

int main() {
	int m, f, r;

	while (1) {
		cin >> m >> f >> r;
		
		if (m == -1 && f == -1 && r == -1) {
			break;
		}

		if (m == -1 || f == -1 || m + f < 30) {
			cout << "F" << endl;
		}
		else if (m + f >= 80) {
			cout << "A" << endl;
		}
		else if (m + f >= 65 && m + f < 80) {
			cout << "B" << endl;
		}
		else if (m + f >= 50 && m + f < 65) {
			cout << "C" << endl;
		}
		else if (m + f >= 30 && m + f < 50) {
			if (r >= 50)
				cout << "C" << endl;
			else
				cout << "D" << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 3068
#include<bits/stdc++.h>
#define Rushia_mywife ios::sync_with_stdio(0);cin.tie(0);
#define rep(i,head,n) for(int i=(head);i<n;i++)
#define int long long
#define F first
#define S second
#define pb push_back
#define p2(n) (1<<(n))
#define lg2(n) __lg(n)
using namespace std;
using pii = pair<long long,long long>;
using ld = long double;
mt19937 mt_rand(time(0));
const int mod = 1000000007;
const int hnum = 998244353;
const ld PI = acos(-1);

int n,d;

void solve(){
    cin >> n >> d;
    d *= d;
    int sum = 0;
    while(n--){
        int x,y; cin >> x >> y;
        sum += (x*x+y*y)<=d;
    }
    cout << sum << '\n';
}

signed main(){
    Rushia_mywife
    solve();
}

Measured memory_bytes: 3660
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int area = a * b;
        int around = 2 * (a + b);
        System.out.println("" + area + " " + around);
    }
}


Measured memory_bytes: 26064
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
template <class T>
using ordered_set = __gnu_pbds::tree<T, __gnu_pbds::null_type, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;
template <class T>
using ordered_multiset = __gnu_pbds::tree<T, __gnu_pbds::null_type, less_equal<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

#define PI atan2(0, -1)
#define EPS 1e-9
#define INF 5e18
#define MOD 1000000007

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

int main(){
    //freopen("sort.in", "r", stdin); freopen("sort.out", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10);
    string s, t; cin >>s >> t;
    int cnt = 0;
    for(int i = 0; i < s.length(); i++) cnt += s[i] != t[i];
    cout << cnt << '\n';
    return 0;
}

/******************************
Kateba ii dake no hanashi darou
Success is only a victory away
- No Game No Life Opening
******************************/

Measured memory_bytes: 3888
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 100000000;
const int MOD = 1000000007;
bool IsPrime(int num)//素数判定
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
int main(){
  std::vector<int> a(100001,0);
  for (int i =3; i <= 100000; i++) {
    /* code */
    if(i%2!=0){
      if(IsPrime(i)&&IsPrime((i+1)/2))a[i]=a[i-1]+1;
      else a[i]=a[i-1];
    }
    else a[i]=a[i-1];
  }
  int q;
  std::cin >> q;
  rep(i,q){
    int l,r;
    std::cin >> l>>r;
    std::cout <<a[r]-a[l-1] << std::endl;
  }
}

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


int main() {
  ll H;
  cin >> H;

  ll ans = 2;
  while(H > 1) {
    H /= 2;
    ans *= 2;
  }
  ans -= 1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <sstream>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector <vector <int>> vii;
typedef vector <long long> vll;
typedef vector <string> vs;
typedef vector <char> vc;
typedef set <int> si;
typedef set <string> ss;
typedef queue <int> qi;
typedef queue <long long> qll;
typedef queue <string> qs;
typedef queue <char> qc;
typedef struct board board;
typedef pair <int, int> pi;
typedef pair <long long, long long> pll;
typedef pair <int, pair<int, int>> pii;

#define eb emplace_back
#define ppb pop_back
#define clr(a) a.clear()
#define F first
#define S second
#define mkp make_pair

#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

#define left(x) x * 2
#define right(x) x * 2 + 1

#define meme(a, b, c) fill(a + 1, a + 1 + b, c)

#define max(a, b) (a > b ? a : b)
#define min(a, b) (a > b ? b : a)
#define abs(a) (a > 0? a : -(a))

#define move(s) s += "#"

#define eprintf(...) fprintf(stderr, __VA_ARGS__);

template <typename T>
void printArr(const T * arr, int s, int fn) {
    for (int i = s; i <= fn; ++ i) cout << arr[i] << " ";
    cout << '\n';
}

template <typename T>
long long minArr(const T * arr, int s, int fn) {
    ll res = 1e16 + 1;
    for (int i = s; i <= fn; ++ i) {
        res = min(res, arr[i]);
    }
    return res;
}

template <typename T>
void printVec(const T * arr) {
    for (int i = 0; i < sz(arr); ++ i) cout << arr[i] << " ";
    cout << '\n';
}

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

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

void to_pray() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cerr << "Ready\n";
}

const int N = 1e5 + 10;
const int NN = 1e3 + 10;
const int NNN = 2e3 + 9;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll LLINF = 1e12 + 7;
const int EPS = 1e-9 - 8;
const int vN = 2e4 + 10;
const int sz = (1 << 22) - 1;
const double PI = acos(-1);

int main () {
    to_pray();

    int a;
    string s;

    cin >> a >> s;

    cout << (a >= 3200?s:"red");

    //eprintf("%.18lf seconds\n", (double)clock() / CLOCKS_PER_SEC);

    cout << '\n';
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int N, M = 0;
  scanf("%d%d", &N, &M);
  int i, sumV, now = 0;
  int voteValue[N];
  for (i = 0; i < N; i++) {
    voteValue[i] = 0;
    scanf("%d", &voteValue[i]);
    sumV += voteValue[i];
  }
  int ch = 4 * M;
  for (i = 0; i < N; i++) {
   if (voteValue[i] * ch >= sumV ){
    now++; 
   }
  }
  if (now >= M){
    printf("Yes");
  }else{
    printf("No");
  }
  
}

Measured memory_bytes: 128
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long a = 1;
        long p = 1000 * a;
        if(p>=n){
            System.out.println(p-n);
        }
        while(n > p){
            a++;
            p = 1000*a;
            if(p>=n){
                System.out.println(p-n);
                break;
            }
            
        }
    }
}





Measured memory_bytes: 35628
#include <iostream>
#include <map>

using namespace std;

typedef map<int, int> mii;

int main() {
    ios::sync_with_stdio(false);

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

    long long ans = 0;
    mii c;
    int ps[n+1];
    ps[0] = 0;
    c[0]++;
    for (int i = 1; i <= n; i++) {
        int a;
        cin >> a;
        a = (a + k - 1) % k;

        if (i >= k) {
            c[ps[i-k]]--;
        }

        ps[i] = (ps[i-1] + a) % k;
        ans += c[ps[i]];

        c[ps[i]]++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 10368
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <numeric>
#include <string>
#include <vector>

using namespace std;
int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(abs(c - a) <= d) {
        cout << "Yes" << endl;
    } else if(abs(b - a) <= d && abs(b - c) <= d) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}



Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N, W = map(int, input().split())

WV = []
for _ in range(N):
  w, v = map(int, input().split())
  WV.append((w, v))

dp = [[0] * (W + 1) for _ in range(N)]
for w in range(W + 1):
  if (w == 0):
    continue
  for i, wv in enumerate(WV):
    if(w < wv[0]):
      if (i - 1 < 0):
        dp[i][w] = 0
      else:
        dp[i][w] = dp[i - 1][w]
    else:
      if (i - 1 < 0):
        val1 = 0
      else:
        val1 = dp[i - 1][w]
      
      if (((i - 1) < 0) or ((w - wv[0]) < 0)):
        val2 = wv[1]
      else:
        val2 = wv[1] + dp[i - 1][w - wv[0]]
      dp[i][w] = val1 if (val1 > val2) else val2

print(dp[N - 1][W])


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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
#define chmax(x, v) do { x = max(x, v); } while (0)
#define chmin(x, v) do { x = min(x, v); } while (0)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

ll a[3][3];

signed main() {
  rep(y,3)
    rep(x,3)
      cin>>a[y][x];
  ll N;
  cin>>N;
  rep(i,N){
    ll t;
    cin >> t;
    rep(y,3)
      rep(x,3)
        if (a[y][x] == t)
          a[y][x] = 0;
  }
  bool bingo = false;
  rep(y,3) {
    if (a[y][0] == a[y][1] && a[y][1] == a[y][2])
      bingo = true;
    if (a[0][y] == a[1][y] && a[1][y] == a[2][y])
      bingo = true;
  }
  if (a[0][0] == a[1][1] && a[1][1] == a[2][2])
    bingo = true;
  if (a[0][2] == a[1][1] && a[1][1] == a[2][0])
    bingo = true;

  cout << (bingo ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define mp make_pair
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define MOD 1000000007
typedef long long ll;
using namespace std;

void FAST() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

int main(){
	



	ll n; cin>>n; ll a;

map<string,int>mp;
ll counta,countb,countc,countd;
 counta=countb=countc=countd=0;
mp.insert({"AC",counta});
mp.insert({"TLE",countb});
mp.insert({"RE",countc});
mp.insert({"WA",countd});

string s;


REP(i,0,n){
  cin>>s;
if(s=="AC"){
	counta++;
	mp[s]=counta;
}

else if(s=="TLE"){
	countb++;
	mp[s]=countb;
}

else if(s=="RE"){
	countc++;
	mp[s]=countc;
}

else if(s=="WA"){
	countd++;
	mp[s]=countd;
}

}
/*
for(auto i:mp){
	cout<<i.first<<" "<<i.second<<endl;
}*/


cout<<"AC x "<<counta<<endl<<"WA x "<<countd<<endl<<"TLE x "<<countb<<endl<<"RE x "<<countc;
	//cerr<<a<<endl;
	
	
}



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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}


const int MOD = 1E9 + 7;
ll exp(int a, int n) {
        if (n == 0) return 1;
        ll b = exp(a, n / 2);
        (b *= b) %= MOD;
        if (n & 1) (b *= a) %= MOD;
        return b;
}


int choose(int n, int k) {
        ll x = 1, y = 1;
        for (int i = n; i >= n - k + 1; i--) (x *= i) %= MOD;
        for (int i = 1; i <= k; i++) (y *= i) %= MOD;
        return x * exp(y, MOD - 2) % MOD;
}


void _main() {
        int n, a, b; cin >> n >> a >> b;
        cout << (exp(2, n) - 1 - choose(n, a) - choose(n, b) + MOD + MOD + MOD) % MOD;
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
    ll n,sm=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            for(int k=1;k<=n;k++)
            {
                sm+=__gcd(__gcd(i,j),k);
            }
        }
    }

    cout<<sm<<endl;









    return 0;
}


Measured memory_bytes: 3632
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << '\n';
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

template <typename T>
void print(const T &a) {
    for (auto e : a) cout << e << ' ';
    cout << '\n';
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

void solve() {
    long long n; cin >> n;
    long long ans = 0;
    for (int a = 1; a < n; a++) {
        ans += (n-1)/a;
    }
    cout << ans << '\n';
}

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

    solve();

    return 0;
}

Measured memory_bytes: 3688
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
using namespace std;

typedef long long ll;

int vmax, vmin;
int xmax, xmin, ymax, ymin;
int x[200003], y[200003];
bool ched[200003];

int main() {
	int n; cin >> n;
	vmin = 1e9;
	for (int i = 0; i < n; ++i) {
		cin >> x[i] >> y[i];
		vmax = max(vmax, max(x[i], y[i]));
		vmin = min(vmin, min(x[i], y[i]));
	}
	xmin = vmin; ymax = vmax;
	xmax = 0; ymin = 1e9;
	for (int i = 0; i < n; ++i) {
		xmax = max(xmax, min(x[i], y[i]));
		ymin = min(ymin, max(x[i], y[i]));
	}
	ll ans = (ll)(xmax - xmin)*(ll)(ymax - ymin);
	ymin = vmin; ymax = vmax;
	priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> que;
	for (int i = 0; i < n; ++i) {
		if (y[i] < x[i]) swap(x[i], y[i]);
		que.push({ x[i], i });
		xmin = min(xmin, x[i]);
		xmax = max(xmax, x[i]);
	}
	bool flag = false;
	while (!que.empty()) {
		int v = que.top().first, pos = que.top().second; que.pop();
		if (ched[pos]) {
			flag = true;
			continue;
		}
		ched[pos] = true;
		xmax = max(xmax, y[pos]);
		que.push({ y[pos], pos });
		if (!flag) xmin = que.top().first;
		ans = min(ans, (ll)(xmax - xmin)*(ll)(ymax - ymin));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3956
import heapq

N_ko, M_mai = map(int, input().split())
prices = list(map(int, input().split()))
prices = [-1 * i for i in prices]

heapq.heapify(prices)

for i in range(M_mai):
    p = abs(heapq.heappop(prices))
    
    p = -1 * (p // 2)

    heapq.heappush(prices, p)

summ = -1 * sum(prices)

print(summ)

Measured memory_bytes: 14180