akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

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

    cout << n * (n - 1) / 2 << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

typedef struct{
  int m[6];
} DICE;

void diceroll(DICE *,char);

int main(){
  DICE dice;
  int i;
  char c[101];

  for(i=0;i<6;i++) scanf("%d",&dice.m[i]);
  scanf("%s",c);
  
  for(i=0;c[i]!='\0';i++) diceroll(&dice,c[i]);

  printf("%d\n",dice.m[0]);
  return 0;
}

void diceroll(DICE *dice,char c){
  int tmp;
  tmp=dice->m[0];
  
  if(c=='N'){
    dice->m[0]=dice->m[1];
    dice->m[1]=dice->m[5];
    dice->m[5]=dice->m[4];
    dice->m[4]=tmp;
  }
  
  else if(c=='S'){
    dice->m[0]=dice->m[4];
    dice->m[4]=dice->m[5];
    dice->m[5]=dice->m[1];
    dice->m[1]=tmp;
  }
  
  else if(c=='E'){
    dice->m[0]=dice->m[3];
    dice->m[3]=dice->m[5];
    dice->m[5]=dice->m[2];
    dice->m[2]=tmp;
  }
  
  else if(c=='W'){
    dice->m[0]=dice->m[2];
    dice->m[2]=dice->m[5];
    dice->m[5]=dice->m[3];
    dice->m[3]=tmp;
  }

  else return;
}



Measured memory_bytes: 2108
n = int(input())
if n % 2 == 0:
    i = 1
    ans = 0

    while True:
        now = n//(5**i * 2)
        if now > 0:
            ans += now
        if now < 1:
            break
        i+= 1
    print(ans)
else:
    print(0)
    



Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
int l[100001], r[100001];
int main(){
    int n;
    scanf("%d", &n);
    vector<int> v;
    int ans = 0, mx = 0, le = 0;
    for(int i=1;i<=n;i++){
        scanf("%d%d", &l[i], &r[i]);
        mx = max(mx, l[i]);
        le = max(le, r[i]-l[i]+1);
    }
    ans = le;
    for(int i=1;i<=n;i++){
        if(mx <= r[i]) v.push_back(r[i]);
    }
    sort(v.begin(), v.end());

    multiset<int> L, R;
    multiset<pii> R2;

    for(int i=1;i<=n;i++){
        if(l[i] <= mx && mx <= r[i]){
            R2.insert(pii(r[i], i));
        }
        else{
            L.insert(l[i]);
            R.insert(r[i]);
        }
    }
    for(int i=0;i<v.size();i++){
        int s = mx, e = v[i];
        while(!R2.empty() && R2.begin()->first < e){
            int j = R2.begin()->second;
            R2.erase(R2.begin());
            L.insert(l[j]);
            R.insert(r[j]);
        }
        if(!L.empty() && !R2.empty()){
            ans = max(ans, e-s+1 + max(0, *R.begin()-*L.rbegin()+1));
        }
        else if(!R2.empty()){
            ans = max(ans, e-s+1 + le);
        }
    }
    printf("%d\n", ans);
}

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

using namespace std;

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

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

  int a, b, c;
  cin >> a >> b >> c;

  set<int> S({a, b, c});
  cout << S.size() << "\n";

  return 0;
}

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

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef tuple<ll, ll, ll> ti;
 
#define REP(a,b,c) for(ll a=b;a<(c);a++)
#define PER(a,b,c) for(ll a=b;a>=(c);a--)
 
inline ll ii(){ ll x; cin >> x; return x; }
inline string is(){ string x; cin >> x; return x; }
inline ld id(){ ld x; cin >> x; return x; }
inline void oi(ll x){ cout << x; }
inline void od(ld x){ cout << fixed << setprecision(10) << x; }
inline void os(string x){ cout << x; }
inline void oe(){ cout << endl; }
inline void oie(ll x){ oi(x); oe(); }
inline void ode(ld x){ od(x); oe(); }
void ose(string x){ os(x); oe(); }

int main(){
    ll N=ii();
    ll K=ii();
    vector<ll> A;
    REP(i,0,N){
        A.push_back(ii());
    }
    ll l=1,r=10E9;
    while(r>l){
        ll m=(l+r)/2;
        ll t=0;
        REP(i,0,N){
            t+=max((A[i]+(m-1))/m-1,(ll)0);
        }
        if(t>K){
            l=m+1;
        }else{
            r=m;
        }
    }
    oie(r);
    return 0;
}


Measured memory_bytes: 5368
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int[][] a = new int[100001][2];
		for (int i = 0; i < N; i++) {
			int d = in.nextInt();
			a[d][0] = d;
			a[d][1]++;
		}
		int ans = 1;
		for (int i = 0; i < a.length; i++) {
			if (i == 0) {
				if (i + 1 < a.length) {
					ans = Math.max(ans, a[i][1] + a[i + 1][1]);
				}
			} else if (i == a.length - 1) {
				ans = Math.max(ans, a[i][1] + a[i - 1][1]);
			} else {
				ans = Math.max(ans, a[i][1] + a[i + 1][1] + a[i - 1][1]);
			}
		}
		System.out.println(ans);
		in.close();
	}
}

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

const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

int n, a, b;

