akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#define ll long long
#define MP make_pair
#define PII pair<int, int>
#define F first
#define S second
using namespace std;
string s,ss;
string res="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz",r;
bool f=0;
int main()
{
	cin >>s>>ss;
	if (ss.size()>s.size())
	{
		cout <<"UNRESTORABLE";
		return 0;
	}
	for (int i=0;i<=s.size()-ss.size();i++)
	{
		bool fl=1;
		for (int j=0;j<ss.size();j++)
		{
			if (s[i+j]=='?') continue;
			if (s[i+j]!=ss[j])
			{
				fl=0;
				break;
			}
		}
		if (fl)
		{
			r=s;
		    for (int j=0;j<ss.size();j++) if (r[i+j]=='?') r[i+j]=ss[j];
		    for (int j=0;j<s.size();j++) if (r[j]=='?') r[j]='a';
		    res=min(res,r);
		    f=1;
		}
	}
	if (!f) cout <<"UNRESTORABLE";
	else cout <<res;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

//++時計回り --反時計回り
// int dx[4] = {1, 0, -1, 0};
// int dy[4] = {0, 1, 0, -1};

int main() {
  int N;
  cin >> N;
  int B[N-1];
  REP(i, N-1) cin >> B[i];
  int A[N] = {};
  A[0] = B[0];
  REP(i, N-1) {
    if (A[i] > B[i]) {
      A[i] = B[i];
      A[i+1] = B[i];
    } else {
      A[i+1] = B[i];
    }
  }
  int ans = 0;
  REP(i, N) ans += A[i];
  cout << ans << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
using namespace std;
#define pb push_back
#define mp make_pair
#define INF 3e9
#define mod 998244353
#define eps 1e-6
#define abs(x) ((x)>=0?(x):-(x))
#define y1 solai
#define fi first
#define se second
typedef long long ll;
void read(ll &x)
{
	scanf("%lld",&x);
}
void read(ll &x, ll &y)
{
	scanf("%lld%lld",&x,&y);
}
void read(ll &x, ll &y, ll &z)
{
	scanf("%lld%lld%lld",&x,&y,&z);
}
void print(ll x)
{
	printf("%lld ",x);
}
void println(ll x)
{
	printf("%lld\n",x);
}
const ll N=300100;
ll n,ans,cnt;
char s[N];
int main()
{
	scanf("%s",s);
	n=strlen(s);
	for(ll i=0;i<n-1;i++)
		if(s[i]=='A')
			cnt++;
		else if(s[i]=='B'&&s[i+1]=='C')
			ans+=cnt,i++;
		else
			cnt=0;
	cout<<ans;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
//main
signed main(){
  int N,K;cin>>N>>K;
  std::vector<int> v(N);
  for(int i=0;i<N;i++)cin>>v[i];
  int sum=0;
  for(int i=0;i<N;i++)sum+=v[i];
  std::vector<int> d;
  for(int i=1;i*i<=sum;i++){
    if(sum%i==0){
      d.push_back(i);
      d.push_back(sum/i);
    }
  }
  int ans=0;
  for(auto p:d){
    std::vector<int> w(N);
    for(int i=0;i<N;i++)w[i]=v[i]%p;
    sort(w.begin(),w.end());
    std::vector<int> ma(N);
    for(int i=0;i<N;i++)ma[i]=(p-w[i])%p;
    for(int i=N-1;i>0;i--)ma[i-1]+=ma[i];
    for(int i=1;i<N;i++)w[i]+=w[i-1];
    for(int i=0;i<N-1;i++)if(ma[i+1]<=K&&w[i]<=K)ans=max(ans,p);
  }
  cout<<ans<<endl;
}


/*
解説AC
確かunratedだから適当にやめた記憶
候補がsumの約数までは自分でわかってたんだけど、そこからどうすればいいのかでとまった
余りは候補のアレになってるからとにかく+Kと-Kの範囲にさえ収まってくれればokなんだね
たとえば負の方にm必要で正の方にn必要ってなったらnとmの差はdの倍数に絶対なってるから
あとはなるべく負にしたいやつ正にしたいやつの順番も一緒だから累積和でok
K回ぴったり使う必要なかったんだね
*/


Measured memory_bytes: 256
n=int(input())
b=list(map(int,input().split()))
i=0
ans=0
while i!=n:
    if i==0:
        ans+=b[i]
    elif i==(n-1):
        ans+=b[i-1]
    else:
        c=[b[i],b[i-1]]
        ans+=min(c)
    i+=1

print(ans)

Measured memory_bytes: 3064
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main{
	static int max = 50001;
	static boolean[] isPrime = new boolean[max];
	public static void main(String[] args) {
		aryPrime();
		List<Integer> list = new ArrayList<Integer>();
		Scanner sc = new Scanner(System.in);
		int m = 50000;
		for(int i = 2; i <= m; i++) {
			if(isPrime[i]) {
				list.add(i);
			}
		}
		int[] dp = new int[m + 1];
		for(int p1 : list) {
			for(int p2 : list) {
				if(p1 < p2) break;
				int idx = p1 + p2;
				if(idx > m) break;
				dp[idx]++;
			}
		}
		while(sc.hasNext()) {
			int n = sc.nextInt();
			if(n == 0) break;
			System.out.println(dp[n]);
		}
		sc.close();


	}
	static void aryPrime(){
        int l = isPrime.length;
        Arrays.fill(isPrime, true);
        isPrime[0] = false;
        isPrime[1] = false;
        for(int i = 2; i <= (int)Math.sqrt(l); i++) {
            if(isPrime[i]) {
                for(int j = i * 2; j < l; j += i) {
                    isPrime[j] = false;
                }
            }
        }
    }
}


Measured memory_bytes: 41280
import java.util.Scanner;


public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int i = 1;
		while(i == i){
			int X = sc.nextInt();
			if(X == 0)
				break;
			System.out.println("Case " + i +": "+ X);
			i++;
		}
		sc.close();
	}
}

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

int N,M,Q;
int a[50], b[50], c[50], d[50];

int ans = 0;

void dfs(int digit,int num,vector<int> X){
    if (digit == N){
        int tmp = 0;
        for (int i = 0;i < Q;i++){
            if (X[b[i]] - X[a[i]] == c[i]) tmp += d[i];
        }
        ans = max(ans,tmp);
    }
    else {
        for (int i = num; i < M + 1; i++) {
            vector<int> Y = X;
            Y.push_back(i);
            dfs(digit + 1, i,Y);
        }
    }
}

int main() {
    cin >> N >> M >> Q;
    for (int i = 0;i < Q;i++){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--;b[i]--;
    }
    vector<int> X;
    dfs(0,1,X);
    cout << ans << endl;
}

Measured memory_bytes: 3604
# Educational DP Contest B-Frog 2

def frog(N, K, h):
    # initialize
    inf = float('inf')
    dp = [inf] * N
    
    minKN = min(K, N)
    for i in range(minKN):
        if i == 0:
            dp[i] = 0
        else: 
            dp[i] = abs(h[0] - h[i])
            for j in range(minKN):
                if j == i:
                    continue
                elif j < i:
                    dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]))
    # DP
    for i in range(N):
        if i == 0:
            continue
        elif i < K:
            continue
        else:
            dp[i] = min([abs(h[k] - h[i]) + dp[k] for k in range(i-K, i)])
    return dp[N-1]
    
