akhauriyash/Code-Regression huggingface dataset:
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <array>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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


int main() {

	long long n; cin >> n;
	vector<long long> h(n); for (long long i = 0; i <= n - 1; i++) cin >> h[i];

	long long curr_max = h[0], ans = 0;

	for (long long i = 1; i <= n - 1; i++) {
		if (curr_max < h[i]) {
			curr_max = h[i];
		}
		else {
			ans += curr_max - h[i];
		}
	}

	cout << ans;

	return 0;
}

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

int* mallocint(int si)
{
    return (int*) malloc(si * sizeof(int));
}

int main()
{
    int n, k;
    cin >> n >> k;
    int *table = mallocint(n);
    for( int i = 0; i < n; i++) table[i] = 1;
    for( int i = 0; i < k; i++)
    {
        int d;
        cin >> d;
        for( int j = 0; j < d; j++ )
        {
            int s;
            cin >> s;
            table[s - 1] = 0;
        }
    }
    int ans = 0; 
    for( int i = 0; i < n; i++)
    {
        ans += table[i];
    }
    cout << ans;

}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n, s) for (int i = (s); i < (n); i++)
#define MOD 1000000007
typedef long long int ll;
using namespace std;
using Graph = vector<vector<int>>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int n = S.length();
    set<char> even{'L', 'U', 'D'}, odd{'R', 'U', 'D'};
    string ans = "Yes";
    reps(i, n + 1, 1)
    {
        if (i % 2 == 0 && !even.count(S[i - 1]))
        {
            ans = "No";
            break;
        }
        else if (i % 2 != 0 && !odd.count(S[i - 1]))
        {
            ans = "No";
            break;
        }
    }
    cout << ans << endl;
    //system("pause");
    return 0;
}

Measured memory_bytes: 256
#pragma region
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define repc(i, m, n) for (int i = m; i < n; i++)
#define reprc(i, m, n) for (int i = m; i > n; i--)
#define all(v) v.begin(), v.end()
#define INF 1e9
#define EPS 1e-10
using namespace std;
typedef long long ll;
#pragma endregion

