akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Tarek
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        APoor solver = new APoor();
        solver.solve(1, in, out);
        out.close();
    }

    static class APoor {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int x = in.nextInt();
            int y = in.nextInt();
            if (x == y && n != y || (y == x && x != n) || (y == n && y != x) || (x == n && x != y)) out.println("Yes");
            else out.println("No");
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21460
a, b, h, m = gets.chomp.split(' ').map{|i| i.to_i }

a2 = a ** 2
b2 = b ** 2

tab = 2 * a * b

theta1 = 2.0 * Math::PI * (h + (m / 60.0)) / 12.0
theta2 = 2.0 * Math::PI * m / 60.0

theta = theta1 - theta2

cos = Math.cos(theta)

puts Math.sqrt(a2 + b2 - tab * cos)


Measured memory_bytes: 14736
#include <algorithm>
#include <cstdio>
#include <cstring>

const int N = 1000;
const int M = 5001;
const int INF = N * M;

int n, p[N], x[N], mi[N], dp[M];

bool solve()
{
    for (int u = n - 1; u >= 0; -- u) {
        memset(dp, 0, sizeof(dp));
        for (int v = u + 1; v < n; ++ v) {
            if (p[v] != u) {
                continue;
            }
            int a = x[v];
            int b = mi[v];
            for (int j = x[u]; j >= 0; -- j) {
                int tmp = INF;
                if (j >= a) {
                    tmp = std::min(tmp, dp[j - a] + b);
                }
                if (j >= b) {
                    tmp = std::min(tmp, dp[j - b] + a);
                }
                dp[j] = tmp;
            }
            if (dp[x[u]] == INF) {
                return false;
            }
        }
        mi[u] = dp[x[u]];
    }
    return true;
}

int main()
{
#ifdef LOCAL_JUDGE
    freopen("E.in", "r", stdin);
#endif
    while (scanf("%d", &n) == 1) {
        for (int i = 1; i < n; ++ i) {
            scanf("%d", p + i);
            p[i] --;
        }
        for (int i = 0; i < n; ++ i) {
            scanf("%d", x + i);
        }
        puts(solve() ? "POSSIBLE" : "IMPOSSIBLE");
    }
}

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

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

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

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

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()

int main() {
  LL A, B;
  char op;
  
  cin >> A >> op >> B;
  
  if(op == '+') cout << A+B << endl;
  else cout << A-B << endl;
  
  return 0;
}

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

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}


int main(){

    string n;
    cin >> n;

    int ans = 0;
    for(char s : n){
        ans += s - '0';
    }

    int c_sum = 0;
    for(int i = 0; i < (int)n.size(); i++){
        if(n[i] != '0'){
            int tmp = c_sum + (n[i] - '0' - 1);
            for(int j = i + 1; j < (int)n.size(); j++){
                tmp += 9;
            }
            ans = max(ans, tmp);
        }
        c_sum += n[i] - '0';
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
#include"iomanip"
#include"iostream"
#include"limits"
#include"cmath"
#include"vector"
#include"algorithm"
#include"list"
#include"queue"
#include"stack"
#include"set"
#include"unordered_set"
#include"map"
#include"unordered_map"
#include"string"
#include"cstring"
#include"assert.h"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define mp make_pair
#define pb push_back
#define mset(a,b) memset(a,b,sizeof(a))
typedef long long ll; 
typedef long double ld; 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    int maxn=1e5+5;
    ll a[maxn];
    for(int i=0;i<n;++i)
    {   
        cin>>a[i];
    }   
    sort(a,a+n);
    ll y=a[n-1];
    ll x=-1;
    for(int i=0;i<n;++i)
    {   
        if(abs((ld)y/2-a[i])<abs((ld)y/2-x))                                                                                                                                            
        {
            x=a[i];
        }
    }   
    cout<<y<<' '<<x<<'\n';
}

Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
#define maxn 300005
using namespace std;
int n,a[maxn],t[maxn],ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		t[i]=a[i];
	}
	sort(t+1,t+n+1);
	for(int i=1;i<=n;i++)
	{
		int tmp=lower_bound(t+1,t+n+1,a[i])-t;
		if((tmp+i)%2) ans++;
	}
	printf("%d\n",ans/2);
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

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

