akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.IO;

namespace AtCoder
{
    struct Point
    {
        public readonly int t;
        public readonly int x;
        public readonly int y;
        public Point(int[] values)
        {
            t = values[0];
            x = values[1];
            y = values[2];
        }
    }

    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        private static bool Solve(Point[] points)
        {
            int x = 0;
            int y = 0;
            int t = 0;
            foreach (var p in points)
            {
                int d = Math.Abs(p.x - x) + Math.Abs(p.y - y);
                if (d > (p.t - t) || (p.t - t - d) % 2 != 0) { return false; }
                x = p.x;
                y = p.y;
                t = p.t;
            }
            return true;
        }

        static void Main(string[] args)
        {
            int N = ReadInt();
            var points = new Point[N];
            for (int i = 0; i < N; ++i)
            {
                var values = ReadInts();
                points[i] = new Point(values);
            }
            Console.WriteLine(Solve(points) ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 18244
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std ;
#define endl '\n' 

bool prime(int n)
{
	for(int i = 2  ; i*i <= n ; i++){ 
		if(n % i == 0) return 0 ;
	}
	return 1 ;
}

int main() {
	int T ,n ,count = 0;
	scanf("%d" ,&T) ;
	
	while(T--){
		scanf("%d" ,&n) ;
		count += prime(n) ;
	}
	
	printf("%d\n" ,count) ;
	return 0 ;
}



Measured memory_bytes: 3200
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bitset>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef long long LL;

typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const LL MOD = 1e9+7; 
//vector <vector<int>> x(20, vector<int> (20)), y(20,vector<int> (20));
/*int counter_1 (int x) {
    if(x == 0) return 0;
    return counter_1(x >> 1) + (x & 1);
}*/

//int Counter(int x)
int main(){
   char c;
   cin >> c;
   c += 1;
   cout << c << endl;
}

    



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll N; cin >> N;
    ll memo[N+10];
    memset(memo, 0, sizeof(memo));
    for(ll i=1; i<=100; ++i){
        for(ll j=1; j<=100; ++j){
            for(ll k=1; k<=100; ++k){
                ll n = i*i + j*j + k*k + i*j + j*k +k*i;
                if(n<=N){memo[n]++;}
            }
        }
    }
    
    for(ll i=1; i<=N; ++i){cout << memo[i] << endl;}
    return 0;
}

Measured memory_bytes: 3668
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int N,a,b; cin>>N;
	int nin_score = inf, place;
	rep(i,N){
		cin>>a>>b;
		if(b < nin_score){
			nin_score = b;
			place = a;
		}
	}
	cout<<place + nin_score<<endl;
	return 0;
}


Measured memory_bytes: 3584
#pragma GCC optimize("O3")
//#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;
#define re return
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all(x)),x.resize(unique(all(x))-x.begin())
#define fi first
#define se second
#define ss second.second
#define sf second.first
#define ff first.first
#define fs first.second
#define sqrt(x) sqrt(abs(x))
#define mp make_pair
#define PI 3.14159265358979323846
#define E 2.71828182845904523536
#define er erase
#define in insert
#define fo(i,n) for((i)=0;(i)<(n);(i)++)
#define ro(i,n) for((i)=n-1;(i)>=0;(i)--)
#define fr(i,j,n) for((i)=(j);(i)<(n);(i)++)
#define rf(i,j,n) for((i)=((n)-1);(i)>=(j);(i)--)
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
    const int N=(int)1e6+100;
    const int M=(int)2e6+100;
    const int inf=(int)1e9+100;
#define filename ""

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //freopen(filename".in","r",stdin);
    //freopen(filename".out","w",stdout);
    //freopen("ans.txt","w",stdout);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    srand(time(0));
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll n,m,i,a;
    ll s=0;
    cin>>n>>m;
    fo(i,m)
    {
        cin>>a;
        n-=a;
    }
    n=max(n,-1ll);
    cout<<n;
}


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

#define rep(i,n) for(int i=0; i<(N); i++)

using namespace std;
namespace geom{
#define at(i) ((*this)[i])
#define pb push_back
#define X real()
#define Y imag()
#define SELF (*this)
typedef long double R;
typedef complex<R> P;
const R EPS = 1e-8;
const R PI=3.14159265358979323846264338327950288;
enum { TURE = 1, FALSE = 0, BORDER= -1};
inline int sig(const R&x){return (abs(x)<EPS?0:x>0?1:-1);}
inline int less(const R &x,const R &y){return sig(x-y)?x<y:BORDER;}
inline R inp(const P &a,const P &b){return (conj(a)*b).X;}
inline R outp(const P &a,const P & b){return (conj(a)*b).Y;}
inline R norm(const P &p){return p.X*p.X+p.Y*p.Y;}
inline P unit(const P & p){return p/abs(p);}
inline P proj(const P &s,const P &t){return t*inp(s,t)/norm(t);}
struct L :public vector<P>{
  L(const P &p1,const P &p2){this->pb(p1);this->pb(p2);}
  L(){}
  P dir()const {return at(1)-at(0);}
  int online(const P &p) const {return !sig(outp(p-at(0),dir()));}
};
struct S: public L {
    S(const P &p1, const P &p2): L(p1,p2){}
    S(){}
    int online(const P &p) const{
        if(!sig(norm( p-at(0) )) || !sig(norm(p - at(1))) ) return BORDER;
        return !sig(outp(p-at(0), dir())) && inp(p-at(0), dir()) > EPS && inp(p-at(1),-dir()) > -EPS;
    }
};
struct C :public P{
  C(){}
  C(const P &p,const R r):P(p),r(r){}
  R r;
  int inside(const P &p)const { return less(norm(p-SELF),r*r);}
};
//inline P proj(const P &s,const L &t){return t[0] + proj(s-t[0], t[1]-t[0]);}

inline int intersect (const C &a,const C &b){
  return less((a.r-b.r)*(a.r-b.r),norm(a-b))+less(norm(a-b),(a.r+b.r)*(a.r+b.r))-1;
}

inline S crosspoint(const C &c1,const C &c2){
  if(!intersect(c1,c2)) return S();
  R d=abs(c1-c2);
  R x=(c1.r*c1.r-c2.r*c2.r+d*d)/(2*d);
  R h=sqrt(max<R>(0.,c1.r*c1.r-x*x));
  P u=unit(c2-c1);
  return S(c1+u*x+u*P(0,-1)*h,c1+u*x+u*P(0,1)*h);
}

// inline S crosspoint(const C &c,const L &l){
//   R d2=dist2(l,c);
//   if(c.r*c.r+EPS < d2) return S();
//   P m= proj(c,l);
//   P u = unit(l[1]-l[0]);
//   R d=sqrt(max<R>(.0,c.r*c.r-d2));
//   return S(m+u*d,m-u*d);
// }

S circlePPR(const P& a, const P& b, R r){
    return crosspoint( C(a,r), C(b,r) );
}
}
using namespace geom;

