akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include <string.h>
#include<math.h>

double s(double a,double b,double c,double d,double e,double f){
	double S=fabs( (c-a)*(f-b)-(d-b)*(e-a) )/2;
	return S;
}

int main(){
	double a,b,c,d,e,f;
	double x,y;
	
	while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f,&x,&y)!=EOF){
		//printf("s(a,b,c,d,e,f)=%lf\n",s(a,b,c,d,e,f));
		//printf("s(x,y,c,d,e,f)+s(a,b,x,y,e,f)+s(a,b,c,d,x,y)=%lf\n",s(x,y,c,d,e,f)+s(a,b,x,y,e,f)+s(a,b,c,d,x,y));
		
		if(s(x,y,c,d,e,f)*s(a,b,x,y,e,f)*s(a,b,c,d,x,y)==0){
			printf("NO\n");
		}else if(s(a,b,c,d,e,f)==s(x,y,c,d,e,f)+s(a,b,x,y,e,f)+s(a,b,c,d,x,y)){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
	}
	return 0;
}

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

int main() {
  int N, K, x = 1;
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    int A, B;
    A = x * 2;
    B = x + K;
    if (A < B) {
      x *= 2;
    }
    else {
      x += K;
    }
  }
  cout << x << endl;
}

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(){
  	string s;
  	int k;
  	cin>>s>>k;
  	rep(i,min((int)s.size(),k)) if (s[i]!='1') {cout<<s[i]<<endl;return 0;}
	cout<<"1"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=105,INF=1<<30;
int state[MAX],N,S[MAX][MAX];
priority_queue<pair<int,int>> Q;

int prim(){
    int sum=0,cnt=1;
    for(int i=0;i<N;i++){
        state[i]=0;
    }
    state[0]=1;
    for(int i=0;i<N;i++){
        if(S[0][i]!=INF) Q.push(make_pair(-S[0][i],i));
    }
    while(1){
        int a=Q.top().first;
        int b=Q.top().second;
        Q.pop();
        if(state[b]==0){
            sum+=-a;
            state[b]=1;
            cnt++;
            for(int i=0;i<N;i++){
                if(S[b][i]!=INF&&state[i]==0) Q.push(make_pair(-S[b][i],i));
            }
        }
        if(cnt==N) break;
    }
    return sum;
}



int main(){
    
    cin>>N;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            int a;cin>>a;
            if(a==-1) S[i][j]=INF;
            else S[i][j]=a;
        }
    }
    cout<<prim()<<endl;

}





Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
int main () {
    int h, w;
    cin >> h >> w;
    for (int i = 1; i <= h; i++) {
        for (char j = 'A'; j < 'A'+w; j++) {
            string s;
            cin >> s;
            if (s == "snuke") {
                cout << j << i << endl;
            }
        }
    }
}

Measured memory_bytes: 256
def genetarete_num(n):
    if n % 2 == 0:
        return int(n/2)
    else:
        return int(3*n+1)

s = int(input())

num = genetarete_num(s)

if num == s:
    print(2)
    exit()

num_list = [s,num]

for i in range(3,1000001):
    num = genetarete_num(num)
    if num in num_list:
        print(i)
        exit()
    num_list.append(num)


Measured memory_bytes: 3188
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N, A, B, C, D;
i64 dp[2][1010];
i64 Cb[1010][1010];

int main()
{
	scanf("%d%d%d%d%d", &N, &A, &B, &C, &D);
	int t = 0;
	dp[t][N] = 1;

	Cb[0][0] = 1;
	for (int i = 1; i <= N; ++i) {
		Cb[i][0] = 1;
		for (int j = 1; j <= N; ++j) Cb[i][j] = (Cb[i - 1][j - 1] + Cb[i - 1][j]) % MOD;
	}

	for (int i = A; i <= B; ++i) {
		for (int j = 0; j <= N; ++j) dp[1 - t][j] = dp[t][j];

		i64 pat = 1;
		for (int k = 1; k <= D; ++k) {
			if (i * k > N) break;
			pat = pat * Cb[i * k - 1][i - 1] % MOD;
			if (k < C) continue;
			for (int j = i * k; j <= N; ++j) {
				ADD(dp[1 - t][j - i * k], dp[t][j] * pat % MOD * Cb[j][i * k] % MOD);
			}
		}
		t = 1 - t;
	}
	printf("%lld\n", dp[t][0]);

	return 0;
}


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

bool A[200],B[200];
int main(){
	int n;scanf("%d",&n);
	int cnt=0;
	int x;scanf("%d",&x);
	rep(i,x){
		int a;scanf("%d",&a);a--;A[a]=true;
	}
	int y;scanf("%d",&y);
	rep(i,y){
		int b;scanf("%d",&b);b--;B[b]=true;
	}
	int z;scanf("%d",&z);
	rep(i,z){
		int c;scanf("%d",&c);c--;
		if(!A[c]||B[c])cnt++;
	}
	cout<<cnt<<endl;
}



Measured memory_bytes: 3248
#[allow(dead_code)]
fn is_whitespace(c: &char) -> bool {
    c.is_whitespace()
}

#[allow(dead_code)]
fn is_eol(c: &char) -> bool {
    ['\r', '\n'].contains(c)
}

#[allow(unused_macros)]
macro_rules! input {
    ($var:ident, $($r:tt)*) => {
        input_inner!{$var, $($r)*}
    };

    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        #[allow(unused_mut, unused_variables, bare_trait_objects)]
        let mut next = move |f: &Fn(&char)->bool| -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|f(&c))
                .take_while(|c|!f(&c))
                .collect()
        };
        input_inner!{next, $($r)*};
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; eol ]) => {
        $next(&is_eol).split(' ').map(|x| x.parse::<$t>().unwrap()).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, parser) => {
        $next
    };

    ($next:expr, $t:ty) => {
        $next(&is_whitespace).parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};

