akhauriyash/Code-Regression huggingface dataset:
n,x = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
for i in range(1,n):
  t = a[i-1]+a[i]-x
  if t <= 0:
    continue
  elif t <= a[i]:
    a[i] -= t
    ans += t
  else:
    a[i] = 0
    a[i-1] -= t-a[i]
    ans += t
print(ans)

Measured memory_bytes: 63984
#include <stdio.h>

int gcd(int a, int b, int c){
  
  int min=a;
  if(min>b) min=b;
  if(min>c) min=c;
  
  while(1){    
    if(a%min==0 && b%min==0 && c%min==0) break;
    min--;
  }
  
  return min;
}

int main(){
  int a,b,c,n;
  long int ans=0; 
  
  scanf("%d",&n);
  
  for(a=1; a<=n; a++){
    for(b=1; b<=n; b++){
      for(c=1; c<=n; c++){
        ans+=gcd(a,b,c);
      }
    }
  }
  
  printf("%ld\n",ans);
  
  return 0;
}

Measured memory_bytes: 1724
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<array>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

#ifdef ONLINE_JUDGE
#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
#define int128 __int128
#else
#define int128 long long
#endif

#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(nullptr));

ll const mod = 1e9 + 7;

namespace {
	ll mul(ll a, ll b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) val += mod;
		if (val >= mod) val -= mod;
		return val;
	}

	ll poww(ll a, ll b) {
		ll val = 1;
		a %= mod;
		while (b > 0) {
			if (b % 2) val = mul(a, val);
			a = mul(a, a);
			b >>= 1;
		}
		return val % mod;
	}

	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

int const maxn = 3e5 + 5;

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	ll x, y, a, b, c; cin >> x >> y >> a >> b >> c;

	vector<ll>p(a), q(b), r(c);
	for (ll i = 0; i < a; i++) cin >> p[i];
	for (ll i = 0; i < b; i++) cin >> q[i];
	for (ll i = 0; i < c; i++) cin >> r[i];

	sort(all(p)); sort(all(q)); sort(all(r));
	reverse(all(p)); reverse(all(q)); reverse(all(r));

	ll ans = 0;
	for (ll i = 0; i < x; i++) {
		ans += p[i];
	}
	for (ll i = 0; i < y; i++) {
		ans += q[i];
	}
	ll i = x - 1, j = y - 1;
	for (ll ii = 0; ii < r.size(); ii++) {
		ll kek1 = -1;
		if (i >= 0) kek1 = r[ii] - p[i];
		ll kek2 = -1;
		if(j >=0 ) kek2 = r[ii] - q[j];
		if (kek1 < 0 and kek2 < 0) break;
		if (kek1 > kek2) {
			ans += kek1;
			i--;
		} else {
			ans += kek2;
			j--;
		}
	}

	cout << ans << endl;




	return 0;
}

/*
8 6

4 5 1 2 3 5 3 3

*/

Measured memory_bytes: 2688
#include<bits/stdc++.h>
#define f first
#define s second
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
set<P> s;
int n,sx,sy,gx,gy,lx,ly;
int dx[6]={0,1,1,0,-1,-1};
int dy[2][6]={
  {1,0,-1,-1,-1,0},
  {1,1,0,-1,0,1}
};

bool used[6][211][211];

int cal(){
  priority_queue<PP,vector<PP>,greater<PP> > Q;
  Q.push(PP(P(0,0),P(sx,sy)));
  while(!Q.empty()){
    PP p=Q.top();
    Q.pop();
    int c=p.f.f,t=p.f.s%6,x=p.s.f,y=p.s.s;
    if(used[t][y+ly][x+lx])continue;
    used[t][y+ly][x+lx]=1;
    if(x==gx&&y==gy)return c;
    for(int i=0;i<6;i++){
      int nx=x+dx[i],ny=y+dy[abs(x)%2][i];
      if(abs(nx)>lx||abs(ny)>ly||s.count(P(nx,ny)))continue;
      Q.push(PP(P(c+((abs(x*y*t)%6)!=i),t+1),P(nx,ny)));
    }
    Q.push(PP(P(c+1,t+1),P(x,y)));
  }
  
  return -1;
}

int main(){
  cin>>sx>>sy>>gx>>gy;
  cin>>n;
  for(int i=0,x,y;i<n;i++){
    cin>>x>>y;
    s.insert(P(x,y));
  }
  cin>>lx>>ly;
  cout<<cal()<<endl;
  return 0;
}

Measured memory_bytes: 3944
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    X,Y,Z = LI()
    xyz = sorted([LI() for _ in range(X+Y+Z)], key=lambda x: x[0]-x[1])
    ys = xyz[:Y]
    yq = []
    tr = 0
    for x,y,z in ys:
        heapq.heappush(yq, y-z)
        tr += y
    ya = [tr]
    for i in range(Z):
        x,y,z = xyz[Y+i]
        tr += y
        heapq.heappush(yq, y-z)
        t = heapq.heappop(yq)
        tr -= t
        ya.append(tr)

    xs = xyz[Y+Z:]
    xq = []
    tr = 0
    for x,y,z in xs:
        heapq.heappush(xq, x-z)
        tr += x
    xa = [tr]
    for i in range(Z):
        x,y,z = xyz[-X-i-1]
        tr += x
        heapq.heappush(xq, x-z)
        t = heapq.heappop(xq)
        tr -= t
        xa.append(tr)

    r = 0
    for a,b in zip(ya, xa[::-1]):
        tr = a+b
        if r < tr:
            r = tr

    return r




