akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define maxn 101000
struct obj
{
	int a,b,c;
	bool operator <(const obj& jj) const 
	{
		return (a-b)<(jj.a-jj.b);
	}
	void input()
	{
		scanf("%d%d%d",&a,&b,&c);
	}
}a[maxn];
int x,y,z,n;
ll mx1[maxn],mx2[maxn];
priority_queue<int>Q;

int main()
{
	scanf("%d%d%d",&x,&y,&z);
	n=x+y+z;
	for(int i=1;i<=n;++i) a[i].input();
	sort(a+1,a+1+n);
	while(!Q.empty()) Q.pop();
	ll tot=0;
	for(int i=1;i<=y;++i)
	{
		Q.push(a[i].c-a[i].b);
		tot+=a[i].b;
	}
	mx1[y]=tot;
	for(int i=y+1;i<=n;++i)
	{
		Q.push(a[i].c-a[i].b);
		tot+=a[i].b;
		int tmp=Q.top(); Q.pop();
		tot+=tmp;
		mx1[i]=tot;
		//printf("mx[%d]=%lld\n",i,mx1[i]);
	}
	tot=0;
	while(!Q.empty()) Q.pop();
	for(int i=n;i>=n-x+1;--i)
	{
		Q.push(a[i].c-a[i].a);
		tot+=a[i].a;
	}
	mx2[n-x+1]=tot;
	for(int i=n-x;i>=1;--i)
	{
		Q.push(a[i].c-a[i].a);
		tot+=a[i].a;
		int tmp=Q.top(); Q.pop();
		tot+=tmp;
		mx2[i]=tot;
		//printf("mx2[%d]=%lld\n",i,mx2[i]);
	}
	ll ans=0;
	for(int i=y;i<n-x+1;++i)
		ans=max(ans,mx1[i]+mx2[i+1]);
	printf("%lld\n",ans);
	return 0;
}


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

using namespace std;

const int maxn = 100010;
int n,k,head[maxn],to[maxn],nextt[maxn],tot = 1,ans;

void add(int x,int y)
{
    to[tot] = y;
    nextt[tot] = head[x];
    head[x] = tot++;
}

int dfs(int u,int faa,int from)
{
    int res = 0;
    for (int i = head[u];i;i = nextt[i])
    {
        int v = to[i];
        if (v == faa)
            continue;
        res = max(res,dfs(v,u,from) + 1);
    }
    if (u != from && res >= k - 1)
    {
        ans++;
        return -1;
    }
    else
        return res;
}

int main()
{
    scanf("%d%d",&n,&k);
    for (int i = 1; i <= n; i++)
    {
        int x;
        scanf("%d",&x);
        if (i == 1)
        {
            if (x != 1)
                ans++;
        }
        else
            add(x,i);
    }
    for (int i = head[1];i;i = nextt[i])
        dfs(to[i],1,to[i]);
    printf("%d\n",ans);

    return 0;
}


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

int main() {
	int X, Y, Z, K;
	cin >> X >> Y >> Z >> K;
	vector<vector<vector<char>>> Used(X, vector<vector<char>>(Y, vector<char>(Z, 0)));
	vector<long long> A(X), B(Y), C(Z);
	for (int i = 0; i < X; i++) cin >> A[i];
	for (int i = 0; i < Y; i++) cin >> B[i];
	for (int i = 0; i < Z; i++) cin >> C[i];
	sort(A.begin(), A.end(), greater<long long>());
	sort(B.begin(), B.end(), greater<long long>());
	sort(C.begin(), C.end(), greater<long long>());
	priority_queue<pair<long long, vector<int>>> Q;
	Q.push({ A[0] + B[0] + C[0],{0,0,0} });
	for (int i = 0; i < K; i++) {
		auto p = Q.top();
		int a = p.second[0], b = p.second[1], c = p.second[2];
		cout << p.first << endl;
		Q.pop();
		if (a + 1 < X && !Used[a + 1][b][c]) Q.push({ A[a + 1] + B[b] + C[c], {a + 1,b,c} }), Used[a + 1][b][c] = 1;
		if (b + 1 < Y && !Used[a][b + 1][c]) Q.push({ A[a] + B[b + 1] + C[c], {a,b + 1,c} }), Used[a][b + 1][c] = 1;
		if (c + 1 < Z && !Used[a][b][c + 1]) Q.push({ A[a] + B[b] + C[c + 1], {a,b,c + 1} }), Used[a][b][c + 1] = 1;
	}
}


Measured memory_bytes: 1012248
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>
#include <cassert>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;



int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;cin>>N;
  bool winner=0;
  repeat(i,N){
    ll a;cin>>a;
    winner |= a&1;
  }
  cout << (winner? "first":"second") <<endl;
  return 0;
}


Measured memory_bytes: 256
N = input()

N_list = []
for s in N:
    N_list.append(s)

