akhauriyash/Code-Regression huggingface dataset:
//#pragma GCC optimize "trapv"
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define S 1000001
#define M 1000000007
#define nl cout<<"\n";
#define er  cout<<"\n***********\n";
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define test lli t;  cin>>t; while(t--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define Y cout<<"YES\n";
#define N cout<<"NO\n";
#define print(x)                 cout<<#x<<": "<<x<<endl;
#define print2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl;
#define print3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define print4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define print5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl;
#define print6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl;

int main()
{
    fast
    // test
    {
        lli n,sum=0;
        cin>>n;
        vector<lli> v(n,0);
        for(lli i=0;i<n;i++)
        {
            cin>>v[i];
        }
        sort(v.begin(),v.end(),greater<lli> ());
        sum=0;
        lli ct=1;
        for(lli i=1;i<n;)
        {
            sum=sum+v[i-ct];
            i++;
            if(i<n)
            sum=sum+v[i-ct];
            
            i++;
            
            ct++;
        }
        cout<<sum;
    }
}
//a+b=a?b+2?(a&b)
//__builtin_popcount(number)
//cout<<fixed<<setprecision(8)<<output<<"\n";




Measured memory_bytes: 4788
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] array = new int[3];
		for(int i = 0; i < array.length; i++)
			array[i] = sc.nextInt();
		Arrays.sort(array);
		int cost = 0;
		for(int i = 0; i < array.length-1; i++) 
			cost += Math.abs(array[i] - array[i+1]);
		System.out.println(cost);
	}
}


Measured memory_bytes: 23124
N = int(input())
S = input()

BtoW_stones_num = 0
for i in range(N):
    if S[i] == "#":
        BtoW_stones_num += 1

count = 0
brack_stone_num = 0
white_stone_num = 0
WtoB_stone_num = 0
for i in range(N-1, -1, -1):
    if S[i] == "#":
        if  white_stone_num == 0:
            brack_stone_num = 0
        else:
            brack_stone_num += 1
        if brack_stone_num > white_stone_num:
            WtoB_stone_num += white_stone_num
            brack_stone_num = 0
            white_stone_num = 0
    else:
        white_stone_num += 1
    
print(brack_stone_num + WtoB_stone_num)

Measured memory_bytes: 3500
#include<bits/stdc++.h>
#define mod 1000000007
#define N 10001
#define D 100
using namespace std;
int dp[N][D][2],d; 
string k;
int solve(int idx,int rem,bool tight){
    if(idx==0){
        if(rem==0){
            dp[idx][rem][tight]=1;
            return dp[idx][rem][tight];
        }
        dp[idx][rem][tight]=0;
        return dp[idx][rem][tight];
    }
    if(dp[idx][rem][tight]!=-1)return dp[idx][rem][tight];
    int lim = tight==0?9:k[idx-1]-'0';
    int ans=0;
    for(int i=0;i<=lim;i++){
        bool curTight = tight;
        if(i<(k[idx-1]-'0'))curTight=0;
        ans = (ans+solve(idx-1,(rem+i)%d,curTight))%mod;
    }   
    dp[idx][rem][tight] = ans;
    return dp[idx][rem][tight];
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>k>>d;
    reverse(k.begin(),k.end());  
    for(int i=0;i<k.size()+1;i++){
        for(int j=0;j<d;j++){
            for(int m=0;m<2;m++){
                dp[i][j][m]=-1;
            }
        }
    }
    int ans = (solve(k.size(),0,1)-1+mod)%mod;
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int A, B, C; cin >> A >> B >> C;
	bool ok = true;
	if (A == B && A == C)ok = true;
	else ok = false;;
	cout << (ok ? "Yes" : "No") << "\n";

	return 0;
}

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

