akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int ans = 0;
    for(int i = 0; i < s.size(); i++)
    {
        if(s[i] == '2') ans++;
    }
    cout << ans << endl;
    return 0;
}



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

using namespace std;

int main(){

	string str;
	cin >> str;
	int q;
	cin >> q;
	for(int i = 0; i < q; i++){
		string command;
		int a, b;
		cin >> command >> a >> b;
		if(command == "print"){
			cout << str.substr(a, b-a+1) << endl;
		}
		if(command == "reverse"){
			reverse(str.begin()+a, str.begin()+b+1);
		}
		if(command == "replace"){
			string p;
			cin >> p;
			str.replace(a, b-a+1, p);
		}
	}
	return 0;
}

Measured memory_bytes: 1220
def d_chat_in_a_circle():
    N = int(input())
    A = sorted([int(i) for i in input().split()], reverse=True)

    ans = [A[0]]
    j = 1
    while True:
        ans.extend([A[j]] * 2)
        j += 1
        if len(ans) > N - 1:
            ans.pop()
            break
    if N % 2 == 0:
        ans.pop()
    return sum(ans)

print(d_chat_in_a_circle())

Measured memory_bytes: 31600
price = int(input())

N =price//1.08
if (N)*1.08 >= price and (N)*1.08 < price+1:
  print(int(N))
elif (N+1)*1.08 >= price and (N+1)*1.08 < price+1:
  print(int(N+1))
else:
  print(":(")

Measured memory_bytes: 3060
#include <stdio.h>

int main(void){

  int a,s,m,h;
  scanf("%d",&a);

  s = a % 60;
  m = a / 60;
  h = m / 60;

  m = m % 60;
  printf("%d:%d:%d\n",h,m,s);

  return 0;
}

Measured memory_bytes: 592
n = int(input())

a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

ans = sum(b)

for i in range(n-1):
    if a[i+1] - a[i] == 1:
        ans += c[a[i] - 1]

print(ans)

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

int digit(int n){
    int res=0;
    if (!n) return 1;
    while(n){n/=10; ++res;}
    return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> d(n);
    for (int i=0;i<n;++i) cin >> d[i];
    for (int i=0;;++i){
        int di=digit(i),ok=0;
        for (int j=0;j+di-1<n;++j){
            int cnt=0;
            for (int k=0;k<di;++k){
                cnt*=10; cnt+=d[j+k];
            }
            if (cnt==i){ok=1; break;}
        }
        if (!ok){
            cout << i << '\n';
            return 0;
        }
    }
}


Measured memory_bytes: 3220
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep1(i,n) for(ll i=1;i<(ll)n;i++)
#define repf(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define repr(i,a,b) for(ll i=(ll)a-1;i>=(ll)b;i--)
#define Fi first
#define Se second
typedef pair<ll, ll> pll;
const ll MAX = 1005;
const char END = '\n';

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

	ll N, K, Ans = 0;
	cin >> N >> K;
	vector<ll> h(N);
	rep(i, N) {
		cin >> h[i];
		if (h[i] >= K)
			Ans++;
	}

	cout << Ans << END;
	return 0;
}


Measured memory_bytes: 1024
import math

a, b, h, m = map(int, input().split())

# 時針（0時からa時）の角度
j = 360/(12*60) * (h*60+m)

# 分針の角度
f = 360/60 * m

# 余弦定理に使う角度
beta = abs(j-f)

# 角度が180度より大きい時は360度から引く
if beta>180:
    beta = 360-beta

print(math.sqrt((a**2)+(b**2)-2*a*b*math.cos(math.radians(beta))))

Measured memory_bytes: 9516
#include<iostream>
#include<stdio.h>
using namespace std;
int main() {
	int a, b, c, n=100000,s;
	cin >> a;
	for (a; a > 0; a--) {
		n *= 1.05;
		if (n % 1000 != 0)n += 1000;
		n /= 1000;
		n *= 1000;
	}
		cout << n<<endl;
	return 0;
}



Measured memory_bytes: 3092
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<queue>
#include<map>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;

vector<int> to[200005];
vector<int> ans;

void dfs(int v, int p=-1){
    for(int u : to[v]){
        if(u==p) continue;
        ans[u] += ans[v];
        dfs(u,v);
    }
}

int main(){
    int n,q;
    cin >> n >> q;
    for(int i=0;i<n-1;i++){
        int a,b;
        cin >> a >> b; --a; --b;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    ans.resize(n);
    for(int i=0;i<q;i++){
        int p,x;
        cin >> p >> x; p--;
        ans[p] += x;
    }
    dfs(0);
    rep(i,n){
        cout << ans[i] << ' ';
    }
    cout << endl;
}

Measured memory_bytes: 23424
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    int n;
    ArrayList<Edge>[] es;
    int q, k;
    int[] xs, ys;

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

    private void read() {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        es = new ArrayList[n];
        for (int i = 0; i < n; i++)
            es[i] = new ArrayList<>();
        for (int i = 1; i < n; i++) {
            int a = sc.nextInt()-1;
            int b = sc.nextInt()-1;
            long c = sc.nextLong();
            es[a].add(new Edge(a, b, c));
            es[b].add(new Edge(b, a, c));
        }
        q = sc.nextInt(); k = sc.nextInt()-1;
        xs = new int[q]; ys = new int[q];
        for (int i = 0; i < q; i++) {
            xs[i] = sc.nextInt() - 1;
            ys[i] = sc.nextInt() - 1;
        }
    }

    private void solve() {
        long[] ret = new long[n];
        Arrays.fill(ret, Long.MAX_VALUE);
        boolean[] used = new boolean[n];
        dfs(k, 0L, used, ret);
        long d1, d2;
        for (int i = 0; i < q; i++) {
            d1 = ret[xs[i]]; d2 = ret[ys[i]];
            System.out.println(d1+d2);
        }
    }


    private void dfs(int cur, long cost, boolean[] used, long[] path) {
        if (used[cur])
            return;
        used[cur] = true;
        path[cur] = cost;
        for (Edge e: es[cur]) {
            if (!used[e.b]) {
                dfs(e.b, cost + e.c, used, path);
            }
        }
    }

    private class Edge {
        int a, b;
        long c;
        Edge(int a, int b, long c) {
            this.a = a;
            this.b = b;
            this.c = c;
        }
    }
}