inline LL gl()
{
	LL f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int N = 200003, M = N << 1;

int n, m;
int a[N], b[N];
char s[N], t[N];

int main()
{
    scanf("%s", s + 1);
    scanf("%s", t + 1);
    for (int i = 1; i <= strlen(s + 1); i+=1)
        if (s[i] != t[i]) {puts("No"); return 0;}
    puts("Yes");
    return 0;
}

Measured memory_bytes: 3692
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#define INF 1000000000000000000LL

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n, m;
	scanf("%d %d", &n, &m);
	ll x[1000], y[1000], z[1000];
	for(int i=0; i<n; i++){
		scanf("%lld %lld %lld", &x[i], &y[i], &z[i]);
	}
	ll ans=-INF;
	ll s[8][1000]={};
	for(int i=0; i<8; i++){
		if((i&1)==0){
			for(int j=0; j<n; j++){
				s[i][j]+=x[j];
			}
		}else{
			for(int j=0; j<n; j++){
				s[i][j]+=(-x[j]);
			}
		}
		if(((i>>1)&1)==0){
			for(int j=0; j<n; j++){
				s[i][j]+=y[j];
			}
		}else{
			for(int j=0; j<n; j++){
				s[i][j]+=(-y[j]);
			}
		}
		if(((i>>2)&1)==0){
			for(int j=0; j<n; j++){
				s[i][j]+=z[j];
			}
		}else{
			for(int j=0; j<n; j++){
				s[i][j]+=(-z[j]);
			}
		}
		sort(s[i], s[i]+n, greater<ll>());
		ll ans1=0;
		for(int j=0; j<m; j++){
			ans1+=s[i][j];
		}
		if(ans1>ans) ans=ans1;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 384
from numpy.linalg import solve
import numpy

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

X, Y = map(int, input().split())
N = X + Y

left = [[1, 2], [2, 1]]
right = [X, Y]
s = solve(left, right)

if s[0] < 0 or s[1] < 0 or N % 3 != 0:
  print(0)
else:
  a = cmb(int(s[0]) + int(s[1]) , min(int(s[0]), int(s[1])))
  print(a % (10**9 + 7))

Measured memory_bytes: 56944
N, K = map(int, input().split())
P = list(map(int, input().split()))
P_E = list(((1 + P[i]) / 2) for i in range(N))

E = 0
prog = sum(P_E[0:K])
max = prog
for i in range(N - K):
    prog += P_E[i + K] - P_E[i]
    if prog > max:
        max = prog
    else:
        pass
    
print(max)



Measured memory_bytes: 25060
#include<stdio.h>
int M[100][100];
int main(void){
    int n,u,k,v;
    int i,j;

    scanf("%d",&n);

    for(i=0;i<n;i++){
	scanf("%d%d",&u,&k);
	u--;
	for(j=0;j<k;j++){
	    scanf("%d",&v);
	    v--;
	    M[u][v]=1;
	}
    }

    for(i=0;i<n;i++){
	for(j=0;j<n;j++){
	    if(j) printf(" ");
	    printf("%d",M[i][j]);
	}
	printf("\n");
    }

    return 0;
}

Measured memory_bytes: 636
//?????????DP??¨??°?????????????????????????????°?§£??????

#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;//cost, vertex
typedef pair<double, pii> piii;//cost, state, vertex

struct edge{
  int to, t;
  double cost;
};

int main(int argc, char *argv[]){
  int n, m, p, s, g;
  while(cin >> n >> m >> p >> s >> g, n){
    s--;g--;
    vector<int> t(n);
    for (int i = 0; i < n; i++) {
      cin >> t[i];
    }
    vector<vector<edge> > graph(m);
    for (int i = 0; i < p; i++) {
      int to, from;
      double cost;
      cin >> from >> to >> cost;
      from--;to--;
      for (int i = 0; i < n; i++) {
        graph[from].push_back((edge){to, i, cost/t[i]});
        graph[to].push_back((edge){from, i, cost/t[i]});
        //std::cout << graph[from][graph[from].size() - 1].cost << std::endl;
      }
    }
    priority_queue<piii, vector<piii>, greater<piii> > que;
    double dp[(1 << n)][m];
    for (int i = 0; i < (1 << n); i++) {
      for (int j = 0; j < m; j++) {
        dp[i][j] = 1e9;
      }
    }
    que.push(piii(0, pii(0, s)));
    dp[0][s] = 0;
    while(que.size()){
      int v = que.top().second.second;
      double c = que.top().first;
      int state = que.top().second.first;
      que.pop();
      for (int i = 0; i < graph[v].size(); i++) {
        edge e = graph[v][i];
        if(state & (1 << e.t))continue;
        int ns = state | (1 << e.t);
        if(dp[ns][e.to] > e.cost + dp[state][v]){
          dp[ns][e.to] = e.cost + dp[state][v];
          que.push(piii(dp[ns][e.to], pii(ns, e.to)));
        }
      }
    }
    double ans = 1e9;
    for (int i = 0; i < (1 << n); i++) {
      ans = min(ans, dp[i][g]);
    }
    if(ans == 1e9){
      std::cout << "Impossible" << std::endl;
    }else{
      printf("%.8lf\n", ans);
    }
  }
  return 0;
}

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

using namespace std;

int main(){
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int T[n+1];
	for(int i=1; i<=n; i++)
		cin >> T[i];
	int m;
	cin >> m;
	vector<pair<int, int>> P;
	for(int i=0, a, b; i<m; i++){
		cin >> a >> b;
		P.push_back({a, b});
	}

	for(auto x : P){
		int a = x.first, b = x.second;
		int sum = 0;
		sum += x.second;
		for(int i=1; i<=n; i++){
			if(i == x.first)	continue;
			sum += T[i];
		}
		cout << sum << endl;
	}
	return 0;
}


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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	vector<int> p(a), q(b), r(c);
	for (auto&& i : p) {
		cin >> i;
	}
	for (auto&& i : q) {
		cin >> i;
	}
	for (auto&& i : r) {
		cin >> i;
	}
	sort(rbegin(p), rend(p));
	sort(rbegin(q), rend(q));
	sort(rbegin(r), rend(r));
	priority_queue<int, vector<int>, greater<int>> pq;
	for (int i = 0; i < min(a, x); i++) {
		pq.push(p[i]);
	}
	for (int i = 0; i < min(b, y); i++) {
		pq.push(q[i]);
	}
	int now = 0;
	while (pq.size() < x + y || (now < c && pq.top() < r[now])) {
		if (pq.size() < x + y) {
			pq.push(r[now]);
		}
		else {
			pq.pop();
			pq.push(r[now]);
		}
		now++;
	}
	long long ans = 0;
	while (pq.size()) {
		ans += pq.top();
		pq.pop();
	}
	cout << ans << "\n";
}

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

using namespace std;

typedef long long ll;
typedef pair<ll,ll> pi;

ll N, M, P, Q, R, S, T, X, A, B, C, Y, Z, arr[200005], coord[200005];


multiset<int> intervals;
vector<pi> events;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> N >> Q;
	for (int i = 1; i <= N; ++i){
		cin >> S >> T >> X;
		coord[i] = X;
		events.push_back(pi(S-X,-i-Q));
		events.push_back(pi(T-1-X,i));
	}
	for (int i = 1; i <= Q; ++i){
		cin >> A;
		events.push_back(pi(A,-i));
	}
	sort(events.begin(),events.end());
	for (int i = 0; i < events.size(); ++i){
		if (events[i].second < -Q){
			intervals.insert(coord[-events[i].second-Q]);
		}
		else if (events[i].second < 0){
			if (intervals.empty()){
				arr[-events[i].second] = -1;
			}
			else arr[-events[i].second] = *intervals.begin();
			
		}
		else{
			intervals.erase(intervals.find(coord[events[i].second]));
		}
	}
	for (int i = 1; i <= Q; ++i){
		cout << arr[i] << '\n';
	}
}

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



Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] numbers = new int[n];
        int min = 2000000000;
        for (int i = 0; i < n; i++) {
            numbers[i] = sc.nextInt();
            min = Math.min(min, numbers[i]);
        }
        
        while (true) {
            boolean end = true;
            int nextMin = min;
            for (int i = 0; i < n; i++) {
                if (min == numbers[i]) continue;
                
                end = false;
                numbers[i] = numbers[i] % min;
                if (numbers[i] == 0) {
                    numbers[i] = min;
                }
                if (numbers[i] < min) {
                    nextMin = numbers[i];
                }
            }
            
            if (nextMin != min) {
                min = nextMin;
            }
            
            if (end) {
                System.out.println(min);
                break;
            }
        }
    }
}