int main()
{
    int N;
    bool flag = false;
    int number[3][3];
    bool ismark[3][3];

    rep(i, 3){
        rep(j, 3){
            cin >> number[i][j];
            ismark[i][j] = false;
        }
    }

    cin >> N;
    vector<int> b(N);

    rep(i, N){
        cin >> b.at(i);
    }

    rep(i, N){
        rep(j, 3){
            rep(k, 3){
                if(b.at(i) == number[j][k]){
                    ismark[j][k] = true;
                }
            }
        }
    }

    rep(i, 3){
        if(ismark[0][i] && ismark[1][i] && ismark[2][i]){
            flag = true;
        }
    }

    rep(i, 3){
        if(ismark[i][0] && ismark[i][1] && ismark[i][2]){
            flag = true;
        }
    }

    if(ismark[0][0] && ismark[1][1] && ismark[2][2]){
        flag = true;
    }

    if(ismark[0][2] && ismark[1][1] && ismark[2][0]){
        flag = true;
    }

    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
stan = A[0]
ans = 0
k = 0
for i in range(1,N):
    if stan == A[i]:
        ans += 1 + k
        k = -((k-1)%2)
    else:
        k = 0
    stan = A[i]
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <cstring>

using namespace std;

const int MOD = 1000000007;
long long dp[2][1<<16];

int main(){
	int N, X, Y, Z;
	while(cin >> N >> X >> Y >> Z){
		memset(dp, 0, sizeof(dp));
		int invalid = ((1<<Z)|(1<<(Y+Z))|(1<<(X+Y+Z))) >> 1;
		dp[0][0] = 1;
		for(int i=1;i<=N;i++){
			long long* cur = dp[1-i%2];
			long long* next = dp[i%2];
			memset(dp[i%2], 0, sizeof(dp[0]));
			for(int j=0;j<(1<<(X+Y+Z-1));j++){
				if(!cur[j]) continue;
				for(int k=1;k<=10;k++){
					int x = (j<<k)|(1<<(k-1));
					if((x&invalid)==invalid) continue;
					x &= (1<<(X+Y+Z-1))-1;
					next[x] += cur[j];
					next[x] %= MOD;
				}
			}
		}
		long long res = 1, sub = 0;
		for(int i=0;i<N;i++) res = (10*res)%MOD;
		for(int j=0;j<(1<<(X+Y+Z-1));j++) sub = (sub+dp[N%2][j])%MOD;
		cout << (res+MOD-sub)%MOD << endl;
	}
}


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

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll dp[110][100010];

int main(){

    int n;
    int W;
    cin >> n >> W;
    vector<int> w(n);
    vector<ll> v(n);
    rep(i,n)cin >> w[i] >> v[i];
    Fill(dp,-1);
    dp[0][0] = 0;
    for(int i=0;i<n;i++){
        for(int j=0;j<=W;j++){
            dp[i+1][j] = max(dp[i+1][j],dp[i][j]);
            if(dp[i][j]!=-1&&j+w[i]<=W){
                dp[i+1][j+w[i]] = max(dp[i+1][j+w[i]],dp[i][j]+v[i]);
            }
        }
    }
    ll mx = 0;
    rep(j,W+1){
        mx = max(mx,dp[n][j]);
    }
    cout << mx << endl;
    return 0;
}

Measured memory_bytes: 86776
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>//pair
#include<cmath>//abs,sqrt
#include<cstring>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
using std::cin;
typedef long long ll;
const int INF=1e+9;
const ll INFLL=1e+17;
int H,W,N;
int R,C;
char S[200010],T[200010];
void solve(){
  int u=0,d=H+1,l=0,r=W+1;
  for(int i=N-1;i>=0;i--){
    if(T[i]=='D'&&u!=0) u--;
    if(T[i]=='U'&&d!=H+1) d++;
    if(T[i]=='L'&&r!=W+1) r++;
    if(T[i]=='R'&&l!=0) l--;    
    if(S[i]=='D'&&d!=1) d--;
    if(S[i]=='U'&&u!=H) u++;
    if(S[i]=='L'&&l!=W) l++;
    if(S[i]=='R'&&r!=1) r--;
    if(r-l==1||d-u==1){
      prin("NO");
      return ;
    }
  }
  if(R<=u||R>=d||C<=l||C>=r) prin("NO");
  else prin("YES");
}
int main(){
  cin>>H>>W>>N;
  cin>>R>>C;
  rep(i,N) cin>>S[i];
  rep(i,N) cin>>T[i];
  solve();
  return 0;
}


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

using namespace std;

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'

int main()
{
	int n,k,coun = 0,a;
	cin >> n >> k;
	for(int i = 1; i <= n; i++)
	{
		cin >> a;
		if(a >= k) coun++;
	}
	cout<< coun << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <list>
#include <functional>
#include <map>
#include <set>
#include <cmath>
#include <string>
#define SIZE 100005
#define INF 1000000007LL

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

int N,K;
ll X[SIZE];

int main(){
	scanf("%d%d",&N,&K);
	for(int i=0;i<N;i++){
		scanf("%lld",&X[i]);
	}
	ll ans = INF;
	/*
	if(X[0] >= 0){
		printf("%lld\n",X[K-1]);
		return 0;
	}else if(X[N-1] <= 0){
		printf("%lld\n",(-1)*X[N-K]);
		return 0;
	}
	*/
	for(int i=0;i<=N-K;i++){
		ll T;
		if(X[i] > 0 || X[i+K-1] <0){
			T = max(abs(X[i]),abs(X[i+K-1]));
		}else{
			T = min(X[i+K-1]*2-X[i],X[i+K-1]-X[i]*2);
		}
		ans = min(ans,T);
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 896
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

N, M = I()
H = l()
good = [1]*N
for k in range(M):
    A, B = map(int, input().split())
    if H[A - 1] >= H[B - 1]:
        good[B - 1] = 0
    if H[A - 1] <= H[B - 1]:
        good[A - 1] = 0
print(sum(good))



Measured memory_bytes: 22040
#include <cstdio>
using namespace std;

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

    int n = b - a;

    long h = 0;
    for (int i = 1; i <= n - 1; i++) {
        h += i;
    }

    printf("%ld\n", h - a);
    return 0;
}

Measured memory_bytes: 888
#include<iostream>
#include<cstring>
using namespace std;
const int V = 100010;
bool dp[V];
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	memset(dp,false,sizeof(dp));
	int n;
	cin>>n;
	dp[0]=true;
	for(int i=1;i<=6;i++){
		int v=99+i;
		for(int j=v;j<=n;j++){
			if(dp[j-v]){
				dp[j]=true;
			}
		}
	}
	cout<<dp[n]<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>

int main(void)
{
  int k;
  char string[105];
  scanf("%d", &k);
  scanf("%s", string);
  int n = strlen(string);
  
  for (int i = 0; i < k && i < n; i++)
  {
    printf("%c", string[i]);
  }
  if (n > k)
  {
    printf("...\n");
  }
  return 0;
}


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

int main(void){

    int N;
    cin >> N;
    int p[N],tmp = 0;
    for(int i = 0; i < N; i++){
        cin >> p[i];
    }
    for(int i = 0; i < N; i++){
        if(p[i] != i+1){
            tmp++;
        }
    }

    if(tmp==0 || tmp == 2){
        cout << "YES" << endl;
    }else{
        cout << "NO"  << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
	int a[6];
	for(int i=1;i<=5;i++)
	{
		scanf("%i",&a[i]);
	}
	for(int i=1;i<=5;i++)
	{
		if(a[i]==0)
		{
			printf("%i",i);
		}
	}
    return 0;
}



Measured memory_bytes: 3828
from collections import deque

class peke:
    def __init__(self,Start,End,S):
        self.start=Start
        self.end=End
        self.S=S
    

S1=deque()
S2=deque()
total=0
A=input()

for n in range(len(A)):
    if A[n]=='\\':
        S1.append(n)
    elif A[n]=='/' and S1:
        j=S1.pop()
        now=n-j
        total=total+now
        while S2:
            if S2[-1].start>j and S2[-1].end<n:
                now=now+S2[-1].S
                S2.pop()
            else:
                break
        S2.append(peke(j,n,now))

print(total)
print(len(S2),end ="")
while S2:
    print(" ",end="")
    print(S2[0].S,end="")
    S2.popleft()
print()



Measured memory_bytes: 7612
H, W = gets.split.map(&:to_i)
S = H.times.map{gets.chomp}

visited = Array.new(H){Array.new(W)}
ans = 0
H.times do |i|
    W.times do |j|
        next if visited[i][j]
        visited[i][j]
        num = [0, 0]
        que = [[i, j]]
        while que.size > 0
            x, y = que.shift
            [[-1, 0], [1, 0], [0, -1], [0, 1]].each do |a, b|
                x2 = x+a
                y2 = y+b
                if x2.between?(0, H-1) && y2.between?(0, W-1) && !visited[x2][y2] && S[x][y] != S[x2][y2]
                    que.push([x2, y2])
                    visited[x2][y2] = true
                    num[S[x][y] == '#' ? 1 : 0] += 1
                end
            end
        end
        ans += num[0] * num[1]
    end
end
puts ans

Measured memory_bytes: 3708
#include <iostream>
#include <fstream>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>

using namespace std;

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

/*
    freopen("input","r",stdin);
    freopen("output","w",stdout);
*/

char C[510][510];

int main() {
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    for (int i = 0;i < H;i++) {
    	for (int j = 0;j < W;j++) {
    		cin >> C[i][j];
    	}
    }
    for (int i = 0;i < H;i++) {
    	cout << '#';
    	for (int j = 1;j < W - 1;j++) {
    		if (i % 2 == 0) cout << '#';
    		else cout << C[i][j];
    	}
    	cout << '.';
    	cout << endl;
    }
    cout << endl;
    cout << endl;
    for (int i = 0;i < H;i++) {
    	cout << '.';
    	for (int j = 1;j < W - 1;j++) {
    		if (i % 2 == 1) cout << '#';
    		else cout << C[i][j];
    	}
    	cout << '#';
    	cout << endl;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int cnt=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			for(int k=1;k<=n;k++){
				cnt++;	
			}
		}
	}
	cout<<cnt<<endl;
	return 0;
}


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

p = [int(_) for _ in input().split()]

count = 0

for i in range(1,n-1):
  if p[i+1]>p[i] and p[i]>=p[i-1]:
    count += 1
  elif p[i-1]>p[i] and p[i]>=p[i+1]:
    count += 1
    
print (count)

Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
    double r;
    double pi = 3.141592653589;
    cin >> r;
    double S = pi*r*r;
    double R = 2 * pi*r;
    cout << fixed << setprecision(5) << S << " " << fixed << setprecision(5) << R << endl;

    return 0;
}

Measured memory_bytes: 1288
class UnionFind

  attr_accessor :nodes, :sizes

  def initialize(num)
    self.nodes = []
    self.sizes = []

    num.times do |n|
      self.nodes[n] = n
      self.sizes[n] = 1
    end
  end

  def root(i)
    # Loop up the chain until reaching root
    while nodes[i] != i do
      # path compression for future lookups
      nodes[i] = nodes[nodes[i]]
      i = nodes[i]
    end
    i
  end

  def union(i, j)
    rooti = root i
    rootj = root j

    # already connected
    return if rooti == rootj

    # root smaller to root of larger
    if sizes[i] < sizes[j]
      nodes[rooti] = rootj
      sizes[rootj] += sizes[rooti]
    else
      nodes[rootj] = rooti
      sizes[rooti] += sizes[rootj]
    end
  end

  def connected?(i, j)
    root(i) == root(j)
  end

end

N, M = gets.split.map &:to_i
uf = UnionFind.new(N)
$<.each{|s|
  x, y, z = s.split.map &:to_i
  uf.union(x-1, y-1)
}
p (0...N).map{|i|
  uf.root(i)
}.uniq.size

Measured memory_bytes: 11504
#include<bits/stdc++.h>
#define INF            1e9
#define REP(i,n)       for(lint i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)      for(lint i=1,i##_len=(n);i<=i##_len;++i)
#define REPI(i,ini,n)  for(lint i=(ini),i##_len=(n);i<i##_len;++i)
#define REPR(i,n)      for(lint i=(n)-1;i>=0;--i)
#define REPR1(i,n)     for(lint i=(n);i>0;--i)
#define REPRI(i,ini,n) for(lint i=(ini)-1,i##_len=(n);i>=i##_len;--i)
#define REPC(i,obj)    for(auto i:obj)
#define R_UP(a,b)      (((a)+(b)-1)/(b))
#define ALL(obj)       (obj).begin(),(obj).end()
using namespace std;
using lint = long long;
template<typename T = lint>inline T in() { T x; cin >> x; return x; }
int binary_search_p(int first_w, int last_w, int k, int max_w, const vector<int>&w)
{
	auto get_minimum_k = [&w](int p_candidate)
	{
		int result = 1;
		int temp = 0;
		REPC(i, w)
		{
			if (temp + i <= p_candidate)temp += i;
			else
			{
				result++;
				temp = i;
			}
		}
		return result;
	};
	int p_candidate = first_w + (last_w - first_w) / 2;
	int min_k = get_minimum_k(p_candidate);
	if (first_w > last_w)
	{
		int result;
		for (int i = max(p_candidate, max_w);; i++)
		{
			if (get_minimum_k(i) <= k)return i;
		}
	}
	return min_k <= k ? binary_search_p(first_w, p_candidate - 1, k, max_w, w) : binary_search_p(p_candidate + 1, last_w, k, max_w, w);
}
signed main()
{
	int n = in(), k = in();
	vector<int>w(n);
	int min_w = 10001, max_w = -1, sum_w = 0;
	REPC(&i, w)
	{
		i = in();
		if (min_w > i)min_w = i;
		if (max_w < i)max_w = i;
		sum_w += i;
	}
	cout << binary_search_p(min_w, sum_w, k, max_w, w) << endl;
}


Measured memory_bytes: 3120
#include <algorithm>
#include <array>
#include <bitset>
#include <chrono>
#include <cmath>
#include <iostream>
#include <numeric>
#include <random>
#include <set>
#include <unordered_set>
#include <vector>
#include <list>
#include <functional>

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

using namespace std;

#define LOCAL 1

#if LOCAL
#define pv(val) cerr << #val << " = " << (val) << endl
#define pvn(name, val) cerr << name << " = " << (val) << endl
#define pl cerr << '@' << __LINE__ << endl
#else
#define pv(val)
#define pvn(name, val)
#define pl
#endif

template <class T>
ostream& operator<<(ostream& os, vector<T> const& vec) {
  if (vec.empty()) {
    os << "{}";
  } else {
    os << '{';
    for (size_t i = 0; i < vec.size() - 1; i++) os << vec[i] << ", ";
    os << vec.back() << '}';
  }
  return os;
}

template <class T, size_t S>
ostream& operator<<(ostream& os, array<T, S> const& arr) {
  if (arr.empty()) {
    os << "{}";
  } else {
    os << '{';
    for (size_t i = 0; i < arr.size() - 1; i++) os << arr[i] << ", ";
    os << arr.back() << '}';
  }
  return os;
}

template <class T, class U>
ostream& operator<<(ostream& os, pair<T, U> const& p){
  os << '(' << p.first << ", " << p.second << ')';
  return os;
}

template<class T, class U>
pair<T, U> operator+(pair<T, U> const& lhs, pair<T, U> const& rhs){
  return {lhs.first + rhs.first, lhs.second + rhs.second};
}

template<class T, class U>
pair<T, U> operator-(pair<T, U> const& lhs, pair<T, U> const& rhs){
  return {lhs.first - rhs.first, lhs.second - rhs.second};
}

template<class T, class U>
U lowerBound(function<T(U)> f, T const& val, U l, U r){
  while(l < r){
    auto m = l + (r - l) / 2;
    auto fm = f(m);
    if(fm < val){
      l = m;
    }else{
      r = m;
    }

  }
}


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

  return 0;
}


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

int main(void){
  int a, b;
  cin >> a >> b;
  if(a%3 == 0 || b%3 == 0 || (a+b)%3 == 0) cout << "Possible" << endl;
  else cout << "Impossible" << endl;
  return 0;
}


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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int N;
	cin >> N;
	vector<ll> A(N);
	for (int i = 0; i < N; i++) cin >> A[i];
	vector<int> order;
	for (int i = 0; i < N; i++) order.push_back(i);
	sort(order.begin(), order.end(), [&](int i, int j) { return A[i] > A[j]; });

	static ll dp[2001][2001];
	for (int i = 0; i < N; i++) for (int j = 0; i + j < N; j++) {
		int pos = order[i + j];
		dp[i + 1][j] = max(dp[i+1][j], dp[i][j] + A[pos] * abs(pos - i));
		dp[i][j + 1] = max(dp[i][j+1], dp[i][j] + A[pos] * abs(pos - (N - 1 - j)));
	}
	ll ans = 0;
	for (int i = 0; i <= N; i++) ans = max(ans, dp[i][N - i]);
	cout << ans << endl;
	return 0;
}

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

