akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long int ll;

int main(){
    /*input*/
    char c[2][3];
    rep(i, 2)	rep(j, 3)   cin >> c[i][j];
    /*calculation*/
    /*output*/
    if(c[0][0] == c[1][2] && c[0][1] == c[1][1] && c[0][2] == c[1][0]){
	cout << "YES" << endl;
    }else{
	cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long i64;
const int P=1e9+7;
struct factor{
	int x,t,v;
	bool operator<(const factor&w)const{return x<w.x;}
}fs[3007];
int n,k,fp=0,ans=0;
void chk(int x){
	if(n&1)fs[fp++]=(factor){x,x+1>>1};
	else if(1&~(n/x))fs[fp++]=(factor){x,x};
}
int pw(int a,int n){
	int v=1;
	for(;n;n>>=1,a=i64(a)*a%P)if(n&1)v=i64(v)*a%P;
	return v;
}
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i*i<=n;++i)if(n%i==0){
		chk(i);
		if(i*i!=n)chk(n/i);
	}
	std::sort(fs,fs+fp);
	for(int i=0;i<fp;++i){
		fs[i].v=pw(k,fs[i].t);
		for(int j=0;j<i;++j)if(fs[i].x%fs[j].x==0){
			(fs[i].v-=fs[j].v)%=P;
		}
		ans=(ans+fs[i].v*i64(fs[i].x))%P;
	}
	printf("%d\n",(ans+P)%P);
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
const double PI = 3.1415926535897932;

int main()
{
	int N;
	cin >> N;
	vector<int> P(N, 0);
	vector<int> Q(N, 0);
	rep(i, N) {
		cin >> P[i];
	}
	rep(i, N) {
		cin >> Q[i];
	}

	vector<int> base;
	rep (i, N) {
		base.push_back(i + 1);
	}

	int pp = -1;
	int pq = -1;
	int cnt = 1;
	do {
		bool fpp = true;
		bool fpq = true;
		for (int i = 0; i < N; ++i) {
			if (P[i] != base[i]) fpp = false;
			if (Q[i] != base[i]) fpq = false;
		}

		if (fpp) pp = cnt;
		if (fpq) pq = cnt;
		cnt += 1;

	} while (std::next_permutation(base.begin(), base.end()));

	cout << abs(pq - pp) << endl;
	return 0;
} 


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


int main(){
	
	long long a,b,n;
	scanf("%lld %lld",&a,&b);
	for( long long i=a; i>0; i--) {
		if( a%i == 0 && b%i == 0) {
			n=i;
			break;
		}
	}
	printf("%lld",a*b/n);
	return 0;
	
}

Measured memory_bytes: 128
n=int(input())
a=list(map(int,input().split()))
ans = []
d=0
for j in range(n):
    d=0
    for i in range(len(a),0,-1):
        if a[i-1]==i:
            ans.append(i)
            del a[i-1]
            d+=1
            break
    if not d:
        break
if d:
    for i in ans[::-1]:
        print(i)
else:
    print(-1)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
typedef long long ll;
int main(void){
    int m;
    cin >> m;
    ll digit=0;
    ll sum=0;
    for(int i=0;i<m;i++){
        ll d,c;
        cin >> d >> c;
        digit += c;
        sum += d*c;
    }
    cout << (digit-1) + (sum-1)/9 << endl;
}


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

using namespace std;
#define ll long long

int main()
{
    //freopen("in.txt","r",stdin);
    long long h,w,a;
    cin>>h>>w;

    a=h*w;
    if(h==1 || w==1)
    {
        cout<<1<<endl;
        return 0;
    }
    if(a%2==0)
        cout<<a/2<<endl;
    else
    {
        a/=2;
        cout<<a+1<<endl;
    }




    return 0;
}


Measured memory_bytes: 256
from collections import deque
# 入力、初期化
N = int(input())
tree = [[] for _ in range(N)]
input_list = []
for _ in range(N - 1):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    input_list.append([a, b])
    tree[a].append(b)
    tree[b].append(a)


# visitedにノードの色を格納する
# visited_edge = [[0] * N for _ in range(N)]
dict = {}
'''
# bfsによる色付けを行う
def bfs(now_node, max_val=0):
    queue = deque([[tree[now_node], -1, now_node]])
    while queue:
        next_nodes, before_color, now_node = queue.pop()
        now_color = 1
        for next_node in next_nodes:
            if visited_edge[now_node][next_node] != 0:
                continue
            if now_color == before_color:
                now_color += 1
            if max_val < now_color:
                max_val = now_color
            visited_edge[next_node][now_node] = now_color
            visited_edge[now_node][next_node] = now_color
            queue.appendleft([tree[next_node], now_color, next_node])
            now_color += 1
    return max_val
'''
def bfs(now_node, max_val=0):
    queue = deque([[tree[now_node], -1, now_node]])
    while queue:
        next_nodes, before_color, now_node = queue.pop()
        now_color = 1
        for next_node in next_nodes:
            key = tuple(sorted([now_node, next_node]))
            if not dict.get(key) is None:
                continue
            if now_color == before_color:
                now_color += 1
            if max_val < now_color:
                max_val = now_color
            dict[key] = now_color
            # visited_edge[now_node][next_node] = now_color
            queue.appendleft([tree[next_node], now_color, next_node])
            now_color += 1
    return max_val

ans = bfs(0)
print(ans)
for a, b in input_list:
    # print(visited_edge[a][b])
    print(dict[tuple(sorted([a,b]))])


Measured memory_bytes: 47704
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<complex>
#include<sstream>
#include<climits>
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 1e5;
int N, H, W;
int a[MAX_N], b[MAX_N];
ll ans[10];

int main() {
  cin >> H >> W >> N;
  rep(i,N) cin >> a[i] >> b[i];

  map<pii, int> squres;
  for (int i = 0; i < N; ++i) {
    for (int x = 0; x > -3; --x) {
      for (int y = 0; y > -3; --y) {
        int px = a[i]+x, py = b[i]+y;
        if (0 < px && px < H-1 && 0 < py && py < W-1) squres[pii(px, py)]++;
      }
    }
  }

  for (map<pii, int>::iterator it = squres.begin(); it != squres.end(); ++it) {
    ans[it->second]++;
  }
  for (int i = 1; i < 10; ++i) ans[0] += ans[i];
  ans[0] = (ll)(H-2)*(ll)(W-2) - ans[0];

  for (int i = 0; i < 10; ++i) {
    printf("%lld\n", ans[i]);
  }

  return 0;
}


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

string a, b;

int main()
{
    ios::sync_with_stdio(false);
    cin >> a >> b;
    int len = a.length();
    int ans = 0;
    for (int i = 0; i < len; i++)
    {
        if (a[i] != b[i])
            ans++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3904
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    a,b,c = LI()
    if a <= c <= b:
        print("Yes")
    else:
        print("No")
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 38512
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define printd(val) std::cout<< #val" = " <<val<<"\n";
#include<bits/stdc++.h>
using ll = long long;
using pii = std::pair<ll,ll>;
using namespace std;
template<class T>T chmin(T& a,T b){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template<class T>T chmax(T& b,T a){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template <class T> T gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T lcm(T a, T b){return a * b / gcd(a, b);}

template<class T> vector<pair<T,T>> duplicator(const vector<T>& input){
    vector<pair<T,T>> out(input.size()-1);
    rep(i,input.size()-1){
        out[i].first =input[i  ];
        out[i].second=input[i+1];
    }
    return(out);
}
vector<char> String_to_vector_char(const string& input){
    vector<char> out(input.size());
    rep(i,input.size()){
        out[i]=input[i];
    }
    return out;
}

ll a,x;
void input(){
    cin>>x>>a;
}
void src(){
    cout<<((x>=a? 10:0));
}

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define FOR(i, a, b) for(ll i=(a); i < (ll)(b); ++i)
template<class T> inline bool chmax(T& a, T b) { if(a < b){ a=b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if(a > b){ a=b; return 1; } return 0;}

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	REP(i,n) cin >> a[i];
	
	int c4=0,c2=0,odd=0;
	REP(i,n){
		if(a[i]%4==0) c4++;
		else if(a[i]%2==0) c2++;
		else odd++;
	}
	
	if(c4==n/2 && n - c4 == odd){
		cout << "Yes\n";
	}else if(odd > c4){
		cout << "No\n";
	}else{
		cout << "Yes\n";
	}
	
	return 0;
}

Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace  std ;
#define       sf scanf
#define      pf printf
#define   pb push_back
#define   mp make_pair
typedef long long  ll;
const int MOD = 1e9+7;
const int   N = 1e6+7;
const ll  INF =  1e18;

#define nr()    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll ar[5000005],br[500005];

int32_t main()
{
    nr();
    ll T, n, nb=0, r;
    cin >> n;
    bool AS=true;
    for(ll i=1; i<=n; ++i)
    {
        cin >> r;
        if(r%2==0)
        {
            if(r%3==0 || r%5==0)
            {
                AS=true;
            }
            else
            {
                AS=false;
                break;
            }
        }
    }
    if(AS)
        cout<<"APPROVED"<<endl;
    else
        cout<<"DENIED"<<endl;
}


Measured memory_bytes: 256
local s = io.read("n")
if s == 1 or s == 2 then
  print(4)
else
  local i = 1
  while true do
    if s == 4 then
      print(i + 3)
      break
    end
    i = i + 1
    if (s % 2 == 0) then
      s = s // 2
    else
      s = s * 3 + 1
    end
  end
end


Measured memory_bytes: 760
from collections import deque, defaultdict

def main():
  directs = ((-1, 0, 1, 0), (1, 0, -1, 0), (0, 1, 0, 1), (0, -1, 0, -1))
  while True:
    w, h = map(int, input().split())
    if w == 0:
      break
  
    mp_l = ["#" * (w + 2)]
    mp_r = ["#" * (w + 2)]
    for _ in range(h):
      l, r = input().split()
      l = "#" + l + "#"
      r = "#" + r + "#"
      mp_l.append(l)
      mp_r.append(r)
    mp_l.append("#" * (w + 2))
    mp_r.append("#" * (w + 2))
    
    for y in range(1, h + 1):
      for x in range(1, w + 1):
        if mp_l[y][x] == "L":
          start_l = (x, y)
        if mp_r[y][x] == "R":
          start_r = (x, y)
    
    dic = [[[[None] * (h + 2) for _ in range(w + 2)] for _ in range(h + 2)] for _ in range(w + 2)]
    def search():
      que = deque()
      app = que.append
      pop = que.popleft
      app((start_l[0], start_l[1], start_r[0], start_r[1]))
      dic[start_l[0]][start_l[1]][start_r[0]][start_r[1]] = True
      while que:
        lx, ly, rx, ry = pop()
        for ldx, ldy, rdx, rdy in directs:
          ltx, lty, rtx, rty = lx + ldx, ly + ldy, rx + rdx, ry + rdy
          if mp_l[lty][ltx] != "#":
            lnx, lny = ltx, lty
          else:
            lnx, lny = lx, ly
          if mp_r[rty][rtx] != "#":
            rnx, rny = rtx, rty
          else:
            rnx, rny = rx, ry
          tmp = dic[lnx][lny][rnx]
          if not tmp[rny]:
            tmp[rny] = True
            lsym, rsym = mp_l[lny][lnx], mp_r[rny][rnx]
            if lsym == "%":
              if rsym == "%":
                print("Yes")
                return
            elif rsym != "%":
              app(((lnx, lny, rnx, rny)))
      print("No")
      return
    search()
 
main()


Measured memory_bytes: 151948
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string wkWd,wd,wd1,wd2;
    int cnt, wkNum;
    
    while(cin >> wkWd, wkWd!="-"){
        wd = wkWd;
        cin >> cnt;
        for(int i=0; i<cnt;i++){
            cin >> wkNum;
            wd1 =  wd.substr(wkNum);
            wd = wd1 + wd.substr(0,wkNum);
        }
        cout << wd << endl;
    }
    
}



Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define pp pair<ll,ll>
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
int inf=1000001000;
ll INF=1e18;
ll mod=1000000007;
ll MOD=INF;

int main() {
    int n;
    cin >> n;
    vector<int> a(n),b(n);
    int c=0,ans=0;
    rep(i,n) cin >> a[i] >> b[i];
    rep(i,n){
        if (a[i]==b[i]) c++;
        else c=0;
        ans=max(ans,c);
    }
    if (ans>=3) cout << "Yes" << endl;
    else cout<< "No" << endl;
}


Measured memory_bytes: 3628
#include <string>
#include <iostream>
#include <vector>
#include <sstream>
#include <istream>
#include <algorithm>
#include <functional>
#include <unordered_map>
#include <utility>
#include <iomanip>

using namespace std;

#ifdef _MSC_VER
#define scanf scanf_s
#define KEYWAIT getchar();getchar();
#else
#define KEYWAIT
#endif

int main()
{
    int a,b,c,d;

    cin >> a;
    cin >> b;
    cin >> c;
    cin >> d;

    cout << min(a, b) + min(c, d) << endl;

    KEYWAIT

    return 0;
}


Measured memory_bytes: 256
N = int(input())

ac = 0
wa = 0
tle = 0
re = 0

for i in range(N):
    s = input()
    if s == "AC":
        ac += 1
    elif s == "WA":
        wa += 1
    elif s == "TLE":
        tle += 1
    else:
        re += 1

print("AC x %s" % ac)
print("WA x %s" % wa)
print("TLE x %s" % tle)
print("RE x %s" % re)


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

typedef long long int lli;
#define int lli
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<lli> vli;
typedef vector<pii> vii;

const int MOD	= 1e9 + 7;
const double PI = acos(-1.0);

#define fastio			ios_base::sync_with_stdio(false);cin.tie(0)
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(c) (c).begin(),(c).end()
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define endl "\n"
#define error_old(x) cerr << #x << " = " << (x) << endl
#define errorp(p) cerr << #p << " = " << (p.first) << ", " << (p.second) << endl
#ifdef DEBUG
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {it++;}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cerr << *it << " = " << a << endl; err(++it, args...); }
#else
#define error(args...)
#endif
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template <typename T> T lcm(T a, T b){return (a*b)/gcd(a,b); }

const int nax = 3005;
int dp[nax][nax];
int val[nax];

int rec(int i, int j){
    if(dp[i][j] != -1){
        return dp[i][j];
    }
    if(i > j){
        return 0;
    }

    dp[i][j] = max(val[i] - rec(i + 1, j), val[j] - rec(i, j - 1));

    return dp[i][j];
}

void solve(){
    // dp[i][j][who] : substring [i, j] and it is turn of who;
    int n;
    cin >> n;
    rep(i, n){
        cin >> val[i];
    }
    rep(i, n){
        rep(j, n){
            dp[i][j] = -1;
        }
    }

    cout << rec(0, n - 1) <<  endl;
}

signed main(){
    #ifdef DEBUG
		freopen("test", "r", stdin);
	#endif
    fastio;
    
    solve();

    return 0;
}


Measured memory_bytes: 70912
H,W = map(int,input().split())
S = [input().split() for _ in range(H)]
x = ""
for i in range(H):
    for j in range(W):
        if S[i][j]=="snuke":
            x = (i,j)
            break
    if x!="":break
a = str(i+1)
b = chr(65+j)
print(b+a)

Measured memory_bytes: 38256
package main

import (
	"fmt"
)

func main() {
	var s string

	fmt.Scan(&s)

	if s == "SSS" {
		fmt.Print("0")
	} else if s == "SSR" || s == "SRS" || s == "RSS" || s == "RSR" {
		fmt.Print("1")
	} else if s == "SRR" || s == "RRS" {
		fmt.Print("2")
	} else if s == "RRR" {
		fmt.Print("3")
	}
}


Measured memory_bytes: 1768
import queue

"""
N = int(input())
#S = input()
# (N,M) = (int(i) for i in input().split(" "))
# A = [int(i) for i in input().split()]
A = []
for i in range(N):
	A.append(int(input()))

print(A)

"""
(N,M) = (int(i) for i in input().split(" "))
if N>=10 or M>=10:
	print(-1)
else:
	print(N*M)


Measured memory_bytes: 3952
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const int INF = 2000000000;
using namespace std;

const int sqrtN = 512;

class sqdiv{
    public:
        int N, K;
        vector<int> data;
        vector<int> bkt;
        sqdiv(int n){ //?????±???????????????????????´
            N = n;
            K = (N + sqrtN - 1) / sqrtN;
            data.assign(K * sqrtN, 0);
            bkt.assign(K, 0);
        }
        void add(int x, int y, int a){
            rep(k,K){
                int l = k * sqrtN, r = (k + 1) * sqrtN;
                if(r <= x || y <= l) continue;
                if(x <= l && r <= y){
                    bkt[k] += a;
                }else{
                    for(int i = max(x, l); i < min(y, r); i++){
                        data[i] += a;
                    }
                }
            }
        }
        int find(int a){
            int k = a / sqrtN;
            return data[a] + bkt[k];
        }
};

int main(){
    int n,q;
    cin >> n >> q;
    sqdiv ob(n);
    rep(i,q){
        bool com;
        int a, b, c;
        cin >> com;
        if(com){
            cin >> a;
            cout << ob.find(a) << endl;
        }else{
            cin >> a >> b >> c;
            ob.add(a,b + 1,c);
        }
    }
}

Measured memory_bytes: 3328
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <utility>
using ll = long long int;
using namespace std;
double pi = 3.141592653589793238;

#define FOR(i,N) for(int i=0;i<N;i++)
#define pb(x) push_back(x)

int main() {
	int A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;

	cout << min({ max(X, Y) * 2 * C ,2 * C * X + B * max(Y - X, 0),2 * C * Y + A * max(X - Y, 0),X * A + Y * B });
	
}

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


int main(){
    vector<int> num(3);
    for(int i=0;i<num.size();i++){ cin >> num.at(i); }
    bool go_siti_go = true;
    
    for(int i=0;i<num.size();i++){
        if(num.at(i) != 5 && num.at(i) != 7){
            go_siti_go = false;
            break;
        }
    }
    if(go_siti_go == true){
        int sum = 0;
        for(int i=0;i<num.size();i++){ sum += num.at(i); }
        if(sum != 17){ go_siti_go = false; }
    }
    
    if(go_siti_go){ cout << "YES" << endl; }
    else{ cout << "NO" << endl; }
    return 0;
}


Measured memory_bytes: 256
#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#ifndef bits/stdc++.h
  #include <bits/stdc++.h>
#endif /* end of include guard */

using namespace std;


#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    char c;cin >> c;
    int a = c - 'A';
    if(a <= 26)cout << "A" << endl;
    else{
        cout << "a" << endl;
    }
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>

#define pb push_back
#define mp make_pair
#define taskname "A"

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef tree <int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

const int maxn = 1e5 + 5;
const int mod = 1e9 + 7;

int d;
ll ans = 0;
ll p[20];

ll Cal(int i , ll d , int len){
    if(i == len / 2)return (d == 0 ? ((len & 1) ? 10 : 1) : 0);
    ll tmp = p[len - i - 1] - p[i];
    ll tmp1 = d / tmp;
    ll ans = 0;
    if(tmp1 >= -9 && tmp1 <= 9)ans += Cal(i+1,d-tmp*tmp1,len) * (10 - abs(tmp1) - (i == 0));
    tmp1 += (d >= 0 ? 1 : -1);
    if(tmp1 >= -9 && tmp1 <= 9)ans += Cal(i+1,d-tmp*tmp1,len) * (10 - abs(tmp1) - (i == 0));
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen(taskname".INP","r")){
		freopen(taskname".INP", "r",stdin);
		freopen(taskname".OUT", "w  ",stdout);
    }
    p[0] = 1;
    for(int i = 1 ; i <= 19 ; ++i)p[i] = p[i - 1] * 10;
    int d;cin >> d;
    for(int i = 1 ; i <= 18 ; ++i)ans += Cal(0,d,i);
    cout << ans;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int[] L = new int[N];
    for (int i = 0; i < N; i++) {
      L[i] = Integer.parseInt(sc.next());
    }
    
    int sum = 0;
    int max = 0;
    for (int i = 0; i < N; i++) {
      sum += L[i];
      if (L[i] > max) {
        max = L[i];
      }
    }
    
    sum = sum - max;
    if (sum > max) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 21844
integer N,K
character(10**5) S
integer x,y
integer ans
read*,N,K
read*,S

x=0;y=0
if (s(1:1) =="L")y=y+1
if (s(N:N) =="R")y=y+1
do i=1,N-1
  if( s(i:i)=="R" .and. s(i+1:i+1) == "L")x=x+1
end do

if(K<X)then
  ans = n - (2*(x-k) + y)
else if(X==K.and.Y==2)then
  ans = n - 2
else
  ans = n - 1
endif 

print"(i0)",ans
end

Measured memory_bytes: 768
#include<iostream>
#include<cmath>
#include<vector>
#include<bitset>
#include<bitset>
#include<string>
#include<utility>
#include<queue>
#include<algorithm>

using namespace std;
int mpown(int m,int n);
int bitCount(int bits);
int main(){
    int n,a,b,c;
    cin >> n>>a>>b>>c;
    vector<int> l(n);
    for(int i=0;i<n;i++)cin >> l.at(i);
    // sort(l.begin(),l.end());
    int fora,forb,forc;
    int foran,forbn,forcn;
    vector<int> cond(n,0);
    int minmp=1000*10;
    int mp;
    // cout << "a " << endl;
    for(int i=0;i<mpown(4,n);i++){
        int pos=0;
        while(i!=0){
            if(cond.at(pos)!=3){
                cond.at(pos)++;
                break;
            }
            else{
                cond.at(pos)=0;
                pos++;
            }
        }
        fora=0;forb=0;forc=0;
        foran=0;forbn=0;forcn=0;
        for(int i=0;i<n;i++){
            if(cond.at(i)==1){
                fora+=l.at(i);foran++;
            }else if(cond.at(i)==2){
                forb+=l.at(i);forbn++;
            }else if(cond.at(i)==3){
                forc+=l.at(i);forcn++;
            }
            
        }
        if(foran*forbn*forcn==0)continue;
        mp=(abs(fora-a)+(foran-1)*10)+(abs(forb-b)+(forbn-1)*10)+(abs(forc-c)+(forcn-1)*10);
        if(minmp > mp)minmp=mp;
    }
    cout << minmp << endl;

    return 0;
}

int bitCount(int bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);    //  2bitごとに計算
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);    //  4bitごとに計算
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);    //  8bitごとに計算
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);    //  16ビットごとに計算   
    return (bits & 0x0000ffff) + (bits >> 16);    //  32ビット分を計算   
}
int mpown(int m,int n){
    if(n==0)return 1;
    else if(n==1) return m;
    else{
        int temp=mpown(m,n/2);
        return temp*temp*(n&1?m:1);
    }
}

Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  i64 N, C;
  cin >> N >> C;
  vector<i64> xs(N);
  vector<i64> val(N);
  REP(i, N) { cin >> xs[i] >> val[i]; }

  auto solve = [&]() -> i64 {
    vector<i64> al(N + 1), ar(N + 1);
    vector<i64> bl(N + 1), br(N + 1);

    i64 xp = 0;
    REP(i, N) {
      al[i + 1] = al[i] + val[i] - (xs[i] - xp);
      bl[i + 1] = max(bl[i], al[i + 1] - xs[i]);
      xp = xs[i];
    }
    xp = C;
    REP(i, N) {
      int j = N - i - 1;
      ar[j] = ar[j + 1] + val[j] - (xp - xs[j]);
      br[j] = max(br[j + 1], ar[j] - (C - xs[j]));
      xp = xs[j];
    }
    i64 best = 0;
    REP(i, N + 1) {
      i64 t = al[i] + br[i];
      if (best < t) {
        best = t;
        // cerr << best << " : left exit at " << i << endl;
      }
      t = ar[i] + bl[i];
      if (best < t) {
        best = t;
        // cerr << best << " : right exit at " << (i + 1) << endl;
      }
    }
    return best;
  };
  cout << solve() << endl;
}

