akhauriyash/Code-Regression huggingface dataset:
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main(){
    string s,t;
    cin >> s >> t;
    int n = s.size();
    int cnt = 0;
    REP(i, n)
    {
        if(s[i] != t[i]){
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3808
def bubblesort(A):
    tot = 0
    flag = 1
    N = len(A)
    
    while flag:
        flag = 0
        for j in xrange(N-1,0,-1):
            if A[j] < A[j-1]:
                A[j],A[j-1] = A[j-1],A[j]
                flag = 1
                tot += 1
    return A,tot

while True:
    try:
        N = int(raw_input())
    except EOFError:
        break
    A = map(int,raw_input().split())
    
    A,tot = bubblesort(A)
    print ' '.join(map(str,A))
    print tot

Measured memory_bytes: 4232
#include<iostream>
#include<algorithm>
using namespace std;
const int N = 1e5+1;
long long a1[N],b1[N],a,b,n;

bool can(long long ans)
{
	long long tot=0;
	for(int i=1;i<=n;++i)b1[i]=a1[i]-b*ans;
	for(int i=1;i<=n;++i)
	if(b1[i]>0)tot+=(b1[i]+a-1)/a;
	if(tot<=ans)return 1;
	return 0;
}










int main()
{
	cin>>n>>a>>b;
	a-=b;
	for(int i=1;i<=n;++i)cin>>a1[i];
	int l=1,r=2e9;
	while(l!=r)
	{
		long long mid=l+r>>1;
		if(can(mid))r=mid;
		else		l=mid+1;
	}
	cout<<l;
	return 0;
}

Measured memory_bytes: 1792
n = int(input())
t = list(map(int,input().split()))
m = int(input())
p = []
x = []
for i in range(m):
    pi,xi = map(int,input().split())
    p.append(pi)
    x.append(xi)
ans = sum(t)
for i in range(m):
    print(ans-t[p[i]-1]+x[i])


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int gcd = gcd(n, 360);
        System.out.println(360 / gcd);
    }

    public static int gcd(int a, int b) {
        return b == 0 ? a : gcd(b, a % b);
    }
}


Measured memory_bytes: 35744
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    numbers=[]
    n = int(input())
    numbers=list(map(int,input().split()))
    small=0
    dp=[]

    for idx,data in enumerate(numbers):
        if idx == 0:
            small=data
            dp.append(data)
        elif data < small:
            small=data
            dp.append(data)
        else:
            continue
    print(len(dp))

if __name__=="__main__":
    main()

Measured memory_bytes: 30968
#include <bits/stdc++.h>
using namespace std;
signed main(){
long long a,b,c,d,z;
  cin>>a>>b>>c>>d;
  if(a<b){
    cout<<a*c<<"\n";
  }else{
    z=a-b;
    cout<<b*c+z*d<<"\n";
  }
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i,n) for(ll i=0;i<(n);++i)
#define rep2(i,a,n) for(ll i=a;i<(n);++i)
#define repr(i,n) for(ll i=n;i>=0; --i)
#define repr2(i,a,n) for(ll i=n;i>=a; --i)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define vi vector<int>
#define vb vector<bool>
#define vll vector<ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define VEC(v) vector<v >

#define INT(...) int __VA_ARGS__;IN(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;IN(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;IN(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;IN(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;IN(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;IN(__VA_ARGS__)
#define LD(...) ld __VA_ARGS__;IN(__VA_ARGS__)

int scan(){ return getchar(); }
void scan(int& a){ cin>>a; }
void scan(long long& a){ cin>>a; }
void scan(char &a){cin>>a;}
void scan(double &a){ cin>>a; }
void scan(long double& a){ cin>>a; }
void scan(char a[]){ scanf("%s", a); }
void scan(string& a){ cin >> a; }
template<class T> void scan(vector<T>&);
template<class T, size_t size> void scan(array<T, size>&);
template<class T, class L> void scan(pair<T, L>&);
template<class T, size_t size> void scan(T(&)[size]);
template<class T> void scan(vector<T>& a){ for(auto& i : a) scan(i); }
template<class T> void scan(deque<T>& a){ for(auto& i : a) scan(i); }
template<class T, size_t size> void scan(array<T, size>& a){ for(auto& i : a) scan(i); }
template<class T, class L> void scan(pair<T, L>& p){ scan(p.first); scan(p.second); }
template<class T, size_t size> void scan(T (&a)[size]){ for(auto& i : a) scan(i); }
template<class T> void scan(T& a){ cin >> a; }

void IN(){}
template <class Head, class... Tail> void IN(Head& head, Tail&... tail){ scan(head); IN(tail...); }

int in() {int x;cin>>x;return x;}
ll llin() {unsigned long long x;cin>>x;return x;}

#define ios cin.tie(NULL), ios_base::sync_with_stdio(false)
#define cfs(n) cout<<fixed<<setprecision((n))
#define endl '\n'
#define ret return 0

constexpr ll mod=998244353;
constexpr ll mod2=10e9+7;
const double PI = 3.1415926535897932384626433832795028841971; //acos(-1)

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

int main(){
  ios; cfs(15);
  int cnt=0;
  INT(l,r,d);
  rep2(i,l,r+1) {
    if(i%d==0) ++cnt;
  }
  cout<<cnt<<endl;
  ret;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define rep(i,N) for(int i=1;i<N;i+=1)
using namespace std;
int main() {
  int A,B;
  cin>>A>>B;
  if(A>=10||B>=10){
    cout<<"-1"<<endl;
  }
  else
    cout<<A*B<<endl;
}
  


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N, M, X;
    cin >> N >> M >> X;
    VEC(int) C(N);
    VEC(VEC(int)) A(N, VEC(int)(M));
    FOR(i, 0, N) {
        cin >> C[i];
        READVEC(A[i]);
    }

    int minCost = -1;
    FOR(set, 0, 1 << N) {
        int cost = 0;
        VEC(int) U(M);
        FOR(i, 0, N) {
            if (set & (1 << i)) {
                cost += C[i];
                FOR(j, 0, M)
                    U[j] += A[i][j];
            }
        }

        if (*min_element(ALL(U)) >= X) {
            if (minCost < 0 || minCost > cost)
                minCost = cost;
        }
    }

    cout << minCost << endl;
    return 0;
};

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define REP(i,x,y) for(ll i=x; i<=y; i++)
#define BIT(t) ((long long 1) << t)
using namespace std;
typedef long long ll;
ll const MOD = 1e9 + 7;
ll mod_p(ll x, ll y) {
	x %= MOD;
	y %= MOD;
	return (x + y + MOD) % MOD;
}

ll mod_m(ll x, ll y) {
	x %= MOD;
	y %= MOD;
	return x * y%MOD;
}

ll mod_pow(ll x, ll t) {
	x %= MOD;
	if (t == 0) {
		return 1;
	}
	else {
		ll v = mod_pow(x, t / 2);
		if (t % 2 == 0) {
			return v * v % MOD;
		}
		else {
			return v * v%MOD * x %MOD;
		}
	}
}

ll mod_inv(ll x) {
	return mod_pow(x, MOD - 2);
}

ll const MAX = 2005;
vector<ll> g[MAX];
bool ex[MAX];

bool dfs(vector<long long>& num, vector<ll>& dist, vector<ll>& point, vector<bool>& visited, ll cur, ll i){
    visited[cur] = 1;
    for(ll nx: g[cur]){
        if(visited[nx]){
            continue;
        }
        dfs(num, dist, point, visited, nx, i);
        
        dist[nx] += num[nx];
        ll dn = dist[nx], dc = dist[cur], pn = point[nx], pc = point[cur];
        if(dist[nx] < dist[cur]){
            swap(dn, dc);
            swap(pn, pc);
        }
        point[cur] = dc * 2 + min(dn - dc, pn) / 2 * 2;
        num[cur] += num[nx];
        dist[cur] += dist[nx];
    }
    num[cur] += ex[cur];
    /*
    if(i == 1){
        cout << cur << " " << num[cur] << " " << dist[cur] << " " << point[cur] << endl;
    }
    */
    return (dist[cur] == point[cur]);
}

ll f(ll n,ll i){
    vector<long long> num(MAX, 0), dist(MAX, 0), point(MAX,0);
    vector<bool> visited(MAX, 0);
    if(dfs(num, dist, point, visited, i, i)){
        //cout << i << " ! " << point[i] << endl;
        return point[i] / 2;
    }else{
        //cout << i << " ? " <<endl;
        return 1e18;
    }
}

int main(){
    ll n;
    cin >> n;
    string s;
    cin >> s;
    REP(i,1,n-1){
        ll a,b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    
    REP(i,1,n){
        ex[i] = (s[i-1] == '1');
    }
    ll ans = 1e18;
    REP(i,1,n){
        ans = min(ans, f(n, i));
    }   
    if(ans == 1e18){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 500;
ll a[N][N];
int di[4] = {-1, 1, 0, 0};
int dj[4] = {0, 0, 1, -1};
vector<ll> primes;
void gen_primes(){
    primes.push_back(2);
    while((int) primes.size() < 2 * N){
        ll cur = primes.back() + 1;
        while(true){
            bool ok = false;
            for(ll p: primes){
                if(cur % p == 0){
                    ok = true;
                    break;
                }
            }
            if(!ok){
                primes.push_back(cur);
                break;
            }
            cur++;
        }
    }
}
ll LCM(ll x, ll y){
    return x / __gcd(x, y) * y;
}
bool valid(int i, int j){
    return (i >= 0 && i < N && j >= 0 && j < N);
}
void gen(){
    gen_primes();
    for(int i = 0; i < N; i++){
        for(int j = i % 2; j < N; j += 2){
            int diag1 = (i + j) / 2, diag2 = (i - j) / 2 + N + N / 2;
            a[i][j] = primes[diag1] * primes[diag2];
        }
    }
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            if(a[i][j] != 0) continue;
            a[i][j] = 1;
            for(int d = 0; d < 4; d++){
                int ni = i + di[d], nj = j + dj[d];
                if(valid(ni, nj)){
                    a[i][j] = LCM(a[i][j], a[ni][nj]);
                }
            }
            a[i][j]++;
        }
    }
}
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    gen();
    int n; cin >> n;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            cout << a[i][j] << " ";
        }
        cout << '\n';
    }
}


