akhauriyash/Code-Regression huggingface dataset:
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
typedef long long ll;

ll sumn(ll x, int n){
  	if (n == 1){return x;}
  	ll ans = x;
 	rep(i,n-1){
      	int powten = pow(10,i+1);
  		ans += (x/powten) * pow(2,i) + sumn(x%powten,i+1);
  	}
	return ans;
}

/*
int sum4(int x){
	return x + (x/1000)*4 + sum3(x%1000);
}
int sum3(int x){
	int ans = 0;
	ans += (x/100)*2 + sum2(x%100);
    ans += (x/10)*1 + (x/10)%10;
    ans += x;
    return ans;
    // ans = (x/100)*2 + sum2(x%100) + sum2(x);
}
int sum2(int x){
	return x + (x/10) + (x%10);
}
*/

void Main()
{
	string S;
  	cin >> S;
  	int sz = S.size();
	ll x = stoll(S);
    cout << sumn(x, sz) << endl;
  	return;
}

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


Measured memory_bytes: 256
H, W, K = map(int, input().split(' '))

c = []
n_black = 0
for i in range(H):
  c.append(input().strip())
  n_black += c[-1].count("#")


def rec_col(count, n):
  if n == len(c):
    yield count
  else:
    yield from rec_col(list(count), n+1)
    for i, color in enumerate(c[n]):
      if color == "#":
        count[i] += 1
    yield from rec_col(list(count), n+1)

def rec_row(result, count, n):
  if n == len(count):
    yield result
  else:
    yield from rec_row(result + count[n], count, n+1)
    yield from rec_row(result, count, n+1)

import collections
ans = collections.Counter()
for count in rec_col([0] * W, 0):
  ans.update(rec_row(0, count, 0))
print(ans[K])


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