Measured memory_bytes: 4992
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	static List<Long> lunlun = new ArrayList<>();

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();

		for (int i = 1; i < 10; i++) {
			lunlun.add((long) i);
		}

		StringBuilder sb;

		int keta = 2;
		while(lunlun.size() < k) {
			for(int i = 1; i < 10; i++) {
				sb = new StringBuilder();
				sb.append(i);
				lun(keta, lunlun, i, sb);
			}
			keta++;
		}

		System.out.println(lunlun.get(k - 1));

		sc.close();
	}

	public static void lun(long n, List<Long> lunlun, int ini, StringBuilder sb) {
		if (n > 1) {
			if (ini == 0) {
				for (int i = 0; i < 2; i++) {
					lun(n - 1, lunlun, ini + i, sb.append(ini + i));
					sb.setLength(sb.length() - 1);
				}
			} else if (ini == 9) {
				for (int i = -1; i < 1; i++) {
					lun(n - 1, lunlun, ini + i, sb.append(ini + i));
					sb.setLength(sb.length() - 1);
				}
			} else {
				for (int i = -1; i < 2; i++) {
					lun(n - 1, lunlun, ini + i, sb.append(ini + i));
					sb.setLength(sb.length() - 1);
				}
			}
		} else {
			lunlun.add(Long.parseLong(sb.toString()));
		}
	}
}


