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

int main()
{
    long long int N,K,Q,i;
    scanf("%lld%lld%lld", &N, &K, &Q);
    long long int A[Q],B[N];
    for(i=0;i<N;i++){
        B[i]=0;
    }
    for(i=0;i<Q;i++){
        scanf("%lld", &A[i]);
        B[A[i]-1]++;
    }
    for(i=0;i<N;i++){
        if(B[i]>Q-K){
            printf("Yes\n");
        }
        else{
            printf("No\n");
        }
    }



    return 0;
}


Measured memory_bytes: 2048
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<iterator>
#include<stack>
#include<queue>
#include<utility>
#include<functional>
#include<bitset>
#include<numeric>
#include<cstring>
#include<tuple>
using namespace std;

int d;
long long ans = 0;
vector< int > c( 30 ), t( 400 ), last( 30, 0 );
vector< vector< int > > arr( 400, vector< int >( 30, 0 ) );

int main( void )
{
	ios :: sync_with_stdio( 0 );
	cin.tie( 0 );
	
	cin >> d;
	for( int i = 1; i <= 26; ++i )
	{
		cin >> c[ i ];
	}
	for( int i = 1; i <= d; ++i )
	{
		for( int j = 1; j <= 26; ++j )
		{
			cin >> arr[ i ][ j ];
		}
	}
	for( int i = 1; i <= d; ++i )
	{
		cin >> t[ i ];
	}
	for( int i = 1; i <= d; ++i )
	{
		last[ t[ i ] ] = i;
		ans += arr[ i ][ t[ i ] ];
		for( int j = 1; j <= 26; ++j )
		{
			ans -= c[ j ] * ( i - last[ j ] );
		}
		cout << ans << "\n";	
	}
	return 0;
}


Measured memory_bytes: 3672
#include<stdio.h>
int main(){
  int a,s,d,f;
  scanf("%d",&a);
  scanf("%d",&s);
  scanf("%d",&d);
  scanf("%d",&f);
  int ansH,ansW;
  ansH=a-d;
  ansW=s-f;
  int ans;
  ans=ansH*ansW;
  printf("%d\n",ans);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

 long long int a,b,c,d,x,y,z,w,y1,z1;
 cin>>a>>b>>c>>d;
 x=a*c;
 y=a*d;
 z=b*c;
 w=b*d;
 y1=max(x,y);
 z1=max(z,w);
 cout<<max(y1,z1);


}  


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

using namespace std;