#[allow(dead_code)]
struct Edge {
    from: usize,
    to: usize,
}

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;
#[allow(dead_code)]
const M: usize = 1_000_000_007;

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

    let mut v = vec![];
    for i in 0..n {
        if i == n - 1 {
            v.push(a[0] + k - a[i]);
        } else {
            v.push(a[i + 1] - a[i]);
        }
    }
    println!("{}", k - v.into_iter().max().unwrap());
}


Measured memory_bytes: 8444
package main

import (
  "fmt"
)

func main() {
  var a, b, c, d, e, k int
  fmt.Scan(&a, &b, &c, &d, &e, &k)
  if e-a > k {
    fmt.Println(":(")
    return
  }
  fmt.Println("Yay!")
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(void) {
  int n,y;cin>>n>>y;
  fr(i, n+1){
    fr(j, n+1-i) if(i*10000+j*5000+(n-i-j)*1000 == y){
      cout << i << ' '<< j << ' ' << n-i-j << endl;
      return 0;
    
    }
  }
   cout << "-1 -1 -1" << endl;
  
  return 0;
}

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

#define N 1000
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007
#define fastio ios::sync_with_stdio(false); cin.tie(0)

int main(){
    fastio;
    // #ifndef ONLINE_JUDGE
    //     freopen("input.in", "r", stdin);
    //     freopen("output.out", "w", stdout);
    // #endif
    long long r, d, x, ans;
    cin >> r >> d >> x;
    for(int i = 0 ; i < 10 ; i++){
    	ans = r*x - d;
    	x = ans;
    	cout << ans << endl;
    }
    return 0;
}

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

int main(){
  int a, b, q;
  cin >> a >> b >> q;
  vector<ll> va(a), vb(b);
  for(int i=0; i<a; ++i) cin >> va[i];
  for(int i=0; i<b; ++i) cin >> vb[i];
  for(int i=0; i<q; ++i){
    ll x;
    cin >> x;
    ll ans = INF;
    auto it1 = lower_bound(va.begin(),va.end(),x);
    auto it2 = lower_bound(vb.begin(),vb.end(),*it1);
    if(it1 != va.end()){
      if(it2 != vb.end()) ans = min(ans, *it2 -x); 
      --it2;
      if(it2 != vb.begin()-1) ans = min(ans, *it1 *2 -x -*it2);
    }
    if(it1 != va.begin()){
      --it1; 
      it2 = lower_bound(vb.begin(),vb.end(),*it1);
      if(it2 != vb.end()) ans = min(ans, *it2 +x -*it1 *2);
      --it2;
      if(it2 != vb.begin()-1) ans = min(ans, x -*it2);
    }
    it1 = lower_bound(vb.begin(),vb.end(),x);
    it2 = lower_bound(va.begin(),va.end(),*it1);
    if(it1 != vb.end()){
      if(it2 != va.end()) ans = min(ans,*it2 -x);
      --it2;
      if(it2 != va.begin()-1) ans = min(ans, *it1 *2 -x -*it2);
    }
    if(it1 != vb.begin()){
      --it1;
      it2 = lower_bound(va.begin(),va.end(),*it1);
      if(it2 != va.end()) ans = min(ans, *it2 +x -*it1 *2);
      --it2;
      if(it2 != va.begin()-1) ans = min(ans, x -*it2);
    }
    printf("%lld\n", ans);
  }
}

Measured memory_bytes: 4764
// copied by Nurstan Duisengaliev
// skatal
#include <bits/stdc++.h>
 
#define ll long long
#define all(x) x.begin(), x.end()
#define in insert
#define mp make_pair
#define F first
#define S second
#define ppf pop_front
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pii pair <int, int>
#define boost() ios_base::sync_with_stdio(0), cin.tie(0)
#define sz(x) (int)x.size()
 
using namespace std;
 
const int N = (int)2e5 + 123;
const int mod = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;

void solve () {
	int n;
	cin >> n;
	bool check = 1;
	for (int i = 1; i <= n; i ++) {
		int x;
		cin >> x;
		if (x % 2 == 0 && x % 3 != 0 && x % 5 != 0) check = 0;	
	}
	if (check == 1) {
		cout << "APPROVED";
	}
	else cout << "DENIED";
}
 
main () {
//	freopen (".in", "r", stdin);
//	freopen (".out", "w", stdout);
	boost ();
	int TT = 1;
//    cin >> TT;
	while (TT --) {
		solve ();
	}
	return 0;	
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pii std::pair<int,int>
#define pli std::pair<ll,int>
#define pil std::pair<int,ll>
#define psi std::pair<string,int>
#define pll std::pair<ll,ll>
#define pci std::pair<char,int>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define pb push_back
#define vll std::vector<ll>
#define vpi std::vector<std::pair<int,int>>
#define vi std::vector<int>
#define vvi std::vector<std::vector<int>>
#define vvpil std::vector<std::vector<std::pair<int,ll>>>
#define vlpii std::vector<std::list<pii>>
#define vlpil std::vector<std::list<pil>>
#define li std::list<int>
#define lpil std::list<pil>
#define Endl printf("\n")
#define vli vector<list<int>>
#define vvll vector<vector<ll>>
#define mp make_pair
#define ma 100000000
#define mod 1000000007
#define Nmax 1000000000000
using namespace std;
int n,m;
vli EdgeList;
int dp[100000];
bool visited[100000];
int ans=0;
void dfs(int u){
    visited[u]=true;
    for(li::iterator i=EdgeList[u].begin();i!=EdgeList[u].end();++i){
        if(!visited[*i]) dfs(*i);
        dp[u]=max(dp[u],dp[*i]+1);
    }
    ans=max(dp[u],ans);
}
int main()
{
    IOS;
    cin>>n>>m;
    EdgeList.resize(n,{});
    int u,v;
    for(int i=0;i<m;i++){
        cin>>u>>v;u--;v--;
        EdgeList[u].pb(v);
    }
    for(int i=0;i<n;i++){
        if(!visited[i]) dfs(i);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 6784
#include <iostream>

using namespace std;

int main() {

    int num;
    cin >> num;

    int* a = new int[num];

    for (int i = 0; i < num; i++) {
        cin >> a[i];
    }
    for (int i = num - 1; i >= 0; i--) {
        cout << a[i];
        if (i == 0)
            break;
        cout << " ";
    }
    cout << endl;
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
const int MAXA=3e5;
int nxt[MAXA],first[MAXA],go[MAXA],tot,tott;
int bo[MAXA];
int add(int x,int y){
    nxt[++tot]=first[x]; first[x]=tot; go[tot]=y;
}
int dfs(int x,int father){
    int tot=0,y;
    bo[x]=++tott;
    for(int i=first[x];i;i=nxt[i])
	if(go[i]!=father){
	    if(!bo[go[i]]){
		y=dfs(go[i],x);
		if(y) printf("%d %d\n",x,go[i]);
		else printf("%d %d\n",go[i],x);
		tot+=y;
	    }else{
		if(bo[go[i]]<bo[x]) continue;
		printf("%d %d\n",x,go[i]);
		tot++;
	    }
	}
    if(tot%2) return 0;
    else return 1;
}

int main(){
    int n,m,x,y;
    scanf("%d%d",&n,&m);
    if(m&1) return printf("-1"),0;
    for(int i=1;i<=m;i++){
	scanf("%d%d",&x,&y);
	add(x,y);
	add(y,x);
    }
    dfs(1,0);
}


Measured memory_bytes: 11008
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
using namespace std;
int main(){
  string s;
  cin >> s;
  int ans = 0;
  for(int i = 0; i < 3; i++){
      if(s[i] == '1') ans++;
  }
  cout << ans << endl;
}

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

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> P;

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

int H, W, K;
int dp[801][801];
string maps[800];

int main() {
	cin >> H >> W >> K;
	REP(i, H) cin >> maps[i];
	
	fill(dp[0], dp[H], INF);
	
	pii sp;
	REP(i, H) REP(j, W) if (maps[i][j] == 'S') sp = pii(i, j);
	
	queue<pii> que;
	que.push(sp);
	dp[sp.first][sp.second] = 0;
	
	int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};
	
	while (!que.empty()) {
		int y = que.front().first;
		int x = que.front().second;
		que.pop();
		
		REP(i, 4) {
			int nx = x + dx[i];
			int ny = y + dy[i];
			if (!(nx >= 0 && nx < W && ny >= 0 && ny < H)) continue;
			if (maps[ny][nx] == '#') continue;
			
			if (dp[ny][nx] <= dp[y][x] + 1) continue;
			
			dp[ny][nx] = dp[y][x] + 1;
			que.push(pii(ny, nx));
		}
	}
	
	int ans = INF;
	
	REP(i, H) REP(j, W) if (dp[i][j] != INF) {
		if (dp[i][j] == 0) dp[i][j] = K;
		dp[i][j] = (dp[i][j] + K - 1) / K * K;
		
		chmin(ans, H - i - 1 + dp[i][j]);
		chmin(ans, W - j - 1 + dp[i][j]);
		chmin(ans, i + dp[i][j]);
		chmin(ans, j + dp[i][j]);
	}
	
	cout << (ans + K - 1) / K << endl;
	
	return 0;
}


Measured memory_bytes: 3584
package main

import (
	"fmt"
	"sort"
)

type Restaurant struct {
	Name  string
	Point int
	Index int
}
type Restaurants []Restaurant

func (r Restaurants) Len() int      { return len(r) }
func (r Restaurants) Swap(i, j int) { r[i], r[j] = r[j], r[i] }
func (r Restaurants) Less(i, j int) bool {
	if r[i].Name == r[j].Name {
		return r[i].Point > r[j].Point
	}
	return r[i].Name < r[j].Name
}

func main() {
	var n int
	fmt.Scan(&n)
	var rs Restaurants = make([]Restaurant, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&rs[i].Name, &rs[i].Point)
		rs[i].Index = i + 1
	}

	sort.Sort(rs)
	for _, v := range rs {
		fmt.Println(v.Index)
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/
map<pair<vl,ll>,ll> mp;
ll solve(vl a,ll t){
	auto p=make_pair(a,t);
	if(mp.find(p)!=mp.end())return mp[p];
	int n=a.size();
	ll ret=LINF;
	rep(i,n){
		chmin(ret,abs(t-a[i]));
	}
	if(n==1)return mp[p]=ret;
	rep(i,n)range(j,i+1,n){
		vl nxt;
		rep(k,n)if(k!=j)nxt.push_back(a[k]);
		nxt[i]+=a[j];
		chmin(ret,solve(nxt,t)+10);
	}
	return mp[p]=ret;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vl t(3),a(n);
	cin>>t>>a;

	vvl ans(3,vl(1<<n,0));
	rep(i,3){
		rep(s,1<<n){
			vl tmp;
			rep(j,n)if(s&(1<<j))tmp.push_back(a[j]);
			ans[i][s]=solve(tmp,t[i]);
		}
	}
	ll v=LINF;
	rep(i,1<<n)rep(j,1<<n)rep(k,1<<n){
		if((i&j) or (j&k) or (k&i))continue;
		chmin(v,ans[0][i]+ans[1][j]+ans[2][k]);
	}
	puta(v);
	return 0;
}

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

int main(void){
int n,t,c,max;
cin>>n>>t;
vector<int> ln,rn;
ln.resize(t);
rn.resize(t);
int r,l;
for(int i=0;i<n;i++){
 cin>>l>>r;
 ln[l]+=1;
 rn[r]+=1;
}
c=0;
max=0;
for(int i=0;i<t;i++){
 c+=ln[i];
 c-=rn[i];
 if(c>max) max=c;
}
cout<<max<<endl;
return 0;

}


Measured memory_bytes: 3636
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int h;
    int w;
    while ((h = sc.nextInt()) != 0 | (w = sc.nextInt()) != 0){
      for(int i = 0;i < h;i++){
        for(int j = 0;j < w;j++){
           System.out.print("#");
        }
        System.out.println("");
      }
      System.out.println("");
    }
  }
}



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

char ar[1010][1010];
int dp[1010][1010];
const int mod = 1e9 + 7;

// return no. of ways to reach (i,j)
// int solve(int i, int j) {
//     if(i == 1 && j == 1) return 1;
//     if(i < 1 || j < 1 || ar[i][j] == '#') return 0;

//     if(dp[i][j] != 0) return dp[i][j];

//     return dp[i][j] = (solve(i-1, j) + solve(i, j-1)) % mod;
// }

int solve(int h, int w) {

    int j = 1;
    for(; j<=w; ++j) {
        if(ar[1][j] == '#') break;
        dp[1][j] = 1;
    }
    //cout << j << '\n';
    for(; j<=w; ++j) {
        dp[1][j] = 0;
    }
    //-----------------
    int i = 1;
    for(; i<=h; ++i) {
        if(ar[i][1] == '#') break;
        dp[i][1] = 1;
    }
    //cout << i << '\n';
    for(; i<=h; ++i) {
        dp[i][1] = 0;
    }
    //-------------------

    for(i=2; i<=h; ++i) {
        for(j=2; j<=w; ++j) {
            if(ar[i][j] == '#') dp[i][j] = 0;
            else dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % mod;
        }
    }

    return dp[h][w];
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int h, w; cin >> h >> w;
    for(int i=1; i<=h; ++i) {
        for(int j=1; j<=w; ++j) {
            cin >> ar[i][j];
        }
    }
    cout << solve(h, w);
    return 0;
}

Measured memory_bytes: 5248
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
      
        String ans = "";
        if (a == b) {
          ans = "Draw";
        } else if (a > b) {
          ans = b == 1 ? "Bob" : "Alice";
        } else if (a < b) {
          ans = a == 1 ? "Alice": "Bob";
        }
    
		// 出力
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

def calcScore(t, s, c):
    scores = [0]*26
    lasts = [0]*26
    for i in range(1, len(t)):
        scores[t[i]] += s[i][t[i]]
        dif = i - lasts[t[i]]
        scores[t[i]] -= c[t[i]] * dif * (dif-1) // 2
        lasts[t[i]] = i
    for i in range(26):
        dif = len(t) - lasts[i]
        scores[i] -= c[i] * dif * (dif-1) // 2
    return scores

D = int(input())
c = list(map(int, input().split()))
s = [[0]*26 for _ in range(D+1)]
for i in range(1, D+1):
    s[i] = list(map(int, input().split()))
t = [-1]*(D+1)
for i in range(1, D+1):
    t[i] = int(input()) - 1
M = int(input())

scores = calcScore(t, s, c)

ans = [None]*M
for i in range(M):
    d, q = map(int, input().split())
    t[d] = q-1
    ans[i] = sum(calcScore(t, s, c))

for v in ans:
    print(v)

Measured memory_bytes: 73508
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

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

    cout << min(b/a, c) << endl;

    return 0;
}

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

using namespace std;
typedef long long i64;

const int INF = 1000000000;
const int N = 300005;

int ans[N];

int main ()
{
    int n, a, b;
    cin >> n >> a >> b;
    if (n < a + b - 1 || n > (i64)a * b) puts("-1");
    else {
        int pos = 0, now = b;
        for (int i = b; i >= 1; --i) ans[++pos] = i;
        if (a != 1) {
            int cn = (n - b) / (a - 1);
            int mod = (n - b) % (a - 1);
            for (int i = 1; i <= a - 1; ++i) {
                int tmp;
                if (i <= mod) tmp = now + cn + 1;
                else tmp = now + cn;
                for (int j = tmp; j > now; --j) ans[++pos] = j;
                now = tmp;
            }
        }
        for (int i = 1; i <= n; ++i) printf(i == 1 ? "%d" : " %d" , ans[i]);
        putchar('\n');
    }
    return 0;
}


Measured memory_bytes: 3328
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    println!("{}", (n - 1) / 2);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
/*
---------author:O7Oo7oO7O-------------
*/

#include <bits/stdc++.h>

#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;

using ll = long long int;



int main()
{
	IOS

	int a,b,c,d;
	cin>>a>>b>>c>>d;
	while(1)
	{
		if(c<=0)
		{
			cout<<"Yes\n";
			break;
		}
		if(a<=0)
		{
			cout<<"No\n";
			break;
		}
		c-=b;
		a-=d;
	}

	return 0;
}


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

int main() {
	int N, A;
  	int i;
	cin >> N >> A;
  
  i = N/500;
  N-500*i <= A;
	if(N-500*i <= A)
      	cout << "Yes" << endl;
	else
		cout << "No" << endl;
}


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

int main() {
    string sd, t;
    cin >> sd >> t;
    int i;
    for (i = sd.size() - 1; i >= 0; i--) {
        bool ok = true;
        for (int j = 0; j < t.size(); j++) {
            if (sd[i - j] != '?' && sd[i - j] != t[t.size() - j - 1]) {
                ok = false;
                break;
            }
        }
        if (ok) {
            break;
        }
    }
    if (i < 0) {
        cout << "UNRESTORABLE" << endl;
    } else {
        for (int j = 0; j < sd.size(); j++) {
            if (j >= i - t.size() + 1 && j <= i) {
                cout << t[t.size() - 1 - (i - j)];
            } else if (sd[j] == '?') {
                cout << "a";
            } else {
                cout << sd[j];
            }
        }
    }
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vi;

ll gcd(ll a, ll b){ // assume a <= b
    if(a > b)
        return gcd(b, a);
    if(b % a == 0 || a == 1 || a == 0)
        return a;
    else
        return gcd(b % a, a);
}

int main() {
    ll N, X;
    cin >> N >> X;
    ll x, minD = 10000000000000, idx = 0; vector<ll> xs(N);
    while(cin >> x){
        if(x != X){
            xs[idx] = abs(x - X);
            if(minD >= xs[idx]) minD = xs[idx];
            idx++;
        }
    }
    
    ll res = xs[0];
    for (ll i = 1; i < xs.size(); i++) {
        res = gcd(res, xs[i]);
    }
    cout << res << endl;
    return 0;
}





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

char S[100010];
int red, blue;

int main() {
   scanf(" %s", S);
   for (int i = 0; S[i]; i++) {
      red += (S[i] == '0');
      blue += (S[i] == '1');
   }//for
   printf("%d\n", 2 * min(red, blue));
   return 0;
}//main


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using vb = vector<bool>;
using boolGraph = vector<vb>;
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const int MOD2 = 998244353;
const double EPS = 1e-9;

int main() {
  int N; cin >> N;
  string S; cin >> S;
  int ans = 1;
  rep(i,N-1) {
    if (S[i] != S[i+1]) ++ans;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

int main(void){
    char c;
    int ans['z' - 'a'] = {0};
    while((c = getchar()) != EOF){
	if(c >= 'A' && c <= 'Z') c += 'a' - 'A'; 
	if(c >= 'a' && c <= 'z'){
	    ans[c - 'a'] += 1;
	}
    }
    for(int i = 0; i <= 'z' - 'a'; i++ ){
        printf("%c : %d\n", i + 'a', ans[i]);
    }
    return 0;
}


Measured memory_bytes: 2700
#include<stdio.h>
#include<math.h>
int main()
{
	long long int a, b = 1,i=0,c;
	scanf("%lld", &a);
	while (b <= a)
	{
		b = b * 2;
		i++;
	}
	c = pow(2, i) - 1;
	printf("%lld", c);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int memo[100000]={0};
void solve(){
	int n; cin>>n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
	}
	memo[0] = 0;
	for (int i = 1; i < n; ++i)
	{
		memo[i]=memo[i-1]+abs(a[i]-a[i-1]);
		if(i>1){
			memo[i] = min(memo[i], memo[i-2]+abs(a[i]-a[i-2]));
		}
	}
	cout<<memo[n-1];
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    // ll t; cin>>t;
    // while(t--)
        solve();
    return 0;
}


Measured memory_bytes: 3972
#include <bits/stdc++.h>
     
    using namespace std;
     
    int n;
     
    int main()
    {
        cin >> n;
        if (n==25)
            cout << "Christmas" << endl;
        else if (n==24)
            cout << "Christmas Eve" << endl;
        else if (n==23)
            cout << "Christmas Eve Eve" << endl;
        else if (n==22)
            cout << "Christmas Eve Eve Eve" << endl;
    }

Measured memory_bytes: 256
N = int(input())
words  = input()
lis = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
result = [""]*len(words)
for i in range(len(words)):
    k = lis.find(words[i])
    if k+N >=len(lis):
        tmp = k+N -len(lis)
    else:
        tmp = k+N
    result[i] = lis[tmp]
print("".join(result))


Measured memory_bytes: 3060
module Main (main) where

import qualified Data.ByteString.Char8 as C8
import Data.List
import Data.Maybe

main :: IO ()
main = do
  [n] <- readInts
  readInts >>= print . solve n

solve :: Int -> [Int] -> Int
solve n = g . foldl' f (0, 0, 0)
  where
    f (m, n, c) x
      | m >= x = (x, n, c+1)
      | otherwise = (x, max c n, 0)
    g (_,x,c) = max x c

-- utils
readInts :: IO [Int]
readInts = map (fst . fromJust . C8.readInt) . C8.words <$> C8.getLine

Measured memory_bytes: 10620
#include<iostream>
#include<cstdio>
#include<algorithm>
//N=2*10e3 L=10e3
using namespace std;
int a[2005];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	sort(a,a+n);
/*	for(int i=0;i<n;i++){
		cout<<a[i]<<" ";
	}
	cout<<endl;*/
	int ans=0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n-1;j++){
			int k=lower_bound(a+j,a+n,(a[i]+a[j]))-a;
//			printf("%d %d %d %d\n",a[i],a[j],a[i]+a[j],k);
			if(k<n){
				ans+=(k-j-1);
			}else{
				ans+=n-j-1;
			}
		}
	}
	cout<<ans;
}

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

int main() {
  int N, a = 1;
  cin >> N;
  vector<int> but(N);
  
  for (int i = 0; i < N; i++) cin >> but.at(i);
  
  for (int i = 1; i <= N; i++) {
    a = but.at(a - 1);
    
    if (a == 2) {
      cout << i << endl;
      break;
    }
    
    if (i == N) cout << -1 << endl;
  }
}


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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#define DEBUG

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	char c;
	cin >> c;
	if(c == 'a' || c == 'i' || c == 'u'
		|| c == 'e' || c == 'o')
		cout << "vowel" << endl;
	else
		cout << "consonant" << endl;
	return 0;
}

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

struct dice{
	int top;
	int front;
	int left;
	int right;
	int back;
	int bottom;
};

void ClockwiseFront(struct dice *X){
	int c = X->top;
	X->top    = X->left;
	X->left   = X->bottom;
	X->bottom = X->right;
	X->right  = c;
}

void ClockwiseRight(struct dice *X){
	int c = X->top;
	X->top    = X->front;
	X->front  = X->bottom;
	X->bottom = X->back;
	X->back   = c;
}

int main(){
	//????????????????????¢?????°????????\?????????
	struct dice X;
	cin >> X.top;
	cin >> X.front;
	cin >> X.right;
	cin >> X.left;
	cin >> X.back;
	cin >> X.bottom;
	//?????¢??????????????\?????????
	string Rotation;
	cin >> Rotation;
	//????????????????????¢?????????
	for(int i = 0; i < Rotation.size(); i++){
		if(Rotation[i] == 'N') ClockwiseRight(&X);
		if(Rotation[i] == 'E') ClockwiseFront(&X);
		if(Rotation[i] == 'S') ClockwiseRight(&X), ClockwiseRight(&X), ClockwiseRight(&X);
		if(Rotation[i] == 'W') ClockwiseFront(&X), ClockwiseFront(&X), ClockwiseFront(&X);
	}
	//?????¢??????????????¨?????????
	cout << X.top << endl;
	return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); 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;}