Measured memory_bytes: 48708
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    map<string, int> mp;
    int N; cin >> N;

    REP(i, N){
        string s; cin >> s;
        if(mp.count(s)){
            int tmp = mp.at(s) + 1;
            mp.erase(s);
            mp.insert(make_pair(s, tmp));
        }
        else{
            mp.insert(make_pair(s, 1));
        }
    }

    int M; cin >> M;
    REP(i, M){
        string s; cin >> s;
        if(mp.count(s)){
            int tmp = mp.at(s) - 1;
            mp.erase(s);
            mp.insert(make_pair(s, tmp));
        }
        else{
            mp.insert(make_pair(s, 1));
        }
    }

    int res = 0;
    for(auto itr = mp.begin(); itr != mp.end(); ++itr){
        res = max(itr -> second, res);
    }
    cout << res << endl;

}

Measured memory_bytes: 256
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

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

    string ans = "No";
    if (a * b % 2 != 0) ans = "Yes";

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;

void solve1() {

}

void solve2() {

}

void solve3() {
	int N;
	cin >> N;
	map<int, int> mp;
	for (int i = 0; i < N; i++)
	{
		int a;
		cin >> a;
		mp[a]++;
	}
	

	int ans = 0;
	for (int i = 0; i <= 100000; i++)
	{
		ans = max(ans, mp[i - 1] + mp[i] + mp[i + 1]);
	}
	cout << ans << endl;
}