Measured memory_bytes: 5536
#include <iostream>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <cmath>

using std::cin;
using std::cout;
using std::endl;
using std::min;
using std::max;
using std::vector;

using llint = long long int;

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

	return 0;
}


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

const int MAX_N = 200000;
int N, Q;
std::vector<int> v[MAX_N];
std::vector<int> w[MAX_N];
std::vector<long long> count(MAX_N,0);

void add(int p, int x){
   count[p] += x;
   for(int i=0; i<v[p].size(); ++i){
      add(v[p][i], count[p]);
   }
}

int main(){
   std::cin >> N >> Q;
   int a, b;
   for(int i=0; i<N-1; ++i){
      std::cin >> a >> b;
      a--; b--;
      v[a].push_back(b);
      //v[b].push_back(a);
   }

   int p;
   int x;
   for(int i=0; i<Q; ++i){
      std::cin >> p >> x;
      p--;
      count[p] += x;
   }
   add(0, 0);

   for(int i=0; i<N; ++i)
      std::cout << count[i] << ' ';
   std::cout << std::endl;
   return 0;

}


Measured memory_bytes: 28928
#include<iostream>
#include<math.h>
#include<bits/stdc++.h>
#define ll long long int
#define hell 1000000007LL
using namespace std;
ll power(ll x, ll y){ 
    if(y==0)
     return 1;
    else
    {
        ll p=power(x,y/2);
        if(y%2==0)
         return (p*p)%hell;
        else
        return (x*((p*p)%hell))%hell;
    }}