if N_list[0] == N_list[1] and N_list[1] == N_list[2]:
    print('Yes')
elif N_list[1] == N_list[2] and N_list[2] == N_list[3]:
    print('Yes')
else:
    print('No')


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};


int main()
{
  int n; cin >> n;
  ll T = 0, A = 0;

  rep(i, n) {
    ll t, a; cin >> t >> a;
    if(i == 0) {
      T = t;
      A = a;
      continue;
    }

    ll i_t = T/t;
    ll i_a = A/a;

    ll j = max(i_t, i_a);

    if(t*j < T || a*j < A) ++j;

    T = t*j; A = a*j;
  }

  cout << A+T << endl;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int

using namespace std;

int main()
{
    string r;

    cin >> r;

    int i , p;

    int a[26]={0};

    for(i=0;i<r.size();i++)
    {
        p=r[i];

        if(p>=97 && p<=122)
        {
            p=r[i]-'a';

            a[p]++;
        }



    }

    bool flg=0;

    for(i=0;i<26;i++)
    {
        if(a[i]%2!=0)
        {
            flg=1;

            break;
        }
    }

    if(flg==1)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }

    return 0;
}


Measured memory_bytes: 3596
using System;

namespace _0051
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                string s = Console.ReadLine();
                int[] x = new int[8];
                for (int j = 0; j < 8; j++)
                {
                    x[j] = s[j];
                }
                Array.Sort(x);
                int max = 0;
                int a = 1;
                for (int j = 0; j < 8; j++)
                {
                    max += x[j] * a;
                    a *= 10;
                }
                Array.Reverse(x);
                int min = 0;
                a = 1;
                for (int j = 0; j < 8; j++)
                {
                    min += x[j] * a;
                    a *= 10;
                }
                Console.WriteLine(max - min);
            }
        }
    }
}

Measured memory_bytes: 9116
#include <stdio.h>
#define MAX 101
#define WHITE 0
#define GRAY 1
#define BLACK 2

int G[MAX][MAX],color[MAX],d[MAX],f[MAX],num,time;

void dfs(int u){
  int ver;
  color[u] = GRAY;
  d[u] = ++time;
  for(ver=1; ver<=num; ver++){
    if(G[u][ver] && color[ver] == WHITE) dfs(ver);
  }
  color[u] = BLACK;
  f[u] = ++time;
 
}

int main(){
  int i,j,u,k,v;

  scanf("%d",&num);
  for(i=1; i<=num; i++){
    color[i] = WHITE;
    for(j=1; j<=num; j++){
      G[i][j] = 0;
    }
  }
  for(i=1; i<=num; i++){
    scanf("%d%d",&u,&k);
    for(j=1; j<=k; j++){
      scanf("%d",&v);
      G[u][v] = 1;
    }
  }

  time = 0;

  for(u=1; u<=num; u++) {
    if(color[u] == WHITE) dfs(u);
  }

  for(u=1; u<=num; u++){
    printf("%d %d %d\n",u,d[u],f[u]);
  }
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
    int t,n;
   cin >> t >> n;
   int b;
   int sum = 0;
   for(int i = 0;i < n;i++){
        cin >> b;
        sum+=b;
   }
   if (sum >= t){
    cout << "Yes";
   }else{cout << "No";}
}


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

typedef long long ll;
#define all(x) (x).begin(),(x).end()