print(main())


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef double dd;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
typedef vector<pair<ll, ll>> vpll;
typedef pair<ll, ll> pll;

#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define all(c) (c).begin(), (c).end()
#define MOD 1000000007
#define MAX 1e5 + 10

vector<int> p;

int dsu_get (int v) {
    return (v == p[v]) ? v : (p[v] = dsu_get (p[v]));
}

void dsu_unite (int a, int b) {
    a = dsu_get (a);
    b = dsu_get (b);
    if (rand() & 1)
        swap (a, b);
    if (a != b)
        p[a] = b;
}

int main(){
#ifdef HOME
    freopen("kek.in", "r", stdin);
    freopen("kek.out", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    p.resize(n);
    vpll x(n);
    vpll y(n);
    vector<pair<ll, pll>> g;
    for(int i = 0; i < n; i++) {
        cin >> x[i].ff >> y[i].ff;
        x[i].ss = i;
        y[i].ss = i;
    }
    sort(all(x));
    sort(all(y));
    for(int i = 0; i < n - 1; i++)
        g.pb(mp(abs(x[i].ff - x[i + 1].ff), mp(x[i].ss, x[i + 1].ss)));
    for(int i = 0; i < n - 1; i++)
        g.pb(mp(abs(y[i].ff - y[i + 1].ff), mp(y[i].ss, y[i + 1].ss)));
    sort(all(g));

    ll m = g.size();
    ll cost = 0;
    for (int i=0; i<n; ++i)
        p[i] = i;
    for (int i=0; i<m; ++i) {
        int a = g[i].second.first,  b = g[i].second.second,  l = g[i].first;
        if (dsu_get(a) != dsu_get(b)) {
            cost += l;
           // res.push_back (g[i].second);
            dsu_unite (a, b);
        }
    }
    cout << cost;
    return 0;
}

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

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);
  int n, a, b, c, d; cin >> n >> a >> b >> c >> d;
  a--;
  b--;
  c--;
  d--;
  string s; cin >> s;
  bool rock = false;
  for(int i=b;i<d;++i) {
    if(s[i] == '#' && rock) {
      cout << "No" << endl;
      return 0;
    } else if(s[i] == '#') {
      rock = true;
    } else {
      rock = false;
    }
  }

  rock = false;
  for(int i=a;i<c;++i) {
    if(s[i] == '#' && rock) {
      cout << "No" << endl;
      return 0;
    } else if(s[i] == '#') {
      rock = true;
    } else {
      rock = false;
    }
  }

  if(b < a && c < d) {
    bool ok = false;
    for(int i=a;i<=c;++i) {
      if(s[i] != '#' && s[i-1] != '#' && s[i+1] != '#') {
        ok = true;
        break;
      }
    }
    if(!ok) {
      cout << "No" << endl;
      return 0;
    }
  } else if(a < b && d < c) {
    bool ok = false;
    for(int i=b;i<=d;++i) {
      if(s[i] != '#' && s[i-1] != '#' && s[i+1] != '#') {
        ok = true;
        break;
      }
    }
    if(!ok) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
}


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

using namespace std;

using ll = long long;

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

    constexpr int n = 5;
    vector<int> idx(n);
    iota(idx.begin(), idx.end(), 0);

    vector<int> take_time(n);
    for (int i = 0; i < n; ++i)
        cin >> take_time[i];

    int min_time = INT_MAX;
    do {
        int cur_time = 0;
        for (int i = 0; i < n; ++i) {
            if (cur_time % 10 == 0) {
                cur_time += take_time[idx[i]];
            }
            else {
                int add_time = 10 - cur_time % 10;
                cur_time += add_time + take_time[idx[i]];
            }
        }
        min_time = min(min_time, cur_time);

    } while (next_permutation(idx.begin(), idx.end()));

    cout << min_time << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<functional>
#include<algorithm>
using namespace std;
int main() {
	int a, b, c, sum = 0;
	cin >> a >> b >> c;
	for (int i = a; i <= b; i++) {
		if (c%i == 0) sum++;
	}
	cout << sum << endl;
}

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

//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//template <typename T> using orderMSet =
//tree <T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef unsigned long long llu;
#define filein freopen("input.txt", "r", stdin)
#define fileout freopen("output.txt", "w", stdout)
#define inf 1000000000000000018
#define mod 1000000007
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>

#define MX 200005
ll arr[MX];