Measured memory_bytes: 193964
#include <stdio.h>

int main()
{
	int i, N, M;
	char S[100002];
	scanf("%d %d", &N, &M);
	scanf("%s", S);
	
	int j, k, dice[100001];
	for (i = N, k = 0; i > 0; ) {
		for (j = (i < M)? i: M; j >= 1; j--) if (S[i-j] == '0') break;
		if (j == 0) break;
		dice[k++] = j;
		i -= j;
	}
	
	if (i > 0) printf("-1\n");
	else {
		for (i = k - 1; i >= 1; i--) printf("%d ", dice[i]);
		printf("%d\n", dice[0]);
	}
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 2128
#include <stdio.h>

int main(void) {
  int t, n, s, f, sum;

  while (1) {
    scanf("%d", &t);
    if (t == 0) break;

    scanf("%d", &n);

    sum = 0;
    while (n--) {
      scanf("%d %d", &s, &f);
      sum += f - s;
    }

    if (sum >= t)
      printf("OK\n");
    else
      printf("%d\n", t - sum);
  }

  return 0;
}

Measured memory_bytes: 612
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n,x,count;
    while((n = sc.nextInt()) != 0 | (x = sc.nextInt()) != 0){
      count=0;
      for(int i=1;i <= n-2;i++){
        for(int j=i+1;j <= n-1;j++){
          for(int k=j+1;k <= n;k++){
            if(i+j+k == x)count++;
          }
        }
      }
      System.out.println(count);
    }
    sc.close();
  }
}



Measured memory_bytes: 26508
#include <stdio.h>

#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define STRS(i,str) for(int i=0;(str)[i];i++)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX3(a,b,c) ((a)>(b)?(a)>(c)?(a):(c):(b)>(c)?(b):(c))
#define MIN3(a,b,c) ((a)<(b)?(a)<(c)?(a):(c):(b)<(c)?(b):(c))
#define MED(a,b,c) ((a)<(b)?(a)>(c)?(a):(b)<(c)?(b):(c):(a)>(c)?(b)<(c)?(c):(b):(a))
#define RNG(a,b) ((a)>(b)?(a)-(b):(b)-(a))
#define RNG3(a,b,c) ((a)>(b)?(b)>(c)?(a)-(c):(c)>(a)?(c)-(b):(a)-(b):(b)>(c)?(c)>(a)?(b)-(a):(b)-(c):(c)-(a))
#define MAXS(a,b) {if((a)<(b))(a)=(b);}
#define MINS(a,b) {if((a)>(b))(a)=(b);}
#define BEGINFOR(a,b,c,d,e,f,g,h,i) a;goto i##_6;i##_2:c;goto i##_6;i##_3:h;goto i##_7;i##_4:d;goto i##_8;i##_5:f;goto i##_8;i##_6:if(b)goto i##_4;else goto i##_9;i##_7:if(g)goto i##_5;else goto i##_1;i##_8:if(e)goto i##_2;else goto i##_3;i##_9:
#define CONTINUE(i) goto i##_3
#define BREAK(i) goto i##_1
#define ENDFOR(i) goto i##_3;i##_1:

#define INT int

class Int{
public:
	int v;
	Int(){scanf("%d", &v);}
	operator int(){return v;}
};

#define ARC(i,a,b) for(INT i=(a);i<(b);++i)
#define ARCH(i,a,b) for(INT i=(a)-1;i>=(b);--i)
#define RC(i,n) ARC(i,0,n)
#define RCH(i,n) ARCH(i,n,0)
#define SRC(i,s) for(INT i=0;(s)[i];++i)
#define ATH(a,b) ((a)>(b)?(a):(b))
#define OTH(a,b) ((a)<(b)?(a):(b))
#define ANTH(a,b) {if((a)<(b))(a)=(b);}
#define ONTH(a,b) {if((a)>(b))(a)=(b);}
#define ANT printf
#define ENT scanf
#define AT putchar
#define ET getchar
#define _ AT('\n');

int main(){
	Int a, b;
	ANT("%d", (a + b + 1) / 2);_
}

Measured memory_bytes: 128
void main() {
  problem();
}

void problem() {
  const X = scan!long;

  void solve() {
    foreach(long a; -5000..5000) {
      foreach(long b; -5000..5000) {
        if (a.pow(5) - b.pow(5) == X) {
          writefln("%s %s", a, b);
          return;
        }
      }
    }
  }

  solve();
}

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

import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons, std.numeric;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; }
T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
void deb(T ...)(T t){ debug writeln(t); }
alias Point = Tuple!(long, "x", long, "y");
import std.bigint, std.functional;

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


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