int main(){
    int N;
    while(cin>>N, N){
        int ans = 1;
        P po[305];
        rep(i,N){
            R x, y;
            cin >> x >> y;
            po[i] = P(x, y);
        }
        rep(i,N) rep(j,i){
            //if( i==j ) continue;
            S s = circlePPR( po[i], po[j], 1.0 );
            //if( s.empty() ) continue;
            //for(auto t: s) cout << t << " "; cout << endl;
            for(auto k: s){
                int count = 0;
                rep(h,N){
                    if( abs(k-po[h]) < 1.0 + EPS ){
                        count++;
                    }
                }
                ans = max(ans, count);
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3148
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

require 'prime'

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end

n = inp[0]
a = inp
arr = na(8,0)
c = 0
a.each do |d|
  arr[d / 400] += 1 if d < 3200
  c += 1 if d >= 3200
end
syu = arr.count{|u|0<u}
if (syu == 0)
  syu = 1
  c -= 1
end
puts "#{syu} #{syu+c}"


Measured memory_bytes: 2300
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<set>
using namespace std;

int main(void){
    int A, B, C, X, Y;
    cin>>A>>B>>C>>X>>Y;
    int ans=A*X+B*Y;
    for(int k=1;k<=max(X,Y);k++){
        ans=min(ans,2*C*k+max(0,X-k)*A+max(0,Y-k)*B);
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INFTY 10000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const int MOD=1000000007;
const int di[4] = {-1,0,1,0};
const int dj[4] = {0,-1,0,1};
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
int main(){
    int k;string s;
    cin>>k>>s;
    int sz = s.length();
    if(sz<=k){
        cout<<s<<endl;
        return 0;
    }
    else{
        rep(i,k)cout<<s[i];
    }
    cout<<"..."<<endl;

    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#define rep(i,n) for(int i = 0; i<(n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){

    vector<vector<int> > a(3, vector<int>(3));
    rep(i,3){
        rep(j,3){
            cin >> a[i][j];
        }
    }

    int n; cin >> n;

    vector<int>b(n);
    rep(i,n) cin >> b[i];

    vector<vector<bool> > rsl(3, vector<bool>(3,0));

    rep(i,3){
        rep(j,3){
            rep(k,n){
                if(a[i][j]==b[k]) rsl[i][j]=1;
            }
        }
    }

    if(rsl[0][0]==1 && rsl[0][1]==1 && rsl[0][2]==1){
         cout << "Yes" << endl; return 0;
    }
    if(rsl[0][0]==1 && rsl[1][1]==1 && rsl[2][2]==1) {
         cout << "Yes" << endl; return 0;
    }
    if(rsl[0][1]==1 && rsl[1][1]==1 && rsl[2][1]==1) {
         cout << "Yes" << endl; return 0;
    }
    if(rsl[0][2]==1 && rsl[1][2]==1 && rsl[2][2]==1){
         cout << "Yes" << endl; return 0;
    }
    if(rsl[1][0]==1 && rsl[1][1]==1 && rsl[1][2]==1){
         cout << "Yes" << endl; return 0;
    }
    if(rsl[2][0]==1 && rsl[2][1]==1 && rsl[2][2]==1){
         cout << "Yes" << endl; return 0;
    }
    if(rsl[2][0]==1 && rsl[1][1]==1 && rsl[0][2]==1) {
         cout << "Yes" << endl; return 0;
    }
    if(rsl[0][0]==1 && rsl[1][0]==1 && rsl[2][0]==1) {
         cout << "Yes" << endl; return 0;
    }

    cout << "No" << endl;


    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a),i##_end=(b);i<=i##_end;i++)
#define per(i,b,a) for(int i=(b),i##_st=(a);i>=i##_st;i--)
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define Es(x,i) for(Edge *i=G[x];i;i=i->nex)
typedef pair<int,int> pii;
typedef long long ll;
const int inf=~0u>>1,MOD=1e9+7;
char *TT,*mo,but[(1<<15)+2];
#ifdef ONLINE_JUDGE
    #define getchar() ((TT==mo&&(mo=((TT=but)+fread(but,1,1<<15,stdin)),TT==mo))?-1:*TT++)
#endif
inline int rd() {
    int x=0,c=0,f=1;
    for(; c<'0'||c>'9'; c=getchar())f=c!='-';
    for(; c>='0'&&c<='9'; c=getchar())x=x*10+c-'0';
    return f?x:-x;
}
const int N=1000011;
int n,m,ak;
ll now;
ll a[N],b[N];
int c[N],d[N];
void tag(int l,int r,int k){
    c[l]++,d[r]--;
    a[l]+=k,b[r]-=k+r-l;
}
int calc(int l,int r){
    if(r>=l)return r-l;
    else return m-l+r;
}
ll mx;
int pos;
int f[N];
ll inte(int pos){
    int e=f[1];
    ll ans=0;
    rep(i,2,n){
        int x=f[i];
        ans+=min(calc(e,x),1+calc(pos,x));
        e=x;
    }
    return ans;
}
int main(){
    n=rd(),m=rd();
    rep(i,1,n)f[i]=rd();
    int e=f[1];
    rep(i,2,n){
        int x=f[i];
        e++;
        //if(x==e)continue;
        if(x>=e){
            tag(e,x,1);
        }else{
            tag(e,m,1);
            tag(1,x,m-e+1);
        }
        e=x;
    }
    rep(i,1,m){
        now+=ak;
        ak+=c[i];
        now+=a[i];
        if(now>mx){
            mx=now,pos=i;
        }
        ak+=d[i];
        now+=b[i];
    }
    ll ans=inte(pos);
    //if(pos-1>0)ans=min(ans,inte(pos-1));
    //if(pos-2>0)ans=min(ans,inte(pos-2));
    rep(i,1,10){
    	if(pos-i>0)ans=min(ans,inte(pos-i));
    	if(pos+i<=m)ans=min(ans,inte(pos+i));
	}
    //if(pos+1<=m)ans=min(ans,inte(pos+1));
    //if(pos+2<=m)ans=min(ans,inte(pos+2));
    cout<<ans<<endl;
}

Measured memory_bytes: 14976
#include<bits/stdc++.h>
#define rep(i,a) for(int (i)=0; (i)<(a); (i)++)
#define rrep(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define rep2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define int long long
typedef long long ll;

using namespace std;
signed main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n; cin>>n;
  vector<vector<int>> G(n);
  vector<pair<int,int>> edge;
  rep2(i,1,n){
    int a,b; cin>>a>>b;
    a--;b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
    edge.emplace_back(a,b);
  }

  int K=0;
  map<pair<int,int>,int> I; //(edge, color)
  vector<int> cs(n,0); // color of edge between its parent

  vector<int> used(n,0);
  queue<int> que;
  used[0]=1; //color of the root
  que.emplace(0);
  while(!que.empty()){
    int v=que.front(); que.pop();
    if(K < (int)G[v].size()) K=G[v].size();
    int cur=1;
    for(int u:G[v]){
      if(used[u]) continue;
      if(cur==cs[v]) cur++;
      cs[u]=I[make_pair(u,v)]=I[make_pair(v,u)]=cur++;
      used[u]=1;
      que.emplace(u);
    }
  }

  cout << K << endl;
  for(auto p:edge) cout << I[p] << endl;
  return 0;
}


Measured memory_bytes: 22256
#include <bits/stdc++.h>
using namespace std;
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
typedef long long ll;
typedef long double ld;
int bestd = -1, root, diam;
vector<int> E[200005];
void go(int x, int p = -1, int d = 0) {
	if (d > bestd) {
		bestd = d;
		root = x;
	}
	diam = max(diam, d);
	for (int y : E[x]) {
		if (y == p) continue;
		go(y, x, d + 1);
	}
}
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 1; i < n; ++i) {
		int a, b;
		scanf("%d%d", &a, &b);
		E[a].push_back(b);
		E[b].push_back(a);
	}
	go(1);
	go(root);
	printf(diam % 3 == 1 ? "Second\n" : "First\n");
}


Measured memory_bytes: 20608
/*
数据不清空，爆零两行泪。
多测不读完，爆零两行泪。
边界不特判，爆零两行泪。
贪心不证明，爆零两行泪。
D P 顺序错，爆零两行泪。
大小少等号，爆零两行泪。
变量不统一，爆零两行泪。
越界不判断，爆零两行泪。
调试不注释，爆零两行泪。
溢出不 l l，爆零两行泪。
*/
#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;
const int N=3000,M=3000;
int n,m;
int a[N+1];
int dp[M+1];
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++)cin>>a[i];
	int ans=0;
	for(int i=1;i<=n;i++){
		if(m==a[i])(ans+=1ll*i*(n-i+1)%mod)%=mod;
		else if(m>a[i])(ans+=1ll*dp[m-a[i]]*(n-i+1)%mod)%=mod;
		for(int j=m;j>=a[i];j--)(dp[j]+=dp[j-a[i]]+(j==a[i]?i:0))%=mod;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
p = lambda x,y:x+y
m = lambda x,y:x-y
t = lambda x,y:x*y
d = lambda x,y:x//y
operations = {'+':p, '-':m, '*':t, '/':d}

while True:
	a,op,b = input().split(' ')
	if op == '?':
		break
	else:
		a,b = int(a),int(b)
		print(operations[op](a,b))

Measured memory_bytes: 7752
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;

int n,k,m,r;
int num[10021],sum[10021];
int kum[10021],nkum[10021];

int main(void){
	while(1){
		scanf("%d%d%d%d",&n,&k,&m,&r);
		if(n==0 && k==0 && m==0 && r==0)break;
		memset(num,0,sizeof(num));
		memset(sum,0,sizeof(sum));
		memset(kum,0,sizeof(kum));
		if(m==0){
			int k=1;
			for(int i=0;i<=r;i++){
				num[i]=k/n;
				k%=n;
				k=k*10;
			}
			printf("%d.",num[0]);
			for(int i=1;i<=r;i++)printf("%d",num[i]);
			printf("\n");
		}
		if(m==1){
			int k=1;
			for(int i=0;i<=10020;i++){
				sum[i]=k/n;
				k%=n;
				k=k*10;
			}
			for(int i=1;i<=n-1;i++){
				int k=1;
				memset(nkum,0,sizeof(nkum));
				for(int j=0;j<=10020;j++){
					nkum[j]=k/(i*n);
					k%=(i*n);
					k=k*10;
				}
				int up=0,nup=0;
				for(int i=10020;i>=0;i--){
					nup=(kum[i]+nkum[i]+up)/10;
					kum[i]=(kum[i]+nkum[i]+up)%10;
					up=nup;
				}
			}
			int up=0,nup=0;
			for(int i=10020;i>=0;i--){
				nup=(sum[i]+kum[i]+up)/10;
				sum[i]=(sum[i]+kum[i]+up)%10;
				up=nup;
			}
			printf("%d.",sum[0]);
			for(int i=1;i<=r;i++)printf("%d",sum[i]);
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 1356
n = int(input())

if n%10 ==2 or n%10 ==4 or n%10 ==5 or n%10 ==7 or n%10 ==9:
  print("hon")
elif n%10 ==0 or n%10 ==1 or n%10 ==6 or n%10 ==8:
  print("pon")
else:
  print("bon")

Measured memory_bytes: 9044
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
const int INF=0x3f3f3f3f;
const int N=300;
int x,y,z;
int f[301][301][301],ans;
int main() {
    scanf("%d%d%d",&x,&y,&z);
    memset(f,0x3f,sizeof(f));
    f[x][y][z]=0;
    ans=INF;
    for (int i=x;i<=N;i++)
	for (int j=y;j<=N;j++)
	    for (int k=z;k<=N;k++) {
		if (i>=2) f[i][j][k]=min(f[i][j][k],f[i-2][j][k]+1);
		if (j>=2) f[i][j][k]=min(f[i][j][k],f[i][j-2][k]+1);
		if (k>=2) f[i][j][k]=min(f[i][j][k],f[i][j][k-2]+1);
		if (j&&k) f[i][j][k]=min(f[i][j][k],f[i][j-1][k-1]+1);
		if (i&&k) f[i][j][k]=min(f[i][j][k],f[i-1][j][k-1]+1);
		if (i&&j) f[i][j][k]=min(f[i][j][k],f[i-1][j-1][k]+1);
		if (i==j&&i==k) ans=min(ans,f[i][j][k]);
	    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 106752
#include <cstdio>
#include <algorithm>

using namespace std;

int main(){
    char s[100001];
    scanf("%s", s);
    int count_0 = 0;
    int count_1 = 0;
    for(int i = 0; s[i] != '\0'; i++){
        if(s[i] == '0'){
            count_0++;
        }else{
            count_1++;
        }
    }
    int ans = min(count_0, count_1) * 2;
    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
using ll = long long int;
int main() {
  string s;
  cin>>s;
  int cnt=0;
  for (int i=0;i<3;i++) {
	if (s.at(i)=='o') cnt++;
  }
  cout <<700+cnt*100;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int testnum = 0;
		while(true) {
			testnum++;
			int n = sc.nextInt();
			if (n == 0) {
				break;
			}
			Vector2[] r = new Vector2[n];
			for(int i=0;i<n;i++) {
				r[i] = new Vector2(sc.nextInt(), sc.nextInt());
			}
			double sum = 0;
			for(int i=0;i<n;i++) {
				Vector2 r1 = r[i];
				Vector2 r2 = r[(i+1)%n];
				sum += r1.cross(r2) / 2;
			}
			System.out.println(testnum + " " + Math.abs(sum));
		}
	}

}
class Vector2 {
	public double x;
	public double y;
	public Vector2(double x,double y) {
		this.x = x;
		this.y = y;
	}
	public double dot(Vector2 v) {
		return this.x*v.x+this.y*v.y;
	}
	public double cross(Vector2 v) {
		return this.x*v.y-this.y*v.x;
	}
	public double norm() {
		return Math.sqrt(this.x*this.x+this.y*this.y);
	}
	public Vector2 normalize() {
		return divide(norm());
	}
	public Vector2 add(Vector2 v) {
		return new Vector2(x+v.x,y+v.y);
	}
	public Vector2 subtract(Vector2 v) {
		return new Vector2(x-v.x,y-v.y);
	}
	public Vector2 multiply(double k) {
		return new Vector2(x*k,y*k);
	}
	public Vector2 divide(double k) {
		return new Vector2(x/k,y/k);
	}
	public String toString() {
		return "(" + this.x + "," + this.y + ")";
	}
}

Measured memory_bytes: 20984
number=int(input())
book=[]
for n in range(number):
    book.append(input().split())

for i in range(len(book)):
    book[i].append(i+1)
    book[i][1]=int(book[i][1])

book1=sorted(book,key=lambda k:-k[1])
book2=sorted(book1,key=lambda k:k[0])

for i in range(len(book2)):
    print(book2[i][2])

Measured memory_bytes: 3064
from networkx import*
H,*S=open(0)
H,W=map(int,H.split())
g=Graph()
a=g.add_edges_from
for i in range(m:=H*W):a([[m*2,h:=i//W],[m*2,w:=i%W+m]]*((c:=S[h][w-m])=='S')+[[h,I:=m*3],[w,I]]*(c=='T'),capacity=I),a([[h,w],[w,h]]*(c>'T'),capacity=1)
print([-1,f:=minimum_cut(g,m*2,I)[0]][f<I])

Measured memory_bytes: 63852
#include <stdio.h>

main() {
  int i, j, H, W;
  
  while(1){
    
    scanf("%d %d", &H, &W);
    
    if (H == 0 && W == 0) break; 
    for (i = 0; i < H; i++) {
      for (j = 0; j < W; j++) {
	  if (j == 0 || j == W-1 || i == 0 || i == H-1) {
	    printf("#");
	  } else {
	    printf(".");
	  }
	}
	printf("\n");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 572
// @author: Arthur Sun

#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <iomanip>

using namespace std;

using ll = long long;

#define all(x) begin(x), end(x)
#define fillc(p, t, v) fill_n((t*) p, sizeof(p) / sizeof(t), v)
#define pb push_back
#define inc(a, b, c) for(auto a(b); a <= (c); a++)
#define dec(a, b, c) for(auto a(b); a >= (c); a--)

#define MAX_N 3004

int N;
double P[MAX_N];

double cache[MAX_N][MAX_N];

double dp(int i, int heads) {
    if(i == N) {
        return heads > N - heads;
    }
    auto& ans = cache[i][heads];
    if(ans >= -0.5) return ans;
    ans = P[i] * dp(i + 1, heads + 1) + (1.0 - P[i]) * dp(i + 1, heads);
    return ans;
}

int main() {
    srand(time(nullptr));
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> N;
    inc(i, 0, N - 1) cin >> P[i];
    fillc(cache, double, -1.0);
    cout << fixed << setprecision(15);
    cout << dp(0, 0) << '\n';
    return 0;
}



Measured memory_bytes: 74560
#include<stdio.h>

int main(void)
{
	int N, i=0;

	scanf("%d", &N);
	if ((N % 1000 - N % 100) / 100 == 7) {
		i = 1;
	}
	else if ((N % 100 - N % 10) / 10 == 7) {
		i = 1;
	}
	else if (N % 10 == 7) {
		i = 1;
	}
	if (i == 0) {
		printf("No");
	}
	else {
		printf("Yes");
	}
	return 0;
}


Measured memory_bytes: 2152
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rfor(i,a,b) for(ll (i) = (a); (i) > (b); --(i))
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;
#define all(x) (x).begin(),(x).end()

ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    for (ll d = 1; d <= k; ++d) {
        r *= n--;
        r /= d;
    }
    return r;
}

int main()
{
    ll n,k,count = 0,ans = 0,a;
    vector<ll> cnt(200000,0);
    cin >> n >> k;
    rep0(i, n){
        cin >> a;
        if(cnt[a] == 0)++count;
        ++cnt[a];
    }
    sort(all(cnt));
    rep0(i, 200000){
        if(count <= k){
            cout << ans << endl;
            break;
        }else{
            if(cnt[i] > 0){
                ans += cnt[i];
                --count;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_solve
{
    class Program
    {
        public const ulong mod = 1000000007;

        static void Main(string[] args)
        {
            var abhm = Input3();
            var a = abhm[0];
            var b = abhm[1];
            var h = abhm[2];
            var m = abhm[3];
            double ans = 0;
            double w1 = ((h / 12.0) + (m / 720.0))*2*Math.PI;
            double w2 = (m / 60.0)*2*Math.PI;
            double dw = 0;
            if (Math.Abs(w1 - w2) <= Math.PI) dw = Math.Abs(w1 - w2);
            else dw = Math.Min(w1, w2) + 2 * Math.PI - Math.Max(w1, w2);
            ans = Math.Sqrt(a * a + b * b - 2*a * b * Math.Cos(dw));
            Console.WriteLine(ans);






        }

        static public long Input()
        {
            return long.Parse(Console.ReadLine());
        }

        static public string[] Input2()
        {
            return Console.ReadLine().Split();
        }
        
        static public long[] Input3()
        {
            string[] data = Console.ReadLine().Split();
            long[] res = new long[data.LongLength];
            for(long i = 0; i < data.LongLength; i++)
            {
                res[i] = long.Parse(data[i]);
            }
            return res;
        }
        public static long Choose(long n, long a)
        {
            long x = 1;
            long y = 1;
            for (long i = 0; i < a; i++)
            {
                x *= n - i;
                y *= i + 1;
            }
            return x / y;
        }

        public static long Gcd(long a, long b)
        {
            long x = Math.Max(a, b);
            long y = Math.Min(a, b);
            if (x % y == 0) return y;
            else return Gcd(y, x % y);
        }
    }
}


Measured memory_bytes: 27936
#include <iostream>
#include <utility>

typedef long long ll;
const ll MOD = 1e9+7;

ll fast_exp(ll b, ll e) {
  ll res = 1;
  while (e) {
    if (e & 1)  res = (res * b) % MOD;
    b = (b * b) % MOD;
    e >>= 1;
  }
  return res % MOD;
}

ll modinv(ll a) {
    return fast_exp(a, MOD-2);
}

ll fac[1000005];
ll inv[1000005];

int main() {
  fac[0] = fac[1] = inv[0] = inv[1] = 1;
  for (int i = 2; i <= 2005; ++i) {
    fac[i] = (fac[i-1] * i) % MOD;
    inv[i] = (inv[i-1] * modinv(i)) % MOD;
  }

  ll S; std::cin >> S;
  ll ans = 0;
  for (ll x = 1; S - 3*x >= 0; ++x) {
    ll y = fac[S - 2*x -1] * inv[x-1] % MOD;
    y *= inv[S-3*x];
    ans = (ans + y) % MOD;
  }
  std::cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 3660
import Enum

defmodule Main do
  def dont_be_late(seq) do
    min_to_arrive = Enum.at(seq, 0) / Enum.at(seq, 2)
    cond do
      min_to_arrive <= Enum.at(seq,1) -> "Yes"
      true -> "No"
    end
  end

 def main do
    seq = IO.read(:line) |> String.trim() |> String.split(" ") |>  map(&String.to_integer/1)
    IO.puts dont_be_late(seq)
 end
end

Measured memory_bytes: 30704
#include <algorithm>
#include <functional>
#include <iostream>
#include <string>
using namespace std;

int main() {
  string s;
  cin >> s ;
  sort(s.begin(),s.end());

  string t;
  cin >> t;
  sort(t.begin(),t.end());

  reverse(t.begin(),t.end());
  if (s < t) cout << "Yes" << endl;
	else cout << "No" << endl;


  return 0;
}

Measured memory_bytes: 256
#include<math.h>
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define    ll   long long int
#define    py   printf("Yes\n")
#define    pn   printf("No\n")
#define    in   cin>>
using namespace std;
int main()
{
    int n,m,h[100000],ma[100000];
    in n>>m;
    for (int i = 1; i <=n; i++)
    {
        in h[i];
        ma[i]=0;
    }
    for (int i = 0; i < m; i++)
    {
        int a,b;
        in a>>b;
        ma[a]=max(ma[a],h[b]);
        ma[b]=max(ma[b],h[a]);
    }
    int ans=0;
    for (int i = 1; i <= n; i++)
    {
        ans+=h[i]>ma[i];
    }
    cout<<ans<<endl;
}


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 30;

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
  cout << "{";
  for (int i = 0; i < vec.size(); i++)
    os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  cout << "}";
  return os;
}

// ===============================================================================

int main() {
  ll n;
  cin >> n;
  vector<ll> v;
  int a, bef = -1;
  for (int i = 0; i < n; i++) {
    cin >> a;
    if (a != bef) v.push_back(a);
    bef = a;
  }

  n = v.size();
  vector<ll> dp(n + 1);
  dp[0] = 1;
  map<ll, ll> sowa;
  for (int i = 1; i <= n; i++) {
    // cout << dp << endl;
    dp[i] = (dp[i - 1] + sowa[v[i - 1]]) % MOD;
    sowa[v[i - 1]] = (sowa[v[i - 1]] + dp[i - 1]) % MOD;
  }
  // cout << dp << endl;
  cout << dp[n] << endl;
}


Measured memory_bytes: 15856
from collections import deque
k=int(input())
cnt=0
ans=0
q=deque()
q.extend([1,2,3,4,5,6,7,8,9])

while(cnt<k):
    ans=q.popleft()
    cnt+=1
#    print(ans,cnt)
    one_digit=ans%10
    if(one_digit==0):
        q.append(int(str(ans) + '0'))
        q.append(int(str(ans) + '1'))
    elif(one_digit==9):
        q.append(int(str(ans) + '8'))
        q.append(int(str(ans) + '9'))
    else:
        q.append(int(str(ans) + str(one_digit-1)))
        q.append(int(str(ans) + str(one_digit)))
        q.append(int(str(ans) + str(one_digit+1)))
print(ans)


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

using namespace std;

#define ll  long long
#define ld  double

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

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 2e5 + 5;

typedef pair<int,int>   ii;

int cnt1[N];
int cnt2[N];

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

    string S;   cin >> S;
    string T;   cin >> T;

    for(int i = 1 ; i <= sz(S) ; ++i)   cnt1[i] = cnt1[i - 1] + (S[i - 1] == 'B');
    for(int i = 1 ; i <= sz(T) ; ++i)   cnt2[i] = cnt2[i - 1] + (T[i - 1] == 'B');

    int q;  cin >> q;

    while (q--) {
        int l1, r1; cin >> l1 >> r1;
        int l2, r2; cin >> l2 >> r2;

        int cnt1B = cnt1[r1] - cnt1[l1 - 1];
        int cnt2B = cnt2[r2] - cnt2[l2 - 1];

        int cnt1A = r1 - l1 + 1 - cnt1B;
        int cnt2A = r2 - l2 + 1 - cnt2B;

        int R1 = (cnt1A - cnt1B + 1000002) % 3;
        int R2 = (cnt2A - cnt2B + 1000002) % 3;

        if (R1 == R2)   cout << "YES\n";
        else            cout << "NO\n";
    }
}


Measured memory_bytes: 1744
def bfs(v):
  distance=[-1]*n
  distance[v]=0
  next=connection[v]
  next2=set()
  visited=[-1]*n
  visited[v]=1
  visitct=1
  ct=0
  while len(next)!=0 and visitct!=n:
    ct+=1
    for i in range(len(next)):
      if visited[next[i]]==-1:
        distance[next[i]]=ct
        visited[next[i]]=1
        visitct+=1
        for j in range(len(connection[next[i]])):
          if visited[connection[next[i]][j]]==-1:
            next2.add(connection[next[i]][j])
    next=list(next2)
    next2=set()
    
  return distance

n=int(input())
l=[list(map(int,input().split())) for i in range(n-1)]
connection=[[] for i in range(n)]
for i in range(n-1):
  connection[l[i][0]-1].append(l[i][1]-1)
  connection[l[i][1]-1].append(l[i][0]-1)

if max(bfs(bfs(0).index(max(bfs(0)))))%3==1:
  print('Second')
else:
  print('First')

Measured memory_bytes: 137076
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma,tune=native")
//#pragma GCC optimize("unroll-loops")

#ifdef __APPLE__
    # include <iostream>
    # include <cmath>
    # include <algorithm>
    # include <stdio.h>
    # include <cstdint>
    # include <cstring>
    # include <string>
    # include <cstdlib>
    # include <vector>
    # include <bitset>
    # include <map>
    # include <queue>
    # include <ctime>
    # include <stack>
    # include <set>
    # include <list>
    # include <random>
    # include <deque>
    # include <functional>
    # include <iomanip>
    # include <sstream>
    # include <fstream>
    # include <complex>
    # include <numeric>
    # include <immintrin.h>
    # include <cassert>
    # include <array>
    # include <tuple>
    # include <unordered_map>
    # include <unordered_set>
    # include <thread>
#else
    #include <bits/stdc++.h>
#endif
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define files(name) name!=""?freopen(name".in","r",stdin),freopen(name".out","w",stdout):0
#define all(a) a.begin(),a.end()
#define len(a) (int)(a.size())
#define elif else if
#define mp make_pair
#define pb push_back
#define fir first
#define sec second
 
using namespace std;
#define int long long
 
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long double ld;
typedef long long ll;
 
const int arr=2e5+10;
const int ar=2e3+10;
const ld pi=acos(-1);
const ld eps=1e-10;
const ll md=1e9+7;
const ll inf=1e18+10;
 
///---program start---///

signed main()
{
    #ifdef __APPLE__
        files("barik");
        freopen("debug.txt","w",stderr);
    #endif

    string s;
    cin>>s;
    if (len(s)%2==1){
        cout<<"No"<<"\n";
        return 0;
    }
    for (int i=0;i<len(s);i++){
        if (s[i]!="hi"[i%2]){
            cout<<"No"<<"\n";
            return 0;
        }
    }
    cout<<"Yes"<<"\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
 
using namespace std;
 
int main()
{
	int n;
	while (cin >> n, n != 0) {
		int c[201];
		memset(c, 0, sizeof(c));
 
		vector<int> t, h;
 
		for (int i = 0; i < n; ++i) { int a; cin >> a; c[a] = 1; }
 
		for (int i = 1; i <= n*2; ++i) {
			if (c[i]) {
				t.push_back(i);
			} else {
				h.push_back(i);
			}
		}
 
		sort(t.rbegin(), t.rend());
		sort(h.rbegin(), h.rend());
 
		int f = 1;
		int card = 0;
 
		while (!t.empty() && !h.empty()) {
			if (f) {
				int idx = t.size();

				while (idx--) if (card < t[idx]) {
						card = t[idx];
						t.erase(t.begin() + idx);
						break;
				}

				if (idx == -1) card = 0;
			} else {
				int idx = h.size();

				while (idx--) if (card < h[idx]) {
						card = h[idx];
						h.erase(h.begin() + idx);
						break;
				}

				if (idx == -1) card = 0;
			}

			f = !f;
		}
 
		cout << h.size() << "\n" << t.size() << endl;
	}
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#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,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    int ans = (b + (a - 1)) / a;

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

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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

int main() {
  ll a, b, c, k;
  cin >> a >> b >> c >> k;

  ll ans = 0;
  ans += min(a, k);

  k -= a;
  k -= b;
  k = max(0LL, k);
  ans -= min(c, k);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>

using namespace std;

int n, x;
long long cnt;
int a[100005];

int main()
{
    scanf("%d%d", &n, &x);
    scanf("%d", &a[0]);
    for(int i = 1; i < n; i++)
    {
        scanf("%d", &a[i]);
        if(a[i - 1] > x)
        {
            cnt += a[i - 1] + a[i] - x;
            a[i] = 0;
            a[i - 1] = x;
        }
        else if(a[i - 1] + a[i] > x)
        {
            cnt += a[i - 1] + a[i] - x;
            a[i] = x - a[i - 1];
        }
    }
    printf("%lld", cnt);
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
const long double PI = (acos(-1));
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int ctoi(char c)
{
    switch (c)
    {
    case '0':
        return 0;
    case '1':
        return 1;
    case '2':
        return 2;
    case '3':
        return 3;
    case '4':
        return 4;
    case '5':
        return 5;
    case '6':
        return 6;
    case '7':
        return 7;
    case '8':
        return 8;
    case '9':
        return 9;
    default:
        return 0;
    }
}
int func(int x)
{
    if (x < 10)
    {
        return x;
    }
    return x % 10 + func(x / 10);
}

int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    int sum = 0;
    for (int i = 1; i <= n; i++)
    {
        if(func(i)>=a&&func(i)<=b){
            sum+=i;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
def warshall_floyd(n,w,d):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d
##############################
n,w = map(int,input().split()) 
#n:頂点数 w:辺の数 
d = [[float("inf") for i in range(n)] for i in range(n)]
edge = [[float("inf") for i in range(n)] for i in range(n)]
#d[u][v] : 辺uvのコスト(存在しないときはinf)
S = []
for i in range(w):
    x,y,z = map(int,input().split())
    if x > y:
        x, y = y, x
    x -= 1
    y -= 1
    d[x][y] = z
    d[y][x] = z 
    edge[x][y]=z
    edge[y][x]=z
    S.append(str(x)+","+str(y))
for i in range(n):
    d[i][i] = 0 #自身のところに行くコストは０
trash = warshall_floyd(n,w,d)
L=[]
for s in range(n):
    for t in range(n):
        for v in range(n):
            if d[s][t] + edge[t][v] == d[s][v] and t < v:
                L.append(str(t)+","+str(v))
ans = 0
for x in S:
        if x not in L:
            ans += 1
print(ans)

Measured memory_bytes: 47852
#include<iostream>
using namespace std;
int main() {

  int a, b;
  cin >> a >> b;
  
  if (a < b) {
    cout << "a < b" << endl;
  }
  else if (a > b) {
    cout << "a > b" << endl;

  }
  else {
    cout << "a == b" << endl;
  }

  return 0;
}


Measured memory_bytes: 3120
#include<bits/stdc++.h>
#define HohleFeuerwerke using namespace std
#define int long long
#define MAXN 100005
HohleFeuerwerke;
string s,t;
inline int read(){
	int s=0,f=1;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) s=s*10+c-'0';
	return s*f;
}
signed main()
{
	bool flag=true;
	ios::sync_with_stdio(false);
	cout.tie(0);cin.tie(0);
	cin>>s>>t;
	for(int i=0;i<t.size()-1;i++)
		if(s[i]!=t[i]) flag=false;
	if(flag) printf("Yes\n");else printf("No\n");
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define mod 998244353

using namespace std;
typedef long long ll;

ll n, a, b, k;
ll ncr[300050];
ll gcd(ll a, ll b, ll &x, ll &y){
	if(a % b == 0){
		x = 0, y = 1;
		return b;
	}
	ll x1, y1;
	ll ans = gcd(b, a%b, x1, y1);
	x = y1;
	y = x1-y1*(a/b);
	return ans;
}
ll inv(ll a){
	ll x, y; 
	if(gcd(a,mod,x,y) == 1) return (x+mod)%mod;
	else return -1;
}

int main(){
	//freopen("rgbcoloring.in", "r", stdin);
	cin >> n >> a >> b >> k;
	// jb == k - ia
	ncr[0] = 1;
	for(ll i = 1; i<=n; i++){
		ncr[i] = ncr[i-1];
		ncr[i] *= (n-(i-1));
		ncr[i] %= mod;
		ncr[i] *= inv(i);
		ncr[i] %= mod;
	}
	ll ans = 0;
	// ia + jb = k
	for(ll i = max((k-n*b)/a, (ll)0); i<=n and k>=i*a; i++){
		if((k-i*a) % b == 0){	
			ans += (ncr[i]*ncr[(k-i*a)/b])%mod;
			ans %= mod;
		}
	}
	cout << ans;
}


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

vector<ll> to[100010];

int main(){
    ll n,m;cin>>n>>m;
    rep(i,0,m){
        ll a,b;cin>>a>>b;
        a--;b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    vector<ll> sign(n,-1);
    queue<ll> q;
    sign[0]=0;
    q.push(0);
    while(!q.empty()){
        ll now=q.front();
        q.pop();
        for(ll nx:to[now]){
            if(sign[nx]!=-1)continue;
            sign[nx]=now+1;
            q.push(nx);
        }
    }
    rep(i,0,n){
        if(sign[i]==-1){cout<<"No"<<endl;return 0;}
    }
    cout<<"Yes"<<endl;
    rep(i,1,n){
        cout<<sign[i]<<endl;
    }
}

    









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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N; cin >> N;
  vector<ll> a(N);
  for (ll i = 0; i < N; i++) cin >> a.at(i);
  sort(a.begin(), a.end(), greater<ll>());
  ll A = 0; ll B = 0;
  for (ll i = 0; i < N; i++) {
    if (i % 2 == 0) A += a.at(i);
    else B += a.at(i);
  }
  cout << A - B << endl;

  return 0;
}



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

using namespace std;
using namespace __gnu_pbds; 
  
#define ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
	enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int mod = (int)1e9 + 7;
const int MX = (int)1e5 + 10;

void add_self(int &x, int y){x += y; if(x >= mod) x -= mod;}
void sub_self(int &x, int y){x -= y; if(x < 0) x += mod;}
void mul(int &x, int y){x = x * 1LL * y % mod;}

int main(){

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

	string s;
	cin >> s;
	int n = s.size();

	ll res = 0;
	map<pair<int, int>, int> mp;
	int prf3 = 0;
	int prf673 = 0;
	mp[{0, 0}] = 1;
	int pw3 = 1;
	int pw673 = 1;
	for(int i = n - 1; i >= 0; --i){
		int d = s[i] - '0';
		prf3 = (prf3 + d * pw3) % 3;
		prf673 = (prf673 + d * pw673) % 673;
		pw3 = pw3 * 10 % 3;
		pw673 = pw673 * 10 % 673;
		res += mp[{prf3, prf673}];
		// cout << prf3 << " " << prf673 << endl;
		mp[{prf3, prf673}]++;
	}
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 3740
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>

#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;

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

	ll ha1 = 0;
	ll ha2 = 0;

	ha1 += x / 500;
	x %= 500;
	ha2 += x / 5;
	//printf("%d\n", ha2);

	ll ans = ha1 * 1000 + ha2 * 5;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int i,j;
  int num,c;
  int array[5];
  char abacus[8][5];
  int firstflag=1;

  for(;;){
    for(i=0;i<8;i++)
      for(j=0;j<5;j++)
        abacus[i][j]='*';

    c=scanf("%d",&num);
    if(c==EOF)
      break;
    else
      if(firstflag==1)
        firstflag=0;
      else if(firstflag==0)
        printf("\n");

    array[4]=num%10;
    num/=10;
    array[3]=num%10;
    num/=10;
    array[2]=num%10;
    num/=10;
    array[1]=num%10;
    num/=10;
    array[0]=num%10;

    for(i=0;i<5;i++){
      if(array[i]>=5){
        abacus[0][i]=' ';
        abacus[1][i]='*';
      }else{
        abacus[0][i]='*';
        abacus[1][i]=' ';
      }

      abacus[2][i]='=';

      array[i]%=5;

      abacus[array[i]+3][i]=' ';
    }

    for(i=0;i<8;i++){
      for(j=0;j<5;j++)
        printf("%c",abacus[i][j]);
      printf("\n");
    }
  }
  return 0;
}

Measured memory_bytes: 0