akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int a1,a2,a3;
signed main()
{
	scanf("%d%d%d",&a1,&a2,&a3);
	if(a1+a2+a3>=22)
		printf("bust");
	else
		printf("win");
	return 0;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
typedef long long LL;

int main() {
  int city[4] = {};
  for (int i = 0; i < 3; ++i) {
    int a, b; std::cin >> a >> b;
    --a; --b;
    ++city[a];
    ++city[b];
  }

  bool valid1 = false;
  bool valid2 = false;
  for (int i = 0; i < 4; ++i) {
    if (city[i] == 1) {
      valid1 = true;
    } else if (city[i] == 2) {
      valid2 = true;
    } else {
      std::cout << "NO" << std::endl;
      return 0;
    }
  }

  if (valid1&&valid2) std::cout << "YES" << std::endl;
  else                std::cout << "NO" << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
#define fi first
#define se second
Int mod = 1e9+7;
//Int mod = 1e6+3;

int main() {
    Int n, k;
    cin >> n >> k;
    dump(k == 1 ? 0 : n - k);
    return 0;
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


using P = pair<i64, vector<i64>>;
#define N_ALPHABET 26
P S1[N_ALPHABET];
P S2[N_ALPHABET];

int main() {
    string s, t; cin >> s >> t;
    i64 L = s.length();

    vector<bool> seen(N_ALPHABET, false);
    REP(i, L) {
        i64 idx = s[i] - 'a';
        if (!seen[idx]) S1[idx].first = i;
        S1[idx].second.pb(i);
    }
    fill(seen.begin(), seen.end(), false);
    REP(i, L) {
        i64 idx = t[i] - 'a';
        if (!seen[idx]) S2[idx].first = i;
        S2[idx].second.pb(i);
    }

    sort(S1, S1 + N_ALPHABET);
    sort(S2, S2 + N_ALPHABET);

    bool ok = true;
    REP(i, N_ALPHABET) {
        if (S1[i].second != S2[i].second) {
            ok = false;
            break;
        }
    }
    cout << (ok ? "Yes" : "No") << endl;

    return 0;
}

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

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

    string s1 = "es";
    string s2 = "s";

    if(s[s.length() - 1] == 's')
        s += s1;
    else
        s += s2;

    cout << s << endl;
    

    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main(){
long int n,sum=0,ct=0,sml;
cin>>n;
const int N=n;
long int a[N];
for(int i=0;i<N;i++){
  cin>>a[i];
  if(a[i]<0){
    ct++;
    a[i]*=-1;
}
if(sml>a[i]||i==0)sml=a[i];
sum+=a[i];
}
if(ct%2==1)sum-=sml*2;
cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 1024
*coins, X = map(int, (input() for _ in range(4)))
ans = 0
for a in range(coins[0] + 1):
    for b in range(coins[1] + 1):
        x = X - (a * 500 + b * 100)
        c = x // 50
        if x >= 0 and x % 50 == 0 and coins[2] >= c:
            ans += 1

print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
 
typedef long long ll;
typedef pair<int, int> ii;

struct NODE{
	int d, p;
	NODE(){d = p = 0;}
	NODE(int d, int p):d(d), p(p){}
	
	bool operator<(const NODE r){
		return p > r.p;
	}
};

int main() {
	
	int n, m;
	while(cin >> n >> m, n){
		vector<NODE> v(n);
		rep(i, n){
			int d, p;
			cin >> d >> p;
			v[i] = NODE(d, p);
		}
		
		SORT(v);
		int ans = 0;
		rep(i, n){
			if(m >= v[i].d) m-= v[i].d;
			else{
				ans += (v[i].d - m) * v[i].p;
				m = 0;
			}
		}
		
		cout << ans << endl;
	}


	return 0;
}

Measured memory_bytes: 3168
# -*- coding: utf-8 -*-
from statistics import mean
from math import factorial as fact

n,a,b = map(int, input().split())
v = sorted([int(x) for x in input().split()], reverse=True)
sel = v[:a]
print(mean(sel))

vn = v.count(sel[-1])
na = sel.count(sel[-1])
nb = min(b-a, vn-na)
# print(na,nb,vn,len(sel),sel[-1])

if na!=len(sel):
    print(fact(vn)//(fact(na)*fact(vn-na)))
elif nb==0:
    print(1)
else:
    ret = 0
    for bi in range(na,na+nb+1):
        ret += fact(vn)//(fact(bi)*fact(vn-bi))
    print(ret)


Measured memory_bytes: 5848
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll int64_t

using namespace std;

int h,w,k;
vector<vector<char>> m;

int ans =0;

int func(vector<bool> hr){
	int cnt = 0;
	rep(i,h){
		if(hr[i])continue;
		rep(j,w){
			if(hr[j+h])continue;
			if(m[i][j] == '#')cnt++;
		}
		if(cnt > k)break;
	}
	if(cnt == k)ans++;
		
	return 0;
}

void dfs(vector<bool> t){
	if(t.size() == h+w){
		func(t);
		return;
	}

	t.push_back(false);
	dfs(t);

	t.back() = true;
	dfs(t);

}

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

	m = vector<vector<char>>(h,vector<char>(w));

	rep(i,h){
		rep(j,w){
			cin >> m[i][j];
		}
	}

	dfs(vector<bool>());


	cout << ans;


	return 0;
}

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

#define INF 0x3fffffff

typedef pair<int, int> Data;
typedef pair<int, Data> Pair;

struct Edge {
  int to;
  int len;
  int hour;
  int type;
};

int N;
int M;
int H;
int K;
int S;
int T;
int P;
int ds[1145];
int bs[1145];
int dp[1145];
bool used[1145];
int mind[114][30];
vector<Edge> es[114];

int Dijkstra(int st) {
  priority_queue<Pair, vector<Pair>, greater<Pair>> q;
  for (int i=0; i<N; i++) {
    for (int j=0; j<=24; j++) mind[i][j] = INF;
  }
  mind[S][0] = 0;
  q.push(Pair(0, Data(S, 0)));
  while (!q.empty()) {
    Pair p = q.top(); q.pop();
    Data d = p.second;
    int cost = p.first;
    int v = d.first;
    int h = d.second;
    if (mind[v][h] < cost) continue;
    for (Edge &e : es[v]) {
      int nh = h+e.hour;
      if (nh > 24) continue;
      int len = e.len;
      if (st >> e.type & 1) len = 0;
      int u = e.to;
      if (mind[u][nh] > mind[v][h]+len) {
        mind[u][nh] = mind[v][h]+len;
        q.push(Pair(mind[u][nh], Data(u, nh)));
      }
    }
  }

  int ret = INF;
  for (int i=0; i<=H; i++) {
    ret = min(ret, mind[T][i]);
  }
  return ret;
}

int main() {
  while (1) {
    scanf("%d%d%d%d", &N, &M, &H, &K);
    if ((N|M|H|K) == 0) return 0;

    for (int i=0; i<N; i++) es[i].clear();

    for (int i=0; i<M; i++) {
      int a, b, c, h, r;
      scanf("%d%d%d%d%d", &a, &b, &c, &h, &r);
      --a;
      --b;
      --r;
      es[a].emplace_back(Edge{b, c, h, r});
      es[b].emplace_back(Edge{a, c, h, r});
    }

    scanf("%d%d", &S, &T);
    --S;
    --T;
    scanf("%d", &P);
    for (int i=0; i<P; i++) {
      int l, k;
      scanf("%d%d", &l, &ds[i]);
      bs[i] = 0;
      for (int j=0; j<l; j++) {
        scanf("%d", &k);
        --k;
        bs[i] |= 1 << k;
      }
    }

    int lim = 1 << K;
    fill(dp, dp+lim, INF);
    fill(used, used+lim, false);
    dp[0] = 0;
    while (1) {
      int u = -1;
      for (int i=0; i<lim; i++) {
        if (used[i]) continue;
        if (u == -1 || dp[u] > dp[i]) u = i;
      }
      if (u == -1) break;
      used[u] = true;
      
      for (int i=0; i<P; i++) {
        int v = u | bs[i];
        if (dp[v] > dp[u]+ds[i]) {
          dp[v] = dp[u]+ds[i];
        }
      }
    }
    
    int ans = INF;
    for (int st=0; st<lim; st++) {
      ans = min(ans, Dijkstra(st)+dp[st]);
    }
    if (ans == INF) puts("-1");
    else printf("%d\n", ans);
  }
}

Measured memory_bytes: 3328
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

int main() {
  int n;
  cin >> n;
  int a[n + 5];
  int b[n];
  for (int i = 0; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    int x = b[i];
    int take = min(a[i], x);
    x -= take;
    a[i] -= take;
    ans += take;
    take = min(a[i + 1], x);
    x -= take;
    a[i + 1] -= take;
    ans += take;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, nuint_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set; 
//#define int long long
#define MOD 1000000007
#define what_is(x) cerr << #x << " is " << x << endl;
#define loop(i,a,n) for(int i=a;i<n;i++)
#define pb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, szof(x))
#define sortall(x) sort(aint(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626 
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<int, int> pt;


signed main() {

	fastio();
	//#define LOCAL_DEFINE	
	#ifdef LOCAL_DEFINE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	int n;
	cin>>n;
	set<int> s;
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		s.insert(x);
	}
	cout<<((s.size()==n)?"YES":"NO");
	return 0;
}





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

using namespace std;
using ll = long long;

int main()
{
    ll N,K;
    cin >> N >> K;
    ll cnt=0;
    for(ll i=0;i<N;i++)
    {
        ll temp;
        cin >> temp;
        if(temp >= K)
        {
            cnt++;
        }
    }

    cout << cnt << endl;
    
    
    
    
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> h(n + 1);
  for (int i = 0; i < n; i++)
    cin >> h[i];

  int last = 0;
  int cnt  = 0;
  int zero = 0;
  queue<int> q;
  int i = 0;
  while (zero != n) {
    if (h[i] > 0) { q.push(i); }
    if (h[i] == 0) {
      bool c = false;
      while (!q.empty()) {
        int j = q.front();
        q.pop();
        h[j]--;
        c = true;
      }
      if (c) {
        cnt++;
      } else {
        zero++;
      }
    }
    if (i == n) {
      i    = 0;
      zero = 0;
    } else
      i++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind
#define rt (a); return (a); 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
llint gcd(llint a, llint b) {
	if (b > a)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
llint Tow(int n) {//2のn乗
	if (n == 0)return 1;
	llint x = Tow(n / 2);
	x %= mod;
	x *= x;
	x %= mod;
	if (n % 2 == 1)x *= 10;
	x %= mod;
	return x;
}

int main(){
	string s;
	cin >> s;
	int a = 0, b = 0,c=0;
	rep(i, 0, s.size()) {
		if (s[i] == 'a')a ++ ;
		if (s[i] == 'b')b++;
		if (s[i] == 'c')c++;
	}
	YES(max({ a,b,c }) - min({ a,b,c })<2)
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

char ans[101][101];

int main()
{
	int A, B, cntA = 1, cntB = 1;

	cin >> A >> B;

	repc(i, 1, 100) {
		repc(j, 1, 50) ans[i][j] = '#';
		repc(j, 51, 100) ans[i][j] = '.';
	}

	for (int i = 1; i <= 100; i += 2) {
		if (cntA >= A) break;
		for (int j = 2; j <= 48; j += 2) {
			if (cntA >= A) break;
			ans[i][j] = '.';
			cntA++;
		}
	}

	for (int i = 1; i <= 100; i += 2) {
		if (cntB >= B) break;
		for (int j = 52; j <= 98; j += 2) {
			if (cntB >= B) break;
			ans[i][j] = '#';
			cntB++;
		}
	}

	puts("100 100");
	repc(i, 1, 100) {
		repc(j, 1, 100) cout << ans[i][j];
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<cstring>
#include<iomanip>
#include<set>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
#define INF 1000000100
#define rep(i,n) for (int i=0;i<n;i++)

const int maxN=1010;
vector<int> G[maxN];
int n;

void add_edge(int a, int b){
    G[a].push_back(b);
}


vector<int> bfs(int sv){
    vector<int> dist(n, INF), pre(n,-1);
    queue<int> q;
    dist[sv]=0;
    q.push(sv);
    while(!q.empty()){
        int u = q.front(); q.pop();
        for(int v:G[u]){
            if(dist[v]!=INF) continue;
            dist[v]=dist[u]+1;
            q.push(v);
            pre[v] = u;
        }
    }
    pair<int,int> best(INF, -1);
    rep(u,n){
        if(u==sv) continue;
        for(int v:G[u]){
            if(v==sv){
                best = min(best, make_pair(dist[u], u));
            }
        }
    }
    if(best.first==INF) return vector<int> (n+1);
    vector<int> ans;
    int v = best.second;
    while(v!=-1){
        ans.push_back(v);
        v = pre[v];
    }
    return ans;

}


int main(){
    int M;
    cin >> n >> M;
    rep(i,M){
        int a,b;
        cin >> a >> b;
        a--;b--;
        add_edge(a,b);
    }
    
    vector<int> ans(n+1);
    rep(i,n){
        auto now = bfs(i);
        if(now.size()<ans.size()) ans = now;
    }
    if(ans.size()==n+1){
        cout << -1 << endl;
        return 0;
    }
    cout << ans.size() << endl;
    for(int v: ans){
        cout << v+1 << endl;
    }
    return 0;

}

Measured memory_bytes: 3268
#include <cstdio>

int main()
{
	int x;
	scanf("%d", &x);

	if (x == 1) return printf("1") * 0;

	int max = 0;
	for (int i = 2; i < 32; ++i)
	{
		int val;
		for (val = i * i; val <= x; val *= i)
			if (max < val) max = val;
	}

	printf("%d", max);

	return 0;
}

Measured memory_bytes: 128
// http://kmjp.hatenablog.jp/entry/2018/09/30/0900

package main

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

const M = 32

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	n := scanInt(sc)
	xs := make([]int64, n)
	ys := make([]int64, n)
	ps := make([]int, n)

	for i := 0; i < n; i++ {
		xs[i] = int64(scanInt(sc))
		ys[i] = int64(scanInt(sc))
		ps[i] = int((abs(xs[i]) + abs(ys[i])) % 2)
		if ps[i] != ps[0] {
			fmt.Println("-1")
			return
		}
	}

	m := M
	ds := make([]int64, m, m+1)
	for i := uint(0); i < uint(m); i++ {
		ds[i] = int64(1 << (M - 1 - i))
	}
	if ps[0] == 0 {
		ds = append(ds, 1)
		m += 1
	}

	fmt.Println(m)
	for _, d := range ds {
		fmt.Printf("%d ", d)
	}
	fmt.Println()

	for a := 0; a < n; a++ {
		s := ""
		for b := 0; b < m; b++ {
			if abs(xs[a]) >= abs(ys[a]) {
				if xs[a] >= 0 {
					s += "R"
					xs[a] -= ds[b]
				} else {
					s += "L"
					xs[a] += ds[b]
				}
			} else {
				if ys[a] >= 0 {
					s += "U"
					ys[a] -= ds[b]
				} else {
					s += "D"
					ys[a] += ds[b]
				}
			}
		}
		fmt.Println(s)
	}
}

func abs(n int64) int64 {
	return int64(math.Abs(float64(n)))
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}

Measured memory_bytes: 1408
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n int
	fmt.Scan(&n)

	ans := 0
	for i := 1; i <= n ;i++ {
		if len(strconv.Itoa(i)) % 2 == 1 {
			ans++
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 1024
//daddy's back in town, back to rolling the damn hash yoooo babeeeeees//
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define double long double
#define x first
#define y second
#define pi pair <int, int>
#define vi vector <int>
#define L nod<<1
#define R ((nod<<1)|1)
#define int ll
const ll mod = 1000000007;
int a[1010], n;

int32_t main(){
	ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    cin>>n;
    for(int i=1; i<=n; i++){
    	cin>>a[i];
    	if(a[i]%2==0){
    		if(a[i]%3!=0 && a[i]%5!=0) return cout<<"DENIED", 0;
    	}
    }
    cout<<"APPROVED";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string rot(int n, string s){
  string r;
  for (int i = 0; i < s.size(); i++) {
    r.append(1, s[i] + (s[i] - 'A' + n < 26 ? n : n-26));
  }
  return r;
}
int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  cout << rot(n,s) << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int n,m,c;
    int b[20];
    int a[20][20];
    cin >> n >> m >> c;
    for(int i = 0; i < m;i++)
        cin >> b[i];
    for(int i = 0;i < n; i++)
        for(int j = 0;j < m;j++)
            cin >> a[i][j];
    int count = 0;
    for(int i = 0;i < n;i++) {
        int result = 0;
        for(int j = 0; j < m;j++) {
            result += a[i][j] * b[j];
        }
        if((result + c) > 0)
            count++;
    }
    cout << count;
}

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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

void solve() {
	long long x; scanf("%lld", &x);
	long long ans = x/11*2;
	x %= 11;
	if (x > 0) ++ans;
	if (x > 6) ++ans;
	printf("%lld", ans);
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define M 1000000007
#define rep(i,a,b) for(int i=a;i<b;i++)
#define m_p make_pair
#define pb push_back
#define vi vector<int>
#define F first 
#define S second 

void solve()
{
	int n,k;
	cin>>n>>k;
	
	int cnt=0;
	while(n)
	{
		cnt++;
		n/=k;
	}
	cout<<cnt<<endl;
}

int main()
{
	int t=1;
	while(t--) solve();
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int N;
    cin >> N;
    map<char,ll> mp;
    rep(i,N){
        string name;
        cin >> name;
        mp[name[0]]++;
    }
    vector<ll> cnt(5);
    string S = "MARCH";
    rep(i,5) cnt[i] = mp[S[i]];
    ll ans = 0;
    for(int i=0;i<3;i++){
        for(int j=i+1;j<4;j++){
            for(int k=j+1;k<5;k++){
                ans += cnt[i]*cnt[j]*cnt[k];
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

// @@ !! LIM()

bool solve() {
  ll A, V, B, W, T; cin >> A >> V >> B >> W >> T;
  if (V <= W) return false;
  ll dist = abs(A - B);
  if (dist <= T * (V - W)) return true;
  return false;


}

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);
  cout << (solve() ? "YES" : "NO") << endl;

  return 0;
}



Measured memory_bytes: 3652
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if (a == b && b == c){
            System.out.println("1");
        }else if (a != b && b == c ){
            System.out.println("2");
        }else if (c != b && a == b ){
            System.out.println("2");
        }else if (a != b && a == c ){
            System.out.println("2");
        }else{
            System.out.println("3");
        }
    }
}


Measured memory_bytes: 35660
import java.util.Scanner

val sc = Scanner(System.`in`)
val s = sc.next()

fun main(args: Array<String>) {
    val mae = "${s[0]}${s[1]}".toInt()
    val usiro = "${s[2]}${s[3]}".toInt()

    if (mae >= 1 && mae <= 12) {
        if (usiro >= 1 && usiro <= 12) {
            println("AMBIGUOUS")
            return
        } else {
            println("MMYY")
            return
        }
    } else {
        if (usiro >= 1 && usiro <= 12) {
            println("YYMM")
            return
        } else {
            println("NA")
            return
        }
    }
}

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

int main()
{
    int n,w;
    std::cin>>n>>w;
    std::vector<std::pair<int,int>> p(n);
    for(int i=0;i<n;i++)std::cin>>p[i].first>>p[i].second; //first : 重さ , second : 価値

    std::vector<std::vector<long long>> dp(n,std::vector<long long>(w+1));  //dp[i][j] : i番目までを使って重さjを作る時の最大価値

    dp[0][p[0].first] = p[0].second;
    for(int i=1;i<n;i++){
        for(int j=0;j<=w;j++){
            dp[i][j] = std::max(dp[i][j],dp[i-1][j]);
            if(j-p[i].first>=0)dp[i][j] = std::max(dp[i][j],dp[i-1][j-p[i].first] + p[i].second);
        }
    }
    std::cout<<*std::max_element(dp[n-1].begin(),dp[n-1].end())<<std::endl;
}

Measured memory_bytes: 79360
#include<stdio.h>
char* judge(float w){
	if(w<=48.0){
		puts( "light fly");
	}else if(w<=51.0){
		puts( "fly");
	}else if(w<=54.0){
		puts( "bantam");
	}else if(w<=57.0){
		puts( "feather");
	}else if(w<=60.0){
		puts( "light");
	}else if(w<=64.0){
		puts( "light welter");
	}else if(w<=69.0){
		puts( "welter");
	}else if(w<=75.0){
		puts( "light middle");
	}else if(w<=81.0){
		puts( "middle");
	}else if(w<=91.0){
		puts( "light heavy");
	}else {
		puts( "heavy");
	}
}
int main(){
	float weight=0.0;
	while(~scanf("%f",&weight)){
	//	printf("%f",weight);
		judge(weight);
	}
	return 0;
}

Measured memory_bytes: 604
dur=int(input())
c=list(map(int,input().split()))
d=[0]*26
r=5
for i in range(dur):
  t=0
  s=list(map(int,input().split()))
  m=-1<<64
  for j in range(26):
    alt=s[j]+r*c[j]*(i+1-d[j])+sum([-r*c[k]*(i+1-d[k]) for k in range(26)])
    if alt>m:
      m=alt
      t=j
  print(t+1)
  d[t]=i+1


Measured memory_bytes: 69524
#include <iostream>
#include <vector>

#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

int main() {
  int a, b;
  cin >> a >> b;
  int ans = 0;
  int outlet = 1;

  while(outlet < b) {
    --outlet;
    outlet += a;
    ++ans;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
N=int(input())
s=[int(input()) for _ in range(N)]

s = sorted(s)
SUM = sum(s)

if SUM % 10 != 0:
  print(SUM)
  exit()

for i in range(N):
  if s[i] % 10 != 0:
    print(SUM - s[i])
    exit()
    
print(0)

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

int main(){
    int x, n, cnt1 = 0, cnt2 = 0, ans;
    cin >> x >> n;
    vector<int> p(n);
    for (int i = 0; i < n; ++i){
        cin >> p[i];
    }
    for (int i = 0; i < 101; ++i){
        cnt1 = 0, cnt2 = 0;
        for (int j = 0; j < n; ++j){
            if (x - i == p[j]) ++cnt1;
            if (x + i == p[j]) ++cnt2;
        }
        if (cnt1 * cnt2 > 0) continue;
        if (cnt1 > 0) ans = x + i;
        else ans = x - i;
        break;
    }
    cout << ans << endl;
    return 0;
}

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

static const int MAX = 10000;
static const int INFTY = (1<<20);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n;
vector<pair<int, int> > adj[MAX];

void dijkstra(){
    priority_queue<pair<int, int> > PQ;
    int color[MAX];
    int d[MAX];
    for(int i=0; i<n; i++){
        d[i] = INFTY;
        color[i] = WHITE;
    }
    
    d[0] = 0;
    PQ.push(make_pair(0, 0));
    color[0] = GRAY;
    
    while(!PQ.empty()){
        pair<int, int> f = PQ.top(); PQ.pop();
        int u = f.second;
        color[u] = BLACK;
        
        if(d[u] < f.first*(-1) ) continue;
        
        for(int j=0; j<adj[u].size(); j++){
            int v = adj[u][j].first;
            if(color[v]==BLACK) continue;
            if(d[v] > d[u] + adj[u][j].second){
                d[v] = d[u]+adj[u][j].second;
                PQ.push(make_pair(d[v]*(-1),v));
                color[v] = GRAY;
            }
        }
    }
    for(int i=0; i<n; i++){
        cout << i << " " << (d[i]==INFTY ? -1 : d[i]) << endl;
    }
}

int main(){
    int k,u,v,c;
    
    //cout << "testing" << endl;
    
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> u >> k;
        for(int j=0; j<k; j++){
            cin >> v >> c;
            adj[u].push_back(make_pair(v, c));
        }
    }
    
    
    dijkstra();
    
    return 0;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    string S;

    cin >> N;
    cin >> S;

    ll plus = 0;
    ll minus = 0;

    ll count = 0;
    REP(i, N){
        if(S[i] == '('){
            plus++;
        }
        if(S[i] == ')'){
            if(plus > 0) plus--;
            else{
                minus++;
            }
        }
        if(minus > plus){
            count++;
            plus = 0;
            minus = 0;
        }
    }

    REP(i, count){
        cout << '(';
    }
    cout << S;
    REP(i, plus){
        cout << ')';
    }
    cout << endl;
    return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP0(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define RREP0(i,n) for(int i=n-1; i>=0; --i)
#define RREP1(i,n) for(int i=n; i>=1; --i)

#define SORT(c) sort((c).begin(),(c).end())
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define CLR(a) memset((a), 0 ,sizeof(a))

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();}

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int INTINF = 2147483647;
const LL LLINF = 9223372036854775807;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(int argc, char const *argv[]) {
  cin.tie(0); ios::sync_with_stdio(false);
  int A,B;
  std::cin >> A >> B;
  if (A%2==1 && B%2==1) {
    std::cout << "Yes" << '\n';
  }else{
    std::cout << "No" << '\n';
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cctype>
using namespace std;
typedef long long lint;
#define cout cerr
#define ni (next_num<int>())
template<class T>inline T next_num(){
	T i=0;char c;
	while(!isdigit(c=getchar())&&c!='-');
	bool flag=c=='-';
	flag?c=getchar():0;
	while(i=i*10-'0'+c,isdigit(c=getchar()));
	return flag?-i:i;
}
template<class T1,class T2>inline void apmax(T1 &a,const T2 &b){if(a<b)a=b;}
template<class T1,class T2>inline void apmin(T1 &a,const T2 &b){if(b<a)a=b;}
const int N=310,O=1000000007,INF=0x7f7f7f7f;
int mxlim[N][4],mnlim[N][4];
int f[N][N][N];
int main(){
	int n=ni+3;
	memset(mnlim,127,sizeof(mnlim));
	memset(mxlim,0,sizeof(mxlim));
	for(int tot=ni;tot--;){
		int l=ni+3,r=ni+3,t=ni;
		apmin(mnlim[r][t],l);
		apmax(mxlim[r][t],l);
	}
	memset(f,0,sizeof(f));
	f[1][2][3]=1;
	for(int k=3;k<=n;k++){
		for(int i=1,ti=k-2;i<=ti;i++){
			for(int j=i+1;j<k;j++){
				bool flag1=j<mnlim[k][1];
				bool flag2=i<mnlim[k][2]&&j>=mxlim[k][2];
				bool flag3=i>=mxlim[k][3];
				int &F=f[i][j][k];
				if(!(flag1&&flag2&&flag3)){
					F=0;
				}
				if(F==0)continue;
				(f[i][j][k+1]+=F)%=O;//color 1
				(f[i][k][k+1]+=F)%=O;//color 2
				(f[j][k][k+1]+=F)%=O;//color 3
			 }
		}
	}
	lint ans=0;
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			ans+=f[i][j][n];
		}
	}
	printf("%lld\n",ans%O);
	return 0;
}

Measured memory_bytes: 116608
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;
vector<ll> a;
vector<ll> memo(114514, -1ll);

ll dp(int x) {
    if (x < 0) return 0ll;
    if (memo[x] != -1ll) return memo[x];

    if (a[x] == 1) {
        return memo[x] = 0ll;
    }
    if (x == 0) {
        return memo[x] = 1ll;
    }
    
    return memo[x] = (dp(x-1)+dp(x-2))%MOD;
    
}

int main(int argc, char const *argv[]) {
    int n,m;
    cin >> n >> m;
    a.resize(n+10);
    // 1が壊れている
    REP(i,m) {
        int x;
        cin >> x;
        a[x] = 1;
    }
    cout << dp(n) << endl;
    return 0;
}

Measured memory_bytes: 4992
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		Map<String,Integer> mp = new HashMap<String,Integer>();
		long ans=0;
		for(int i=0;i<n;i++) {
			char c[]=sc.next().toCharArray();
			Arrays.sort(c);
			String s=String.valueOf(c);
			if(!mp.containsKey(s)) {
				mp.put(s,0);
			}else {
				int num=mp.get(s)+1;
				ans+=num;
				mp.put(s, num);
			}
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 53440
num = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
split_num = min(a,b,c,d,e)
extra = 0
if num % split_num != 0:
	extra = 1
print(int(num / split_num) + extra + 4)

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


int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  sort(A.begin(),A.end());
  bool can = true;
  int j=2;
  int cnt=0;
  if(N%2 == 0){
    for(int i=0; i<N; i+=2){
      if(A[i] != j-1 || A[i] != A[i+1]){
        can = false;
        break;
      }else{
        j += 2;
        cnt++;
      }
    }
  }else{
    if(A[0] != 0){
      can = false;
    }
    for(int i=1; i<N; i+=2){
      if(A[i] != j || A[i] != A[i+1]){
        can = false;
        break;
      }else{
        j += 2;
        cnt++;
      }
    }
  }
  if(can){
    ll ans = 1;
    for(int i=0; i<cnt; i++){
      ans *= 2;
      ans %= mod;
    }
    cout << ans << endl;
  }else{
    cout << 0 << endl;
  }
  return 0;
}


Measured memory_bytes: 768
#include<iostream>
#include<math.h>#include <cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<cmath>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<string>
#include<string.h>
#include<map>
#include<vector>
#include<set>
#include<algorithm>
#include<stdio.h>
using namespace std;
int main()
{
	int n,a,s1=0,s2=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a;
		if(a%2!=0)
		s1++;
		if(a%4==0)
		s2++;
	}
	if(s1+s2==n)
	{
		if(s1-s2<=1)
		cout<<"Yes";
		else
		cout<<"No";
	}
	else
	{
		if(s2>=s1)
		cout<<"Yes";
		else
		cout<<"No"; 
	} 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int n;
    string s;
    cin>>n>>s;
    if(n%2!=0) cout<<"No"<<endl;
    else{

        bool ok=true;
        for(int i = 0;i<=s.size()/2-1; i++){
            if(s[i]!=s[i+s.size()/2]) {
                //cout<<i<<" "<<i+s.size();
                //cout<<s[i]<<" "<<s[i+s.size()]<<endl;
                ok=false;
            }
        }
        if(ok) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())
D = tuple(map(int, input().split()))
m = int(input())
T = tuple(map(int, input().split()))

from collections import Counter
CD = Counter(D)
CT = Counter(T)
for t, ct in CT.items():
    cd = CD[t]
    if ct > cd:
        print('NO')
        break
else:
    print('YES')


Measured memory_bytes: 57240
N,Q = map(int,input().split())
AB = [list(map(int,input().split())) for _ in [0]*(N-1)]
PX = [list(map(int,input().split())) for _ in [0]*Q]

E = [[] for _ in [0]*N]
for a,b in AB:
    a-=1
    b-=1
    E[a].append(b)
    E[b].append(a)

V = [0]*N
for p,x in PX:
    p-=1
    V[p] += x

q = [0]
done = [False]*N
while q:
    i = q.pop()
    done[i] = True
    for j in E[i]:
        if done[j] : continue
        V[j] += V[i]
        q.append(j)

print(*V)


Measured memory_bytes: 125904
from collections import deque

N = int(input())
A = list(map(int, input().split()))
box = [0] * (N+1)
M = 0
ans = deque()

for i in range(N, 0, -1):
    tmp = 0
    for j in range(i*2, N+1, i):
        tmp += box[j]
    tmp = tmp % 2
    if tmp != A[i-1]:
        box[i] = 1
        M += 1
        ans.appendleft(i)

if M == 0:
    print(0)
else:
    print(M)
    print(*ans)


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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

#define P pair<lli,lli>

signed main(){

	lli n;
	cin>>n;

	map<lli,lli> cnt;
	REP(i,0,n){
		lli a;
		cin>>a;
		cnt[-a]++;
	}

	lli now=0;
	lli d[2];

	for(auto e:cnt){
		lli num = -1*e.first;
		if(e.second>=4){
			d[now]=num;
			now++;
		}
		if(now>=2){
			cout<<d[0]*d[1]<<endl;
			return 0;
		}
		if(e.second>=2){
			d[now]=num;
			now++;
		}
		if(now>=2){
			cout<<d[0]*d[1]<<endl;
			return 0;
		}
	}
	cout<<0<<endl;
	return 0;
}

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

int main(void) {
    int64_t N;
    int64_t l,r,g;
    int64_t last;
    int64_t maxg = 0;
    cin >> N;
    vector<int64_t> A(N);
    for(int i=0;i<N;i++) {
        cin >> A[i];
    }
    vector<int64_t> L(N);
    vector<int64_t> R(N);
    
    last = A[0];
    L[0] = A[0];
    for(int i=1;i<N;i++) {
        last = __gcd(last,A[i]);
        L[i] = last;
    }

    last = A[N-1];
    R[N-1] = A[N-1];
    for(int i=N-2;i>=0;i--) {
        last = __gcd(last,A[i]);
        R[i] = last;
    }

    for(int i=0;i<N;i++) {
        if((i-1) < 0) l = R[i+1];
        else l = L[i-1];
        if((i+1) == N) r = L[i-1];
        else r = R[i+1];

        g = __gcd(l,r);
        if(maxg < g) {
            maxg = g;
        }
    }

    cout << maxg << endl;
    return 0;
}


Measured memory_bytes: 2560
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val t = readLine()!!.split(' ').map { it.toInt() }
    var cur = 1
    t.forEach { if (cur == it) cur++ }
    println(if (cur == 1) -1 else n - cur + 1)
}

Measured memory_bytes: 80772
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans, mod = 0, 0

for i in range(N):

    if mod > A[i]:
        ans += A[i]
        A[i] = 0
    else:
        ans += mod
        A[i] -= mod
        mod = 0

    if B[i] > A[i]:
        ans += A[i]
        mod = B[i] - A[i]
    else:
        ans += B[i]
        mod = 0

ans += min(mod, A[N])

print(ans)


Measured memory_bytes: 18624
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;

int main() {
	int N, D, X;
	cin >> N >> D >> X;

	for (int i = 0; i < N; i++) {
		X++;
		int A;
		cin >> A;

		int n = A;
		while (n + 1 <= D) {
			X++;
			n += A;
		}
	}

	cout << X << endl;
}

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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define PB push_back
#define MP make_pair
#define ALL(x) (x).begin(),(x).end()
typedef long long ll;

string S,T,R;

int main()
{
	cin >> S >> T >> R;
	char cur = 'a';
	int a = 0,b = 0,c = 0;

	while(true){
		if(cur == 'a'){
			if(a == S.size()){
				break;
			}
			cur = S [a++];
		}
		else if(cur == 'b'){
			if(b == T.size()){
				break;
			}
			cur = T [b++];
		}
		else{
			if(c == R.size()){
				break;
			}
			cur = R [c++];
		}
	}

	cur += 'A' - 'a';
	cout << cur << endl;

	return 0;
}


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

int main()
{
    string s1,s2;
    cin>>s1>>s2;
    s1=(s1+s2);
    int k,x;
    k=stoi(s1);
    x=sqrt(k);
    if(x*x==k)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}



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

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

  int result =  n % 1000 == 0 ? 0 : 1000 - (n % 1000);

  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3592
#editorial
x,y=map(int, input().split())
ans=10**12
#00
if y-x>0:
    ans=min(ans,y-x)
#10
if y+x>=0:
    ans=min(ans,y+x+1)
#01
if -y-x>=0:
    ans=min(ans,-y-x+1)

if x-y>0:
    ans=min(ans,x-y+2)

print(ans)

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

int gcd(int a,int b){
    if(a > b) swap(a,b);
    if(b % a == 0) return a;
    return gcd(a, b%a);
}

int main() {
    int N,X;
    cin >> N >> X;
    int x[N];
    for(int i=0;i<N;i++){
        cin >> x[i];
        x[i] -= X;
        x[i] = max(x[i], -x[i]);
    }
    int ans=x[0];
    for(int i=1;i<N;i++){
        ans = gcd(ans, x[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


ll N,X,M;
int pre[201010];
ll A[201010],S[201010];
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>X>>M;
	MINUS(pre);
	A[1]=S[1]=X;
	pre[X]=1;
	int start,loop;
	for(i=2;i<=201010;i++) {
		A[i]=(A[i-1]*A[i-1])%M;
		S[i]=S[i-1]+A[i];
		
		if(i==N) {
			cout<<S[i]<<endl;
			return;
		}
		
		if(pre[A[i]]>=0) {
			start=pre[A[i]];
			loop=i-pre[A[i]];
			break;
		}
		pre[A[i]]=i;
	}
	
	ll ret=0;
	ll lp=(N-start)/loop;
	ret+=lp*(S[start+loop]-S[start]);
	N-=lp*loop;
	ret+=S[N];
	cout<<ret<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 5172
#include <stdio.h>
#define MAX 2000000


int heap[MAX];
char Ch[100];
int heap_size=0;


void maxheapify(int j){
  int largest,leftH,rightH;
    int tmp;
 

    leftH = Left(j);


    rightH = Right(j);

  if(leftH <= heap_size && heap[leftH] > heap[j]){
    largest=leftH;
  }

  else {
    largest=j;
  }

  if(rightH <= heap_size && heap[rightH] > heap[largest]){
   
 largest=rightH;

  }
  if(largest != j){

    tmp=heap[j];

     heap[j]=heap[largest];
    heap[largest]= tmp;


    maxheapify(largest);
  }
}
 




void heapIncreaseKey(int,int);
 
void maxHeapInsert(int key){
  heap_size = heap_size+1;
  heap[heap_size]=-1;
  heapIncreaseKey(heap_size,key);
}
 
void heapIncreaseKey(int i,int key){
  int tree;
  if(key < heap[i]){
    return ;
  }
  heap[i]=key;
  while(i > 1 && heap[Parent(i)] < heap[i]){
   
    tree = heap[i];
    heap[i]=heap[Parent(i)];


    heap[Parent(i)]=tree;
    i = Parent(i);
  }
}
 
int heapExtractMax(){
  int m;
  if(heap_size < 1){
    return -1;
  }
  m = heap[1];
  
  heap[1]=heap[heap_size];
  heap_size = heap_size -1;
  maxheapify(1);
  return m;
}
 


int Parent(int i){

  return(i/2);
}


int Left(int i){

  return 2*i;
}

int Right(int i){

  return 2*i+1;
}

int main(){

  int i;


while(1){
    scanf("%s",Ch);
    if(Ch[0]=='i'){

      scanf("%d",&i);

      maxHeapInsert(i);

    } 
    else if(Ch[2]=='d'){
      break;
    } 

    else {
      printf("%d\n",heapExtractMax());
    }
  }
  
  return 0;
}

Measured memory_bytes: 4696
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#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;
//const long long MOD = 998244353;
using namespace std;

ll dp[105][2];

int main(int argc, char* argv[])
{
    int n,P;
    scanf("%d%d", &n, &P);
    int i;
    dp[0][0]=1;
    for(i=1; i<=n; i++) {
        int tmp;
        scanf("%d", &tmp);
        dp[i][0]=dp[i-1][0];
        dp[i][1]=dp[i-1][1];
        if(tmp%2) {
            dp[i][0]+=dp[i-1][1];
            dp[i][1]+=dp[i-1][0];
        }
        else {
            dp[i][0]+=dp[i-1][0];
            dp[i][1]+=dp[i-1][1];
        }    
    }
    printf("%lld\n", dp[n][P]);

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>

using namespace std;

#define RPT(i, b, e) for (int i = (b); i <= (e); i++)
#define RPT0(i, n) RPT(i, 0, n - 1)
#define RPT1(i, n) RPT(i, 1, n)

void resolve()
{
    int N;
    cin >> N;
    vector<int> X(N);
    RPT0(i, N) cin >> X[i];

    double average;
    RPT0(i, N) average += X[i];
    average /= N;
    int P = (int)(average + 0.5);

    int ans = 0;
    RPT0(i, N) ans += (P - X[i]) * (P - X[i]);

    cout << ans << endl;
}

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


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long LL;
LL T;
long long GCD(long long a,long long b)
{
	if(a<b) swap(a,b);
	long long r=a%b;
	while(r)
	{
		r=a%b;
		a=b;b=r;
	}
	return a;
}
int main() {
	scanf("%d",&T);
	for(int i=1;i<=T;i++) {
		LL a,b,c,d;bool flag=true;
		scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
		if(b>d||a<b) {
			printf("No\n");
			continue;
		}
		if(c>=b) {
			printf("Yes\n");
			continue;
		}
		LL x=a%b,y=GCD(d,b);
		LL k1=x;
		LL k2=(x+y)%b;
		LL delta=k2-k1;
		if(c<k1||c<k2)
			flag=false;
		else if(delta==0)
			flag=true;
		else if(delta>0) {
			if(k1+(c-k1+delta)/delta*delta<b)
				flag=false;
		}
		else {
			LL you=(k1+delta-1)/delta*delta-k1;
			if(you>0&&b-you>c)
				flag=false;
		}
		if(flag) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include <vector>
#include<algorithm>
#include <climits>

using namespace std;
int main()
{
    // 整数の入力
    int number;
    cin >> number;

  // スペース区切りの整数の入力
  std::vector<int> data(number);
  int counter = 0;
  int min = INT_MAX;
  for(int i = 0; i < number; i++) {
	int tmp;
    cin >> tmp;
    if (min >= tmp) {
      counter++;
      min = tmp;
    }
    data.push_back(tmp);
  }
  cout << counter << endl;
  
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
const int oo = 1e9;
int main()
{
    int no_of_stones, no_of_steps;
    cin >> no_of_stones >> no_of_steps;
    vector <int> height(no_of_stones + 1, 0);
    for(int i = 1; i <= no_of_stones; i++)
    {
        cin >> height[i];
    }
    vector<int>minimum_cost(no_of_stones + 1, oo);
    minimum_cost[1] = 0;
    for(int i=2;i<=no_of_stones;i++)
    {
        for(int j=i-1;j>=max(1,i-no_of_steps);j--)
        {
            minimum_cost[i] = min(minimum_cost[i], minimum_cost[j] + abs(height[i] - height[j]));
        }
    }
    cout << minimum_cost[no_of_stones];
    return 0;
}

Measured memory_bytes: 1024