using ll = long long;

ll n,m,ans=1;
string s,t;
ll a[100005];

ll solve(){
  rep(i,n){
    if(a[i]<=(ll)1e18/ans) ans*=a[i]; 
    else return -1;
  }
  return ans;
}

int main() {
  cin >> n;
  rep(i,n) cin >> a[i];
  cout << (!count(a,a+n,0) ? solve() : 0) << endl; 
}

Measured memory_bytes: 4416
while True:

    raw = input().split()
    ope = raw.pop(1)
    a, b = map(int, raw)
    
    if ope == "+":
        result = a + b
    elif ope == "-":
        result = a - b
    elif ope == "*":
        result = a * b
    elif ope == "/":
        result = a // b
    else:
        break
        
    print(result)


Measured memory_bytes: 5596
#include <iostream>
using namespace std;
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int n,q;
    string s;
    cin >> n >> q >> s;
    int cum[100001];
    int c=0;
    cum[0]=0;
    for (int i=1;i<n;i++) {
        if(s[i-1]=='A' && s[i]=='C') c++;
        cum[i]=c;
    }
    int l,r;
    for (int i=0;i<q;i++) {
        cin >> l >> r;
        cout << (cum[r-1] - cum[l-1]) << "\n";
    }
    cout << flush;
    return 0;
}