int main()
{
	ll k, n, diff = 0;
	cin>>k>>n;

	for(int i = 0; i < n; i++) {
		cin>>arr[i];
	}

	for(int i = 1; i < n; i++) {
        diff = max(diff, arr[i]-arr[i-1]);
	}
	diff = max(diff, k-arr[n-1]+arr[0]);

	cout<<k-diff<<endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  int ans = 1e9;
  ans = min(a*x+b*y, ans);
  ans = min(max(x,y)*2*c, ans);
  if(x > y)
    ans = min(2*c*y+(x-y)*a, ans);
  else
    ans = min(2*c*x+(y-x)*b, ans);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
s = str(input())
r, g, b = map(s.count, "RGB")
ans = r*g*b
for i in range(n):
    for j in range(i+1, n):
        k = 2*j - i
        if k<n and len(set([s[i], s[j], s[k]])) == 3:
            ans -= 1
print(ans)

Measured memory_bytes: 73820
from itertools import accumulate

def runlength(S):
    cnt = 1
    A = []
    for i in range(len(S)-1):
        if S[i] == S[i+1]:
            cnt += 1
        else:
            A.append(cnt)
            cnt = 1
    else:
        A.append(cnt)

    return A


def main():
    N, K = map(int, input().split())
    S = input()
    T = []
    prev = '1'
    cnt = 0
    for c in S:
        if prev == c:
            cnt += 1
        else:
            T.append(cnt)
            cnt = 1
        prev = c
    
    T.append(cnt)    
    if prev == '0':
        T.append(0)

    w = 2 * K + 1
    if len(T) <= w:
        print(N)
        exit()

    acc = [0] + list(accumulate(T))
    ans = 0
    for i in range(0, len(T) - w + 1, 2):
        ans = max(ans, acc[i+w] -acc[i])

    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 86156
#include<stdio.h>

int main(){
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if(x - r >= 0 && x + r <= W){
        if(y - r >= 0 && y + r <= H){
            printf("Yes\n");
            return 0;
        }
    }
    
    printf("No\n");
    return 0;
}


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

int main()
{
long long N;
cin>>N;
long long ans=0;
for(long long i=2;i*i<=N;i++)
{
	if(N%i==0)
	{
		
		if(N/(i-1)==N%(i-1))ans+=i-1;
		
		if(N/((N/i)-1)==N%((N/i)-1))ans+=N/i-1;
		}
	}
	if(N!=2)
	ans+=N-1;
	cout<<ans;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	char x,y,z;
	int cup[3]={1,0,0},a,b,c;
	for(;;){
		if(scanf("%c,%c",&x,&y) == EOF){break;}
		scanf("%c",&z);
		if(x == 'A'){a = 0;}
		if(x == 'B'){a = 1;}
		if(x == 'C'){a = 2;}
		if(y == 'A'){b = 0;}
		if(y == 'B'){b = 1;}
		if(y == 'C'){b = 2;}
		c = cup[a];
		cup[a] = cup[b];
		cup[b] = c;
	}
	if(cup[0] == 1){printf("A\n");}
	else if(cup[1] == 1){printf("B\n");}
	else if(cup[2] == 1){printf("C\n");}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define MOD 1000000007
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define rep(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
inline ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
inline ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
inline ll char_to_ll(char c) { return (int)(c - '0'); }
inline ll string_to_ll(string s) { return atoi(s.c_str()); }
inline bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }

int main(){
    ll a, b;
    cin >> a >> b;
    printf("%lld %lld %.10f\n", a / b, a % b, double(a) / double(b));

    return 0;
}



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

int main()
{
	int n, s[1000];
	double avg, t;
	cin.tie(0);
	while (cin >> n && n > 0) {
		avg = 0;
		for (int i = 0; i < n; i++) {
			cin >> s[i];
			avg += s[i];
		}
		avg /= n;

		t = 0;
		for (int i = 0; i < n; i++) {
			t += (s[i] - avg) * (s[i] - avg);
		}
		printf("%.8lf\n", sqrt(t / n));
	}
}


Measured memory_bytes: 3152
h,w=map(int,input().split())
town=[]
for i in range(h):
    town.append(list(map(int,input().split())))
ans=float("inf")
for i in range(h):
    for j in range(w):
        ans_i=0
        for k in range(h):
            for l in range(w):
                ans_i+=min(abs(k-i),abs(l-j))*town[k][l]
        ans=min(ans,ans_i)
print(ans)


Measured memory_bytes: 5612
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 10e+6
#define DEKA 1000000007

using namespace std;



int main(){
    int n;
    cin >> n;
    double a[n+10];
    long max=0;
    long max2=0;
    for (int i=0;i<n;i++) {
        cin >> a[i];
        if(max<=a[i]) max=a[i];
    }
    double f=max;
    double kijun=f/2;
    for(int i=0;i<n;i++){
        double d=abs(a[i]-kijun);
        double e=abs(max2-kijun);
        if(d<=e) max2=a[i];
    }
    cout << max << " " << max2 << endl;
}

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



int main(){
  int n,res, ans;;
  cin >> n;
  
  res = n%500;
  ans += n/500*1000;
  ans += res/5*5;
  
  cout << ans << endl;
  
  
}

Measured memory_bytes: 256
#include <stdio.h>

char *decrypt_caesar(char *s);

int main(void)
{
	char str[1001];
	
	gets(str);
	puts(decrypt_caesar(str));
	return (0);
}

char *decrypt_caesar(char *s)
{
	int i;
	
	for (i = 0; s[i] != '\0'; i++) {
		s[i] = 'A' + (s[i] - 'A' + 23) % 26;
	}
	return (s);
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define ins insert

#define debug(a) cerr<<(a)<<endl
#define dbrep(a,n) rep(_i,n) cerr<<(a[_i])<<" "; cerr<<endl
#define dbrep2(a,n,m) rep(_i,n){rep(_j,m) cerr<<(a[_i][_j])<<" "; cerr<<endl;}

using namespace std;

template<class A, class B>
ostream &operator<<(ostream &os, const pair<A,B> &p){return os<<"("<<p.fi<<","<<p.se<<")";}
template<class A, class B>
istream &operator>>(istream &is, pair<A,B> &p){return is>>p.fi>>p.se;}

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin>>N;
    vi a(N);
    rep(i,N) cin>>a[i];
    bool same=true;
    rep(i,N-1)if(a[i]!=a[i+1]) same=false;

    bool yes;
    if (same){
        yes = (a[0]==N-1 || a[0]<=N/2);
    }else{
        int high = *max_element(all(a));
        int low = high-1;
        rep(i,N)if(!(a[i]==low||a[i]==high)){
            cout<<"No\n";
            return 0;
        }
        int xcnt=0,ocnt=0;
        rep(i,N){
            if (a[i]==high) xcnt++;
            else ocnt++;
        }
        yes = (xcnt>=2 && ocnt+1<=high && high<=ocnt+xcnt/2);
    }
    cout<<(yes?"Yes":"No")<<"\n";
    return 0;
}


Measured memory_bytes: 3680
from itertools import*
s,k=open(0)
k=int(k)
g=[len(list(v))for _,v in groupby(s)]
print(sum(c//2for c in g)*k-(g[0]*g[-2]%2*s[0]==s[-2])*(-k//2**(len(s)-1==g[0])+1))

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

int main(void) {
	ll a,b,v,w,t;
	cin >> a >> v >> b >> w >> t;
	if (a > b) {
  		if (a-v*t <= b-w*t) {
      		cout << "YES" << "\n";
      		return 0;
    	}
    }
  	if (a < b) {
  		if (a+v*t >= b+w*t) {
      		cout << "YES" << "\n";
      		return 0;
    	}
    }
	cout << "NO" << "\n";
	return 0;
}

Measured memory_bytes: 3680
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <string.h>
#include <string>
#include <cmath>
#include <cstdio>
#include <functional>
#include <map>
#include <typeinfo>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<double, double> pd;
typedef pair<ll, ll> pl;


int main()
{
  int n, a;
  scanf("%d %d", &n, &a);
  
  if(n % a == 0)
    printf("%d\n", n/a);
  else
    printf("%d\n", n/a+1);
  
  return 0;
}


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

int main() {
    int n;
    cin>>n;
    int c[n],b[n];
    c[0]=0;
    cin>>b[0];
    for(int i=1;i<n;i++){
        cin>>b[i];
        if(b[i]>b[i-1]){
            c[i]=0;
        }
        else{
            c[i]=c[i-1]+1;
        }
    }
    sort(c,c+n);
    cout<<c[n-1];
	return 0;
}


Measured memory_bytes: 4332
#include"stdio.h"
typedef long long ll;
int main(void)
{
	ll n,m,s;
	scanf("%lld%lld",&n,&m);
	if(2*n<=m)
	s=n+(m-2*n)/4;
	else
	s=m/2;
    printf("%lld",s);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const LL P = 1e9+7;

LL fp(LL a, LL n){
    if(n== 0)
        return 1;

    LL h = fp(a , n / 2);
    h = h*h %P;
    if(n&1){
        h = h * a %P;
    }

    return h;
}

LL fac(LL n){
    LL r = 1;
    for(int i=2;i<=n;i++){
        r = r * i % P;
    }
    return r;
}
LL C(LL m, LL n){
    LL num = 1;
    for(int i=m-n+1;i<=m;i++)
        num = num * i % P;
    return num * fp(fac(n), P-2) % P;
}
int main(){
    LL n, a, b;
    cin >>n>>a>>b;
    LL res = fp(2, n) - 1 - C(n, a) - C(n, b);
    res %= P;
    if(res < 0)
        res += P;
    cout <<res;
}


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

using namespace std ;
typedef long long ll;
typedef string str;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll ;
typedef vector<int> vint;
typedef vector<double> vdou ;
typedef vector<ll> vll;
typedef vector<vint> vvint;
typedef vector<str> vstr;
typedef vector<pii> vpii ;
typedef vector<pll> vpll ;

#define REP(i, n) for (ll (i) = 0; (i) < (ll)(n); i++) 
#define FOR(i, a, b) for(ll (i) = a; (i) < (ll)b; i++)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define CHI 1000000000000000003
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define NP next_permutation
#define SZ(x)  (ll)x.size()
#define SP(x)  setprecision((ll)x)

const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const double PI = M_PI;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}
//-----------------------------------------




















//-----------------------------------------
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  str s ;
  cin >> s ;
  int ans = INF ;
  REP(i,26){
    str t ;
    t = (char)('a'+i) + s + (char)('a'+i) ;
    int n = SZ(t) ;
    int maxi = 0 ;
    int tmp = 0 ;
    REP(j,n){
      if(t[j]!=(char)('a'+i)){
        tmp++; 
      }
      else{
        tmp = 0 ;
      }
      maxi = max(maxi,tmp) ;
    }
    ans = min(ans,maxi) ;
  }
  cout << ans <<endl ;
        
      
  
  
  
  return 0 ;
}



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

typedef double LD;
typedef long long LL;
typedef pair<int, int> PII;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())

const LL MOD = 1000000007;
const LL INF = 1e9;
const LL LINF = INF * INF;
const LL MAXN = 100007;

int A[MAXN];
LL S[MAXN], SP[MAXN];

int main()
{
	ios_base::sync_with_stdio(0);
	//freopen("In.txt", "r", stdin);
	int n, k;
	LL ans = -LINF;
	cin >> n >> k;
	FOR(i, 1, n + 1) cin >> A[i];
	S[0] = 0; SP[0] = 0;
	FOR(i, 1, n + 1)
	{
		S[i] = S[i - 1] + A[i];
		SP[i] = SP[i - 1] + max(0, A[i]);
	}
	FOR(i, 1, n - k + 2)
		ans = max(ans, SP[i - 1] + SP[n] - SP[i + k - 1] + max(0LL, S[i + k - 1] - S[i - 1]));
	cout << ans;
	//cout << endl; system("pause");
	return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define rep(i,j,k) for(int i=j;i<=k;i++)
#define rep2(i,j,k) for(int i=j;i>=k;i--)
using namespace std;
template<typename T> void read(T &num){
	char c=getchar();T f=1;num=0;
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){num=(num<<3)+(num<<1)+(c^48);c=getchar();}
	num*=f;
}
template<typename T> void qwq(T x){
	if(x>9)qwq(x/10);
	putchar(x%10+'0');
}
template<typename T> void write(T x){
	if(x<0){x=-x;putchar('-');}
	qwq(x);putchar('\n');
}
template<typename T> void chkmin(T &x,T y){x=x<y?x:y;} 
char c[110][110];int dp[110][110];
inline int d(char a,char b){
	return ((a=='.')&&(b=='#'));
}

int main(){
	int n,m;read(n);read(m);
	rep(i,1,n){
		rep(j,1,m)cin>>c[i][j];
	}
	
	memset(dp,127,sizeof(dp));
	dp[1][0]=0;c[1][0]='.';
	rep(i,1,n){
		rep(j,1,m){
			chkmin(dp[i][j],dp[i][j-1]+d(c[i][j-1],c[i][j]));
			if(i>1)chkmin(dp[i][j],dp[i-1][j]+d(c[i-1][j],c[i][j]));
		}
	} 
	write(dp[n][m]);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int N;
	scanf("%d",&N);
	int A[N],i;
	for(i=0;i<N;i++) scanf("%d",&A[i]);
	double B[N];
	double ans;
	for(i=0;i<N;i++){
		B[i] = 1.0/(double)A[i];
		ans += B[i];
	}
	ans = 1.0/ans;
	printf("%lf",ans);
	
	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x1 = Integer.parseInt(sc.next());
		int y1 = Integer.parseInt(sc.next());
		int x2 = Integer.parseInt(sc.next());
		int y2 = Integer.parseInt(sc.next());
		sc.close();

		int x = x2 - x1;
		int y = y2 - y1;

		System.out.print(x2 - y + " ");
		System.out.print(y2 + x + " ");
		System.out.print(x2 - y - x + " ");
		System.out.println(y2 + x - y);
	}

}


Measured memory_bytes: 23508
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt(), h = sc.nextInt(), n = sc.nextInt();
		int xmax = w, ymax = h, xmin = 0, ymin = 0;
		for (int i = 0 ; i < n ; i++) {
			int x = sc.nextInt(), y = sc.nextInt(), a = sc.nextInt();
			if (a == 1) xmin = Math.max(xmin, x);
			if (a == 2) xmax = Math.min(xmax, x);
			if (a == 3) ymin = Math.max(ymin, y);
			if (a == 4) ymax = Math.min(ymax, y);
		}
		if (xmax - xmin < 0 || ymax - ymin < 0) {
			System.out.println("0");
		}else {
			System.out.println((xmax - xmin) * (ymax - ymin));
		}
	}
} 

