akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
4 5
0 1 2
0 2 1
1 2 1
1 3 1
2 3 2

output:
3
"""

import sys
from collections import deque


def graph_bfs(source, target, parent):
    visited = [False] * v_num
    queue = deque()
    queue.appendleft(source)
    visited[source] = True

    while queue:
        current = queue.popleft()
        for adj, cp in adj_table[current].items():
            if cp and not visited[adj]:
                queue.append(adj)
                visited[adj] = True
                parent[adj] = current

    return True if visited[target] else False


def graphFordFulkerson(source, sink):
    parent = [-1] * v_num
    max_flow = 0

    while graph_bfs(source, sink, parent):
        path_flow = float('inf')

        bk_1 = sink
        while bk_1 is not source:
            path_flow = min(path_flow, adj_table[parent[bk_1]][bk_1])
            bk_1 = parent[bk_1]

        max_flow += path_flow

        bk_2 = sink
        while bk_2 is not source:
            parent_bk_2 = parent[bk_2]
            assert parent_bk_2 != -1
            # adj_table[parent_bk_2].setdefault(bk_2, 0)
            adj_table[bk_2].setdefault(parent_bk_2, 0)

            # print(bk_2, parent_bk_2, path_flow, bk_1, parent[bk_1], parent, adj_table)
            adj_table[parent_bk_2][bk_2] -= path_flow
            adj_table[bk_2][parent_bk_2] += path_flow
            bk_2 = parent[bk_2]

    return max_flow


def generate_adj_table(_edges):
    for edge in _edges:
        source, target, cp = map(int, edge)
        init_adj_table[source][target] = cp

    return init_adj_table


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    v_num, e_num = map(int, _input[0].split())
    edges = map(lambda x: x.split(), _input[1:])

    init_adj_table = [dict() for _ in range(v_num)]
    adj_table = generate_adj_table(edges)
    ans = graphFordFulkerson(source=0, sink=v_num - 1)
    print(ans)

Measured memory_bytes: 8180
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <cmath>
using Int = long long;
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
int main()
{
    int W, a, b; cin >> W >> a >> b;
    if (a > b) swap(a, b);
    cout << max(0, b - a - W) << endl;
    return 0;
}

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

using namespace std;

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

typedef long long ll;
typedef vector<int> vi;

int main(){
	int n;
    cin >> n;
    vi b(n-1);
    rep(i, n-1){
        cin >> b[i];
    }
    ll ans = b[0];
    for(int i = 1; i < n-1; i++){
        ans += min(b[i], b[i-1]);
    }
    ans += b[n-2];

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


Measured memory_bytes: 256
<?php
$result=1;  //一番西側の山は必ず海が見える
$in_a=fgets(STDIN);
$in_b=fgets(STDIN);
$input=explode(" ",$in_b);

$count=count($input);

$max_height=$input[0];

for($i=1;$i<$count;$i++){
    if($input[$i-1]<=$input[$i]){
        if($max_height<=$input[$i]){
            $max_height=$input[$i];
            $result++;
        }
    }
}
echo $result;


Measured memory_bytes: 4604
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"


const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,1,0,-1 };
struct aa {
	int x;
	int y;
	int time;
};
int main() {
	while (1) {
		int W, H; cin >> W >> H;
		if (!W)break;
		vector<vector<vector<int>>>field(H, vector<vector<int>>(W,vector<int>(4)));
		for (int y = 0; y < 2*H-1; ++y) {
			if (y % 2) {
				for (int x = 0; x < W; ++x) {
					int a; cin >> a;
					if (a) {
						field[y / 2][x][1] = true;
						field[y / 2 + 1][x][3] = true;
					}
				}
			}
			else {
				for (int x = 0; x < W-1; ++x) {
					int a; cin >> a;
					if (a) {
						field[y / 2][x][2] = true;
						field[y / 2][x + 1][0] = true;
						
					}
				}
			}
		}
		vector<vector<int>>memo(H, vector<int>(W, 1e8));
		queue<aa>que; que.push(aa{ 0,0,0 });
		memo[0][0] = 0;
		int ans = 0;
		while (!que.empty()) {
			aa atop= que.front();
			
			que.pop();
			for (int way = 0; way < 4; ++way) {
				const int newx = atop.x + dx[way];
				const int newy = atop.y + dy[way];
				if (newx >= 0 && newx < W&&newy >= 0 && newy < H&&!field[atop.y][atop.x][way]) {
					if (memo[newy][newx] > atop.time + 1) {
						memo[newy][newx] = atop.time + 1;
						que.push(aa{ newx,newy,atop.time + 1 });
					}
				}
			}
		}
		if (memo[H - 1][W - 1]<1e6) {
			cout << memo[H - 1][W - 1]+1 << endl;
		}
		else {
			cout << 0 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3208
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <map>
#include <functional>
#include <cmath>
#include <cstdint>
#include <mutex>
#include <thread>
#include <bitset>


using namespace std;

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

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

	while (1)
	{
		c -= b;

		if (c <= 0)
		{
			cout << "Yes";
			break;
		}

		a -= d;

		if (a <= 0)
		{
			cout << "No";
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 3624
//ALDS1_6_A Sort II - Counting Sort
#include <cstdio>
using namespace std;
#define MAX 2000001
#define VMAX 10000

void dump(int *A, int s,int n)
{
	for (int i = s; i < n; i++)
	{
		if (i != s)
			printf(" ");
		printf("%d", A[i]);
	}
	printf("\n");
}

int main(void)
{

	int n, k = 0;
	scanf("%d", &n);
	int *A = new int[n + 2];
	int *B = new int[n + 2];
	for (int i = 0; i < n; i++)
	{
		int a;
		scanf("%d", &A[i+1]);
		if (A[i+1] > k)
		{
			k = A[i+1];
		}
	}
	//dump(A,1, n+1);
	int *C = new int[k + 1];
	//初期化
	for (int i = 0; i < k+1; i++)
	{
		C[i] = 0;
	}
	//dump(C,0, k+1);
	//要素の数を数える
	for (int i = 0; i < n; i++)
	{
		C[A[i+1]]++;
	}
	//dump(C,0, k+1);
	//要素の累積数
	for (int i = 1; i < k+1; ++i)
	{
		C[i] = C[i] + C[i - 1];
	}
	//dump(C,0, k+1);
	for (int j = n; j >= 1; j--)
	{
		B[C[A[j]]] = A[j];
		C[A[j]] = C[A[j]] - 1;
	}
	dump(B,1, n+1);
	delete[] A;
	delete[] B;
	delete[] C;
	return 0;
}



Measured memory_bytes: 17928
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=2e5+5;
int n;ll m,a[N]={0},tree[20][N],as[N];
int num[20][N];
void build(int c,int lef,int rig) {
    int mid=(lef+rig)>>1,left_num=mid-lef+1,l=lef,r=mid+1;
    for(int i=lef;i<=rig;i++) if(tree[c][i]<as[mid]) left_num--;
    for(int i=lef;i<=rig;i++) {
        num[c][i]=num[c][i-1];
        if(i==lef) num[c][i]=0;
        if(tree[c][i]==as[mid]) {
            if(left_num) left_num--,num[c][i]++,tree[c+1][l++]=tree[c][i];
            else tree[c+1][r++]=tree[c][i];
        }
        else if(tree[c][i]<as[mid]) tree[c+1][l++]=tree[c][i],num[c][i]++;
        else tree[c+1][r++]=tree[c][i];
    }
    if(lef==rig) return;
    build(c+1,lef,mid);build(c+1,mid+1,rig);
}
ll query(int c,int lef,int rig,int ql,int qr,int k) {
    int s,ss,mid=(lef+rig)>>1;//s为ql--qr区间进入左子树的个数，ss为lef--ql-1区间进入左子树的个数
    int b,bb;//b为lef--qr-1区间进入右子树的个数，bb为ql--qr区间进入右子树的个数
    if(ql==lef) s=num[c][qr],ss=0;
    else s=num[c][qr]-num[c][ql-1],ss=num[c][ql-1];
    if(lef==rig) return tree[c][lef];
    if(s>=k) {
        ql=lef+ss;qr=ql+s-1;
        return query(c+1,lef,mid,ql,qr,k);
    }
    else {
        b=ql-lef-ss;
        bb=qr-ql+1-s;
        ql=mid+b+1;//需要忽略lef--ql-1区间中进入右子树的数
        qr=ql+bb-1;
        return query(c+1,mid+1,rig,ql,qr,k-s);
    }
}
int main() {
    scanf("%d%lld",&n,&m);
    for(int i=1;i<=n;i++) scanf("%lld",a+i),a[i]-=m,a[i]+=a[i-1],as[i]=a[i];
    for(int i=1;i<=n;i++) tree[0][i]=a[i];
    ll ans=0,cur=0;
    sort(as+1,as+1+n);
    build(0,1,n);
    for(int i=1;i<=n;i++) {
        int l=i,r=n+1,mid;
        while(l<r) {
            mid=((l+r)>>1)-i+1;
            if(query(0,1,n,i,n,mid)<cur) l=mid+i;
            else r=mid+i-1;
        }
        ans+=n+1-r;
        cur=a[i];
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 50304
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <set>
#include <deque>
#include <queue>
#include <bitset>
#include <stack>

#define mod 1000000007
#define INF2 9999999999
#define INF (1<<30)
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
//#define P pair<int, int>

using namespace std;
using ll = __int64_t;

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int DX[] = {1, 1, 0, -1, -1, -1, 0, 1};
int DY[] = {0, -1, -1, -1, 0, 1, 1, 1};

void solve(){
  int n, res=0;
  string s;
  char alphabet[2][30];
  cin >> n >> s;
  
  for(int i = 0; i < n; i++){
    rep(m, 2){
      rep(n, 30){
        alphabet[m][n] = false;
      }
    }
    for(int j = 0; j <= i; j++){
      alphabet[0][s[j]-'a'] = true;
    }
    for(int k = i+1; k < n; k++){
      alphabet[1][s[k]-'a'] = true;
    }
    int temp = 0;
    for(int l = 0; l < 30; l++){
      if(alphabet[0][l] && alphabet[1][l]) temp++;
    }
    res = max(temp, res);
  }
  cout << res << endl;
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
#define For(i,n) for(int i=1;i<=n;i++)
#define Fork(i,k,n) for(int i=k;i<=n;i++)
#define ForkD(i,k,n) for(int i=n;i>=k;i--)
#define Rep(i,n) for(int i=0;i<n;i++)
#define ForD(i,n) for(int i=n;i;i--)
#define RepD(i,n) for(int i=n;i>=0;i--)
#define Forp(x) for(int p=pre[x];p;p=next[p])
#define Forpiter(x) for(int &p=iter[x];p;p=next[p])  
#define Lson (o<<1)
#define Rson ((o<<1)+1)
#define MEM(a) memset(a,0,sizeof(a));
#define MEMI(a) memset(a,0x3f,sizeof(a));
#define MEMi(a) memset(a,128,sizeof(a));
#define MEMx(a,b) memset(a,b,sizeof(a));
#define INF (0x3f3f3f3f)
#define F (1000000007)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vi vector<int> 
#define pi pair<int,int>
#define SI(a) ((a).size())
#define Pr(kcase,ans) printf("Case #%d: %lld\n",kcase,ans);
#define PRi(a,n) For(i,n-1) cout<<a[i]<<' '; cout<<a[n]<<endl;
#define PRi2D(a,n,m) For(i,n) { \
						For(j,m-1) cout<<a[i][j]<<' ';\
						cout<<a[i][m]<<endl; \
						} 
#pragma comment(linker, "/STACK:102400000,102400000")
#define ALL(x) (x).begin(),(x).end()
#define gmax(a,b) a=max(a,b);
#define gmin(a,b) a=min(a,b);
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
ll mul(ll a,ll b){return (a*b)%F;}
ll add(ll a,ll b){return (a+b)%F;}
ll sub(ll a,ll b){return ((a-b)%F+F)%F;}
void upd(ll &a,ll b){a=(a%F+b%F)%F;}
inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(!isdigit(ch)) {if (ch=='-') f=-1; ch=getchar();}
	while(isdigit(ch)) { x=x*10+ch-'0'; ch=getchar();}
	return x*f;
} 
#define MAXN (112345)
bool use[MAXN]={};
typedef pair<int,pi > pii;
pair<int ,pi > l[MAXN],r[MAXN];
int cmp(pii a,pii b){
	return a.se.fi>b.se.fi;
}
int cmp2(pii a,pii b){
	return a.se.se<b.se.se;
}
ll dis(ll &now,pi p) {
	if(p.fi<=now&&now<=p.se) return 0;
	else if(now<p.fi) {
		ll c=p.fi-now; now=p.fi; return c;
	}else {
		ll c=now-p.se; now=p.se; return c;
	}
}
int main()
{
//	freopen("C.in","r",stdin);
//	freopen(".out","w",stdout);
	int n=read(); 
	For(i,n) {
		int x=read(),y=read();
		r[i]=l[i]=mp(i,mp(x,y));
	}
	sort(l+1,l+1+n,cmp);
	sort(r+1,r+1+n,cmp2);
	ll ans=0;
	int i=1,j=1;
	ll now=0;
	For(kk,n) {
		if(kk%2) {
			while(use[l[i].fi]) ++i;
			use[l[i].fi]=1;
			ans+=dis(now,l[i].se);
		}else {
			while(use[r[j].fi]) ++j;
			use[r[j].fi]=1;
			ans+=dis(now,r[j].se);
		}
	}
	ans+=max(now,-now);
	ll ans2=ans;
	
	ans=0;now=0;i=j=1;
	MEM(use)
	For(kk,n) {
		if(kk%2==0) {
			while(use[l[i].fi]) ++i;
			use[l[i].fi]=1;
			ans+=dis(now,l[i].se);
		}else {
			while(use[r[j].fi]) ++j;
			use[r[j].fi]=1;
			ans+=dis(now,r[j].se);
		}
	}
	ans+=max(now,-now);
//	cout<<ans<<' '<<ans2<<endl;
	
//	ans=min(ans,ans2);
	
	cout<<max(ans,ans2)<<endl;	
	
	return 0;
}


Measured memory_bytes: 2688
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)

//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

vector<int> d;

int main(){
    int n,k;
    cin >> n>> k;
    rep(i,n){
        int v;
        cin >> v;
        d.push_back(v);
    }
    int ans=0;
    rep(l,min(k,n)+1){
        reps(r,0,min(k,n)-l+1){
            
            int temp=0;
            vector<int> e;
            rep(i,l){
                e.push_back(d[i]);
                temp+=d[i];
            }
            rep(i,r){
                e.push_back(d[n-i-1]);
                temp+=d[n-i-1];
            }
                /*
                rep(i,e.size()){
                    cerr<<e[i]<<' ';
                }
                cerr<<endl;
                */
            sort(e.begin(),e.end());
        
            rep(i,min(r+l,k-r-l)){
                if(e[i]<0){
                    temp-=e[i];
                }
            }
                
                //cerr<<temp<<endl;
            ans=max(ans,temp);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
const lines: string[] = [];
const reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
});
reader.on("line", function (line: string) {
  lines.push(line);
});

let dp: any;
let inputSize;

//数字の配列
let input: any = [];

reader.on("close", function () {
  inputSize = Number(lines[0]);
  input = lines[1].split(" ").map(Number);

  dp = input.map(() => {
    return Infinity;
  });

  dp[0] = 0;

  for (let i = 1; i < inputSize; i++) {
    if (i > 0) {
      dp[i] = Math.min(dp[i], dp[i - 1] + abs(input[i - 1] - input[i]));
    }
    if (i > 1) {
      dp[i] = Math.min(dp[i], dp[i - 2] + abs(input[i - 2] - input[i]));
    }
  }
  console.log(dp[inputSize - 1]);
});

function abs(val: number) {
  return val < 0 ? -val : val;
}


Measured memory_bytes: 29328
w, h, n = map(int, input().split(" "))

graph = list()
for x in range(0, w + 1):
    graph.append([0 for y in range(0, h + 1)])

for loop in range(0, n):
    x, y, a = map(int, input().split(" "))

    if a == 1:
        for dx in range(0, x):
            for dy in range(0, h + 1):
                graph[dx][dy] = 1

    if a == 2:
        for dx in range(x + 1, w + 1):
            for dy in range(0, h + 1):
                graph[dx][dy] = 1

    if a == 3:
        for dx in range(0, w + 1):
            for dy in range(0, y):
                graph[dx][dy] = 1

    if a == 4:
        for dx in range(0, w + 1):
            for dy in range(y + 1, h + 1):
                graph[dx][dy] = 1

all = True
min_x = 1000
max_x = -1
min_y = 1000
max_y = -1
for x in range(0, w + 1):
    # print(graph[x])
    for y in range(0, h + 1):
        if graph[x][y] == 0:
            all = False
            min_x = min(min_x, x)
            max_x = max(max_x, x)
            min_y = min(min_y, y)
            max_y = max(max_y, y)

if all:
    print(0)
else:
    print((max_x - min_x) * (max_y - min_y))


Measured memory_bytes: 3188
n, k = map(int, input().split())
s = input()
res = ''

for i in range(n):
    if (i == k - 1):
#        res.append(s[i].lower)
        res += s[i].lower()
    else:
#        res.append(s[i])
        res += s[i]

print(res)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
 
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
 
long double a, b, x;
 
void input() {
    cin >> a >> b >> x;
}
 
long double f(long double a, long double b, long double theta) {
    if(theta > PI / 2.0 - EPS) {
        return 0.0;
    }
    long double ret;
    if(a * tan(theta) <= b) {
        ret = a * a * b - a * a * a * tan(theta) / 2.0;
    } else {
        ret = b * b / tan(theta) * a / 2.0;
    }
    return ret;
}
 
void solve() {
    input();
    long double ok = PI / 2.0;
    long double ng = 0.0;
    for(int _ = 1; _ <= 100000; _++) {
        long double mid = (ok + ng) / 2.0;
        if(f(a, b, mid) < x) ok = mid;
        else ng = mid;
    }
    cout << fixed << setprecision(10) << ok / PI * 180 << endl;
    return;
}
 
int main() {
    solve();
    return 0;
}

Measured memory_bytes: 4072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int N; cin >> N;
    int ans = 0;
    for(int i=0; i<N; i++){
        int a; cin >> a;
        a--;
        ans += a;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <math.h>
#include <string>
#include <cstdlib>

int dx[8] = {1, 2, 1, 2, -1, -2, -1, -2}, dy[8] = {2, 1, -2, -1, -2, -1, 2, 1};

int main() {
	int a, b, c; cin >> a >> b >> c;
	if(a == b) {
		if(b == c) cout << 1 << endl;
		else cout << 2 <<endl;
	}
	else {
		if(b != c && a != c) cout << 3 << endl; 
		else cout << 2 <<endl;
	}
}

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

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

// Yes-Noを出力する問題で楽をする
void Ans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

//---------------------------

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int d = abs(a-b), e = abs(b-c), f = abs(c-a);
    cout << d+e+f-max(max(d,e),f) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int K = Integer.parseInt(sc.next());
        sc.nextLine();
        boolean D[] = new boolean[10];
        for (int i = 0; i < K; i++) {
            int index = Integer.parseInt(sc.next());
            D[index] = true;
        }
        int n = N;
        while (n <= 10*N) {
            int tmp = n;
            while (tmp > 0) {
                if (D[tmp%10])
                    break;
                tmp /= 10;
            }
            if (tmp==0)
                break;
            n++;
        }
        System.out.println(n);
        sc.close();
    }   
}

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

using namespace std;
int main() {
	int a[30];
	int x;
	for (int i = 0; i < 30; i++) {
		a[i] = -1;
	}

	for (int i = 0; i < 28; i++) {
		cin >> x;
		a[x-1] = 0;
	}
	for (int i = 0; i < 30; i++) {
		if (a[i] == -1) cout << i+1 << endl;
	}


	
	


	//getchar();
	//getchar();
}

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

int main()
{
  ll a,b,c;
  cin >> a >> b >> c;
  if(a+b+c>=22)
  {
    cout << "bust" << endl;
  } else {
    cout << "win" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<algorithm>

using namespace std;

bool judge(const int x,const char str[]){
	
	char ans[1000];
	
	if(x%3 ==0 && x%5 == 0)
		strcpy(ans,"FizzBuzz");
	else if(x%3==0)
		strcpy(ans,"Fizz");
	else if(x%5==0)
		strcpy(ans,"Buzz");
	else
		sprintf(ans,"%d",x);
	
	/*
	cout << "judge" << endl;
	cout << "-" << str << "-" << endl;
	cout << "-" << ans << "-" << endl;
	*/
	if( strcmp(ans,str) )return false;
	
	return true;
}

int main(void){
	int m,n;
	while(scanf("%d%d", &m, &n) && m != 0 && n != 0){
		
		queue<int> Q;
		char str[1000];
		vector<int> ans;
		
		for(int i = 1; i <= m; i++)
			Q.push(i);
		
		for(int i = 1; i <= n; i++){
			scanf("%s", str);
			if(Q.size() == 1)continue;
			
			if( judge(i,str) ){
				Q.push(Q.front());
				Q.pop();
			}else{
				Q.pop();
			}
		}
		
		while(!Q.empty()){
			ans.push_back(Q.front());
			Q.pop();
		}
		
		sort(ans.begin(),ans.end());
		
		for(int i = 0; i < ans.size(); i++){
			printf("%d%s",ans[i],i==ans.size()-1?"\n":" ");
		}
	}
	return 0;
}

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

int main() {
  int32_t n;
  cin >> n;
  set<int32_t> st;

  int32_t answer = 0;
  for (int32_t i = 0; i < n; i++) {
    int32_t a;
    cin >> a;
    if (st.count(a)) {
      st.erase(a);
      answer--;
    } else {
      st.insert(a);
      answer++;
    }
  }
  cout << answer << endl;
}


Measured memory_bytes: 4864
import java.io.*;
class Main{
	public static void main(String[] args)  throws IOException{ 
		int[][][] Room = new int[4][3][10];
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        	String str = br.readLine();
		int line = Integer.parseInt(str);

		for(int i = 0; i < line; i++) {
 
			String str2 = br.readLine();
        	        String[] str3 = str2.split(" ");
 
                	int Building = Integer.parseInt(str3[0]);
                	int Floor = Integer.parseInt(str3[1]);
                	int RoomFirst = Integer.parseInt(str3[2]);
                	int People = Integer.parseInt(str3[3]);
 
                	Room[Building -1][Floor -1][RoomFirst -1] += People;
           	}
 
 	        for(int l = 0; l < 4; l++) {
                	for(int j = 0; j < 3; j++) {
                    		for(int k = 0; k < 10; k++) {
                        		System.out.print(" " + Room[l][j][k]);
                    		}
                    		System.out.println("");                   
                	}
                	if(l != 3) {
                 		System.out.println("####################");
                	}
		}
	}
}

Measured memory_bytes: 19332
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <cctype>
#include <algorithm>
#include <functional>
#include <utility>
#include <vector>
#include <queue>
using ll = long long;
const int maxn = 105;
const ll INF = 0x7fffffffffffLL;
struct Edge {
  int u, v; ll cap, flow;
};
std::vector<Edge> edges;
std::vector<int> G[maxn];
inline void ins_edge(int u, int v, ll f) {
  edges.push_back((Edge){u, v, f, 0LL});
  edges.push_back((Edge){v, u, 0LL, 0LL});
  const int m = edges.size();
  G[u].push_back(m - 2);
  G[v].push_back(m - 1);
}

int d[maxn]; int s, t;
inline bool bfs() {
  static bool vis[maxn];
  memset(d, 0, sizeof(d));
  memset(vis, 0, sizeof(vis));
  std::queue<int> Q; Q.push(s);
  vis[s] = true; d[s] = 1;
  while(!Q.empty()) {
    const int u = Q.front(); Q.pop();
    for(int i = 0; i < G[u].size(); i ++) {
      Edge &e = edges[G[u][i]];
      if(!vis[e.v] && e.cap > e.flow) {
        vis[e.v] = true;
        d[e.v] = d[u] + 1;
        Q.push(e.v);
      }
    }
  }
  return vis[t];
}
int cur[maxn];
ll dfs(int x, ll a = INF) {
  if(a == 0 || x == t) return a;
  ll ret = 0;
  for(int &i = cur[x]; i < G[x].size(); i ++) {
    Edge &e = edges[G[x][i]];
    const int v = e.v;
    ll f;
    if(d[v] == d[x] + 1 && (f = dfs(v, std::min(a, e.cap - e.flow))) > 0) {
      ret += f; a -= f;
      e.flow += f;
      edges[G[x][i] ^ 1].flow -= f;
      if(a == 0) break;
    }
  }
  if(a > 0) d[x] = -1;
  return ret;
}
inline ll dinic() {
  ll ans = 0;
  while(bfs()) {
    memset(cur, 0, sizeof(cur));
    ans += dfs(s);
  }
  return ans;
}

int A[maxn];
int main() {
  int n; scanf("%d", &n);
  s = 0; t = n + 1;
  ll ans = 0;
  for(int i = 1; i <= n; i ++) {
    scanf("%d", &A[i]);
    if(A[i] >= 0) {
      ans += A[i];
      ins_edge(i, t, A[i]);
    } else {
      ins_edge(s, i, -A[i]);
    }
  }
  for(int i = 1; i <= n; i ++) {
    if(A[i] >= 0) continue;
    for(int j = i * 2; j <= n; j += i) {
      if(A[j] > 0) {
        ins_edge(i, j, INF);
      }
    }
  }
  ans -= dinic();
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author NMouad21
 */
public class Main {
  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    BFrog2 solver = new BFrog2();
    solver.solve(1, in, out);
    out.close();
  }

  static class BFrog2 {
    public final void solve(int testNumber, InputReader in, PrintWriter out) {
      int n = in.nextInt();
      int k = in.nextInt();
      int[] h = in.nextIntArray(n);
      int[] dp = new int[n];
      for (int i = 1; i < n; i++) {
        dp[i] = Math.abs(h[i] - h[i - 1]) + dp[i - 1];
        for (int j = 1; j <= k; j++) {
          if (i - j >= 0) {
            dp[i] = Math.min(dp[i], Math.abs(h[i] - h[i - j]) + dp[i - j]);
          }
        }
      }
      out.println(dp[n - 1]);
    }
  }

  static final class InputReader {
    private final InputStream stream;
    private final byte[] buf = new byte[1 << 16];
    private int curChar;
    private int numChars;

    public InputReader() {
      this.stream = System.in;
    }

    public InputReader(final InputStream stream) {
      this.stream = stream;
    }

    private final int read() {
      if (this.numChars == -1) {
        throw new UnknownError();
      } else {
        if (this.curChar >= this.numChars) {
          this.curChar = 0;

          try {
            this.numChars = this.stream.read(this.buf);
          } catch (IOException ex) {
            throw new InputMismatchException();
          }

          if (this.numChars <= 0) {
            return -1;
          }
        }

        return this.buf[this.curChar++];
      }
    }

    public final int nextInt() {
      int c;
      for (c = this.read(); isSpaceChar(c); c = this.read()) {}

      byte sgn = 1;
      if (c == 45) { // 45 == '-'
        sgn = -1;
        c = this.read();
      }

      int res = 0;

      while (c >= 48 && c <= 57) { // 48 == '0', 57 == '9'
        res *= 10;
        res += c - 48; // 48 == '0'
        c = this.read();
        if (isSpaceChar(c)) {
          return res * sgn;
        }
      }

      throw new InputMismatchException();
    }

    private static final boolean isSpaceChar(final int c) {
      return c == 32 || c == 10 || c == 13 || c == 9
          || c == -1; // 32 == ' ', 10 == '\n', 13 == '\r', 9 == '\t'
    }

    public final int[] nextIntArray(final int n) {
      int[] arr = new int[n];
      for (int i = 0; i < n; i++) {
        arr[i] = nextInt();
      }
      return arr;
    }
  }
}


Measured memory_bytes: 22100
#include <stdio.h>
#include <string.h>
#define N 100;

int main(void){
    char S[5];
    char x[7][5] = {"SAT","FRI","THU","WED","TUE","MON","SUN"};
    int A = 0;
    int n;
    
    scanf("%s",S);
    
    for(n=0;n<10;n++){
        if(strcmp(S,x[n]) == 0){
            A = n + 1;
            break;
        }
    }
   
    
    printf("%d\n",A);
    
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int main()
{
	char a[101];
	cin >> a ;
	int len=strlen(a);
	for(int i=0;i<len;i++)
	{
		a[i]='x';
	}
	cout << a << endl ;
	
	return 0;
}

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

const int INF = 1e9;
int N,R;
int s,t,d;

int dist[1501][1501];
bool used[1501] = {false};
bool memo[1501][1501] = {false};

typedef pair<int,int> PR;
vector<PR> li[1501];

vector<PR> course;

void dijkstra(int rt){
	priority_queue<PR,vector<PR>,greater<PR> > que;
	que.push(make_pair(0,rt));

	while(!que.empty()){
		PR p = que.top(); que.pop();
		int v = p.second;
		if(dist[rt][v] < p.first) continue;
		for(int i = 0; i < li[v].size(); i++){
			PR e = li[v][i];
			if(dist[rt][e.second] > dist[rt][v] + e.first){
				dist[rt][e.second] = dist[rt][v] + e.first;
				que.push(make_pair(dist[rt][e.second],e.second));
			}
		}
	}
}

void running(int src,int dst){
	if(src == dst){
		return;
	}
	if(memo[src][dst]){
		return;
	}
	memo[src][dst] = memo[dst][src] = true;
	used[dst] = true;
	for(int i = 0; i < li[dst].size(); i++){
		int cost = li[dst][i].first;
		int from = li[dst][i].second;
		if(dist[src][from] + cost == dist[src][dst]){
			used[from] = true;
			running(src,from);
		}
	}
}

int main(){
	scanf("%d%d",&N,&R);
	for(int i = 0; i < R; i++){
		scanf("%d%d%d",&s,&t,&d);
		li[s].push_back(make_pair(d,t));
		li[t].push_back(make_pair(d,s));
	}
	for(int i = 1; i <= N; i++){
		for(int j = 1; j <= N; j++){
			dist[i][j] = i == j ? 0 : INF;
		}
	}

	for(int i = 1; i <= N; i++){
		dijkstra(i);
	}

	int mxdist = 0;
	for(int i = 1; i <= N; i++){
		for(int j = i+1; j <= N; j++){
			mxdist = max(mxdist,dist[i][j]);
		}
	}
	for(int i = 1; i <= N; i++){
		for(int j = i+1; j <= N; j++){
			if(dist[i][j] == mxdist){
				course.push_back(make_pair(i,j));
			}
		}
	}
	
	for(int i = 0; i < course.size(); i++){
		running(course[i].first,course[i].second);
	}

	int cnt = 0;
	for(int i = 1; i <= N; i++){
		if(!used[i]){
			cnt++;
		}
	}
	printf("%d\n",cnt);
	for(int i = 1; i <= N; i++){
		if(!used[i]){
			printf("%d\n",i);	
		}
	}
	return 0;
}





Measured memory_bytes: 28196
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


//#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define repB(i, z, n) for(int i = n - 1; i >= z; i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
#define PI 3.14159265358979
//const int64_t INF = 1LL << 60;
//const int INF = 1 << 29;
//const int64_t MOD = 1000000007;
//const int64_t INF = 998244353;
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 namespace std;
//#define P pair<int, int>
typedef pair<int, int> P;
using namespace std;

int main(){
    int K, X;
    cin >> K >> X;
    int start = max(X - K + 1, -1000000);
    int end = min(X + K - 1, 1000000);
    rep(i, start, end + 1){
        cout << i << " ";
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main () {
	int i, n;
        int fib[55];

	fib[0] = 1;
	fib[1] = 1;

	scanf("%d", &n);

	for (i = 2; i <= n; i++) {
		fib[i] = fib[i - 1] + fib[i - 2];
        }

	printf("%d\n", fib[n]);

	return 0;
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) (a).begin(),(a).end()
#define SORT(a) sort(all(a))
#define rSORT(a, i) sort(all(a),(i))

using ll = long long;
constexpr ll INF = 10000000000;
constexpr ll MOD = 1000000007;

using namespace std;

int main() {
	string s; cin >> s;

	ll W = 0;
	ll cnt = 0;
	rep(i, s.size()) {
		if (s[i] == 'W') {
			W += i;
			cnt++;
		}
	}
	
	ll count = cnt * (cnt - 1) / 2;
	cout << W - count << endl;
}

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

#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(v) reverse((v).begin(),(v).end())
#define ANS(ans) cout<<(ans)<<endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)


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

    string ans;

    REP(i, s.length()){
        char c =s[i];
        int num=c-'A';
        ans.push_back('A'+(num+n)%26);
    }
    ANS(ans);

    return 0;
}


Measured memory_bytes: 256
s=str(input())
n=len(s)
a=[0]
count=0
for i in range(n):
    if s[i:i+1]=='<':
        count+=1
        a.append(count)
    else:
        count=0
        a.append(0)
#print(a)
count=0
for i in range(n-1,-1,-1):
    if s[i:i+1]=='>':
        count+=1
        a[i]=max(a[i],count)
    else:
        count=0

print(sum(a))

Measured memory_bytes: 24092
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)
#define pb push_back
#define deb(x) cout<<#x<<" "<<x<<endl;
#define deb2(x, y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define deb3(x, y, z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
const int mod = 1e9 + 7;
template<class T, class U> inline void add_self(T &a, U b){a += b;if (a >= mod) a -= mod;if (a < 0) a += mod;}
template<class T, class U> inline void min_self(T &x, U y) { if (y < x) x = y; }
template<class T, class U> inline void max_self(T &x, U y) { if (y > x) x = y; }

template <typename T>void print(T v, bool show_index = false){int w = 2;if(show_index){for(int i=0; i<v.size(); i++)cout<<setw(w)<<i<<" ";cout<<endl;}for(auto i= v.begin(); i!=v.end(); i++)cout<<setw(w)<<*i<<" ";cout<<endl;}
template <typename T>void print_vv(T v){if(v.size()==0) {cout<<"Empty"<<endl; return;} int w = 3;cout<<setw(w)<<" ";for(int j=0; j<v[0].size(); j++)cout<<setw(w)<<j<<" ";cout<<endl;for(auto i= 0; i<v.size(); i++){cout<<i<<" {";for(auto j = 0; j!=v[i].size(); j++){cout<<setw(w)<<v[i][j]<<",";}cout<<"},"<<endl;}cout<<endl;}
template <class T, class U> void print_m(map<T,U> m, int w=3){if(m.empty()){cout<<"Empty"<<endl; return;}for(auto x: m)cout<<"("<<x.first<<": "<<x.second<<"),"<<endl;cout<<endl;}

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    swap(a,b); swap(a,c);
    cout<<a<<" "<<b<<" "<<c<<endl;

    return 0;
}

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

ll cnt;

void print(vector<int> A) {
  for (int i = 0; i < A.size(); ++i) {
    cout << ( (i) ? " " : "" ) << A[i];
  }
  cout << endl;
}

vector<int> insertionSort(vector<int> A, int n, int g) {
  for (int i = g; i < n; ++i) {
    int v = A[i];
    int j = i - g;
    while (j >= 0 && A[j] > v) {
      A[j + g] = A[j];
      j -= g;
      ++cnt;
    }
    A[j + g] = v;
  }
  return A;
}

vector<int> shellSort(vector<int> A, int n) {
  cnt = 0;
  vector<int> G; {
    for (int h = 1; ; ) {
      if (h > n) break;
      G.push_back(h);
      h = 3 * h + 1;
    }
    cout << G.size() << endl;
    reverse(begin(G), end(G));
    print(G);
  }
  for (int i = 0; i < G.size(); ++i) {
    A = insertionSort(A, n, G[i]);
  }
  return A;
}

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

  int N; { cin >> N; }
  vector<int> A(N); { for (int i = 0; i < N; ++i) cin >> A[i]; }
  A = shellSort(A, N); {
    cout << cnt << endl;
    for (auto&& x : A) cout << x << endl;
  }
  return 0;
}



Measured memory_bytes: 14548
# a ÷ bを考える。bが固定され、aが推移していくことを考えると、余りは0, 1, 2, ...b-1が繰り返される。
# 例 a, b <= 5の場合
# b=1でaが推移していく場合 ：a=0で余り0, a=1で余り0, a=2で余り0, a=3で余り0, a=4で余り0, a=5で余り0
# b=2でaが推移していく場合 ：a=0で余り0, a=1で余り1, a=2で余り0, a=3で余り1, a=4で余り0, a=5で余り1
# b=3でaが推移していく場合 ：a=0で余り0, a=1で余り1, a=2で余り2, a=3で余り0, a=4で余り1, a=5で余り2
# b=4でaが推移していく場合 ：a=0で余り0, a=1で余り1, a=2で余り2, a=3で余り3, a=4で余り0, a=5で余り1
# b=5でaが推移していく場合 ：a=0で余り0, a=1で余り1, a=2で余り2, a=3で余り3, a=4で余り4, a=5で余り0
# 上記より、bをループさせれば「ある値以上の余りがいくつあるか」を求められる？
# 上記の右側の部分の合計をO(1)で求めたい


n, k = map(int, input().split())

if k == 0:
    print(n*n)
    exit()
res = 0
# bをnumとして考える
for num in range(k, n + 1):
    # numに対して余りのループがいくつあるか考える
    group = n // num
    mod = n % num

    # 余りの最大値はnum-1
    # group×「1グループ内にどれだけ余りがkを超える数があるか」 + 「1グループに満たないもの」
    res += group * max(0, num - k) + max(mod - k+1, 0)
print(res)


Measured memory_bytes: 2940
#include <iostream>
#include <numeric>
#include <string>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <cmath>

#define repd(i,a,b); for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define ll long long int
 
 
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n],x[n];
  rep(i,n){
    cin >> a[i];
  }
  int sum=0;
  int sub=0;
  rep(j,n){
    sum += a[j];
  }
  for(int k=0;k<(n-1)/2;k++){
    sub += a[2*k];
  }
  x[n-1] = sum-2*sub;
  x[0] = 2*a[n-1] - x[n-1];
  for(int m=1;m<(n-1);m++){
    x[m] = 2*a[m-1] - x[m-1];
  }
  rep(p,n){
    cout << x[p] << " ";
  }
  
  
 
 return 0;
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
#define ll long long
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
 
int main()
{
	long long int n, sum = 0;
	cin >> n;

	for (long long int i = 1; i < n+1; i++)
	{
		if (i%3 != 0 && i%5 != 0)
		{
			sum = sum + i;
		}
	}

	cout << sum;

	return 0;
}

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

using namespace std;

typedef long long ll;

#define faster ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define read freopen("in.txt","r",stdin)
#define write freopen("out.txt","w",stdout)
#define mem(x,n) memset(x,n,sizeof(x))
#define all(x) x.begin(), x.end()
#define endl "\n"

int main()
{
	faster;
	
	string s;
	cin >> s;

	ll ans = 0;

	for(ll i = 0; i < s.size(); i++){
		ans += s[i]-'0';
	}

	cout << ((ans % 9 == 0) ? "Yes" : "No") << endl;
	
	return 0;
}

Measured memory_bytes: 3696
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (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, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
    }

    println!("{}", (n-1)/2);
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <math.h>

int main(int argc, const char * argv[]) {
    double x1, x2, y1, y2;
    scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
    printf("%.8lf\n", sqrt((x1-x2) * (x1-x2) + (y1-y2) * (y1-y2)));
    return 0;
}



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

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

	int			n;
	cin >> n;
	vector<int>	A(n);
	vector<int>	B;

	/* rep(i, n) */
	/* 	cin >> A.at(i); */
	for (int &a : A)
		cin >> a;
	B = A;
	sort(B.rbegin(), B.rend());
	/* max = B.at(0); */
	/* second_max = B.at(1); */
	rep(i, n)
	{
		if (A.at(i) != B.at(0))
			cout << B.at(0) << endl;
		else
			cout << B.at(1) << endl;
	}
}


Measured memory_bytes: 3200
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#include <complex>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000; //10^15
typedef long long ll;
typedef unsigned long long ull;


ll powMod(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll t = powMod(x, n/2, mod);
  t = t * t % mod;
  if (n & 1) return t * x % mod;
  return t;
}


int main(void) {

  string s; int a = 0, b = 0;
  cin >> s;
  rep(i, 3) {
    if (s[i] == 'A') a++;
    if (s[i] == 'B') b++;
  }
  if (a *b != 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;

}


Measured memory_bytes: 256
def factoring(n):
    """
    This program factorize any number.
    This returns the dictionary of prime factors of the number.(if n=18=2*3**2, this returns {2:1,3:2})
        """
    if n == 0:
        return {0: 1}
    if n == 1:
        return {1: 1}

    # 今回のアルゴリズムについて
    # nが素数でない⇔nは√n以下の素因数を持つ⇒√n以下のすべての素数を列挙して、それでnを割っていってみる。
    #√n以下の素数をすべて書き出すために、エラトステネスの篩を使用する。t以下の素数をすべて列挙するためには√tまでの素数について調べれば十分なので、√nまでの素数を書き出すためには√√nまでの数について真面目に篩をかければいい。

    nOrigin = n
    n = n**0.5
    # n(=√input())以下の素数のリストをエラトステネスにより作成する
    # 素数の位置にはその数が、合成数の位置には-1が格納されているリストを作成
    # 0が格納されているのはまだ確認していない数。
    numlist = [0 for i in range(int(n) + 1)]
    numlist[0] = -1
    numlist[1] = -1

    #√√n以下の数について篩をかけていく
    t = 2
    while t < (n**0.5):
        if numlist[t] == 0:
            numlist[t] = t
            k = 2
            while t * k <= n:
                numlist[t * k] = -1
                k += 1
        t += 1

    #√√nより大きい数で、篩にかからなかった数は素数。
    while t <= n:
        if numlist[t] == 0:
            numlist[t] = t
        t += 1

    #√n以下の数で割っていく。
    result = {}
    for i in numlist:
        if i == -1:
            continue
        j = 0
        while nOrigin % i == 0:
            j += 1
            nOrigin = nOrigin / i
        if j == 0:
            continue
        else:
            result[i] = j

    if int(nOrigin) != 1:
        result[int(nOrigin)] = 1
    return result


n=int(input())

fact=factoring(n)
retval=1
for i in fact.items():
    retval*=(i[0]**i[1]-i[0]**(i[1]-1))
print(retval)



Measured memory_bytes: 6016
import sys
sys.setrecursionlimit(10 ** 6)


def dfs(n, v, m):
    global N, M, X
    rst = 10 ** 8
    if n == N:
        if all(x >= X for x in m):
            rst = v
    else:
        nv = v + C[n]
        nm = tuple(m[i] + A[n][i] for i in range(M))
        rst = min(dfs(n + 1, v, m), dfs(n + 1, nv, nm))
    return rst


N, M, X = map(int, input().split())
A = [None] * N
C = [None] * N
for i, s in enumerate(sys.stdin.readlines()):
    C[i], *A[i] = map(int, s.split())

rst = dfs(0, 0, tuple([0] * M))
ans = rst if rst < 10 ** 8 else -1
print(ans)


Measured memory_bytes: 9332
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;

int main()
{
    char str[11];
    string ans;
    int i = 0;
    scanf("%s", str);
    while (str[i] != '\0')
    {
        if (str[i] == 'h' && str[i + 1] == 'i')
        {
            ans = "Yes";
            i += 2;
        }
        else
        {
            ans = "No";
            break;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N;
double T, A;
vector<int> H(1010);
int main() {
    cin >> N;
    cin >> T >> A;
    for(int i = 0; i < N; ++i) {
        cin >> H.at(i);
    }

    int num = 0;
    double min = 100000.0;
    for(int i = 0; i < N; ++i) {
        double tmp = T - (double)H.at(i) * 0.006;
        double sub = abs(A - tmp);
        if(sub < min) {
            min = sub;
            num = i+1;
        }
    }
    cout << num << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<cstring>
#include<queue>
#include<cmath>
#include<algorithm>
using namespace std;
long long n,s;
long long f(long long x,long long y)
{
	long long re=0;
	while(x!=0)
	{
		re+=x%y;
		x/=y;
	}
	return re;
}
int main()
{
	scanf("%lld %lld",&n,&s);
	long long e=n-s;
	if(n==s)
	{
		printf("%lld",n+1);
		return 0;
	}
	if(e<0)
	{
		printf("-1\n");
		return 0;
	}
	if(s==1)
	{
		for(long long i=2;i*i<=n;i++)
		{
			if(n%i==0)
			{
				long long k=1;
				while(k<n)
				{
					k=k*i;
				}
				if(k==n)
				{
					printf("%lld\n",i);
					return 0;
				}
			}
		}
		printf("%lld\n",max(n,2ll));
		return 0;
	}
	long long jans=9223372036854775807ll;
	for(long long i=1;i*i<=e;i++)
	{
		if(e%i==0)
		{
			long long ans=i+1;
			if(f(n,ans)==s)
			{
				jans=min(jans,ans);
			}
			ans=e/i+1;
			if(f(n,ans)==s)
			{
				jans=min(jans,ans);
			}
		}
	}
	if(jans!=9223372036854775807ll)
		printf("%lld\n",jans);
	else
	{
		printf("-1\n");
	}
}

Measured memory_bytes: 128
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		a,b,c,h,i,j,k,l,m,n,x,y;
	ll		ans = INFL;
	string	s;
	cin >> n;
	for(i=1;i<=100000;i++) {
		if (i>n) break;
		if (n%i!=0) continue;
		x = i;
		y = n/i;
		a = b = 0;
		while(x>0) {
			x = x / 10;
			a++;
		}
		while(y>0) {
			y = y / 10;
			b++;
		}
		ans = min(ans , max(a,b));

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


Measured memory_bytes: 256