akhauriyash/Code-Regression huggingface dataset:
/*#define _USE_MATH_DEFINES
#include<cmath>*/
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define rREP(i,a,n) for(int (i)=(n)-1; (i)>=(a);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 2147483647;
constexpr ll mod = 1000000007;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
	
int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N; cin >> N;
	vector<vector<pair<int, int>>>xy(N);
	rep(i, N) {
		int a; cin >> a;
		rep(j, a) {
			int x, y;cin >> x >> y;
			xy[i].push_back(make_pair(x, y));
		}
	}
	int ans = 0;
	for (int bit = 0;bit < (1 << N);++bit) {
		bitset<20>honest = bit;
		rep(i, N) {
			for (auto p : xy[i]) {
				if (!(bit & (1 << i)))continue;
				if (p.second == 0) {
					if (bit & (1 << p.first - 1))goto e;
				}
				if (p.second == 1) {
					if (!(bit & (1 << p.first - 1)))goto e;
				}
			}
		}
		chmax(ans, (int)honest.count());
	e:;
	}
	cout << ans << "\n";
	

	return 0;
}


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

int main(){
  string S;
  cin >> S;
  
  int N=S.size();
  int temp=0, maxlen=0;
  for(int i=0; i<N; i++){
    if(S[i]=='A'||S[i]=='C'||S[i]=='G'||S[i]=='T'){
      temp++;
    }else{
      maxlen=max(maxlen,temp);
      temp=0;
    }
  }
  cout << max(maxlen,temp) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main(){
    int N,Q;
    string s;

    cin >> N >> Q >> s;    
    s="0"+s+"0";
    
    string t,d,tmp_t,tmp_d;

    for(int i=0;i<Q;++i){
        cin >>tmp_t >>tmp_d;
        t.append(tmp_t);
        d.append(tmp_d);
    }

    int L=0,R=N+1;;

    for(int i=Q-1;i>-1;--i){
        if(t[i]==s[L] && d[i]=='R') L=L-1;
        else if(t[i]==s[L+1] && d[i]=='L') L=L+1;
        if(t[i]==s[R] && d[i]=='L') R=R+1;
        else if(t[i]==s[R-1] && d[i]=='R') R=R-1;
    }
    
    cout << R-L-1;

}

Measured memory_bytes: 1336
#include <iostream>
#include<stdio.h>
using namespace std;
int main(void){
     int d;
     while(cin>>d){
        int a=0,b=0;
        for(int i=0;i<600;i+=d){
            b=i*i;
            a+=b;
        }
        cout<<a*d<<endl; 
     }
    return 0;
}


Measured memory_bytes: 3056
fun main(args: Array<String>) {
    solve(java.util.Scanner(System.`in`))
}

fun pow(a: Int, p: Int): Long = pow(a.toLong(), p)
fun pow(a: Long, p: Int): Long = when {
    p == 0 -> 1L
    p % 2 == 1 -> a * pow(a, p - 1)
    else -> {
        val half = pow(a, p / 2)
        half * half
    }
}

fun solve(sc: java.util.Scanner) {
    val H = sc.nextInt()
    val W = sc.nextInt()
    val K = sc.nextInt()
    val A = Array(H) { sc.next().toCharArray() }

    val S = Array(H + 1) { Array(W + 1) { 0 } }
    for (h in 0 until H) {
        for (w in 0 until W) {
            var next = if (A[h][w] == '1') 1 else 0
            if (w > 0) {
                next += S[h + 1][w]
            }
            S[h + 1][w + 1] = next
        }
    }
    for (h in 1 until H) {
        for (w in 0 until W) {
            S[h + 1][w + 1] += S[h][w + 1]
        }
    }

//    S.forEach { println(it.joinToString()) }

    var result = Int.MAX_VALUE
    for (hs in 0 until pow(2, H).toInt()) {
        val hb = (1 until H).filter { b -> hs and (1 shl (b - 1)) != 0 } + H
        var nw = hb.count() - 1
        var wPrev = 0
        var w = 1
        while (w <= W) {
            var max = 0
            var hPrev = 0
            for (h in hb) {
                val n = S[h][w] - S[hPrev][w] - S[h][wPrev] + S[hPrev][wPrev]
                if (n > max) {
                    max = n
                }
                hPrev = h
            }
            if (max > K) {
                if (wPrev == w - 1) {
                    nw = -1
                    break
                }
                wPrev = w - 1
                nw++
                continue
            }
            w++
        }
        if (nw >= 0) {
            if (nw < result) {
                result = nw
            }
        }
    }
    println(result)
}


Measured memory_bytes: 44040
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(int)(b); i++)
#define FORD(i, a, b) for (int i=a; i>(int)(b); i--)
#define PPC(x) __builtin_popcount(x)
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define ft first
#define sd second
#ifdef DEBUG
#include "debug.h"
#else
#define dbg(...) 0
#endif
using namespace std;

const int maxN = 1 << 17, mod = 1000000007;

template <class T1, class T2> inline void addMod(T1& a, T2 b)	{   a = (a + b) % mod;  }
template <class T1, class T2> inline void multMod(T1& a, T2 b)	{   a = a * b % mod;    }

