akhauriyash/Code-Regression huggingface dataset:
/*================================================================
*   Copyright (C) 2019 Sangfor Ltd. All rights reserved.
*
*   创 建 者： badcw
*   创建日期： 2019/12/22
*
================================================================*/
#include <bits/stdc++.h>

#define ll long long
using namespace std;

const int maxn = 1e5+50;
const int mod = 1e9+7;
ll qp(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

template <class T>
inline bool scan(T& ret) {
    char c;
    int sgn;
    if (c = getchar(), c == EOF) return 0; // EOF
    while (c != '-' && (c < '0' || c > '9')) c = getchar();
    sgn = (c == '-') ? -1 : 1;
    ret = (c == '-') ? 0 : (c - '0');
    while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c - '0');
    ret *= sgn;
    return 1;
}

//template <class T>
//inline void out(T x) {
//    if (x > 9) out(x / 10);
//    putchar(x % 10 + '0');
//}

int n;
vector<int> edge[maxn];
int x, y;
int dep[maxn], fa[maxn][30];

void dfs(int u, int pre) {
    dep[u] = dep[pre] + 1, fa[u][0] = pre;
    for(int i = 1; (1 << i) <= n; i ++)
        fa[u][i] = fa[fa[u][i - 1]][i - 1];
    for(auto v : edge[u]) if(v != pre) dfs(v, u);
}

int LCA(int u, int v) {
    if(dep[u] < dep[v]) swap(u, v);
    int d = dep[u] - dep[v];
    for(int i = 0; (1 << i) <= d; i ++)
        if((1 << i) & d) u = fa[u][i];
    if(u == v) return u;
    for(int i = 20; i >= 0; i --)
        if(fa[u][i] != fa[v][i])
            u = fa[u][i], v = fa[v][i];
    return fa[u][0];
}

int dist(int u, int v) {
    return dep[u] + dep[v] - 2 * dep[LCA(u, v)];
}

int main(int argc, char* argv[]) {
    scanf("%d%d%d", &n, &x, &y);
    for (int i = 1; i < n; ++i) {
        int u, v;
        scanf("%d%d", &u, &v);
        edge[u].push_back(v);
        edge[v].push_back(u);
    }
    dfs(1, 0);
    int res = 0;
    int res2 = n + 1;
    for (int i = 1; i <= n; ++i) {
        int tmp1 = dist(x, i);
        int tmp2 = dist(y, i);
        if (tmp1 == tmp2) res2 = min(res2, tmp2);
        else if (tmp1 < tmp2) res = max(res, tmp2 - 1);
    }
    if (res2 != n + 1) {
        printf("%d\n", max(res2, res));
    } else printf("%d\n", res);
    return 0;
}

Measured memory_bytes: 21888
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		List<Integer> outputs = new ArrayList<Integer>();

		while(sc.hasNextInt()){
			int value = sc.nextInt();
			if(value != 0){
				outputs.add(value);
			}
			else{
				break;
			}
		}
		
		for(int i = 0; i<outputs.size(); ++i){
			System.out.println("Case " + (i + 1) + ": " + outputs.get(i));
		}
	}
}

Measured memory_bytes: 44292
a, b, c, x, y = map(int, input().split())
if a + b > 2 * c and x > y:
    if a > 2 * c:
        ans = 2 * x * c
    else:
        ans = (x - y) * a + 2 * y * c
elif a + b > 2 * c and x <= y:
    if b > 2 * c:
        ans = 2 * y * c
    else:
        ans = (y - x) * b + 2 * x * c
else:
    ans = x * a + y * b
print(ans)

Measured memory_bytes: 3064
N, M = map(int, input().split())
S = input()
S = S[::-1]

dp = [-1] * (N+1)
dp[0] = 0

pos = 0
while pos < N:

    p = pos
    update = False

    for i in range(1, M + 1):
        if p + i > N:
            break
        if S[p + i] == "0":
            update = True
            pos = p + i
            dp[pos] = dp[p] + 1

    if not update:
        break

if dp[N] == -1:
    print(-1)
    exit()

dp = dp[::-1]
num = dp[0]
ans = []
pos = 0

while num > 0:
    for i in range(1, M + 1):
        if dp[pos + i] == num - 1:
            num -= 1
            pos += i
            ans.append(str(i))
            break

ans = " ".join(ans)
print(ans)


Measured memory_bytes: 13668
N = int(input())
#x, y = map(int, input().split())
#a = [list(map(int, input().split())) for _ in range(N)]
a = list(map(int, input().split()))
#s = input()
for i in range(N):
    a[i] = a[i]**-1  
ans = sum(a)
print(ans**-1)


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

string alpha("abcdefghijklmnopqrstuvwxyz");
string s;