int main(){
    
    int N;cin>>N;
    vector<int> S(N+1,0);
    for(int i=1;i<=N;i++){
        int a;cin>>a;
        S[i]=S[i-1]+a;
    }
    int ans=100000000;
    for(int i=1;i<N;i++){
        int a=S[i];
        int b=S[N]-S[i];
        int c=abs(a-b);
        ans=min(ans,c);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
N,K = map(int,input().split())
A=  list(map(int,input().split()))
now = 0
if K <= N:
    for i in range(K):
        now = A[now]-1
    print(now+1)
else:
    alr = [0]
    alr2 = [False for i in range(N)]
    alr2[0] = True
    now = 0
    for i in range(K):
        now = A[now]-1
        if alr2[now] == False:
            alr.append(now)
            alr2[now] = True
        else:
            loop = alr[alr.index(now):]
            rem = K - i - 1
            break
    ans = loop[rem%len(loop)]+1
    print(ans)
    

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

typedef long long ll;

int main() {
	ios::sync_with_stdio(0);
	
	string a, b;
	cin >> a >> b;
	string s = a+b;
	ll ans = stoll(s);
	ll k = sqrt(ans);
	cout << (k*k == ans ? "Yes" : "No");
	
	return 0;
}

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

int main()
{
	int n, k, q;
	cin >> n >> k >> q;

	vector<int> arr(n, k);
	map<int, int> m;

	for (int i = 0; i < q ;i++)
	{ 
		int a;
		cin >> a;
		if (m.find(a ) == m.end())
		{
			m.insert(make_pair(a, 0));
		}
		m[a]++;
	}
	
	for (int i = 0; i < n; i++)
	{
		arr[i] = arr[i] - q + m[i + 1];

		if (arr[i] <= 0)
		{
			cout << "No" << endl;
		}
		else
		{
			cout << "Yes" << endl;
		}
	}
}

Measured memory_bytes: 5760
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>


typedef long long ll;
typedef long double ld;

using namespace std;

map<int, int> ss;

void ex() {
	cout << "Impossible\n";
	exit(0);
}

void gd() {
	cout << "Possible\n";
	exit(0);
}

int a[1200];
int n;

int main() {
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		++ss[a[i]];
	}
	int mx = ss.rbegin()->first;
	--ss[mx];
	if (!ss[mx]) {
		ex();
	}
	--ss[mx];
	for (int i = mx - 1; i > mx / 2; --i) {
		if (!ss[i])
			ex();
		--ss[i];
	}
	for (int i = mx - 1; i > mx / 2; --i) {
		if (!ss[i])
			ex();
		--ss[i];
	}
	if (mx % 2 == 0) {
		if (!ss[mx / 2])
			ex();
		--ss[mx / 2];
	}
	if (mx == 1) {
		if (n != 2) {
			ex();
		}
		gd();
	}
	int lb, rb = mx;
	if (mx % 2 == 0)
		lb = mx / 2 + 1;
	else
		lb = mx / 2 + 2;
	for (pair<int, int> i: ss) {
		if (i.second == 0)
			continue;
		if (i.first < lb || i.first > rb) {
			ex();
		}
	}
	gd();

	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
#define __lcm(a,b) ((a)/__gcd(a,b)*(b))
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950288419716939937510582097;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}
const int MAX_N=100005;
LL C,x[MAX_N],v[MAX_N],A[MAX_N],B[MAX_N],n,ans; 
int main()
{
	cin>>n>>C;
	x[n+1]=C;
	For(i,1,n)cin>>x[i]>>v[i];
	For(i,1,n)A[i]=A[i-1]+x[i-1]-x[i]+v[i];
	per(i,n,1)B[i]=B[i+1]+x[i]-x[i+1]+v[i];
	For(i,2,n)A[i]=max(A[i],A[i-1]);
	per(i,n-1,1)B[i]=max(B[i+1],B[i]);
	For(i,1,n)ans=max(ans,max(max(A[i],B[i]),max(A[i-1]+B[i]-(C-x[i]),A[i]+B[i+1]-x[i])));
	cout<<ans<<endl;
	return 0;
}



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

using namespace std;

#define mod 1e9+7
#define ll long long int
#define epsilon 1e-7

ll ma(ll x, ll y){
    if(x>y)return x;
    return y;
}
char l[100003];
ll dp[100003][2];
int main(void){
    scanf("%s", &l);
    int n = 0;
    while(l[n] != '\0')n++;
    //printf("%d, %s\n", n, l);
    dp[0][0] = 1;
    dp[0][1] = 0;
    for(int i = 0;i < n;i++){
        for(int j = 0;j < 2;j++){
            for(int d = 0;d <= (j?1:l[i]-'0');d++){
                if(!d){
                    dp[i+1][j || (d < l[i]-'0')] += dp[i][j];
                    dp[i+1][j || (d < l[i]-'0')] %= 1000000007;
                }else{
                    dp[i+1][j || (d < l[i]-'0')] += dp[i][j] * 2;
                    dp[i+1][j || (d < l[i]-'0')] %= 1000000007;
                }
            }
        }
        /*for(int i = 0;i <= n;i++){
        for(int j = 0;j < 2;j++){
            printf("dp[%d][%d] = %7lld ",i, j, dp[i][j]);
        }
        printf("\n");
        }*/
    }
    /*for(int i = 0;i <= n;i++){
        for(int j = 0;j < 2;j++){
            printf("dp[%d][%d] = %7lld ",i, j, dp[i][j]);
        }
        printf("\n");
    }*/
    printf("%lld\n", (dp[n][0] + dp[n][1])%1000000007);
    return 0;
}

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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	vector<int> a;
	for(int i=0; i<3; i++){
		int t;
		cin >> t;
		a.pb(t);
	}

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

	if(a[0] + a[1] == a[2]){
		puts("Yes");
	}else{
		puts("No");
	}
	
	
	return 0;
}


Measured memory_bytes: 256
N, K = gets.split(' ').take(2).map(&:to_i)
height_list = gets.split(' ').take(N).map(&:to_i)

dp = Array.new(N, Float::INFINITY)
dp[0] = 0

for i in 0...(N - 1)
  height = height_list[i]
  for j in 1..K
    break if i + j > N - 1
    cost = dp[i] + (height - height_list[i + j]).abs
    dp[i + j] = cost if cost < dp[i + j]
  end
end

puts dp[N - 1]


Measured memory_bytes: 13732
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime;