long long qpow(long long a, long long b)
{
    long long res0 = 1;
    for (; b!=0; b>>=1)
    {
        if (b & 1)  multMod(res0, a);
        multMod(a, a);
    }
    return res0;
}

long long T[maxN], fact[maxN], tcaf[maxN];

long long cf(int n, int k)
{
	bool static initd = false;
	if (!initd)
	{
		fact[0] = 1;
		FOR(i, 1, maxN)
			fact[i] = fact[i - 1] * i % mod;
		tcaf[maxN - 1] = qpow(fact[maxN - 1], mod - 2);
		for (int i=maxN-1; i>0; i--)
			tcaf[i - 1] = tcaf[i] * i % mod;
		initd = true;
	}
	if (k < 0 or k > n)
		return 0;
	long long res0 = fact[n];
	multMod(res0, tcaf[k]);
	multMod(res0, tcaf[n-k]);
	return res0;
}

void solve()
{
	int n, k;
	scanf ("%d%d", &n, &k);
	FOR(i, 0, n)
		scanf ("%lld", T+i);
	sort(T, T+n);
	
	long long res = 0;
	FOR(i, 0, n)
	{
		addMod(res, cf(i, k-1) * T[i]);
		multMod(T[i], mod-1);
		addMod(res, cf(n-1-i, k-1) * T[i]);
	}
	
	printf("%lld\n", res);
}

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


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

