akhauriyash/Code-Regression huggingface dataset:
S = input()
S_num = list(map(int, S))

n_white_even = sum(S_num[0::2])
n_black_even = len(S_num[0::2]) - n_white_even
n_white_odd = sum(S_num[1::2])
n_black_odd = len(S_num[1::2]) - n_white_odd

# even: white, odd: black
cand_1 = n_black_even + n_white_odd
# even: black, odd: white
cand_2 = n_white_even + n_black_odd

print(min(cand_1, cand_2))


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

using namespace std;

int main(void){

    string str;
    cin >> str;

    char s[3] = {0};

    for(int i = 0;i < 3;i++){
        s[str[i]-'a']++;
    }

    if(s[0] == s[1] && s[1] == s[2]) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

int main()
{
	int N = 0, M = 0, k = 0, ans = 0;
	std::cin >> N >> M;
	std::vector<int>p(M);
	std::vector<std::vector<int>> E(M);

	for (int i = 0; i < M; i++)
	{
		std::cin >> k;
		E[i].resize(k);
		for (int j = 0; j < k; j++)
		{
			std::cin >> E[i][j];
			E[i][j]--;
		}
	}

	for (int i = 0; i < M; i++) std::cin >> p[i];
	
	for (int i = 0; i < (1 << N); i++)
	{
		bool light = true;
		for (int j = 0; j < M; j++)
		{
			int cnt =  0;
			for (int& S : E[j])
			{
				if ((i >> S) & 1) cnt++;
			}
			cnt %= 2;
			if (cnt != p[j]){ light = false; }
		}

		if (light) ans++;
	}

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
using namespace std;

typedef long long ll;
typedef double db;
typedef long double ldb;

template<class T> inline void checkmin(T &a,const T &b){if(b<a) a=b;}
template<class T> inline void checkmax(T &a,const T &b){if(b>a) a=b;}

const int inf=1e9+10;

int s,w; 

int main(){
	scanf("%d%d",&s,&w);
	if(s<=w) printf("unsafe\n");
	else printf("safe\n");
	return 0;
}


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

using namespace std;

const int MAX_N = 233;

struct Point {
    int x, y;
    Point() {}
    Point(int x, int y) : x(x), y(y) {}
    Point operator-(const Point &rhs) const { return Point(x - rhs.x, y - rhs.y); }
    bool operator==(const Point &rhs) const { return x == rhs.x && y == rhs.y; }
} poi[MAX_N];

int N, ans;

int main() {
    scanf("%d", &N); ans = N;
    for (int i = 1; i <= N; i++) scanf("%d%d", &poi[i].x, &poi[i].y);
    for (int i = 1; i <= N; i++)
        for (int j = i + 1; j <= N; j++) {
            Point diff = poi[i] - poi[j];
            int curr = N;
            for (int a = 1; a <= N; a++) {
                for (int b = 1; b <= N; b++) {
                    if (poi[a] - poi[b] == diff) curr--;
                }
            }
            ans = min(ans, curr);
        }
    printf("%d\n", ans);
}

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

int main(){
  string S; cin >> S;
  int N=S.size();
  vector<int> MY(N,0);
  int even=0;
  int odd=0;
  int EVEN=0;
  int ODD=0;
  int k=-1;
  int K=N;
  for(int i=0;i<N;i++){
    if(S.at(i)=='L' && (i-k)%2==1){
      MY.at(i)+=odd;
      MY.at(i-1)+=even;
      k=i;
      even=0;
      odd=0;
    }
    if(S.at(i)=='L' && (i-k)%2==0){
      MY.at(i)+=even;
      MY.at(i-1)+=odd;
      k=i;
      even=0;
      odd=0;
    }
    if(S.at(i)=='R' && (i-k)%2==0) even++;
    if(S.at(i)=='R' && (i-k)%2==1) odd++;
  }
  for(int i=N-1;i>=0;i--){
    if(S.at(i)=='R' && (K-i)%2==0){
      MY.at(i)+=EVEN;
      MY.at(i+1)+=ODD;
      K=i;
      EVEN=0;
      ODD=0;
    }
    if(S.at(i)=='R' && (K-i)%2==1){
      MY.at(i)+=ODD;
      MY.at(i+1)+=EVEN;
      K=i;
      EVEN=0;
      ODD=0;
    }
    if(S.at(i)=='L' && (K-i)%2==0) EVEN++;
    if(S.at(i)=='L' && (K-i)%2==1) ODD++;
  }
  for(int i=0;i<N;i++){
    cout << MY.at(i) << endl;
  }
}
    

Measured memory_bytes: 1152
#define ll long long int
#define pb push_back
#define mp make_pair
#include <bits/stdc++.h>
using namespace std;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

	ll t=1,r,n,a,b,c,x,y,sum,cnt,i,j,k,m,l,q,maxx,minn,temp,ans,flag,z,h,w,p,ts,first,second;
	
	string str,ttr;
	long double dans;
	
	
	
//	cin >> t;

	
	for(ts=1;ts<=t;ts++)
	{
	    flag=0;sum=0;cnt=0;ans=0;maxx=0,minn=99999999999; x=0;y=0;temp=0;
	    
	    cin >>x >> y >> a >> b >> c;
	    
	    ll arr[a],brr[b],crr[c];
	    
	    for(i=0;i<a;i++)
	    cin >> arr[i];
	    
	    for(i=0;i<b;i++)
	    cin >> brr[i];
	    
	    for(i=0;i<c;i++)
	    cin >> crr[i];
	    
	    sort(arr,arr+a,greater<ll>());
	    sort(brr,brr+b,greater<ll>());
	    sort(crr,crr+c,greater<ll>());
	    
	    for(i=0;i<x;i++)
	    sum=sum+arr[i];
	    
	    for(i=0;i<y;i++)
	    sum=sum+brr[i];
	    
	  //  cout << sum<<endl;
	    
	    first=x-1;second=y-1;
	    
	    for(i=0;i<c;i++)
	    {  
	        if(first>=0 && second>=0)
	        {
	            if(arr[first]<brr[second] )
	            {
	                if(crr[i]>arr[first])
	                {
	                    
	                    sum=sum+crr[i]-arr[first];
	                    first--;
	                }
	                
	                else if(crr[i]>brr[second])
	                {
	                    
	                    sum=sum+crr[i]-brr[second];
	                    second--;
	                }
	                
	            }
	            else{
	                if(crr[i]>brr[second])
	                {
	                    
	                    sum=sum+crr[i]-brr[second];
	                    second--;
	                }
	            }
	        }
	        else if(first>=0 && crr[i]>arr[first])
	        {
	            sum=sum+crr[i]-arr[first];
	            first--;
	        }
	        
	        else if(second>=0 && crr[i]>brr[second])
	        {
	            sum=sum+crr[i]-brr[second];
	            second--;
	        }
	    }
	    
	    cout << sum <<"\n";
	}
	return 0;
}

Measured memory_bytes: 2560
// by syu
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

var in = NewScanner(os.Stdin, 0)

func main() {
	N, K := in.Int(), in.Int()
	x := in.ArrayInt(N)
	min := math.MaxInt64
	for i := 0; i < N-K+1; i++ {
		a, b := x[i], x[i+K-1]
		sum := Min2(Abs(a), Abs(b)) + b - a
		if sum < min {
			min = sum
		}
	}
	Pln(min)
}

type Scanner struct {
	*bufio.Scanner
}

func NewScanner(r io.Reader, max int) *Scanner {
	s := bufio.NewScanner(r)
	s.Split(scanWords)
	if max <= 0 {
		max = 1048576
	}
	s.Buffer([]byte{}, max)
	return &Scanner{s}
}
func (s *Scanner) Int() int {
	s.Scan()
	i, e := strconv.ParseInt(s.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return int(i)
}
func (s *Scanner) ArrayInt(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = s.Int()
	}
	return r
}
func isSpace(b byte) bool {
	return b == ' ' || b == '\n' || b == '\r' || b == '\t'
}
func scanWords(data []byte, atEOF bool) (advance int, token []byte, err error) {
	start := 0
	for start < len(data) && isSpace(data[start]) {
		start++
	}
	for i := start; i < len(data); i++ {
		if isSpace(data[i]) {
			return i + 1, data[start:i], nil
		}
	}
	if atEOF && len(data) > start {
		return len(data), data[start:], nil
	}
	return start, nil, nil
}
func Min2(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func Abs(n int) int {
	y := n >> 63
	return (n ^ y) - y
}
func Pln(s ...interface{}) {
	fmt.Println(s...)
}


Measured memory_bytes: 2944
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<(DUMP(),__VA_ARGS__).str()<<" ["<<__LINE__<<"]"<<endl)
struct DUMP:ostringstream{template<class T>DUMP &operator,(const T&t){if(this->tellp())*this<<", ";*this<<t;return *this;}};
#else
#define dump(...)
#endif
template<class T> ostream& operator<<(ostream& os, vector<T> const& v){
    rep(i,v.size()) os << v[i] << (i+1==v.size()?"":" ");
    return os;
}

int n;
int sum[1000], in[1000];

int main(){
    while(~scanf("%d\n", &n) && n){
        memset(sum,0,sizeof(sum));
        memset(in,-1,sizeof(in));
        rep(i,n){
            int M,D,h,m;
            char s[2];
            int id;
            scanf("%02d/%02d %02d:%02d %s %03d ", &M, &D, &h, &m, s, &id);
            // dump(M,D,h,m,s,id);
            if(s[0] == 'I') in[id] = h*60+m;
            else{
                int t = h*60+m;
                if(id==0){
                    rep(j,1000)if(j){
                        if(in[j]!=-1) sum[j] += t-max(in[j],in[0]);
                    }
                }else{
                    if(in[0]!=-1) sum[id] += t-max(in[id],in[0]);
                }
                in[id] = -1;
            }
        }
        printf("%d\n", *max_element(sum+1,sum+1000));
    }
}

Measured memory_bytes: 1188
#include <cstdio>

using namespace std;

template<typename Type>
void Get_Val(Type &Ret)
{
	Ret = 0;
	char ch;
	while (ch = getchar(), ch > '9' || ch < '0')
		;
	do
	{
		(Ret *= 10) += ch - '0';
	}
	while (ch = getchar(), ch >= '0' && ch <= '9');
}

const int Max_N(100050);
const int Max_Q(100050);
typedef long long int LL;

int N, Q;
LL V[Max_Q];

void init()
{
	int _Q;
	Get_Val(N), Get_Val(_Q);
	V[++Q] = N * 1LL;
	while (_Q--)//把V处理成严格递增的情况 
	{
		Get_Val(V[++Q]);
		while (Q - 1 >= 1 && V[Q - 1] >= V[Q])
			V[Q - 1] = V[Q], --Q;
	}
}

/*
设S[i]表示进行前i次操作得到的答案，solve(i, l)表示进行前i次操作，序列前l个数的答案，其中l <= V[i]。显然有S[i] = solve(i, V[i])
solve(i, l) = S[i - 1] * floor(l / V[i - 1]) + solve(i - 1, l mod V[i - 1])
对于solve(i - 1, l mod V[i - 1])，可以找到第一个l >= V[j <= i - 1]，直接solve(j, l mod V[j])即可，因为中间的floor(l / V[k]) = 0且l mod V[k] = l，对其而言无意义 
这样只会跳log次。Cnt[i]表示S[i]在最终答案中出现了多少次，倒推计算Cnt[i]，每次solve的过程可以把贡献加到Cnt上
*/

LL Cnt[Max_Q], Ans[Max_N];

inline void insert(const int &l, const int &r, const LL &v)
{
	Ans[l] += v, Ans[r + 1] -= v;
}

void solve(const int &x, const LL &l, const LL &cnt)
{
	if (x == 1)
	{
		Cnt[1] += cnt * (l / V[1]);
		insert(1, static_cast<int>(l % V[1]), cnt);
	}
	else
	{
		Cnt[x - 1] += cnt * (l / V[x - 1]);
		if (l % V[x - 1] == 0LL)
			return;
		int up(1), down(x), mid;
		while (up < down)
		{
			mid = up + ((down - up) >> 1);
			if (l % V[x - 1] >= V[mid - 1])
				up = mid + 1;
			else
				down = mid;
		}
		solve(up - 1, l % V[x - 1], cnt);
	}
}

int main()
{
	init();
	Cnt[Q] = 1LL;
	for (int i = Q;i >= 2;--i)
		solve(i, V[i], Cnt[i]);
	insert(1, V[1], Cnt[1]);
	for (int i = 1;i <= N;++i)
		printf("%lld\n", Ans[i] += Ans[i - 1]);
	return 0;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
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 fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
#define dame { printf("No\n"); return 0;}
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(998244353)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)


signed main(){
    int n;
    string s;
    cin >> n >> s;
    int A[n + 1];
    int tmp = 0;
    REPR(i,n-1){
        if(s[i] == '.'){
            tmp ++;
        }
        A[i] = tmp;
    }
    int all_white = A[0];
    int all_black = n - all_white;
    int res = 3000000;
    A[n] = 0;
    REP(i,n + 1){
        res = min( A[i] + all_black - (n - i - A[i]) , res);
    }
    cout << res << endl;


}


Measured memory_bytes: 2180
n, d = map(int, input().split())
x = [list(map(int, input().split())) for i in range(n)]
ans = 0
for i in range(n - 1):
    for j in range(i + 1, n):
        sum = 0
        for k in range(d):
            sum += (x[i][k] - x[j][k]) ** 2
        for k in range(200):
            if k ** 2 == sum:
                ans += 1
                break
print(ans)


Measured memory_bytes: 3060
#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(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int m, f, r;
	while (true) {
		cin >> m >> f >> r;
		if (m == -1 && f == -1 && r == -1) break;
		if (m == -1 || f == -1) {
			puts("F");
		} else if (m + f >= 80) {
			puts("A");
		} else if (m + f >= 65) {
			puts("B");
		} else if (m + f >= 50) {
			puts("C");
		} else if (m + f >= 30 && r >= 50) {
			puts("C");
		} else if (m + f >= 30) {
			puts("D");
		} else {
			puts("F");
		}
	}
}

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



Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A;
  string op;
  cin >> N >> A;
 
  if (N % 500 <= A ) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  }