namespace AtCoder.D
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var (N, X) = Read2Longs();
            var p = new long[N + 1];
            var count = new long[N + 1];
            count[0] = 1;
            p[0] = 1;
            for (var i = 1; i <= N; i++)
            {
                count[i] = 2 * count[i - 1] + 3;
                p[i] = 2 * p[i - 1] + 1;
            }
            var pcount = 0L;
            var j = N;
            while (X > 0 && j > 0)
            {
                var kukaku = GetKukaku(count[j], X);
                if (kukaku == 1)
                {
                    X -= X;
                }
                else if (kukaku == 2)
                {
                    X -= 1;
                }
                else if (kukaku == 3)
                {
                    pcount += p[j - 1] + 1;
                    X -= X;
                }
                else if (kukaku == 4)
                {
                    pcount += p[j - 1] + 1;
                    X -= count[j - 1] + 2;
                }
                else if (kukaku == 5)
                {
                    pcount += p[j];
                    X -= X;
                }
                j--;
            }
            if (X > 0)
            {
                pcount++;
            }
            return pcount;
        }
        private static int GetKukaku(long n, long x)
        {
            var line = (n - 3) / 2;
            if (x == 1)
            {
                return 1;
            }
            else if (x <= line + 1)
            {
                return 2;
            }
            else if (x == line + 2)
            {
                return 3;
            }
            else if (x <= 2 * line + 2)
            {
                return 4;
            }
            else
            {
                return 5;
            }
        }
        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 28244
N, M = map(int, input().split()) 
AB = [list(map(int, input().split())) for i in range(N)]
AB.sort()
cost = 0
while M > 0:
  if AB[0][1] < M:
    cost = cost + AB[0][0]*AB[0][1]
    M=M-AB[0][1]
    AB.pop(0)
  else:
    cost = cost + AB[0][0]*M
    M = 0
    
print(cost)
    

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

