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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using namespace std;

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

int main(void){
	int t;
	cin >> t;

	rep(loop,t){
		vector<int> add;

		int cur;
		while(cin >> cur,cur) add.push_back(cur);

		int n=0;
		for(auto &it:add) if(it>0) n++;

		vector<vector<int>> ans(n);
		vector<int> degree(n,0),ord;
		cur=-1;

		for(auto &it:add){
			int len=0;
			if(it>0){
				ord.push_back(++cur);
				degree[cur]=it;

				len=ord.size();
				if(len>=2){
					const int a=ord[len-1],b=ord[len-2];
					degree[a]--,degree[b]--;
					ans[a].push_back(b);
					ans[b].push_back(a);
				}
			}else{
				len=ord.size();
				const int a=ord[len-1],b=ord[len-1+it];
				degree[a]--,degree[b]--;
				ans[a].push_back(b);
				ans[b].push_back(a);
			}

			while(ord.size() && degree[ord[ord.size()-1]]==0) ord.pop_back();
		}

		rep(i,n){
			cout << i+1;
			sort(_all(ans[i]));
			for(auto &j:ans[i]) cout << " " << j+1;
			cout << endl;
		}	
	}
	return 0;
}

Measured memory_bytes: 3072
(defun split (str)
  (labels ((inner (rest-str-list stack-str-list temp-out)
                  (if rest-str-list
                      (let ((now-char (car rest-str-list)))
                        (cond ((eq #\space now-char) (inner (cdr rest-str-list)
                                                            '()
                                                            (cons (concatenate 'string (reverse stack-str-list))
                                                                  temp-out)))
                              (t (inner (cdr rest-str-list)
                                        (cons now-char stack-str-list)
                                        temp-out))))
                      (reverse (cons (concatenate 'string (reverse stack-str-list))
                                     temp-out)))))
          (inner (concatenate 'list str)
                 '()
                 '())))

(defun input-to-list (str)
  (mapcar #'parse-integer (split str)))

(defvar whxy (input-to-list (read-line)))
(let* ((w (car whxy))
       (h (cadr whxy))
       (x (caddr whxy))
       (y (cadddr whxy))
       (area (/ (* w h) 2)))
  (format t "~,6f " (float area))
  (format t "~d" (if (and (eq x (/ w 2))
                          (eq y (/ h 2)))
                     1
                     0)))

Measured memory_bytes: 15460
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define set0(a) memset ((a), 0 , sizeof(a))
#define set1(a) memset((a),-1,sizeof (a))
#define pi pair<int, int>
#define ps pair<string, string>
#define pl pair<long, long>
#define pll pair<long long, long long>
#define vll vector<long long>
#define vl vector<long>
#define vi vector<int>
#define vs vector<string>
#define vps vector< ps >
#define vpi vector< pi >
#define vpl vector< pl >
#define vpll vector< pll >
#define flash  ios_base::sync_with_stdio(false); cin.tie(NULL);
long long modexp(long long A,long long B,long long M){
    if(B==0)
    return 1;
    else if(B%2==0)
    return modexp((A*A)%M,B/2,M);
    else if(B%2!=0)
    return (A*modexp((A*A)%M,(B-1)/2,M))%M;

}
bool sortbysec(const pll &a,
              const pll &b)
{
    return (a.second < b.second);
}

void func(void)
{
        freopen("input.c","r",stdin);
        freopen("output.c","w",stdout);
}
int main(){
    ll n;
    cin>>n;
    ll a[n];
    ll h[n]={};
    int flag=0;
    for(ll i=0;i<n;i++){
            cin>>a[i];
            h[a[i]]++;
            if(n%2==0 && a[i]==0){
                flag=1;
                break;
            }
            if(h[0]>1){
                  flag=1;
                break;
            }
            if(h[a[i]]>2){
                 flag=1;
                break;
            }

    }
    ll ans;
    if(flag!=1){

             ans=modexp(2,n/2,mod);

    }
    else ans=0;

    cout<<ans<<endl;
}


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

namespace AltCoder
{
    public sealed class C_Vacation
    {
        public static void Main()
        {
            int N = Convert.ToInt32(Console.ReadLine());
            int[,] d = new int[N + 1, 3];

            for (long i = 0; i < N; i++)
            {
                int[] abc = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => Convert.ToInt32(x)).ToArray();

                if (i == 0)
                {
                    for (int j = 0; j < 3; j++)
                    {
                        d[i + 1, j] = abc[j];
                    }
                }
                else
                {
                    for (int k = 0; k < 3; k++)
                    {
                        for (int j = 0; j < 3; j++)
                        {
                            if (k != j)
                            {
                                d[i + 1, k] = Math.Max(d[i + 1, k], d[i, j] + abc[k]);
                            }
                        }
                    }
                }
            }

            int result = Math.Max(d[N, 2], Math.Max(d[N, 0], d[N, 1]));
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 16436
def main():
    N = int(input())
    T = tuple(tuple(map(int, input().split())) for _ in [0] * N)

    for t, x, y in T:
        if t < x + y or t & 1 != (x + y) & 1:
            print('No')
            break
    else:
        print('Yes')

main()


Measured memory_bytes: 18220
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<(int)(N);i++)
typedef vector<vector<int>> Matrix;
const Matrix direction={{0,1},{1,0},{-1,0},{0,-1}};
const int INF=0x7fffffff>>1;
int A=0,H,W;
void warshall_floyd(Matrix &d)
{
  int n=H*W;
  rep(k,n)
  {
    rep(i,n)
    {
      rep(j,n)
      {
        if(d.at(i).at(k)==INF||d.at(k).at(j)==INF) continue;
        d.at(i).at(j)=min(d.at(i).at(j),d.at(i).at(k)+d.at(k).at(j));
      }
    }
  }
  rep(i,n)rep(j,n)if(d.at(i).at(j)<=n) A=max(A,d.at(i).at(j));
}
int main()
{
  int u,v,x,y;
  char c;
  cin>>H>>W;
  Matrix data(H,vector<int>(W,0)),graph(H*W,vector<int>(H*W,INF));
  rep(i,H*W)rep(j,H*W){if(i==j)graph.at(i).at(j)=0;}
  rep(i,H)rep(j,W){cin>>c;if(c=='.') data.at(i).at(j)=1;}
  rep(i,H)
  {
    rep(j,W)
    {
      if(data.at(i).at(j)==1)
      {
        x=i*W+j;
        rep(k,4)
        {
          u=i+direction.at(k).at(0);
          v=j+direction.at(k).at(1);
          y=u*W+v;
          if(u<0||u>=H||v<0||v>=W||x<0||x>=H*W||y<0||y>=H*W) continue;
          if(data.at(u).at(v)==1) graph.at(x).at(y)=1;
        }
      }
    }
  }
  warshall_floyd(graph);
  cout<<A<<endl;
}

Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <numeric>

using namespace std;

int main(){
    long long n;
    cin >> n;
    long long ans = 0;
    for (long long i = 1; i <= n; i++)
    {
        if(i*i<=n)ans=i*i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
////////////////////////////////////////////
///                                      ///
///         Template ver. 1 rapel        ///
/// Fear is Temporary, Regret is Forever ///
///          Must Try and Get AC         ///
///                                      ///
////////////////////////////////////////////
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>

#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>

#include <math.h>
#include <complex>

#include <assert.h>
#include <time.h>
//#include <chrono>
//#include <random>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>

#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define endl '\n'
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

void desperate_optimization(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

const LL MOD = 1e9 + 7;
const int N = 1e5;
const int D = 100;
LL dp[2][N + 5][D + 5];

string s;
int d;

LL calc(int issame, int idx,int sisa) {
	if(idx == s.size()) return (sisa == 0);
	LL &res = dp[issame][idx][sisa];
	if(res != -1) return res;
	res = 0;
	int x = s[idx] - '0';
	if(issame == 0) x = 9;
	for(int i = 0;i <= x;i++) {
		res = (res + calc(issame & (i == x), idx + 1, (sisa + i) % d)) % MOD;
	}
	return res;
}

void hora(int tc) {
	cin>>s>>d;
	memset(dp,-1,sizeof dp);
	cout<<(calc(1,0,0) + MOD - 1) % MOD<<endl;	
}

int main(){
	desperate_optimization(10);
	int ntc = 1;
	//cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) hora(tc);
	return 0;
}



Measured memory_bytes: 165120
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    sc.useDelimiter(",|\n");
    int w=sc.nextInt();
    int array[]=new int[w];
    for(int i=0;i<w;i++) array[i]=i+1;
    int n=sc.nextInt();
    int a,b,c;
    for(int i=0;i<n;i++){
      a=sc.nextInt();
      b=sc.nextInt();
      c=array[a-1];
      array[a-1]=array[b-1];
      array[b-1]=c;
    }
    for(int i=0;i<w;i++) System.out.println(array[i]);
    sc.close();
  }
}


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

int main(){
	string s;
	cin>>s;
	int ans=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='g'){
			if(i%2)ans++;
		}
		else{
			if(i%2==0)ans--;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int main() {
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;
    vector<int> W, S;
    for (int i = 0; i < 30; i++) {
        for (int j = 0; j < 30; j++) {
            int w = A * i + B * j;
            if (w != 0 && w * 100 <= F) W.push_back(w);
        }
    }
    for (int i = 0; i < 100; i++) {
        for (int j = 0; j < 100; j++) {
            int s = C * i + D * j;
            S.push_back(s);
        }
    }
    sort(S.begin(), S.end());
    int ans_a = 100 * A;
    int ans_b = 0;
    for (auto w : W) {
        auto it = upper_bound(ALL(S), min(w * E, F - w * 100));
        if (it != S.begin()) {
            int s = *(it - 1);
            if (ans_b * (100 * w + s) < s * (ans_a + ans_b)) {
                ans_a = 100 * w;
                ans_b = s;
            }
        }
    }
    cout << ans_a + ans_b << " " << ans_b << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <stack>
#include <string>

int main() {
  std::stack<int> st;
  std::string s;
  while (std::cin >> s) {
    if (s == "+") {
      int b = st.top();
      st.pop();
      int a = st.top();
      st.pop();
      st.push(a + b);
    } else if (s == "-") {
      int b = st.top();
      st.pop();
      int a = st.top();
      st.pop();
      st.push(a - b);
    } else if (s == "*") {
      int b = st.top();
      st.pop();
      int a = st.top();
      st.pop();
      st.push(a * b);
    } else {
      st.push(std::stoi(s));
    }
  }
  std::cout << st.top() << std::endl;
  st.pop();
  return 0;
}


Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
 
int main(){
  ll h,a,sum=2;
  ll b=3;
  cin>>h;
  a=log2(h);
  for(int i=1;i<a;i++){
    sum=2*b;
    b=1+sum;
  }
  if(h==1){
    cout<<1<<endl;
  }else{
  cout<<sum+1<<endl;
  }
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextInt()
    val xs = mutableListOf<Int>()
    val ys = mutableListOf<Int>()
    (1..n).forEach {
        xs.add(scanner.nextInt())
    }
    (1..n).forEach {
        ys.add(scanner.nextInt())
    }

    val xys = xs.zip(ys)
    val f = { p: Pair<Int, Int> -> Math.abs(p.first - p.second) }

    println(xys.map(f).sum())
    println(Math.sqrt(xys.map { p -> Math.pow(f(p).toDouble(), 2.0) }.sum()))
    println(Math.cbrt(xys.map { p -> Math.pow(f(p).toDouble(), 3.0) }.sum()))
    println(xys.map(f).max())
}



Measured memory_bytes: 28492
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n);
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

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

  auto num = atoi(s.c_str());

  ll ans = 0;
  ll n = s.size();

  ll i_s[n];

  REP(i, n) i_s[i] = s[i] - '0';

  /*
  
  REP(bit, (1<<n)){
    vector<ll> l;
    vector<ll> r;
    for (int i = 0; i < n; ++i) {
      if (bit & (1<<i)) { // i が bit に入るかどうか
	l.push_back(i_s[i]);
      }
      else{
	r.push_back(i_s[i]);
      }
    }

    ll l_v=0L, r_v=0L;

    REP(i, l.size()){
      l_v += l[i]*pow(10,l.size()-1-i);
    }
    REP(i, r.size()){
      r_v += r[i]*pow(10,r.size()-1-i);
    }
    
    cout << l_v + r_v << endl;
    ans += l_v + r_v;
  }

  cout << ans - num << endl;
  
  */

  string plus[n-1];
  //REP(i, pow(2, (n-1))){
  REP(i, (1 << (n-1))){
    ll sum=0, cur=0;
    REP(j, n){
      if(i & (1 << (j-1))){
	//cout << "sum: " << sum << endl;
	sum += cur;
	cur = 0;
      }
      cur = cur * 10 + i_s[j];
    }
    sum += cur;
    ans += sum;
  }

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


Measured memory_bytes: 256
c = 0

while True:
  a,b = map(int, input().split()); c+=1
  if a < b:
    print(a,b)
  elif a >b:
    print(b,a)
  elif a ==b and a !=0 and b!=0:
    print(a,b)
 
  elif a ==0 and b == 0: break
  


Measured memory_bytes: 5612
main(){double a,l,x,s,t;
for(;~scanf("%lf%lf%lf",&a,&l,&x);)
s=(l+l+a)/2,printf("%lf\n",sqrt((a/2)*(a/2)*(s-a)*s)+sqrt(l*l*x*(l+x+l))/2);exit(0);}

Measured memory_bytes: 652
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A, B;
  cin >> A >> B;
  for(int i=1; i<=1050; i++) {
    if(A == i*8/100 && B == i*10/100) {
      cout << i << "\n";
      return 0;
    }
  }
  cout << -1 << "\n";
  return 0;
}


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

int main()
{ ll i, j, k, n, kn, val, tmp, suma, maxa;

  cin>>n;
  vl2 veka(n+1, vl1(4)), dp(n+1, vl1(4));
  for(i=1;i<=n;i++) cin>>veka[i][1]>>veka[i][2]>>veka[i][3];

  veka[0][1]=0; veka[0][2]=0; veka[0][3]=0;
  dp[0][1]=0; dp[0][2]=0; dp[0][3]=0;

  for(i=1;i<=n;i++)
    { for(k=1;k<=3;k++)
       { suma=0;
         for(j=1;j<=3;j++)
           { if(j != k)
               { val=dp[i-1][j];
                 if(val>suma) suma = val;
               }
           }
         dp[i][k]+=(suma+veka[i][k]);
       }
    }

   suma=0;
   for(j=1;j<=3;j++)
     { val=dp[n][j];
       if(val>suma) suma = val;
     }
   cout << suma << endl;
  return 0;
}
/*
3
10 40 70
20 50 80
30 60 90
*/


Measured memory_bytes: 17232
N = int(input())
a = list(map(int, input().split()))
score = [[1,399,0],[400,799,0],[800,1199,0],[1200,1599,0],[1600,1999,0],[2000,2399,0],[2400,2799,0],[2800,3199,0],[3200,4800,0]]

for i in range(N):
    for j in range(len(score)):
        if score[j][0] <= a[i] <= score[j][1]:
            score[j][2] += 1
            break
        else:
            continue
ans = 0
for _,_,cnt in score[:-1]:
    if cnt >= 1:
        ans += 1
print(max(1, ans, ans-score[-1][2]), ans+score[-1][2])

Measured memory_bytes: 3064
#include <iostream>
#include<string>
#include<sstream>
#include<vector>

using namespace std;
int main()
{
    long long int r,d;
int   arr[2000];
    cin>>r>>d;
    int val,equ;
    cin>>val;
    int counter=0;
  arr[0]=val;
    for(int i=0 ;i<10; i++)
    {
            if(arr[i]<0){ break;}
      if(arr[i]>0){  counter++; arr[i+1] =(arr[i]*r)-d;}

    }
    for(int i=1 ; i<=counter; i++)
    {
        cout<<arr[i]<<endl;
    }





}


Measured memory_bytes: 256
#7  Integer Cards
n,m = map(int,input().split())
a = list( map(int,input().split()))
bc=[[0]*2 for _ in range(m)]
for i in range(m):
    bc[i] = list(map(int,input().split()))

a.sort()
bc.sort(reverse=True,key=lambda x:x[1])

nokori=n
bc2=[]
for (bb,cc) in bc:
    if bb<=nokori:
        bc2.extend([cc]*bb)
        nokori-=bb
    else:
        bc2.extend([cc]*nokori)
        nokori=0
        break

print( sum(sorted(a+bc2,reverse=True)[:n]) )
    

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

#define MOD 1000000007

using namespace std;

int main() {
	string s;
	cin >> s;
	int a[4];
	a[0] = 1;
	a[1] = a[2] = a[3] = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'A') {
			a[1] = (a[1] + a[0]) % MOD;
		} else
		if (s[i] == 'B') {
			a[2] = (a[2] + a[1]) % MOD;
		} else
		if (s[i] == 'C') {
			a[3] = (a[3] + a[2]) % MOD;
		} else {
			a[3] = (3LL * a[3] + a[2]) % MOD;
			a[2] = (3LL * a[2] + a[1]) % MOD;
			a[1] = (3LL * a[1] + a[0]) % MOD;
			a[0] = (3LL * a[0]) % MOD;
		}
		// for (int i = 0; i < 4; i++) {
		// 	printf("%d%c", a[i], " \n"[i == 3]);
		// }
	}
	cout << a[3] << endl;
	return 0;
}

Measured memory_bytes: 512
#include<sstream>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())
#define indexOf(v,x) (find(all(v),x)-v.begin())


using namespace std;

int dpt[101][128];
int dpd[10001];
int dp[101][128];

int e[100],c[100];
int h[100],a[100];


int main(){
	int S,T,U,N,O,D;
	cin>>S>>T>>U>>N>>O>>D;
	rep(i,T)cin>>e[i]>>c[i];
	rep(i,N)cin>>h[i]>>a[i];
	memset(dpt,-1,sizeof(dpt));
	dpt[0][0]=0;
	rep(i,T){
		for(int j=i;j>=0;j--){
			for(int k=S-e[i];k>=0;k--){
				if(dpt[j][k]==-1)continue;
				dpt[j+1][k+e[i]]=max(dpt[j+1][k+e[i]], dpt[j][k]+c[i]);
			}
		}
	}
	memset(dpd,-1,sizeof(dpd));
	dpd[0]=0;
	rep(i,N){
		rep(j,100*100+1){
			if(dpd[j]==-1||10000<j+a[i])continue;
			dpd[j+a[i]]=max(dpd[j+a[i]],dpd[j]+h[i]);
		}
	}
	int v=0;
	rep(i,100*100+1){
		v=max(v,dpd[i]);
		dpd[i]=v;
	}
	memset(dp,-1,sizeof(dp));
	dp[0][S]=0;
	rep(i,D){
		rep(j,S+1){
			if(dp[i][j]==-1)continue;
			rep(k,j+1){
				if(dpt[U][k]==-1)continue;
				dp[i+1][min(S,j-k+O)]=max(dp[i+1][min(S,j-k+O)], dp[i][j]+dpd[dpt[U][k]]);
			}
		}
	}
	int ans=-1;
	rep(i,S+1)ans=max(ans,dp[D][i]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1312
N,A,B = map(int,input().split())

h = []

for i in range(N):
    h.append(int(input()))

def det(num):
    count = 0
    for i in range(N):
        H = h[i]-B*num
        count += max(0,H//(A-B) + min(1,H%(A-B)))
    if count <= num:
        return True
    else:
        return False

x = 1###False
y = max(h)###True

while y - x > 1:
    if det((x+y)//2):
        y = (x+y)//2
    else:
        x = (x+y)//2
    #print(x,y)

print(y)

Measured memory_bytes: 51296
//#include"pch.h"
//#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<algorithm>
#include<iostream>
using namespace std;

int main() {
	int N;
	int A[100];
	int min = 1000000000, max = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		min = (min > A[i]) ? A[i] : min;
		max = (max < A[i]) ? A[i] : max;
	}
	cout << max - min << endl;

	return(0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n, a, t, k, res;
int main() {
	scanf("%d", &n);
	while (n--) {
		scanf("%d%d", &a, &k);
		while (a > k && a % k != 0) {
			t = a / k + 1;
			a -= max(a % k / t, 1) * t;
		}
		res ^= a / k;
	}
	puts(res ? "Takahashi" : "Aoki");
	return 0;
}

Measured memory_bytes: 256
A = [[int(i) for i in input().split()] for i in range(3)]

if all(A[i][j] - A[i][j + 1] == A[i + 1][j] - A[i +1][j + 1] for i in range(2) for j in range(2)):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <cstdio>
int n;
int A[1000000];

int binrarrySeach (int &key) {
    int left = 0;
    int right = n;
    while(left < right) {
        
        int mid = (left + right) / 2;
        if (A[mid] == key){
            return 1;
        } else if ( A[mid] > key) {
            right = mid;
        } else {
            left = mid + 1;
        }
    }
    return 0;
}

int main() {
    int q;
    int t;
    int count = 0;
    scanf("%d", &n);
    
    for (int i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }
    
    scanf("%d", &q);
    for (int i = 0; i < q; i++) {
        scanf ("%d", &t);
        
        if(binrarrySeach(t) == 1){
            count++;
        }
    }
    
    printf("%d\n", count);
    return 0;
}


Measured memory_bytes: 3148
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int a, b;
    cin >> a >> b;
    swap(a,b);
    cout << (a + b - 1) / a << endl;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define MOD ((int)(1e9) + 7)
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define filename "lynext"
#define freop freopen(filename ".cik","w",stdout);freopen(filename ".gir","r",stdin)
const long long int N = ((long long int)1e3) + 5;
const long long int M = ((long long int)1e3) + 5;
const long long int llinf = (long long int)1e18;
const int inf = INT_MAX;
typedef long long int lli;

lli ans;
lli n;
lli arr[N];

int main ()
{
	fast;
	//freop;
	cin >> n;
	for (lli i = 1; i <= n * 2; i++)
	{
		cin >> arr[i];
	}
	sort(arr + 1, arr + (2 * n) + 1);
	for (lli i = 1; i <= 2 * n; i += 2)
	{
		ans += min(arr[i],arr[i + 1]);
	}
	cout << ans << "\n";
}


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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int m, k;
    cin >> m >> k;
    // (0,0,1,...,1<<m - 1, 1<<m - 1)
    if (k >= (1 << m))
    {
        cout << -1 << endl;
        return 0;
    }
    if (k == 0)
    {
        vector<int> ret;
        for (int i = 0; i < (1 << m); i++)
        {
            ret.push_back(i);
            ret.push_back(i);
        }
        printv(ret);
        return 0;
    }
    int sum = 0;
    for (int i = 1; i < (1 << m); i++)
        sum ^= i;
    if (k != (k ^ sum))
    {
        cout << -1 << endl;
        return 0;
    }
    vector<int> ret = {0};
    ret.push_back(k);
    ret.push_back(0);
    for (int i = 1; i < k; i++)
        ret.push_back(i);
    for (int i = k + 1; i < (1 << m); i++)
        ret.push_back(i);
    ret.push_back(k);
    for (int i = (1 << m) - 1; i >= k + 1; i--)
        ret.push_back(i);
    for (int i = k - 1; i >= 1; i--)
        ret.push_back(i);
    printv(ret);
}


Measured memory_bytes: 2932
N = 100001
A,B = [True]*N,[0]*N
A[0],A[1] = False,False
for i in range(2,N):
    if A[i]:
        for j in range(i*2,N,i):
            A[j] = False
c=0
for i in range(3,N):
    if A[i] and A[(i+1)//2]:
        c += 1
    B[i] = c
Q = int(input())
for i in range(Q):
    l,r = map(int,input().split())
    print(B[r]-B[l-1])

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

using namespace std;

const long long MOD = 1e9 + 7;

inline long long add(long long x, long long y) {
	return ((x % MOD) + (y % MOD)) % MOD;
}

inline long long multiply(long long x, long long y) {
	return ((x % MOD) * (y % MOD)) % MOD;
}

int main() {
	
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);

	string s;
	cin >> s;

	int n = s.length();
	vector<vector<long long>> dp(13, vector<long long>(n));

	if(s[n-1] == '?') {
		for(int i = 0; i < 10; i++) {
			dp[i][n-1] = 1;
		}
	}
	else {
		int num = (s[n - 1] - '0');
		dp[num][n-1] = 1;
	}

	int x = 10;

	for(int i = n - 2; i >= 0; i--) {
		vector<int> v(13);
		if(s[i] == '?') {
			for(int j = 0; j <= 9; j++) {
				int r = (x * j) % 13;
				v[r]++;
			}
		}
		else {
			int d = (s[i] - '0');
			int r = (x * d) % 13;
			v[r] = 1;
		}

		for(int x = 0; x < 13; x++) {
			for(int y = 0; y < 13; y++) {
				int r = (x + y) % 13;
				dp[r][i] = add(dp[r][i], multiply(v[x], dp[y][i+1]));
			}
		}

		x = (x * 10) % 13;
	}

	cout << dp[5][0] << ' ';

	return 0;
}

Measured memory_bytes: 11472
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = (s); i < (n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==v.size()-1?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

struct edge {
    int id,to;
    edge(int id,int to):id(id),to(to) {}
};

void dfs(vector<vector<edge>> &G,vi &depth,vi &par,vi &par_id,int v = 0,int p = -1,int p_id = -1) {
    par[v] = p;
    par_id[v] = p_id;
    for(edge &e : G[v]) {
        if(e.id == p_id) continue;
        depth[e.to] = depth[v]+1;
        dfs(G,depth,par,par_id,e.to,v,e.id);
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    vector<vector<edge>> G(n);
    rep(i,n-1) {
        int a,b;
        cin >> a >> b;
        a--; b--;
        G[a].eb(i,b);
        G[b].eb(i,a);
    }
    vi depth(n),par(n),par_id(n);
    depth[0] = 0;
    dfs(G,depth,par,par_id);
    vi inc(n-1);
    auto add = [&](int i,int v) {
        inc[v] |= 1<<i;
    };
    int m;
    cin >> m;
    rep(i,m) {
        int u,v;
        cin >> u >> v;
        u--; v--;
        if(depth[u] > depth[v]) swap(u,v);
        while(depth[u] < depth[v]) {
            add(i,par_id[v]);
            v = par[v];
        }
        while(u != v) {
            add(i,par_id[u]);
            add(i,par_id[v]);
            u = par[u];
            v = par[v];
        }
    }
    ll ans = 0;
    rep(bit,1<<m) {
        int cnt = __builtin_popcount(bit);
        ll ret = 1;
        rep(i,n-1) if(!(inc[i]&bit)) ret *= 2;
        if(cnt&1) ans -= ret;
        else ans += ret;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if(x<=W-r&&y<=H-r&&r<=x&&r<=y){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    int M = 0;
    int res = 0;
    for(int i=0; i<N; ++i) {
        int p;
        cin >> p;
        res += p;
        M = max(M, p);
    }
    cout << res - M / 2 << endl;
}

Measured memory_bytes: 256
S=input()
L,R=[0],[0]
for s in S:
    if s == '<': L.append(L[-1]+1)
    else: L.append(0)
for s in S[::-1]:
    if s == '>': R.append(R[-1]+1)
    else: R.append(0)
ans = 0
for i in range(len(S)+1):
    ans += max(L[i], R[-1-i])
print(ans)


Measured memory_bytes: 79756
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n;
  cin >> n;
  ll k = 0;
  for(int i = 1;i <= 11111;i++){
    ll now = i * 5 + 1;
    bool pri = true;
    for(int j = 2;j <= sqrt(now);j++){
      if(now % j == 0)pri = false;
    }
    if(k < n - 1 && pri)cout << now << " ",k++;
    else if(pri){
      cout << now << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3544
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(T: int, X: int):
    return  T / X


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    T = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    result = solve(T, X)
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5140
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF (1<<29)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
const int dx[] = {-1,0,0,1},dy[] = {0,1,-1,0};

typedef long long int ll;

using namespace std;

int ice[1001][1001];
int jun[1001][1001];
int oce[1001][1001];
int main(){
    int m,n,k;
    memset(ice,0,sizeof(ice));
    memset(jun,0,sizeof(jun));
    memset(oce,0,sizeof(oce));
    cin >> m >> n;
    cin >> k;
    REP(i,m){
	string s;
	cin >> s;
	REP(j,n){
	    if(s[j] == 'O') oce[i+1][j+1]++;
	    if(s[j] == 'J') jun[i+1][j+1]++;
	    if(s[j] == 'I') ice[i+1][j+1]++;
	}
    }
    REP(i,n+1){
	REP(j,m){
	    oce[j+1][i] += oce[j][i];
	    jun[j+1][i] += jun[j][i];
	    ice[j+1][i] += ice[j][i];
	}
    }
    REP(i,n){
	REP(j,m+1){
	    oce[j][i+1] += oce[j][i];
	    jun[j][i+1] += jun[j][i];
	    ice[j][i+1] += ice[j][i];
	}
    }
    REP(i,k){
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	a--;
	b--;
	int oans,ians,jans;
	oans = oce[c][d] - oce[c][b] - oce[a][d] + oce[a][b];
	jans = jun[c][d] - jun[c][b] - jun[a][d] + jun[a][b];
	ians = ice[c][d] - ice[c][b] - ice[a][d] + ice[a][b];
	printf("%d %d %d\n",jans,oans,ians);
    }
    return 0;
}

Measured memory_bytes: 12948
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(ll x = l;x<u;x++)
#define RREP(x,l,u) for(ll x = l;x>=u;x--)
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define mst(x,a) memset(x,a,sizeof(x))
#define all(a) a.begin(),a.end()
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-(x)))
#define lson (ind<<1)
#define rson (ind<<1|1)
#define se second
#define fi first
#define sz(x) ((int)x.size())
#define EX0 exit(0);

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;
typedef vector<ll> VLL;
typedef vector<int> VI;
const int block_size = 320;
typedef complex<ll> point;
const ll mod = 1e9 + 7;
const ll inf = 1e9 + 7;
const ld eps = 1e-9;
const db PI = atan(1) * 4;

template<typename T, typename S>inline bool upmin(T&a, const S&b) { return a > b ? a = b, 1 : 0; }
template<typename T, typename S>inline bool upmax(T&a, const S&b) { return a < b ? a = b, 1 : 0; }

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a%b); }
namespace SOLVE {
	VI diff; // difference to root
	VI parent;

	void update(int x) { // finds the distance of vertex from parent
		int og = x, ogparent = parent[x];
		if (ogparent == og) { // x itself is a root
			return;
		}
		if (ogparent == parent[ogparent]) { // x is already a secondary
			return;
		}
		update(ogparent); // update the node ahead of it otherwise

		parent[og] = parent[ogparent];
		diff[og] += diff[ogparent];
	}


	void relate(int x, int y, int z) {
		update(x);
		update(y);
		if (parent[x] != parent[y]) {
			diff[parent[y]] = z - diff[y];
			parent[parent[y]] = x;
		}		
	}

	void distance(int a, int b) {
		update(a);
		update(b);
		if (parent[b] != parent[a]) {
			cout << '?' << endl;
		}
		else {
			cout << diff[b] - diff[a] << endl;
		}
		return;
	}

	void main() {
		int n, q;
		int a, b, c, d;
		cin >> n >> q;
		parent.resize(n);
		diff.resize(n, 0);

		REP(i, 0, n) {
			parent[i] = i;
		}
		REP(i, 0, q) {
			cin >> a;
			if (a == 0) {
				cin >> b >> c >> d;
				relate(b, c, d);
			}
			else {
				cin >> b >> c;
				distance(b, c);
			}
		}
	}
}


signed main() {

	int t;
	//    in(t);
	t = 1;
	while (t--) {
		SOLVE::main();

	}

	return 0;
}



Measured memory_bytes: 3624
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    num_list = i_list()

    num_list.sort()

    print(num_list[0] + num_list[1])

if __name__ == '__main__':
    main()


Measured memory_bytes: 77056
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <cstring>
#include <ctime>
#include <queue>
#include <map>
#include <stack>
using namespace std;
typedef long long ll;
const int maxn = 105;
const int mod = 1000000007;

int main() {
 // freopen("in.cpp","r",stdin);
  ll ret=1;
  int n;
  cin>>n;
  stack<int>st;
  for(int i=1;i<=n;i++){
    int x;
    cin>>x;
    if(st.empty())st.push(1);
    else{
      if(st.top()==x-1){
        ret=ret*(st.size()+1)%mod;
      } else st.push(st.top()+2);
    }
    //cout<<i<<" "<<st.size()<<endl;
  }
  while(!st.empty()){
    ret=ret*st.size()%mod;
    st.pop();
  }
  cout<<ret<<endl;
  return 0;
}


Measured memory_bytes: 640
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

const int MOD = 1e9 + 7;
const int INF = INT_MAX;

signed main() {
    Fast();

    int a, b, c, d;
    cin >> a >> b >> c >> d;

    cout << ((a + b == c + d) ? "Balanced" : (a + b > c + d) ? "Left" : "Right");
    cout << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int h,w;
    cin>>h>>w;
    char a[h][w];
    int count=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>a[i][j];
            if(a[i][j]=='#')count++;
        }
    }
    
    if(count==h+w-1)cout<<"Possible"<<endl;
    else cout<<"Impossible"<<endl;
    
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        String s = scanner.nextLine();
        char[] chars = s.toCharArray();

        if (chars[2] == chars[3] && chars[4] == chars[5]){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);

  int A,B,C;
  cin>>A>>B>>C;
  cout<<min(C,B/A)<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = getInt(sc);
		while (!isPrime(x)) {
			x++;
		}
		System.out.println(x);
	}

	private static boolean isPrime(int x) {
		if (x == 2) {
			return true;
		}
		for (int i = 3; i < x; i = i + 2) {
			if (x % i == 0) {
				return false;
			}
		}
		return true;
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をlongで返却
	 *
	 * @return
	 */
	public static long getLong(Scanner sc) {

		return Long.parseLong(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をintで返却
	 *
	 * @return
	 */
	public static int getInt(Scanner sc) {

		return Integer.parseInt(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をStringで返却
	 *
	 * @return
	 */
	public static String getString(Scanner sc) {

		return sc.next();
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をint配列で返却
	 *
	 * @return
	 */
	public static int[] getIntArray(Scanner sc) {
		String line = "";
		// 直前にnext()を実行していると改行コードだけ取ってしまうのでその対策
		while (line.equals("")) {
			line = sc.nextLine();
		}

		String[] strArray = line.split(" ");
		int[] intArray = new int[strArray.length];
		for (int i = 0; i < strArray.length; i++) {
			intArray[i] = Integer.parseInt(strArray[i]);
		}
		return intArray;
	}

}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    ll n, x;
    cin >> n >> x;
    vector<ll> a(n);
    vector<ll> b(n);
    ll ans = 0;
    REP(i, n) {
        cin >> a[i];
        b[i] = a[i];
        ans += a[i];
    }

    REP1(k, n - 1) {
        ll t = 0;
        REP(i, n) {
            int idx = i - k;
            if (idx < 0) idx += n;
            ll c = min(b[i], a[idx]);
            t += c;
            b[i] = c;
        }
        chmin(ans, x * k + t);
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int a,b,c;
  cin >>a>>b>>c;
  if ((a ==b)&&(a ==c)){
    cout << "No" << endl;
  }
  else{
  if (a ==b){
    cout << "Yes"<< endl;
  }
  else if (a == c) { 
    cout <<"Yes"<< endl;
  }
  else if (b == c){
    cout <<"Yes" << endl;
    
  }
  else {
    cout << "No" << endl;
  }
  }
}

Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;

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

    string a = S.substr(0, S.length() / 2);
    string b = S.substr(S.length() / 2 , S.length());
    reverse(b.begin(), b.end());

    int count = 0;
    for (int i = 0; i < a.length(); ++i) {
        if(b.length() > i) {
            if(a[i] != b[i]) {
                count++;
            }
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDigit(a,b) (a+b-1)/b //小数点切り上げ
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD = int(1e9)+7; 
using namespace std;
using pii = pair<lol, lol>;
typedef vector<int> vit;

//最大公約数
lol gcd(lol x, lol y){ return (y != 0 ? gcd(y, x % y) : x); }
//最小公倍数
lol lcm(lol x, lol y){ return ((x * y) / gcd(max(x, y), min(x, y))); }

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  lol n, k;
  cin >> n >> k;
  lol a[n + 5];
  rep(i, n){
    cin >> a[i];
  }
  lol high = 1e9, low = 0;
  while(high - low  > 1){
    lol mid = (high + low) / 2, sum = 0;
    rep(i, n){
      sum += (a[i] - 1) / mid;
    }
    //cout << mid << " " << sum << '\n';
    if(sum <= k){
      high = mid;
    } else {
      low = mid;
    }
  }
  cout << high << '\n';
  return 0;
}


Measured memory_bytes: 5148
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    A, B = map(int, readline().split())
    if A <= 5:
        print(0)
    elif A <= 12:
        print(B//2)
    else:
        print(B)
    
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**7)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
PI = math.pi
# endregion
X, t = ri_()
print(max(0, X - t))

Measured memory_bytes: 63084