Measured memory_bytes: 1488
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;

#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

int main(){
    ll N,M; cin>>N>>M;
    vec d(N);
    rep(i,N) cin>>d[i];
    sort(ALL(d));
    vec SUM(N+1,0);
    rep(i,N) SUM[i+1]=d[i]+SUM[i];
    
    ll SMALL=d[0]*2-2, BIG=d[N-1]*2+2;
    ll countS=M, countB=M;
    ll count;
    while(BIG>SMALL+1){
        ll MID=(SMALL+BIG)/2;
        count=0;
        rep(i,N) count+=(N-(lower_bound(ALL(d),MID-d[i])-d.begin()));
        if(count>M) {SMALL=MID; countS=count;}
        else {BIG=MID; countB=count;}
    }
    ll ans=0;
    //cout<<BIG<<' '<<SMALL<<endl;
    //cout<<countB<<endl;
    rep(i,N){
        ll k=lower_bound(ALL(d),BIG-d[i])-d.begin();
        ans+=(SUM[N]-SUM[k]);
        ans+=(N-k)*d[i];
        //cout<<d[i]<<' '<<N-k<<' '<<SUM[N]<<' '<<SUM[k]<<endl;
    }
    ans+=(SMALL*(M-countB));
    cout<<ans<<endl;


}

