akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>

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

    int count[2] = {0};
    for(size_t i = 0; i < S.size(); i++) {
        count[S[i] - '0']++;
    }

    std::cout << std::min(count[0], count[1]) * 2 << std::endl;

    return 0;   
}


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

#define ff              first
#define fo(i,n)         for(i=0;i<n;i++)
#define Fo(i,k,n)       for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define deb(x)          cout << #x << "=" << x << endl
#define deb2(x, y)      cout << #x << "=" << x << "," << #y << "=" << y << endl
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const int N = 3e5, M = N;
//=======================

vi g[N];

void solve() {
	int i, j, n, m;
	string t;
	cin >> t;
	int d = 0;
	fo(i, t.length())
	{
		d += t[i] - '0';
	}
	string s = (d % 9 == 0) ? "Yes\n" : "No\n";
	cout << s << "\n";
}

int32_t main()
{
	FIO;
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	solve();
	return 0;
}

void ipgraph(int n, int m) {
	int i, u, v;
	while (m--) {
		cin >> u >> v;
		u--, v--;
		g[u].pb(v);
		g[v].pb(u);
	}
}

void dfs(int u, int par) {
	for (int v : g[u]) {
		if (v == par) continue;
		dfs(v, u);
	}
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<long long, int> pli;

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

ll mod = 1000000007;

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

  ll t1,t2,a1,a2,b1,b2;
  cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
  ll d1 = t1 * (a1 - b1);
  ll d2 = t2 * (a2 - b2);
  if(d1 > 0 && d1 + d2 > 0)cout << 0 << endl;
  else if(d1 < 0 && d1 + d2 < 0)cout << 0 << endl;
  else if(d1 + d2 == 0)cout << "infinity" << endl;
  else{
    ll sum = d1 + d2;
    if(d2 < 0){
      d2 *= -1;
      sum *= -1;
    }
    ll n =  d2 / sum;
    ll ret = n * 2 - 1;
    if(d2 % sum == 0)ret--;
    cout << max(0ll,ret) << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ul unsigned long long int
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define pll pair<long long int, long long int>
#define pii pair<int, int>
#define vii vector<int>
#define vll vector<long long int>
#define sii set<int>
#define sll set<long long int>
#define usi unordered_set<int, custom_hash>
#define usl unordered_set<long long int, custom_hash>
#define mii map<int, int>
#define mll map<long long int, long long int>
#define umi unordered_map<int, int, custom_hash>
#define uml unordered_map<long long int, long long int, custom_hash>
#define ski stack<int>
#define skl stack<long long int>
#define all(v) v.begin(),v.end()
using namespace std;
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c`
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};


const int N=1e5+1;
const int mod=998244353;
ll a[N], b[N], c[N];

ll dp[101][N];

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
#endif
    
    ll n, w;
    cin>>n>>w;
    for(int i=0;i<=n;++i){
        for(int j=0;j<=N;++j){
            dp[i][j]=INT_MAX;
        }
    }
    int ans=0;
    dp[0][0]=0;
    for(int i=1;i<=n;++i){
        int u, v;   cin>>u>>v;
        for(int j=0;j<N;++j){
            if(j>=v){
                dp[i][j]=min(dp[i][j], dp[i-1][j-v]+u);
            }
            dp[i][j]=min(dp[i][j], dp[i-1][j]);
            if(dp[i][j]<=w){
                ans=max(ans, j);
            }
        }
    }

    cout<<ans<<endl;

}

Measured memory_bytes: 80128
import java.util.*;
import java.io.PrintWriter;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		long[] dp=new long[n];
		int[] h=new int[n];
		int[] a=new int[n];
		for(int i=0; i<n; i++){
			h[i]=sc.nextInt()-1;
		}
		for(int i=0; i<n; i++){
			a[i]=sc.nextInt();
		}
		SegTree st=new SegTree(n);
		long ans=0;
		for(int i=0; i<n; i++){
			dp[i]=a[i]+st.query(0,h[i]+1);
			ans=Math.max(ans,dp[i]);
			st.set(h[i],dp[i]);
		}
		
		System.out.println(ans);
	}
	static class SegTree{
		int n=1;
		long[] v;
		
		public SegTree(int n) {
			while(this.n<n)this.n*=2;
			v=new long[2*this.n-1];
		}
		
		void set(int k,long val) {
			k+=n-1;
			v[k]=val;
			while(k>0) {
				k=(k-1)/2;
				v[k]=Math.max(v[2*k+1],v[2*k+2]);
			}
		}
		//bをプラス1
		long query(int a,int b) {
			return query(0,n,a,b,0);
		}
		
		long query(int l,int r,int a,int b,int k) {
			if(r<=a||b<=l)return 0;
			else if(a<=l&&r<=b)return v[k];
			else {
				long vl=query(l,(l+r)/2,a,b,2*k+1);
				long vr=query((l+r)/2,r,a,b,2*k+2);
				return Math.max(vl,vr);
			}
		}
	}
}

Measured memory_bytes: 114084
#include <iostream>
#include <string>
using namespace std;
using Int = long long;
int main()
{
    string s; cin >> s;
    int A[4];
    for (int i = 0; i < 4; i++) A[i] = s[i] - '0';
    for (int i = 0; i < 8; i++) {
        int ans = A[0];
        for (int j = 1; j < 4; j++) {
            ans += i & (1 << (j-1)) ? (+1) * A[j] : (-1) * A[j];
        }
        if (ans == 7) {
            cout << A[0];
            for (int j = 1; j < 4; j++) {
                cout << (i & (1 << (j-1)) ? "+" : "-");
                cout << A[j];
            }
            cout << "=7" << endl;
            break;
        }
    }
    return 0;
}

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

int main(){

    int n;
    int cnt=0;
    cin>>n;
    vector<int> d(n);
    for(int i=0;i<n;i++) cin>>d.at(i);

    sort(d.begin(),d.end());
    reverse(d.begin(),d.end());

    for(int i=0;i<n-1;i++){

        if(d.at(i)>d.at(i+1)) cnt++;

    }
    
    cout<<cnt+1<<endl;







    return 0;
}

Measured memory_bytes: 256
import itertools
a = []
for _ in range(5):
  a.append(int(input()))
k = int(input())
a = a[::-1]
combs = itertools.combinations(a, 2)
for (n, m) in combs:
    if n - m > k:
        print(':(')
        exit()
print('Yay!')

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

using namespace std;

int main() {
    int n;
    cin >> n;
    long s[n];
    for (auto &si:s) cin >> si;
    long dp, best=0;
    for (int c=1; c<n; c++) {
        dp = 0;
        for (int k=1; k<=(n-1)/c-1; k++) {
            if ((n-1) % c == 0 && n-1 <= 2*k*c) break;
            dp += s[n-k*c-1] + s[k*c];
            best = max(best, dp);
            // cerr << c << ' ' << k << ' ' << dp << '\n';
        }
    } 
    cout << best << '\n';
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N,K;
	cin >> N >> K;
    vector<int>h(N);
    int ans = 0;
    for(int i = 0; i < N; i++) {
        cin >> h[i];
        if(h[i] >= K) {
            ans++;
        }
    } 
    cout << ans << endl;
}


Measured memory_bytes: 3612
#pragma GCC optimize("-Ofast","-funroll-all-loops")
#include<bits/stdc++.h>
//#define int long long
using namespace std;
int a,b,v,w,t;
signed main(){
	cin>>a>>v>>b>>w>>t;
	if(w>=v)	puts("NO");
	else	if(abs(a-b)<=1LL*t*(v-w))	puts("YES");
	else	puts("NO");
	return 0;
}


Measured memory_bytes: 3624
from collections import deque

def bfs(maze, visited, s, h, w):
  queue = deque(s)
  #　返り値
  va = 0
  while queue:
    y,x = queue.popleft()
    for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
      new_y, new_x = y+j, x+k
      if new_x < 0 or new_x >= w or new_y < 0 or new_y >=h :
        continue
      if maze[new_y][new_x] == "." and visited[new_y][new_x] == -1:
        #　移動回数の計算
        visited[new_y][new_x] = visited[y][x] + 1
        va = max(va,visited[new_y][new_x])
        queue.append([new_y, new_x])
  return va
############

h,w = map(int,input().split())

maze = [['' for j in range(w)] for i in range(h)]
for i in range(h) :
  m1 = input()
  for j in range(w) :
    maze[i][j] = m1[j]

visited = [[-1]*(w) for _ in range(h)]
ans = []
s = []
s_append = s.append
for sy in range(h) :
  for sx in range(w):
    if maze[sy][sx] == '#' :
      s_append([sy,sx])
      maze[sy][sx] = '.'
      visited[sy][sx] = 0

print(bfs(maze, visited, s, h, w))

Measured memory_bytes: 158064
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cout << i << "\n"

// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;

//とりあえず1-indexedでつくったBIT
template <class T>
struct BinaryIndexedTree {
  T n;
  std::vector<T> bit;

  BinaryIndexedTree(T i) : n(i), bit(i + 1, 0){};

  // a番目にwを加算
  void add(T a, T w) {
    for (T x = a; x <= n; x += (x & -x)) {
      bit[x] += w;
    }
  }

  //[1,a]の和
  T sum(T a) {
    T ret = 0;
    for (T x = a; x > 0; x -= (x & -x)) {
      ret += bit[x];
    }
    return ret;
  }
};

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll n,k,ans=0;
  std::cin>>n>>k;

  std::vector<ll> a(n);
  rep(i,0,n)std::cin>>a[i];

  rep(i,0,n){
    rep(j,i+1,n){
      if(a[i]>a[j])ans++;
    }
  }

  sort(all(a));

  ll temp=0;

  rep(i,0,n){
    auto itr=std::lower_bound(all(a),a[i]);
    temp=(temp+(ll)(itr-a.begin()))%MOD;
  }

  std::cout<<((k*ans)%MOD+(((k*(k-1)/2)%MOD)*temp)%MOD)%MOD;

  return 0;
}

Measured memory_bytes: 256
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 LN           PIC X(500).
01 N            PIC 9(3).
01 cur          PIC 9(10) VALUE 1.
01 i            PIC 9(18) VALUE 1.
01 j            PIC 9(18).
01 len          PIC 9(10). 
01 A            PIC 9(4) VALUE 1.
01 FLG          PIC 9(1) VALUE 1.

PROCEDURE DIVISION.
MAIN.
    ACCEPT N.
    ACCEPT LN.
    PERFORM N TIMES
        PERFORM VARYING j FROM cur BY 1 UNTIL LN(j:1) = SPACE
        END-PERFORM
        COMPUTE len = j - cur
        MOVE LN(cur:len) TO A
        IF FUNCTION MOD(A, 2) = ZERO AND FUNCTION MOD(A, 3) NOT = ZERO
            AND FUNCTION MOD(A, 5) NOT = ZERO THEN
            MOVE ZERO TO FLG
            EXIT PERFORM
        END-IF
        COMPUTE cur = j + 1
        ADD 1 TO i
    END-PERFORM.
    IF FLG = 1
        DISPLAY "APPROVED"
    ELSE
        DISPLAY "DENIED"
    END-IF.

MAIN-EXIT.
    STOP RUN.

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

LL N,K;
LL ans;

int main(){
	cin >> N >> K;
	if(K == 0) return cout << N*N << endl , 0;
	repp(i,K+1,N+1){
		ans += N/i * (i-K);
		ans += max((LL)0,N%i-K+1);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>  // https://boostjp.github.io/tips/math.html
#include <boost/dynamic_bitset.hpp>  // https://boostjp.github.io/tips/dynamic_bitset.html

constexpr int64_t DIV1097 = 1000000007LL;

using namespace std;

int main()
{
    int64_t N;
    std::cin >> N;

    struct Point {
        int64_t x;
        int64_t y;
        int64_t h;
    };

    std::vector<Point> P;
    Point o;
    for (decltype(N) i = 0; i < N; ++i) {
        int64_t x, y, h;
        std::cin >> x >> y >> h;
        P.push_back({x, y, h});
        if (h != 0) {
            // H == 0の場所がでないものでH候補計算する
            o  = {x, y, h};
        }
    }

    for (int64_t cx = 0; cx <= 100; ++cx) {
        for (int64_t cy = 0; cy <= 100; ++cy) {
            int64_t thisH = o.h + std::abs(o.x - cx) + std::abs(o.y - cy);
            for (int64_t i = 0; i < N; ++i) {
                if (P[i].h != std::max(thisH - std::abs(P[i].x - cx) - std::abs(P[i].y - cy), (int64_t)0)) {
                    goto next;
                }
            }
            std::cout << cx << " " << cy << " " << thisH << std::endl;
            return 0;
        next:
            int a;
        }
    }

    return 0;
}


Measured memory_bytes: 256
/* kadai3_3
   Saikyo_Kazune
*/
#include <stdio.h>
//累乗関数を自前定義
int pow(int K,int L){
    if(L==0){
        return 1;
    }
    else if(L%2==1){
        return K*pow(K,L-1);
    }
    else{
        return pow(K,L/2)*pow(K,L/2);
    }
}
 
int main(void){
   //int型　num_N,num_K,桁数ようにLを宣言
   int num_N,num_K,L=1;
   scanf("%d %d",&num_N,&num_K);
   while(num_N/pow(num_K,L)!=0){
       L++;
   }
   printf("%d\n",L);
 
   return 0;
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

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

using ll = long long;

using namespace std;

int main() {
  in(int, n);
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  ll all = 0;
  rep(i, n) all ^= a[i];
  rep(i, n) {
    if (i) cout << " ";
    cout << (all ^ a[i]);
  }
  cout << endl;
}


Measured memory_bytes: 4748
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N, M;
    cin >> N >> M;
    vector<ll> A(N), B(N);
    vector<vector<ll>> v(M+1);
    priority_queue<ll> que;
    rep(i,N){
        cin >> A[i] >> B[i];
        if(A[i] > M) continue;
        v[A[i]].push_back(B[i]);
        //que.push(Pll(B[i],A[i]));
    }
    ll ans = 0;
    rep(i,M){
        ll d = i+1;
        for(auto& u:v[d]){
            que.push(u);
        }
        if(que.empty())continue;        
        ll t = que.top();
        //ll t = que.top().first;
        //ll d = que.top().second;
        que.pop();
        ans += t;
    }
    cout << ans << endl;
}

Measured memory_bytes: 9876
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,D;
  cin>>N>>D;
  vector<vector<int>> p(N,vector<int>(D));
  for(int i=0;i<N;i++){
    for(int j=0;j<D;j++){
      cin>>p.at(i).at(j);
    }
  }
  int count =0;
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      int sum=0;
      for(int k=0;k<D;k++){
        int a = p.at(j).at(k)-p.at(i).at(k);
        sum+=a*a;
      }
      for(int m=0;m<160;m++){
        if(sum==m*m){
          count++;
          break;
        }
      }
    }
  }
  
  cout<<count<<endl;
  
  return 0;
}
        
        
        
        
        
        


Measured memory_bytes: 256
import sys
import os
import math
import bisect
import collections
import itertools
import heapq
import re
import queue

# import fractions

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, K = il()
    X = il()

    ret = MAX
    for n in range(N - K + 1):
        l = abs(X[n]) + abs(X[n]-X[n+K-1])
        r = abs(X[n+K-1]) + abs(X[n+K-1] - X[n])
        ret = min(ret, l, r)
    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 13764
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;


int main() {
int N;
cin>>N;
ll x,A[N];
cin>>x;
rep(i,N){
    cin>>A[i];
}
ll ans=0;

rep(i,N-1){
if(A[i]+A[i+1]>x){
    if(A[i]>x){
        ans+=A[i+1];
        A[i+1]=0;
        ans+=A[i]-x;
    }
    else{
        ans+=A[i]+A[i+1]-x;
        A[i+1]=x-A[i];
    }

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

Measured memory_bytes: 4376
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
long long int INF = 3e18;
double Pi = 3.1415926535897932384626;
 
//vector<ll> G[550010];
//vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
 
 
ll mod = 1000000007;
/*
2000000011 is prime
2000000033 is prime
*/

ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}


ll fact[800005],rfact[800005];

void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=800000; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[800000] = rui(fact[800000],mod - 2);
    for(ll i=800000; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod) * rfact[n-r]) % mod;}

 
ll n,m,num,sum,a,b,c,d,e,g,h,w,i,j,q,r;
ll k,ans;
ll x[500005],y[500005],z[500005];
char s[500005];



int main(){
    cin >> n >> m;
    c3_init();
    if(n > m)swap(n,m);
    if(m - n >= 2){
        p(0);
        return 0;
    }else if(m - n == 1){
        ans = (fact[m] * fact[n]) % mod;
        p(ans);
        return 0;
    }else{
        ans = (fact[m] * fact[n] * 2) % mod;
        p(ans);
        return 0;
    }
    
    
    
    return 0;
}






Measured memory_bytes: 14848
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    char c; cin >> c;
    cout << (char)(c + 1) << endl;
    return 0;
}

Measured memory_bytes: 256
import math

def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

N = int(input())
for l in range(N):

    xa,ya,ra,xb,yb,rb = [float(i) for i in input().split()]
    d = math.sqrt((xa-xb)**2 + (ya-yb)**2)
    if d < ra-rb:
        print(2)
    elif d < rb-ra:
        print(-2)
    elif d > ra+rb:
        print(0)
    else:
        print(1)


Measured memory_bytes: 5672
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}
 
const int maxn=100005;
//i_am_noob
int n,d,a[20][10],dist,ans=0;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> n >> d;
	rep(n) rep1(j,d) cin >> a[i][j];
	rep(n) rep2(j,i+1,n){
		dist=0;
		rep1(k,d) dist+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
		rep1(k,20000) if(dist==k*k) ans++;
	}
	print1(ans);
	return 0;
}


Measured memory_bytes: 256
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){

  int n,q;
  cin>>n>>q;
  string s;cin>>s;
  int ac[n];
  ac[0] = 0;
  REP(i,n-1){
    if(s[i]=='A'&&s[i+1]=='C'){
      ac[i+1] = ac[i] + 1;
    }else{
      ac[i+1] = ac[i];
    }
  }

  REP(i,q){
    int l,r;
    cin>>l>>r;
    l--;
    r--;
    cout<<ac[r] - ac[l]<<endl;;
  }


  return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
using namespace std;

string a, b;
int main() {
    cin >> a;
    for (int i = 0; a[i]; i++) {
        if (a[i] != 'B') {
            b += a[i];
        } else if (!b.empty()) {
            b.pop_back();
        }
    }
    cout << b;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    long long sum=0;
    cin>>n;
    if(n%500==0)
    {
        sum=(n/500)*1000;
    }
    else
    {
        sum=(n/500)*1000;
        int k=n%500;
        sum+=(k/5)*5;
    }
    cout<<sum<<endl;
    return 0;
}



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

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

  vector<char> ans;

  while(N>0){
    N--;
    ll c = N%26;
    N++;
    ans.push_back(c+'a');
    N -= c;
    N /= 26;
    if(N==0)break;
  }

  reverse(all(ans));

  for(char x: ans){
    cout<<x;
  }
  cout<<endl;
}

Measured memory_bytes: 3628
#include<iostream>


using namespace std;

int judge_even(string s,int i){
  string s_ = s.substr(i,1);
  if(s_=="L" || s_=="U"||s_=="D") return 0;
  return 1;
}

int judge_odd(string s,int i){
  string s_ = s.substr(i,1);

  if(s_=="R" || s_=="U"||s_=="D"){

    return 0;
  }
  return 1;
}

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

  for(int i=0;i<n;i++){
    if(i%2==1){
      int judge = judge_even(s,i);
      if(judge == 1){
        cout << "No" << endl;
        return 0;
      }
    }else{
      int judge = judge_odd(s,i);
      if(judge == 1){
        cout << "No" << endl;
        return 0;
      }
    }
  }
   cout << "Yes" << endl;
   return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int K; string S;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> K >> S;
	if (S.length() <= K) cout << S << endl;
	else cout << S.substr(0, K) + "..." << endl;
}







Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  string ans = "YES";
  for(int i = 0; i < N-1; i++){
    if(A.at(i) == A.at(i+1)){
      ans = "NO";
    }
  }
      
  cout << ans << endl;
}

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

using namespace std;
typedef long long int lli;
#define fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
typedef pair<lli, lli> pii;
#define ff first
#define ss second
#define MOD 1000000007
#define pb push_back
#define EPS 1e-6
const lli MAX = 1e9 + 7;

int main()
{
    fast;
    int t = 1;
    while (t--)
    {
        string s;
        cin >> s;
        lli n = s.size();
        if (s[n - 1] == 's')
            s += "es";
        else
            s += "s";
        cout << s << "\n";
    }
    return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i, c) for(long long i=0; i<(long long)c; i++)
const ll INF=1000000000000001;
//146813779479510
//1000000000000001
int main() {
	ll n;
	int a,j;
	string s;
	char c;

	cin>>n;
	s="";
	while(n>0){
		if (n>=27){
			a=n%26;
			if (a==0){
				c='z';
				s=s+c;
				n/=26;
				n--;
			}
			else{
				c= 'a'+a-1;
				s=s+c;
				n/=26;
			}
//			cout <<"c1="<<c<<endl;
//			cout <<"n1="<<n<<endl;
		}
		else{
			c= 'a'+ n-1;
//			cout <<"c2="<<c<<endl;
			s=s+c;
			n=0;
			break;
		}
		j++;
	}
	reverse(s.begin(),s.end());
	cout <<s << endl;
	return 0;
}


Measured memory_bytes: 3656
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = []
for _ in range(N):
    A.append(list(map(int, input().split())))

ans = 0
for a in A:
    if sum(aa * bb for aa, bb in zip(a, B)) + C > 0:
        ans += 1

print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pii;
typedef vector<pii> vii;
typedef vector<ll> vi;
typedef queue<ll> qi;
typedef queue<char> qc;
typedef queue<string> qs;
typedef vector<char> vc;
typedef vector<string> vs;
typedef map<char,ll> mpci;
typedef map<ll,ll> mpii;
typedef map<string,ll> mpsi;
typedef set<ll> sei;
typedef set<char> sec;
typedef set<string> ses;
typedef stack<ll> si;
typedef stack<char> sc;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<pll> vpll;
typedef vector<pdd> vdd;
typedef unsigned int uint;
typedef long double ld;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vii> vvii;
/*=====================================================================*/
#define pb push_back
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define sz(a) (int)(a.size())
#define len(a) (int)(a.length())
#define all(s) (s).begin(),(s).end()
#define fi first
#define se second
#define be begin
#define en end
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define forn(i,p,n) for(int i=p;i<=n;i++)
#define ford(i,p,n) for(int i=n-1;i>=p;i--)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();++i)
#define zero(a) memset(a,0,sizeof(a))
#define number(a,num) memeset(a,num,sizeof(a))

/*=====================================================================*/

inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
inline void write(long long x) {
  static long long sta[35];
  long long top = 0;
  do {
    sta[top++] = x % 10, x /= 10;
  } while (x);
  while (top) putchar(sta[--top] + 48);
  puts("");
}
/*======================================================================*/
bool prime(int n)
{
	if(n==0||n==1)
	  return false;
	for(int i=2;i*i<=n;i++)
	  if(n%i==0)
	    return false;
	return true;
}
/*======================================================================*/
const int dx[]={-1,0,1,0};
const int dy[]={0,-1,0,1};
/*======================================================================*/
int main()
{
  /*
	ios_base::sync_with_stdio(0);
	cin(tie);
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
  */
  /*====================================================================*/
  ll n;
  cin>>n;
  ll maxn=0;
  for(ll i=1;i*i<=n;i++)
    if(n%i==0)
    {
  	  maxn=max(i,maxn);
    }
  cout<<(maxn+n/maxn)-2;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] color = new int[9];
		for (int i = 0; i < n; i++) {
			int a = sc.nextInt();
			if (a >= 3600) {
				a = 3599;
			}
			color[a / 400]++;
		}
		sc.close();

		int min = 0;
		for (int i = 0; i < color.length - 1; i++) {
			if (color[i] > 0) {
				min++;
			}
		}
		if (min == 0) {
			System.out.println("1 " + color[8]);
		} else {
			System.out.println(min + " " + (min + color[8]));
		}
	}
}


Measured memory_bytes: 22868
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		System.out.println(tokens[2] + " " + tokens[0] + " " + tokens[1]);
	}

	void calc() {
	}

	void showResult() {
	}

}


Measured memory_bytes: 20692
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //  repマクロ
#define leng(n) (int)(log10(n)+1)  //  桁数
using namespace std;

signed main() {
  int N, X;
  cin >> N >> X;
  vector<int> L(N);
  for (int i = 0; i < N; i++) {
    cin >> L[i];
  }
  
  int ans = 1;
  int now = 0;
  for (int i = 0; i < N; i++) {
    now += L[i];
    if (now > X) break;
    else ans++;
  }
  cout << ans << endl;
}

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

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

  if(d == 25) cout << "Christmas" << endl;
  if(d == 24) cout << "Christmas Eve" << endl;
  if(d == 23) cout << "Christmas Eve Eve" << endl;
  if(d == 22) cout << "Christmas Eve Eve Eve" << endl;

  return 0;

}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class ADiscountFare {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int x, y;
	    in >> x >> y;
	    out << x + y / 2 << endl;
	}
};


int main() {
	ADiscountFare solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);
    int a[3],b[3];
    scanf("%d%d%d", &a[0], &a[1], &a[2]);
    scanf("%d%d%d", &b[0], &b[1], &b[2]);

    int i,j;
    int cnt0=0,cnt1=0,cnt2=0;
    for(i=0; i<3; i++) {
        if(a[i]<b[i]) cnt0++;
        else if(a[i]>b[i]) cnt1++;
        else cnt2++;
    }
    if(cnt0+cnt2==3) {
        cnt0=3;
    }
    else if(cnt1+cnt2==3) {
        swap(a[0],b[0]);
        swap(a[1],b[1]);
        swap(a[2],b[2]);
        cnt0 = 3;
    }

    if(cnt0==3) {
        ll ans = 0;
        for(i=0; i<=n; i+=a[0]) {
            for(j=0; j<=n-i; j+=a[1]) {
                int tmp = n-i-j;
                int k = tmp / a[2];
                ll val = (ll)(b[0]-a[0])*(i/a[0]) + (ll)(b[1]-a[1])*(j/a[1]) + (ll)(b[2]-a[2])*k + n;
                ans = MAX(ans, val);
            }
        }
        printf("%lld\n", ans);
    }
    else if(cnt0+cnt2==2) {
        int p=-1,q=-1,r=-1;
        for(i=0; i<3; i++) {
            if(a[i]<=b[i]) {
                if(p<0) p=i;
                else    q=i;
            }
            else {
                r=i;
            }
        }

        ll ans0 = 0;
        int rsave=0;
        for(i=0; i<=n; i+=a[p]) {
           int tmp = n-i;
           int k = tmp / a[q];
            ll val = (ll)(b[p]-a[p])*(i/a[p]) + (ll)(b[q]-a[q])*k + n;
            if(ans0<val) {
                ans0 = val;
                rsave = r;
            }
        }
        //printf("%lld\n", ans0);

        {
            ll k = ans0 / b[r];
            ll ans = ans0 + (a[r]-b[r])*k;
            printf("%lld\n", ans);
        }
    }
    else {
        int p=-1, q=-1, r=-1;
        for(i=0; i<3; i++) {
            if(a[i]<=b[i]) {
                if(r<0) r=i;
            }
            else {
                if(p<0) p=i;
                else    q=i;
            }
        }
        ll kk = n / a[r];
        ll nn = n + (b[r]-a[r])*kk;
        //printf("%lld\n", ans);

        ll ans0 = 0;
        int rsave=0;
        for(i=0; i<=nn; i+=b[p]) {
           int tmp = nn-i;
           int k = tmp / b[q];
            ll val = (ll)(a[p]-b[p])*(i/b[p]) + (ll)(a[q]-b[q])*k + nn;
            if(ans0<val) {
                ans0 = val;
                rsave = r;
            }
        }
        printf("%lld\n", ans0);
    }

    return 0;
}


Measured memory_bytes: 128
K = gets.to_i
N = 50
a = Array.new(N){N - 1 + K/N}
k = K % N
k.times{
    min = a[0]
    min_i = 0
    (1 ... N).each{|i|
        if min > a[i]
            min = a[i]
            min_i = i
        end
    }
    a[min_i] += N + 1
    a.map!{|i|i-1}
}
puts N
puts a.join(" ")


Measured memory_bytes: 14312
n = int(input())
kisu_list = [i for i in range(1,n+1) if i%2==1]
count = 0
for kisu in kisu_list:
    yakusu = [i for i in range(1,kisu+1) if kisu%i==0]
    if len(yakusu)==8:
        count += 1
print(count)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n,x,t;
	int ans;
	cin >> n >> x >>t;
	ans = n / x;
	if(n % x != 0)	ans++;
//	cout << ans << t <<endl;
	cout << ans * t << endl;
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];

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

    for (int i = 1; i < N; i++) {
        if (A[i] == A[i - 1]) {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    while(cin>>n)
    {
        int a,maxn=0,minn=1000000000;
        for(int i=0;i<n;i++)
        {
            cin>>a;
            if(a>maxn)
                maxn=a;
            if(a<minn)
                minn=a;
        }
        cout<<maxn-minn<<endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[200010],ans;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",a+i);
        if(a[i]==ans+1)
        {
            ans++;
        }
    }
    if(ans==0)
    {
        printf("-1");
        return 0;
    }
    printf("%d",n-ans);
}

Measured memory_bytes: 1024
# AtCoder Regular Contest 099
# C - Minimization 

N,K =map(int,input().split())
A=list(map(int,input().split()))

ans=0

a=N-K
ans+=1

if a>0:
    ans+=a//(K-1)
    if a%(K-1)==0:
        pass
    else:
        ans+=1
else:
    pass

print(ans)

Measured memory_bytes: 20612
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''
N, X = map(int, input().split())
L = list(map(int, input().split()))

count = 1
pos = 0

for i in range(N):
	pos += L[i]
	if pos <= X:
		count += 1
		
print(count)

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

int main(){
  vector<int> chumon(5);
  for(int i=0; i<chumon.size(); i++){
    cin >> chumon[i];
  }
  int minTemp = chumon[0]%10;
  for(int i=1; i<chumon.size(); i++){
    if(minTemp > chumon[i]%10 && chumon[i]%10 != 0){
      minTemp = chumon[i]%10;
    }
  }
  int sumTime = 0;
  for(int i=0; i<chumon.size(); i++){
    sumTime += chumon[i];
    if(sumTime%10 != 0){
      sumTime += (10 - sumTime%10);
    }
  }
  if(minTemp == 0){
    cout << sumTime << endl;
  }else{
    sumTime -= (10 - minTemp);
    cout << sumTime << endl;
  }

  // end process
  return 0;
}


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

using namespace std;

#define int long long

const int INF = 1e18;
const int MAX_C = 30 + 5, MAX_N = 500 + 5;

int n, c;
int d[MAX_C][MAX_C], cnt_col[3][MAX_C], cost[3][MAX_C];

void solve() {
    cin >> n >> c;
    for (int i = 0; i < c; ++i) {
        for (int j = 0; j < c; ++j) {
            cin >> d[i][j];
        }
    }
    int col;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            cin >> col;
            ++cnt_col[(i + j) % 3][col - 1];
        }
    }
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < c; ++j) {
            int res = 0;
            for (int k = 0; k < c; ++k) {
                if (k == j) {
                    continue;
                }
                res += cnt_col[i][k] * d[k][j];
            }
            cost[i][j] = res;
        }
    }
    int ans = INF;
    for (int i = 0; i < c; ++i) {
        for (int j = 0; j < c; ++j) {
            for (int k = 0; k < c; ++k) {
                if (i == j || j == k || i == k) {
                    continue;
                }
                int res = cost[0][i] + cost[1][j] + cost[2][k];
                ans = min(ans, res);
            }
        }
    }
    cout << ans << "\n";
}

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

    solve();

    return 0;
}

Measured memory_bytes: 384
import copy

def nuri(is_tate, n, hako):
    if is_tate:
        for i in range(len(hako)):
            hako[i][n] = 'r'

    else:
        for i in range(len(hako[n-1])):
            hako[n][i] = 'r'
        

h, w, k = map(int, input().split())
ans = 0
c = []
for i in range(h):
    c.append(list(input()))

for i in range(2 ** (h+w)):
    c_ex = copy.deepcopy(c)
    for j in range(h+w):
        if ((i >> j) & 1):
            if j >= h:
                idx = j-h
                nuri(True, idx, c_ex)
            else:
                idx = j
                nuri(False, idx, c_ex)

    num = 0
    for j in range(len(c_ex)):
        num += c_ex[j].count('#')
    if num == k:
        ans += 1

print(ans)

Measured memory_bytes: 9356
import std.stdio;

int[40] ptn;

void main(){
	int n;
	ptn[1..4] = [1, 2, 4];
	for (int i = 3; i < 30; i++) ptn[i+1] = ptn[i] + ptn[i-1] + ptn[i-2];
	while (readf("%d\n", &n), n) writeln((((ptn[n]+9)/10)+364)/365);
}

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

int main(){
    std::string w, t;
    std::cin >> w;

    int count = 0;
    while(std::cin >> t){
        std::transform(t.begin(), t.end(), t.begin(), ::tolower);
        if(t == w){
            ++count;
        }
    }

    std::cout << count << std::endl;

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

double dot(P a,P b){return real(conj(a)*b);};
double cross(P a,P b){return imag(conj(a)*b);};

int main(){
  stack<int> st;
  int x;
  while(~scanf("%d",&x)){
    if(x == 0){
      cout<<st.top()<<endl;
      st.pop();
    }else{
      st.push(x);
    }
  }
  return 0;
}

Measured memory_bytes: 1208
s = str(input())
cnt = []
l = 0
pos = 0

for i in range(len(s)):
    l = 0
    pos = i
    while s[pos] == 'A' or s[pos] == 'C' or s[pos] == 'G' or s[pos] == 'T':
        l += 1
        pos += 1
        if pos >= len(s):
            break

    cnt.append(l)

print(max(cnt))

Measured memory_bytes: 3064