akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {
			var inputArray = retreiveLongArray();
			var inputCount = 2;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			int H = (int)inputArray[0]-1;
			int W =(int) inputArray[1]-1;

			//マスを作る
			var masu = new List<int[]>();

			for (int i = 0; i <= H; i++) {

				var inpStr = retreiveStringArray()[0];
				var intArray = inpStr.Select(x => {
					return x == '.' ? 0 : 1;
				}).ToArray();
				masu.Add(intArray);

			}
			//白ますの数を数える
			var shiroCount = 0;
			foreach (var arr in masu) {
				shiroCount += arr.Where(x => x == 0).Count();
			}

			//最短経路のマス数を格納
			_saitankeiro = int.MaxValue;
			_bestWay = new Dictionary<string, int>();
			var keiroStack = new Stack<string>();

			//DFSで全経路を探索
			DFS(H, W, 0, 0,  masu,"-1_-1",1);


			//答えの出力
			var ans = _saitankeiro == int.MaxValue ? -1: shiroCount - _saitankeiro;
			Console.WriteLine(ans);

		}
		/// <summary>
		/// 最短経路を格納
		/// </summary>
		private static int _saitankeiro;

		/// <summary>
		/// 最短経路を格納
		/// </summary>
		private static Dictionary<string,int> _bestWay;

		private static void DFS(int H,int W,int h,int w,List<int[]> masu,string previous,int nanmasume) {

			var positionStr = h + "_" + w;

			//範囲外の場合も探索しない
			if (h < 0 | H < h) {
				return;
			}
			//範囲外の場合も探索しない
			if (w < 0 | W < w) {
				return;
			}
			//障害物があった場合も探索しない
			if (masu[h][w] == 1) {
				return;
			}

			//初めての到達か、最短で到達した場合のみ調査続行
			if (_bestWay.ContainsKey(positionStr)) {
				var best = _bestWay[positionStr];
				if(best <= nanmasume) {
					return;
				}
				_bestWay[positionStr] = nanmasume;
			}
			else {
				_bestWay.Add(positionStr, nanmasume);
			}


			//到達した場合
			if (h==H && w == W) {
				_saitankeiro = Math.Min(_saitankeiro, nanmasume);
				return;
			}

			//何マス目が最短経路より大きくなってしまった場合、探索の意味なし
			if(nanmasume >= _saitankeiro) {
				return;
			}


			var nextPositons = new List<Tuple<int, int>> {
				Tuple.Create(h+1,w),
				Tuple.Create(h,w+1),
				Tuple.Create(h-1,w),
				Tuple.Create(h,w-1),
			};
			foreach (var posi in nextPositons) {
				var nextposition = posi.Item1 + "_" + posi.Item2;
				if (nextposition == previous) {
					continue;
				}
				DFS(H, W, posi.Item1, posi.Item2,masu,positionStr, nanmasume+1);
			}

		}


		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}

Measured memory_bytes: 18232
#include<iostream>
#include<iomanip>
#include<sstream>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<map>
#include<vector>
#include<queue>
#include<set>
#include<numeric>

using namespace std ;

#define pb(n) push_back(n)
#define fi first
#define se second
#define np string::npos
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define repc(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto n :(array))

typedef long long ll ;
typedef vector<int> vi ;
typedef vector<ll> vl ;
typedef map<string,int> dict;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
double eps = 1e-10 ;

template <typename T>
void out(vector < T > v)
{
  for(size_t i = 0; i < v.size(); i++)
  {
    debug(v[i]);
  }
}

template<typename T>
string ntos( T i ) {
  ostringstream s ;
  s << i ;
  return s.str() ;
}

template<typename T>
T ston(string str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  double a,b,c,d,e,f,x,y;
  while(cin >> a >> b >> c >> d >> e >> f){
    x = (b*f-e*c)/(b*d-e*a) * 1000 ;
    if(x > 0){
      x += 0.5 ;
    }
    else if(x < 0){
      x -= 0.5 ;
    }
    x = (double)((int)(x))/1000.0 ;
    y = (c*d-a*f)/(b*d-e*a) * 1000 ;
    if(y > 0){
      y += 0.5 ;
    }
    else if(y < 0){
      y -= 0.5 ;
    }
    y =(double)((int)(y))/1000 ;
    cout << fixed << setprecision(3) << x << " " << y << endl;
  }
  return 0;
}

Measured memory_bytes: 1292
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
//const int MOD =  (int)1e9 + 7;
const int MOD = 998244353;
const double EPS = 1e-9;

struct ST
{
	vector<int> node;
	int N;

	ST(int sz)
	{
		N = 1;
		while (N < sz)N *= 2;
		node.resize(2 * N - 1, -INF);
	}

	ST(int* a, int sz)
	{
		N = 1;
		while (N < sz)N *= 2;
		node.resize(2 * N - 1, -INF);

		rep(i, 0, sz)node[N - 1 + i] = a[i];
		rrep(i, 0, N - 1)node[i] = max(node[2 * i + 1], node[2 * i + 2]);
	}

	ST(vector<int> a)
	{
		N = 1;
		while (N < SZ(a))N *= 2;
		node.resize(2 * N - 1, -INF);

		rep(i, 0, SZ(a))node[N - 1 + i] = a[i];
		rrep(i, 0, N - 1)node[i] = max(node[2 * i + 1], node[2 * i + 2]);
	}

