akhauriyash/Code-Regression huggingface dataset:
#define	_USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cctype>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <set>
#include <complex>
#include <utility>
#include <numeric>
#include <bitset>
using namespace std;
const int INF=1<<30;

int d[11][7];
int x=2,y=1;
int k=0;

typedef pair<int,int> P;

int main(){
	
	int a,b,c;
	int p[11]={0};
	cin>>a>>b>>c;
	p[a]++;
	p[b]++;
	p[c]++;
	
	if(p[5]==2&&p[7])
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;

vector<ll> G[MAX];
list<ll> out;
bool V[MAX];
ll N;
ll indeg[MAX];
ll ans[MAX];

void bfs(ll s){
    queue<ll> q;
    q.push(s);
    V[s]=true;
    while(!q.empty()){
        ll u=q.front();
        q.pop();
        out.push_back(u);
        for(ll i=0;i<G[u].size();i++){
            ll v=G[u][i];
            indeg[v]--;
            if(indeg[v]==0 && !V[v]){
                ans[v]=u;
                V[v]=true;
                q.push(v);
            }
        }
    }
}

void  tsort(){
    for(ll i=0;i<N;i++){
        indeg[i]=0;
    }
    for(ll u=0;u<N;u++){
        for(ll i=0;i<G[u].size();i++){
            ll v= G[u][i];
            indeg[v]++;
        }
    }

    for(ll u=0;u<N;u++){
        if(indeg[u]==0 && !V[u]){
            ans[u]=-1;
            bfs(u);
        }
    }
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll M;
    cin>>N>>M;
    rep(i,N+M-1){
        ll s,t;
        cin>>s>>t;
        s--;t--;
        G[s].pb(t);
    }
    tsort();
    rep(i,N){
        cout<<ans[i]+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 26240
#include<bits/stdc++.h>
using namespace std;
typedef long long ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef pair<string, string> pss; 
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef vector<pii> vii; 
typedef vector<int, pii> viii; 
typedef vector<pll> vll; 
typedef vector<ll> vl; 
typedef vector<vl> vvl; 
typedef vector<vector<vl>> vvvl; 
vvl a;ll r,c;
vvvl dp;
ll dfs(ll p, ll x, ll y){
    if(dp[p][x][y]!=-1)return dp[p][x][y];
    if(x==r && y==c){
        if(p<3) return dp[p][x][y]=a[x][y];
        else return dp[p][x][y]=0;
    }
    if(p<3 && a[x][y]){
        ll a1=0;
        if(x+1<=r){
            a1=dfs(0,x+1,y)+a[x][y];
        }
        if(y+1<=c){
            a1=max(a1, max(dfs(p,x,y+1), a[x][y]+dfs(p+1,x,y+1)));
        }
        return dp[p][x][y]=a1;
    }else {
        ll a1=0;
        if(x+1<=r)a1=dfs(0,x+1,y);
        if(y+1<=c)a1=max(a1,dfs(p,x,y+1));
        return dp[p][x][y]=a1;
    }
}
int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout); 
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL) ; cout.tie(NULL);
    ll i,j,k,x,y;
    cin>>r>>c>>k;
    dp.assign(4, vvl(r+1, vl(c+1, -1)));
    a.assign(r+1, vl(c+1,0));
    for(i=0;i<k;i++){
        cin>>x>>y>>j;
        a[x][y]=j;
    }
    cout<<dfs(0,1,1)<<endl;
    return 0;
}


Measured memory_bytes: 355756
#include <iostream>

using namespace std;

int main() {
    int n;
    unsigned long long int dp[31];
    while (true) {
        cin >> n;
        if (n == 0) {
            return 0;
        }
        dp[0] = 1;
        for (int i=1; i<=n; i++) {
            dp[i] = 0;
            if (i >= 3) {
                dp[i] += dp[i-3];
            }
            if (i >= 2) {
                dp[i] += dp[i-2];
            }
            dp[i] += dp[i-1];
        }
        cout << (dp[n]/3650)+(dp[n]%3650 == 0? 0: 1) << endl;
    }
    return 0;
}

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



long long int ar[1000005];

int main()
{
    /*ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);*/

    long long int a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z;


    cin>>n;
    map <long long int , long long int> mp;
    set <long long int > st;
    vector <long long int> v1;
    m=0;
    for(i=0;i<n;i++)
    {
        cin>>a;
        m=max(m,a);
        st.insert(a);
        mp[a]++;
        v1.push_back(a);
    }
    c=n;
    for(i=0;i<n;i++)
    {
        a=v1[i];
        //cout<<a<<" "<<mp[a]<<" "<<ar[a]<<"\n";
        if(mp[a]>1)
        {
           if(ar[a]==0)
           {
               ar[a]=1;
               c-=mp[a];
           }
        }
        k=2;
        while((a*k)<=m)
        {

            if(ar[a*k]==0 && st.find(a*k)!=st.end())
            {
                c-=mp[a*k];
                ar[a*k]=1;
            }
            k++;
        }
    }

    cout<<c<<"\n";

    return 0;


}