typedef long long ll;
int main()
{
	int k, n;
	cin >> k >> n;

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

	for (int i = 0; i < (n - 1); i++) {
		T[i] = A[i + 1] - A[i];
	}
	T[n - 1] = k - A[n - 1] + A[0];

	//for (int u : T)  cout << u << endl;
	ll sum = 0;
	int Max = 0;
	for (int i = 0; i < n; i++) {
		sum += T[i];
		Max = max(Max, T[i]);
	}
	cout << sum - Max << endl;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<cmath>
#include<string>

#define ls (t<<1)
#define rs ((t<<1)+1)
#define mid ((l+r)>>1)
#define fi first
#define se second
#define mk make_pair
#define pb push_back

#define N 100005
#define M 200005
#define seed 23333

using namespace std;
int i,j,m,n,p,k,A[N*3],a[N*3];
long long ans;
int main()
{
		scanf("%d",&n); n*=3;
		for (i=1;i<=n;++i) scanf("%d",&a[i]);
		sort(a+1,a+n+1);
		for(i=n/3+1;i<=n;i+=2) ans+=a[i];
		cout<<ans<<endl;
}


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

int main()
{
    int n;
    int64_t a, b;
    std::cin >> n >> a >> b;
    int x;
    std::cin >> x;

    int64_t sum = 0;
    for (int i = 1; i < n; ++i)
    {
        int y;
        std::cin >> y;
        sum += std::min((y - x) * a, b);

        x = y;
    }

    std::cout << sum << std::endl;
    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MDK=1e9+7;
string L;
vector < ll > pow3;

ll f(int p){
    if(p==L.size()) return 1;
    if(L[p]=='0') return f(p+1);
    return (pow3[L.size()-1-p]+2*f(p+1))%MDK;
}

void _prepare(){
    cin>>L;
    pow3.resize(L.size());
    pow3[0]=1;
    for(int i=1;i<L.size();++i)
        pow3[i]=pow3[i-1]*3%MDK;
}

int main(){
    _prepare();
    cout<<f(0)<<endl;
    return 0;
}

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

int main(){
  vector<int> s={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin>>k;
  cout<<s[k-1]<<endl;
}


Measured memory_bytes: 256
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std, core.bitop;
// dfmt on

void main()
{
    auto abc = aryread();
    abc.sort();
    writeln(abc[0 .. 2].sum());
}


Measured memory_bytes: 3624
#include <stdio.h>

#define NMAX 10

int main () {
	int N;
	int ptmp;
	int pmax = 100;
	int sum = 0;
	scanf ("%d", &N);

	for (int i=0; i<N; i++) {
		scanf ("%d", &ptmp);
		if (ptmp > pmax)
			pmax = ptmp;
		sum += ptmp;
	}

	printf ("%d\n", sum - pmax/2);
	return 0;
}




Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

ll n, x;

ll solve(vector<ll> a) {
  ll res = 0;
  if (a[0] > x) {
    res += a[0] - x;
    a[0] = x;
  }
  rep(i, n - 1) {
    if (a[i] + a[i + 1] > x) {
      res += a[i] + a[i + 1] - x;
      a[i + 1] = x - a[i];
    }
  }
  return res;
}

int main() {
  cin >> n >> x;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  ll ans = solve(a);
  reverse(a.begin(), a.end());
  ans = min(ans, solve(a));
  cout << ans << endl;




  
  return 0;
}

Measured memory_bytes: 1804
function Main(input) {
	var inputArr = input.split("\n");
	var inArr1 = inputArr[0].split(" ");
	var a = parseInt(inArr1[0], 10);
	var b = parseInt(inArr1[1], 10);
  　if (a === b) {
    	console.log(a + b);
    } else if (a > b) {
        console.log(a * 2 - 1);
    } else {
        console.log(b * 2 - 1);
   	}
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

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

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            String result = "ABC";
            if (Integer.parseInt(br.readLine()) >= 1000) {
                result = "ABD";
            }

            System.out.println(result);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
        cin >> A.at(i);
    int cnt = 0;
    while (true)
    {
        for (int i = 0; i < N; i++)
        {
            if (A.at(i) % 2)
            {
                cout << cnt << endl;
                return 0;
            }
        }

        for (int i = 0; i < N; i++)
        {
            A.at(i) /= 2;
        }
        cnt++;
    }
}

Measured memory_bytes: 3592
#include<iostream>
#include<cstring>
using namespace std;
int N,A;
int main(){
    cin>>N;
    int ans[N];
    memset(ans,0,sizeof ans);
    for(int i=2;i<=N;i++){
        cin>>A;
        ans[A-1]++;
    }
    for(int i=0;i<N;i++){
        cout<<ans[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 4412
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<pair<ll,ll>,null_type,less<pair<ll,ll> >,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
/* ll t = 0;
ordered_multiset me;
...
me.insert({x, t++});
me.erase(me.lower_bound({x, 0}));
cout << me.order_of_key({x, 0}) << "\n";

///////////   t is insertion time
*/
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
typedef long double lld;
lld pi=3.14159265358;
ll powr(ll a,ll b)
{
    ll c=1;
    ll i;
    for(i=0;i<b;i++)
        c*=a;
    return c;
}
ll hell=1000000007;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
ll parent[100005];
ll sizer[100005];
ll findpar(ll x)
{
    if(x==parent[x])
        return x;
    return parent[x]=findpar(parent[x]);
}
vector<pair<ll,ll> > v;
vector<ll> fans;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,m,i;
    cin>>n>>m;
    for(i=0;i<m;i++)
    {
        ll x,y;
        cin>>x>>y;
        v.pb(mp(x,y));
    }
    for(i=0;i<100005;i++)
        {parent[i]=i;
        sizer[i]=1;
        }
    ll ans=((n*(n-1))/2);
    for(i=(m-1);i>=0;i--)
    {
        fans.pb(ans);
        ll a=findpar(v[i].F);
        ll b=findpar(v[i].S);
        if(a!=b)
        {
            ans=ans-(sizer[a]*sizer[b]);
            if(sizer[a]>=sizer[b])
            {
                sizer[a]+=sizer[b];
                sizer[b]=0;
                parent[b]=a;
            }
            else
            {
                sizer[b]+=sizer[a];
                sizer[a]=0;
                parent[a]=b;
            }

        }
    }
    reverse(all(fans));
    for(i=0;i<m;i++)
        cout<<fans[i]<<"\n";
    return 0;
}




Measured memory_bytes: 6256
class BinaryTree {
  constructor(n) {
    this.nodes = [];
    for (let i = 0; i < n; i++) this.nodes[i] = {id: -1, parentId: -1, leftId: -1, rightId: -1}
  }

  get root() { return this.nodes.find(n => n.parentId === -1); }

  add(id, leftId, rightId) {
    let n = this.nodes[id];
    [n.id, n.leftId, n.rightId] = [id, leftId, rightId];
    if (leftId !== -1) this.find(leftId).parentId = id;
    if (rightId !== -1) this.find(rightId).parentId = id;
  }

  find(id) { return this.nodes[id] || {}; }

  preorder(id = this.root.id) {
    if (id === -1) return;
    let n = this.find(id);
    process.stdout.write(` ${id}`);
    this.preorder(n.leftId);
    this.preorder(n.rightId);
  }

  inorder(id = this.root.id) {
    if (id === -1) return;
    let n = this.find(id);
    this.inorder(n.leftId);
    process.stdout.write(` ${id}`);
    this.inorder(n.rightId);
  }

  postorder(id = this.root.id) {
    if (id === -1) return;
    let n = this.find(id);
    this.postorder(n.leftId);
    this.postorder(n.rightId);
    process.stdout.write(` ${id}`);
  }
}

(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());
  let tree = new BinaryTree(n);
  lines.map(l => l.split(' ').map(Number)).forEach(line => tree.add(...line));
  console.log('Preorder');
  tree.preorder();
  console.log('\nInorder');
  tree.inorder();
  console.log('\nPostorder');
  tree.postorder();
  console.log();
})();



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

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp make_pair
#define FILE "parade"

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const ull ULLINF = numeric_limits<ull>::max();
const double PI = acos(-1.0);

int main()
{
//    freopen(FILE".in", "r", stdin);
//    freopen(FILE".out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string ans = "";
    string s;
    cin >> s;
    for(char a: s)
    {
        if(a == 'B' && ans.size())
            ans.pop_back();
        else if(a == '0' || a == '1')
            ans.pb(a);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
//set many funcs template
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}

int main(void){
    int sx,sy,tx,ty,i;
    scanf("%d%d%d%d",&sx,&sy,&tx,&ty);
    for(i=1;i<=zt(sy,ty);i++){printf("U");}
    for(i=1;i<=zt(sx,tx);i++){printf("R");}
    for(i=1;i<=zt(sy,ty);i++){printf("D");}
    for(i=1;i<=zt(sx,tx);i++){printf("L");}
    printf("L");
    for(i=1;i<=zt(sy,ty)+1;i++){printf("U");}
    for(i=1;i<=zt(sx,tx)+1;i++){printf("R");}
    printf("DR");
    for(i=1;i<=zt(sy,ty)+1;i++){printf("D");}
    for(i=1;i<=zt(sx,tx)+1;i++){printf("L");}
    printf("U\n");
    return 0;
}

Measured memory_bytes: 128
#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 = 1e9;

int main() {
  ll n, m = 1000, st = 0;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  rep(i, n - 1) {
    m += st * a[i], st = 0;
    if (a[i + 1] > a[i]) st += m / a[i], m -= st * a[i];
  }
  m += st * a[n - 1];

  cout << m << endl;
  return 0;
}


Measured memory_bytes: 3628
#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;
    int ans = 1;
    rep(i, 3) {
        ans *= n;
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MAXN=1e5+10,MAXM=1e6+10;
const int INF=~(1<<31),MOD=1e9+7;

priority_queue<int> pq;

int main()
{
    int n,m;;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
    {
        int temp;
        scanf("%d",&temp);
        pq.push(temp);
    }
    for(int i=1;i<=m;i++)
    {
        int temp=pq.top();
        pq.pop();
        pq.push(temp/2);
    }
    ll ans=0;
    while(!pq.empty())
    {
        ans+=pq.top();
        pq.pop();
    }
    cout<<ans;
	return 0;
}



Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
#define Yes "Yes"
#define No "No"
#define YES "YES"
#define NO "NO"
typedef long long ll;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    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 <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
const int maxn=106;
const int maxw=1e4+6;
const int INF=0x7fffffff;

class node{
public:
	int value,weight;
	node(int value=0,int weight=0):value(value),weight(weight){}	
}a[maxn];

int n,w;
int dp[maxn][maxw];

int main() {
	std::ios::sync_with_stdio(false);
	cin>>n>>w;
	int x,y;
	for(int i=1;i<=n;i++){
		cin>>x>>y;
		a[i]=node(x,y);
	}
	
	for(int i=1;i<=n;i++){
		for(int j=1;j<=w;j++){
			if(j<a[i].weight) dp[i][j]=dp[i-1][j];
			else dp[i][j]=max(dp[i-1][j],dp[i-1][j-a[i].weight]+a[i].value);
		}
	}
	cout<<dp[n][w]<<endl;
	return 0;
}


Measured memory_bytes: 7112
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, m, n) for (int i = m; i<n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
#define SUM(x) accumulate(x.begin(), x.end(),0);
#define vint(v,n) vector<int> v(n); REP(i,n) scanf("%lld", &v[i]);
#define vstr(v,n) vector<string> v(n); REP(i,n) scanf("%lld", &v[i]);
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
int k=0,n=0, m=0, l=0,r=0,a=0, b=0, c=0, d=0,e=0,ans=0,ans2=0,x=0,y=0;
string s,t,S;
signed main() {
    cin >> n >> a;
    l = a;
    r = a+n - 1;
    if(r<=0)ans = r;
    else if (l >= 0) ans = l;
    else ans = 0;
    ans2 = (r + l) * (r - l + 1) / 2 - ans;
    cout << ans2 << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
ll pwr[210], mod=998244353;
void pre(){
  pwr[0]=1;	
  for(int i=1; i<=200; ++i){
    pwr[i]=(pwr[i-1]*2)%mod;
  }
}
ll x[210], y[210];
map<pair<ll,ll>, ll> mp;
int main(){
  int n;
  pre();
  while(cin>>n){
    for(int i=0; i<n; ++i){
      scanf("%lld%lld",&x[i],&y[i]);
    }
    ll ans=pwr[n]-n-1, tmp1, tmp2, tmp;
    for(int i=0; i<n; ++i){
      mp.clear();
      for(int j=i+1; j<n; ++j){
        tmp1=(y[i]-y[j]);
        tmp2=(x[i]-x[j]);
        tmp=__gcd(tmp1, tmp2);
        tmp1/=tmp;
        tmp2/=tmp;
        ++mp[mk(tmp1, tmp2)];
      }
      for(map<pair<ll,ll>, ll>::iterator it=mp.begin(); it!=mp.end(); ++it){
        ans-=(pwr[it->second])-1;
        ans%=mod;
      }
    }
    ans%=mod;
    if(ans<0)
      ans+=mod;
    printf("%lld\n",ans);
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int H, A; cin >> H >> A;
    cout << ceil((double)H / A) << endl;
}


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

#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

////////////////////////////////////////////////////////////////////

const int N = 2e5 + 5;

int main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	ll a, b, k; cin >> a >> b >> k;
	ll aa = max(a - k, 0ll);
	k -= (a - aa);
	ll bb = max(b - k, 0ll);
	cout << aa << ends << bb << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void) {
  while(1){
    int N,n,S[1000],t=0;
    double m,a2=0;
    scanf("%d\n",&N);
    if(N==0) break;
    for(n=0;n<N;n++) {
      scanf("%d",&S[n]);
      t=t+S[n];
    }
    m=(double)t/n;
    for(n=0;n<N;n++) {
      a2=a2+(m-S[n])*(m-S[n]);
    }
    printf("%.8lf\n",sqrt((double)a2/n));
  }
  return 0;
}

Measured memory_bytes: 644
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <utility>
#include <algorithm>
#include <math.h>

using namespace std;

#define ll long long

int main(){
  	int P, Q, R;
  	cin >> P >> Q >> R;
  	cout << P+Q+R-max({P,Q,R}) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;


template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

// 繰り返し二乗法
ll pow2(ll n, ll p, ll mod) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n % mod, p / 2, mod);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret % mod;
	}
}

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	const ll mod = 1e9 + 7;

	ll N;
	std::cin >> N;
	vll A(N);
	vector<vll> cnt(N + 1, vll(60 + 1, 0));
	rep(i, 0, N) {
		std::cin >> A[i];
		repeq(j, 0, 60) {
			if (A[i] & (1LL << j)) {
				cnt[i][j]++;
			}
		}
		cnt[i + 1] = cnt[i];
	}

	ll ans = 0;
	rep(i, 0, N) {
		repeq(j, 0, 60) {
			ll tmp;
			if (A[i] & (1LL << j)) {
				tmp = N - i - 1 - cnt[N][j] + cnt[i][j];
			}
			else {
				tmp = cnt[N][j] - cnt[i][j];
			}
			tmp %= mod;
			ans += (tmp * ((1LL << j)%mod)) % mod;
			ans %= mod;
		}
	}

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


Measured memory_bytes: 157804
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
using i64 = long long;

int main()
{
  i64 n, m;
  cin >> n >> m;
  vector<i64> edge[n];
  for (i64 i = 0; i < m; i++)
  {
    i64 x, y, z;
    cin >> x >> y >> z;
    x--;
    y--;
    edge[x].push_back(y);
    edge[y].push_back(x);
  }
  i64 ans = 0;
  vector<i64> t(n, -1);
  for (i64 i = 0; i < n; i++)
    if (t[i] == -1)
    {
      t[i] = ans;
      queue<i64> que;
      que.push(i);
      while (que.size())
      {
        i64 p = que.front();
        que.pop();
        for (i64 j : edge[p])
          if (t[j] == -1)
          {
            t[j] = ans;
            que.push(j);
          }
      }
      ans++;
    }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 8052
#include "bits/stdc++.h"

using namespace std;

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define in(x, a, b) a <= x && x < b
const int inf = 1000000001;
const ll INF = 2e18;
const ll MOD = 1000000007;
//const ll mod = 1000000009;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p <<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };


int main() {
	ll mi = INF;
	ll a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	for (int i = 0; i < 2*max(x, y) + 6;i+=2){
		ll nedan = c*i;
		if (i/2 < x) {
			nedan += (x - i/2)*a;
		}
		if (i/2 < y) {
			nedan += (y - i/2)*b;
		}
		mi = min(mi, nedan);
	}
	cout << mi << endl;
}

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

int main(){
    int n;
    cin >> n;
    int ans = 0;

    for(int i= 0;i<n;i++){
        int num = n - i;
        int keta = 1;
        while(num/10 != 0) keta++,num/=10;
        if(keta%2 == 1 ) ans++;

    }

    cout << ans << endl;
    // for(int i=0 ;i<strlen(n);i++) cout << n[i] ;

    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  int n;
  cin>>n;
  int a,b;
  cin>>a>>b;
  int cnt[3] = {};
  int p;
  REP(i,n){
    cin>>p;
    if(p<=a){
      cnt[0]++;
    }else if(p>b){
      cnt[2]++;
    }else{
      cnt[1]++;
    }
  }
  
  int ans = 101;
  REP(i,3){
    ans = min(ans,cnt[i]);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<typename T1, typename T2>
inline bool chmin (T1& a, T2 b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  string s;
  cin >> s;
  int n = s.length();
  vector<int> a(n);
  for (int i = 0; i < n; i++) a[i] = s[i] - '0';
  int ret = 1e9;
  for (int t = 0; t < 2; t++) {
    int tmp = 0;
    for (int i = 0; i < n; i++) {
      if ((i & 1) ^ t ^ a[i]) tmp++;
    }
    chmin(ret, tmp);
  }
  cout << ret << endl;
  return 0;
}

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

using namespace std;

const int MaxN = 1005;
const int Mod = 1000000007;

int n, m;
bool a[MaxN][MaxN];
int dp[MaxN][MaxN];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    char ch;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            cin >> ch;
            a[i][j] = (ch == '.');
        }
    }
    dp[0][1] = 1;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            dp[i][j] = (a[i][j] ? (dp[i - 1][j] + dp[i][j - 1]) % Mod : 0);
        }
    }
    cout << dp[n][m];
    return 0;
}

Measured memory_bytes: 8528
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long a = sc.nextLong();
		long b = sc.nextLong();
		long[] h = new long[n];
		for(int i = 0; i < n; i++) h[i] = sc.nextLong();
		long l = 0, r = Integer.MAX_VALUE;
		while(r - l != 1) {
			long mid = (r + l) / 2;
			long[] x = Arrays.copyOf(h, h.length);
			long cnt = 0;
			for(int i = 0; i < x.length; i++) {
				if(x[i] - b * mid <= 0) continue;
				cnt += ((x[i] - b * mid) + (a - b - 1)) / (a - b);
			}
			if(mid >= cnt) r = mid;
			else l = mid;
		}
		System.out.println(r);
	}
}


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