	void update(int i, int a)
	{
		node[N - 1 + i] = a;
		int k = N - 1 + i;
		while (k > 0)
		{
			k = (k - 1) / 2;
			node[k] = max(node[2 * k + 1], node[2 * k + 2]);
		}
	}

	int query(int a, int b, int k, int l, int r = -1)
	{
		if (r == -1)r = N;
		if (b <= l || r <= a)
		{
			return -INF;
		}
		if (a <= l && r <= b)
		{
			return node[k];
		}
		else
		{
			return max(query(a, b, 2 * k + 1, l, (l + r) / 2), query(a, b, 2 * k + 2, (l + r) / 2, r));
		}
	}
};

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

	int N;
	cin >> N;
	vector<pii> A(N + 1);
	vector<int> DP(N + 1, 0);
	ST st(N + 1);

	rep(i, 0, N)
	{
		cin >> A[i].first >> A[i].second;
	}
	A[N] = mp(INF, INF);

	sort(all(A));

	rep(i, 0, SZ(A))
	{
		st.update(i, A[i].first + A[i].second);
	}

	DP[N] = 1;
	rrep(i, 0, N)
	{
		int idx = lower_bound(all(A), mp(A[i].first + A[i].second, 0LL)) - A.begin();
		int tar = st.query(i, idx, 0, 0);
		st.update(i, tar);
		idx = lower_bound(all(A), mp(tar, 0LL)) - A.begin();
		int res = DP[idx] + DP[i + 1];
		DP[i] = res;
		DP[i] %= MOD;
	}

	cout << DP[0] << endl;

	return 0;
}

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

#define N_MAX 100002

using namespace std;

int n, m;

bool ok[N_MAX];

int total[N_MAX];
int out[N_MAX];