int main(){
  string s,t;
  cin >> s;
  t = "CODEFESTIVAL2016";
  
  int cnt;
  
  for(int i = 0; i < 16; i++){
    if(s.at(i) != t.at(i)) cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
import java.io.*;

public class Main {

  public static void main(String[] args) throws IOException {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    String[] in = br.readLine().split(" ");
    int n = Integer.parseInt(in[0]);
    int a = Integer.parseInt(in[1]);
    int b = Integer.parseInt(in[2]);

    br.close();

    int mx = Math.min(a, b);
    int mn = Math.max(a + b - n, 0);
    System.out.println(mx + " " + mn);
  }
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define pp pop_back
#define in insert
#define ff first
#define ss second
#define e endl
#define MOD 998244353
int main()
{
    int a,b,i;
   cin>>a>>b;
   int ma[3]={0};
   ma[a-1]=1;ma[b-1]=1;
   for(i=0;i<3;i++)
   {
       if(ma[i]==0)
        cout<<i+1<<e;
   }


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=200005;
int n,a[N],p[2],dp[3],v[2];
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++)scanf("%d",&a[i]);
	int ans=0,now=0;
	for (int i=1;i<=n+1;i++){
		p[0]=0;p[1]=a[i]-now;
		if (p[0]<p[1])swap(p[0],p[1]);
		dp[0]=dp[1]=1e9;dp[2]=0;
		for (int j=0;j<2;j++)
			for (int k=0;k<2;k++)
				dp[j+k]=min(max(0,v[j]+p[k]),dp[j+k]);
		int delta=dp[0]>a[i];
		for (int j=0;j<2;j++)v[j]=dp[j+delta];
		ans+=delta;now=a[i];
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

const int MAX = 510000;
const int MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

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

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

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

    ll N, K;
    cin >> N >> K;
    vec A(N);
    Rep (i, N) {
        cin >> A[i];
    }

    sort(A.begin(), A.end());
    COMinit();

    ll ans = 0;
    for (ll i = N-1; i >= 0; i--) {
        ans += ((A[i] * COM(i, K-1) % MOD) + MOD) % MOD;
        ans %= MOD;
    }

    Rep (i, N) {
        A[i] *= -1;
    }
    reverse(A.begin(), A.end());
    
    for (ll i = N-1; i >= 0; i--) {
        ans += ((A[i] * COM(i, K-1) % MOD) + MOD) % MOD;
        ans %= MOD;
    }

    cout << ans << endl;
}

Measured memory_bytes: 13056
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int H = getint(), N = getint();

	int dp[10000] = {};
	rep1(i, H - 1) dp[i] = 2e9;

	int kotae = 2e9;
	rep(i, N) {
		int a = getint();
		int b = getint();
		rep(j, H) {
			if (dp[j] < 1e9) {
				int k = j + a;
				if (k >= H) chmin(kotae, dp[j] + b);
				else chmin(dp[k], dp[j] + b);
			}
		}
	}

	printf("%d", kotae);

	Would you please return 0;
}

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

//宣言
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

//数値
#define MOD 1000000007
#define INF (1<<20)
const double EPS = 1e-10;
const double PI = acos(-1.0);

//操作
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,n) FOR(i,0,n)
#define REPB(i,n) for(int i=n;i>=0;i--)
#define SORT(A) sort(A,A+sizeof(A)/sizeof(A[0]))
#define VSORT(A) sort(A.begin(),A.end())
#define EXIST(s,e) (s.find(e)!=s.end())
#define PB push_back
#define MP make_pair

//DEBUG
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main() {

	int a,b;
	string s;
	cin >> a>>b;
	int x;
	x = (a + b) / 2;
	if((a + b) % 2) x++;
	cout << x;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true; } return false; }





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	if(n == 0){
		cout << 0 << endl;
		return 0;
	}
	string ans = "";
	while(n != 0){
		if(n % -2 == 0){
			ans = '0' + ans;
		}
		else{
			ans = '1' + ans;
			n--;
		}
		n /= -2;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;
#define MAX_V 110000
long long int INF = 1e18;

struct edge{
	int to;
	long long int cost;
};

vector<edge> E[MAX_V];
long long int d[MAX_V];

void func(int u, int pre, int dist){
	d[u] = dist;
	for(int i = 0; i < E[u].size(); i++){
		if(E[u][i].to != pre){
			func(E[u][i].to, u, dist + E[u][i].cost);
		}
	}
}

int main(){
	
	int N;
	cin >> N;
	
	for(int i = 0; i < N - 1; i++){
		int u, v, c;
		cin >> u >> v >> c;
		edge p;
		p.cost = c;
		p.to = v;
		E[u].push_back(p);
		p.to = u;
		E[v].push_back(p);
	}
	
	func(0, -1, 0);
	
	int index = 0;
	int dmax = 0;
	for(int i = 0; i < N; i++){
		if(d[i] > dmax){
			dmax = d[i];
			index = i;
		}
	}
	func(index, -1, 0);
	
	dmax = 0;
	for(int i = 0; i < N; i++){
		if(d[i] > dmax){
			dmax = d[i];
		}
	}
	
	cout << dmax << endl;
	
	return 0;
}


Measured memory_bytes: 15756
N,Y = map(int,input().split())

list = [-1,-1,-1]
for x in range(0,N+1):
    for y in range(0,N+1-x):
        z = N - x - y
        sumOfMoney = 10000*x + 5000*y + 1000*z

        if sumOfMoney == Y:
            list[0] = x
            list[1] = y
            list[2] = z

print(str(list[0]) + " " + str(list[1]) + " " + str(list[2]))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    int arr[n];
    int sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        sum+=arr[i];
    }
    float d=sum*(1.0)/(4*m);
    //cout<<d<<endl;
    int c=0;
    for(int i=0;i<n;i++)
    {
        if(arr[i]>=d)
        {
            c++;
        }
    }
    if(c>=m)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}

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

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

Measured memory_bytes: 3128
N,D=map(int,input().split())
mat=[]
for d in range(N):
     mat.append([int(x) for x in input().split()])

import math
c=0
for i in range(len(mat)-1):
    for j in range(i+1,len(mat)):
        dist=math.sqrt(sum([(x-y)**2 for x,y in zip(mat[i],mat[j])]))
        if int(dist)==dist:
                c+=1
print(c)

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

signed main () {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int h, w, k;
	cin >> h >> w >> k;
	vector < string > c(h);
	for (int i = 0; i < h; ++i)
		cin >> c[i];
	int ans = 0;
	for (int m1 = 0; m1 < (1 << h); ++m1) {
		for (int m2 = 0; m2 < (1 << w); ++m2) {
			vector < string > t = c;
			for (int i = 0; i < h; ++i) {
				if (m1 & (1 << i)) {
					for (int j = 0; j < w; ++j)
						t[i][j] = '.';
				}
			}
			for (int i = 0; i < w; ++i) {
				if (m2 & (1 << i)) {
					for (int j = 0; j < h; ++j)
						t[j][i] = '.';
				}
			}
			int here = 0;
			for (int i = 0; i < h; ++i) {
				for (int j = 0; j < w; ++j)
					here += int(t[i][j] == '#');
			}
			ans += int(here == k);
		}
	}
	cout << ans << '\n';
}


