akhauriyash/Code-Regression huggingface dataset:
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr int MOD_TYPE = 1;
constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
constexpr int INF = (int)1e9;
constexpr ll LINF = (ll)4e18;
constexpr ld PI = acos(-1.0);
constexpr ld EPS = 1e-11;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

#pragma endregion

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  while (1)
  {
    c -= b;
    if (c <= 0)
    {
      Yes(true);
      return 0;
    }
    a -= d;
    if (a <= 0)
    {
      Yes(false);
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define int int64_t
using namespace std;
void print(const vector<int>&xs){
  for(auto&x:xs)cout<<x<<",";
  cout<<endl;
}
int N;
vector<int>A,F_left,F_right;
main(){
  cin>>N;
  A=F_left=F_right=vector<int>(N);
  for(auto&x:A)cin>>x;
  // print(A);
  for(int i=1;i<N;++i)A[i]+=A[i-1];
  // print(A);
  for(int mid=2;mid<=N-2;++mid){  // middle.
    if(mid==2){
      F_left[mid]=1;
    }else{
      int left=F_left[mid]=F_left[mid-1];
      int P=A[left-1];
      int Q=A[mid-1]-A[left-1];
      int diff_prev=abs(P-Q);  // difference previous.
      while(true){
        left=F_left[mid]+1;
        if(left>=mid)break;
        P=A[left-1];
        Q=A[mid-1]-A[left-1];
        int diff_next=abs(P-Q);
        if(diff_next<diff_prev){
          ++F_left[mid];
          diff_prev=diff_next;
        }else{
          break;
        }
      }
    }
  }
  for(int mid=N-2;mid>=2;--mid){
    if(mid==N-2){
      F_right[mid]=N-1;
    }else{
      int right=F_right[mid]=F_right[mid+1];
      int R=A[right-1]-A[mid-1];
      int S=A[N-1]-A[right-1];
      int diff_prev=abs(R-S);  // difference previous.
      while(true){
        right=F_right[mid]-1;
        if(right<=mid)break;
        R=A[right-1]-A[mid-1];
        S=A[N-1]-A[right-1];
        int diff_next=abs(R-S);
        // printf("mid, right, prev, next=%d, %d, %d, %d\n",mid,right,diff_prev,diff_next);
        if(diff_next<diff_prev){
          --F_right[mid];
          diff_prev=diff_next;
        }else{
          break;
        }
      }
    }
  }
  // print(F_left);
  // print(F_right);
  int answer=0x3f3f3f3f;
  for(int mid=2;mid<=N-2;++mid){
    const int left=F_left[mid];
    const int right=F_right[mid];
    const int P=A[left-1];
    const int Q=A[mid-1]-A[left-1];
    const int R=A[right-1]-A[mid-1];
    const int S=A[N-1]-A[right-1];
    const int n_max=max(max(P,Q),max(R,S));
    const int n_min=min(min(P,Q),min(R,S));
    const int difference=abs(n_max-n_min);
    // printf("P, Q, R, S=%d, %d, %d, %d\n",P,Q,R,S);
    if(difference<answer){
      // printf("update %d,%d,%d\n",left,mid,right);
    }
    answer=min(answer,difference);
  }
  cout<<answer<<endl;
}


Measured memory_bytes: 4992
fun main(args: Array<String>) {
    val s = readLine()!!
    val sb = StringBuilder()

    for (c in s) {
        when (c) {
            'B' -> if (sb.isNotEmpty()) sb.deleteCharAt(sb.lastIndex)
            else -> sb.append(c)
        }
    }

    println(sb.toString())
}


Measured memory_bytes: 33484
#include <iostream>

using namespace std;
int main(void){
    int H,W;

    while(true){
        cin >> H >> W;
        
        if(H==0 and W==0) break;
        
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                if((j%2-i%2)==0){
                    cout << "#";
                }else{
                    cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}



Measured memory_bytes: 3072
using System;
public class Test{
  public static void Main(){
    var num = Console.ReadLine().Split(' ');
    int A = int.Parse(num[0]);
    int B = int.Parse(num[1]);
    double H = double.Parse(num[2]);
    double M = double.Parse(num[3]);
    double X=0; 
    double Hrad = (H*60+M)/720;
    double Mrad = M/60;
    if(Hrad >= Mrad){
      if(Hrad-Mrad >= 1-Hrad+Mrad){
        X = A*A + B*B - 2*A*B*Math.Cos((Hrad-Mrad)*2*Math.PI);
      }else{
        X = A*A + B*B - 2*A*B*Math.Cos((1-Hrad+Mrad)*2*Math.PI);
      }
    }else{
      if(Mrad-Hrad >= 1-Mrad+Hrad){
        X = A*A + B*B - 2*A*B*Math.Cos((Mrad-Hrad)*2*Math.PI);
      }else{
        X = A*A + B*B - 2*A*B*Math.Cos((1-Mrad+Hrad)*2*Math.PI);
      }
    }
    Console.Write(Math.Sqrt(X));
  }
}

Measured memory_bytes: 27940
#include<bits/stdc++.h>
const long long N=2000+10;
const long long P=1e9+7;
using namespace std;

long long n,k,f[N][N];
long long fac[N*N],inv[N*N],fai[N*N],ma;

long long read()
{
	long long a,f=1;
	char c;
	c=getchar();
	while(c<'0'||c>'9')
	{
	  if(c=='-') f=-1;
	  c=getchar();
	}
	a=c-'0';
	c=getchar();
	while(c>='0'&&c<='9')
	{
	  a=a*10+c-'0';
	  c=getchar();
	}
	return a*f;
}

long long qpow(long long x,long long b)
{
	long long y;
	if(b==0) return 1;
	if(b==1) return x;
	y=qpow(x,b/2)%P;
	y=y*y%P;
	if(b%2) y=y*x%P;
	return y;
}

int main()
{
	long long i,j,s,t;
	n=read(); k=read();
	if(k==1){printf("1\n"); return 0;}
	ma=n*k;
	fac[0]=inv[0]=fai[0]=1;
	fac[1]=inv[1]=fai[1]=1;
	for(i=2;i<=ma;i++)
	{
	  fac[i]=(fac[i-1]*i)%P;
	  inv[i]=(P-P/i)%P*inv[P%i]%P;
	  fai[i]=fai[i-1]*inv[i]%P;
	}
//	for(i=1;i<=n;i++) cout<<inv[i]<<" ";
//	cout<<endl;
	for(i=0;i<=n;i++) f[i][0]=1;
	for(i=1;i<=n;i++)
	  for(j=1;j<=i;j++)
	  {
	  	f[i][j]=f[i-1][j]%P;
	  	s=((n-i)%P+((n-j+1)*(k-1)%P)-1)%P;
	  	t=(fac[s]*fai[k-2]%P)*fai[s-k+2]%P;
	  	f[i][j]=(f[i][j]+(t*f[i][j-1]%P)*(n-j+1)%P)%P;
	  }
/*	for(i=1;i<=n;i++)
	{
	  for(j=1;j<=i;j++) cout<<f[i][j]<<" ";
	  cout<<endl;
	}*/
	printf("%d\n",f[n][n]);
	return 0;
}

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


int main(){

    string S;
    ll ans = 1e7;
    cin >> S;
    for(int i = 0; i < S.size() - 2; i++ ){
        string tmp = "";
        for(int j = 0; j < 3; j++){
            tmp += S[i + j]; 
        }
        ans = min(ans,abs((stoll(tmp) - 753)));
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
import sys

def main():
    inputslen = int(sys.stdin.readline().rstrip())
    inputs= sys.stdin.readline()

    sortvalue = [int(i) for i in inputs.split()]
    count = 0
    for i in range(0, inputslen-1):

        minidx = i
        for j in range(i, inputslen):
            if sortvalue[j] < sortvalue[minidx]:
                minidx = j
        if sortvalue[minidx] != sortvalue[i]:
            minvalue = sortvalue[minidx]
            sortvalue[minidx] = sortvalue[i]
            sortvalue[i] = minvalue
            count += 1

    printvalue = map(str, sortvalue)
    print(' '.join(printvalue))
    print(count)

if __name__ == '__main__':
    main()


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

int sum(int n){
  int total=0;
  while(n>0){
    total+= n%10;
    n/=10;
  }
  return total;
}


int main(){
  int n,a,b;
  cin >> n >> a >> b;
  int ans=0;
  for(int i=1; i<=n; i++){
    int S=sum(i);
    if(S>=a && S<=b){
      ans+=i;
    }
  }
cout << ans << endl;  
  
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<bitset>
#include<iomanip>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<cstdio>
#include<cstdlib>
#include<cmath>
using namespace std;


struct Dice{
  int s[6];
  void roll(char c){
    int b;
    if(c=='E'){
      b=s[0];
      s[0]=s[3];
      s[3]=s[5];
      s[5]=s[2];
      s[2]=b;
    }
    if(c=='W'){
      b=s[0];
      s[0]=s[2];
      s[2]=s[5];
      s[5]=s[3];
      s[3]=b;
    }
    if(c=='N'){
      b=s[0];
      s[0]=s[1];
      s[1]=s[5];
      s[5]=s[4];
      s[4]=b;
    }
    if(c=='S'){
      b=s[0];
      s[0]=s[4];
      s[4]=s[5];
      s[5]=s[1];
      s[1]=b;
    }
    if(c=='R'){
      b=s[1];
      s[1]=s[2];
      s[2]=s[4];
      s[4]=s[3];
      s[3]=b;
    }    
  }
  int top() {
    return s[0];
  }
  int right(){
    return s[2];
  }
  int left(){
    return s[3];
  }
  int front(){
    return s[1];
  }
};

bool same(Dice a,Dice b){
  for(int i=0;i<6;i++) if(a.s[i]!=b.s[i]) return false;
  return true;
}

int main(){
    int n;
    cin >> n;
    Dice d[n];
    for(int i=0; i < n; i++){
        for(int j=0; j < 6; j++){
            cin >> d[i].s[j];
        }
    }
    bool f = false;
    for(int fst = 0; fst < n; fst++){
        for(int sec = fst+1; sec < n; sec++){
    for(int i=0; i < 4; i++){
        d[0].roll('R');
        for(int j=0; j < 4; j++){
            d[0].roll('N');
            if(same(d[fst], d[sec]))f = true;
        }
    }
    d[fst].roll('W');
    for(int i=0; i < 4; i++){
        d[fst].roll('N');
        if(same(d[fst], d[sec]))f = true;
    }
    d[fst].roll('E');
    d[fst].roll('E');
    for(int i=0; i < 4; i++){
        d[fst].roll('N');
        if(same(d[fst], d[sec]))f = true;
    }
        }
    }
    cout << (f ? "No":"Yes") << endl;
    return 0;
}


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

#define foreach(i,v) for(auto&& i: v)
#define all(x) (x).begin(), (x).end()

typedef std::vector< std::string > VS;
typedef std::vector<int> VI;
typedef long long ll;

template <class C> C& mini(C& a, C b) { if (b < a) a = b; return a; }
template <class C> C& maxi(C& a, C b) { if (a < b) a = b; return a; }

using namespace std;

template <typename T> void read(T& x) { x.read(); }
template <typename T> void read(vector<T>& v) { for (T& x: v) read(x); }
template <typename X, typename Y> void read(pair<X, Y>& p) { read(p.first); read(p.second); }
template <> void read(int& x) { scanf("%d", &x); }
template <> void read(unsigned int& x) { scanf("%u", &x); }
template <> void read(long long& x) { scanf("%lld", &x); }
template <> void read(unsigned long long& x) { scanf("%llu", &x); }
template <typename T> void readv(vector<T>& v) { int N; read(N); v.resize(N); read(v); }
template <typename T, typename ...Ts> void read(T& x, Ts&... args) { read(x); read(args...); }

static char S[30010];
static char reach[3][1000];

int main(int argc, const char* argv[]) {
    int N;
    scanf("%d\n%s\n", &N, S);
    reach[0][S[0]-'0'] = 1;
    reach[0][S[1]-'0'] = 1;
    reach[1][(S[0]-'0')*10 + S[1]-'0'] = 1;
    for (int i = 2; i < N; i++) {
        int c = S[i] - '0';
        for (int j = 0; j <= 99; j++)
            if (reach[1][j])
                reach[2][j*10 + c] = 1;
        for (int j = 0; j <= 9; j++)
            if (reach[0][j])
                reach[1][j*10 + c] = 1;
        reach[0][c] = 1;
    }

    int ret = 0;
    for (int i = 0; i <= 999; i++)
        ret += reach[2][i];
    printf("%d\n", ret);

    return 0;
}


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

// #include <iostream>
// #include <fstream>
// #include <string>
// #include <map>
// #include <vector>
// #include <algorithm>
// #include <regex>
// #include <chrono>
// #include <sstream>
// #include <iomanip>
// #include <queue>
// #include <stack>
// #include <set>
// #include <unordered_map>
// #include <unordered_set>


using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define int long long
struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 998244353;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T&b){if(a<b)return(a=b,1);return 0;}
template<class T>bool chmin(T &a, const T&b){if(b<a)return(a=b,1);return 0;}

ll sum[70];

signed main() {

	int n;
	cin >> n;
	vector<ll> a(n);

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

	for(int i = 0; i < n; i++) {
		for(int j = 0; j < 61; j++) {
			sum[j] = sum[j] + !!(a[i]&(1LL<<j));
		}
	}

	ll ans = 0;

	for(ll i = 0; i < 61; i++) {
		ll t = (sum[i] * (n-sum[i]) % SMOD);
		ll tt = (1LL << i) % SMOD;

		
		ans += t * tt % SMOD;
		ans %= SMOD;
	}

	cout << ans << endl;

    return 0;
}



Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <deque>
#include <queue>//for queue and priority_queue
#include <fstream>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#define endl "\n"
typedef long long ll;
using namespace std;
void Lancer() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
bool isPrime(ll n){
	if (n == 2 || n == 3 || n == 5)
		return true;
	else if (n % 2 == 0 || n % 3 == 0 || n % 5 == 0 || n == 1)
		return false;
	else {
		for (int i = 5; i <= sqrt(n); i += 2){
			if (n%i == 0)
				return false;
		}
		return true;
	}
}

//char arr[57][57];
int main(){
	Lancer();
	ll n, res = 0,t;
	cin >> n;
	vector<int> vec(n);
	for (int i = 0; i < n; i++)
		cin >> vec[i];
	bool ch = true;
	while(ch){
		for (int i = 0; i < n; i++){
			if (vec[i] % 2 != 0){
				ch = false;
				break;
			}
			vec[i] /= 2;
		}
		if (ch)res++;
	}
	cout << res;
	cout << endl;
	return 0;
}


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

#define MAX 200000000


int getChar(char a);
int searchKey();
int find();
void insert();
int M[MAX];
char string[15];

int main(){
  int size;
  char com[7];
  scanf("%d" ,&size);
  
  while(size--)
  {
    scanf("%s %s" ,com ,string);

    if(com[0] == 'i')
    {
      insert();
    }
    else
    {
      if(find())
      {
	printf("yes\n");
      }
      else
      {
	printf("no\n");
      }
    }
  }

  return 0;
}

int getChar(char a){
  if(a == 'A')
  {
    return 1;
  }
  else if(a == 'C')
  {
    return 2;
  }
  else if(a == 'G')
  {
    return 3;
  }
  return 4;
}

int searchKey()
{
  int sum = 0;
  int p = 1;
  for(int i = 0 ; i < strlen(string) ; i++)
  {
    sum += p*(getChar(string[i]));
    p *=5;
  }
  return sum;
}

int find()
{
  int key = searchKey();

  if(M[key]){
    return 1;
  }

  return 0;
}

void insert(){
  M[searchKey()] = 1;
}



Measured memory_bytes: 18592
#include <bits/stdc++.h>
using namespace std;
#define INF 2000000000
typedef long long int ll;
typedef pair<ll,ll> ii;
typedef pair<ii,ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
#define getbit(n,i) (((n)&(1LL<<(i)))!=0)
#define setbit0(n,i) ((n)&(~(1LL<<(i))))
#define setbit1(n,i) ((n)|(1LL<<(i)))
#define lastone(n) ((n)&(-(n)))
#define read freopen("debug\\in.txt","r",stdin)
#define write freopen("debug\\out.txt","w",stdout)
#define DBG(a) cout<<#a<<" ->->->-> "<<a<<"\n"
#define EN cout<<"\n"
#define fi first
#define se second
#define PI (acos(-1))
#define fastread ios::sync_with_stdio(false);cin.tie(NULL)
#define mod (1000000007)
#define asz 200005
template<class T> ostream& operator<<(ostream &s,pair<T,ll> a)
{
    s<<a.fi<<' '<<a.se;
    return s;
}
int main()
{
    fastread;
    ll T=1;
//    cin>>T;
    for(ll qq=1;qq<=T; qq++)
    {
        ll n,m;
        cin>>n>>m;
        vector<string> grid(n);
        for(auto &x:grid)cin>>x;
        vector<string> red(n);
        for(int i=0;i<n;i++)
        {
            if(i%2)
            {
                for(int j=0;j<m-1;j++)red[i]+='#';
                red[i]+='.';
            }
            else
            {
                red[i]+='#';
                for(int j=1;j<m;j++)
                {
                    if(grid[i][j]=='#')red[i]+='#';
                    else red[i]+='.';
                }
            }
        }
        vector<string> blue(n);
        for(int i=0;i<n;i++)
        {
            if(i%2==0)
            {
                blue[i]+='.';
                for(int j=1;j<m;j++)blue[i]+='#';
            }
            else
            {
                for(int j=0;j<m-1;j++)
                {
                    if(grid[i][j]=='#')blue[i]+='#';
                    else blue[i]+='.';
                }
                blue[i]+='#';
            }
        }
        for(auto x:red)cout<<x<<endl;
        cout<<endl;
        for(auto x:blue)cout<<x<<endl;
    }
}



Measured memory_bytes: 1536
N, M = map(int, input().split())
X = list(map(int, input().split()))
X.sort()

dist = [0] * (M-1)
for i in range(M-1):
    dist[i] = X[i+1] -X[i]

dist.sort()

if N >= M:
    ans = 0
else:
    ans = sum(dist[:M-N])

print(ans)

Measured memory_bytes: 13968
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1ll<<60;

using Graph = vector<vector<ll>>;
Graph G;
vector<ll> dist;

int main(int argc, char **argv)
{
	ll N, M; cin >> N >> M;
	vector<ll> H(N);
	for (ll i = 0; i < N; ++i) cin >> H[i];
	G.resize(N);

	for (ll i = 0; i < M; ++i)
	{
		ll a, b; cin >> a >> b;
		--a, --b;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	ll res{0};
	for (ll v = 0; v < N; ++v)
	{
		ll ok{true};
		ll th = H[v];
		for (auto &nv : G[v])
		{
			if (th <= H[nv])
				ok = false;
		}
		if (ok) ++res;
	}
	std::cout << res << std::endl;
}


Measured memory_bytes: 9856
#include <iostream>;
using namespace std;
int main()
{
    int a,b;
    char op;
    for(int i=0; ;i++){
    cin>>a>>op>>b;
    if(op=='+')cout<<a+b<<endl;
    else if(op=='-')cout<<a-b<<endl;
    else if(op=='*')cout<<a*b<<endl;
    else if(op=='/')cout<<a/b<<endl;
    else break;}
    return 0;
}
    


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

//const double PI = acos(-1);
using ll = long long;
using ull = unsigned long long;
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define REP(i,n) for (int i = 0; i < (n); i++)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second

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

  int n, m, c;
  cin >> n >> m >> c;
  int b[m];
  REP(i,m) cin >> b[i];
  int ans = 0;
  REP(i,n){
    int sum = 0;
    REP(j,m) {
      int a;
      cin >> a;
      sum += a * b[j];
    }
    ans += (sum + c) > 0;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void)
{
  int size;
  cin>>size;
  int numbers[size];
  for(int i=0;i<size;i++)
  {
    cin>>numbers[i];
  }
  int count2[size]={0};
  int count3[size]={0};
  int max=1000;
  int count22=0;
  for(int i=0;i<size;i++)
  {
    while(numbers[i]%2==0&&numbers[i]>=2)
    {
      numbers[i]/=2;
      count2[i]++;
      count22++;
    }
    while(numbers[i]*3<=1000000000)
    {
      numbers[i]*=3;
      count3[i]++;
    }
    if(max>=count2[i]+count3[i])
    {
      max=count2[i]+count3[i];
    }
  }
  //for(int i=0;i<size;i++)
  //{
  //  cout<<count2[i]<<endl;
  //}
  cout<<count22;
}


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

int main(void) {
  int n;
  scanf("%d", &n);
  int a = n % 10;
  if (a == 3) {
    printf("bon\n");
  } else if (!a || a == 1 || a == 6 || a == 8) {
    printf("pon\n");
  } else {
    printf("hon\n");
  }

  return 0;
}


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

int main(void) {
    int n;
    scanf("%d", &n);
    int dig = 0, tmp = n;
    while (tmp) {
        dig++;
        tmp /= 10;
    }
    vector<int> v;
    for (int i = 1; i <= 9; i++) v.push_back(i);
    for (int i = 100; i <= 999; i++) v.push_back(i);
    for (int i = 10000; i <= 99999; i++) v.push_back(i);
    v.push_back(10000000);
    sort(v.begin(), v.end());
    int ans = lower_bound(v.begin(), v.end(), n) - v.begin();
    if (dig % 2 == 1) ans += 1;
    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 892
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;let mut next =||{iter .next () .unwrap () } ;input_inner !{next ,$($r ) *} } ;($($r :tt ) *) =>{let stdin =std ::io ::stdin () ;let mut bytes =std ::io ::Read ::bytes (std ::io ::BufReader ::new (stdin .lock () ) ) ;let mut next =move ||->String {bytes .by_ref () .map (|r |r .unwrap () as char ) .skip_while (|c |c .is_whitespace () ) .take_while (|c |!c .is_whitespace () ) .collect () } ;input_inner !{next ,$($r ) *} } ;}
macro_rules !input_inner {($next :expr ) =>{} ;($next :expr ,) =>{} ;($next :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($next ,$t ) ;input_inner !{$next $($r ) *} } ;}
macro_rules !read_value {($next :expr ,($($t :tt ) ,*) ) =>{($(read_value !($next ,$t ) ) ,*) } ;($next :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($next ,$t ) ) .collect ::<Vec <_ >>() } ;($next :expr ,chars ) =>{read_value !($next ,String ) .chars () .collect ::<Vec <char >>() } ;($next :expr ,usize1 ) =>{read_value !($next ,usize ) -1 } ;($next :expr ,$t :ty ) =>{$next () .parse ::<$t >() .expect ("Parse error" ) } ;}

fn main() {
   input! {
      n: usize,
      k: usize,
      a: [usize; n]
   }

   let mut dp = vec![false; k + 1];
   for i in 1..k + 1 {
      for j in 0..n {
         if i >= a[j] {
            dp[i] |= !dp[i - a[j]];
         }
      }
   }
   println!("{}", if dp[k] { "First" } else { "Second" });
}


Measured memory_bytes: 4352
import sys
import math
import bisect
def input():
    return sys.stdin.readline()[:-1]
n,t=map(int,input().split())
ab = []
for i in range(n):
    ab.append(list(map(int,input().split())))

dp = [[0 for i in range(t)]for i in range(n+1)]
ab = sorted(ab,key=lambda x:x[0])
ans = ab[0][1]
for i in range(1,n):
    for j in range(t):
        if j-ab[i-1][0]>=0:
            dp[i][j] += max(dp[i-1][j-ab[i-1][0]] + ab[i-1][1],dp[i-1][j])
        else:
            dp[i][j] += dp[i-1][j]

    ans = max(ans,dp[i][-1]+ab[i][1])

print(ans)


Measured memory_bytes: 120924
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<complex>
#include<utility>
#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 push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
typedef complex<double> P;
double dot(P a,P b){
  return real(conj(a)*b);
}
double cross(P a,P b){
  return imag(conj(a)*b);
}
P pin(){
  double x,y;
  cin>>x>>y;
  P p(x,y);
  return p;
}
int main(){
  int n;
  cin>>n;
  while(n--){
    P a[4];
    rep(i,4)a[i]=pin();
    P b=a[1]-a[0];
    P c=a[3]-a[2];
    if(cross(b,c)==0)cout<<2<<endl;
    else if(dot(b,c)==0)cout<<1<<endl;
    else cout<<0<<endl;
  }
}

Measured memory_bytes: 1236
#include <iostream>
#include <cmath>

using namespace std;

int main() {
  int N;
  cin >> N;
  int s = (sqrt(1+8*N)-1)/2 + 1;
  int r = s*(s+1)/2 - N;
  for (int i = 1; i <= s; ++i) {
    if (i == r) continue;
    cout << i << endl;
  }
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define test() int t;cin>>t;loop(test,1,t+1)
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define nl cout<<"\n"
#define sp cout<<" "
#define F first
#define S second
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define MOD 1000000007
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

ll mod( ll n, ll m=MOD ){ n%=m,n+=m,n%=m;return n; }

const int MAXN = 1e5+5;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

int rem[MAXN];

int main() 
{
    fastio();

    string s;
    cin>>s;
    int n = s.size();
    rem[0] = 1;
    vector<int>ans(13,0);
    ans[0]=1;
    for(int i=1;i<n;i++)
    {
        rem[i] = rem[i-1]*10;
        rem[i] = mod(rem[i],13);
    }

    for(int i=n-1;i>=0;i--)
    {
        if( s[i] != '?' )
        {
            int tt = rem[n-i-1];
            tt *= (s[i]-'0');
            tt = mod(tt,13);
            vector<int>tans(13,0);
            for(int c=0;c<13;c++)
            {
                int nn = (tt+c)%13;
                tans[nn] += ans[c];
                tans[nn] = mod(tans[nn]);
            }
            ans = tans;
        }
        else
        {
            int rr = rem[n-i-1];
            vector<int>tans(13,0);
            for(int now=0;now<10;now++)
            {
                int tt = rr*now;
                tt = mod(tt,13);
                for(int c=0;c<13;c++)
                {
                    int nn = (tt+c)%13;
                    tans[nn] += ans[c];
                    tans[nn] = mod(tans[nn]);
                }
            }
            ans = tans;
        }
    }
    cout<<ans[5];

    return 0;
}

Measured memory_bytes: 848
#include <bits/stdc++.h>
#include <math.h>
#include <regex>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001001001001001001;

int main(){

    ll n,x,y; cin >> n >> x >> y;
    x--; y--;

    vector<vector<pair<ll,ll>>> A(n);
    for(int i=0;i<=n-2;i++){
        A.at(i).push_back(make_pair(i+1,1));
        A.at(i+1).push_back(make_pair(i,1));
    }
    A.at(x).push_back(make_pair(y,1));
    A.at(y).push_back(make_pair(x,1));

    vector<ll> ans(n,0);

    for(int i=0;i<=n-1;i++){
        vector<ll> d(n,INF);
        d.at(i)= 0;
        priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> q; // pair: first is length of shortest path and second is index of vertex
        q.push(make_pair(0,i));
        while(!q.empty()){
            pair<int,int> p = q.top();
            q.pop();
            if(p.first > d.at(p.second)) continue;    
            for(int i=0;i<(int)A.at(p.second).size();i++){
                if(d.at(A.at(p.second).at(i).first) > d.at(p.second) + A.at(p.second).at(i).second){
                    d.at(A.at(p.second).at(i).first) = d.at(p.second) + A.at(p.second).at(i).second;
                    q.push(make_pair(d.at(A.at(p.second).at(i).first),A.at(p.second).at(i).first));
                }
            }
        }
        for(int i=0;i<n;i++){
            ans.at(d.at(i))++;
        }
    }

    for(int i=1;i<=n-1;i++){
        cout << ans.at(i)/2 << endl;
    }
    return 0;
}

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

using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
#define lin "\n"
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(0)
int a[105], b[105], c[105];

void solve() {
    int m, n;
    cin >> m >> n;
    ll cnt = 0;
    for (int i = m; i <= n; ++i) {
        string s = to_string(i);
        bool ok = true;
        for (int j = 0; j < s.size() / 2; ++j) {
            if (s[j] != s[s.size() - j - 1]) {
                ok = false;
                break;
            }
        }
        if (ok)
            cnt++;
    }
    cout << cnt << lin;
}

int main() {
    fast_io;
    int t = 1;
//    cin >> t;
    int c = 1;
    while (t--) {
//        printf("Case %lld: ",c);
//        cout<<"Case "<<c<<": ";
        solve();
        c++;
    }
}

Measured memory_bytes: 3728
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define INF 100000000
using namespace std;
int main(){
  int e;
  while(1){
    cin >> e;
    if(e==0) break;
    int ans = INF;
    for(int y=0; y<1000; y++){
      for(int z=0; z<1000; z++){
	int x = e-y*y-z*z*z;
	if(x<0) continue;
	ans = min(ans,x+y+z);
      }
    }
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3088
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
#include <assert.h>
#include <deque>
using namespace std;

/*
using PAIR = pair<string, int>;
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long ll;

#define fi first
#define se second
#define rep(i, n) for (ll i = 0; i < n; i++)
#define debugA() cerr << "AAAAA" << endl
#define debug_() cerr << "-------------" << endl
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v)                   \
    for (int i = 0; i < v.size(); i++) \
    {                                  \
        cout << v[i] << " ";           \
    }                                  \
    cout << endl;
#define debug_vec2(v)                         \
    for (int i = 0; i < v.size(); i++)        \
    {                                         \
        for (int j = 0; j < v[i].size(); j++) \
        {                                     \
            cout << v[i][j] << " ";           \
        }                                     \
        cout << endl;                         \
    }

using Graph = vector<vector<int>>;
using P = pair<int, int>;
using P1 = pair<int, pair<int, int>>; // クラスカル法とかで、{cost, {from, to}}的に使う。
const int INF = 1001001001;
const double pi = acos(-1);

bool is_prime(ll n)
{
    if (n == 1)
        return false;
    for (ll i = 2; i * i <= n; ++i)
    {
        if (n % i == 0)
            return false;
    }
    return true;
}

int main()
{
    int q;
    cin >> q;
    vector<bool> a(100009, false);
    vector<int> SUM(100009, 0);
    for (int i = 1; i < a.size(); i++)
    {
        if (is_prime(i))
        {
            a[i] = true;
            if (a[(i + 1) / 2])
            {
                SUM[i] = SUM[i - 1] + 1;
            }
        }
    }
    for (int i = 0; i < 100007; i++)
    {
        SUM[i + 1] += SUM[i];
    }
    for (int i = 0; i < q; i++)
    {
        int l, r;
        cin >> l >> r;
        cout << SUM[r] - SUM[l - 1] << endl;
    }

    return 0;
}


Measured memory_bytes: 1024
n, m = list(map(int, input().split()))
a = {}

for i in range(m):
    a[int(input())] = True

c = [0] * (n+1)
c[0] = 1

for i in range(1, n+1):
    if not i in a:
        c[i] = c[i-1] + c[i-2]

print(c[n] % 1000000007)

Measured memory_bytes: 465900
N, TL = map(int, input().split())
C = []
T = []
for i in range(N):
    a, b = map(int, input().split())
    C.append(a)
    T.append(b)
cost = 10000
for i in range(N):
    if T[i] <= TL:
        cost = min(cost, C[i])
if cost == 10000:
    print("TLE")
else:
    print(cost)


Measured memory_bytes: 38256
#include <iostream>
using namespace std;
int main()
{
  int n, m;
  cin >> n >> m;
  int totaldays = 0;
  int val;
  for(int i = 0; i<m; i++)
  {
    cin >> val;
    totaldays += val;
  }
  
  cout << (totaldays > n ? -1 : (n - totaldays));
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

template <class T>
void setmin(T &a, T b) {
    if (b < a) a = b;
}

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

    int n, m;
    cin >> n >> m;

    constexpr int INF = 1 << 29;
    vector<int> dp(1 << n, INF);
    dp[0] = 0;

    for (int j = 0; j < m; j++) {
        int a, b;
        cin >> a >> b;

        int l = 0;
        for (int i = 0; i < b; i++) {
            int c;
            cin >> c;
            c--;

            l ^= 1 << c;
        }

        for (int k = 0; k < 1 << n; k++) {
            setmin(dp[k | l], dp[k] + a);
        }
    }

    int r = dp[(1 << n) - 1];
    cout << (r == INF ? -1 : r) << endl;

    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-


n, m = map(int, input().split())
if n > 1 and m > 1:
    print((n-2)*(m-2))
else:
    if n == 1 and m == 1:
        print(1)
    else:
        if n == 1:
            print(m-2)
        else:
            print(n-2)

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

int main() {
  int n;
  int a, b;
  cin >> n;
  if ( n == 2 ) {
    cin >> a >> b;
  }
  string ans = ( n == 1 ) ? "Hello World" : to_string(a+b);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
# ABC 126 C
n, k = [int(el) for el in input().split(' ')]
H = []
for i in range(1, n+1):
    h = 0
    while i < k:
        i = 2*i
        h += 1
    H.append(h)

total = 1/n * sum([(1/2)**h for h in H])
print(total)


Measured memory_bytes: 7064
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

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

  int n, k;
  cin >> n >> k;
  vector<ll> a(n);
  for (auto &x: a) cin >> x;

  vector<ll> a_sum(n+1), a_sum_optimal(n+1);
  for (int i = 0; i < n; i++) {
    a_sum[i+1] = a_sum[i] + a[i];
    if (a[i] > 0) a_sum_optimal[i+1] = a_sum_optimal[i] + a[i];
    else a_sum_optimal[i+1] = a_sum_optimal[i];
  }

  ll ans = 0;
  for (int i = 0; i < n - k + 1; i++) {
    ll white = (a_sum_optimal[i] - a_sum_optimal[0]) + (a_sum_optimal[n] - a_sum_optimal[i+k]);
    ll black = (a_sum_optimal[i] - a_sum_optimal[0]) + (a_sum[i+k] - a_sum[i]) + (a_sum_optimal[n] - a_sum_optimal[i+k]);
    if (max(white, black) > ans) ans = max(white, black);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)

int main(){
    for(int n,r;cin>>n>>r,n;){
        vi cur(n);
        rep(i,n) cur[i] = n-i;
        rep(i,r){
            int p,c; cin >> p >> c;
            p--;
            vi next = cur;
            rep(i,c+p){
                next[i] = cur[(i+p)%(c+p)];
            }
            swap(cur,next);
        }
        cout << cur[0] << endl;
    }
}

Measured memory_bytes: 1220
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

//#pragma gcc target ("avx2")
//#pragma gcc optimization ("o3")
//#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2.0) //等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

ll lcm(ll number1, ll number2) {
	return number1 / gcd(number1, number2) * number2;
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/


int main() {

	double l;
	scanf("%lf", &l);
	printdb(pow(l / 3.0, 3));

	Please AC;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
 
using namespace std;
int main()
{
  long N;
  long ans;

  ans = 0;
  cin >> N;

  for(int i = 1; i < N+1; i++)
  if((i%3 != 0) && (i%5 != 0)){
    ans += i;
  //  cout << i << endl;
  }

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

Measured memory_bytes: 3632
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF = 1 << 29;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int N,K;
vector<int> A;
const int MAX_N = 5010;
int8_t dp[MAX_N][MAX_N];
int src;
int tabooo[MAX_N];
int memo(int pos, int val){
  if (val >= K - A[src] and val < K){
    return 1;
  }

  if (pos == N){
    return 0;
  }
  int8_t &res = dp[pos][val];
  if (res >= 0){
    return res;
  }
  res = 0;
  res = memo(pos + 1, val);
  if (res&1){
    return res;
  }
  if (not tabooo[pos]){
    res = memo(pos + 1, min(K, val + A[pos]));
    if (res&1){
      return res;
    }
  }

  return res;
}


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

  A.resize(N);
  for (auto &val : A){
    cin >> val;
  }
  sort(A.begin(), A.end());
  int left,right;
  left = -1;
  right = N;
  while (right - left > 1){
    int med = (right + left) / 2;
    if (med >= N){
      right--;
      continue;
    }else if(med < 0){
      left++;
      continue;
    }

    src = med;
    memset(dp, -1, sizeof(dp));
    tabooo[med] = true;
    int res = memo(max(0, left), 0);
    tabooo[med] = false;
    if (res > 0){//necessary
      right = med;
    }else{//unnecessary
      left = med;
  
    }
  }
  cout << (left + 1) << endl;

  return 0;
}


Measured memory_bytes: 25088
package main

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

func main() {
	n := readLineToSlice()
	// fmt.Println(n)
	ints := make([]int, len(n))
	for i:=0; i<len(n); i++ {
		take,_ := strconv.Atoi(n[i])
		ints[i] = take
	}
	sum := 0
	for i:= 0; i<len(n); i++ {
		sum += ints[i]
	}
	if sum %9 == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

var sc = bufio.NewScanner(os.Stdin)

func scan_init() {
	sc.Split(bufio.ScanWords)
}
func scanInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func scan() string {
	sc.Scan()
	return sc.Text()
}

var rdr = bufio.NewReaderSize(os.Stdin, 200000)

func readLine() string {
	buf := make([]byte, 0, 200000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}
func readLineToNumber() int {
	S := readLine()
	number, _ := strconv.Atoi(S)
	return number
}
func readLineToSlice() []string {
	S := readLine()
	list := strings.Split(S, "")
	return list
}
func readLineToNumberSlice(memo map[string]int) []int {
	// err時は-1を代入
	S := readLine()
	intList := make([]int, len(S))
	for i := 0; i < len(S); i++ {
		if val, ok := memo[string(S[i])]; ok {
			intList[i] = val
		} else {
			intList[i] = -1
		}
	}
	return intList
}

Measured memory_bytes: 7352
#include<stdio.h>
#define N 100

int main() {
    int n, k, l, t;
    int i, j;
    int A[N][N];

    for ( i = 0; i < N; i++) {
        for ( j = 0; j < N; j++) {
            A[i][j] = 0;
        }
    }
    
    scanf("%d", &n);
    for(i=0;i<n;i++) {
        scanf("%d%d",&l , &k);
        for ( j = 0; j < k; j++) {
            scanf("%d", &t);
            A[l-1][t-1] = 1;
        }
    }

    for ( i = 0; i < n; i++) {
        for ( j = 0; j < n-1; j++) {
            printf("%d ", A[i][j]);
        }
            printf("%d\n", A[i][j]);
    }
    
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<cmath>
#include<queue>
#include<functional>
#include<algorithm>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
using namespace std;
 

int main(void)
{
	
	int n;
	while(cin>>n,n){
		//????????????,?????\
		map<int,int> sec;
		
		//-1(???)???0???????§???????
		sec[0]=-1;
		sec[1000000000]=-1;
		
		for(int i=0;i<n;i++){
			string s;
			cin>>s;
			
			if(s=="W"){
				int a,len;
				cin>>a>>len;
				
				for(auto it=sec.begin();it!=sec.end();it++){
					if(it->second==-1){
						it->second=a;
						auto it2=it;
						it2++;
						if(it2->first - it->first >= len){
							if(it2->first - it->first == len) break;
							else{
								sec[it->first+len]=-1;
								break;
							}
						}
						else len-=it2->first - it->first;
					}
				}
				
			}else if(s=="D"){
				
				int a;
				cin>>a;
				
				for(auto it=sec.begin();it!=sec.end();it++){
					if(it->second == a) it->second=-1;
				}
			}else if(s=="R"){

				int a;
				cin>>a;
				
				for(auto it=sec.begin();it!=sec.end();it++){

					auto it2=it;
					it2++;
					if(it2==sec.end()){cout<<-1<<endl; break;}
					if(it->first<=a && a<it2->first){
						cout<<it->second<<endl;
						break;
					}

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

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

using i32 = int_fast32_t;
using i64 = int_fast64_t;

template<i64 M>
struct modint {
    i64 x;

    constexpr modint(const i64 y = 0) noexcept : x(y >= 0 ? y % M : (M - (-y) % M) % M) {}

    constexpr modint operator-() const noexcept { return modint(-x); }
    constexpr modint operator+(const modint &rhs) const noexcept { return modint(*this) += rhs; }
    constexpr modint operator-(const modint &rhs) const noexcept { return modint(*this) -= rhs; }
    constexpr modint operator*(const modint &rhs) const noexcept { return modint(*this) *= rhs; }
    constexpr modint operator/(const modint &rhs) const noexcept { return modint(*this) /= rhs; }

    constexpr modint &operator+=(const modint &rhs) noexcept {
        x += rhs.x;
        if (x >= M) x -= M;
        return *this;
    }

    constexpr modint &operator-=(const modint &rhs) noexcept {
        if (x < rhs.x) x += M;
        x -= rhs.x;
        return *this;
    }

    constexpr modint &operator*=(const modint &rhs) noexcept {
        x = x * rhs.x % M;
        return *this;
    }

    constexpr modint &operator/=(const modint &rhs) noexcept {
        i64 a = rhs.x, b = M, u = 1, v = 0;
        while (b > 0) {
            i64 t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        *this *= u;
        return *this;
    }

    friend ostream &operator<<(ostream &os, const modint &p) {
        return os << p.x;
    }

    friend istream &operator>>(istream &is, const modint &a) {
        i64 t;
        is >> t;
        a = modint(t);
        return is;
    }
};

constexpr i64 MOD = 1e9 + 7;
using m64 = modint<MOD>;

template<typename T = m64>
struct combinatorics {
    vector<T> fac;

    combinatorics(i32 n): fac(n+1) {
        fac[0] = 1;
        for (i32 i = 1; i <= n; i++) fac[i] = fac[i-1] * i;
    }

    T p(i32 n, i32 k) const {
        if (k < 0 || n < k) return 0;
        return fac[n] / fac[n-k];
    }

    T c(i32 n, i32 k) const {
        if (k < 0 || n < k) return 0;
        return fac[n] / (fac[k] * fac[n-k]);
    }

    T h(i32 n, i32 k) const {
        return c(n+k-1, k);
    }
};

int main() {
    i32 n, k;
    cin >> n >> k;
    vector<vector<i32>> g(n);
    for (i32 i = 0; i < n-1; i++) {
        i32 a, b;
        cin >> a >> b, a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    queue<i32> q;
    q.push(0);
    vector<i32> dist(n, -1);
    dist[0] = 0;
    combinatorics<> c(k);
    m64 ans = c.p(k, g[0].size()+1);
    while (!q.empty()) {
        i32 t = q.front(); q.pop();
        for (auto& e : g[t]) {
            if (dist[e] != -1) continue;
            ans *= c.p(k-2, g[e].size()-1);
            dist[e] = dist[t] + 1;
            q.push(e);
        }
    }

    cout << ans << endl;
}


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

int sum(int x){
  int sum = 0;
  while(true){
    int a = 10;
    sum += x % a;
    x = x / a;
    a = a * 10;
    if (x == 0){
      return sum;
    }
  }
}

int main(){
  int N, A, B;
  cin >> N >> A >> B;
  
  int ans = 0;
  for (int i = 1; i <= N; i++){
    if(sum(i) >= A && sum(i) <= B){
      ans += i;
    }
  }
  cout << ans << endl;  
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <numeric>
#include <set>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 999999999
#define MINF -999999999
#define ALL(n) n.begin(),n.end()

int main() {
	char s[60][60] = {};
	int a, b, v1[4] = { -1,1,0,0 }, v2[4] = { 0,0,1,-1 };
	cin >> a >> b;
	REPO(i, a) REPO(j, b) cin >> s[i][j];
	REPO(i, a) {
		REPO(j, b) {
			if (s[i][j] == '#') {
				bool a = {};
				REP(k, 4) if (s[i + v1[k]][j + v2[k]] == '#') a = true;
				if (!a) {
					cout << "No" << endl;
					return 0;
				}
			}
		}
	}
	cout << "Yes" << endl;
	return 0;

}



Measured memory_bytes: 256