int main(void)
{
    int N;
    cin >> N;
    vector<ll> T(N), A(N);
    REP(i, N) cin >> T[i] >> A[i];

    ll t = T[0], a = A[0];
    Rep(i, 1, N){
        set<ll> s;
        s.insert(t/T[i]);
        s.insert(t/T[i]+1);
        s.insert(a/A[i]);
        s.insert(a/A[i]+1);
        for(auto&& si: s){
            if(t <= T[i]*si && a <= A[i]*si){
                t = T[i]*si;
                a = A[i]*si;
                break; 
            }
        }
    }
    pr(t+a);
}

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

int main(){
  string S,tmp;
  cin>>S;
  int length,ans,num,cand;
  ans=753;
  length=S.size();
  for(int i=0;i<length-2;++i){
    tmp=S.substr(i,3);
    num=stoi(tmp);
    cand=abs(num-753);
    ans=min(ans,cand);
  }
  cout<<ans;
  return 0;
  }

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();

		if(b == 1) {
			System.out.println(0);
			return;
		}

		int ans = 1;
		if(a >= b) {

		}else {
			int temp = b - a;
			ans += temp / (a - 1);
			if(temp % (a - 1) != 0)
				ans++;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21972
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int x, a, b;
    cin >> x >> a >> b;
    if (b - a <= 0)
        cout << "delicious" << "\n";
    else if (b - a <= x)
        cout << "safe" << "\n";
    else
        cout << "dangerous" << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

signed main(void){
    int a,b,x;
    cin >> a >> b >> x;
    if(2*x>=a*a*b){
        //double k = 2*x/(a*a);
        //k-=b;
        double Ans=atan2(2*a*a*b-2*x,a*a*a);
        Ans*=180/PI;
        printf("%.8f\n",Ans);
    }else{
        //double k= 2*x/(a*b);
        double Ans=atan2(a*b*b,2*x);
        Ans*=180/PI;
        printf("%.8f\n",Ans);
        
    }
    return 0;
}



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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }


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

    int a, b, h;
    cin >> a >> b >> h;
    cout << (a + b) * h / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    int n,k,ans; cin>>n>>k;
    if(k>(n-1)*(n-2)/2) ans=-1;
    else ans=n*(n-1)/2-k;
    cout<<ans<<endl;
    if(ans!=-1){
        rep(i,n-1) cout<<i+1<<" "<<n<<endl;
        int cnt=n-1;
        for(int i=1;i<=n-2;i++){
            for(int j=i+1;j<=n-1;j++){
                if(cnt==ans){
                  i=n; break;
                }
                cout<<i<<" "<<j<<endl;
                cnt++;
            }
        }
    }
}