Measured memory_bytes: 23380
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int x = sc.nextInt();

            int ans = 1;
            for (int i = x; i > 0; i--) {
                boolean ok = false;
                for (int b = 1; b <= 40; b++) {
                    for (int p = 2; p <= 10; p++) {
                        if (i == pow(b, p)) {
                            ans = i;
                            ok = true;
                            break;
                        }
                    }
                    if (ok) {
                        break;
                    }
                }
                if (ok) {
                    break;
                }
            }

            System.out.println(ans);
        }
    }

    // baseのn乗を計算を返す
    static int pow(int base, int n) {
        int ret = 1;
        for (int i = 0; i < n; i++) {
            ret *= base;
        }
        return ret;
    }

}


Measured memory_bytes: 22356
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<vector>
#define inf 2147483647
#define rep(i,a,b) for(int i=a;i<b;i++)
#define  rr read()
#define repb(i,a,b) for(int i=a;i<=b;i++)
#define CloseIo   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll long long
using namespace std;
const int N = 1e5 + 5;
const ll mo = 1e10 +7;
const int M = 100+50;
const ll mod = 998244353;
int main(){
	int a,b,c,d,e,k;
	cin>>a>>b>>c>>d>>e>>k;
	int s[15]={0};
	s[0]=b-a;s[1]=c-a;s[2]=d-a;s[3]=e-a;
	s[4]=c-b;s[5]=d-b;s[6]=e-b;
	s[7]=d-c;s[8]=e-c;s[9]=e-d;
	for(int i=0;i<10;i++)
		if(s[i]>k){
			cout<<":("<<"\n";
			return 0;
		}
	cout<<"Yay!"<<"\n";
    return 0;
}

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