int main(){
    cin >> s;

    for(int i = 0; i < alpha.size(); i++){
        if(int(s.find(alpha[i])) == -1){
            cout << alpha[i];
            return 0;
        }
    }
    cout << "None";
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

bool cmp(pii a,pii b){
	return a.first<b.first;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<int> a(9);
	rep(i,n){
		int x;
		cin >> x;
		if(x<400) a.at(0)++;
		else if(x<800) a.at(1)++;
		else if(x<1200) a.at(2)++;
		else if(x<1600) a.at(3)++;
		else if(x<2000) a.at(4)++;
		else if(x<2400) a.at(5)++;
		else if(x<2800) a.at(6)++;
		else if(x<3200) a.at(7)++;
		else a.at(8)++;
	}
	int sum=0;
	rep(i,8){
		if(a.at(i)>0) sum++;
	}
	if(sum==0){
		cout << 1 << " " << a.at(8) << endl;
	}
	else{
		cout << sum << " " << sum+a.at(8) << endl;
	}
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int n,m,i,j,s[50][2],p[50][2],d,min,l;
  scanf("%d%d",&n,&m);
  for (i=0;i<n;i++) scanf("%d%d",&s[i][0],&s[i][1]);
  for (i=0;i<m;i++) scanf("%d%d",&p[i][0],&p[i][1]);
  for (i=0;i<n;i++){
    min=200000000;
    for (j=0;j<m;j++){
      d=(s[i][0]>p[j][0])? s[i][0]-p[j][0]:p[j][0]-s[i][0];
      d+=(s[i][1]>p[j][1])? s[i][1]-p[j][1]:p[j][1]-s[i][1];
      if (d<min){
        min=d;
        l=j;
      }
    }
    printf("%d\n",l+1);
  }
  return 0;
}

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

#define int long long

vector<string> G;

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

int graph[52][52];

int mod = 1000000007;
signed main() {
    int n;
    cin >> n;
    string s1, s2;
    cin >> s1 >> s2;
    if(n==1) {
        cout << 3 << endl;
        return 0;
    }
    G.push_back(s1);
    G.push_back(s2);

    int cnt = 0;
    int ans = 6;
    int i = 0;
    if(s1[i]==s2[i]) {
        i++;
        cnt = 1;
        ans = 3;
    }
    else {
        ans = 6;
        cnt = 2;
        i += 2;
    }
    for(int j=i; j<n; ++j) {
        if(s1[j]==s2[j]) {
            cnt++;
            if(cnt==2) {
                ans = (ans*2)%mod;
                cnt = 1;
            }
            else if(cnt==3) {
                cnt = 1;
            }
        } else {
            cnt += 2;
            j++;
            if(cnt==3) {
                ans = (ans*2)%mod;
                cnt = 2;
            }
            else if(cnt==4) {
                ans = (ans*3)%mod;
                cnt = 2;
            }
        }
    }
    cout << (ans)%mod << endl;

    return 0;
}



Measured memory_bytes: 256
def check_bng(t):
	c = 0
	for i in range(3):
		if t[i][0] + t[i][1] + t[i][2] == -3:
			c = 1
		if t[0][i] + t[1][i] + t[2][i] == -3:
			c = 1
	if t[0][0] + t[1][1] + t[2][2] == -3 or t[2][0] + t[1][1] + t[0][2] == -3:
		c = 1

	return c

def check(b,t):
	for i in range(3):
		if t[i].count(b) == 1:
			t[i][t[i].index(b)] = -1
	return t

if __name__ == '__main__':
	A1 = [int(a) for a in input().split()]
	A2 = [int(a) for a in input().split()]
	A3 = [int(a) for a in input().split()]
	N = int(input())

	t = [A1, A2, A3]

	nlst = []
	for i in range(N):
		check(int(input()),t)

	if check_bng(t) == 1:
		print('Yes')
	else:
		print('No')

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int main(){
	int N,D,i;
	cin>>N>>D;
	i=2*D+1;
	if(N%i==0){
		cout<<N/i;
	}else{
		cout<<N/i+1;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define mod 1000000007

using namespace std;

typedef long long ll;

string a, b;

int st[2050];
int dr[2050];

int mx1[2050];
int mx2[2050];
int getans()
{
    int n = a.size(), i, j;

    for(i = 0; i < n; i++)
        if(b[i] == '1')
            break;

    if(i >= n)
    {
        for(i = 0; i < n; i++)
            if(a[i] == '1')
                return (1<<30);
        return 0;
    }

    for(i = 0; i < n; i++)
    {
        for(j = i; ; j--)
            if(b[(j + n) % n] == '1')
                break;
        st[i] = j;
        for(j = i; ; j++)
            if(b[j%n] == '1')
                break;
        dr[i] = j;
    }

    int rv = (1<<30);
    for(i = 0; i < n; i++)
    {
        vector <pair<int, int> > v;
        int x = i;
        for (j = 0; j < n; j++)
        {
            if(a[j] == b[(j - i + n) % n])
                continue;
            x++;
            int s = -i + j, e = j;
            if(st[e] >= s)
                continue;
            v.pb({dr[e] - e, (s+n)%n - st[(s+n)%n]});
        }
        sort(v.begin(), v.end());

        mx1[0] = 0;
        for(j = 0; j < v.size(); j++)
            mx1[j + 1] = max(mx1[j], v[j].fi);
        mx2[v.size()] = 0;
        for(j = v.size() - 1; j >= 0; j--)
            mx2[j] = max(mx2[j + 1], v[j].se);

        for(j = 0; j <= v.size(); j++)
            rv = min(rv, x + 2 * (mx1[j] + mx2[j]));
    }
    return rv;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> a;
    cin >> b;
    int n = a.size();
	int ans = getans();
	reverse(a.begin(), a.end());
	reverse(b.begin(), b.end());
	ans = min(ans, getans());
	if(ans == (1<<30))
        cout << -1;
    else
        cout << ans;
    return 0;
}


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

int main(){
    int b,r,g,c,s,t;
    
    while(cin >> b >> r >> g >> c >> s >> t ,b+r+g+c+s){
        int medal = 100;
        medal += 95*b+63*r+7*g+2*c+3*s-3*t;
        cout << medal << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int>pi;
#define elif else if
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define Rep(x,y) for(int k=x;k<y;k++)
#define all(x) x.begin(),x.end()
#define pb push_back
#define vint vector<int>
#define vvint vector<vector<int>>
#define vtr vector<string>
#define vvtr vector<vector<string>>
#define vhar vector<char>
#define vvhar vector<vector<char>>
#define mod 100000007
#define elif else if
#define str string
int digitsum(int a){
  int b=0;
  while(a){
    b+=a%10;
    a/=10;
  }
  return b;
}
signed main(){
  int N,M,O,P=0,c=0,co=1,cou=0,minN=mod;
  double D,Do;
  char C,Ca;
  str S,T,U;
  cin>>S>>N;
  N--;
  while(true){
    if(S[c]=='1'&&c==N){
      cout<<'1'<<endl;
      break;
    }
    else if(S[c]!='1'){
      cout<<S[c]<<endl;
      break;
    }
    c++;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdin = new Scanner(System.in);
		String s;
		s = stdin.next();
		boolean a = true;
		for (int i = 0; i < s.length(); i++) {
			for (int j = 0; j < i; j++) {
				if (s.charAt(i) == s.charAt(j)) {
					a = false;
				}
			}
		}
		if (a) {
			System.out.println("yes");
		} else {
			System.out.println("no");

		}
	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  char a,b;
  cin >> a >> b;

  cout << (a==b ? 'H' : 'D') << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <iomanip>
#include <cmath>
#include <queue>
#include <bitset>
#include <numeric>
#include <array>
#include <cstring>
#include <random>
#include <chrono>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main() {

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

  ll x, k, d;

  cin >> x >> k >> d;

  if(x < 0) x *= -1;

  ll ans = (k % 2 == 0 ? x : min(abs(x - d), abs(x + d)));

  ll cx = x;

  ll m = min(cx / d, k);

  cx -= m * d;

  k -= m;

  if(k % 2 == 0) ans = min(ans, abs(cx));

  if(k) { cx -= d; k--; }

  if(k % 2 == 0) ans = min(ans, abs(cx));

  cout << ans;

  return 0;
}
/*

*/


Measured memory_bytes: 3592
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define MAX 100005
#define True 1
#define False 0

typedef struct queue{
  char n[100];
  int s;
} Queue;

int head, tail, n;
Queue  Q[MAX];

int isFull(){
  if(head==(tail+1)%MAX)return True;
  else return False;
}
void enqueue(Queue x){
  if(isFull()==True){
    fprintf(stderr,"Enqueue Error!\n");
    exit(1);
  }
  Q[tail]=x;
  tail=(tail+1)%MAX;
}
Queue dequeue(){
  Queue x=Q[head];

   head=(head+1)%MAX;
   return x;
}
int min(int x, int y){
  if(x<y)return x;
  else return y;
}

int main(){
  int e=0, mint, i, q;
  Queue queue;

  scanf("%d%d",&n,&q);
  for(i=1 ; i<=n ; i++){
    scanf("%s",Q[i].n);
    scanf("%d",&Q[i].s);
  }
  head=1;
  tail=n+1;
  while(head!=tail){
    queue=dequeue();
    mint=min(q, queue.s);
    queue.s-=mint;
    e+=mint;
    if(queue.s>0)enqueue(queue);
    else{
      printf("%s %d\n",queue.n, e);
    }
  }
  return 0;
}


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

int main(){
    int w,h,x,y;
    cin >> w >> h >> x >> y;
    cout << (double)w*h/2 << endl;
    if(x*2==w && y*2==h){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 3784
#include<bits/stdc++.h>
using namespace std;
#define con continue
#define bk break
#define LL long long
#define db double
#define pt cout<<'\n'
#define ms(a, b) memset((a), (b), sizeof(a))
#define mp make_pair
#define endl '\n'
int inf=2147483647;const long long ll =9223372036854775807,ninf=1000000000;const double eps = 1e-6; const long long nll =223372036854775807;
#define sz size()
#define len(X) strlen(X)
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ULL unsigned long long
#define de cout<<"test"<<endl;
#define st system("pause");
#define M_PI 3.1415926
LL A[100005]={};
int main()
{
    int a;
    while(cin>>a){
        for(int i=0;i<a;i++){
            cin>>A[i];
        }
        LL ans=ll;
        LL tmp=0;
        int flag=0;
        LL now=0;
        for(int i=0;i<a;i++){
            if(!flag){
                flag=1;
                if(now+A[i]<=0){
                    tmp+=abs(now+A[i])+1;
                    now=1;
                }
                else{
                    now+=A[i];
                }
            }
            else{
                flag=0;
                if(now+A[i]>=0){
                        tmp+=abs(now+A[i])+1;
                    now=-1;
                }
                else{
                    now+=A[i];
                }
            }
        }
        ans=min(ans,tmp);
        tmp=0;
        flag=1;
        now=0;
                for(int i=0;i<a;i++){
            if(!flag){
                flag=1;
                if(now+A[i]<=0){
                    tmp+=abs(now+A[i])+1;
                    now=1;
                }
                     else{
                    now+=A[i];
                }
            }
            else{
                flag=0;
                if(now+A[i]>=0){
                        tmp+=abs(now+A[i])+1;
                    now=-1;
                }
                     else{
                    now+=A[i];
                }
            }
        }
           ans=min(ans,tmp);
           cout<<ans<<endl;
    }
    return 0;
}


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

int main()
{
    int L,R,d;
    int count=0;
    int i;
    scanf("%d%d%d",&L,&R,&d);
    for(i=L;i<R+1;i++)
    {
        if((i>d||i==d)&&(i%d==0))
            count++;
    }
    printf("%d",count);
    return 0;
}

Measured memory_bytes: 1728
#include <cstdio>

int main(){
    int x;
    scanf("%d",&x);
    int a = x;
    int b = 0;
    while(a != 0){
        b = b + a % 10;
        a = (a - a % 10) / 10;
    }
    if(x % b == 0){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 128
/* HARDWORK IS THE KEY TO SUCCESS.
   RATING IS TEMPORARY , KNOWLEDGE IS PERMANENT.!!!*/

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define T int t = 1; cin>>t; while(t--)
#define ain ll n,k,i; cin>>n; ll a[n]; for(i=0; i<n; i++) cin>>a[i]
#define matin ll m,n; cin >> n >> m; ll a[n + 1][m + 1]; for(ll i=1;i<=n;i++) for(ll j=1;j<=m;j++) cin>>a[i][j];
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define I insert
#define pb push_back

const ll maxs = 1e5+3;
const ll maxs1 = 1e3+4;
const ll mod = 1e9 + 7;
inline ll add(ll a, ll b) { return (mod + a + b) % mod;}
inline ll sub(ll a, ll b) {return (a - b + mod) % mod;}
inline ll mul(ll a, ll b) {return (1ll * a * b) % mod;}
ll fastpow(ll x, ll y) {
    ll res = 1; x = x % mod; while (y > 0) { if(y & 1) res = (res * x) % mod; y = y >> 1;x = (x * x) % mod;}return res;}
ll inv(ll x) {
    return fastpow(x, mod - 2);
}



int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    
    ll a;
    cin >> a;
    ll b = a * a;
    ll c = a * a * a;
    ll d = a + b + c;
    cout << d;
    
    

}


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

#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define vvi vector<vi>
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )

const int INF = 1e9;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9 + 7;


int main() {

    int ans = 0;
    int n;
    cin >> n;
    vi a(n + 1);
    vector<bool> jafoi(n + 1, false);
    fo(i, n) cin >> a[i + 1];

    for ( int i = 1; i <= n; i++ ) {
        if ( i == a[a[i]] and !jafoi[i] ) {
            jafoi[i] = jafoi[a[i]] = true;
            ans++;
        }
    }

    cout << ans << endl;



    return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>

using namespace std;

int main()
{
	int n, a, b, c, x;
	while(1){
		cin >> n >> a >> b >> c >> x;
		if(n == 0 && a == 0 && b == 0 && c == 0 && x == 0) break;
		int y[200], next_x=0, cnt = 0;
		for(int i = 0; i < n; i++){
			cin >> y[i];
		}
		int now_y;
		for(int i = 0; i < n; i++){
			now_y = y[i];
			while(1){
				next_x = (a * x + b) % c;
				if(y[i] == x){
					if(i != n-1) cnt++;
					x = next_x;
					break;
				}
				else {
					cnt++;
					if(cnt > 10000){
						cnt = -1;
						i = 200;
						break;
					}
					else x = next_x;
				}
			}
		}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

string s;

void input(){
    cin >> s;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    int n = s.size();
    ll ans = 0;
    for(int i=0;i<n-1;i++){
        if(s[i] == 'W' && s[i+1] == 'B') ans++;
        else if(s[i] == 'B' && s[i+1] == 'W') ans++;
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
    int N, X;
    int tmp;
    int sum = 0;
    int min = 1000;
    cin >> N >> X;
    for(int i = 0; i < N; i++) {
        cin >> tmp;
        if(tmp < min) {
            min = tmp;
        }
        sum += tmp;
    }
    X = X - sum;
    int MinNum = (X / min);
    cout << N + MinNum << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  long H,W,N;
  cin>>H>>W>>N;
  int ans=0;
  int pd=0;
  while(pd<N){
    if(H>W){
      pd+=H;
      ans++;
      W--;
    }
    else{
      pd+=W;
      ans++;
      H--;
    }
  }
cout<<ans<<endl;
}


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

#define int long long

signed main()
{
    int n;
    while(cin>>n, n) {
        vector<pair<int, int> > v;
        v.push_back(make_pair(201,201));
        for(int i=0; i<n-1; ++i) {
            int a, b;
            cin >> a >> b;
            int x = v[a].first;
            int y = v[a].second;
            if(b==0) --x;
            else if(b==1) ++y;
            else if(b==2) ++x;
            else if(b==3) --y;
            v.push_back(make_pair(x,y));
        }

        int max_x = -1, max_y = -1;
        int min_x = 1000000, min_y = 1000000;
        for (auto e : v) {
            int x = e.first;
            int y = e.second;
            max_x = max(max_x, x);
            max_y = max(max_y, y);
            min_x = min(min_x, x);
            min_y = min(min_y, y);
        }
        cout << max_x - min_x + 1 << " " << max_y - min_y + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 2992
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a[1000001],q=0,i=1;
  cin>>a[1];
  while(q==0){
    if(a[i]%2==1){
      a[i+1]=3*a[i]+1;
    }else{
      a[i+1]=a[i]/2;
    }
    for(int j=1; j<i; j++){
	if(a[i]==a[j]){
	  q=i;
	}
    }
    i++;
  }
  cout<<q<<'\n';
  return 0;
}


Measured memory_bytes: 256
//https://codeforces.com/contest/1330/problem/D
#include<bits/stdc++.h>
typedef long long ll;
const int mod=1e9+7;
const int N=1e2+5;

int n,m;
int a[N];

int main()
{
	// freopen("test.in","r",stdin);
	// scanf("%d",&T);
	// while(T--)
	// {
	scanf("%d%d",&n,&m);
	int s=0;
	for(int i=1;i<=n;i++) scanf("%d",&a[i]),s+=a[i];
	int count=0;
	for(int i=1;i<=n;i++)
	{
		if(s<=a[i]*m*4) count++;
	}
	if(count>=m) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
     
    	int main(){
          
          int A;
          int B;
          
          cin >> A >> B;
          
          if(B%A == 0){
            cout << A+B << endl;
          }
          else{
            cout << B-A << endl;
          }
        }

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  long long int n,a,b,i,j,s=51,t=0;
  long long int v[50],temp,sum=0,cnt=1;
  scanf("%lld %lld %lld",&n,&a,&b);
  for(i=0;i<n;i++)
    scanf("%lld",&v[i]);
  for(i=0;i<n-1;i++){
    for(j=i+1;j<n;j++){
      if(v[i]<v[j]){
        temp=v[i];
        v[i]=v[j];
        v[j]=temp;
      }
    }
  }
  for(i=0;i<a;i++)
    sum+=v[i];
  printf("%lf\n",(double)sum/(double)a);
  for(i=0;i<n;i++){
    if(s==51&&v[i]==v[a-1])
      s=i;
    if(v[i]==v[a-1])
      t=i;
  }
  sum=0;
  if(t==a-1)
    printf("1\n");
  else if(v[0]==v[a-1]){
    for(i=a;i<=b;i++){
      if(i<=t+1){
        cnt=1;
        for(j=0;j<i;j++){
          cnt*=(t+1-j);
          cnt/=j+1;
        }
        sum+=cnt;
      }
    }
    printf("%lld\n",sum);
  }
  else{
    for(j=s;j<a;j++){
      cnt*=(t+1-j);
      cnt/=(j-s+1);
    }
    sum+=cnt;
    printf("%lld\n",sum);
  }
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int n = sc.nextInt();
			if(n==0) break;
			
			int[][] map = new int[n+1][];
			int p;
			for(int i=0;i<=n;i++){
				p = sc.nextInt();
				map[i] = new int[p];
				for(int j=0;j<p;j++) map[i][j] = sc.nextInt();
			}
			
			int ans = -1;
			int count = 0;
			for(int i=0;i<n;i++){
				count = 0;
				for(int j=0;j<map[i].length;j++){
					for(int k=0;k<map[n].length;k++){
						if(map[n][k]==map[i][j]){
							count++;
							break;
						}
					}
				}
				if(count==map[n].length){
					if(ans==-1)	ans = i+1;
					else{
						ans = -1;
						break;
					}
				}
			}
			System.out.println(ans);
		}	
	}	
}

Measured memory_bytes: 63368
#include<stdio.h>
int a[10000];
main()
{
	int m,n,i,j,s=0,k,t=0;
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		s=s+a[i];
	}
	if(s%(4*m)==0) k=s/(4*m);
	else k=s/(4*m)+1;
	for(i=0;i<n;i++)
	{
		if(a[i]>=k) t++;
	}
	//printf("%d %d %d\n",s,k,t);
	if(t>=m) printf("Yes");
	else printf("No");
}

Measured memory_bytes: 128
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		// 整数の入力
		int n = sc.nextInt();
		int x = sc.nextInt();

		int ans = 0;
		int sum = 0;

		while(sum<=x&&ans<n){
			sum += sc.nextInt();
			ans++;
		}

		if(sum<=x)ans++;

		// 出力
		System.out.println(ans);
	}
}

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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    double T, X;
    cin >> T >> X;
    cout << OF64 << T / X << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int f(int a, int b) {
    return a*a*a*a*a - b*b*b*b*b;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int x;
    cin >> x;
    
    for (int i = 0; i <= 120; ++i) {
        for (int j = -120; j <= 120; ++j) {
            if (f(i, j) == x) {
                cout << i <<' ' << j << endl;
                goto endloop;
            }
        }
    }
    endloop:
    return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

int main(void)
{
	int r, g, b, n, count = 0;
	cin >> r >> g >> b >> n;
	for (int i = 0; i <= n / r; i++)
	{
		for (int j = 0; j <= n / g; j++)
		{
			if (n - i * r - j * g == 0) { count++; }
			else if (n - i * r - j * g > 0 && (n - i * r - j * g) % b == 0) { count++; }
		}
	}
	cout << count << endl;
	return 0;
}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var AB = ReadSplitInt();
            if (AB[0] % 3 == 0 || AB[1] % 3 == 0 || AB.Sum() % 3 == 0)
                Println("Possible");
            else
                Println("Impossible");
        }


        static List<long> ReadLines(long n)
        {
            var l = new List<long>();
            for (long i = 0; i < n; i++)
            {
                l.Add(ReadLong());
            }
            return l;
        }

        static void YesOrNo(bool e)
        {
            if (e) Println("Yes");
            else Println("No");
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
        static long Lcm(long a, long b) => a / Gcd(a, b) * b;

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}


Measured memory_bytes: 13268
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

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

    int k;
    cin >> k;

    int a, b;
    cin >> a >> b;

    bool f = false;
    for (int i = a; i <= b; i++) {
        if (i % k == 0) f = true;
    }

    if (f) cout << "OK" << endl;
    else cout << "NG" << endl;
    
}


Measured memory_bytes: 3612
import collections
n = int(input())
dic = collections.defaultdict(int)
ans = 0
if n < 357:
    print(0)
else:
    ls = ["357","375","537","573","735","753"]
    ls_next = []
    for i in range(len(ls)):
        if int(ls[i]) <= n:
            ls_next.append(ls[i])
    ls = ls_next
    ans += len(ls_next)
    for i in range(10):
        ls_next = []
        for j in range(len(ls)):
            for k in range(len(ls[0])):
                if int(ls[j][:k]+"3"+ls[j][k:]) <= n:
                    ls_next.append(ls[j][:k]+"3"+ls[j][k:])
                if int(ls[j][:k]+"5"+ls[j][k:]) <= n:
                    ls_next.append(ls[j][:k]+"5"+ls[j][k:])
                if int(ls[j][:k]+"7"+ls[j][k:]) <= n:
                    ls_next.append(ls[j][:k]+"7"+ls[j][k:])
        for j in range(len(ls_next)):
            dic[ls_next[j]] = 1
        ls_next = list(dic.keys())
        #print(ls_next)
        if len(ls_next) == 0:
            break

        ans += len(ls_next)
        ls = ls_next
        dic.clear()
    print(ans)


Measured memory_bytes: 15172
#include <bits/stdc++.h>
using namespace std;
 
//#define kk
#define int long long
#define FOR(a, b) for(int i=a; i<=b; i++)
#define REP(i, a, b) for(int i=a; i<=b; i++)
#define ff first
#define ss second
#define ll long long
#define inf 1000000000
#define pb push_back
#define mod 1000000007
 
const ll INF=1e18+5;
const int maxN=2e5+5;
typedef pair<int, int> pi;
 
pair<int, pi> arr[maxN];
int st[4*maxN];

int query(int si, int ss, int se, int qs, int qe){
	if(qs>se || qe<ss) return INT_MIN;
	
	if(qs<=ss && se<=qe) return st[si];
	
	int mid=ss+(se-ss)/2;
	
	int l=query(2*si, ss, mid, qs, qe);
	int r=query(2*si+1, mid+1, se, qs, qe);
	
	return max(l, r);
}

void update(int si, int ss, int se, int qi, int val){
	if(ss==se){
		st[si]=val;
		return;
	}
	
	int mid=ss+(se-ss)/2;
	
	if(qi<=mid) update(2*si, ss, mid, qi, val);
	else update(2*si+1, mid+1, se, qi, val);
	
	st[si]=max(st[2*si], st[2*si+1]);
}

void solve(){
	int n, x;
	cin>>n;
	
	FOR(1, n){
		cin>>x;
		arr[i].ff=x;
	}
	
	FOR(1, n){
		cin>>x;
		arr[i].ss.ff=x;
		arr[i].ss.ss=i;
	}
	
	
	sort(arr+1, arr+n+1, [&](pair<int, pi> a, pair<int, pi> b){
		return a.ff>b.ff;
		});
	
	
	FOR(1, n){
		int index=arr[i].ss.ss;
		int val=query(1, 1, n, index, n);
		val+=arr[i].ss.ff;
		update(1, 1, n, index, val);
	}
	
	int ans=-INF;
	
	FOR(1, n){
		ans=max(ans, st[i]);
	}
	
	cout<<ans<<endl;
}
 
 
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cout<<fixed<<setprecision(6);
	
	#ifdef kk
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	
	int T=1;
	//cin>>T;
	
	while(T--){		
		solve();
	}
}


Measured memory_bytes: 12396
/** 
If comrades that you trust gather around you, hope can take physical form and become visible. That’s what I believe.
*/
#include <bits/stdc++.h>
using namespace std;
/**
(▀̿Ĺ̯▀̿ ̿) (ง ͠° ͟ل͜ ͡°)ง
*/
const int MOD = 998244353;
const int N = 2e5 + 7;
using pi = pair<int, int>;
pi a[N];
int f[N], p[N];
int add(int a, int b) {
    a += b;
    if (a < MOD) a += MOD;
    return a % MOD;
}


auto solve() -> void {
    int n, k; cin >> n >> k;
    for (int i = 1; i <= k; ++i) cin >> a[i].first >> a[i].second;
    f[n] = 1; p[n] = 1;
    for (int i = n - 1; i >= 1; --i) {
        for (int j = 1; j <= k; ++j) {
            auto l = i + a[j].first;
            auto r = min(n, i + a[j].second);

            if (l > r) continue;
            f[i] = add(f[i], add(p[l], -p[r + 1]));
        }
        p[i] = add(p[i + 1], f[i]);
    }
    cout << f[1] << '\n';
}
auto main() -> int {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int tc = 1;
    while (tc--) {
        solve();
    }
    
    return 0;
}


Measured memory_bytes: 5168
/*
	AOJ 0501 'Data Conversion'
	http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0501
 */

import std.stdio;
import std.array;
import std.range;
import std.conv;
import std.string;
import std.algorithm;

void main()
{
	while(true)
	{
		int N = readln().chomp().to!int;

		if(N == 0) break;
		
		int[char] table;

		foreach(_; 0..N)
		{
			auto line = readln().split().map!("a.to!char");
			table[line[0]] = line[1];
		}

		int M = readln().chomp().to!int;
		string ans;

		foreach(_; 0..M)
		{
			char c = readln()[0];
			ans ~= (c in table ? table[c] : c);
		}

		writeln(ans);
	}
}

Measured memory_bytes: 2196
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

int main() {
    int n;
    cin >> n;
    vector<int> t(n);
    REP(i, n) cin >> t[i];
    int m;
    cin >> m;
    vector<int> p(m), x(m), ans(m);
    REP(i, m) {
        cin >> p[i] >> x[i];
        REP(j, n) {
            if(j == p[i] - 1)
                ans[i] += x[i];
            else
                ans[i] += t[j];
        }
    }
    REP(i, m) cout << ans[i] << endl;
}


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

using namespace std;

struct P{
  int s;
  int t;
  int c;
};

int ds[4] = {0, 1, 0, -1}, dt[4] = {1, 0, -1, 0};

int bfs(char ch[1001][1001], P st, P go, int w, int h)
{
  bool fa[1001][1001];
  fill(&fa[0][0], &fa[1000][1000],  true);
  P p, q;
  queue<P> que;
  que.push(st);
  int c = 0;
  while(!que.empty()){
    p = que.front();
    que.pop();

    if(p.s == go.s && p.t == go.t){
      c = p.c;
      break;
    }

    for(int i = 0; i < 4; i++){
      q.s = p.s + ds[i];
      q.t = p.t + dt[i];
      if(q.s >= 0 && q.s < h && q.t >= 0 && q.t < w){
	if(fa[q.s][q.t] && ch[q.s][q.t] != 'X'){
	  fa[q.s][q.t] = false;
	  q.c = p.c + 1;
	  que.push(q);
	}
      }
    }
  }

  return c;
}

int main()
{
  int w, h, n, c;
  char ch[1001][1001];
  P pa[10];

  while(cin>>h>>w>>n && h && w && n){
    for(int i = 0; i < h; i++){
      for(int j = 0; j < w; j++){
	cin >> ch[i][j];
	if(ch[i][j] == 'S'){
	  pa[0].s = i;
	  pa[0].t = j;
	  pa[0].c = 0;
	} else if(ch[i][j] != '.' && ch[i][j] != 'X'){
	  pa[(int)(ch[i][j]-'0')].s = i;
	  pa[(int)(ch[i][j]-'0')].t = j;
	  pa[(int)(ch[i][j]-'0')].c = 0;
	}
      }
    }
    c = 0;

    for(int i = 0; i < n; i++){
      c += bfs(ch, pa[i], pa[i+1], w, h);
    }

    cout << c << endl;
  }

  return 0;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP (i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back

using namespace std;

typedef long long ll;

// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

vector<pair<int, int>> edge[100000];
ll dist[100000];

void dfs(int cur, int prev, ll d) {
  dist[cur] = d;

  rep (i, edge[cur].size()) {
    if (prev != edge[cur][i].F) {
      dfs(edge[cur][i].F, cur, d + edge[cur][i].S);
    }
  }
}

int main() {
  int N;
  cin >> N;
  rep (i, N - 1) {
    int u, v, w;
    cin >> u >> v >> w;
    u--; v--;
    edge[u].eb(mp(v, w));
    edge[v].eb(mp(u, w));
  }

  dfs(0, 0, 0);

  rep (i, N) {
    if ((dist[i] - dist[0]) % 2) cout << '1' << endl;
    else cout << '0' << endl;
  }
}


Measured memory_bytes: 10240
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=100100;
inline long long read(){
    long long x=0,f=1;char c=getchar();
    while(c>'9'||c<'0'){if(c=='-') f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return f*x;
}
int val[maxn],tmp[maxn],n,num[maxn],m,x,ans[maxn];
long long k;double last[maxn];
int main(){
    n=read();
    for(register int i=1;i<=n;i++) 
        val[i]=read(),tmp[i]=i,ans[i]=i;
    m=read();k=read()*1ll;
    for(register int i=1;i<=m;i++)
        x=read(),swap(tmp[x],tmp[x+1]);
    for(;k;k>>=1){
        if(k&1){
            for(register int i=1;i<=n;i++)
                num[i]=ans[tmp[i]];
            for(register int i=1;i<=n;i++)
                ans[i]=num[i]; 
        }         
        for(register int i=1;i<=n;i++)
            num[i]=tmp[tmp[i]];
        for(register int i=1;i<=n;i++)
            tmp[i]=num[i];
    }
    for(register int i=1;i<=n;i++)
        last[i]=val[ans[i]]-val[ans[i]-1];
    for(register int i=1;i<=n;i++)
        printf("%.1lf\n",last[i]+=last[i-1]);
}

Measured memory_bytes: 3840
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

N = INT()
A = LIST()

A.sort()

ans = []
if N-1 <= bisect(A, 0):
	tmp = A[-1]
	for i in range(2, N+1):
		ans.append((tmp, A[-i]))
		tmp -= A[-i]
else:
	idx = max(0, bisect(A, 0)-1)
	tmp = A[idx]
	for i in range(idx+1, N-1):
		ans.append((tmp, A[i]))
		tmp -= A[i]

	ans.append((A[-1], tmp))
	tmp = A[-1] - tmp

	for i in range(idx-1, -1, -1):
		ans.append((tmp, A[i]))
		tmp -= A[i]

print(tmp)
for x in ans:
	print(*x)

	

Measured memory_bytes: 25288
<?php
list($k, $s) = ints();
$cnt = 0;
for ($x = 0; $x <= $k; ++$x) {
    for ($y = 0; $y <= min($s - $x, $k); ++$y) {
        $z = $s - $x - $y;
        if ($z >= 0 && $z <= $k) $cnt++;
    }
}
echo $cnt;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 5112
#include <iostream>
#include <cstdio> 
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N=110;
char a[N],b[N],c[N];
int main() {
    int n,ans=0;
    scanf("%d%s%s%s",&n,a,b,c);
    for(int i=0;i<n;i++) {
	if(a[i]==b[i]) {
	    if(b[i]!=c[i]) ++ans;
	}
	else if(a[i]==c[i]||b[i]==c[i]) ++ans;
	else ans+=2;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
int l[101];
int main() {
    int n, x;
    int ans = 1;
    scanf("%d%d", &n, &x);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &l[i]);
    }
    int current = 0;
    for (int i = 1; i <= n; ++i) {
        current += l[i];
        if (current > x) {
            break;
        }
        ++ans;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void){
  
  int input, choice, min[2000], price[2000], sum = 0;
  int tmp;
  
  scanf("%d%d", &input, &choice);
  
  for(int i = 0; i < input; i++){
    scanf("%d", &price[i]);
	for(int j = 0; j < i; j++){
      if(price[j] > price[i]){
        tmp = price[j];
        price[j] = price[i];
        price[i] = tmp;
      }
    }
  }
  
  /*for(int i = 0; i < input; i++){
    printf("%d ", price[i]);
  }
  printf("\n");*/
  
  for(int i = 0; i < choice; i++){
    sum += price[i];
  }
  
  printf("%d\n", sum);
  
  return 0;
}

Measured memory_bytes: 1740
n = int(input())
dp = [10**10]*(n+1)
dp[0] = 0
for i in range(1, n+1):
    tmp = 1
    while tmp <= i:
        dp[i] = min(dp[i], dp[i-tmp]+1)
        tmp *= 6
for i in range(1, n+1):    
    tmp = 1
    while tmp <= i:
        dp[i] = min(dp[i], dp[i-tmp]+1)
        tmp *= 9
print(dp[n])

Measured memory_bytes: 42844
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)

bool solve() {
  int H, W;
  cin >> H >> W;
  vector<int> cnt(26);
  rep(i, 0, H*W) {
    char c; cin >> c;
    cnt[c-'a']++;
  }
  int two = 0, one = (H * W) % 2;
  if(H % 2) two += W / 2 * 2;
  if(W % 2) two += H / 2 * 2;
  int four = H * W - two - one;
  rep(i, 0, 26) {
    while(four && cnt[i] >= 4) {
      cnt[i] -= 4; four -= 4;
    }
  }
  rep(i, 0, 26) {
    while(two && cnt[i] >= 2) {
      cnt[i] -= 2; two -= 2;
    }
  }
  rep(i, 0, 26) {
    while(one && cnt[i] >= 1) {
      cnt[i] -= 1; one -= 1;
    }
  }
  if(four || two || one) return false;
  return true;
}

int main() {
  cout << (solve() ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define n_p(v) next_permutation(v.begin(),v.end())
#define to_ll(b) stoll(b)
#define MOD 1000000007
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	string s; cin>>s;
	int n=s.size();
	string ans;
	for(int i=0;i<n;i+=2){
		ans.push_back(s[i]);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1e16
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b,ll m){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a) % m;  a = (a * a) % m;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 1e5 + 3;
ll i,n,m,a;
ll dp[N];
bool mark[N];
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>n>>m;
    rep(i,1,m + 1){
        cin>>a;
        mark[a] = 1;
    }
    dp[0] = 1;
    rep(i,1,n + 1) if(!mark[i]){
        dp[i] = dp[i - 1];
        if(i > 1)
            dp[i] = (dp[i] + dp[i - 2]) % mod;
    }
    cout<<dp[n];
    return 0;
}

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

int N, K;
int R, S, P;
string T;

int main() {
    cin >> N >> K >> R >> S >> P >> T;
    long long ans = 0;
    map<char, int> point;
    point['r'] = P; point['s'] = R; point['p'] = S;
    vector<bool> flag(N, false);
    for (int i = 0; i < N; i++) {
        char temp = T[i];
        if (i < K) {
            ans += point[temp];
            continue;
        }
        if (temp == T[i - K] && !flag[i - K]) {
            flag[i] = true;
        } else {
            ans += point[temp];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main()
{
  vector<int> n(4); REP(i, 4) cin >> n[i];
  sort(ALL(n));
  if (n == vector<int>{1, 4, 7, 9}) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256