ll gcd(ll x,ll y)
{
    if(y==0)
     return x;
    else
    return gcd(y,x%y);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
    ll a,b;
    cin>>a>>b;
    if(a%b!=0)
    cout<<a/b+1;
    else
    cout<<a/b;}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    if (a <= c && c <= b && b <= d)
    {
        cout << b - c << endl;
        return 0;
    }
    if (a <= c && c <= b && b > d)
    {
        cout << d - c << endl;
        return 0;
    }
    if (c <= a && a <= d && b < d)
    {
        cout << b - a << endl;
        return 0;
    }
    if (a >= c && a <= d && b >= d)
    {
        cout << d - a << endl;
        return 0;
    }
    cout << 0 << endl;

    return 0;
}


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

bool check(int N, int M, int K){
	if(N * M == K || K == 0){
		return true;
	}
	for(int i = 0; i <= N; i++){
		for(int  j = 0; j <= M; j++){
			if((i * M + j * N) - 2 * i * j == K){
				return true;
			}
		}
	}
	return false;
}

int main(){
	int N, M, K;
	cin >> N >> M >> K;
	cout << (check(N, M, K) ? "Yes" : "No") << endl;
	return 0;
}

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

const char* input_table[32][2]={
	{"A","00000"},
	{"B","00001"},
	{"C","00010"},
	{"D","00011"},
	{"E","00100"},
	{"F","00101"},
	{"G","00110"},
	{"H","00111"},
	{"I","01000"},
	{"J","01001"},
	{"K","01010"},
	{"L","01011"},
	{"M","01100"},
	{"N","01101"},
	{"O","01110"},
	{"P","01111"},
	{"Q","10000"},
	{"R","10001"},
	{"S","10010"},
	{"T","10011"},
	{"U","10100"},
	{"V","10101"},
	{"W","10110"},
	{"X","10111"},
	{"Y","11000"},
	{"Z","11001"},
	{" ","11010"},
	{".","11011"},
	{",","11100"},
	{"-","11101"},
	{"'","11110"},
	{"?","11111"}
};

const char* output_table[32][2]={
	{"101"     ," "},
	{"000000"  ,"'"},
	{"000011"  ,","},
	{"10010001","-"},
	{"010001"  ,"."},
	{"000001"  ,"?"},
	{"100101"  ,"A"},
	{"10011010","B"},
	{"0101"    ,"C"},
	{"0001"    ,"D"},
	{"110"     ,"E"},
	{"01001"   ,"F"},
	{"10011011","G"},
	{"010000"  ,"H"},
	{"0111"    ,"I"},
	{"10011000","J"},
	{"0110"    ,"K"},
	{"00100"   ,"L"},
	{"10011001","M"},
	{"10011110","N"},
	{"00101"   ,"O"},
	{"111"     ,"P"},
	{"10011111","Q"},
	{"1000"    ,"R"},
	{"00110"   ,"S"},
	{"00111"   ,"T"},
	{"10011100","U"},
	{"10011101","V"},
	{"000010"  ,"W"},
	{"10010010","X"},
	{"10010011","Y"},
	{"10010000","Z"}
};

void insert_to_buffer(char* buffer,char mozi) {
	int i;
	for(i=0;i<32;i++) {
		if(mozi==input_table[i][0][0]) {
			strcat(buffer,input_table[i][1]);
			break;
		}
	}
}

int output_buffer(char* buffer) {
	int i,j;
	int len1,len2;
	for(i=0;i<32;i++) {
		if(strncmp(buffer,output_table[i][0],strlen(output_table[i][0]))==0) {
			len1=strlen(output_table[i][0]);
			len2=strlen(buffer);
			putchar(output_table[i][1][0]);
			for(j=len1;j<len2;j++)buffer[j-len1]=buffer[j];
			buffer[len2-len1]=0;
			return 1;
		}
	}
	return 0;
}

int main(void) {
	int c;
	char buffer[100]={0};
	while((c=getchar())!=EOF) {
		if(c=='\n') {
			while(output_buffer(buffer));
			buffer[0]=0;
			putchar('\n');
		} else {
			insert_to_buffer(buffer,c);
			while(output_buffer(buffer));
		}
	}
	return 0;
}

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

signed main(){
    int a,b,c;
        cin >> a >> b >> c;
        int x= 0,ans = 0;
        while(!(a <= x)){
            x += b;
            ans+=c;
        }
        cout << ans << endl;
 
    return 0;
}


Measured memory_bytes: 3624
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

using ll = long long;
using namespace std;

constexpr ll INF = numeric_limits<ll>::max();