Measured memory_bytes: 52596
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;
typedef long long ll;

int main() {

    int N, M, K;
    cin >> N >> M >> K;
    vector<int> A(N), B(M);
    rep(i,N) cin >> A[i];
    rep(i,M) cin >> B[i];

    vector<ll> sum_A(N + 1, 0), sum_B(M + 1, 0);
    rep(i,N) sum_A[i + 1] = sum_A[i] + A[i];
    rep(i,M) sum_B[i + 1] = sum_B[i] + B[i];

    int b = M;
    int ans = 0;
    rep(a,N+1) {
        while (b >= 0 && sum_A[a] + sum_B[b] > K) b--;
        if (b >= 0) ans = max(ans, a + b);
    }

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

Measured memory_bytes: 7960
import java.util.Scanner;

//Patrol
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int[] a = new int[101];
			while(true){
				int s = sc.nextInt();
				int t = sc.nextInt();
				if((s|t)==0)break;
				a[s]++;
				a[t]++;
			}
			int o = 0;
			for(int s:a)if(s%2==1)o++;
			System.out.println(o!=2?"NG":a[1]%2==1&&a[2]%2==1?"OK":"NG");
		}
	}
}

Measured memory_bytes: 12000
def main():
    a, b, c, k = map(int, input().split())
    res = 0
    if k-a >= 0:
        res += a
    else:
        res += k
    # if k-a-b >= 0:
    #     res += 0
    if k-a-b > 0:
        res += (k-a-b)*-1
    print(res)
                
if __name__ == '__main__':
    main()

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

#define FOR(i, j, k) for (int i = j; i < k; i++)
#define REP(i, j) FOR(i, 0, j)
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

