akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(10**7)

def main():
    N, Q = [int(i) for i in input().split()]
    V = [set() for _ in range(N)]
    for _ in range(N - 1):
        a, b = [int(i) - 1 for i in input().split()]
        V[a].add(b)
        V[b].add(a)
    C = [0] * N
    for _ in range(Q):
        p, x = [int(i) for i in input().split()]
        C[p - 1] += x
    cur = [(0, 0)]
    while cur:
        nxt = []
        for n, x in cur:
            C[n] = x = C[n] + x
            for c in V[n]:
                V[c].remove(n)
                nxt.append((c, x))
        cur = nxt
    print(' '.join(str(c) for c in C))

main()


Measured memory_bytes: 146936
N, = map(int, input().split())
X = list(map(int, input().split()))
r = 0
for d in range(1, N):
    s = 0
    vs = set([0, N-1])
    for ld in range(d, N-d, d):
        bld = N-ld-1
        vs.add(bld)
        if ld in vs:
            break
        s += X[ld] + X[bld]
        r = max(s, r)
print(r)


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

int main(){
    int N;
    cin >> N;
    vector<int> A(N+1);
    ll sum = 0;
    for(int i = 1; i<N+1; i++){
        cin >> A[i];
        sum += A[i];
    }
    vector<ll> ans(N+1);
    ans[1] = sum;
    for(int i = 2; i <= N-1; i+=2) ans[1] -= 2*A[i];
    cout << ans[1] << " ";
    for(int i = 2; i < N+1; i++){
        ans[i] = 2*A[i-1] - ans[i-1];
        cout << ans[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
char f[300][300];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin>>N;
    rep(i,0,N){
        rep(j,0,N){
            cin>>f[i][j];
        }
    }
    ll res=0;
    rep(i,0,N){
        bool t=true;
        rep(j,0,N){
            rep(k,0,N){
                if(f[j][k]!=f[((k+i)%N+N)%N][((j-i)%N+N)%N]) t=false;
            }
        }
        if(t) res++;
    }
    cout <<res*N<<"\n";
}

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

#define MAX 101
#define INFTY 1000000

int G[MAX][MAX];
int d[MAX];

void Dijkstra(int);

int main(void){
  int i, j, k, n, v, u, c;

  scanf("%d", &n);
  for(i=0; i<n; i++){
    for(j=0; j<n; j++){
      G[i][j] = INFTY;
    }
  }

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

  Dijkstra(n);

  return 0;
}

void Dijkstra(int n){
  int i, j, k, min;
  int d[MAX], c[MAX];

  d[0] = 0;
  for(i=1; i<n; i++){
    d[i] = INFTY;
    c[i] = 0;
  }

  while(1){
    min = INFTY;

    for(i=0; i<n; i++){
      if(c[i] != 1 && d[i] < min){
        j = i;
        min = d[i];
      }
    }

    if(min == INFTY) break;

    c[j] = 1;
    for(k=0; k<n; k++){
      if(c[k] != 1 && d[j] + G[j][k] < d[k]) d[k] = d[j] + G[j][k];
    }
  }

  for(i=0; i<n; i++) printf("%d %d\n", i, d[i]);

  return;
}

Measured memory_bytes: 640
x=0
d1=0
d2=0
M,D=map(int, input().split())
for m in range(1,M+1):
  for d in range(1,D+1):
    d1=d//10
    d2=d-d1*10
    if m==d1*d2 and d1>=2 and d2>=2:
      x=x+1
print(x)

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

int main()
{
    int n,k;
    cin>>n>>k;
    vector<int> h(n+1,0);
    for(int i=1;i<=n;i++)
        cin>>h[i];
    vector<int> dp(n+1);
    dp[0]=0;
    dp[1]=0;
    dp[2]=abs(h[2]-h[1]);
    for(int i=3;i<=n;i++)
    {
             int min_=INT_MAX;
             for(int j=1;j<=k;j++)
             {
                 if(i-j>=1)
                 {
                     if(abs(dp[i-j]+abs(h[i]-h[i-j]))<min_)
                        min_=abs(dp[i-j]+abs(h[i]-h[i-j]));
                 }
                 else break;
             }
             dp[i]=min_;
    }
    cout<<dp[n]<<endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <boost/math/common_factor_rt.hpp>
#define USE_MATH_DEFINES
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;

using namespace std;
// namespace mp = boost::multiprecision;
// namespace mt = boost::math
// using Bint = mp::cpp_int;

ll n, k;

ll check(ll p, ll w[]) {
    ll tmp = 0;
    rep(i, k) {
        ll weight = 0;
        while (weight + w[tmp] <= p) {
            weight += w[tmp];
            tmp++;
        }
    }
    return tmp;
}

int main() {
    bool flag = false;
    cin >> n >> k;
    ll w[n], sum = 0;
    rep(i, n) {
        cin >> w[i];
        sum += w[i];
    }
    ll left = 0, right = 1000000000;
    while (right - left > 1) {
        ll mid = (left + right) / 2;
        if (check(mid, w) >= n)
            right = mid;
        else
            left = mid;
    }
    cout << right << endl;
}


Measured memory_bytes: 3892
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>	
#include <cmath>
#include <string>
#include<math.h>
#include<sstream>//���炵���̂Œ���
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define Cout(s) cout<<s<<endl
using namespace std;
typedef long long ll;
string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } }
string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } }
//================================================

int a = 1, b = 0, c, d, n, k = 0, ans = 0;
string s, t;
int mod = 1000000007;
int tosi = 2019;