int main(){
	int H,W,N;
	cin>>H>>W>>N;
    vector <int>a(N);
    for(int i=0 ; i<N ; i++){
        cin>>a[i];
    }
	
	vector <int>b(W*H,0);
	int now=0;
	bool dis=true;
	for(int i=0 ; i<N ; i++){
		for(int j=0 ; j<a[i] ; j++){
			b[now]=i+1;
			if(i==N-1 && j==a[i]-1)break;
			if(now%W==W-1 && dis==true){
				now+=W;
				dis=false;
			}
			else if(now%W==0 && now!=0 && dis==false){
				now+=W;
				dis=true;
			}
			else if(dis)now+=1;
			else now-=1;
		}
	}
	for(int i=0 ; i<H*W ; i++){
		cout<<b[i]<<" ";
		if(i%W==W-1)cout<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 384
N, M, X, Y = map(int, input().rstrip().split())
x = list(map(int, input().rstrip().split()))
y = list(map(int, input().rstrip().split()))
x = max(x)
y = min(y)
Z = [i for i in range(x+1, y+1)]
ans = "War"
for z in Z:
    if z > X and Y >= z:
        ans = "No War"
        break
print(ans)


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

int main(void){
    int n;
    cin >> n;
    vector<int> h(n);
    vector<int> sor(n);
    for(int i=0; i<n; i++){
        cin >> h[i];
        sor[i] = h[i];
    }
    
    sort(sor.begin(), sor.end());
    int before = 0;
    int ans = 0;
    for(int i=0; i<n; i++){
        bool mount = false;
        if(sor[i]>before){
            int now = sor[i];
            for(int j=0; j<n; j++){
                if(h[j] >= now && !mount){
                    mount = true;
                }else if(h[j] < now && mount){
                    ans += (now - before);
                    mount = false;
                }
                if(j == n-1 && h[j] >= now){
                    ans += (now - before);
                }
            }
            before = now;
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))

typedef struct edge{ll s,g;}E;
int edgehikaku(const void*a,const void*b){
	E*p=(E*)a,*q=(E*)b;
	if((*p).s<(*q).s)return -1;
	if((*p).s>(*q).s)return  1;
	if((*p).g<(*q).g)return -1;
	return 1;
}

E e[200010];
int id[100010];
int check[100010];
ll a[100010];

ll f(int n){
	//nから上に行く本数を返す
	check[n]=1;
	
	//子のsumとmaxを覚えておく
	ll s=0,M=0,flag=0;
	rep(i,id[n],id[n+1])if(!check[e[i].g]){
		ll temp=f(e[i].g);
		s+=temp;
		M=max(M,temp);
		flag=1;
	}
	
	//葉ならa[n]本上にいく
	if(!flag)return a[n];
	
	//そうでないなら上にはsum-(sum-a[n])*2即ちa[n]*2-sum本行く
	//これが0未満ならダメ
	if(a[n]*2-s<0){
		puts("NO");
		exit(0);
	}
	
	//そもそも数が足りなければダメ
	if(a[n]>s){
		puts("NO");
		exit(0);
	}
	
	//M-(a[n]*2-sum)がsum-(a[n]*2-sum)の1/2より真に大きいとだめ
	if((M-(a[n]*2-s))*2>s-(a[n]*2-s)){
		puts("NO");
		exit(0);
	}
	
	return a[n]*2-s;
}

int main(){
	int n;
	scanf("%d",&n);
	rep(i,0,n)scanf("%lld",a+i);
	rep(i,0,n-1){
		ll x,y;
		scanf("%lld %lld",&x,&y);
		x--,y--;
		e[2*i].s=x;
		e[2*i].g=y;
		e[2*i+1].s=y;
		e[2*i+1].g=x;
	}
	qsort(e,2*n-2,sizeof(E),edgehikaku);
	
	int p=0;
	rep(i,1,n){
		while(e[p].s!=i)p++;
		id[i]=p;
	}
	id[n]=2*n-2;
	
	//コーナーケース
	if(n==2){
		puts(a[0]==a[1]?"YES":"NO");
		return 0;
	}
	
	//葉でない頂点を親とする
	p=0;
	while(id[p+1]-id[p]==1)p++;
	puts(f(p)?"NO":"YES");
}

Measured memory_bytes: 10180
"""
NTC here
"""
from sys import stdin, setrecursionlimit
setrecursionlimit(10**7)

def iin(): return int(stdin.readline())
 
 
def lin(): return list(map(int, stdin.readline().split()))

# range = xrange
# input = raw_input
def main():
    x,y=lin()
    ans=[0,3,2,1]
    sol=0
    if x<4:sol+=ans[x]
    if y<4:sol+=ans[y]
    if x==y==1:sol+=4
    print(sol*100000)
    



    
                











main()

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */

int main() {
  ll a,b,c,k; cin >> a >> b >> c >> k;
  if(k%2 == 0) cout << a-b << endl;
  else cout << b-a << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>

using namespace std;

int main(void)
{
	int n, flag;
	flag = 0;
	cin >> n;
	for (int a = 1; a <= 9; a++) {
		for (int b = 1; b <= 9; b++) {
			if (n == a * b) {
				flag = 1;
			}
		}
	}
	if (flag) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define MIN(a, b) (a<b?a:b)


int main(int argc, char const* argv[])
{
	int n, i;
	int b[100];
	scanf("%d",&n);
	for(i=0; i<n-1; i++) {
		scanf("%d",b+i);
	}
	int ans=b[0]+b[n-2];
	for(i=1; i<n-1; i++) {
		ans += MIN(b[i-1], b[i]);
	}
	printf("%d\n", ans);
	
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))

#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s))
#define repiins(x, y, z, s) for ((x) = (z); (x) <= (y); (x) += (s))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)

#define All(x) (x).begin(),(x).end()

#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))

#define Unique(v) v.resize(unique(All(v)) - v.begin())

#define peq(p0, p1)(p0.first == p1.first && p0.second == p1.second)

#define End '\n'
#define Out(x) cout<<(x)<<End
#define OutP(p, sep, end) cout<<p.first<<sep<<p.second<<end

template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lb std::lower_bound
#define ub std::upper_bound

#define lbi(v, x) lb(All(v), (x))-v.begin()
#define ubi(v, x) ub(All(v), (x))-v.begin()

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);
	//std::cout.precision(18);

    int n, l;

	cin >> n >> l;

	string s[n];

	int i;

	rep(i, n) cin >> s[i];

	sort(s, s + n);

	rep(i, n) cout << s[i];
	cout << End;
	
	return 0;
}


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

int main(){
  string S;
  string ans;
  cin >> S;

  if (S == "Sunny"){
    ans = "Cloudy";
  } else if (S == "Cloudy") {
    ans = "Rainy";
  } else {
    ans = "Sunny";
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
static const int INF = 1ll<<60;
typedef pair<int,int> P1;
typedef pair<int,pair<int,int> > P2;

string s;
int ans = INF;
vector<int> v[26];

signed main(){
    cin>>s;
    for(int i=0;i<s.size();++i)v[s[i]-'a'].PB(i + 1);
    for(int i = 0;i<26;++i){
        if(v[i].size()){
            int res = 0;
            for(int j=0;j<v[i].size();++j){
                int length;
                if(j == 0)length = v[i][j] - 1;
                else length = v[i][j] - v[i][j-1] - 1;
                res = max(res,length);
            }
            res = max(res,(int)s.size() - v[i][v[i].size() - 1]);
            ans = min(ans,res);
        }
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass
{
    static void Main()
    {
        var NK = ReadLine().Split().Select(int.Parse).ToArray();
        int N = NK[0];
        int K = NK[1];
        var D = ReadLine().Split().Select(int.Parse).ToArray();

        int num = N;
        while (true)
        {
            if (c(num, D))
            {
                break;
            }
            num++;
        }
        WriteLine(num);
    }
    static bool c(int num,int[] K)
    {
        while (num>0)
        {
            if (K.Contains(num % 10)) return false;
            num /= 10;
        }
        return true;
    }
}


Measured memory_bytes: 28200
#pragma GCC optimize(2)
#include <bits/stdc++.h>
const int maxn=3e5+100;
const int mod=1e9+7;
typedef long long ll;
using namespace std;


int main()
{
    string s;
    cin>>s;
    int sum=0;
    for(int i=0;i<s.size()/2;i++){
        if(s[i]!=s[s.size()-i-1])
            sum++;
    }
    cout<<sum<<endl;
}
/*
17
AAAAABBBCCBBBBCCC
100 1 10
*/


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
# input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return map(int,input().split())
def LI(): return list(map(int,input().split()))

def main():
    N = INT()
    L = LI()
    L.sort()
    answer = 0
    for i in range(N):
        answer += min(L[2*i],L[2*i+1])

    print(answer)
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
using namespace std;

int main(){
	int n;
	while(cin>>n){
		int a=0;
		for(int i=0;i<=9;i++){
			for(int j=0;j<=9;j++){
				for(int k=0;k<=9;k++){
					for(int l=0;l<=9;l++){
						if(i+j+k+l==n) a+=1;
					}
				}
			}
		}
		cout<<a<<endl;
	}
	return 0;
}

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

int a[200006],n,s;

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;++i) {scanf("%d",a+i);s^=a[i];}
    for(int i=1;i<=n;++i) printf("%d ",s^a[i]);
}

Measured memory_bytes: 4596
main = do
  x <- getLine
  ps <- map read . words <$> getLine
  putStrLn . show $ solve ps

solve :: [Integer] -> Integer
solve ps =
  let mi = minimum ps
      calced = filter (/= 0) . map (\x -> x `mod` mi) $ ps
  in if null calced then mi else solve (mi:calced)


Measured memory_bytes: 36220
#include <iostream>
#include <vector>
#include <algorithm>
#include <memory>
#include <string>

template <class T>
using sp = std::shared_ptr<T>;

struct Node
{
    explicit Node(int key)
        : key {key}
    {}

    int key;
    sp<Node> paprent    {nullptr};
    sp<Node> left       {nullptr};
    sp<Node> right      {nullptr};
};

class BinarySearchTree
{
public:

    void insert(int key)
    {
        auto z = std::make_shared<Node>(key);
        //xの親を保持
        sp<Node> y {nullptr};
        auto x {root};

        while (x != nullptr)
        {
            //親を保持
            y = x;
            if (key < x->key)
                x = x->left;
            else
                x = x->right;
        }
        z->paprent = y;

        if (y == nullptr)           root = z;
        else if (z->key < y->key)   y->left = z;
        else                        y->right = z;
    }

    void printInorder()
    {
        printInorder(root);
    }

    void printPreorder()
    {
        printPreorder(root);
    }

private:

    sp<Node> root {nullptr};

    void printInorder(sp<Node> c)
    {
        if (c == nullptr)
            return;
        
        printInorder(c->left);
        std::cout << " " << c->key;
        printInorder(c->right);
    }

    void printPreorder(sp<Node> c)
    {
        if (c == nullptr)
            return;

        std::cout << " " << c->key;
        printPreorder(c->left);
        printPreorder(c->right);
    }
};

void solve();

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

void solve()
{
    using namespace std;
    
    int n;
    cin >> n;
    BinarySearchTree tree;

    for (int i = 0; i < n; ++i)
    {
        string s;
        cin >> s;


        if (s == "insert")
        {
            int key;
            cin >> key;
            tree.insert(key);
        }
        else
        {
            tree.printInorder();
            cout << endl;
            tree.printPreorder();
            cout << endl;
        }
    }


}


Measured memory_bytes: 42228
#include <iostream>
#include <algorithm>
using namespace std;

int main() {
	int n;
	string s;
	int count[300010];
	int ans = 500000, hoge;
	cin >> n >> s;
	for (int i = 0; i < 300010; i++)count[i] = 0;
	if (s[0] == 'W')count[1]++;
	for (int i = 1; i < n; i++) {
		if (s[i] == 'W')count[i+1] = count[i] + 1;
		else count[i + 1] = count[i];
	}
	for (int i = 1; i <= n; i++) {
		hoge = 0;
		hoge = count[i - 1] - count[0];
		hoge += (n - i) - (count[n] - count[i]);
		if (ans > hoge)ans = hoge;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1796
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) obj.begin(),obj.end()
#define pb(obj) push_back(obj)
#define REP(i,N) for(ll i=0;i<N;i++)
const int MOD = 1000000007;
typedef long long ll;
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
   fac[0] = fac[1] = 1;
   finv[0] = finv[1] = 1;
   inv[1] = 1;
   for (int i = 2; i < MAX; i++){
       fac[i] = fac[i - 1] * i % MOD;
       inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
       finv[i] = finv[i - 1] * inv[i] % MOD;
   }
}
// 二項係数計算
long long COM(int n, int k){
   if (n < k) return 0;
   if (n < 0 || k < 0) return 0;
   return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int num_of_amida(int n){//n本の間でのあみだの数
    int a=0;
    if(n<0)return 0;
    for(int i=0;n-i>=i;i++){
        a+=COM(n-i,i);
    }
    return a;
}
ll DP[101][9];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    COMinit();
    int H,W,K;
    cin>>H>>W>>K;
    DP[0][1]=1;
    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
            if(j==1){
                DP[i][1]+=num_of_amida(W-1)*DP[i-1][1]%MOD;
                DP[i][1]+=num_of_amida(W-2)*DP[i-1][2]%MOD;
            }
            else if(j==W){
                DP[i][W]+=num_of_amida(W-1)*DP[i-1][W]%MOD;
                DP[i][W]+=num_of_amida(W-2)*DP[i-1][W-1]%MOD;
            }
            else{
                DP[i][j]+=(num_of_amida(j-1)*num_of_amida(W-j))*DP[i-1][j]%MOD;
                DP[i][j]+=(num_of_amida(j-2)*num_of_amida(W-j))*DP[i-1][j-1]%MOD;
                DP[i][j]+=(num_of_amida(j-1)*num_of_amida(W-j-1))*DP[i-1][j+1]%MOD;
            }
            DP[i][j]%=MOD;
        }
    }
    cout<<DP[H][K]<<endl;
}

Measured memory_bytes: 12160
#include <iostream>
using namespace std;
int main(){
  int N;
  int A[110];
  cin >> N;
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  int MAX = A[0];
  int MIN = A[0];
  for (int i = 0; i < N; i++){
    if (MAX < A[i]) MAX = A[i];
	if (MIN > A[i]) MIN = A[i];
  }
  cout << MAX - MIN << endl;
}


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

namespace ConsoleApp1
{
    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }

    class Program
    {
        static void Main(string[] args) => B();

        static void B()
        {
            Func<int, int> func = (N) =>
            {
                for (int i = N; i > 0; i--)
                {
                    if (i >= 64)
                        return 64;
                    if (i >= 32)
                        return 32;
                    if (i >= 16)
                        return 16;
                    if (i >= 8)
                        return 8;
                    if (i >= 4)
                        return 4;
                    if (i >= 2)
                        return 2;
                    if (i >= 1)
                        return 1;
                }
                return 0;
            };
            Console.WriteLine(func(ReadInt()));
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int DigitsSum(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static IList<string> ReadSplit() => Read().Split().ToList();
        static IList<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
    }
}

Measured memory_bytes: 11092
import sys
import math
import bisect


def main():
    A = list(map(int, input().split()))
    A.sort()
    if A[0] == A[1] and A[1] != A[2]:
        print('Yes')
    elif A[0] != A[1] and A[1] == A[2]:
        print('Yes')
    else:
        print('No')

if __name__ == "__main__":
    main()


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

//.define
// #define FILE_IN_OUT
#define RET(_x)    return cout << (_x) << '\n', 0;
#define all(_obj)  (_obj).begin(), (_obj).end()
#define loop(_n)   for (int i = 0; i < (_n); ++i)
#define sz(_obj)   static_cast<int>((_obj).size())
#ifdef SHJ_LOCAL
#define debug(_x)  std::cerr << (#_x) << " = " << (_x) << '\n' << std::flush;
#else
#define debug(_x)  {}
#endif
#define endl "\n"
template<typename P, typename Q>
P CeilDiv(P _dividend, Q _divider) {
    return static_cast<P>((_dividend - 1LL + _divider) / _divider);
}
template<typename Tp>
inline void outarr(Tp _begin, Tp _end, const char* _delim = " ") {
    for (Tp current = _begin; current != _end; ++current) {
        std::cout << *current << _delim;
    }
    std::cout << '\n';
}

//.constant
using ll  = long long;
using pii = std::pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr int MOD = static_cast<const int>(1e9 + 7);

//.data

//.code
int main() {
#ifdef FILE_IN_OUT
    std::ifstream cin ("input.txt",  std::ios::in);
    std::ofstream cout("output.txt", std::ios::out);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif

    string s;
    cin >> s;
    ll sum = 0;
    for (char c : s) {
        sum += c - '0';
    }
    cout << (sum % 9 == 0 ? "Yes" : "No") << endl;

#ifdef FILE_IN_OUT
    cin.close();
    cout.close();
#endif
    return 0;
}

Measured memory_bytes: 3740
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)

	A, B, C, D := getInt(), getInt(), getInt(), getInt()

	ans := A * B
	if C*D > ans {
		ans = C * D
	}
	out(ans)
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

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

char c;
double x1,Y1,x2,y2,xq,yq;

int main(){
	while(cin>>x1>>c>>Y1>>c>>x2>>c>>y2>>c>>xq>>c>>yq){
		double dx=x2-x1,dy=y2-Y1,vx=xq-x1,vy=yq-Y1,n=sqrt(dx*dx+dy*dy),d=(dx*vy-dy*vx)/n;
		printf("%.5f %.5f\n",xq+dy*2*d/n,yq-dx*2*d/n);
	}
}

Measured memory_bytes: 0
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::setprecision(20) << std::fixed;

  int N;
  cin >> N;

  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  int now_max = A[0];
  long long ans = 0;
  for (int i = 1; i < N; i++) {
    if (A[i] > now_max) {
      now_max = A[i];
    } else {
      ans += now_max - A[i];
    }
  }
  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 3968
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int a = parseInt(sc.next());
		int b = parseInt(sc.next());
		sc.close();
		out.println(a<10&&b<10?a*b:-1);
	}
}