namespace problem
{
  class Test
  {
    static void Main()
    {
      var S = new List<int>();
      var H = new List<int>();
      var C = new List<int>();
      var D = new List<int>();

      int i = int.Parse(Console.ReadLine());
      for (int a = 0; a < i; a++)
      {
        var s = Console.ReadLine().Split();
        switch (s[0])
        {
          case "S":
            S.Add(int.Parse(s[1]));
            break;
          case "H":
            H.Add(int.Parse(s[1]));
            break;
          case "C":
            C.Add(int.Parse(s[1]));
            break;
          case "D":
            D.Add(int.Parse(s[1]));
            break;
        }
      }
     // S.Sort(); H.Sort(); S.Sort(); D.Sort();

      for (int m = 0; m < 13; m++)
      {
        if (!S.Contains(m + 1)) Console.WriteLine("S {0}", m + 1);
      }
      for (int m = 0; m < 13; m++)
      {
        if (!H.Contains( m + 1)) Console.WriteLine("H {0}", m + 1);
      }
      for (int m = 0; m < 13; m++)
      {
        if (!C.Contains(m + 1)) Console.WriteLine("C {0}", m + 1);
      }
      for (int m = 0; m < 13; m++)
      {
        if (!D.Contains(m + 1)) Console.WriteLine("D {0}", m + 1);
      }
    }
  }
}