int main()
{
    cin >> n >> m;
    ok[1] = true;
    for(int i = 1; i <= n; i++)
        total[i] = 1;
    for(int i = 1; i <= m; i++)
    {
        int x, y;
        cin >> x >> y;
        if(ok[x] == true)
            ok[y] = true;
        out[x]++;
        if(total[x] == out[x])
            ok[x] = false;
        total[y]++;
    }
    int ans = 0;
    for(int i = 1; i <= n; i++)
        if(ok[i] == true)
            ans++;
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 1152
from math import *

N = int(input())
data = []
for i in range(N):
    x, y = map(int, input().split())
    data.append((atan2(y, x), x, y))

data.sort()
ret = 0
for i in range(N):
    x = data[i][1]
    y = data[i][2]
    ret = max(ret, sqrt(x**2 + y**2))

for i in range(N):
    for j in range(N):
        if i < j and data[j][0] - data[i][0] < pi:
            x = 0
            y = 0
            for k in range(i, j+1):
                x += data[k][1]
                y += data[k][2]
            ret = max(ret, sqrt(x**2 + y**2))
        elif i > j and data[i][0] - data[j][0] >= pi:
            x = 0
            y = 0
            for k in range(i, N):
                x += data[k][1]
                y += data[k][2]
            for k in range(j+1):
                x += data[k][1]
                y += data[k][2]
            ret = max(ret, sqrt(x**2 + y**2))

print(ret)
                


Measured memory_bytes: 41328
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
from functools import reduce
import sys
import math
import bisect
import random
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return list(map(float, sys.stdin.readline().split()))
def LS():return sys.stdin.readline().split()
def SR(n): return [list(sys.stdin.readline())[:-1] for i in range(n)]
def IR(n): return [int(sys.stdin.readline()) for i in range(n)]
def LIR(n): return [list(map(int, sys.stdin.readline().split())) for i in range(n)]
def LSR(n): return [list(map(list, sys.stdin.readline().split())) for i in range(n)]
_gcd = lambda x, y: _gcd(y, x%y) if (x%y) else y
_lcm = lambda x, y: x*y // _gcd(x, y)
def gcd(*numbers):
    return reduce(_gcd, numbers)
def lcm(*numbers):
    return reduce(_lcm, numbers)
sys.setrecursionlimit(1000000)
INF = float('inf')
mod = 1000000007
dire4 = [(1,0), (0,1), (-1,0), (0,-1)]
dire8 = [(1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1)]

S = S()

Rend, Lend = 0, 0

ans = [0]*(len(S))

for i in range(len(S)-1):
    if (S[i]=='R' and S[i+1]=='L'):
        l, r = i, i+1
        for j in range(i+1,len(S)):
            if (S[j]=='L'):
                Lend = j
            else:
                break
        else:
            ans[l] = ((l-Rend+1)//2 + (l-Rend+1)&1) + (r-Lend+1)//2
            ans[r] = (l-Rend+1)//2 + ((r-Lend+1)//2 + (r-Lend+1)&1)

        ans[l] = ((l-Rend+1)//2) + ((l-Rend+1)&1) + ((Lend-r+1)//2)
        ans[r] = ((l-Rend+1)//2) + ((Lend-r+1)//2) + ((Lend-r+1)&1)
        Rend = Lend+1
        i = Rend

print(*ans)

Measured memory_bytes: 49532
from bisect import bisect_left

N = int(input())
A = list(map(int, input().split()))

A.sort()
for i in reversed(range(N)):
    a = A[i]
    ia = bisect_left(A, a/2)
    a1, a2 = A[ia-1], A[ia]
    if a2 == a:
        b = a1
    elif min(a1, a-a1) > min(a2, a-a2):
        b = a1
    else:
        b = a2
    break
    
print(a, b)

Measured memory_bytes: 14428
#include <iostream>
#include <map>
#include <vector>

template<typename T>
class LineSet {
private:
  std::map<T,T> L;// 傾き→切片
  T max_a, min_a;
public:
  LineSet(T ai) : L(), max_a(-ai), min_a(ai) {}
  void push(T a, T b){// push ax + b
    min_a = std::min(min_a,a);
    max_a = std::max(max_a,a);
    
    if(L.empty()){
      L[a] = b;
      return;
    }
    
    if(L.size() == 1){
      if(L.find(a) != L.end())
        L[a] = std::min(L[a],b);
      else
        L[a] = b;
      return;
    }

    if(a == min_a or a == max_a){
      if(L.find(a) != L.end())
        L[a] = std::min(L[a],b);
      else
        L[a] = b;
    }
    
    if(L.find(a) == L.end() or L[a] != b){
      return;
    }
    
    while(1){
      auto ll = L.find(a);
      if(ll == L.begin()) break;
      auto lm = prev(ll);
      if(lm == L.begin()) break;
      auto lr = prev(lm);
      if((lm->first-lr->first)*(lm->second-ll->second) < (ll->first-lm->first)*(lr->second-lm->second))
        break;
      L.erase(lm);
    }
    while(1){
      auto lr = L.find(a);
      auto lm = next(lr);
      if(lm == L.end()) break;
      auto ll = next(lm);
      if(ll == L.end()) break;
      if((lm->first-lr->first)*(lm->second-ll->second) < (ll->first-lm->first)*(lr->second-lm->second))
        break;
      L.erase(lm);
    }
  }
  T get(T x){
    if(L.size() == 1){
      auto [a, b] = *L.begin();
      return a*x + b;
    }
    T la = min_a, ra = max_a;
    while(ra-la > 1){
      T m = (la+ra)/2;
      auto r = L.lower_bound(m);
      auto l = prev(r);
      if(l->first*x+l->second < r->first*x+r->second){
        ra = l->first;
      }else{
        la = r->first;
      }
    }
    auto [a, b] = *L.find(la);
    return a*x+b;
  }
};

#include <iostream>
#include <vector>
using namespace std;

int main(){
  long long N, C;
  cin >> N >> C;
  vector<long long> H(N);
  LineSet<long long> cht(1e9);
  for(int i = 0; i < N; ++i){
    cin >> H[i];
  }
  vector<long long> dp(N);
  cht.push(-2*H[0],H[0]*H[0]);
  for(int i = 1; i < N; ++i){
    dp[i] = cht.get(H[i]) + H[i]*H[i] + C;
    cht.push(-2*H[i],dp[i]+H[i]*H[i]);
  }
  cout << dp.back() << endl;
}


Measured memory_bytes: 18816
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(){
    string s; cin >> s;
    cout << s.substr(0, 3) << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <string.h>
#include <string>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long n, a, b;
    cin >> n >> a >> b;
    
    long long  cnt = n / (a+b);
    long long spare = n % (a+b);
    if (spare > a) spare = a;
    cout << cnt * a + spare << '\n';
}

Measured memory_bytes: 3628
#include "bits/stdc++.h"
using namespace std;
#define IOS { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define pb push_back
#define nl cout<<"\n"
#define endl "\n"
#define ll long long
#define ld long double
#define all(c) (c).begin(),(c).end()
#define trav(a,x) for(auto a = x.begin() ; a != x.end() ; a++)
#define rep(i,n) for(int i = 0 ; i < n ; i++)
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define f first
#define s second

inline ll max(ll a,ll b) {return ((a>b)?a:b);}
inline ll min(ll a,ll b) {return ((a>b)?b:a);}
inline ll gcd(ll a ,ll b) {if(b==0) return a; a%=b;return gcd(b,a);}
ll power(ll x, ll y){if(y == 0) return 1; ll a = power(x,y/2);if (y % 2 == 0) return a * a; else return x * a * a; }
ll powermod(ll x, ll ex , ll md) {ll ans = 1ll;while (ex > 0) {if (ex & 1ll) ans = (ans * x) % md; ex >>= 1ll;x = (x * x) % md;}return ans;}

const ll inf = 1e18 + 9;
const ll mod = 1e9 + 7;
const ld PI = acos(-1);
const ld eps = 1e-9;

const ll N = 1e6 + 1;

void solve(){
    ll n;
    cin >> n;
    ll a[n];
    rep(i , n) cin >> a[i];
    ll s = a[0];
    for(ll i = 1 ; i < n ; i++) s = s^a[i];
    rep(i , n) {
        ll x = (s^(a[i]));
        cout << x << " ";
    }
}
int main(){
    IOS;
    cout << fixed << setprecision(20);
    ll NTC=1;
    // cin>>NTC;
    ll PTC=0;
    while(PTC++<NTC){
        // cout<<"Case #"<<PTC<<":"<<' ';
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


Measured memory_bytes: 5240
#include<stdio.h>
int main(void) {
	double a, b, c, d, e, f, xans, yans;
	while (scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f) != EOF)
	{
		xans = ((e*c - f*b) / (a*e - d*b)) + 0.00005;
		yans = ((c*d - f*a) / (d*b - a*e)) + 0.00005;
		printf("%.3f %.3f\n", xans, yans);
	}
	return 0;
}

Measured memory_bytes: 656
#include <bits/stdc++.h>
#define rep(n) for (int I = 0; (I) < (n); ++(I) )
#define repeat(i, n) for( int i = 0; (i) < (n); ++(i) )
#define repeat_to(i, n) for( int i = 0; (i) <= (n); ++(i) )
#define repeat_from(i, m, n) for( int i = (m); (i) < (n); ++(i) )
#define repeat_from_to(i, m, n) for( int i = (m); (i) <= (n); ++(i) )
#define dump(x) cout << " " << #x << "=" << x
#define vdump(v) for(size_t T=0; T<v.size(); ++T){cout << " " << #v << "[" << T << "]=" << v[T];} cout << endl
using namespace std;
using lint = long long;
using ld = long double;

// 最大公約数
lint gcd(lint a, lint b) {
    // 引数の一方が 0 なら他方の値を返す
    return b ? gcd(b, a%b) : a;
}

int main(void) {
    int n, t;
    cin >> n >> t;
    vector<int> x(n);
    repeat(i, n) cin >> x[i];
    
    int ans = 0;
    int end = 0;
    repeat(i, n) {
        int newend = x[i] + t;
        if (x[i] < end) {
            ans += newend - end;
            end = newend;
        }
        else {
            ans += t;
            end = newend;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
s=(input())
s1=int(s[:2])
s2=int(s[2:])

if 1<= s1 <=12 and 1<= s2 <= 12:
    print("AMBIGUOUS")

elif 0<= s1 <=99 and 1<= s2 <= 12:
    print("YYMM")

elif 1<= s1 <=12 and 0<= s2 <= 99:
    print("MMYY")

else:
    print("NA")

Measured memory_bytes: 3060
import java.util.Scanner;
 
class Main {
    public static void main(final String[] args) {
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] w = new int[n];
      for (int i = 0; i < n; i++) {
        w[i] = sc.nextInt();
      }
      
      int f = 0;
      int b = 0;
      int f_cnt = 0;
      int b_cnt = n - 1;
      for (int j =0; j < n; j++) {
        if (f < b) {
          f += w[f_cnt++];
        } else {
          b += w[b_cnt--];
        }
      }
      System.out.println(Math.abs(f-b));
    }
  }

Measured memory_bytes: 23124
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        long x = Long.parseLong(sc.next());
        
        long a = 100;
        int ans = 0;
        while(a < x){
            a += a/100;
            ans++;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 35672
import sys
readline = sys.stdin.readline

def gcd(a,b):
    if b == 0:
        return a
    return gcd(b,a%b)

def lcm(a, b):
    return a*b//gcd(a, b)

N, M = map(int, readline().split())
A = list(map(int, readline().split()))

B = [a//2 for a in A]

L = 1
for b in B:
    L = lcm(L, b)

ans = 0
if all((L//b) & 1 for b in B):
    ok = 0
    ng = M*2
    while abs(ok-ng) > 1:
        med = (ok+ng)//2
        if (med*2-1)*L <= M:
            ok = med
        else:
            ng = med
    print(ok)
else:
    print(ans)


Measured memory_bytes: 60004
let () =
    let main () =
        let h, w, a, b = Scanf.sscanf (read_line ()) "%d %d %d %d" (fun h w a b -> h, w, a, b) in
        for i = 1 to h - b do
            Printf.printf "%s%s\n" (String.make a '1') (String.make (w - a) '0')
        done;
        for i = h - b + 1 to h do
            Printf.printf "%s%s\n" (String.make a '0') (String.make (w - a) '1')
        done
    in
    main ()

Measured memory_bytes: 2688
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>

using namespace std;
typedef pair<long long int, long long int> P;

long long int INF = 1e18;

#define MAX_N 110000

int par1[MAX_N], par2[MAX_N];
int rnk1[MAX_N], rnk2[MAX_N];
long long int diff1[MAX_N], diff2[MAX_N];

// 初期化
void init(int n, int par[], int rnk[], long long int diff[]){
	for(int i = 0; i < n; i++){
		par[i] = i;
		rnk[i] = 0;
		diff[i] = 0;
	}
}

// x の親を返す
P find(int x, int par[], long long int diff[]){
	P p;
	if(par[x] == x){
		p.first = x;
		p.second = 0;
		return p;
	}
	p = find(par[x], par, diff);
	diff[x] += p.second;
	p.second = diff[x];
	par[x] = p.first;
	return p;
}

// x と y を併合する
bool unite(int x, int y, int z, int par[], int rnk[], long long int diff[]){
	P px = find(x, par, diff);
	P py = find(y, par, diff);
	int x_par = px.first;
	int y_par = py.first;
	if(x_par == y_par){
    if(px.second != py.second + z){
      return false;
    }
		return true;
	}

	if(rnk[x_par] < rnk[y_par]){
		par[x_par] = y_par;
		diff[x_par] = diff[y_par] - px.second + py.second + z;
	}else{
		par[y_par] = x_par;
		diff[y_par] = diff[x_par] + px.second - py.second - z;
		if(rnk[x_par] == rnk[y_par]){
			rnk[x_par]++;
		}
	}
  return true;
}

// x, y が同じグループか判定
bool same(int x, int y, int par[], long long int diff[]){
	P px = find(x, par, diff);
	P py = find(y, par, diff);
	int x_par = px.first;
	int y_par = py.first;
	return (x_par == y_par);
}

int main(){
  init(MAX_N, par1, rnk1, diff1);
  init(MAX_N, par2, rnk2, diff2);
  int n, q;
  cin >> n >> q;
  for(int loop = 0; loop < q; loop++){
    int tp;
    cin >> tp;
    if(tp == 0){
      long long int x, y, z;
      cin >> x >> y >> z;
      bool ret = unite(x, y, z, par1, rnk1, diff1);
      if(!ret){
        return 0;
      }
    }else{
      long long int x, y;
      cin >> x >> y;
      if(same(x, y, par1, diff1)){
        cout << diff1[x] - diff1[y] << endl;
      }else{
        cout << "?" << endl;
      }
    }
  }
  return 0;
}



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

int main() {
  int n;
  cin >> n;
  bool f = false;
  rep(i,0,n){
    char s;
    cin >> s;
    if(s == 'Y') f = true;
  }
  if(f) cout << "Four" << endl;
  else cout << "Three" << endl;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define foreach(u,v) for(auto (u) : (v))
#define pb push_back
#define mp make_pair
#define mt make_tuple

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;

const int inf = 1e9;
const ll linf = 1LL<<60;
const ll mod = 1e9 + 7;
const double eps = 1e-9;

/*
*/

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

  ll ans = 0;
  if(a >= k){
    ans = 1+k;
  }else{
    ans = a;
    k -= a-1;

    if(b-a > 2 and k >= 2){
      ans += k%2; 
      ans += k/2 * (b-a);
    }else{
      ans += k;
    }
  }

  cout << ans << endl;

  return 0;
}


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

vector<int> s(150);
int top = 0;

void push(int x){
  s[++top] = x;
}

int pop(){
  top--;

  return s[top+1]; 
}

int main()
{
  string x;
  int cnt = 0;
  int a, b;
  
  while(cin >> x) {
    if(x == "+"){
      a = pop();
      b = pop();
      push(a + b);
    }

    else if(x == "-"){
      b = pop();
      a = pop();
      push(a - b);
    }
    
    else if(x == "*"){
      a = pop();
      b = pop();
      push(a * b);
    }
    
    else push(stoi(x));
    
  }

  cout << pop() << endl;

  return 0;

}



Measured memory_bytes: 3220
#include <bits/stdc++.h>
#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++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

void	solve()
{
	string n;
	cin >> n;
	for (char c : n) {
		if (c == '9')
			cout << 1;
		else
			cout << 9;
	}
	cout << endl;
}

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

	solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int l,r;
    scanf("%d%d",&l,&r);
    if(r-l+1>=2020)
        printf("0");
    else
    {
        int ans=2019;
        for(int i=l; i<=r; i++)
            for(int j=i+1; j<=r; j++)
                if(((i%2019)*(j%2019))%2019<ans)
                    ans=((i%2019)*(j%2019))%2019;
        printf("%d",ans);
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN=10+3;
int n,m;
int k[MAXN],s[MAXN][MAXN],p[MAXN];
int r[MAXN];
int ans;
void dfs(int d){
	if(d>n){
		bool flag=1;
		for(int i=1;i<=m;i++){
			int cnt=0;
			for(int j=1;j<=k[i];j++){
				if(r[s[i][j]]==1)
					cnt++;
			}
			if(cnt%2!=p[i]){
				flag=0;
				break;
			}
		}
		if(flag)
			ans++;
		return;
	}
	r[d]=0;
	dfs(d+1);
	r[d]=1;
	dfs(d+1);
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		scanf("%d",&k[i]);
		for(int j=1;j<=k[i];j++)
			scanf("%d",&s[i][j]);
	}
	for(int i=1;i<=m;i++)
		scanf("%d",&p[i]);
	dfs(1);
	printf("%d\n",ans);
	return 0;
}

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

#define OUT(x)  cerr << #x << " = " << x << endl;
#define all(x)  x.begin(), x.end()
#define mp      make_pair
#define pii     pair<int, int>
#define piii    pair<int, pair<int, int>>

int main() {
        string s;
        cin >> s;
        int n = s.size();
        for (int i = 0; i < n - 1; i ++) {
                if (s[i] == s[i + 1]) {
                        cout << i + 1 << ' ' << i + 2 << endl;
                        return 0;
                }
                if (i < n - 2 && s[i] == s[i + 2]) {
                        cout << i + 1 << ' ' << i + 3 << endl;
                        return 0;
                }
        }
        cout << -1 << ' ' << -1 << endl;
        return 0;
}



Measured memory_bytes: 512
#include<iostream>

using namespace std;

int main(){
  double R5,R10;

  while(cin >> R5 >> R10){
    if(R5 < 35.50 && R10 < 71.00){
      cout << "AAA" << endl;
    }
    else if(R5 < 37.50 && R10 < 77.00){
      cout << "AA" << endl;
    }
    else if(R5 < 40.00 && R10 < 83.00){
      cout << "A" << endl;
    }
    else if(R5 < 43.00 && R10 < 89.00){
      cout << "B" << endl;
    }
    else if(R5 < 50.00 && R10 < 105.00){
      cout << "C" << endl;
    }
    else if(R5 < 55.00 && R10 < 116.00){
      cout << "D" << endl; 
    }
    else if(R5 < 70.00 && R10 < 148.00){
      cout << "E" << endl;
    }
    else{
      cout << "NA" << endl;
    }

  }
  return 0;
}

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

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VL = vector<long long>;
using VVL = vector<VL>;

#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)
#define CLEAR(var, with) memset(var, with, sizeof(var))
#define ALL(x) x.begin(), x.end()
#define LL long long
#define ULL unsigned long long
#define TIME cout << "Time elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms" << endl;

char a, b;
bool isHonest()
{
    bool c = a == 'H', d = b == 'H';
    return c == d;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	//freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
    cin >> a >> b;
    if(isHonest())
        cout << 'H' << endl;
    else
        cout << 'D' << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    string s;
    cin >> n >> s;
    int w = 0;
    int e = 0;
    for(int i = 0; i < n; i++)
    {
        if(s[i] == 'W') w++;
        else e++;
    }

    int bw = 0;
    int be = 0;
    int ans = 1e8;
    for(int i = 0; i < n; i++)
    {
        char cand = s[i];
        if(cand == 'W') w--;
        else e--;
        ans = min(ans, bw + e);

        if(cand == 'W') bw++;
        else be++;
    }
    cout << ans << endl;
}


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

#define mod 1000000007

using namespace std;
typedef long long ll; 
 
int main(void){
	
	int H, W;
	
	cin >> H >> W;
	
	vector<string> a(H);
	
	for(int i=0; i<H; i++)
		cin >> a[i];
	
	vector<bool> row(H, false);
	vector<bool> col(W, false);
	
	for(int i=0; i<H; i++){
		for(int j=0; j<W; j++){
			if(a[i][j] == '#'){
				row[i] = true;
				col[j] = true;
			}
		}
	}
	
	for(int i=0; i<H; i++){
		if(row[i]){
			for(int j=0; j<W; j++){
				if(col[j]){
					cout << a[i][j];
				}
			}
			cout << endl;
		}
	}	
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for (int i = 0; i < (n); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;cin >> n >> m;
    vector<vector<int>> d(n,vector<int>(n,inf));
    rep(i,n) d[i][i]=0;
    vector<int> a(m),b(m),c(m);
    rep(i,m){
        cin >> a[i] >> b[i] >> c[i];
        a[i]--,b[i]--;
        d[a[i]][b[i]]=d[b[i]][a[i]]=c[i];
    }
    rep(i,n) rep(j,n) rep(k,n) chmin(d[j][k],d[j][i]+d[i][k]);
    int ans=0;
    rep(i,m){
        bool f=true;
        rep(j,n){
            rep(k,n){
                if(d[j][k]==d[j][a[i]]+c[i]+d[b[i]][k]){
                    f=false;
                }
            }
        }
        if(f){
            ans++;
        }
    }
    cout << ans << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> H(N);
  for(int i = 0; i < N; i++) cin >> H.at(i);
  vector<int> vec(N);
  vec.at(0)=0;
  for(int i = 1; i < N; i++){
    if(H.at(i-1) >= H.at(i)) vec.at(i)=vec.at(i-1)+1;
    else vec.at(i) = 0;
  }
  sort(vec.begin(), vec.end(),greater<>());
  cout << vec.at(0);
}

Measured memory_bytes: 1024
from collections import Counter

n = int(input())
A = [int(i) for i in input().split()]
all = sum(A)

Q = int(input())
bc = [[int(i) for i in input().split()] for _ in range(Q)]

nums = {i:0 for i in range(1, 10 ** 5 + 1)}
for a in A:
    nums[a] += 1

for i in range(Q):
    #print(nums)
    b, c = bc[i][0], bc[i][1]
    if b in nums.keys(): all += (c - b) * nums[b]
    print(all)

    nums[c] += nums[b]
    nums[b] = 0

Measured memory_bytes: 41648
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

def main():
    N = int(input())
    print(2*pi*N)

if __name__ == '__main__':
    main()


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

using namespace std;
using ll=int64_t;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using mii = map<int, int>;
using vi=vector<int>;
using vii=vector<vi>;
using vl=vector<ll>;
using vll=vector<vl>;
using tpi=tuple<int, int, int>;

int main() {
    using vp=vector<pii>;
    int M1, D1, M2, D2;
    cin >> M1 >> D1 >> M2 >> D2;
    if (D2 - D1 == 1) {
        cout << 0 << endl;
    } else {
        cout << 1 << endl;
    }

    return 0;
}


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

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

if( A+B == C || A+C == B || B+C == A ){
cout << "Yes" << endl;
}else{
cout << "No" << endl;
}
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    ll a[3 * n];
    REP(i,3 * n){
        cin >> a[i];
    }
    sort(a, a + 3 * n);
    ll ans = 0;
    for(int i = n; i < 3 * n; i += 2){
        ans += a[i];
    }
    cout << ans << endl;
}

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

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

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

/*他のライブラリを入れる場所*/

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll h,n=1;
    cin>>h;

    while(1){
        n*=2;
        if(n==h){
            n*=2;
            puta(n-1);
            return 0;
        }else if(n>h){
            puta(n-1);
            return 0;
        }
    }
    
}


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

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

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b && b==c) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

int main() {
    int N, M;
    cin >> N >> M;
    string S;
    cin >> S;

    vector<int> ans;

    int pos = N;
    while (pos != 0) {
        int k;
        for (int i=pos; i>=max(pos-M, 0); --i) {
            if (S[i] == '0') {
                k = i;
            }
        }

        if (k == pos) {
            cout << -1 << endl;
            return 0;
        }

        ans.push_back(pos - k);
        pos = k;
    }

    reverse(ans.begin(), ans.end());

    for (int i=0; i<(int)ans.size(); ++i) {
        cout << (i == 0 ? "" : " ") << ans[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 1144
n = int(input())
s = ''
X = list(map(int, input().split()))
if(len(X) % 2 == 0):
    for i in range(0, n, 2):
        s += str(X[n - 1 - i])
        s += ' '
    for i in range(0, n, 2):
        s += str(X[i])
        s += ' '
else:
    for i in range(0, n, 2):
        s += str(X[n - i - 1])
        s += ' '
    for i in range(1, n, 2):
        s += str(X[i])
        s += ' '
print(s[:-1])

Measured memory_bytes: 26180
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD (1e9+7)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

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

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

int main(void)
{
    int n;
    cin >> n;
    ll ans;
    cin >> ans;
    REP(i, n-1){
        ll a;
        cin >> a;
        ans = lcm(ans, a);
    }
    pr(ans);
}

Measured memory_bytes: 256
# D
import math
X = int(input())

B = -math.floor(math.pow(X, 0.2))
for b in range(B, 1000):
    a = int(math.pow(X + b ** 5, 0.2))
    if a ** 5 - b ** 5 == X:
        break
        
print(a, b)

Measured memory_bytes: 9444
#include<bits/stdc++.h>
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define ll long long
#define M 100000007
#define fr first
#define sc second
#define endl "\n"
#define vc vector
#define pb push_back
#define pii pair<ll,ll>
#define psi pair<string,ll>
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PI 3.14159265
#define r0 return 0

/* typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
*/
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
using namespace std;

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

    cout<<max(a+b,max(a-b,a*b));
}


Measured memory_bytes: 256
from sys import stdin
def input():
    return stdin.readline().strip()

n = int(input())
l = []
for _ in range(n):
    l.append(int(input()) - 1)

now = 0
ans = 0
for _ in range(n):
    now = l[now]
    ans += 1
    if now == 1:
        print(ans)
        exit()
else:
    print(-1)

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

#define ll long long
#define ii pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pi acos(-1.0)
#define oo 1000000007
#define loo 0x7fffffffffffffff

#define prime 1000000007

#define W(x) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << "\n";
using namespace std;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    string s; cin >> s;
    int ans = 0;
    for(auto l : s) ans+=l-'0';
    if(ans%9) cout << "No\n";
    else cout << "Yes\n";
    return 0;
}

Measured memory_bytes: 3756
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int n,c=0;
	map<int,int> mp;
	cin>>n;
	FOR(i,0,n){
		int b;
		cin>>b;
		mp[b]++;
	}
	for(auto t:mp){
		c+=(t.ND)%2;
	}

	cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 4992
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    int h, w, m; cin>>h>>w>>m;
    int x[300030], y[300030];
    int cnt[300030]={};
    vector<int> v[300030];
    for(int i=0; i<m; i++){
        cin>>x[i]>>y[i];
        x[i]--; y[i]--;
        cnt[y[i]]++;
        v[x[i]].push_back(y[i]);
    }
    multiset<int> st;
    for(int i=0; i<w; i++){
        st.insert(cnt[i]);
    }
    int ans=0;
    for(int i=0; i<h; i++){
        for(auto j:v[i]){
            ans=max(ans, (int)v[i].size()+cnt[j]-1);
            st.erase(st.find(cnt[j]));
        }
        if(st.size()){
            ans=max(ans, *st.rbegin()+(int)v[i].size());
        }
        for(auto j:v[i]) st.insert(cnt[j]);
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 37620
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long int ll;
typedef unsigned long long int ull;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> o_set;

#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define     int                 ll
#define     xx                  first
#define     yy                  second    
#define     all(a)              a.begin(),a.end()
#define     vi                  vector<int>
#define     vpi                 vector<pii>
#define     pii                 pair<int, int>
#define     present(DT, val)    (DT.find(val) != DT.end()) //for set and map
#define     cpresent(DT, val)   (find(all(DT),val) != DT.end()) //vectors
#define     input               "/home/pollution/Desktop/WorkSpace/C++/Files/input.txt"
#define     output              "/home/pollution/Desktop/WorkSpace/C++/Files/output1.txt"
#define     error               "/home/pollution/Desktop/WorkSpace/C++/Files/error.txt"
#define     IO()                ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     INF                 2e18
#define     MOD                 1000000007
#define     clr(x)              memset(x, 0, sizeof(x))
#define     out(a)              for (auto i: a) cout<<i<<' '; cout<<'\n'
#define     setd(val,n)         cout<<fixed<<setprecision(n)<<val<<'\n'

int par[(int)1e6], sz[(int)1e6], ans = 1;

int find_parent(int x){
	if(x==par[x]){
		return x;
	}
	return par[x] = find_parent(par[x]);
}

void unions(int a, int b){
	int x = find_parent(a);
	int y = find_parent(b);
	if(x!=y){
		if(sz[y] > sz[x]){
			swap(sz[x],sz[y]);
		}
		sz[x] += sz[y];
		ans = max(ans,sz[x]);
		par[y] = x;
	}
}

void solve(){
	clr(par);
	clr(sz);
    int n,m,u,v;
    cin >> n >> m;
    for(int i = 0; i < m; ++i){
    	cin >> u >> v;
    	if(par[u]==0){
    		par[u] = u;
    		sz[u] = 1;
    	}
    	if(par[v]==0){
    		par[v] = v;
    		sz[v] = 1;
    	}
    	unions(u,v);
    }
    cout << ans << '\n';
}

signed main() { 
    IO();
    
    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0; 
}

Measured memory_bytes: 19264
#include <bits/stdc++.h>
using namespace std; 
typedef long long ll;
const ll MAX_VAL = 80*80*80*2+3;
const ll   N  = 81;
int n,m;
int a[N][N]; int b[N][N];
int memo[N][N][N * N * 2 + 5];
int ans = 1e9;
int calcMemo(int i, int j, int have) {
	if (have >= N * N) return 1e9;
	if (have <= -N * N) return 1e9;
	if (i  == n) return 1e9;
	if (j == m) return 1e9;
	if (i == n - 1&&j==m-1) {
		have = min(abs(have + a[i][j] - b[i][j]), abs(have - a[i][j] + b[i][j]));
		ans = min(ans, have);
		return have; 
	}
	int &ret = memo[i][j][have + N * N]; if (ret != -1) return ret; 
	
	int c1 = calcMemo(i + 1, j, have + a[i][j] - b[i][j]); 
	int c2 = calcMemo(i + 1, j, have - a[i][j] + b[i][j]); 
	int c3 = calcMemo(i, j + 1, have + a[i][j] - b[i][j]); 
	int c4 = calcMemo(i, j + 1, have - a[i][j] + b[i][j]); 

	return ret = min(abs(min(c1,c2)),abs(min(c3,c4)));
}
int main() {
	ios::sync_with_stdio(0);
	
	cin >> n >> m; 
	for(int i =0 ; i < n; i++)for(int j = 0; j < m; j++) cin >> a[i][j]; 
	for(int i = 0; i < n; i++) for(int j = 0; j< m; j++) cin >> b[i][j]; 
	
	memset(memo, -1, sizeof memo);
	calcMemo(0,0,0);
	
	cout << ans << endl;
	
	
	return 0; 
}

Measured memory_bytes: 336768
//#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#include <math.h>
 
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
// using namespace __gnu_pbds;
// template<class T> using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
 
#define ll long long int
#define ull unsigned long long int
 
#define lp(i,n) 	    for(int i=0;i<(int)(n);i++)
#define lpi(i, j, n)    for(int i=(j);i<(int)(n);i++)
#define lpd(i, j, n)    for(int i=(j);i>=(int)(n);i--)
 
#define all(v)  	 ((v).begin()), ((v).end())
#define sz(v)    	 ((int)((v).size()))
#define clr(v, d)    (memset(v, d, sizeof(v)))
#define PB           push_back
#define MP           make_pair
#define N 100002

#define PI 3.14159265359
 
ll gcd(ll a, ll b);
vector<string> split(string target,unsigned char c );
 
 
ll n,k,t,m,x,y;
ll ans;
ll mod=1e9 +7;
pair<double,double>v[102];
bool isPrime(ll h); 

string s;
map<pair<string,string>,ll>mp;
void calc(int num){
	string red="",blue="";
	lp(i,n){
		if(num & (1<<i))red+=s[i];
		else blue+=s[i];
	}
	mp[MP(red,blue)]++;
}

ll solve(int num){
	string blue="",red="";
	lp(i,n){
		if(num & (1<<i)){
			blue+=s[i+n];
		}
		else red+=s[i+n];
	}
	reverse(all(blue));
	reverse(all(red));
	return mp[MP(blue,red)];
}
int main() {
// freopen("d.in","r",stdin); 
// 	freopen("d_out.txt","w",stdout); 
cout.precision(2);
ios_base::sync_with_stdio(false);
cin.tie(NULL);  cout.tie(NULL);

cin>>n>>s;
x=1<<n;
lpi(i,1,x-1)calc(i);

lpi(i,1,x-1)ans+=solve(i);
ans+=2;
lp(i,n){
	if(s[i]!=s[2*n -1 -i]){
		ans-=2; break;
	}
}
cout<<ans;




	

}



 

	

ll gcd(ll a, ll b){
	return b==0?a:gcd(b,a%b);
}
 
 
vector<string> split(string target,unsigned char c ){
	string d="";
	vector<string>arr;
	for(auto n:target)
	{
		if(n!=c)
		d+=n;
		else if(d!="")
		arr.push_back(d),d="";
	}
	if (d!="")
	arr.push_back(d),d="";
	return arr;
}
// bool isPrime(ll h){
//      for(ll i=0;primes[i]*primes[i]<= h;i++)
//      if (h%primes[i]==0)
//      	return 0;
//      return h!=1;
//  }
 bool isPrime(ll g){
   if((g%2==0 && g>2) || g==1)return 0;
   for(ll i=3;i*i<=g;i+=2)if(g%i==0)return 0;
   return 1;   
 
 }

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

int main() {
    int n;
    cin >> n;
    deque<int> ans;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (n % 2 != i % 2) ans.push_front(a); else ans.push_back(a);
    }
    for (auto& e : ans) cout << e << " ";
}


Measured memory_bytes: 2944