void solve4() {
	int N;
	cin>>N;
	vector<int> v;
	for(int i = 0; i < N;i++) {
		int p;
		cin>>p;
		v.push_back(p);
	}
	int ans = 0;
	for (int i = 0; i < v.size(); i++)
	{
		if(v[i]-1 == i) {
			int t = v[i];
			v[i] = v[i + 1];
			v[i + 1] = t;
			ans++;
		}
		
	}
	cout<<ans<<endl;
}

int main() {
	//solve1();
	//solve2();
	// solve3();
	solve4();

	return 0;
}

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

#define ll long long
#define ull unsigned long long

using namespace std;

const int INVALID = -1;
using Tree = vector<vector<int>>;
vector <ll> tot;
vector <ll> cnt;
// vector <int> p;
// vector <ll> x;

void dfs(const Tree& tree, int v, int p, ll val) {
	tot[v] = cnt[v] + val;
	for (auto nv : tree[v]){
		if (nv == p) continue;
		dfs(tree, nv, v, tot[v]);
	}
}

int main() {
	ll N, Q;
	cin >> N >> Q;

	Tree tree(N);
	for (int ii = 0; ii < N-1; ++ii){
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		tree[a].push_back(b);
		tree[b].push_back(a);
	}

	cnt.assign(N, 0);
	for (int ii = 0; ii < Q; ++ii){
		int p;
		ll x;
		cin >> p >> x;
		p--;
		cnt[p] += x;
	}

	//頂点0を根としてDFSしてカウンタの値を計算
	int root = 0;
	tot.assign(N, 0);
	dfs(tree, /*v=*/root, /*p=*/-1, 0);

	for (int ii = 0; ii < N; ++ii){
		cout << tot[ii] << " ";
	}
	cout << "\n";


	return 0;
}