Measured memory_bytes: 1792
/**
 *    author:  tourist
 *    created: 13.06.2020 15:36:53       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  cout << s.substr(0, 3) << '\n';
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<setw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値
#include <functional>//sort第三引数greater<型名>()で降順
#include <map>

using namespace std;
using ll = long long int;

int main(){
    int N;cin>>N;
    string s;
    int AC = 0;
    int WA = 0;
    int TLE = 0;
    int RE = 0;
    for(int i=0;i<N;i++){
        cin >> s;
        if(s=="AC") AC++;
        else if(s=="WA") WA++;
        else if(s=="TLE") TLE++;
        else RE++;
    }
    cout << "AC x " << AC << endl;
    cout << "WA x " << WA << endl;
    cout << "TLE x " << TLE << endl;
    cout << "RE x " << RE << endl;
    return 0;
}

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

const ll MOD = 1e9 + 7;

int main(void){
    int n;
    cin >> n;
    ll x = 1, y = 1, z = 1;
    rep(i, n){
        x = (x * 10) % MOD;
        y = (y * 9) % MOD;
        z = (z * 8) % MOD;
    }
    ll ans = x - (y * 2) + z;
    ans %= MOD;
    ans = (ans + MOD) % MOD;
    cout << ans << endl;
    return 0;
}

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

int main() {

    string s1, s2, s;

    cin >> s1 >> s2;

    s = s1 + s2;

   // cout << s << endl;
    stringstream ss(s);
    ll a;

    ss >> a;

    ll sq = sqrt(a);

    if(sq*sq == a) cout << "Yes" << endl;
    else cout <<  "No" << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
        string read = rstr();
        string a = "ACGT";
        WriteLine(a[3-a.IndexOf(read)]);
    
    
    }
    //各種読取
    static string rstr(){
        return ReadLine();
    }
    static int rint(){
        return int.Parse(ReadLine());
    }
    static long rlong(){
        return long.Parse(ReadLine());
    }
    static string[] stra(){
        return ReadLine().Split(' ');
    }
    static int[] inta(){
        string[] read_str_array = ReadLine().Split(' ');
        int[] return_int_array = new int[read_str_array.Length];
        for(int countup_i=0;countup_i<read_str_array.Length;countup_i++){
            return_int_array[countup_i] = int.Parse(read_str_array[countup_i]);
        }
        return return_int_array;
    }
    static int[,] inta2(int num_array,int in_array){
        int[,] int_array2 = new int[num_array,in_array];
        for(int i=0;i<num_array;i++){
            int[] temp_array = inta();
            for(int j=0;j<in_array;j++){
                int_array2[i,j] = temp_array[j];
            }
        }
        return int_array2;
    }
    static long[] longa(){
        string[] read_str_array = ReadLine().Split(' ');
        long[] return_long_array = new long[read_str_array.Length];
        for(long countup_i=0;countup_i<read_str_array.Length;countup_i++){
            return_long_array[countup_i] = long.Parse(read_str_array[countup_i]);
        }
        return return_long_array;
    }
    static double[] doublea(){
        string[] read_str_array = ReadLine().Split(' ');
        double[] return_double_array = new double[read_str_array.Length];
        for(long countup_i=0;countup_i<read_str_array.Length;countup_i++){
            return_double_array[countup_i] = long.Parse(read_str_array[countup_i]);
        }
        return return_double_array;
    }
    // A/B小数点以下切上
    static long divideup(long divided,long divid){
        long temp_divide = divided/divid;
        if(divided % divid > 0){
            temp_divide++;
        }
        return temp_divide;
    }
    static long GCD(long a,long b){
        if(a < b){
            long temp = a;
            a = b;
            b = temp;
        }
        if(a % b == 0){ return b; }
        else{
            long temp = b;
            b = a%b;
            a = temp;
            return GCD(a,b);
        }
    }
    static long LCM(long a,long b){
        return a * b / GCD(a,b);
    }
}
//知見
// (string) hogestr -> (char[]) hoge
    // char hoge = hogestr.ToCharArray();
// (char[]) hoge -> (string) hogestr
    // string hoge = new string(hoge);
// Hashtable ×  Dictionary ○
// Dictionary hoge<string,int>
    // hoge.ContainsKey(string) -> return boolean
    // hoge[string] -> return int
    // hoge[int] -> CE
// Dictionary hoge<int1,int2>
    // hoge<int1,int2>: hoge[int1] -> return int2
    // KeyValuePair<int,int> k <-> k.Key == int1 / k.Value == int2
// SortedDictionary() > SortedList() ???
// キュー　-> 幅優先 ???
// スタック -> 深さ優先 ???


Measured memory_bytes: 11232
#include <iostream>
#include <string>
using namespace std;
 
 
#define F(i, a) for (int i = 0; i < (a); i++)
#define Fd(i, a) for (ll i = (a)-1; i >= 0; i--)
#define Fs(i, a, j) for (ll i = (j); i < (a); i++)
#define deb(x) cout << #x << " " << x << endl;
#define debs(x) cout << #x << " " << x << " ";
#define deba(x) for (auto _i:x) cout << _i << " "; cout << endl;
#define ms(a) memset(a,0,sizeof(a));
#define ll long long
#define mp make_pair
#define eb emplace_back
#define FastOpen freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define int long long
//int power(int x,int p){if(p==0)return 1;if(p==1)return x;if(p%2)return x*power(x,p-1);int y=power(x,p/2);return y*y;}
/*
*/