int main(){
	
	ll n; cin >> n;
	ll cnt{}, f{10};
	while(1){
		cnt += n/f;
		if(n/f==0) break;
		f *= 5;
	}
	cout << (n%2?0:cnt) << endl;
	
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define MN 100000
#define MM 200000
int n,a[MN+5],top,lst,cnt;
int hd[MN+5],to[MM+5],nxt[MM+5];
char s[MN+5];
void gg(){puts("-1");exit(0);}
void add(int u,int v){
	static int rn=0;
	to[rn]=v,nxt[rn]=hd[u];
	hd[u]=rn++;
}
int getpt(){return ++cnt;}
int main(){
	memset(hd,0xff,sizeof(hd));
	scanf("%s",&s[1]); n=strlen(&s[1]);
	if(s[1]=='0') gg();
	for(int i=1;i<=n;i++)
		if(s[i]=='1'&&s[n-i]!='1') gg();
	add(1,2); top=2,lst=2,cnt=2;
	for(int i=2;(i<<1)<=n;i++){
		if(s[i]=='1'){
			while(lst!=i) add(getpt(),top),lst++;
			int tmp=getpt();
			add(top,tmp),top=tmp,lst++;
		}
	}
	while(cnt<n) add(++cnt,top);
	for(int i=1;i<=n;i++){
		for(int j=hd[i];~j;j=nxt[j]){
			printf("%d %d\n",i,to[j]);
		}
	}
}

Measured memory_bytes: 2560
n = int(input())
s = input()
cnt = 0

for N in range(1000):
    tgt = str(N).zfill(3)
    if tgt[0] in s:
        i = s.index(tgt[0])
        if tgt[1] in s[i+1:]:
            j = s[i+1:].index(tgt[1]) + i
            if tgt[2] in s[j+2:]:
                cnt += 1
print(cnt)


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

#define MAX 100

int cnt;

void SelectionSort(int A[], int N) {
  for ( int i = 0; i < N; i++ ) {
    int min = i;
    for ( int j = i; j < N; j++) {
      if (A[j] < A[min]) {
        min = j;
      }
    }
    if (A[i] != A[min]) {
      swap(A[i], A[min]);
      cnt++;
    }
  }
}

int main() {
  int N;
  int A[MAX];

  cin >> N;

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

  SelectionSort(A, N);

  for ( int i = 0; i < N - 1; i++) {
    cout << A[i] << " " << flush;
  }
  cout << A[N - 1] << endl;
  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 3096
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
int sub(int a, int b) { return (a -= b) < 0 ? a + mod : a; }
int ctz(int x) { return __builtin_ctz(x); }
int clz(int x) { return __builtin_clz(x); }

int main(){
  ios_base::sync_with_stdio(false); cin.tie(0);
  #ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif

	int k, x;
  cin >> k >> x;
  cout << (k * 500 >= x ? "Yes" : "No");
}

Measured memory_bytes: 256
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

n=int(input())
li=factorization(n)
ans=0
for i in range(len(li)):
    k=1
    while True:
        if li[i][1]-k>=0:
            li[i][1]-=k
            ans+=1
        else:
            break
        k+=1
if n<=1:
    print(0)
else:
    print(ans)

Measured memory_bytes: 63376
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S, T;
  cin >> S >> T;
  int count = 0;
  for(int i = 0; i < S.size(); i++){
    if(S[i] != T[i]){
      count++;
    }else{
      continue;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3852
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;

int main(void)
{
    IOS
    int n; cin >> n;
    if (n==1) cout << "Hello World" << endl;
    else {
        int a, b;
        cin >> a >> b;
        cout << a + b << endl;
    }

    return 0;
}

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

int main(void)
{
    string S;
    cin >> S;

    int N = S.size();
    // printf("N = %d\n", N);
    bool strong = true;
    // Sは回文である。
    for (int i = 0, j = N - 1; i < N; i++, j--)
    {
        if (S[i] != S[j])
        {
            strong = false;
        }
    }

    // Sの1文字目から(N−1)/2文字目まで(両端含む)からなる文字列は回文である。
    int end = (N - 1) / 2;
    // printf("end = %d\n", end);
    for (int i = 0, j = end - 1; i < end; i++, j--)
    {
        // printf("%c %c\n", S[i], S[j]);
        if (S[i] != S[j])
        {
            strong = false;
        }
    }

    // Sの(N+3)/2文字目からN文字目まで(両端含む)からなる文字列は回文である。
    int start = (N + 3) / 2;
    // printf("N = %d\n", N);
    // printf("start = %d\n", start);
    for (int i = start - 1, j = N - 1; i < N; i++, j--)
    {
        // printf("%c %c\n", S[i], S[j]);
        if (S[i] != S[j])
        {
            strong = false;
        }
    }

    if (strong == true)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return (0);
}

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

const int N = 2000 * 2000 + 1;
using value_type = long long;

std::bitset<N> bit;
value_type sum = 0;
int n;

inline int read()
{
	int s = 0,f = 1; char ch;
	while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
	while(isdigit(ch)) s = s * 10 + ch - '0',ch = getchar();
	return s * f;
}

int main()
{
	bit[0] = 1;
	n = read();
	for(int i = 1,x;i <= n;i++)
		x = read(),bit |= (bit << x),sum += x;
	for(auto i = (sum + 1) >> 1;i <= sum;i++)
		if(bit[i]) {
			printf("%lld",i);
			return 0;
		}

	exit(0);
}


Measured memory_bytes: 1664
#include<type_traits>
#include<vector>
#include<array>
#include<iterator>
#include<numeric>
#include<algorithm>

template<typename RandomAccessIterator>
void radix_sort(RandomAccessIterator begin, RandomAccessIterator end){
    if constexpr (std::is_integral_v<typename RandomAccessIterator::value_type>){

        using integer_type = typename RandomAccessIterator::value_type;
        unsigned long now_shift = 0, byte_size = sizeof(integer_type);

        std::vector<integer_type> tmp(end - begin);

        for(unsigned long i{0}; i < byte_size; ++i){
            std::array<unsigned long, 256> count{{}};

            for(auto it = begin; it != end; ++it)++count[(*it >> now_shift) & 255];

            std::partial_sum(std::begin(count), std::end(count), std::begin(count));

            for(auto it = end; it-- != begin; )tmp[--count[(*it >> now_shift) & 255]] = *it;

            std::copy(std::begin(tmp), std::end(tmp), begin);

            now_shift += 8;
        }

        if constexpr (std::is_signed_v<integer_type>)std::rotate(begin, std::partition_point(begin, end, [](auto i){return i >= 0;}), end);

    } else if constexpr (std::is_integral_v<typename RandomAccessIterator::value_type::first_type>){

        using pair_type = typename RandomAccessIterator::value_type;
        using key_type = typename pair_type::second_type;

        unsigned long now_shift = 0, byte_size = sizeof(key_type);

        std::vector<pair_type> tmp(end - begin);

        for(unsigned long i{0}; i < byte_size; ++i){
            std::array<unsigned long, 256> count{{}};

            for(auto it = begin; it != end; ++it)++count[(it -> first >> now_shift) & 255];

            std::partial_sum(std::begin(count), std::end(count), std::begin(count));

            for(auto it = end; it-- != begin; )tmp[--count[(it -> first >> now_shift) & 255]] = *it;

            std::copy(std::begin(tmp), std::end(tmp), begin);

            now_shift += 8;
        }

        if constexpr (std::is_signed_v<key_type>)std::rotate(begin, std::partition_point(begin, end, [](auto i){return i.first >= 0;}), end);

    } else puts("guee radix sort muzukashi.");
}

#include<random>
#include<iostream>
#include<utility>
#include<string>

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<unsigned long> A(N);
    for(auto&& i : A)cin >> i;
    sort(begin(A), end(A));
    if(A.front() == 0)return 0 & puts("0");
    unsigned long tmp{1};
    for(const auto& i : A){
        if(1000000000000000000 / i < tmp)return 0 & puts("-1");
        tmp *= i;
    }
    cout << tmp << endl;
}

Measured memory_bytes: 3948
#include <iostream>

int main() {
    int32_t x, y, w, h, r;
    std::cin >> w >> h >> x >> y >> r;

    if (0 <= x - r && x + r <= w && 0 <= y - r && y + r <= h) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }
}


Measured memory_bytes: 3116
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long A = sc.nextLong();
    long B = sc.nextLong();
    Main abc122D = new Main();
    System.out.println(abc122D.solve(A, B));
  }

  public long solve(long A, long B){
    if(A == B){
      return A;
    } else {
      return f(A-1) ^ f(B);
    }
  }

  private long f(long x) {
    if(x % 2 == 0){
      return x^(x/2%2);
    } else {
      return f(x+1) ^ (x+1);
    }
  }
}