Measured memory_bytes: 28928
#include <iostream>
#include <iomanip>
#include <cmath>

int main() {
    double x1, y1, x2, y2;
    std::cin >> x1 >> y1 >> x2 >> y2;
    std::cout << std::fixed << std::setprecision(8) << std::pow(std::pow(x1 - x2, 2) + std::pow(y1 - y2, 2), 0.5) << std::endl;
    return 0;
}


Measured memory_bytes: 3436
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

string S;
bool used[26];

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

  cin >> S;

  if (S == "zyxwvutsrqponmlkjihgfedcba") {
      cout << -1 << endl;
      return 0;
  }

  if (len(S) < 26) {
      for (int i = 0; i < len(S); ++i) {
          used[S[i]-'a'] = true;
      }
      for (int i = 0; i < 26; ++i) {
          if (!used[i]) {
              S += 'a'+i;
              break;
          }
      }
  } else {
      for (int i = len(S)-2; i >= 0; --i) {
          if (S[i] > S[i+1]) {
              used[S[i+1]-'a'] = true;
          } else {
              used[S[i+1]-'a'] = true;
              for (int j = S[i]-'a'; j < 26; ++j) {
                  if (used[j]) {
                      S[i] = 'a'+j;
                      S.resize(i+1);
                      break;
                  }
              }
              break;
          }
      }
  }

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