Measured memory_bytes: 9680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int inf = 1e9;
double pi = 3.14159265359;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, b, a) for (int i = a - 1; i >= b; i--)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

int main() {
    int h, w;
    cin >> h >> w;
    char grid[h][w];
    rep (i, 0, h) rep (j, 0, w) cin >> grid[i][j];
    int cnt[h][w];
    rep (i, 0, h) rep (j, 0, w) cnt[i][j] = 0;
    int cnt2[h][w];
    rep (i, 0, h) rep (j, 0, w) cnt2[i][j] = 0;
    rep (i, 0, h) {
        int sum = 0;
        rep (j, 0, w) {
            if (grid[i][j] == '.') cnt[i][j] = ++sum;
            else {
                sum = 0;
            }
        }
        per (j, 0, w) {
            if (grid[i][j] == '.' && j + 1 < w)
                cnt[i][j] = max (cnt[i][j + 1], cnt[i][j]);
        } /*
         rep (j, 0, w) { cout << cnt[i][j]; }
         cout << "\n";*/
    }
    rep (j, 0, w) {
        int sum = 0;
        rep (i, 0, h) {
            if (grid[i][j] == '.') cnt2[i][j] = ++sum;
            else {
                sum = 0;
            }
        }
        per (i, 0, h) {
            if (grid[i][j] == '.' && i + 1 < h)
                cnt2[i][j] = max (cnt2[i + 1][j], cnt2[i][j]);
        }
    } /*
     cout << "\n";
     rep (i, 0, h) {
         rep (j, 0, w) cout << cnt2[i][j];
         cout << "\n";
     }*/
    int ans = 0;
    rep (i, 0, h) rep (j, 0, w) ans = max (ans, cnt[i][j] + cnt2[i][j] - 1);
    cout << ans << "\n";
}

Measured memory_bytes: 35456
#include<bits/stdc++.h>
    using namespace std;
     
    int main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
     
        string s,t;
      cin>>s>>t;
      t.pop_back();
      if(t==s) cout << "Yes";
      else cout << "No";
      
      
     
    }

Measured memory_bytes: 3596
#include <cstdio>
#include <queue>
using namespace std;

#define iter(i, n) for (int i = 1; i <= n; ++i)

#define INA -1
#define INB +1
#define INC 0

const int NR = 1e5 + 20;

typedef long long i64;

int status[NR];
int X, Y, Z;
int a[NR], b[NR], c[NR];
typedef pair<int, int> pii;

#define fi first
#define se second

priority_queue<pii> ab, ac, bc;

int topBC() { while (status[bc.top().se] != INC) bc.pop(); return bc.top().se; }
int topAC() { while (status[ac.top().se] != INC) ac.pop(); return ac.top().se; }
int topAB() { return ab.top().se; }

int main() {
	scanf("%d%d%d", &X, &Y, &Z);
	i64 ans = 0;
	iter(i, X + Y + Z) {
		scanf("%d%d%d", &a[i], &b[i], &c[i]);
		ans += c[i];
		bc.push(pii(b[i] - c[i], i));
		ac.push(pii(a[i] - c[i], i));
		status[i] = INC;
	}
	
	iter(i, Y) {
		int id = topBC();
		ans += b[id] - c[id];
		status[id] = INB;
		ab.push(pii(a[id] - b[id], id));
		//printf("%d C->B\n", id);
		bc.pop();
	}

	iter(i, X) {
		int i0 = topAC();
		int i1 = topBC();
		int i2 = topAB();

		if (a[i0] - c[i0] > b[i1] - c[i1] + a[i2] - b[i2]) {
			ans += a[i0] - c[i0];
			status[i0] = INA;
		//	printf("%d C->A\n", i0);
		
			ac.pop();
		} else {
			ans += b[i1] - c[i1] + a[i2] - b[i2];
			status[i1] = INB;
			bc.pop();

			status[i2] = INA;
			ab.pop();

			ab.push(pii(a[i1] - b[i1], i1));
		}
	}

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


Measured memory_bytes: 4844
N,M = map(int,input().split())
ans = {}
for i in range(M):
    a,b = map(str, input().split() )
    if ans.get(a,0):
        ans[a].append(b)
    else:
        ans[a] = [b]
c = 0
p = 0
t = ans.values()
for line in t:
    k = 0
    for i in line:
        if i == "AC":
            c += 1
            p += k
            break
        else:
            k += 1
print(c,p)

Measured memory_bytes: 68824
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int initialize(int);
void push(int);
int pop(void);

int top=0;
int num[1000];

int main(){
  int x,a,b;
  char s[1000];

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      a=pop();
      b=pop();

      push(a+b);

    } else if ( s[0] == '-' ){ 
      a=pop();
      b=pop();

      push(b-a);

    } else if ( s[0] == '*' ){

      a=pop();
      b=pop();

      push(a*b);

    } else {
      x = atoi(s);
      push(x);
    }
  }

  printf("%d\n",pop());

  return 0;
}

void push(int x)
{
  top++;
  num[top]=x;
}