int main()
{
    string s;
    cin >> s;
    for (int i = 0; i < s.size() - 1; i++) {
        if (s[i] == s[i + 1]) {
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
    return 0;
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string r, g, b;
	cin >> r >> g >> b;
	string T = r + g + b;
	int res = stoi(T);
	if (res % 4 == 0) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define endl "\n"
#define ll long long
#define sz(s) (int)(s.size())
#define INF 0x3f3f3f3f3f3f3f3fLL
#define all(v) v.begin(),v.end()
#define watch(x) cout<<(#x)<<" = "<<x<<endl
const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };
#if __cplusplus >= 201402L
template<typename T>
vector<T> create(size_t n) {
	return vector<T>(n);
}
template<typename T, typename ... Args>
auto create(size_t n, Args ... args) {
	return vector<decltype(create<T>(args...))>(n, create<T>(args...));
}
#endif
void run() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifdef EZZAT
	freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#else
#endif
}

int main() {
	run();
	int n, m;
	cin >> n >> m;
	vector<int> h(n + 1);
	vector<bool> good(n + 1, true);
	for (int i = 1; i <= n; i++)
		cin >> h[i];
	while (m--) {
		int u, v;
		cin >> u >> v;
		if (h[u] >= h[v])
			good[v] = false;
		if (h[u] <= h[v])
			good[u] = false;
	}
	int cnt = 0;
	for (int i = 1; i <= n; i++)
		cnt += good[i];
	cout << cnt << endl;
}


Measured memory_bytes: 3728
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>


using namespace std;
using namespace __gnu_pbds;


#define LL long long
#define N 100005
#define MOD 1000000007
#define dd double
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

int main() {

ios_base::sync_with_stdio(false);
cin.tie(NULL);
	
	int t=1;
	//cin>>t;
	while(t--){
		string s;
		cin>>s;
		if(s=="AAA" || s=="BBB")
			cout<<"No"<<'\n';
		else
			cout<<"Yes"<<'\n';
	}



return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll, ll> pair_t;
using Graph = vector<vector<ll>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 3.1415926535897932;
const ll INF = 1 << 29;
/****** define constant end ********/

/****** define variable start ******/
ll x, y, z;
/******* define variable end *******/

ll solve() {
  cin >> x >> y >> z;
  cout << z << " " << x << " " << y;
  return 0;
}
int main() {
  // clock_t start = clock();
  cout << std::fixed << std::setprecision(10);
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll end_solve = solve();
  /*
  clock_t end = clock();
  const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
  1000.0; printf("time %lf[ms]\n", time);
  */

  return (int)end_solve;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define REPR(i,n) for(int i=n-1; i>=(int)(0); i--)
#define FOR(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define FORR(i,a,b) for(int i=(int)(b)-1; i>=(int)(a); i--)
#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()
//**関数リスト**//
int ctoi(char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.second < secondElof.second;
}
ll nod(ll F) {
	ll keta = 1;
	while (F / 10 > 0) {
		keta++;
		F /= 10;
	}
	return keta;
}
ll gcd(ll x, ll y) {
	ll r;
	if (x < y) {
		swap(x, y);
	}
	while (y > 0) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}
ll lcm(ll x, ll y) {
	return x * y / gcd(x, y);
}
ll isPrime(ll x) {
	ll i;
	if (x < 2) {
		return 0;
	}
	else if (x == 2) {
		return 1;
	}
	else if (x % 2 == 0) {
		return 0;
	}
	else {
		for (i = 3; i * i <= x; i += 2) {
			if (x % 1 == 0) {
				return 0;
			}
		}
		return 1;
	}
}
void eratos(vl isPrime) {
	//(注)isPrimeのサイズはN+1にする！実際にはmain内に配置して使用
	ll i, j;
	REP(i, isPrime.size()) {
		isPrime[i] = 1;
	}
	isPrime[0] = 0; isPrime[1] = 0;
	for (i = 2; i * i <= isPrime.size() - 1; i++) {
		if (isPrime[i] == 1) {
			j = i * 2;
			while (j <= isPrime.size() - 1) {
				isPrime[j] = 0;
				j = j + i;
			}
		}
	}
}
ll modinv(ll a, ll m) {
	ll b = m, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
void bitSearch(ll n) {
	//実際にはコピーして中身を改変して使う
	ll i;
	REP(i, pow(2, n)) {
		ll p = i;
		REP(i, n) {
			cout << p % 2;
			p /= 2;
		}
		cout << endl;
	}
}

void bfs(ll now) {
	//中身は毎回書き換えて使用
	queue<ll> Q;
	Q.push(now);
	ll u;
	while (!Q.empty()) {
		u = Q.front();
		Q.pop();
		//ll v=;
		//Q.push(v);
	}
}
//**定義場所**//
ll i, j, k, l, m, n;
ll N, M, K, H, W;
ll MOD = 1000000007;
ll ans = 0;
//***********//

int main() {
	cin >> N;
	vl H(N);
	for (i = 0; i < N; i++) {
		cin >> H[i];
	}
	ll pre = 0;
	ll b = true;
	for (i = 0; i < N; i++) {
		pre = max(pre, H[i]);
		if (pre - H[i] >= 2) {
			b = false;
			break;
		}
	}
	if (b == true) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}

Measured memory_bytes: 1024
K, A, B = map(int, input().split())
if K <= A or B - A <= 2:
  print(K+1)
else:
  x = (K-A+1)//2
  r = A+(B-A)*x
  if (K-A+1)%2 == 1:
    r = r+1
  print(r)

Measured memory_bytes: 2940
n = list(input())
k = int(input())
t = len(n)
ketaDP = [[[0 for i in range(2)] for j in range(k+1)] for u in range(t)]
#ketaDP = [上から何桁目][0以外が何回出てる][nより小さいの確定？]
ketaDP[0][0][0] = 1
ketaDP[0][1][0] = int(n[0])-1
ketaDP[0][1][1] = 1
for i in range(1,t):
    now = int(n[i])
    for j in range(k+1):
        ketaDP[i][j][0] += ketaDP[i-1][j][0]
    for j in range(k):
        ketaDP[i][j+1][0] += ketaDP[i-1][j][0] * 9
    if now == 0:
        for j in range(k+1):
            ketaDP[i][j][1] += ketaDP[i-1][j][1]
    elif now != 0:
        for j in range(k+1):
            ketaDP[i][j][0] += ketaDP[i-1][j][1]
        for j in range(k):
            ketaDP[i][j+1][1] += ketaDP[i-1][j][1]
            ketaDP[i][j+1][0] += ketaDP[i-1][j][1]*(now-1)
print(sum(ketaDP[t-1][k]))
        

Measured memory_bytes: 62996
// Problem : F - Tree and Constraints
// Contest : AtCoder Beginner Contest 152
// URL : https://atcoder.jp/contests/abc152/tasks/abc152_f
// Memory Limit : 1024.000000 MB 
// Time Limit : 4000.000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

#include <bits/stdc++.h>

using namespace std;

int N, M;
int u[55], v[55];
vector<int> graph[55];
int msk[55];
long long dp[55][1<<20];
int lft[55], rht[55], t;
int dep[55], par[55];

void dfs(int n){
	lft[n] = ++t;
	for(auto e : graph[n]){
		if(e != par[n]){
			par[e] = n;
			dep[e] += dep[n] + 1;
			dfs(e);
		}
	}
	rht[n] = ++t;
}

int main(){
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> N;
	for(int i = 1; i<N; i++){
		cin >> u[i] >> v[i];
		graph[u[i]].push_back(v[i]);
		graph[v[i]].push_back(u[i]);
	}
	dfs(1);
	cin >> M;
	for(int j = 0; j<M; j++){
		int a, b;
		cin >> a >> b;
		for(int i = 1; i<N; i++){
			int c = 0;
			if(par[u[i]] == v[i]){
				swap(u[i], v[i]);
			}
			c += (lft[v[i]] <= lft[a] && rht[a] <= rht[v[i]]);
			c += (lft[v[i]] <= lft[b] && rht[b] <= rht[v[i]]);
			if(c == 1){
				msk[i] |= (1<<j);
			}
		}
	}
	dp[0][0] = 1;
	for(int i = 0; i<N-1; i++){
		for(int m = 0; m<1<<M; m++){
			dp[i+1][m] += dp[i][m];
			dp[i+1][m|msk[i+1]] += dp[i][m];
		}
	}
	cout << dp[N-1][(1<<M)-1] << "\n";
}

Measured memory_bytes: 403712
use std::str::FromStr;
use std::collections::HashSet;

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

fn get_vec<T : FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
}

fn main() {
    let v : Vec<i32> = get_vec();
    let x = v[0];
    let y = v[1];
    let mut s1 = HashSet::new();
    s1.insert(1);
    s1.insert(3);
    s1.insert(5);
    s1.insert(7);
    s1.insert(8);
    s1.insert(10);
    s1.insert(12);
    let mut s2 = HashSet::new();
    s2.insert(4);
    s2.insert(6);
    s2.insert(9);
    s2.insert(11);
    if s1.contains(&x) && s1.contains(&y) || s2.contains(&x) && s2.contains(&y) {
        println!("Yes");
    }
    else {
        println!("No");
    }
}

Measured memory_bytes: 4352
#include <iostream>
#include <cmath>
#include <cstdio>

using namespace std;

int main(){
    double x1, y1, x2, y2, x3, y3;
    while(cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3){
        x2 -= x1;
        y2 -= y1;
        x3 -= x1;
        y3 -= y1;
        double S = abs(x2 * y3 - x3 * y2);
        double a = sqrt(x2 * x2 + y2 * y2);
        double b = sqrt(x3 * x3 + y3 * y3);
        double dx = x2 - x3;
        double dy = y2 - y3;
        double c = sqrt(dx * dx + dy * dy);
        double r = S / (a + b + c);
        double l = max(a, max(b, c));
        printf("%.10lf\n", l/(2+l/r));
    }
}

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

int gcd(int x, int y){
  int a = max(x, y);
  int b = min(x, y);
  if ( b == 0)return a;

  return gcd(b, a%b);
}

int main(){
  int n, X;
  cin >> n >> X;
  int x[n];
  x[0] = X;
  for ( int i = 1; i <= n; i++){
    cin >> x[i];
  }

  sort(x, x+n+1);
  int diff, gcdN = 0;
  for ( int i = 1; i <= n; i++){
    diff = x[i] - x[i-1];
    gcdN = gcd(diff, gcdN);
  }

  cout << gcdN << endl;

  return 0;
}

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

#define endl "\n"
#define int long long int
#define mod 1000000007
#define pint pair<int,int>
#define vint vector<vector<int>>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

const int N = 1e6 + 5;
int A[N];

int mat[1005][1005];

int solve(int A[], int n)
{
    int i, ans = 0;
    sort(A, A+n);
    reverse(A, A+n);

    int c = count(A, A+n, A[0]);
    int remain = n-1;

    ans = min(remain, (2*c - 1)) * A[0];
    remain -= min(remain, 2*c-1);

    //cout<<remain<<endl;
    //cout<<ans<<endl;
    if(remain == 0)
        return ans;

    for(i=0;i<n;i++)
    {
        if(A[i] != A[0])
            break;
    }
    //cout<<i<<endl;

    while(remain)
    {
        c=0;
        int j = i;
        while(i < n)
        {
            if(A[i] != A[j])
                break;
            i++;
            c++;
        }
        ans += min(remain, (2*c)) * A[j];
        remain -= min(remain, 2*c);
    }
    return ans;
}

int32_t main()
{
    //code
	IOS;

    int t,n,m,k,i,j,x,y,a,b;

    //cin>>t;
    t=1;
    while(t--)
    {
        cin>>n;
        for(i=0;i<n;i++)
            cin>>A[i];

        cout<<solve(A, n)<<endl;
    }

	return 0;
}

Measured memory_bytes: 5184
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    if (n % 2) cout << 0;
    else {
        ll a = 5, z = 0;
        while (a < n) {
            ll b = n / a;
            z += b / 2;
            a *= 5;
        }
        cout << z;
    }
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=m-1; i>=n; i--)
#define SORT(v,n) do{sort(v,v+n);reverse(v,v+n);}while(0)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x,n/2)%MOD;
  return x%MOD*POW(x,n-1)%MOD;
}

ll POW2(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW2(x*x,n/2);
  return x*POW2(x,n-1);
}

ll POW3(ll x,ll n,ll m){
  x%=m;
  if(n==0)return 1;
  if(n%2==0)return POW3(x*x,n/2,m)%m;
  return x*POW3(x,n-1,m)%m;
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}

ll lcm(ll u, ll v) {
  return u*v/gcd(u,v);
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll KAI2(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI2(m-1);
}

ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll COM2(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI2(m)/KAI2(n)/KAI2(m-n);
}

ll DEC(ll x,ll m,ll n)//xのm進数でのx^nの位の値
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)//xのn進数での桁数
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)//x!のnで割り切れる回数
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}

