akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))

int main(){
	ll h,w,n;
	cin >> h >> w >> n;
	cout << (ll)(n+max(h,w)-1)/(max(h,w)) << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
typedef pair<int,P>P2;
#define fi first
#define se second

string s;
int n,q,x;

int sol(){
  int sum=0,l=0,r=x-1,b=0,c=0,ans=0;
  r(i,x){
    if(s[i]=='M')b++;
    if(s[i]=='C')c++,ans+=b;
  }
  while(r!=s.size()){
    if(s[l]=='D')sum+=ans;

    if(s[l]=='M')ans-=c,b--;
    if(s[l]=='C')c--;

    if(s[r+1]=='M')b++;
    if(s[r+1]=='C')c++,ans+=b;

    l++;r++;
  }
  return sum;
}

signed main(){
  cin>>n>>s>>q;
  r(i,n+1)s+='@';
  while(q--){
    cin>>x;
    cout<<sol()<<endl;
  }
}

Measured memory_bytes: 2436
# -*- coding: utf-8 -*-

def input_int():
    return int(input())


def answer():
    n = input_int()

    count = 0
    for a in range(1, n):
        b = (n - 1) // a
        if b >= a:
            count += (b - a) * 2
            count += 1
        else:
            continue
    print(count)


answer()

Measured memory_bytes: 9100
def main():
    N = int(input())
    jobs = []
    for i in range(N):
        job = list(map(int, input().split()))
        jobs.append(job)
    jobs.sort(key=lambda x: x[1])

    total = 0
    for job in jobs:
        total += job[0]
        if total > job[1]:
            ans = "No"
            break
    else:
        ans = "Yes"
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 53608
#include <stdio.h>
#define LENGTH 100000
int main (void)
{
    int N;
    long H[LENGTH];
    long rMove[LENGTH];
    long maxMove = 0;
    scanf("%d", &N);
    int i;
    for (i = 0; i < N; i++) {
        scanf("%d", &H[i]);
    }

    if (N == 1) {
        printf("%d", maxMove);
        return 0;
    }

    rMove[N-1] = 0;
    for (i = N - 1; i > 0; i--) {
        //printf("H[i-1]=%d,H[i]=%d\n", H[i-1],H[i]);
        if (H[i - 1] >= H[i]) {
            rMove[i - 1] = rMove[i] + 1;
            if (rMove[i - 1] > maxMove) maxMove = rMove[i - 1];
        } else {
            rMove[i - 1] = 0;
        }
    }

    printf("%d", maxMove);

    return 0;
}

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

using namespace std;

int n,k;
const int N=1e5+5;
const int INF=2e9;
int mem[N];
int h[N];

int frog(int i)
{
    if (i==n-1)
        return 0;
    if (mem[i]!= -1)
        return mem[i];

    int ans=INF;

    for (int j=1;j<=k;j++){
        if (i+j <n)
            ans=min(ans,abs(h[i]-h[i+j]) + frog (i+j));
    }
    mem[i]= ans;
    return mem[i];
}

int main()
{
    scanf("%d %d",&n,&k);
    memset(mem,-1,sizeof mem);

    for (int i=0;i<n;i++)
        scanf("%d",&h[i]);

    printf("%d\n",frog(0));
    return EXIT_SUCCESS;
}


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

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

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

map<pii, ll> ma;

int cnt(int digit, int len) {
    if (ma.count(pii(digit, len))) {
        return ma[pii(digit, len)];
    }

    if (len <= 1) return len;

    long long &ret = ma[pii(digit, len)];
    ret = 0;

    ret += cnt(digit, len-1);
    if (digit+1 <= 9) ret += cnt(digit+1, len-1);
    if (digit-1 >= 0) ret += cnt(digit-1, len-1);
    return ret;
}

string ans = "";

void solve(int len, int K, int digit) {
    if (len == 0) return;
    if (digit-1 >= 0) {
        int t = cnt(digit-1, len);
        // cout << len << " " << digit-1 << " " << K << " " << t << endl;
        if (t >= K) {
            ans += char('0' + digit-1);
            return solve(len-1, K, digit-1);
        }
        K -= t;
    }
    {
        int t = cnt(digit, len);
        // cout << len << " " << digit << " " << K << " " << t << endl;
        if (t >= K) {
            ans += char('0' + digit);
            return solve(len-1, K, digit);
        }
        K -= t;
    }
    if (digit+1 <= 9) {
        int t = cnt(digit+1, len);
        // cout << len << " " << digit+1 << " " << K << " " << t << endl;
        if (t >= K) {
            ans += char('0' + digit+1);
            return solve(len-1, K, digit+1);
        }
        K -= t;
    }
}

int main() {
    int K;
    cin >> K;
    rep(i, 20) {
        rep2(j,1,10) {
            ll t = cnt(j, i);
            if (t >= K) {
                // cout << "main " << i << " " << j << " " << t << " " << K << endl;
                ans = char('0'+j);
                solve(i-1, K, j);
                cout << ans << endl;
                return 0;
            }
            K -= t;
        }
    }
}

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

int r, c;
string str[10], tmp[10];

int color(int x, int y){
     int i, j, k;
     for(i=0; i<r; ++i) tmp[i]=str[i];
     for(i=0; i<r; ++i){
          if(x & (1<<i)){
               for(j=0; j<c; ++j) tmp[i][j]='*';
          }
     }
     for(i=0; i<c; ++i){
          if(y & (1<<i)){
               for(j=0; j<r; ++j) tmp[j][i]='*';
          }
     }
     int cnt=0;
     for(i=0; i<r; ++i){
          for(j=0; j<c; ++j) if(tmp[i][j]=='#') cnt++;
     }
     return cnt;
}

int main(){
     int i, j, k;
     cin >> r >> c >> k;
     for(i=0; i<r; ++i) cin >> str[i];
     int cnt=0;
     for(i=0; i<(1<<r); ++i){
          for(j=0; j<(1<<c); ++j){
               if(color(i, j)==k) cnt++;
          }
     }
     cout << cnt << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(){
	int md4 = 0, md2 = 0, md1 = 0, n, rd;
	scanf("%d", &n);
	for(int i = 0; i < n; ++i){
		scanf("%d", &rd);
		if(rd%4 == 0)
			md4++;
		else if(rd%2 == 0)
			md2++;
		else
			md1++;
	}
	if(md1 <= md4 || (md1 <= md4+1 && md2 == 0)){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	//printf("%d %d %d\n", md1, md2, md4);
	return 0;
}

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

int main(int argc, char const *argv[]){
    int n;
    const int m[6] = {500, 100, 50, 10, 5, 1};

    while (cin>>n, n){
        int ans = 0;
        int ret = 1000 - n;
        for (int i = 0; i < 6; i++){
            int t = ret / m[i];
            ret -= t * m[i];
            ans += t;
        }

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

Measured memory_bytes: 2988
#include <stdio.h>

int 
main(){
	long int N;
	long int p[200200];
	int i;
	scanf("%ld",&N);
	
	for(i=0;i<N;i++){
		scanf("%ld",p+i);
		
	}
	long st = p[0];
	long cnt=0;
	for(i=1;i<N;i++){
		
		if(st>=p[i]){
			st = p[i];
			cnt++;
		}
	}
	cnt++;

	printf("%ld\n",cnt);
		
	
 return 0;
}

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

using namespace std;

typedef vector<int> Vec;

int N, maxi;
vector<string> v;
Vec num,l;
set<Vec> st;

int solve(int k, int idx, int sum, int S, int p){
    if(k == maxi){
        if(p != 0 || st.count(num)) return 0;
        st.insert(num);
        return 1;
    }
    int res = 0;
    if(idx == N-1){
        int val = (int)(v[idx][k]-'A');
        int ns = (sum + p) % 10;
        int np = (sum + p) / 10;
        if(num[val] != -1){
            if(l[idx] > 0 && k == l[idx] && num[val] == 0){
                return 0;
            }
            if(ns == num[val]){
                res = solve(k+1, 0, 0, S, np);
            }
        }else{
            for(int i = 0 ; i < 10 ; i++){
                if(S >> i & 1) continue;
                num[val] = i;
                if(ns == i && !(l[idx] > 0 && k == l[idx] && i == 0)){
                    res += solve(k+1, 0, 0, S|(1<<i), np);
                }
                num[val] = -1;
            }
        }
    }else{
        if(v[idx][k] == '*'){
            res = solve(k, idx+1, sum, S, p);
        }else{
            int val = (int)(v[idx][k]-'A');
            if(num[val] != -1){
                if(l[idx] > 0 && k == l[idx] && num[val] == 0){
                    return 0;
                }
                res += solve(k, idx+1, sum+num[val], S, p);
            }else{
                for(int i = 0 ; i < 10 ; i++){
                    if(S >> i & 1) continue;
                    num[val] = i;
                    if(!(l[idx] > 0 && k == l[idx] && i == 0)){
                        res += solve(k, idx+1, sum+i, S|(1<<i), p);
                    }
                    num[val] = -1;
                }
            }
        }
    }
    return res;
}

int main(){
    while(cin >> N, N){
        v.resize(N); l.resize(N);
        maxi = 0;
        Vec len(N);
        for(int i = 0 ; i < N ; i++){
            cin >> v[i];
            l[i] = len[i] = v[i].size();
            l[i]--;
            maxi = max(maxi, len[i]);
            reverse(v[i].begin(),v[i].end());
        }
        if(len[N-1] < maxi){
            cout << 0 << endl;
            continue;
        }
        for(int i = 0 ; i < N ; i++){
            while(len[i] != maxi){
                v[i] += '*';
                len[i]++;
            }
        }
        num.resize(26, -1); st.clear();
        cout << solve(0, 0, 0, 0, 0) << endl;
    }
    return 0;
}

Measured memory_bytes: 8160
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;

  if(n % 1110 < 10 || n % 1000 % 111 < 10)
    cout << "Yes" << endl;
  else cout << "No" << endl;
  // ここにプログラムを追記
}

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

int recursive(int num) {
  if (num < 10) {
    return num;
  }
  return recursive(num / 10) + (num % 10);
}

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

  int ans = 100000;
  for (int a = 1; a < N; a++) {
    int b = N - a;
    int sum = recursive(a) + recursive(b);
    ans = min(ans, sum);
  }

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

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

using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)
static const ll maxLL = (ll)1 << 62;

int main() {
	ll N; cin >> N;
	ll A[100] = { };
	rep(i, 0, N)cin >> A[i];
	ll maxV = 0;
	rep(i, 0, N) {
		rep(j, 0, N) {
			maxV = max(maxV, abs(A[i] - A[j]));
		}
	}
	cout << maxV << endl;
	return 0;
}

Measured memory_bytes: 256
n=int(input())
f=1
a=list(map(int,input().split()))
for i in range(n):
	if a[i]%2==0:
		if not(a[i]%3==0 or a[i]%5==0):
			f=0
			break
if f:
	print("APPROVED")
else:
	print("DENIED")


Measured memory_bytes: 2940
n,x=map(int, input().split())
a=list(map(int, input().split()))
a.sort()
count=0
i=0
while x>0 and i<n:
    x-=a[i]
    if x>=0:count+=1
    i+=1 
if x!=0 and count==n:count-=1
print(count)

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
 
char s[8005];
 
int a[10000];
int b[10000];
int c[10000];
int d[10000]; 
 
int dp[2][8002][16002];
 
int main(){
 
	int x,y;
 
	scanf("%s",s);
 
	scanf("%d %d",&x,&y);
 
 
	int len=strlen(s);
 
	int i,j;
 
	int dir=0;
	int cnt1=0;
	int cnt2=0;
 
	for(i=0;i<len;i++){
		if(s[i]=='F'&&dir==0){
			a[cnt1]++;
			if(s[0]=='T'){
			d[cnt1]++;
			}
			else{
				if(cnt1!=0){
				d[cnt1]++;
				}
			}
		}
		else if(s[i]=='F'&&dir==1){
			b[cnt2]++;
			c[cnt2]++;
		}
		else{
			if(dir==0){
				cnt1++;
			}
			else{
				cnt2++;
			}
			dir=1-dir;
		}
	}
 
	dp[0][0][a[0]+8000]=1;
 
	for(i=1;i<=cnt1;i++){
		for(j=0;j<16002;j++){
			if (dp[0][i-1][j] == 1){
                dp[0][i][j+a[i]] = 1;
                dp[0][i][j-d[i]] = 1;
            }
		}
	}
 
	dp[1][0][b[0]+8000]=1;
	dp[1][0][-c[0]+8000]=1;
 
	for(i=1;i<=cnt2;i++){
		for(j=0;j<16002;j++){
			if (dp[1][i-1][j] == 1){
                dp[1][i][j+b[i]] = 1;
                dp[1][i][j-c[i]] = 1;
            }
		}
	}
 
	if(dp[0][cnt1][x+8000]==1&&dp[1][cnt2][y+8000]==1){
	printf("Yes\n");
	}
	else{
	printf("No\n");
	}
 
	return 0;
}

Measured memory_bytes: 497920
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
using namespace std;

void Main() {
    // input
    u_int64_t N;
    cin >> N;
    vector<u_int64_t> frinedly(N);
    for (u_int64_t i = 0; i < N; i++) {
        cin >> frinedly[i];
    }



    // translate
    sort(frinedly.begin(), frinedly.end());
    u_int64_t sum = 0;
    u_int64_t j = 0;
    u_int64_t k = 1;
    for (u_int64_t i = 1; i < frinedly.size(); i++) {
        sum += frinedly[N-1-j];
        if (k == 1) {
            k = 0;
            j++;
        } else {
            k++;
        }


    }

    // output
    cout << sum << endl;

}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 4836
#include <cstdlib>
#include <iostream>


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

  int n, k;
  std::cin >> n >> k;
  std::cout << ((n >= k * 2 - 1) ? "YES" : "NO") << std::endl;

  return EXIT_SUCCESS;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
 
int main(){
	ll X;
    cin>>X;
    if(X<1200)cout<<"ABC";
    else cout<<"ARC";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N;
ll a[200010];
int main(){
    cin>>N;
    for(ll i=0;i<N;i++){
        cin>>a[i];
        a[i]-=i;
    }
    sort(a,a+N);
    ll ans=0;
    for(ll i=0;i<N;i++){
        ans += abs(a[i]-a[N/2]);
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<queue>

using namespace std;

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

#ifdef __BORLANDC__
	typedef __int64 ll;
#else
	typedef long long ll;
#endif

const int INF = 1000000000;
const int MOD = 1000000007;
const int N = 222;
const int W = 11111;


int n,r;
vector<int> w;

void init(){
	w.clear();
}

bool input(){
	cin>>n>>r;
	if(!n)return false;
	rep(i,n){
		int a;
		cin>>a;
		w.push_back(a);
	}
	return true;
}

int memcomb[N][N];
int setcomb(){
	rep(i,N)rep(j,N)memcomb[i][j]=0;
	memcomb[0][0]=1;
	reps(i,1,N){
		memcomb[i][0]=1;
		reps(j,1,N){
			memcomb[i][j] = memcomb[i-1][j]+memcomb[i-1][j-1];
			memcomb[i][j] %= MOD;
		}
	}
}
int comb(int a,int b){
	return memcomb[a][b];
}

int revdp[N][W];
void setrevdp(){
	rep(i,N)rep(j,W)revdp[i][j]=0;
	
	vector<int> revw = w;
	reverse(revw.begin(),revw.end());
	
	revdp[0][0]=1;
	reps(i,0,revw.size()){
		rep(j,r+1){
			revdp[i+1][j] += revdp[i][j];
			revdp[i+1][j] %= MOD;
			if(j-revw[i]>=0)revdp[i+1][j] += revdp[i][j-revw[i]];
			revdp[i+1][j] %= MOD;
		}
	}
	
	/*
	reps(i,0,revw.size()+1){
		rep(j,r+1)printf("%2d ",revdp[i][j]);puts("");
	}*/
}

int solve_dp(int num){
	int sum = 0;
	rep(i,num)sum+=w[i];
	
	int pos = w.size()-num-1;
	int ret = 0;
	
	int st = max(0, r-sum-w[num]+1);
	int en = r-sum+1;
	
	//printf("%d %d %d  (%d to %d)\n",pos,num,w[num],st,en);
	reps(i,st,en){
		ret += revdp[pos][i];
		ret %= MOD;
	}
	return ret;
}

int solve(){
	
	w.push_back(INF);
	sort(w.begin(),w.end());
	
	setrevdp();
	
	int sum = 0;
	rep(i,w.size()){
		int a=0;
		rep(j,w.size())if(w[j]==w[i])a++;
		int b=0;
		rep(j,i+1)if(w[j]==w[i])b++;
		
		int res1 = solve_dp(i);
		ll result = res1;
		sum += result%MOD;
		sum %= MOD;
		//printf("%d %d %d\n",res1,comb(a,b),sum);
	}
	
	return sum;
}

int main(){
	setcomb();
	while(init(),input()){
		printf("%d\n",solve());
		break;
	}
}

Measured memory_bytes: 11028
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;

public class Main {
	long H, W;
	long result = 0;

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		H = Long.parseLong(tokens[0]);
		W = Long.parseLong(tokens[1]);
	}

	void calc() {
		long odd = W / 2;
		if (W % 2 != 0) {
			odd += 1;
		}
		long even = W - odd;
		if (H == 1 || W == 1) {
			result = 1;
		} else if (H % 2 == 0) {
			result = H / 2 * W;
		} else {
			result = H / 2 * W + odd;
		}
		System.out.println(result);

	}

	void showResult() {
	}

}

Measured memory_bytes: 21204
#include<bits/stdc++.h>
#define n 500000
#define mem(arr) memset(arr, 0, sizeof(arr))
using namespace std;
typedef long long lli;
typedef double llf;
typedef pair<int, int> P;
void solve();
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int times = 1;
//	cin >> times;
	for(int i=0; i<times; i++)
	{
		solve();
		cout << '\n';
	}
	return 0;
}

int a, b, c, d, e, f, g, h;
int arr[n + 50], arr1[n + 50], arr2[n + 50];

//type here

void solve()
{
	cin >> a >> b;
	set<int> S;
	S.insert(a); S.insert(b);
	for(int i=1; i<=3; i++)
	{
		if(!S.count(i))
		{
			cout << i << '\n';
			return;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
const int maxn = 2 * 1e5 + 5;
long long a[maxn], f[maxn], g[maxn];

long long fun(int i, int n){
    int l = i + 1, r = n;
    int j = (l + r) / 2;
    while(l < r){
        long long k1 = g[j] - g[i-1], k2 = f[j] ^ f[i-1];
        if(k1 != k2) r = j - 1;
        else l = j + 1;
        j = (l + r) / 2;
    }
    long long k1 = g[j] - g[i-1], k2 = f[j] ^ f[i-1];
    if(k1 != k2) j--;
    return j - i;
}

int main(){
    int n; cin >> n;
    for(int i = 1; i <= n; i++){
        scanf("%lld", &a[i]);
        f[i] = f[i-1] ^ a[i];
        g[i] = g[i-1] + a[i];
    }
    long long ans = n;
    for(int i = 1; i <= n; i++){
        ans += fun(i, n);
    }
    printf("%lld\n", ans);
    return 0;
}


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

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

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

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

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

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: String,
    }
    let mut count = 0;
    for c in s.chars() {
        if c == 'x' {
            count += 1;
        }
    }
    if count >= 8 {
        println!("NO");
    } else {
        println!("YES");
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
string s;
int ans;
int main()
{
	cin>>s;
	ans=s.size();
	for(int i=0;i<s.size()-1;i++)
	{
		if(s[i]!=s[i+1])
		{
			ans=min(ans,max(i+1,(int)s.size()-i-1));
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int sg(int a,int k)
{
    int w = a/k, r = a%k;
    int d = r / (w+1);
    return r % (w+1) ? sg(a - (w+1) * (d+1),k) : w;
}
int main()
{
    int n,s=0;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int a,k;
        cin >> a >> k;
        s ^= sg(a,k);
    }
    cout << (s ? "Takahashi" : "Aoki") << endl;
}


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

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

    vector<int> house(n);
    vector<int> dist(n);

    for (int i = 0; i< n;i++){
        cin >> house.at(i);
    }

    for (int i = 0; i < n - 1; i++){
        dist.at(i) = house.at(i + 1) - house.at(i);
    }

    dist.at(n - 1) = k + house.at(0) - house.at(n - 1);

    sort(dist.begin(), dist.end());

    cout << accumulate(dist.begin(), dist.end(), 0) - dist.at(n - 1) << endl;
}


Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <stack>
using namespace std;

void file()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

typedef long long ll;
typedef pair<int, int> pi;
const ll INF64 = 1e18;
const int INF = 1e9 + 7;
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)
#define x first
#define y second
#define pb push_back
#define all(a) (a).begin(), (a).end()

const int N = 1e5 + 10;
int dp[N];


int main()

{
	file();

	int n, k;
	cin >> n >> k;
	vector<int> h(n);
	forn(i, n)
		cin >> h[i];
	fore(i, 1, N)
		dp[i] = INF;
	fore(i, 1, n)
		fore(j, max(0, i - k), i)
			dp[i] = min(dp[i], dp[j] + abs(h[j] - h[i]));
	cout << dp[n - 1] << endl;
}

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

int main(){
  int n,k;
  ll sum=0,work;
  cin >> n >>k;
  priority_queue<ll> a;
  rep(i,n){cin >> work;a.push(work);} 
  while(!a.empty()){
    if(k!=0){
      k--;
    }else{
      sum+=a.top();
    }
    a.pop();
  }
  cout << sum << endl;
}

Measured memory_bytes: 2420
"""AtCoder Beginner Contest 178.

C
"""

import sys


def input() -> str:  # noqa: A001
    """Input."""
    return sys.stdin.readline()[:-1]


def main():
    """Run."""
    mod = 1000000007
    n = int(input())

    ans = 0

    if n <= 1:
        ans = 0
    elif n == 2:
        ans = 2
    else:
        ans = 10**n
        ans -= 9**n
        ans -= 9**n
        ans += 8**n

    print(ans % mod)


main()


Measured memory_bytes: 11128
#include <iostream>

#include <cmath>

using namespace std ;

	int main(){
		
		int N , X, T ;
		
		cin>>N>>X>>T;
		
		double ratio = (double)N/X ;
		
		
		long long l = ceil(ratio)*T;
		
		if(N == 0){
			cout<<0;
		}else{
				
			cout<<l;
		}
		
	}

Measured memory_bytes: 3708
t = list(input())

for i in range(len(t)):
    if t[i] == '?':
        t[i] = 'D'
ans = 0
if t[0] == 'D':
    ans += 1
for i in range(1, len(t)):
    if t[i] == 'D' and t[i-1] == 'P':
        ans += 2
    elif t[i] == 'D':
        ans += 1
print("".join(t))


Measured memory_bytes: 10844
#include <bits/stdc++.h>
#define DIM 200
using namespace std;

int v[DIM];
char sol[DIM];
int n,i;

int ask (int v[]){

    cout<<"? ";
    for (int i=1;i<=n;i++)
        cout<<v[i]<<" ";

    cout<<"\n";

    string ans;
    cin>>ans;
    if (ans == "Red")
        return 1;
    return 0;

}

int main (){

    cin>>n;

    for (i=1;i<=n;i++)
        v[i] = i;
    int val = ask (v);


    int st = 1, dr = n+1;
    while (st + 1 < dr){
        int mid = (st+dr)>>1;

        for (i=mid;i<=mid+n-1;i++)
            v[i-mid+1] = i;

        if (ask(v) == val)
            st = mid;
        else dr = mid;
    }

    if (val){
        sol[st] = 'R';
        sol[st+n] = 'B';
    } else {
        sol[st] = 'B';
        sol[st+n] = 'R';
    }

    /// st+1...st+n-1 nr de R e egal cu nr de B

    for (i=1;i<n;i++)
        v[i] = st+i;

    for (i=1;i<st;i++){

        v[n] = i;
        if (ask(v))
            sol[i] = 'R';
        else sol[i] = 'B';

    }

    for (i=st+n+1;i<=2*n;i++){
        v[n] = i;
        if (ask(v))
            sol[i] = 'R';
        else sol[i] = 'B';
    }

    /// mai trb sa determin partea aia in care R = B
    int k = 0;
    for (i=1;i<st;i++)
        v[++k] = i;
    for (i=st+n+1;i<=2*n;i++)
        v[++k] = i;


    for (i=st+1;i<st+n;i++){
        v[n] = i;
        if (ask(v))
            sol[i] = 'R';
        else sol[i] = 'B';
    }


    cout<<"! ";
    for (i=1;i<=2*n;i++)
        cout<<sol[i];

    cout<<"\n";

    return 0;
}


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

int main() {
  int n;
  cin>>n;
  int a[n];
  for (int i=0; i<n; i++) {
    cin>>a[i];
  }
  long long cnt = a[0] - 1;;
  int p = 2;
  for (int i=1; i<n; i++) {
    if (p > a[i]) {
    } else if (p == a[i]) {
      ++p;
    } else {
      cnt += (a[i] - 1) / p;
    }
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 640
import sys

def resolve():
    readline=sys.stdin.readline

    n=int(readline())
    a,b=map(int, readline().rstrip().split())
    for _ in range(n-1):
        x,y=map(int, readline().rstrip().split())
        start=max(a//x,b//y)
        for z in range(start,start+1000):
            if x*z>=a and y*z>=b:
                a,b=x*z,y*z
                break
    print(a+b)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

Measured memory_bytes: 3064
<?php
list($n, $c, $k) = ints();
for ($i = 0; $i < $n; ++$i) list($t[]) = ints();
sort($t);
$cnt = $nbus = $num = 0;
foreach ($t as $tt) {
    if ($tt <= $nbus && $num < $c) {
        ++$num;
        continue;
    }
    $nbus = $tt + $k;
    $num = 1;
    ++$cnt;
}
echo $cnt;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 21120
#include <bits/stdc++.h>
#define LL long long
#define mp make_pair
#define pb push_back
#define VI vector<int>
#define pii pair<int,int>
using namespace std;
int n, m;
int main(){
	scanf("%d %d", &n, &m);
	printf("%d\n", n*(n-1)/2 + m*(m-1)/2);
	return 0;
}

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

#include <cmath>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(n) begin(n), end(n)
#define IN(a, x, b) (a <= x && x < b)
#define INIT                        \
  std::ios::sync_with_stdio(false); \
  std::cin.tie(0);
template <class T>
inline T CHMAX(T& a, const T b) {
  return a = (a < b) ? b : a;
}
template <class T>
inline T CHMIN(T& a, const T b) {
  return a = (a > b) ? b : a;
}

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);

int main() {
  INIT;
  int a;
  cin >> a;
  cout << a + (a * a) + (a * a * a) << endl;

  return 0;
}

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

typedef long long ll;

int main(){
  int N,Q;
  cin >> N;
  dsu g(N);
  cin >> Q;
  for(int i=0; i<Q; i++){
    int t,u,v;
    cin >> t >> u >> v;
    if(t == 0) g.merge(u,v);
    else cout << g.same(u,v) << endl;
  }
  return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> h(N);
  for (int i = 0; i < N; i++) {
    cin >> h[i];
  }
  sort(h.begin(), h.end());
  int ans = 9999999999;
  for (int i = 0; i <= N - K; i++) {
    ans = min(ans, h[i + K - 1] - h[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
use proconio::input;

fn main() {
    input! {
        n: i32,
    }
    println!("{}", match n % 10 {
        1 => "pon",
        2 => "hon",
        3 => "bon",
        4 => "hon",
        5 => "hon",
        6 => "pon",
        7 => "hon",
        8 => "pon",
        9 => "hon",
        0 => "pon",
        _ => "ng",
    });
}


Measured memory_bytes: 2140
s = input()
t = input()
 
L = len(s)
l = len(t)
Ans = 1000
 
for i in range(L-l+1):
    ans = 0
    for j in range(l):
        if s[i+j] != t[j]:
            ans += 1 
    Ans = min(ans,Ans)
 
print(Ans)

Measured memory_bytes: 9048
#include <stdio.h>

main(void)
{
	int H,W,a,b;
	
	while(1){
		scanf("%d%d",&H,&W);
		
		if(H==0 && W==0) break;
		
		for(a=1;a<=H;a++){
			for(b=1;b<=W;b++){
				if(a==1 || a==H) printf("#");
				
				else if(a!=1 && a!=H){
					if(b==1 || b==W) printf("#");
					else printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}
	

Measured memory_bytes: 572
from collections import deque


n = int(input())
a = deque()

for i in range(n):
        s = input()
        if s == 'deleteFirst':
                a.popleft()
        elif s == 'deleteLast':
                a.pop()
        else:     
            s ,t = s.split()
            if s == 'insert':
                a.appendleft(t)
            elif s == 'delete':
                if t in  a:
                    a.remove(t)
        
print(*a, sep = ' ')


Measured memory_bytes: 69732
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()

struct mint{
    static const long long MOD = 2019;

    long long v;

    mint() : v(0) {}
    mint(long long x){
        x = x % MOD;
        if(x < 0){ x += MOD; }
        v = x;
    }
    mint& operator+=(mint a){
        v += a.v;
        if(v >= MOD){ v -= MOD; }
        return *this;
    }
    mint& operator*=(mint a){
        v *= a.v;
        v %= MOD;
        return *this;
    }
    mint& operator-=(mint a){
        v -= a.v;
        if(v < 0){ v += MOD; }
        return *this;
    }
    mint& operator/=(mint a){
        return (*this) *= a.inv();
    }

    mint operator*(mint a) const{
        return mint(v) *= a;
    }

    mint operator+(mint a) const {
        return mint(v) += a;
    }

    mint operator-(mint a) const {
        return mint(v) -= a;
    }

    mint operator/(mint a) const {
        return mint(v) /= a;
    }

    mint pow(long long k) const {
        mint res(1),tmp(v);
        while(k){
            if(k&1) res *= tmp;
            tmp *= tmp;
            k >>= 1;
        }
        return res;
    }
    mint inv(){return pow(MOD - 2); }

    static mint comb(long long n, int k){
        mint res(1);
        for(int i = 0; i < k; ++i){
            res *= mint(n - i);
            res /= mint(i + 1);
        }
        return res;
    }

    static mint factorial(long long n){
        mint res(1);
        for(int i = n; i > 1; --i){
            res *= mint(i);
        }
        return res;
    }

    bool operator<(const mint &a) const {
        return v < a.v;
    };
};


int main(){
    ios_base::sync_with_stdio(false);

    string s;
    cin >> s;

    array<ll, 2019> count;
    fill(ALL(count), 0);
    count.at(0) = 1;

    ll ans = 0;
    mint sum = 0, p10 = 1;
    RREP(i, s.size()){
        p10 *= 10;
        sum = sum + p10 * (s.at(i) - '0');
        ans += count.at(sum.v);
        count.at(sum.v)++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3792
use proconio::{fastout, input, marker::*};

#[fastout]
fn main() {
    input! {
        a: usize,
        b: usize,
        c: usize,
    }

    let tmp = b;
    let b = a;
    let a = tmp;

    let tmp = c;
    let c = a;
    let a = tmp;

    println!("{} {} {}", a, b , c);

}


Measured memory_bytes: 2188
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int n;
    cin>>n;
    vector<ll> a(n+1);
    vector<ll> b(n+1);
    vector<ll> c(n);
    for(int i=1; i<=n; i++) cin>>a[i];
    for(int i=1; i<=n; i++) cin>>b[i];
    for(int i=1; i<n; i++) cin>>c[i];
    ll ans = 0;
    int prev = -1;
    for(int i=1; i<=n; i++){
        ans+=b[ a[i] ];
        if(prev+1 == a[i])
            ans+=c[prev];
        prev = a[i];
    }
    cout<<ans<<endl;
}


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

typedef long long ll;
typedef pair<int,int> pii;

long long MOD = 10000000000 + 7;

int main(){
  cout << setprecision(10);

  int N;
  cin >> N;
  vector<ll> a(N), b(N), c(N);

  for(int i = 0; i < N; i++){
    cin >> a.at(i) >> b.at(i) >> c.at(i);
  }

  vector<ll> dp_a(N, 100000000000000);
  vector<ll> dp_b(N, 100000000000000);
  vector<ll> dp_c(N, 100000000000000);

  dp_a[0] = a[0];
  dp_b[0] = b[0];
  dp_c[0] = c[0];
  for(int i = 1; i < N; i++){
    dp_a[i] = max(dp_b[i-1] + a[i], dp_c[i-1] + a[i]);
    dp_b[i] = max(dp_a[i-1] + b[i], dp_c[i-1] + b[i]);
    dp_c[i] = max(dp_a[i-1] + c[i], dp_b[i-1] + c[i]);
  }

  cout << max(dp_a[N-1], max(dp_b[N-1], dp_c[N-1])) << endl;


}


Measured memory_bytes: 4992
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(llint i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define Pll pair<llint,llint>
#define keta(a)  fixed << setprecision(a)
const ll mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
const ll INF = 1000000000;



int main() {
	int n;
	string s;
	cin >> n >> s;
	map<char, int> x;
	x['B'] = 0;
	x['R'] = 1;
	x['G'] = 2;
	llint a[3][4002] = {0};
	rep(i, 0, n) {
		a[0][i + 1] = a[0][i];
		a[1][i + 1] = a[1][i];
		a[2][i + 1] = a[2][i];
		a[x[s[i]]][i+1]++;
	}
	ll ans = 0;
	rep(i, 0, n-3) {
		rep(j, i + 2, n) {
			if (s[i] == s[j])continue;
			int z = 3 - x[s[i]] - x[s[j]];
			ll cnt = a[z][j + 1] - a[z][i];
			if ((j + i) % 2==0&& x[s[(i + j) / 2]] == z)cnt--;
			ans += cnt;
		}
	}
	cout << ans << endl;
    return 0;
}

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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define REPR(i,a,b) for(ll i=b;i>=a;i--)
#define repr(i,n) REPR(i,0,n)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define fi first
#define se second
#define m_p make_pair

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

    ll a,b,c;
    cin >> a >> b >> c;
    if(a==b) cout << c << "\n";
    else if(b==c) cout << a << "\n";
    else cout << b << "\n";
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayDeque

fun main(args: Array<String>) {
    val s = readLine()!!
    val q = readInteger()
    var state = true
    val queue = ArrayDeque<String>()
    queue.add(s)
    var reverseCount = 0
    repeat(q) {
        val query = readStringList()
        if (query[0] == "1") {
            state = !state
            reverseCount++
        } else {
            if (query[1] == "1") {
                if (state) {
                    queue.addFirst(query[2])
                } else {
                    queue.addLast(query[2])
                }
            } else {
                if (state) {
                    queue.addLast(query[2])
                } else {
                    queue.addFirst(query[2])
                }
            }
        }

//        println(queue.joinToString(", "))
//        println(state)
//        println()
    }

    val ans = queue.joinToString("")
    if (state == false) {
        println(ans.reversed())
    } else {
        println(ans)
    }
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


Measured memory_bytes: 82592
S = list(input())
i = 0
r = len(S)-1
ans = 0
while i < len(S) or r >= 0:
  if i >= len(S):
    if r < 0:
      break
    else:
      if S[r] == "x":
        ans += 1
        r -= 1
      else:
        ans = -1
        break
  if r < 0:
    if i >= len(S):
      break
    else:
      if S[i] == "x":
        ans += 1
        i += 1
      else:
        ans = -1
        break
  if i < len(S) and r >= 0:
    if S[i] != S[r]:
      if S[i] == "x":
        ans += 1
        i += 1
      elif S[r] == "x":
        ans += 1
        r -= 1
      else:
        ans = -1
        break
    else:
      i += 1
      r -= 1
print(ans//2)

Measured memory_bytes: 4084
#include <stdio.h>

int main(void) {
	int a,b,max;
	scanf("%d%d",&a,&b);
	max=a+b;
	if(a-b>max)	{
	max=a-b;
	}
	if(a*b>max){
		max=a*b;
	}
	printf("%d\n",max);
	return 0;
   
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rbf(a, x) for (auto& a : x)
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define drep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define Maxe(x) *max_element(all(x))
#define Mine(x) *min_element(all(x))
#define Size(x) ((ll)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
#define Fi first
#define Se second
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

    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;
    }

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo
//mint,dijkstra,gyakugen

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        char a;
        cin>>a;
        ll x=a-'a';
        if(x<26&&x>=0)cout<<"a"<<endl;
        else cout<<"A"<<endl;
    }

Measured memory_bytes: 3632
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String n = sc.nextLine();
        long sum = 0;
        for(int i = 0; i < n.length(); i++){
            sum+=n.charAt(i)-'0';
        }
        if(sum%9==0){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 41388
def main():
  H,W = map(int,input().split())
  _a = [input() for _ in range(H)]
  a =["#"*(W+2)]*(H+2)
  for i in range(H):
    a[i+1] = "#" + _a[i] + "#"
  for i in range(H+2):
    print(a[i])

main()  

Measured memory_bytes: 9100
#include<iostream>
#include<string>
#include<algorithm>
#include<cstring>
using namespace std;
#define MAX_N 16
#define INF 200000
#define REP(i,n) for(int i=0;i<n;i++)
#define rep(n) REP(i,n)

int times[MAX_N][MAX_N+1];
int n;
int dp[ 1<< MAX_N];

int solve(int clear)
{	
	if(dp[clear]!=0) return dp[clear];

	if(clear ==((1<<n) -1 ) )	return 0;

	int ans = INF;
	rep(n)
	{
		if((clear >>i)&1 )continue;
		ans =min(ans,times[i][0]+solve(clear|1<<i));
		REP(j,n)
		{
			if((clear >> j)&1)ans =min(ans, times[i][j+1]+solve(clear|(1<<i)));
		}
	}
	return dp[clear] = ans ;
}

int main()
{	
	while(cin >> n && n )
	{
		memset(dp,0,(1<<MAX_N)*sizeof(int));
		REP(i,n)REP(j,n+1)cin >> times[i][j]; 	
		cout << solve(0) << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#define N_MAX 50
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
ll N,M,A,B,C,T,d[N_MAX];

mat cal(mat mA,mat mB){
  mat res=mat(N,vec(N,0));
  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++)
      for(int k=0;k<N;k++) res[i][j]+=mA[i][k]*mB[k][j]%M;
  return res;
}

void mod_power(mat &mA){
  mat res=mat(N,vec(N,0));
  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++) res[i][j]=(i==j);
  for(int i=0;i<=30;i++){
    if(T&(1LL<<i)) res=cal(res,mA);
    mA=cal(mA,mA);
  }
  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++) mA[i][j]=res[i][j];
}

int main(){
  while(1){
    cin>>N>>M>>A>>B>>C>>T;
    if(!N&&!M&&!A&&!B&&!C&&!T) break;
    mat mA=mat(N,vec(N,0));
    for(int i=0;i<N;i++) cin>>d[i];
    for(int i=0;i<N;i++)
      for(int j=0;j<N;j++){
	if(i==j) mA[i][j]=B;
	if(i+1==j) mA[i][j]=C;
	if(i==j+1) mA[i][j]=A;
      }
    mod_power(mA);
    mat mB=mat(N,vec(N,0));
    for(int i=0;i<N;i++) mB[i][0]=d[i];
    mA=cal(mA,mB);
    for(int i=0;i<N;i++){
      cout<<mA[i][0]%M;
      if(i!=N-1) cout<<' ';
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 1328
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=998244353;
const int INF=1e9;

int main(){
    int n;
    cin>>n;
    int cnt[n+1]={};
    int d[n];
    for(int i=0;i<n;i++){
        cin>>d[i];
        cnt[d[i]]++;
    }
    if(d[0]!=0||cnt[0]!=1){
        cout<<0<<endl;
        return 0;
    }
    ll ans=1;
    for(int i=1;i<n;i++){
        ans=(ans*cnt[d[i]-1])%MOD;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
N,M = map(int,input().split())
A = list(map(int,input().split()))
BC = [list(map(int,input().split())) for i in range(M)]

BC.sort(key = lambda x:x[1],reverse = True)
A.sort()
keep1 = BC[0][1]
keep2 = BC[0][0]
p = 0
B = [BC[i][0] for i in range(M)]
for i in range(min(sum(B),N)):
        if A[i] < keep1:
                A[i] = keep1
                if i == keep2-1:
                        p += 1
                        if p < M:
                            keep2 += BC[p][0]
                            keep1 = BC[p][1]

print(sum(A))

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

using namespace std;

int main(){
	
	while(1){
		
		int be,af,p;
		
		cin >> be >> af >> p;
		
		if(be==0) break;
		
		int ma=0;
		
		for(int i=1;i<p-1;i++){
			for(int j=1;j<p-1;j++){
				int a=i*(100+be)/100;
				int b=j*(100+be)/100;
				
				if(a+b==p){
					int c=i*(100+af)/100;
					int d=j*(100+af)/100;
					ma=max(ma,c+d);
				}
			}
		}
		cout << ma << endl;
	}
	
	
	return 0;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int a1, a2, a3;
  cin >> a1 >> a2 >> a3;

  if((a1==a2 && a1!=a3)
  || (a1==a3 && a1!=a2)
  || (a2==a3 && a1!=a2))
  {	
    cout << "Yes" << endl;
    
  }
  else
  {
  
  cout << "No" << endl;
}
}

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

#define IO          ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int         long long
#define double      long double
#define vi          vector <int>
#define vvi         vector <vi>
#define pii         pair <int,int>
#define vii         vector <pii>
#define nl          '\n'
#define yy          "YES\n"
#define nn          "NO\n"
#define pb          emplace_back
#define all(v)      (v).begin(), (v).end()
#define rall(v)     (v).rbegin(), (v).rend()
#define mod         1000000007

signed main()
{
        IO;
        int n;
        cin >> n;
        if (n >= 30) {
            cout << "Yes";
        }
        else {
            cout << "No";
        }
}


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

using namespace std;
typedef long long int ll;

int main()
{
    int n;
    cin >> n;
    vector<vector<char>>v(8,vector<char>(8,'.'));
    vector<int>a,b;
    vector<pair<int,int>>Q;
    for(int i = 0; i < 8; i++) a.push_back(i);
    b = a;
    for(int i = 0; i < n; i++)
    {
        int r,c;
        cin >> r >> c;
        v[r][c] = 'Q';
        Q.push_back(make_pair(r,c));
        vector<int>::iterator e1 = remove(a.begin(), a.end(), r);
        a.erase(e1, a.end());
        vector<int>::iterator e2 = remove(b.begin(), b.end(), c);
        b.erase(e2, b.end());
    }
    do
    {
        do
        {
            bool f = true;
            for(int i = 0; i < 8-n; i++)
            {
                for(int j = i+1; j < 8-n;j++)
                {
                    if(abs(a[i]-a[j]) == abs(b[i]-b[j])) f = false;
                }
                for(int j = 0; j < n; j++)
                {
                    if(abs(a[i]-Q[j].first) == abs(b[i]-Q[j].second)) f = false;
                }
            }
            if(f)
            {
                for(int i = 0; i < 8-n; i++)
                {
                    v[a[i]][b[i]] = 'Q';
                }
            }
        }while(next_permutation(a.begin(),a.end()));
    }while(next_permutation(b.begin(),b.end()));
    for(int i = 0; i < 8; i++)
    {
        for(int j =  0; j < 8; j++) cout << v[i][j];
        cout << endl;
    }
}



Measured memory_bytes: 3168
#include<iostream>
#include<set>
#include<queue>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

string clock(int num){
	int n=num/60,m=num%60;
	string res="";
	if(n/10!=0)res+=(char)(n/10+'0');
	res+=(char)(n%10+'0');
	res+=':';
	res+=(char)(m/10+'0');
	res+=(char)(m%10+'0');
	return res;
}

int main(){
	int n,h,m,size;
	priority_queue<int,vector<int>,greater<int> > que;
	set<int> st;
	cin>>n;
	rep(i,n){cin>>h>>m;st.insert(h*60+m);}
	cin>>n;
	rep(i,n){cin>>h>>m;st.insert(h*60+m);}
	for(set<int>::iterator ite=st.begin();ite!=st.end();ite++)que.push(*ite);
	while(!que.empty()){
		cout<<clock(que.top());
		if(que.size()==1)cout<<endl;
		else cout<<" ";
		que.pop();
	}
	return 0;
}

Measured memory_bytes: 1236
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------
long long n;
long long num;
long long cnt;
long long ans;

void solve(){
    if(n % 2 != 0){//奇数だったら絶対に0
        cout << 0 << endl;
    }
    else{//偶数のときを考える
    ans = 0;
    num = n / 2;
    cnt = 1;
    while(num >= 5){
        num /= 5;
        ans += num;
        cnt++;
    }
    cout << ans << endl;
    }
}

int main(){
    cin >> n;
    solve();
    return 0;
}



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

int main() {
  int n, l; cin >> n >> l;
  vector<string> s(n);
  for (int i=0; i<n; i++){
    cin >> s.at(i);
  }
  
  sort(s.begin(), s.end());
  
  for (int i=0; i<n; i++){
    cout << s.at(i);
  }
  cout <<endl;
}


Measured memory_bytes: 256