int main()
{
	cin >> n;
	map<string, ll> anna;
	rep(i, n) { cin >> s; sort(all(s)); anna[s]++; }
	ll sum = 0;
	for (auto iter = anna.begin(); iter != anna.end(); iter++) {
		sum += iter->second * (iter->second - 1) / 2;
	}
	cout << sum << endl;

	return 0;
}


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

int main()
{
  int N;
  cin >> N;
  vector<int> h(N);
  rep(i,N) cin >> h[i];

  for(int i=N-1;i>0;i--){
    if(h[i-1] > h[i]){
      if(h[i-1] > h[i] + 1){
        cout << "No" << endl;
        return 0;
      }else{
        h[i-1]--;
      }
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 640
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	string A, B; cin >> A >> B;
	int ans = 0;
	F0R(i, sz(A)) if (A[i] == B[i]) ans++;
	cout << ans << endl;
	
	
	return 0;
}

Measured memory_bytes: 256
N = int(input())
W = []
for i in range(N):
    W.append(input())

if len(W) != len(set(W)):
    print('No')
else:
    i = 0
    while i < N - 1:
        if W[i][-1] == W[i + 1][0]:
            i += 1
        else:
            print('No')
            break
    if i == N - 1:
        print('Yes')
    

Measured memory_bytes: 3060
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1)
	{
		cerr << name << " = " << arg1 << endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args)
	{
		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " = " << arg1 << " || ";
		__f(comma+1, args...);
	}
#else
#define debug(...)
#endif

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ; ";
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
	return os << "[ " << p.first << ", " << p.second << "]" ;
}

#define FAST_IO std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define pb push_back
#define mp make_pair
#define ld long double
#define sz(a) (ll)(a).size()
#define endl "\n"

// priority_queue<ll, vector<ll>, less<ll>>pq;     // Max Heap
// priority_queue<ll, vector<ll>, greater<ll>>pq;  // Min Heap

typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//K-th smallest
//cout << k << "kth (1 based indexing) smallest: " << *A.find_by_order(k - 1) << endl;
//NO OF ELEMENTS < X
//cout << "No of elements less than " << X << " are " << A.order_of_key(X) << endl;

int main()
{
	FAST_IO;

    ll a[5];
    for(int i=0;i<5;i++) cin >> a[i];
    for(int i=0;i<5;i++)
    {
    	if(a[i] == 0)
    	{
    		cout << i + 1 << endl;
    		return 0;
    	}
    }
    return 0;
}

Measured memory_bytes: 3636
/* 
   AOJ 1125
   Get Many Persimmon Trees
   2015.4.26
 */

#include<stdio.h>

int field[100][100] = {0};

int search_most_trees(int field_width, int field_height, int estate_width, int estate_height)
{
  int estate_x, estate_y, field_x, field_y, trees = 0, max_trees = 0;


  for(field_x = 0; field_x <= field_width - estate_width; field_x++)
    {
      for(field_y = 0;  field_y <= field_height - estate_height; field_y++)
	{
	  for(estate_x = field_x; estate_x < estate_width + field_x; estate_x++)
	    {
	      for(estate_y = field_y; estate_y < estate_height + field_y; estate_y++)
		{
		  if(field[estate_x][estate_y] == 1)
		    {
		      trees++;
		    } 
		}
	    }
	  if(trees >= max_trees)
	    {
	      max_trees = trees;
	    }
	  trees = 0;
	}
    }
  return max_trees;
}

