akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
using namespace std;

int main(void){
  int mm=0;
  int nn=0;
  scanf("%d",&nn);
  scanf("%d",&mm);
  int i=0;
  int n[100005]={0};
  for(i=1;i<nn;i++){
    scanf("%d",&(n[i]));
    n[i]+=n[i-1];
  }
  int ans=0;
  int im=0;
  int is=0;
  for(i=0;i<mm;i++){
    scanf("%d",&(im));
    im+=is;
    ans=(abs(n[im]-n[is])+ans)%100000;
    is=im;
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 1424
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s;
	ll k;
	cin >> s >> k;
	int n = s.size();
	ll ans = 0;
	if (s == string(n, s[0]))
		ans = k * n / 2;
	else {
		vector<int> vec; 
		for (int i = 0; i < n - 1; i++) {
			int j = i;
			while (s[i] == s[i + 1])
				i++;
			vec.push_back(i - j + 1);
		}
		if (s[0] == s[n - 1]) {
			for (int i = 1; i < vec.size() - 1; i++) {
				ans += vec[i] / 2;
			}
			ans *= k;
			int a = vec[0], b = vec[vec.size() - 1];
			ans += a / 2 + b / 2 + (k - 1) * ((a + b) / 2);
		} else {
			for (int x : vec) {
				ans += x / 2;
			}
			ans *= k;
		}
	}
	cout << ans;
	return 0;
}

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

using namespace std;

int main(){
	string N;
	cin>>N;
	bool ans = false;
	if(N[0] == '7') ans = true;
	if(N[1] == '7') ans = true;
	if(N[2] == '7') ans = true;
	cout<< (ans?"Yes":"No") <<endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int maxAC = max(A, C);
  int minBD = min(B, D);
  int match = minBD - maxAC;
  if(match < 0){ match = 0; }
  cout << match << endl;
  return 0;
}

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

int main(){

  string A, B;
  getline(cin, A);
  getline(cin, B);

  if(A.size()>B.size()){
    cout << "GREATER" << endl;
    return 0;
  }else if(A.size() < B.size()){
    cout << "LESS" << endl;
    return 0;
  }else{
    for(int i=0; i<A.size(); i++){
      if(A[i] > B[i]){
        cout << "GREATER" << endl;
        return 0;
      }else if (A[i] < B[i]){
        cout << "LESS" << endl;
        return 0;
      }
    }
  }
  cout << "EQUAL" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int H,W,i,j;
   
    while(1){
        scanf("%d %d",&H,&W);
        if(H==0&&W==0) break;
        
        for(i=1;i<=H;i++){
            for(j=1;j<=W;j++){
                if(i!=1&&i!=H&&j!=1&&j!=W){
                    putchar('.');
                }else{
                    putchar('#');
                }
            }
            putchar('\n');
            
        }
        putchar('\n');
    }
    
    return 0;
    
}



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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)


signed main(){

	lli a,b;
	cin>>a>>b;
	cout<<max(0LL,a-2*b)<<endl;

	return 0;
}

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

int main() {
  int n, c = 0;
  cin >> n;
  
  for (int i = 1;n >= i;i++) {
    if (1 <=i && i <= 9)
      c++;
    else if (100 <= i && i <= 999)
      c++;
    else if (10000 <= i && i <= 99999)
      c++;
  }
  cout << c << endl;
}

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

void swap(int &a, int &b){
	int tmp = a;
	a = b;
	b = tmp;
	return;
}
/*
void maxHeapify(vector<int> &A, int i){
	int l = 2 * i + 1;
	int r = 2 * i + 2;
	int largest;
	if (l < A.size() && A[l] > A[i]){
		largest = l;
	}
	else{
		largest = i;
	}
	if (r < A.size() && A[r] > A[largest]){
		largest = r;
	}

	if (largest != i){
		swap(A[i], A[largest]);
		maxHeapify(A, largest);
	}
}

void buildMaxHeap(vector<int> &A){
	for (int i = A.size() / 2 - 1; i >= 0; i--){
		maxHeapify(A, i);
	}
}*/

void insert(vector<int> &A, int v){
	int n = A.size();
	A.push_back(v);
	while (n != 0){
		int i = (n - 1) / 2;
		if (A[n] > A[i]){
			swap(A[n], A[i]);
		}
		n = i;
	}
	return;
}

int extract(vector<int> &A){
	int n = A.size() - 1;
	int res = A[0];
	A[0] = A[n];
	A.pop_back();

	for (int i = 0, j; 2 * i + 1 < n;){
		j = 2 * i + 1;
		if (j != n - 1 && A[j] < A[j + 1]){
			j++;
		}
		if (A[i] < A[j]){
			swap(A[i], A[j]);
		}
		i = j;
	}
	return res;
}

int main(){
	int x;
	char com[20];
	vector<int> A;

	while(true){
		scanf("%s", com);
		if (com[1] == 'x'){
			printf("%d\n", extract(A));
		}
		else if (com[0] == 'i'){
			scanf("%d", &x);
			insert(A, x);
		}
		else if (com[2] == 'd'){
			break;
		}
	}

	return 0;
}


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