Measured memory_bytes: 3604
from collections import deque

INF=float('inf')

n=int(input())
g=[[] for _ in range(n)]
for _ in range(n-1):
    u,v,w=map(int,input().split())
    g[u-1].append((v-1,w))
    g[v-1].append((u-1,w))

q,k=map(int,input().split())
ds=[INF]*n
ds[k-1]=0
que=deque()
que.append((k-1,0))
while len(que):
    u,d=que.popleft()
    for v,w in g[u]:
        if ds[v]==INF:
            ds[v]=d+w
            que.append((v,d+w))

for _ in range(q):
    u,v=map(int,input().split())
    print(ds[u-1]+ds[v-1])


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


int main(){
    int N,K;
    cin >> N >> K;
    double ans=0;
    for(int i=1; i<=N; i++){
        int point=i;
        double anss=1.0;
        while(point < K){
            point = point*2;
            anss = anss*0.50;
        }
        ans += anss/N;
    }
    printf("%.12f\n",ans);
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ts cout<<"ok"<<endl
#define int long long
#define hh puts("")
#define pc putchar
#define mo 1000000007
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
//char buf[1<<21],*p1=buf,*p2=buf;
using namespace std;
const int N=4000005,M=2005;
int n,k,jc[N],ny[N],f[M][M];
inline int read(){
    int ret=0,ff=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-') ff=-1;ch=getchar();}
    while(isdigit(ch)){ret=ret*10+(ch^48);ch=getchar();}
    return ret*ff;
}
void write(int x){if(x<0){x=-x,pc('-');}if(x>9) write(x/10);pc(x%10+48);}
void writeln(int x){write(x),hh;}
void writesp(int x){write(x),pc(' ');}
//总共n个白球,n*(k-1)个其他颜色球,时刻满足白球个数大于等于其余颜色个数 
//f[i][j]:放i个白球,用了j种颜色的方案 
int ksm(int x,int y){
	int res=1;
	while(y){
		if(y&1) res=res*x%mo;
		y>>=1;
		x=x*x%mo;
	}
	return res;
}
int C(int x,int y){
	return jc[x]*ny[y]%mo*ny[x-y]%mo;
}
signed main(){
	n=read(),k=read();
	if(k==1){
		write(1);
		return 0;
	}
	jc[0]=1;
	for(int i=1;i<=N-5;i++) jc[i]=jc[i-1]*i%mo;
	ny[N-5]=ksm(jc[N-5],mo-2);
	for(int i=N-6;i>=0;i--) ny[i]=ny[i+1]*(i+1)%mo;
	f[0][0]=1;
	for(int i=1;i<=n;i++){
		for(int j=0;j<=i;j++){
			f[i][j]=f[i-1][j];
			if(j>0) f[i][j]=(f[i][j]+f[i][j-1]*(n-j+1)%mo*C(n*k-i-(j-1)*(k-1)-1,k-2)%mo)%mo;
		}
	}
	write(f[n][n]);
    return 0;
}

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

int main() {
    int n, h, w;
    cin >> n >> h >> w;
    cout << (n - w + 1) * (n - h + 1) << endl;
}

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

int main(){
	int n,k,c[10],l[10],e[10000],d,a,b;
	while(true){
		cin>>n;
		cin>>k;
		if(n==0 && k==0){
			break;
		}
		for(int i=0;i<n;i++){
			cin>>c[i];
			if(c[i]>=10){
				l[i]=100;
			}
			else{
				l[i]=10;
			}
		}
		d=0;
		if(k==2){
			for(int i=0;i<n;i++){
				for(int j=0;j<n;j++){
					b=0;
					if(i!=j){
						a=c[i]*l[j]+c[j];
						for(int k=0;k<d;k++){
							if(a==e[k]){
								goto Exit1;
							}

						}
						e[d]=a;
						d++;
Exit1:
						a=0;
					}
				}
			}
		}

		if(k==3){
			for(int i=0;i<n;i++){
				for(int j=0;j<n;j++){
					for(int m=0;m<n;m++){
						b=0;
						if(i!=j && (j!=m && m!=i)){
							a=c[i]*(l[j]*l[m])+c[j]*l[m]+c[m];
							for(int k=0;k<d;k++){
								if(a==e[k]){
									goto Exit2;
								}
							}
							e[d]=a;
							d++;
Exit2:
							a=0;
						}

					}
				}
			}
		}

		if(k==4){
			for(int i=0;i<n;i++){
				for(int j=0;j<n;j++){
					for(int m=0;m<n;m++){
						for(int o=0;o<n;o++){
							b=0;
							if(((i!=j && o!=i) && (j!=m && m!=i)) && (o!=j && o!=m)){
								a=c[i]*(l[j]*l[m]*l[o])+c[j]*(l[m]*l[o])+c[m]*l[o]+c[o];
								for(int k=0;k<d;k++){
									if(a==e[k]){
										goto Exit3;
									}
								}
								e[d]=a;
								d++;
Exit3:
								a=0;
							}
						}

					}
				}
			}
		}

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

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

#define VMAX 10000 
#define M 2000001

int main()
{
  unsigned short *A, *B;

  int S[VMAX + 1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short) * n + 1);
  B = malloc(sizeof(short) * n + 1);

  for(i = 0; i <= VMAX; i++)
      S[i] = 0;
   
  for(i = 0; i < n; i++)
      scanf("%d",&A[i + 1]);
      
  for(i = 0; i < n; i++)
    S[A[i + 1]]++;
  
  for(i = 1; i <= VMAX; i++)
    S[i] = S[i] + S[i - 1];
 
  for(j = 1; j <= n; j++){
    B[S[A[j]]] = A[j];
    S[A[j]]--;
  }
 
  for(i = 1; i <= n; i++){
      if(i > 1)
	printf(" ");
      printf("%d", B[i]);
    }
  printf("\n");
  
  return 0;
}



Measured memory_bytes: 9652
#include<bits/stdc++.h>
using namespace std;
const int N=2e4+10;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int n,a[N];
int main() {
    cin>>n;
    for(int i=1;i<=n;i++) a[gi()]=i;
    for(int i=1;i<=n;i++) printf("%d ",30000*i);
    puts("");
    for(int i=1;i<=n;i++) printf("%d ",30000*(n-i+1)+a[i]);
    return 0;
}
//orzgzy
//鸡贼明年进队超稳


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int N;
vector<int> v;

int main() {
	cin >> N;
	v.resize(N);
	REP(i, N) cin >> v[i];
	
	vector<int> u(N);
	REP(i, N) cin >> u[i];
	
	REP(i, N) {
		if (v[i] > u[i]) {
			swap(v, u);
			break;
		}
		if (v[i] < u[i]) break;
	}
	
	int ans = -1;
	do {
		++ans;
		if (u == v) break;
	} while (next_permutation(ALL(v)));
	
	cout << ans << endl;
	
	return 0;
}


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

int main(){
    char b;
    cin >> b;
    if(b=='A') cout << 'T' <<endl;
    else if(b=='C') cout << 'G' <<endl;
    else if(b=='G') cout << 'C' <<endl;
    else cout << 'A' <<endl;
}

Measured memory_bytes: 256
// Daritys Morgho ban Rovegrie
// Math = ♥
// Sometimes it is people that no one imagines anything of who do things that no one can imagine
// After all this time? Always

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>		// uncomment before submission
//#include <ext/pb_ds/tree_policy.hpp>			// uncomment before submission
//using namespace __gnu_pbds;					// uncomment before submission
using namespace std;
//<---------------------------------------------------Template----------------------------------------------------------->
#define int long long
#define ll long long
#define ld long double
const int INF = 1e15 + 7;
const int MAX = 1e5 + 7;
const int MOD = 1e9 + 7;
typedef pair<ll, ll> ii;
typedef vector<ll> vi;                  // Vector of long long
typedef vector<vi> vvi;                 // Vector of vi
typedef vector<ii> vii;                 // Vector of pairs
typedef vector<vii> vvii;               // Vector of Vector of pairs
typedef vector<bool> vb;                // Vector of bool
#define pq priority_queue               // Max heap (To convert to min heap, use negative sign before every value)
#define ff first                        // For pairs
#define ss second                       // For pairs
#define pb push_back                    // Push back to vector
#define mp make_pair                    // Makes pairs to be stored as pair
#define endl "\n"                       // Changes endl to \n
#define all(c) (c).begin(), (c).end()   // Mainly used by me in sorting
#define range(c, r) (c).begin(), (c).begin() + (r)                // Mainly used in sorting
#define present(c, x) ((c).find(x) != (c).end())                  // for sets, maps, multi-maps
#define cpresent(c, x) (find(all(c),x) != (c).end())              // for vectors
#define testcases(t) int (t); cin>>(t); while((t)--)              // inputing testcases
#define run(x, c) for((x)=(c).begin(); (x)!=(c).end(); (x)++)     // Mainly used by me for range based loops
// ordered_set adds two new functions to set - (set).find_by_order([kth element based on zero indexing]) and order_of_key()
// order_of_key returns number of elements less that parameter. If element exists, that order is its index
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
//<----------------------------------------------------------------------------------------------------------------------->

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;

    int A[n + 2];
    for (int i = 1; i <= n; i++) cin >> A[i];
    A[0] = A[n + 1] = 0;

    int s = 0;
    for (int i = 0; i <= n; i++) s += labs(A[i] - A[i + 1]);

    int S[n];
    for (int i = 1; i <= n; i++)
        S[i] = s + labs(A[i - 1] - A[i + 1]) - labs(A[i - 1] - A[i]) - labs(A[i] - A[i + 1]), cout << S[i] << endl;

    return 0;
}

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

int main(){
  int N, X;
  cin >> N >> X;
  vector<int> m(N);
  int sum = 0;
  for(int i = 0; i < N; i++){
    cin >> m[i];
    sum += m[i];
  }
  X -= sum;
  sort(m.begin(), m.end());
  int ans;
  ans = X / m[0] + N;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cctype>
#include <stdio.h>
using namespace std;
int main() {
    int n;
    string Ya, Ha;
    int Yscore = 0, Hscore = 0;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> Ya >> Ha;
        if(Ya > Ha) {
            Yscore += 3;
        }else if(Ya < Ha){
            Hscore += 3;
        }else if(Ya == Ha){
            Yscore++;
            Hscore++;
        }
    }
    cout << Yscore << " " << Hscore << endl; 
    return 0;
}

Measured memory_bytes: 3100
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")

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

#define pb push_back
#define F first
#define S second
#define f(i,a,b)  for(int i = a; i < b; i++)
#define endl '\n'
using ll = long long;
#define int ll
using db = long double;
using ii = pair<int, int>;

const int N = 1e5 + 5, LG = 19, MOD = 998244353;
const int SQ =320;
const long double EPS = 1e-7;
int ans[2005];
int n, x, y;
int32_t main(){
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif

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

  f(i,0,n)
    f(j,i+1,n){
      int mn = j - i;
      mn = min(mn,abs(i-x)+abs(j-y)+1);
      mn = min(mn,abs(i-y)+abs(j-x)+1);
      ans[mn]++;
    }

  f(i,1,n)cout<<ans[i]<<'\n';

  return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void){
	int A[100];
	int N,t,j;
	cin>>N;
	for(int i=0;i<N;i++) cin>>A[i];
	for(int k=0;k<N;k++){
		cout<<A[k];
		if(k!=N-1)cout<<" ";
		
	}
	cout<<endl;
	for(int i=1;i<N;i++){
		
		t=A[i];
		j=i-1;
		while(j>=0&&A[j]>t){
			A[j+1]=A[j];
			j--;
			A[j+1]=t;
		}
		for(int k=0;k<N;k++){
		cout<<A[k];
		if(k!=N-1)cout<<" ";
		
	}
		cout<<endl;
	}
	return 0;
}


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

int main(void){
    // Your code here!
   long long x,k,d,ans;
   cin>>x>>k>>d;
   x=abs(x);
   if(x/d > k){
       ans=abs(x-k*d);
   }
   else{
       long long e;
       e = x/d;
       k-=e;
       x-=d*e;
       if(k%2 == 1) x=abs(x-d); 
       ans = x;
      
   }
   
   cout<<ans<<endl;
}


Measured memory_bytes: 3588
import numpy as np
import sys
sys.setrecursionlimit(10**7)
n = int(input())
edge = [tuple(map(int,input().split()))for _ in range(n - 1)]
T = [[] for _ in range(n)]
for i,(a,b) in enumerate(edge):
  # 木といいつつ有向グラフのように処理
  T[a -1].append([b - 1,i])
  #T[b - 1].append([a - 1,i])
ans = [None] * (n - 1)
def rec(cur,color):
  cnt = 1
  for (to,j) in T[cur]:
    if cnt == color:
      cnt += 1
    ans[j] = cnt
    rec(to,cnt)
    cnt += 1
rec(0,0)
print(max(ans))
[print(a) for a in ans]

Measured memory_bytes: 87796
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define eb emplace_back
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 233;
ll f[maxn];
int main()
{
	int h,n;cin>>h>>n;
	for(int i=1;i<=30000;i++)f[i] = 1e18;
	for(int i=1;i<=n;i++){
		int a,b;cin>>a>>b;
		for(int j=a;j<=30000;j++)
			f[j] = min(f[j],f[j-a]+b);
	}
	ll ans = 1e18;
	for(int i=h;i<=30000;i++)ans = min(ans,f[i]);
	cout << ans << endl;
}


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

int main(){

	int height[10];

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

	int sort[3]={0,0,0};
	int box;

	for(int i=0;i<10;i++){
		if(height[i]>sort[2]){
			sort[2]=height[i];
			if(sort[1]<sort[2]){
				box=sort[1];
				sort[1]=sort[2];
				sort[2]=box;
				if(sort[0]<sort[1]){
				box=sort[0];
				sort[0]=sort[1];
				sort[1]=box;
				}
			}
		}
	}

	for(int i=0;i<3;i++){
		cout << sort[i] << endl;
	}

    return 0;
}


Measured memory_bytes: 3096
D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for i in range(D)]
t = [0]*D
for i in range(D):
    t[i] =int(input())
