akhauriyash/Code-Regression huggingface dataset:
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>
#define pll              pair<long,long>
#define pii              pair<int,int>
#define scn(a)           scanf("%d", &a)
#define scn2(a, b)       scanf("%d%d", &a, &b)
#define scn3(a, b, c)    scanf("%d%d%d", &a, &b, &c)
#define pairl            pair<ll , ll >
#define scnl(a)          scanf("%lld", &a)
#define scnl2(a, b)      scanf("%lld%lld", &a, &b)
#define scnl3(a, b, c)   scanf("%lld%lld%lld", &a, &b, &c)
#define scns(s)          scanf("%s",s)
#define prts(s)          printf("%s\n",s)
#define prt(a)           printf("%d\n", a)
#define prtl(a)          printf("%lld\n", a)
#define prs(a)           printf("%d ", a)
#define prt2(a, b)       printf("%d %d\n", a, b)
#define prt3(a, b, c)    printf("%d %d %d\n", a, b, c)
#define prsl(a)          printf("%lld ", a)
#define prtl2(a, b)      printf("%lld %lld\n", a, b)
#define prtl3(a, b, c)   printf("%lld %lld %lld\n", a, b, c)
#define ptcs(a)          printf("Case %d: ", a)
#define pf               printf
#define sc               scanf
#define m_p              make_pair
#define vi               vector<int >
#define vil              vector<ll >
#define pb               push_back
#define mem(a, b)        memset((a), (b), sizeof(a))
#define lg2(n)           (31-__builtin_clz(n))
#define N                200010
#define inf              9999999
#define ll               long long
#define ull              unsigned long long
#define MIN              INT_MIN
#define MAX              INT_MAX
#define fast             ios_base::sync_with_stdio(false),cin.tie(NULL)
using namespace std;
ll gcd(ll a, ll b){if(b==0) {return a;}return gcd(b, a % b);}
ll BigMod(ll B,ll P,ll M){     ll R=1; while(P>0)      {if(P%2==1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return R;}
//___________________________________________________________________________________________________________________
ll dp[N],arr[N];
char str[N];
vector<ll>prime;
bool flag[N];
map<ll,ll>mp1;
void seive()
{
    flag[0]=1;
    flag[1]=1;
    prime.push_back(2);
    for(int i=4;i<=N;i+=2) flag[i]=1;
    for(int i=3;i<=N;i+=2)
    {
        if(flag[i]==0)
        {
            prime.push_back(i);
            if(N/i>=i)
            {
                for(int j=i+i;j<=N;j+=i)
                {
                    flag[j]=1;
                }
            }
        }
    }
}
int main()
{
    fast;
    string s;
    int n;
    cin>>s>>n;
    for(int i=0;i<s.size();i+=n) cout<<s[i];
    //cout<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define INF 1<<31-1
#define LNF 9223372036854775807
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
#define NUM 100001

void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int dup(int a,int d){if(a%d==0)return a/d;else return a/d+1;}
int mod(int a,int m){if(a<0)return a%m+m;else return a%m;}
int GCD(int a,int b){int c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
int LCM(int a,int b){return a*b/GCD(a,b);}
int POW(int a,int n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return (int)ans;}
int icmp(const void* a,const void* b){return *(int*)a-*(int*)b;}
int lcmp(const void* a,const void* b){return *(LL*)a-*(LL*)b;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int scmp(const void* a,const void* b){return strcmp(*(char**)a,*(char**)b);}
LL fac[NUM],finv[NUM],inv[NUM];
void comi(){int i;fac[0]=fac[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fac[i]=fac[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
int com(int n,int k){if(n<k||n<0||k<0)return 0;return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;}


int main(){
  int N,M,i,ans=0;
  scanf("%d",&N);

  printf("%d\n",(N-1)/2);
	return 0;
}


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

int main(){
  int N,M;
  cin >> N;
  map<string,int> B;
  vector<string> C(N);
  for(int i=0;i<N;i++){
    string S;
    cin >> S;
    C.at(i)=S;
    if(B.count(S)){
      B.at(S)++;
    }
    else{
      B[S]=1;
    }
  }
  cin >> M;
  map<string,int> R;
  for(int i=0;i<M;i++){
    string S;
    cin >> S;
    if(R.count(S)){
      R.at(S)++;
    }
    else{
      R[S]=1;
    }
  }
  int max_ans=0;
  for(int i=0;i<N;i++){
    int ans;
    if(R.count(C.at(i))){
      ans=B.at(C.at(i))-R.at(C.at(i));
    }
    else{
      ans=B.at(C.at(i));
    }
    max_ans=max(max_ans,ans);
  }
  cout << max_ans << endl;
}  

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

const int MS = 1e9;

int main()
{
	int N, K, S;
	scanf("%d %d %d", &N, &K, &S);

	if (S == MS)
	{
		for (int i = 1; i <= K; i++) printf("%d ", S);
		for (int i = 1; i <= N - K; i++) printf("%d ", 1);
	}
	else
	{
		for (int i = 1; i <= K; i++) printf("%d ", S);
		for (int i = 1; i <= N - K; i++) printf("%d ", MS);
	}
	return 0;
}

Measured memory_bytes: 1280
// in the name of Allah

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

#define endl '\n'
#define pb push_back
#define ll long long
#define double long double
#define sz(x) ((int) (x.size()))

#define fr first
#define se second

#define inf 1e9
#define max_n 200002
#define mod 1000000007

ll add(ll a, ll b) {
	a += b;
	if(a >= mod) return a - mod;
	return a;
}

ll mul(ll a, ll b) {
	a *= b;
	if(a >= mod) return a % mod;
	return a;
}

ll power(ll a, ll b) {
	ll p = 1;
	while(b) {
		if(b&1) p = mul(p, a);
		a = mul(a, a);
		b /= 2;
	}
	return p;
}

ll tree[max_n];

void update(int idx, ll val) {
	while(idx < max_n) {
		tree[idx] = max(tree[idx], val);
		idx += (idx & -idx);
	}
}

ll query(int idx) {
	ll res = 0;
	while(idx > 0) {
		res = max(res, tree[idx]);
		idx -= (idx & -idx);
	}
	return res;
}

int n;
ll a[max_n];
int h[max_n];

int main() {
	// ll start = clock();
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	for(int i=0; i<n; i++) cin >> h[i];
	for(int i=0; i<n; i++) cin >> a[i];
	ll res = 0;
	memset(tree, 0, sizeof tree);
	for(int i=0; i<n; i++) {
		ll ans = a[i] + query(h[i]-1);
		update(h[i], ans);
		res = max(res, ans);
	}
	cout << res << endl;
	// cerr << (clock() - start) / (CLOCKS_PER_SEC*1.0) << endl;
	return 0;
}

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

int main(void)
{
    long int H;
    int i, j;
    int count = 0;
    long int sum, answer;

    cin >> H;

    while (H > 0)
    {
        H /= 2;
        count++;
    }

    for (i = 0, sum = 1; i < count; i++)
    {
        sum *= 2;
    }

    answer =  (sum - 1);

    cout << answer << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}


// ----------------------------------------------------------------------------
int main(){
  int n,m;
  cin >> n >> m;
  vector<vector<int>> a(n,vector<int> (m));
  vector<int> b(m);
  for(int i=0; i<n; i++){
    for(int j=0; j<m; j++){
      cin >> a[i][j];
    }
  }
  for(int i=0; i<m; i++){
    cin >> b[i];
  }
  for(int i=0; i<n; i++){
    int sum=0;
    for(int j=0; j<m; j++){
      sum += a[i][j] * b[j];
    }
    cout << sum << endl;
  }
  return 0;
}



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

struct StCrd
{
  string m_sMrk;
  int    m_nNum;
  int    m_nSeq;
};

void fnInput(vector<StCrd>& rvoCrd)
{
  int nMaxSiz;
  cin >> nMaxSiz;

  rvoCrd.resize(nMaxSiz);
  for (int i = 0; i < nMaxSiz; i++)
  {
    cin >> rvoCrd[i].m_sMrk >> rvoCrd[i].m_nNum;
    rvoCrd[i].m_nSeq = i + 1;
  }
}

int fnPartition(vector<StCrd>& rvoCrd, int nFront, int nBack)
{
  int nMid = nFront;

  for (int i = nFront; i < nBack; i++)
    if (rvoCrd[i].m_nNum <= rvoCrd[nBack].m_nNum)
      swap(rvoCrd[nMid++], rvoCrd[i]);

  swap(rvoCrd[nMid], rvoCrd[nBack]);
  return nMid;
}

void fnQuickSort(vector<StCrd>& rvoCrd, int nFront, int nBack)
{
  if (nFront < nBack)
  {
    int nMid = fnPartition(rvoCrd, nFront, nBack);
    fnQuickSort(rvoCrd, nFront, nMid - 1);
    fnQuickSort(rvoCrd, nMid + 1, nBack);
  }
}

void fnResult(const vector<StCrd>& cnrvoCrd)
{
  bool bStable = true;
  for (int i = 0; i < cnrvoCrd.size();    )
  {
    int j = i;
    while (cnrvoCrd[i].m_nNum == cnrvoCrd[++j].m_nNum)
      if (cnrvoCrd[i].m_nSeq < cnrvoCrd[j].m_nSeq);
      else
      {
        bStable = false; 
        goto LOOP_END;
      }

    i = j;
  }

LOOP_END:
  if (bStable)  cout << "Stable" << endl;
  else          cout << "Not stable" << endl;

  for (int i = 0; i < cnrvoCrd.size(); i++)
    cout << cnrvoCrd[i].m_sMrk << " " << cnrvoCrd[i].m_nNum << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<StCrd> voCrd;

  fnInput(voCrd);
  fnQuickSort(voCrd, 0, voCrd.size() - 1);
  fnResult(voCrd);

  return 0;
}

Measured memory_bytes: 9028
#coding: utf-8
n = int(input())
boxes = list(map(int,input().split()))
answer = 'Yes'

for i in reversed(range(1,len(boxes))):
	# print(str(i-1)+str(i))
	if boxes[i-1] - boxes[i] > 1:
		answer = 'No'
		break
	elif boxes[i-1] - boxes[i] == 1:
		boxes[i-1] = boxes[i-1] -1

print(answer) 


Measured memory_bytes: 14252
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        long s = scanner.nextLong();
        long l = 1000000000;

        if (s % l == 0) {
            System.out.printf("0 0 %d 0 0 %d\n", s / l, l);
        } else {
            while (true) {
                long a = l + s / l * l;
                long b = a - s;
                for (long i = 1; i * i <= b; i++) {
                    if (b % i == 0) {
                        System.out.printf("0 0 %d %d %d %d\n", l, i, b / i, a / l);
                        return;
                    }
                }
                l--;
            }
        }
    }
}

Measured memory_bytes: 22740
#include <iostream>
#define lli long long int
using namespace std;

int main() 
{
    lli n;
    cin >> n;
    lli a[n + 1];
    a[0] = 0;
    for(lli i = 1; i <= n; i++)
        cin >> a[i];
    lli dp[n+1] = {0};
    dp[2] = abs(a[2] - a[1]);
    for(lli i = 3; i <= n; i++ )
    {
        if(i > 2)
        dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2]+ abs(a[i] - a[i - 2]));
    }
    cout << dp[n];
    return 0;
}

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

long gcd(long a, long b){
    if(a==0) return b;
    if(b==0) return a;
    do{
        long t=a%b;
        a=b;
        b=t;
    }while(b!=0);
    return a;
}

int main(void){
    long n, s;
    cin >> n >> s;
    long g=0;
    for(long i=0; i<n; i++){
        long t;
        cin >> t;
        g=gcd(labs(t-s), g);
    }
    cout << g << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>

using namespace std;

int N, A, B, tot;
int per[20][200010];
int ans[200010];

int popcount(int u)
{
	return u ? popcount(u - (u & -u)) + 1 : 0;
}

void work(int pos)
{
	for (int i = 0; i < tot; i++)
	{
		if (pos > i)
		{
			ans[i] = per[N][i];
			continue;
		}
		int t = (i - pos) / 2 + 1;
		if (t & 1)
			ans[(1 << N) - 1 - (t >> 1 << 1) - (~i & 1)] = per[N][i];
		else
			ans[i - t] = per[N][i];
	}
}

int main()
{
	cin >> N >> A >> B;
	if (~popcount(A ^ B) & 1)
	{
		cout << "NO" << endl;
		return 0;
	}
	per[1][0] = 0, per[1][1] = 1;
	for (int i = 2; i <= N; i++)
	{
		int cur = (1 << i);
		for (int j = 0; j < cur; j++)
			per[i][j] = per[i - 1][j >> 1];
		for (int j = 0; j < cur; j += 4)
		{
			per[i][j + 1] |= (1 << i - 1);
			per[i][j + 2] |= (1 << i - 1);
		}
	}
	tot = (1 << N);
	for (int i = 0; i < tot; i++) per[N][i] ^= A;
	for (int i = 0; i < tot; i++)
		if (per[N][i] == B)
		{
			work(i);
			break;
		}
	cout << "YES" << endl;
	for (int i = 0; i < tot; i++)
		cout << ans[i] << ' ';
	cout << endl;
	return 0;
}


Measured memory_bytes: 15872
import copy
H,W=map(int,input().split())
List = []
for i in range (H):
  List.append(list(input()))
flag = False
NewList = []
#横の列の確認
for i in range(H):
  for j in range(W):
    if List[i][j]== "#":
      flag = True
  if flag:
    NewList.append(List[i])
  flag = False
flag1 = [True]*W
#縦の列の確認
for i in range(W):
  for j in range(len(NewList)):
    if NewList[j][i]== "#":
      flag1[i] = False
      
for j in range(len(NewList)):
  for i in range(W-1,-1,-1):
    if flag1[i]:
      NewList[j].pop(i)    
  
resList=[""]*H
for i in range(len(NewList)):
  for j in range(len(NewList[i])):
    resList[i] += NewList[i][j]
for element in resList:
  print(element)

Measured memory_bytes: 9348
# <>>><<><<<<<>>><
# >< is 0
S = input()
part = S.replace('><','> <').split(' ')

ans=0
for p in part:
    left  = p.count('<')
    right = p.count('>')
    ans += sum(range(1, max(left, right) + 1))
    ans += sum(range(1, min(left, right)))

print(ans)



Measured memory_bytes: 12828
n, m = map(int, input().split())

ans = [-1 for i in range(n)]

pf = True
for i in range(m):
    s, c = map(int, input().split())
    if ((not ans[s-1] == -1) and (not ans[s-1] == c)) or ((not n == 1)and s == 1 and c == 0):
        print(-1)
        pf = False
        break
    else:
        ans[s-1] = c

if pf and n == 1:
    if ans[0] == -1:
        print(0)
    else:
        print(ans[0])
elif pf:
    if ans[0] == -1:
        ans[0] = 1
    for i in range(n):
        if ans[i] == -1:
            ans[i] = 0
    print(''.join(map(str, ans)))


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

int main()
{
    int n, m, a, ans = 0;
    cin >> n >> m;
    ans += n;
    rep (i, m)
    {
        cin >> a;
        ans -= a;
    }

    if (ans >= 0)
        cout << ans << endl;
    else
        cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3564
import java.util.Scanner;

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

		int n = sc.nextInt();

		int a[][] = new int[3][n + 1];
		int sum = 0;
		for (int i = 1; i <= n; i++) {
			a[1][i] = sc.nextInt();
		}
		sum += a[1][1];
		for (int i = 1; i <= n; i++) {
			a[2][i] = sc.nextInt();
			sum += a[2][i];
		}
		int ans = sum;
		for (int i = 2; i <= n; i++) {
sum=sum-a[2][i-1]+a[1][i];
if(ans<=sum){
	ans=sum;
}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23764
N=int(input())
p=[float(i) for i in input().split()]

dp=[[] for _ in range(N)]

dp[0]=[1-p[0],p[0]]
for i in range(1,N):
    dp[i].append(dp[i-1][0]*(1-p[i]))
    for j in range(1,i+1):
        dp[i].append(dp[i-1][j]*(1-p[i])+dp[i-1][j-1]*p[i])
    dp[i].append(dp[i-1][-1]*p[i])

a=(N+1)//2
print(sum(dp[N-1][a:]))


Measured memory_bytes: 110392
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <cassert>

using namespace std;
using ll = long long;

const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> c(n), cnt(n, 0);
    for(int i = 0; i < n; i++) cin >> c[i];
    int q; cin >> q;
    int ans = -1;
    for(int i = 0; i < q; i++)
    {
        int t, x, d; cin >> t >> x >> d;
        x--;
        if(t == 1)
        {
            cnt[x] += d;
            if(cnt[x] > c[x] and ans == -1) ans = x + 1;
        }
        else
        {
            cnt[x] -= d;
            if(cnt[x] < 0 and ans == -1) ans = x + 1;
        }
    }
    if(ans == -1) cout << 0 << endl;
    else cout << ans << endl;
    return 0;
}




Measured memory_bytes: 3248
#include<stdio.h>
    int main(void){
    int A,B,C,i,j,cou,cou2,v[1000000],w[1000000],l[1000000];
        char S[100000];
    scanf("%d",&A);
    scanf("%s",&S);
    for(i=0;i<A;i++){
        if(S[i]=='R'){
            cou++;
        }else{
            cou2++;
        }
    }
    
    if(cou>cou2){
        printf("Yes");
    }else{
        printf("No");
    }
    return 0;
    }

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<set>
#include<string>
#include<cstring>
using namespace std;

int main()
{
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	int x_max =x, y_min = y;
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		x_max = max(x_max, t);
	}
	for (int i = 0; i < m; i++) {
		int t;
		cin >> t;
		y_min = min(y_min, t);
	}
	if (x_max < y_min)
		cout << "No War" << endl;
	else
		cout << "War" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef vector<vector<ll>> mat;
typedef vector<int> vec;

void solve() {
	int n, x;
	cin >> n >> x;
	vector<int> m(n);
	rep(i, n)cin >> m[i];
	int ans = n;
	int mi = mod;
	rep(i, n) {
		x -= m[i]; mi = min(mi, m[i]);
	}
	ans += x / mi;
	cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(6);
	//init();
	solve();
	stop
		return 0;
}


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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
using lint = long long int;

int main() {
    int N, X, Y;
    cin >> N >> X >> Y;
    --X; --Y;

    vector<int> ans(N, 0);
    for_(i,0,N) for_(j,i+1,N) {
        int ix = abs(X - i);
        int iy = abs(Y - i);
        int xj = abs(X - j);
        int yj = abs(Y - j);

        int d = min(ix + xj, iy + yj);
        d = min(d, ix + 1 + yj);
        d = min(d, j - i);
        ans[d]++;
    }

    for_(k,1,N) cout << ans[k] << endl;
}

Measured memory_bytes: 256
/**
 *    author:  FromDihPout
 *    created: 2020-08-03
**/

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


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int x, a, b;
    cin >> x >> a >> b;
    
    if (abs(a - x) < abs(b - x)) {
        cout << "A";
    }
    else {
        cout << "B";
    }
    return 0;
}

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

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}

int main(){
    string s,t;
    cin >> s >> t;
    if(s.size()+1==t.size()){
        if(t.substr(0,s.size())==s){
            puts("Yes");
            return 0;
        }
    }
    puts("No");

    return 0;
}











Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define N 209
#define pi pair<int,int>
using namespace std;
typedef long long ll;
map<int,int>m;
int main()
{
    int n,k;
    cin>>n>>k;
    while(k--)
    {
        int d;
        cin>>d;
        while(d--)
        {
            int a;
            cin>>a;
            m[a]++;
        }
    }
    int cnt=0;
    for(int i=1;i<=n;i++) if(m[i]==0) cnt++;
    cout<<cnt<<endl; //main();
    return 0;
}


Measured memory_bytes: 3640
def solve(string):
    n, *a = map(int, string.split())
    m1, m2 = sorted(a)[-2:]
    index = a.index(m2)
    return "\n".join([str(m1) if i == index else str(m2) for i in range(n)])


if __name__ == '__main__':
    n = int(input())
    print(solve('{}\n'.format(n) + '\n'.join([input() for _ in range(n)])))


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

using namespace std;

int main(void) {
	int sosu[250000] = { 0 };
	for (int i = 2; i < 250000; i++) {
		for (int j = 2; i*j < 250000; j++) {
			sosu[i*j] = 1;
		}
	}

	for (;;) {
		int n;
		cin >> n;

		if (n == 0) {
			break;
		}

		int count = 0;
		for (int i = n + 1; i <= 2*n; i++) {
			if (sosu[i] == 0) {
				count++;
			}
		}
		printf("%d\n", count);
	}
}

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

const int N = 3005;
long long dp[N][N][2];
bool vis[N][N][2];
int arr[N];
int n;

long long  rec(int l,int r,int f)
{
    if(l>r) return 0;
    long long &ret=dp[l][r][f];
    if(vis[l][r][f]) return ret;
    vis[l][r][f]=1;
    if(f==0)
    {
        ret=-1e16;
        ret=max(ret,arr[l]+rec(l+1,r,f^1));
        ret=max(ret,arr[r]+rec(l,r-1,f^1));
    }
    else
    {
        ret=1e16;
        ret=min(ret,-arr[l]+rec(l+1,r,f^1));
        ret=min(ret,-arr[r]+rec(l,r-1,f^1));
    }
    return ret;
}

int main()
{
    scanf("%d",&n);
    for(int i=1; i<=n; i++) scanf("%d",&arr[i]);
    printf("%lld\n",rec(1,n,0));



}


Measured memory_bytes: 158208
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

void check(bool b) {
    if(b)
    {
        cout << "Yes" << endl;
    }else
    {
        cout << "No" << endl;
    }
}

int main(){
    string s;
    cin >> s;
    int ans = 0;
    int tmp = 0;
    for (int i = 0; i < 3; i++)
    {
        if(s[i]=='R')
        {
            tmp++;
        }else
        {
            ans = max(ans, tmp);
            tmp = 0;
        }
    }
    ans = max(ans, tmp);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
//typedef pair<int,bool> pib;
//typedef pair<int,int> pii;



int n,m,i,j,k,b;

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

    scanf("%d", &n);
    int arr[n];
    for(;i<n;i++){
        scanf("%d", &arr[i]);
        if(abs(arr[i])>abs(b)) {
            b=arr[i];
            j=i;
        }
    }

    printf("%d\n", 2*n-1);

    for(i=1; i<=n; i++) printf("%d %d\n", j+1, i);

    if(b>=0) for(i=1; i<n; i++) printf("%d %d\n", i, i+1);

    else for(i=n; i>1; i--) printf("%d %d\n", i, i-1);


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
using namespace std;
typedef pair<int, int> P;

const int INF = 1e9;

struct SegTree {
    int N;
    vector<int> dat, lazy;
    SegTree() {}
    SegTree(int n) {
        N = 1;
        while(N < n) N *= 2;
        dat.resize(2 * N, 0);
        lazy.resize(2 * N, 0);
    }
    void lazy_evaluate(int k, int l, int r){
        if(lazy[k] != 0){
            dat[k] += lazy[k] * (r - l);
            if(k < N - 1){
                lazy[k * 2 + 1] += lazy[k];
                lazy[k * 2 + 2] += lazy[k];
            }
            lazy[k] = 0;
        }
    }
    int marge(int x, int y){
        return x + y;
    }
    void update(int a, int b, int x){ update(a, b, 0, 0, N, x); }
    void update(int a, int b, int k, int l, int r, int x){
        lazy_evaluate(k, l, r);
        if(r <= a || b <= l) return;
        if(a <= l && r <= b){
            lazy[k] += x;
            lazy_evaluate(k, l, r);
        }else{
            int m = (l + r) / 2;
            update(a, b, k * 2 + 1, l, m, x);
            update(a, b, k * 2 + 2, m, r, x);
            dat[k] = marge(dat[k * 2 + 1], dat[k * 2 + 2]);
        }
    }
    int query(int a, int b){ return query(a, b, 0, 0, N); }
    int query(int a, int b, int k, int l, int r) {
        lazy_evaluate(k, l, r);
        if(r <= a or b <= l) return 0;
        if(a <= l and r <= b) return dat[k];
        int m = (l + r) / 2;
        int x = query(a, b, k * 2 + 1, l, m);
        int y = query(a, b, k * 2 + 2, m, r);
        return marge(x, y);
    }
};

signed main(){
    int n, q;
    cin >> n >> q;
    SegTree sg(n);
    rep(i, 0, q){
        int k, s, t, x;
        cin >> k;
        if(k == 0){
            cin >> s >> t >> x;
            sg.update(s - 1, t, x);
        }else{
            cin >> s >> t;
            cout << sg.query(s - 1, t) << endl;
        }
    }
}

Measured memory_bytes: 7008
#include<stdio.h>
int gcd(int x,int y){
    int r,m;
    if(x < y){
        m=x;
        x=y;
        y=m;
    }
    while(y > 0){
        r = x % y;
        x = y;
        y = r;
    }
    return x;
}
int main()
{
    unsigned long long int a,b,x,n;
    while(scanf("%lld%lld",&a,&b)!=EOF){
        x=gcd(a,b);
        printf("%lld ",x);
        n=a/x*b;
        printf("%lld\n",n);
    }
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,p;
    while(cin>>a>>p){
        int t = (a*3)+p;
        cout<<t/2<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())
bits_raw = input()
bits = [int(bits_raw[i]) for i in range(n)]
m = int(input())
ones = []
zeros = []
for i in range(n):
    if(bits[i] == 1):
        ones.append(i)
    else:
        zeros.append(i)
if(len(zeros) > m):
    for i in range(m):
        bits[zeros[i]] = 1
    print(''.join(map(str, bits)))
else:
    allone = [1 for i in range(n)]
    l = len(ones)
    for i in range(m - len(zeros)):
        allone[ones[l - i - 1]] = 0
    print(''.join(map(str, allone)))

Measured memory_bytes: 7804
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
 int a=0,b=0;
 	for(int i=0;i<3;i++){
    	if(s[i] == 'A'){
        	a++;
        }
      	else{
        	b++;
        }
    }
	if(a>0 && b>0){
    	cout<<"Yes";
    }
  	else{
    	cout<<"No";
    }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

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

vector< P > v;
int n;

void rec( int c, int total, int pos );
int res;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> n;
    int a[SIZE], c[SIZE];
    for( int i = 0; i < n; ++i ) cin >> a[i];
    for( int i = 0; i < n; ++i ) cin >> c[i];
    for( int i = 0; i < n; ++i ) {
        v.pb( MP( a[i], c[i] ) );
    }
    rec( 0, 0, 0 );
    cout << res << endl;

    return 0;
}

void rec( int c, int total, int pos )
{
    if( pos == n ) {
        res = max( res, c - total );
        return;

    }

    for( int i = pos; i < n; ++i ) {
        rec( c + v[i].F, total + v[i].S, i + 1 );

    }
    res = max( res, c - total );
    return;

}


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

int main() {
  int n, a;
  cin >> n;
  n = 1;
  while (cin >> a) {
    n *= !(a % 2) ? ((!(a % 3) || !(a % 5)) ? 1 : 0) : 1;
  }
  cout << (n ? "APPROVED" : "DENIED") << '\n';
  return 0;}


Measured memory_bytes: 256
#include <stdio.h>

const int N = 15;
using namespace std;

int main()
{
	int n, s[N] = {0}, h[N] = {0}, c[N] = {0}, d[N] = {0};
	
	scanf("%d", &n);
	for(int i = 0; i < n;i++)
	{
		char k;
		int p;
		
		scanf(" %c %d", &k, &p);
		if (k == 'S')
		{
   	 		s[p]++;
		}
		else if (k == 'H')
		{
   	 		h[p]++;
		}
		else if (k == 'C')
		{
   	 		c[p]++;
		}
		else if (k == 'D')
		{
   	 		d[p]++;
		}
		
	}
	for (int i = 1;i <=13; i++)
	{
		if(s[i]!= 1)
		{
			printf("S %d\n", i);
		}
	}
	for (int i = 1;i <=13; i++)
	{
		if(h[i]!= 1)
		{
			printf("H %d\n", i);
		}
	}
	for (int i = 1;i <=13; i++)
	{
		if(c[i]!= 1)
		{
			printf("C %d\n", i);
		}
	}
	for (int i = 1;i <=13; i++)
	{
		if(d[i]!= 1)
		{
			printf("D %d\n", i);
		}
	}	
}



Measured memory_bytes: 2744
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

    string s; cin >> s;
    rep(i,s.size()) {
        if(i == 3) cout << s[i] << " ";
        else cout << s[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<bitset>
#include<vector>
#include<cmath>
#include<queue>
#include<map>
#include<set>

using namespace std;

int read()
{
	int ans=0,f=1;
	char c=getchar();
	while(c>'9'||c<'0'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){ans=ans*10+c-'0';c=getchar();}
	return ans*f;
}

int a,b;

int main()
{
	a=read();b=read();
	if(a==1)
		if(b==2)
			printf("3\n");
		else
			printf("2\n");
	else if(a==2)
		if(b==1)
			printf("3\n");
		else
			printf("1\n");
	else
		if(b==2)
			printf("1\n");
		else
			printf("2\n");
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace MyProgram
{
    public class Program
    {	
        public static void Main(string[] args)
        {
            int[] n = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            int N = n[0];
            int M = n[1];
            int X = n[2];
            int Y = n[3];
            
            int[] x = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            int[] y = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            Array.Sort(x);
            Array.Sort(y);
            
         
            
            bool War = true;
            
            for(int i = X+1 ; i <= Y ; i++)
            {
                if(i > x[x.Length-1] && i <= y[0])
                {
                    War = false;
                }
            }
            
            if(War) Console.WriteLine("War");
            else Console.WriteLine("No War");
        }
    }
}

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

int main() {
	// your code goes here
	long long int i,j,f=0,n;
	cin>>n;
	for(i=1;i<=9;i++)
	{
		for(j=1;j<=9;j++)
		{
			if(i*j==n)
			{
				f=1;
				break;
			}
		}
	}
	if(f==1)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
}

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

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

typedef long long ll;
typedef long long int64;

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

  vector<pair<pair<string, int>, int>> s(n);

  for(int i=0; i<n; i++){
    string tmp;
    int score;
    cin >> tmp >> score;
    s[i].first = make_pair(tmp, -score);
    s[i].second = i + 1;
  }

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

  for(int i=0; i<n; i++){
    cout << s[i].second << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lll = int64_t;
using ll = __int128_t;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  lll N,M,V,P;
  cin >> N >> M >> V >> P;
  vector<lll> a(N);
  vector<ll> psum(N+1);
  map<ll,ll> m;
  for(ll i = 0; i < N; ++i){
    cin >> a[i];
    ++m[a[i]];
  }
  sort(a.rbegin(),a.rend());
  for(ll i = 0; i < N; ++i) psum[i+1] = psum[i]+a[i];
  vector<lll> keys,nans;
  for(auto& p : m) keys.push_back(p.first);
  nans.push_back(0);
  for(ll i = 0; i < keys.size(); ++i){
    nans.push_back(nans.back()+m[keys[i]]);
  }
  ll b = 0,e = keys.size()-1;
  lll ans = P;
  while(b <= e){
    ll i = (b+e)/2;
    ll key = keys[i];
    ll tot = nans[i+1];
    if(tot+P-1 >= N){
      ans = max(ans,N-nans[i]);
      e = i-1;
      continue;
    }
    if(tot+P-1 >= V){
      if(key+M >= a[P-1]){
        ans = max(ans,N-nans[i]);
        e = i-1;
        continue;
      }
    }
    else{
      ll L = N-tot;
      ll Len = L-(P-1);
      ll Tot = (V-(tot+P-1))*M;
      ll Tot1 = Len*a[P-1]-(psum[L]-psum[P-1]);
      ll delta = 0;
      if(Tot > Tot1) delta = (Tot-Tot1+Len-1)/Len;
      if(key+M >= a[P-1]+delta){
        ans = max(ans,N-nans[i]);
        e = i-1;
        continue;
      }
    }
    b = i+1;
  }
  cout << ans;
  return 0;
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)

int gx, gy, dp[20][20];
bool able[20][20][2];

void solve() {
	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1;
	
	for_(y,0,gy+1) for_(x,0,gx+1) {
		if (!able[y][x][0]) dp[y+1][x] += dp[y][x];
		if (!able[y][x][1]) dp[y][x+1] += dp[y][x];
	}
	
	if (dp[gy][gx] > 0) cout << dp[gy][gx] << endl;
	else cout << "Miserable Hokusai!" << endl;
}

int main() {
	int T; cin >> T;
	
	for_(i,0,T) {
		memset(able, 0, sizeof(able));
		cin >> gx >> gy;
		
		int p; cin >> p;
		for_(i,0,p) {
			int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
			able[min(y1,y2)][min(x1,x2)][abs(x1 - x2)] = 1;
		}
		
		solve();
	}
	
	return 0;
}

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

int main(){
    int s;
    int m;
    int h;
    int h2;
    
    cin >> s;
    
    h = s / 3600;
    
    h2 = s % 3600;
    
    m = h2 / 60;
    
    s = h2 % 60;
    
    cout << h << ":" << m << ":" << s << endl;
    
}


Measured memory_bytes: 3116
from sys import stdin
O = list(stdin.readline().rstrip())
E = list(stdin.readline().rstrip())
ans = []
diff = len(O)-len(E)
for o, e in zip(O, E):
    ans.append(o+e)
if diff == 1:
    ans.append(O[-1])
elif diff == -1:
    ans.append(E[-1])
print(''.join(ans))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    ll N, K, R, S, P;
    cin >> N >> K >> R >> S >> P;
    string T;
    cin >> T;

    vector<ll> score(N, 0);
    for (ll i = 0; i < N; i++) {
        if(i < K){
            if(T[i] == 'r'){
                score[i] = P;
            }
            else if(T[i] == 's'){
                score[i] = R;
            }
            else{
                score[i] = S;
            }
        }
        else{
            if(T[i] == T[i-K]){
                if(score[i-K] > 0){
                    score[i] = 0;
                }
                else{
                    if(T[i] == 'r'){
                        score[i] = P;
                    }
                    else if(T[i] == 's'){
                        score[i] = R;
                    }
                    else{
                        score[i] = S;
                    }
                }
            }
            else if(T[i] == 'r'){
                score[i] = P;
            }
            else if(T[i] == 's'){
                score[i] = R;
            }
            else{
                score[i] = S;
            }
        }
    }

    ll ans = 0;
    for (ll i = 0; i < N; i++) {
        ans += score[i];
    }

    printf("%lld\n", ans);
}

Measured memory_bytes: 4312
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


n = ni()
a = [0] + list(li()) + [0]

sm = 0
for i in range(len(a)-1):
    sm += (abs(a[i+1]-a[i]))

for i in range(1,len(a)-1):
    print(sm - abs(a[i]-a[i-1]) - abs(a[i+1]-a[i]) + abs(a[i+1]-a[i-1]))


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

int main()
{
    string a;
    cin>>a;
    if (a=="A"){
        cout<< "T" <<endl;
    } else if (a=="T"){
        cout<< "A" <<endl;
    } else if (a=="C"){
        cout<< "G" <<endl;
    } else if (a=="G"){
        cout<< "C" <<endl;
    } else {
        cout<< " " <<endl;
    }
}

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

int A[100100];

int main(){
	int n,a;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> a;
		A[a]++;
		A[a+1]++;
		if(a>0) A[a-1]++;
	}
	
	int Mx=-1e9;
	for(int i=1;i<100001;i++){
		Mx=max(Mx,A[i]);
	}
	
	cout << Mx << endl;
	return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using namespace std;

using lint=int64_t;
using uint=uint32_t;
using ulint=uint64_t;

template<class T>
using vector2d=vector<vector<T>>;

template<class T>
bool UpdateMax(T &a, const T &b){
  if(a<b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template<class T>
bool UpdateMin(T &a, const T &b){
  if(a>b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template <class T>
void OutVec(const vector<T>& vec){
  for(int i = 0; i < vec.size() - 1; ++i){
    cout<<vec[i]<<" ";
  }
  cout<<vec.back()<<endl;
}

template <class T>
void OutVec2d(const vector2d<T>& vec){
  for(auto v:vec){
    OutVec(v);
  }
}

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

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

  return 0;
}




Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define P pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007;
//最大公約数
int gcd(int s,int b){
    if(b==0)return s;
    return gcd(b,s%b);
}
signed main(){
    int n;
    cin>>n;
    int ka=n/2-1;
    int fi,la;
    int d[n];
    rep(i,n){
        cin>>d[i];
    }
    sort(d,d+n);
    rep(i,n){
        if(i==ka){
            fi=d[i];
        }
        if(i==ka+1){
            la=d[i];
            break;
        }
    }
    cout<<la-fi<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i = (a);i<=(b);i++)
#define ROF(i,a,b) for(int i = (a);i>=(b);i--)
#define MST(a,x) memset(a,x,sizeof(a))
#define ll long long
#define PB push_back
#define PH push
#define MP make_pair
#define FT first
#define SD second
#define N 100005
#define M 51
#define INF 1000000007
#define MOD 1000000007
#define MOD2 1000000009
#define eps 1e-7
using namespace std;
inline int Max(int a,int b)
{
    return (((b-a)>>(32-1))&(a^b))^b;
}
inline int Min(int a,int b)
{
    return (((b-a)>>(32-1))&(a^b))^a;
}

ll dx[N];
int p[N],nxt[75][N];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m,k;
    while(cin>>n)
    {
        ll pre = 0;
        ll st;
        FOR(i,1,n)
        {
            ll x;
            cin>>x;
            if(i!=1)dx[i-1] = x-pre;
            else st = x;
            pre = x;
        }
        cin>>m>>k;
        FOR(i,1,n-1)p[i] = i;
        FOR(i,1,m)
        {
            int q;
            cin>>q;
            swap(p[q],p[q-1]);
        }
        FOR(i,1,n-1)nxt[0][i] = p[i];
        FOR(i,1,70)
        {
            FOR(j,1,n-1)
            {
                nxt[i][j] = nxt[i-1][nxt[i-1][j]];
            }
        }
        int i = 0;
        FOR(i,1,n-1)p[i] = i;
        while(k)
        {
            if(k&1)
            {
                FOR(j,1,n-1)p[j] = nxt[i][p[j]];
            }
            k>>=1;
            i++;
        }
        cout<<st<<endl;
        FOR(i,1,n-1)
        {
            st+=dx[p[i]];
            cout<<st<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 30208
#include <bits/stdc++.h>
using namespace std;
int a, b;
int main() {
    ios::sync_with_stdio(false);
    cin >> a >> b;
    if (a > 0 && b > 0) {
        cout << "Positive" << endl;
    } else if (max(a, b) >= 0 && min(a, b) <= 0 || a == 0 || b == 0) {
        cout << "Zero" << endl;
    } else {
        if ((abs(min(a, b)) - abs(max(a, b))) % 2==0) {
            cout << "Negative" << endl;
        } else {
            cout << "Positive" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<vector>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
const long long mod = 1e9 + 7;

int main(){
    int n, ans = 1;
    cin >> n;
    int h[n];
    rep(i, n) cin >> h[i];
    for(int i = n-1; i>0; i--){
        if(h[i] >= h[i-1]) continue;
        else if(h[i] >= h[i-1] - 1) h[i-1] -= 1;
        else ans = 0;
    }
    if(n == 1) cout << "Yes" << endl;
    else if(ans) cout << "Yes" << endl;
    else cout << "No" << endl; 
}

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

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

	unsigned long long A, B, C;
	cin >> A >> B >> C;
	if(A % 2 == 0 || B % 2 == 0 || C % 2 == 0){
		cout << 0 << endl;
		return 0;
	}

	if(A > B && A > C){
		cout << B * C << endl;
		return 0;
	}
	if(B > A && B > C){
		cout << A * C << endl;
		return 0;
	}

	cout << A * B << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long k;
int main()
{
    cin>>k;
    queue<long long> q;
    for(int i=1; i<=9; i++) q.push(i); 
    while(!q.empty())
    {
        long long x=q.front(); q.pop();
        k--;
        if(k==0)
        {
            cout<<x<<endl;
            break;
        }
        for(int y=(x%10)-1; y<=(x%10)+1; y++)
        {
            if(y<0 || y>=10) continue;
            q.push(x*10+(long long)y);
        }
    }
    return 0;
}

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

using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef long int li;

int main()
{
    IOS;
    //freopen("fr.txt","r",stdin);
    int a;
    cin>>a;
    cout<<(a+pow(a,2)+pow(a,3))<<endl;

    return 0;
}


Measured memory_bytes: 4156
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    int x;
    cin >> x;
    if(x >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int a, b, k;
  cin >> a >> b >> k;
  rep(i, a, b + 1) {
    if (i - a + 1 <= k || b - k < i)
      cout << i << endl;
  }
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, int> pdi;
typedef pair<ll, ll> pll;
 
# define S second
# define F first
# define kill(x) return(cout << x << endl, 0)
# define debug(x) cerr<< #x << " : " << x << endl
# define ddebug(x, y) cerr<< #x << " : " << x  << ", " << #y << " : " << y << endl
# define sz(s) (int)s.size()
# define sq(x) (x) * (x)
# define PB(x) push_back(x)
# define smax(x, y) (x) = max((x), (y))
# define smin(x, y) (x) = min((x), (y))
# define all(x) x.begin(), x.end()
# define SP fixed << setprecision(10)
# define UB upper_bound

const int MAXN = 200 * 1000 + 10;
int n, q;
char c[MAXN], s[MAXN];
bool d[MAXN];

bool dead(int ind)
{
	for (int i = 0; i < q; i ++)
	{
		if (c[i] == s[ind])
			ind += (d[i] ? +1 : -1);
		if (ind < 0)
			return true;
	}
	return false;
}

int bs()
{
	int l = 0, r = n + 1;
	while (r - l > 1)
	{
		int mid = (l + r) / 2;
		if (dead(mid - 1))
			l = mid;
		else
			r = mid;
	}
	return l;
}

int32_t main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	cin >> n >> q;
	for (int i = 0; i < n; i ++)
		cin >> s[i];
	for (int i = 0; i < q; i ++)
	{
		char cc;
		cin >> c[i] >> cc;
		d[i] = (cc == 'R');
	}

	int ans1 = bs();
	reverse(s, s + n);
	for (int i = 0; i < q; i ++)
		d[i] ^= 1;
	int ans2 = bs();

	cout << n - min(ans1 + ans2, n) << endl;

	return 0;
}


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

const int INF = pow(2, 31) - 1;
#define ll long long
#define DEBUG(x) cout << "DEBUG>" << #x << ":" << x << endl;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main() {
  int N, Y;
  cin >> N >> Y;
  FOR(i, 0, N) {
    FOR(j, 0, N) {
      int k = N - i - j;
      if(k < 0) continue;
      if(10000 * i + 5000 * j + 1000 * k == Y) {
        cout << i << " " << j << " " << k << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES // for C++  
#include "bits/stdc++.h"
#define LL long long
#define NUM 1000000007

using namespace std;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (b <=c || d <=a)
    {
        cout << 0 << endl;
    }
    else if (a <=c && c <=d && d <=b)
    {
        cout << d - c << endl;
    }
    else if (c <=a && a <=b && b <=d)
    {
        cout << b - a << endl;
    }
    else if (a <=c && c <=b && b <=d)
    {
        cout << b - c << endl;
    }
    else if (c <=a && a <=d && d <=b)
    {
        cout << d - a << endl;
    }
}

Measured memory_bytes: 256