Measured memory_bytes: 23252
li_a = input().split()

li_b = input().split()

li_a = [int(i) for i in li_a]
i = 0
li_b = [int(i) for i in li_b]

i = li_a[1]
for j in range(i):
    li_a[0] -= li_b[j]

if li_a[0] <= 0:
    print("Yes")
else:
    print("No")

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

int main() {

  int N;
  cin >> N;
  int S = 0;
  int M = 0;
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    S += x;
    if (x > M) {
      M = x;
    }
  }
  cout << S - M / 2 << endl;

}


Measured memory_bytes: 256
#create date: 2020-07-04 09:52

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    n = ni()
    keta = len(str(n))
    if keta == 1:
        print(n)
    elif keta == 2:
        print(9)
    elif keta == 3:
        print(9 + (n - 99))
    elif keta == 4:
        print(9 + (999 - 99))
    elif keta == 5:
        print(9 + (999 - 99)  + n - 9999)
    else:
        print(9 + (999 - 99) + (99999 - 9999))

if __name__ == "__main__":
    main()

Measured memory_bytes: 9208
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;

signed main(){
    int n, W;
    cin >> n >> W;
    vector<int> w(n), v(n);
    rep(i, 0, n){
        cin >> w[i] >> v[i];
    }
    vector<P> dp;
    dp. push_back(P(0, 0));
    set<int> st;
    st.insert(0);
    // map<int, int> dp;
    rep(i, 0, n){
        for(int j = dp.size() - 1; j >= 0; j--){
            int prew = dp[j].first;
            int neww = prew + w[i];
            if(neww > W) continue;
            if(!st.count(prew)) continue;
            if(!st.count(neww)){
                dp. push_back(P(neww, dp[j].second + v[i]));
                st.insert(neww);
            }else{
                int id = 0;
                rep(k, 0, dp.size()) if(dp[k].first == neww) id = k;
                dp[id].second = max(dp[id].second, dp[j].second + v[i]);                
            }
        }
        sort(all(dp));
    }
    int ans = 0;
    rep(i, 0, dp.size()) ans = max(ans, dp[i].second);
    cout << ans << endl;
}

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