Measured memory_bytes: 256
// D - Coloring Edges on Tree
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define eb emplace_back

int main(){
	int N; cin>>N;
	vvi tree(N);
	vi C;
	rp(i, 0, N-1){
		int a,b; cin>>a>>b; a--,b--;
		tree[a].eb(b); tree[b].eb(a);
		C.eb(b);
	}

	int K = 0;
	vi p_color(N), visited(N);
	queue<int> q;
	q.push(0);
	visited[0] = true;
	while(!q.empty()){
		int p = q.front(); q.pop();
		K = max(K, (int)tree[p].size());
		int color = 1;
		for(auto c:tree[p]){
			if(visited[c]) continue;
			if(color==p_color[p]) color++;
			p_color[c] = color++;
			q.push(c);
			visited[c] = true;
		}
	}

	cout<< K <<endl;
	for(auto c:C) cout<< p_color[c] <<endl;
}

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

const int N = 100005;
const int INF = 1e9;

string s;
int n;
int f[N];

namespace SuffixArray {
	int pos[N][18];
	int sa[N]; // suffix array (positions)
	int lcp[N];
	int gap, k; // k = log

	bool cmp(int x, int y) {
		pair<int,int> p = {pos[x][k - 1], (x + gap <= n ? pos[x + gap][k - 1] : -INF)};
		pair<int,int> q = {pos[y][k - 1], (y + gap <= n ? pos[y + gap][k - 1] : -INF)};
		return p < q;
	}