int pop(void)
{

  top--;
  return num[top+1];
}

Measured memory_bytes: 548
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <tuple>
#include <numeric>
#define FOR0(var, max) for (ui (var) = 0; (var) < (max); ++(var))
#define FOR_INV(var, min, max) for (ui (var) = (max) - 1; (var) + 1 > (min); --(var))
#define FORITER(var, iter) for (auto (iter) = (var).begin(); (iter) != (var).end(); (iter)++)
#define FORITER_INV(var, iter) for (auto (iter) = (var).rbegin(); (iter) != (var).rend(); (iter)++)

using namespace std;

using uc = unsigned char;
using ui = unsigned int;
using ul = unsigned long long int;
using sl = signed long long int;

const static ul NMAX = 100000;
const static sl AMAX = 1000000000;
const static sl AMIN = -1000000000;

static ul N;
static sl Ai[NMAX];
static sl dp[NMAX + 1][2];
priority_queue<pair<sl, ui>> Q;

void solve(void) {
  dp[0][0] = 0;
  dp[0][1] = AMIN - 1;
  FOR0(i, N) {
    dp[i + 1][0] = max(dp[i][0] + Ai[i], dp[i][1] - Ai[i]);
    dp[i + 1][1] = max(dp[i][0] - Ai[i], dp[i][1] + Ai[i]);
  }
  cout << dp[N][0] << endl;
}

int main(void) {
  cin >> N;
  FOR0(i, N) {
    cin >> Ai[i];
  }
  solve();
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  int min = 50;
  for(int i=0;i<N;i++) {
    int A;
    cin >> A;
    int j=0;
    while(A%2 == 0) {
      A/=2;
      j++;
    }
    if(j<min) {
      min = j;
    }
  }
  cout << min << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<map>
using namespace std;
int main(){
  int n;
  map<int,int> m;
  while(scanf("%d",&n)>0){
    int &i = m[n];
    if(i == 0) i=1;
    else i++;
  }
  int max=0;
  for(auto i:m)
    if(max < i.second)
      max=i.second;
  for(auto i:m)
    if(max==i.second)
      printf("%d\n",i.first);
}

Measured memory_bytes: 1012
#include<bits/stdc++.h>
using namespace std;
int n;
int a[300005] , b[300005];
int main()
{
    scanf("%d",&n);getchar();
    for(int i = 1;i <= n;i++){
        char ch = getchar();
        if(ch == 'W'){
            a[i] = 1;
        }
        else b[i] = 1;
    }
    for(int i = 1;i <= n;i++) {a[i] += a[i - 1];b[i] += b[i - 1];}
    int ans= 1e9;
    for(int i = 1;i <= n;i++){
        int x = a[i - 1] - a[0];
        int y = b[n] - b[i];
        if(x + y < ans) ans = x + y;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 2560
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		int n = sc.nextInt();
        long value1 = 2;
        long value2 = 1;
        if (n == 1) {
            // 出力
		    System.out.println(value2);
            return;
        }
        for(int i = 2; i < n; i++) {
          if (i % 2 == 0) {
            value1 = value1 + value2;
          } else {
            value2 = value1 + value2;
          }
        }

		// 出力
		System.out.println(value1 + value2);
	}
}

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

using namespace std;

template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

template< typename G >
struct DoublingLowestCommonAncestor {
  const int LOG;
  vector< int > dep;
  const G &g;
  vector< vector< int > > table;

  DoublingLowestCommonAncestor(const G &g) : g(g), dep(g.size()), LOG(32 - __builtin_clz(g.size())) {
    table.assign(LOG, vector< int >(g.size(), -1));
  }

  void dfs(int idx, int par, int d) {
    table[0][idx] = par;
    dep[idx] = d;
    for(auto &to : g[idx]) {
      if(to != par) dfs(to, idx, d + 1);
    }
  }

  void build() {
    dfs(0, -1, 0);
    for(int k = 0; k + 1 < LOG; k++) {
      for(int i = 0; i < table[k].size(); i++) {
        if(table[k][i] == -1) table[k + 1][i] = -1;
        else table[k + 1][i] = table[k][table[k][i]];
      }
    }
  }

  int query(int u, int v) {
    if(dep[u] > dep[v]) swap(u, v);
    for(int i = LOG - 1; i >= 0; i--) {
      if(((dep[v] - dep[u]) >> i) & 1) v = table[i][v];
    }
    if(u == v) return u;
    for(int i = LOG - 1; i >= 0; i--) {
      if(table[i][u] != table[i][v]) {
        u = table[i][u];
        v = table[i][v];
      }
    }
    return table[0][u];
  }
};

int main() {
  int N, Q;
  scanf("%d", &N);
  UnWeightedGraph g(N);
  for(int i = 0; i < N; i++) {
    int k;
    scanf("%d", &k);
    while(k--) {
      int c;
      scanf("%d", &c);
      g[i].push_back(c);
    }
  }
  DoublingLowestCommonAncestor< UnWeightedGraph > lca(g);
  lca.build();
  scanf("%d", &Q);
  while(Q--) {
    int x, y;
    scanf("%d %d", &x, &y);
    printf("%d\n", lca.query(x, y));
  }
}



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

typedef long long ll;
const int maxn=1e6+7;
const int inf=INT_MAX;
const ll inff=1e18;
const ll mod=998244353;
#define pii pair<int,int>
#define mkp make_pair
#define F first
#define S second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define int ll

#ifdef HNO2
#define IOS
#else
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0);
#endif // HNO2