m=[0]*D
last_day=[0]*26
a=[[0 for i in range(26)] for j in range(D)]
for u in range(D):
    i=t[u]
    for y in range(u,D):
        a[y][i-1]=u+1
    if u==0:
        m[u]=s[u][i-1]
    else:
        m[u]=m[u-1]+s[u][i-1]
mm=[0]*D
for d  in range(D):
    for i in range(26):
        mm[d]+=c[i]*(d+1-a[d][i])
    if not d==0:
        mm[d]+=mm[d-1]
for d in range(D):
    m[d]-=mm[d]
    print(m[d])

Measured memory_bytes: 9652
#include<stdio.h>

int main()
{
	int a, b, d, r;
	double f, aa, bb;

	scanf("%d %d", &a, &b);

	d = a / b;
	r = a % b;

	aa = a;
	bb = b;

	f = aa / bb;

	printf("%d %d %f", d, r, f);

	return 0;
}

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

int main() {
    int k;
    char str[102];
    scanf("%d", &k);
    char hero[k];
    scanf("%s", str);
    
    if (k < strlen(str)){
        for (int i = 0; i < k; ++i){
            hero[i] = str[i];
        }
        hero[k] = '\0';
        printf("%s...\n", hero);
    }
    else 
        printf("%s\n", str);
    
    
    return 0;
}


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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N;
    Scd(N);

    vii x(N);
    queue<int> must;
    queue<int> free;
    vi ans(N*N);
    Rep(i,N){
        x[i].second = i+1;
        Scd(x[i].first);
        x[i].first--;
    }
    sort(x.begin(),x.end());
    Rep(i,N){
        Rep(j,x[i].second-1) must.push( x[i].second );
    }

    int ai = 0;
    bool OK = true;
    Rep(xi,N){
        int to = x[xi].first;
        while( ai < to ){
            if( must.size() ) ans[ai] = must.front(), must.pop();
            else if( free.size() ) ans[ai] = free.front(), free.pop();
            else OK = false;
            ai++;
            if( !OK ) break;
        }
        if( must.size() && must.front() == x[xi].second ) OK = false;
        ans[ai++] = x[xi].second;
        Rep(j,N-x[xi].second ) free.push( x[xi].second );
        if( !OK ) break;
    }
    while( free.size() ) ans[ai++] = free.front(), free.pop();


    YesNo(OK);
    if( OK ) Rep(i,N*N) printf("%d%c", ans[i], i == N*N-1 ? '\n' : ' ' );
    return 0;
}



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