	void buildSA() {
		for (int i = 1; i <= n; ++i) pos[i][0] = s[i] - 'a';
		for (k = 1, gap = 1; k <= 17; gap <<= 1, ++k) {
			vector <int> buf;
			for (int i = 1; i <= n; ++i) buf.push_back(i);
			sort(buf.begin(), buf.end(), cmp);

			int cnt = 0;
			for (int i = 0; i < n; ++i) {
				if (i > 0 && !cmp(buf[i], buf[i - 1]) && !cmp(buf[i - 1], buf[i])) {
					pos[buf[i]][k] = cnt;
				}
				else pos[buf[i]][k] = ++cnt;
			}
		}
		// done! -> sa[]
		for (int i = 1; i <= n; ++i) sa[pos[i][17]] = i;
	}

	int getLCP(int x, int y) {
		int ret = 0;
		for (int i = 17; i >= 0; --i) {
			if (x + (1 << i) - 1 <= n && y + (1 << i) - 1 <= n && pos[x][i] == pos[y][i]) {
				x += (1 << i); y += (1 << i); ret += (1 << i);
			}
		}
		return ret;
	}

	void buildLCP() {
		// lcp[i] is LCP of SA[i] and SA[i + 1]
		for (int i = 1; i < n; ++i) lcp[i] = getLCP(sa[i], sa[i + 1]);
	}

