akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <cstring>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

int main(void)
{
    ll x, money = 100, r;
        cin >> x;
 
        for(r = 0; money < x; ++r){
                money += money / 100;                                                                                                
        }
 
        cout << r << endl;
}

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

int main(){
    char a[4], b[4], c[4];

    scanf("%s", a);
    scanf("%s", b);
    scanf("%s", c);

    printf("%c%c%c\n", a[0], b[1],c[2]);
    return 0;
}


Measured memory_bytes: 128
N, K = map(int, input().split())
A = [int(x) for x in input().split()]
A.sort()
cards = 0
tail = N
needs = N
while tail:
  for i in range(tail):
    if A[i] + cards >= K:
      cards += A[i - 1]
      tail = i - 1
      needs = i
      break
  else:
    cards += A[i]
    tail = i
print(needs)

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

int N, M;
int A[10];
ll cost[] = {1, 2, 5, 5, 4, 5, 6, 3, 7, 6};

string dp[20202];

int main() {
    cin >> N >> M;
    rep(i, M) cin >> A[i];

    rep(i, N+1) dp[i] = "X";
    dp[0] = "";

    for (int i = 0; i < N; ++i) {

        if (dp[i] == "X") continue;

        for (int j = 0; j < M; ++j) {
            string next = dp[i] + char(A[j] + '0');
            string now = dp[i + cost[A[j]]];

            if (now == "X") now = "";

            if (now.size() > next.size()) continue;
            else if (now.size() < next.size()) {
                //sort(next.rbegin(), next.rend());
                dp[i + cost[A[j]]] = next;
            }
            else {
                //sort(next.rbegin(), next.rend());
                int tmp1[10] = {0}, tmp2[10] = {0};
                rep(k, next.size()) {
                    tmp1[next[k]-'0']++;
                    tmp2[now[k]-'0']++;
                }
                for (int k=9; k>=1; --k) {
                    if (tmp1[k] == tmp2[k]) continue;
                    else if (tmp1[k] > tmp2[k]) {
                        dp[i + cost[A[j]]] = next;
                        break;
                    }
                    else break;
                }
            }
        }
    }
    sort(dp[N].rbegin(), dp[N].rend());
    cout << dp[N] << endl;
}


Measured memory_bytes: 44288
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;
void swap(int &a, int &b);

int main()
{

	// 行列
	int **MatrixA;
	int *VectorB;
	int *VectorC;
	int iRow, iCol;

	cin >> iRow >> iCol;

	// Definition
	MatrixA = new int *[iRow];
	for (int i = 0; i < iRow; ++i)
	{
		MatrixA[i] = new int[iCol];
		for (int j = 0; j < iCol; ++j)
		{
			cin >> MatrixA[i][j];
		}
	}
	VectorB = new int[iCol];

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

	// Calculation
	VectorC = new int[iRow]();
	for (int i = 0; i < iRow; ++i)
	{
		for (int j = 0; j < iCol; ++j)
		{
			VectorC[i] += MatrixA[i][j] * VectorB[j];
		}
	}

	for (int i = 0; i < iRow; ++i)
		cout << VectorC[i] << endl;



	return 0;
}




Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N, K; cin >> N >> K;
    if(K > 1) Out(N - K);
    else Out(0);

    return 0;
}


Measured memory_bytes: 764
#include <stdio.h>
  
int main()
{
    int n[100], x[100], i, a, b, c, count[100];
 
    for (i = 0; i < 100; i++) {
        scanf("%d %d", &n[i], &x[i]);
        if (n[i] == 0 && x[i] == 0) 
            break;
    }
    
    for (i = 0; i < 100 ; i++) {
        if (n[i] == 0 && x[i] == 0) 
            break;
        count[i] = 0;
        for (a = 1; a <= n[i]; a++) {
            for (b = a + 1; b <= n[i]; b++) {
                for (c = b + 1; c <= n[i]; c++) {
                    if (a + b + c == x[i])
                        count[i] += 1;
                }
            }
        }
    }
 
    for (i = 0; i < 100 ; i++) {
        if (n[i] == 0 && x[i] == 0) 
            break;
        printf("%d\n", count[i]);
    }
 
    return 0;
}

Measured memory_bytes: 600
def comb(n, r):
    x = 1
    for i in range(n-r+1, n+1):
        x *= i
    for i in range(1, r+1):
        x //= i
    return x

n = int(input())
x = 1

for i in range(1, n+1):
    x *= i

d = dict()
for i in range(2, 100):
    tmp = 0
    while x % i == 0:
        tmp += 1
        x //= i
    if tmp:
        d[i] = tmp

c = [ 0 for _ in range(5)]
for v in d.values():
    if v >= 2:
        c[0] += 1
    if v  >=4:
        c[1] += 1
    if v >= 14:
        c[2] += 1
    if v >= 24:
        c[3] += 1
    if v >= 74:
        c[4] += 1

ans = c[4]
ans += c[3]*(c[0] - 1)
ans += c[2]*(c[1] - 1)
ans += comb(c[1], 2)*(c[0]-2)
print(ans)


Measured memory_bytes: 3064
NKQ= input().split(" ")
N = int(NKQ[0])
K = int(NKQ[1])
Q = int(NKQ[2])
LIST = []

for i in range(0, N):
    LIST.append(K)

for i in range(0, Q):
    offset = int(input()) - 1
    LIST[offset] += 1
        
for i in LIST:
    if i - Q >= 1:
        print("Yes")
    else:
        print("No")
    