int main(void)
{
  int trees_num, width, height, i, j, tree_x, tree_y, estate_width, estate_height, get_trees_num;
  while(1)
    {
      scanf("%d", &trees_num);
      if(trees_num == 0)
	{
	  break;
	}
      scanf("%d %d", &width, &height);
      
      for(i = 0; i < trees_num; i++)
	{
	  scanf("%d %d", &tree_x, &tree_y);
	  field[tree_x - 1][tree_y - 1] = 1;
	}

      scanf("%d %d", &estate_width, &estate_height);

      /* for(i = 0; i < height; i++) */
      /* 	{ */
      /* 	  for(j = 0; j < width; j++) */
      /* 	    { */
      /* 	      printf("%3d", field[j][i]); */
      /* 	    } */
      /* 	  printf("\n"); */
      /* 	} */

      get_trees_num = search_most_trees(width, height, estate_width, estate_height);

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

      for(i = 0; i < width; i++)
	{
	  for(j = 0; j < height; j++)
	    {
	      field[i][j] = 0;
	    }
	}
      
    }
  return 0;
}

Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define re(i,a,b) for(int i=(a);i<(b);i++)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define clr(a) memset(a,0,sizeof(a));
#define il inline
#define sz(a) ((int)o.size())
#define run(x) for(int k=head[x];k;k=e[k].ne)
#define v e[k].t
#define all(a) o.begin(),o.end()
#define pb push_back 
#define w1 first
#define w2 second
#define adm(a,b,c) {a=a+b;if(a>=c)a-=c;else if(a<0)a+=c;}
typedef double db;
typedef long long ll;typedef long double ld;typedef unsigned long long ull;
typedef pair<int,int> pa;
const int N=1e3+5,M=1e7+5,INF=1e9,mod=1e9+7;
const ll linf=1e18;const double eps=1e-8,pi=acos(-1);
il int gmin(int &a,int b){if(a>b)a=b;}il ll gmin(ll &a,ll b){if(a>b)a=b;}il int gmax(int &a,int b){if(a<b)a=b;}il ll gmax(ll &a,ll b){if(a<b)a=b;}
il void read(ll&x){ll f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il ll read(ll&x,ll&y){read(x);read(y);}
il void read(int&x){int f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il int read(int&x,int&y){read(x);read(y);}
il void read(int&a,int&b,int&c){read(a);read(b);read(c);}il void read(ll&a,ll&b,ll&c){read(a);read(b);read(c);}
il int read(){int x;read(x);return x;}
il ll qpow(ll a,ll b,ll p){ll ret=1;for(;b;b>>=1,a=a*a%p)if(b&1)ret=ret*a%p;return ret;}il ll qpow(ll a,ll b){ll ret=1;for(;b;b>>=1,a=a*a%mod)if(b&1)ret=ret*a%mod;return ret;}
il ll qmul(ll a,ll b,ll p){ll ret=0;for(;b;b>>=1,a=(a<<1)%p)if(b&1)adm(ret,a,p);return ret;}il ll qmul(ll a,ll b){ll ret=0;for(;b;b>>=1,a=(a<<1)%mod)if(b&1)adm(ret,a,mod);return ret;}
il void judge(){
	freopen("destiny.in","r",stdin);
	freopen("destiny.out","w",stdout);
}
void ad(ll&a,ll b){(a+=b)%=mod;}
struct mat{
	ll a[2][2];
	friend mat operator*(mat a,mat b){
		mat c;clr(c.a);
		re(i,0,2)re(j,0,2)re(k,0,2)ad(c.a[i][j],a.a[i][k]*b.a[k][j]%mod);
		return c;
	}
};
mat qpow(mat a,ll b){
	mat res={1,0,0,1};
	for(;b;b>>=1,a=a*a)if(b&1)res=res*a;
	return res;
}
int n,m,a[N][N],cb;ll K;
char s[N];
int main(){
	read(n,m);read(K);
	rep(i,1,n){
		scanf("%s",s+1);
		rep(j,1,m)cb+=(a[i][j]=s[j]=='#');
	}
	int xc=0,yc=0;
	rep(i,1,n)if(a[i][1]&&a[i][m])yc++;
	rep(i,1,m)if(a[1][i]&&a[n][i])xc++;
	ll res=1;
	if(xc&&yc)res=1;else
	if(!xc&&!yc)res=qpow(cb,K-1,mod);else{
		int o=0;
		if(yc){
			rep(i,1,n)re(j,1,m)o+=a[i][j]&&a[i][j+1];
			mat f=(mat){cb,mod-o,0,yc};
			f=qpow(f,K-1);
			cout<<(f.a[0][0]+f.a[0][1])%mod;
		}else
		if(xc){
			re(i,1,n)rep(j,1,m)o+=a[i][j]&&a[i+1][j];
			mat f=(mat){cb,mod-o,0,xc};
			f=qpow(f,K-1);
			cout<<(f.a[0][0]+f.a[0][1])%mod;
		}
		return 0;
	}cout<<res<<endl;
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int ar[10000],n,x,sum=0,count=0;
    vector<int>v;
    cin>>n>>x;
    for(int i=0;i<n;i++)
    {
        cin>>ar[i];
        sum=sum+ar[i];
        v.push_back(sum);
    }
    for(int i=0;i<v.size();i++)
    {
        if(v[i]<=x)count++;
    }
    cout<<count+1<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int h = in.nextInt();
        int n = in.nextInt();
        for (; n > 0; n--) h -= in.nextInt();
        if (h <= 0)
            System.out.println("Yes");
        else
            System.out.println("No");

    }
}


Measured memory_bytes: 49012
#include<iostream>
using namespace std;   
 
int main(){
    int a, b;
    cin >> a >> b;
    if (a == b){
        cout << "a == b" << endl;
    }
    else if (a > b){
        cout << "a > b" << endl;
    }
    else{
        cout << "a < b" << endl;
    }
 
    return 0;
}

Measured memory_bytes: 1156
#!/usr/bin/env ruby

class Object
  def tapp
    debug = false
    if debug
      require 'PP'
      tap { PP.pp(self, $stderr) }
    else
      self
    end
  end
end

# v = gets.split.map(&:to_i)
# while l = gets
# end
nb = 0
sum = 0
gets.chomp.each_char do |c|
  if c == 'B'
    nb += 1
  else
    sum += nb
  end
end
puts sum

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

int main(){
    ll a, b, x;
    cin >> a >> b >> x;
    if(a==0){
        cout << b/x +1 << endl;
    }else{
        cout << b/x-(a-1)/x << endl;
    }
    return 0;
}

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

int main(){
    int K,S;cin>>K>>S;
    int count=0;
    for(int X=0;X<=K;X++){
        for(int Y=0;Y<=K;Y++){
            if(0<=S-X-Y&&S-X-Y<=K){
                count++;
            }
        }
    }cout<<count<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N,K;
set<ll> st;
int main(){
    cin>>N>>K;
	for(ll i=0;i<K;i++){
		ll d;cin>>d;
		for(ll j=0;j<d;j++){
			ll a;cin>>a;
			st.insert(a);
		}
	}
	cout<<N-st.size()<<endl;

    return 0;
}

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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++ i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")

using ll = std::int64_t;
using vint = std::vector<std::int32_t>;
using vll = std::vector<ll>;
using vstr = std::vector<std::string>;
using pint = std::pair<std::int32_t, std::int32_t>;
using usetint = std::unordered_set<std::int32_t>;
using usetstr = std::unordered_set<std::string>;

constexpr std::int32_t INF = 1001001001;

void Main() {
    int n;
    cin >> n;
    vector<pint> a(n);
    rep(i, n) {
        int b;
        cin >> b;
        a[i] = make_pair(b, i);
    }
    sort(ALL(a));
    rep(i, n) {
        cout << a[i].second + 1 << (i == n - 1 ? "\n" : " ");
    }
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
    int train = 0;
    int bus = 0;
 if(A <= B) { train = A; }
 else { train = B; }

 if(C <= D) { bus = C; }
 else { bus = D; }

 cout << train + bus;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;
int main(void){

  int N,x;
  long long int res=0;
  int i;
  cin>>N>>x;
  vector<int> a(N+1);
  for(i=1;i<=N;i++){
    cin>>a[i];
  }
  if(a[1]>x){
    res=a[1]-x;
    a[1]=x;
  }
  for(i=2;i<=N;i++){
    if(a[i]+a[i-1]>x){
      res+=a[i]-(x-a[i-1]);
      a[i]=x-a[i-1];
    }
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long int 
#define endl '\n'
#define INF 1000000000
#define MOD 1000000007
#define MAX 100000000 
#define mp make_pair
#define pb push_back
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    ll a[n],ans=0,x=1;
    for(int i=0;i<n;i++)
    {
    	cin>>a[i];
    }
    for(int i=0;i<63;i++)
    {
    	ll a1=0,b=0;
    	//cout<<x<<" ";
    	for(int j=0;j<n;j++)
    	{
    		if(a[j]&x)
    		{
    			a1++;
    		}
    		else
    		b++;
    	}
    	a1=a1*b;
    	a1=a1%MOD;
    	a1=((a1%MOD)*(x%MOD))%MOD;
    	//cout<<a1<<" ";
    	x=x*2;
    	ans=(ans+a1)%MOD;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 5952
while True:
    n,k=map(int,input().split())
    if n==0 and k==0: 
        break
    a=[int(input()) for _ in range(n)]
    s=sum(a[0:k])
    ss=[s]
    for i in range(k,n):
        s=s+a[i]-a[i-k]
        ss.append(s)
    print(max(ss))


Measured memory_bytes: 11700
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
map<int,int>mp;
bool check(int n)
{
    while(n>0){
        int cur=n%10;
        n/=10;
        if(mp[cur])
            return 0;
    }


return 1;
}
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n,k;
    cin>>n>>k;
    for(int i=0; i<k; i++)
    {
        int a;
        cin>>a;
        mp[a]++;
    }
    for(int i=n; i<=MAX; i++)
    {
        if(check(i))
        {
            cout<<i<<endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3608
package main

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

// 組み合わせの数
func main() {
	sc := bufio.NewScanner(os.Stdin)
	for {
		sc.Scan()
		ary := strings.Split(sc.Text(), " ")
		n, _ := strconv.Atoi(ary[0])
		x, _ := strconv.Atoi(ary[1])
		if n == 0 && x == 0 {
			break
		}
		cnt := 0
		for i := 1; i <= n; i++ {
			for j := 1; j <= n; j++ {
				if j <= i {
					continue
				}
				for k := 1; k <= n; k++ {
					if k <= i || k <= j {
						continue
					} else if i+j+k == x {
						cnt++
					}
				}
			}
		}
		fmt.Println(cnt)
	}
}



Measured memory_bytes: 1088
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std ;
#define int                 long long
#define ull                 unsigned long long int
#define ld                  long double
#define vi                  vector<int>
#define vii                 vector<pair<int,int>>
#define vvi                 vector<vector<int>>
#define pii                 pair<int,int>
#define prec(x)             fixed<<setprecision(15)<<x
#define all(x)              x.begin(),x.end()
#define rall(x)             x.rbegin(),x.rend()
#define rev(x)              reverse(x.begin(),x.end())
#define mset(a,b)           memset(a,b,sizeof(a))
#define mcpy(a,b)           memcpy(a,b,sizeof(a))
#define fo0(i,n)            for(int i=0,i##end=n;i<i##end;i++)
#define fo1(i,n)            for(int i=1,i##end=n;i<=i##end;i++)
#define fo(i,a,b)           for(int i=a,i##end=b;i<=i##end;i++)
#define foe(i,x)            for(__typeof((x).end())i=(x).begin();i!=(x).end();++i)
#define fre(i,x)            for(__typeof((x).rend())i=(x).rbegin();i!=(x).rend();++i)
#define mk(arr,n,type)    type *arr=new type[n];
#define dbg(x) cerr << #x << " is " << x << endl;
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
clock_t beg = clock();
const int inf=1e18;const int mod=1e9+7;const int N=2e5+9;
const double pi = 3.1415926535897932384626433;
void FILE_IO(){
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}

void JH(){
    int d=0,e=0,f=0,g=0,p=0,w=0,flag=0,ans=0,res=0,cnt=0,sum=0;double f1=0.0,f2=0.0,f3=0.0;
    int h1,m1,h2,m2,k;cin>>h1>>m1>>h2>>m2>>k;
    m1=h1*60+m1;
    m2=h2*60+m2;
    int diff=m2-m1;
    cout<<diff-k<<endl;
}

int32_t main()
{
    FILE_IO();FAST_IO;int t=1;
    // cin>>t;
    while(t--){JH();}cerr<<"Execution time: "<<(double)(clock()-beg)/1000<<"s ";
}

Measured memory_bytes: 3808
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"


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

	int n,m;
	cin>>n>>m;
	int s=0;
	rep(i,n)s+=m+i;
	if(m>0)s-=m;
	if(m+n<=0)s-=m+n-1;
	cout<<s<<endl;
}


Measured memory_bytes: 256
def mini(N, h):
    listfrog = [2**31-1] * (N)
    listfrog[0] = 0
    for i in range(len(listfrog)):
        if i+1 <= N-1:
            listfrog[i+1] = min(listfrog[i+1], abs(h[i] - h[i+1]) + listfrog[i]) 
        if i+2 <= N-1:
            listfrog[i+2] = min(listfrog[i+2], abs(h[i] - h[i+2]) + listfrog[i])
    return listfrog[-1]

N = int(input())
h = list(map(int, input().split()))

print(mini(N,h))

Measured memory_bytes: 13924
#include <bits/stdc++.h>
#include <cmath>
#include <iostream>

using namespace std;

int main() {
  int S,A,B,C,D;
  cin>>S;
  A=S/1000;
  B=S/100%10;
  C=S/10%10;
  D=S%10;
  if(A==B || B==C || C==D) cout<<"Bad";
  else cout<<"Good";
}


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

int main() {
  int N;
  cin >> N;
  if (N/10%111==0||(N-1000*(N/1000))%111==0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
x = gets()
y = x.split()
r = y[0].to_i
c = y[1].to_i
fir = []
msum = 0
i = 0
while i < r
 xx = gets()
 yy = xx.split()
 yyy = yy.map{|a| a.to_i}
 h = 0
 sum = 0
 while h < c
  sum += yyy[h]
  if fir[h].nil?
   fir[h] = yyy[h]
  else
   fir[h] += yyy[h]
  end
  h += 1
 end
 yyy << sum
 msum += sum
 puts yyy.join(" ")
 i += 1
end

fin = fir << msum
puts fin.join(" ")


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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k;
    cin >> n >> k;
    vector<int> nums(n);
    vector<int> dp(n, INT_MAX);
    for (int i = 0; i < n; i++) {
        cin >> nums[i];
    }
    dp[0] = 0;
    for (int i = 1; i < n; i++) {
        for (int j = i - k; j < i; j++) {
            if (j < 0) continue;
            dp[i] = min(dp[i], dp[j] + abs(nums[i] - nums[j]));
        }
    }
    cout << dp[n - 1];
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int iseven(string s){
  int ssize = s.size();

  if(s.size() % 2 == 1) ssize--;

  
  while(ssize >= 2){
    string s1 = "", s2 = "";
    for(int i = 0; i < ssize; i++){
      if(i < ssize/2) s1 += s.at(i);
      else s2 += s.at(i);
    }
    if(s1 == s2 && s.size() != ssize) return ssize;
    ssize -= 2;
  }
  return -1;
}

int main(){
  string S;
  cin >> S;
  cout << max(1, iseven(S)) << endl;;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>

#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;



int main() {

    int n, m;
    cin >> n >> m;
    if(n==m)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

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

using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define f_in freopen("test.in","r",stdin);
#define f_out freopen("test.in","w",stdout);
#define debug(x) cerr << #x << " : " << x << "\n";
#define _ cin.sync_with_stdio(0); cin.tie(0);
#define tl cout <<"\nTime elapsed: "<<(1000 * clock() / CLOCKS_PER_SEC)<<"ms\n"


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

inline char nc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}

template<typename T = int>
inline T nxt(){
    char c=nc();T x=0; int f=1;
    for(;c>'9'||c<'0';c=nc())if(c=='-')f=-1;
    for(;c>='0'&&c<='9';x=x*10+c-'0',c=nc()); x*=f;
    return x;
}

const int N = (int) 1e4 + 123;
int a[N], b[N];

int main(){
    int n = nxt();
    ll k = 0;
    rep(i,0,n) a[i] = nxt(), k -= a[i];
    rep(i,0,n) b[i] = nxt(), k += b[i];
    rep(i,0,n){
        if(b[i] > a[i]) k -= (b[i] - a[i] + 1)/2;
    }
    if(k < 0) cout << "No\n";
    else cout << "Yes\n";
}


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

int main() {
	
	ll n; string s; cin >> n >> s;
	ll Nr = 0;
	ll Ng = 0;
	ll Nb = 0;
	for (ll i = 0; i < n; i++) {
		if (s[i] == 'R') Nr++;
		if (s[i] == 'G') Ng++;
		if (s[i] == 'B') Nb++;	
	}
	ll sum = Nr * Ng * Nb;
	ll tmp = 0;
	for (ll i = 0; i < n - 2; i++) {
		for (ll j = i + 1; j < n - 1; j++) {
			ll k = 2 * j - i;
			if (n - 1 < k) continue;
			if (s[i] != s[j] && s[j] != s[k] && s[k] != s[i]) {
				tmp++;
			}			
		}
	}
	cout << max(0LL, sum - tmp) << endl;
	return 0;
}

Measured memory_bytes: 3640
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);

        String hitachi = stdIn.next();
        //System.out.println(hitachi);

        //String hitachi = "";
//        if (args == null || args.length != 1) {
//            System.out.println("No");
//            System.exit(0);
//        }else {
            //hitachi = args[0];
            if(hitachi.length() > 10 || hitachi.length() == 0) {
                System.out.println("No");
                //System.exit(0);
                return;
            }
            if(!hitachi.matches("[a-z]*")) {
                System.out.println("No");
                System.exit(0);
            }
            if(hitachi.contains(" ")) {
                System.out.println("No");
                System.exit(0);
            }

            do {
                //System.out.println("[" + hitachi + "]");

                if (hitachi.startsWith("hi")) {
                    //hitachi = hitachi.substring(2, hitachi.length() - 1);
                    hitachi = hitachi.substring(2);
                    //System.out.println("substring = [" + hitachi + "]");
                } else {
                    System.out.println("No");
                    System.exit(0);
                }
            } while (hitachi.length() > 0);
            System.out.println("Yes");
        //}
    }

}


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

int main(){
  int A,B,C;
  cin>>A>>B>>C;
  for(int i=0;i<B;i++){
    if((A*i)%B==C){
      cout<<"YES"<<endl;
      return 0;
    }
  }
  cout<<"NO"<<endl;
  return 0;
}

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

using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;

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

    cout << n*n*n << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
int n;cin>>n;int a[n],b[n],c[n];
for(int i=0;i<n;i++)cin>>a[i];
for(int i=0;i<n;i++)cin>>b[i];
for(int i=0;i<n;i++)cin>>c[i];
int sum=0;
for(int i=0;i<n-1;i++){
    if(a[i]+1==a[i+1])sum+=c[a[i]-1];
} 
for(int i=0;i<n;i++)sum+=b[i];
cout<<sum<<endl;  



}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    int aIdx, zIdx;
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == 'A') {
            aIdx = i;
            break;
        }
    }
    for (int i = s.size() - 1; i > 0 ; --i) {
        if (s[i] == 'Z') {
            zIdx = i;
            break;
        }
    }
    cout << zIdx - aIdx + 1 << endl;
}

Measured memory_bytes: 640
n = int(input())
lst = list(map(int, input().split()))
q = int(input())
ans = sum(lst)

num = [0]*(10**5+1)

for i in range(n):
  num[lst[i]] += 1
  
for i in range(q):
  b, c = map(int, input().split())
  num[c] += num[b]
  ans += (c-b)*num[b]
  num[b] = 0 
  print(ans)
  

Measured memory_bytes: 84528
n = int(input())
ori = []
tra = []
for i in range(n):
    x,y = map(int,input().split())
    ori.append((x,y))
    tra.append((x+y,x-y))

i_maxu = None
i_minu = None
maxu = None
minu = None
i_maxv = None
i_minv = None
maxv = None
minv = None
for i,(u,v) in enumerate(tra):
    if maxu is None or u > maxu:
        maxu = u
        i_maxu = i
    if maxv is None or v > maxv:
        maxv = v
        i_maxv = i
    if minu is None or u < minu:
        minu = u
        i_minu = i
    if minv is None or v < minv:
        minv = v
        i_minv = i

if maxu - minu > maxv - minv:
    i,j = i_minu,i_maxu
else:
    i,j = i_minv,i_maxv

x1,y1 = ori[i]
x2,y2 = ori[j]
print( abs(x1-x2) + abs(y1-y2) )


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

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

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

	ll sum = 0;
	ll tmp_sum = 0;
	rep(i, n) {
		int a;
		cin >> a;
		tmp_sum += a;
		if (!a) {
			sum += tmp_sum / 2;
			tmp_sum = 0;
		}
	}
	sum += tmp_sum / 2;

	cout << sum << endl;

	return 0;
}

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

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

    if(n[n.size()-1]=='3'){
        cout<<"bon"<<endl;
    }else if(n[n.size()-1]=='0'||n[n.size()-1]=='1'||n[n.size()-1]=='6'||n[n.size()-1]=='8'){
        cout<<"pon"<<endl;
    }else{
        cout<<"hon"<<endl;
    }
}

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

int main() {
  int N;
  cin >> N;
  int y = 0;//約数
  int c = 0;//答え
  
  for(int i = 0; i < N; i++){
    for(int j = 0; j <= i; j++){
      if(i % 2 == 0 && (i + 1) % (j + 1) == 0){
        y++;
      }
    }
    if(y == 8){
      c++;
    }
    y = 0;
  }
  cout << c << endl;
}

Measured memory_bytes: 256
from itertools import permutations


n = int(input())
xys = [list(map(int, input().split())) for _ in range(n)]

min_cost = n
for xyi, xyj in permutations(xys, 2):
    xi, yi = xyi
    xj, yj = xyj
    p = xj - xi
    q = yj - yi

    cost = n
    for x, y in xys:
        for xx, yy in xys:
            if x == xx - p and y == yy - q:
                cost -= 1
    min_cost = min(min_cost, cost)

print(min_cost)


Measured memory_bytes: 3064
from math import gcd

def main():
    K = int(input())
    ans = 0
    for k in range(1,K+1):
        for j in range(1,K+1):
            tmp = gcd(j, k)
            for i in range(1,K+1):
                ans+=gcd(i,tmp)
    print(ans)
    return

main()

Measured memory_bytes: 67920
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const ll INF=1e18;
const int MOD=1e9+7;
const double pi=acos(-1);

int main(){
  ll n;
  cin >> n;
  ll ans=0;
  vector<ll>a(n);
  vector<ll>b(n);
  vector<ll>sa(n+1);
  vector<ll>sb(n+1);
  sa[0]=0,sb[0]=0;
  rep(i,n)cin>>a[i];
  rep(i,n)cin>>b[i];
  rep(i,n)sa[i+1]=sa[i]+a[i];
  rep(i,n)sb[i+1]=sb[i]+b[i];
  rep(i,n){
    ans=max(ans,sa[i+1]-sa[0]+sb[n]-sb[i]);
  }
  cout << ans << endl;
      
    
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int H,W,i,j;
	while(1){
		scanf("%d %d",&H,&W);
		if(H==0 && W==0){
			break;
		}
		for(i=1;i<=H;i++){
			for(j=1;j<=W;j++){
				if(i%2==1){
					if(j%2==1){
						printf("#");
					}
					if(j%2==0){
						printf(".");
					}
				}
				if(i%2==0){
					if(j%2==0){
						printf("#");
					}
					if(j%2==1){
						printf(".");
					}
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 572
#include <vector>
#include <algorithm>
#include <cstdio>

using namespace std;

int main()
{
	int num;
	vector<int> counts(100010);
	scanf("%d", &num);

	for (int i = 0; i < num; ++i)
	{
		int temp;
		scanf("%d", &temp);
		counts[temp    ]++;
		counts[temp + 1]++;
		counts[temp + 2]++;
	}

	printf("%d", *max_element(counts.begin(), counts.end()));
	return 0;
}

Measured memory_bytes: 640
def f(n):
    if n % 2 == 0:
        return n / 2
    else:
        return 3 * n + 1

s = [int(input())]

for i in range(1000001):
    s.append(f(s[i]))
    if len(set(s)) == i + 1:
        print(i + 2)
        exit()

Measured memory_bytes: 3060
S = input()
N = len(S)

T1 = S[::-1]
T2 = S[0:(N-1)//2]
T3 = S[(N+3)//2-1:N]

if S == T1 and T2 == T2[::-1] and T3 == T3[::-1]:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 38384
#include<stdio.h>
#include<stdlib.h>
int main()
{
	int a, b, c, t;
	int  j = 0;
	int  temp;
	scanf("%d%d%d", &a, &b, &c);
	if (a == b && b == c)
		printf("0");
	if ((a == b && a != c) || (a == c && a != b) || (b == c && a != b))
	{
		if (a > b)
		{
			t = a; a = b; b = t;
		}
		if (b > c)
		{
			t = b; b = c; c = t;
		}
		if (a > b)
		{
			t = a; a = b, b = t;
		}
		if (c == b)
		{
			if ((c - a) % 2 != 0)
			{
				temp = (c - a + 1) / 2;
				temp = temp + 1;
				printf("%d", temp);
			}
			else
				printf("%d", (c - a) / 2);
		}
		if (a == b)
		{
			printf("%d", c - a);
		}
	}
	if (a != b && a != c && b != c)
	{
		if (a>b)
		{
			t = a; a = b; b = t;
		}
		if (b>c)
		{
			t = b; b = c; c = t;
		}
		if (a>b)
		{
			t = a; a = b, b = t;
		}
		for (a; b < c; b++)
		{
			a++;
			j++;
		}
		if ((c - a) % 2 != 0)
		{
			j = j + (c - a + 1) / 2;
			j = j + 1;
			printf("%d", j);
		}
		else
		{
			j = j + (c - a) / 2;
			printf("%d", j);
		}
	}
	return 0;
}

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


priority_queue<int>pque;
int main()
{
    int n,m;
    cin>>n>>m;
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        int p;
        cin>>p;
        pque.push(p);
    }
    while(m)
    {
        int pp=pque.top();
        pque.pop();
        pp/=2;
        m--;
        pque.push(pp);
    }
    while(!pque.empty())
    {
        int pp=pque.top();
        pque.pop();
        ans+=pp;
    }
    cout<<ans<<endl;
    return 0;
}
/*
10
16 7
15 15
12 14
2 5
3 9
1 10
14 14
4 6
*/


Measured memory_bytes: 1020
s = input()
k = int(input())
n = len(s)
le = [""]*n
ne = []

for i in range(n):
    le[i] = s[i]
    if s[i] == "a":
        ne.append(0)
    else:
        ne.append(123-ord(s[i]))
        
rem = k
for i in range(n):
    if rem >= ne[i]:
        rem -= ne[i]
        le[i] = 'a'
        
saigo = ord(le[n-1]) - 97
ssm = (rem+saigo) % 26
le[n-1] = chr(97+ssm)

print(*le,sep = "")

Measured memory_bytes: 53920
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e6 + 13;
int a[N], b[N];
signed main()
{
#ifdef home
    freopen(".in", "r", stdin);
    freopen(".out", "w", stdout);
#else
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i] >> b[i];
    }
    int pls = 0, ans = 0;
    for (int i = n - 1; i >= 0; i--)
    {
        a[i] += pls;
        pls += (b[i] - a[i] % b[i]) % b[i];
        ans += (b[i] - a[i] % b[i]) % b[i];
    }
    cout << ans;
}

Measured memory_bytes: 5120
// #pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
#define fou(i,a,n) for(int i=a;i<n;i++)
#define fod(i,a,n) for(int i=n-1;i>=a;i--)
#define rep(n) fou(_,0,n)
#define tra(a,x) for(auto& a : x)

#define emb emplace_back
#define pub push_back
#define pob pop_back
#define mp make_pair
#define fi first
#define se second
#define siz(xs) ((int)(xs).size())
#define all(xs) xs.begin(),xs.end()
#define lla(xs) xs.rbegin(),xs.rend()
#define sortup(xs) sort(all(xs))
#define sortdown(xs) sort(lla(xs))
template<class C>void mini(C &a,C b){a=min(a,b);}
template<class C>void maxi(C &a,C b){a=max(a,b);}
#define in(T,...) T __VA_ARGS__;_cin(__VA_ARGS__)
#define out(...) _cout(__VA_ARGS__)
void _cin(){}template<class Head,class...Tail>void _cin(Head&&head,Tail&&...tail){cin>>head;_cin(forward<Tail>(tail)...);}
void _cout(){}template<class Head,class...Tail>void _cout(Head&&head,Tail&&...tail){cout<<head<<endl;_cout(forward<Tail>(tail)...);}
template<class Type>void _cinvec(Type t,int n){}template<class Type,class Head,class...Tail>void _cinvec(Type t,int n,Head&&head,Tail&&...tail){rep(n){cin>>t;head.eb(t);}_cinvec(t,n,forward<Tail>(tail)...);}

#define VI vector<int>
#define VD vector<double>
#define VS vector<string>
#define VVI vector<VI>
#define VVD vector<VD>
#define VVS vector<VS>

// #define int int64_t
// #define double long double

// map,文字列処理


signed main(){
  in(string,S);
  int s=siz(S);
  string str1;fou(i,0,s)str1.pub(i%2==0?'0':'1');
  string str2;fou(i,0,s)str2.pub(i%2==0?'1':'0');
  int x1=0,x2=0;
  fou(i,0,s){
    if(S[i]!=str1[i]) x1++;
    if(S[i]!=str2[i]) x2++;
  }
  out(min(x1,x2));
}

Measured memory_bytes: 640
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<int,int> P;
#define fi first
#define se second
#define all(v) (v).begin(),v.end()
set<string> c;
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int h,w,a,b;
cin>>h>>w>>a>>b;
vector<vector<int>> t(h,vector<int>(w,0));
for(int i=0;i<b;i++){
   for(int j=0;j<a;j++)t[i][j]=1;
}
for(int i=b;i<h;i++){
   for(int j=a;j<w;j++)t[i][j]=1;
}
for(int i=0;i<h;i++){
   for(int j=0;j<w;j++)cout<<t[i][j];
   cout<<endl;
}
}


Measured memory_bytes: 5248
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

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

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin>>n;
  vector<int>h(n+2,0);
  rep(i,n)cin>>h[i+1];
  int res=0;
  while(1)
  {
    int max=0;
    rep(i,n+2)chmax(max,h[i]);

    if(max==0)break;
    vector<int>th=h;
    th.erase(unique(all(th)),th.end());

  //  rep(i,th.size())cout<<th[i];
  //  cout<<endl;
    rep(i,th.size())if(th[i]==max)res++;
    rep(i,n+2)if(h[i]==max)h[i]--;
  //  cout<<res<<endl;
  }


  cout<<res<<endl;
  return 0;

}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main(){
    int n; cin >> n;
    string s;
    int ans=0,ba=0,bx=0,xa=0;
    for(int i=0;i<n;i++){
        cin >> s;
        for(int j=0;j<s.length()-1;j++){
            if(s.at(j)=='A'&&s.at(j+1)=='B') ans ++;
        }
        if(s.at(0)=='B'){
            if(s.at(s.length()-1)=='A') ba++;
            else bx++;
        }else if(s.at(s.length()-1)=='A') xa++;
    }
    if(ba==0)ans += min(bx,xa);
    else if(xa==0&&bx==0) ans+=ba-1;
    else ans += ba+min(bx,xa);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(3, "Ofast", "inline")

#include <bits/stdc++.h>

#define start ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define int ll
#define ls st<<1
#define rs st<<1|1
#define pii pair<int,int>
#define rep(z, x, y) for(int z=x;z<=y;++z)
#define repd(z, x, y) for(int z=y;z>=x;--z)
#define com bool operator<(const node &b)
using namespace std;
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
const int maxn = (ll) 3e5 + 5;
const int mod = 998244353;
const int inf = 0x3f3f3f3f;
int T = 1;
int num1, num2;

int now = 0;
int f[maxn];

void f1(int val) {
    int tmp = (num1 + val) % (now + 1);
    cout << f[tmp] + 1 << '\n';
}

void f2(int val) {
    int tmp = ((num2 + val) % (now - 1) + now - 1) % (now - 1);
    cout << f[tmp] + 1 << '\n';
}

int fac1[maxn];
int fac2[maxn];

void solve() {
    rep(i, 1, 2e5) {
        int t = i;
        int s = __builtin_popcount(t);
        t %= s;
        f[i] = f[t] + 1;
    }
    string s;
    int n;
    cin >> n;
    fac1[0] = fac2[0] = 1;
    cin >> s;
    for (auto &i:s)now += (i == '1');
    if (now == 0) {
        rep(i, 1, n)cout << 1 << '\n';
        return;
    }
    if (now == 1) {
        if (s[s.size() - 1] == '1') {
            rep(i, 1, n - 1)cout << 2 << '\n';
            cout << 0 << '\n';
        } else {
            rep(i, 0, n - 1) {
                if (s[i] == '1')
                    cout << 0 << '\n';
                else if (i != n - 1)
                    cout << 1 << '\n';
                else if (i == n - 1)
                    cout << 2 << '\n';
            }
        }
        return;
    }
    rep(i, 1, n) {
        fac1[i] = fac1[i - 1] * 2 % (now + 1);
        fac2[i] = fac2[i - 1] * 2 % (now - 1);
    }
    for (auto &i:s) {
        num1 = num1 * 2 + (i == '1');
        num2 = num2 * 2 + (i == '1');
        num1 %= (now + 1);
        num2 %= (now - 1);
    }
    for (int i = 0, j = n - 1; i < n; ++i, --j) {
        if (s[i] == '1')
            f2(-fac2[j]);
        else
            f1(fac1[j]);
    }
}

signed main() {
    start;
    while (T--)
        solve();
    return 0;
}

Measured memory_bytes: 8444