int lowerBound(vector<int> arr, int n){
        int low = -1, high = arr.size();
        while(high-low>1){
                int mid = (high-low)/2 + low;
                if (arr[mid] > n) high = mid;
                else low = mid;
        }
        return high;
}

int main(){
        int  n;
        cin >> n;
        vector<int> l(n);
        for(int i=0; i<n; i++) cin >> l.at(i);
        sort(l.begin(), l.end());

        int ans = 0;
        for(int i=2; i<n; i++){
                for(int j=1; j<i; j++){
                        ans += max(0, j-lowerBound(l, l[i]-l[j]));
                }
        }
        cout << ans << endl;

        return 0;
}

Measured memory_bytes: 256
N = int(input())
Dice = [list(map(int, input().split())) for i in range(N)]

count = 0
flag=[]
for i in range(N):
    if Dice[i][0] == Dice[i][1]:
        flag.append(1)
    else:
        flag.append(0)

for i in range(len(flag)):
    if flag[i]==1:
        count+=1
    else:
        count=0
    if count==3:
        print("Yes")
        exit()

print("No")

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

using namespace std;

#define USE_CPPIO() ios_base::sync_with_stdio(0); cin.tie(0)
typedef pair<int, int> P;
#define F first
#define S second
#define INF 0x3f3f3f3f
#define MP make_pair
#define PB push_back
#define LL long long