int main() {
    cin >> n >> a >> b;
    cout << min(b, a*n) << endl;
}
































Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  char C; 
  string alp = "abcdefghijklmnopqrstuvwxyz";
  cin >> C;
  int index=0;

  for(int i=0; i<30; i++){
	if(C == alp.at(i)){
	  index=i;
      break;
	}
	
  }

  cout << alp.at(index+1) << endl;
}


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

using namespace std;

int main(){

	int x;
	cin>>x;
	vector<int> pr;
	int a[200000];
	for(int i=2;i<200000;i++){
	
		a[i]=0;
	}
	for(int i=2;i<200000;i++){

		if(a[i]==0){

			if(i*i<=200000){
			for(int j=i*i;j<200000;j+=i){
			
				a[j]=1;
			}
			}
			else{
			
				break;
			}
		}
	}

	for(int i=2;i<200000;i++){	

		if(a[i]==0){

			pr.push_back(i);
		}
	}

	int l=0,r=pr.size();
	int mid;
	while(l<=r){
	
		mid=l+(r-l)/2;
		if(pr[mid]==x){
		
			cout<<x<<'\n';
			return 0;
		}
		else if(pr[mid]>x){
		
			r=mid-1;
		}
		else{
		
			l=mid+1;
		}
	}
	cout<<pr[r+1]<<'\n';
	return 0;

}


Measured memory_bytes: 4548
#include <stdio.h>

int main(void){
  double h,h1,h2;
  double High,Low;
  double d;
  scanf("%lf",&h1);
  scanf("%lf",&h2);
  if(h1>h2){
    High=h1;
    Low=h2;
  }else{
    High=h2;
    Low=h1;
  }
  while(scanf("%lf",&h)!=EOF){
    if(h>High){
      High=h;
    }
    if(h<Low){
      Low=h;
    }
  }
  d=High-Low;
  printf("%.1f\n",d);
  return 0;
}

Measured memory_bytes: 652
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A[3][10]={},B[3][10]={},C[3][10]={},D[3][10]={};
    int n,x,i,j;
    int b,f,r,v;

    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d %d %d %d",&b,&f,&r,&v);
        switch(b){
            case 1:
                A[f-1][r-1]+=v;
                break;
            case 2:
                B[f-1][r-1]+=v;
                break;
            case 3:
                C[f-1][r-1]+=v;
                break;
            case 4:
                D[f-1][r-1]+=v;
                break;
            }
    }

    for(x=0;x<4;x++){
        for(i=0;i<3;i++){
            for(j=0;j<10;j++){
                    printf(" ");
                    switch(x){
                        case 0:
                            printf("%d",A[i][j]);
                            break;
                        case 1:
                            printf("%d",B[i][j]);
                            break;
                        case 2:
                            printf("%d",C[i][j]);
                            break;
                        case 3:
                            printf("%d",D[i][j]);
                            break;

                    }
            }printf("\n");
        }if(x<3)
        printf("####################\n");
    }
    return 0;
}




Measured memory_bytes: 3200
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define REP(i, start, end) for (ll i = start, i##Len = (end); i < i##Len; ++i)
#define REPR(i, start, end) for (ll i = start, i##Len = (end); i > i##Len; --i)
using ll = long long;
using namespace std;

int main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    int x;
    cin >> x;
    cout << (x ^ 1) << endl;
}

Measured memory_bytes: 3648
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

# シミュレーション関数
def to_end(num, board, query, goal):
    for (qs, qd) in query:
        if qs == board[num]:
            if qd == 'L':
                num -= 1
            elif qd == 'R':
                num += 1
                
            if num == goal:
                return True
            
    return False


# 左へ二分探索
def find_rightest_left(board, query):
    left = 0
    right = len(board)-1
    
    while right-left > 1:
        mid = (left+right) // 2
        if to_end(mid, board, query, 0):
            left = mid
        else:
            right = mid
            
    return left
            
# 右へ二分探索
def find_leftest_right(board, query):
    R = len(board)-1
    left = 0
    right = R
    
    while right-left > 1:
        mid = (left+right) // 2
        if to_end(mid, board, query, R):
            right = mid
        else:
            left = mid
            
    return R - right
    
n,q = li()
board = "0" + ns() + "0"
query = [tuple(ls()) for _ in range(q)]

rightest_left = find_rightest_left(board, query)
leftest_right = find_leftest_right(board, query)

print(max(n - rightest_left - leftest_right, 0))