void solve() {
  ll N;
  cin >> N;
  ll lim = sqrt(N) + 1;

  ll ans = INF;
  for (int i = 1; i <= lim; i++) {
    if (N % i == 0) {
      ans = min(ans, i + (N / i) - 2);
    }
  }
  cout << ans << endl;
}

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


Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))
cnt = {}

ans = 0

for v in a:
    for offset in range(-1, 2):
        val = v + offset
        if (val in cnt):
            cnt[val] += 1
        else:
            cnt[val] = 1

        if cnt[val] > ans:
            ans = cnt[val]

print(ans)

Measured memory_bytes: 24120
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb(in,tmp) in.push_back(tmp)
#define all(in) in.begin(),n.end()
#define PI acos(-1)
using namespace std;
int main(){

  int n;
  cin>>n;
  rep(i,n){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(c>=5&&d>=2)cout<<(a*c+b*d)*0.8<<endl;
    else if(c<5&&d>=2&&(a*5+b*d)*0.8<a*c+b*d)cout<<(a*5+b*d)*0.8<<endl;
    else if(c>=5&&d<2&&(a*c+b*2)*0.8<a*c+b*d)cout<<(a*c+b*2)*0.8<<endl;
    else if(c<5&&d<2&&(a*5+b*2)*0.8<a*c+b*d)cout<<(a*5+b*2)*0.8<<endl;
    else cout<<a*c+b*d<<endl;
  }
}

Measured memory_bytes: 1240
// -----------------------------------
// Author     : MatsuTaku
// Country    : Japan
// Created    : 04/26/20 20:17:32
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int a,b,c,d; cin>>a>>b>>c>>d;
  auto x = (c-1)/b+1;
  auto y = (a-1)/d+1;
  cout << (x <= y  ? "Yes" : "No") << endl;

  return 0;
}


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