Measured memory_bytes: 32260
// Problem : A - Getting Difference
// Contest : AtCoder - AtCoder Grand Contest 018
// URL : https://atcoder.jp/contests/agc018/tasks/agc018_a
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
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;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,b,a) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define bug(x) cout<<#x<<"="<<x<<endl; 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 200001; //check the limits, dummy
 string as[]={"POSSIBLE","IMPOSSIBLE"};
int main() 
{
	ios_base::sync_with_stdio(0); cin.tie(0);    
	int N,K;
	cin>>N>>K;
	vi v(N);
	F0R(x,N)
		cin>>v[x];
	sort(all(v));
	if(v.back()<K)
	{
		cout<<as[1]<<nl;
		return 0;
	}
	if(binary_search(all(v),K))
	{
		cout<<as[0]<<nl;
		return 0;
	}
	int mn=v[0];
	F0R(x,N-1)
	{
		ckmin(mn,v[x+1]-v[x]==0?INT_MAX:v[x+1]-v[x]);
	}
	F0R(x,N)
	{
		if(v[x]<=K)
			continue;
		if((v[x]-K)%mn==0)
		{
			cout<<as[0]<<nl;
			return 0;
		}
	}
	cout<<as[1]<<nl;
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3700
n,m,x=[int(j) for j in input().split()]
l=[]
import numpy as np
for i in range(n):
    tmp=[int(j) for j in input().split()]
    l.append((tmp[0],np.array(tmp[1:])))
ans=10**18
for i in range(1<<n):
    tl=np.array([0]*m)
    tc=0
    for j in range(n):
        if i>>j&1:
            c,ll=l[j]
            tc+=c
            tl+=ll
    if len(tl[tl>=x])==m:
        ans=min(ans,tc)

if ans!=10**18:
    print(ans)
else:
    print(-1)

Measured memory_bytes: 27304
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}

struct Gcd {
    l_table: Vec<usize>,
    r_table: Vec<usize>,
}

impl Gcd {
    fn new() -> Gcd {
        Gcd {
            l_table: vec![],
            r_table: vec![],
        }
    }

    fn make_table(&mut self, vals: Vec<usize>) {
        self.l_table.push(0);
        for &val in vals.iter() {
            if let Some(&last) = self.l_table.last() {
                self.l_table.push(gcd(last, val));
            } else {
                self.l_table.push(val);
            }
        }

        for &val in vals.iter().rev() {
            if let Some(&last) = self.r_table.last() {
                self.r_table.push(gcd(last, val));
            } else {
                self.r_table.push(val);
            }
        }
        self.r_table.reverse();
        self.r_table.push(0);
    }

    fn gcd(&self, index: usize) -> usize {
        gcd(self.l_table[index], self.r_table[index+1])
    }
}

fn gcd(a: usize, b: usize) -> usize {
    if b == 0 {
        a
    }
    else if a % b == 0 {
        b
    } else {
        gcd(b, a % b)
    }
}

fn main() {
    let n = read::<usize>();
    let aa = read_vec::<usize>();

    let mut max = 1;
    let mut gcd = Gcd::new();
    gcd.make_table(aa);

    for i in 0..n {
        max = std::cmp::max(max, gcd.gcd(i));
    }
    println!("{}", max);
}

Measured memory_bytes: 11512
n,x = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
if a[0] > x:
    ans += a[0]-x
    tmp = x
else:
    tmp = a[0]
for i in range(1,n):
    if a[i] + tmp > x:
        tmp2 = a[i] + tmp - x
        ans += tmp2
        tmp = a[i] - tmp2
    else:
        tmp = a[i]
print(ans)

Measured memory_bytes: 63984
#include <iostream>

using namespace std;