ll ORD(ll x,ll n)//xのnで割り切れる回数
{
  if(x==0)return INF;
  if(x%n!=0)return 0;
  return 1+ORD(x/n,n);
}

ll SGS(ll x,ll y, ll m)//1+x+…+x^(y-1)をmで割った余り
{
  if(y==0)return 0;
  if(y%2==0){
    return (1+POW3(x,y/2,m))*SGS(x,y/2,m)%m;
  }
  return (1+x*SGS(x,y-1,m))%m;
}

ll SSGS(ll x,ll y,ll m)//Σ[k=1→y](1+x+…+x^(k-1))をmで割った余り
{
  if(y==0)return 0;
  if(y==1)return 1;
  if(y%2==0){
    return (SSGS(x,y/2,m)*(POW3(x,y/2,m)+1)%m+SGS(x,y/2,m)*y/2%m)%m;
  }
  return (SSGS(x,y-1,m)*x%m+y)%m;
}

int main()
{
  double w,h,x,y;
  cin >> w >> h >> x >> y;
  cout << w*h/2 << " ";
  if(w/2==x&&h/2==y)cout << "1";
  else cout << "0";
}

Measured memory_bytes: 256
n = int(input())
card = list(map(int, input().split()))

alice = []
bob = []
for i in range(1, n+1):
    val = max(card)
    del card[card.index(val)]
    if i % 2 == 1:
        alice.append(val)
    else:
        bob.append(val)