Measured memory_bytes: 888
n=int(input())
l=list(map(int,input().split()))
m=max(l)
l.remove(m)
if m%2!=0:
  med=(m+1)//2
else:
  med=m//2
mi=m
for ll in l:
  mi=min(mi,abs(ll-med))
if med+mi in l:
  print(m,med+mi)
else:
  print(m,med-mi)

Measured memory_bytes: 14052
#define _USE_MATH_DEFINES
#define INF 0x0f0f0f0f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};
 
static const double EPS = 1e-8;

int main(){
  int total_station;
  int total_road;
  int water_source_idx;
  int main_station1_idx;
  int main_station2_idx;
  while(~scanf("%d %d %d %d %d",
	       &total_station,
	       &total_road,
	       &water_source_idx,
	       &main_station1_idx,
	       &main_station2_idx)){
    if(total_station == 0) break;

    int nodes[101][101];
    memset(nodes,0x0f,sizeof(nodes));
    for(int i=1;i<=total_station;i++){
      nodes[i][i] = 0;
    }

    for(int i=0;i<total_road;i++){
      int from,to,cost;
      scanf("%d %d %d",&from,&to,&cost);
      nodes[from][to] = cost;
    }

    for(int k=1;k<=total_station;k++){
      for(int i=1;i<=total_station;i++){
	for(int j=1;j<=total_station;j++){
	  nodes[i][j] = min(nodes[i][k]+nodes[k][j],nodes[i][j]);
	}
      }
    }

    int res = INF;
    for(int i=1;i<=total_station;i++){
      res = min(nodes[water_source_idx][i]
		+ nodes[i][main_station1_idx]
		+ nodes[i][main_station2_idx],res);
    }

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

Measured memory_bytes: 1232
import java.util.*;

public class Main {
	final static int MOD = 1000000007;
	
	public static void main(String[] args) {
		MyScanner in = new MyScanner();
		int a = in.nextInt();
		int b = in.nextInt();
		
		int tapp = 1;
		int count = 0;
		
		while (tapp < b) {
			tapp--;
			tapp += a;
			count++;
		}
		
		System.out.println(count);
		
	}
	
	static class MyScanner {
		static Scanner sc = new Scanner(System.in);
		
		String next() {
			return sc.next();
		}
		
		String nextLine() {
			return sc.nextLine();
		}
		
		int nextInt() {
			return Integer.parseInt(sc.next());
		}
		
		double nextDouble() {
			return Double.parseDouble(next());
		}
		
		long nextLong() {
			return Long.parseLong(next());
		}
		
		int[] nextIntArray(int n) {
			int[] array = new int[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextInt();
			}
			return array;
		}
		
		double[] nextDoubleArray(int n) {
			double[] array = new double[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextDouble();
			}
			return array;
		}
		
		long[] nextLongArray(int n) {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}
			return array;
		}
		
		String[] nextLineArray(int n) {
			String[] array = new String[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLine();
			}
			return array;
		}
		
		int[][] nextIntMatrix(int n, int m) {
			int[][] matrix = new int[n][m];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++) {
					matrix[i][j] = nextInt();
				}
			}
			return matrix;
		}
		
		double[][] nextDoubleMatrix(int n, int m) {
			double[][] matrix = new double[n][m];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++) {
					matrix[i][j] = nextDouble();
				}
			}
			return matrix;
		}
		
		long[][] nextLongMatrix(int n, int m) {
			long[][] matrix = new long[n][m];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++) {
					matrix[i][j] = nextLong();
				}
			}
			return matrix;
		}
	}
}

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


