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

int main(void)
{
    ll a, b, x;
    cin >> a >> b >> x;

    if (a > 0)
    {
        ll diva = (a - 1) / x;
        ll divb = b / x;

        ll ans = divb - diva;

        cout << ans << endl;
    } else {
        ll diva = -1;
        ll divb = b / x;

        ll ans = divb - diva;

        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3644
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
 
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) v.erase(remove(v.begin(), v.end(), a), v.end())
#define REP(i,n) for (int (i) = 0; (i) < (n); (i)++)
using namespace std;
 
int N, A, B;
int h[100000];
 
bool can_destroy(int cnt)
{
	int c = cnt;
	REP(i, N)
	{
		int a = h[i] - cnt * B;
		int S = A - B;
		if (a > 0)
		{
			int n = a / S;
			if (a - n * S > 0)
			{
				n++;
			}
			c -= n;
			if (c < 0)
			{
				return false;
			}
		}
	}
	return true;
}
 
signed main()
{
	cin >> N >> A >> B;
	REP(i, N) cin >> h[i];
 
	int l = 0;
	int r = 1000000000;
 
	while (true)
	{
		if (r - l <= 1) break;
		int m = (r - l) / 2 + l;
		if (can_destroy(m))
		{
			r = m;
		}
		else
		{
			l = m;
		}
	}
 
	cout << r << endl;
}

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

int main() {
  int N,T,A;
  cin >> N >> T >> A;  
  vector<int> H(N);  
  for(int i=0; i<N; ++i){
    cin >> H[i];
  }
  
  int ans;
  int temp = 10000000;
  vector<int> LT(N);
  for(int i=0; i<N; ++i){
    LT[i] = (T*1000 - H[i]*6)-A*1000;
    if (LT[i]<0) LT[i]=LT[i]*(-1);
    if (LT[i] < temp){
      temp = LT[i];
      ans = i+1;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(int argc, char const *argv[])
{
   string s;
   cin >> s;
   int ans = 0;
   for(int i = 0; i < s.size()/2; i++){
      if(s[i] != s[s.size() - i -1])
         ans++;
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 256
n, d = map(int, input().split())
X = []
for i in range(n):
    X.append([int(i) for i in input().split()])

rs = 0
for i in range(n):
    for ii in range(i+1, n):
        dis = 0
        for j in range(d):
            dis += (X[i][j]-X[ii][j])**2
        if dis**0.5 %1 == 0:
            rs += 1

print(rs)

Measured memory_bytes: 3064
import java.util.*;

public class Main {

    static class Edge {
        int from, to;

        public Edge(int from, int to) {
            this.from = from;
            this.to = to;
        }
    }

    static class UnionFind {
        int[] size;
        int[] id;

        public UnionFind(int n) {
            size = new int[n];
            id = new int[n];

            for (int i = 0; i < n; ++i) {
                size[i] = 1;
                id[i] = i;
            }
        }

        void unify(int p, int q) {
            int root1 = find(p);
            int root2 = find(q);

            if (size[root1] > size[root2]) {
                size[root1] += size[root2];
                id[root2] = root1;
            } else {
                size[root2] += size[root1];
                id[root1] = root2;
            }
        }

        int find(int p) {
            int root = p;
            while (root != id[root]) root = id[root];
            while (p != root) {
                int next = id[p];
                id[p] = root;
                p = next;
            }
            return root;
        }

        boolean connected(int p, int q) {
            return find(p) == find(q);
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        List<Edge> edges = new ArrayList<>();
        for (int i = 0; i < M; ++i) {
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;
            edges.add(new Edge(a, b));
        }

        int res = 0;
        for (int i = 0; i < M; ++i) {
            UnionFind uf = new UnionFind(N);
            for (int j = 0; j < M; ++j) {
                if (i == j) continue;
                uf.unify(edges.get(j).from, edges.get(j).to);
            }
            if (!uf.connected(edges.get(i).from, edges.get(i).to)) ++res;
        }

        System.out.println(res);
    }
}

Measured memory_bytes: 21972
#include<stdio.h>
int main(){
   int a = 0;
   int b = 0;
   scanf("%d",&a);
   scanf("%d",&b);
   if(a > b){
     if(b == 1){
       printf("Bob");

       return 0;
     }
     printf("Alice");
   }
   else if(a < b){
     if(a == 1){
       printf("Alice");

       return 0;
     }
     printf("Bob");
   }
   else if(a == b){
     printf("Draw");
   }
   
   return 0;
}

Measured memory_bytes: 128
#include <string>
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;

int main()
{
    char c;
    cin >> c;
    c++;
    cout << c  << endl ;
}

Measured memory_bytes: 256
N = int(input())
a, b, c = map(int, input().split())
dp_a = [a]
dp_b = [b]
dp_c = [c]

for _ in range(N-1):
    a, b, c = map(int, input().split())
    former_a, former_b, former_c = dp_a[-1], dp_b[-1], dp_c[-1]
    dp_a.append(max(former_b+a, former_c+a))
    dp_b.append(max(former_c+b, former_a+b))
    dp_c.append(max(former_a+c, former_b+c))

print(max(dp_a[-1], dp_b[-1], dp_c[-1]))

Measured memory_bytes: 15012
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;

class Main {
	public static void main(String args[]) {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);

		try {
			String buf = null;
			int n;
			while (!(buf = br.readLine()).equals("0")) {
				HashMap<Character, Character> map = new HashMap<Character, Character>();
				n = Integer.parseInt(buf.trim());
				for (int i=0;i<n;i++) {
					String str = br.readLine();
					Character key = str.charAt(0);
					Character val = str.charAt(2);
					map.put(key, val);
				}
				n = Integer.parseInt(br.readLine().trim());
				for (int i=0;i<n;i++) {
					Character c = br.readLine().charAt(0);
					if (map.containsKey(c)) {
						System.out.print(map.get(c));
					} else {
						System.out.print(c);
					}
				}
				System.out.println("");
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 47376
let tenki s t =
  if s.[0] = t.[0] then if s.[1] = t.[1] then if s.[2] = t.[2] then 3
                                                               else 2
                                         else if s.[2] = t.[2] then 2
                                                               else 1
                   else if s.[1] = t.[1] then if s.[2] = t.[2] then 2
                                                               else 1
                                         else if s.[2] = t.[2] then 1
                                                               else 0
let s = read_line ()
let t = read_line ()
let () = Printf.printf "%d\n" (tenki s t)

Measured memory_bytes: 3648
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>
#include <vector>

#define TRACE(x) std::cout << #x << " = " << x << "\n"
#define _ << " _ " <<

template <int32_t P>
struct IntModT {
  int32_t value;

  IntModT() : value(0){};
  explicit IntModT(int32_t value) : value(value){};

  IntModT& operator+=(const IntModT& other) {
    value += other.value;
    if (value >= P) value -= P;
    return *this;
  }

  IntModT& operator-=(const IntModT& other) {
    value -= other.value;
    if (value < 0) value += P;
    return *this;
  }

  IntModT& operator*=(const IntModT& other) {
    int64_t result =
        static_cast<int64_t>(value) * static_cast<int64_t>(other.value);
    value = static_cast<int32_t>(result % P);
    return *this;
  }
};

template <int32_t P>
IntModT<P> operator+(const IntModT<P>& a, const IntModT<P>& b) {
  auto res = a;
  return res += b;
};

template <int32_t P>
IntModT<P> operator-(const IntModT<P>& a, const IntModT<P>& b) {
  auto res = a;
  return res -= b;
};

template <int32_t P>
IntModT<P> operator*(const IntModT<P>& a, const IntModT<P>& b) {
  auto res = a;
  return res *= b;
};

template <int32_t P>
bool operator==(const IntModT<P>& a, const IntModT<P>& b) {
  return a.value == b.value;
};

template <int32_t P>
std::ostream& operator<<(std::ostream& os, const IntModT<P>& a) {
  os << a.value;
  return os;
}

using IntMod = IntModT<1000000007>;

int main() {
  std::ios_base::sync_with_stdio(false);

  int N;
  std::cin >> N;

  std::vector<int> C(N);
  for (int i = 0; i < N; ++i) {
    std::cin >> C[i];
  }

  int M = *max_element(C.begin(), C.end());
  std::vector<IntMod> sf(M + 1);

  std::vector<IntMod> f(N + 1);
  f[0] = IntMod{1};

  for (int i = 0; i < N; ++i) {
    f[i + 1] = f[i];

    if (i == 0 || C[i] != C[i - 1]) {
      f[i + 1] += sf[C[i]];
      sf[C[i]] += f[i];
    }
  }

  std::cout << f[N] << "\n";
  return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

vvl G(101010);
vvl color(101010,vl(11,0));

void dfs(ll u, ll d, ll c){
    rep(j,d+1) if(!color[u][j]) color[u][j] = c;
    if(d==0) return;
    for(auto v : G[u]){
        if(color[v][d-1]) continue;
        dfs(v,d-1,c);
    }
}

int main(){
    ll n,m; cin >> n >> m;
    rep(i,m){
        ll a,b; cin >> a >> b; a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    ll q; cin >> q;
    vector<tuple<ll,ll,ll>> query(q);
    rep(i,q){
        ll v,d,c; cin >> v >> d >> c; v--;
        query[i] = tie(v,d,c);
    }
    reverse(all(query));
    rep(i,q){
        ll v,d,c;
        tie(v,d,c) = query[i];
        dfs(v,d,c);
    }
    rep(i,n) cout << color[i][0] << endl;
}

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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

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

    cout << (a <= b ? a : (a - 1)) << endl;

    return 0;
}


Measured memory_bytes: 256
def main():
    n,k=map(int,input().split())
    li=map(int,input().split())
    x=list(li)
    a=x[0:k]
    for i in range(k,n):
        if(a[0]<x[i]):
            print('Yes')
        else:
            print('No')
        del a[0]
        a.append(x[i])
    
main()


Measured memory_bytes: 31528
//****************************//
/**********  main *************/
//****************************//
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
 
using namespace std;
typedef long long ll;
 
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(i=0;i<n;i++)
#define FOR(i,a,b) for(i=a;i<b;i++)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
 
 
int main() {
 
	std::cin.tie(0);
 
    ll x;
    cin >> x ;

    int i,tmp;
    int a_count=0,b_count=0;
    tmp=1;

    a_count = x/500 ;

    b_count = (x - (a_count * 500) ) / 5;

    cout << a_count * 1000 + b_count * 5 << endl;


    return 0;
}

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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"
#define debug(x) cout<<#x<<" = "<<x<<endl;

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

const li N=405;

li dp[N][N];

void solve()
{
    li n;

    cin>>n;

    li a[n];

    vi sum(n);

    f(i,0,n-1)
    {
        cin>>a[i];

        sum[i]=(i>0?sum[i-1]:0)+a[i];
    }

    fr(l,n-1,0)
    {
        f(r,l,n-1)
        {
            if(l==r)
            {
                dp[l][r]=0;
            }
            else
            {
                dp[l][r]=1e18;

                f(i,l,r-1)
                {
                    dp[l][r]=min(dp[l][r],dp[l][i]+dp[i+1][r]+sum[r]-(l>0?sum[l-1]:0ll));
                }
            }
        }
    }

    cout<<dp[0][n-1];
}

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);

    li t=1;

    // cin>>t;

    while(t--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 4888
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#pragma region Macros
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
#define LAST(X) X[X.size()-1]
#define MOD 1000000007
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
inline bool BETWEEN(int x, int min,int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}

using namespace std;
#pragma endregion
signed main() {
	string S;
	cin >> S;
	S[5] = ' ';
	S[13] = ' ';
	cout << S;
}

Measured memory_bytes: 256
from collections import deque

K = int(input())

q = deque(range(1, 10))

for i in range(K):
    x = q.popleft()
    r = x % 10
    y = 10 * x + r
    if r != 0:
        q.append(y - 1)
    q.append(y)
    if r != 9:
        q.append(y + 1)

print(x)


Measured memory_bytes: 11880
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T, class T2> void smin(T& a, T2 val) {if (a > val) a = val;}template<class T, class T2> void smax(T& a, T2 val) {if (a < val) a = val;}
const int N = 5*(int)1e3 + 10;

int n, p[N], c[N], k;

int32_t main(){_
   
   cin>>n>>k;

   for (int i = 1; i <= n; ++i)
   {
      cin >> p[i];
   }
   
   for (int i = 1; i <= n; ++i)
   {
      cin >> c[i];
   }

   int ret = -inf;

   for (int start = 1; start <= n; ++start)
   {
      int curr = start;
      vector<int> reach;
      while(1){
         reach.push_back(c[p[curr]]);
         curr = p[curr];
         if(curr == start)
            break;
      }

      int len = (int)(reach.size());
      // cost to reach over here...

      int currans = reach[0];
      for (int i = 1; i < (int)(reach.size()); ++i)
      {
         reach[i] += reach[i-1];
         smax(currans, reach[i]);
      }

      int times = k / len; 
      if (k % len == 0){
         --times;
      }

      int cost_times = times * reach.back();
      if(!times)
         cost_times = -inf;

      int rem = k;
      rem -= times * (int)(reach.size());

      int inside = -inf;
      for (int i = 0; i < rem; ++i)
         smax(inside, reach[i]);

      tr(start, times, reach, currans, cost_times, inside);
      if(inside != -inf){
         if(cost_times == -inf)
            cost_times = 0;
         cost_times += inside;
      }

      if(k >= len)
         smax(cost_times, currans);
      smax(ret, cost_times);
   }

   cout<<ret;

   return 0;
}

Measured memory_bytes: 3816
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

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

    ll a[n];
    for(ll i = 0; i < n; i++){
        cin >> a[i];
    }

    vector<ll> b;
    if(n % 2 == 0){
        for(int i = n - 2; i >= 0; i -= 2){
            b.push_back(a[i]);
        }
        for(int i = 1; i < n - 1; i += 2){
            b.push_back(a[i]);
        }
        b.push_back(a[n - 1]);
        reverse(b.begin(), b.end());
    }else{
        for(int i = n - 1; i >= 0; i -= 2){
            b.push_back(a[i]);
        }
        for(int i = 1; i < n; i += 2){
            b.push_back(a[i]);
        }
    }

    for(ll i = 0; i < n; i++){
        cout << b[i] << " ";
    }

    cout << endl;
}

Measured memory_bytes: 5488
#include<bits/stdc++.h>
using namespace std;
namespace io{
    const int l=1<<20;
    char buf[l],*s,*t,c;
    inline void gc(){
        if(s==t){
            t=(s=buf)+fread(buf,1,l,stdin);
            c=s==t?EOF:*s++;
        }else c=*s++;
    }
    template<class IT>inline void gi(IT &x){
        x=0;gc();while(c<'0'||c>'9')gc();
        while('0'<=c&&c<='9'){x=(x<<1)+(x<<3)+(c^48);gc();}
    }
    char buf0[20];int a;
    template<class IT>inline void pi(IT x){
        if(x<0){putchar('-');x=-x;}
        do buf0[++a]=x%10+48;while(x/=10);
        while(a)putchar(buf0[a--]);
        putchar('\n');
    }
};
using io::gi;
using io::pi;
typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,ll > pil;
typedef pair<ll ,int> pli;
typedef pair<ll ,ll > pll;
typedef vector<int> vi;
typedef vector<ll > vl;
#define pque priority_queue
#define rep(i,l,r) for(i=(l);i<=(r);++i)
#define per(i,l,r) for(i=(l);i>=(r);--i)
#define REP(i,l,r) for(i=(l);i< (r);++i)
#define PER(i,l,r) for(i=(l);i> (r);--i)
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define fi first
#define se second
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
const int N=5005;
int d[N];
ll solve(int k,int m){
    int i;ll s=0ll;
    REP(i,0,k)s+=(d[i]%m)?d[i]%m:m;
    return s;
}
int main(){
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int k,q,n,m,i,x;
    scanf("%d%d",&k,&q);
    REP(i,0,k)scanf("%d",&d[i]);
    while(q--){
        scanf("%d%d%d",&n,&x,&m);--n;
        printf("%d\n",n-(x%m+solve(k,m)*(n/k)+solve(n%k,m))/m);
    }
    return 0;
}

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

int main(){
    /*
        N: 栄養ドリンクが売られているお店の数
        M: 買い集める栄養ドリンクの本数
    */
    int N, M;
    cin >> N >> M;

    /*
        A: 栄養ドリンクの値段
        B: そのお店で購入できる栄養ドリンクの本数
    */
    vector<int> A(N), B(N);
    for(int i = 0; i < N; i++){
        cin >> A[i] >> B[i];
    }

    vector<pair<int, int>> AB(N);
    for(int i = 0; i < N; i++){
        AB[i] = make_pair(A[i], B[i]);
    }    

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

    long long ans = 0;
    for(int i = 0; i < N; i++){
        int buy = min(M, AB[i].second);
        ans += (long long)buy * AB[i].first;
        M -= buy;
    }

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 1792
/*
 _____ _             _              _           _ 
|_   _| |__   ___   / \   _ __  ___| |__  _   _| |
  | | | '_ \ / _ \ / _ \ | '_ \/ __| '_ \| | | | |
  | | | | | |  __// ___ \| | | \__ \ | | | |_| | |
  |_| |_| |_|\___/_/   \_\_| |_|___/_| |_|\__,_|_|                                                

*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<ll,ll>
#define msi         map<string,ll>
#define mis         map<ll, string>
#define rep(i,a,b)    for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)
#define trav(a, x) 	for(auto& a : x)
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pair<ll, ll>>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define max(a,b)	(a>b?a:b)
#define min(a,b)	(a<b?a:b)

/*	For Debugging	*/
#define DEBUG 		cerr<<"\n>>>I'm Here<<<\n"<<endl;
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl;
#define what_is(x)  cerr << #x << " is " << x << endl;

std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define DECIMAL(n)  cout << fixed ; cout << setprecision(n);
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace __gnu_pbds;
using namespace std;
#define PI 3.141592653589793
#define N  10005
ll dp[1005][10005];
void solve()
{
	ll n;
	cin>>n;
	vector<vi>v(n,vector<ll>(4));
	rep(i,0,n)
	{
		cin>>v[i][1]>>v[i][2]>>v[i][3];
		v[i][0]=-(v[i][2]+v[i][1]);
	}
	sort(all(v));
	rep(i,0,10001)
	dp[n][i]=0;
	repr(i,0,n)
	{
		rep(j,0,v[i][1])
		dp[i][j]=dp[i+1][j];
		rep(j,v[i][1],10001)
		dp[i][j]=max(dp[i+1][j],dp[i+1][min(v[i][2],j-v[i][1])]+v[i][3]);
	}
	// rep(i,0,n+1)
	// {
	// 	rep(j,0,10)
	// 	{
	// 		cout<<dp[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }
	ll mx=0;
	rep(i,0,n)
	{
		mx=max(mx,dp[i+1][v[i][2]]+v[i][3]);
	}
	cout<<mx<<endl;
	return;
}
int main()
{
	FAST
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		solve();
	}
	TIME
	return 0;
}

Measured memory_bytes: 78592
#include <bits/stdc++.h>
 
typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(ll i=0;i<(n);i++)
 
using namespace std;
 
 
int main(){
    int h, w;
    cin >> h >> w;
    map<char, ll> m;
    rep(i, h){
        rep(j, w){
            char c;
            cin >> c;
            m[c]++;
        }
    }
 
    map<int, int> mm;
 
    for(auto iter = m.begin(); iter != m.end(); iter++){
        ll v = (int)(iter->second % 4);
        if(v == 3){
            mm[1]++;
            mm[2]++;
        }
        else mm[v]++;
    }
 
    if(h == 1 || w == 1){
        if(h%2 == 0 || w%2 == 0){
            if(mm[1] == 0)    cout << "Yes" << endl;
            else              cout << "No" << endl;
        }
        else{
            if(mm[1] == 1)        cout << "Yes" << endl;
            else                  cout << "No" << endl;
        }
    }
    else if(h%2 == 1 && w%2 == 1){
        ll x = ((h-1)/2)+((w-1)/2);
        if(mm[1] == 1 && mm[2] <= x)        cout << "Yes" << endl;
        else                                cout << "No" << endl;
    }
    else if(h%2 == 1 || w%2 == 1){
        ll x;
        if(h%2 == 0) x = h/2;
        else         x = w/2;
        if(mm[1] == 0 && mm[2] <= x)  cout << "Yes" << endl;
        else                          cout << "No" << endl;
    }
    else{
        if(mm[1] == 0 && mm[2] == 0) cout << "Yes" << endl;
        else                         cout << "No" << endl;
    }
 
 
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int A[N];
  for(int i=0; i<N; i++) {
    cin >> A[i];
  }
  int count=0;
  int ans=0;
  sort(A,A+N);
  int B=-1;
  for(int i=0; i<N; i++) {
    if(A[i]==A[i+1]) {
      count++;
    }
    else {
      if(count%2==0) {
        ans++;
        count=0;
      }
      else {
        count=0;
      }
    }
  }
  cout << ans << endl;
}
  

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

int main()
{
    string s,t;
    cin >> s >> t;
    int n=s.length(),m=t.length();
    vector<vector<int>>dp(n+1,vector<int>(m+1,0));
    
    
    for(int i=1;i<=n;++i)
    {
        for(int j=1;j<=m;++j)
        {
            if(s[i-1]==t[j-1])
            {
                dp[i][j]=max(dp[i][j],dp[i-1][j-1]+1);
            }
            dp[i][j]=max(dp[i][j],dp[i-1][j]);
            dp[i][j]=max(dp[i][j],dp[i][j-1]);
        }
    }
    //cout << dp[n][m] << endl;
    
    string str;
    
    while(n && m)
    {
        if(s[n-1]==t[m-1])
        str+=s[n-1],n--,m--;
        else if(dp[n-1][m]>dp[n][m-1])
        n--;
        else 
        m--;
    }
    reverse(str.begin(),str.end());
    
    cout << str << endl;
    return 0;
}

Measured memory_bytes: 38636
#include <cstdio>
#include <queue>

using namespace std;


int main(){
    int n;
    int m;
    int a[112345];
    priority_queue<int> que;

    scanf("%d %d", &n, &m);
    for(int i=0; i < n; i++){
        scanf("%d", a + i);
        que.push(a[i]);
    }

    for(int i=0; i < m; i++){
        int top = que.top();
        que.pop();
        que.push(top/2);
    }

    unsigned long long sum = 0;
    while(!que.empty()){
        sum += que.top();
        que.pop();
    }
    printf("%lld\n", sum);

    return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef unordered_set<int> si;
typedef pair<int, int> pp;
typedef vector<pp> vpp;
typedef unsigned int i64;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define all(e) (e).begin(), (e).end()
#define pb push_back

template <typename T>
bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template <typename T>
bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}


template <typename T>
void printV(vector<T> A) {
  if (A.empty()) cerr << "EMTPY\n";
  else { 
    cerr << "[";
    for (int i = 0; i < A.size() -1 ; ++i) {
      cerr << A[i] << ", ";
    }
    if (A.size()) cerr << A.back() << "]\n";
  }
}


template <typename T>
void printVV(vector<vector<T>> A) {
  cerr << "[";
  for (auto v : A) {
    printV<T>(v);
  }
  cerr << "]";
}

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << ": " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&& ...args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

int main(int argc, char **argv) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // 6 5 3 10
  ll x; cin >> x;
  ll ans = (ll) 1e18 ;
  for (ll i = 1; i <= sqrt(x); ++i) {
    if (x % i == 0) {
      ll nxt = x / i;
      if (!chmin(ans, i-1+nxt-1)) break;
    }
  }
  cout << ans << endl;
  return 0;
}



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

using namespace std;

typedef long long int lli ;

lli i,j,k,l,m,n,t,a,b,c,d,x,y,sum=0,total=0;
lli ar[10000000]={0},ind=0;

int main()
{
    //freopen("Input.txt","r",stdin);

    cin>>t;

    while(1)
    {
        x=t%(-2);
        t=t/(-2);

        if(x<0)
        {
            x=x+2;
            t++;
        }

        ar[ind]=x;

        ind++;

        if(t==0)
        {
            break;
        }
    }

    for(i=ind-1 ; i>=0 ; i--)
    {
        cout<<ar[i];
    }
    cout<<"\n";
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
#与えられるパズルの数は1000以下です
MOVE = [[1,4],[0,2,5],[1,3,6],[2,7],[0,5],[1,4,6],[2,5,7],[3,6]]
ans = {"01234567":0}
def swap(field,a,b):
    tmp = list(field)
    tmp[a],tmp[b] = tmp[b],tmp[a]
    return "".join(tmp)

def BFS():
    global ans
    q = [[0,"01234567"]]
    while len(q) != 0:
        g, field = q.pop(0)
        a = field.find("0")
        for b in MOVE[a]:
            tmp = swap(field,a,b)
            if not tmp in ans:
                ans[tmp] = g+1
                q.append([g+1,tmp])

BFS()
while True:
    try:
        print ans[raw_input().replace(" ","")]
    except:
        break

Measured memory_bytes: 6072
L = (10, 50, 100, 500)
def calc():
    ret = [0] * 4
    r = sum(L[i] * N[i] for i in xrange(4)) - M
    for i in xrange(3, -1, -1):
        ret[i] += r / L[i]
        r -= ret[i] * L[i]
    return ret

M = int(raw_input())
while M != 0:
    N = map(int, raw_input().split())
    for i, n in zip(L, map(lambda a, b: max(0, a - b), N, calc())):
        if n == 0:
            continue
        print i, n
    M = int(raw_input())
    if M == 0:
        break
    print

Measured memory_bytes: 4240
using System;

class Sample
{
    static void Main()
    {

        int[] array = new int[10];
        int i = 0;
        for (i = 0; i < 10; ++i)
        {
            array[i] = int.Parse(Console.ReadLine());
        }

        Array.Sort(array);

        Console.WriteLine("{0}\n{1}\n{2}", array[9], array[8], array[7]);
        Console.ReadLine();
    }
}


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

int ceil(int a, int b){
  return a/b + ((a%b) != 0);
}

int main(){

  long long a[100005], l[100005], r[100005];
  int K;
  cin >> K;
  for(int i=1; i<=K; i++) cin >> a[i];
  l[K] = r[K] = 2;

  for(int i=K-1; i>=0; i--){
    l[i] = 1ll * ((l[i+1]-1) / a[i+1] + 1) * a[i+1];
    r[i] = 1ll * r[i+1]/a[i+1] * a[i+1] + a[i+1] - 1;
    if(l[i] > r[i]) {
      cout << -1 << endl;
      return 0;
    }
  }

  cout << l[0] << " " << r[0] << endl;
  return 0;
}


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

using namespace std;

int main(){
    int N,ans=0,a,b,ren=1;
    cin >> N;
    cin >> a;
    for(int i=1;i<N;i++){
        cin >> b;
        if(a==b){
            ren++;
        }else{
            ans += ren/2;
            a = b;
            ren = 1;
        }
    }

    ans += ren/2;

    cout << ans << endl;
}

Measured memory_bytes: 256
def bfs(plane, first, last)
  def isInPlane(y, x)
    x < 0 || x >= $w || y < 0 || y >= $h ? false : true
  end

  directions = [[1, 0], [-1, 0], [0, 1], [0, -1]]
  queue = [first]
  plane[first[0]][first[1]] = 0
  while !queue.empty?
    current = queue.pop;
    x = current[1]; y = current[0];
    return plane[y][x] if current == last
    directions.each do |d|
      yd = y+d[0]; xd = x+d[1]
      if isInPlane(yd, xd) && plane[yd][xd] == '.'
        plane[yd][xd] = plane[y][x] + 1
        queue.unshift([yd, xd])
      end
    end
  end
  nil
end

$h, $w = gets.split.map(&:to_i)
ss = $<.map(&:chop).map(&:chars)
shortest = bfs(ss, [0, 0], [$h-1, $w-1])
if shortest
  p $h * $w - ss.flatten.count('#') - shortest - 1
else
  p -1
end

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

int main(){
    int n, k;
    cin>>n>>k;
    int a[100000];
    for(int i=0; i<n; i++) cin>>a[i];
    int mn=a[0];
    for(int i=0; i<n; i++) mn=min(a[i], mn);
    int cnt=0;
    int l=-1;
    for(int i=0; i<n; i++){
        if(a[i]==mn){
            int c=(i-l+k-3)/(k-1);
            l+=(k-1)*c+1;
            i=l+1;
            cnt+=c;
        }
    }
    if(l<n-1){
        int c=(n-l+k-3)/(k-1);
        cnt+=c;
    }
    cout<<cnt<<endl;
    return 0;
}


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

int n, m, a, b;
bool can[2][200000];

int main() {
	int i;
	
	cin >> n >> m;
	for (i = 0; i < m; i++) {
		cin >> a >> b;
		a--; b--;
		if (a == 0) can[0][b] = true;
		if (b == n - 1) can[1][a] = true;
	}
	
	for (i = 0; i < n; i++) {
		if (can[0][i] && can[1][i]) {
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}
	cout << "IMPOSSIBLE" << endl;
	return 0;
}

Measured memory_bytes: 640
/**
 *      ABC 95 A
 *      author  : kyomukyomupurin
 *      created : 2018/08/23
**/

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

int main(){
    string s;
    cin >> s;
    int cost = 700;

    for (int i = 0; i < s.size(); ++i) {
        if (s.at(i) == 'o'){
            cost += 100;
        }
    }
    
    cout << cost << endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    int a,b;
    cin>>a>>b;
    if(max(a,b)>8)cout<<":("<<endl;
    else cout<<"Yay!"<<endl;
}


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

int main(){
    int n,k;
    cin>>n>>k;
    vector<int> h(n+1,0),dp(n+1,INT_MAX);
    for(int i=1;i<=n;i++)
        cin>>h[i];
    dp[0] = inf;
    dp[1] = 0;
    for(int i=2;i<=n;i++){
        for(int j=1;j<=k;j++){
            if(i-j>=0)
                dp[i] = min(dp[i], abs(h[i]-h[i-j])+dp[i-j]);
        }
    }
    cout<<dp[n]<<endl;
    return 0;
}



Measured memory_bytes: 4060
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        double[] input = Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse);

        Console.WriteLine(input[0] / input[2] <= input[1] ? "Yes" : "No");
    }
    static int ReadInt()
    {
        return int.Parse(Console.ReadLine());
    }
    static string[] ReadStringArray()
    {
        return Console.ReadLine().Split(' ');
    }
    static int[] ReadIntArray()
    {
        return ReadStringArray().Select(i => int.Parse(i)).ToArray();
    }
}

Measured memory_bytes: 27548
n = int(input())
nums = input().split()
max = int(nums[0])
min = int(nums[0])
sum = int(nums[0])
for i in range(n-1):
    m = int(nums[i+1])
    if m > max:
        max = m
    if m < min:
        min = m
    sum = sum + m
    
print(min, max, sum)

Measured memory_bytes: 8364
def q1():
    A, B = (int(i) for i in input().split())

    ans = 0
    for i in range(2):
        if A > B:
            ans += A
            A -= 1
        else:
            ans += B
            B -= 1
        
    return ans


if __name__ == '__main__':
    print(q1())


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


 int main () {
   int n;
   cin>>n;
   int x[n];
   for(int i=0;i<n;i++) cin >> x[i];
   int MAX = *max_element(x+0,x+n);
   int MIN = *min_element(x+0,x+n);
 
   int SUM_MIN = 100000007;
   for(int i=MIN;i<MAX+1;i++){
     int sum = 0;
     for(int k=0;k<n;k++){
       sum += pow(x[k]-i,2);
     }
     SUM_MIN = min(sum,SUM_MIN);
   }
  
  cout << SUM_MIN << endl;
  
   return 0;
 }




Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main()
{
    string s; cin >> s;
    if(s[2] == s[3] && s[4] == s[5])
    {
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }
        
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int a,b,c,k,ans=0;

int main(){
	cin>>a>>b>>c>>k;
	if(k<=a){
		ans=k;
		k=0;
	}
	else{
		ans=a;
		k-=a;
	}
	if(k>b){
		k-=b;
		if(k>c)
			ans-=c;
		else
			ans-=k;
	}
	cout<<ans;
	
	return 0;
}

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

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

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

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

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

    def __len__(self):
        return self._len

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

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

        return self._func(res_left, res_right)

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


import sys,io,os
I = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
#I = input

M = 300005
N,K = map(int, I().split())
A = [int(I()) for _ in range(N)]

S = SegmentTree([0] * M, 0, max)

for a in A:
	l = max(0, a - K)
	h = min(M, a + K + 1)
	S[a] = S.query(l, h) + 1

print(S.query(0, M))





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

using namespace std;

int N, X;
const int MAX_N = 100;
int m[MAX_N];

int main() {
	int sum = 0;
	cin >> N >> X;
	for (int i = 0; i < N; i++) {
		cin >> m[i];
		sum += m[i];
	}
	sort(m, m + N);
	cout << (X - sum) / m[0] + N << 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;
using ll = long long;

struct UnionFind {
  vector<int> d;
  UnionFind (int n): d(n,-1) {}
  int find(int x) {
    if(d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if(x == y) return false;
    if(d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};

int main() {
  int n, q;
  cin >> n >> q;
  UnionFind uf(n);
  rep(i,q) {
    int t, u, v;
    cin >> t >> u >> v;
    if(t) cout << uf.same(u,v) << endl;
    else uf.unite(u,v);
  }
  return 0;
}

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

#define ll long long
#define reg register
#define rep(i, a, b) for(reg int i = a; i <= b; ++i)

using namespace std;

#define MOD 924844033
#define N 2005

int n, k, cnt, a[N << 1];
ll fac[N] = {1}, f[N << 1][N][2];

inline ll ksm(ll x, int p) {
    ll res = 1;
    for (; p; p >>= 1, x = x * x % MOD) if (p & 1) res = res * x % MOD;
    return res;
}

int main() {
    scanf ("%d%d", &n, &k);
    rep (i, 1, n) fac[i] = fac[i - 1] * i % MOD;
    f[0][0][0] = 1;
    rep (i, 1, k) {
        rep (l, 1, 2) {
            for (reg int j = i; j <= n; j += k) {
                ++cnt;
                if (j != i) a[cnt] = 1; 
            }
        }
    }
    rep (i, 1, n * 2) {
        rep (j, 0, n) {
            f[i][j][0] = (f[i - 1][j][1] + f[i - 1][j][0]) % MOD;
            if (a[i] && j != 0) f[i][j][1] = f[i - 1][j - 1][0];
        }
    }
    ll ans = 0;
    rep (i, 0, n) {
        if (i & 1) ((ans -= (f[2 * n][i][0] + f[2 * n][i][1]) * fac[n - i] % MOD) += MOD) %= MOD;
        else (ans += (f[2 * n][i][0] + f[2 * n][i][1]) * fac[n - i] % MOD) %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 125568
from collections import deque
S=input()
table=deque()
table.append(1)
ans=0
for s in S:
    if s=='S':
        table.append(1)
        #print(table,ans)
    else:
        if len(table)==1:
            table[0]==1
           #print(table,ans)
        else:
            table.pop()
            ans+=table[-1]
            #table[-1]+=1
            #print(table,ans)
print(len(S)-2*ans)

Measured memory_bytes: 4324
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define double long double
#define pii pair<int, int>
#define FOR(i, a, b) for(int i = a; i < (int)(b); ++i)
#define all(x) x.begin(), x.end()
#define deb(x) cout << (#x) << " is " << (x) << endl;
const int mod = 1000 * 1000 * 1000 + 7;
using namespace std;

inline int add(int a, int b){
	a += b;
	// if(a >= mod)
    //     a -= mod;
    a %= mod;
	return a;
}
 
inline int sub(int a, int b){
    // if (a < b) {
    //     a /= 0;
    // }
	a -= b;
	if(a < 0) {
        a += mod;
        // a /= 0;
    }
    // a %= mod;
	return a;
}

int32_t main() {
    int n, k;
    cin >> n >> k;
    int a[n + 1];
    FOR(i, 1, n + 1) {
        cin >> a[i];
    }
    int d[n + 1][k + 1];
    int p[n + 1][k + 1];
    memset(d, 0, sizeof(int) * (n + 1) * (k + 1));
    memset(p, 0, sizeof(int) * (n + 1) * (k + 1));
    FOR(i, 0, a[1] + 1) {
        d[1][i] = 1;
    }
    p[1][0] = d[1][0];
    FOR(i, 1, k + 1) {
        p[1][i] = add(p[1][i - 1], d[1][i]);
    }
    FOR(i, 2, n + 1) {
        FOR(j, 0, k + 1) {
            if (j - a[i] > 0) {
                d[i][j] = sub(p[i - 1][j], p[i - 1][j - a[i] - 1]);
            }
            else {
                d[i][j] = p[i - 1][j];
            }

            if (d[i][j] < 0) {
                d[i][j] /= 0;
            }

            if (j > 0) {
                p[i][j] = add(p[i][j - 1], d[i][j]);
            }
            else 
                p[i][j] = d[i][j];

            if (p[i][j] < 0) {
                p[i][j] /= 0;
            } 
        }
    }
    cout << d[n][k];
    return 0;
}

Measured memory_bytes: 161396
import math
N = int(input())
l = list(map(int, input().split()))
ct = 0
for i in range(N):
    for j in range(N):
        for k in range(N):
            if l[i] != l[j] and l[k]:
                if l[j] != l[k]:
                    if l[i] < l[j] < l[k]:
                        if l[i] + l[j] > l[k]:
                            ct += 1
print(ct)


Measured memory_bytes: 9112
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int length = scanner.nextInt();
        scanner.nextLine();
        final char[] chars = scanner.nextLine().toCharArray();
        final int index = scanner.nextInt();

        final char correct = chars[index - 1];

        for (int i = 0; i < length; i++) {
            if (chars[i] != correct) {
                chars[i] = '*';
            }
        }

        System.out.println(chars);
    }
}

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

using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

#define LOOP(N) for(int i=(int)(N); i--;)
#define REP(i, N) for(int i=0; i<(N); ++i)
#define FOR(i, start, end) for(int i=(int)(start); i<(end); ++i)
#define ALL(a) (a).begin(),(a).end()

class FastIO {
public:
    FastIO() {
        cin.tie(0);
        ios::sync_with_stdio(false);
    }
    ~FastIO() {}

    template <class T>
    void scan(T &v) {
        cin >> v;
    }
    template <class T, class... Rest>
    void scan(T &v, Rest&... rest) {
        scan(v);
        scan(rest...);
    }

    template <class T>
    void print(T v) {
        cout << v;
    }
    template <class T, class... Rest>
    void print(T v, Rest... rest) {
        print(v);
        print(" ");
        print(rest...);
    }
    template <class T>
    void print(vector<T> v) {
        for (T t: v) {
            print(t);
            print(" ");
        }
        print("\b\n");
    }
    template <class T>
    void prints(T v) {
        print(v);
        cout << "\n";
    }
};

void _main(FastIO&);
int main() {
    FastIO io;
    _main(io);
}



void _main(FastIO &io) {
    int N; io.scan(N);
    vector<int> h(N);
    REP(i, N) cin >> h[i];

    int max = 0, c = 0;
    FOR(i, 1, N) {
        if (h[i-1] >= h[i]) {
            c++;
        }
        else {
            if (max < c) max = c;
            c = 0;
        }
    }
    if (max < c) max = c;
    cout << max;
}

Measured memory_bytes: 640
def solve(k, koho, cho=[], syo=0):
    if syo == 2:
        lenc=len(cho)
        for i in range(min(k,lenc)):
            mn = min(cho)
            if mn < 0:
                cho.remove(mn)
            else:
                break
        return sum(cho)
    if syo == 1:
        koho = koho[::-1]
    re = []
    lenk = len(koho)
    for i in range(min(k, lenk)+1):
        re.append(solve(k - i, koho[i:], cho+koho[:i], syo + 1))
    return max(re)

n, k = map(int, input().split())
vs = list(map(int, input().split()))
print(solve(k, vs))


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
#include <math.h>
#include<cmath>
#define INF 1000000000;
using namespace std;
vector<pair<long long,long long>>juice;
int main() {
	int a = 0;
	string u;
	long long counto = 0;
	cin >> u >>counto;
	for (long long i = 0; i < u.size(); i++) {
		if (u[i] > '1'||counto==i+1) {
			cout << u[i] << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	int a[5],i,m;
	for(i=0;i<5;i++){
		cin >> a[i];
		if(i==0){
			m = i;
		}else{
			if(a[m]%10>a[i]%10 && a[i]%10!=0) m = i;
		}
	}
	int n = 0;
	for(i=0;i<5;i++){
		if(m!=i && a[i]%10!=0){
			n = n + (a[i] / 10) * 10 + 10;
		}else if(m!=i && a[i]%10==0){
			n = n + (a[i] / 10) *10;
		}else{
			n = n + a[i];
		}
	}
	cout << n << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;

class dice
{
    int left, right, top, bottom, front, back;

public:
    void turn(char op);
    void getdice(int t, int f, int r, int l, int ba, int bo);
    void disp();
};

void dice::turn(char op)
{
    int tmp;
    if (op == 'E')
    {
        tmp = top;
        top = left;
        left = bottom;
        bottom = right;
        right = tmp;
    }
    else if (op == 'W')
    {
        tmp = top;
        top = right;
        right = bottom;
        bottom = left;
        left = tmp;
    }
    else if (op == 'N')
    {
        tmp = top;
        top = front;
        front = bottom;
        bottom = back;
        back = tmp;
    }
    else if (op == 'S')
    {
        tmp = top;
        top = back;
        back = bottom;
        bottom = front;
        front = tmp;
    }
}

void dice::getdice(int t, int f, int r, int l, int ba, int bo)
{
    left = l, right = r, top = t, bottom = bo, front = f, back = ba;
}

void dice::disp()
{
    cout << top << endl;
}

int main()
{
    int n, t, f, r, l, ba, bo, lenop;
    dice a;
    string op;
    cin >> t >> f >> r >> l >> ba >> bo;
    cin >> op;
    lenop = op.size();
    a.getdice(t, f, r, l, ba, bo);
    for (int i = 0; i < lenop; i++)
    {
        a.turn(op[i]);
    }
  	a.disp();
    return 0;
}



Measured memory_bytes: 3180
INF = float("inf") #const

def main():
    s = input()
    n = len(s)
    ans = 0

    if n%2==0:
        s1 = s[:n//2]
        s2 = s[n//2:]
        for i in range(n//2):
            if s1[i] != s2[(n//2)-i-1]:
                ans += 1
    else:
        s1 = s[:n//2]
        s2 = s[(n//2)+1:]
        for i in range(n//2):
            if s1[i] != s2[(n//2)-i-1]:
                ans += 1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll mod= 1e9 + 7;


int main(){
  int a,b,c;
  cin >> a >>b >>c;
  if(a+b>=c){cout << "Yes" << endl;}else{cout << "No" << endl;}
}

Measured memory_bytes: 3628