	void run() {
		buildSA();
		buildLCP();

		for (int i = 1; i <= n; ++i) {
			int p = sa[i] + lcp[i - 1];
			int low = p - sa[i] + 1;
			int high = n - sa[i] + 1;
			f[high + 1]--;
			f[low]++;	
		}

		for (int i = 1; i <= n; ++i) {
			f[i] += f[i - 1]; // range update
		}
	}
};

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

	cin >> s;
	n = s.size();
	s = ' ' + s;

	SuffixArray::run();

	int res = 0;
	for (int i = 1; i <= n; ++i) {
		res = max(res, f[i]);
	}

	printf("%d\n", res);
}

Measured memory_bytes: 8736
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 1e5 + 10;

int main() {
	fast_cin();
	int n, k;
	cin >> n >> k;
	int a = n / 2, b = 2 * n - 1, c = 3 * n - 1;
	vector<vector<int>> t(n);
	for (int i = 0; i < n; ++i) {
		if (a + k + b + k > c + k) {
			cout << -1 << endl;
			return 0;
		}
		t[i] = {a + k, b + k, c + k};
		--c;
		if (a + 1 < b - 2) {
			++a; b -= 2;
		} else {
			a = 0;
			b = 2 * n - 2;
		}
	}
	for (int i = 0; i < n; ++i) {
		for (auto &j : t[i]) {
			cout << j << ' ';
		}
		cout << '\n';
	}
}

Measured memory_bytes: 7808
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;

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

int main(void){

    vector<char> s(6);
    rep(i, 6){
        cin >> s.at(i);
    }
    if(s.at(2) == s.at(3) && s.at(4) == s.at(5)){
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

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

template<class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template<class T, class V>
typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) {
    t = v;
}
template<class T, class V>
typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v){
    for (auto &e : t) fill(e, v);
}

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }

#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


int N, K;
string S;

int main() {
    while (cin >> N >> K >> S) {
        S[K-1] = S[K-1] - ('A' - 'a');
        cout << S << endl;
    }
}

















Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
         int A,B,K;
         cin>>K;
         cin>>A>>B;
         int count=0;

         for(int i=A;i<=B;i++)
                  {
                           if(i%K==0)
                           {
                                    count++;


                           }

                  }

                  if(count>0)
                           cout<<"OK"<<endl;
                  else
                           cout<<"NG"<<endl;



         return 0;
}


Measured memory_bytes: 3576
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <algorithm>

#define MOD_BIG 1000000007
#define MOD_BIG2 998244353
using std::string;
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using ll = long long;
using std::vector;

template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) {
    vec.resize(len);
    for (auto &v : vec) ndarray(v, args...);
}

//////////////////////////////////////



//////////////////////////////////////