Measured memory_bytes: 23764
#include<stdio.h>
int a[1000001],n;
int bs(int k){
    int l=0,r=n,mid;
    while(l<r){
        mid=(l+r)/2;
        if(k==a[mid]) return 1;
        if(k>a[mid]) l=mid+1;
        if(k<a[mid]) r=mid;
    }
    return 0;
}
int main(){
    int i,q,x,sum=0;
    scanf("%d",&n);
    for(i=0;i<n;++i) scanf("%d",&a[i]);
    scanf("%d",&q);
    for(i=0;i<q;++i){
        scanf("%d",&x);
        if(bs(x)) sum++;
    }
    printf("%d\n",sum);
    return 0;
}


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

int main()
{
	int n;
	while (cin >> n, n)
	{
		map<char, char> table;
		for (int i = 0; i < n; i++)
		{
			char a, b;
			cin >> a >> b;
			table[a] = b;
		}
		cin >> n;
		for (int i = 0; i < n; i++)
		{
			char c;
			cin >> c;
			if (table.count(c)) cout << table[c];
			else cout << c;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3052
#include<iostream>
//#include<algorithm>
#include<math.h>

using namespace std;
int max(int a, int b, int c)
{
	int d;
	d = (a < b) ? b : a;
	d = (d < c) ? c : d;
	return d;
}
int a, b;
char can[60][60];
int dk[4][2] = { {0,1},{0,-1},{1,0},{-1,0} };
bool check(int x, int y)
{
	for (int i = 0; i < 4; i++)
	{
		if (can[x + dk[i][0]][y + dk[i][1]] == '#')
		{
			return true;
		}
	}
	return false;
}
int main()
{
	while (cin >> a >> b)
	{
		for (int i = 0; i < a; i++)
		{
			for (int j = 0; j < b; j++)
			{
				cin >> can[i][j];
			}
		}
		bool ok = false;
		for (int i = 1; i < a - 1; i++)
		{
			for (int j = 1; j < b - 1; j++)
			{
				if (can[i][j] == '#') 
				{
					if (!check(i, j))
					{
						ok = true;
						i = a;
						break;
					}
				}
			}
		}
		if (ok)
		{
			cout << "No" << endl;
		}
		else
		{
			cout << "Yes" << endl;
		}

	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>

#define pb push_back
#define mp make_pair

using namespace std;

template<typename T>inline void upmin(T &x,T y) { y<x?x=y:0; }
template<typename T>inline void upmax(T &x,T y) { x<y?x=y:0; }

typedef unsigned int u32;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod pi=acos(-1);
const int oo=1<<30;
const LL OO=1e18;

const int N=1<<18;

int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}

int a[N],R[N],up[N],low[N];
vector<PR> e[N];
int ans[N];
int main()
{
	int n=gi(),i,t;
	for (i=0;i<1<<n;i++) a[i]=gi()-1,R[i]=R[i>>1]>>1|(i&1)<<(n-1);
	for (i=(1<<n)-1;~i;i--) {
		up[i]=~a[i]?a[i]:(1<<n)-1;
		for (t=0;t<n;t++)
			if (!(i>>t&1))
				upmin(up[i],up[i|1<<t]);
	}
	for (i=0;i<1<<n;i++) {
		low[i]=~a[i]?a[i]:0;
		for (t=0;t<n;t++)
			if (i>>t&1)
				upmax(low[i],low[i^(1<<t)]);
	}
	for (i=0;i<1<<n;i++)
		if (low[i]>up[i])
			return puts("NO"),0;
		else
			e[up[i]].pb(mp(low[i],i));
	priority_queue<PR>q;
	for (i=(1<<n)-1;~i;i--) {
		for (auto t:e[i]) q.push(t);
		if (q.empty()||q.top().first>i) return puts("NO"),0;
		ans[R[q.top().second]]=i;q.pop();
	}
	puts("YES");
	for (i=0;i<1<<n;i++)
		printf("%d ",ans[i]+1);
	return 0;
}


Measured memory_bytes: 21248
//a[i]は、min(b[i],b[i-1])
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define all(x) (x).begin(),(x).end()
using ll = long long;
using namespace std;

int main() {
  int n;
  cin>>n;
  vector<int> b(n);
  rep(i,n-1) cin>>b[i];
  vector<int> a(n);
  a[0]=b[0];
  a[n-1]=b[n-2];
  int ans=a[0]+a[n-1];
  for(int i = 1 ; i < (n)-1 ; i ++ ){
    a[i]=min(b[i-1],b[i]);
    ans+=a[i];
    //cout<<a[i]<<endl;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<string>
#include<utility>
#include<iostream>
#include<queue>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<bitset>

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int main(){
    char s[4]={};
    scanf("%s",s);
    int a[26]={};
    REP(i,4)a[s[i]-'A']++;
    int j=0;
    REP(i,26){
        if(a[i]==0)continue;
        else if(a[i]==2)j++;
        else{
            printf("No\n");
            return 0;
        }
    }
    if(j==2)printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
int main(){
  ll n;cin>>n;
  ll sa=0,sb=0;
  ll a[n],b[n];
  vector<ll> v;
  for(int i=0;i<n;i++){
    cin>>a[i]>>b[i];
    sa+=a[i];
    sb+=b[i];
    v.push_back(a[i]);
    v.push_back(b[i]);
  }
  sort(v.begin(),v.end());
  ll ss=0;
  for(int i=0;i<n;i++)ss+=v[i];
  ll ans=min(sa,sb);
  for(int i=0;i<n;i++){
    ll sum=a[i]+b[i];
    if(a[i]>b[i])swap(a[i],b[i]);
    ll h=v[n-1];
    ll k=ss;
    if(h>=b[i]){
      k-=a[i]+b[i];
    }
    else if(h>=a[i]){
      if(a[i]>=v[n-3])k-=v[n-1]+v[n-2];
      else k-=v[n-1]+a[i];
    }
    else{
      k-=v[n-1]+v[n-2];
    }
    ans=min(ans,sum+k);
  }
  cout<<ans<<endl;
}


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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

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

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}



int main(){
    int x;
    cin >> x;
    int a = x/100;
    int b = x%100;
    if(a*5<b){
        cout << '0' << endl;
    }else{
        cout << '1' << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int K; cin >> K;
  int ans = 0, coe = 0;
  for(int a = 1; a <= K; a++){
    for(int b = a; b <= K; b++){
      for(int c = b; c <= K; c++){
        for(int gcd = a; gcd >= 1 ; gcd--){
          if(a % gcd == 0 && b % gcd == 0 && c % gcd == 0){
            coe = 6;
            if(a == b || b == c || c == a){
              coe = 3;
              if(a == b && b == c && c == a) coe = 1;
            }
            ans += coe * gcd;
            break;
          }
        }
      }
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
int main() {
	int A=0, B=0, C=0, D=0, E=0, F=0,p,x,y;
	scanf("%d %d %d %d %d %d", &A, &B, &C, &D, &E, &F);
	p = 1000000;
	if (A < p)p = A;
	if (B < p)p = B;
	if (C < p)p = C;
	if (D < p)p = D;
	x = A + B + C + D;
	if (E < F)  y = F;
	else y = E;
	printf("%d\n", x-p + y);
	return 0;
}

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

using namespace std;

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

  int n, d, x;
  cin >> n >> d >> x;

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

  int ans = x;
  for (int i = 0; i < n; ++i) {
    int cnt = 1;
    for (int j = 1; j <= d; ++j) {
      if (d < a[i] * j + 1) {
        break;
      }
      ++cnt;
    }
    ans += cnt;
  }

  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 256
/******************************************
*    AUTHOR:         JULIAN FERRES        *
*    INSTITUITION:   FIUBA                *
******************************************/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define forr(i, a, b) for(int i = (a); i < (int) (b); i++)
#define forn(i, n) forr(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define DBG(x) cerr << #x << " = " << (x) << endl
#define DBGV(v,n) forn(i,n) cout << v[i] << " \n"[i==n-1];
#define esta(x,c) ((c).find(x) != (c).end())
#define RAYA cerr << "===============================" << endl
const int K = 100005;
const int N = 105;
const int mod = 1000000007;

void add(ll &a, ll b){
	a+=b;
	if(a>=mod) a-=mod;
}
void sub(ll &a, ll b){
	a-=b;
	if(a<0) a+=mod;
}

int n,k;
vi a(N);
vector<vi> dp(N,vi(K,0)); 
vector<vi> pre(N,vi(K,0)); // dp[i][j] = dp[i][0] + ... + dp[i][j]

int main()
{
	FIN;
	cin >> n >> k;
	forn(i,n) cin >> a[i];

	forn(value,a[0]+1) add(dp[0][value],1);

	add(pre[0][0],1);
	sub(pre[0][a[0]+1],1);

	forr(i,1,n){
		forn(j,k+1){
			ll tmp = dp[i - 1][j];
			add(pre[i][j], tmp);
			if(j+a[i]<=k)
				sub(pre[i][j + a[i] + 1], tmp);
			// dp[i][j] = dp[i][j-a[i]] + ... + dp[i][j]
		}
		ll prefix = 0;
		forn(j,k+1){
			add(prefix, pre[i][j]);
			add(dp[i][j], prefix);
		}
	}
	cout << dp[n-1][k] << endl;

	return 0;
}




Measured memory_bytes: 165360
import sys

N, Q = map(int, input().split())
S = input()
P = [[int(v) - 1 for v in sys.stdin.readline().split()] for _ in range(Q)]
X = [0] * (N + 1)

for i in range(N):
    if S[i:i + 2] == 'AC':
        X[i + 1] = X[i] + 1
    else:
        X[i + 1] = X[i] 


for l, r in P:
    print(X[r] - X[l])


Measured memory_bytes: 24444
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <sstream>
#include <iterator>
#include <complex>
using namespace std;

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

	vector<int> a(N);
	vector<int> b(N);
	for(int i=0; i<N; i++)
	{
		cin>>a[i];
		b[a[i]-1] = i+1;
	}

	for(int i=0; i<N; i++)
	{
		cout<<b[i]<<" ";
	}
	cout<<endl;
}

Measured memory_bytes: 1664
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
const int MAXN=1e5+3;
const int INF=0x3f3f3f3f;
const int MOD=1e9+7;
signed main()
{
    int x,a;
    scanf("%d%d",&x,&a);
    x<a?puts("0"):puts("10");
    return 0;
}


Measured memory_bytes: 256
/*
    Problem 99
    https://atcoder.jp/contests/ddcc2020-qual/tasks/ddcc2020_qual_d
*/
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int M;
    cin >> M;
    vector<ll> d(M), c(M);
    for (int i = 0; i < M; i++) cin >> d[i] >> c[i];
    ll D = 0;
    ll S = 0;
    for (int i = 0; i < M; i++) {
        D += c[i];
        S += d[i] * c[i];
    }

    cout << (D - 1) + (S - 1) / 9 << '\n';
}

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

using namespace std;

int main() {
	string S;
	int Q;
	cin >> S >> Q;
	vector<char> ans;
	for (int i = 0; i < S.size(); i++)ans.push_back(S[i]);
	bool flag = false;
	int T;
	int F;
	char C;

	for (int i = 0; i < Q; i++) {
		cin >> T;
		if(T == 1){
			flag = !flag;
		}
		else {
			cin >> F;
			cin >> C;
			if (F == 1) {
				if (flag)ans.push_back(C);
				else ans.insert(ans.begin(), C);
			}
			else {
				if (!flag)ans.push_back(C);
				else ans.insert(ans.begin(), C);
			}
		}
	}
	if (flag) for (int i = ans.size() - 1; i >= 0; i--)cout << ans[i];
	else for (int i = 0; i < ans.size(); i++)cout << ans[i];



	return 0;

}

Measured memory_bytes: 1144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 2e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int a, b;
    cin >> a >> b;

    if (a <= 0 && 0 <= b) {
        cout << "Zero" << endl;
        return 0;
    }
    if (b < 0) {
        if ((b - a) % 2 == 0) {
            cout << "Negative" << endl;
        } else {
            cout << "Positive" << endl;
        }
        return 0;
    }
    cout << "Positive" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
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; }
#define M 1000000007
#define all(a) (a).begin(),(a).end()
#define rep(i,n) reps(i,0,n)
#define reps(i,m,n) for(int i=(m);i<(n);i++)
int main(){
  ll n;cin>>n;
  if(n%2){
    cout<<0;return 0;
  }
  ll c=0LL;
  for(ll i=10;i<=1e18;i*=5){
    c+=n/i;
    if(i==1e18)break;
  }
  cout<<c;
}

Measured memory_bytes: 256
let S  = readLine()!
let C = Array(S.characters)

var count = [Character: Int]()

for c in C{
  if (count[c] == nil){
    count[c] = 1
  }
  else{
    if let a = count[c]{
    	count[c] = a + 1
    }
  }
}

var ans = "Yes"
for i in count.values {
  if i != 2 {
    ans = "No"
  }
}

if count.count != 2 {
  ans = "No"
}

print(ans)


Measured memory_bytes: 6128
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

signed main(void)
{
	int n, k;
	cin >> n >> k;
	int ans = 0;
	if (k % 2 == 1) {
		ans = pow(n / k,3);
	}
	else {
		ans = pow(n/k,3);
		ans += pow((n / (k / 2)- n / k ), 3);
	}
	print(ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
double dist(int x1, int y1, int x2, int y2) {
    double dx = x1 - x2;
    double dy = y1 - y2;
    return sqrt(dx * dx + dy * dy);
}
typedef pair<int, double> P;
vector<P> G[1010];
double d[1010];
int V;
void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P>> que;
    fill(d, d + V + 1, INF2);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
        for (int i = 0; i < G[v].size(); i++){
            P e = G[v][i];
            if (d[e.first] > d[v] + e.second) {
                d[e.first] = d[v] + e.second;
                que.push(P(d[e.first], e.first));
            }
        }
    }
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int xs, ys, xt, yt;
    cin >> xs >> ys >> xt >> yt;
    int n; cin >> n;
    int x[1010], y[1010], r[1010];
    x[0] = xs, y[0] = ys, r[0] = 0;
    rep(i, n) {
        cin >> x[i + 1] >> y[i + 1] >> r[i + 1];
    }
    x[n + 1] = xt, y[n + 1] = yt, r[n + 1] = 0;
    rep(i, n + 2) {
        rep(j, n + 2) {
            if( i == j) continue;
            double tmpd = dist(x[i], y[i], x[j], y[j]) - r[i] - r[j];
            tmpd = max(0.0, tmpd);
            G[i].push_back({j, tmpd});
            G[j].push_back({i, tmpd});
        }
    }
    V = n + 2;
    dijkstra(0);
    cout << fixed << setprecision(12) << d[n + 1] << endl;

    return 0;
}


Measured memory_bytes: 37744
import java.util.Scanner

import scala.annotation.tailrec

object Main {
  def main(args: Array[String]): Unit = {
    //nextLineとnextを同時に使ったら死ぬ
    val sc = new Scanner(System.in)

    val n = sc.nextInt()
    val k = sc.nextLong()
    val as = Vector.fill(n)(sc.nextInt())

    @scala.annotation.tailrec
    def dfs(now: Int,
            set: Set[Int] = Set.empty[Int],
            acc: Vector[Int] = Vector()): Vector[Int] = {
      if (set.contains(now)) acc :+ now
      else {
        dfs(as(now) - 1, set + now, acc :+ now)
      }
    }

    val m = dfs(0)
    val last = m.last
    val l = m.takeWhile(_ != last)
    val s = m.dropWhile(_ != last).init

    val ans = {
      if (k < l.length) {
        l(k.toInt) + 1
      } else {
        if (l.isEmpty) {
          val mm = k % s.length
          val an = if (mm == s.length) 0 else mm
          s(an.toInt) + 1
        } else {
          val more = k - l.length + 1
          val mm = more % s.length

          val mmm =
            if (mm == 0) s.length - 1 else mm - 1

          s(mmm.toInt) + 1
        }
      }
    }

    println(ans)
  }

  //region

  def debug(args: Any*): Unit = {
    Console.err.println(args.mkString(" "))
  }

  def printExecTime(process: => Unit): Unit = {
    val start = System.currentTimeMillis
    process
    debug("処理時間： " + (System.currentTimeMillis - start) + " ミリ秒")
  }

  def bitSearch[T](n: Int, choice: Vector[T]): Vector[Vector[T]] = {
    @tailrec
    def bitSearchLogic(n: Int,
                       choice: Vector[T],
                       acc: Vector[Vector[T]]): Vector[Vector[T]] = {
      if (n == 0) acc
      else {
        val newAcc =
          acc.flatMap(vec => {
            choice.map(c => vec :+ c)
          })
        bitSearchLogic(n - 1, choice, newAcc)
      }
    }

    val firstAcc = choice.map(i => Vector(i))
    bitSearchLogic(n - 1, choice, firstAcc)
  }
  //endregion
}


Measured memory_bytes: 89644
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using ll = long long;
using namespace std;

int main() {
  int h, w;
  cin >> h >> w;
  string s[50];
  for (int i = 0; i < h; i++) cin >> s[i];

  // (dx[i], dy[i]) 8方向の進行差分
  const int dx[8] = {1,  0, -1,  0,  1, -1, -1,  1};
  const int dy[8] = {0,  1,  0, -1,  1,  1, -1, -1};

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (s[i][j] == '#') continue;

      int num = 0;
      for (int d = 0; d < 8; d++) {
        const int ni = i + dy[d];
        const int nj = j + dx[d];

        if (ni < 0 || h <= ni) continue;
        if (nj < 0 || w <= nj) continue;
        if (s[ni][nj] == '#') num++;
      }
      s[i][j] = char(num + '0');
    }
  }

  for (int i = 0; i < h; i++) cout << s[i] << endl;
}


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

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

    vint sum(N+1);
    REP(i,N) sum[i+1]=sum[i]+(s[i]=='E');

    int ans=N;
    REP(i,N){
        int l=i-sum[i];
        int r=sum[N]-sum[i+1];
        ans=min(ans,l+r);
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 3076
#include<bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define LL long long
using namespace std;

const int maxn=2e5+7,p=998244353;
int n,ans=1;
pii a[maxn];
stack<pii> stk;

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i) {
		scanf("%d %d",&a[i].fi,&a[i].se);
	}
	sort(a+1,a+n+1);
	reverse(a+1,a+n+1);
	stk.push(make_pair(2e9+42,ans));
	for(int i=1;i<=n;++i) {
		int pos=a[i].fi+a[i].se;
		while(pos>stk.top().fi) stk.pop();
		ans=(ans+stk.top().se)%p;
		stk.push(make_pair(a[i].fi,ans));
	}
	printf("%d",ans);
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>    
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//using namespace __gnu_pbds; 
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
//#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x,m) (((x)%m*(x)%m)%m)%m
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define int long long 
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
const ll mod           = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
#define N 1000001
const ll N2      = 70;
const ld PI      = 3.141592653589793;
//template<class T>using onset=tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
ll lcm(ll a , ll b){return (a*b)/gcd(a,b);}
void solve(){
  #ifndef ONLINE_JUDGE  
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif
}
signed main(){
    fastio();
    string s; 
    cin>>s; 
    ll n=s.length();
    if(s[n-1]=='s'){
      s+="es";
    }
    else{
      s+='s'; 
    }
    cout<<s;
    //printclock;
    return 0;
}

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {

	public static void selection_sort(int[] a) {
		int num_swaps = 0;
		for (int i = 0; i < a.length; i++) {
			int mini = i;
			for (int j = i; j < a.length; j++) {
				if (a[j] < a[mini])
					mini = j;
			}
			// swap
			int tmp = a[i];
			a[i] = a[mini];
			a[mini] = tmp;
			if (i != mini)
				num_swaps++;
		}
		display(a);
		System.out.println(num_swaps);
	}

	public static void display(int[] a) {
		for (int i = 0; i < a.length; i++) {
			System.out.print(a[i]);
			if (i != a.length - 1)
				System.out.print(" ");
			else
				System.out.print("\n");
		}
	}

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = s.nextInt();
		}
		selection_sort(a);
	}
}


Measured memory_bytes: 26216
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

#ifdef DEBUG
mt19937 mrand(300); 
#else
mt19937 mrand(chrono::steady_clock::now().time_since_epoch().count()); 
#endif

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int maxn = (int) 1e5 + 5;
int n, m;
vector<int> g[maxn];
vector<int> ids[maxn];

bool read() {
  if (scanf("%d%d", &n, &m) < 2) {
    return false;
  }
  for (int i = 0; i < n; i++) {
    g[i].clear();
    ids[i].clear();
  }
  for (int i = 0; i < m; i++) {
    int v, u;
    scanf("%d%d", &v, &u);
    v--;
    u--;
    g[v].push_back(u);
    ids[v].push_back(i);
    g[u].push_back(v);
    ids[u].push_back(i);
  }
  return true;
}

int s[maxn], t[maxn];
int used[maxn];
int need[maxn];

void dfs(int v, int pe, int p) {
  used[v] = true;
  for (int i = 0; i < sz(g[v]); i++) {
    int u = g[v][i], e = ids[v][i];
    if (e == pe) {
      continue;
    }
    if (used[u]) {
      if (s[e] == -1) {
        s[e] = v;
        t[e] = u;
        need[v] ^= 1;
      }
      continue;
    }
    dfs(u, e, v);
  }
  if (need[v]) {
    assert(pe != -1);
    s[pe] = v;
    t[pe] = p;
    need[v] ^= 1;
  } else {
    if (pe != -1) {
      s[pe] = p;
      t[pe] = v;
      need[p] ^= 1;
    }
  }
}

void solve() {
  if (m & 1) {
    printf("-1\n");
    return;
  }
  for (int i = 0; i < n; i++) {
    used[i] = false;
    need[i] = 0;
  }
  for (int i = 0; i < m; i++) {
    s[i] = -1;
    t[i] = -1;
  }
  dfs(0, -1, -1);
  for (int i = 0; i < m; i++) {
    printf("%d %d\n", s[i] + 1, t[i] + 1);
  }
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<char> A (H*W);

  for (int i = 0; i < H*W; i++) cin >> A.at(i);
    
  for (int i = 0; i < W+2; i++) cout << "#";
  
  cout << endl;
  
  for (int i = 0; i < H*W;) {
    cout << "#";
    for (int j = 0; j < W; j++) {
      cout << A.at(i);
      i++;
    }
    cout << "#" << endl;
  }
  
  for (int i = 0; i < W+2; i++) cout << "#";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<long long>A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  sort(A.begin(),A.end());
  bool flag=true;
  for(int i=0;i<N-1;i++){
    if(A.at(i)==A.at(i+1)){
      flag=false;
      break;
    }
    else{
    }
  }
  if(flag){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 1920
N, M = map(int, input().split())
KA=[]
for _ in range(N):
    KA.append(list(map(int, input().split())))
#print(N, M, KA)
KA=[set(val[1:]) for val in KA]
#print(KA)
for val in KA:
    KA[0]=KA[0].intersection(val)
#print(KA[0])
print(len(KA[0]))


Measured memory_bytes: 3060
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
from bisect import bisect_left
def resolve():
    N = ir()
    S = sr()
    R = []
    G = []
    B = []
    for i in range(N):
        if S[i] == 'R':
            R.append(i+1)
        elif S[i] == 'G':
            G.append(i+1)
        else:
            B.append(i+1)
    ans = len(R)*len(G)*len(B)
    for r in R:
        for g in G:
            if abs(r+g)%2 == 0:
                if abs(r+g)//2 in B:
                    ans -= 1
    for r in B:
        for g in G:
            if abs(r+g)%2 == 0:
                if abs(r+g)//2 in R:
                    ans -= 1
    for r in R:
        for g in B:
            if abs(r+g)%2 == 0:
                if abs(r+g)//2 in G:
                    ans -= 1
            # for b in B:
            #     rg = abs(r-g)
            #     gb = abs(g-b)
            #     br = abs(b-r)
            #     if rg != gb and gb != br and br != rg:
            #         ans += 1
                # i = min(r, g, b)
                # k = max(r, g, b)
                # a = k-i
                # if a != 2*r and a != 2*g and a != 2*b:
                #     ans += 1
    # for n in R:
    #     # x = bisect_left(G, n)
    #     for i in G:
    #         a = max(n, i)
    #         b = min(n, i)
    #         x = bisect_left(B, a)
    #         ans += len(B[x:])
    #         if 2*a-b in B:
    #             ans -= 1
    # for n in R:
    #     # x = bisect_left(B, n)
    #     for i in B:
    #         a = max(n, i)
    #         b = min(n, i)
    #         x = bisect_left(G, a)
    #         ans += len(G[x:])
    #         if 2*a-b in G:
    #             ans -= 1
    # # for n in G:
    # #     x = bisect_left(R, n)
    # #     for i in R[x:]:
    # #         x = bisect_left(B, i)
    # #         ans += len(B[x:])
    # #         if 2*i-n in B:
    # #             ans -= 1
    # for n in G:
    #     # x = bisect_left(B, n)
    #     for i in B:
    #         a = max(n, i)
    #         b = min(n, i)
    #         x = bisect_left(R, a)
    #         ans += len(R[x:])
    #         if 2*a-b in R:
    #             ans -= 1
    # for n in B:
    #     x = bisect_left(R, n)
    #     for i in R[x:]:
    #         x = bisect_left(G, i)
    #         ans += len(G[x:])
    #         if 2*i-n in G:
    #             ans -= 1
    # for n in B:
    #     x = bisect_left(G, n)
    #     for i in G[x:]:
    #         x = bisect_left(R, i)
    #         ans += len(R[x:])
    #         if 2*i-n in R:
    #             ans -= 1
    print(ans)
resolve()

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

string solve(string const & s, int k) {
    vector<string> t;
    REP (l, s.length()) {
        REP3 (r, l + 1, min<int>(s.length() + 1, l + k + 1)) {
            t.push_back(s.substr(l, r - l));
        }
    }
    sort(ALL(t));
    t.erase(unique(ALL(t)), t.end());
    return t[k - 1];
}

int main() {
    string s; cin >> s;
    int k; cin >> k;
    cout << solve(s, k) << endl;
    return 0;
}


Measured memory_bytes: 1660
#include<stdio.h>

void run(void){
  int a[3];
  int i;
  for(i=0;i<3;i++) scanf("%d",a+i);
  int max=0;
  for(i=1;i<3;i++) if(a[max]<a[i]) max=i;
  printf("%c\n",'A'+max);
}

int main(void){
  run();
  return 0;
}



Measured memory_bytes: 2072
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
using ll = long long int;
const lint INF = 1001001001001001LL;
const lint MOD = 1000000007LL;
int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

void yes(){ cout << "yes" << endl; }
void Yes(){ cout << "Yes" << endl; }
void YES(){ cout << "YES" << endl; }
void no(){ cout << "no" << endl; }
void No(){ cout << "No" << endl; }
void NO(){ cout << "NO" << endl; }
void possible(){ cout << "possible" << endl; }
void Possible(){ cout << "Possible" << endl; }
void POSSIBLE(){ cout << "POSSIBLE" << endl; }
void impossible(){ cout << "impossible" << endl; }
void Impossible(){ cout << "Impossible" << endl; }
void IMPOSSIBLE(){ cout << "IMPOSSIBLE" << endl; }

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for(int i = s; i < t; i++)
#define all(a) a.begin(),a.end()
using pss = pair<string, string>;


void f(lint cur, lint n, map<pss, lint> &mp, string str1, string str2, string s){
  if(cur == n){
    mp[{str1, str2}]++;
    return;
  }

  f(cur + 1, n, mp, str1, str2 + s[cur], s);
  f(cur + 1, n, mp, str1 + s[cur], str2, s);
}

int main(){
  
  lint n; cin >> n;
  string s; cin >> s; 
  string t1, t2;
  t1 = s.substr(n, n);
  t2 = s.substr(0, n);


  reverse(all(t2));

  map<pss, lint> mp1;
  map<pss, lint> mp2;
  
  f(0, n, mp1, "", "", t1);
  f(0, n, mp2, "", "", t2);
  
  lint ans = 0;
  for(auto x : mp1){
    ans += x.second * mp2[x.first];
  }

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


Measured memory_bytes: 104192
#include <stdio.h>
int main(void){
    int x, y;
    int t;
 
    for (;;) {
        scanf("%d%d", &x, &y);
        if (x == 0 && y == 0) break;
        if (x > y) t = x, x = y, y = t;
        printf("%d %d\n", x, y);
    }
    return 0;
}


Measured memory_bytes: 1972
/*
    When you are not practicing someone else is,
    and the day u meet them u will Lose.

    So, all you need is Practice, Practice and Practice.
*/
#include <bits/stdc++.h>
using namespace std;
                     
#define int             long long
#define ld              long double
#define mp              make_pair
#define ff              first
#define ss              second
#define pb              push_back
#define fo(i,n)         for(i=0;i<n;i++)
#define fo1(i,n)        for(i=1;i<=n;i++)
#define FO(i,a,b)       for(i=a;i<=b;i++)
#define FOR(i,a,b)      for(i=a;i>=b;i--)
#define all(c)          c.begin(),c.end()
#define rall(c)         c.rbegin(),c.rend()
#define si              set<int>
#define vi              vector<int>
#define mii             map<int,int>
#define pii             pair<int,int>
#define vpii            vector<pii>
#define vvi             vector<vi>
#define usi             unordered_set<int>
#define umii            unordered_map<int,int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int,vi,greater<int> >
#define sp(x)           cout<<setprecision(x)<<fixed;
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)     __builtin_ctzll(x)
#define in(a,n)         vi a(n);fo(i,n)cin>>a[i];
#define in1(a,n)        vi a(n+1);fo1(i,n)cin>>a[i];
#define w(t)            int t;cin>>t;while(t--)
#define sz(v)           (int)v.size()
#define gcd             __gcd
#define lcm(x,y)        x*(y/gcd(x,y))
#define endl            '\n'
#define PI              3.14159265358979323846
const int inf =         1e18;
const int mod =         1e9+7;
void __p(int x) {cout<<x;}
void __p(int32_t x){cout<<x;}
void __p(float x){cout<<x;}
void __p(double x){cout<<x;}
void __p(ld x) {cout<<x;}
void __p(char x){cout <<'\''<<x<<'\'';}
void __p(const char *x){cout <<'\"' <<x<<'\"';}
void __p(const string &x) {cout<<'\"'<<x<<'\"';}
void __p(bool x) {cout<<(x?"true":"false");}
void _p() {cout << "]\n";}
template<typename T,typename V>     void __p(const pair<T,V> &x) {cout<<'{';__p(x.first);cout<<',';__p(x.second);cout<<'}';}
template<typename T>                void __p(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __p(i); cout << "}";}
template <typename T,typename... V> void _p(T t, V... v) {__p(t);if(sizeof...(v))cout<<", ";_p(v...);}
int po(int x,int p) {int ans=1;x%=mod;while(p>0){if(p&1)ans=(ans*x)%mod;p=p>>1;x=(x*x)%mod;}return ans;}
int inv(int x){return po(x,mod-2)%mod;}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout<<"["<<#x<<"]=[";_p(x)
#else 
#define dbg(x...)
#endif
/**********************************************************************************/



const int N=1e6+6;
int n,m,k,x,y,z,a,b,c,d,i,j,l,r,f,q;








void sol()
{   string s;
    cin>>s;
    int c=0;
    for(auto p:s)
    {
        c+=p-'0';
    }
    
    
    
    
    
    cout<< ((c%9)?"No":"Yes") <<endl;
}





int32_t main()
{   
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //pre();
    //sp(10);
    // w(t)
    sol();
    return 0;
}


Measured memory_bytes: 3768