int main() {
  int N, Z, W;
  cin >> N >> Z >> W;

  vll a(N);
  REP(i, N) cin >> a[i];

  ll ans = abs(a[N - 1] - W);

  if (N > 1)
    ans = max(ans, abs(a[N - 2] - a[N - 1]));

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    #define ss second
    #define ff first
    string a,b;
    int n,n2;
    int dp[3100][3100];
    int nex[3100][26];
    int o[26];
    int go(int idx,int idx2)
    {
        if(idx==n)
           {dp[idx][idx2]=0;return 0;}
        int &ret=dp[idx][idx2];
        if(ret!=-1)
            return ret;
        ret=0;
            if(idx2!=0){
            if(nex[idx2-1][a[idx]-'a']!=-1)

                ret=max(ret,1+go(idx+1,nex[idx2-1][a[idx]-'a']+1));
            }
            else
            {
                if(o[a[idx]-'a']!=-1)
                {
                ret=max(ret,1+go(idx+1,o[a[idx]-'a']+1));
                }
            }
        ret=max(ret,go(idx+1,idx2));
      //  cout<<idx<<' '<<idx2<<' '<<ret<<endl;
        return ret;
    }
    void build(int idx,int idx2)
    {
        if(idx==n)
            return;
        if(idx2!=0){
            if(nex[idx2-1][a[idx]-'a']!=-1&&dp[idx][idx2]==dp[idx+1][nex[idx2-1][a[idx]-'a']+1]+1)
                {
                    cout<<a[idx];
                build(idx+1,nex[idx2-1][a[idx]-'a']+1);
                return ;
            }
            }
            else
            {
                if(o[a[idx]-'a']!=-1&&dp[idx][idx2]==dp[idx+1][o[a[idx]-'a']+1]+1)
                {cout<<a[idx];
                build(idx+1,o[a[idx]-'a']+1);
                return;
                }
            }
        if(dp[idx][idx2]==dp[idx+1][idx2])
        {
            build(idx+1,idx2);
            return ;
        }
    }
    int main(){
        memset(dp,-1,sizeof dp);
        memset(nex,-1,sizeof nex);
        memset(o,-1,sizeof o);
        cin>>a>>b;
        n=a.size();
        n2=b.size();
        for(int i=n2-1;i>=0;i--)
        {
                for(int j=0;j<26;j++)
                    nex[i][j]=o[j];
                o[b[i]-'a']=i;
        }
        go(0,0);

        build(0,0);
    }


Measured memory_bytes: 38400
#include <stdio.h>

int main()
{
    int n, x;
    int i, j, k;
    int count;
    while(1) {
        scanf("%d %d", &n, &x);
        if(n == 0 && x == 0) {
            break;
        }
        count = 0;
        for(i = 1; i <= n-2; i++) {
            for(j = i+1; j <= n-1; j++) {
                for(k = j+1; k <= n; k++) {
                    if(i+j+k == x) {
                        count += 1;
                    }
                }
            }
        }
        printf("%d\n", count);
    }
    return 0;
}


Measured memory_bytes: 2100
#ifdef DBG1
  #define LOCAL
#endif

#ifdef LOCAL
  #define _GLIBCXX_DEBUG
#endif

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#ifdef DBG1
    #define dbg(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dbg(...)
#endif

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;

bool solve() {
  int n;
  if (scanf("%d", &n) != 1) { return false; }
  vector <int> a(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }

  ll _max = 2, _min = 2;
  for (int i = n - 1; i >= 0; --i) {
    _max += a[i] - 1 - _max % a[i];
    _min += (a[i] - _min % a[i]) % a[i];
    dbg("a %d min %lld max %lld\n", a[i], _min, _max);
    if (_min > _max) {
      printf("-1\n");
      return true;
    }
  }
  printf("%lld %lld\n", _min, _max);
  return true;
}

int main() {
  while (solve());
  return 0;
}

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

#define int long long

const int N=66;
const int A=50;
const int INF=0x3f3f3f3f3f3f3f3f;

int n,a[N],b[N];

bool nw[N][N];

bool G[N][N];
int mn[N][N];

int ans;

bool work()
{
	int i,j,t,mx(0);
	for(i=1;i<=n;++i)
	{
		for(j=0,t=INF;j<=A;++j)if(nw[i][j])
			t=min(t,mn[j][b[i]]);
		mx=max(mx,t);
	}
	if(mx)
	{
		ans+=1ll<<mx;
		for(i=1;i<=n;++i)
			for(j=0;j<=A;++j)if(nw[i][j])
				nw[i][j%mx]=true;
		return true;
	}
	else
		return false;
}

signed main()
{
	scanf("%lld",&n);
	int i,j,k;
	for(i=1;i<=n;++i)
	{
		scanf("%lld",a+i);
		nw[i][a[i]]=true;
	}
	for(i=1;i<=n;++i)
		scanf("%lld",b+i);
	memset(mn,0x3f,sizeof mn);
	for(i=0;i<=A;++i)
		for(j=0,G[i][i]=1,mn[i][i]=0;j<i;++j)
			for(k=1;k<=i;++k)if(G[i%k][j])
			{
				G[i][j]=true;
				mn[i][j]=k;
				break;
			}
	for(i=1;i<=n;++i)
		if(!G[a[i]][b[i]])
		{
			printf("-1\n");
			return 0;
		}
	while(work());
	printf("%lld\n",ans);
	return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S;
  int K;
  cin >> S >> K;
  vector<vector<vector<int>>> dp(S.size() + 1,
                                 vector<vector<int>>(2, vector<int>(K + 2, 0)));
  dp[0][0][0] = 1;
  for (int i = 0; i < (int)S.size(); i++) {
    int c = S[i] - '0';
    for (int j = 0; j < 2; j++) {
      for (int k = 0; k < K + 1; k++) {
        for (int nc = 0; nc < 10; nc++) {
          if (nc > c && j == 0) continue;
          int nj = nc < c ? 1 : j;
          int nk = nc != 0 ? k + 1 : k;
          dp[i + 1][nj][nk] += dp[i][j][k];
        }
      }
    }
  }
  cout << dp[S.size()][0][K] + dp[S.size()][1][K] << '\n';
  return 0;
}


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

int main() {
    string s;
    cin >> s;
    if (s == "Sunny") puts("Cloudy");
    else if (s == "Cloudy") puts("Rainy");
    else puts("Sunny");
    return 0;
}

Measured memory_bytes: 256
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int n;
int k;
string str;
int main(){
	while(cin>>n>>k,n||k){
		map<string,int> ma;
		vector<string> num;
		rep(i,n){
			string d;
			cin>>d;
			num.push_back(d);
		}
		sort(num.begin(),num.end());
		for(int i = 0;i <1<<n;i++){//全探索最強!!ビットで集合表せるのすごくね?
			int cnt = 0;
			for(int j = 0;j < n;j++){
				if(i&(1<<j))cnt++;
			}
			if(cnt!=k)
				continue;
			vector<string> w;
			for(int j = 0;j < n;j++){
				if(i&(1<<j))
					w.push_back(num[j]);
			}
			do{
				string check;
				for(int j = 0;j < w.size();j++){
					check +=w[j];
				}
				ma[check] +=1;
			}while(next_permutation(w.begin(),w.end()));
			w.clear();
		}
		cout <<ma.size()<<endl;
		ma.clear();
		num.clear();
	}
	return 0;
}

Measured memory_bytes: 1504
#!/usr/bin/env python3
import sys


def solve(N: int, W: int, w: "List[int]", v: "List[int]"):
    total_value = sum(v)
    dp = [[float("inf")] * (total_value + 1) for _ in range(N+1)]
    for i in range(N+1):
        dp[i][0] = 0

    for i in range(N):
        for j in range(1, total_value+1):
            if j - v[i] >= 0:
                dp[i+1][j] = min(
                    dp[i][j],
                    dp[i][j-v[i]] + w[i]
                )
            else:
                dp[i+1][j] = dp[i][j]

    weight = 0
    res = 0
    for j in range(total_value+1):
        if dp[-1][j] <= W:
            weight = dp[-1][j]
            res = j
    print(res)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    w = [int()] * (N)  # type: "List[int]"
    v = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        w[i] = int(next(tokens))
        v[i] = int(next(tokens))
    solve(N, W, w, v)


if __name__ == '__main__':
    main()


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

const int N = 15, inf = 0x3f3f3f3f;

int n, m, e[N][1 << N], dp[N][1 << N], sum[1 << N], mask;

#define ctz __builtin_ctz
#define for_bit(i, s) for (int _##i = s, i = ctz(_##i); _##i; i = ctz(_##i = _##i & _##i - 1))

void down(int &x, int y) { x = std::min(x, y); }
int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> n >> m, mask = ~(-1 << n);
	for (int i = 0, x, y, z; i < m; ++i)
		std::cin >> x >> y >> z, --x, --y, e[x][1 << y] = e[y][1 << x] = z;
	for (int i = 0; i < n; ++i)
		for (int j = 1; j < 1 << n; ++j)
			e[i][j] = e[i][j & -j] + e[i][j & j - 1];
	std::memset(dp, 0x3f, sizeof dp), dp[0][1] = 0;
	for (int s = 0; s <= mask; ++s)
		for_bit(i, s) if (dp[i][s] != inf) {
			int v = dp[i][s], c = mask ^ s;
			if (i != n - 1) for_bit(j, c) if (e[i][1 << j]) down(dp[j][s | 1 << j], v + e[j][s ^ 1 << i]);
			for (int p = c & c - 1; ; p = p - 1 & c) {
				int q = c ^ p; sum[q] = sum[q & q - 1] + e[ctz(q)][s ^ 1 << i];
				if (!p) break;
			}
			for (int p = c; p; p = p - 1 & c) down(dp[i][s | p], v + sum[p]);
		}
	std::cout << dp[n - 1][mask] << '\n';
	return 0;
}

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