int main(void){

    int N, M, X;
    int i;
    int result;
    int *Mary;
    int cnt = 0;

    scanf("%d %d %d",&N,&M,&X);

    Mary = (int*)malloc(sizeof(int)*M);
    for(i=0;i<M;i++){
        scanf("%d",&Mary[i]);
    }

    //for(i=0;i<M;i++){
    //    printf("%d ",Mary[i]);
    //}
    //printf("\n");

    while(Mary[cnt] <= X & cnt < M){
        cnt++;
    }

    if(cnt<(M-cnt)){
        printf("%d\n",cnt);
    }else{
        printf("%d\n",(M-cnt));
    }

    free(Mary);

    return 0;
}


Measured memory_bytes: 128
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <vector>
using namespace std;

typedef pair<int, int> point;
#define X first
#define Y second

point operator+(const point &a, const point &b) {
	return point(a.X + b.X, a.Y + b.Y);
}

enum { N, E, S, W, D };
point dv[] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};

char convert[128];

constexpr int MAX_D = 10;
constexpr int MAX_T = 100;

constexpr int MAX_C = 50;

bool can_move[MAX_C + 1][MAX_C + 1][D];
set<point> dp[MAX_D * MAX_T + 1][D];

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

	convert['N'] = N;
	convert['E'] = E;
	convert['S'] = S;
	convert['W'] = W;

	int n, sx, sy, t;
	cin >> n >> sx >> sy >> t;

	for(int i = 0; i < n; ++i) {
		int x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;

		if(x1 == x2) {
			if(y1 > y2) swap(y1, y2);

			for(int y = y1; y <= y2; ++y) {
				if(y > y1) can_move[y][x1][S] = true;
				if(y < y2) can_move[y][x1][N] = true;
			}
		}
		else {
			if(x1 > x2) swap(x1, x2);

			for(int x = x1; x <= x2; ++x) {
				if(x > x1) can_move[y1][x][W] = true;
				if(x < x2) can_move[y1][x][E] = true;
			}
		}
	}

	vector<int> dist(t);
	vector<int> direction(t);

	for(int i = 0; i < t; ++i) {
		char c;
		cin >> dist[i] >> c;
		direction[i] = convert[c];
	}

	partial_sum(begin(dist), end(dist), begin(dist));

	for(int dir = 0; dir < D; ++dir) {
		dp[0][dir].insert(point(sx, sy));
	}

	int check_index = 0;
	for(int d = 0; d < dist.back(); ++d) {
		const bool is_check_time = (d == dist[check_index]);

		for(int dir = 0; dir < D; ++dir) {
			for(int next_dir = 0; next_dir < D; ++next_dir) {
				if((dir ^ next_dir) == 2) continue;
				if(is_check_time && (dir != direction[check_index] && next_dir != direction[check_index])) continue;

				for(const auto &p : dp[d][dir]) {
					if(!can_move[p.Y][p.X][next_dir]) continue;
					dp[d + 1][next_dir].insert(p + dv[next_dir]);
				}
			}
			dp[d][dir].clear();
		}

		if(is_check_time) ++check_index;
	}

	set<point> ans;
	for(int dir = 0; dir < D; ++dir) {
		if((dir ^ direction.back()) == 2) continue;

		for(const auto &p : dp[dist.back()][dir]) {
			if(dir == direction.back() || can_move[p.Y][p.X][direction.back()]) {
				ans.insert(p);
			}
		}
	}

	for(const auto &p : ans) {
		cout << p.X << " " << p.Y << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1496
// clang-format off

#include <bits/stdc++.h>

#define int long long int
#define main signed main()
#define bye return 0
#define rep(i, n) for (int i = 0; i < (n); i++)
#define each(p, v) for (auto p = (v).begin(); p != (v).end(); p++)
#define all(v) (v).begin(), (v).end()
#define prec(n) fixed << setprecision(n)
#define exact(x) { return (x); }

#define sum(v) accumulate(all(v), 0)
#define stlice(s, l) substr(s, (s) + (l) + 1)
#define odd(n) ((n) % 2)
#define even(n) (!((n) % 2))

#define INF 1e9
#define MOD (1e9 + 7)

#define pb push_back
#define mt make_tuple
#define fi first
#define se second
#define str string
#define vi vector<int>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<str>

using namespace std;

// clang-format on

main {
  int n;
  cin >> n;
  vi a(n * 3);
  rep(i, n * 3) cin >> a[i];
  sort(all(a));
  int c = 0;
  rep(i, n) c += a[n + 2 * i];
  cout << c << endl;
  bye;
}


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

int main()
{
  int a, b, c, k;
  scanf("%d%d%d%d", &a, &b, &c, &k);

  if(k <= a){
    printf("%d\n", k);
  }else if(k <= a+b){
    printf("%d\n", a);
  }else{
    printf("%d\n", 2*a+b-k);
  }
  return 0;
}

Measured memory_bytes: 1732
N = int(input())
A = [int(input()) for _ in range(N)]

m = [0, 0]
for i in range(N):
  if A[i] > m[0]:
    m[0] = A[i]
    m[1] = i  

m2 = 0
for i in range(N):
  if i == m[1]:
    continue
  m2 = max(A[i], m2)

res = []
for i in range(N):
  if i != m[1]:
    print(m[0])
  else:
    print(m2)

Measured memory_bytes: 12516
#include<iostream>
#include<vector>
using namespace std;
using ll = long long;

int main(){
    string s;
    cin>>s;
    if(s=="Sunny"){
    cout<<"Cloudy";
    }
    else if(s=="Cloudy"){
    cout<<"Rainy";
    }
    else if(s=="Rainy"){
    cout<<"Sunny";
    }
    return 0;
}
    

Measured memory_bytes: 256
#include <iostream>

 

using namespace std;

 

int main()
{
    int i, ans, a, b, c;
    
    cin >> a >> b >> c;
    ans = 0;
    for(i=a; i<=b; i++)
    {
        if(c % i == 0  )
         ans++;    
    }
    cout << ans << endl;
}


Measured memory_bytes: 3100
#include <cassert>
#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>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// 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>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

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

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
int n,m,v,i;
void solve(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n;
  ll ans = LLONG_MAX,X=0,x=0;
  // ll a[200005];
  std::vector<ll> a(n);
  rep(i,n) {
    cin>>a[i];
    X += a[i];
  }

  rep(i,n){
    x += a[i];
    if(i+1<n) ans = min(ans,abs(X-x*2));
  }
  cout<<ans<<endl;
}

int main(){
  solve();
  return 0;
}


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

int main()
{
    int q1, b, c1, c2, q2;

    while( cin >> q1 )
    {
        if( !q1 )
            break;
        
        cin >> b >> c1 >> c2 >> q2;

        bool judge = false;
        for( int i = q2; i >= 1; i-- )
        {
            int sum = b - c1 * i;
            if( sum < 0 )
                continue;
            else if( sum / c2 + i >= q1 )
            {
                cout << i << " " << sum / c2 << endl;
                judge = true;
                break;
            }
        }

        if( !judge )
            cout << "NA" << endl;
    }

    return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : a)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(a * b, c) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main(){
    string str;
    cin>>str;
    if(str.size()==1){cout<<"0"; return 0;}
    int num,i,one=0,zero=0,on=0,zr=0,tot1,tot2;
    for(i=0;i<str.size();i++){
        if(i%2==0) {if (str[i]=='1') zero++;}
        else {if (str[i]=='0')one++;}
        if(i%2==0) {if (str[i]=='0') on++;}
        else {if (str[i]=='1') zr++;}
    }
    tot1=zero+one;
    tot2=on+zr;
    cout<<min(tot1,tot2);
}

Measured memory_bytes: 3704
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define vi vector<int>
const ll INF=1e9+5;
typedef struct node
{
    int av;
    node *next;
} *LPTR;
int max(int a,int b)
{
    if(a>b) return a;
    return b;
}
void add(LPTR &L,int x)
{
    if(!L)
    {
        LPTR l=new node;
        l->av=x;
        l->next=NULL;
        L=l;
        return ;
    }
    add(L->next,x);
}
int dfs(LPTR edg[],int v,int v1,map<int,int> &dp)
{
    if(!edg[v1]) return 0;
    if(dp[v1]!=-1) return dp[v1];
    LPTR l=edg[v1];
    ll ans=-1;
    while(l)
    {
        ans=max(ans,1+dfs(edg,v,l->av,dp));
        l=l->next;
    }
    dp[v1]=ans;
    return ans;
}
int main()
{
    int n,m;
    cin>>n>>m;
    int p,q;
    LPTR edg[n+1]={ };
    int indegree[n+1]={ };
    int indeg[n+1]={ };
    while(m--)
    {
        cin>>p>>q;
        add(edg[p],q);
        indegree[q]++;
        indeg[q]++;
    }
    map <int,int> dp;
    for(int i=1;i<=n;i++) {dp[i]=-1;}
    vector<int> pi,tsort;int cnt=0;
    int ans=0;
    for (int i = 1; i <= n; ++i)
    {
        ans=max(ans,dfs(edg,n,i,dp));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 15104
#include "bits/stdc++.h"
using namespace std;

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

	vector<int> d1(n);
	vector<int> d2(n);

	for (int i = 0; i < n; i++) {
		cin >> d1[i];
		cin >> d2[i];
	}

	string ans = "No";
	for (int i = 0; i < n - 2; i++) {
		if (d1[i] == d2[i] && d1[i + 1] == d2[i + 1] && d1[i + 2] == d2[i + 2]) {
			ans = "Yes";
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

int main(){
  long long X;
  cin  >> X ;
  int a,b;
  for(long long i=0;i<150;i++){
    for(long long j=-150;j<150;j++){
      if(pow(i,5)-pow(j,5)==X){
        a=i;
        b=j;
        break;
      }
    }
  }
  cout << a <<" "<< b << endl;
}

Measured memory_bytes: 4100
#include<iostream>
using namespace std;
int main()
{
	int arr[33]={0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int n;
	cin>>n;
	cout<<arr[n]<<endl;
} 

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
long long N;


int main(){
  int n, x; cin >> n >> x;
  int ans[2*n-1] = {};
  if(n==2){
    if(x==1 || x==3){
      cout << "No" << endl; return 0;
    }
    cout << "Yes" << endl;
    rep(i, 3){
      cout << i+1 << endl;
    }
    return 0;
  }
  if(x==1 || x==(2*n-1)){
    cout << "No" << endl; return 0;
  }
  cout << "Yes" << endl;
  if(x==(2*n-2)){
    ans[n-1] = x; ans[n-2] = x-1; ans[n] = x+1; ans[n+1] = x-2;
    int ire = 1;
    rep(i, 2*n-1){
      if(ans[i]!=0) continue;
      ans[i] = ire; ire++;
    }
    rep(i, 2*n-1){
      cout << ans[i] << endl;
    }
    return 0;
  }
  ans[n] = x; ans[n-1] = x-1; ans[n-2] = x+1; ans[n+1] = x+2;
  int ire = 1;
  rep(i, 2*n-1){
    if(ire==x-1) ire+=4;
    if(ans[i]!=0) continue;
    ans[i] = ire; ire++;
  }
  rep(i, 2*n-1){
    cout << ans[i] << endl;
  }
}

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

int minimumChar(string S1, string S2)
{
    
    int n = S1.size(), m = S2.size();

    int ans = INT_MAX;

    
    for (int i = 0; i < m - n + 1; i++) {
        int minRemovedChar = 0;

        for (int j = 0; j < n; j++) {
            if (S1[j] != S2[i + j]) {
                minRemovedChar++;
            }
        }

        
        ans = min(minRemovedChar, ans);
    }

   
    return ans;
}

int main()
{

    string S1, S2;
    cin >> S1 >> S2;

    cout << minimumChar(S2, S1);

    return 0;
}

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

int main()
{
    int n;
    double s[1000] = {0}, sum, m, div;
    while (1)
    {
        cin >> n;
        if (n == 0)
        {
            break;
        }
        div = sum = 0;
        for (int i = 0; i < n; i++)
        {
            cin >> s[i];
            sum += s[i];
        }
        m = sum / n;
        for (int i = 0; i < n; i++)
        {
            div += (s[i] - m) * (s[i] - m);
            s[i] = 0;
        }

        cout << setprecision(8) << sqrt(div / n) << endl;
    }
}



Measured memory_bytes: 3284
#include <iostream>
#include <string>
#include <cctype>

int main ()
{
	std::string str;
	getline(std::cin, str);
	
	int len = str.size();
	
	char* str_ch = new char[len + 1];
	std::char_traits<char>::copy(str_ch, str.c_str(), len + 1);
	
	for (int i=0; i<len; i++)
	{
		if (isupper(str_ch[i])) str_ch[i] = tolower(str_ch[i]);
		else if (islower(str_ch[i])) str_ch[i] = toupper(str_ch[i]);
	}
	
	
	std::cout << std::string(str_ch) << std::endl;
	
	delete[] str_ch;
	
	return 0;
}




Measured memory_bytes: 3180
#include <stdio.h>

int main(void) {
  int s,h,m;
  scanf("%d",&s);
  h=s/3600;
  m=(s-h*3600)/60;
  s=s-(m*60+h*3600);
printf("%d:%d:%d\n",h,m,s);
  return 0;
}


Measured memory_bytes: 2124
N = gets.to_i
S = gets.chomp

eData = Array.new(N+1, 0)
wData = Array.new(N+1, 0)

1.upto(N) do |i|
    # 累積和
    # Eの人の累積和
	eData[i] = eData[i - 1] + (S[i - 1] == 'E' ? 1 : 0)
	# Wの人の累積和
	wData[i] = wData[i - 1] + (S[i - 1] == 'W' ? 1 : 0)
end

result = []
1.upto(N) do |i|
    # i番の人が、リーダーのとき
    # リーダーより左グループのWの人数(Eに代わる人数)
    w_to_e = wData[i - 1]
    # リーダーより右グループのEの人数(Wに代わる人数)
	e_to_w  = eData[N] - eData[i]

	#
	result <<  w_to_e + e_to_w
end

# 変更人数の最小値
p result.min


Measured memory_bytes: 9476
#include<iostream>
#include<string>
using namespace std;
#define MAX 100000

int main(){
    int WA[MAX];
    bool AC[MAX];
    int i, n, m, p;
    int wsum = 0, asum = 0;
    string str;

    cin >> n >> m;
    for(i=0; i<m; i++){
        WA[i] = 0;
        AC[i] = false;
    }

    for(i=0; i<m; i++){
        cin >> p >> str;
        if(AC[p] == false){
            if(str == "AC"){
                asum++;
                wsum += WA[p];
                AC[p] = true;
            }else if(str == "WA"){
                WA[p]++;
            }
        }
    }
    cout << asum << " " << wsum << endl;

}

Measured memory_bytes: 768
#include<iostream>
#include<vector>
#include<math.h>
using namespace std;
long long pow2(long long x,int y,long long mod) {
  if(y == 0)return 1;
  else if(y%2 == 0)return (long long)powl(pow2(x,y/2,mod),2.0)%mod;
  else return (((long long)powl(pow2(x,y/2,mod),2.0)%mod)*x)%mod;
}
int main() {
  int N,K;
  cin >> N >> K;
  long long ans = 0;
  vector<long long> f(N+1),fi(N+1);
  f[0] = 1;
  int i;
  for(i=0;i<N;i++)f[i+1] = f[i]*(i+1)%1000000007;
  for(i=0;i<=N;i++)fi[i] = pow2(f[i],1000000005,1000000007);
  for(i=0;i<=min(N-1,K);i++) {
    ans += (fi[i]*fi[i]%1000000007)*(fi[N-i]*fi[N-i-1]%1000000007)%1000000007;
    ans %= 1000000007;
  }
  ans = ans * (f[N]*f[N-1]%1000000007) % 1000000007;
  cout << ans%1000000007 << endl;
}

Measured memory_bytes: 3328
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    md=10**9+7
    n=II()
    aa=LI()
    cs=[0]
    for a in aa:cs.append(cs[-1]^a)
    #print(cs)

    cnt={}
    cnt0=[1]*len(cs)
    for i,s in enumerate(cs[1:],1):
        if s==0:
            cnt0[i]=cnt0[i-1]+1
        elif s in cnt:
            cnt0[i]=cnt0[i-1]
            c0=cnt0[i]-cnt0[cnt[s][2]]
            cnt[s][0]=(cnt[s][0]+cnt[s][1]*c0)%md
            cnt[s][1]=(cnt[s][1]+cnt[s][0])%md
            cnt[s][2]=i
        else:
            cnt0[i]=cnt0[i-1]
            cnt[s]=[1,1,i]
    #print(cnt)
    #print(cnt0)

    if cs[-1]==0:ans=sum(v[1] for v in cnt.values())+pow(2,cnt0[-1]-2,md)
    else:ans=cnt[cs[-1]][0]
    print(ans%md)

main()

Measured memory_bytes: 109160
#include<iostream>
#include<string>
using namespace std;
int main()
{
    int k,a,b;
    cin>>k;
    cin>>a>>b;
    for(int i=a;i<=b;i++)
    if(i%k==0){
        cout<<"OK"<<endl;
        return 0;
    }
    cout<<"NG"<<endl;
    return 0;
}


Measured memory_bytes: 3636
import java.util.*;

public class Main{
  static int w,h,f,m,o;
  static int[][] t;
  static int dx[] = {-1,1};

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

    while(true){
      w = sc.nextInt();
      h = sc.nextInt();
      if(w == 0 && h == 0) break;

      f = sc.nextInt();
      m = sc.nextInt();
      o = sc.nextInt();
      t = new int[h][w];

      for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
          t[i][j] = sc.nextInt();
        }
      }

      PriorityQueue<State> open = new PriorityQueue<State>();
      boolean[][][][][] closed = new boolean[h][w][w][w][m+1];
      if(o-1 >= 1){
        o--;
        for(int i=0;i<w;i++){
          int cost = t[0][i];
          if(cost < 0){
            open.add(new State(-cost,i,0,i,i,o));
          }
          else{
            int no = Math.min(o + cost, m);
            open.add(new State(0,i,0,i,i,no));
          }
        }
      }

      State ans = null;
      while(!open.isEmpty()){
        State st = open.poll();
        if(st.o <= 0 || st.cost > f || closed[st.y][st.x][st.l][st.r][st.o]) continue;
        closed[st.y][st.x][st.l][st.r][st.o] = true;

        //System.out.println(st);

        if(st.y == h-1){
          ans = st;
          break;
        }
        st.o--;
        if(st.y == h-1 || st.o == 0) continue;

        int tt = t[st.y+1][st.x];
        if(tt < 0){
          open.add(new State(st.cost-tt,st.x,st.y+1,st.x,st.x,st.o));
        }
        else{
          int no = Math.min(st.o + tt, m);
          open.add(new State(st.cost,st.x,st.y+1,st.x,st.x,no));
        }

        for(int i=0;i<2;i++){
          int nx = st.x + dx[i];
          int ny = st.y;
          if(nx < 0 || nx >= w) continue;

          if(st.l <= nx && nx <= st.r){
            open.add(new State(st.cost,nx,ny,st.l,st.r,st.o));
          }
          else{
            tt = t[ny][nx];
            int nl = Math.min(st.l,nx);
            int nr = Math.max(st.r,nx);
            if(tt < 0){
              open.add(new State(st.cost-tt,nx,ny,nl,nr,st.o));
            }
            else{
              int no = Math.min(st.o + tt, m);
              open.add(new State(st.cost,nx,ny,nl,nr,no));
            }
          }
        }
      }

      if(ans == null){
        System.out.println("NA");
      }
      else{
        System.out.println(ans.cost);
      }
    }
  }
}

class State implements Comparable<State>{
  int cost,x,y,l,r,o;

  State(int cost,int x,int y,int l,int r,int o){
    this.cost = cost;
    this.x = x;
    this.y = y;
    this.l = l;
    this.r = r;
    this.o = o;
  }

  public int compareTo(State st){
    return this.cost - st.cost;
  }

  public String toString(){
    return String.format("(%d,%d) (%d<-->%d) (cost:%d,o:%d)",x,y,l,r,cost,o);
  }
}

Measured memory_bytes: 0
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

import java.util.*;

public class Main{
  static long n, y;

  public static void main(String[] args){
    FastScanner sc = new FastScanner();

    n = sc.nextInt(); y = sc.nextInt();

    for(long a = 0; a <= n; a++){
      for(long b = 0; a + b <= n; b++){
        long c = n - (a + b);
        if(y == (10000L * a + 5000L * b + 1000L * c)){
          System.out.println(a + " " + b + " " + c);
          return;
        }
      }
    }
    System.out.println("-1 -1 -1");
  }
}

class FastScanner {
  private static final InputStream in = System.in;
  private static final PrintWriter out = new PrintWriter(System.out);
  private final byte[] buffer = new byte[2048];
  private int p = 0;
  private int buflen = 0;

  public FastScanner(){
  }

  private boolean hasNextByte() {
    if(p < buflen){
      return true;
    }
    p = 0;
    try{
      buflen = in.read(buffer);
    }catch (IOException e) {
      e.printStackTrace();
    }
    if(buflen <= 0){
      return false;
    }
    return true;
  }

  public boolean hasNext() {
    while(hasNextByte() && !isPrint(buffer[p])){
      p++;
    }
    return hasNextByte();
  }

  private boolean isPrint(int ch) {
    if(ch >= '!' && ch <= '~'){
      return true;
    }
    return false;
  }

  private int nextByte() {
    if(!hasNextByte()){
      return -1;
    }
    return buffer[p++];
  }

  public String next() {
    if(!hasNext()){
      throw new NoSuchElementException();
    }
    StringBuilder sb = new StringBuilder();
    int b = -1;
    while(isPrint((b = nextByte()))){
      sb.appendCodePoint(b);
    }
    return sb.toString();
  }

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

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

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


Measured memory_bytes: 22996
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())




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

	int t;
	cin>>t;
	rep(i,t){
		int n,d;
		cin>>n>>d;
		int ans=d;
		n--;
		ans += n/2*254;
		if (n&1){
			int a = 0;
			rep(y, 128){
				a = max(a, y + (y^d) - d);
			}
			ans+=a;
		}
		cout<<ans<<endl;
	}


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
bool E[(int)1e7];

int main(){
  int n, m;
  while(cin >> m >> n, n){
    int M = 1e7;
    fill(E, E+M, true);
    for(int i = m; i < M; ++i){
      if(!n) break;
      if(!E[i]) continue;
      E[i] = false;
      --n;
      for(int j = 1; i*j < 1e7; ++j) E[i*j] = false;
    }
    for(int i = m; i < M; ++i){
      if(E[i]){
        cout << i << endl;
        break;
      }
    }
  }
  return 0;
}



Measured memory_bytes: 12800
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> d(k, 0);
  for (int i = 0; i < k; i++) {
    cin >> d[i];
  }

  int ans = n;
  while (true) {
    bool is_ok = true;
    int tmp = ans;
    while (tmp != 0) {
      int digit = tmp % 10;
      for (int i = 0; i < k; i++) {
        if (digit == d[i]) {
          is_ok = false;
        }
      }
      tmp /= 10;
    }
    if (is_ok) {
      cout << ans << endl;
      return 0;
    }
    ans++;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 100000000

typedef  long long ll;

using namespace std;

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

int gcd(long long int a,long long int b){
    long long int r;
    if(a < b){
        int tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r != 0){
        r = a % b;
        a = b;
        b = r;
    }
    return r;
}

void Integer_factorization(long long int b,long long int n){
    long long int a = 2;
    long long int count = 0;
    long long int ans = 1;
    long long int ndash = n;
    if(b == 1) cout << n << endl;
    else{
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    cout<<  ans << endl;
    }
}

void ys(){
    cout << "Yes" << endl;
}

void yb(){
    cout << "YES" << endl;
}

void ns(){
    cout << "No" << endl;
}

void nb(){
    cout << "NO" << endl;
}

int main(){
    string s;
    cin >> s;
    char c;
    
        if(s[0] == 'A') c = 'T';
        else if(s[0] == 'C') c = 'G';
        else if(s[0] == 'G') c = 'C';
        else c = 'A';
    

    
    
    cout << c  << endl;
    
}

Measured memory_bytes: 256
#include<stdio.h>

#define MAX 100
#define WHITE 0
#define GLAY 1
#define BLACK 2
#define FALSE -1
#define INFTY 3000
#define NIL -1

int G[MAX][MAX];
int color[MAX];
int d[MAX];//最小の辺の重みを記録
int p[MAX];//v's parent
int n;
int sum;


void prim();

int main(){
  int i,j;

  scanf("%d",&n);

  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      scanf("%d",&G[i][j]);
    }
  }

  prim();
  printf("%d\n",sum);
  
  return 0;
}

void prim(){
  int i,mincost,u;

  for(i = 0; i < n; i++){
    color[i] = WHITE;
    p[i] = NIL;
    d[i] = INFTY;
  }

  d[0] = 0;

  while(1){
    mincost = INFTY;
    u = NIL;
    for(i = 0; i < n; i++){
      if(color[i] != BLACK && d[i] < mincost){
        mincost = d[i];
        u = i;
      }
    }
    
    if(mincost == INFTY)break;

    color[u] = BLACK;

    for(i = 0; i < n; i++){
      if(color[i] != BLACK && G[u][i] != FALSE){
        if(G[u][i] < d[i]){
          d[i] = G[u][i];
          p[i] = u;
          color[i] = GLAY; 
        }
      }
    }
  }
  sum = 0;

  for(i = 0; i < n; i++){
    if(p[i] != NIL)sum += G[i][p[i]];
  }

}



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

using namespace std;

int main()
{
    int a,b,c;
    scanf("%d%d",&a,&b);
    c=a+b;
    if(c>=24)
    {
        c-=24;
        printf("%d",c);
    }
    else if(c<24)
    {
        printf("%d",c);
    }


}


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

using namespace std;

const int N = 100 + 5;

typedef long long LL;



bool cmp(int a , int b){return a < b;}



int main(){

	ios::sync_with_stdio(false);

	cin.tie(0);

	LL a , b , c;

	cin>>a>>b>>c;

	if(a%2==0||b%2==0||c%2==0) cout<<0<<endl;

	else cout<<(min(min(a*b , a*c) , b * c))<<endl;

	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int32_t main(){
	fastio();
	string s;
	cin >> s;
	int sum = 0;
	for(auto i:s){
		sum += (i - '0');
	}	
	if(sum % 9) cout << "No";
	else cout << "Yes";
	
}

Measured memory_bytes: 3724
#include<stdio.h>

int main(void)
{
	int n;
	fflush(stdout);
	scanf("%d", &n);

	int arr[n];

	fflush(stdout);
	for(int i = 0; i < n; i++){
		scanf("%d",&arr[i]);
	}
	for(int j = n-1; j >= 0; j--){
		printf("%d", arr[j]);
		if(j != 0)
			printf(" ");
		else
			printf("\n");
	}

	return 0;
}



Measured memory_bytes: 2112
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApplication
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var a = Utilities.ReadInt();
            var b = Utilities.ReadInt();
            var h = Utilities.ReadInt();
            var result = (a + b) * h / 2;

            System.Console.WriteLine(result);
        }
    }

    public static class Utilities
    {
        #region Extensions for IO
        public static int ReadInt()
            => ReadInts().First();
        public static IEnumerable<int> ReadInts()
            => ReadStrings().Select(int.Parse);

        public static string ReadString()
            => ReadStrings().First();
        public static IEnumerable<String> ReadStrings()
            => Console.ReadLine().Split(' ');
        #endregion

        #region Extensions of int
        public static bool IsOdd(this int n)
            => !n.IsEven();

        public static bool IsEven(this int n)
            => n % 2 == 0;
        
        public static bool CanDivideWith(this int n, int divisor)
            => n % divisor == 0;
        #endregion

        public static int ToInt(this string str)
            => int.Parse(str);
    }
}


