akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int,int>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

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

	int N, M;
	cin >> N >> M;
	map<int, int> m;

	for (int i = 0; i < N; i++) {
		int A, B;
		cin >> A >> B;
		m[A] += B;
	}

	int ans = 0;

	for(auto tmp:m){
		int buy = min(M, tmp.second);
		ans += tmp.first * buy;
		M -= buy;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 6528
inp = input().split()

K = int(inp[0])
A = int(inp[1])
B = int(inp[2])

count = 1

remain = K

if (B - A <= 2):
    count += remain
else:
    if (A - 1 >= remain):
        remain = 0
        count += remain
    else:
        while(True):
            remain -= A-1
            count += A-1
            if (remain == 0):
                break
            elif (remain%2== 1):
                count += remain//2*(B-A)
                count += 1
                break
            else:
                count += remain//2*(B-A)
                break


print(count)


Measured memory_bytes: 3064
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int x = scan.nextInt();
        int y = scan.nextInt();
        int z;
        
                
        
        while (x+y>0) {
            if(x>y){
                z=x;
                x=y;
                y=z;   
        }

        System.out.println(x+" "+y);
        x = scan.nextInt();
        y = scan.nextInt();
       
    }
}
}


Measured memory_bytes: 35820
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define all(x)     		(x).begin(),(x).end()
#define ub    			upper_bound
#define lb 				lower_bound
#define ins				insert
#define int 			long long
#define endl			'\n'
#define ff              first
#define ss              second
#define ull				unsigned long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define si 				set<int>
#define usi 			unordered_set<int>		
#define mii             map<int,int>
#define umii			unordered_map<int ,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define rep(i,a,n)		for(int i=a;i<n;++i)
#define repd(i,a,n)		for(int i=a;i>n;--i)
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define Mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define deb(x)			cout<<#x <<"="<<x<<endl;
#define deb2(x,y)		cout<<#x<<"="<<x<<"  "<<#y<<"="<<y<<endl;
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
int Pow(int a,int b){int res=1;while(b>0){if(b&1)res*=a;a*=a;b/=2;}return res;}
int MPow(int a,int  b){int res=1;while(b>0){if(b&1)res=(res*a)%Mod;a=(a*a)%Mod;b/=2;}return res%Mod;}
int log(int x){return 64-__builtin_clzll(x)-1;}

void c_p_p()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
}
struct Node
{
	int a,b,c,d;
	
};
bool cmp(Node A,Node B)
{
	return A.a<B.a;
}
const int Max=1e6+1;
int A[Max];

int32_t main()
{
	c_p_p();
	int n;
	cin>>n;
	si S;
	rep(i,0,n)
	{
		int a;
		cin>>a;
		A[a]+=1;
		S.ins(a);
	}
	int ans=0;
	for(auto it:S)
	{
		bool foo=1;
		for(int j=2;j<=sqrt(it);++j)
		{
			if(it%j==0)
			{
				if(A[j] || A[it/j])foo=0;
			}
			
		}
		if(it!=1)
		{
			if(A[1] || A[it]>1)foo=0;
		}
		else 
		{
			if(A[1]>1)foo=0;
		}
		ans+=foo;
	}
	cout<<ans;
	
	return 0;
}
	

Measured memory_bytes: 19720
# coding: utf-8

list = []

while True:
    num = input().rstrip().split(" ")
    if (int(num[0]) == 0) and (int(num[1]) == 0):
        break
    list.append(num)

for i in range(len(list)):
    for j in range(int(list[i][0])):
        for k in range(int(list[i][1])):
            if ((j % 2) == 0):
                if ((k % 2) == 0):
                    print("#", end="")
                else:
                    print(".", end="")
            else:
                if ((k % 2) == 0):
                    print(".", end="")
                else:
                    print("#", end="")
        print()
    print()

Measured memory_bytes: 8996
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;

// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>

vector <ll> v;

ll fep(ll x, ll y, ll mod)
{ll res=1;while(y>0){if(y&1)res=(res*x)%mod;
    y=y>>1;x=(x*x)%mod;}return res%mod;}

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

	ll n,i,m,j,k,x,y,a,b,t,v,w;
	string s;
	
	cin >> a >> v >> b >> w >> t;
	k=b-a;
	if(v<=w)
	{
		cout << "NO";
		return 0;
	}
	v=w-v;
	if(abs(v*t)>=abs(k))
		cout << "YES";
	else
		cout << "NO";

	return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