int main(void){
    int N;
    int D;
    int X;
    cin>>N;
    cin>>D>>X;
    int A[N];
    for(int i = 0; i < N; i++){
        cin>>A[i];
    }

    int sum = X;
    for(int i = 0; i < N; i++){
        for(int d = 1; d <= D; d++){
            if(A[i]==1) sum++;
            else if((d % A[i])==1) sum++;
        }
    }

    cout<<sum<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

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

    const long long INF = 1LL << 50;
    vector<long long> dp(n + 1, -INF);
    dp[0] = 0;
    vector<pair<int, pair<int,int>>> pre(n + 1, make_pair(-1, make_pair(-1, -1))); 
    for (int i = 0; i < n; ++i) {
        long long sum = 0;
        long long& ans = dp[i + 1];
        for (int j = i; j >= i; j -= 2) {
            sum += A[j];
            if (ans < sum) {
                ans = sum;
                pre[i + 1] = make_pair(0, make_pair(j + 1, i + 1));
            }
            if (j - 2 >= 0 && ans < sum + dp[j - 2 + 1]) {
                ans = sum + dp[j - 2 + 1];
                pre[i + 1] = make_pair(pre[j - 2 + 1].second.second, make_pair(j + 1, i + 1));
            }
        }
        if (i - 2 >= 0 && dp[i - 2 + 1] > ans) {
            ans = dp[i - 2 + 1];
            pre[i + 1] = pre[i - 2 + 1];
        }
    }
    long long res = *max_element(dp.begin() + 1, dp.end());
    cout << res << '\n';
    vector<pair<int,int>> segs;
    {
        int cur = 0;
        for (int i = 1; i <= n; ++i) {
            if (dp[i] == res) {
                cur = i;
                break;
            }
        }
        // cout << cur << endl;
        while (cur > 0) {
            int l = pre[cur].second.first;
            int r = pre[cur].second.second;
            segs.emplace_back(l, r);
            cur = pre[cur].first;
        }
    }
    reverse(segs.begin(), segs.end());
    int revs = 0;

    vector<int> ops;
    if (!segs.empty()) {
        for (auto& s : segs) {
            // cout << s.first << " - " << s.second << '\n';
        }
        for (int i = 1; i < segs[0].first; ++i) {
            ops.push_back(1);
        }
        for (int i = n, j = 0; i > segs.back().second; --i, ++j) {
            ops.push_back(n - segs[0].first + 1 - j);
        }
        for (int j = 0; j < segs.size(); ++j) {
            int l = j == 0 ? 1 : 3;
            int r = segs[j].second - segs[j].first + l;
            for (int x = 2; x < r; x += 2) {
                ops.push_back(2);
            }

            if (j < segs.size()) {
                int ll = 2;
                int rr = segs[j + 1].first - 1 - segs[j].second - 1 + ll;
                for (int x = 3; x < rr; x += 2) {
                    ops.push_back(3);
                }
            }

        }
    } else {
        assert(0);
    }
    
    cout << ops.size() << '\n';
    for (auto x : ops) {
        cout << x << '\n';
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define rep(i,n) for(int i=0;i<(n);i++)
#define EPS (10e-9)

using namespace std;

double dp[16][9];
const string room[3] = { "ABC", "DEF", "GHI" };
const int dir[][2] = { {-1, 0 }, { 0, 1 }, { 1, 0 }, { 0, -1 } };

int main()
{
	int n;
	while (cin >> n && n ){
		char s, t, b;
		cin >> s >> t >> b;
		int cr = -1, cc = -1;

		rep (i, 16 ) rep (j, 9 ) dp[i][j] = 0.0;
		rep (i, 3 ) rep (j, 3 ){
			if (s == room[i][j] ){
				cr = i, cc = j;
				break;
			} // end if
		} // end rep

		dp[0][s-'A'] = 1.0;
		rep (i, n ){
			for (int j = 0; j < 9; j++ ){
				if (dp[i][j] > EPS ){
					cr = j/3, cc = j%3;
					char C = room[cr][cc];
					rep (k, 4 ){
						int nr = cr + dir[k][0];
						int nc = cc + dir[k][1];
						if (nr < 0 || nc < 0 || nr >= 3 || nc >= 3 || room[nr][nc] == b ){
							dp[i+1][C-'A'] += 1./4.*dp[i][C-'A'];
						}else{
							dp[i+1][room[nr][nc]-'A'] += 1./4.*dp[i][C-'A'];
						} // end if
					} // end rep
				} // end if
			} // end for
		} // end rep
		printf ("%.9lf\n", dp[n][t-'A'] );
	} // end loop
		
	return 0;
}

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

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

    int a[N+1];
    for(int i = 1; i <= N; i++) cin >> a[i];

    int ans = 0;
    for(int i = 0; i <= min(N, K); i++) {
        for(int j = 0; i+j <= min(N, K); j++) {
            vector<int> v;
            for(int x = 1; x <= i; x++) v.emplace_back(a[x]);
            for(int x = N; x >= N-j+1; x--) v.emplace_back(a[x]);

            sort(v.begin(), v.end());

            int rem = K-(i+j);
            int tot = 0;
            for(auto x: v) tot += x;

            for(int i = 0; i < min(rem, (int)v.size()); i++) {
                if(v[i] < 0) tot += abs(v[i]);
            }

            ans = max(ans, tot);
            
            // cout << "i is " << i << endl;
            // cout << "j is " << j << endl;
            // cout << "rem is " << rem << endl;
            // cout << "tot is " << tot << endl;
            // for(auto x: v) cout << x << " ";
            // cout << endl << endl;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int n;
ll a[100100];

bool check(int p){
	int i;
	ll sum = a[p];
	for(i=0; i<n; ++i){
		if(i==p){
			continue;
		}
		if(a[i]>sum*2){
			return false;
		}
		sum += a[i];
	}
	return true;
}

int main(void){
	int i,l,r,m;
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> a[i];
	}
	sort(a,a+n);
	if(check(0)){
		cout << n << endl;
		return 0;
	}
	l = 0; r = n;
	if(check(0)){
		cout << n << endl;
		return 0;
	}
	while(r-l>1){
		m = ((l+r)>>1);
		if(check(m)){
			r = m;
		}else{
			l = m;
		}
	}
	cout << (n-r) << endl;
	return 0;
}


Measured memory_bytes: 1024
fun c107(args: Array<String>) {
    val (n, k) = args[0].split(" ").map { it.toInt() }
    val numList = args[1].split(" ").map { it.toInt() }

    val ans = (0..numList.size - k)
            .map {
                Math.min(
                        Math.abs(numList[it]) + Math.abs(numList[it + k - 1] - numList[it]),
                        Math.abs(numList[it + k - 1]) + Math.abs(numList[it + k - 1] - numList[it])
                )
            }
            .min()

    println(ans)
}

fun main(args: Array<String>) {
    c107(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}

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

int main() {
    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    if (a == 0) cout << 1 << endl;
    else if (b == 0) cout << 2 << endl;
    else if (c == 0) cout << 3 << endl;
    else if (d == 0) cout << 4 << endl;
    else if (e == 0) cout << 5 << endl;
    return 0;
}

Measured memory_bytes: 3160
def check(p):
    global k, wlist   
    loadage = 0
    num = 1
    
    for w in wlist:
        loadage += w
        if loadage > p:
            num += 1
            if num > k:
                return False
            loadage = w
    return True

n, k = map(int, input().split())
wlist = []

for _ in range(n):
    wlist.append(int(input()))
    
maxw = max(wlist)
sumw = sum(wlist)
p = 0

while maxw < sumw:
    p = (maxw + sumw) // 2
    if check(p):
        sumw = p
    else:
        maxw = p = p+1
        
print(p)


Measured memory_bytes: 9556
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define scan(n,v) v.resize(n); rep(i,n){ cin>>v[i];}
#define MOD 1000000007ll
#define Yes(flag) cout<<((flag)? "Yes":"No");
#define YES(flag) cout<<((flag)? "YES":"NO");
#define be begin
#define pb push_back
#define fi first
#define se second
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
template<class T>T 
chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>T 
chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
//------------------------------------------------------
int n;
string p,q;
priority_queue<string> qu;
void input(){
    cin>>n;
    char s;
    rep(i,n){
        cin>>s;
        p+=s;
    }
    rep(i,n){
        cin>>s;
        q+=s;
    }
}
void src(){
    if(q<p){swap(p,q);}
    int ans=0;
    do{
        if(p==q){break;}
        ans++;
    }while(next_permutation(ALL(p)));
    cout<<ans;
}   
int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 256
local N, K = io.read("n", "n")

local ceil = math.ceil
local log = math.log
local function getx(n)
    return ceil(log(K/n, 2))
end

local ans = 0.0

local head_win_limit = math.min(K-1, N)
for n=1, head_win_limit do
    local x = getx(n)
    --print(n, x)
    ans = ans + (1.0/N) * ((1.0/2.0) ^ x)
end

if N-K+1 > 0 then
    ans = ans + (N-K+1.0)/N
end
print(ans)

Measured memory_bytes: 880
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxN = 80, inf = 1e7, dd = 80*80; int n, m;
int a[2][maxN][maxN];

int memo[maxN][maxN][2*dd + 1];
int solve(int i = 0, int j = 0, int da = 0, int db = 0)
{
  if (i == n - 1 && j == m - 1) return min(abs((da + a[0][i][j]) - (db + a[1][i][j])), abs((da + a[1][i][j]) - (db + a[0][i][j])));
  if (memo[i][j][abs(da - db)] != -1) return memo[i][j][abs(da - db)];
  int ans = inf;
  if (i + 1 < n)
  {
    ans = min(ans, solve(i + 1, j, da + a[0][i][j], db + a[1][i][j]));
    ans = min(ans, solve(i + 1, j, da + a[1][i][j], db + a[0][i][j]));
  }
  if (j + 1 < m)
  {
    ans = min(ans, solve(i, j + 1, da + a[0][i][j], db + a[1][i][j]));
    ans = min(ans, solve(i, j + 1, da + a[1][i][j], db + a[0][i][j]));
  }
  return memo[i][j][abs(da - db)] = ans;
}

int main()
{
  while (scanf("%d %d", &n, &m) != EOF)
  {
    for (int i = 0; i < 2; i ++)
      for (int j = 0; j < n; j ++)
        for (int k = 0; k < m; k ++)
          scanf("%d", &a[i][j][k]);
    memset(memo, -1, sizeof(memo));
    int ans = solve();
    printf("%d\n", ans);
  }
  return 0;
}

Measured memory_bytes: 320384
#include <bits/stdc++.h>
#define int long long int 
using namespace std;

signed main() {
    int n,m,x;
    cin>>n>>m>>x;
    int c[n];
    vector<vector<int>> v(n,vector<int>(m));
    for(int i=0;i<n;i++)
    {
        cin>>c[i];
        for(int j=0;j<m;j++)
        {
            cin>>v[i][j];
        }
    }
    int ans=INT_MAX;
    int all = 1<<n;
    for(int i=0;i<all;i++)
    {
        vector<int> lev(m,0);
        int cost=0;
        for(int j=0;j<n;j++)
        {
            if((i>>j) & 1)
            {
                cost += c[j];
                for(int j1=0;j1<m;j1++)
                {
                    lev[j1] += v[j][j1];
                }
            }
        }
        bool flag=1;
        for(int i1=0;i1<m;i1++)
        {
            if(lev[i1]<x)
            {
                flag=0;
            }
        }
        if(flag)
        {
            ans = min(ans,cost);
        }

    }
    if(ans==INT_MAX)
    cout<<-1;
    else
    cout<<ans;
    return 0;
}


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

using namespace std;

int main()
{
    string s;
    cin>>s;

    int l=s.length();
    long long int sum=0;
    for(int i=0;i<l;i++)
    {
        sum=sum+(s[i]-'0');

    }
    if(sum%9==0)
    {
        cout<<"Yes";
    }
    else
        cout<<"No";
    return 0;
}




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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;

#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()
constexpr auto INF = 2000000000;
constexpr auto MOD = 1000000007;


int main() {

	int n, k, q;
	cin >> n >> k >> q;
	vi p(n,0);

	rep(i, q) {
		int a;
		cin >> a;
		p[a - 1]++;
	}

	rep(i, n) {
		if (k - q + p[i]>0)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}

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

int main(void){
    int i;
    int num;
    int tmp;
    cin >> num;
    for (i = 1; i <= num; i++){
        tmp = i;
        if (i % 3 == 0 && !(i == 0)){
            cout << " " << i; 
        }
        else {
            while(tmp > 0){
                if (tmp%10 == 3){
                    cout << " " << i;
                    break;
                }
            tmp /= 10;
            }
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5+10 , OO = 0x3f3f3f3f;

#define clr(arr,val) memset(arr , val , sizeof (arr))
#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n)-1;i >= 0;i--)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define ALL(v) ((v).begin()) , ((v).end())
#define SZ(v)  ((int)((v).size()))
typedef pair <int,int> pii ;
typedef vector < pii > vii ;
typedef vector < int > vi;
int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);


int point[15][15];
int n ,d;


int main()
{   

      ios_base::sync_with_stdio(0);
      cin.tie(0);cout.tie(0);

      cin >> n >> d;
      loop(i, n){
            loop(j, d)
                  cin >> point[i][j];
      }      
      int cnt = 0;  // dis = 0;
      loop(i , n){
            range(j , i+1 , n-1){
                  int dis = 0;
                  loop(dimen, d){
                        dis += ((point[i][dimen]-point[j][dimen])*(point[i][dimen]-point[j][dimen]));
                  }
                  double ans = sqrt(dis);
                  int rkm = ans;
                  if(rkm-ans == 0) cnt++;
            }
      }
      cout << cnt << "\n";

      return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <utility>
using namespace std;

int main()
{
    char b;
    cin >> b;
    if(b == 'A'){
        cout << 'T' << endl;
    }else if(b == 'C'){
        cout << 'G' << endl;
    }else if(b == 'G'){
        cout << 'C' << endl;
    }else{
        cout << 'A' << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <utility>
#include <functional>

using namespace std;

int main() {
	string s;
	cin >> s;
	int n = s.size();
	cout << s[0] << n - 2 << s[n - 1] << endl;

	return 0;
}

Measured memory_bytes: 256
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    A, B, C, D, E, F = LI()

    # 水と砂糖の用意できるパターンを列挙
    # 水に対して砂糖の量を2分探索
    w = set()
    for i in range(F // (100 * A) + 1):
        for j in range((F - i * 100 * A) // (100 * B) + 1):
            if i != 0 and i != 0:
                w.add(i * A + j * B)
    # print(w)

    s = set()
    for i in range(F // C + 1):
        for j in range((F - i * C) // D + 1):
            s.add(i * C + j * D)
    s = list(s)
    s.sort()
    # print(s)

    ans = [A, 0]
    c = 0
    for i in w:
        ng = len(s)
        ok = -1
        while abs(ok-ng)>1:
            m = (ng+ok)//2
            if s[m] <= E * i and s[m] + 100 * i <= F:
                ok = m
            else:
                ng = m
        if 0 <= ok < len(s) and 100 * s[ok] / (i + s[ok]) > c:
            ans = [i, s[ok]]
            c = 100 * s[ok] / (i + s[ok])

    print(ans[0] * 100 + ans[1], ans[1])

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10184
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int n,m,a[102][102]={0},i,j;
    char tmp;
    cin>>n>>m; 
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++) 
        {
            cin>>tmp;
            if(tmp=='#') a[i][j]=1;
        }
    }
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            if(a[i][j]==1) cout<<'#';
            else cout<<a[i+1][j+1]+a[i+1][j-1]+a[i+1][j]+a[i][j+1]+a[i][j-1]+a[i-1][j+1]+a[i-1][j]+a[i-1][j-1];
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
INF = float("inf")


def yes():
    print("Yes")  # type: str


def no():
    print("No")  # type: str


def solve(s: str, t: str):
    s = "".join(sorted(list(s)))
    t = "".join(sorted(list(t), reverse=True))
    if s < t:
        yes()
    else:
        no()
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    s = next(tokens)  # type: str
    t = next(tokens)  # type: str
    solve(s, t)


if __name__ == '__main__':
    main()


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

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

    if (a < 0) {
        if (b < 0) {
            if (a == b) {
                cout << "Positive" << endl;
            } else if ((b + a) % 2 == 0) {
                cout << "Negative" << endl;
            } else {
                cout << "Positive" << endl;
            }
        } else {
            cout << "Zero" << endl;
        }
    } else if (a > 0) {
        if (b > 0) {
            cout << "Positive" << endl;
        } else {
            cout << "Zero" << endl;
        }
    } else {
        cout << "Zero" << endl;
    }

    return 0;
}


Measured memory_bytes: 3600
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce


def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


def MAP(): return map(int, input().split())


def LIST(): return list(map(int, input().split()))


def ZIP(n): return zip(*(MAP() for _ in range(n)))


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    K = INT()
    S = input()
    if len(S) <= K:
        print(S)
    else:
        T = S[:K] + "..."
        print(T)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10596
#include <bits/stdc++.h>
#define F first
#define S second
#define $ ios::sync_with_stdio(0);
#define endl '\n'
using namespace std;
using ll = long long int;
using ii = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<ii>;
using graph = vector<vi>;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
const int MAXN = 212345;
const ll mod = 1000000007;
int v[MAXN];
int main() {
    int n;
    ll sqs = 0, sum = 0;
    scanf("%d", &n);
    int minor = INF, major = -INF;
    for (int i = 0; i<n; ++i) {
        scanf("%d", v+i);
        sum += v[i];
        sqs += v[i] * v[i];
        if (v[i] < minor) minor = v[i];
        if (v[i] > major) major = v[i];
    }
    ll ans = INFL, aux;
    for (int i = minor; i<=major; ++i) {
        aux = sqs - 2LL*i*sum + n*i*i;
        ans = min(ans, aux);
    }
    printf("%lld\n", ans);

}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
#define FOR(i,a,b) for(ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
int main(){
  int n,h,w;
  cin >> n >> h >> w;
  int ans = 0;
  int a,b;
  REP(i,n) {
    cin >> a >> b;
    if(a>=h&&b>=w) ans++;
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define REPW(i,n) for(i=0;i<(int)(n);++i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : "\n"); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> *i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> " " >> p.second; return is; }
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------
 
int cnt[26];
signed main() {
    string s;
    cin>>s;
    int n=SZ(s);
 
    int ans=n*(n+1)/2+1;
    REP(i,n) {
        cnt[s[i]-'a']++;
        ans-=cnt[s[i]-'a'];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 720
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

#include <bits/stdc++.h>
using namespace std;



int main() {
    int X,Y,Z;

    cin >> X >> Y >> Z;

    swap(X,Y);
    swap(X,Z);

    cout << X << " " << Y << " " << Z << endl;
}


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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

signed main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(c <= a+b) cout << "Yes\n";
    else cout << "No\n";
    return 0;   
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int at[110];
int use[110];
int last[110];
int req[110][110];
int sr[110];
int lis[11000];
int main(){
	int a,b,c;
	while(scanf("%d%d%d",&a,&b,&c),a){
		int ret=0;
		for(int i=0;i<110;i++)use[i]=0;
		for(int i=0;i<110;i++)at[i]=a+1;
		for(int i=0;i<110;i++)last[i]=0;
		for(int i=0;i<c;i++){
			int d;scanf("%d",&d);
			sr[i]=d;
			for(int j=0;j<d;j++)scanf("%d",&req[i][j]);
		}
		int L=0;
		for(int i=0;i<60;i++){
			for(int j=0;j<c;j++)if(sr[j]>i)lis[L++]=req[j][i];
		}
		int t=0;
		for(int i=0;i<L;i++){
				int e=lis[i];
				ret+=at[e];
				if(at[e]<a+1)use[at[e]]--;
				last[e]=t;
				t++;
				if(use[1]<b){
					use[1]++;ret++;at[e]=1;
				}else{
					for(int i=2;i<=a+1;i++){
						if(i==a+1||use[i]<b){
							use[i]++;at[e]=i;ret+=i;break;
						}
					}
					int f=9999999;
					int v=0;
					for(int i=0;i<110;i++)if(at[i]==1){
						if(f>last[i]){f=last[i];v=i;}
					}
					ret++;
					for(int i=2;i<=a+1;i++){
						if(i==a+1||use[i]<b){
							use[i]++;at[v]=i;ret+=i;break;
						}
					}
					use[at[e]]--;ret+=at[e];ret++;at[e]=1;
				}
			
		}
		printf("%d\n",ret);
	}
}

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

int abs(int x){
	if(x>0) return x;
	else return -x;
}

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

    int* a = new int[N];
    int index = 0;
    int minuscount = 0;
    for(int i=0;i<N;i++){
    	cin >> a[i];
    	if(abs(a[index]) > abs(a[i]) ){
    		index = i;
    	}
    	if(a[i] < 0) minuscount++;
    }

    long sum = 0;

    for(int i=0;i<N;i++){
    	if(i == index && minuscount % 2 == 1) sum -= abs(a[i]);
    	else sum += abs(a[i]);
    }
    cout << sum << endl;
  	
}

Measured memory_bytes: 640
N = int(input())
num = [0,0,0,0,0]
for i in range(N):
	a = input()
	if a[0]=='M':
		num[0] += 1
	if a[0]=='A':
		num[1] += 1
	if a[0]=='R':
		num[2] += 1
	if a[0]=='C':
		num[3] += 1
	if a[0]=='H':
		num[4] += 1


num_1 = num[0]*num[1]*num[2]
num_2 = num[0]*num[1]*num[3]
num_3 = num[0]*num[1]*num[4]
num_4 = num[1]*num[2]*num[3]
num_5 = num[1]*num[2]*num[4]
num_6 = num[2]*num[3]*num[4]
num_7 = num[0]*num[2]*num[3]
num_8 = num[0]*num[2]*num[4]
num_9 = num[0]*num[3]*num[4]
num_10 = num[1]*num[3]*num[4]

answer = num_1 + num_2 + num_3 + num_4 + num_5 + num_6 + num_7 + num_8 + num_9 + num_10

print(answer)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    ll n,a,b;
    cin >> n >> a >> b;
    if((b-a)%2 == 0){
        cout << (b-a)/2 << endl;
    }else{
        cout << (b-a)/2 + 1 + min(a-1, n-b);
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Roc ios_base::sync_with_stdio(false), cin.tie(NULL)
#define ll long long
#define NMAX 3009
using namespace std;
long double pd[NMAX][NMAX], v[NMAX], ans;
int n, cat;

int main()
{
    Roc;
    cin >> n;
    cat = (n + 1) / 2;
    for(int i = 1; i <= n; ++i)
        cin >> v[i];


    pd[1][0] = 1 - v[1];
    for(int i = 2; i <= n; ++i)
        pd[i][0] =  (1 - v[i]) * pd[i- 1][0];
    pd[1][1] = v[1];

    for(int i = 1; i <= n; ++i)
        for(int j = 1; j <= n; ++j)
        {
            pd[i][j] += pd[i-1][j-1] * v[i] + pd[i - 1][j] * (1.00 - v[i]);
        }

    for(int i = cat; i <= n; ++i)
        ans += pd[n][i];
    cout << setprecision(10) << ans << '\n';
    return 0;
}


Measured memory_bytes: 141568
use std::collections::VecDeque;

mod input {
    use std;

    pub fn read_line() -> String {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
        read_line()
            .split(' ')
            .filter_map(|x| x.parse::<T>().ok())
            .collect::<Vec<T>>()
    }

    pub fn read_chars() -> Vec<char> {
        read_line().chars().collect()
    }
}

fn main() {
    let (n, m) = {
        let token = input::read_vec::<usize>();
        (token[0], token[1])
    };

    let a = (0..n).map(|_| input::read_chars()).collect::<Vec<_>>();

    let mut queue: VecDeque<(usize, usize)> = VecDeque::new();
    let mut dist: Vec<Vec<i32>> = vec![vec![1000005; m]; n];

    for i in 0..n {
        for j in 0..m {
            if a[i][j] == '#' {
                dist[i][j] = 0;
                queue.push_back((i, j));
            }
        }
    }

    while let Some((i, j)) = queue.pop_front() {
        for (ni, nj) in [(!0usize, 0usize), (1, 0), (0, !0), (0, 1)]
            .iter()
            .map(|&(di, dj)| (i.wrapping_add(di), j.wrapping_add(dj)))
            .filter(|&(ni, nj)| ni < n && nj < m)
        {
            if dist[i][j] + 1 < dist[ni][nj] {
                dist[ni][nj] = dist[i][j] + 1;
                queue.push_back((ni, nj));
            }
        }
    }

    if let Some(ans) = dist.iter().filter_map(|x| x.iter().max()).max() {
        println!("{}", ans);
    }
}


Measured memory_bytes: 27896
num = int(input())
Lucas_num = []
for i in range(87):
    if i == 0:
        Lucas_num.append(2)
    elif i == 1:
        Lucas_num.append(1)
    else:
        Lucas_num.append(Lucas_num[i - 2] + Lucas_num[i - 1])

print(Lucas_num[num])


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

using namespace std;

int main(){
 	int x=0, max=0;
  	int n; cin >> n;
  	string s;
  	cin >> s;
  	for(char i:s){
     	if(i=='I')
          	x++;
     	else if(i=='D')
          	x--;
      	if(x>max) max=x;
    }
  	cout << max;
}

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

int p, q;
int main() {
	cin >> p >> q;
	vector<int> A = {};
	for (int i = 2; i * i <= q; i++) {
		if(q % i == 0) {
			A.push_back(i);
			A.push_back(q / i);
		}
	}
	for (auto i : A) {
		while (p % i == 0 and q % i == 0) {
			p /= i;
			q /= i;
		}
	}
	vector<int> pr ={};
	for (int i = 2; i * i <= q; i++) {
		if (q % i == 0) pr.push_back(i);
		while (q % i == 0) q /= i;
	}
	for (auto pp : pr) {
		q *= pp;
	}
	cout << q << endl;
}



Measured memory_bytes: 3168
#include <vector>
#include <iostream>
#include <vector>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
using ll = long long ;

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

    if(x>=400 && x<=599){
        cout << 8 << endl ;
    }else if(x>=600 && x<=799){
        cout << 7 << endl ;
    }else if(x>=800 && x<=999){
        cout << 6 << endl ;
    }else if(x>=1000 && x<=1199){
        cout << 5 << endl ;
    }else if(x>=1200 && x<=1399){
        cout << 4 << endl ;
    }else if(x>=1400 && x<=1599){
        cout << 3 << endl ;
    }else if(x>=1600 && x<=1799){
        cout << 2 << endl ;
    }else if(x>=1800 && x<=1999){
        cout << 1 << endl ;
    }

    return 0 ;
}


Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

bool increment(ll aa[], ll n, ll m){
    rep(i, n){
        if(aa[i] < m){
            aa[i]++;
            rep(j, i){
                aa[j] = aa[i];
            }
            return true;
        }

        if(i == n - 1){
            return false;
        }
    }

    cout << "error" << endl;
    return false;
}

void print_aa(ll aa[], ll n){
    repr(i, n){
        cout << aa[i] << " ";
    }
    cout << endl;
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n, m, q; cin >> n >> m >> q;
    ll a[q], b[q], c[q], d[q];
    rep(i, q){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--; b[i]--;
        a[i] = n - 1 - a[i];
        b[i] = n - 1 - b[i];
    }

    ll aa[n];
    rep(i, n){
        aa[i] = 1;
    }

    ll max_score = 0;

    do{
        ll temp_score = 0;
        // print_aa(aa, n);
        rep(i, q){
            // cout << aa[b[i]] - aa[a[i]] << " " << c[i] << endl;
            if(aa[b[i]] - aa[a[i]] == c[i]){
                temp_score += d[i];
                // cout << "added" << endl;
            }
        }
        // cout << endl;

        max_score = max(max_score, temp_score);
    }
    while(increment(aa, n, m));

    cout << max_score << endl;

    return 0;
}

Measured memory_bytes: 3616
a,b,c,x,y = map(int,input().split())

ans = [0,0,0]
ans[0] = a*x + b*y
ans[1] = max(x,y)*2*c

if x < y:
  ans[2] += x*2*c
  ans[2] += b*(y-x)
else:
  ans[2] += y*2*c
  ans[2] += a*(x-y)
print(min(ans))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 200005
#define il inline
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,n,a) for(int i=n;i>=a;i--)
#define  pi  acos(-1)
#define ld  double
#pragma GCC optimize(2)
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int a[N],cnt[N];
int main() {
    IOS
    int n;
    cin>>n;
    for(int i=2;i<=n;i++){
        cin>>a[i];
        cnt[a[i]]++;
    }
    for (int j = 1; j <=n ; ++j) {
        cout<<cnt[j]<<endl;
    }
    return 0;
}

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

int main() {
	int N, M, D, T;
	bool check = true;
	map<int, int> mp;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> D;
		mp[D]++;
	}
	cin >> M;
	for (int i = 0; i < M; i++) {
		cin >> T;
		if (mp[T] == 0) check = false;
		else mp[T]--;
	}
	if (check) puts("YES");
	else puts("NO");
}

Measured memory_bytes: 9600
import sys
from collections import deque
stdin=sys.stdin

ns=lambda:input().rstrip()
ni=lambda:int(input().rstrip())
nm=lambda:map(int,input().split())
nl=lambda:list(map(int,input().split()))

N,Q=nm()
AB=[nl() for i in range(N-1)]
PQ=[nl() for i in range(Q)]
root=[[] for i in range(N)]
N_val=[0]*N
ans_val=[0]*N
d=[0]*N

def bfs():
  que=deque([])
  que.append(0)
  while que:
    p=que.popleft()
    for i in root[p]:
       if(d[i]==0):
         ans_val[i]=ans_val[p]+N_val[i]
         que.append(i)
         d[i]=1
      
def dfs(x,d,s):
  for i in root[x]:
    if(d[i]==0):
      s+=N_val[i]
      ans_val[i]=s
      d[i]=1
      dfs(i,d,s)
      s-=N_val[i]
      

for i in range(N-1):
  root[AB[i][0]-1]+=[AB[i][1]-1]
  root[AB[i][1]-1]+=[AB[i][0]-1]
  
for i in range(Q):
  N_val[PQ[i][0]-1]+=PQ[i][1]

  
ans_val[0]=N_val[0]
d[0]=1
#dfs(0,d,N_val[0])
bfs()
print(*ans_val)

Measured memory_bytes: 123296
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	int n,m;
    cin>>n>>m;
    vi h(n);
    vi c(n,1);
    FOR(i,0,n){
        cin>>h[i];
    }
    vi a(m),b(m);
    FOR(i,0,m){
        cin>>a[i]>>b[i];
        a[i]--;b[i]--;
        if(h[a[i]]>h[b[i]]){
            c[b[i]]=0;
        }else if(h[a[i]]<h[b[i]]){
            c[a[i]]=0;
        }else{
            c[a[i]]=0;
            c[b[i]]=0;
        }
    }

    int sm=0;
    FOR(i,0,n){
        sm+=c[i];
    }
    cout<<sm;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int main(){
	string s;
	cin >> s;
	int a[26];
	FOR(i,26) a[i]=0;
	int i=0;
	while(i < s.length()){
		a[s[i]-'a']++;
		i++;
	}
	int j=0;
	for(;j<26;j++){
		if(a[j] >1) break;
	}
	//for(;j<26;j++) cout << a[i] <<" ";
	//cout << j;
	if(j>=26) cout << "yes";
	else cout <<"no";
	return 0;
}

Measured memory_bytes: 256