int main() {
    
    using P = std::pair<ll, ll>;
    
    ll N, K;
    cin >> N >> K;
    vector<ll> vec(N);
    vector<P> lrs(N-K+1);
    vector<ll> rnbn(N);
    P lr = P(N, -1);
    for (ll i = 0; i < N; i++) {
        cin >> vec[i];
    }
    for (ll i = 1; i < N; i++) {
        if (vec[i] > vec[i-1]) {
            rnbn[i] = rnbn[i-1] + 1;
        } else {
            rnbn[i] = 1;
        }
    }
    
    ll ans = 1;
    bool f = true;
    std::set<ll> s;
    for (ll i = 0; i < K-1; i++) {
        if (vec[i] >= vec[i+1]) {
            f = false;
            break;
        }
    }
    for (ll i = 0; i < K; i++) {
        s.insert(vec[i]);
        lr.first = std::min(lr.first, vec[i]);
        lr.second = std::max(lr.second, vec[i]);
        lrs[0] = lr;
    }
    for (ll i = K; i < N; i++) {
        bool tmp = true;
        if (lr.first == vec[i-K]) {
            auto itr = s.lower_bound(vec[i-K]);
            lr.first = *std::next(itr);
            s.erase(itr);
            lr.first = std::min(lr.first, vec[i]);
            lr.second = std::max(lr.second, vec[i]);
            if (lr.second == vec[i]) {
                ans--;
                tmp = false;
            }
        } else if (lr.second == vec[i-K]) {
            auto itr = s.lower_bound(vec[i-K]);
            lr.second = *std::prev(itr);
            s.erase(itr);
            lr.first = std::min(lr.first, vec[i]);
            lr.second = std::max(lr.second, vec[i]);
        } else {
            s.erase(vec[i-K]);
            lr.first = std::min(lr.first, vec[i]);
            lr.second = std::max(lr.second, vec[i]);
        }
        ans++;
        s.insert(vec[i]);
        lrs[i-K+1] = lr;
        
        if (lr.first == vec[i-K+1] && lr.second == vec[i]) {
            if (rnbn[i] >= K) {
                if (f && tmp) {
                    ans--;
                }
                f = true;
            }
        }
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 12800
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>


using namespace std;
typedef unsigned long long ll;

ll N;
ll ans = 0;
void enumeration(ll e, ll s){

    if(s == 9){
        return;
    }

    for(ll i = 3; i <= 7; i = i + 2){
        //cout << e * 10 + i << endl;
        ll t = e * 10 + i;
        bool f3 = 0, f5 = 0, f7 = 0;
        for(ll j = 0; j < s + 1; j++){

           // cout << t % 10 ;

            if(t % 10 == 3){
                f3 = 1;
            }
            if(t % 10 == 5){
                f5 = 1;
            }
            if(t % 10 == 7){
                f7 = 1;
            }

            t /= 10;

        }
        //cout << endl;
        
        if((f3 & f5 & f7) == 1 && e * 10 + i <= N){
            ans++;
            //cout << e * 10 + i << endl;
        }
        enumeration(e * 10 + i , s + 1 );
    }
}

int main(){

    cin >> N;
    enumeration(0, 0);

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <assert.h>
#include <numeric>
#include <math.h>
#include <climits>
#include <stack>
#include <iomanip>
#include <sstream>

using namespace std;

template <typename T>
inline bool sign(T A) {
    return (A>0)-(A<0);
}
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SREP(i,s,n) for(int i=s; (n-i)*sign(n-s)>0; i+=sign(n-s))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef unsigned long long ull;

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    if (b == 1) return 1;
    T r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

bool _less(pair<int, int> a, pair<int, int> b) {
    return a.second < b.second;
}

template <template<class,class,class...> class C, typename K, typename V, typename... Args>
V map_get(const C<K,V,Args...>& m, K const& key, const V & defval)
{
    typename C<K,V,Args...>::const_iterator it = m.find( key );
    if (it == m.end())
        return defval;
    return it->second;
}

#define MOD (1'000'000'000 + 7)



int main(void)
{
    ll N;
    cin >> N;
    vector<vector<ll>> E(N+1);
    vector<vector<ll>> n(N+1);
    vector<pair<ll, ll>> e(N-1);
    REP(i, N-1) {
        ll a, b;
        cin >> a >> b;
        E[a].push_back(b);
        E[b].push_back(a);
        n[a].push_back(i);
        n[b].push_back(i);
        e[i] = make_pair(a, b);
    }

    ll K = 0;
    REP(i, N)
    {
        K = max(K, ll(E[i].size()));
    }

    vector<ll> c(N - 1);
    queue<pair<ll, ll>> q;
    q.push(make_pair(1, 0));
    while (q.size())
    {
        auto node = q.front();
        q.pop();
        ll rc = node.second;

        ll col = 1;
        REP(i, E[node.first].size()) {
            if (col == rc) {
                col++;
            }
            if (c[n[node.first][i]] == 0) {
                c[n[node.first][i]] = col;
                q.push(make_pair(E[node.first][i], col));
                col++;
            }
        }
    }
    

    cout << K << endl;
    REP(i, N-1) {
        cout << c[i] << endl;
    }
}


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

int main() {
    int n;
    cin >> n;
    vector<ll> a(n+1);
    vector<ll> b(n);
    rep(i, n+1) cin >> a[i];
    rep(i, n) cin >> b[i];
    ll ans = 0;
    rep(i, n) {
        if (b[i] >= a[i]) {
            ans += a[i];
            b[i] -= a[i];
            a[i] = 0;
        }
        else {
            ans += b[i];
            a[i] -= b[i];
            b[i] = 0;
        }
        if (b[i] >= a[i+1]) {
            ans += a[i+1];
            b[i] -= a[i+1];
            a[i+1] = 0;
        }
        else {
            ans += b[i];
            a[i+1] -= b[i];
            b[i] = 0;
        }
    }
    cout << ans << endl;
}

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

int main(void){
  int a,b,c;
  cin>>a>>b>>c;
  if((a==5 && b==5 && c==7)||(a==5 && b==7 && c==5)||(a==7 && b==5 && c==5))
    cout<<"YES";
  else cout<<"NO";
  cout<<endl;
  return 0;
}

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

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

    int count = 0;
    int A = N;
    for(int i = 1; i < 10; i++){
        int n = A % 10;
        count += n;
        A /= 10;
    }

    if(N % count == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  int a, b, c;
  readf("%s %s %s\n", &a, &b, &c);
  auto ac = a - b;
  if (ac >= c) {
    writeln("0");
  } else {
    writeln(c - ac);
  }
}


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

int int_sort(const void *a, const void *b)
{
    return strcmp((char *)a, (char *)b);
}

int main()
{
    long int n, i, j;
    long int num;
    int val;
    char keywords[200000][11];
    char name[11];
    scanf("%ld", &n);

    for(i=0; i<n; i++)
    {
        scanf("%s", keywords[i]);
    }
    // sort
    qsort((void*)keywords, n, 11, int_sort);

    num = 1;
    for(i=1; i<n; i++)
    {
        if(strcmp(keywords[i], keywords[i-1]) != 0)
        {
            num++;
        }
    }
    printf("%ld\n", num);

    return 0;
}




Measured memory_bytes: 5740
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()
// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//CODE


template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;


vector<int> dijkstra(WeightedGraph<int> &G,int s)
{ 
  
  vector<int> path(G.size(),I64_MAX);
  path[s] = 0;
  priority_queue <pair<int,int> ,vector<pair<int,int> > ,greater<pair<int,int> > > que;

  que.emplace(path[s],s);

  while(!que.empty())
  {
    int cost;
    int idx;
    tie(cost,idx) = que.top();
    que.pop();

    if(path[idx] < cost) continue;
    for (auto &e: G[idx])
    {
      int next_cost = cost + e.cost;
      if(path[e.to] <= next_cost) continue;
      path[e.to] = next_cost;
      que.emplace(path[e.to],e.to);
    }
  }

  return path;
}
void solve(void)
{
  int x,a,b;
  cin>>x>>a>>b;
  if(abs(a-x) < abs(x-b))
  {
    cout<<"A"<<endl;
  }
  else
  {
    cout<<"B"<<endl;
  }
  
  return;
}


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

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();
  

 
  return 0;
}


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

int main() { 
    const int dx[4] = {1, 0, -1, 0};
    const int dy[4] = {0, 1, 0, -1};
    int h, w, ans = 0;
    cin >> h >> w;
    vector<string> s;
    s.push_back(string(w+2, '#'));   // 上端
    for(int i = 0; i < h; ++i) {
        string _s;
        cin >> _s;
        _s = '#' + _s + '#';  // 左右端
        s.push_back(_s);
    }
    s.push_back(string(w+2, '#'));  //　下端

    for(int sh = 1; sh <= h; ++sh) {
        for(int sw = 1; sw <= w; ++sw) {
            if(s[sh][sw] == '.') {
                queue<pair<int, int>> q;
                q.push({sh, sw});
                vector<vector<int>> dist(h+2, vector<int>(w+2, -1));
                dist[sh][sw] = 0;
                while(!q.empty()) {
                    int i = q.front().first, j = q.front().second;
                    q.pop();
                    int nowDist = dist[i][j];
                    ans = max(ans, nowDist);

                    for(int dir = 0; dir < 4; ++dir) {
                        int nx = i + dx[dir], ny = j + dy[dir];
                        if(s[nx][ny] == '#') continue;
                        if(dist[nx][ny] == -1) {
                            dist[nx][ny] = nowDist + 1;
                            q.push({nx, ny});
                        }
                    }
                }
            }
        }
    }
    
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256