//const int INF = 1e9+7;

void solve() {
    string s; cin >> s;
    int res = 0;
    for (auto e: s) {
        res += (e-'0');
    }
    if (res%9) {
        cout << "No" << endl;
    }else cout << "Yes" << endl;
}

signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//    FastOpen
    int t; t=1;
    while (t--) solve();
}





Measured memory_bytes: 3292
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<list>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define ll long long

using namespace std;

int n;
int a[16];
int x[16][16];
int y[16][16];

int main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		rep(j, a[i]) {
			cin >> x[i][j] >> y[i][j];
		}
	}

	int ans = 0;
	for (int bit = 0; bit < (1 << n); bit++) {
		bool check = true;
		rep(i, n) {
			if (!(bit & (1 << i)))continue;
			rep(j, a[i]) {
				if (y[i][j] == 1 && !(bit & (1 << x[i][j]-1)))check = false;
				if (y[i][j] == 0 && (bit & (1 << x[i][j]-1)))check = false;
			}
		}
		if (check) {
			int count = 0;
			rep(i, n) {
				if (bit & (1 << i))count++;
			}
			ans = max(ans, count);
		}
	}
	cout << ans << endl;

	return 0;
}

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

string Sp, T;
vector<int> Vs{};
string lastStr = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";
// int lastInd = -1;