#include <set>
#include <functional>
#include <map>
#include <queue>
#include <cstring>
#include <stack>
#include <iomanip>
#include <climits>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define show(x) cout << #x << " = " << x << endl;
typedef long long ll;
typedef pair<int,int> pii;
bool check(vector<int>x,vector<int>a,int n){
    bool flag = true;
    int c = 0;
    rep(i,n){
        c=0;
        if(a[x[i]]!=i+1)flag = false;
        rep(j,x[i]){
            if(a[j] == i+1)c++;
        }
        if(c!=i)flag = false;
    }
    rep(i,n){
        c = 0;
        rep(j,n*n){
            if(a[j]==i+1)c++;
        }
        if(c!=n)flag = false;
    }
    return flag;
}
int main(){
    int n;
    cin >> n;
    vector<int>x(n);
    vector<pii>p(n);
    rep(i,n){
        cin >> x[i];
        x[i]--;
        p[i] = pii(x[i],i+1);
    }
    sort(p.begin(),p.end());
    vector<int>a(n*n,0);
    rep(i,n){
        a[x[i]] = i+1;
    }
    //rep(i,n*n)cout << a[i] << " ";
    //cout << endl;
    int now = 0;
    int c = 0;
    rep(i,n){
        c = 0;
        while(1){
            if(c==p[i].second-1)break;
            if(a[now]==0){
                a[now]=p[i].second;
                c++;
            }
            else if(a[now]==p[i].second){
                puts("No");
                return 0;
            }
            now++;
            if(now==n*n)break;
        }
    }
    //rep(i,n*n)cout << a[i] << " ";
    //cout << endl;
    now = n*n-1;
    reverse(p.begin(),p.end());
    rep(i,n){
        c = 0;
        //now = n*n-1;
        //cout << i << " " << p[i].second << endl;
        while(1){
            if(0){
                show(c);
                show(p[i].second);
            }
            if(now==-1)break;
            if(c==n-p[i].second)break;
            if(a[now]==0){
                a[now]=p[i].second;
                c++;
            }else if(a[now]==p[i].second){
                puts("No");
                return 0;
            }
            now--;
            if(now==-1)break;
        }
    }
    if(check(x,a,n)){
        puts("Yes");
        rep(i,n*n){
            cout << a[i];
            if(i!=n*n-1)cout << " ";
        }
        cout << endl;
        
    }
    else puts("No");
    return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define vint vector<int>
#define pri_que priority_queue
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    int res=1;
    vint t(n);
    rep(i,n){
        cin >> t[i];
        res=lcm(res,t[i]);
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3668
n = int(input())
dp = [None] * (n+1)
dp[1] = 1
dp[0] = 0
sixs = [6]
nines = [9]
i = 1
while sixs[i-1] * 6 <= n:
    sixs.append(sixs[i-1]*6)
    i += 1

i = 1
while nines[i-1] * 6 <= n:
    nines.append(nines[i-1]*9)
    i += 1
for current in range(2, n+1):
    smin = n
    for six in sixs:
        if current - six >= 0 and dp[current-six] != None:
            smin = min(smin, dp[current-six] + 1)
    nmin = n
    #print (smin, nmin)
    for nine in nines:
        if current - nine >= 0 and dp[current-nine] != None:
            nmin = min(nmin, dp[current-nine] + 1)
    #print (dp)
    dp[current] = min(dp[current-1] + 1, nmin, smin)
print (dp[n])
#print (dp)

Measured memory_bytes: 9720
N = int(input())
A = []
n = N ** 0.5
p = int(n)

for i in range(1, p + 1):
	if N % i == 0 and i <= n:
		A.append(i)
		
a = int(max(A))
b = int(N / a)
print(a + b - 2)


Measured memory_bytes: 3188
#include <stdio.h>
#include <stdlib.h>

long common_elem(long i, long j) {
  if (j < i) 
    return i * (i - 1) / 2 + 1 + j;
  else
    return common_elem(j, i);
}

int main(int argc, char *argv[]) {
  long N;
  scanf("%ld", &N);
  // printf("%ld\n", N);
  
  // find k
  long k = -1;
  for (long i = 2; i * (i - 1) <= 2 * N; i++) {
    if (i * (i - 1) == 2 * N) {
      k = i;
      break;
    }
  }
  
  if (k < 0) {
    printf("No\n");
  } else {
    printf("Yes\n");
    printf("%ld\n", k);
    for (long i = 0; i < k; i++) {
      printf("%ld", k - 1);
      for (long j = 0; j < k; j++) {
        if (j != i) {
          printf(" %ld", common_elem(i, j));
        }
      }
      printf("\n");
    }
  }
  
  return 0;
}


Measured memory_bytes: 1280
MAXC = 10000

def solve(n,ma,mb,list)
  dp = []

  #init dp
  all_a = 0
  all_b = 0
  list.each do |a,b,c|
    all_a += a
    all_b += b
  end

  dp[0] = []
  (0..all_a).each do |a|
    (0..all_b).each do |b|
      dp[0][a] ||= []
      dp[0][a][b] = MAXC
    end
  end
  dp[0][0][0] = 0

  (1..n).each do |k|
    dp[k] = []
    ea,eb,ec = list[k-1]

    (0..all_a).each do |a|
      (0..all_b).each do |b|
        dp[k][a] ||= []

        nosel = dp[k-1][a][b]
        sel = MAXC
        sel = (dp[k-1][a - ea][b - eb] + ec) if a >= ea && b >= eb
        if sel < nosel
          dp[k][a][b] = sel
        else
          dp[k][a][b] = nosel
        end
      end
    end

  end

  ans = MAXC
  (1..all_a).each do |a|
    (1..all_b).each do |b|
      next unless Rational(a,b) == Rational(ma,mb)
      ans = dp[n][a][b] if ans > dp[n][a][b]
    end
  end

  return -1 if ans == MAXC
  return ans
end

def main
  n,ma,mb = gets.split.map(&:to_i)
  list = []
  n.times do
    list << gets.split.map(&:to_i)
  end
  puts solve(n,ma,mb,list)
end

main


Measured memory_bytes: 24572
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'
#define endl '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int n, k, q;
    cin >> n >> k >> q;

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

    int ans = IINF;
    rep(x, n){
        int prev = -1;
        bool ok = true;
        priority_queue< int, vector<int>, greater<int> > que;
        rep(i, n + 1){
            if(i == n || a[i] < a[x]){
                if(prev < x && x < i && i - prev - k <= 0){
                    ok = false;
                    break;
                }
                vector<int> v;
                REP(j, prev + 1, i){
                    v.emplace_back(a[j]);
                }
                SORT(v);
                for(int j = 0 ; j < i - prev - k ; ++j){
                    que.push(v[j]);
                }
                prev = i;
            }
        }
        ok &= (int)que.size() >= q;
        if(ok){
            rep(i, q - 1){
                que.pop();
            }
            chmin(ans, que.top() - a[x]);
        }
    }

    cout << ans << endl;

    cout << flush;

    return 0;
}

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

#define _GLIBCXX_DEBUG

#define vint vector<int>
#define vvint vector<vint>
#define rep(i, n) for ((i) = 0; (i) < (n); (i)++)

int main(){
    int N; 
    vint S;
    
    int i, j, k;

    map<int, int> m;

    cin >> N;
    S.resize(1 << N);
    rep (i, 1 << N) {
        cin >> S[i];
    }

    sort(S.rbegin(), S.rend());

    m[1] = 1001001001;
    int prev_S = 0, prev_elem = 0;
    for (auto s: S) {
        if (prev_S != s) {
            prev_elem = 0;
        }
        auto it = m.lower_bound(prev_elem);
        while (it != m.end() and it->second == s) {
            it++;
        }

        if (it == m.end()) {
            cout << "No\n";
            return 0;
        }

        
        prev_elem = it -> first;
        prev_S = s;
        int elem = prev_elem;
        m.erase(it);
        elem <<= 1;
        while (elem < (1 << (N + 1))) {
            m[elem + 1] = prev_S;
            elem <<= 1;
        }
        // for (auto e: m) {
        //     cout << (e.first) << ',' << (e.second) << ' ';
        // }
        // cout << '\n';
    }
    
    

    cout << "Yes\n";

    return 0;
}

Measured memory_bytes: 10320
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<fstream>
#include<map>
#include<iostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef queue<int> qi;
typedef queue<ll> ql;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define rep(i,n) for (int i=1;i<=n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
int cnt[100005]; 
int c=0;
int main()
{
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    rep(i,n){
    	int x;
    	cin>>x;
    	cnt[x]++;cnt[x+1]++;
		if (x>0) cnt[x-1]++;
		else c++;
    }
    int ans=c;
    for (int i=0;i<100005;i++) ans=max(ans,cnt[i]);
    cout<<ans;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define pb          push_back
#define pll         pair<ll,ll>
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod         998244353
#define mode        1000000007
#define inf         1000000000000000000LL
#define vl          vector<ll>
#define F           first
#define S           second
#define db          long double
#define sz(x)       (ll)x.size()
#define fix(n)      cout<<fixed<<setprecision(n)
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define all(x)      x.begin(),x.end()
#define mset(x)     memset(x,0,sizeof x)
#define pi          3.14159265358979323



void solve()
{
       ll n;
       cin>>n;
       vl a(n),ans(n);
       rep(i,0,n) cin>>a[i];
       while(a.size()>0)
       {
              ll f=0;
              for(ll i=a.size()-1; i>=0; i--)
              {
                     if(a[i]==i+1)
                     {
                            ans.pb(i+1);
                            a.erase(a.begin()+i);
                            f=1;
                            break;
                     }
              }
              if(f==0 && a.size())
              {
                     cout<<-1;
                     exit(0);
              }
       }
       reverse(ans.begin(), ans.end());
       rep(i,0,n) cout<<ans[i]<<" ";
}

int main()
{
    speed_up
    ll T=1;
    //cin>>T;
    while(T--)
        solve();
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();

        String ans = (c - a - b) * (c - a - b) - 4 * a * b > 0
                ? "Yes" : "No";
        if (c - a - b < 0) ans = "No";

        System.out.println(ans);
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


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



int main(){
    int h, w;
    cin >> h >> w;

    char m[h][w];
    int che[h][w];
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> m[i][j];
            che[i][j] = 100;
        }
    }

    int ans = 0;
    int dx[4] = {1, -1, 0, 0};
    int dy[4] = {0, 0, 1, -1};
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(m[i][j] == '.'){
                for(int t = 0; t < h; t++){
                    for(int b = 0; b < w; b++){
                        che[t][b] = 100;
                    }
                }
                queue<pair<int, int> > q;
                q.push(make_pair(i, j));
                che[i][j] = 0;
                int max = 0;
                while(!q.empty()){
                    pair<int, int> p = q.front();
                    q.pop();
                    for(int k = 0; k < 4; k++){
                        int x = p.second + dx[k];
                        int y = p.first + dy[k];
                        if(x < w && x >= 0 && y >= 0 && y < h){
                            if(m[y][x] == '.' && che[y][x] == 100){
                                q.push(make_pair(y, x));
                                che[y][x] = che[p.first][p.second] + 1;
                                if(max < che[y][x]){
                                    max = che[y][x];
                                }
                            }
                        }
                    }
                }
                if(ans < max){
                    ans = max;
                }
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 384
import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]
def init_dp1(init, N): return [init for _ in range(N)]
def init_dp2(init, N, M): return [[init for _ in range(M)] for _ in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if n is None:
            return

        if self.v is None:
            self.v = n
            return
        self.v = self.f(self.v, n) 


def main():
    N, Z, W = read_values()
    A = read_list()
    res = V(max, abs(W - A[-1]))
    if N >= 2:
        res.ud(abs(A[-1] - A[-2]))

    print(res)


if __name__ == "__main__":
    main()



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

int main(){
  #define int int64_t
  int X,Y,Z,K;
  cin>>X>>Y>>Z>>K;
  vector<int> A(X);
  vector<int> B(Y);
  vector<int> C(Z);
  vector<int> V;
  for(int i=0;i<X;++i){
    scanf("%lld",&A.at(i));
  }for(int i=0;i<Y;++i){
    scanf("%lld",&B.at(i));
  }for(int i=0;i<Z;++i){
    scanf("%lld",&C.at(i));
  }
  sort(A.begin(),A.end());
  sort(B.begin(),B.end());
  sort(C.begin(),C.end());
  reverse(A.begin(),A.end());
  reverse(B.begin(),B.end());
  reverse(C.begin(),C.end());
  for(int i=0;i<X;++i){
    for(int j=0;j<Y;++j){
      for(int k=0;k<Z;++k){
        if((i+1)*(j+1)*(k+1)<=K){
          V.emplace_back(A.at(i)+B.at(j)+C.at(k));
        }
      }
    }
  }
  sort(V.begin(),V.end());
  reverse(V.begin(),V.end());
  for(int i=0;i<K;++i){
    printf("%lld\n",V.at(i));
  }
}


Measured memory_bytes: 1404
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <set>
#define MOD 1000000007
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> h(n);

    int max=0;
    int count=0;
    for(int i=0;i<n;i++){
        cin >> h[i];
    }

    for(int i=0;i<n;i++){
        if(max <= h[i]){
            count++;
            max = h[i];
        }
    }

    cout << count << endl;

    
    
}

Measured memory_bytes: 256
S = list(input())
n = len(S)
def dfs(count,s):
    if count == n:
        # 最後に数式を足す
        return eval(s)
    # + を挟むか否か
    plus = dfs(count+1, s+'+'+S[count]) #挟んだ場合
    nothing = dfs(count+1, s+S[count])  #挟まない場合
    return plus + nothing

print(dfs(1,S[0]))

Measured memory_bytes: 3060
import math,collections
n=int(input())
a=sorted(map(int,input().split()))[::-1]
s=collections.Counter(a)
r=0
f=0
for i,v in enumerate(a):
	p=2**math.ceil(math.log2(v))-v
	if f:f=0
	elif s[v]==0:pass
	elif p in s.keys()and s[p]>0:s[v]-=1;s[p]-=1;r+=1
	elif i<n-1 and p==0 and v==a[i+1]and s[v]>1:s[v]-=2;r+=1;f=1
print(r)

Measured memory_bytes: 33416
#include <iostream>
#include <string>

using namespace std;

int main() {
  int r, g, b;
  cin >> r >> g >> b;
  
  int num = 100 * r + 10 * g + b;
  string answer = "NO";
  if (num % 4 == 0) {
    answer = "YES";
  }

  cout << answer << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int info = sc.nextInt();
        
        int b,f,r,v=0;
        
        int[][][] house=new int[4][3][10];
        
        for(int i=0;i<info; i++){
            b = sc.nextInt();
            f = sc.nextInt();
            r = sc.nextInt();
            v = sc.nextInt();
            
            house[b-1][f-1][r-1] += v;
        }
        
        for(int i = 0; i < 4; i++){
            for(int j = 0; j < 3; j++){
                for(int k = 0; k < 10; k++){
                    if(k != 9){
                        System.out.print(" " + house[i][j][k]);
                    }else{
                        System.out.println(" " + house[i][j][k]);
                    }
                }
            }
            if(i!=3){
                System.out.println("####################");
            }
        }
        
    }
}



Measured memory_bytes: 29508
import itertools

while True:
    c = input().split()
    n, x = int(c[0]), int(c[1])
    if n == x == 0:
        break
    count = 0
    for i, j, k in itertools.combinations(range(1, n + 1), 3):
        if i + j + k == x:
            count += 1
    print(count)



Measured memory_bytes: 5632
#a = gets.split(" ").map{|x| x.to_i}
=begin
n = gets.to_i
count = 0
n.times do |i|
  if((i + 1) % 2 == 1)
    count += 1
  end
end
p count.to_f / n.to_f
=end

=begin
nk = gets.split(" ").map{|x| x.to_i}
N = nk[0]
K = nk[1]

h = gets.split(" ").map{|x| x.to_i}
count = 0

N.times do |i|
  if(K <= h[i])
    count += 1
  end
end
p count
=end

N = gets.to_i
a = gets.split(" ").map{|x| x.to_i}

array = Array.new(N)
N.times do |i|
  array[a[i] - 1] = i + 1
end
N.times do |i|
  print "#{array[i]} "
end


Measured memory_bytes: 12036
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
#define fi first;
#define se second;
#define print(x,y) (cout << (x) << (y))
#define inf INT_MAX
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int,bool> pib;
typedef vector<pii> vii;
typedef vector<pib> vib;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<string,string> pss;
const int MOD = 1000000007;

int main(){
    boost;
   string s;
   cin >> s;
   if(s=="AAA" || s == "BBB") cout << "No"; else cout << "Yes";
    return 0;
}



Measured memory_bytes: 256
N,M=map(int,input().split())
d = dict()
for i in range(M):
  a,b=map(int,input().split())
  if a not in d:
    d[a]=b
  else:
    if d[a]!=b:
      print(-1)
      exit(0)
tmp=0
for i in range(10):
  if 3 in d and d[3] != i:
    continue
  for j in range(10):
    if 2 in d and d[2] != j:
      continue
    for k in range(10):
      if N!=1 and k ==0:
        continue
      if 1 in d and d[1]!= k:
        continue
      print((str(k)+str(j)+str(i))[:N])
      exit(0)
print(-1)

Measured memory_bytes: 3064
import sys
input = sys.stdin.readline

def main():
    max_density = 0
    whole_weight = 0
    sugar_weight = 0
    A, B, C, D, E, F = map(int, input().split())
    for n_a in range(int(F / (100 * A)) + 1):
        for n_b in range(int((F - 100 * n_a * A) / (100 * B)) + 1):
            max_sugar = min(E * (n_a * A + n_b * B), F - 100 * (n_a * A + n_b * B))
            for n_c in range(int(max_sugar / C) + 1):
                for n_d in range(int((max_sugar - C * n_c) / D) + 1):
                    if 100 * (n_a * A + n_b * B) + n_c * C + n_d * D == 0:
                        continue
                    density = (n_c * C + n_d * D) / (100 * (n_a * A + n_b * B) + n_c * C + n_d * D)
                    if density > max_density or (density == 0 and max_density == 0):
                        max_density = density
                        whole_weight = 100 * (n_a * A + n_b * B) + n_c * C + n_d * D
                        sugar_weight = n_c * C + n_d * D

    print(whole_weight, sugar_weight)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
class in{struct It{int it;const bool rev;explicit constexpr It(int it_, bool rev=false):it(it_),rev(rev){}int operator*(){return it;}bool operator!=(It& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const It i,n;public:explicit constexpr in(int n):i(0),n(n<0?0:n){}explicit constexpr in(int i,int n):i(i,n<i),n(n){}const It& begin(){return i;}const It& end(){return n;}};

#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    i64 g, t; cin >> g >> t;
    vector<i64> a(n + 1, 0LL);
    for(int i : in(n)) cin >> a[i + 1];
    vector<i64> dp(n + 1, 1e18);
    dp[0] = 0LL;
    int j = 0;
    i64 mi = 1e18;
    for(int i : in(1, n + 1)) {
        dp[i] = dp[i - 1] + t;
        while(j < i && t <= 2LL * (a[i] - a[j + 1])) {
            mi = min(mi, dp[j] - 2 * a[j + 1]);
            ++j;
        }
        dp[i] = min(dp[i], dp[j] + t);
        dp[i] = min(dp[i], mi + 2 * a[i]);
    }
    cout << dp[n] + g << endl;
    return 0;
}

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

int main() {
  int N, A;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
      cin >> A;
      a[i] = A;
  }
  int count = 0;
  while (1) {
    for (int i = 0; i < N; i++) {
      if (a[i] % 2 == 1){
        cout << count << endl;
        return 0;
      }
      a[i] = a[i] / 2;
    }
    count += 1;
  }
  cout << count << endl;
}


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

int main() {
  int x, y; cin >> x >> y;
  int group[13] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
  cout << (group[x] == group[y] ? "Yes" : "No") << endl;
}

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

int main(){
    double x1, y1, x2, y2;
    scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
    double nx = pow(x1-x2, 2);
    double ny = pow(y1-y2, 2);
    printf("%lf\n", sqrt(nx+ny));
    return 0;
}


Measured memory_bytes: 3216
dic = {}
for antenna in ["A", "B", "C", "D", "E"]:
    dic[antenna] = int(input())
distant = int(input())

flg = False
for i in dic.keys():
    for j in dic.keys():
        if abs(dic[j] - dic[i]) > distant:
            flg = True
            break

if flg == True:
    print(":(")
else:
    print("Yay!")


Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <string>
#include <unordered_map>
#include <cmath>
#include <algorithm>

typedef long long ll;
typedef long double ld;

using namespace std;
int main()
{
  int a, b, c;
  cin >> a >> b >> c;

  if ((a == b && a != c) || (a == c && a != b) || (c == b && a != c))
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
from sys import stdin
def input():
    return stdin.readline().strip()

n, k = map(int, input().split())
xy  = []
for _ in range(n):
    i, j = map(int, input().split())
    xy.append((i, j))

xy.sort()

# decide left, right, down
ans = 10 ** 19
for left in range(n-k+1):
    for right in range(left+k-1, n):
        horiz = xy[right][0] - xy[left][0]

        choose = sorted(xy[left:right+1], key=lambda x: x[1])
        for down in range(len(choose)-k+1):
            # up = down + k - 1
            # vert = choose[down+k-1][1] - choose[down][1]
            area = horiz * (choose[down+k-1][1] - choose[down][1])
            if area < ans:
                ans = area

print(ans)

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

int main(){
  int r,c,q,a[50000],b[50000],o[50000];
  int nr,nc;
  bool row[50000],col[50000];
  int ans;

  while(1){
    cin >> r >> c >> q;
    if(!r && !c && !q)break;

    for(int i=0;i<r;i++)row[i] = false;
    for(int i=0;i<c;i++)col[i] = false;

    ans = nr = nc = 0;
    for(int i=0;i<q;i++)cin >> a[i] >> b[i] >> o[i];

    for(int i=q-1;i>=0;i--){
      if(a[i]){
	if(!col[b[i]]){
	  if(o[i])ans += r-nr;
	  col[b[i]] = true;
	  nc++;
	}
      }else{
	if(!row[b[i]]){
	  if(o[i])ans += c-nc;
	  row[b[i]] = true;
	  nr++;
	}
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1548
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, ll> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

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

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 100010;
const int MAXK = 510;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << min(a, b) + min(c, d);
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#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>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int main(int argc, char **argv) {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max(a * b, c * d) << endl;
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	a := getNextInt(scanner)
	b := getNextInt(scanner)
	c := getNextInt(scanner)
	d := getNextInt(scanner)
	dp := makeGrid(c+1, d+1)
	dp[a][b] = 1
	for i := a + 1; i < c+1; i++ {
		dp[i][b].addAs(dp[i-1][b].mul(mint(b)))
	}
	for i := b + 1; i < d+1; i++ {
		dp[a][i].addAs(dp[a][i-1].mul(mint(a)))
	}
	for i := a + 1; i < c+1; i++ {
		for j := b + 1; j < d+1; j++ {
			dp[i][j].addAs(dp[i-1][j].mul(mint(j)))
			dp[i][j].addAs(dp[i][j-1].mul(mint(i)))
			dp[i][j].subAs(dp[i-1][j-1].mul(mint(j - 1).mul(mint(i - 1))))
		}
	}
	fmt.Fprintln(writer, dp[c][d])
}
func makeGrid(h, w int) [][]mint {
	index := make([][]mint, h, h)
	data := make([]mint, h*w, h*w)
	for i := 0; i < h; i++ {
		index[i] = data[i*w : (i+1)*w]
	}
	return index
}

type mint int64

func (mt mint) mod() mint {
	m := mint(998244353)
	mt %= m
	if mt < 0 {
		return mt + m
	}
	return mt
}
func (mt mint) inv() mint {
	return mt.pow(mint(0).sub(2))
}
func (mt mint) pow(n mint) mint {
	p := mint(1)
	for n > 0 {
		if n&1 == 1 {
			p.mulAs(mt)
		}
		mt.mulAs(mt)
		n >>= 1
	}
	return p
}
func (mt mint) add(x mint) mint {
	return (mt + x).mod()
}
func (mt mint) sub(x mint) mint {
	return (mt - x).mod()
}
func (mt mint) mul(x mint) mint {
	return (mt * x).mod()
}
func (mt mint) div(x mint) mint {
	return mt.mul(x.inv())
}
func (mt *mint) addAs(x mint) *mint {
	*mt = mt.add(x)
	return mt
}
func (mt *mint) subAs(x mint) *mint {
	*mt = mt.sub(x)
	return mt
}
func (mt *mint) mulAs(x mint) *mint {
	*mt = mt.mul(x)
	return mt
}
func (mt *mint) divAs(x mint) *mint {
	*mt = mt.div(x)
	return mt
}


Measured memory_bytes: 74588
def li():
    return list(map(int, input().split()))


if __name__ == "__main__":
    n = int(input())
    h_list = li()

    result = True
    state = h_list[0] - 1
    for index in range(1, n):
        if state > h_list[index]:
            result = False
            break
        elif state == h_list[index]:
            pass
        else:
            state = h_list[index] - 1
    if result:
        print("Yes")
    else:
        print("No")

# なるべく小さい高さを保って列を作れるかを確認すれば十分
# range(1,n)
# 初期値　１番目の値　True
# 更新処理
# 　前の値より小さい場合　任意の値　False
# 　前の値と同じ　今の値　True
# 　前の値より大きい　今の値-1　True
# 　最後にTrueだったら可能


Measured memory_bytes: 63984
package main
 
import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)
 
func main() {
	N := getStdinInt()
	if N % 1000 == 0 {
		fmt.Printf("%d", 0)
	} else {
		fmt.Printf("%d", 1000-N%1000)
	}
}
 
var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)
 
func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinInt2() (int, int) {
	list := getStdinIntArr()
	return list[0], list[1]
}
func getStdinInt3() (int, int, int) {
	list := getStdinIntArr()
	return list[0], list[1], list[2]
}
func getStdinInt64() int64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return rtn
}
func getStdinInt64_2() (int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1]
}
func getStdinInt64_3() (int64, int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1], list[2]
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}
func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}
func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, _ := sc.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