Measured memory_bytes: 3620
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;
using ll = long long;
using ld = long double;

constexpr int NA = -1; // not assigned

void solve(ll N, ll M, vector<ll> s, vector<ll> c) {
  vector<ll> v(N, NA);
  int ans = 0;
  for (int i = 0; i != M; ++i) {
    ll &d = v[s[i]-1];
    if (d != NA && d != c[i]) {
      ans = NA;
      break;
    }
    d = c[i];
  }

  if (N != 1 && !v[0]) ans = NA;

  if (ans != NA) {
    for (int i = 0; i != N; ++i) {
      if (v[i] == NA) {
        v[i] = (N==1 || i) ? 0 : 1;
      }
    }

    ans = accumulate(v.begin(), v.end(), 0,
                     [](int acc, int x) { return acc * 10 + x; });
  }

  cout << ans << endl;
}

int main() {
  ll N;
  cin >> N;
  ll M;
  cin >> M;
  vector<ll> s(M);
  vector<ll> c(M);
  for (int i = 0; i < M; i++) {
    cin >> s[i];
    cin >> c[i];
  }
  solve(N, M, move(s), move(c));
  return 0;
}


Measured memory_bytes: 256
def bi(x,n):
    o = [0]*n
    c = 0
    while x:
        o[c] = x%2
        x //= 2
        c += 1
    return o

S = input()
l = len(S)-1
ans = 0
for i in range(2**l):
    o = bi(i,l)
    j = ''.join([S[x]+['+',''][o[x]] for x in range(l)]+[S[-1]])
    for k in j.split('+'):
        ans += int(k)

print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

int p=0;
int q[2000001];

int max(int,int);
int extract();
void swap(int,int);
void insert(int);

int main(){
  char c[10];
  int i,j;
  int k;
  while(1){
    scanf("%s",c);
  
  if(c[0]=='i'){
      scanf("%d",&k);
      insert(k);
    }

    if(c[0]=='e'){

      if(c[1]=='x')
    printf("%d\n",extract());

      if(c[1]=='n') break;
    }
  }
  return 0;
}

int max(int a,int b){

  if(q[a]>q[b])return a;
  else return b;

}

void swap(int a,int b){
  int t;
  t=q[a];
  q[a]=q[b];
  q[b]=t;
}
 
void insert(int k){
  int t;
  int i,j;
  p++;
  q[p]=k;
  i=p;
  while(q[i]>q[i/2] && i>1){
    swap(i,i/2);
    i=i/2;
  }
}

int extract(){
  int r=q[1];
  int i;
  int t;
  int M;
  q[1]=q[p];
  p--;
  i=1;
  while(i*2 <= p ){
    if(i*2+1 <= p)
      M=max(i*2,i*2+1);
    else M=i*2;
    if(max(M,i)==M){swap(M,i);i=M;}
    else break;
     
  }
  return r;
}

Measured memory_bytes: 4696
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		System.out.println(Solution(N));
	}
	static String Solution(int N) {
		int number = 0;
		String s = N+"";
		for(int i=0; i<s.length(); i++) {
			number = number + Integer.parseInt(s.charAt(i)+"");
		}
		if(N%number==0) {
			return "Yes";
		}
		return "No";
	}
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int t;
	string s;
	cin>>t>>s;
	int count = 0;
	for(int i = 0; i < s.size()-2; i++)
	{
		if(s[i]=='A' and s[i+1]=='B' and s[i+2]=='C')
		{
			count++;
		}
	}
	cout<<count<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int a = s.nextInt();
		int b = s.nextInt();
		int c = 0;
		int sum = a+b;
		
		if (a%3 == 0){
			c += 1;
		}
		if (b%3 == 0){
			c += 1;
		}
		if (sum%3 == 0){
			c += 1;
		}
		
		if (c>0){
			System.out.println("Possible");
		}else{
			System.out.println("Impossible");
		}
	}
}


Measured memory_bytes: 21716
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
#import bisect #bisect.bisect_left(B, a)
from collections import defaultdict #d = defaultdict(int) d[key] += value
from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

N = ii()

L = [input() for i in range(N)]

#cnt = Counter(L).most_common()
cnt = defaultdict(int)
cnt['AC'] = 0
cnt['WA'] = 0
cnt['TLE'] = 0
cnt['TLE'] = 0
for s in L:
    cnt[s] += 1

print('AC x', cnt['AC'])
print('WA x', cnt['WA'])
print('TLE x', cnt['TLE'])
print('RE x', cnt['RE'])