Measured memory_bytes: 6584
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
int a[1000005];
int len_p[100005];
int len_m[100005];

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(int i=0;i<n-1;i++){
		if(a[i]>a[i+1])len_m[i]++;
		if(a[i]<a[i+1])len_p[i]++;
	}
	for(int i=n-1;i>=0;i--){
		if(len_m[i]>0){
			len_m[i]+=len_m[i+1];
		}
		if(len_p[i]>0){
			len_p[i]+=len_p[i+1];
		}
		if(len_m[i]==0 && len_p[i]==0){
			len_m[i]+=len_m[i+1];
			len_p[i]+=len_p[i+1];
		}
	}
	int res=0;
	for(int i=0;i<n;i++){
		res=max(res,len_p[i]+len_m[i]);
	}
	printf("%d\n",res+1);
	return 0;
}

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

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

  // ここにプログラムを追記
  sum = (1 + N) * N / 2;
  
  long long a = N % 3;
  long long b = N / 3; 
  sum -= (3 + (N - a)) * b / 2;  
  // (3 + 6) * N / 2
  
  long long c = N % 5;
  long long d = N / 5;
  sum -= (5 + (N - c)) * d / 2;
  // (5 + 15) * 3 / 2
  
  long long e = N % 15;
  long long f = N / 15;
  sum += (15 + (N - e)) * f / 2;
  // (15 + 15) * 

  cout << sum << endl;  
}


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

using namespace std;

using ll = long long;

constexpr char newl = '\n';

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

    int l, r, d;
    cin >> l >> r >> d;
    --l;
    cout << r / d - l / d << newl;

    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