int main() {
  int N,s,f;
  cin >> N;
  s = N;
  while(s > 0){
    f += s % 10;
    s /= 10;
  }
  if(N % f == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>
#include <random>
using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef map<int, int> mii;
typedef pair<int, ii> edge;


#define sc(x)  scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mem(arr,val) memset(arr,val,sizeof arr)
#define sz(v) (int)v.size()
#define rsz(v) v.resize
#define clr(v) v.clear()
#define rev(v) reverse(all(v))
#define lop(i,end) for(int i=0; i<end; i++)
#define rlop(i,start) for(int i=start-1; i>=0; i--)
#define loop(i,start,end) for(int i=start; i<end; i++)
#define rloop(i,start,end) for(int i=start-1; i>=end; i--)
#define PB push_back
#define pb pop_back
#define mP make_pair
#define f first
#define s second

const ll OO = (ll)(4e18) + 9;
const int MOD = (int)(1e9) + 7;
const int oo = 2147483647;
const double EPS = 1e-8;
const double PI = acos(-1.0);

//enum dir { D, R, U, L , dr, ur, dl, ul };
int dx[] = { 1, 0, -1, 0, 1, -1, 1, -1 };
int dy[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

string abc = "abcdefghijklmnopqrstuvwxyz";
string vowels = "aeiouy"; //and sometimes "aeiouy"

template<typename X, typename Y> bool ckmin(X& a, Y b) { return a > b ? a = b, true : false; }
template<typename X, typename Y> bool ckmax(X& a, Y b) { return a < b ? a = b, true : false; }
bool cklex(string &a, string b) {
	if (b == "") return false;
	if (a == "") return a = b, true;
	if (sz(a) < sz(b)) return false;
	if (sz(b) < sz(a)) return a = b, true;
	if (a < b) return false;
	return a = b, true;
}

int dcmp(ld d1, ld d2) { return fabs(d1 - d2) <= EPS ? 0 : d1 > d2 ? 1 : -1; } //Compare Double Numbers
ll gcd(ll x, ll y) { return !y ? x : gcd(y, x%y); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
int conv_2_1(int r, int c, int nCol) { return (nCol*r) + c + 1; } //convert index from 2D array to 1D array. (Zero-indexed)
ii conv_1_2(int n, int nCol) { return{ n / nCol, n % nCol }; } //convert index from 1D array to 2D array (row, col). (Zero-indexed)
template<typename T> void inter(T X) { cout << X << endl; fflush(stdout); }



int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int t = 1;
	//cin >> t;
	while (t--) {
		string s;
		cin >> s;
		int sum = 0;
		for (auto c : s) sum = (sum + (c - '0')) % 9;
		if (not sum) cout << "Yes\n";
		else cout << "No\n";
	}


	return 0;
}


Measured memory_bytes: 3780
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll long long

ll n,k;
ll v[1111];


int main(){ 
  cin>>n>>k;
  rep(i,n)cin>>v[i];

  ll ans=0;


  for(ll ku=0;ku<=k;ku++){
    ll cnt=0;
    vector<ll>ju;
    ju.clear();

    for(ll lef=0;lef<=ku;lef++){
      ll tmp=0;
      vector<ll>tmp_ju;
      tmp_ju.clear();

      bool have[1111];
      rep(i,n)have[i]=0;

      for(int i=0;i<min(n,lef);i++){
        if(!have[i]){tmp+=v[i];tmp_ju.pb(v[i]);have[i]=1;}
      }

      for(int i=0;i<min(n,ku-lef);i++){
        if(!have[n-i-1]){tmp+=v[n-1-i];tmp_ju.pb(v[n-1-i]);have[n-1-i]=1;}
      }


      //cout<<ku<<" "<<lef<<" "<<tmp<<endl;
      //cout<<cnt<<endl;
      sort(tmp_ju.begin(),tmp_ju.end());
      int ss=tmp_ju.size();
      for(int i=0;i<k-ku;i++)if(i<ss&&tmp_ju[i]<0)tmp-=tmp_ju[i];
     //cout<<cnt<<endl;
      ans=max(ans,tmp);
    }


  }


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


Measured memory_bytes: 256
class Matrix:

  def __init__(self, mat, mod=10**9+7):
    assert(len(mat) and len(mat[0]))
    from copy import deepcopy
    self.MOD = mod
    self.mat = deepcopy(mat)

  def matunit(self, n):
    return Matrix([[(x==y) for x in range(n)] for y in range(n)], mod=self.MOD)

  def __add__(self, other):
    assert(len(self.mat)==len(other.mat) and len(self.mat[0])==len(other.mat[0]))
    h = len(self.mat)
    w = len(self.mat[0])
    ret = [[(self.mat[y][x]+other.mat[y][x])%self.MOD for x in range(w)] for y in range(h)]
    return ret

  def __mul__(self, other):
    assert(len(self.mat[0])==len(other.mat))
    h = len(self.mat)
    w = len(other.mat[0])
    ret = [[0 for _ in range(w)] for _ in range(h)]
    for y in range(h):
      for z in range(len(other.mat)):
        for x in range(w):
          ret[y][x] += self.mat[y][z]*other.mat[z][x]
    for y in range(h):
      for x in range(w):
        ret[y][x] %= self.MOD
    return Matrix(ret, mod=self.MOD)

  def __pow__(self, k):
    assert(len(self.mat)==len(self.mat[0]))
    from copy import deepcopy
    ret = self.matunit(len(self.mat))
    n = Matrix(deepcopy(self.mat), mod=self.MOD)
    while k:
      if k&1:
        ret = ret * n
      n = n * n
      k >>= 1
    return ret

  def __str__(self):
    return "[{}]".format("\n".join(str(row) for row in self.mat))

L, A, B, M = list(map(int, input().split()))

d = [0 for i in range(20)]
for i in range(1, 19):
  l = -1
  r = L
  while r-l>1:
    m = (l+r)//2
    if len(str(A+B*m))>i:
      r = m
    else:
      l = m
  d[i] = r

x = Matrix([[0, A, 1]], mod=M)
for i in range(1, 19):
  dt = d[i]-d[i-1]
  y = Matrix([[10**i, 0, 0], [1, 1, 0], [0, B, 1]], mod=M)
  y = y ** dt
  x *= y
print(x.mat[0][0])


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

using namespace std;

int main() {
	int n; cin >> n;
	long double x, ans = 0;
	string u;
	while (n--) {
		cin >> x >> u;
		if (u == "JPY") ans += x;
		else ans += x * 380000.0;
	}
	printf("%.6Lf\n",ans);
}

Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

const real eps = 1e-10;

void main(){
    auto n = readInt();
    long[] d, v, s;
    foreach(i; iota(n)) {
        int si, di, vi;
        readlnTo(si, di, vi);
        s ~= si;
        d ~= di;
        v ~= vi;
    }
    auto dpt = new double[][](1<<n, n);
    auto dpb = new int[][](1<<n, n);
    const double inf = 1e9;
    foreach(i; iota(n)) {
        dpt[0][i] = 0;
    }
    foreach(i; iota(1, 1<<n)) {
        foreach(j; iota(n)) {
            dpt[i][j] = inf;
        }
    }

    long weight(int b) {
        long ans;
        foreach(i; iota(n)) {
            if(b & (1<<i)) {
                ans += v[i] * 20;
            }
        }
        return ans;
    }
    double time(int i, int j, int b) {
        auto dist = abs(d[i] - d[j]);
        return dist * (70. + weight(b)) / 2000;
    }

    foreach(i; iota(1, 1<<n)) {
        foreach(j; iota(n)) {
            if(!(i & (1 << j))) {
                continue;
            }
            auto bb = i&~(1<<j);
            foreach(k; iota(n)) {
                double t = dpt[bb][k] + time(k, j, bb);
                if(dpt[i][j] > t) {
                    dpt[i][j] = t;
                    dpb[i][j] = k;
                }
            }
        }
    }
    int minIdx;
    foreach(i; iota(n)) {
        if(dpt[(1<<n)-1][i] < dpt[(1<<n)-1][minIdx]) {
            minIdx = i;
        }
    }
    int[] ans;
    int b = (1<<n)-1;
    while(b != 0) {
        ans ~= minIdx;
        auto nextIdx = dpb[b][minIdx];
        auto nextB = b & ~(1<<minIdx);
        minIdx = nextIdx;
        b = nextB;
    }
    ans.retro.map!(a => s[a]).map!(to!string).join(" ").writeln();
}

Measured memory_bytes: 9684
#include<bits/stdc++.h>
#include<iomanip>
#define mins(a,b) a=min(a,b)
#define maxs(a,b) a=max(a,b)
template < typename T > std::string to_string( const T& n )
  {
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
  }
using namespace std;

const long long INF=9000000000000000;
int main(){
int n,m,ans=0;
cin>>n>>m;
if(n>=13)
cout<<m<<endl;
else if(5<n and n<13)
cout<<m/2<<endl;
else
cout<<0<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

struct S{
    int to, val, cost;
    bool operator>(const S &s) const{
        return cost > s.cost;
    }
};

int n, m, s, t;
vector<int> G[100010];
int d[100010][3];

void calc(int s){
    rep(i, 0, n) rep(j, 0, 3) d[i][j] = INF;
    d[s][0] = 0;
    priority_queue<S, vector<S>, greater<S> > q;
    q.push({s, 0, 0});
    while(!q.empty()){
        S s = q.top(); q.pop();
        int from = s.to;
        int val = s.val;
        int cost = s.cost;
        if(d[from][val] < cost) continue;
        rep(i, 0, G[from].size()){
            int next = G[from][i];
            int nextv = (val + 1) % 3;
            int newCost = cost + 1;
            if(d[next][nextv] > newCost){
                d[next][nextv] = newCost;
                q.push({next, nextv, newCost});
            }
        }
    }
}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> n >> m;
    rep(i, 0, m){
        int u, v;
        cin >> u >> v;
        u--; v--;
        G[u].push_back(v);
    }
    cin >> s >> t;
    s--; t--;
    calc(s);
    // rep(i, 0, n){
    //     rep(j, 0, 3){
    //         cout << i << ' ' << j << ' ' << d[i][j] << endl;
    //     }
    // }
    if(d[t][0] == INF) cout << -1 << endl;
    else cout << d[t][0] / 3 << endl;
}

Measured memory_bytes: 8384
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;

int main()
{
  int n;
  cin>>n;
  vecint a(n), b(n), c(n-1);
  for(int i:boost::irange(0, n)) {
    cin>>a[i];
  }
  for(int i:boost::irange(0, n)) {
    cin>>b[i];
  }
  for(int i:boost::irange(0, n-1)) {
    cin>>c[i];
  }
  int sum=0;
  for(int i:boost::irange(0, n)) {
    if (i<n-1) {
      if (a[i]+1 == a[i+1]) sum += c[a[i]-1];
    }
    sum += b[a[i]-1];
  }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;

int main(){
    int n,a[105];cin>>n;
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=n-1;i>=0;i--){
        if(i==0) cout<<a[i]<<endl;
        else cout<<a[i]<<" ";
    }
}


Measured memory_bytes: 3080
from sys import stdin

def main():
    N = int(input())
    H = map(int, input().split())

    h = list(H)
    for i in range(N - 2, -1, -1):
        if h[i] > h[i+1]:
            h[i] -= 1
    for i in range(N - 1):
        if h[i] > h[i+1]:
            print('No')
            break
    else:
        print('Yes')

input = lambda: stdin.readline()
main()


Measured memory_bytes: 14252
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

h,w = inpl()
c = [input() for i in range(h)]
for i in c:
    print(i)
    print(i)


Measured memory_bytes: 38384
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define inf 1000000000
using namespace std;

int main(){
    int N,K,i,a,ans=inf;
    cin >> N >> K;

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

    sort(h,h+N);

    for(i=0 ; i<N-(K-1) ; i++){
        a = 0;
        a = h[i+K-1]-h[i];
        ans = min(ans , a);
    }

    cout << ans << endl;

}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>  
#include <stdbool.h>   
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define PI 3.14159265358979323846;
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
/*
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r)
*/
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r)
#define TYPE long long
#define ll long long
#define MEMSET(a) memset(a,0,sizeof(a))
#define MEMSET_U(a) memset(a,-1,sizeof(a))
#define bool    _Bool
const int mod = (int)1e09 + 7;

//#define DEBUG1
//#define DEBUG2
//#define DEBUGF
#define DUMMY

int in(void) { int i; scanf("%d", &i); return i; }
long long llin(void) { long long i; scanf("%lld", &i); return i; }
double din(void) { double i; scanf("%lf", &i); return i; }
void chin(char s[]) { scanf("%s", s); }

void print(int a) { printf("%d\n", a); }
void llprint(long long a) { printf("%lld\n", a); }
void dprint(double a) { printf("%.10f\n", a); }
void print2(int a, int b) { printf("%d %d\n", a, b); }
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; }
long long llmax(long long a, long long b) { return a > b ? a : b; }
long long llmin(long long a, long long b) { return a < b ? a : b; }
double dmax(double a, double b) { return a > b ? a : b; }
double dmin(double a, double b) { return a < b ? a : b; }
//long long llmax(long long a, long long b) { return a > b ? a : b; }
//long long llmin(long long a, long long b) { return a < b ? a : b; }
//double dmax(double a, double b) { return a > b ? a : b; }
int cmp(const void *a, const void *b) { return *(TYPE *)a - *(TYPE *)b; }
int cmp_r(const void *a, const void *b) { return *(TYPE *)b - *(TYPE *)a; }
int char_cmp(const void *a, const void *b) { return strcmp((char *)a, (char *)b); }
int char_cmp_r(const void *a, const void *b) { return strcmp((char *)b, (char *)a); }
void swap(int *a, int *b) { int t = *a; *a = *b; *b = t; }



int main() {
	char S[200001];
	scanf("%s", S);
	int l, r, ans;

	for (int i = 0; i < strlen(S); i++) {
		if (S[i] == 'A') {
			l = i;
			break;
		}
	}
	for (int j = strlen(S)-1; j >= 0; j--) {
		if (S[j] == 'Z') {
			r = j;
			break;
		}
	}
	ans = r - l + 1;
	printf("%d\n", ans);

#ifdef DEBUGF
	getch();
#endif
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
typedef long long ll;

const int MAX_N=2e5,MAX_M=2e5;

int N,M,A[MAX_N];

int n[MAX_N],ovr[MAX_N];

int main(){
	cin>>N>>M;
	REP(i,N){
		cin>>A[i];
		n[A[i]-1]++;
	}
	REP(i,N){
		REP(j,n[i]){
			if (i-j>=0){
				ovr[i-j]++;
			}
		}
	}
	int ans=0;
	REP(i,N){
		if (ovr[i]==0){
			ans++;
		}
	}
	REP(i,M){
		int x,y;
		cin>>x>>y;
		x--;
		int w=A[x];
		if (w-n[w-1]>=0 && --ovr[w-n[w-1]]==0){
			ans++;
		}
		n[w-1]--;
		n[y-1]++;
		if (y-n[y-1]>=0 && ovr[y-n[y-1]]++==0){
			ans--;
		}
		A[x]=y;
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval>newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!

// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  int N,K; cin >> N >> K;
  cout << max(N-K+1,0) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <utility>

using namespace std;
using Point = pair<int,int>;

int map[52][52];

void BFS(const Point &p0);

int main(){
  int w,h;
  while(cin>>w>>h&&w>0&&h>0){

    for(int i=1;i<h+1;++i){
      for(int j=1;j<w+1;++j){
        cin >> map[i][j];
      }
    }

    int num = 0;
    for(int i=1;i<h+1;++i){
      for(int j=1;j<w+1;++j){
        if(map[i][j]){
          BFS(Point(i,j));
          num++;
        }
      }
    }
    cout << num << endl;
  }

  return 0;
}

void BFS(const Point &p0){
  queue<Point> q;
  q.push(p0);
  map[p0.first][p0.second] = 0;
  while(!q.empty()){
    auto p = q.front();q.pop();
    int y = p.first , x = p.second;

    for(int i=-1;i<=1;++i){
      for(int j=-1;j<=1;++j){
        if(i==0&&j==0)continue;
        if(map[i+y][j+x]){
          q.push(Point(i+y,j+x));
          map[i+y][j+x] = 0;
        }
      }
    }
  }
}

Measured memory_bytes: 2996
n = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(n):
    if (i - 1) >= 0 and (i + 1) < n:
        if ((p[i - 1]) < p[i] < (p[i + 1])) or ((p[i + 1]) < p[i] < (p[i - 1])):
            count = count + 1
print(count)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#define print(n) std::cout << n << std::endl
using namespace std;


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

   vector<int> a(n);
   vector<int> b(n);
   vector<int> c(n - 1);

   for (int i = 0; i < n; ++i) {
       cin >> a[i];
       --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; ++i) {
        sum += b[a[i]];
        if(i > 0 && (a[i] - (a[i - 1] + 1) == 0)){
            sum += c[a[i - 1]];
        }
    }

    print(sum);

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    
        string s;
    cin>>s;
    if(s[0]=='R'&&s[1]=='R'&&s[2]=='R') cout<<3;

    else if(s[0]=='R'&&s[2]=='R')cout<<1<<endl;
    else if(s[0]=='R'&&s[1]=='R')cout<<2<<endl;
    else if(s[1]=='R'&&s[2]=='R')cout<<2<<endl;
else if(s[0]!='R'&&s[1]!='R'&&s[2]=='R') cout<<1;
else if(s[0]=='R'&&s[1]!='R'&&s[2]!='R') cout<<1;
else if(s[0]!='R'&&s[1]=='R'&&s[2]!='R') cout<<1;
    else if(s[0]!='R'&&s[2]!='R') cout<<0;
    else if(s[0]!='R'&&s[1]!='R') cout<<0;
    else if(s[0]!='R'&&s[1]!='R'&&s[2]!='R') cout<<0;




    return 0;
}


Measured memory_bytes: 3564
#include<iostream>
using namespace std;
int main()
{
  int x; cin>>x;
  int ans = 0;
  for(int i=1; i<=x; i++)
  {
    int temp = i, d = 0;
    while(temp>0)
    {
      d++;
      temp /= 10;
    }
    ans += (d & 1);
  }
  cout<<ans<<"\n";
}


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


int main(void)
{
	int syu, ryou;
	int test[10000];
	cin >> syu >> ryou;

	for (int i = 0; i < syu ; i++) {
		cin >> test[i];
	}
	
	int ans = 0;

	for (int i = 0; i < syu; i++) {
		ans += test[i];
	}
	ryou -= ans;

	int min=1000000;
	for (int i = 0; i < syu; i++) {
		if (min > test[i]) {
			min = test[i];
		}
	}
	int num = 0;
	num += syu;
	num += ryou / min;

	cout << num << endl;
	
}


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

#define endl '\n'

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    long long sum = 0;
    cin >> n;
    for(int i = 1; i <= n; i++) {
        if(i % 3 != 0 && i % 5 != 0)
            sum += i;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <math.h>
using namespace std;
int B,C; int N; int A[10];
bool dfs(int i){
  if(i==10) return true;
  if(A[i]>max(B,C)){
    if(B>C){B=A[i];}else{C=A[i];} dfs(i+1);
  }else if(A[i]<max(B,C)&&A[i]>min(B,C)){
    if(B>C){C=A[i];}else{B=A[i];} dfs(i+1);
  }else{
    return false;
  }
 }
void solve(){
  B=0; C=0;
  for(int i=0; i<10; i++){
      cin>>A[i];
    }
  if(dfs(0)){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
    }
  }
int main() {
  cin>>N;
  for(int i=0; i<N; i++){
  solve();
  }
}

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

int n;

vector<vector<int>> to;
vector<vector<int>> w;
vector<int> ans;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> n;
    
    to.resize(n);
    w.resize(n);
    ans.resize(n,-1);
    
    for(int i = 0; i < n - 1; i++){
        int u,v,e;
        
        cin >> u >> v >> e;
        
        u--;
        v--;
        
        if(e % 2 == 0) e = 0;
        else e = 1;
        
        to[u].push_back(v);
        to[v].push_back(u);
        
        w[u].push_back(e);
        w[v].push_back(e);
    }
    
    queue<int> q;
    ans[0] = 0;
    q.push(0);
    
    while(!q.empty()){
        int v = q.front();
        q.pop();
        for(int i = 0; i < (int)to[v].size(); i++){
            int u = to[v][i];
            int x = w[v][i];
            if(ans[u] != -1) continue;
            ans[u] = (ans[v] + x) % 2;
            q.push(u);
        }
    }
    
    for(int i = 0; i < n; i++) cout << ans[i] << endl;
    
}



Measured memory_bytes: 11904
A, B, C=map(int,input().split())
count=0
while A!=B or B!=C or C!=A:
  if A+2<=B or A+2<=C:
    A+=2
    count+=1
  elif B+2<=C or B+2<=A:
    B+=2
    count+=1
  elif C+2<=A or C+2<=B:
    C+=2
    count+=1
  elif A<=B<=C or B<=A<=C:
    A+=1
    B+=1
    count+=1
  elif B<=C<=A or C<=B<=A:
    B+=1
    C+=1
    count+=1
  elif C<=A<=B or A<=C<=B:
    C+=1
    A+=1
    count+=1
print(count)
  
  


Measured memory_bytes: 3064
//https://atcoder.jp/contests/dp/tasks/dp_b
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}}star;
#define DEBUG if(0)
#endif
#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}
class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};

int N,K=2;
LL h[112345];
LL dp[112345];
int main(){
    cin>>N>>K;
    for(int i:range(N))cin>>h[i];
    dp[0]=0;
    for(int i:range(1,N)){
        dp[i]=1e18;
        for(int k:range(1,K+1))if(i-k>=0)chmin(dp[i],dp[i-k]+abs(h[i]-h[i-k]));
    }
    cout<<dp[N-1]<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <cassert>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'
#define FIR first
#define SEC second
#define PB push_back
#define SZ(x) ((int)x.size())

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

const int MOD = 998244353;
int dp[3005], dp2[3005];

void solveSingleCase(int caseNo)
{
    int N, S;
    cin >> N >> S;
    VEC(int) A(N);
    READVEC(A);

    memset(dp, 0, sizeof dp);
    dp[0] = 1;
    for (int a : A) {

        FOR(s, 0, S + 1) {
            dp2[s] = dp[s] * 2 % MOD;
            if (s >= a)
                dp2[s] += dp[s - a];
            dp2[s] %= MOD;
        }

        FOR(s, 0, S + 1)
            dp[s] = dp2[s];
    }

    cout << dp[S] << endl;
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int T = 1;
    // cin >> T;
    FOR(tcase, 1, T + 1) {
        solveSingleCase(tcase);
    }
    return 0;
};


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


void solve(long long N, std::vector<long long> A){
    vector<ll> ans(N);
    rep(i, N){
        ans[A[i]] = i + 1;
    }
    for(auto x: ans){
        cout << x << " ";
    }
    cout << endl;
}

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
        A[i]--;
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 2432
#include<iostream>
using namespace std;
int main(){
  int k,a,b,cnt=0;
  cin >> k;
  cin >> a >> b;
  for(int i=a; i<=b; i++){
    if(i%k==0){
      cout << "OK" << endl;
      cnt++;
      break;
    }
  }
  if(cnt==0){
    cout << "NG" << endl;
  }

}


Measured memory_bytes: 3596
<?php


fscanf(STDIN, "%d%d", $n, $m);

$array_map = array_fill(1, $m,[]);
for($i=0; $i<$n;$i++){
    fscanf(STDIN, "%d%d", $a, $b);
    $array_map[$a][] = $b;
}
$avail = [];
$list = [];
$ans = 0;
$max = 0;
for($i=1;$i<=$m;$i++){
    foreach($array_map[$i] as $value){
        if(isset($avail[$value])) {
            $avail[$value]++;
        }else{
            $avail[$value] = 1;
        }
        $max = max($max, $value);
    }
    if($max != 0) {
        $ans += $max;
        if($avail[$max] == 1){
            unset($avail[$max]);
            $max = max(array_keys($avail));
        }else{
            $avail[$max]--;
        }

    }
}
echo $ans;

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

using namespace std;

int main(int argc, char const *argv[]) {
  string S;
  cin >> S;
  int start = 0;
  int length = S.length();
  bool Dflag = false;
  bool Eflag = false;

  while (start != length) {
    string tmpL = S.substr(start, 5);
    string tmpS = S.substr(start, 2);
    if (tmpL == "dream") {
      start += 5;
      Dflag = true;
      Eflag = false;
    } else if (tmpL == "erase") {
      start += 5;
      Dflag = false;
      Eflag = true;
    } else if (Dflag && tmpS == "er") {
      start += 2;
      Dflag = false;
    } else if (Eflag && S[start] == 'r') {
      start += 1;
      Eflag = false;
    } else {
      break;
    }
  }
  if (start != length) {
    cout << "NO\n";
  } else {
    cout << "YES\n";
  }
  return 0;
}


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

Measured memory_bytes: 384
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,mod=1000000007;
const long long llinf=9223372036854775807ll;
int n,k;
int main(){
	cin>>n>>k;
	cout<<(((n+1)/2>=k)?"YES":"NO");
	return 0;
}

Measured memory_bytes: 256