diff = sum(alice) - sum(bob)
print(diff)



Measured memory_bytes: 3316
#include <cstdio>
#include <cctype>
#include <utility>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;while(isspace(c)){c=gcu();}if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m?-n:n;}
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(bool b) {pcu('0'+b);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	long n = in(), t = 0;
	for (int i = 0; i < n; i++)
		t += in();
	outl(t / n);
}


Measured memory_bytes: 2440
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
 
#define ff                  first
#define ss                  second
#define endl                "\n"
#define loop(i,s,e)         for(int i=s;i<e;i++)
#define int                 long long
#define vi                  vector<int> 
#define S(v)                sort(v.begin(),v.end())
#define RS(v)               sort(v.rbegin(),v.rend())
#define R(v)                reverse(v.begin(),v.end())
#define mxpq(T)             priority_queue <T>
#define mnpq(T)             priority_queue<T,vector<T>,greater<T>>
#define prv(v)              for(auto &x : v)cout << x << " ";
#define piirv(v)            for(auto &x : v)cout << x.ff << " " << x.ss << endl;
#define prvv(v)             for(auto &x : v)for(auto &y : x.ss)cout << y << " ";
#define mp                  make_pair
#define pii                 pair<int,int>
#define mset(a,f)           memset(a , f , sizeof(a))
#define pb                  push_back
#define inf                 INT_MAX
#define INF                 LLONG_MAX
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;

const int N = 2e5 + 6;
pii A[105];
int dp[101][N];
int n , w;

void solve()
{
    cin >> n >>  w;

    loop(i,1,n+1)cin >> A[i].ff >> A[i].ss;

    // loop(i,0,101)loop(j,0,w+5)dp[i][j] = -inf;

    // loop(i,0,101)dp[i][0] = 0;
    // loop(i,0,101)loop(j,0,n+1)dp[i][A[i].ff] = 0;

    loop(i,1,n+1)
    {
        loop(j,1,w+1)
        {
            if(j-A[i].ff >= 0)
            {
                dp[i][j] = max(dp[i-1][j] , dp[i-1][j-A[i].ff] + A[i].ss);
            }
            else dp[i][j]  = dp[i-1][j];
        }
    }

    cout << dp[n][w] << endl;

}
 
int32_t main()
{
 
cout<<fixed<<setprecision(16);

ios_base:: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
     

     int t = 1;
     // cin >> t;
     while(t--)solve();
  
}

Measured memory_bytes: 153344
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int left1, left2, right1, right2;
  cin >> left1 >> left2 >> right1 >> right2;
  
  if((left1+left2) > (right1+right2)){
  	cout << "Left" << endl;
  } else if((left1+left2) < (right1+right2)){
  	cout << "Right" << endl;
  } else{
  	cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int x = in.nextInt();

            int ans = 1;
            for (int i = 2; i <= x; i++) {
                int t = i * i;
                if (t > x) break;
                while (t * i <= x) t *= i;
                ans = Math.max(ans, t);
            }

            out.println(ans);
        }

    }

    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
            st = new StringTokenizer("");
        }

        public String nextString() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

    }
}