int ppow(int x,int y)
{
    if (y==0) return 1;
    int ret=ppow(x,y/2);
    ret=ret*ret%mod;
    if (y&1) ret=ret*x%mod;
    return ret;
}

int a[3007];
int dp[3007];

int32_t main()
{
    IOS
    int n,S;
    cin>>n>>S;
    for (int i=1;i<=n;i++) cin>>a[i];
    int inv2=ppow(2,mod-2);
    dp[0]=ppow(2,n);
    for (int i=1;i<=n;i++)
        for (int j=S;j>=0;j--)
            if (j>=a[i]) dp[j]=(dp[j]+dp[j-a[i]]*inv2%mod)%mod;
    cout<<dp[S]<<endl;
}



Measured memory_bytes: 3696
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <unordered_set>

#define ll long long int
#define mod 1000000007

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int n, k;
    cin >> n >> k;
    unordered_set<int> us;
    for(int i =0;i<k;i++){
        int x;
        cin >> x;
        for(int j =0;j<x;j++){
            int z;
            cin >> z;
            us.insert(z);
        }
    }
    cout << n - us.size();
}









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

int main(){
	unsigned long long int N,A,B,C,D,E;
	std::cin>>N>>A>>B>>C>>D>>E;

	unsigned long long int min = std::min({A,B,C,D,E});
	unsigned long long int amari = N/min;
	if(N%min == 0 ){
		amari--;	
	}

	std::cout<<(5 + amari)<<std::endl;

	return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::io::{BufWriter, Write};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    input!(
        n: usize,
        s: chars,
    );

    let n = (n % 26) as u8;
    let s = s as Vec<char>;

    let s = s.into_iter()
        .map(|c| (((c as u8 - 'A' as u8) + n as u8)  % 26  + 'A' as u8) as char)
        .collect::<Vec<char>>();

    println!("{}", s.into_iter().collect::<String>());
}

fn main() {
    let stack_size = 1 << 28;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


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

int main() {

	int c1x, c1y, c1r;
	int c2x, c2y, c2r;

	cin >> c1x >> c1y >> c1r;
	cin >> c2x >> c2y >> c2r;

	double distanceCenter = sqrt(pow(c2x - c1x, 2) + pow(c2y - c1y, 2));
	double sumRange = c1r + c2r;

	if (distanceCenter > sumRange)
		cout << "4" << endl;
	else if (distanceCenter == sumRange)
		cout << "3" << endl;
	else if (distanceCenter < sumRange &&
		distanceCenter > abs(c1r - c2r))
		cout << "2" << endl;
	else if (distanceCenter == abs(c1r - c2r))
		cout << "1" << endl;
	else
		cout << "0" << endl;

	return 0;
}


Measured memory_bytes: 3116
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var ans = m1(0, n);
        Console.WriteLine(ans);
    }

    static int[] d = new[] { 7, 5, 3 };
    static int m1(int x, int max)
    {
        var sum = m2(x) ? 1 : 0;
        for (int i = 0; i < 3; i++)
        {
            var n = 10 * x + d[i];
            if (0 < n && n <= max)
            {
                sum += m1(n, max);
            }
        }
        return sum;
    }

    static bool m2(int x)
    {
        var s = x.ToString();
        return s.Contains('7') && s.Contains('5') && s.Contains('3');
    }
}


Measured memory_bytes: 13268
def dif_num(x,y):
    if x == y:
        return 0
    else:
        return 1

a,b,c = map(int,input().split())
if dif_num(a,b) == 1 and dif_num(a,c) == 1:
    print(a)
if dif_num(a,b) == 1 and dif_num(b,c) == 1:
    print(b)
if dif_num(a,c) == 1 and dif_num(c,b) == 1:
    print(c)

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

using namespace std;

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mkp make_pair

#define se second
#define fi first

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

int main(){

    bool flag=false;
    ll ans=0,sum=0;

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

    for (int i = 1; i <= 3; i++)
    {
        if(a==i)continue;
        if(b==i)continue;

        cout << i <<endl;
    }
    

    //cout <<fixed<<setprecision(16)<< << endl;
    //cout << dig(n) << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream> 
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
using namespace std;
int main() {
	int N, K;
	cin >> N >> K;
	if (N + 1 - 2 * K >= 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#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(){
    string s;
    cin >> s;
    if((s[2]==s[3])&&(s[4]==s[5])) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}

int main() {
	vector<int > in;
	for (int i = 0; i < 3; i++) {
		int a;
		cin >> a;
		in.push_back(a);
	}
	sort(in.begin(), in.end());
	int sa1 = in[2] - in[1];
	int sa2 = in[2] - in[0];
	long long int ans = 0;
	ans = ans + sa1 / 2;
	ans = ans + sa2 / 2;
	sa1 = sa1 % 2;
	sa2 = sa2 % 2;
	if (sa1 == 0 && sa2 == 0) {
		cout << ans;
		return 0;
	}
	if (sa1 == 1 && sa2 == 1) {
		cout << ans + 1;
		return 0;
	}
	cout << ans + 2;
}

Measured memory_bytes: 256
/*
      author  : nishi5451
      created : 14.08.2020 17:19:44
*/

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


int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(a.rbegin(),a.rend());
    int Alice=0,Bob=0;
    for(int i=0; i<n; i++){
        if(i%2) Bob+=a[i];
        else Alice+=a[i];
    }
    cout << Alice-Bob << endl;
    return 0;
}

Measured memory_bytes: 3556