int main(int argc, char *argv[])
{
    int N;
    std::cin >> N;
    if (N >= 1000) {
        std::cout << "ABD" << std::endl;
    } else {
        std::cout << "ABC" << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    int INF = Integer.MAX_VALUE;

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        long Q=sc.nextLong();
        long H=sc.nextLong();
        long S=sc.nextLong();
        long D=sc.nextLong();
        long N=sc.nextLong();
        long L1=Math.min(S,Math.min(4*Q,2*H));
        if(2*L1<D){
            System.out.println(N*L1);
        }else{
            long x=N/2;
            
            System.out.println(D*x+L1*(N%2));
        }
    }
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
struct edge{int from, to;};

int main(){
    int a, b;
    cin >> a >> b;
    int num;
    if(1<=b && b<10) num=a*10+b;
    else if(10<=b&&b<100) num=a*100+b;
    else num=a*1000+b;
    bool flag=false;
    for(int i=1;i<=sqrt(num);i++){
        if(i*i==num) flag=true;
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <array>
#define FOR(i,a,b) for(int i=(a);i<=(b);++i) 
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i) 
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>> 
#define CO cout<<
#define EN <<endl 
#define all(x) (x).begin(),(x).end() 
using namespace std;
template <typename T> istream & operator >> (istream & is, vector<T> & vec) { for (T& x : vec) is >> x; 	return is; }
using ll = long long;
using VI = vector<int>;

int main() {
	int n; string s; int k; CI n >> s >> k;

	REP(i, n) {
		if (s[i] != s[k-1]) s[i] = '*';
	}

	CO s EN;

	return 0;
}

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

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int N;
cin>>N;
if(N%2==0)cout<<(N/2)/float(N)<<endl;
else cout<<((N+1)/2)/float(N)<<endl;
//system("pause");
return 0;
}

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

using namespace std;

constexpr int64_t kMod = 1e9+7;

int main() {
  int S;
  cin >> S;
  vector<int64_t> dp(S+1);
  dp[0] = 1;
  for (int s = 3; s <= S; ++s) {
    for (int i = s-3; i >= 0; --i) {
      dp[s] += dp[i];
      dp[s] %= kMod;
    }
  }
  cout << dp[S] << endl;

  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define MODNum 1000000007
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    ll N, K, ans;
    ll R, S, P;
    string T;
    scanf("%lld %lld", &N, &K);
    scanf("%lld %lld %lld", &R, &S, &P);
    cin >> T;
    ans = 0;
    REP(int, i, 0, N){
        if ( T.at(i) == 'r' ) ans += P;
        else if ( T.at(i) == 's' ) ans += R;
        else if ( T.at(i) == 'p' ) ans += S;
    }
    char prev;
    for ( int j = 0; j < K; j++ ){
        int Flag = 0;
        for ( int i = j; i < N; i = i + K ){
            if ( i == j ) prev = T.at(i);
            else if ( T.at(i) == prev && Flag == 0 ){
                if      ( T.at(i) == 'r' ) ans -= P;
                else if ( T.at(i) == 's' ) ans -= R;
                else if ( T.at(i) == 'p' ) ans -= S;
                Flag = 1;
            }
            else{
                prev = T.at(i);
                Flag = 0;
            }
        }
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<map>
int main(){
  int n,i,a[100001];
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&a[i]);
  }

  std::map<long long,long long> b;
  for(i=1;i<=n;i++){
    b[a[i]]++;
  }
  long long x=0;
  for(auto it =b.begin();it != b.end();it++){
    long long num=it ->first;
    long long cnt=it ->second;
    if(cnt>=num){
      x=x+cnt-num;
    }
    else{
      x=x+cnt;
    }
  }

    printf("%lld",x);

    return 0;
}



Measured memory_bytes: 6656
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>
using namespace std;


const long long int mod=1000000007;
const long long int INF=99999999999999999;



long long int H,res=0,now=1;
int main() {
	cout << fixed << setprecision(18);
	
	cin>>H;
	while(H!=0){
		res+=now;
		H/=2;
		now*=2;
	}
	cout<<res;
} 

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long int ll;
static const int MAX_N = 100000;

int N; ll T; int Q;
ll A[MAX_N]; int D[MAX_N];
ll ans[MAX_N];

int main(){
	cin >> N >> T >> Q;
	for(int i = 0; i < N; i++) cin >> A[i] >> D[i];
	if(D[0] == 2) ans[0] = A[0] - T;
	if(D[N - 1] == 1) ans[N - 1] = A[N - 1] + T;
	for(int i = 0; i < N - 1; i++){
		if(D[i] == 1 && D[i + 1] == 2){
			ans[i] = min((A[i] + A[i + 1]) / 2, A[i] + T);
			ans[i + 1] = min((A[i] + A[i + 1]) / 2, A[i + 1] - T);
		}
	}
	for(int i = 1; i < N; i++){
		if(D[i] == 2) ans[i] = max(ans[i - 1], A[i] - T);
	}
	for(int i = N - 2; i >= 0; i--){
		if(D[i] == 1) ans[i] = min(ans[i + 1], A[i] + T);
	}
	for(int i = 0; i < Q; i++){
		int x;
		cin >> x;
		x--;
		cout << ans[x] << endl;
	}
	return 0;
}



Measured memory_bytes: 5024
#include<bits/stdc++.h>
using namespace std;
 
#define cinsc ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOR(i,k,n)  for(int64 i=k;i<(int64)n;i++)
#define FORr(i,k,n)  for(int64 i=(int64)k;i>=n;i--)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define FOREACHr(it, l) for (auto it = l.rbegin(); it != l.rend(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define SQ(x) ((x)*(x))
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
const int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const int dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddx[4] = {1,0,-1,0};
const int ddy[4] = {0,1,0,-1};
//ONLINE_JUDGE   LOCAL
 
int64 powr(int64 x,int64 y,int64 p)  
{  
    int res = 1;    
    x = x % p; 
    if (x == 0) return 0;
    while (y > 0){   
        if (y & 1)  
            res = (res*x) % p;   
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
} 
 
void  in_o(){
#ifndef LOCAL
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	cinsc;
}

int main(){
	//in_o();
	int h,w;
	cin>>h>>w;
	string s[h];
	FOR(i,0,h){
		cin>>s[i];
	}
	FOR(i,0,h){
		FOR(j,0,w){
			int cnt=0;
			if(s[i][j]=='.') continue;
			FOR(k,0,4){
				int x=i+ddx[k];
				int y=j+ddy[k];
				if(s[x][y]=='#') cnt++;
			}
			if(!cnt) return cout<<"No"<<endl,0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define mod 1000000007
#define maxN 200005

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

}



int main()
{

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	{
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	}
#endif
	string s;
	cin >> s;
	int n = 0;
	for (int i = 0; i < s.size(); i++) {
		n += (s[i] - '0');
	}
	if (n % 9) {
		cout << "No" << endl;
	} else {
		cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 3668
#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;

int main(){
    int n, m, q, A[100100];
    scanf("%d", &n);
    for (int i=0;i<n;i++) scanf("%d", &A[i]);
    cin >> m;
    int sum = 0;
    for (int i=0;i<m;i++){
        scanf("%d", &q);
        if (*lower_bound(A, A+n, q) == q) sum++;
    }
    cout << sum << endl;
}



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

#define IOS		    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ld 		    long double
#define ll 		    long long int
#define ull 	   	unsigned long long int
#define pb		    push_back
#define mp		    make_pair
#define F		    first
#define S		    second
#define lb		    lower_bound
#define ub		    upper_bound
#define deb(x)      cout<<"#x "<<x<<"\n";
#define trace(x,y)  cout<<"#x "<<x<<" #y "<<y<<"\n";


const int mod = 1e9;
ll a, b, n;
ll cmp(ll x){
    return (ll)floor((ld)(a*x)/b) - (ll)a*((ll)floor((ld)x/b));
}


int main(){
    IOS;
    cin >> a >> b>> n;
    long long int  l = 0, r = n, mid;
    long long int ans = LONG_MIN;
    while(l<=r){
        mid = l + (r-l)/2;
        ll val = cmp(mid);
        if(val >= ans){
            ans = val;
            l = mid+1;
        }
        else r= mid-1;
    }
    cout<<ans<<"\n";
return 0;
}


Measured memory_bytes: 3584
x, y = map(int, input().split())
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]

if (x in a and y in a) or (x in b and y in b) or (x in c and y in c):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9048
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>
#define _USE_MATH_DEFINES

const long INF = (1l << 30);
const long LINF = (1l << 60); //1.15*10^18

long n, k;

int main(){
    scanf("%ld%ld", &n, &k);
    printf("%ld\n", std::min(n % k, std::abs(n % k - k)));
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ALL(c) begin(c), end(c)
using namespace std;
using ll = long long;
using ld = long double;

const mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());



int main(){
	//freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout);
	ios::sync_with_stdio(0);cin.tie(0);//cout.precision(12);cout<<fixed;
	
	int d,t,s;
	cin>>d>>t>>s;
	
	cout<<(t*s>=d ? "Yes" : "No");
	
	return 0;
}


Measured memory_bytes: 3640
//temprates
#include <iostream>
#include <tuple>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>

using ll = long long;
using namespace std;

#define FOR(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
#define LFOR(i,a,b) for(ll i = (ll)(a); i <= (ll)(b); i++)
#define FORR(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define LFORR(i,a,b) for(ll i = (int)(a); i >= (ll)(b); i--)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define LREP(i,n) LFOR(i,0,(ll)(n)-1)
#define REPR(i,n) FORR(i,(int)(n)-1,0)
#define LREPR(i,n) LFORR(i,(ll)(n)-1,0)

#define SIZ(v) int(v.size())
const int INF = 1e8;
const ll LINF = 1e15;





int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  cout << (n-2)*180 << endl;
}


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

long long int sx, sy, tx, ty, i;

int main(){
    scanf("%lld%lld%lld%lld", &sx, &sy, &tx, &ty);
    for(i = sy; i < ty; ++i){
        cout << 'U';
    }
    for(i = sx; i < tx; ++i){
        cout << 'R';
    }
    cout << 'D';
    for(i = sx + 1; i < tx; ++i){
        cout << 'L';
    }
    for(i = sy + 1; i < ty; ++i){
        cout << 'D';
    }
    cout << "LL";
    for(i = sy; i < ty + 1; ++i){
        cout << 'U';
    }
    for(i = sx; i < tx + 1; ++i){
        cout << 'R';
    }
    cout << "DRDD";
    for(i = sx + 1; i < tx; ++i){
        cout << 'L';
    }
    for(i = sy + 1; i < ty; ++i){
        cout << 'D';
    }
    cout << "LLU" << endl;
    return 0;
}


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

using namespace std;

int N;
vector<int> G[100005];

int dfs(int v, int prev)
{
	int res, ret = 0;
	for(int i = 0; i < G[v].size(); i++){
		if(G[v][i] == prev) continue;
		res = dfs(G[v][i], v);
		if(res == -1) return -1;
		ret += res;
	}
	if(ret >= 2) return -1;
	if(ret == 1) return 0;
	if(ret == 0) return 1;
}

int main(void)
{
	cin >> N;
	int a, b;
	for(int i = 0; i < N-1; i++){
		cin >> a >> b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	
	if(dfs(1, -1)){
		cout << "First" << endl;
	}
	else{
		cout << "Second" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 5888
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>
#include<unordered_map>
#include<deque>
#include<cmath>





using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const ll INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
const ll mod = 1000 * 1000 * 1000 + 7;


void solve() {
    int n, k, s;
    cin >> n >> k >> s;
    int x = s + 1;
    if (s == 1000000000)
        x = 1;
    for (int i = 0; i < k; ++i) {
        cout << s << " ";
    }
    for (int i = k; i < n; ++i)
        cout << x << " ";
    cout << endl;
}


//#define LOCAL

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



#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}


Measured memory_bytes: 1280
import sys
sys.setrecursionlimit(10 ** 6)  # 再帰関数の再帰の深さを設定
to_index = lambda x: int(x) - 1  # 入力した数字に1を引いたものを返す
print_list_in_2D = lambda x: print(*x, sep="\n")  # リストの要素を改行を挟んで表示する関数

# 入力を整数に変換して受け取る
def input_int():
    return int(input())

def map_int_input():
    return map(int, input())

MII = map_int_input

def MII_split():
    return map(int, input().split())

def MII_to_index():
    return map(to_index, input())

def MII_split_to_index():
    return map(to_index, input().split())

# 入力全てを整数に変換したものの配列を受け取る
def list_int_inputs():
    return list(map(int, input()))

LII = list_int_inputs

def LII_split():
    return list(map(int, input().split()))

# 2次元リスト化
def LII_2D(rows_number):
    return [LII() for _ in range(rows_number)]

def LII_split_2D(rows_number):
    return [LII_split() for _ in range(rows_number)]

N = input_int()
As = LII_split()

count = 0
ps = dict()
ms = dict()
for i in range(N):
    p = i + 1 + As[i]
    if p in ps:
        ps[p].append(i)
    else:
        ps[p] = [i]
    m = i + 1 - As[i]
    if m in ms:
        ms[m].append(i)
    else:
        ms[m] = [i]


for m, m_indicies in ms.items():
    if m not in ps:
        continue
    else:
        p_indicies = ps[m]
        count += len(p_indicies) * len(m_indicies)

print(count)

Measured memory_bytes: 91012
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0) {
				break;
			}
			int max = 0;
			int[][][] map = new int[n + 1][n + 2][4];
			for (int i = 1; i < n + 1; i++) {
				char[] line = scanner.next().toCharArray();
				for (int j = 1; j < n + 1; j++) {
					int a = line[j - 1] - '0';
					if (a == 1) {
						map[i][j][0] = map[i - 1][j - 1][0] + 1;
						map[i][j][1] = map[i - 1][j][1] + 1;
						map[i][j][2] = map[i - 1][j + 1][2] + 1;
						map[i][j][3] = map[i][j - 1][3] + 1;
						for (int k = 0; k < 4; k++) {
							max = Math.max(max, map[i][j][k]);
						}

					}
				}
			}
			System.out.println(max);
		}
	}
}

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

int main() {

int N;
int X;
int L;

int sum=0;
int count=1;
scanf("%d",&N);
scanf("%d",&X);

while (N--){
	scanf("%d",&L);

	sum=sum+L;

	if(sum<=X){
	count=count+1;
}
}
printf("%d\n",count);
	

	// your code goes here
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

S=list(input().rstrip('\n'))

kake10 = [0,10,7,4,1,11,8,5,2,12,9,6,3]
now = {0:1,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:0,11:0,12:0}
for i in S:
  now = {kake10[x]:now[x] for x in range(13)}
  if i=='?':
    now2 = {x:sum(now[(x+y)%13] for y in range(4,14))%1000000007 for x in range(13)}
    now = now2
  else:
    a = int(i)
    now = {(x+a)%13:now[x] for x in range(13)}
print(now[5])

Measured memory_bytes: 9776
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
main(){
    int K,S;
    cin >> K >> S;
    int cnt = 0;
    for(int i = 0;i <= K;i++){
        for(int j = 0;j <= K;j++){
            if(S - i - j <= K && S - i - j >= 0)cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256