int main() {
  int A,B,C;
  cin>>A>>B>>C;
  bool ans = false;
  if(A==B && A!=C) ans =true;
  else if(A==C && A!=B) ans=true;
  else if(B==C && A!=B) ans=true;
  if(ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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


int main()
{
    int N;
    cin >> N;
    vector<double> t(N+2, 0), v(N+2, 0);
    for(int i = 1; i <= N; i++) cin >> t[i];
    for(int i = 1; i <= N; i++) cin >> v[i];
 
 
    vector<double> l(N+2, 0), r(N+2, 0);
    for(int i = 2; i < N+2; i++) l[i] = l[i-1] + t[i-1];
    for(int i = 1; i < N+2; i++) r[i] = r[i-1] + t[i];

    vector<double> maxv;
    for(double x = 0; x <= r[N+1]; x += 0.5) {
        double minv = 100;
        for(int i = 0; i < N+2; i++) {
            if( x <= l[i] )           minv = min( minv, v[i] + (l[i] - x) );
            if( l[i] < x && x < r[i]) minv = min( minv, v[i] );
            if( r[i] <= x )           minv = min( minv, v[i] + (x - r[i]) );
        }
        maxv.push_back( minv );
    }
 
    double ans = 0;
    for(int i = 1; i < maxv.size(); i++) ans += 0.5 * (maxv[i] + maxv[i-1]) / 2;
    cout << fixed << setprecision(3) << ans << endl;
 
    return 0;
}

Measured memory_bytes: 896
#include <algorithm>
#include <iostream>
#include <vector>
#include <cstdint>

int main() {
  constexpr std::int64_t kModulus = 998244353;
  int A, B, C, D;
  std::cin >> A >> B >> C >> D;
  std::vector<std::vector<std::int64_t>> mem(C, std::vector<std::int64_t>(D));
  mem[A - 1][B - 1] = 1;
  for (int j = B; j < D; ++j) {
    mem[A - 1][j] = mem[A - 1][j - 1] * A % kModulus;
  }
  for (int i = A; i < C; ++i) {
    mem[i][B - 1] = mem[i - 1][B - 1] * B % kModulus;
    for (int j = B; j < D; ++j) {
      mem[i][j] = mem[i - 1][j] * (j + 1) + mem[i][j - 1] * (i + 1);
      mem[i][j] -= mem[i - 1][j - 1] * i * j;
      mem[i][j] = (mem[i][j] % kModulus + kModulus) % kModulus;
    }
  }
  std::cout << mem[C - 1][D - 1] << std::endl;
  return 0;
}


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

# define rep(i, n) for(int(i)=0;(i)<(n);(i)++)
# define reps(i, n) for(int(i)=1;(i)<=(n);(i)++)
# define rrep(i, n) for(int i=((int)(n)); i>0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>=0; --i)
# define ALL(v) v.begin(), v.end()
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<typename T> void dump(T e){std::cout << e << std::endl;}
template<typename T> void dump(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void dump(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ dump(v); } }
typedef long long ll;


int main(){
  int x,y; cin >> x >> y;
  if (x < y) swap(x,y);
  
  int r=0;
  while((r=x%y)!=0) {
    x = y;
    y = r;
  }
  cout << y << endl;
}



Measured memory_bytes: 3080
#include <cstddef>
#include <complex>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <limits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>

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

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

int main()
{
    using namespace std;

    int n;
    cin >> n;

    vec<double> x(n);
    vec<string> u(n);

    double ans{};

    for (int i = 0; i < n; ++i)
    {
        cin >> x[i] >> u[i];
    }

    for (int i = 0; i < n; ++i)
    {
        if (u[i] == "JPY")
        {
            ans += x[i];
        }
        else
        {
            ans += x[i] * 380000.0;
        }
    }

    cout << fixed << ans << endl;
    

    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl

using namespace std;

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

const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll LINF = 1e18;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const int ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int gcd(int a, int b) {
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

int lcm(int a, int b) { return a * b * gcd(a, b); }

bool compareP(pair<int, int> a, pair<int, int> b) {
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

int main() {
    ll n, ans = 1;
    cin >> n;
    int a[100010] = {};
    a[0] = 3;
    rep(i, n) { int tmp;
        cin >> tmp;
        ans *= a[tmp];
        a[tmp]--;
        a[tmp + 1]++;
        ans %= 1000000007;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 
#define int long long
#define double long double

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

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

int n,k;double p[210000];
signed main(){
  cin>>n>>k;
  rep(i,n){
    cin>>p[i];
    p[i] = (p[i]*(p[i]+1))/2/p[i];
  }
  double ans = 0;
  rep(i,k)ans += p[i];
  double sum = ans;
  repd(i,k,n){
    sum -= p[i-k];
    sum += p[i];
    chmax(ans, sum);
  }
  cout << fixed << setprecision(10) <<  ans << endl;
}




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

#if __has_include(<local.h>)
#include <local.h>
#endif

using namespace std;

typedef long long int LL;
typedef long long int LLint;

//Faster Program
#define endl "\n"

//Faster Coding
#define ED return
#define GET(a) int a;cin >> a
#define DGET(a) double a;cin >> a
#define SGET(a) string a;cin >> a
#define CGET(a) char a;cin >> a
#define PRINT(a) cout << a << "\n"
#define ANS(a,b) int a;cin >> a;cout << b << "\n"
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define SORT(vec) sort(vec.begin(),vec.end())
#define REV(vec) reverse(vec.begin(),vec.end())
#define ALL(x) (x).begin(),(x).end()

//As Function
#define UP(a,b) ((a+(b-1))/b)
#define IPOW(x,y) LL(pow(x,y))

//Debug
#ifdef LOCAL_H
#define TEST cout << "OK\n"
#define DEBUG(a) a
#else
#define TEST
#define DEBUG(a)
#endif

#ifdef LOCAL_H
[[maybe_unused]]
#endif
const double PI = M_PI;
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const int INF = int(999999999);
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const long long MOD = int(1000000007);

//Settings
#ifdef LOCAL_H
const bool DO_BENCHMARK = true;
#endif
const int DOUBLE_ACCURACY = 15;

#ifndef LOCAL_H
    const bool DO_BENCHMARK = false;
#endif

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(DOUBLE_ACCURACY);
    void solve();
    if(DO_BENCHMARK){
        clock_t clock_start = clock();
        solve();
        clock_t clock_end = clock();
        const double time = static_cast<double>(clock_end-clock_start)/CLOCKS_PER_SEC*1000.0;
        cout << "\n" << time << "[ms]\n";
    }
    else solve();
}

/************************************************************************************************************************************************/

void solve(){
    int N;
    cin >> N;
    vector<string> vec (N);
    for(int i = 0;i < N;i++){
        cin >> vec[i];
    }
    SORT(vec);

    int max_num = 0;
    vector<pair<int,string>> str (0);
    for(int i = 1;i < N;i++){
        if(vec[i] == vec[i-1]){
            max_num++;
        }
        else{
            str.push_back(make_pair(N-max_num,vec[i-1]));
            max_num = 0;
        }
    }
    str.push_back(make_pair(N-max_num,vec[N-1]));
    SORT(str);
    for(int i = 0;i < N;i++){
        cout << str[i].second << endl;
        if(i == N-1 || str[i].first != str[i+1].first){
            break;
        }
    }
}


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

int main()
{
    int N, M, L, R;
    cin >> N >> M;
    int min = 0, max = N+1;
    for (int i = 0; i < M; i++)
    {
        cin >> L >> R;
        if(min < L)
            min = L;
        if(max > R)
            max = R;
    }
    int ans = 0;
    if(max >= min)
        ans = max - min + 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
#define ll long long
const int L=2e5+5,N=1e5+5;
int n,nk,i,j,now,f[N],g[N][26];
char s[L];
ll cal(ll m){
	if (m<=n) return g[m][now];
	ll l1=n,l2=nk,k,s1=g[l1][now],s2=g[l2][now];
	while (l1+l2<=m)
		k=l1,l1+=l2,l2=k,k=s1,s1+=s2,s2=k;
	return s1+cal(m-l1);
}
int main(){
	scanf("%s",s+1);n=strlen(s+1)/2;
	for (f[0]=-1,i=1,j=-1;i<=n;f[i]=++j,i++)
		for (;j>=0&&s[j+1]!=s[i];j=f[j]);
	nk=n-f[n];
	for (i=1;i<=n;i++){
		for (j=0;j<26;j++) g[i][j]=g[i-1][j];
		g[i][s[i]-97]++;
	}
	ll l,r;scanf("%lld%lld",&l,&r);
	for (now=0;now<26;now++)
		printf("%lld ",cal(r)-cal(l-1));
}

Measured memory_bytes: 10880
import sys

def lcs():
    seq1 = raw_input()
    seq2 = raw_input()
    
    a, b = len(seq1), len(seq2)
    x1 = [0 for i in range(b+1)]
    for i in range(a):
        e1 = seq1[i]
        x2 = x1 + []
        for j in range(b):
            if e1 == seq2[j]:
                x1[j+1] = x2[j] + 1
            if x1[j+1] < x1[j] :
                x1[j+1] = x1[j]
    return x1[-1]

n = input()
for i2 in range(n):
    print lcs()

 

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

int f(int n){
	int ret = 0;
	while(n){
		ret += n % 10;
		n /= 10;
	}
	return ret;
}

int main(){
	int n;
	cin >> n;
	if(n % f(n))
		cout << "No";
	else
		cout << "Yes";
	return 0;
}

Measured memory_bytes: 256
s = input()
news = [0, 0, 0, 0]
for i in range(len(s)):
    if s[i] == "N":
        news[0] += 1
    elif s[i] == "E":
        news[1] += 1
    elif s[i] == "W":
        news[2] += 1
    elif s[i] == "S":
        news[3] += 1
if news[0] > 0 and news[3] == 0:
    print("No")
    exit()
if news[0] == 0 and news[3] > 0:
    print("No")
    exit()
if news[1] > 0 and news[2] == 0:
    print("No")
    exit()
if news[1] == 0 and news[2] > 0:
    print("No")
    exit()
print("Yes")


Measured memory_bytes: 3064
<?php
    fscanf(STDIN,"%d",$X);
    
    //500円を何枚持てるか
    $gohyaku_num = intval(floor($X/500));
    
    $X = $X - (500*$gohyaku_num);
    
    $go_num = intval(floor($X/5));
    
    $ans = 1000*$gohyaku_num + 5*$go_num;
    
    echo $ans;

?>

Measured memory_bytes: 16172
use std::io;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("buf");
	let mut iter = buf.split_whitespace();
	//println!("hello");
	let a:i128 = match iter.next().unwrap().parse() {
		Ok(n) => n,
		Err(_) => panic!("a"),
	};
	let b:i128 = match iter.next().unwrap().parse() {
		Ok(n) => n,
		Err(_) => panic!("b"),
	};
	let c:i128 = match iter.next().unwrap().parse() {
		Ok(n) => n,
		Err(_) => panic!("c"),
	};
	let k:i128 = match iter.next().unwrap().parse() {
		Ok(n) => n,
		Err(_) => panic!("k"),
	};

	if a >= k {
		println!("{}", k);
	}else if a + b >= k {
		println!("{}", a);
	}else{
		let d = k - (a+b);
	 	println!("{}", a - d  );
	}
}

Measured memory_bytes: 2092
#include <iostream> 

using namespace std; 

int main() {
  int n; 
  cin>>n;
  int a[n]; 
  int i; 
  for(i=0;i<n;i++) { 
    cin>>a[i]; 
  } 
  if (n== 0) {
    cout<<0<<endl; 
    return 0;
  }
  else if (n == 1) { 
    cout<<a[0]<<endl;
    return 0;
  } 
  int pdp = abs(a[1] - a[0]); 
  int ppdp = 0; 
  for (i=2;i<n;i++) { 
    
    int c = min(pdp + abs(a[i] - a[i-1]), ppdp + abs(a[i] - a[i-2]));
    ppdp = pdp; 
    pdp = c;
   
  }
  cout<<pdp<<endl;
  return 0;
  
  }


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long X;
  cin >> X;
  long long ans = 0; 
  long long temp = 100;

  while(temp<X){
    ans++;
    temp += (long long)(temp*0.01);
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
import * as fs from 'fs';

function bigMax(...a: bigint[]): bigint {
  return a.reduce((prev, current) => prev > current ? prev : current);
}
function main(input) {
  input = input.split('\n');
  const N = parseInt(input[0]);
  const X = 10 ** 9 + 7;
  let ans = 1, a = 1, b = 2, c = 1;
  /*
  const a = Math.floor(N / 10);
  const b = N - a * 10;
  for (let i = 0; i < a; i++) {
    ans *= 1024;
    ans %= 10 ** 9 + 7;
  }
  ans *= 2 ** b;
  ans += 10 ** 9 + 5;
  ans %= 10 ** 9 + 7;
  */
  for (let i = 0; i < N; i++) {
    a *= 10;
    a %= X;
    b *= 9;
    b %= X;
    c *= 8;
    c %= X;
  }
  ans = a - b + c + X;
  ans %= X;
  console.log('%d', ans);
}

main(fs.readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 33072
fun main() {
    val x = nextLong()
    var balance = 100L
    var years = 0L
    while(balance < x) {
        years++
        balance += balance / 100
    }
    println(years)
}

val scanner = java.util.Scanner(System.`in`)
fun next(): String = scanner.next()
fun nextInt() = scanner.nextInt()
fun next2Int() = Pair(scanner.nextInt(), scanner.nextInt())
fun next3Int() = Triple(scanner.nextInt(), scanner.nextInt(), scanner.nextInt())
fun nextLong() = scanner.nextLong()
fun nextLine(): String = scanner.nextLine()
fun nextList() = nextLine().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextIntArray(size: Int) = IntArray(size) { nextInt() }
fun nextLongList() = nextList().map(String::toLong)
fun printYesNo(isYes: Boolean) = println(if (isYes) "Yes" else "No")

Measured memory_bytes: 36328
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long[] T = new long[n];
    for(int i = 0; i<n; i++) {
      T[i] = sc.nextLong();
    }
    for(int i = 0; i<n-1; i++) {
      T[i+1] =T[i] / gcd(T[i],T[i+1]) * T[i+1];
    }
    System.out.println(T[n-1]);
  }
  public static long gcd(long a, long b) {
    if(b == 0) return a;
    else return gcd(b, a%b);
  }
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <map> 
#include <algorithm>
#include <cstring>

#define ll long long
using namespace std; 

void solve(){
  int n; 
  cin >> n; 
  int a[n]; 
  for(int i=0; i<n; i++){
    cin >> a[i]; 
  }
  int ans = 0; 
  for(int i=0; i<n-2; i++){
    for(int j= i+1; j<n-1; j++){
      for(int k=j+1; k<n; k++){
        if(a[i]==a[j] || a[i]==a[k] || a[j]==a[k]){
          continue; 
        }
        if((a[i]+a[j]>a[k]) && (a[i]+a[k]>a[j]) && (a[k]+a[j]>a[i])){
          // cout << i+1 <<" " << j+1 << " " << k+1 << "\n"; 
          ans++; 
        }
      }
    }
  }
  cout << ans << "\n"; 
}

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

Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<algorithm>

typedef long long ll;
using namespace std;
int main()
{
	int N, CNT;
	CNT = 0;
	cin >> N;
	for (int i = 1; i < N+1; i++)
	{
		CNT += i;
	}
	cout << CNT << endl;
}

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


int main() {
	ll n;
	cin >> n;
	ll ans = (0 + n - 1) * n / 2;
	cout << ans << endl;
	return 0;
}

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

int main() {
  int n;
  string s;
  bool y = false;
  cin >> n;
  for (int i=0; i<n; i++) {
    cin >> s;
    if (s=="Y") {
      y = true;
      break;
    }
  }
  if (y) {
    cout << "Four" << endl;
  } else {
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 3572
#include <utility>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <numeric>
#include <limits>
#include <queue>
#include <cstdint>
#define ll long long int
#define rep(i,rept) for (int (i) = 0; (i) < rept; (i)++)
#define Yes(b) std::cout<< (b ? "Yes" : "No")<<std::endl
#define YES(b) std::cout<< (b ? "YES" : "NO")<<std::endl
#define fr first
#define se second
#define lolo 92233720368547757
#define susu 1000000007
typedef std::pair<int, int> pp;
using namespace std;
int main() {

	long long int n, m, a[101], cnt = 0, sum = 0;
	cin >> n >> m;
	rep(i, n) {
		cin >> a[i];
		sum += a[i];
	}
	if (sum == m) {
		cout << n;
		return 0;
	}
	sort(a, a + n);
	rep(i, n) {
		if (i == n - 1) {
			break;
		}
		if (m >= a[i]) {
			m -= a[i];
			cnt++;
		}
		else {
			break;
		}
	}
	
	cout << cnt;
	return 0;
}


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

int main(){
    string s;
    cin >> s;
    rep(i,3){
        if(s[i]=='1'){
            s[i] = '9';
        }else{
            s[i] = '1';
        }
    }
    cout << s << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

int main(void){
  int r ,D,x;cin >> r >> D >> x;
  for(int i = 0; i<10; i++){
    x = r*x - D;
    cout << x << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main(){
  array<int,3>xs;
  for(auto&x:xs)cin>>x;
  sort(xs.begin(),xs.end());
  int n_colors=3;
  if(xs[0]==xs[1])--n_colors;
  if(xs[1]==xs[2])--n_colors;
  cout<<n_colors<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
int k;
int H1, H2;
int M1, M2;
        scanf("%d %d %d %d %d", &H1, &M1, &H2, &M2, &k);
int l =(H2 * 60 + M2) -(H1 * 60 + M1) - k;
        printf("%d\n", l);
  
  return 0;
}

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

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

int main()
{
    int N,M;
    cin>>N>>M;
    int maxl=1,maxr=N;
    REP(i,M)
    {
        int l,r;
        cin>>l>>r;
        maxl=max(l,maxl);
        maxr=min(r,maxr);
    }
    if(maxr-maxl+1<0)
    {
        cout<<0<<endl;
    }else{
    cout<<maxr-maxl+1<<endl;
    }
}

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::bitset;

#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define reps(i,s,e) for(int i=s; i<(int)e; i++)
#define coutd(i) cout << std::fixed << std::setprecision(i)
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;

template<class T>
using Set = std::set<T>;
template<class T, class U>
using Map = std::map<T, U>;

template<class T>
using Graph = vector<vector<T>>;

const int INT_BIG = 1<<28;

int main() {
    int N;
    cin >> N;
    int count = 0;
    rep(i, N) {
        int a;
        cin >> a;
        
        if (i % 2 == 0 && a % 2 == 1) {
            count ++;
        }
    }
    cout << count << endl;
}

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

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define sz(x) int(x.size())
const ll mod = 1000000007;
const ll INF = 1001001001001001000;
const int M = 12801;
const int d = 6400;

int dp[80][80][M];

int main() {
    int h,w; cin >> h >> w;
    int grid[h][w]; rep(i,h) rep(j,w) cin >> grid[i][j];
    rep(i,h) rep(j,w) {
        int b; cin >> b;
        grid[i][j] -= b;
    }
    rep(i,h) rep(j,w) rep(k,M) dp[i][j][k] = 0;
    rep(i,h) {
        rep(j,w) {
            if (i == 0 && j == 0) {
                dp[0][0][grid[0][0]+d] = 1;
                dp[0][0][-grid[0][0]+d] = 1;
                continue;
            }
            rep(k,M) {
                bool reach = 0;
                if ((i > 0) && dp[i-1][j][k] == 1) reach = 1;
                if ((j > 0) && dp[i][j-1][k] == 1) reach = 1;
                if (reach) {
                    if ((0 <= k+grid[i][j]) && (k+grid[i][j] < M)) dp[i][j][k+grid[i][j]] = 1;
                    if ((0 <= k-grid[i][j]) && (k-grid[i][j] < M)) dp[i][j][k-grid[i][j]] = 1;
                }
            }
        }
    }

    int ans = 100100100;
    rep(k,M) {
        if (dp[h-1][w-1][k]) {
            ans = min(ans, abs(k-d));
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 323396
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;

int main(void)
{
	int a[3], n, b;
	while (scanf("%d %d %d", &a[0], &a[1], &a[2]), a[0]){
		sort(a, a + 3);
		int r = a[0]*a[0] + a[1]*a[1];
		cin >> n;
		for (int i = 0; i < n; i++){
			cin >> b;
			if (r < (b*2)*(b*2)) cout << "OK" << endl;
			else cout << "NA" << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 0
def gcd1(x,y):
    while (x % y) != 0:
        x,y = y,x%y
    return y

def Gcd(x,y):
    if x < y:
        _ = x
        x = y
        y = _
    return gcd1(x,y)

N = int(input())
AList = list(map(int,input().split()))
AList.sort(reverse=True)

gcd = Gcd(AList[0],AList[1])
for n in range(2,N):
    gcd = Gcd(gcd,AList[n])

print(gcd)

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

using namespace std;
long long K,N,C;
bool flag=false;
int main()
{
  cin>>N;
  long long count=0;
  for(int i=1;i<N+1;i++){
    if(i%3==0||i%5==0){
    }else{
      count+=i;
    }
  }
  cout<<count;
  return 0;
}




Measured memory_bytes: 3636
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
 
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}



int cnt[N];
void solve()
{
	set<int> st;
	int n, m;
	cin >> n >> m;
	int a[n][m];
	rep(i, n){
		int x;
		cin >> x;
		rep(j, x){
			cin >> a[i][j];
			++cnt[a[i][j] - 1];
		}
	}
	int res = 0;
	rep(i, m){
		res += (cnt[i] == n);
	}
	cout << res;
}


 
 
int main()
{
    Red;
  	// int T; cin >> T; while(T--)
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <queue>
#include <stack>
#include <bitset>
#define y1 y11
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define NAME ""

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

const ld PI = acos(-1.0);

const int MAXN = 1000001;
string s;
string t;
int a[MAXN];

int main()
{
	int n;
	cin >> n;
	cin >> s >> t;
	if (s == t)
	{
		cout << 0 << endl;
		return 0;
	}
	int p = n;
	int ans = 0;
	int k = 0;
	for (int i = n - 1; i >= 0; i--)
	{
		p = min(p, i);
		if ((i != 0) && (t[i] == t[i  - 1])) continue;
		while ((p >= 0) && (s[p] != t[i])) p--;
		if (p < 0)
		{
			cout << -1 << endl;
			return 0;
		}
		a[k] = p;
		int lg = 0, rg = k + 1;
		while (lg < rg)
		{
			int md  = (lg + rg) / 2;
			if (a[k - md] - md >= i) rg = md;
			else lg = md + 1;
		}
		ans = max(ans, lg);
		k++;
	}
	cout << ans + 1 << endl;
	return 0;
}






Measured memory_bytes: 6280
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>
#include <random>
#include <functional>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

ll min(ll a, ll b) {return a < b ? a : b;}
ll min(int a, ll b) {return a < b ? a : b;}
ll min(ll a, int b) {return a < b ? a : b;}
ll min(int a, int b) {return a < b ? a : b;}

ll max(ll a, ll b) {return a > b ? a : b;}
ll max(int a, ll b) {return a > b ? a : b;}
ll max(ll a, int b) {return a > b ? a : b;}
ll max(int a, int b) {return a > b ? a : b;}

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()

const int MOD = 1e9 + 7;


double solve(int n, double x1, double d)
{
    if (n == 1)
    {
        return (x1 + x1 + d) / 2;
    }
    double x2 = x1 + d, x3 = x2 + d;
    double mid = (2 * x1 + (2 * n - 1) * d) / 2;
    return mid + solve(n - 1, ((2 * n - 1) * x1 + x2 + 2 * x3) / (2 * n), ((2 * n + 4) * d) / (2 * n));
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    double x1, d;
    cin >> n >> x1 >> d;
    printf("%.9f", solve(n, x1, d));
}


Measured memory_bytes: 9600
#include <iostream>
#include <string>
#include <vector>

using namespace std;

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

  string last(&s.back());

  if (last.compare("s"))
  {
    s += "s";
  }
  else
  {
    s += "es";
  }

  cout << s << endl;

  return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[N][N];
int color[N], d[N], f[N], tt;

void dfs_visit(int u) {
    int v;
    color[u] = GRAY;
    d[u] = ++tt;
    for ( v = 0; v < n; v++) {
        if (M[u][v] == 0 ) continue;
        if (color[v] == WHITE ) {
            dfs_visit(v);
        }
    }
    color[u] = BLACK;
    f[u] = ++tt;
}

void dfs() {
    int u;
    for ( u = 0; u < n; u++) {
        if ( color[u] == WHITE ) dfs_visit(u);
    }
    for (u = 0; u < n; u++) {
        printf("%d %d %d\n", u + 1, d[u], f[u]);
    }
}

int main() {
    int u, v, k, i, j;
    
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        for (j = 0; j < n; j++) M[i][j] = 0;
    }
    
    for (i = 0; i < n; i++) {
        scanf("%d %d", &u, &k);
        u--;
        for ( j = 0; j < k; j++) {
            scanf("%d", &v);
            v--;
            M[u][v] = 1;
        }
    }
    
    dfs();
    
    return 0;
}


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

const ll maxs = 2e5+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;

#define IOS ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'

void pre(){

}

bool isOk_l(vector<pair<ll,ll>> A){
    ll cnt=0;
    for(auto p : A){
        ll b = cnt + p.ff;
        if(b <  0)
            return false;
        cnt += p.ss;
    }
    return true;
}

bool isOk_r(vector<pair<ll,ll>> A){
    ll cnt=0;
    reverse(A.begin(),A.end());
    for(auto p : A){
        ll b = cnt + p.ff;
        if(b < 0)
            return false;
        cnt += p.ss;
    }   
    return true;
}

void solve(){
    ll n;
    cin >> n;
    vector<pair<ll,ll>> l , r;
    ll tot=0;
    for(ll i=0;i<n;i++){
        string s;
        cin >> s;
        ll b=0,h=0;
        for(auto ch : s){
            if(ch == '(')
                h++;
            else h--;
            b = min(b,h);            
        }
        if( h > 0) l.pb({b,h});
        else r.pb({b-h,-h});

        tot += h;
    }
    /*
        (  --> b=0  h=1    
        )( --> b=-1 h=0
        order should be :
        ( )(
        priority to higher val of b
    */
    sort(l.begin(),l.end());
    reverse(l.begin(),l.end());
    /*
        ))    --> b=-2  h=-2  b-h = 0  
        )))(  --> b=-3  h=-2  b-h = -1
        )))(( --> b=-3  h=-1  b-h = -2
        )     --> b=-1  h=-1  b-h = 0
        order should be :
        )))(( )))( ) )) 
        priority to lower val of b-h
    */
    sort(r.begin(),r.end());
    if( isOk_l(l) and isOk_r(r) and tot==0 )
        cout << "Yes\n";
    else cout << "No\n";
}

int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input00.txt","r",stdin);
    // #endif
    IOS;
    pre();
    ll T = 1;   
    //cin>>T;
    while(T--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 34588
import numpy as np

def solve():
    for i in range(K,N):
        if A[i-K] < A[i]:
            print("Yes")
        else:
            print("No")


if __name__ == "__main__":
    N,K = list(map(int, input().split()))  
    A = list(map(int, input().split()))  
    solve()


Measured memory_bytes: 50056
object Main {

  def main(args: Array[String]): Unit = {
    import scala.io.StdIn._

    // 10000, 5000円は 1000円札で表現できるので、
    // a枚, b枚, (N - a - b)枚 で計 Y円
    // 各最大枚数は, 10000 が Y / 10000 枚,
    // 5000 円 が
    // a枚, b枚

    val Array(n, y) = readLine().split(" ").map(_.toInt)
    val maxA = y / 10000
    val results = for {
      a <- 0 to maxA
      restA = y - (10000 * a)
      maxB = restA / 5000
      b <- 0 to maxB
      restB = restA - (5000 * b)
      c = n - a - b
      if (restB - (1000 * c)) == 0
    } yield (a, b, c)

    if (results.isEmpty)
      println("-1 -1 -1")
    else
      println(results.head._1 + " " + results.head._2 + " " + results.head._3)
  }

}

Measured memory_bytes: 105656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

int main() {
    string s, t;
    cin >> s >> t;
    cout << t + s << endl;
    
    return 0;
}


Measured memory_bytes: 256
/*************************************************************************
    > File Name: A.cpp
    > Author: HandsomeHow
    > Mail: handsomehowyxh@gmail.com 
    > Created Time: 2017/7/23 19:59:48
 ************************************************************************/

#include <bits/stdc++.h>
using namespace std;

#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define cl(a) memset((a),0,sizeof(a))
#ifdef HandsomeHow
#define dbg(x) cerr << #x << " = " << x << endl
#else
#define dbg(x)
#endif
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
const int inf=0x3f3f3f3f;
const double eps=1e-8;
const int mod=1000000007;
const double pi=acos(-1.0);
inline void gn(long long&x){
    int sg=1;char c;while(((c=getchar())<'0'||c>'9')&&c!='-');c=='-'?(sg=-1,x=0):(x=c-'0');
    while((c=getchar())>='0'&&c<='9')x=x*10+c-'0';x*=sg;}
inline void gn(int&x){long long t;gn(t);x=t;}
inline void gn(unsigned long long&x){long long t;gn(t);x=t;}
ll gcd(ll a,ll b){return a? gcd(b%a,a):b;}
ll powmod(ll a,ll x,ll mod){ll t=1ll;while(x){if(x&1)t=t*a%mod;a=a*a%mod;x>>=1;}return t;}
// (づ°ω°)づe★------------------------------------------------

int main(){
#ifdef HandsomeHow
    //freopen("data.in","r",stdin);
    //freopen("data.out","w",stdout);
#endif
    int mx=0;
    int n, k;gn(n);gn(k);
    int g = 0;
    rep(i,1,n){
        int x;gn(x);
        mx=max(mx,x);
        g=gcd(g,x);
    }
    int dif=mx-k;
    if(dif<0 || (dif%g!=0))puts("IMPOSSIBLE");
    else puts("POSSIBLE");
    return 0;
}



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

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:
            print(x, ' ', y, ' ', z)
            exit()


print('-1 -1 -1')


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

int main(){
  
  int n, t, a;
  cin >> n >> t >> a;
  
  vector<int>h(n);
  
  int i = 0;
  for(i = 0; i < n; i++){
    cin >> h[i];
  }
  
  double ans = 0;
  int select = 0;
  double tmp;
  double sub;
  for(i = 0; i < n; i++){
    tmp = t - h[i]*0.006;
    sub = a - tmp;
    if(i == 0){
      ans = abs(sub);
      select = 1;
    }
    else{
      if(ans > abs(sub)){
        ans = abs(sub);
        select = i + 1;
      }
    }
  }
  
  cout << select;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define time_taken_start int begtime = clock();
#define time_taken_end int endtime = clock(); \
cerr << "\n\n" << "Time elapsed: " << \
(endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
return 0;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 100000000000000007
#define eps 0.000000000001
#define pi acosl(-1)
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vpl vector<pll>
#define vll vector<ll>
#define mseti multiset <ll>
#define msetd multiset <ll,greater<ll>>
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound 
#define stp fixed<<setprecision(20)
#define endl '\n'
ll fac[20009];
ll power(ll x,ll y)
{
    ll res=1;
  
    while(y>0)
    {
        if(y&1)
            res=res*x;
        res%=mod;
        y=y>>1;
        x=x*x;
        x%=mod;
    } 
    return res; 
}
ll inv(ll x)
{
    return power(x,mod-2);
}
ll ncr(ll n,ll r)
{
	ll res=fac[n];
	res*=inv(fac[r]);
	res%=mod;
	res*=inv(fac[n-r]);
	res%=mod;
	return res;
}
void solve()
{
    ll s;
    cin>>s;
    fac[0]=1;
    for(ll i=1;i<2000;i++)
    {
    	fac[i]=fac[i-1]*i;
    	fac[i]%=mod;
    }
    ll ans=0;
    for(ll i=1;i<=s;i++)
    {
    	ll x=s-(i*2);
    	if(x<i)
    		break;
    	ans+=ncr(x-1,i-1);
    	ans%=mod;
    }
    cout<<ans;
}
int main()
{
    FAST
    #ifdef ayk_16
    freopen("input.txt","rt",stdin);
    freopen("output.txt","wt",stdout);
    #endif
    time_taken_start
    ll t=1;
    //cin>>t;
    for(ll i=0;i<t;i++)
    {
        //cout<<"Case #"<<i+1<<": ";
        solve();
    }
    time_taken_end
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define inf LLONG_MAX
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    vector<ll> imos(100002);
    ll n; cin >> n;
    rep(i, n) {
        ll m; cin >> m;
        imos[m]++; imos[m+3]--;
    }


    vector<ll> h(100002);
    rep(i, imos.size()) {
        if (i == 0) h[i] = imos[i];
        else {
            h[i] = imos[i] + h[i-1];
        }
    }

    ll max_num = 0;
    ll index = 0;
    rep(i, h.size()) {
        if (h[i] > max_num) {
            max_num = h[i];
            index = i - 1;
        }
    }
    cout << max_num << endl;
    return 0;
}

Measured memory_bytes: 1792
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int[] ary = new int[n];

		for (int i=0; i<n; i++) {
			ary[i] = stdIn.nextInt();
		}

		int count = 0;
		for (int i=0; i<ary.length; i++) {
			for (int j=ary.length-1; j>i; j--) {
				if (ary[j] < ary[j-1]) {
					swap(ary,j,j-1);
					count++;
				}
			}
		}

		for (int i=0; i<ary.length-1; i++) {
			System.out.print(ary[i] + " ");
		}
		System.out.println(ary[ary.length-1]);
		System.out.println(count);
	}

	static void swap(int[] ary,int x,int y){
		int temp = ary[x];
		ary[x] = ary[y];
		ary[y] = temp;
	}
}

Measured memory_bytes: 19124
#include <stdio.h>

int main(void) {
	int num1,num2;

	scanf("%d%d", &num1,&num2);
	if (num2%num1 == 0) {
		printf("%d\n", num1+num2);
	}
	else {
		printf("%d", num2 - num1);
	}
	return 0;
}

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

#define ll long long
#define ull unsigned long long 
#define endl '\n'
#define pii pair<int, int>
#define all(a) a.begin(),a.end()

template <typename T>
inline T gcd(T a, T b) { while (b != 0) swap(b, a %= b); return a; }

int main(){
    int n;
    cin >> n;
    vector<int> a;
    a.push_back(INT_MAX);
    for(int i=0; i<n-1; ++i){
        int x;
        cin >> x;
        a.push_back(x);
    }
    a.push_back(INT_MAX);

    ll ans=0;
    for(int i=0; i<(int)a.size()-1; ++i){
        ans += min(a[i], a[i+1]);
    }
    cout << ans;
}


Measured memory_bytes: 3580
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int y = sc.nextInt();
        
        boolean fin = false;
        for(int i = 0; i <= n && !fin; i++){
            for(int j = 0; i + j <= n; j++){
                if(i*1000+j*5000+(n-i-j)*10000==y){
                    System.out.println((n-i-j) + " " + j + " " + i);
                    fin = true;
                    break;
                }
            }
        }

        if(!fin) System.out.println("-1 -1 -1");
    }
}


Measured memory_bytes: 21972
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 998244353
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000


int main(){
	int n, m, x, z, y;
	vector<int> a[400];
	long long ans = 1;
	long long s = 1;
	scanf("%d %d", &n, &m);
	f(i, n){
		f(j, m){
scanf("%d", &x);
		a[i].push_back(x);
        }
	}
	f(i, n + m - 1){
		ans *= 2;
		ans %= MOD;
	}
	z = 0;
	f(j, m){
		y = -1;
		f(i, n){
			if (a[i][j] == 1)y = i;
		}
		if (y >= 0){
			z++;
			f(i, n){
				if (a[i][j] == 1){
					f(jj, m){
						a[i][jj] = a[i][jj] ^ a[y][jj];
					}
				}
			}
			f(jj, m){
				a[y][jj] = 0;
			}
		}
	}
	s = 1;
	f(i, (n + m-z-1)){
		s *= 2;
		s %= MOD;
	}
	ans = (ans + MOD - s) % MOD;
	printf("%lld\n", ans);



	return 0;
}

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

int main() {
    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int> tmp(N, 0);
    rep(i, Q) {
        int A;
        cin >> A;
        tmp[A - 1] += 1;
    }
    rep(i, N) {
        int ans = K - Q + tmp[i];
        (ans > 0) ? puts("Yes") : puts("No");
    }
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 ll dp[100001];

ll mincost(ll arr[], ll n){
    if(n == 0){
        return 0;
    }
    if(n == 1){
        return abs(arr[1]-arr[0]);
    }
    if(dp[n]!=-1){
        return dp[n];
    }
    ll c2 = mincost(arr,n-2) + abs(arr[n-2]-arr[n]);
    ll c1 = mincost(arr,n-1) + abs(arr[n-1]-arr[n]);
    dp[n] = min(c1,c2);
    return dp[n];
}

int main() {
    ll n;
    cin>>n;
    ll arr[n];
    for(int i = 0; i<n; i++){
        cin>>arr[i];
        dp[i] = -1;
    }
    cout<<mincost(arr,n-1)<<endl;
}


Measured memory_bytes: 8320