bool could(int i) {
  for (int j = 0; j < T.size(); ++j) {
    if ((i + j) < Sp.size()) {
      if (Sp[i + j] != '?' && Sp[i + j] != T[j]) {
        return false;
      }
    }
    else {return false;}
  }
  return true;
}

bool findLast() {
  for (int i = 0; i < Sp.size(); ++i) {
    if (could(i)) {
      Vs.push_back(i);
    }
  }
  if (Vs.size() > 0) {return true;}
  else {return false;}
}

string restore(int l) {
  string temp = Sp;
  for (int j = 0; j < T.size(); ++j) {
    temp[l + j] = T[j];
  }
  for (int i = 0; i < temp.size(); ++i) {
    if (temp[i] == '?') {temp[i] = 'a';}
  }
  return temp;
}

void findBest() {
  for (int i = 0; i < Vs.size(); ++i) {
    string rest = restore(Vs[i]);
    if (lastStr > rest) {lastStr = rest;}
  }
}

int main(void){
    // Here your code !
    cin >> Sp;
    cin >> T;
    if (!findLast()) {printf("UNRESTORABLE\n");}
    else {
      findBest();
      for (int i = 0; i < Sp.size(); ++i) {printf("%c", lastStr[i]);}
      printf("\n");
    }
    return 0;
}

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