int main()
{
	int num;
	string str;
	while(cin >> num)
	{
		cin >> str;
		for(int i = 0; i < str.size(); i++)
			cout << (char)((str[i] - 'A' + num) % 26 + 'A');
	}

	return 0;
}

Measured memory_bytes: 256
// A.

#include <iostream>
#include <sstream>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
	int n, k;
	cin >> n >> k;
	bool ans = (n + 1) / 2 >= k;
	cout << (ans ? "YES" : "NO") << endl;
	return 0;
}


Measured memory_bytes: 256
#https://atcoder.jp/contests/arc061/tasks/arc061_a
# -*- coding: utf-8 -*-
import itertools
S = input()
ans = 0
bit_list = list(itertools.product([0,1], repeat=len(S)-1))
for bits in bit_list:
  A =[]
  bits = list(bits)
  bits.append(0)
  for i in range(len(S)):
    A.append(S[i])
    if bits[i] == 1: A.append("+")
  ans += eval("".join(A))
print(ans)

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

int N, M;
int k[100000];
bool red[100000];
int res;

int main() {
  cin >> N >> M;
  for(int i = 0; i < N; ++i) k[i] = 1;
  red[0] = true;
  for(int i = 0; i < M; ++i) {
    int X, Y; cin >> X >> Y; --X; --Y;
    --k[X]; ++k[Y];
    if(red[X]) red[Y] = true;
    if(k[X] == 0) red[X] = false;
  }
  for(int i = 0; i < N; ++i) res += red[i];
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 768
#include <cstdio>
#include <algorithm>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)

constexpr int MAX_N = 100000;

using ll = long long;

ll N, K;
ll A[MAX_N], B[MAX_N];
ll ans;

void f( ll p )
{
  ll sum = 0;

  rep( i, N )
  {
    if( (p|A[i]) == p )
      sum += B[i];
  }

  ans = std::max( ans, sum );

  return;
}

int main()
{
  scanf( "%lld%lld", &N, &K );
  rep( i, N )
    scanf( "%lld%lld", A+i, B+i );

  f( K );

  rep( i, 32 ) if( K >> i & 1 )
    f( (K & (~(1<<i))) | ((1<<i)-1) );

  printf( "%lld\n", ans );

  return 0;
}

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

int main()
{   int n,m;
    scanf("%d%d",&n,&m);
    int k[n],a[30][30]={0};
    int b[30]={0};
    for(int i=0;i<n;i++){
        scanf("%d",&k[i]);
        for(int j=0;j<k[i];j++){
            int tmp;
            scanf("%d",&tmp);
            a[i][tmp-1]++;
        }
    }
    int  ans=0;
    for(int i=0;i<m;i++){
        for(int j=0;j<n;j++){
            if(a[j][i]==1){
                b[i]++;
            }
        }
        if(b[i]==n){
            //printf("%dis liked",i);
            ans++;
        }
    }
    printf("%d",ans);

    return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
        return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
        var t = ReadIntArray();
        int n = t[0], m = t[1];

        var x = ReadIntArray();
        Array.Sort(x);

        var d = new int[m-1];
        for (int i = 0; i < m-1; i++)
        {
            d[i] = x[i+1] - x[i];
        }

        Array.Sort(d);

        int ncut = Math.Min(m, n) - 1;
        int ans = x[m-1]-x[0];

        for (int i = 0; i < ncut; i++){
            ans -= d[m-2-i];
        }

        WriteLine(ans);
    }
}