Measured memory_bytes: 2904
#include<stdio.h>
int main(void)
{
	int w,h,c,x,a,b;
	scanf("%d %d %d",&w,&h,&c);
	if(w<h){
		x=w;
	}
	if(w>h){
		x=h;
	}
	while(1){
		if(h%x==0&&w%x==0){
			break;
		}
		x=x-1;
	}
	a=(h/x)*(w/x);
	b=a*c;
	printf("%d\n",b);
	return 0;
}
	

	
	

	


Measured memory_bytes: 2104
// "static void main" must be defined in a public class.
import java.util.* ;
public class Main {
    public static void main(String[] args) {
        Scanner S = new Scanner( System.in ) ;
        String s = S.nextLine() ;
        int result = 0 ; int count = 0 ;
        for( char ch : s.toCharArray() ) {
            if( ch=='R' ) {
                count++ ;
            }else count = 0 ;
            result = Math.max( result , count ) ;
        }
        System.out.println(result) ;
    }
}

Measured memory_bytes: 35616
c=[[] for _ in range(3)]
for i in range(3):
    c[i] = list(map(int, input().split()))

diff0 = [x - y for x, y in zip(c[0], c[1])]
diff1 = [x - y for x, y in zip(c[0], c[2])]
 
if diff0[0] == diff0[1] and diff0[0] == diff0[2] and diff1[0] == diff1[1] and diff1[0] == diff1[2]:
    print('Yes')
