akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

int main() {
    ll a,b,c;
    cin >> a >> b >> c;
    for (ll i=a;i<a*b;i+=a){
        if (i%b==c){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <unordered_map>


int main (void) {

  long long X, Y;
  std::cin >> X >> Y;

  std::vector<long long> t;
  t.push_back(X);

  while(1) {
    auto &x = t.back();
    if ( x * 2 > Y ) break;
    else t.push_back(x*2);
  }

  std::cout << t.size() << std::endl;
  return 0;
}

Measured memory_bytes: 256
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>

#pragma region _define

#define int LL
#define f(i,a,b) for(LL i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl
#define all(a) a.begin(),a.end()
#define size(s) s.size()
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl
#define INF 1<<29
#define R 1000000007

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vc = vector<char>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using si = stack<LL>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using v_pi = vector<pi>;

#pragma endregion

#pragma region _graph

#define node 50  //グラフの最大位数　適宜変更
//bool graph[node][node]; bool visited[node] = { false };
#define link(a,b,m) f(i,0,m){cin>>a[i]>>b[i]; a[i]--; b[i]--; graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;}

#pragma endregion

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		//ret %= 1000000007;
	}
	return ret;
}

#pragma endregion 

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

	st s;
	cin >> s;
	int ans = 0;
	int j = 0;
	f(i, 0, size(s)) {
		if (s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C') {
			j++;
			ans = max(ans, j);
			continue;
		}
		j = 0;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
def main():
    n = int(input())
    inputs = [input().split() for i in range(n)]
    inputs_list = []
    for i in inputs:
        if int(i[0]) - int(i[1]) < 0:
            inputs_list.append([0, int(i[0]) + int(i[1])])
        else:
            inputs_list.append([int(i[0]) - int(i[1]), int(i[0]) + int(i[1])])
    sorted_data = sorted(inputs_list, key=lambda x: (x[1]))

    ans = [sorted_data[0]]
    cur = ans[0][1]
    for i in range(len(sorted_data) - 1):
        if cur <= sorted_data[i + 1][0]:
                ans.append(sorted_data[i + 1])
                cur = sorted_data[i + 1][1]
    print(len(ans))


if __name__ == '__main__':
    main()


Measured memory_bytes: 52064
N, K = map(int, input().split())
A = list(map(int, input().split()))

Rewards_0, Rewards_1 = [], []  # i桁目を0 or 1にしたときの報酬
for i in range(40):
    reward_0, reward_1 = 0, 0
    for a in A:
        if a & (2 ** i):
            reward_0 += 2 ** i
        elif 2 ** i <= K:
            reward_1 += 2 ** i
    Rewards_0.append(reward_0)
    Rewards_1.append(reward_1)

dp0 = [0] * 41  # K以下か未確定
dp1 = [0] * 41  # K以下であることが確定

for i in reversed(range(40)):
    if K & (2 ** i):
        dp0[i] = dp0[i + 1] + Rewards_1[i]
        dp1[i] = dp0[i + 1] + Rewards_0[i]
    else:
        dp0[i] = dp0[i + 1] + Rewards_0[i]

    if dp1[i + 1] != 0:
        dp1[i] = max(dp1[i], dp1[i + 1] + max(Rewards_0[i], Rewards_1[i]))

print(max(dp0[0], dp1[0]))


Measured memory_bytes: 69348
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int counts[][] = new int[2][100001];
		for(int i = 0; i < num; i ++) {
			counts[i % 2][sc.nextInt()] ++;
		}
		int maxCount[][] = {{0, 0}, {0, 0}};
		int maxNumber[] = {0, 0};
		for(int i = 1; i <= 100000; i ++) {
			for(int j = 0; j < 2; j ++) {
				if(counts[j][i] > maxCount[j][0]) {
					maxCount[j][1] = maxCount[j][0];
					maxCount[j][0] = counts[j][i];
					maxNumber[j] = i;
				}else if(counts[j][i] > maxCount[j][1]) {
					maxCount[j][1] = counts[j][i];
				}
			}
		}
		int ans = num;
		if(maxNumber[0] == maxNumber[1]) {
			ans -= Math.max(maxCount[0][0] + maxCount[1][1], maxCount[0][1] + maxCount[1][0]);
		}else {
			ans -= maxCount[0][0] + maxCount[1][0];
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 59120
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <set>
#include <numeric>

#include <map>
#include <math.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <bitset>
#include <math.h>

#define INF 100100100

typedef long long int llint;

using namespace std;

typedef pair<int, int>Pii;

#define pi 3.141592653589793
#define mod 1000000007

vector<int>a;

int main() {
	int n;
	cin >> n;
	vector<int>a(n);
	for (int i = 0; i < n; i++)cin >> a[i];
	int req = a[0];
	for (int i = 1; i < n; i++) {
		if (req == 2) {
			cout << i << endl;
			return 0;
		}
		req = a[req-1];
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 640
// by adiforluls
#pragma GCC optimize ("-O2")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define FAST            ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll              long long
#define ld              long double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define all(a)          (a).begin(),(a).end()
#define clz(a)          __builtin_clz(a) // count leading zeroes
#define ctz(a)          __builtin_ctz(a) // count trailing zeroes
#define popc(a)         __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define rep(i,a,b)      for(int i=a;i<b;i++)
#define rfor(i,a,b)     for(int i=a; i>=b; i--)
#define debug(x)        cerr << #x << " = " << x << endl;
#define F               first
#define S               second
#define endl            '\n'
#define SIZE            1000005
#define deci(n)         cout<<fixed<<setprecision(n)
#define ordered_set     tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key(k)
// find_by_order(k)
const ld PI = acos(-1.0);
const int INF = 0x3f3f3f3f;
const ll lul2 = 998244353;
const ll lul = 1000000007;

void mod(ll &x)
{
    if(x>=lul) x-=lul;
    if(x<0) x+=lul;
}

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

ll expo(ll n, ll p)
{
    if(p == 0) return 1;
    ll x = expo((n*n)%lul, p/2)%lul;
    if(p&1) return (x*n)%lul;
    return x;
}
//---------------------------------------------------------------------

void solve()
{
    int n,l; cin>>n>>l;
    int a[n];
    rep(i,0,n) cin>>a[i];
    int ans = -1;
    rep(i,0,n-1)
    {
        if(a[i]+a[i+1]>=l) ans = i+1;
    }
    if(ans == -1) {cout<<"Impossible"; return;}
    vector<int> order;
    rep(i,1,n)
    {
        if(i == ans) break;
        order.pb(i);
    }
    rfor(i,n-1,1)
    {
        if(i == ans) break;
        order.pb(i);
    }
    order.pb(ans);
    cout<<"Possible"<<endl;
    for(int i:order) cout<<i<<endl;
}
int main()
{   
    FAST;
   //  #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
   //  #endif
    int t; t=1;
    rep(i,1,t+1){
        solve();
    }
    return 0;
}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int cost[333][333];

int dp[333][333];

int H,W;
int calc(string S,string T){
    fill_n(*dp,333*333,1001001001);
    memset(cost,0,sizeof(cost));

    for(int d=0;d<H;d++){
        int c=0;
        int cc=0;
        for(int i=H-1;i>=d;i--){
            if(S[i-d]==T[i])c++;
            cost[i-d][i]=c;
            if(S[i]==T[i-d])cc++;
            cost[i][i-d]=cc;
        }
    }

    dp[0][0]=0;
    for(int i=0;i<=H;i++){
        for(int j=0;j<=H;j++){
            if(i!=H)chmin(dp[i+1][j],dp[i][j]+cost[i][j]);
            if(j!=H)chmin(dp[i][j+1],dp[i][j]+cost[i][j]);
        }
    }
    return dp[H][H];
}

signed main(){
    cin>>H>>W;
    vector<string>vec(H);
    rep(i,H)cin>>vec[i];

    int ans=0;
    for(int i=0;i<W-1;i++){
        string S,T;
        for(int j=H-1;j>=0;j--){
            S+=vec[j][i];
            T+=vec[j][i+1];
        }
        ans+=calc(S,T);
    }

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


Measured memory_bytes: 2304
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>
#include<queue>
using namespace std;

vector<pair<int, int> > edge[401];
int dp[401];
int n;

int main()
{
  int m;
  for(;cin>>n>>m;)
    {
      // node[i][0]=in,[1]=max
      int node[n+1][2];
      vector<pair<int,int> > edge[n+1];

      memset(node,0,sizeof(node));
      int a,b,c;
      for (int i=0; i < m; i++) {
        cin>>a>>b>>c;
        node[b][0]++;
        edge[a].push_back(make_pair(b,c));
      }
      queue<int> qu;

      /*      for (int i=0; i < edge[0].size(); i++) {
        node[edge[0][i].first][0]--;
        if(node[edge[0][i].first][0]<=0)
          qu.push(edge[0][i].first);
        node[edge[0][i].first][1]=max(node[edge[0][i].first][1],
                                      edge[0][i].second);
                                      }*/
      qu.push(0);

      for(;!qu.empty();)
        {
          int now=qu.front();
          qu.pop();

          for (int i=0; i < edge[now].size(); i++) {
            int next = edge[now][i].first;
            node[next][0]--;
            if(node[next][0]<=0)
              qu.push(next);
            node[next][1]=max(node[next][1],
                              node[now][1]+edge[now][i].second);
          }
        }
      cout<<node[n-1][1]<<endl;

    }
}

Measured memory_bytes: 1240
from bisect import bisect_left

N, M, V, P = map(int, input().split())
A = list(map(int, input().split()))
A.sort()

B = [0] * N
B[0] = A[0]
for i in range(1, N):
    B[i] = B[i - 1] + A[i]

if V <= P:
    tmp = bisect_left(A[:-P], A[-P] - M)
    print (N - tmp)
    exit()

v = V - (P - 1) #P-1個は関係ないところですでに使用済み

#大丈夫かどうかの確認
def check(x):
    if A[x] + M < A[-P]:
        return False
    if v - 1 <= x:
        return True
    
    zan = M * (v - (x + 1))
    # print ('zan', zan)
    if x > 0:
        used = B[-P] - B[x]
    else:
        used = B[-P]
    # print ('used', used)
    if (A[x] + M) * ((N - P) - x) - used >= zan:
        return True
    return False     

#二分探索の初期値
l = 0
r = N - P
while r - l > 1:
    # print (l, r)
    # s = str(input())
    mid = (l + r) // 2
    if check(mid):
        r = mid
    else:
        l = mid
# print (A)
# print (B)
if check(l):
    print (N - l)
    exit()
if check(r):
    print (N - r)

# for i in range(N - P):
#     print (i, check(i))

# print ('v', v)

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

using LL = long long;

void solve(auto A, auto B, auto C, auto D) {
  auto K = (A+B) / (min(A,B)+1);
  auto l = 0ll;
  auto h = A+B+1;
  while(l+1 < h) {
    auto a = (l+h) / 2;
    auto b = max(0ll, (a-1)/K);
    if(B-b <= (A-a+1)*K) l = a;
    else                 h = a;
  }
  auto x = l + max(0ll, (l-1)/K);
  for(auto i = C; i <= min(x,D); ++i) {
    if(i%(K+1)) cout << "A";
    else        cout << "B";
  }
  for(auto i = max(x+1,C); i <= D; ++i) {
    auto j = A+B-(i-1);
    if(j%(K+1)) cout << "B";
    else        cout << "A";
  }
  cout << endl;
}

int main() {
  int Q;
  cin >> Q;
  for(auto i = 0; i < Q; ++i) {
    LL A, B, C, D;
    cin >> A >> B >> C >> D;
    solve(A, B, C, D);
  }
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>


#define fs first
#define sc second

using namespace std;


typedef long long ll;
typedef pair<ll, ll> P;


int main(){
    int N, K;
    cin >> N >> K;
    if(K == 1){
        cout << 0 << endl;
    }
    else {
        cout << N - K << endl;
    }


    return 0;
}


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

int main() {
    int n, k, x, y;
    cin >> n >> k >> x >> y;
    int sum = 0;
    if (n <= k) {
        sum = n * x;
    } else {
        sum = k * x;
        sum += (n - k) * y;
    }

    cout << sum;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int K, N;
	int* A;
	int p;
	int result_1;
	int R;

	cin >> K;
	cin >> N;

	R = K;

	A = (int*)malloc(N * sizeof(int));

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

	//スタート地点
	for (int i = 0; i < N; i++) {
		if (i > 0) {
			result_1 = K - A[i] + A[i - 1];
		}
		else {
			result_1 = A[N - 1] - A[i];
		}

		if (R > result_1) R = result_1;
	}

	cout << R;

	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int n,m,cnt[2][2];
int deg[100005],id[100005];
vector < int > ele[100005],adj[100005],vs;
bool vis[100005];
bool dfs(int v,int f,int st){
	int i;
	if(vis[v]) return 0;
	if(id[v]!=-1 && f!=-1){
		++cnt[st][id[v]];
		return 1;
	}
	if(id[v]==-1) vis[v]=1;
	for(i=0;i<(int)adj[v].size();++i){
		int u=adj[v][i];
		if(u!=f && (id[v]==-1 || id[u]==-1)){
			if(dfs(u,v,st)) return 1;
		}
	}
	return 0;
}
int main(){
  	int i,j,k;
  	scanf("%d%d",&n,&m);
  	for(i=0;i<m;++i){
    	int u,v;
      	scanf("%d%d",&u,&v);
      	--u;--v;
		adj[u].push_back(v);
		adj[v].push_back(u);
      	++deg[u];
      	++deg[v];
    }
	bool OK=0;
	memset(id,-1,sizeof(id));
	for(i=0;i<n;++i){
		if(deg[i]&1){
			printf("No\n");
			return 0;
		}
		if(deg[i]>=6) OK=1;
		if(deg[i]==4){
			id[i]=(int)vs.size();
			vs.push_back(i);
		}
	}
	if(OK || vs.size()>2)
		printf("Yes\n");
	else if(vs.size()<2)
		printf("No\n");
	else{
		for(i=0;i<(int)adj[vs[0]].size();++i){
			if(adj[vs[0]][i]==vs[1]) ++cnt[0][1];
		}
		while(dfs(vs[0],-1,0));
		while(dfs(vs[1],-1,1));
		if(cnt[0][0]+cnt[1][1]+(cnt[0][1]+cnt[1][0])/2>=3)
			printf("Yes\n");
		else
			printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 10880
using System;

namespace ABC168
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var A = int.Parse(input[0]);
            var B = int.Parse(input[1]);
            var H = int.Parse(input[2]);
            var M = int.Parse(input[3]);

            var angleA = H * 30 + (double)M / 2;
            var angleB = M * 6;

            var answer = Distance(A, B, angleA, angleB);
            System.Console.WriteLine(answer);
        }

        static double Distance(int A, int B, double angleA, double angleB)
        {
            var angle = Math.Abs(angleA - angleB) * Math.PI / 180;
            var distance = A * A + B * B - 2 * A * B * Math.Cos(angle);
            return Math.Sqrt(distance);
        }
    }
}


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

using namespace std;
using i64 = std::int_fast64_t;

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

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

  vector<vector<pair<i64, i64>>> G(N);
  for (int i = 0; i < N - 1; i++) {
    i64 a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    G[a].emplace_back(make_pair(b, c));
    G[b].emplace_back(make_pair(a, c));
  }

  int Q, K;
  cin >> Q >> K;
  K--;

  vector<i64> D(N, 1LL << 58);
  priority_queue<pair<i64, i64>, vector<pair<i64, i64>>,
                 greater<pair<i64, i64>>>
      que;

  que.push(make_pair(0, K));
  D[K] = 0;

  while (!que.empty()) {
    auto q = que.top();
    que.pop();

    int u = q.second;
    if (D[u] < q.first) continue;

    for (auto p : G[u]) {
      int v = p.first;
      i64 c = p.second;
      if (chmin(D[v], D[u] + c)) {
        que.push(make_pair(D[v], v));
      }
    }
  }

  for (int i = 0; i < Q; i++) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    cout << D[x] + D[y] << '\n';
  }
  return 0;
}


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

int main(){
  int k,s;
  cin >> k >> s;
  int ans = 0;
  for(int x=0;x<=k;x++){
    for(int y=0;y<=k;y++){
      if(s-x-y>=0 && s-x-y<=k)ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

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

typedef long long ll;

void maxHeap(vector<ll> &h, int i){
    int sub = i+1;
    int left = sub*2-1;
    int right = sub*2;
    int largest = sub-1;
    if(left <= h.size() && h[left] > h[largest]) largest = left;
    if(right <= h.size() && h[right] > h[largest]) largest = right;

    if(largest != i){
        swap(h[largest],h[i]);
        maxHeap(h,largest);
    }
}

void buildMaxHeap(vector<ll> &heap, int h){
    for(int i=h/2;i>=0;i--){
        maxHeap(heap, i);
    }
}

void print(const vector<ll> &h){
    for(ll a : h) cout << " " << a;
    cout << "\n";
}

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

    vector<ll> heap;
    int h;
    cin >> h;
    ll a;
    for(int i=0;i<h;i++){
        cin >> a;
        heap.push_back(a);
    }

    buildMaxHeap(heap,h);
    print(heap);
    return 0;
}



Measured memory_bytes: 6972
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <utility>
#include <random>
#include <chrono>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//const int mod = 1e9+7;
typedef __int128 bint;
const int N = 1e5+10;
bint a[N];

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main()
{
    quickread();
    int n;
    cin >> n;
    bint res = 1;
    ll num;
    for(int i = 0; i < n; i ++) {
        cin >> num;
        a[i] = num;
    }
    sort(a, a+n);
    for(int i = 0; i < n; i ++) {
        res *= a[i];
        if(res > 1000000000000000000) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << (ll)res << endl;
    return 0;
}


Measured memory_bytes: 5184
#include <stdio.h>

int main(void) {
	int cnt[26] = {0};
	char w[101];
	
	scanf("%s",w);
	
	for (int i = 0;w[i] != '\0';i++) {
		cnt[w[i]-'a']++;
	}

	for (int i = 0;i < 26;i++) {
		if (cnt[i] % 2) {
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");

	return 0;
}


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

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

        int start = 0;
        int cnt = 0;
        while (1) {
                size_t t = S.find("ABC", start);
                if (t == -1) {
                        break;
                }
                cnt++;
                start = t + 3;
        }
        cout << cnt << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int A,B,C;
    scanf("%d" , &A);
    scanf("%d" , &B);
    scanf("%d" , &C);
    if(A <= C){
      if(C <= B){
        printf("Yes");
        return 0;
      }
    }
    printf("No");
    return 0;
}


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

int main()
{
    int N;
    string S[100];
    int color[4];
    int sum = 0;

    cin >> N;

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

    for (int i = 0; i < N; i++){
        if (S[i] == "Y"){
            cout << "Four" << endl;
            return (0);
        }
    }
    cout << "Three" << endl;
    return (0);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
#include <tuple>
using namespace std;

int main(){
  int N, M, K;
  cin >> N >> M >> K;
  vector<vector<pair<int,int>>> G(N);
  for(int i = 0; i < M; ++i){
    int u, v, l;
    cin >> u >> v >> l;
    --u,--v;
    G[u].emplace_back(l,v);
    G[v].emplace_back(l,u);
  }
  const long long INF = 1e18;
  vector<long long> D(N,INF);
  priority_queue<pair<long long,int>> Q;
  for(int i = 0; i < K; ++i){
    int s;
    cin >> s;
    --s;
    D[s] = 0;
    Q.emplace(0,s);
  }
  while(Q.size()){
    int v;
    long long d;
    tie(d,v) = Q.top();
    d *= -1;
    Q.pop();
    if(D[v] < d) continue;
    for(auto e : G[v]){
      long long d_ = d+e.first;
      if(D[e.second] > d_){
        D[e.second] = d_;
        Q.emplace(-d_,e.second);
      }
    }
  }
  long long ans = 0;
  for(int i = 0; i < N; ++i){
    ans = max<double>(ans,D[i]);
    for(auto e : G[i]){
      int v = e.second;
      long long l = e.first;
      if(min(D[i],D[v])+l == max(D[i],D[v])) continue;
      long long t = D[i]+(D[v]-D[i]+l+1)/2;
      // cerr << i << " " << v << " -> " << t << endl;
      ans = max(ans,t);
    }
  }
  cout << ans << endl;
}



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

int main() {
	int N;
	cin >> N;
	vector<int> H(N);

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

	bool yes = true;

	for (int i = N - 1; i > 0; i--) {
		if (H[i - 1] > H[i] + 1) {
			yes = false;
			break;
		}
		else if (H[i - 1] == H[i] + 1) {
			H[i - 1] = H[i];
		}
	}

	for (int i = 1; i < N; i++) {
		if (H[i - 1] > H[i]) {
			yes = false;
			break;
		}
	}

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

	return 0;
}

Measured memory_bytes: 768
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val N = nextInt()
    val A = nextLongList().sorted()
    var cnt = 0
    var sum = A[0]
    for (i in 1 until N) {
        if (sum * 2 < A[i]) {
            cnt = i
        }
        sum += A[i]
    }
    println(N - cnt)
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(a, b) << " " << max(0, a + b - n) << endl;
    
    return 0;
}



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

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

  int i, n, a, b, c;
  vector<int> triangle;
  cin >> n;

  for (i = 0; i < n; i++) {
    cin >> a;
    cin >> b;
    cin >> c;
    triangle.push_back(a);
    triangle.push_back(b);
    triangle.push_back(c);

    sort(triangle.begin(), triangle.end());
    if (triangle.at(0) * triangle.at(0) + triangle.at(1) * triangle.at(1) == triangle.at(2) * triangle.at(2)) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }

    triangle.clear();
  }

  return 0;
}

Measured memory_bytes: 1216
# from collections import defaultdict

n, m = map(int, input().split())
high = [int(i) for i in input().split()]
# a_b = [[int(i) for i in input().split()] for i in range(m)]

high_d = {}
for i in range(n):
    # d = defaultdict(list)
    high_d[i+1] = high[i]
# print(high_d)

d = {}
for _ in range(m):
    a, b = map(int, input().split())
    if a not in d:
        d[a] = [b]  # リストにし忘れ
    else:
        d[a].append(b)
    if b not in d:
        d[b] = [a]  # リストにし忘れ
    else:
        d[b].append(a)


# print(d)
cnt = 0
for i, li in d.items():
    # [a].append(b)
    is_true = True
    for j in li:
        if high_d[i] > high_d[j]:
            continue
        else:
            is_true = False
    if is_true:
        cnt += 1

cnt += n - len(d)

print(cnt)


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

using namespace std;
int a[100005][5], p[100005][5];

int main()
{
    int n, i, j;
    cin>>n;
    for (i=0;i<n;i++)
    {
        for(j=0;j<3;j++)
        {
            cin>>a[i][j];
        }
    }
    for(i=0;i<n;i++)
    {
        for(j=0;j<3;j++)
        {
            if(i==0)
            {
                p[i][j]=a[i][j];
            }
            else if(j==0)
            {
                p[i][j]=a[i][j]+max(p[i-1][1],p[i-1][2]);
            }
            else if(j==1)
            {
                p[i][j]=a[i][j]+max(p[i-1][0],p[i-1][2]);
            }
            else if(j==2)
            {
                p[i][j]=a[i][j]+max(p[i-1][1],p[i-1][0]);
            }
        }
    }
    n--;
    cout<<max(p[n][0],max(p[n][1],p[n][2]))<<"\n";

    return 0;
}


Measured memory_bytes: 4096
import bisect
m = int(input())
a = list(map(int,input().split()))
a.sort()

if a[-1] <= 0: #ok
    a1 = -(sum(a)) + 2 * a[-1]
    print(a1)
    p = a[-1]
    q = a[-2]
    for i in range(-1,-(len(a)),-1):
        print(str(p)+ " " + str(q))
        if i == -(len(a) -1):
            break
        p = p - q
        q = a[i-2]
elif a[0] >= 0:
    print(sum(a[1:]) - a[0])
    p = a[0]
    q = a[1]
    for i in range(len(a)-1):
        print(str(p)+" "+str(q))
        p = p - q
        if i + 2 > len(a) - 2:
            break 
        q = a[i+2]
    print(str(a[-1])+" "+str(p))
else:
    c = bisect.bisect_left(a,0)
    c1 = 0
    for x in a:
        c1 += abs(x)
    print(c1)
    p = a[c-1]
    q = a[c]
    for i in range(c,m-1):
        print(str(p)+" "+str(q))
        p = p - q
        q = a[i+1]
    p1 = a[-1]
    q1 = a[0]
    for i in range(c-1):
        print(str(p1)+" "+str(q1))
        p1 = p1 - q1
        q1 = a[i+1]
    print(str(p1)+ " "+str(p))

Measured memory_bytes: 58964
import heapq
W, H = map(int, input().split())
Q = []
for _ in range(W):
  p = int(input())
  heapq.heappush(Q, [p, 0])
for _ in range(H):
  q = int(input())
  heapq.heappush(Q, [q, 1])
cnt = 0
L = [H + 1, W + 1]
while Q:
  c, l = heapq.heappop(Q)
  cnt += c * L[l]
  L[1 - l] -= 1
print(cnt)

Measured memory_bytes: 31988
#include <iostream>

int main()
{
    int W, H, x, y, r;
    
    std::cin >> W >> H >> x >> y >> r;
    
    if(0 <= x - r && x + r <= W
    && 0 <= y - r && y + r <= H){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
    return 0;
}

Measured memory_bytes: 3088
n, t = list(map(int, input().split()))
dishes = [list(map(int, input().split())) for _ in range(n)]

dishes.sort(key = lambda x: (x[0], -x[1]))
#print(dishes)

# dp[i][j]はi番目までの品物から時間の和がj以下なるように選んだときの価値の和の最大値を表す。
dp = [[-1 for _ in range(t + 1)] for _ in range(n + 1)]

for j in range(t):
	dp[0][j] = 0

for i in range(n):
	for j in range(t):
		if j - dishes[i][0] >= 0:
			dp[i + 1][j] = max(dp[i][j], dp[i][j - dishes[i][0]] + dishes[i][1])
		else:
			dp[i + 1][j] = dp[i][j]
	dp[i + 1][t] = max(dp[i][t], dp[i][t - 1] + dishes[i][1])

#print(dp)
print(dp[-1][-1])

Measured memory_bytes: 123992
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr int INF = 1e9;
int main() {
  string s;
  cin >> s;
  int n = sz(s);
  set<int> r, l;
  for (int i = 0; i < n; i++) {
      if (s[i] == 'R') r.insert(-i);
      else l.insert(i);
  }
  vector<int> res(n,0);
  for (int i = 0; i < n; i++) {
      if (s[i] == 'R') {
        auto itr = l.lower_bound(i);
        
        int d = (*itr) - i;
        int id = (*itr) - (d & 1);
        res[id]++;
        } else {
        auto itr = r.lower_bound(-i);
        
        int d = i + (*itr);
        int id = -1 * (*itr) + (d & 1);
        res[id]++;
      }
  }
  for (int i = 0; i < n; i++) cout << res[i] << " ";
  cout << endl;
  return 0;
} 

Measured memory_bytes: 5632
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int n, m; cin >> n >> m;
    vector<int> diffs(n+1);
    for(int i=0; i<m; ++i){
        int l, r; cin >> l >> r;
        --l; --r;
        ++diffs[l];
        --diffs[r+1];
    }
    int ans=0;
    int sum=0;
    for(int i=0; i<n; ++i){
        sum+=diffs[i];
        if(sum==m) ++ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
li = []
li.append(a)
li.append(b)
li.append(c)
li.append(d)
li.append(e)

ans = []
sum_a = 0
for i in li:
  num = i % 10
  sum_a += i
  if num == 0:
    ans.append(0)
  else:
    ans.append(10-num)
num_a = sum_a + sum(ans) - max(ans)
print(str(num_a))


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

class ABC123B{
    public static void Main(){
        var ae = new List<int>();
        ae.Add(int.Parse(Console.ReadLine()));
        ae.Add(int.Parse(Console.ReadLine()));
        ae.Add(int.Parse(Console.ReadLine()));
        ae.Add(int.Parse(Console.ReadLine()));
        ae.Add(int.Parse(Console.ReadLine()));
        var ae2 = new List<int>();
        ae.ForEach(x=>ae2.Add(10-x%10));
        ae2.RemoveAll(x=>x==10);
        if(ae2.Count != 0)ae2.Remove(ae2.Max());
        Console.WriteLine(ae.Sum()+ae2.Sum());
    }
}

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

int main() {
	int N;
	int k;
	cin >> N;
	cin >> k;
	int r = 0;
	int sum = 0;
    char a[N+1];
    for(int i = 1; i <= N; i++)
    cin >> a[i];
    for(int i = 1; i <= N; i++)
    {
    	if (a[i] == a[i+1])
     	sum++;
    	if ((a[i+1] != a[i]) && (i != N))
    	r++;
    }
    if((r+1)/2>k)
    sum += k*2;
    else 
    sum+=r;
	cout << sum;
	return 0;
}

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

int	main()
{
	string	S;
	cin >> S;
	int	size = S.size();
	if (size == 3) {
		if (S.at(0) == S.at(2)) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
		return 0;
	}
	for (int i = 0; i < (size - 1) / 4; ++i) {
		if (S.at(i) == S.at(size - 1 - i) &&
			S.at(i) == S.at((size - 1) / 2 - 1 - i) &&
			S.at(i) == S.at((size - 1) / 2 + 1 + i))
			continue;
		cout << "No" << endl;
		return 0;
	}
	if ((size - 1) / 2 % 2 == 1) {
		if (S.at((size - 1) / 4) != S.at(size - 1 - (size - 1) / 4)) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

LL big_mod(LL val,LL pow,LL mod);
LL mod_inverse(LL val,LL mod);






int main()
{
//    FAST();

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

    int a,b;
    S("%d %d",&a,&b);
    if(a > 12)
    {
        P("%d",b);
    }
    else if(a > 5)
    {
        P("%d",b/2);
    }
    else
    {
        P("0");
    }
    return 0;
}







LL big_mod(LL val,LL pow,LL mod)
{
    LL res = 1;
    val = val % mod;
    while(pow > 0)
    {
        if(pow & 1)
        {
            res = (res*val) % mod;
        }
        pow = pow >> 1;
        val = (val*val) % mod;
    }
    return res;
}

LL mod_inverse(LL val,LL mod)
{
    LL mod1 = mod;
    if(mod == 1)
    {
        return 0;
    }
    LL y = 0;
    LL x = 1;
    LL quotient,temp;
    while(val > 1)
    {
        quotient = val / mod;
        temp = mod;
        mod = val % mod;
        val = temp;
        temp = y;
        y = x - quotient * y;
        x = temp;
    }
    if(x < 0)
    {
        x += mod1;
    }
    return x;
}


Measured memory_bytes: 256
import java.util.*;
class Main{
 public static void main(String[] args){
  Scanner sc = new Scanner(System.in);
   int N = sc.nextInt();
    switch(N%10){
      case 3:System.out.println("bon");break;
      case 0:case 1:case 6:case 8:System.out.println("pon");break;
      default:System.out.println("hon");break;
    }
  }
}

Measured memory_bytes: 35640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;
using static Read;

class Program
{
    public static void Main()
    {
        var a = Int();
        var o = String();
        var b = Int();
        if(o == "+")
        {
            WriteLine($"{a + b}");
        }
        else
        {
            WriteLine($"{a - b}");
        }
    }
}

static class Read
{
    static Queue<string> queue = new Queue<string>();
    static void Enqueue()
    {
        ReadLine().Split(' ').ToList().ForEach(a => queue.Enqueue(a));
    }
    public static int Int()
    {
        if(queue.Count == 0)
            Enqueue();
        return int.Parse(queue.Dequeue());
    }
    public static long Long()
    {
        if(queue.Count == 0)
            Enqueue();
        return long.Parse(queue.Dequeue());
    }
    public static double Double()
    {
        if(queue.Count == 0)
            Enqueue();
        return double.Parse(queue.Dequeue());
    }
    public static string String()
    {
        if(queue.Count == 0)
            Enqueue();
        return queue.Dequeue();
    }
    public static int[] IntArray()
    {
        return ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
    }
    public static long[] LongArray()
    {
        return ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();
    }
    public static double[] DoubleArray()
    {
        return ReadLine().Split(' ').Select(a => double.Parse(a)).ToArray();
    }
    public static string[] StringArray()
    {
        return ReadLine().Split(' ');
    }
}


Measured memory_bytes: 11348
#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10;

int n, k;
int a[nax];
long long s[nax];

void change (int * a) {
    for (int i = 1 ; i <= n ; ++ i)
        s[i] = 0;
    for (int i = 1 ; i <= n ; ++ i) {
        int l = max(i - a[i], 1);
        int r = min(i + a[i], n);
        s[l] ++;
        s[r + 1] -- ;
    }

    for (int i = 1 ; i <= n ; ++ i) {
        s[i] += s[i - 1];
        a[i] = min(s[i], (long long)n);
    }
}

int main () {
    scanf("%d %d", &n, &k);
    for (int i = 1 ; i <= n ; ++ i) {
        scanf("%d", a + i);
    }

    int op = 0;
    for (int i = 1 ; i <= k ; ++ i) {
        change(a);
        bool ok = true;
        ++ op;
        for (int j = 1 ; j <= n ; ++ j) {
            ok &= (a[j] == n);
        }

        if (ok) break;
    }

    //fprintf(stderr, "op %d\n", op);

    for (int i = 1 ; i <= n ; ++ i)
        printf("%d ", a[i]);
}
/*
    Good Luck
        -Lucina
*/


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

using namespace std;
long long mem[303][303][303];
int n;
int h[303];

long long solve(int ind, int prv, int k) {
    if (ind == n + 1) return 0;

    long long &ret = mem[ind][prv][k];
    if (~ret) return ret;
    ret= 1e18;
    if (k)
        ret = solve(ind + 1, prv, k - 1);

    long long dif = max(h[ind] - h[prv], 0);
    ret = min(ret, solve(ind + 1, ind, k) + dif);

    return ret;
}

int main() {
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
#endif
    memset(mem, -1, sizeof(mem));
    int k;
    scanf("%d %d", &n, &k);
    for(int i=1; i<=n; i++)
        scanf("%d", h + i);

    printf("%lld\n", solve(1, 0, k));
    return 0;
}

Measured memory_bytes: 217600
#include <iostream>
#include <algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
    int sx,sy,tx,ty; cin>>sx>>sy>>tx>>ty;
    rep(i,ty-sy) cout<<'U';
    rep(i,tx-sx) cout<<'R';
    rep(i,ty-sy) cout<<'D';
    rep(i,tx-sx+1) cout<<'L';
    rep(i,ty-sy+1) cout<<'U';
    rep(i,tx-sx+1) cout<<'R';
    cout<<'D'<<'R';
    rep(i,ty-sy+1) cout<<'D';
    rep(i,tx-sx+1) cout<<'L';
    cout<<'U';
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
typedef pair<string,string> Ps;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	// 1 変数を入れる
	int x,y,cost;
};
ll s[101]={},s2[101]={},s3[101]={},s4[101]={};

int main() {

	int n;
	ll w;
	cin>>n>>w;
	int w1=2,w2=1,w3=1,w4=1;
	ll W,u;
	cin>>W>>u;
	s[1]=u;
	rep(i,n-1){
		ll x,y;
		cin>>x>>y;
		if(x==W){
			s[w1]=y;
			w1++;
		}
		if(x==W+1){
			s2[w2]=y;
			w2++;
		}
		if(x==W+2){
			s3[w3]=y;
			w3++;
		}
		if(x==W+3){
			s4[w4]=y;
			w4++;
		}
	}
	sort(s,s+w1,greater<ll>());
	sort(s2,s2+w2,greater<ll>());
	sort(s3,s3+w3,greater<ll>());
	sort(s4,s4+w4,greater<ll>());

	ll i1=0,ma=0,u1=0;
	rep(i,w1){
		ll i2=0,u2=0;
		u1+=s[i];
		i1+=W;
		if(i==w1-1){
			i1=0;
			u1=0;
		}
		rep(j,w2){
			ll i3=0,u3=0;
			u2+=s2[j];
			i2+=W+1;
			if(j==w2-1){
				i2=0;
				u2=0;
			}
			rep(k,w3){
				ll i4=0,u4=0;
				u3+=s3[k];
				i3+=W+2;
				if(k==w3-1){
					i3=0;
					u3=0;
				}
				rep(l,w4){
					u4+=s4[l];
					i4+=W+3;
					if(l==w4-1){
						i4=0;
						u4=0;
					}
					if(i1+i2+i3+i4<=w){
						ma=max(ma,u1+u2+u3+u4);
					}
				}
			}
		}
	}
	cout<<ma<<endl;

	return 0;
}


Measured memory_bytes: 256
N, Y = gets.chomp.split(" ").map(&:to_i)

count = 0
catch(:break_loop) do
  (0..N).each {|ten|
    (0..N-ten).each{|five|
      if 10000*ten + 5000*five + 1000*(N-ten-five) == Y
        puts "#{ten} #{five} #{N-ten-five}"
        count += 1
        throw :break_loop
      end
    }
  }
end
  
if count == 0
  puts "-1 -1 -1"
end


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

using namespace std;
int main(){
 long int A,B,K;
 cin >> A >> B >> K;
 long int ta,ao;

if(A >= K){
  ta = A-K;
  ao = B;
}
else if(A+B-K>=0){
  ta = 0;
  ao = B-K+A;
}
else{
  ta = 0;
  ao = 0;
}

cout << ta << " "<< ao;

}

Measured memory_bytes: 256
rgb = [ int(x) for x in input().split() ]
n = rgb.pop()
r,g,b = sorted( rgb,key=lambda x:-x )

cnt= 0
for i in range( int(n/r)+1 ):
    m = n - r * i
    for j in range( int(m/g)+1 ):
        l = m - g * j
        if l%b==0: cnt+=1
#
print( cnt )

Measured memory_bytes: 3064
a, b, k = input().split()
A = int(a)
B = int(b)
K = int(k)
for i in range(K):
  if i%2 == 0:
    if A%2 == 1:
      A -= 1
    B += A/2
    A -= A/2
  else:
    if B%2 == 1:
      B -= 1
    A += B/2
    B -= B/2
ans1 = str(int(A))
ans2 = str(int(B))
print(ans1 + " " + ans2)

Measured memory_bytes: 3064
H,W = map(int,input().split())

S = [[True]*(W+2)]
S += [[True] + [x == '#' for x in input().rstrip()] + [True] for _ in range(H)]
S.append([True]*(W+2))

dx = [0,0,1,-1]
dy = [1,-1,0,0]

edge = []
for i in range(1,H+1):
    for j in range(1,W+1):
        if S[i][j]:
            continue
        for d in range(4):
            x = dx[d]
            y = dy[d]
            if (not S[i+y][j+x]) and (not ((i+y-1)*W+(j+x),(i-1)*W+j) in edge):
                edge.append(((i-1)*W+j,(i+y-1)*W+(j+x)))

S = [[float("inf")] * (H*W) for _ in range(H*W)]
for i in range(H*W):
    S[i][i] = 0
for a,b in edge:
    S[a-1][b-1] = 1
    S[b-1][a-1] = 1

from scipy.sparse.csgraph import floyd_warshall
S = floyd_warshall(S)

answer = 0
for i in range(H*W):
    for j in range(i):
        if S[i][j] < float("inf"):
            answer = max(answer, S[i][j])

print(int(answer))

Measured memory_bytes: 22424
#include <stdio.h>
int main(void)
{
	int n,a,card[52],i;
	char mark;
	for(i=0;i<52;i++) card[i]=0;
	scanf("%d", &n);
	for(i=0;i<n;i++){
		scanf(" %c %d", &mark, &a);
		a-=1;
		if(mark=='S') card[a]=1;
		else if(mark=='H') card[a+13]=1;
		else if(mark=='C') card[a+26]=1;
		else if(mark=='D') card[a+39]=1;
	}
 	for(i=0;i<52;i++){
		if(card[i]==0){
			if((i/13)==0) printf("S %d\n", i+1);
			else if((i/13)==1) printf("H %d\n", i%13+1);
			else if((i/13)==2) printf("C %d\n", i%13+1);
			else if((i/13)==3) printf("D %d\n", i%13+1);
		}
	}
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;
//typedef pair<ll, ll> P;
//typedef pair<double, P> T;

const ll mod = 1000000007;
const ll INF = 100000010000;

ll N, C[200010];

ll ans;

ll pow_mod(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2 == 1)
	{
		return x * pow_mod(x, y - 1) % mod;
	}
	else
	{
		ll half = pow_mod(x, y / 2);
		return half * half % mod;
	}
}

ll div_mod(ll x)
{
	return pow_mod(x, mod - 2);
}

/*ll sum_bit(ll i)
{
	ll s = 0;
	while (i > 0)
	{
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

void add_bit(ll i, ll x)
{
	while (i <= 2 * N + 10)
	{
		bit[i] += x;
		i += i & -i;
	}
}*/

void init()
{
	cin >> N;
	
	for (int i = 0; i < N; i++)
	{
		cin >> C[i];
	}
}

void output()
{
	cout << ans << endl;
}



void solve()
{
	sort(C, C + N);
	reverse(C, C + N);

	for (ll i = 0; i < N; i++)
	{
		if (i == 0)
		{
			(ans += C[i] * pow_mod(2, N - 1) % mod) %= mod;
		}
		else
		{
			(ans += pow_mod((ll)2, i - 1) * C[i] % mod * (i + 2) % mod * pow_mod(2, N - i - 1) % mod) %= mod;
		}
	}
	ans *= pow_mod(2, N);
	ans %= mod;
}

int main()
{
	init();
	
	solve();

	

	output();
	ll N;
	cin >> N;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define md 1000000007
#define ll long long 
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define fastmap mp.reserve(1024);mp.max_load_factor(0.25);
#define fastset st.reserve(1024);st.max_load_factor(0.25);
ll int mpw(ll int a,ll int b,ll int m)
{
	ll int ans=1;
	if(a==0)return 0;
	if(a==1 || b==0)return 1;
	while(b)
	{
		if(b&1)
		{
			ans=(ans*a)%m;
		}
		a=(a*a)%m;
		b>>=1;
	}
	return ans;
}
 
ll int pw(ll int a,ll int b)
{
	ll int ans=1;
	if(a==0)return 0;
	if(a==1 || b==0)return 1;
	while(b)
	{
		if(b&1)
		{
			ans*=a;
		}
		a*=a;
		b>>=1;
	}
	return ans;
}
 
ll int mn(ll int a,ll int b)
{
	if(a<=b)
	{
		return a;
	}
	return b;
}
 
ll int mx(ll int a,ll int b)
{
	if(a>=b)
	{
		return a;
	}
	return b;
}
vector<vector<ll int>>D; 
int main()
{
	fio
	int n;
	cin>>n;
	vector<vector<char>>nm(n,vector<char>(n));
	vector<ll int>shf(n+1);
	shf[0]=1;
	for(int i=1;i<=n;++i)
	{
		shf[i]=shf[i-1]*2;
	}
	for(int i=0;i<n;++i)
	{
		for(int j=0;j<n;++j)
		{
			cin>>nm[i][j];
		}
	}
	D.clear();
	int mx1=shf[n];
	D.resize(n,vector<ll int>(mx1,0));
	for(int j=0;j<n;++j)
	{
		if(nm[0][j]=='1')
		{
			D[0][shf[j]]=1;
		}
	}
	for(int i=1;i<n;++i)
	{
		for(int j=0;j<mx1;++j)
		{
			if(__builtin_popcount(j)==i)
			{
				for(int k=0;k<n;++k)
				{
					if(nm[i][k]=='1' && ((j&(shf[k]))==0))
					{
						D[i][j|(shf[k])]=(D[i][j|(shf[k])]+D[i-1][j])%md;
					}
				}
			}
		}
	}
	cout<<D[n-1][mx1-1]<<"\n";
	return 0;
}

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

int main(){
  int n,k,r,s,p;
  string t; cin >>n >>k >>r >>s >>p >>t;
  rep(i,n-k) {
    if(t[i]==t[i+k]) t[i+k]='*';
  }
  int ans = 0;
  rep(i,n){
    if(t[i]=='r') ans += p;
    if(t[i]=='s') ans += r;
    if(t[i]=='p') ans += s;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int main(){
    int w,h,n,x,y,tx,ty;
    cin>>w>>h>>n;
    int sum=0;
    cin>>tx>>ty;
    for(int i=1;i<n;++i){
        cin>>x>>y;
        if((x-tx)*(y-ty)>0) sum +=max(abs(x-tx),abs(y-ty));
        else sum +=abs(x-tx)+abs(y-ty);
        tx=x;ty=y;
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 3080
#include <iostream>
#include <string>

int main() {
  std::string S;
  std::cin >> S;

  for (size_t i = 0; i < S.size(); ++i) {
    if (i % 2 == 0) {
      if (S.at(i) == 'L') {
        std::cout << "No" << std::endl;
        return 0;
      }
    } else {
      if (S.at(i) == 'R') {
        std::cout << "No" << std::endl;
        return 0;
      }
    }
  }
  std::cout << "Yes" << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp(a,b) make_pair(a,b)
#define ff first
#define setp(a) setprecision(a)<<fixed
#define ss second
#define fori(v) for(int i=0; i<v; i++)
#define forj(v) for(int j=0; j<v; j++)
#define fork(v) for(int k=0; k<v; k++)
#define forl(v) for(int l=0; l<v; l++)
#define fort(v) for(int t=0; t<v; t++)
#define forz(v) for(int z=0; z<v; z++)
#define ll long long 
#define MAX (int)(pow(10,7) + 10)
#define dim 3
#define pb(a) push_back(a)
// #define cout out
// #define cin in
ll inf = pow(10,18);
ll modulo = pow(10,9) + 7;
double eps = 1e-6;
ifstream in;
ofstream out;


void deal(){
	vector<vector<ll> > arr(dim, vector<ll>(dim));
	fori(dim){
		forj(dim){
			cin>>arr[i][j];
		}
	}
	vector<vector<ll> > seen(dim ,vector<ll> (dim, 0));
	ll n;
	cin>>n;
	fori(n){
		ll ed;
		cin>>ed;
		forj(dim){
			fork(dim){
				if(arr[j][k] == ed){
					seen[j][k] = 1;
				}
			}
		}
		
	}
	fori(dim){
		bool ok = 1;
		forj(dim){
			ok&=seen[i][j];
		}
		if(ok){
			cout<<"Yes";
			return;
		}
		ok = 1;
		forj(dim){
			ok&=seen[j][i];
		}
		if(ok){
			cout<<"Yes";
			return;
		}
	}
	bool ok = 1;
	fori(dim){
		ok&=seen[i][i];
		
	}
	if(ok){
		cout<<"Yes";
		return;
	}
	
	ok = 1;
	fori(dim){
		ok&=seen[i][dim-1-i];
		
	}	
	if(ok){
		cout<<"Yes";
		return;
	}
	cout<<"No";
}

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



/* 
6 8 
1 2
2 3
3 4
4 1
2 5
3 5
1 6
4 6
*/

Measured memory_bytes: 256