Measured memory_bytes: 20704
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define MODB 998244353
#define INF 9223372036854775807
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
signed main()
{
  int x=0,y=0,z=0,w=0,n=0,m=0;
  std::cin >> x;
  z=x;
  while(x!=0){
    y+=x%10;
    x/=10;
  }
  std::cout << ((z%y==0)?"Yes":"No") << '\n';
}


Measured memory_bytes: 256
//BISMILLAHIR RAHMANIR RAHIM
#include <bits/stdc++.h>
#define mem(a, b) (memset(a, b, sizeof(a)))
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
#define PI acos(-1)
#define INF 2147483647
#define MOD 1000000007
#define MAX 100005
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<int, ii> pii;
typedef vector<ii> vii;
typedef priority_queue<int,vector<int>,greater<int> > PQ;

int Set(int mask, int pos){return mask = mask | (1<<pos);}
bool check(int mask, int pos){return (bool)(mask & (1<<pos));}

int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n;

    cin>>n;

    ll sum = 0;

    for(int i = 1; i <= n; i++){
        if(i % 3 != 0 && i % 5 != 0)
            sum += (ll) i;
    }

    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 3652
/*----------------by syr----------------*/
/*
  -----  -----  -----
  |   |  |---|    _/
  |   |  | \_    /
  -----  |   \  -----

  |---\  \   /  |\  /|
  |   |   \_/   | \/ |
  |   |   / \   |    |
  |---/  /   \  |    |
*/
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cstring>
#include<cstdlib>
#include<deque>
#include<fstream>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<limits>
#include<list>
#include<map>
#include<math.h>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<sstream>
#include<string>
#include<time.h>
#include<utility>
#include<vector>

