akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
typedef long long ll;

vector<pair<ll,int>> factorize(ll n){
	vector<pair<ll,int>> res;
	for (ll i = 2; i*i <= n; ++i) {
		if(n%i) continue;
		res.emplace_back(i,0);
		while(n%i==0){
			n /= i;
			res.back().second++;
		}
	}
	if(n != 1) res.emplace_back(n,1);
	return res;
}

int main(){
	ll n;
	cin >> n;
	auto p = factorize(n);
	ll ans = 0;
	rep(i,p.size()){
		ll k = 0;
		while(k*(k+1)/2 <= p[i].second){
			k++;
		}
		k--;
		ans += k;
	}
	cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3628
#include<stdio.h>
int main()
{
int W,H,x,y,r;
scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
if(W>=x+r&&x>=r&&H>=y+r&&y>=r)
{
   printf("Yes\n");
   
}
else
{
printf("No\n");
}
return 0;
}

Measured memory_bytes: 584
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;

int main() {
    int64_t n;
    cin >> n;
    int64_t d[n];
    int64_t sum = 0;
    for (int i = 0; i < n; i++) {
	    cin >> d[i];
        sum += d[i];
    }
    int64_t dsum = 0;
    for (int i = 0; i < n - 1; i++) {
	    sum -= d[i];
        dsum += d[i] * sum;
    }
    
    cout << dsum << endl;
}


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

int main()
{
	int k, x;
	cin >> k >> x;

	for (int i = x - k + 1; i < x + k; i++)
	{
		if (i != x + k - 1)
		{
			cout << i << " ";
		}
		else
		{
			cout << i << endl;
		}
	}
}


Measured memory_bytes: 256
using System;
using System.Numerics;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace debug
{
    class ProgramC
    {
        static void Main(string[] args)
        {

            //入力
            string[] s = Console.ReadLine().Split(' ');
            long n = long.Parse(s[0]);
            long x = long.Parse(s[1]);
            string[] a = Console.ReadLine().Split(' ');
            long[] xi = new long[n];
            long ans = 0;

            for (int i = 0; i < n; i++)
                xi[i] = long.Parse(a[i]);

            if(n == 1)
            {
                Console.WriteLine(Math.Abs(xi[0] - x));
                return;
            }

            ans = gcd(Math.Abs(xi[0] - x), Math.Abs(xi[1] - x));
            //i番目の最大公約数を見つける
            for (int i = 2; i < n;i++)
            {
                ans = gcd(ans, Math.Abs(xi[i] - x));
            }

            //答え出力
            Console.WriteLine(ans);

        }

        /*最大公約数を求める関数*/
        static long gcd(long p, long q)
        {
            if (p < q)
            {
                long temp = p;
                p = q;
                q = temp;
            }

            long r = 1;

            while (r != 0)
            {
                r = p % q;
                p = q;
                q = r;
            }

            return p;
        }

    }



}


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

int main() {
    int d, n;
    cin >> d >> n;
    vector <int> t(d), a(n), b(n), c(n);
    rep (i, d) cin >> t[i];
    rep (i, n) cin >> a[i] >> b[i] >> c[i];

    vector <vector <int>> dp(d + 1, vector <int> (101, -1));
    dp[0][0] = 0;
    rep (i, d) rep (j, 101) if (dp[i][j] != -1) rep (k, n) if (a[k] <= t[i] && t[i] <= b[k]) {
        if (i == 0) dp[i + 1][c[k]] = 0;
        else        dp[i + 1][c[k]] = max(dp[i + 1][c[k]], dp[i][j] + abs(j - c[k]));
    }

    int ans = 0;
    rep (i, 101) ans = max(ans, dp[d][i]);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3220
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

AB = [(A[i],B[i]) for i in range(N)]
AB.sort(key=lambda x: x[1])

A = [AB[i][0] for i in range(N)]
B = [AB[i][1] for i in range(N)]

AI = [(AB[i][0], i) for i in range(N)]

A.sort()
AI.sort(key=lambda x:x[0])

flag = True
for i in range(N):
    if A[i] > B[i]:
        flag = False
        break

idx = AI[0][1]
cnt = 1
while idx != 0:
    idx = AI[idx][1]
    cnt += 1

if cnt == N:
    flag2 = False
    for i in range(N-1):
        if B[i] >= A[i+1]:
            flag2 = True
            break
else:
    flag2 = True

if flag and flag2:
    print('Yes')
else:
    print('No')

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

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


Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def log(*args):
    print(*args, file=sys.stderr)


def main():
    n, m = map(int, input().split())
    l = [list(map(int, input().split())) for _ in range(n)]
    ans = 0
    for i in [-1, 1]:
        for j in [-1, 1]:
            for k in [-1, 1]:
                l2 = []
                for (x, y, z) in l:
                    s = x * i + y * j + z * k
                    l2.append(s)
                l2 = sorted(l2, reverse=True)
                ans = max(ans, sum(l2[:m]))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <stdio.h>
#include <stdlib.h>

#define rep(i,n) for(i = 0; i < n; i++)
 
int main(void){
 int N, M;
 int i, j, k, l;
 int flag;
 char **A, **B;
 scanf("%d%d\n", &N, &M);
 A = (char **)malloc(sizeof(char *)*N);
 for(i = 0; i < N; i++) A[i] = (char *)malloc(N);
 B = (char **)malloc(sizeof(char *)*M);
 for(i = 0; i < M; i++) B[i] = (char *)malloc(M);
 for(i = 0; i < N; i++){
  for(j = 0; j < N; j++) A[i][j] = getchar();
  getchar();
 }
 for(i = 0; i < M; i++){
  for(j = 0; j < M; j++) B[i][j] = getchar();
  getchar();
 }
 
 for(i = 0; i <= N - M; i++){
  for(j = 0; j <= N - M; j++){
   flag = 1;
   for(k = 0; k < M; k++){
    for(l = 0; l < M; l++){
     if(A[k + i][l + j] != B[k][l]) flag = 0;
    }
   }
   if(flag){
    printf("Yes\n");
    return 0;
   }
  }
 }
 printf("No\n");
 return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
//cout << fixed << setprecision(10);

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

  int ans = 0;
  rep(i,s.size()/2) {
    if (s[i] != s[s.size()-1-i]) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        long N = scan.nextLong();
        BigInteger answer = BigInteger.ZERO;
        long temp = (long) Math.sqrt(N);
        temp += 10;
        BigInteger x = new BigInteger(Long.toString(temp));
        BigInteger y = BigInteger.ZERO;
        do {
            x = x.subtract(BigInteger.ONE);
            y = (x.add(BigInteger.ONE)).multiply(x);
        }
        while ((new BigInteger(Long.toString(N)).compareTo(y)) < 1);
        for (int i = 1; i < x.longValue()+1; i++) {
            if (N % i != 0) {
                continue;
            }
            answer = answer.add(new BigInteger(Long.toString(N / i - 1)));
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 23764
import java.util.*;
import java.io.*;
public class Main{
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());
		sc.close();
		int cou = 0;
		boolean che = true;
		for(int i = a ; i > 0 && che ; i--){
			if(a % i == 0 && b % i == 0){
				cou++;
			}
			if(k == cou){
				che = false;
				ou.print(i + "\n");
			}
		}
		ou.flush();
    }
}

Measured memory_bytes: 38432
a, b = map(int, input().split())

result = 0
for i in range(a, b + 1):
    i_str = str(i)
    idx_of_half = len(i_str) // 2
    first_half = i_str[:idx_of_half]
    if len(i_str) % 2 != 0:
        idx_of_half += 1
    second_half = i_str[idx_of_half:]

    if first_half == second_half[::-1]:
        result += 1

print(result)


Measured memory_bytes: 3060
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<map>
#include<ctime>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<bitset>
#define ll long long 
#define ull unsigned long long 
#define mem(a) memset(a,0,sizeof(a))
#define rint register int 
#define rll register long long 
#define rull register unsigned long long 
#define rchar register char
#define rstring register string 
#define rfloat register float
#define rdouble register double 
#define fio ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define For(i,a,b) for(int i=a;i<b;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define cFor(i,a,b) for(int i=a;i>b;i--)
#define cFOR(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
const int MAX=1e6;
ll x[MAX];
string s[MAX];
int main(){
	mem(x);
	int n;
	cin>>n;
	FOR(i,1,n)
		cin>>s[i]>>x[i];
	string X;
	cin>>X;
	int idx=0;
	FOR(i,1,n)
		if(X==s[i])
			idx=i;
	ll ans=0;
	FOR(i,idx+1,n)
		ans+=x[i];
	cout<<ans<<endl;			
}

Measured memory_bytes: 15872
#include <iostream>

int main(void){


  int n,a,b;

  std::cin >> n;

  if(n == 1){
    std::cout << "Hello World" << std::endl;
  }else{
    std::cin >> a >> b;
    std::cout << (a+b) << std::endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
//#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}


inline void solve(){

  int n, m;
  int l[100004],r[100004];
  int mem[200005]={};
  cin >> n >> m;

  FOR(i,m){
    cin >> l[i] >> r[i] ;
    mem[l[i]]++;
    mem[r[i]+1]--;
  }
  int sum = 0;
  iFOR(i,1,n+1){
    mem[i] += mem[i-1] ; 
  }
  FOR(i,n+1){
    if(mem[i] >= m)
      sum++;
  }

  cout << sum fin;
   
    

}
struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;signed main(){solve();return 0;}


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

int gcd(int x,int y){
 int tmp;
 int r;
 if(x > y){
    tmp = x;
    x = y;
    y = tmp;
  }
  r = y % x;
  while(r!=0){
    y = x;
    x = r;
    r = y % x;
  }
  return x;
}
int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++)cin >> a[i];
    int ans;
    ans=gcd(a[0],a[1]);
    for(int i=2;i<n;i++)ans=gcd(ans,a[i]);
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) { return std::vector<T>(n, std::forward<T>(val)); }
template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}
template<class Cond> struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  template<class T> bool operator()(T& a, const T& b) const { if(cond(a, b)) { a = b; return true; } return false; }
};
template<class Cond> chain<Cond> make_chain(Cond cond) { return chain<Cond>(cond); }

int main() {
  i64 N;
  cin >> N;
  vector<i64> S(1 << N);
  multiset<i64> st;
  rep(i,0,(1 << N)) {
    cin >> S[i];
    st.insert(S[i]);
  }
  vector<i64> vec;
  vec.push_back(*(--st.end()));
  st.erase(--st.end());
  rep(k,0,N) {
    vector<i64> next(vec.size() * 2);
    rep(i,0,vec.size()) {
      next[i * 2] = vec[i];
      auto iter = st.lower_bound(vec[i]);
      if(iter == st.begin()) {
        cout << "No" << endl;
        return 0;
      }
      --iter;
      next[i * 2 + 1] = *iter;
      st.erase(iter);
    }
    swap(next, vec);
    sort(all(vec));
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 17784
// -*- mode: cpp; coding=utf-8-unix; -*-
// vim: filetype=cpp fileencoding=utf-8 fileformat=unix
#include <iostream>
#include <iomanip>
#include <math.h>
#include <map>
#include <list>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <sstream>
#include <string.h>
// #include <limits.h>

#define FOR(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define FORUL(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define FORULE(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define FOREACH(it, X) for(__typeof((X).begin()) it = (X).begin(); it != (X).end(); it++)
#if defined(_MSC_VER) || __cplusplus > 199711L
#define AUTOVAR(newvar,v) auto newvar = (v)
#else
#define AUTOVAR(newvar,v) __typeof(newvar) r = (v)
#endif
#define PB(x) push_back(x)
#define MP(x,y) make_pair((x),(y))
#define MEMSET(m,v) memset(m,v,sizeof(m))

typedef long long				 ll;
typedef unsigned long long		ull;

#define INTMAX  99999999

#define DEBUG 1

#if DEBUG
#define DOUT cout<<"["<<__LINE__<<"]:"
#else
#define DOUT 0 && cout
#endif

using namespace std;

#define MAX_N (1000*100)

int N;
int h[MAX_N];

int memo[MAX_N+2];

int calc(int pos)
{
	if (memo[pos]>=0) {
		return memo[pos];
	}
	if(pos>=N-1) {
		return 0;
	}
	if(pos==N-2) {
		memo[pos] = calc(pos+1)+abs(h[pos+1]-h[pos]);
	}
	else {
		memo[pos] = min(calc(pos+1)+abs(h[pos+1]-h[pos]), calc(pos+2)+abs(h[pos+2]-h[pos]));
	}
	return memo[pos];
}

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false);

	cin >> N;
	FOR(n,N) {
		cin >> h[n];
	}
	FOR(n,N+2) {
		memo[n] = -1;
	}

	cout << calc(0) << endl;

	return 0;
}



Measured memory_bytes: 2560
fun main(args: Array<String>) {
    val (r, c) = readLine()!!.split(" ").map { it.toInt() }

    var sheets = MutableList(r) { MutableList(c) { 0 } }

    (0 until r).forEach { sheets[it] = readLine()!!.split(" ").map(String::toInt).toMutableList() }

    (0 until r).forEach { row ->
        sheets[row].forEach { print("$it ") }
        print("${sheets[row].sum()}")
        println()
    }

    (0 until c).forEach { column ->
        print("${sheets.sumBy { it[column] }} ")
    }

    println("${sheets.sumBy { it -> it.sumBy { it } }}")
}


Measured memory_bytes: 37340
n = int(input())
list_d = []
for _ in range(n):
    a, b = map(int, input().split())
    list_d.append(a == b)
for i in range(n-2):
    if list_d[i] and list_d[i+1] and list_d[i+2]:
        print('Yes')
        exit()
print('No')

Measured memory_bytes: 9172
"use strict";

const main = arg => {
    const input = arg.trim().split("\n");

    const X = parseInt(input[0].split(" ")[0]);
    const N = parseInt(input[0].split(" ")[1]);
    if (N === 0) {
        console.log(X)
        return
    }
    const p = input[1].split(" ").map(n => parseInt(n));

    p.sort((a, b) => a - b)
    let lv = X
    let rv = X
    while (lv > 0) {
        if (p.includes(lv)) {
            lv--
        } else {
            break
        }
    }
    while (rv <= 100) {
        if (p.includes(rv)) {
            rv++
        } else {
            break
        }
    }
    if (Math.abs(X - lv) > Math.abs(X - rv)) {
        console.log(rv)
    } else {
        console.log(lv)
    }

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


Measured memory_bytes: 29636
#include <iostream>
#include <vector>
using namespace std;
vector<vector<bool>> graph(8,vector<bool>(8)) ;
vector<bool> visit(8);

int dfs(int v, int N){
    
    
    bool all_Visit = true;  // 変数：全て訪問済
    
    // 全て訪問済か確認
    for(int i = 0; i < N; i++){
        if(visit[i] == false) all_Visit = false;
    }
    
    // 全て訪問のとき1を返して加える
    if(all_Visit) return 1;
    
    
    int ret = 0;  // 変数：今回の答えの値リピート
    
    for(int i = 0; i < N; i++){
        if(graph[v][i] == false) continue;  // 判定：入力時に値が入ってない
        if(visit[i]) continue; // ルート自身が存在しない時
        
        visit[i] = true;
        ret += dfs(i, N);
        visit[i] = false;
    }
    
    return ret;
}





int main(void){
    
    int N, M;
    
    cin >> N >> M;
    
    for(int i = 0; i < M; i++){
        int A, B;
        cin >> A >> B;
        A--, B--;
        graph[A][B] = graph[B][A] = true;
    }
    
    //vector<bool> visit(8);
    for(int i = 0; i < N; i++){
        visit[i] = false;
    }
    
    visit[0] = true;
    cout << dfs(0, N) << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;
	void doIt() {
		int h = sc.nextInt();
		int w = sc.nextInt();
		int K = sc.nextInt();
		int dp[][] = new int[h + 1][w];
		for(int i = 0; i <= h; i++)Arrays.fill(dp[i],0);
		dp[0][0] = 1;
		for(int i = 0; i < h; i++) {
			for(int j = 0; j < w; j++) {
				//kのビットパターン：横棒[w-1...0]
				for(int k = 0; k < 1 << (w - 1); k++) {
					if(validate(k, w)) {
						//左方向への分岐
						if(j >= 1 && ((k >> (j - 1)) & 1) == 1) {
							dp[i + 1][j - 1] += dp[i][j];
							dp[i + 1][j - 1] %= MOD;
						}
						//右方向への分岐
						else if(j < w - 1 && (k >> j & 1) == 1) {
							dp[i + 1][j + 1] += dp[i][j];
							dp[i + 1][j + 1] %= MOD;
						}
						//分岐無し
						else {
							dp[i + 1][j] += dp[i][j];
							dp[i + 1][j] %= MOD;
						}
					}
				}
			}
		}
		System.out.println(dp[h][K - 1]);
	}
	
	boolean validate(int num, int w) {
		//validであるかどうかを返す。
		int n = num;
		for(int i = 0; i < (w - 1); i++) {
			if(((n >> i) & 1) == 1 && ((n >> i) & 1) == ((n >> (i + 1)) & 1)){
				return false;
			}
		}
		return true;
	}
	
	Main(){doIt();}
	public static void main(String[] args) {
		new Main();
	}
}



Measured memory_bytes: 21972
#!/usr/bin/env python3
import sys

YES = "YES"  # type: str
NO = "NO"  # type: str


def solve(r: int, g: int, b: int):
    return YES if int(str(''.join(map(str, [r, g, b])))) % 4 == 0 else NO


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    r = int(next(tokens))  # type: int
    g = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    print(solve(r, g, b))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
i64 mod = 1000000007;
//int int_max = 2147483647;
i64 INF = 1e12;
int max_n = 1e5;

template<typename IntType>
struct mat2d_t {
    mat2d_t(size_t h, size_t w) : h(h), w(w) {
        mat = std::vector<std::vector<IntType>>(h, std::vector<IntType>(w, 0));
    }
    mat2d_t(size_t h, size_t w, IntType init) : h(h), w(w){
        mat = std::vector<std::vector<IntType>>(h, std::vector<IntType>(w, init));
    }

    std::vector<IntType>& operator[](size_t p) {
        return mat[p];
    }

    const std::vector<IntType>& operator[](size_t p) const {
        return mat[p];
    }
    size_t height() const {
        return h;
    }
    size_t width() const {
        return w;
    }

private:
    std::vector<std::vector<IntType>> mat;
    size_t h;
    size_t w;
};

int main(int argc, char **argv) {
    i64 h,w;
    cin >> h >> w;
    mat2d_t<int> map(h,w,0);
    for (int i=0; i<h; ++i) {
        for (int j=0;j<w; ++j) {
            char c;
            cin >> c;
            map[i][j] = c == '.' ? 0 : 1;
        }
    }

    mat2d_t<i64> dp(h,w,0);
    dp[0][0]=1;

    for (int i=0; i<h; ++i) {
        for (int j=0; j<w; ++j) {
            if (i==0&&j==0) continue;
            if (map[i][j] == 1) {
                dp[i][j]=0;
                continue;
            }
            if (i!=0) {
                dp[i][j] += dp[i-1][j];
            }
            if (j!=0) {
                dp[i][j] += dp[i][j-1];
            }
            dp[i][j] %= mod;
        }
    }
    cout << dp[h-1][w-1] << endl;
    return 0;
}


Measured memory_bytes: 12032
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    string s;
    cin >> s;
    int n = s.size();
    --n;
    ll ans = 0;
    rep(i, 1<<n) {
        ll sum = 0;
        ll tmp_num = s[0] - '0';
        rep(j, n) {
            if ((i>>j) & 1) {
                sum += tmp_num;
                tmp_num = s[j+1] - '0';
            }
            else {
                tmp_num = tmp_num * 10LL + s[j+1] - '0';
            }
        }
        sum += tmp_num;
        //cout << sum << endl;
        ans += sum;
    }
    cout << ans << endl;
    return 0;
}


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

typedef long long ll;

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

#define FOR(i, start, end) for(ll i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

int main(void) {
    int N;
    cin >> N;
    map<string, int> prize;
    REP (i, N) {
        string name;
        cin >> name;
        prize[name]++;
    }
    cout << prize.size() << endl;

    return 0;
}

Measured memory_bytes: 18724
#include<iostream>
#include<vector>
#include<map>
using namespace std;
long long MAX=1e6+1;

long long f(long long n){
    if(n%2==0) return n/2;
    else return 3*n+1;
}

int main(){
    long long s;
    cin >> s;
    map<long long,long long> m;
    long long a[MAX];
    a[0]=s;
    m[s]++;
    long long ans;
    for(long long i=1;i<MAX;i++){
        a[i]=f(a[i-1]);
        m[a[i]]++;
        if(m[a[i]]==2){
            ans=i+1;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    a = ni()

    print(a + a**2 + a**3)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9724
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(auto i=0;i<n;++i)
#define REPR(i,n) for(auto i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(auto i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

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

using namespace std;

typedef pair<int,int> pii;


int main(){

  int n;
  string s;
  cin >> n >> s;

  int sum_w = 0, sum_b = 0;

  REP(i,n){
    if(s[i] == '#'){
      sum_b++;
    }else{
      sum_w++;
    }
  }

  int ans = min(sum_w, sum_b);
  int w = 0, b = 0;
  REP(i,n-1){
    if(s[i] == '#'){
      b++;
    }else{
      w++;
    }
    ans = min(ans, b + sum_w - w);
  }

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



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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
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 pair<ll,ll>P;
const ll mod=1e9+7;
const int INF = 1000000;
const double PI=3.14159265359;

int main(){

  ll n;cin>>n;
  ll a[n];
  string s="APPROVED",t="DENIED";
  set<ll>se;

  rep(i,0,n){
    cin>>a[i];
    if(a[i]%2==0)se.insert(a[i]);
  }
  for(auto v:se){
    if(!(v%3==0||v%5==0)){
      out(t);
      return 0;
    }
  }

  out(s);
  // for(auto k:a){
  //   if(!(k%2==0&&(k%3==0||k%5==0))){
  //     out(t);
  //     return 0;
  //   }
  // }



  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    s='0'+s;
    int pay=0,re=0;
    for(int i=s.size()-1;i>=0;i--)
    {
        if(s[i]>'5'){
            re+=10-(s[i]-'0');
            s[i]='0';
            s[i-1]++;
        }
        else if(s[i]=='5'&&s[i-1]>='5'){
            re+=10-(s[i]-'0');
            s[i]='0';
            s[i-1]++;
        }
    }
    for(int i=0;i<s.size();i++)
        pay+=s[i]-'0';

    cout<<pay+re;
    return 0;
}


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


using namespace std;

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

    vector<vector<long long int>> A(a,vector<long long int>(b,0));
    vector<vector<long long int>> B(b,vector<long long int>(c,0));

    for (int d = 0; d < a; ++d) {
        for (int e = 0; e < b; ++e) {
            cin >> A.at(d).at(e);
        }
    }

    for (int f = 0; f < b; ++f) {
        for (int g = 0; g < c; ++g) {
            cin >> B.at(f).at(g);
        }
    }

    vector<vector<long long int>> Result(a,vector<long long int>(c,0));

    for (int i = 0; i < a; ++i) {
        for (int k = 0; k < b; ++k) {
            for (int j = 0; j < c; ++j) {
                Result.at(i).at(j) += A.at(i).at(k) * B.at(k).at(j);
            }
        }
    }

    for (int l = 0; l < a; ++l) {
        for (int m = 0; m < c; ++m) {
            cout << Result.at(l).at(m);

            if(m != c -1){
                cout << " ";
            }
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 3280
n,q=map(int,input().split())
s=input()
td=[input().split()for _ in range(q)]
def check(i,x):
  for t,d in td:
    if s[i]==t:
      if d=="L":i-=1
      else:i+=1
    if i==x:return True
    if i==-1 or i==n:return False
  return False
ok=-1
ng=n
while ok+1!=ng:
  mid=(ok+ng)//2
  if check(mid,-1):ok=mid
  else:ng=mid
ans=ng
ok=-1
ng=n
while ok+1!=ng:
  mid=(ok+ng)//2
  if check(mid,n):ng=mid
  else:ok=mid
ans+=(n-ng)
print(max(0,n-ans))

Measured memory_bytes: 41264
#!/usr/bin/python3
# -*- coding:utf-8 -*-

import numpy

MAX = 10 ** 9 + 7

def prod_mod(la, mod):
  x = 1
  for a in la:
    x *= a
    x %= mod
  return x

def main():
  n, k = map(int, input().strip().split())
  la = numpy.array(list(map(int, input().strip().split())))
  la.sort()
  if n == k:
    print(prod_mod(la, MAX))
  else:
    if k % 2 == 1 and (la >= 0).sum() == 0:
      print(prod_mod(la[-k:], MAX))
    else:
      il, ir = 0, n-1
      cnt = 0
      l = []
      if k % 2 == 1:
        l.append(la[ir])
        ir -= 1
        cnt += 1
      while k - (cnt + 2) >= 0:
        if la[il] * la[il+1] > la[ir-1] * la[ir]:
          l.extend([la[il], la[il+1]])
          il += 2
        else:
          l.extend([la[ir-1], la[ir]])
          ir -= 2
        cnt += 2
      print(prod_mod(l, MAX))
      

if __name__=='__main__':
  main()



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

int main() {
  vector<pair<int, string>> v;
  map<string, int> m;
  int n, a;
  cin >> n;
  rep(i, n){
    string s;
    cin >> s;
    if(m.count(s)) ++m[s];
    else m[s] = 1;
  }
  for(auto p: m) v.push_back(make_pair(p.second, p.first));
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  rep(i, v.size()){
    if(v[i].first == v[0].first) continue;
    else{
      a = i-1;
      break;
    }
  }
  for(int i = a; i >= 0; --i) cout << v[i].second << endl;
  return 0;
}

Measured memory_bytes: 29172
#include <bits/stdc++.h>
#define int long long
using namespace std;

int power5(int x){
	return x*x*x*x*x;
}

int32_t main(){
	int x;
	cin >> x;
	map<int, int> dp;
	dp[0] = 0;
	for(int i=1; i<=200; i++){
		dp[power5(i)] = i;
	        dp[-power5(i)] = -i;	
	}
	int a, b;
	for(int i=-200; i<=200; i++){
		if(dp.find(power5(i)-x) != dp.end()){
			a = i;
			b = dp[power5(i)-x];
			break;
		}
	} 
	cout << a << " " << b << "\n";
}
		


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

//#define int long long
#define DBG 0
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) c.begin(),c.end()
static const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
static const int MOD = (int)(1e9 + 7);

signed main() {
	int L, N; cin >> L >> N;
	int m = 0;
	rep(i, 0, N) {
		int x, w; cin >> x >> w;
		m += x*w;
	}
	bool minus = false;
	if (m > 0)minus = true;
	m = abs(m);
	vector<int> X, W;
	rrep(i, 1, L + 1) {
		if (m == 0)break;
		int x = i, w = m / i;
		if (w) {
			X.emplace_back(x);
			W.emplace_back(w);
			m -= (m / i)*i;
		}
	}
	cout << X.size() << endl;
	rep(i, 0, X.size()) {
		if (minus)cout << "-";
		cout << X[i] << " " << W[i] << endl;

	}
	return 0;
}

Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define hetu int t;cin >> t;while(t--) 

void solve()
{
    string s;
    cin >> s;
    ll sum=0;
    for(ll i=0;i<s.length();++i)
    sum+=(s[i]-48);
    //cout << sum << endl;
    if(sum%9==0)
    cout << "Yes" << endl;
    else
    cout << "No" << endl;

}
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    //hetu
    solve();
    return 0;
}

Measured memory_bytes: 3720
import sys
from bisect import bisect_left

N = int(input())
dp = []
append = dp.append
result = -1

for n in map(int, sys.stdin.readlines()):
    i = bisect_left(dp, n)
    if i > result:
        append(n)
        result += 1
    else:
        dp[i] = n

print(result+1)

Measured memory_bytes: 18740
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;

int main(){
  int n,k;
  cin >> n >> k;
  int cnt = 0;
  while(n>0){
    n = (n-n%k)/k;
    cnt++;
  }
  printf("%d\n", cnt);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAX_ANS = 100000;

int main(){
    int H,W,K;
    cin >> H >> W >> K;
    vector<string> S(H);
    for(int i=0;i<H;i++){
        string s;
        cin >> s;
        S[i] = s;
    }

    int ans =MAX_ANS;
    
    for(int bit =0;bit <(1<<H-1);bit++){
        int Sans =0;
        vector<int> hDivide;
        for(int i=0;i<H-1;i++){
            if(bit & (1<<i)){
                hDivide.push_back(i+1);
                Sans++;
            }
        }
        hDivide.push_back(H);
        vector<int> num(S.size(),0);
        bool divide = false;
        bool finished = false;
        int lastDivided = -1;
        for(int i=0;i<W;i++){
            if(finished){
                Sans = MAX_ANS;
                break;
            }
            if(divide){
                for(int j=0;j<num.size();j++){
                    num[j] =0;
                }
                i--;
                divide = false;
            }
            int pre = 0;
            for(int target:hDivide){
                if(divide){
                    break;
                }
                for(int j=pre;j<target;j++){
                    if(S[j][i] == '1'){
                        num[target-1]++;
                    }
                    if(num[target-1] >K){
                        Sans++;
                        divide =true;
                        if(lastDivided == i){
                            finished = true;
                        }
                        
                        lastDivided = i;
                        break;
                    }
                }
                pre = target;
            }
        }
        ans = min(ans,Sans);

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

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
#include<limits.h>
using namespace std;
using T = tuple<int,int,int>;

#define eb emplace_back
#define pb push_back
#define MP make_pair
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define rep(i,j,n) for (int i = j; i < n; ++i)
#define repn(i,j,n) for (int i = j; i <= n; ++i)
#define revn(i,j,n) for (int i = j; i >= n; --i)
#define sz(i) i.size()
#define mem(i,v) memset(i,v,sizeof(i))
#define all(v) v.begin(), v.end()
//#define endl '\n'
#define int long long
#define INF 1e7
#define ss second
#define ff first
#define vi vector<int>
#define pri(arr,a,b) repn(i,1,a){repn(j,i+1,b){cout<<arr[i][j]<<" ";}cout<<endl;}

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair<int,pair<int,int>> piii;
 
string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cerr << " " << to_string(H); debug_out(T...);}
#define pr(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

const int mod=1e9+7;
//const int mod=998244353;
const int up=2e5+10;
const int MAXN=100;

int a[3001],dp[3001][3001];

int solvedp(int i,int j){
    if(dp[i][j]!=-1){
        return dp[i][j];
    }
    if(i==j){
        return dp[i][j]=a[i];
    }
    int ans=max(a[i]-solvedp(i+1,j),a[j]-solvedp(i,j-1));
    return dp[i][j]=ans;
}

void solve()
{
    mem(dp,-1);
    int n;
    cin>>n;
    repn(i,1,n){
        cin>>a[i];
    }
    cout<<solvedp(1,n)<<endl;
}



int32_t main()
{
    // #ifndef ONLINE_JUDGE
    //     freopen("inputf.in", "r", stdin);
    //     freopen("outputf.in", "w", stdout);
    // #endif
    fast_cin();
    int T;
    //sieve();
    //Sieve(100);
    //cin>>T;
    T=1;
    int t1=1;
    while(true)
    {  
        solve();  
        t1++;
        if(t1>T)
            break;
    }
}

Measured memory_bytes: 74128
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>

using namespace std;

int main()
{
	int N, Y, Y1, x, y, z;

	scanf("%d %d", &N, &Y);

	Y1=Y/1000;

	int res=(Y1-N)%9;

	if(res==0){
			if(Y1-N>=0 && N>=(Y1-N)/9){
				y=0;
				x=(Y1-N)/9;
				z=N-x-y;
			}else{
				x=-1; y=-1; z=-1;
			}
	}else if(res==1){
			if(Y1-N-28>=0 && N>=(Y1-N-28)/9+7){
				y=7;
				x=(Y1-N-28)/9;
				z=N-x-y;
			}else{
				x=-1; y=-1; z=-1;
			}
	}else if(res==2){
			if(Y1-N-20>=0 && N>=(Y1-N-20)/9+5){
				y=5;
				x=(Y1-N-20)/9;
				z=N-x-y;
			}else{
				x=-1; y=-1; z=-1;
			}
	}else if(res==3){
			if(Y1-N-12>=0 && N>=(Y1-N-12)/9+3){
				y=3;
				x=(Y1-N-12)/9;
				z=N-x-y;
			}else{
				x=-1; y=-1; z=-1;
			}
	}else if(res==4){
			if(Y1-N-4>=0 && N>=(Y1-N-4)/9+1){
				y=1;
				x=(Y1-N-4)/9;
				z=N-x-y;
			}else{
				x=-1; y=-1; z=-1;
			}
	}else if(res==5){
			if(Y1-N-32>=0 && N>=(Y1-N-32)/9+8){
				y=8;
				x=(Y1-N-32)/9;
				z=N-x-y;
			}else{
				x=-1; y=-1; z=-1;
			}
	}else if(res==6){
			if(Y1-N-24>=0 && N>=(Y1-N-24)/9+6){
				y=6;
				x=(Y1-N-24)/9;
				z=N-x-y;
			}else{
				x=-1; y=-1; z=-1;
			}
	}else if(res==7){
			if(Y1-N-16>=0 && N>=(Y1-N-16)/9+4){
				y=4;
				x=(Y1-N-16)/9;
				z=N-x-y;
			}else{
				x=-1; y=-1; z=-1;
			}
	}else{
			if(Y1-N-8>=0 && N>=(Y1-N-8)/9+2){
				y=2;
				x=(Y1-N-8)/9;
				z=N-x-y;
			}else{
				x=-1; y=-1; z=-1;
			}
	}

	printf("%d %d %d\n", x, y, z);
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;
ll inf = 1000000000;
typedef pair<ll, ll> P;
int main() {
	ll n, a, b;
	cin >> n >> a >> b;
	ll sum = n % (a + b);
	if (sum >= a) {
		cout << n / (a + b) * a + a << endl;
		return 0;
	}
	else {
		cout << n / (a + b) * a + sum << endl;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256
/*
    Author: Alam Khan
    AUST CSE 40th Batch

*/

#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef deque<ll> dl;
typedef stack<ll> stl;
typedef set<ll> sl;
typedef map<string, ll> msl;
typedef map<ll,ll> mll;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
#define sf(n)     scanf("%lld",&n)
#define sff(n,m)     scanf("%lld %lld",&n,&m)
#define sfff(n,m,r)     scanf("%lld %lld %lld",&n,&m,&r)
#define sfs(n)     scanf("%s",n)
#define pf(n)     printf("%lld\n",n)
#define pff(n,m)     printf("%lld %lld\n",n,m)
#define pfff(n,m,r)     printf("%lld %lld %lld\n",n,m,r)
#define pfs(n)     printf("%s\n",n)
#define pfcs(i,n)     printf("Case %lld: %lld\n",i,n)
#define pb     push_back
#define prf     printf
#define inf     2e18
#define low     -1000000000000
#define PI        acos(-1.0)
#define rep1(i,n) for(i=1;i<n;i++)
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,a,n) for(i=a;i<n;i++)
#define repe1(i,n) for(i=1;i<=n;i++)
#define repe0(i,n) for(i=0;i<=n;i++)
#define repe(i,a,n) for(i=a;i<=n;i++)
#define endl  "\n"
#define FAST  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr freopen("input.txt","r",stdin)
#define fw freopen("output.txt","w",stdout)

int main()
{
    ll i,n,t,k,j,x=0,y=0,m;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>y;
        if(y%2==1 && i%2==1)
            x++;
    }
    cout<<x<<endl;
    return 0;
}



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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007; // 998244353

#define CLR(a) memset((a), 0, sizeof(a))

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

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

struct Node{
    int id;
    int v;
    bool done = false;
    Node(int id, int v=1e9): id(id), v(v) {}
    Node(): id(0), v(1e9) {}
};

bool operator>(Node a, Node  b){
    return a.v > b.v;
}

struct Edge{
    int from, to, id;
    int cost;
    Edge(int from, int to, int cost=1, int id=-1): from(from), to(to), cost(cost), id(id) {}
};

struct Graph{
    int N;
    vector<vector<Edge>> adj;
    vector<Node> node;

    Graph(int N): N(N) {
        adj.assign(N, vector<Edge>());
        node.assign(N, Node());
        for(int i=0; i<N; ++i) node[i].id = i;
    }

    Graph() {}

    void add_edge(int i, int j, int cost=1, int id=-1){
        Edge e(i, j, cost, id);
        adj[i].emplace_back(e);
    }

    vector<Edge> get_adj(Node node){
        return adj[node.id];
    }

    void assign(int n){
        N = n;
        adj.assign(N, vector<Edge>());
        node.assign(N, Node());
        for(int i=0; i<N; ++i) node[i].id = i;
    }

    void reset(){
        for(int i=0; i<N; ++i){
            node[i].done = false;
            node[i].v = 1e9;
        }
    }
};

Graph G;
int N,M;
VI dp;

int dfs(int n){
    if(dp[n] != -1) return dp[n];
    int res = 0;
    for(Edge e : G.adj[n]){
        chmax(res, dfs(e.to)+1);
    }
    return dp[n] = res;
}

int main(void){
    cin >> N >> M;
    G.assign(N); dp.assign(N,-1);
    REP(i,N+M-1){
        int a,b; cin >> a >> b; a--; b--;
        G.add_edge(b,a);
    }

    VI ans(N,0);
    REP(i,N){
        for(Edge e : G.adj[i]){
            if(dfs(i) == dfs(e.to)+1) ans[i] = e.to+1;
        }
    }

    REP(i,N) cout << ans[i] << en;
    return 0;
}

Measured memory_bytes: 11264
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <complex>

int main(){

  // read problem
  long long int N, P;
  std::string strtmp;
  scanf("%lld%lld", &N, &P);
  std::cin >> strtmp;

  std::vector<long long int> S;
  for(long long int i = 0; i < N; i++){
    S.push_back((long long int)strtmp[i] - '0');
  }

  /*std::cerr << N << " " << P << std::endl;
  std::cerr << "initial S: " << std::endl;
  for(long long int i = 0; i < N; i++){
    std::cerr << S[i] << " ";
  }std::cerr << std::endl;*/

  long long int ans;

  // if P == 2
  if(P == 2){
    ans = 0;
    for(long long int i = 0; i < N; i++){
      if((S[i]+2)%2 == 0){
        ans += i+1;
      }
    }
    std::cerr << "Answer: " << std::endl;
    std::cout << ans << std::endl;

    return 0;
  }

  // if P == 5
  if(P == 5){
    ans = 0;
    for(long long int i = 0; i < N; i++){
      if((S[i]+5)%5 == 0){
        ans += i+1;
      }
    }
    std::cerr << "Answer: " << std::endl;
    std::cout << ans << std::endl;

    return 0;
  }

  // remake S
  long long int tmp = 1;

  for(long long int i = N-1; i >= 0; i--){
    S[i] = (S[i]*tmp+P)%P;
    tmp = (tmp*10+P)%P;
  }
  /*std::cerr << N << " " << P << std::endl;
  std::cerr << "secondary S: " << std::endl;
  for(long long int i = 0; i < N; i++){
    std::cerr << S[i] << " ";
  }std::cerr << std::endl;*/

  for(long long int i = 1; i < N; i++){
    S[i] = S[i-1] + S[i];
  }
  /*std::cerr << N << " " << P << std::endl;
  std::cerr << "tertiary S: " << std::endl;
  for(long long int i = 0; i < N; i++){
    std::cerr << S[i] << " ";
  }std::cerr << std::endl;*/

  std::vector<long long int> count(P);
  for(long long int i = 0; i < N; i++){
    count[(S[i]+P)%P]++;
  }

  ans = 0;
  ans += count[0] + (count[0]*(count[0]-1))/2;
  for(long long int i = 1; i < P; i++){
    ans += (count[i]*(count[i]-1))/2;
  }

  std::cerr << "Answer: " << std::endl;
  std::cout << ans << std::endl;

  return 0;
  
}


Measured memory_bytes: 2680