void solve(std::string S){
    for(char i = 'a'; i <= 'z'; i++)
    {
        if(S.find(i) == string::npos){
            cout << i << endl;
            return;
        }
    }

    cout << "None" << endl;
    
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 512
#include "stdio.h"


int main()
{
    int n, a[100], j, x, c, i, mini,d;
    scanf("%d", &n);
    
    c = 0;
    for (i = 0; i <= n - 1; i++)
        scanf("%d", &a[i]);

    i = 0;

    for (i = 0; i <= n - 1; i++) {
        mini = i;
        for (j = i; j <= n - 1; j++) {
            if (a[j] < a[mini]) {
                mini = j;
                d = 1;
        }
        }
        if (d == 1) {
            x = a[i];
            a[i] = a[mini];
            a[mini] = x;
            c++;
        }
        d = 0;
        }
    

    j = 0;
    for (j = 0; j < n - 1; j++)
        printf("%d ", a[j]);

    printf("%d\n", a[n - 1]);
    printf("%d\n", c);
    return 0;
}

Measured memory_bytes: 1780
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
int n;
string s[10000];
int sl[10000];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    for(int i=0;i<n;i++) {
        cin>>s[i];
        sl[i]=s[i].length();
        s[i]=s[i].c_str();
    }
    int countab=0;
    int counta=0;
    int countb=0;
    int m=0;
    for(int i=0;i<n;i++){
        bool a=false;
        bool b=false;
        if(s[i][0]=='B'){
            countb++;
            b=true;
        }
        if(s[i][sl[i]-1]=='A') {
            counta++;
            a=true;
        }
        if(a==true&&b==true)m++;
        for(int j=0;j<sl[i]-1;j++){
            if(s[i][j]=='A'&&s[i][j+1]=='B'){
                countab++;
            }
        }
    }
    int ans=countab+min(counta,countb);
    if(counta==countb&&m==counta&&counta>0){
        ans--;
    }
    cout <<ans<< "\n";
}

Measured memory_bytes: 896
#include<cstdio>

using namespace std;
int main(){
    int a,b,g[5]={},f=1;
    for(int i=0;i<3;i++){
        scanf("%d%d",&a,&b);
        g[a]++;
        g[b]++;
    }
    for(int i=1;i<=4;i++){
        if(g[i]==0||g[i]==3){
            f=0;
        }
    }
    if(f){
        printf("YES\n");
    }
    else{
        printf("NO\n");
    }
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define mx 1000000
main()
{

    long long i,j,k,l,m,n,o,q,p;
   string s;
   while(cin>>s){
    j=0;
    l=s.size();
    for(i=0;i<l;i++)j+=(s[i]-48);
    if(j%9==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

   }
    return 0;
}




Measured memory_bytes: 3704
n, m = map(int, input().split())
resultList = [[0] * 2 for i in range(n)]
#print(resultList)
ansAC = 0
ansWA = 0
for i in range(m) :
    result = input().split()
    prob = int(result[0]) - 1
    if result[1] == 'AC' and resultList[prob][0] == 0 :
        resultList[prob][0]= 1
        ansAC += 1
        ansWA += resultList[prob][1]
    if result[1] == 'WA' and resultList[prob][0] == 0 :
        resultList[prob][1] += 1

print(ansAC, ansWA)


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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

vector<ll> a,z;

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

    ll N;
    string S;
    cin >> S;

    REP(i,S.size()){
        if(S.at(i)=='A'){
            a.push_back(i);
        }
        else if(S.at(i)=='Z'){
            z.push_back(i);
        }
    }
    reverse(z.begin(), z.end());

    cout << z.at(0) - a.at(0) + 1 << endl;

}


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

int main() {
	int n,d,s,c=0;double d1;
	cin>>n>>d;
	int a[n][d];
	for(int i=0;i<n;i++)
	for(int j=0;j<d;j++)
	cin>>a[i][j];
	for(int i=0;i<n-1;i++)
	{
	    for(int j=i+1;j<n;j++)
	    {s=0;
	        for(int k=0;k<d;k++)
	            s+=(a[j][k]-a[i][k])*(a[j][k]-a[i][k]);
	        d1=sqrt(s);
	        if(d1-(int)d1==0.0)
	        c++;
	    }
	}
	cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main() {
	int a=0;
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '+')a++;
		if (s[i] == '-')a--;
	}
	cout << a<<endl;
	return 0;
}


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

using namespace std;