if __name__ == "__main__":
    N, K = map(int, input().split())
    h = list(map(int, input().split()))
    print(frog(N, K, h))

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

int main(void)
{
    ios_base::sync_with_stdio(0);   cin.tie(0);
    int n, h;
    cin >> n;
    int ans = 0, cnt = 0, prev = 0;
    while(n--)
    {
        cin >> h;
        if(prev >= h)
        {
            ++cnt;
            ans = max(ans, cnt);
        }
        else    cnt = 0;
        prev = h;
    }
    ans = max(ans, cnt);
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
// DP

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

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

ll dp[110][100100];
ll W[110], V[110];

int main() {
  int n,w; cin >> n >> w;
  rep(i,n) cin >> W[i] >> V[i];

  const long long INF = 1LL << 60;

  rep(i,110){ rep(j,100100) dp[i][j] = INF; }
  dp[0][0] = 0;

  rep(i,n) {
    rep(j,100100) {
      if(j >= V[i])
      chmin( dp[i+1][j], dp[i][j - V[i]] + W[i] );
      
      chmin( dp[i+1][j], dp[i][j] );
    }
  }
  
  ll ans = 0;
  rep(j,100100){
    if(dp[n][j] <= w) ans = j;
  }
  cout << ans << endl;
  
}

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

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007
#define mm(arr) memset(arr, 0, sizeof(arr))

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


Measured memory_bytes: 3616
#include <string>
#include <iostream>
using namespace std;
const int b = 257;
const int mod1 = 1000000007;
const int mod2 = 1000000009;
string s; int h1[500009], h2[500009], pw1[500009], pw2[500009]; bool okl[500009], okr[500009];
int hash1(int l, int r) {
	return (h1[r] - 1LL * h1[l] * pw1[r - l] % mod1 + mod1) % mod1;
}
int hash2(int l, int r) {
	return (h2[r] - 1LL * h2[l] * pw2[r - l] % mod2 + mod2) % mod2;
}
int main() {
	cin >> s;
	pw1[0] = pw2[0] = 1;
	for (int i = 1; i <= s.size(); i++) {
		h1[i] = (1LL * h1[i - 1] * b + s[i - 1]) % mod1;
		h2[i] = (1LL * h2[i - 1] * b + s[i - 1]) % mod2;
		pw1[i] = 1LL * pw1[i - 1] * b % mod1;
		pw2[i] = 1LL * pw2[i - 1] * b % mod2;
	}
	int z = -1;
	for (int i = 1; i <= s.size(); i++) {
		if (s.size() % i != 0) continue;
		bool f = true;
		for (int j = i; j < s.size(); j++) {
			if (s[j] != s[j - i]) f = false;
		}
		if (f) {
			z = i;
			break;
		}
	}
	if (z == s.size()) puts("1\n1\n");
	else if (z == 1) printf("%u\n1\n", s.size());
	else {
		for (int i = 1; i <= s.size(); i++) {
			int p1 = hash1(0, i), p2 = hash2(0, i);
			for (int j = i * 2; j <= s.size(); j += i) {
				if (p1 != hash1(j - i, j) || p2 != hash2(j - i, j)) break;
				okl[j] = true;
			}
		}
		for (int i = 1; i <= s.size(); i++) {
			int p1 = hash1(s.size() - i, s.size()), p2 = hash2(s.size() - i, s.size());
			for (int j = i * 2; j <= s.size(); j += i) {
				if (p1 != hash1(s.size() - j, s.size() - j + i) || p2 != hash2(s.size() - j, s.size() - j + i)) break;
				okr[s.size() - j] = true;
			}
		}
		int ret = 0;
		for (int j = 1; j < s.size(); j++) {
			if (!okl[j] && !okr[j]) ret++;
		}
		printf("2\n%d\n", ret);
	}
	return 0;
}

Measured memory_bytes: 9604
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cout << #x << ": " << x << endl
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'

int gcd(int a, int b){ return ((b == 0) ? a : gcd(b, a % b)); }

int bc(int a){
	return __builtin_popcount(a);
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n, a, b, c;
	cin >> n >> a >> b >> c;
	vi l(n);
	int ans = 1e9;
	rep(i, n) cin >> l[i];
	repn(i, 1, (1 << n)) repn(j, 1, (1 << n)){
		if(i & j) continue;
		repn(k, 1, (1 << n)){
			if(i & k || j & k) continue;
			int cur = 0;
			int ret = 0;
			rep(s, n) if(i & (1 << s)) cur += l[s];
			ret += abs(a - cur);
			cur = 0;
			rep(s, n) if(j & (1 << s)) cur += l[s];
			ret += abs(b - cur);
			cur = 0;
			rep(s, n) if(k & (1 << s)) cur += l[s];
			ret += abs(c - cur);
			ret += 10 * (bc(i) + bc(j) + bc(k) - 3);
			ans = min(ans, ret);
		}
	}
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


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

#define F first
#define S second
#define int long long
#define ull  unsigned long long
#define pb push_back

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 3000000;
int mod = 1e9 + 7;
int a[N], T;
bitset < 4000000 > bs;
bool ok(int p, int a, int b){
    int x = p / (T + 1);
    b -= x;
    a -= T * x + p % (T + 1);
    if (a < 0 || b < 0) return 0;
    return (a + 1) * T >= b;
}
main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt","w", stdout);
    int q;
    cin >> q;
    while(q--){
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        T = (max(a, b) - 1) / (min(a, b) + 1) + 1;
        int l = 0;
        int r = a + b + 1;
        while(r - l > 10){
            int mid = (r + l) / 2;
            if (mid % (T + 1) == 0) mid++;
            if (ok(mid, a, b)) l = mid; else r = mid;
        }
        for (int i = l; i <= r; i++){
            if (i % (T + 1) && ok(i, a, b)){
                l = i;
            }
        }
        int x = l / (T + 1);
        int B = b - x;
        int A = a - T * x - l % (T + 1);
        for (int i = c; i <= d; i++){
            int x = i;
            if (x <= l){
                x %= (T + 1);
                if (x == 0){
                    cout << "B";
                } else{
                    cout << "A";
                }
            } else{
                x -= l;
                x -= (A + B) % (T + 1);
                if (x <= 0){
                    cout << "B";
                } else{
                    x--;
                    x %= (T + 1);
                    if (x == 0){
                        cout << "A";
                    } else{
                        cout << "B";
                    }
                }
            }
        }
        cout << endl;
    }
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int N,P;
    cin>>N>>P;
    if(N==1){
        cout<<P<<endl;
        return 0;
    }
    int ans=1;
    for(int i=2;i*i<=P;i++){
        int num=0;
        int p=P;
        while(p%i==0){
            p/=i;
            num++;
        }
        if(num>=N){
            ans=i;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
S = input()
ans = N+1
W_cnt = S.count('W')
left_W_cnt = 0
right_W_cnt = W_cnt
E_cnt = S.count('E')
left_E_cnt = 0
right_E_cnt = E_cnt

for i in range(0, N):
    if S[i] == 'W':
        left_W_cnt += 1
        ans = min(ans,(left_W_cnt-1 + right_E_cnt))
    else:
        right_E_cnt -= 1
        ans = min(ans,(left_W_cnt + right_E_cnt))
    #print(left_W_cnt,right_E_cnt)
print(ans)

Measured memory_bytes: 3700
{-# LANGUAGE MultiWayIf #-}

import Control.Monad
import Data.Maybe (fromJust)
import qualified Data.ByteString.Char8 as B
import Data.IORef
import Data.Array.IO

main :: IO ()
main = do
    [w, h, n] <- map (fst . fromJust . B.readInt) . B.words <$> B.getLine :: IO [Int]
    as <- replicateM n $ map (fst . fromJust . B.readInt) . B.words <$> B.getLine :: IO [[Int]]
    t <- newArray ((1, 1), (w, h)) 0 :: IO (IOArray (Int, Int) Int)
    forM_ as $ \[x, y, a] ->
        if  | a == 1 -> forM_ [1..x] $ \xx -> forM_ [1..h] $ \yy -> writeArray t (xx, yy) 1
            | a == 2 -> forM_ [x+1..w] $ \xx -> forM_ [1..h] $ \yy -> writeArray t (xx, yy) 1
            | a == 3 -> forM_ [1..w] $ \xx -> forM_ [1..y] $ \yy -> writeArray t (xx, yy) 1
            | a == 4 -> forM_ [1..w] $ \xx -> forM_ [y+1..h] $ \yy -> writeArray t (xx, yy) 1
    s <- newIORef (0 :: Int)
    forM_ [1..w] $ \x ->
        forM_ [1..h] $ \y -> do
            color <- readArray t (x, y)
            when (color == 0) $ modifyIORef s (+ 1)
    print =<< readIORef s


Measured memory_bytes: 1148
from collections import deque

S = list(input())
S = deque(S)
Q = int(input())
reverse = 1
query = [input().split() for i in range(Q)]
for i in query:
    if len(i) == 1:
        reverse *= -1
    elif (i[1]=='1' and reverse == 1) or (i[1]=='2' and reverse==-1):
        S.appendleft(i[2])
    else:
        S.append(i[2])
if reverse == -1:
   S.reverse() 
print(''.join(list(S)))

Measured memory_bytes: 44516
until (n = $<.gets.to_i).zero?
  min_dif = Float::INFINITY
  persons = []
  n.times.map {$<.gets.split.map(&:to_i)}.each do |p, h, w|
    h = Rational(h, 100)
    dif = (Rational(w, h * h) - 22).abs
    if dif < min_dif
      persons = [p]
      min_dif = dif
    elsif dif == min_dif
      persons << p
    end
  end
  puts persons.sort.first
end


Measured memory_bytes: 6936
import sys

a, b, c, x, y = input().split(" ")

a = int(a)
b = int(b)
c = int(c)
x = int(x)
y = int(y)

best_price = sys.maxsize

for i in range(0, max(x + 1, y + 1) * 2 + 1, 2):
    rest_a = x
    rest_b = y

    if i // 2 >= x:
        rest_a = 0
    else:
        rest_a = x - i // 2

    if i // 2 >= y:
        rest_b = 0
    else:
        rest_b = y - i // 2

    price = rest_a * a + rest_b * b + c * i
    if price < best_price:
        best_price = price
    # print("buy a = " + str(rest_a) + ", b = " + str(rest_b) + ", c = " + str(i) + ", price = " + str(price))

print(best_price)



Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<stack>
#include<iostream>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define MOD 1000000007
#define vec(a) vector<int>a
using namespace std;



int main()
{
#ifndef ONLINE_JUDGE
	freopen("output.txt", "w", stdout);
	freopen("input.txt", "r", stdin);
#endif
		ll n,i,j,l,k;
		cin>>n;
		l=n%10;
		if(l==0 || l==1 || l==6 || l==8)
			cout<<"pon"<<"\n";
		else if(l==3)
			cout<<"bon"<<"\n";
		else 
			cout<<"hon\n";
		return 0;
}
	


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define llu unsigned long long int
#define sa(a,n,t) for(int ii=0;ii<n;ii++) scanf("%"#t"",&(a)[ii])
#define rep(i,n) for(int i=0;i<n;i++) 
#define reps(i,a,n) for(int i=a;i<n;i++) 
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rreps(i,a,n) for(int i=n-1;i>=a;i--)
#define validl(i,a,b) ((i>=a)&&(i<=b))?1:0
#define validmat(x,y,a,b,c,d) (validl(x,a,b) && validl(y,a,b))?1:0
#define validmn(x,y,m,n) validmat(x,y,0,m,0,n)
#define valid(i,n) validl(i,0,n)
#define v(t) vector<t>
#define vv(t) vector<vector<t> >
#define mk make_pair
#define pb push_back
#define pa(a,n,t)  for(int i=0;i<n;i++) printf("%"#t"",a[i])
#define p2 pair<int,int>
#define p3 pair<p2,int>
#define fi first
#define se second
#define sd(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld",a)
#define pd(a) printf("%d",a)
#define sf(a) scanf("%lf",&a)
#define pf(a) printf("%lf",a)
#define nline printf("\n")
#define ss(a) scanf("%s",a)
#define ps(a) printf("%s",a)
#define sc(a) scanf("%c",&a)
#define pc(a) printf("%c",&a)
#define mf(m,f) m.find(f)!=m.end()
#define pp3(m) cout<<m.fi.fi<<" "<<m.fi.se<<" "<<m.se<<" "
#define pp2(m) cout<<m.fi<<" "<<m.se<<" "
#define debug 0
/*v(int) adj[200001];
void dfs(int i,int p){
    rep(j,adj[i].size()){
        if(p!=adj[i][j])
            dfs(adj[i][j],i);
    }
}*/
int n,m,p,q;
int main()
{
  ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  string s;
  cin>>s;
  int c=0;
  rep(i,s.length())
  c+=s[i]-'0';
  if(c%9==0)cout<<"Yes\n";else cout<<"No\n";
  return 0;
}

Measured memory_bytes: 3776
from collections import deque
n,c,k,*t = map(int,open(0).read().split())
d = deque(sorted(t)+[float("inf")])
f = d[0]
cnt = ans = 0
while d:
	if d[0]-f <= k:
		del d[0]
		cnt += 1
		if cnt == c:
			f = d[0]
			cnt = 0
			ans += 1
	else:
		f = d.popleft()
		cnt = 1
		ans += 1
print(ans-(c==1))

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

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= 9; i++) {
    if (n % i == 0) {
      if (1 <= n / i && n / i <= 9) {
        cout << "Yes" << endl;
        return 0;
      }
      else continue;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def main():
    N, M = map(int, input().split())
    cities = []

    for i in range(M):
        p, y = map(int, input().split())
        cities.append((i, p, y))

    city_nums = [0]*(N+1)
    ids = []
    for city in sorted(cities, key=lambda x: x[2]):
        city_nums[city[1]] += 1
        # s = f"{city[1]:0>6}{pref[city[1]]:0>6}"
        s = '{0:0>6}{1:0>6}'.format(city[1], city_nums[city[1]])
        ids.append((city[0], s))

    for _, num in sorted(ids, key=lambda x: x[0]):
        print(num)


if __name__ == "__main__":
    main()


Measured memory_bytes: 38384
#include<stdio.h>

int main(void)
{
	int i,pips[6];
	char com[100];
	int temp,top = 0,back = 1,right = 2,left = 3,front = 4,bottom = 5;


	for(i = 0;i < 6;i++){
		scanf("%d",&pips[i]);
	}

	scanf("%s",com);
	for(i = 0;com[i] != 0;i++){
		if(com[i] == 'S'){
			temp = back;
			back = top;
			top = front;
			front = bottom;
			bottom = temp;
		}
		else if(com[i] == 'N'){
			temp = front;
			front = top;
			top = back;
			back = bottom;
			bottom = temp;
		}
		else if(com[i] == 'E'){
			temp = right;
			right = top;
			top = left;
			left = bottom;
			bottom = temp;
		}else{
			temp = left;
			left = top;
			top = right;
			right = bottom;
			bottom = temp;
		}
	}
	printf("%d\n",pips[top]);
	return 0;
}

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

int main() {
  string S, T;
  cin >> S >> T;
  
  T.pop_back();
  
  if ( S == T ){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  
  return 0;

}

Measured memory_bytes: 3592
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>

using namespace std;

constexpr long double EPS = 1e-10;

class Point{
    public: 
    long double x,y;
    Point(long double x = 0.0, long double y = 0.0): x(x), y(y) {}
    Point operator + (const Point &p) const { return Point(x+p.x, y+p.y); }
    Point operator - (const Point &p) const { return Point(x-p.x, y-p.y); }
    Point operator * (const long double &a) const { return Point(x*a, y*a); }
    Point operator / (const long double &a) const { return Point(x/a, y/a); }
    bool operator < (const Point &p) const { return (x != p.x ? x < p.x : y < p.y); }
    bool operator == (const Point &p) const { return fabsl(x - p.x) < EPS && fabsl(y - p.y) < EPS; }
    long double abs() const { return sqrt(norm()); }
    long double norm() const { return x*x + y*y; }
    long double dot(Point &p) const { return x*p.x + y*p.y; }
    long double cross(Point &p) const { return x*p.y - y*p.x; }   
};

bool check(int n, vector<Point> &ps, long double r) {
    for(int i=0;i<n;++i) {
        for(int j=i+1;j<n;++j) {
            Point p1 = ps[i], p2 = ps[j];
            long double d = sqrt(r * r / (p2-p1).norm() - 0.25);
            if(r * r / (p2-p1).norm() - 0.25 < 0.0) return false;
            Point q = Point(
                (p1.x+p2.x)/2.0 + d*(p2.y-p1.y), 
                (p1.y+p2.y)/2.0 - d*(p2.x-p1.x)
            );
            bool ok = true;
            for(int k=0;k<n;++k) {
                if((ps[k]-q).abs() > r+EPS) {
                    ok = false;
                    break;
                }
            }
            if(ok) return true;
            ok = true;
            q = Point(
                (p1.x+p2.x)/2.0 - d*(p2.y-p1.y), 
                (p1.y+p2.y)/2.0 + d*(p2.x-p1.x)
            );
            for(int k=0;k<n;++k) {
                if((ps[k]-q).abs() > r+EPS) {
                    ok = false;
                    break;
                }
            }
            if(ok) return true;
        }
    }

    return false;
}

int main() {
    int n;
    cin >> n;
    vector<Point> ps(n);
    for(int i=0;i<n;++i) {
        cin >> ps[i].y >> ps[i].x;
    }

    if(n == 2) {
        cout << setprecision(14) << fixed << (ps[1]-ps[0]).abs()/2.0 << endl;
        return 0;
    }

    long double r_low = 0.0, r_high = 100000.0;
    for(int i=0;i<50;++i) {
        long double r = (r_low + r_high) / 2.0;
        if(check(n, ps, r)) {
            r_high = r;
        } else {
            r_low = r;
        }
    }

    cout << setprecision(14) << fixed << r_high << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i, n) for(ll (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(ll (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b)
{
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    
    return b ? gcd(b, a % b) : a;
}

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

int main() {
  ll a, b;
  cin >> a >> b;
  cout << lcm(a, b) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main() {
	int i;
	int	x[10000],y[10000];

//input dataset
	for (i = 0; i < 10000; i++) {
		scanf("%d %d", &x[i],&y[i]);
		if (!(x[i] || y[i])) break;
	}

	
//outputs
	for (i = 0; i < 10000 && (x[i]||y[i]); i++) {
		if (x[i] > y[i]) printf("%d %d\n", y[i], x[i]);
		else printf("%d %d\n", x[i], y[i]);
	}

	return 0;
}

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

int main() {
  string S, T;
  cin >> S >> T;
  
  int count = 0;
  for(int i=0; i < S.size(); i++){
    if(S.at(i) != T.at(i))
      count++;
  }
  cout << count << endl;
}

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

template<typename dtype, dtype initValue /*範囲外の時に返す値*/>
class RMQ{
public : 
  
  struct data{
    bool type; //0 - empty   , 1 - update
    dtype value;
  };
  
  int n,n_;
  vector<dtype> dat;
  vector<data> td;
  int toMax;          //0 -> RangeMin 1->RangeMax;
  
  RMQ(){n=-1;}
  RMQ(int n_, int toMax = 0):n_(n_),toMax(toMax){
    n=1;
    while(n<n_)n*=2;
    td.resize(2*n-1,(data){0,initValue});
    dat.resize(2*n-1,initValue);
  }

  inline dtype merge(dtype a, dtype b){return toMax? max(a, b):min(a, b);}
  
  
  dtype dfs(int a,int b,dtype x,bool flag,int k,int l,int r){
    if(r <= a || b <= l) return flag? dat[k]:initValue;
    if(a <= l && r <= b){
      if(flag == true){
        td[k]=(data){1,x};
        dat[k]=x;
      }
      return dat[k];
    }
    
    if(td[k].type){
      td[k].type = 0;
      dat[k*2+1] = dat[k*2+2] = td[k].value;
      td[k*2+1] = td[k*2+2] = (data){1,td[k].value};
    }

    dtype vl=dfs(a, b, x, flag, k*2+1, l, (l+r)/2);
    dtype vr=dfs(a, b, x, flag, k*2+2, (l+r)/2, r);
    return flag? (dat[k] = merge(vl, vr)):merge(vl,vr);
  }
  
  //[l,r)の値をxに変更　update(l,r,x)
  void update(int l,int r,dtype x){
    assert(l <= r), assert(l <= n && r <= n), assert(l >= 0 && r >= 0);
    dfs(l, r, x, true, 0, 0, n);
  }
  
  //[l,r)の最小値を得る　find(l,r);
  dtype get(int l,int r){
    assert(l <= r), assert(l <= n && r <= n), assert(l >= 0 && r >= 0);
    return dfs(l, r, initValue , false, 0 , 0 ,n);
  }
};

typedef tuple<int,int,int> T;

signed main(){
  
  const int INF = 1e15;
  
  int N, Q;
  cin>>N>>Q;
  
  RMQ<int,INF> rmq(Q);
  
  vector<T> vec;
  
  for(int i=0;i<N;i++){
    int s, t, x;
    cin>>s>>t>>x;
    vec.push_back( T( -x, s, t ) );
  }
  
  sort( vec.begin(), vec.end() );
  
  vector<int> D(Q);
  
  for(int i=0;i<Q;i++) cin>>D[i];
  
  for(T tmp : vec){
    
    int s, t, x;

    tie( x, s, t ) = tmp;
    
    x *= -1;
    
    int l = max( 0LL, s - x );
    int r = max( 0LL, t - x );
    
    if( r == 0 ) continue;
    
    int L = lower_bound( D.begin(), D.end(), l ) - D.begin();    
    int R = lower_bound( D.begin(), D.end(), r ) - D.begin();
    
    rmq.update( L, R, x );
    
  }
    
  for(int i=0;i<Q;i++){
    
    int ans = rmq.get( i, i + 1 );
    
    if( ans == INF ) ans = -1;

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


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


public class Main{
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));

        // Start writing your solution here. -------------------------------------
        int n = sc.nextInt(), W = sc.nextInt();
        int w[] = new int[n + 1], v[] = new int[n + 1];
        int max = 0, sum = 0;
        for(int i = 1; i <= n ; i ++)
        {
            w[i] = sc.nextInt();
            v[i] = sc.nextInt();
            sum += v[i];
        }
        long dp[][] = new long[n + 1][sum + 1];
        Arrays.fill(dp[0], 100000000000000000l);
        dp[0][0] = 0;
        for(int i = 1; i <= n; i++)
        {
            for(int j = 1; j <= sum; j++)
            {
                dp[i][j] = dp[i - 1][j];
                if(v[i] <= j) dp[i][j] = Math.min(dp[i][j], dp[i - 1][j - v[i]] + w[i]);
            }
        }
        for(int j = sum; j >= 0; j--)
            if(dp[n][j] <= W) {
                out.println(j);
                out.close();
                return;
            }
        /*
        int n      = sc.nextInt();        // read input as integer
        long k     = sc.nextLong();       // read input as long
        double d   = sc.nextDouble();     // read input as double
        String str = sc.next();           // read input as String
        String s   = sc.nextLine();       // read whole line as String

        int result = 3*n;
        out.println(result);                    // print via PrintWriter
        */

        // Stop writing your solution here. -------------------------------------
        out.close();
    }
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    //--------------------------------------------------------
}

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

#define MAX_SOSU 1000000

int main(void)
{
	int n;
	int i, j, k, f;
	int sosu[MAX_SOSU];
	k = 0;
	sosu[0] = 0;
	for( i=2; i<=MAX_SOSU; i++) {
		f = 0;
		for( j=2; j<=sqrt(i); j++ ) {
			if ( i % j == 0 ) {
				f = 1;
				goto out;
			}
		}
		out:
		if ( f == 0 ) k++;
		sosu[i - 1] = k;
	}
	
	while( scanf( "%d", &n ) != EOF ) printf( "%d\n", sosu[n - 1] );
	
	return 0;
}

Measured memory_bytes: 4500
a, b, x = gets.chomp.split.map(&:to_i)

if a * a * b <= x * 2 # あまり傾かない
  puts Math.atan((2.0 * (a * a * b - x)) / (1.0 * a * a * a)) * 180 / Math::PI
else
  puts Math.atan((a * b * b)/ (2.0 * x)) * 180 / Math::PI
end


Measured memory_bytes: 3836
#pragma GCC optimize("O3")   //
#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, b, a) for(int i = b - 1; i >= a; i--)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;
typedef unsigned long long ull;

unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
std::mt19937 eng(seed);

uniform_int_distribution<> DD(0, (1ll << 31));

ll random2(){
    return (ll(DD(eng))*(1ll << 31) + ll(DD(eng))) & ((1ll << 62ll)-1);
}

ll n,m,k,q,T;

const ll big = 1000000007;
const ll big2 = 1000000009;
const ll mod =  998244353;

const int MAXN = 500001;

ll up[MAXN+1] = {0};
ll FAC[MAXN+1] = {0};
ll INV[MAXN+1] = {0};

ll powmod(ll i, ll j){
    if(j == 0)return 1;
    ll h = powmod(i,j/2);
    if(j%2 == 0)return (h*h)%big;
    return (((h*h)%big)*i)%big;
}

ll bin(ll i, ll j){
    if(i < j)return 0;
    ll b = (INV[j]*INV[i-j])%big;
    return (FAC[i]*b)%big;
}

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

    //freopen("input.txt","r",stdin);
    //freopen("autput.txt","w",stdout);

    ll a,b,c,d,e;

    cin >> n >> m;

    up[n] = 1;
    for(ll c1 = n-1; c1 >= 0; c1--){
        up[c1] = (up[c1+1] * (m-c1)) % big;
    }

    ll t = 1;
    for(ll c1 = 0; c1 < MAXN+1; c1++){
        FAC[c1] = t;
        t *= (c1+1);
        t %= big;
    }
    INV[MAXN] = powmod(FAC[MAXN], big-2);
    for(ll c1 = MAXN-1; c1 >= 0; c1--){
        INV[c1] = (INV[c1+1] * (c1+1))%big;
    }

    ll ans = 0;
    t = 1;

    for(ll k = 0; k <= n; k++){
        ll temp = (up[0] * up[k])%big;
        temp *= bin(n,k);
        temp %= big;
        ans += t*temp;
        ans %= big;

        t = big-t;
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 15288
#include <iostream>

using namespace std;

int main() {
  int ans = 0;
  int cnt = 0;
  char c;
  while (cin >> c) {
    if (c == 'A' || c == 'C' || c == 'G' || c == 'T')
      ++cnt;
    else
      cnt = 0;
    ans = max(cnt, ans);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
long long mod = 998244353;
long long p(long long a, long long b) {
	if (b == 0) return 1;
	long long k = p(a, b/2);
	if (b % 2 == 0) {
		return (k*k) % mod;
	}
	return ((k*k) % mod) * a % mod;
}
int main () {
	int n;
	cin >> n;
	vector<int> d(n);
	map<int, int> m;
	int M = 0;
	for (int i = 0; i < n; i++) {
		cin >> d[i];
		m[d[i]]++;
		M = max(M, d[i]);
	}
	if (!(d[0] == 0 && m[0] == 1)) {
		cout << 0 << endl;
		return 0;
	}
	long long ans = 1;
	for (int i = 1; i <= M; i++) {
		if (m[i-1] == 0) {
			cout << 0 << endl;
			return 0;
		}
		ans *= p(m[i-1], m[i]);
		ans %= mod;
	}
	cout << ans << endl;
}

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

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

    int M = 100010;

    int N, C;
    cin >> N >> C;
    int Chan[C][M] = {};
    for(int i = 0; i < N; i++){
        int s, t, c;
        cin >> s >> t >> c;
        c--;
        for(int j = s; j <= t; j++){
            Chan[c][j] = 1;
        }
    }

    int ans = 0;
    for(int i = 0; i < M; i++){
        int cnt = 0;
        for(int j = 0; j < C; j++){
            cnt += Chan[j][i];
        }
        ans = max(ans, cnt);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 12032
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

ll SUM(vector<ll>&& vec){return accumulate(all(vec),0LL);} // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
bool isPrime(ll n); // 素数か
vector<ll> primes(ll n); // 素因数分解
int ctoi(char c){return c - '0';}

const ll COM_MAX = (ll)(1e6+100); // combinationの最大値
vector<ll> fac(COM_MAX),finv(COM_MAX),inv(COM_MAX);
void comb_init(); // 初期化
ll comb(ll n,ll k); // nCk

void dfs(int n,int now,string s){
  if(n == now)cout<<s<<endl;
  else rep(i,3)dfs(n+1,now,s+(char)('a'+i));
}

// TODO: write
int main() { 
  int h,w,n;cin>>h>>w>>n;

  print(n/max(h,w)+!!(n%max(h,w)));
  return 0;
}




void comb_init(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(int i=2;i<COM_MAX;++i){
    fac[i]=fac[i-1]*i%INF;
    inv[i]=INF-inv[INF%i]*(INF/i)%INF;
    finv[i]=finv[i-1]*inv[i]%INF;
  }
}

ll comb(ll n,ll k){
  if(n<k)return 0;
  if(n<0||k<0)return 0;
  return fac[n]*(finv[k]*finv[n-k]%INF)%INF;
}

bool isPrime(ll n) {
	for (int i = 2; n >= i * i; ++i) {
		if(!(n % i))return false;
	}
  return true;
}
vector<ll> primes(ll n){
  vector<ll> v;
  for (ll i = 2; i*i <= n; ++i) {
    while(n%i==0){
      n/=i;
      v.pb(i);
    }
  }
  if(n != 1)v.pb(n);
  return v;
}


/* 二分探索の時に使う
template<typename T>bool isOk(T key,T value){
  return key <= value;
}
template<typename T>T binary_search(vector<T> a,T key){
  T ok = a.size();
  T ng = -1;
  while(abs(ok - ng) > 1){
    T mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}
*/

Measured memory_bytes: 23680
#define _CRT_SECURE_NO_WARNINGS
#define REL
#include <algorithm>
#include <string>
#include <iostream>
#include <complex>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <stack>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <random>
#include <set>
#include <vector>
#include <unordered_map>
#include <bitset>
#include <unordered_set>
#include <array>
#include <forward_list>
#include <chrono>
#include <iomanip>
#include <utility>
#include <assert.h>

#pragma GCC optimize("Ofast")
#pragma target("sse", "sse1")

#define mp make_pair
#define pb push_back

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

mt19937 gen(34);

int n, ans;
string s;

int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	//freopen("memory.in", "r", stdin);
	//freopen("memory.out", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> s;
	for (int i = 2; i < s.length(); i++)
		ans += (s[i] == 'C' && s[i - 1] == 'B' && s[i - 2] == 'A');
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int A, B;
  scanf("%d %d", &A, &B);

  double C = (double)(B-1)/(double)(A-1);
  if(C == (int)C)
    printf("%d\n", (int)C);
  else
    printf("%d\n", (int)C+1);
  
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int n;
vector<int> a;
bool last=false;
void solve(){
    cin >> n;
    rep(i,n){
        int a_;
        cin >> a_;
        a.push_back(a_);
    }
    if (n==1){
        cout << "Yes" << endl;
        return;
    }
    Rep(i,1,n){
        if (last){
            if (a[i-1]+1<=a[i]) {
                a[i]-=1;
            }else if (a[i-1]>a[i]){
                cout << "No" << endl;
                return;
            }
        }else{
            if (a[i-1]<=a[i]){
                a[i]-=1;
                last=true;
            }else if(a[i-1]-1==a[i]){
                last=true;
            }else{
                cout << "No" << endl;
                return;
            }
        }
    }

    cout << "Yes" << endl;
    return;
}

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

Measured memory_bytes: 892
from collections import Counter
n=int(input())
v=list(map(int,input().split()))

A=v[0::2]
B=v[1::2]
a=len(A)
b=len(B)

#print(Counter(A).most_common()[0][0])
#print(Counter(B).most_common()[0][0])

if Counter(A).most_common()[0][0] !=Counter(B).most_common()[0][0]:
    s=Counter(A).most_common()[0][1]
    t=Counter(B).most_common()[0][1]
    print( (a-s)+(b-t))
else:
  r=a
  s=b
  if Counter(A).most_common()[0][1]<a:
    o=Counter(A).most_common()[1][1]
    p=Counter(B).most_common()[0][1]
    r= (a-o)+(b-p)
  if Counter(B).most_common()[0][1]<b:
    w=Counter(A).most_common()[0][1]
    x=Counter(B).most_common()[1][1]
    s= (a-w)+(b-x)
  print(min( r, s))


Measured memory_bytes: 17544
#include <stdio.h>

int gcd(int a, int b)
{
	if (a < b)
	{
		int temp;
		temp = a;
		a = b;
		b = temp;
	}
	while (b > 0)
	{
		int r= a % b;
		a = b;
		b = r;
	}	
	return a;
}

int main()
{
	int a, b;
	scanf("%d%d", &a, &b);
	printf("%d\n", gcd(a, b));
}


Measured memory_bytes: 2732
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma,tune=native")
//#pragma GCC optimize("unroll-loops")

#ifdef __APPLE__
    # include <iostream>
    # include <cmath>
    # include <algorithm>
    # include <stdio.h>
    # include <cstdint>
    # include <cstring>
    # include <string>
    # include <cstdlib>
    # include <vector>
    # include <bitset>
    # include <map>
    # include <queue>
    # include <ctime>
    # include <stack>
    # include <set>
    # include <list>
    # include <random>
    # include <deque>
    # include <functional>
    # include <iomanip>
    # include <sstream>
    # include <fstream>
    # include <complex>
    # include <numeric>
    # include <immintrin.h>
    # include <cassert>
    # include <array>
    # include <tuple>
    # include <unordered_map>
    # include <unordered_set>
    # include <thread>
#else
    # include <bits/stdc++.h>
#endif

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define files(name) name!=""?freopen(name".in","r",stdin),freopen(name".out","w",stdout):0
#define all(a) a.begin(),a.end()
#define len(a) (int)(a.size())
#define elif else if
#define mp make_pair
#define pb push_back
#define fir first
#define sec second

using namespace std;
#define int long long

typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long double ld;
typedef long long ll;

const int arr=2e5+10;
const int ar=2e3+10;
const ld pi=acos(-1);
const ld eps=1e-10;
const ll md=1e9+7;
const ll inf=1e18+10;

///---program start---///

signed main()
{
    #ifdef __APPLE__
        files("barik");
        freopen("debug.txt","w",stderr);
    #endif

    string s;
    cin>>s;
    int ans=0;
    for (int m=0;m<(1ll<<(len(s)-1));m++){
        int sum=0;
        int cur=0;
        for (int i=0;i<len(s);i++){
            cur=cur*10+(s[i]-'0');
            if (i==len(s)-1 || (m&(1ll<<i))!=0 ){
                sum+=cur;
                cur=0;
            }
        }
        ans+=sum;
    }
    cout<<ans<<"\n";
}


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

int main(){
    ll n,k;
    cin>>n>>k;
    ll h[n+1];
    h[0]=0;
    bool ans[n+1];
    for (int i=0; i<=n; i++){
        ans[i]=true;
    }
    for (ll i=1; i<=n; i++){
        cin>>h[i];
    }
    for (int i=0; i<k; i++){
        ll a,b;
        cin>>a>>b;
        if (h[a]>=h[b]) ans[b]=false;
        if (h[b]>=h[a]) ans[a]=false;
    }
    ll count=0;
    for (int i=1; i<=n; i++){
        if (ans[i]==true) count+=1;
    }
    cout<<count<<endl;
}

Measured memory_bytes: 4504
#include <iostream>
#include <set>

using namespace std;

int min(int a, int b)
{
    if( a < b ) return a;
    else return b;
}

int main()
{
    int N;
    cin >> N;
    
    set<int> s;
    int sum = 0;
    for( int i = 0; i < N; ++i ){
        int tmp;
        cin >> tmp;
        s.insert(tmp);
        sum += tmp;
    }
    
    int diff = 0;
    for( auto itr = s.begin(); itr != s.end(); ++itr ){
        if( (sum-diff)%10 == 0 ) diff = min(*itr, diff+*itr);
    }
    
    if( (sum-diff)%10 == 0 ) cout << 0 << endl;
    else cout << sum-diff << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX 500111
#define mod 1000000007
const long long  inf = 2000000000000000000;
using namespace std;
int co[777],ca = 0,cb = 0;
bool dp[2][MAX];
bool b[777][777];
vector<int> g[777];
bool dfs(int u,bool c){
    co[u] = c;
    if(c)ca++;
    else cb++;
    bool ret = 1;
    for(auto v : g[u]){
        if(co[v] == -1) ret  &= dfs(v,1-c);
        else if(co[v] == co[u])return 0;
    }
    return ret;
}


vector<pair<int,int> > v;
int main(){ 
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); 
    int n,m,x,y;
    cin>>n>>m;
    memset(b,0,sizeof b);
    for(int i =0 ;i < m ; i++){
        cin>>x>>y;
        b[x][y] = 1;
        b[y][x] = 1;
    }
    for(int i = 1 ; i <= n ; i++){
        for(int j = i + 1; j <= n ;j++){
            if(b[i][j])continue;
            g[i].push_back(j);
            g[j].push_back(i);
        }
    }
    memset(co,-1,sizeof co);
    for(int i = 1; i <= n ;i++){
        if(co[i] == -1){
            if(!dfs(i,0)){
                cout<<-1;
                return 0;
            }
            v.push_back({ca,cb});
            ca = 0;cb= 0;
        }
    }
    memset(dp,0,sizeof dp);
    dp[0][v[0].first] = 1;
    dp[0][v[0].second] = 1;
    for(int i = 1; i < v.size(); i++){
        for(int j = 0; j < MAX ; j++){
            if(dp[0][j]){
                dp[1][j + v[i].first] = 1;
                dp[1][j + v[i].second] = 1;
            }
        }
        for(int j = 0; j < MAX ;j ++){dp[0][j] = dp[1][j];dp[1][j] = 0;}

    }
    long long  ans = inf;
    for(int i = 0; i < MAX; i++)if(dp[0][i])ans = min(ans,1LL*i*(i-1)/2 + 1LL*(n-i)*(n-i-1)/2);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3712
#include <iostream>

using namespace std;

int main() {
	int count;
	cin >> count;
	
	while(count-- >0){
		int t[3];
		for(int i=0;i<3;i++){
			cin >> t[i];
		}
		if(((t[0]*t[0])==((t[1]*t[1])+(t[2]*t[2]))) || ((t[1]*t[1])==((t[0]*t[0])+(t[2]*t[2]))) || ((t[2]*t[2])==((t[1]*t[1])+(t[0]*t[0])))){
			cout << "YES" <<endl;
		}else{
			cout << "NO" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

int main() {
    int n, ans = 0;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int now;
        cin >> now;
        while (now % 2 == 0) {
            ++ans;
            now >>= 1;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256