int N;
vector<int> par;
void init(int m)
{
    N = m;
    par.resize(N);
    for (int i = 0; i < N; ++i) par[i] = i;
}
int find(int x) {
    return (par[x] == x) ? x : (par[x] = find(par[x]));
}
int isunion(int x, int y) {
    return find(x) == find(y);
}
int tounion(int x, int y)
{
    int p = find(x), q = find(y);
    if (p == q) return 0;
    par[q] = p;
    return 1;
}

int main() {
    int n, m, q;
    cin >> n >> m;
    init(n);
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        tounion(a, b);
    }
    cin >> q;
    for (int i = 0; i < q; ++i) {
        int a, b;
        cin >> a >> b;
        cout << (isunion(a, b) ? "yes\n" : "no\n");
    }
    return 0;
}

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

using namespace std;

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

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

int main() {
    int cnt[2] = {};
    int N;
    cin >> N;
    string s;
    cin >> s;
    stack<char> st;
    rep(i, N) {
        if (s[i] == ')') {
            if (st.size()) st.pop();
            else {
                cnt[0]++;
            }
        }
        else {
            st.push(s[i]);
        }
    }
    rep(i, cnt[0]) cout << "(";
    cout << s;
    rep(i, st.size()) cout << ")";
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::Read;
#[allow(dead_code)]
fn getline() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok().unwrap();
    ret
}
fn get_word() -> String {
    let mut stdin = std::io::stdin();
    let mut u8b: [u8; 1] = [0];
    loop {
        let mut buf: Vec<u8> = Vec::with_capacity(16);
        loop {
            let res = stdin.read(&mut u8b);
            if res.unwrap_or(0) == 0 || u8b[0] <= b' ' {
                break;
            } else {
                buf.push(u8b[0]);
            }
        }
        if buf.len() >= 1 {
            let ret = String::from_utf8(buf).unwrap();
            return ret;
        }
    }
}