Measured memory_bytes: 16636
#include<bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
using namespace std;
const ll maxn=1e9+7;

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


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <string.h>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <stdlib.h>
using namespace std;
typedef long long int lld;
typedef long double ld;
int arr[55],ans;
int main(void){
	int n;
	scanf("%d",&n);
	for(int e=0;e<n;e++) scanf("%d",&arr[e]);
	for(int e=0;e<n;e++){
		for(int p=e+1;p<n;p++){
			ans += arr[e]*arr[p];
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int s,w;
	scanf("%d %d", &s, &w);
	if (!(1 <= s && s <= 100) && !(1 <= w && w <= 100)) return 0;
	if (w >= s) puts("unsafe");
	else puts("safe");
	return 0;
}

Measured memory_bytes: 1612
#include <iostream>
#define ll long long
using namespace std;

int main(){
  int x; cin>>x;
  int a = x%100;
  int b = a/5;
  a = a%5;
  b = b + a/4;
  a = a%4;
  b = b + a/3;
  a = a%3;
  b = b + a/2;
  a = a%2;
  b = b + a;
  
  if(x/100>=b){cout<<1;}
  else{cout<<0;}
  
  return 0;
}

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

const int Maxn = 2e5;

struct Node {
	int tim, x, typ;
	Node(){}
	Node(int a, int b, int c) {
		tim = a, x = b, typ = c;
	}
	bool operator < (const Node &rhs) const {
		return tim < rhs.tim;
	}
};

int N, M;
Node A[Maxn * 2 + 5];
int len;
multiset<int> t;

int main() {
#ifdef LOACL
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	scanf("%d %d", &N, &M);
	for(int i = 1; i <= N; i++) {
		int s, t, x;
		scanf("%d %d %d", &s, &t, &x);
		A[++len].tim = s - x;
		A[len].x = x, A[len].typ = 1;
		A[++len].tim = t - x;
		A[len].x = x, A[len].typ = 0;
	}
	sort(A + 1, A + len + 1);
	int k = 1;
	for(int i = 1; i <= M; i++) {
		int d;
		scanf("%d", &d);
		while(k <= len)
			if(A[k].tim <= d) {
				if(A[k].typ == 1) t.insert(A[k].x);
				else t.erase(t.find(A[k].x));
				k++;
			} else break;
		int ans = -1;
		if(t.size()) ans = *t.begin();
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 15360
#include<stdio.h>
int keta(int num){
int acc=0;
while(num>0){
num/=10;
acc++;
}
return acc;
}
int main(){
int a, b;
while(scanf("%d %d",&a,&b)!=EOF){
      printf("%d\n",keta(a+b));
}
return 0;
}

Measured memory_bytes: 600
from sys import stderr

def debug(*args):
    print(*args, file=stderr)


def input_sweets_owners():
    input()
    return list(map(int, input().split()))

n_sukuke_num, k_sweets_types_num = map(int, input().split())
ai_sweets_owners = [input_sweets_owners() for _ in range(k_sweets_types_num)]

# debug(ai_sweets_owners)
# for _ in range(k_sweets_types_num):
#     input()
#     ai_sweets_owners.append(list(map(int, input().split())))

sunuke_n_has = {}

for i, sweets_owners in enumerate(ai_sweets_owners):
    for sweets_owner in sweets_owners:
        sunuke_n_has[sweets_owner] = True

# debug(sunuke_n_has)

result = 0
for sunuke_i in range(1, n_sukuke_num+1):
    # debug(sunuke_i in sunuke_n_has)
    if not sunuke_i in sunuke_n_has:
        result += 1

print(result)


Measured memory_bytes: 9236
import java.util.*;
import java.util.ArrayList;
import java.util.List;

public class Main {
    public static void main(String[] args) {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        num = num +1;
        int l = sc.nextInt();
        int ans = 0;
        int taste[] = new int[num];
        int eat;
        int eat2 = l;
        if(l > 0){
            eat = l;
        }else{
            eat = l * -1;
        }
         for(int i = 1; i < num; i++){
            taste[i] = l + i - 1;
            ans = ans + taste[i];
            if(taste[i] < 0){
                taste[i] = taste[i]* -1;
                if(taste[i] < eat){
                    eat = taste[i];
                    eat2 = taste[i]*-1;
                    //System.out.println(eat2);
                }
            }else{
                if(taste[i] < eat){
                    eat = taste[i];
                    eat2 = taste[i];
                    //System.out.println(eat2);
                }
            }
        }
        ans = ans - eat2;
        System.out.println(ans);
    }
}

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

// boost
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

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

  ll n;
  cin >> n;
  vll h(n);
  rep(i, n) cin >> h[i];

  ll ans = 0;
  ll cnt = 0;
  REP(i, n) {
    if (h[i] <= h[i - 1]) {
      cnt++;
    } else {
      chmax(ans, cnt);
      cnt = 0;
    }
  }
  chmax(ans, cnt);

  cout << ans << endl;

  return 0;
}


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

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main(int argc, char const *argv[]) {
	int n;
	std::cin >> n;
	std::vector<int> a(n);
	std::vector<int> b(n);
	std::vector<int> c(n-1);
	for (size_t i = 0; i < a.size(); i++) {
		std::cin >> a[i];
		a[i]--;
	}
	for (size_t i = 0; i < b.size(); i++) {
		std::cin >> b[i];
	}
	for (size_t i = 0; i < c.size(); i++) {
		std::cin >> c[i];
	}

	int ans = b[a[0]];
	for (size_t i = 1; i < a.size(); i++) {
		ans += b[a[i]];
		if (a[i] == a[i-1] + 1) {
			ans += c[a[i-1]];
		}
	}

	std::cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
    string a,b;
    int n=2,c=0;
    cin>>a>>b;
    for(int i=0;i<3;i++){
        if(a[i]==b[n])
            c++;
        n--;
    }
    if(c==3)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define in_range(x, y, r, c) (x <= r && y <= c && x >= 0 && y >= 0)
#define MAXN 200100
#define pii  pair<int, int>
#define ff first
#define ss second
using namespace std;
const int mod = 1e9+7;

int main(){
    int n;
    string s;
    cin >> s;

    n = s.size();

    vector<int> v(n, 1);

    for (int i=0; i<n-1; i++){
        if (s[i] == 'R' and s[i+1] != 'L') v[i+1]+=v[i], v[i]=0;
        if (s[n-1-i] == 'L' and s[n-2-i] != 'R') v[n-2-i] += v[n-1-i], v[n-1-i] = 0;
    }

    for (int i=0; i<n-1; i++){
        if (v[i] != 0){
            if ((v[i]+v[i+1])%2 == 0){
                v[i] = v[i+1] = (v[i]+v[i+1])/2;
            }
            else {
                int media = (v[i]+ v[i+1])/2, l = 0, r = 0;
                if (v[i]%2 == 1) r=1;
                else l = 1;
                v[i] = v[i+1] = media;
                v[i] += r;
                v[i+1] +=l;
            }
            i++;
        }
    }

    for (int i=0; i<n;i++){
        if (i) cout << " ";
        cout << v[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int H, W, h, w; cin >> H >> W >> h >> w;
    cout << (H-h)*(W-w) << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cmath>
#include <climits>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
#include <functional>
#include <algorithm>

using namespace std;

#define fast_cin() ios_base::sync_with_stdio(false)

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

const int max_N = 1e5 + 10;
vector<int> E[max_N];

int solve(int node);

int main()
{
	fast_cin();
	int N;
	cin >> N;
	for (int i = 2; i <= N; ++i) {
		int u;
		cin >> u;
		E[u].push_back(i);
	}

	cout << solve(1) << endl;
}

int solve(int node)
{
	int res = E[node].size();
	vector<int> temp;
	for (auto &v : E[node]) {
		temp.push_back(solve(v));
	}
	sort(temp.begin(), temp.end(), greater<int>());
	int n = 1;
	for (auto &c : temp) {
		res = max(res, c + n);
		++n;
	}
	return res;
}


Measured memory_bytes: 15232
import sys
import math
def resolve():
    S=list(input().rstrip())
    c=0
    for i in range(math.floor(len(S)/2)):
        if(S[i]!=S[len(S)-i-1]):
            c+=1
    print(c)

from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """redcoder"""
        output = """1"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """vvvvvv"""
        output = """0"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """abcdabc"""
        output = """2"""
        self.assertIO(input, output)

if __name__ == "__main__":
    #unittest.main()
    resolve()

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

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

long long MOD = 1000000000 + 7;

int main(){
  cout << setprecision(10);
  int N,M;
  ll K;
  cin >> N >> M >> K;
  vector<ll> A(N), B(M);
  for(int i = 0; i < N; i++){
    cin >> A[i];
    if(i > 0){
      A[i] += A[i-1];
    }
  }
  for(int i = 0; i < M; i++){
    cin >> B[i];
    if(i > 0){
      B[i] += B[i-1];
    }
  }

  for(int i = 0; i < N; i++){
    cerr << A[i] << " ";
  } 
  cerr << endl;

  for(int i = 0; i < M; i++){
    cerr << B[i] << " ";
  } 
  cerr << endl;


  // Aをx冊、Bをy冊読む

  ll max_val = 0;
  for(int x = 0; x <= N; x++){
    ll tmp = 0;
    ll time;
    if( x == 0){
      time = 0;
      tmp = 0;
    } else { 
      time = A[x-1];
      tmp = x;
    }
    if(time > K) continue;

    // cerr << "i: " << x << " time: " << time << " K - time: " << K - time << endl;

    if(B[0] > K - time) {

    } else {
      auto itr = upper_bound(B.begin(), B.end(), K - time);
      // cerr << "itr: " << itr - B.begin() << endl;
      if(itr == B.end()){
        tmp += M;
      } else { 
        tmp += itr - B.begin();
      }
    }


    max_val = max(tmp, max_val);

  }
  cout << max_val << endl;
}



Measured memory_bytes: 9720
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int a[200010];
    rep(i, N) cin >> a[i];
    int sum = 0;
    rep(i, N) sum ^= a[i];
    //cout << sum << endl;
    rep(i, N) {
        if(i != 0) cout << " ";
        cout << (sum ^ a[i]);
    }
    cout << endl;
    //cout << (13^11^7) << endl;

    return 0;
}
// 10100, 01011, 01001, 11000

Measured memory_bytes: 5152
// -*- coding:utf-8-unix -*-

#[macro_use]
extern crate lazy_static;
extern crate num_bigint; // 0.2.2
extern crate num_traits; // 0.2.8
use num_bigint::BigInt;
use num_traits::Pow;

// use proconio::derive_readable;
use proconio::fastout;
use proconio::input;
// use std::convert::TryInto;
use libm::*;
use std::cmp::*;
use std::collections::{BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::*;
use std::ops::Range;
use std::str::FromStr;
use superslice::*;

use itertools::Itertools;
use lazy_static::lazy_static;
use std::sync::Mutex;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

lazy_static! {
    static ref H: Mutex<Vec<i32>> = Mutex::default();
    static ref W: Mutex<Vec<i32>> = Mutex::default();
}

//abc085-D
// #[fastout]
fn main() {
    input![n: usize, mut h: i64, ab: [(usize, usize); n]];

    let a_max = ab.iter().map(|(a, b)| *a).max().unwrap();
    let mut b = ab.iter().map(|(a, b)| *b).collect_vec();
    b.sort_by_key(|b| Reverse(*b));
    // eprintln!("{:?}", b);

    let mut ans: i64 = 0;
    for b in b.iter() {
        if a_max > *b {
            break;
        }

        if h <= 0 {
            println!("{}", ans);
            return;
        }

        h -= *b as i64;
        ans += 1;
    }

    while h > 0 {
        ans += 1;
        h -= a_max as i64;
    }

    println!("{}", ans);
}

// let mut values = VALUES.lock().unwrap();
// values.extend_from_slice(&[1, 2, 3, 4]);
// assert_eq!(&*values, &[1, 2, 3, 4]);

// -100000000
//  1000000000


Measured memory_bytes: 6572
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = /*1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 1'000'000;
const int LOGN = 19;

int n, m, k;

void solve(int) {
  int64 n, a, b;
  cin >> n >> a >> b;
  if (abs(a - b) & 1) {
    int64 x = min(a, b);
    int64 y = n - max(a, b) + 1;
    cout << min((max(a, b) - x) / 2 + x, (n - min(a, b) - y) / 2 + y) << '\n';
  } else {
    cout << abs(a - b) / 2 << '\n';
  }
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <utility>
using namespace std;
const int INF=2147483647;
struct segment_tree{
    pair<long long int,long long int> map[2000010];
    void build(int now,int l,int r){
        map[now].first=map[now].second=0;
        if(l==r)return;
        int mid=(l+r)/2;
        build(now*2+1,l,mid);
        build(now*2+2,mid+1,r);
        return ;
    }
    void change(int n,int now,int L,int R,int l,int r){
        if(R<l||L>r)return;
        if(L>=l&&R<=r){
            map[now].second+=n;
            map[now].first+=(R-L+1)*n;
            return;
        }
        int mid=(L+R)/2;
        map[now*2+1].first+=map[now].second*(mid-L+1);
        map[now*2+2].first+=map[now].second*(R-mid);
        map[now*2+1].second+=map[now].second;
        map[now*2+2].second+=map[now].second;
        map[now].second=0;
        change(n,now*2+1,L,mid,l,r);
        change(n,now*2+2,mid+1,R,l,r);
        map[now].first=map[now*2+1].first+map[now*2+2].first;
        return ;
    }
    long long int find(int now,int L,int R,int l,int r){
        if(R<l||L>r)return 0;
        if(L>=l&&R<=r)return map[now].first;
        int mid=(L+R)/2;
        map[now*2+1].first+=map[now].second*(mid-L+1);
        map[now*2+2].first+=map[now].second*(R-mid);
        map[now*2+1].second+=map[now].second;
        map[now*2+2].second+=map[now].second;
        map[now].second=0;
        return find(now*2+1,L,mid,l,r)+find(now*2+2,mid+1,R,l,r);
    }
};
int main(){
    int n,m,k,l,r;
    segment_tree arr;
    scanf("%d%d",&n,&m);
    arr.build(0,1,n);
    while(m--){
        scanf("%d%d%d",&k,&l,&r);
        if(k==0){
            scanf("%d",&k);
            arr.change(k,0,1,n,l,r);
        }
        else printf("%lld\n",arr.find(0,1,n,l,r));
    }
}

Measured memory_bytes: 34024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const ll INF = 1LL << 60;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
const int MAX = 700000;
const int MOD = 1000000007;


int main(){
  ll n,m,v,p;
  cin>>n>>m>>v>>p;
  vll a(n);
  rep(i,n){
    cin>>a[i];
  }
  ll bb=0;
  sort(all(a));
  ll cu=0;
  ll ans=0;
  ll kk=0;
  if(v>=p){
    kk=v-p;
  }
  p=n-p;
  for(int i=0;i<p+1;i++){
    bb+=a[i];
  }
  for(int i=0;i<p+1;i++){
    if(i==p){
      COUT(n-p);
      break;
    }
    bb-=a[i];
    ll mi=a[i];
    mi+=m;
    if(kk==0){
      if(a[p]>mi){
        cu++;
      }
      else{
        COUT(n-cu);
        break;
      }
    }
    else{
      if(a[p]>mi){
        cu++;
      }
      else{
        ll huya=kk*m;
        ll ok=mi*(p-i)-bb+(i*m);
        if(huya>ok){
          cu++;
        }
        else{
          COUT(n-cu);
          break;
        }
      }
    }
  }
}


Measured memory_bytes: 1152
require 'prime'

n = gets.to_i

h = {}

(2..n).each{|x| x.prime_division.each{|x,y| h[x] ||= 0; h[x] += y}}

r = 0

(2..n).each do |i|
  next unless h[i]
  (i+1..n).each do |j|
    next unless h[j]
    (j+1..n).each do |k|
      next unless h[k]
      r += 1 if h[i] >= 2 && h[j] >= 4 && h[k] >= 4
      r += 1 if h[i] >= 4 && h[j] >= 2 && h[k] >= 4
      r += 1 if h[i] >= 4 && h[j] >= 4 && h[k] >= 2
    end
  end
end

(2..n).each do |i|
  next unless h[i]
  (i+1..n).each do |j|
    next unless h[j]
    r += 1 if h[i] >= 14 && h[j] >= 4
    r += 1 if h[i] >= 4 && h[j] >= 14

    r += 1 if h[i] >= 24 && h[j] >= 2
    r += 1 if h[i] >= 2 && h[j] >= 24
  end
end

(2..n).each do |i|
  next unless h[i]
  r += 1 if h[i] >= 74
end

puts r


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

typedef long long ll;
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);

void solveA() {
	int a, b, c;
  	cin >> a >> b >> c;
  	int ans = max(abs(a-b), abs(b-c));
  	ans = max(ans, abs(a-c));
  	cout << ans;
}

/*
const int N = 1e5+10;
int dep[N];

struct SegTree{
	ll t[N<<2], rmq[N<<2];
	void build(int node, int L, int R) {
		if(L == R) return void(t[node] = 0, rmq[node] = L);
		int mid = (L+R)>>1, lc = node<<1, rc = lc|1;
		build(lc,L,mid), build(rc,mid+1,R);
		t[node] = 0, rmq[node] = rmq[lc];
	}
	void upd(int node, int L, int R, int pos, int v) {
		if(L == R) return void(t[node] += v);
		int mid = (L+R)>>1, lc = node<<1, rc = lc|1;
		if(pos <= mid) upd(lc,L,mid,pos,v);
		else upd(rc,mid+1,R,pos,v);
		t[node] = t[lc] + t[rc];
		
	}
	int sum(int node, int L, int R, int l, int r) {
		if(r < L || R < l) return 0;
		if(l <= L && R <= r) return t[node];
		int mid = (L+R)>>1, lc = node<<1, rc = lc|1;
		return sum(lc,L,mid,l,r) + sum(rc,mid+1,R,l,r);
	}
	int get(int node, int L, int R, int l, int r) {

	}
}

void solveD() {

}
*/

int main() {
	solveA();
	//solveD();
	return 0;
}


Measured memory_bytes: 256
N, Y = map(int, input().split())
res10000 = -1
res5000 = -1
res1000 = -1

for x in range(N+1):
    for y in range(N+1-x):
        z = N - x - y
        if 10000*x + 5000*y + 1000*z == Y:
            res10000 = x
            res5000 = y
            res1000 = z
            
print(str(res10000) + " " + str(res5000) + " " + str(res1000))

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
using namespace std;
 
string change(int n){
    string s = "";
    while(n > 0){
	s += (n % 10 + '0');
	n/=10;
    }
    reverse(s.begin(),s.end());
    return s;
}
 
int main(){
    int n;
 
    while(cin >> n ,n){
	string str;
	cin >> str;
 
	while(n--){
	    string tmp = "";
	    int cnt = 1;
	    char key = str[0];
	    int size = str.size();
	    str[size] = '#';
	    for(int i = 1 ; i <= size ; i++){
		if(key == str[i]){
		    cnt++;
		}
		else{
		    tmp += change(cnt);
		    tmp += key;
		    key = str[i];
		    cnt = 1;
		}
	    }
       
	    str = tmp;
	}
	cout << str << endl;
    }
    return 0;
}

Measured memory_bytes: 3356
#include <stdio.h>
#define N 40000
#define M 20000

int C[N];
int bump[N];
int all[N];
int op;

#if 1
#define gun() getchar_unlocked()
#else
#define gun() getchar()
#endif


int main(){
  int i,j,k,a,b,s,d,e;
  b=M,d=s=0;
  for(a=1;;a++){
    e=gun();
    if(e<=' ')
      break;
    if(e=='\\'){
      if(s>0)
	d+=s,all[op++]=s,s=0;
      C[--b]=a;
    }
    else if(e == '/'){
      if(C[b]>0)
	bump[op]=C[b],s+=a-C[b];   
      else if(s>0)
	d+=s,all[op++]=s,s=0;
      b++;    
    }
  }
  if(s>0)
    d+=s,all[op++]=s;

  printf("%d\n",d);
  k=op;
  i=op-1;
  while(i>0){
    j=i-1;
    while(j>=0&&bump[j]>bump[i]){
      all[i]+=all[j],all[j]=0,j--,k--;
    }
    i=j;
  }
  printf("%d",k);
  for(i=0;i<op;i++)
    if(all[i]>0)
      printf(" %d",all[i]);
  putchar('\n');
  return 0;
}
    

  



Measured memory_bytes: 2096
#include <bits/stdc++.h>
using namespace std;
int main(){
        long long int h, n; cin >> h >> n;
        long long int m = 0;
        for (long long int x = 0; x < n; ++x){
            long long int a; cin >> a;
            m += a;
        }
        if (m >= h) cout << "Yes" << endl;
        else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3600
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        String[] nums = s.nextLine().split(" ");
        int x = Integer.parseInt(nums[0]);
        int a = Integer.parseInt(nums[1]);
        if(x < a){
            System.out.println("0");
            return;
        }
        System.out.println("10");
    }
}

Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef double db; 
#define fi first
#define se second 
#define pb push_back
#define vi vector<int>
#define SZ(x) (int)(x.size())
#define sci(x) scanf("%d",&(x))
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
ll modpow(ll x,ll n,ll mod){ll res=1;for(;n;n>>=1,x=x*x%mod)if(n&1)res=res*x%mod;return res;} 
const db eps=1e-8,PI=acos(-1.0);
const int N=34,M=1e6+10,INF=0x3f3f3f3f,mod=1e9+7;//998244353
int a[]={0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}; 
int main(){
	int k;
	sci(k);printf("%d",a[k]);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
#define fi first
#define se second
Int mod = 1e9+7;
Int INF = 1e18;
double EPS = 0.00000001;
//Int mod = 1e6+3;

int main() {
    Int n, a, b;
    cin >> n >> a >> b;
    dump(min(a * n, b));
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, t) for(int i = (s), mi = (t); i <= mi; i++)
#define dwn(i, s, t) for(int i = (s), mi = (t); i >= mi; i--)

int read() {
	int x = 0, f = 1; char c = getchar();
	while(!isdigit(c)){ if(c == '-') f = -1; c = getchar(); }
	while(isdigit(c)){ x = x * 10 + c - '0'; c = getchar(); }
	return x * f;
}

#define maxn 2010

int A[maxn];
bitset <maxn * maxn> f;

int main() {
	int n = read(), tot = 0;
	rep(i, 1, n) A[i] = read(), tot += A[i];
	
	tot = tot + 1 >> 1;
	int cur = 0;
	f[0] = 1;
	rep(i, 1, n) f |= f << A[i];
	rep(i, 1, tot << 1) if(f[i] && i >= tot) return printf("%d\n", i), 0;
	
	return 0;
}

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

int dp[100005];
bool visited[100005];
vector<int> adj[100005];

void visit(int vertex){
	visited[vertex] = 1;
	dp[vertex] = 0;
	for(int child:adj[vertex]){
		if(!visited[child]){
			visit(child);
		}
		dp[vertex] = max(dp[vertex] , 1 + dp[child]);
	}
}

int main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		adj[x].push_back(y);
	}
	
	for(int i = 1; i <= n; i++){
		if(!visited[i]){
			visit(i);
		}
	}
	
	int ans = 0;
	for(int i = 1; i<=n ; i++){
		ans = max(ans, dp[i]);
	}
	
	cout<<ans;
	
}

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

const int INF = 1 << 29;
int a[110], e[110], r[110];
int d, n;
// dp[?????????][????¨????] = ????°?????????°
int dp[110][110];

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

	while(cin >> d >> n && (d || n)){

		for(int i = 0; i < n; ++i){
			cin >> a[i] >> e[i] >> r[i];
		}

		for(int i = 0; i < 110; ++i){
			for(int j = 0; j < 110; ++j){
				dp[i][j] = INF;
			}
		}

		dp[0][0] = 0;
		for(int i = 0; i <= d; ++i){
			for(int j = 0; j <= 100; ++j){
				for(int k = 0; k < n; ++k){
					if(j >= r[k]){
						int nd = min(i + a[k], d);
						int ne = min(j + e[k], 100);
						dp[nd][ne] = min(dp[nd][ne], dp[i][j] + 1);
					}
				}
			}
		}

		int ans = INF;
		for(int j = 0; j <= 100; ++j){
			ans = min(ans, dp[d][j]);
		}
		if(ans != INF)
			cout << ans << endl;
		else
			cout << "NA" << endl;
	}

	return 0;
}

/*
// ?¨??????????,??????????????°???????¨????
int func(int hp, int m, int k){
	if(hp <= 0) return m;
	int res = INF;
	for(int i = 0; i < n; ++i){
		if(k >= r[i]){
			res = min(res, func(hp - a[i], m + 1, k + e[i]));
		}
	}
	if(res == INF){
		cout << "NA" << endl;
		return 0; 
	}
	if(m == 0){
		cout << res << endl;
	}
	return res;
}

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

	while(cin >> d >> n && (d || n)){

		for(int i = 0; i < n; ++i){
			cin >> a[i] >> e[i] >> r[i];
		}

		func(d, 0, 0);
	}

	return 0;
}
*/
/*
a ??????????????????
e ??????????¨????
r ??????????¨????
*/

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

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

  switch(X%7){
    case 0:cout<<"thu";break;
    case 1:cout<<"fri";break;
    case 2:cout<<"sat";break;
    case 3:cout<<"sun";break;
    case 4:cout<<"mon";break;
    case 5:cout<<"tue";break;
    case 6:cout<<"wed";break;
  }
  cout<<endl;
}



Measured memory_bytes: 3116
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#define REP(i,n)for (int i=0;i<(n);i++)
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ll long long
using namespace std;
typedef pair<int,int> P;
int main(){
	int x,a,b;
	cin>>x>>a>>b;
	if(abs(a-x)<abs(b-x)){
		cout<<"A"<<endl;
	}else{
		cout<<"B"<<endl;
	}
}


Measured memory_bytes: 256