#define PH push
#define MP make_pair
#define PB push_back
#define fst first
#define snd second
#define FOR(i,x,y) for(int i=(x);i<(y);++i)
#define REP(i,x,y) for(int i=(x);i<=(y);++i)
#define x0 x0123456789
#define y0 y0123456789
#define x1 x1234567890
#define y1 y1234567890
#define x2 x2345678901
#define y2 y2345678901

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ldb;
typedef pair<int,int> pii;

const int INF=1e9+7;

int a,b,c;

int main(){
	scanf("%d%d%d",&a,&b,&c);
	if(a+b>=c){
		printf("%d\n",b+c);
	}else{
		printf("%lld\n",1ll*a+b+1+b);
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;

int main(){
  int n;
  cin >> n;
  int v[n];
  rep(i, n)
    cin >> v[i];
  //ここまで入力

  //奇数番目と偶数番目に登場する数字のカウント
  map<int, int> odd, even;
  for(int i=0; i<n; i+=2)
    odd[v[i] ]++;
  for(int i=1; i<n; i+=2)
    even[v[i] ]++;

  //奇数番目と偶数番目の数のうち，最頻値を調べる
  int odd_max = v[0], even_max = v[1];
  for(auto m : odd)
    if(m.second > odd[odd_max] )
      odd_max = m.first;
  for(auto m : even)
    if(m.second > even[even_max] )
      even_max = m.first;

  //偶奇ともに登場する数字は1種類
  if(odd[odd_max] == n/2 && even[even_max] == n/2){
    //全ての数字が同じ
    if(v[0] == v[1])
      cout << n/2 << endl;
    //もとからジグザグ
    else
      cout << 0 << endl;
  }
  //それ以外
  else{
    //最頻値が同じときは，二番目の最頻値で考える
    if(odd_max == even_max){
      int odd_max2 = -1;
      for(auto m : odd)
	if(m.second > odd[odd_max2] && m.first != odd_max)
	  odd_max2 = m.first;
      int even_max2 = -1;
      for(auto  m : even)
	if(m.second > even[even_max2] && m.first != even_max)
	  even_max2 = m.first;
      if(odd[odd_max2] < even[even_max2] )
	cout << n/2-odd[odd_max] + n/2-even[even_max2] << endl;
      else
	cout << n/2-odd[odd_max2] + n/2-even[even_max] << endl;
      
    }
    //最頻値を考える
    else
      cout << n/2-odd[odd_max] + n/2-even[even_max] << endl;
  }
  
  return 0;
}


Measured memory_bytes: 5376
N = int(input())
t,a = map(int,input().split())
height = list(map(int,input().split()))
subduction = [float(abs(t-height[i]*0.006-a)) for i in range(N)]
ans = float(10**7)
lst = []
for i in range(N):
  if ans > subduction[i]:
    ans = subduction[i]
    lst.append(i)
print(lst[-1]+1)
  


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

int main(){
  int n,m,t;cin>>n>>m;
  vector<int> x(n,0);
  REP(i,m*2){
    cin>>t;
    x.at(t-1)++;
  }
  REP(i,n) cout<<x.at(i)<<endl;
}

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

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

    vector<int> h(n);
    rep (i, n)
        cin >> h[i];

    int ans = 1;
    int maxNum = h[0];
    rep (i, n - 1)
        if (h[i + 1] >= h[i] && h[i + 1] >= maxNum)
        {
            ans++;
            maxNum = max(h[i + 1], maxNum);
        }

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

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define ll long long
#define REP(i, n) for (ll (i) = 0; (i) < (n); (i)++)
#define REPI(i, a, b) for (ll (i) = (a); (i) < (b); (i)++)
#define int long long
using namespace std;
using P = pair<int, int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;

class UnionFind {
public:
  VI par, rank;
  UnionFind(int n) {
    par = VI(n); iota(par.begin(), par.end(), 0);
    rank = VI(n, 0);
  }
  int root(int x) {
    if (par[x] == x) {
      return x;
    } else {
      return par[x] = root(par[x]);
    }
  }
  void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) { return; }
    if (rank[x] < rank[y]) {
      par[x] = y;
    } else {
      par[y] = x;
      if (rank[x] == rank[y]) { rank[x]++; }
    }
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
};

struct edge { int u, v, cost; };
bool comp(const edge& e1, const edge& e2) { return e1.cost < e2.cost; }
int V, E;
vector<edge> es;

int kruskal() {
  sort(es.begin(), es.end(), comp);
  UnionFind uf(V);
  int ans = 0;
  for (edge e: es) {
    if (uf.same(e.u, e.v)) { continue; }
    uf.unite(e.u, e.v);
    ans += e.cost;
  }
  return ans;
}
signed main() {
  cin >> V >> E;
  es.resize(E);
  REP (i, E) {
    cin >> es[i].u >> es[i].v >> es[i].cost;
  }
  cout << kruskal() << endl;
}



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

int solve(int w,int h,int x,int y){
  float ans = (float)w * h / 2;
  int kano = 0;
  if(x*2==w & y*2==h){
    kano = 1;
  }
  cout << ans << " " << kano;
  return 0;
}

int main(){
  int w,h,x,y;
  cin >> w >> h >> x >> y;
  solve(w, h, x, y);
  return 0;
}


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

#define ll long long

template<typename T> void drop(const T &x){cout<<x<<'\n';exit(0);}

void solve() {
  int n; cin >> n;
  vector<vector<int>> a(n, vector<int> (3));
  for(int i=0; i<n; ++i) for(int j=0; j<3; ++j) cin >> a[i][j];

  vector<vector<int>> dp(n+1, vector<int> (3));
  for(int i=0; i<n; ++i) {
    for(int j=0; j<3; ++j) {
      for(int k=0; k<3; ++k) {
        if(j == k) continue;
        dp.at(i+1).at(k) = max(dp.at(i+1).at(k), dp.at(i).at(j)+a.at(i).at(k));
      }
    }
  }
  int ans = 0;
  for(int i=0; i<3; ++i) ans = max(ans, dp.at(n).at(i));
  cout << ans << '\n';
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T=1;
  //cin >> T;
  while(T--) solve();

  return 0;
}


Measured memory_bytes: 14144
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

signed main(){
	int d,n;
	cin>>d>>n;
	vi t(d),a(n),b(n),c(n);
	rep(i,0,d) cin>>t[i];
	rep(i,0,n) cin>>a[i]>>b[i]>>c[i];


	vi cMAX(d),cMIN(d);
	rep(i,0,d){
		int MAX=0,MIN=1000;
		rep(j,0,n){
			if(a[j]<= t[i] && t[i]<=b[j]){
				MAX=max(MAX,c[j]);
				MIN=min(MIN,c[j]);
			}
			cMAX[i]=MAX;
			cMIN[i]=MIN;
		}
	}

	int ans=0,dpM[300]={},dpm[300]={};
	rep(i,1,d){
		dpM[i]=max(dpM[i-1]+abs(cMAX[i]-cMAX[i-1]),dpm[i-1]+abs(cMAX[i]-cMIN[i-1]));
		dpm[i]=max(dpM[i-1]+abs(cMIN[i]-cMAX[i-1]),dpm[i-1]+abs(cMIN[i]-cMIN[i-1]));
		//cout<<dpM[i]<<" "<<dpm[i]<<endl;
	}
	ans=max(dpM[d-1],dpm[d-1]);
	o(ans);
}

Measured memory_bytes: 1208
import numpy as np

n = []
for i in range(5):
    n.append(int(input()))

n = np.array(n)

#n=np.sort(n)
m=[]
s=0
for p in n:
	t = p % 10
	if (t == 0):
		m.append(10)
	else:
		m.append(t)
for i in range(len(n)):
	if i==np.argmin(m):
		s += n[i]
	else:
		s += n[i] + (10-m[i])
print(s)



Measured memory_bytes: 12392