Measured memory_bytes: 18024
#include<cstdio>
#define N 2000005
#define mo 1000000007
using namespace std;
struct data{
	int x,y,v;
}a[4],b[4];
int x1,x2,x3,x4,x5,x6;
int y1,y2,y3,y4,y5,y6;
int fac[N],inv[N],ans;
int C(int x1,int y1,int x2,int y2){
	return 1ll*fac[x2-x1+y2-y1]*inv[x2-x1]%mo*inv[y2-y1]%mo;
}
int solve(data a,data b){
	int ans=0,x1=a.x,y1=a.y,x2=b.x,y2=b.y;
	for (int i=x3;i<=x4;i++) ans=(ans+1ll*C(x1,y1,i,y3-1)*C(i,y3,x2,y2)%mo*(mo-i-y3))%mo;
	for (int i=x3;i<=x4;i++) ans=(ans+1ll*C(x1,y1,i,y4)*C(i,y4+1,x2,y2)%mo*(i+y4+1))%mo;
	for (int i=y3;i<=y4;i++) ans=(ans+1ll*C(x1,y1,x3-1,i)*C(x3,i,x2,y2)%mo*(mo-i-x3))%mo;
	for (int i=y3;i<=y4;i++) ans=(ans+1ll*C(x1,y1,x4,i)*C(x4+1,i,x2,y2)%mo*(i+x4+1))%mo;
	return ans;
}
int main(){
	fac[0]=inv[0]=inv[1]=1;
	for (int i=2;i<N;i++)
		inv[i]=1ll*(mo-mo/i)*inv[mo%i]%mo;
	for (int i=1;i<N;i++){
		fac[i]=1ll*fac[i-1]*i%mo;
		inv[i]=1ll*inv[i-1]*inv[i]%mo;
	}
	scanf("%d%d%d%d%d%d",&x1,&x2,&x3,&x4,&x5,&x6);
	scanf("%d%d%d%d%d%d",&y1,&y2,&y3,&y4,&y5,&y6);
	a[0]=(data){x2,y2,1}; a[1]=(data){x1-1,y1-1,1};
	a[2]=(data){x2,y1-1,-1}; a[3]=(data){x1-1,y2,-1};
	b[0]=(data){x6+1,y6+1,1}; b[1]=(data){x5,y5,1};
	b[2]=(data){x6+1,y5,-1}; b[3]=(data){x5,y6+1,-1};
	for (int i=0;i<4;i++)
		for (int j=0;j<4;j++)
			ans=(ans+a[i].v*b[j].v*solve(a[i],b[j]))%mo;
	printf("%d",(ans%mo+mo)%mo);
}


Measured memory_bytes: 15744
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#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 <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
int cnt[26];
signed main() {
    string s; cin >> s;
    rep(i,0,s.length()) cnt[ s[i] - 'a' ]++;

    vector<pii> vec;
    queue<pii> que;
    rep(i,0,26) {
        if(cnt[i] == 0) continue;
        vec.push_back(make_pair(cnt[i], i));
    }
    sort(vec.begin(), vec.end());
    reverse(vec.begin(), vec.end());
    rep(i,0,vec.size()) que.push(vec[i]);

    bool ans = true;
    int pre1 = -1, pre2 = -1;
    rep(i,0,s.length()) {
        pii cur = que.front(); que.pop();
        int num = cur.first, ch = cur.second;

        if(ch == pre1 || ch == pre2) {
            ans = false;
            break;
        }
        else {
            num--;
            if(num) que.push(make_pair(num, ch));
            pre2 = pre1;
            pre1 = ch;
        }
    }
    
    cout << (ans ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define N 1000+1
 
void search(char *,char *);
 
int main(){
  int n,i;
  char x[N],y[N];

  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%s",x);
    scanf("%s",y);
    search(x,y);
  }
  return 0;
}

void search(char *x,char *y){
  int i,j;
  int mLen,nLen;
  int z[N][N];

  nLen=strlen(x);//x???????????°
  mLen=strlen(y);//y???????????°

  for(i=1;i<=nLen;i++) z[i][0]=0;
  for(j=0;j<=mLen;j++) z[0][j]=0;
   
  for(i=1;i<=nLen;i++){
    for(j=1;j<=mLen;j++){
      if(x[i-1]==y[j-1]){
	z[i][j] = z[i-1][j-1]+1;
      }
      else if(z[i-1][j]>=z[i][j-1]){
	z[i][j] = z[i-1][j];
      }      
      else{
	z[i][j]=z[i][j-1];
      }
    }
  }
  printf("%d\n",z[nLen][mLen]);
}

Measured memory_bytes: 4524
#include <stdio.h>

int dat[100001] = {};
int main() {
    long n, ans=1;
    int t;
    scanf("%ld", &n);
    for (long i=0; i<n; i++) {
        long a;
        scanf(" %ld", &a);
        dat[a]++;
    }
    t = n % 2 + 1;
    if (t == 2 && dat[0] != 1) {
        puts("0");
        return 0;
    }
    for (long i=t; i<n; i+=2)
        if (dat[i] != 2) {
            puts("0");
            return 0;
        }
    for (long i=1; i<=n/2; i++)
        ans = (2 * ans) % 1000000007;
    printf("%ld\n", ans);
}

Measured memory_bytes: 512
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};


int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n;
    cin>>n;
    vector<int> a(n);
        rep(i,n) cin>>a.at(i);
    int cnt=0;
    rep(i,n-2){
        REP(j,i+1,n-1){
            if(a[i]==a[j]) continue;
            REP(k,j+1,n){
                if(a[i]==a[k] ||a[j]==a[k]) continue;
                if(abs(a[i]-a[j])>=a[k] || a[i]+a[j]<=a[k]) continue;
                cnt ++;
            }
        }
    }
    cout<<cnt<<endl;
}/*
./problem.exe
*/

Measured memory_bytes: 3644
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <string>
#include <tuple>