else:
    print('No')





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

int main(void)
{
    int N;
    std::cin >> N;

    std::vector<std::string> s(N);
    for (int i = 0; i < N; i++) {
        std::cin >> s[i];
        sort(s[i].begin(), s[i].end());
    }
    sort(s.begin(), s.end());

    uint64_t ans = 0;
    int i = 0;
    while (i < N - 1) {
        int j = i + 1;
        for (; j < N; j++) 
            if (s[i] != s[j]) break;
        ans += (static_cast<uint64_t>(j) - static_cast<uint64_t>(i)) * (static_cast<uint64_t>(j) - static_cast<uint64_t>(i) - 1) / 2;
        i = j;
    }

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

    return 0;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353,INF=1e18;



int main() {
    int N;
    cin>>N;
    map<ll,int> mp;
    ll sum=0;
    rep(i,N){
        ll A;
        cin>>A;
        mp[A]++;
        sum+=A;
    }
    int Q;
    cin>>Q;
    rep(query,Q){
        ll B,C;
        cin>>B>>C;
        if(!mp.count(B)){cout<<sum<<endl;continue;}
        sum+=mp[B]*(C-B);
        cout<<sum<<endl;
        mp[C]+=mp[B];
        mp[B]=0;
    }
}

Measured memory_bytes: 8576
(function(input) {
    var p = input.replace(/\n$/, '').split('\n');
    var n = Number(p.shift());
    for (var i = 0; i < n; i++) {
        var args = p[i].split(' ').map(Number);
        //console.log(args);
        var x1 = args.shift();
        var y1 = args.shift();
        var x2 = args.shift();
        var y2 = args.shift();
        var x3 = args.shift();
        var y3 = args.shift();
        var x = ((Math.pow(x3, 2) - Math.pow(x2, 2) + Math.pow(y3, 2) - Math.pow(y2, 2)) * (y2 - y1)
            - (Math.pow(x2, 2) - Math.pow(x1, 2) + Math.pow(y2, 2) - Math.pow(y1, 2)) * (y3 - y2))
            / 2 / ((y2 - y1) * (x3 - x2) - (x2 - x1) * (y3 - y2));
        var y = ((Math.pow(y3, 2) - Math.pow(y2, 2) + Math.pow(x3, 2) - Math.pow(x2, 2)) * (x2 - x1)
            - (Math.pow(y2, 2) - Math.pow(y1, 2) + Math.pow(x2, 2) - Math.pow(x1, 2)) * (x3 - x2))
            / 2 / ((x2 - x1) * (y3 - y2) - (y2 - y1) * (x3 - x2));

        console.log(x.toFixed(3), y.toFixed(3), Math.sqrt(Math.pow(x1 - x, 2) + Math.pow(y1 - y, 2)).toFixed(3));
    }
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,-1,0,1},dy={1,0,-1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}

ll gcd(ll a,ll b){
	if(a%b==0) return b;
	else gcd(b,a%b);
}

ll lcm(ll a,ll b){
	return a/gcd(a,b)*b;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a,b,c,d;cin >> a >> b >> c >> d;
	ll l=lcm(c,d);
	ll ans=b-(b/c+b/d-b/l)-(a-1-((a-1)/c+(a-1)/d-(a-1)/l));
	cout << ans << endl;
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

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

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll K, S;
    cin >> K >> S;

    ll ans = 0;
    for (ll i = 0; i <= K; i++) {
        for (ll j = 0; j <= K; j++) {
            ll k = S-i-j;
            if (0 <= k && k <= K) {
                ans++;
            }
        }
    }

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

Measured memory_bytes: 256