const long mod = 1000000007;
vector<long> fact, invfact;

long power(long n, long k) {
  if (k == 0) return 1;
  long next = power(n, k / 2);
  if (k % 2 == 0) return next * next % mod;
  return next * next % mod * n % mod;
}

void init(long n) {
  fact.push_back(1);
  invfact.push_back(1);
  for (int i = 0; i < n; i++) {
    fact.push_back(fact.at(i) * (i + 1) % mod);
    invfact.push_back(power(fact.at(i + 1), mod - 2));
  }
}

long comb(long n, long r) {
  return fact.at(n) * invfact.at(r) % mod * invfact.at(n - r) % mod;
}

int main()
{
  long n, k;
  cin >> n >> k;
  init(n);
  vector<long> c;
  if (n != k) {
    c.push_back(0);
  } else {
    c.push_back(1);
  }
  for (long i = 0; i < k + 1; i++) {
    if (n - k - 1 < i) {
      c.push_back(0);
    } else {
      c.push_back(comb(n - k - 1, i));
    }
  }
  for (long i = 0; i < k; i++) {
    cout << comb(k - 1, i) * ((c.at(i) + 2 * c.at(i + 1) + c.at(i + 2)) % mod) % mod << endl;
  }
}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int mod = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  //b,a
  ll n;
  cin >> n;
  
  ll ans = 0;
  for(int i = 1; i <= n; i++){
    int count = 0;
    for(int j = 1; j <= i; j++){
      if(i % j == 0)
        count++;
    }
    if(count == 8 && i % 2 == 1)
      ans++;  
  }
  
  cout << ans << "\n";

}

Measured memory_bytes: 256
import std.stdio,std.conv, std.algorithm, std.container,std.array,std.range,std.string,std.typecons;
const dx = [1,0,-1,0];
const dy = [0,1,0,-1];
void read(T...)(auto ref T args){ 
	auto line = readln().split(); 
	foreach(i,ref arg; args) arg = line[i].to!(typeof(arg));
}
int sum(int n){return n * (n + 1)/ 2;}
int tax(int per,int yen) {return yen * (100 +per) / 100;}
void main(){
	int x,y,s;
	while(read(x,y,s),x|y|s){
		int ans ;
		foreach(i;1..s/2+1){
			foreach(j;i..s){
				if (tax(x,i) + tax(x,j) == s ){
					ans = max(ans,tax(y,i) + tax(y,j));break;
				}else if(tax(x,i) + tax(x,j) > s)break;				
			}
		}
		ans.writeln;
	}
}

Measured memory_bytes: 2460
#include <bits/stdc++.h>
using namespace std;
long cas(string S, long k){
long i, s=S[0]-'0', l=S.size(), m=0; string T="";
if(l<k){ return 0; }
for(i=1; i<l; i++){ if(S[i]!='0'){ T=S.substr(i); break; } }
if(k==1){ return 9*(l-1)+s; }
else{
  if(k==3){ m=(s-1)*(l-1)*(l-2)*9*9/2+9*9*3*(l-1)*(l-2)*(l-3)/2; }
  else{ m=(s-1)*(l-1)*9+9*9*(l-1)*(l-2)/2; }
  return m+cas(T, k-1); }
}
int main(){
string N; long K; cin >> N >> K;
cout << cas(N, K) << "\n";
}

Measured memory_bytes: 256
# coding: utf-8
while 1:
    r0,w0,c,r=map(int,input().split())
    if r0==0:
        break
    n=r0/w0
    x=0
    if n>=c:
        print(0)
        continue
    while n<c:
        x+=1
        n=(r0+r*x)/w0
    print(x)


Measured memory_bytes: 5600
l=[[1,2,3,4,5,6,7,8,9]]
for i in range(9):
    l.append([])
    for j in l[-2]:
        if j%10==0:
            l[-1].append(j*10)
            l[-1].append(j*10+1)
        elif j%10==9:
            l[-1].append(j*10+8)
            l[-1].append(j*10+9)
        else:
            k=j%10
            l[-1].append(j*10+k-1)
            l[-1].append(j*10+k)
            l[-1].append(j*10+k+1)
ll=[]
for lis in l:
    ll+=lis
ll.sort()
print(ll[int(input())-1])

Measured memory_bytes: 53164