int32_t main()
{
	IOS;
	int m, d;
	cin >> m >> d;
	int ans = 0;
	for(int i = 2; i <= 9; i++)
	{
		for(int j = 2; j <= 9; j++)
		{
			int cur = i * 10 + j;
			if(cur > d)
				continue;
			int curm = i * j;
			if(curm <= m)
				ans++;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SC               scanf
#define PF               printf
#define ull              unsigned long long
#define ld               long double
#define D                double
#define F                first
#define S                second
#define pb               push_back
#define pf               push_front
#define MP               make_pair
#define sort_a(a)        sort(a.begin(),a.end());
#define sort_d(a)        sort(a.rbegin(),a.rend());
#define READ(f)          freopen(f, "r", stdin)
#define WRITE(f)         freopen(f, "w", stdout)
#define rev(s)           reverse(s.begin(),s.end())
#define it(it,mp)        for(auto it=mp.begin() ; it!=mp.end() ; it++)
#define IOS              ios_base :: sync_with_stdio(false); cin.tie(NULL);
const int N = 1e5 + 5;
const int inf = 1e9 + 1;
const double eps = 1e-15;
const double EPS = 1e-9;
const double PI = acos(-1.0);
typedef long long int                   ll;
typedef pair<int,int>                   PII;
int main()
{
    IOS
    //READ("0test.txt");
    //WRITE("");
     int n ;
     cin >> n ;
     map<string,int>mp;
     string s ;
     while(n--){
            cin >> s ;
        mp[s]++;
     }
     int mx = 0 ;
     for(auto it : mp){
        mx = max(it.S,mx) ;
     }
      for(auto it : mp){
        if(it.S==mx)cout<<it.F<<"\n";
     }
    return 0;
}


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

using namespace std;

#define Rep(i,a,b)  for (int i=(a);i<(b);i++)
#define rep(i,n)    for (int i=0;i<(n);i++)
#define all(x)      (x).begin(), (x).end()

#define ll long long

int main()
{
	string s;
	cin >> s;
	int ans = 0 + count(all(s), '+') - count(all(s), '-');
	cout << ans << endl;
}



Measured memory_bytes: 256
import java.util.*;

 
class Main {
 
    private static Scanner sc = new Scanner(System.in);
 
    public static void main(String[] args) {
        String s = sc.next();
        //String s2 = sc.next();
        //int x =Integer.parseInt(s);
        String ans="";
        if(s.equals("A")){
            ans="T";
        }else if(s.equals("T")){
            ans="A";
        }else if(s.equals("C")){
            ans="G";
        }else{
            ans="C";
        }
        //String s = String.valueOf(i);
        //int i = Integer.parseInt(s);
        //System.out.println((s + s).contains(s2) ? "Yes" : "No");
        System.out.println(ans);
        /*
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            while ((line = br.readLine()) != null) {
                String[] tokens = line.split(" ");
                int h = Integer.parseInt(tokens[0]);
                int w = Integer.parseInt(tokens[1]);
                
                }
            }
        }
        */
        
    }
}


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

int main() {
    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;

    if (a == 0) cout << '1' << endl;
    if (b == 0) cout << '2' << endl;
    if (c == 0) cout << '3' << endl;
    if (d == 0) cout << '4' << endl;
    if (e == 0) cout << '5' << endl;
    return 0;
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <ll, int> ii;
typedef pair <ii,int> iii;

const ll inf = 1e17;
const ll mod = 1e9 + 7;
const int N = 200005;

void solve(){
	int n, m, k, ans = 0;
	cin >> n >> m >> k;
	vector<ll> a(n), b(m);
	for(int i = 0; i < n; i++){
		cin >> a[i];
		if(i)a[i] += a[i-1];
	}
	for(int i = 0; i < m; i++){
		cin >> b[i];
		if(i) b[i] += b[i-1];
		if(b[i] <= k) ans = max(ans, i+1);
	}
	for(int i = 0; i < n; i++){
		if(a[i] > k) break;
		ll newk = k - a[i];
		int pos = lower_bound(all(b), newk+1) - b.begin(); // pego qualquer b[i] que seja <= newk
		ans = max(ans, i + pos + 1);
	}
	cout << ans << endl;
}

int main(){
	fastio;
	int t = 1;
	//cin >> t;
	while(t--)
		solve();
	return 0;
}


Measured memory_bytes: 6356
#include<bits/stdc++.h>
using namespace std;int n,m,l,x;main(){cin>>n>>m;int a[2*n];for(int i=0;i<2*n;i++)cin>>a[i];sort(a,a+2*n);for(int i=2*n-1;i>l;i--){while(a[i]+a[l]<m&&l<i-1)l++;if(a[i]+a[l]>=m){a[i]-=m;l++;}}sort(a,a+2*n);for(int i=0;i<n;i++)x=max(x,a[i]+a[2*n-i-1]);cout<<x<<endl;}

Measured memory_bytes: 1152
A,B,M=map(int,input().split())
a=input().split()
A=list(a)
b=input().split()
B=list(b)
ab=int(min(A))+int(min(B))

X=list()
Y=list()
C=list()
for i in range(M):
  x,y,c=map(int,input().split())
  X.append(x)
  Y.append(y)
  C.append(c)
ans=list()
for i in range(M):
  xx=int(X[i])-1
  yy=int(Y[i])-1
  cc=int(C[i])
  num=int(A[xx])+int(B[yy])-cc
  ans.append(num)
Ans=int(min(ans))
print(min(ab,Ans))

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


int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int max_n = max(max(a,b), c);

	if ((a+b+c-max_n)%2 == 0) {
		cout << (3*max_n-a-b-c)/2 << endl;
	}
	else {
		cout << (3*max_n-a-b-c+1)/2+1 << endl;
	}

}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
 
int W, H, x, y;
 
int main(int argc, char const* argv[])
{
    std::cin >> W >> H >> x >> y;
    
    std::cout << double(W)*double(H)/2 << " ";
 
    if (W == x + x && H == y + y) {
        std::cout << 1 << std::endl;
    }
    else {
        std::cout << 0 << std::endl;
    }
 
    return 0;
}


Measured memory_bytes: 256
N=int(input())
num1=0
am=0
a2=0
for x in range(N):
  a=int(input())
  if am<a:
    a2=am
    num1=x
    am=a
  elif a2<a:
    a2=a
for y in range(N):
  if y==num1:
    print(a2)
  else:
    print(am)
  

Measured memory_bytes: 9292
from collections import deque
import numpy as np


def bfs(y, x, H, W, S):
    dirs = [(-1, 0), (0, -1), (1, 0), (0, 1)]
    depth = -np.ones((H+2, W+2), dtype=np.int64)
    q = deque()
    q.append((y, x))
    depth[y][x] = 0
    max_depth = 0
    while q:
        y, x = q.popleft()
        max_depth = max(max_depth, depth[y][x])
        for dy, dx in dirs:
            ny, nx = y + dy, x + dx
            if depth[ny][nx] == -1 and S[ny][nx] == '.':
                depth[ny][nx] = depth[y][x] + 1
                q.append((ny, nx))
    return max_depth


def solve():
    H, W = map(int, input().split())
    S = list()
    S.append(['#'] * (W+2))
    for _ in range(H):
        buf = input()
        S.append(list('#' + buf + '#'))
    S.append(['#'] * (W+2))

    dist_max = 0
    for y in range(H):
        for x in range(W):
            if S[y+1][x+1] == '.':
                d = bfs(y+1, x+1, H, W, S)
                dist_max = max(d, dist_max)
    print(dist_max)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 12520
# Consider sardines as vectors in 2D plane,
# and grouping them by their tangent(B[i] / A[i]).
Mod = 1000000007
N = gets.to_i
zs = 0 # count of zero vectors
X = []
Y = []
(0...N).each{ 
  a,b = gets.split.map &:to_i
  if a == 0 && b == 0
    zs += 1; next
  end

  # limitate arg into [0,pi)
  if b < 0
    a = -a; b = -b;
  end
  if b == 0 && a < 0
    a = -a
  end
  if a > 0
    # arg in [0,pi/2)
    g = a.gcd(b)
    X << "#{b/g}/#{a/g}"
  else
    # arg in [pi/2,pi)
    # -> rotate -pi/2
    a,b = b,-a
    g = a.gcd(b)
    Y << "#{b/g}/#{a/g}"
  end
}

xh = {} # count of finite-positive tangents
yh = {} # count of infinite or negative tangents
args = {} # all tangents
X.each{ |arg| args[arg] = 1; xh[arg] = (xh[arg] || 0) + 1 }
Y.each{ |arg| args[arg] = 1; yh[arg] = (yh[arg] || 0) + 1 }

bins = [1] # bins[i] = 2^i
(N+1).times{ bins << ((bins[-1] * 2) % Mod) }

ans = args.keys.reduce(1){ |s,arg|
  x = xh[arg] || 0
  y = yh[arg] || 0
  s = s * (bins[x] + bins[y] - 1)
  s % Mod
} + zs - 1
p ans % Mod


Measured memory_bytes: 69620
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
	char a[2314];
	gets(a);
	int l=999999;
	for (int i=0;i<=strlen(a);i++)
	{
		if(a[i]=='C')
		{
			l=i;
		}
		if(a[i]=='F'&&i>l)
		{
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
}

Measured memory_bytes: 256
al = input().split()
bl = input().split()
cl = input().split()
al = [int(i) for i in al]
bl = [int(i) for i in bl]
cl = [int(i) for i in cl]
h1 = [0,0,0]
h2 = [0,0,0]
h3 = [0,0,0]
n = int(input())
for h in range(n):
  m = int(input())
  ac = 0
  bc = 0
  cc = 0
  for i in al:
    if i == m:
      h1[ac] = 1
    ac += 1
  for i in bl:
    if i == m:
      h2[bc] = 1
    bc += 1
  for i in cl:
    if i == m:
      h3[cc] = 1
    cc += 1
if h1 == [1,1,1]:
  print("Yes")
elif h2 == [1,1,1]:
  print("Yes")
elif h3 == [1,1,1]:
  print("Yes")
elif h1[0]==1 and h2[0]==1 and h3[0]==1:
  print("Yes")
elif h1[1]==1 and h2[1]==1 and h3[1]==1:
  print("Yes")
elif h1[2]==1 and h2[2]==1 and h3[2]==1:
  print("Yes")
elif h1[0]==1 and h2[1]==1 and h3[2]==1:
  print("Yes")
elif h1[2]==1 and h2[1]==1 and h3[0]==1:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		int N;
		Scanner scanner = new Scanner(System.in);

		N = scanner.nextInt();

		if(N == 1) {
			System.out.println("Hello World");
		} else if (N == 2) {
			int A = scanner.nextInt();
			int B = scanner.nextInt();
			System.out.println(A + B);
		}
	}

}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
void YESNO(bool), YesNo(bool);
template <class T1, class T2>
bool chmin(T1 &l, const T2 &r);
template <class T1, class T2>
bool chmax(T1 &l, const T2 &r);
void solve(long long N, long long M, long long L, std::vector<long long> A,
           std::vector<long long> B, std::vector<long long> C, long long Q,
           std::vector<long long> s, std::vector<long long> t)
{
  lli inf = 1e17;
  vector<vector<lli>> d1(N, vector<lli>(N, inf));
  vector<vector<lli>> d2(N, vector<lli>(N, inf));
  rep(i, M) A[i]--, B[i]--;
  rep(i, N) d1[i][i] = d2[i][i] = 0;
  rep(i, M) d1[A[i]][B[i]] = d1[B[i]][A[i]] = C[i];
  rep(k, N) rep(i, N) rep(j, N)
      chmin(d1[i][j], d1[i][k] + d1[k][j]);
  rep(i, N) rep(j, N)
  {
    d2[i][j] = (d1[i][j] == 0) ? 0 : (d1[i][j] <= L ? 1 : inf);
  }
  rep(k, N) rep(i, N) rep(j, N)
      chmin(d2[i][j], d2[i][k] + d2[k][j]);
  rep(i, Q)
  {
    auto d = d2[s[i] - 1][t[i] - 1];
    cout << (d < inf ? d - 1 : -1) << endl;
  }
}

signed main()
{
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  long long L;
  scanf("%lld", &L);
  std::vector<long long> A(M);
  std::vector<long long> B(M);
  std::vector<long long> C(M);
  for (int i = 0; i < M; i++)
  {
    scanf("%lld", &A[i]);
    scanf("%lld", &B[i]);
    scanf("%lld", &C[i]);
  }
  long long Q;
  scanf("%lld", &Q);
  std::vector<long long> s(Q);
  std::vector<long long> t(Q);
  for (int i = 0; i < Q; i++)
  {
    scanf("%lld", &s[i]);
    scanf("%lld", &t[i]);
  }
  solve(N, M, L, std::move(A), std::move(B), std::move(C), Q, std::move(s),
        std::move(t));
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2>
bool chmin(T1 &l, const T2 &r)
{
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2>
bool chmax(T1 &l, const T2 &r)
{
  return (l < r) ? (l = r, true) : false;
}


Measured memory_bytes: 4352
import java.util.Scanner;
import static java.lang.Math.PI;

public class Main{
	private static Scanner scan;
	public static void main(String[] args) {
		scan = new Scanner(System.in);
		scan.useDelimiter(",|\\s+");
		double x = 0,y = 0;
		int 慮 = 90;
		while(true){
			int r = Integer.parseInt(scan.next());
			int 慮s = Integer.parseInt(scan.next());
			if(r == 0 && 慮s == 0)break;
			x = x + r * Math.cos(慮 * PI / 180);
			y = y + r * Math.sin(慮 * PI / 180);
			慮 = 慮 - 慮s;
		}
		System.out.println((int)x);
		System.out.println((int)y);
		System.exit(0);
	}

}

Measured memory_bytes: 11000
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    n = int(input())
    ans = 0
    for i in range(105, n + 1, 2):
        c = 0
        for j in range(1, i + 1):
            if i % j == 0:
                c += 1
        if c == 8:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <string>
using namespace std;
int dp[1000][1000];
int main(){
	int n,m,c[1000],d[1000];
	cin>>n>>m;
	for(int i=0;i<n;i++)
		cin>>d[i];
	for(int i=0;i<m;i++)
		cin>>c[i];
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
			dp[i][j]=0;
	dp[1][0]=d[0]*c[0];
	for(int i=2;i<=n;i++)
		dp[i][0]=1000000000;
	for(int i=1;i<=n;i++){
		for(int j=1;j<m;j++){
			if(j==0)
				dp[i][0]=dp[i-1][0]+d[i-1]*c[j];
			else if(dp[i][j-1]<=dp[i-1][j-1]+d[i-1]*c[j])
				dp[i][j]+=dp[i][j-1];
			else
				dp[i][j]+=dp[i-1][j-1]+d[i-1]*c[j];
		}
	}
	cout<<dp[n][m-1]<<endl;
	return 0;
}

Measured memory_bytes: 4340
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define All(A) A.begin(),A.end()
#define RAll(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<double,double> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const LL INF=1<<30;

int dp[100001][201];

int main(){
    int N;
    int W;
    cin >> N >> W;
    vector<int> w(N);
    for(int i=0;i<N;i++){
        cin >> w[i];
    }
    sort(All(w));
    memset(dp,0,sizeof(dp));
    dp[0][0]=1;
    for(int i=0;i<N;i++){
        for(int j=W;j>=0;j--){
            for(int k=0;k<=i;k++){
                if(dp[j][k]==0) continue;
                if(k==0){
                    if(j+w[i]<=W) dp[j+w[i]][k]=(dp[j+w[i]][k]+dp[j][k])%mod;
                    dp[j][i+1]=(dp[j][i+1]+dp[j][k])%mod;
                    dp[j][k]=0;
                }
                else{
                    if(j+w[i]<=W) dp[j+w[i]][k]=(dp[j+w[i]][k]+dp[j][k])%mod;
                }
            }
        }
    }
    LL ans=0;
    for(int i=0;i<=W;i++){
        for(int j=0;j<=N;j++){
            if(j==0){
                ans=(ans+dp[i][j])%mod;
            }
            else{
                if(w[j-1]>W-i){
                    ans=(ans+dp[i][j])%mod;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 81676
#include<bits/stdc++.h>
#define il inline
#define stt static
#define rg register
#define ll long long
#define db double
#define pii pair<int,int>
#define mp make_pair
#define fst first
#define snd second
#define pb push_back
#define y1 substitute_of_y1
#define DEBUG(x) cerr<<#x" = "<<x<<endl;
using namespace std;

template<typename T> il T rd(){
	T nmb=0;int sgn=0;char chr=getchar();
	while(!isdigit(chr)){if(chr=='-')sgn=1;chr=getchar();}
	while(isdigit(chr)){nmb=(nmb<<3)+(nmb<<1)+chr-'0';chr=getchar();}
	return sgn?-nmb:nmb;
}
template<typename T> void wt(T nmb){
	if(nmb>9)wt(nmb/10);
	putchar(nmb%10+'0');
}
template<typename T> il void cmax(T &x,T y){x=x>y?x:y;}
template<typename T> il void cmin(T &x,T y){x=x<y?x:y;}
inline void proc_status(){
	ifstream t ("/proc/self/status");
	cerr<<string(istreambuf_iterator<char>(t),istreambuf_iterator<char>())<<endl;
	/*freopen("/proc/self/status","r",stdin);
	char ch[100];
	while(scanf("%s",ch)!=EOF)cerr<<ch<<endl;*/
}

const int N=5e5+10;
const int P=998244353;

int fac[N],inv[N];
il int pwr(int x,int y){
	int z=1;
	for(;y;y>>=1,x=(ll)x*x%P)
		if(y&1)z=(ll)z*x%P;
	return z;
}
il void getfac(int n){
	fac[0]=1;
	for(int i=1;i<=n;++i)
		fac[i]=(ll)fac[i-1]*i%P;
	inv[n]=pwr(fac[n],P-2);
	for(int i=n;i;--i)
		inv[i-1]=(ll)inv[i]*i%P;
}
il int C(int n,int m){
	if(n<0||m<0||n<m)return 0;
	return (ll)fac[n]*inv[m]%P*inv[n-m]%P;
}

int main(){
	int n=rd<int>(),m=rd<int>();
	getfac(max(n,m));
	int Ans=0;
	for(int i=0,lim=min(n,m);i<=lim;++i)
		(Ans+=(ll)(i&1?P-1:1)*C(n,i)%P*C(m,i)%P*fac[i]%P*pwr(n+1,m-i)%P*pwr(m+1,n-i)%P)%=P;
	printf("%d\n",Ans);
	return 0;
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

  int h,w,a,b; cin >> h >> w >> a >> b;
  swap(a,b);
  static int dp[1001][1001];
  for(int i = 0; i < min(a,h-a); i++){
    for(int j = max(b,w-b); j < w; j++){
      dp[i][j] = 1;
    }
  }

  for(int i = max(0LL,min(a,h-a)); i < h; i++){
    for(int j = 0; j < max(b,w-b); j++){
      dp[i][j] = 1;
    }
  }

  bool check = true;
  for(int i = 0; i < h; i++){
    int cnt = 0;
    for(int j = 0; j < w; j++){
      if(dp[i][j] == 1) cnt++;
    }
    if(min(cnt,w-cnt) != b) check = false;
  }
  for(int i = 0; i < w; i++){
    int cnt = 0;
    for(int j = 0; j < h; j++){
      if(dp[j][i] == 1) cnt++;
    }
    if(min(cnt,h-cnt) != a) check = false;
  }

  if(check){
    for(int i = 0; i < h; i++){
      for(int j = 0; j < w; j++){
        cout << dp[i][j];
      }
      cout << endl;
    }
  }else {
    cout << "No" <<  endl;
  }

  return 0;
}


Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;
const LL mod = 1e9 + 7;
const int N = 200005;

vector<int> G[N];
int d[N];
void dfs(int u, int fa) {
    for (auto v : G[u]) {
        if (v == fa) continue;
        d[v] = d[u] + 1;
        dfs(v, u);
    }
}
vector<int> a[N];
int ans[N];
int main() {
    int n;
    cin >> n;
    for (int i = 1; i < n; i++) {
        int u, v;
        cin >> u >> v;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    dfs(1, 0);
    int m = 0;
    for (int i = 1; i <= n; i++) {
        a[d[i]].push_back(i);
        m = max(m, d[i]);
    }
    int x = 1, y = 2, z = 3;
    int sum = 0;
    for (int i = 0; i <= m; i += 2) {
        sum += a[i].size();
    }
    if (n - sum <= n / 3) {
        for (int i = 1; i <= m; i += 2) {
            for (auto j : a[i]) {
                ans[j] = z;
                z += 3;
            }
        }
        for (int i = 0; i <= m; i += 2)
            for (auto j : a[i]) {
                if (x <= n) {
                    ans[j] = x;
                    x += 3;
                } else if (y <= n) {
                    ans[j] = y;
                    y += 3;
                } else {
                    ans[j] = z;
                    z += 3;
                }
            }
    } else if (sum <= n / 3) {
        for (int i = 0; i <= m; i += 2) {
            for (auto j : a[i]) {
                ans[j] = z;
                z += 3;
            }
        }
        for (int i = 1; i <= m; i += 2)
            for (auto j : a[i]) {
                if (x <= n) {
                    ans[j] = x;
                    x += 3;
                } else if (y <= n) {
                    ans[j] = y;
                    y += 3;
                } else {
                    ans[j] = z;
                    z += 3;
                }
            }
    } else {
        for (int i = 0; i <= m; i++) {
            for (auto j : a[i]) {
                if (i % 2 == 0) {
                    if (x <= n) {
                        ans[j] = x;
                        x += 3;
                    } else if (z <= n) {
                        ans[j] = z;
                        z += 3;
                    } else {
                        ans[j] = y;
                        y += 3;
                    }
                } else {
                    if (y <= n) {
                        ans[j] = y;
                        y += 3;
                    } else if (z <= n) {
                        ans[j] = z;
                        z += 3;
                    } else {
                        ans[j] = x;
                        x += 3;
                    }
                }
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        printf("%d%c", ans[i], " \n"[i == n]);
    }
    return 0;
}


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

typedef long long ll;

string s1;
string s2;
ll n1;
ll n2;
ll memo[3001][3001];

char mm[3001][3001];
int mm1[3001][3001];

ll func(ll i,ll j)
{
	if(i == n1-1 || j == n2-1)
	{
		if(s1[i] == s2[j])
			{
				mm[i][j]=s1[i];
				mm1[i][j]=0;
				return 1;
			}
		else
		{
			if(i==n1-1)
			{
				while( j != n2-1)
				{
					if(s1[i] == s2[j])
					{
						mm[i][j]=s1[i];
						mm1[i][j]=0;
						return 1;
					}
					j++;
				}
				if(s1[i] == s2[j])
				{
					mm[i][j]=s1[i];
					mm1[i][j]=0;	
					return 1;
				}
				else
					return 0;
			}
			else
			{
				while( i != n1-1)
				{
					if(s1[i] == s2[j])
					{	
						mm[i][j]=s1[i];
						mm1[i][j]=0;
						return 1;
					}
					i++;
				}
				if(s1[i] == s2[j])
					{
						mm[i][j]=s1[i];
						mm1[i][j]=0;
						return 1;
					}
				else
					return 0;
			}
		}
	}
	if(memo[i][j]!=-1)
		return memo[i][j];
	
	if(s1[i] == s2[j])
	{
		memo[i][j]=1+func(i+1,j+1);
		//mm[i][j]=make_pair(i+1,j+1);
		mm[i][j]=s1[i];
		mm1[i][j]=0;
		return memo[i][j];
	}
	else
	{
		ll tt=func(i+1,j);
		ll t1=func(i,j+1);
		memo[i][j]=max(tt,t1);
		if(tt>t1)
			mm1[i][j]=1;
		else
			mm1[i][j]=2;
		return memo[i][j];
	}
 }


int main() 
{
 	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifdef DEBUG
     		freopen("input.txt", "rt", stdin);
 	#endif
	cin >> s1;
	cin >> s2;
	s1+='a';
	s2+='z';
	n1=s1.length();
	n2=s2.length();

	for(int i=0;i<3001;i++)
	{
		for(int j=0;j<3001;j++)
		{
			memo[i][j]=-1;
			mm[i][j]='1';
			mm1[i][j]=-1;
		}
	}
	
	ll vv = func(0,0);
	int i=0;
	int j=0;
	int count=0;
	// for(int i=0;i<30;i++)
	// {
	// 	for(int j=0;j<30;j++)
	// 	{
	// 		cout<<mm[i][j]<<" ";
	// 	}
	// 	cout<<"\n";
	// }
	while(mm1[i][j]!=-1)
	{
		if(mm1[i][j]==0)
		cout<<mm[i][j];
		if(mm1[i][j]==0)
		{
			i++;
			j++;
		}
		else if(mm1[i][j]==1)
		{
			i++;
		}
		else
		{
			j++;
		}
	}
	cout<<"\n";
 	return 0;	
}

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

int main(void) {

    int n, m;
    cin >> n >> m;

    if (n % 2 == 0) {
        int half = n / 2;
        int oddMax, evenMax;
        if (half % 2 == 0) {
            oddMax = half - 1;
            evenMax = half - 2;
        }
        else {
            oddMax = half - 2;
            evenMax = half - 1;
        }
        int aOdd = 1;
        int bOdd = 1 + oddMax;
        int aEven = oddMax + 2;
        int bEven = aEven + evenMax;
        for (int i = 1; i <= m; i++) {
            if (i % 2 == 0) {
                cout << aEven << " " << bEven << endl;
                aEven++;
                bEven--;
            }
            else {
                cout << aOdd << " " << bOdd << endl;
                aOdd++;
                bOdd--;
            }
        }
    }
    else {
        int a = 1;
        int b = n - 1;
        for (int i = 0; i < m; i++) {
            cout << a << " " << b << endl;
            a++;
            b--;
        }
    }

    return 0;

}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n >> s;
    vector<int> e_ruiseki(n);
    vector<int> w_ruiseki(n);
    if (s[0] == 'E')
    {
        e_ruiseki[0] = 1;
        w_ruiseki[0] = 0;
    }
    else
    {
        e_ruiseki[0] = 0;
        w_ruiseki[0] = 1;
    }
    for (int i = 0; i < n - 1; i++)
    {
        if (s[i + 1] == 'E')
        {
            e_ruiseki[i + 1] = e_ruiseki[i] + 1;
            w_ruiseki[i + 1] = w_ruiseki[i];
        }
        else
        {
            e_ruiseki[i + 1] = e_ruiseki[i];
            w_ruiseki[i + 1] = w_ruiseki[i] + 1;
        }
    }

    int ans;
    ans = e_ruiseki[n - 1] - e_ruiseki[0];
    for (int i = 1; i < n; i++)
    {
        int tmp = 0;
        tmp += w_ruiseki[i - 1];
        tmp += e_ruiseki[n - 1] - e_ruiseki[i];
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}

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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}


void dfs(int a, int edges, const vector<vector<int>>& adj, vector<bool>& vis) {
        if (edges == 2 && a == adj.size() - 1) {
                cout << "POSSIBLE\n";
                exit(0);
        }
        if (edges > 2) return;
        vis[a] = 1;
        for (auto b: adj[a]) {
                if (!vis[b]) {
                        dfs(b, edges + 1, adj, vis);
                }
        }
}


void _main() {
        int n, m; cin >> n >> m;
        vector<vector<int>> adj(n + 1);
        while (m--) {
                int a, b; cin >> a >> b;
                adj[a].emplace_back(b);
                adj[b].emplace_back(a);
        }

        vector<bool> vis(n + 1);
        dfs(1, 0, adj, vis);
        cout << "IMPOSSIBLE";
}




signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


Measured memory_bytes: 15208
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();
    int Q = sc.nextInt();
    String S = sc.next();
    
    int[] l = new int[Q];
    int[] r = new int[Q];

    for (int i = 0; i < Q; i++) {
      l[i] = sc.nextInt();
      r[i] = sc.nextInt();
    }

    sc.close();

    String[] s = S.split("");

    int[] ac = new int[N+1];
    
    ac[0] = 0;
    ac[1] = 0;

    for (int i = 1; i < N; i++){
      if (s[i-1].equals("A") && s[i].equals("C")) {
        ac[i+1] = ac[i] + 1; 
      } else {
        ac[i+1] = ac[i];
      }
    }

    for (int i = 0; i < Q; i++){
      System.out.println(ac[r[i]] - ac[l[i]]);
    }

  }

}

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

int main() {
  string a, b, c;
  bool flag;
  int a_length = 0;
  int b_length = 0;
  int c_length = 0;
  int turn = 0;

  cin >> a >> b >> c;

  flag = true;
  while (flag)
  {
    if (turn == 0)
    {
      a_length++;

      if (a_length > a.length()) flag = false;

      if (a[a_length - 1] == 'a') turn = 0;
      else if (a[a_length - 1] == 'b') turn = 1;
      else turn = 2;
    }
    else if (turn == 1)
    {
      b_length++;

      if (b_length > b.length()) flag = false;

      if (b[b_length - 1] == 'a') turn = 0;
      else if (b[b_length - 1] == 'b') turn = 1;
      else turn = 2;
    }
    else if (turn == 2)
    {
      c_length++;

      if (c_length > c.length()) flag = false;

      if (c[c_length - 1] == 'a') turn = 0;
      else if (c[c_length - 1] == 'b') turn = 1;
      else turn = 2;
    }
  }

  if (a_length > a.length()) cout << 'A' << endl;
  else if (b_length > b.length()) cout << 'B' << endl;
  else cout << 'C' << endl;
}

Measured memory_bytes: 888
#include <string>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <climits>
#include <cfloat>

using namespace std;

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

const int INF = INT_MAX;

typedef long long LL;
typedef pair<int,int> P;


int main(){
    double w;
    while(cin>>w){
        if(w<=48){
            cout << "light fly" << endl;
        }else if(w<=51){
            cout << "fly" << endl;
        }else if(w<=54){
            cout << "bantam" << endl;
        }else if(w<=57){
            cout << "feather" << endl;
        }else if(w<=60){
            cout << "light" << endl;
        }else if(w<=64){
            cout << "light welter" <<endl;
        }else if(w<=69){
            cout << "welter" << endl;
        }else if(w<=75){
            cout << "light middle" << endl;
        }else if(w<=81){
            cout << "middle" << endl;
        }else if(w<=91){
            cout << "light heavy" << endl;
        }else{
            cout << "heavy" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#define pb push_back
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

int main() {
    int i, n, ans=0;
    scanf("%d", &n);
    vpii x(n);
    for(i=0; i<n; i++) {
        x[i].sc=i;
        scanf("%d", &x[i].fs);
    }
    sort(all(x));
    for(i=0; i<n; i++) if((x[i].sc^i)&1) ans++;
    printf("%d\n", ans/2);
    return 0;
}

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

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int y = sc.nextInt();

        for (int i = 0; i <= n; i++) {
            for (int j = 0; j <= n - i; j++) {
                int k = n - j - i;
                if (10000 * i + 5000 * j + 1000 * k == y) {
                    System.out.println(i + " " + j + " " + k);
                    return;
                }
            }
        }
        System.out.println("-1 -1 -1");
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }

}


Measured memory_bytes: 24660
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

int main(){
  using namespace std;
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  int pow_mod=1;
  int sum=0, ans=0, cnt;
  vector<int> mod;
  vector<int> modLast;
  cin >> s;
  // 1文字ずつの余りをチェックしていく
  for(int i=(int)s.length()-1; i>=0; i--){
    //cout << s[i] << endl;
    mod.push_back((pow_mod*(int)(s[i]-'0'))%2019);
    //cout << (int)(s[i]-'0') << " " << pow_mod << " " << (pow_mod*(int)(s[i]-'0'))%2019 << endl;
    pow_mod=(pow_mod*10)%2019;
  }
  // まず、最後の文字を固定した場合の余りを全て求める
  modLast.push_back(0);
  for(int i=1; i<=(int)s.length(); i++){
    sum=(sum+mod[i-1])%2019;
    modLast.push_back(sum);
  }
  //cout << count(modLast.begin(), modLast.end(), 0) << endl;
  for(int i=0; i<2019; i++){
    cnt = (int)count(modLast.begin(), modLast.end(), i);
    if(cnt>=2){
      ans += (cnt*(cnt-1))/2;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5652
N=int(input())
W=list(map(int,input().split()))

S_t=[0]*N
tmp=0
ans=10000000
for t in range(N):
  tmp+=W[t]
  S_t[t]=tmp
  
Sum=S_t[N-1]
for t in range(N):
  S1=S_t[t]
  S2=Sum-S1
  if abs(S1-S2)<ans:
    ans = abs(S1-S2)

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e18 + 3)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int x;
    cin >> x;
    cout << x * x << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
const int INF = 0x3f3f3f3f;
const double pi = acos(-1);
using ll = long long;
using namespace std;

ll n;
int main() {
    scanf("%lld", &n);
    ll mn = 1e12;
    for (ll i = 1; i*i <= n; ++i) {
        if (n%i == 0) {
            mn = min(mn, i-1 + n/i-1);
        }
    }
    printf("%lld\n", mn);
    return 0;
}





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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++) 
#define ll long long
#define ld long double
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)  
#define outdeb(fir, sec, thr) cout << fir << ":" << sec << ":" << thr << endl

void greatFirst(int& a, int& b)
{
  if(a < b)
  {
    int tmp = a;
    a = b;
    b = tmp;
  }
}

int main()
{
  ll h, w;
  cin >> h >> w ;
  int a[h][w];
  rep(i,h){
    string tmp;
    cin >> tmp;
    rep(j,w)
    {
      if(tmp[j] == '.')
      {
        a[i][j] = 0;
      }
      else
      {
        a[i][j] = 1;
      }
    }
  }
  
  int dp[h][w];
  dp[0][0] = 0;
  rep(i, h)
  {
    rep(j, w)
    {
      if(i ==0 && j==0) continue;
      int tmp = 999999;
      if(i > 0)
      {
        if(a[i][j] == a[i-1][j])
        {
          tmp = min(tmp, dp[i-1][j]);
        }
        else
        {
          tmp = min(tmp, dp[i-1][j]+1);
        }
      }
      if(j > 0)
      {
        if(a[i][j] == a[i][j-1])
        {
          tmp = min(tmp, dp[i][j-1]);
        }
        else
        {
          tmp = min(tmp, dp[i][j-1]+1);
        }
      }
      dp[i][j] = tmp;
    }
  }
  int ans = ((dp[h-1][w-1] / 2) + (dp[h-1][w-1] % 2));
  if(a[0][0] == 1 && a[h-1][w-1] == 1)
  {
    ans++;
  }
  
  cout << fixed << ans << endl;
  
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <math.h>
#include <cmath>
#include <stdio.h>
#define   pi   3.1415926535
using namespace std;

int main(){
	double a, b, C, S, L, h, cs, cc;

	cin>>a>>b>>C;
	C = C * pi / 180;
	cs = sin(C);
	cc = cos(C);

	S = a * b * cs / 2;
	L = a + b + sqrt(a*a + b*b - 2*a*b*cc);
	h = b * cs;

	printf("%.8lf\n%.8lf\n%.8lf\n", S, L, h);

	return 0;
}

Measured memory_bytes: 1240
import java.io.*;

class Main{
	public static void main(String[] args){
		// System.out.println("Please enter a and b");
		try{
			BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
			String str = buf.readLine();
			String[] ent = str.split(" ");
			int a = Integer.parseInt(ent[0]);
			int b = Integer.parseInt(ent[1]);

			if ( a < b ){
				System.out.println("a < b");
			}else if( a > b ){
				System.out.println("a > b");
			}else{
				System.out.println("a == b");
			}
		} catch(IOException e){
			System.out.println("入力がおかしいです。");
		}

	}
}


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

using namespace std;


int main(int argc, char** argv){
    int N;
    cin >> N;
    int a = 0, b = 0, c = 0;
    int internals = 0;
    for (int i=0; i<N; i++){
        string s;
        cin >> s;
        if (s[0] == 'B'){
            if (s[s.length()-1] == 'A') c++;
            else b++;
        } else if (s[s.length()-1] == 'A') a++;
        for (size_t j=0; j<s.length()-1; j++)
            if (s[j] == 'A' && s[j+1] == 'B')
                internals++;
    }
    if (a == 0 && b == 0 && c > 0) c--;
    int ans = min(a, b) + c + internals;
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 256