Measured memory_bytes: 21332
#include <iostream>
#include<time.h>
#include<string>
#include<cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<stack>
#include<set>
#include <limits>
#include <climits>
#include <numeric>
#include<cassert>
#include<cctype>
#include<iterator>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef vector<ll>VI;
typedef vector<bool>VB;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define VV(T) vector<vector<T>>
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define bitrep(bit,A) for(int bit=A; ;bit=(bit-1)&A)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) (ll)((a).size())
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=c_max(x,a)
#define chmin(x,a) x=c_min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define SORT(c) stable_sort(ALL(c))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
#define MOD 1000000007
#define INF 1<<30
#define INFTY 1000000000000000001LL
#define MAX_INT INT_MAX
#define Endl '\n'
#define greater greater<int>()
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
using Graph=vector<vector<ll> >;//int と P
// g++ -o a a.cpp -Wall -lm -std=c++14
VI calc_next(const VI &ar){
    VI res;
    for(auto val:ar){
        for(int j=-1;j<=1;j++){
            int add=(val%10)+j;
            if(add>=0&&add<=9)res.push_back(val*10+add);
        }
    }
    return res;
}

int main(){
    int k;cin>>k;
    VI all,cur;
    for(int v=1;v<10;++v)cur.push_back(v),all.push_back(v);

    for(int d=1;d<10;++d){
        cur=calc_next(cur);
        for(auto val:cur)all.push_back(val);
    }
    cout<<all[k-1]<<Endl;
}

Measured memory_bytes: 6428
N, M = map(int, input().split())
nextroom = [[] for _ in range(N)]
for _ in range(M):
  A, B = map(int, input().split())
  nextroom[A-1].append(B-1)
  nextroom[B-1].append(A-1)

sgn = [-1 for _ in range(N)]
sgn[0] = 0

depth = [float('inf') for _ in range(N)]
depth[0] = 0

now = [0]
nextvisit = []
for j in range(1, M+1):
  for n in now:
    for i in nextroom[n]: 
      if depth[i] > j:
        nextvisit.append(i)
        sgn[i] = n
        depth[i] = j
  now = [] + nextvisit
  nextvisit = []

if -1 in sgn:
  print('No')
else:
  print('Yes')
  for k in range(1, len(sgn)):
    print(sgn[k]+1)

Measured memory_bytes: 110340
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll; ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (y == 0) return x;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y;}
//cout << fixed << setprecision(10);

int main(){
    ll n; cin>>n;
    ll t,cnt=0;
    rep(i,n){
        cin>>t;
        if(t%2==0){
            if(t%3==0||t%5==0) cnt++;
        }
        else cnt++;
    }
    if(cnt==n) cout<<"APPROVED"<<endl;
    else cout<<"DENIED"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
    int N,K;
    cin >> N >> K;
    long long int H[N];
    vector<long long int> v;
    long long int count = 0;
    for(int i = 0;i < N;i++){
        cin >> H[i];
        v.push_back(H[i]);
    }
    sort(v.begin(), v.end());
    for(int i = 0;i < N-K;i++){
        count += v[i];
    }
    cout << count << endl;
}

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

int main()
{
  int n;
  cin >> n;
  int times[105];

  int total = 0;
  for (int i = 0; i < n; i++)
  {
    cin >> times[i];
    total += times[i];
  }

  int m;
  cin >> m;
  int ans[105];
  for (int i = 0; i < m; i++)
  {
    int p, x;
    cin >> p >> x;
    p--;

    ans[i] = total - (times[p] - x);
  }

  for (int i = 0; i < m; i++)
  {
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 256
N = int(input())

RL = []

for i in range(N):

    x,l = map(int,input().split())
    RL.append([x+l,x-l])

RL.sort()

nrmax = float("-inf")
ans = 0

for i in range(N):

    if nrmax <= RL[i][1]:
        ans += 1
        nrmax = RL[i][0]

print (ans)


Measured memory_bytes: 59776
#include <stdio.h>

int main(void){
    int sx,sy,tx,ty,dx,dy;
    
    scanf("%d%d%d%d", &sx, &sy, &tx,&ty);
    dx = tx-sx;
    dy = ty-sy;
    
    for (int i=0; i<dy; i++) putchar('U');
    for (int i=0; i<dx; i++) putchar('R');
    for (int i=0; i<dy; i++) putchar('D');
    for (int i=0; i<dx; i++) putchar('L');
    putchar('L');
    for (int i=0; i<dy+1; i++) putchar('U');
    for (int i=0; i<dx+1; i++) putchar('R');
    putchar('D');
    putchar('R');
    for (int i=0; i<dy+1; i++) putchar('D');
    for (int i=0; i<dx+1; i++) putchar('L');
    puts("U");
    return 0;
}

Measured memory_bytes: 128