Measured memory_bytes: 2184
import std.algorithm;
import std.bigint;
import std.concurrency;
import std.container;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.meta;
import std.numeric;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


auto solve(long A, long B, long C) {
    return min(C, B / A);
}


void main() {
    auto input = stdin.byLine.map!split.joiner;

    long A;
    A = input.front.to!long;
    input.popFront;

    long B;
    B = input.front.to!long;
    input.popFront;

    long C;
    C = input.front.to!long;
    input.popFront;

    static if (is(ReturnType!solve == void))
        solve(A, B, C);
    else
        solve(A, B, C).writeln;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>

using namespace std;

int main(void) {
	int N,M;
	while (cin >> N >> M, N) {
		map<int,int> data;
		vector<int> w(N),h(M);
		for (int i = 0; i < N; ++i) {
			cin >> w[i];
			++data[w[i]];
		}
		int temp;
		for (int i = 0; i < N-1; ++i) {
			temp = w[i];
			for (int j = i+1; j < N; ++j) {
				temp += w[j];
				++data[temp];
			}
		}

		int res = 0;
		for (int i = 0; i < M; ++i) {
			cin >> h[i];
			if (data[h[i]] > 0) {
				res += data[h[i]];
			}
		}
		for (int i = 0; i < M-1; ++i) {
			temp = h[i];
			for (int j = i+1; j < M; ++j) {
				temp += h[j];
				if (data[temp] > 0) {
					res += data[temp];
				}
			}
		}
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 20900
a,b = map(int, input().split())

def num(a,b):
    a = str(a) * b
    return a
    
aa = num(a,b)
bb = num(b,a)

def compare(a,b):
    if len(a) > len(b):
        return a
    else:
        return b

bigger = compare(aa,bb)

if aa == bb:
    print(aa)

for n in range(len(bigger)):
    if int(aa[n]) > int(bb[n]):
        print(bb)
        break
    elif int(aa[n]) < int(bb[n]):
        print(aa) 
        break 
    else:
        continue

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a, b;
    string s;
    while(cin>>a>>b>>s)
    {
        int p=0, q=0;
        if(s.size()==(a+b+1) && s[a]=='-') p=1;
        {
            for(int i=0; i<s.size(); i++)
            {
                if(i!=a)
                {
                    if(s[i]=='0' || s[i]=='1' || s[i]=='2' || s[i]=='3' || s[i]=='4' || s[i]=='5' || s[i]=='6' || s[i]=='7' || s[i]=='8' || s[i]=='9') q++;
                }
            }
        }
        if(p==1 && q==(s.size()-1)) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <utility>
using namespace std; 

int main() {
    string S; cin >> S;
	int red = 0, yellow = 0;
	for (int i = 0; i < S.size(); i++){
		if(S[i] == '0') red++;
		else yellow++;
	}
	cout << 2 * min(red, yellow) << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
	int a, b;
	cin >> a >> b;
	if (a <= 8 && b <= 8) {
		cout << "Yay!" << endl;
	}
	else {
		cout << ":(" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

        int c500 = stdin.nextInt();
        int c100 = stdin.nextInt();
        int c50 = stdin.nextInt();
        int cSum = stdin.nextInt();

        int count = 0;

        for (int i = 0; i <= c500; i++) {
            for (int j = 0; j <= c100; j++) {
                for (int k = 0; k <= c50; k++) {
                    if (i * 500 + j * 100 + k * 50 == cSum) {
                        count++;
                    }
                }
            }
        }

        System.out.println(count);
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a=0;cin>>n;
  vector<int>l(n*2);
  for(int i=0;i<n*2;i++)cin>>l.at(i);
  sort(l.begin(),l.end());
  for(int i=0;i<n;i++)a+=l.at(i*2);
  cout<<a<<endl;
}

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

using namespace std;

typedef long long LL;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

#define INF 100000000

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

	priority_queue<LL> pq[8];
	for (int n = 0; n < N; n++)
	{
		LL a, b, c;
		cin >> a >> b >> c;
		pq[0].push(a + b + c);
		pq[1].push(a + b - c);
		pq[2].push(a - b - c);
		pq[3].push(a - b + c);
		pq[4].push(-a + b + c);
		pq[5].push(-a + b - c);
		pq[6].push(-a - b - c);
		pq[7].push(-a - b + c);
	}
	LL sum[8];
	memset(sum, 0, sizeof(sum));
	for (int m = 0; m < M; m++)
	{
		for (int n = 0; n < 8; n++)
		{
			sum[n] += pq[n].top();
			pq[n].pop();
		}
	}
	LL best = LLONG_MIN;
	for (int n = 0; n < 8; n++)
		best = max(sum[n], best);
	cout << best << endl;
}



Measured memory_bytes: 3688
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'
#define endl '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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

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

struct node{
    int y, x, cost;
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int h, w, k;
    cin >> h >> w >> k;

    vector<string> a(h);
    int sy = -1, sx = -1;
    rep(i, h){
        cin >> a[i];
        rep(j, w){
            if(a[i][j] == 'S'){
                sy = i;
                sx = j;
            }
        }
    }

    vector< vector<int> > cost(h, vector<int>(w, IINF));
    cost[sy][sx] = 0;
    queue<node> que;
    que.push({sy, sx, 0});

    auto inside = [&](int y, int x){
        return 0 <= y && y < h && 0 <= x && x < w;
    };

    while(!que.empty()){
        node now = que.front();
        que.pop();
        if(cost[now.y][now.x] < now.cost){
            continue;
        }
        rep(i, 4){
            int ny = now.y + dy4[i];
            int nx = now.x + dx4[i];
            if(inside(ny, nx) && a[ny][nx] != '#' && chmin(cost[ny][nx], now.cost + 1)){
                que.push({ny, nx, now.cost + 1});
            }
        }
    }

    int ans = IINF;
    rep(i, h){
        rep(j, w){
            if(cost[i][j] <= k){
                if(cost[i][j] < k && (i == 0 || i == h - 1 || j == 0 || j == w - 1)){
                    chmin(ans, 1);
                }
                chmin(ans, 1 + (min({i, h - i - 1, j, w - j - 1}) + k - 1) / k);
            }
        }
    }

    cout << ans << endl;

    cout << flush;

    return 0;
}

Measured memory_bytes: 3456