signed main()
{
    string s; cin >> s;
    int y = stoi(s.substr(0,4));
    int m = stoi(s.substr(5,2));

    if (y < 2019){
        puts("Heisei");
    } else if (y > 2019){
        puts("TBD");
    } else { // y==2019
        if(m <= 4){
            puts("Heisei");
        } else {
            puts("TBD");
        }
    }

    return 0;
}


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

int main() {
	int x = 0, max = 0, n;
	string s;
	cin >> n >> s;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'I') {
			x++;
		} else {
			x--;
		}
		if (max < x)max = x;
	}
	cout << max << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val cnt = readLine()!!.toInt()
    var nums = readLine()!!.split(" ").subList(0, cnt - 1).map { it.toInt() }
    var ope = 0
    while (0 == nums.count { it.and(1) == 1 }) {
        ope++
        nums = nums.map { it.shr(1) }
    }
    print(ope)
}


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

int64_t nCr(int64_t n, int64_t r)
{
  int64_t res = 1;
  for (int k = 1; k <= r; k++)
  {
    res = res * (n - k + 1) / k;
  }
  return res;
}

int main()
{
  int64_t N, P, a, odds = 0, evens = 0, res = 0;
  cin >> N >> P;
  for (int i = 0; i < N; i++)
  {
    cin >> a;
    (a % 2) ? odds++ : evens++;
  }
  if (P) // oddsから奇数個選択。evensの選択は任意
  {
    for (int i = 1; i <= odds; i += 2)
    {
      res += nCr(odds, i) * pow(2, evens);
    }
  }
  else // oddsから偶数個選択。evensの選択は任意
  {
    for (int i = 0; i <= odds; i += 2)
    {
      res += nCr(odds, i) * pow(2, evens);
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
int main() {
  int n,k,ans;
  cin >> n >> k;
  ans = 0;
  rep(i,n){
    int x,l;
    cin >> x;
    l = min(x, k-x);
    ans += l*2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n], dif[n];
  for(int i=0; i<n; i++){
    cin >> a[i];
    if(i==0)
      dif[0] = a[0];
    else{
      dif[i] = a[i]- a[i-1];
    }
  }
  int ans=0;
  for(int i=0; i<n; i++){
    if(dif[i]>0){
      ans += dif[i];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3620
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

N,Q = map(int,input().split())
# 1-indexed union-find
# parent(親)
par = [i for i in range(N+1)]
# rank(深さ)
rank = [0]*(N+1)
# 同グループの頂点数
size = [1]*(N+1)

# 木の根を求める
def root(x):
    if par[x] == x:             # 根の時
        return x
    else:
        par[x] = root(par[x])   # 経路圧縮
        return par[x]

# xとyの属する集合を併合(ランク有)
def unite(x,y):
    x = root(x)
    y = root(y)
    if x == y:
        return
    if rank[x] < rank[y]:
        par[x] = y              # xの親をyに
        size[y] += size[x]      # yの頂点数+=xの頂点数
    else:
        par[y] = x              # yの親をxに
        size[x] += size[y]      # xの頂点数+=yの頂点数
        if rank[x] == rank[y]:
            rank[x] += 1
 
for i in range(Q):
    p,a,b = map(int,input().split())
    if p == 0:
        unite(a,b)
    else:
        print(1 if root(a) == root(b) else 0)

Measured memory_bytes: 84840
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int Y = sc.nextInt();
        int countA = Integer.MAX_VALUE;
        if (X <= Y) countA = Math.abs(Y-X);
        int countB = Integer.MAX_VALUE;
        if (-X <= Y) countB = Math.abs(Y+X)+1;
        int countC = Integer.MAX_VALUE;
        if (X <= -Y) countC = Math.abs(-Y-X)+1;
        int countD = Integer.MAX_VALUE;
        if (-X <= -Y) countD = Math.abs(-Y+X)+2;
        System.out.println(Math.min(Math.min(countA, countB), Math.min(countC, countD))); 
    }
    
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,n) for(int i=(int)(n-1);i>=0;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define print(x) cout << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<int, P> PIP;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;
typedef set<int> S;

#define INF INT_MAX/3
#define MAX_N 1000000001


int main(){
    cin.sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;

    ll num = 0;
    rep(i, n - 1) {
        num = num + num / (k - 1) + 1;
    }
    cout << num << endl;

    return 0;
}

Measured memory_bytes: 3172
const main = (str) => {
    const x = +str;
    let p = 100
    let count = 0;
    while(true){
        count++;
        p += Math.floor(p/100);
        if(p >= x){
            console.log(count);
            break;
        }
    }
};

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29544
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N;
int64_t V[100000];
int64_t C[100000];

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N;
	for (size_t i = 0; i < N; i++)
	{
		in >> V[i];
	}
	for (size_t i = 0; i < N; i++)
	{
		in >> C[i];
	}
	int64_t sum = 0;
	for (size_t i = 0; i < N; i++)
	{
		sum += std::max<int64_t>( V[i] - C[i],0);
	}
	out << sum << endl;

	return 0;
}
#endif


Measured memory_bytes: 256
<?php
$n=trim(fgets(STDIN));
$a=explode(" ",trim(fgets(STDIN)));
$ans=30;
$i=0;
while($i<$n){
    $c=$a[$i];
    $ans_i=0;
    while($c%2==0){
        ++$ans_i;
        $c/=2;
    }
    $ans=min($ans,$ans_i);
    /*if($ans==0){
        break;
    }*/
    ++$i;
}
echo $ans;

Measured memory_bytes: 4856
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <istream>
#include <ostream>

#include <cstdlib>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define rep(i,n) for(ll i=0; i < (n); ++i)
#define rrep(i,n) for(ll i=((n)-1); i >= 0; --i)

#define OPLT(T) bool operator<(const T & lop_, const T & rop_)
#define OPEQ(T) bool operator==(const T & lop_, const T & rop_)

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

istream& operator>>(istream& istr, __float128& obj) { double d; istr >> d; obj = d; return istr; };
ostream& operator<<(ostream& ostr, __float128& obj) { ostr << static_cast<double>(obj); return ostr; };

int main() {
	string s;
	cin >> s;
	int a = 0;
	if(s[0] == s[(int)s.size()-1])
		a = 1;
	if((a + s.size()) % 2) {
		cout << "First" << endl;
	}
	else {
		cout << "Second" << endl;
	}
	return 0;
}


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

typedef pair<int, int> PII;

const int MAX_N = 210;
const int MAX_H = 50;
const int INF = 1e9;

struct edge{
  int to, cost, hour, r;
  edge(int to, int cost, int hour, int r):
    to(to), cost(cost), hour(hour), r(r){}
};

struct State{
  int v, hour, cost;
  State(int v, int hour, int cost):
    v(v), hour(hour), cost(cost){}
};

int N, M, H, K;
vector<edge> G[MAX_N];
vector<PII> V;
int S, T, P;
int money[(1<<12)];
int dp[MAX_H][MAX_N];

void init(){
  for(int i = 0 ; i < MAX_N ; i++) G[i].clear();
  V.clear();
  fill(money, money+(1<<12), INF);
}

int solve(int bit){
  for(int i = 0 ; i < MAX_H ; i++)
    for(int j = 0 ; j < MAX_N ; j++) dp[i][j] = INF;

  queue<State> que;
  que.push(State(S, 0, 0));  

  dp[0][S] = 0;
  
  while(!que.empty()){
    State q = que.front(); que.pop();
    
    int v = q.v;
    for(int i = 0 ; i < (int)G[v].size() ; i++){

      int r = G[v][i].r;
      int nexv = G[v][i].to;
      int nexh = q.hour + G[v][i].hour;      
      int nexc;
      
      nexc = q.cost + G[v][i].cost;
      if((bit>>r) & 1) nexc = q.cost;
      
      if(dp[nexh][nexv] > nexc && nexh <= H){     
	dp[nexh][nexv] = nexc;
	
	que.push(State(nexv, nexh, nexc));
      }
    }    
  }
  int ret = INF;
  for(int i = 0 ; i <= 24 ; i++) ret = min(ret, dp[i][T]);
  return ret;
}

void rec(int bit, int cost){
  if(money[bit] <= cost) return;
  money[bit] = cost;
  for(int i = 0 ; i < (int)V.size() ; i++){
    int t = bit | V[i].first;
    if(t == bit) continue;
    rec(t, cost + V[i].second);
  }
}

int main(){
  while(cin >> N >> M >> H >> K, N|M|H|K){
    init();
    
    int from, to, cost, hour, r;
    for(int i = 0 ; i < M ; i++){
      cin >> from >> to >> cost >> hour >> r;
      from--, to--, r--;
      G[from].push_back(edge(to, cost, hour, r));
      G[to].push_back(edge(from, cost, hour, r));
    }
    
    cin >> S >> T;
    S--, T--;
    cin >> P;
    
    for(int i = 0 ; i < P ; i++){
      int l, d;
      cin >> l >> d;
      int k;
      int bit = 0;
      for(int j = 0 ; j < l ; j++){
	cin >> k;
	k--;
	bit += (1<<k);
      }      
      V.push_back(PII(bit, d));
    }
    
    rec(0, 0);
    
    int ans = INF;
    for(int i = 0 ; i < (1<<K) ; i++){
      ans = min(ans, solve(i) + money[i]);
    }
    
    cout << (ans == INF ? -1 : ans) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1364
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {

//    	File file = new File("test.txt");
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);
    	String a = sc.next();
    	String b = sc.next();
    	sc.close();
    	String A = "";
    	String B = "";
    	for(int i = 0; i < Integer.parseInt(b); i++){
    		A = A.concat(a);
    	}
    	for(int i = 0; i < Integer.parseInt(a); i++){
    		B = B.concat(b);
    	}
    	if(0 <= A.compareTo(B)){
    		System.out.println(B);
    	}else{
    		System.out.println(A);
    	}


    }
}

Measured memory_bytes: 21844
function Main(input) {
	input = input.split("\n");
	const input1 = input[0].split(" ")
	const A = parseInt(input1[0])
	const B = parseInt(input1[1])
	const C = parseInt(input1[2])
	const result = A-B > C ? 0 : C - (A-B)
	console.log(result)

}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#ifdef LOCAL
//#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>
#define endl '\n'

using namespace std;

int main() {
#ifdef LOCAL
    freopen("in", "r", stdin);
    //    freopen("out", "w", stdout);
#endif
    ios::sync_with_stdio(0), cin.tie(0);
    int n, x;
    cin >> n >> x;
    vector<int> m(n);
    for (int i = 0; i < n; i++)
        cin >> m[i];
    sort(m.begin(), m.end());
    
    int ans = 0;
    for (auto& i : m) {
        ++ans;
        x -= i;
    }
    
    while (x >= m[0]) {
        x -= m[0];
        ++ans;
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  int ans=1;
  string A="remaerd",B="resare",C="maerd",D="esare";
  reverse(S.begin(),S.end());
  while(S.size()>0){
    int L=S.size();
    if(S.substr(0,7)==A) S.erase(0,7);
    else if(S.substr(0,6)==B) S.erase(0,6);
    else if(S.substr(0,5)==C) S.erase(0,5);
    else if(S.substr(0,5)==D) S.erase(0,5);
    else{
      ans=0;
      break;
    }
  }
  cout<<(ans?"YES":"NO")<<endl;
}

Measured memory_bytes: 512
import sys
from itertools import accumulate

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


def main():
    N, *A = map(int, read().split())

    csum = [0]
    csum.extend(accumulate(A))

    ans = INF
    for i in range(1, N):
        tmp = abs(csum[i] - (csum[N] - csum[i]))
        if ans > tmp:
            ans = tmp

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 106064
#include <algorithm>
#include <iostream>

int main()
{
    std::string s;
    std::cin >> s;

    std::reverse(std::begin(s), std::end(s));

    const int mod = 1000000007;

    long long reminds[13] = { 1 };
    int position = 1;
    for (auto num : s) {
        long long new_reminds[13] = { 0 };
        if (num == '?') {
            for (int i = 0; i < 10; i++) {
                for (int k = 0; k < 13; k++) {
                    new_reminds[(i * position + k) % 13] += reminds[k];
                    new_reminds[(i * position + k) % 13] %= mod;
                }
            }
        } else {
            int i = num - '0';
            for (int k = 0; k < 13; k++) {
                new_reminds[(i * position + k) % 13] += reminds[k];
                new_reminds[(i * position + k) % 13] %= mod;
            }
        }
        position *= 10;
        position %= 13;

        std::copy(std::begin(new_reminds), std::end(new_reminds), reminds);
    }

    std::cout << reminds[5] << std::endl;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define inf (int)(3e18)
#define P pair<int,int>
#define mod (int)(1e9+7)
#define mod2 998244353

template<class T> inline void chmin(T &a, T b) {
	a = min(a, b);
}
template<class T> inline void chmax(T &a, T b) {
	a = max(a, b);
}

int N,K,C;
string S;
int pre[200005],ba[200005];
int pre2[200005],ba2[200005];
signed main(){
	cin>>N>>K>>C>>S;
	int now=0,cnt=0;
	rep(i,N){
		if(S[i]=='o'&&now<=i){
			now=i+C+1;cnt++;
		}
		pre[i]=cnt;
		pre2[i]=now;
	}
	now=N-1,cnt=0;
	for(int i=N-1;i>=0;i--){
		if(S[i]=='o'&&now>=i){
			now=i-C-1;cnt++;
		}
		ba[i]=cnt;
		ba2[i]=now;
	}
	rep(i,N){
		if(S[i]=='o'){
			int cnt=0;
			if(i)cnt=pre[i-1]+ba[max(pre2[i-1],i+1)];
			else cnt=ba[i+1];
			if(cnt<K)cout<<i+1<<endl;
		}
	}
}


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

int main()
{
    int m,f,r;
    for( ; ; )
    {
        cin >> m >> f >> r;
        if(m==-1 && f==-1 && r==-1)
        {
            break;
        }
        else if(m==-1 || f==-1)
        {
            cout << "F" << endl;
        }
        else if(m+f>=80)
        {
            cout << "A" << endl;
        }
        else if(m+f>=65)
        {
            cout << "B" << endl;
        }
        else if(m+f>=50)
        {
            cout << "C" << endl;
        }
        else if(m+f>=30)
        {
            if(r>=50)
            {
                cout << "C" << endl;
            }
            else
            {
                cout << "D" << endl;
            }
        }
        else
        {
            cout << "F" << endl;
        }
    }
}


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

int main(){

  int n,a=0,b=0;
  string s1,s2;

  cin>>n;
  for(int i=0;i<n;i++){
    cin>>s1>>s2;
    if ( s1 == s2 ){
      a+=1;
      b+=1;
    }
    else if ( s1 < s2 ) b+=3;
    else if ( s1 > s2 ) a+=3;

  }

  cout<<a<<" "<<b<<endl;


  return 0;
}



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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }

using namespace std;

int main(int argc, char** argv) 
{
#ifdef HOME
	if(IsDebuggerPresent())
	{
		freopen("../in.txt", "rb", stdin);
		freopen("../out.txt", "wb", stdout);
	}
#endif
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(10);
	cout << fixed;
	int N, res = 0;
	cin >> N;
	vector<int> A(N);
	for (auto& ai : A)
		cin >> ai;
	forn(i, N)
	{
		if (i % 2 == 0 && A[i] % 2)
			++res;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>
#include <stdlib.h>
int main(void){
	int n;
	scanf("%d",&n);
	int a[n+2];
	int i;
	int max=0;
	a[0] 	= 0;
	a[n+1]	= 0;
	for(i=1;i<n+1;i++){
		scanf("%d",&a[i]);
		max += abs(a[i-1]-a[i]);
	}
	max += abs(a[n+1] -a[n]);
	for(i=1;i<n+1;i++){
		int ans = max;
		ans = ans + abs(a[i-1]-a[i+1]) - (abs((a[i-1]-a[i])) + abs(a[i]-a[i+1]));
		printf("%d\n",ans);
	}
	return 0;
}

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

int main (){
	int n, x;
	cin >> n >> x;
	int m[114514];
	//int l=x;
	for (int i = 0; i < n; i++) {
		cin >> m[i];
		x -= m[i];
	}
	sort(m, m+n);
	cout << n + x/m[0] << endl;
	return 0;
}



Measured memory_bytes: 256