int main() {
  size_t N, M;
  scanf("%zu %zu", &N, &M);

  std::vector<size_t> g(N+1);
  for (size_t i = 0; i < M; ++i) {
    size_t L, R;
    scanf("%zu %zu", &L, &R);
    ++g[L-1];
    --g[R];
  }
  for (size_t i = 1; i <= N; ++i)
    g[i] += g[i-1];

  int res = 0;
  for (size_t i = 0; i <= N; ++i)
    if (g[i] == M) ++res;

  printf("%d\n", res);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define pii pair<int,int>
#define reset(x,n) memset((x),(n),sizeof(x))
#define all(n) (n).begin(),(n).end()
#define pb push_back
#define IOS ios::sync_with_stdio(0),cin.tie(0);
long double dp[3005][3005];
int main(){
	long double x;
	int n;
	cin>>n;
	dp[0][0]=1;
	for(int i=1;i<=n;i++){
		cin>>x;
		for(int j=0;j<=n;j++){
			dp[i][j]+=dp[i-1][j]*(1-x);
			dp[i][j+1]+=dp[i-1][j]*(x);
		}
	}
	long double ans=0;
	for(int i=n/2+1;i<=n;i++){
		ans+=dp[n][i];
	}
	cout<<fixed<<setprecision(10)<<ans<<'\n';
}


Measured memory_bytes: 141056
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<cstring>
#include<utility>
#include<set>
#include<stack>
#include<complex>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
#define bv vector<bool>
using namespace std;
typedef pair<int, int>PI;
using namespace std;
#define MAX  999999
int main(){
    int n;
    while(cin>>n,n){
        vvi v(111,vi()); vi u(111,0);
        rep(i,n){
            int temp; cin>>temp;
            rep(j,temp){int a;cin>>a; v[a].push_back(i);};
        }
        int temp; cin>>temp;
        rep(i,temp)cin>>u[i];
        bool check = false; int ans = 0;
            int cnt = 0;
            rep(i,temp){
                if(v[u[i]].empty()) break;
                cnt++;
                if(v[u[i]].size() == 1){check = true;ans = v[u[i]].back();}
                }
        if(cnt != temp) check = false;
        if(check) cout << ans+ 1<< endl;
        else cout << -1 << endl;
    }
}

Measured memory_bytes: 3228
#include <iostream>

using namespace std;

int main(){
    int a,b,ans;
    char op;
    while(true){
        cin >> a >> op >> b;
        if(op == '?')break;
        else if(op == '+'){
            ans = a+b;
        }
        else if(op == '-'){
            ans = a-b;
        }
        else if(op == '*'){
            ans = a*b;
        }
        else if(op == '/'){
            ans = a/b;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int index = S.length();
		String ans = "yes";
		char[] ary = new char[index];
		for(int i =  0 ; i < S.length(); i++) {
			ary[i] = S.charAt(i);
		}
		for(int i = 0 ; i < index ; i++) {
			for(int j = i + 1 ; j < index ; j++) {
				if(ary[i] == ary[j]) {
					ans = "no";
				}
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
 
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define LL long long 
#define mod 998244353 
#define FOR(i, j, k) for (int i=j ; i<k ; i++)
#define ROF(i, j, k) for (int i=j ; i>=k ; i--) 
 
const long long INF = 1e18;
const long long MAX = 1e5+10;

int main(){
    fastio;
    int n; cin>>n;
    int a = n/500;
    int b = n%500;
    b=b/5;
    cout<<a*1000 + b*5;
}

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

struct node{
  struct node *r;
  struct node *l;
  struct node *p;
  int key;
};
typedef struct node * Node;

Node root;

Node find(Node u, int k){
  while(u!=NULL && k != u->key){
    if(k<u->key)u=u->l;
    else u=u->r;
  }
  return u;
}


void insert(int k){
  Node x = root;
  Node y = NULL;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->l = NULL;
  z->r = NULL;

  while(x!=NULL){
    y=x;
    if(z->key < x->key){
      x=x->l;
    }
    else {
      x=x->r;
    }
  }
  z->p=y;
  if(y==NULL){
    root=z;
  }
  else{
    if(z->key < y->key){
      y->l=z;
    }
    else{
      y->r=z;
    }
  }


}

void inorder(Node u){
  if(u==NULL)return ;
  inorder(u->l);
  printf(" %d",u->key);
  inorder(u->r);

}
void preorder(Node u){
  if(u==NULL)return ;
  printf(" %d",u->key);
  preorder(u->l);
  preorder(u->r);
}


int main(){
  int n, i, x;
  char c[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", c);
    if ( c[0] == 'f' ){
      scanf("%d", &x);
      Node t = find(root, x);
      if ( t != NULL ) printf("yes\n");
      else printf("no\n");
    }
    if ( c[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( c[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}



Measured memory_bytes: 20496
# AOJ 0577: Unique number
# Python3 2018.6.30 bal4u

c = [[0 for j in range(3)] for i in range(101)]
n = int(input())
p = [[0 for j in range(3)] for i in range(n)]
for i in range(n):
	p[i] = list(map(int, input().split()))
	for j in range(3): c[p[i][j]][j] += 1
for i in range(n):
	s = 0
	for j in range(3):
		if c[p[i][j]][j] == 1: s += p[i][j]
	print(s)


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

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

void Eratosthenes(int n,vi& primes)
{
	primes.assign(n+1,0);
	repi(i,2,n+1)
		primes[i]=1;
	repi(i,2,n+1){
		if(primes[i]==0)
			continue;
		for(int j=i+i;j<=n;j+=i)
			primes[j]=0;
	}
}

int main()
{
	for(int n;cin>>n;){
		vi primes;
		Eratosthenes(n,primes);
		cout<<count(allof(primes),1)<<endl;
	}
	
	return 0;
}

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

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

    int ama;

    ama = n % 10;
    n /= 10;

    if (ama == 7)
    {
        cout << "Yes" << endl;
        return 0;
    }
    ama = n % 10;
    n /= 10;

     if (ama == 7)
    {
        cout << "Yes" << endl;
        return 0;
    }

    ama = n % 10;
    n /= 10;

    if (ama == 7)
    {
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;


    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include <string>
#include<algorithm>
#include <set>
#include <cmath>
using namespace std;
typedef long long lint;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep0(i,n) rep(i,0,n)

int main(void) {
	ios::sync_with_stdio(false);
	int r;
	cin >> r;
	cout << r * r;
	return 0;
}
//
////sort Ｎ個の配列a
//sort(a, a + N); //昇順
//sort(a, a + N, greater<int>()); //降順
//
////最大公約数（ユークリッドの互除法利用）
//int gcd(int a, int b) {
//	if (a == 0) return b;
//	if (b == 0) return a;
//	int m = max(a, b);
//	int n = min(a, b);
//	if (m%n == 0) return n;
//	else return gcd(n, m%n);
//
//}
//
////最小公倍数
//int lca(int a, int b) {
//	if (a == 0) return 0;
//	if (b == 0) return 0;
//	return a * b / gcm(a, b);
//}
//
////n^k(整数)
//int pow_int(int n, int k) {
//	int re = 1;
//	for (int i = 0; i < k; i++) re *= n;
//	return re;
//}



Measured memory_bytes: 256
#include <iomanip>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int H, W;
vector<string> S;

pair<int, int> dfs(int y, int x, vector<vector<bool>>& visit) {
  const vector<pair<int, int>> dirs = {{+1, 0}, {-1, 0}, {0, +1}, {0, -1}};
  int black = (S[y][x] == '#') ? 1 : 0;
  int white = (S[y][x] == '.') ? 1 : 0;
  rep(i, 4) {
    int ny = y + dirs[i].first;
    int nx = x + dirs[i].second;
    if (ny < 0 || nx < 0 || H <= ny || W <= nx) continue;
    if (S[y][x] == S[ny][nx] || visit[ny][nx]) continue;
    visit[ny][nx] = true;
    int b, w;
    tie(b, w) = dfs(ny, nx, visit);
    black += b;
    white += w;
  }
  return make_pair(black, white);
}

int main(void) {
  ios::sync_with_stdio(false);
  cin >> H >> W;
  S.resize(H);
  rep(i, H) cin >> S[i];

  vector<vector<bool>> visit(H, vector<bool>(W, false));
  int64_t answer = 0;
  rep(i, H) {
    rep(j, W) {
      if (S[i][j] == '#' && !visit[i][j]) {
        visit[i][j] = true;
        int b, w;
        tie(b, w) = dfs(i, j, visit);
        answer += (int64_t)b * (int64_t)w;
      }
    }
  }
  cout << answer << endl;
  return 0;
}


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

int main(){
  int N;
  cin >>N;
  int count = 0;
  for (int i = 1; i <= 9; i++ ) {
    for (int p = 1; p <= 9; p++ ) {
      if (i*p == N){
        count+=1;
      }
    }
  }
  if (count != 0){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int max( int a, int b, int c, int d, int e )
{
    int pre1,pre2;
    if( a < b )
    {
        pre1 = b;
    }
    else
    {
        pre1 = a;
    }
    if( c < d )
    {
        pre2 = d;
    }
    else
    {
        pre2 = c;
    }
    if( pre1 < pre2 )
    {
        if( pre2 < e )
        {
            return e;
        }
        else
        {
            return pre2;
        }
    }
    else
    {
        if( pre1 < e )
        {
            return e;
        }
        else
        {
            return pre1;
        }
    }
}

int main()
{
    while( 1 )
    {
        int a = 0,b = 0,c = 0, d = 0,e = 0;
        int num1,num2;
        scanf( "%d %d\n", &num1, &num2 );
        if( num1 == 0 && num2 == 0 ) break;
        a += num1 + num2;
        scanf( "%d %d\n", &num1, &num2 );
        b += num1 + num2;
        scanf( "%d %d\n", &num1, &num2 );
        c += num1 + num2;
        scanf( "%d %d\n", &num1, &num2 );
        d += num1 + num2;
        scanf( "%d %d\n", &num1, &num2 );
        e += num1 + num2;
        int ma = max( a,b,c,d,e );
        if( ma == a )
        {
            printf( "A %d\n", a );
        }
        else if( ma == b )
        {
            printf( "B %d\n", b );
        }
        else if( ma == c )
        {
            printf( "C %d\n", c );
        }
        else if( ma == d )
        {
            printf( "D %d\n", d );
        }
        else if( ma == e )
        {
            printf( "E %d\n", e );
        }
    } 
    return 0;
}


Measured memory_bytes: 2556
#include <bits/stdc++.h>
#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(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

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

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

  priority_queue<int> pq;
  rep(i,n) pq.push(a[i]);

  rep(i,m) {
    int tmp = pq.top();
    pq.pop();
    tmp /= 2;
    pq.push(tmp);
  }

  ll ans = 0;
  rep(i,n) {
    int tmp = pq.top();
    pq.pop();
    ans += tmp;
  }

  cout << ans << endl;
}

Measured memory_bytes: 1276
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <tuple>
#include <cmath>
using namespace std;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;

int main(){
    char a,b;
    cin>>a>>b;
    if(a=='H'&&b=='H'||a=='D'&&b=='D'){
        cout<<'H'<<endl;
    }else{
        cout<<'D'<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;
string ans;
int sx,sy,tx,ty;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	cin >> sx >> sy >> tx >> ty;
	char right,left,up,down;
	right = 'R',left = 'L',up = 'U', down = 'D';
	if(tx - sx < 0)swap(right,left);
	if(ty - sy < 0)swap(up,down);
	REP(i,abs(tx-sx))ans += right;
	REP(i,abs(ty-sy))ans += up;
	REP(i,abs(tx-sx))ans += left;
	REP(i,abs(ty-sy))ans += down;
	ans += down;
	REP(i,abs(tx-sx) + 1)ans += right;
	REP(i,abs(ty-sy) + 1)ans += up;
	ans += left;
	ans += up;
	REP(i,abs(tx-sx) + 1)ans += left;
	REP(i,abs(ty-sy) + 1)ans += down;
	ans += right;
	cout << ans << endl; 
  return 0;
}


Measured memory_bytes: 256
_, A, B, C, D = map(lambda n: int(n) - 1, input().split())
S = input()
if S.count("##", A, D):
    print("No")
elif C < D:
    print("Yes")
elif S.count("...", B - 1, D + 2):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3572
import numpy as np

N = int(input())
X = np.array(list(map(int, input().split())))

average = np.mean(X)

m1 = int(average)
m2 = m1 + 1

ans1 = np.dot(X - m1, X - m1)
ans2 = np.dot(X - m2, X - m2)

print(min(ans1, ans2))



Measured memory_bytes: 12508
from collections import deque
n,c,k = map(int,input().split())
t = []
for _ in range(n):
    tt = int(input())
    t.append(tt)
t.sort()
ans = deque([])
cnt = 0
for i, tt in enumerate(t):
    if i == 0:
        ans.append([tt+k,1])
        cnt += 1
    else:
        flg = False
        for i in range(len(ans)):
            tmp = ans.popleft()
            if tmp[0] < tt or tmp[1] == c:

                continue
            else:
                flg = True
                break
        if flg :
            tmp[1] += 1
            if tmp[1] != c:
                ans.appendleft(tmp)
        else:
            tmp = [tt+k,1]
            ans.append(tmp)
            cnt += 1
print(cnt)


Measured memory_bytes: 7744
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <map>
#include <vector>
#include <string>
#include <vector>
#include <cassert>
#include <cmath>
#include <stack>
#include <cctype>
#include <queue>
#include <algorithm>
#include <memory>
#include <memory.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int INF = 1 << 30;
const double EPS = 1e-10;
const double PI = 3.14159;

int A[200];

int main(){
	int n;
	while(cin >> n && n){
		for(int i = 0; i < n; i++){
			cin >> A[i];
		}
		int m = *max_element(A, A + n);
		int mi = *min_element(A, A + n);
		int res = accumulate(A, A + n, 0);
		cout << (res - m - mi) / (n - 2) << endl;
	}
	return 0;
}

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

int main() {
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;

    vector<int> x(N);
    vector<int> y(M);

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

    int maxX = (int) -1e9;
    for (int i = 0; i < N; ++i) {
        if (x[i] >= maxX) {
            maxX = x[i];
        }
    }

    int minY = (int) 1e9;
    for (int i = 0; i < M; ++i) {
        if (y[i] < minY) {
            minY = y[i];
        }
    }

    for (int z = -100; z <= 100; ++z) {
        if (X < z && z <= Y) {
        } else {
            continue;
        }

        if (maxX >= z) {
            continue;
        }

        if (minY < z) {
            continue;
        }

        cout << "No War" << endl;
        return 0;
    }

    cout << "War" << endl;

    return 0;
}


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

using namespace std;

int main() {
	string s;
	cin >> s;
	int ans = 0;
	
	if (s[5] == '0' && '4' < s[6])ans++;
	if (s[5] == '1')ans++;

	if (ans==0) {
		cout << "Heisei" << endl;
	}
	else {
		cout << "TBD" << endl;
	}
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef pair<int,int> pii;

const int maxn=100005;
int n,m,v,p;
ll a[maxn];

bool check(int i){
	ll cur=a[i]+m,tot=0;
	int cnt=0;
	REP(j,n){
		if(j==i)continue;
		cnt++;
		if(cnt>n-p)break;
		if(a[j]>cur)return false;
		tot+=min(ll(m),cur-a[j]);
	}
	return 1LL*max(0,v-p)*m<=tot;
}

int main(){
	scanf("%d%d%d%d",&n,&m,&v,&p);
	REP(i,n)scanf("%lld",&a[i]);
	sort(a+1,a+1+n);
	int l=0,r=n+1;
	while(r-l>1){
		int mid=l+r>>1;
		if(check(mid))r=mid;
		else l=mid;
	}
	printf("%d\n",n-r+1);
	return 0;
}

Measured memory_bytes: 1024
n = int(input())
s3 = 0
s5 = 0
s15 = 0
count = 0
for i in range(int(n / 3)):
    s3 += (i+1) * 3
for i in range(int(n / 5)):
    s5 += (i + 1) * 5
for i in range(int(n / 15)):
    s15 += (i + 1) * 15
for i in range(n):
    count += (i+1)
print(count-s3-s5+s15)

Measured memory_bytes: 64696
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;


import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;


public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final int H1 = sc.nextInt();
			final int M1 = sc.nextInt();
			final int H2 = sc.nextInt();
			final int M2 = sc.nextInt();
			final int K = sc.nextInt();
			
			final int HM1 = H1 * 60 + M1;
			final int HM2 = H2 * 60 + M2;
			
			final int diff = HM2 - HM1;
			
			System.out.println(Math.max(diff - K, 0));
			
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}


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

typedef long long ll;

const int ALPHA = 2;
const int MAX = 2*100005;

int trie[MAX][ALPHA+5];
ll d[MAX];
bool child[MAX];
int ct = 2;
void insert(string s) {
	int cur = 1;
	for (char i : s) {
		if (trie[cur][i-'0'] != 0) {
			cur = trie[cur][i-'0'];
		}
		else {
			child[cur] = true;
			trie[cur][i-'0'] = ct;
			d[ct] = d[cur] + 1;
			cur = ct;
			ct++;
		}
	}
}

ll nim(ll n) {
	ll i = 1;
	while (n%(2*i) == 0) {
		i *= 2;
	}
	return i;
}

int main() {
	// freopen("a.in", "r", stdin);
	int n; ll l; cin >> n >> l;
	for (int i=0; i<n; i++) {
		string s; cin >> s;
		insert(s);
	}
	vector<ll> depths;
	for (int i=1; i<=ct; i++) {
		for (int j=0; j<ALPHA; j++) {
			if (child[i] && trie[i][j] == 0) {
				depths.push_back(l-d[i]);
			}
		}
	}
	ll nimber = 0;
	for (ll i : depths) { nimber ^= nim(i); }
	cout << ((nimber == 0) ? "Bob" : "Alice");
}

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

int main()
{   int n,m;
    scanf("%d%d",&n,&m);
    int l[m],r[m],table[100002]={0};
    for(int i=0;i<m;i++){
        scanf("%d%d",&l[i],&r[i]);
        table[l[i]]++;
        table[r[i]+1]--;
    }
    for(int i=1;i<=n;i++){
        table[i]+=table[i-1];
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        if(table[i]==m){
            ans++;
        }
        //printf("tabel%d is %d\n",i,table[i]);
    }
    
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 1280
n = gets.chop.to_i
array = gets.split.map(&:to_i)
 
# 偶数のみ、奇数のみの配列を抽出する
even = array.select.with_index {|a, i| i%2 == 0 }
odd  = array.select.with_index {|a, i| i%2 == 1 }
 
# どの数字が何回出現するかを示すハッシュをつくる
even_count = even.inject(Hash.new(0)){|hash, ae| hash[ae] += 1; hash}
odd_count  = odd.inject(Hash.new(0)){|hash, ao| hash[ao] += 1; hash}
 
# 出現回数順に並べ替える
even_count = even_count.sort {|(k1, v1), (k2, v2)| v2 <=> v1 }
odd_count = odd_count.sort {|(k1, v1), (k2, v2)| v2 <=> v1 }
 
# 出現回数トップの数字が異なる場合
if even_count[0][0] != odd_count[0][0]
    replace = n - (even_count[0][1] + odd_count[0][1])
 
# 出現回数トップの数字が同じ場合
else
    # 1種類しか数字がない場合は、2番目に多い数字の出現回数を0とする
    if even_count.size > 1
        even_second = even_count[1][1]
    else
        even_second = 0
    end
    if odd_count.size > 1
        odd_second = odd_count[1][1]
    else
        odd_second = 0
    end
    replace = n - [even_count[0][1] + odd_second, even_second + odd_count[0][1]].max
end
 
p replace

Measured memory_bytes: 21180
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N = S()
A = []
for i in range(len(N)):
    A.append(int(N[i]))
ans = sum(A)
if ans % 9 == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 79032
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in1(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define inN(x, N) rep(i, N) in1(x[i])
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
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; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());

    ll A, B, C;
    in3(A, B, C);

    outl((A * B) / 2);

    return 0;
}


Measured memory_bytes: 3608
#include <iostream>
using namespace std;
const int MAX = 71;
 
char judge(char c){
    if('0' <= c && c <= '9') return c;
    return '#';
}
 
string strMax(string x,string y){
    string tx = "",ty = "";
    bool flg = false;
     
    if(x == "#" && y == "#") return "#";
    if(x == "#") return y;
    if(y == "#") return x;
     
    for(int i = 0 ; i < x.size() ; i++){
        if(x[i] == '0' && !flg){
            continue;
        }
        else{
            flg = true;
            tx += x[i];
        }
    }
    x = tx;
    flg = false;
    for(int i = 0 ; i < y.size() ; i++){
        if(y[i] == '0' && !flg){
            continue;
        }
        else{
            flg = true;
            ty += y[i];
        }
    }
    y = ty;
     
    if(x.size() > y.size()) return x;
    else if(x.size() < y.size()) return y;
     
    for(int i = 0 ; i < x.size() ; i++){
        if(x[i] > y[i]) return x;
        else if(x[i] < y[i]) return y;
    }
    return x;
}
 
int main(){
    int H,W;
    string str[MAX];
     
    while(cin >> H >> W , H + W){
        string dp[MAX][MAX];
        for(int i = 0 ; i < W ; i++){
            cin >> str[i];
        }
        dp[0][0] = judge(str[0][0]);
         
        for(int i = 1 ; i < W ; i++){
            if(judge(str[i][0]) == '#'){
                dp[i][0] = "#";
            }
            else if(dp[i-1][0] != "#"){
                dp[i][0] = dp[i-1][0];
                dp[i][0] += judge(str[i][0]);
            }
            else{
                dp[i][0] += judge(str[i][0]);
            }
        }
         
        for(int j = 1 ; j < H ; j++){
            if(judge(str[0][j]) == '#'){
                dp[0][j] = "#";
            }
            else if(dp[0][j-1] != "#"){
                dp[0][j] = dp[0][j-1];
                dp[0][j] += judge(str[0][j]);
            }
            else{
                dp[0][j] += judge(str[0][j]);
            }
        }
         
        string ans = "0";
        for(int i = 1 ; i < W ; i++){
            for(int j = 1 ; j < H ; j++){
                if(judge(str[i][j]) == '#') dp[i][j] = '#';
                else{
                    dp[i][j] = strMax(dp[i-1][j],dp[i][j-1]);
                    if(dp[i][j] != "#"){
                        dp[i][j] += judge(str[i][j]);
                    }
                    else{
                        dp[i][j] = "";
                        dp[i][j] += judge(str[i][j]);
                    }
                }
            }
        }
        for(int i = 0 ; i < W ; i++){
            for(int j = 0 ; j < H ; j++){
                ans = strMax(ans,dp[i][j]);
	    }
	}
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3340
#include <iostream>
#include <vector>
#include <functional>
using namespace std;

//  a^b % m
long long powmod(long long a, long long b, long long m)
{
    long long r = 1;
    for (; b>0; b>>=1, a=a*a%m)
        if (b&1)
            r = r*a%m;
    return r;
}

int main()
{
    int N;
    cin>>N;
    vector<vector<int>> E(N);
    for (int i=0; i<N-1; i++)
    {
        int A, B;
        cin>>A>>B;
        E[A-1].push_back(B-1);
        E[B-1].push_back(A-1);
    }

    long long M = 1000000007;

    vector<long long> P2(N+1);
    P2[0] = 1;
    for (int i=1; i<=N; i++)
        P2[i] = P2[i-1]*2%M;

    long long ans = 0;
    function<int(int, int)> f = [&](int c, int p)
    {
        int s = 0;
        long long ph = P2[N-1];
        int lc = 0;
        for (int e: E[c])
            if (e != p)
            {
                int n = f(e, c);
                ph -= (P2[n]-1+M)%M;
                s += n;
                lc++;
            }
        if (N-s-1>0)
        {
            ph -= (P2[N-s-1]-1+M)%M;
            lc++;
        }
        ph -= 1;
        ans += (ph%M+M)%M * powmod(P2[N], M-2, M) % M;
        ans %= M;
        return s+1;
    };
    f(0, -1);
    cout<<ans<<endl;
}


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

int main(){
    int a=0;
    string s;
    cin >> s;
    for(int i=0;i<s.length();i++)
    if (stoi(s.substr(i,1))==2)
        a++;
    cout << a << endl;
    return 0;
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

struct Edge {
  int l;
  int r;
  int64 c;
};

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

  int n, m;
  cin >> n >> m;
  vector<vector<Edge>> v_to_edges(n);
  for (int i = 0; i < m; i++) {
    int l;
    int r;
    int64 c;
    cin >> l >> r >> c;
    l--;
    r--;
    Edge e({l, r, c});
    v_to_edges[l].push_back(e);
  }

  multiset<int64> s;
  constexpr int64 INF = 1E18;
  vector<int64> dp(n, INF);
  vector<vector<int64>> v_to_ends(n);
  dp[0] = 0;
  for (const auto& e : v_to_edges[0]) {
    s.insert(e.c);
    v_to_ends[e.r].push_back(e.c);
  }

  for (int v = 1; v < n; v++) {
    if (!s.empty()) {
      dp[v] = *s.begin();
    }
    if (dp[v] == INF) continue;
    for (int64 x : v_to_ends[v]) {
      s.erase(s.find(x));
    }
    for (const auto& e : v_to_edges[v]) {
      s.insert(dp[v] + e.c);
      v_to_ends[e.r].push_back(dp[v] + e.c);
    }
  }

  if (dp[n - 1] == INF) {
    cout << -1 << endl;
  } else {
    cout << dp[n - 1] << endl;
  }
}

Measured memory_bytes: 11904