namespace {

#define VEVE(i, a, b) for (ll i = a, __##i = b; i < __##i; ++i)
#define DYDY(i, a, b) for (ll i = a, __##i = b; i > __##i; --i)
#define RARA(x, seq) for (auto &x : seq)
#define SIZE(x) ((ll)(x.size()))
#define ALL(x) x.begin(), x.end()

typedef int64_t ll;
typedef double dd;

void Solve(ll) {
  ll n;
  if (not(cin >> n))
    return;
  vector<ll> arr(n);
  RARA(a, arr) cin >> a;
  ll lef = 0, bad = 0, res = 0;
  vector<ll> cnt(20, 0);
  VEVE(rig, 0, n) {
    VEVE(bit, 0, 20) if ((arr[rig] >> bit & 1) and ++cnt[bit] == 2)
        ++bad;
    for (; bad; ++lef)
      VEVE(bit, 0, 20) if ((arr[lef] >> bit & 1) and --cnt[bit] == 1) --bad;
//    DEBUG(lef, rig);
    res += rig - lef + 1;
  }
  cout << res << endl;
}

void Init() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
}
}

int32_t main() {
#ifdef AZN
  freopen("input.txt", "r", stdin);
#endif
  Init();
  ll tests = 11;
  VEVE(test, 1, tests + 1) Solve(test);
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define dev 998244353 //tenka1
#define P pair<int,int>
#define F first
#define S second

signed main(){
    int n,d;
    cin>>n>>d;
    int o=d*2+1;
    int ans=(n+o-1)/o;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 100010
#define ll long long
#define mod 1000000007
using namespace std;

int n, l1[N], l2[N], flag[N], now, p1[N], p2[N], f[N], s[N], L, R, sf[N], x;
ll w[N], A, B, ans;

inline void solve(){
	memset(flag, 0, sizeof(flag));
	for(int i=1; i<=n-1; i++)if(w[i+1]-w[i]>=A)flag[i]=1;
	now=1; l1[1]=1;
	for(int i=2; i<=n; i++){if(!flag[i-1])now=i; l1[i]=now;}
	memset(flag, 0, sizeof(flag));
	for(int i=1; i<=n-1; i++)if(w[i+1]-w[i]>=B)flag[i]=1;
	now=1; l2[1]=1;
	for(int i=2; i<=n; i++){if(!flag[i-1])now=i; l2[i]=now;}
	now=0; for(int i=1; i<=n; i++){while(w[i]-w[now+1]>=A)now++; p1[i]=now;}
	now=0; for(int i=1; i<=n; i++){while(w[i]-w[now+1]>=B)now++; p2[i]=now;}
	
	f[0]=f[1]=1; sf[0]=1; sf[1]=2;
	s[0]=1; s[1]=2;
	for(int i=2; i<=n; i++){
		if(l2[i-1]==1)f[i]=1; else f[i]=0;
		L=max(l2[i-1]-1, 1); R=min(p1[i], i-2);
		if(L<=R)f[i]=(f[i]+s[R]-s[L-1]+mod)%mod;
		sf[i]=(sf[i-1]+f[i])%mod;
		L=l1[i]; R=min(p2[i+1]+1, i);
		if(L<=R)x=(sf[R]-sf[L-1]+mod)%mod; else x=0;
		s[i]=(s[i-1]+x)%mod;
	}
	ans=((ans+sf[n])%mod-sf[l1[n]-1]+mod)%mod;
}

int main(){
	scanf("%d%lld%lld", &n, &A, &B);
	for(int i=1; i<=n; i++)scanf("%lld", &w[i]);
	ans=0; solve();
	swap(A, B); solve();
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 4224
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(int i = m;i >= n;--i)
#define INF INT_MAX/2
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const ll MOD = 1e9 + 7;
struct edge { ll from; ll to; ll cost; };

ll F(ll n){
	ll ret = 0;

	rep(i, 0, 45) {
		ll s = (1LL << i);
		if (i == 0) {
			if (n % 4 == 1 || n % 4 == 2) {
				ret += 1;
			}
		}
		else {
			if (n & s) {
				if ((n % s) % 2 == 0) {
					ret += s;
				}
			}
		}
	}
	return ret;
}




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

	ll ans = F(a - 1)^F(b);

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

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

#define rep(i,n)	for(int i = 0;i < n;i++)
#define rep2(i,n)	for(int i = 1;i <= n;i++)
#define each(i,x)	for(auto & i : x)

using namespace std;

struct edge
{
	edge(int _s,int _t,int _cost)
	{
		s = _s;t = _t;cost = _cost;
	}
	int s;
	int t;
	int cost;
};

int main()
{
	int n;
	cin >> n;
	while(n)
	{
		vector<edge> ary;
		int mt = 0;
		rep(i,n)
		{
			int a,b,d;
			cin >> a >> b >> d;
			ary.push_back(edge(a,b,d));
			if(mt < a)
			{
				mt = a;
			}
			if(mt < b)
			{
				mt = b;
			}
		}
		mt++;
		vector<vector<int>> cost(mt,vector<int>(mt,1000000));
		rep(i,mt)
		{
			cost[i][i] = 0;
		}
		rep(i,ary.size())
		{
			int a = ary[i].s;
			int b = ary[i].t;
			int d = ary[i].cost;
			rep(j,mt)
			{
				rep(k,mt)
				{
					if(cost[j][k] > cost[j][a] + cost[b][k] + d)
					{
						cost[j][k] = cost[j][a] + cost[b][k] + d;
					}
					if(cost[j][k] > cost[j][b] + cost[a][k] + d)
					{
						cost[j][k] = cost[j][b] + cost[a][k] + d;
					}
				}
			}
		}
		int smin = 1000000;
		int imin = 0;
		rep(i,mt)
		{
			int s = 0;
			rep(j,mt)
			{
				s += cost[i][j];
			}
			if(smin > s)
			{
				smin = s;
				imin = i;
			}
		}
		cout << imin << ' ' << smin << endl;
		cin >> n;
	}
	return 0;
}

Measured memory_bytes: 1212