#[allow(dead_code)]
fn get<T: std::str::FromStr>() -> T { get_word().parse().ok().unwrap() }

const MOD: i64 = 1_000_000_007;

// This solution was written after the author read the editorial.
fn solve() {
    let n: usize = get();
    let m: usize = get();
    let mut dp = vec![vec![vec![0i64; 2]; n + 1]; 2]; // [?-th step][#red][touched]
    for i in 0 .. n + 1 {
        dp[0][i][if i == 0 { 1 } else { 0 }] = 1;
    }
    for i in 0 .. m {
        let t = i % 2;
        for j in 0 .. n + 1 {
            for b in 0 .. 2 {
                dp[1 - t][j][b] = 0;
            }
        }
        for j in 0 .. n + 1 {
            for b in 0 .. 2 {
                if j > 0 {
                    let nb = b | if j == 1 { 1 } else { 0 };
                    dp[1 - t][j][nb] += dp[t][j - 1][b];
                    dp[1 - t][j][nb] += dp[t][j][b];
                    dp[1 - t][j][nb] %= MOD;
                }
                if j < n {
                    let mut tot = 0;
                    tot += dp[t][j + 1][b];
                    tot += dp[t][j][b];
                    dp[1 - t][j][b | if j == 0 { 1 } else { 0 }] += tot;
                    dp[1 - t][j][b | if j == 0 { 1 } else { 0 }] %= MOD;
                }
            }
        }
    }
    let mut tot = 0;
    for i in 0 .. n + 1 {
        tot += dp[m % 2][i][1];
        tot %= MOD;
    }
    println!("{}", tot);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
import Data.Char
import Data.List
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import Control.Monad
import qualified Data.IntSet as S

main = do
    ss <- zipWith (\i c -> (ord c - ord 'a', i)) [1..] <$> getLine
    ts <- map (\c -> ord c - ord 'a') <$> getLine
    let n = length ss
    let abc = V.create $ do
            vec <- VM.replicate 26 S.empty
            forM_ ss $ \(c,i) -> do
                VM.modify vec (S.insert i) c
            forM_ [0..25] $ \c -> do
                s <- VM.read vec c
                when (not (S.null s)) $ do
                    let m = S.findMin s
                    VM.modify vec (S.insert (m+n)) c
            return vec
    
    let f Nothing _ = Nothing
        f (Just (k,i)) c = (\j -> if j >= n then (k+1,j-n) else (k,j)) <$> S.lookupGT i (abc V.! c)
    
    let ans = case (foldl' f (Just (0,-1)) ts) of
               Just (k,i) -> n*k + i
               _ -> -1
    
    print ans

Measured memory_bytes: 44904
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;
using pll = pair<long long, long long>;
const long long INF = 1<<29;

const int MOD = 1000000007;
long long ruizyou(long long m,long long n){
  if(m == 0)return 0;
  if(m == 1)return 1;
  long long ans = 1;
  long long tmp = m;
  for(int i=0;i<=30;i++){
    if(n & (1<<i)){
      ans *= tmp;
      ans %= MOD;
    }
    tmp *= tmp;
    tmp %= MOD;
  }
  return ans;
}
long long kaizyou(long long x){
  if(x == 0)return 1;
  return x * kaizyou(x-1) % MOD;
}
long long comb(long long x,long long y){
  long long bunsi = kaizyou(x);
  long long bunbo = kaizyou(x-y) * kaizyou(y) % MOD;
  return bunsi * ruizyou((int)bunbo,MOD-2) % MOD;
}
struct unionfind{
  vector<int> par;
  vector<int> hukasa;
  unionfind(int n){
    par = vector<int>(n);
    hukasa = vector<int>(n,0);
    for(int i=0;i<n;i++){
      par.at(i) = i;
    }
  }
  int root(int x){
    if(par.at(x) == x)return x;
    return root(par.at(x));
  }
  void unite(int x,int y){
    int rx = root(x);
    int ry = root(y);
    if(rx == ry)return;
    if(hukasa.at(rx) >= hukasa.at(ry)){
      par.at(ry) = rx;
      hukasa.at(rx) = max(hukasa.at(ry) + 1,hukasa.at(rx));
    }
    else{
      par.at(rx) = ry;
    }
  }
  bool same(int x,int y){
    return root(x) == root(y);
  }
};
int ctoi(char a){
  return a - '0';
}
long long gcd(long long a,long long b){
  long long c = max(a,b);
  long long d = min(a,b);
  if(d % c == 0)return c;
  return gcd(c,d%c);
}
long long lcm(long long a,long long b){
  return a * b / gcd(a,b);
}
int main(){
  int n;
  cin >> n;
  vector<string> s(n);
  for(int i=0;i<n;i++)cin >> s.at(i);
  int c0 = 0,c1 = 0,c2 = 0,c3 = 0;
  for(int i=0;i<n;i++){
    if(s.at(i) == "AC")c0++;
    else if(s.at(i) == "WA")c1++;
    else if(s.at(i) == "TLE")c2++;
    else c3++;
  }
  cout << "AC x " << c0 << endl;
  cout << "WA x " << c1 << endl;
  cout << "TLE x " << c2 << endl;
  cout << "RE x " << c3 << endl;
  
}

Measured memory_bytes: 6436
import sys

N = int(input())
aAB = [[int(_) for _ in sLine.split()] for sLine in sys.stdin.readlines()]
aAB = sorted([a+b,a,b] for a,b in aAB)[::-1]
iA = 0
iB = 0
for i in range(N):
    if i % 2:
        iB+=aAB[i][2]
    else:
        iA+=aAB[i][1]
print(iA-iB)


Measured memory_bytes: 36060
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll a,b,c,i,j,k,l,m,n,ans,tmp,hoge,fuga,piyo;
ll x[10010],y[10010];
string s,str;
char ch;
int main(){
  cin>>a>>b;

  ans=(a*b+1)/2;
  if(a==1||b==1){
    ans=1;
  }
  cout<<ans;
  return 0;
}

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

const int MOD = 1e9 + 7;

using namespace std;

int main(){
  int N;
  cin >> N;
  
  vector<long long> A(N);
  long long sum_A = 0;
  long long prod = 0;
  for(int i = 0; i < N; i++){
    cin >> A[i];
    
    sum_A += A[i];
    sum_A %= MOD;
    
    prod -= A[i] * A[i] % MOD;
    prod %= MOD;
  }
  
  prod += ((sum_A * sum_A % MOD - prod) * 500000004) % MOD;
  
  cout << (prod + MOD) % MOD << endl;
  
  return 0;
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

constexpr int MOD = 1e9+7;

vector<string> G;
int H, W;
int h[303][303];

int calc_cost(int a, int b, int C) {
  int& ret = h[a][b];
  if(ret + 1) return ret;
  if(a == 0 || b == 0) return 0;
  ret = calc_cost(a-1, b-1, C);
  ret += (G[a-1][C] == G[b-1][C+1]);
  return ret;
}

int main() {

  cin >> H >> W;
  G.resize(H);
  rep(i, H) cin >> G[i];

  ll ans = 0;

  rep(C, W - 1) {
    static int dp[303][303];
    rep(i, 303) rep(j, 303) h[i][j] = -1, dp[i][j] = inf;
    dp[0][0] = 0;
    rep(i, H + 1) rep(j, H + 1) {
      dp[i+1][j] = min(dp[i+1][j], dp[i][j] + calc_cost(H - i, H - j, C));
      dp[i][j+1] = min(dp[i][j+1], dp[i][j] + calc_cost(H - i, H - j, C));
    }
    ans += dp[H][H];
    ans %= MOD;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <cmath>
#include <math.h>
#include <iomanip>
using namespace std;



int main()
{
    int n;
    cin >> n;
    n--;
    int num = 0;
    if(n==1){
        cout << 2;
    }else{
    while(num==0){
        
        n=n+1;
        for(int i=2;i<n;i++){
            num=n%i;
            if(num==0){
                break;
            }
        }
    }

    cout << n;

    }

    

}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
       Scanner sc = new Scanner(System.in);
       int a = sc.nextInt();
       int b = sc.nextInt();
       int c = sc.nextInt();
       if(a == 7 && b == 5 && c == 5){
           System.out.println("YES");
       }else if(a == 5 && b == 7 && c == 5){
           System.out.println("YES");
       }else if(a == 5 && b == 5 && c == 7){
           System.out.println("YES");
       }else{
           System.out.println("NO");
       }
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, s, n) for (int i = (s); i < (int)(n); i++)
#define INF 100000000

using namespace std;

int main() {
   string s,t;
   cin >> s >> t;
   sort(s.begin(),s.end());
   sort(t.begin(),t.end(),greater<char>());
   cout <<( s<t ? "Yes" : "No" )<< endl;
}

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

#define fi first
#define se second
#define mp make_pair

int main(){
	cin.tie(NULL);

	int n,a,hitung= 0, i;
	cin >> n;
	for (i = 1; i <= n; i++){
		cin >> a;
		if (a % 2 == 1)
			hitung++;
	}	
	if (hitung % 2 == 0){
		cout << "YES" << endl;
	}else
		cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

void run(void){
  int n,k;
  scanf("%d%d",&n,&k);
  int a[100];
  int i;
  for(i=0;i<n;i++) scanf("%d",a+i);
  char *dp=(char *)calloc(k+1,sizeof(char));
  for(i=1;i<=k;i++){
    char win=0;
    for(int j=0;j<n && a[j]<=i;j++){
      if(dp[i-a[j]]==0){
	win=1;
      }
    }
    dp[i]=win;
  }
  printf("%s\n",dp[k]?"First":"Second");
}

int main(void){
  run();
  return 0;
}

Measured memory_bytes: 256
fn main() {
    proconio::input! {
        n: usize,
        mut a: i32,
        mut b: i32,
        mut c: i32,
        s: [String;n],
    }
    let mut r = String::with_capacity(n);
    for i in 0..n {
        let p=f(&s[i]);
        let v1=if (p&1)==1 {a} else {b};
        let v2=if (p&4)==4 {c} else {b};
        if v1+v2==0 {
            println!("No");
            return;
        }
        let w=if v1==0 {
            1
        }
        else if v2==0 {
            2
        }
        else if v1==1 && v2==1 {
            if i+1<n {
                let q=f(&s[i+1]);
                if (p&1)==1 {
                    if (q&1)==1 {
                        1
                    }
                    else{
                        2
                    }
                }
                else {
                    if (q&2)==2 {
                        1
                    }
                    else {
                        2
                    }
                }
            }
            else {
                1
            }
        }
        else if v1<v2 {
            1
        }
        else {
            2
        };
        if w==1 {
            if (p&1)==1 {a+=1;} else {b+=1;};
            if (p&4)==4 {c-=1;} else {b-=1;};
            r.push(if (p&1)==1 {'A'} else {'B'});
        }
        else {
            if (p&1)==1 {a-=1;} else {b-=1;};
            if (p&4)==4 {c+=1;} else {b+=1;};
            r.push(if (p&4)==4 {'C'} else {'B'});
        }
    }
    println!("Yes");
    for c in r.chars() {
        println!("{}",c);
    }
}
fn f(s: &String) -> usize {
    let s=s.as_bytes();
    if s[0]==b'A' {
        if s[1]==b'B' {
            3
        }
        else {
            5
        }
    }
    else {
        6
    }
}

Measured memory_bytes: 7820
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long a,b,c,k;
    cin >> a >> b >> c >> k;
    if(k%2==0){
        cout << a-b << endl;
    }else{
        cout << b-a << endl;
    }
    return 0; 
}

Measured memory_bytes: 3596
N = int(input())
name_dict = {}
for i in range(N):
  n, c = input().split()
  c = int(c)
  if n not in name_dict:
    name_dict[n] = [[c, i+1]]
  else:
    name_dict[n].extend([[c, i+1]])

name_dict = sorted(name_dict.items())
for i, value in name_dict:
  value = sorted(value, reverse=True)
  for j in value:
    print(j[1])

Measured memory_bytes: 3064
#include<stdio.h>
int main(){
    int h,n;
    int a[100000];
    int sum=0;
    scanf("%d %d",&h,&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(int i=0;i<n;i++){
        sum=sum+a[i];
    }
    if(h<=sum){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;

const int MAXN = 500000 + 1000;

int n, s[MAXN];
int cnt;

void mul(int x)
{
	for(int i = 0; i <= n - 1; i++)
		s[i] *= x;
	for(int i = 0; i <= n - 1; i++)
		s[i + 1] += s[i] / 10, s[i] %= 10;
	while(s[n])
		s[n + 1] += s[n] / 10, s[n] %= 10, n++;
	cnt = 0;
	for(int i = 0; i <= n - 1; i++)
		cnt += s[i];
}

void add(int x)
{
	cnt -= s[0], s[0] += x, cnt += s[0];
	for(int i = 0; i <= n - 1 && s[i] >= 10; i++)
	{
		cnt -= s[i] + s[i + 1];
		s[i + 1] += s[i] / 10, s[i] %= 10;
		cnt += s[i] + s[i + 1];
	}
	while(s[n])
	{
		cnt -= s[n] + s[n + 1];
		s[n + 1] += s[n] / 10, s[n] %= 10;
		cnt += s[n] + s[n + 1];
		n++;
	}
}

void print()
{
	for(int i = n - 1; i >= 0; i--)
		cerr << s[i];
	cerr << endl;
	cerr << cnt << endl;
}

int main()
{
	ios::sync_with_stdio(false);
	// freopen("1.in", "r", stdin);
	// freopen("1.out", "w", stdout);

	static char ss[MAXN];

	cin >> ss;
	n = strlen(ss);
	for(int i = 0; i <= n - 1; i++)
		s[i] = ss[n - 1 - i] - '0';

	mul(9);
	// print();

	int ans = 0;
	while(9 * ans < cnt)
	{
		add(9);
		ans += 1;
		// print();
	}
	cout << ans << endl;

	return 0;
}


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

int main(){
    ll X,Y;
    cin >> X >> Y;
    bool flag = false;
    for(int i = 0; i <= X; i++){
        if(i * 2 + (X - i) * 4 == Y){
            flag = true;
        }
    }
    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n, m; cin >> n >> m;
	vi s(m), c(m);
	rep(i, m) cin >> s[i] >> c[i];
	
	for(int i = 0; i <= 999; i++){
		vi d;
		for(int j = i; j; j /= 10) d.pb(j % 10);
		if(!d.size()) d.pb(0);
		
		if(d.size() != n) continue;
		
		bool ok = 1;
		rep(i, m) if(d[n - s[i]] != c[i]) ok = 0;
		if(ok){
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
int n;
int arr[10];
int brr[10];
int main(){
    cin>>n;
    for (int x=0;x<n;x++) cin>>arr[x];
    for (int x=0;x<n;x++) cin>>brr[x];
    
    vector<int> v;
    for (int x=0;x<n;x++) v.push_back(x+1);
    
    int index=0;
    int A,B;
    do{
        
        for (int x=0;x<n;x++){
            if (arr[x]!=v[x]) goto pass1;
        }
        A=index;
        pass1:;
        
        for (int x=0;x<n;x++){
            if (brr[x]!=v[x]) goto pass2;
        }
        B=index;
        pass2:;
        
        index++;
    }while (next_permutation(v.begin(),v.end()));
    cout<<abs(A-B);
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	N := nextInt()
	W := nextInts(N)
	m := 100001
	right := 0
	left := 0
	for _, w := range W {
		right += w
	}
	for _, w := range W {
		right -= w
		left += w
		d := right - left
		if Abs(d) < m {
			m = Abs(d)
			continue
		}
		break
	}
	fmt.Println(m)
}

func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}

func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}

func nextString() string {
	return nextReader()
}

func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

func nextInt64s(n int) []int64 {
	r := make([]int64, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt64()
	}
	return r
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}

func Min(a int, b int) int {
	if a > b {
		return b
	}
	return a
}

func Max(a int, b int) int {
	if a > b {
		return a
	}
	return b
}

func MinA(arg ...int) int {
	var s = arg[0]
	for _, v := range arg {
		s = Min(s, v)
	}
	return s
}

func MaxA(arg ...int) int {
	var s = arg[0]
	for _, v := range arg {
		s = Max(s, v)
	}
	return s
}

func Abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v)) os<<*i<<(i==end(v)-1?"":" "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
    is>>p.first>>p.second; return is; }
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;}
template <class T> using heap = priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N;
    cin>>N;
    vector<int> A(N);
    cin>>A;
    int ans=INF;
    REP(i,N) {
        int cnt=0;
        while(A[i]%2==0) {
            A[i]/=2;
            cnt++;
        }
        chmin(ans,cnt);
    }
    cout<<ans<<endl;
    return 0;
}


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

int main()
{
    int n, m;
    cin >> n >> m;
    vector<P> p(m);
    rep(i, m) cin >> p[i].first >> p[i].second;
    rep(x, 1000) {
        string s = to_string(x);
        vector<int> d;
        rep(i, s.size()) d.push_back(s[i]-'0');
        if (d.size() != n) continue;
        bool ok = true;
        rep(i, m) {
            if (d[p[i].first - 1] != p[i].second) ok = false;
        }
        if (ok) {
            cout << x << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3644