akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	read  = bufio.NewReader(os.Stdin)
	write = bufio.NewWriter(os.Stdout)
)

func min(a, b int) int {
	if a <= b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a >= b {
		return a
	}
	return b
}

func yesno(result bool) {
	if result {
		fmt.Fprintln(write, "Yes")
	} else {
		fmt.Fprintln(write, "No")
	}
}

func printansStr(result bool, a, b string) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func printansInt(result bool, a, b int) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func main() {
	defer write.Flush()

	var n, d int
	fmt.Fscan(read, &n, &d)

	d = d*2 + 1
	fmt.Fprintln(write, (n+d-1)/d)
}


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

int main(){
	
	int n;
	cin >> n;
	vector<int> a(n);
	int sum = 0;

	int bef = 0;
	for(int i = 0; i < n; i++)
	{	
		cin >> a[i];
		sum += abs(a[i] - bef);
		bef = a[i];
	}
	sum += abs(a[n-1]);

	for(int i = 0; i < n; i++)
	{
		if(i == 0) cout << sum + abs(a[i+1]-0) - abs(a[i+1] - a[i]) - abs(0 - a[i]) << endl;
		else if(i == n-1) cout << sum + abs(a[i-1]-0) - abs(a[i-1] - a[i]) - abs(0 - a[i]) << endl;
		else cout << sum + abs(a[i-1] - a[i+1]) - abs(a[i-1] - a[i]) - abs(a[i+1] - a[i]) << endl;
	}
	
	

	return 0;
}

Measured memory_bytes: 1664
#include <stdio.h>
 
void dfs(int o, int n, int G[][101], int *oT, int *d, int *f) {
  int i;
  d[o] = *oT;
  for(i = 1; i <= n; ++i) {
    if(!G[o][i]) continue;
    if(d[i] != -1) continue;
    ++(*oT);
    dfs(i,n,G,oT,d,f);
    ++(*oT);
  }
  f[o] = *oT + 1;
}
 
int main() {
  int n;
  int i,j,k;
  int G[101][101];
  int src, dst;
  int T, d[101], f[101];
  for(i = 0; i < 101; ++i)  {
    d[i] = -1;
    for(j = 0; j < 101; ++j) {
      if(i == 0) G[i][j] = 1;
      else G[i][j] = 0;
    }
  }
 
  scanf("%d", &n);
  for(i = 1; i <= n; ++i) {
    scanf("%d %d", &src, &k);
    while(k--) {
      scanf("%d", &dst);
      G[src][dst] = 1;
    }
  }
 
  T = 0;
  dfs(0,n,G,&T,d,f);
  for(i = 1; i <= n; ++i) {
    printf("%d %d %d\n", i, d[i], f[i]);
  }
  return 0;
}



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

int main() {
  int x, root, ans;
  bool isPrime=false;
  cin >> x;
  root = ((int)sqrt(x)+1);
  if(x==2 || x==3) {
    cout << x << endl;
    return 0;
  }
  while(1) {
    for(int i=2; i<=root; i++) {
      if(x%i==0) {
        break;
      } else
      if(i==root) isPrime=true;
    }
    if(isPrime) {
      ans=x;
      break;
    }
    x++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	readBytes  func() []byte
	stdout     *bufio.Writer
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// readString() string
// readInt() int
// readInt64() int64
// readFloat64() float64

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	N := readInt()
	M := readInt()
	l := 1
	r := N
	for i := 0; i < M; i++ {
		L := readInt()
		R := readInt()

		if l < L {
			l = L
		}
		if R < r {
			r = R
		}
	}
	if r < l {
		println(0)
	} else {
		println(r - l + 1)
	}
}

// -----------------------------------------------------------------------------


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

const double eps = 1e-9;
bool same(double a, double b) { return abs(a - b) < eps; }

struct P {
    double x, y;
    P() : x(0), y(0) {}
    P(double x, double y) : x(x), y(y) {}
    P operator + (P b) { return P(x + b.x, y + b.y); }
    P operator - (P b) { return P(x - b.x, y - b.y); }
    P operator * (double b) { return P(x * b, y * b); }
    P operator / (double b) { return P(x / b, y / b); }
    double operator * (P b) { return x * b.x + y * b.y; }
    double operator ^ (P b) { return x * b.y - y * b.x; }
    double abs() { return hypot(x, y); }
    P unit() { return *this / abs(); }
    P spin(double o) {
        double c = cos(o), s = sin(o);
        return P(c * x - s * y, s * x + c * y);
    }
};

struct L {
    // ax + by + c = 0
    double a, b, c, o;
    P pa, pb;
    L() : a(0), b(0), c(0), o(0), pa(), pb() {}
    L(P pa, P pb) : a(pa.y - pb.y), b(pb.x - pa.x), c(pa ^ pb), o(atan2(-a, b)), pa(pa), pb(pb) {}
    P project(P p) { return pa + (pb - pa).unit() * ((pb - pa) * (p - pa) / (pb - pa).abs()); }
    P reflect(P p) { return p + (project(p) - p) * 2; }
    double get_ratio(P p) { return (p - pa) * (pb - pa) / ((pb - pa).abs() * (pb - pa).abs()); }
    bool inside(P p) {
        double x = get_ratio(p);
        return x >= 0 && x <= 1;
    }
};

struct C {
    P c;
    double r;
    C() : r(0) {}
    C(P c, double r) : c(c), r(r) {}
};

bool parallel(L x, L y) { return same(x.a * y.b, x.b * y.a); }

P intersect(L x, L y) { return P(-x.b * y.c + x.c * y.b, x.a * y.c - x.c * y.a) / (-x.a * y.b + x.b * y.a); }

int pip(vector<P> ps, P p) {
    int c = 0;
    for (int i = 0; i < ps.size(); ++i) {
        int a = i;
        int b = (i + 1) % ps.size();
        L l(ps[a], ps[b]);
        P q = l.project(p);
        if ((p - q).abs() < eps && l.inside(q)) return 1;
        if (same(ps[a].y, ps[b].y) && same(ps[a].y, p.y)) continue;
        if (ps[a].y > ps[b].y) swap(a, b);
        if (ps[a].y <= p.y && p.y < ps[b].y && p.x <= ps[a].x + (ps[b].x - ps[a].x) / (ps[b].y - ps[a].y) * (p.y - ps[a].y)) ++c;
    }
    return (c & 1) * 2;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n; cin >> n;
    vector<P> ps(n);
    for (int i = 0; i < n; ++i) cin >> ps[i].x >> ps[i].y;
    int q; cin >> q; while (q--) {
        P p; cin >> p.x >> p.y;
        cout << pip(ps, p) << '\n';
    }
}



Measured memory_bytes: 3508
import java.util.*;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int D = sc.nextInt();

        int x = Math.min(A,B);
        int y = Math.min(C,D);

            System.out.print(x+y);
        }
}


Measured memory_bytes: 35548
def ans(M, nums):
    for _ in range(M):
        s, c = map(int, input().split())
        
        if nums[s-1] == -1:
            nums[s-1] = c
            continue
        else:
            if nums[s-1] != c: 
                return -1
    
    for i, num in enumerate(nums):
        if num != -1:
            continue
        else:
            if i == 0:
                if len(nums) == 1:
                    nums[i] = 0
                else:
                    nums[i] = 1
            else:
                nums[i] = 0
    
    ans = int(''.join(map(str, nums)))
    
    if len(str(ans)) == len(nums):
        return ans
    else:
        return -1
 
N, M = map(int, input().split())
nums = [-1 for i in range(N)]
 
print(ans(M, nums))

Measured memory_bytes: 38384
# a:0 c:1 g:2 t:3
# agc acg gac a?gc ag?c
from collections import defaultdict
MOD = 10 ** 9 + 7


def ok(s: str) -> bool:
    if 'AGC' in s:
        return False
    sl = list(s)
    if len(s) < 3:
        return True
    for i in range(len(s)-1):
        st = sl.copy()
        st[i], st[i + 1] = sl[i + 1], sl[i]
        if 'AGC' in ''.join(st):
            return False
    return True


n = int(input())
dp = [defaultdict(int) for _ in range(n + 1)]
dp[0][''] = 1
for i in range(1, n + 1):
    for k in dp[i - 1].keys():
        for c in 'ACGT':
            st = k[1 if i > 4 else 0:] + c
            if ok(st):
                dp[i][st] += dp[i - 1][k]
                dp[i][st] %= MOD
print(sum(dp[n].values()) % MOD)

Measured memory_bytes: 6408
#include <bits/stdc++.h>
#define fio ios_base::sync_with_stdio(false)
#define pdl cout << "*" << endl
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1000000000
#define INFLL 1000000000000000000ll
#define ff first
#define ss second
#define long int64_t
using namespace std;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
uniform_int_distribution<> dis(0, INF<<1);
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char* name, Arg1&& arg1){ cerr << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args)
{ const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma+1, args...); }

const int N = 100001;

int h[N];

int main()
{
	fio;
	int n, k, ans = 0;
	cin >> n >> k;
	for(int i=1; i<=n; i++)
	{
		cin >> h[i];
		if(h[i] >= k)
			ans++;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;

int main()
{
	ll n;
	cin >> n;
	ll ans=1;
	ll edge=1000000000000000000;
	int flag=1;
	while(n--)
	{
		ll tem;
		cin >> tem;
		ll a=edge/ans;
		if(ans&&tem>a) flag=0;
		ans*=tem;
        if(tem==0)
        {
            flag=1;
            ans=0;
        }
	}
	if(!flag) cout << -1;
	else cout << ans;





	return 0;
}



Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main (){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int l=a+b,r=c+d;
  if(l<r)
    cout<<"Right"<<endl;
  else if(l>r)
    cout<<"Left"<<endl;
  else
    cout<<"Balanced"<<endl;
  return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <map>
#include <cstring>
#include <string>
#include <math.h>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repp(i, m, n) for(int i = m; i < (int)n; i++)
#define reps(i, n) for(int i = 1; i <= (int)n; i++)
#define repps(i, m, n) for(int i = m; i <= (int)n; i++)
#define pb push_back
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;


int main()
{
	int ans=0;
	int n, w[2010], b[2010], wb[2010][2010], bw[2010][2010], x;
	int dp[2010][2010]={};
	char c;
	cin >> n;
	reps(i, 2*n)
	{
		cin >> c >> x;
		if(c=='W') w[x]=i;
		else b[x]=i;
	}

	

	reps(i, n) for(int j=i+1; j<=n; j++)
	{
		if(w[i]>w[j]) ans++;
		if(b[i]>b[j]) ans++;
	}
	//cout << ans << endl;
	dp[0][0]=0;
	reps (j, n)
	{
		dp[j][0]=dp[j-1][0];
		reps(i, n) if(b[i]<w[j]) dp[j][0]++;
		wb[0][j]=dp[j][0]-dp[j-1][0];
	}

	reps(i, n) reps(j, n)
	{
		wb[i][j]=wb[i-1][j];
		if(b[i]<w[j]) wb[i][j]--;
	}

	reps(j, n)
	{
		dp[0][j]=dp[0][j-1];
		reps(i, n) if(w[i]<b[j]) dp[0][j]++;
		bw[0][j]=dp[0][j]-dp[0][j-1];
	}

	reps(i, n) reps(j, n)
	{
		bw[i][j]=bw[i-1][j];
		if(w[i]<b[j]) bw[i][j]--;
	}

	reps(i, n) reps(j, n)
	{
		dp[i][j]=min(dp[i-1][j]+wb[j][i], dp[i][j-1]+bw[i][j]);
		//cout << tw << tb << ' ' << dp[i][j] << ' ';
	}
	cout << ans + dp[n][n] << endl;

	return 0;
}

Measured memory_bytes: 47616
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long
#define endl "\n"
#define print_array(name,n) for(ll o=0;o<n;o++) cout<<name[o]<<" "
#define fr(i,f,t) for(ll i=(f);i<t;i++)
#define fb(i,f,t) for(ll i=(f);i>=t;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 2e18
bool sortbysecond(const pair<int,int> &a,const pair<int,int> &b){
	return (a.ss>b.ss);
}
template <typename T>
string NumberTostring(T Number )
{
	ostringstream ss;
	ss<<Number;
	return ss.str();
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    string s;
    cin>>s;
    if(s[1]=='B'){
    	cout<<"ARC"<<endl;
    }
    else{
    	cout<<"ABC"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3652
N = int(input())
*S, = map(int, input().split())

ans = 0
for d in range(1, N):
    r = k = 0
    while k*d <= N-1:
        a = N-1-k*d
        if a <= d or (a <= k*d and a % d == 0):
            break
        r += S[N-1-k*d] + S[k*d]
        k += 1
        ans = max(ans, r)
print(ans)

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

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

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

map<string, int> mp;
vector<string> input;
int H, W;

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

void f(int x, int y, set<pii>& st, string& s, const int dir) {
  //  cout << x << " " << y << " " << dir <<" " << s << endl;
  //  cout <<mp.size() << endl;
  //  cout <<s.size() << " " << st.size() << " " << mp.size() << endl;
  s += input[y][x];
  if(s.size() >= 2)   mp[s]++;
  pii p;
  p = make_pair(y, x);
  st.insert(p);
  (x += dx[dir] + W) %= W;
  (y += dy[dir] + H) %= H;
  assert(x >= 0 && x < W);
  assert(y >= 0 && y < H);
  p = make_pair(y, x);
  if(st.count(p)) {
    //    mp[s]++;
    return;
  }
  f(x, y, st, s, dir);
}

int main() {
  while(cin >> H >> W) {
    if(H == 0 && W == 0) break;
    mp.clear();
    input.resize(H);
    rep(i, H) cin >> input[i];
    rep(i, H) rep(j, W) {
      //mp[input[i].substr(j, 1)]++;
      rep(k, 8) {
	set<pii> st;
	string s;
	f(j, i, st, s, k);
      }
    }
    string s;
    for(map<string, int>::iterator it = mp.begin(); it != mp.end(); ++it) {
      if(it->second == 1) continue;
      if(s.size() < it->first.size()) s = it->first;
      else {
	if(s.size() == it->first.size() && s > it->first) s = it->first;
      }
    }
    if(s.size() == 0) cout << 0 << endl;
    else cout << s << endl;
  }
  return 0;
}

Measured memory_bytes: 38048
# -*- coding: utf-8 -*-
# 天気の入力
s = (input())
# 出力
odds = s[::2] # 奇数
evens = s[1::2] # 偶数
if 'L' in odds:
    print('No')
elif 'R' in evens:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long i64;
typedef pair<i64,i64> P;


i64 n;

int main(){
	cin >> n;
	
	i64 c = 0;
	if(n == 2){
		cout << 0 << endl;
		return 0;
	}
	for(i64 i = 1; i*i < n; i++){
		if(n % i == 0){
			i64 j = n/i;
			if(n % (j-1) == n / (j-1)) c += j - 1;
		}
	}
	
	cout << c << endl;
	
	return 0;
}

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

using namespace std;

int dist(int i, int j, const string & in){
    if(in[j] == in[j+i] || in[j+i] == in[j+2*i] || in[j+2*i] == in[j] ) return 0;
    else return 1;
}

int main(){
    int N;
    cin >> N;
    string in;
    vector<int> r, g, b;
    cin >> in;
    for(int i=0; i!=in.size(); i++){
        switch(in.at(i)){
            case 'R': r.push_back(i);
                break;
            case 'G': g.push_back(i);
                break;
            case 'B': b.push_back(i);
                break;
        }
    }

    int sum =0;
    if(N%2){
        for(int i=1; i!=N/2+1; i++){
            for(int j=0; j+2*i<N; j++){
                sum += dist(i,j,in);
            }
        }
    }else{
        for(int i=1; i<=N/2-1; i++){
            for(int j=0; j+2*i<N; j++){
                sum += dist(i,j,in);
            }
        }
    }

    cout << r.size() * g.size() * b.size() - sum << endl;
    return 0;

}

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

int main(){
  int a , b;
  cin >> a >> b;
  int c = a * b;
  if (c % 2 == 1){ 
    cout << "Odd" <<endl;
  }
  else {
    cout << "Even" << endl;
  }
  
}
 

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

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

Measured memory_bytes: 256
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int num = int.Parse(Console.ReadLine());
            string[] val = Console.ReadLine().Split(' ');

            int count = 0;

            for (int i = 0; i < num; i++)
            {
                int target = int.Parse(val[i]);

                int t = (i - 1);
                int t2 = (i + 1);

                if (t < 0 || t2 > num-1)
                    continue;

                int[] vs = { int.Parse(val[t]), target, int.Parse(val[t2]) };
                Array.Sort(vs);

                if (vs[1] == target)
                    count++;
            }


            Console.WriteLine(count.ToString());
        }
    }
}


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


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	int k;
	cin>>k;
	int a,b;
	cin>>a>>b;
	bool flag = false;
	
	for(int i=a;i<=b;i++){
		if(i%k==0){
			flag = true;
			break;
		}
	}
	
	if(flag)cout<<"OK";
	else cout<<"NG";
}


Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#define cs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define rep(i,b)  for(int i=0;i<(int)(b);i++)
#define Rep(i,n) for(int i=1;i<(int)(n);i++)
#define repp(i,a,b)  for(int i=a;i<=(int)(b);i++)
#define Repp(i,a,b)  for(int i=a;i>=(int)(b);i--)
typedef long long ll;
typedef long double ld;

using namespace std;
int n;
void dfs(string s,char c){
    if(s.size()==n) {cout<<s<<'\n';return;}
    
    for(char t='a';t<c;t++) dfs(s+t,c);
    dfs(s+c,c+1);
}
int main(){
    cs
    cin>>n;
    dfs("",'a');
}

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

using namespace std;

const int maxn = 404;
char grid[maxn][maxn];
int visited[maxn][maxn];
long long black, yellow;

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

void init()
{
    memset(visited, 0, sizeof(visited));
}

void dfs(int x, int y, char c)
{
    if (x < 0 || x >= rows || y < 0 || y >= columns || visited[x][y] || grid[x][y] == c)
        return;

    visited[x][y] = 1;

    if (grid[x][y] == '#')
        black++;
    else
        yellow++;

    for (int i = 0; i < 4; i++)
    {
        dfs(x + dx[i], y + dy[i], grid[x][y]);
    }
}

int main()
{
    cin >> rows >> columns;
    long long answer = 0;

    for (int i = 0; i < rows; i++)
    {
        for (int j = 0; j < columns; j++)
        {
            cin >> grid[i][j];
        }
    }

    for (int i = 0; i < rows; i++)
    {
        for (int j = 0; j < columns; j++)
        {
            if (grid[i][j] == '#' and visited[i][j] == 0)
            {
                black = yellow = 0;
                dfs(i, j, '.');
                answer += black * yellow;
            }
        }
    }

    cout << answer << endl;

    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define FORI(i,v) for (auto i = v.begin(); i != v.end(); i++)
#define ALL(v) v.begin(), v.end()
#define CHMIN(x,y) x = min(x, y)
#define CHMAX(x,y) x = max(x, y)

const int MAX = 2e5+10;
const ll INF = 1e15;
const int K = 10;
int N;
ll A[MAX];

ll dp[MAX*K][2];

inline int idx(int n, int k) {
    return n * K + k - n/2 + K/2;
}

ll solve() {
    REP (i, MAX) REP (k, K) dp[i*K+k][0] = dp[i*K+k][1] = -INF;
    dp[idx(1, 0)][0] = 0;
    dp[idx(1, 1)][1] = A[0];
    FOR (n, 2, N+1) FOR (k, (n-1)/2-2, (n+1)/2+2) {
        CHMAX(dp[idx(n, k)][0], dp[idx(n-1, k)][0]);
        CHMAX(dp[idx(n, k)][0], dp[idx(n-1, k)][1]);
        CHMAX(dp[idx(n, k)][1], dp[idx(n-1, k-1)][0] + A[n-1]);
    }

    return max(dp[idx(N, N/2)][0], dp[idx(N, N/2)][1]);
}

int main() {
    cin >> N;
    REP (i, N) cin >> A[i];
    cout << solve() << endl;
}

Measured memory_bytes: 36412
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int arr[n][3];
  for(int i=0;i<n;i++)
      for(int j=0;j<3;j++)
          cin>>arr[i][j];
    
  vector<vector<int>> dp(n,vector<int> (3,0));
  dp[0][0]=arr[0][0];
  dp[0][1]=arr[0][1];
  dp[0][2]=arr[0][2];
    
  for(int i=1;i<n;i++)
  {  
      for(int j=0;j<3;j++)
      {
          dp[i][j]=arr[i][j];
          if(j==0) dp[i][j]+=max(dp[i-1][j+1],dp[i-1][j+2]);
          else if(j==1) dp[i][j]+=max(dp[i-1][j-1],dp[i-1][j+1]);
          else dp[i][j]+=max(dp[i-1][j-1],dp[i-1][j-2]);
      }
  }
  int ans=max(dp[n-1][0],dp[n-1][1]);
  ans=max(ans,dp[n-1][2]);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s,w;
    cin >> s >> w;
    if(s[0]==w[2] && s[1]==w[1] && s[2]==w[0]){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int i, n, a, b, c;

    scanf("%d", &n);

    for (i = 0; i < n; i++){
        scanf("%d %d %d", &a, &b, &c);

        if (a >= b && a >= c){
            b = b * b + c * c; 
           // printf("%d", b);
            if (a*a == b){
                printf("YES\n");
            }else {
                printf("NO\n");
            }
        }else if (b >= a && b >= c){
            a = a * a + c * c; 
            //printf("%d", a);
            if (b * b == a){
                printf("YES\n");
            }else {
                printf("NO\n");
            }
        }else if (c >= a && c >= b){
            a = a * a + b * b; 
            //printf("%d", a);
            if (c * c == a){
                printf("YES\n");
            }else {
                printf("NO\n");
            }
        }
    }

    return (0);
}



Measured memory_bytes: 2024
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
using P = pair<double,double>;

int N;
double L;
vector<P> V;

bool eval(double u){
    double l=L;
    for(auto v:V){
        l+=v.first*(u-v.second);
        l=min(L,l);
        if(l<=0) return false;
    }
    double l1=l;
    for(auto v:V){
        l+=v.first*(u-v.second);
        l=min(L,l);
        if(l<=0) return false;
    }
    return abs(l1-l)<1e-9;
}

int main(){
    while(cin>>N>>L,N){
        V.clear();
        int s,t=0,u;
        for(int i=0;i<N;i++){
            cin>>s;
            if(s-t) V.emplace_back(s-t,0);
            cin>>t>>u;
            V.emplace_back(t-s,u);
        }
        if(t!=86400)V.emplace_back(86400-t,0);
        double lb=0, ub=1e6;
        for(int i=0;i<50;i++){
            if(eval((lb+ub)/2)){
                ub=(lb+ub)/2;
            }else{
                lb=(lb+ub)/2;
            }
        }
        cout<<fixed;
        cout.precision(6);
        cout<<lb<<endl;        
    }

    return 0;
}

Measured memory_bytes: 5024
#include "bits/stdc++.h"
using namespace std;
 
////////////// Prewritten code follows. Look down for solution. ////////////////

#define fs first
#define sc second
#define pb push_back
#define len(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1e9+7;

/// command for char arrays with spaces -> scanf(" %[^\n]", texto);
 
////////////////////////// Solution starts below. //////////////////////////////

const int N = 1e3+5;

string grid[N];

int main(){

	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		cin >> grid[i];
	}
	vector<vector<ll> > dp(N, vector<ll>(N, 0LL));
	dp[0][0] = 1LL;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			if(i + j == 0) continue;
			if(grid[i][j] == '#') continue;
			else{
				if(i-1 >= 0) dp[i][j] += dp[i-1][j];
				if(j-1 >= 0) dp[i][j] += dp[i][j-1];
				dp[i][j] %= MOD;
			}
		}
	}
	cout << dp[n-1][m-1] << endl;
	
	return 0;
}



Measured memory_bytes: 9216
s = input()
dp = [[0 for j in range(13)] for _ in range(len(s) + 1)]
dp[0][0] = 1
# print(dp)
for i in range(1, len(s) + 1):
    if s[i - 1] == '?':
        for k in range(0, 10):
            for l in range(0, 13):
                dp[i][(l * 10 + k) % 13] += dp[i - 1][l]
    else:
        for l in range(0, 13):
            dp[i][(l * 10 + int(s[i - 1])) % 13] += dp[i - 1][l]
    for l in range(0, 13):
        dp[i][l] = dp[i][l] % (10 ** 9 + 7)
    # print(dp)
print(dp[len(s)][5])

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

int main(void){
    int n, tmp;
    cin >> n;
    set<int> d;
    for(int i=0;i<n;i++){
        cin >> tmp;
        d.insert(tmp);
    }
    cout << d.size() << endl;
    return 0;
}

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

int main(){
	int N; string C; cin>>N>>C;
	int l = 0, r = N-1, c = 0;
	while(l < r){
		if(C[l] != 'W') l++;
		else if(C[r] != 'R') r--;
		else{ l++; r--; c++; }
	}
	cout<< c <<endl;
}


Measured memory_bytes: 3740
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

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

    ll ans = 0;
    ll nxt = 0;
    for(int i=0; i<N; i++){
        ll a; cin >> a;
        ans += (nxt+a)/2;
        
        if(a == 0) nxt = 0;
        else if(nxt == 0 && a%2 == 1) nxt = 1;
        else if(nxt == 1 && a%2 == 0) nxt = 1;
        else nxt = 0;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define F first
#define S second

using namespace std;
const int N = 20 + 5;

int B[N];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n , m , c , ans = 0; cin >> n >> m >> c;
    for (int i=0; i<m; i++)
        cin >> B[i];

    for (int i=0; i<n; i++){
        int tmp = 0;
        for (int j=0; j<m; j++){
            int x; cin >> x;
            tmp += x * B[j];
        }
        if (tmp + c > 0)
            ans++;
    }
    cout << ans;
}


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

typedef long long ll;

using namespace std;
int main(){
    int N;
    cin >> N;
    ll ans = 1;
    for (int i = 1; i <= N; ++i) {
    	ans = ans * i % MOD;
    }
    cout << ans << endl;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = (a); i < int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ull << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())

using namespace std;
using i32 = int;
using i64 = long long;
using f64 = double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf64 = vector<f64>;
using vstr = vector<string>;

template<typename T, typename S> void amax(T &x, S y) { if (x < y) x = y; }
template<typename T, typename S> void amin(T &x, S y) { if (y < x) x = y; }

const int MOD = 1000000007;

struct mint {
  int x;
  mint(): x(0) {}
  mint(int a) { x = a % MOD; if (x < 0) x += MOD; }
  mint &operator+=(mint that) { x = (x + that.x) % MOD; return *this; }
  mint &operator-=(mint that) { x = (x + MOD - that.x) % MOD; return *this; }
  mint &operator*=(mint that) { x = (i64) x * that.x % MOD; return *this; }
  mint &operator/=(mint that) { return *this *= that.inverse(); }
  mint operator-() { return mint(-this->x); }
  friend ostream& operator<<(ostream &out, mint m) { return out << m.x; }
  mint inverse() {
    int a = x, b = MOD, u = 1, v = 0;
    while (b) { int t = a / b; a -= t * b; u -= t * v; swap(a, b); swap(u, v); }
    return mint(u);
  }
  #define op(o, p) mint operator o(mint that) { return mint(*this) p that; }
    op(+, +=) op(-, -=) op(*, *=) op(/, /=)
  #undef op
  #define op(o) bool operator o(mint that) const { return x o that.x; }
    op(==) op(!=) op(<) op(<=) op(>) op(>=)
  #undef op
};

mint sums[410][410];
mint g[410][410];
mint dp[410][410];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  reps(i, 400) sums[0][i] = 1;
  reps(i, 400) rep(j, 400) sums[j + 1][i] = sums[j][i] * i;
  rep(i, 401) rep(j, 400) sums[i][j + 1] += sums[i][j];
  int n, c;
  cin >> n >> c;
  vi32 a(n), b(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];
  rep(i, n) rep(j, 401) g[i][j] = sums[j][b[i]] - sums[j][a[i] - 1];
  dp[0][0] = 1;
  rep(i, n) rep(j, c + 1) rep(k, c + 1) {
    if (j + k > c) continue;
    dp[i + 1][j + k] += dp[i][j] * g[i][k];
  }
  cout << dp[n][c] << endl;
  return 0;
}


Measured memory_bytes: 2176
n,x = gets.strip.split.map(&:to_i)
num = gets.strip.split.map(&:to_i)
#累積和
s = Array.new(num.length+1)
s[0] = 0
0.upto(num.length-1) do |i|
  s[i+1] = s[i] + num[i]
end
puts s.count{|y| y<=x}

Measured memory_bytes: 14432
from collections import defaultdict


def mod_inv(a, m):
    return pow(a, m-2, m)


def combination(a, b):
    if b > a - b:
        return combination(a, a - b)
    ans = fact[a] * ifact[b] * ifact[a-b]
    return ans


MOD = 10**9+7
n, k = map(int, input().split())
k = min(k, n-1)

fact = defaultdict(int)
fact[0] = 1
ifact = defaultdict(int)
ifact[0] = 1
for i in range(1, n+1):
    fact[i] = fact[i-1] * i
    fact[i] %= MOD
    ifact[i] = mod_inv(fact[i], MOD)
    ifact[i] %= MOD

ans = 0
for i in range(k+1):
    ans += combination(n, i) * combination((n-i-1)+i, i)
    ans %= MOD

print(ans % MOD)




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

vector<pair<ll,ll>> prime_factorize(ll n){
    vector<pair<ll,ll>>res;
    for(ll a=2;a*a<=n;a++){
        if(n%a!=0) continue;
        ll ex=0;
        while(n%a==0){
            ex++;
            n/=a;
        }
        res.push_back({a, ex});
    }
    if(n!=1) res.push_back({n, 1});
    return res;
}

int main(){
    ll n;
    cin>>n;
    ll ans=0;
    auto p=prime_factorize(n);

    // for(pair<ll,ll> x : p){
    //     cout<<x.first<<":"<<x.second<<endl;
    // }
    for(int i=0;i<p.size();i++){
        int cnt=1;
        while(p[i].second>=cnt){
            p[i].second-=cnt;
            cnt++;ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3576
import java.util.*;
public class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int a = sc.nextInt();
                int b = sc.nextInt();
                System.out.println(a * b - a - b + 1);
        }
}//0=48
 //a=97 a -> +26 = 123
//鶏になれ

Measured memory_bytes: 35600
#include <iostream>
#include <cstdio>
#include <map>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <list>
#include <stack>
#include <queue>
using namespace std;

typedef list<int> L;
typedef pair <int,int> P;
typedef vector<int> V;
typedef queue<int> Q;
typedef stack<int> S;
typedef map<string,int> M;

int main()
{
    int n;
    while (cin >> n, n) {
        vector<P> v;
        v.push_back(P(1,1));
        int R = 1, L = 1, T = 1, B = 1;
        for (int i = 1; i < n; i++) {
            int t1, t2;
            cin >> t1 >> t2;
            int x = v[t1].first, y = v[t1].second;
            if (t2 == 0) y--;
            else if (t2 == 1) x--;
            else if (t2 == 2) y++;
            else if (t2 == 3) x++;
            v.push_back(P(x, y));
            if (x > T) T = x;
            else if (x < B) B = x;
            else if (y > R) R = y;
            else if (y < L) L = y; 
        }
        cout << (R - L + 1) << " " << (T - B + 1) << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1204
#include <iostream>
#include <vector>
#include <string>
#include <climits>
#include <algorithm>
using namespace std;
string a;
int d,n,mod=1e9+7;

int digitSum(int idx,int sum,bool tight,vector<vector<int> > &dp){
	if(idx==n)
		return sum==0?1:0;
	if(!tight&&dp[n-idx-1][sum]!=-1)
		return dp[n-idx-1][sum];
	int ans =0;
	int k = tight?a[idx]-48:10;
	for(int i=0;i<k;i++)
		ans = (digitSum(idx+1,(sum+i)%d,0,dp)+ans)%mod;
	if(tight){
		ans = (digitSum(idx+1,(sum+k)%d,1,dp)+ans)%mod;
	} else {
		dp[n-idx-1][sum] = ans;
	}
	return ans;
}

int main()
{	
	cin >> a >> d;
	n = a.size();
	vector<vector<int> > dp(n,vector<int>(d,-1));
	cout << (digitSum(0,0,1,dp)-1+mod)%mod;
    return 0;
}

Measured memory_bytes: 8468
program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int64):: n,m
    integer(int64),parameter:: md=10**9+7

    read*, n,m

    if (abs(n-m) >= 2) then
        print'(i0)', 0
    else if (n == m) then
        print'(i0)', mod(fact(n)*fact(n)*2,md)
    else
        print'(i0)', mod(fact(n)*fact(m),md)
    end if

contains
function fact(x) result(ret)
    integer(int64)::x,ret,i

    ret=1
    do i=2,x
        ret=mod(ret*i,md)
    end do
end function
end program name

Measured memory_bytes: 256
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

#define getchar getchar_unlocked
#define putchar putchar_unlocked
int32_t nextint(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); bool s=false; if(c=='-'){s=true;c=getchar_unlocked();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); int s=0; if(c=='-'){s=1;c=getchar_unlocked();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar_unlocked(); while(c==' '||c=='\n') c=getchar_unlocked(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar_unlocked(); } *s='\0'; return len; }

int main(void){
	char s[4]={0,0,0,10};
	read(0, s, 3);
	write(1, s, 4);
}


Measured memory_bytes: 1404
import java.io.*;
import java.util.*;

public class Main {
  private static String solve(String[] st, int[] ab, String u) {
    for (int i = 0; i < 2; i++) {
      if (st[i].equals(u)) {
        ab[i]--;
      }
    }
    return String.format("%d %d", ab[0], ab[1]);
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    String[] st = reader.next(2);
    int[] ab = reader.nextInt(2);
    String u = reader.next();
    out.println(solve(st, ab, u));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


Measured memory_bytes: 21204
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

class Main
{
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(String[] args)
    {
        FastReader sc = new FastReader();
        int ret[] = new int[4];
        Arrays.fill(ret,0);

        int n = sc.nextInt();
        for(int i=0;i<n;i++){
            String c = sc.next();
            int index = 0;
            switch (c) {
                case "AC":
                    index = 0;
                    break;
                case "WA":
                    index = 1;
                    break;
                case "TLE":
                    index = 2;
                    break;
                case "RE":
                    index = 3;
            }
            ret[index]++;
        }
        System.out.println("AC x " + ret[0]);
        System.out.println("WA x " + ret[1]);
        System.out.println("TLE x " + ret[2]);
        System.out.println("RE x " + ret[3]);

    }
}

Measured memory_bytes: 48040
n ,y = map(int,input().split())

for i in range(n+1):
    for j in range(n+1):
        noguti = (y - (i * 10000 + j * 5000)) // 1000
        if noguti + i + j == n and noguti >= 0:
            print(i,j,noguti)
            quit()

print(-1,-1,-1)

Measured memory_bytes: 42140
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define forn for(int i=0;i<n;i++)
#define form for(int j=0;j<m;j++)
#define pb push_back
#define s second
#define f first
int main()
{
   ll n,m;
   cin>>n>>m;
   pair<ll,ll> arr[n];
   forn cin>>arr[i].f>>arr[i].s;
   sort(arr,arr+n);
   ll cost=0;
   forn
   {
     if(m-arr[i].s>=0) {cost+=arr[i].s*arr[i].f; m-=arr[i].s;}
     else {cost+=arr[i].f*m; break;}
   }
   cout<<cost;
   return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#include <numeric>
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

int r[4040], g[4040], b[4040];

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

	int N;
	string S;
	cin >> N >> S;
	map<char, int>mp;
	mp['R'] = 0;
	mp['G'] = 1;
	mp['B'] = 2;
	for (int i = 0; i < N; i++) {
		r[i + 1] = r[i] + (S[i] == 'R');
		g[i + 1] = g[i] + (S[i] == 'G');
		b[i + 1] = b[i] + (S[i] == 'B');
	}


	ll ans = 0;
	for (int i = 0; i < N; i++) {
		for (int j = i+1; j < N; j++) {
			if (S[i] == S[j])continue;
			set<int>st;
			st.insert(mp[S[i]]);
			st.insert(mp[S[j]]);
			int tmp = (2*j-i < N)?mp[S[2*j-i]]:-1;
			if (!st.count(0)) {
				ans += r[N] - r[j + 1];
				if (tmp == 0)ans--;
			}
			else if (!st.count(1)) {
				ans += g[N] - g[j + 1];
				if (tmp == 1)ans--;
			}
			else {
				ans += b[N] - b[j + 1];
				if (tmp == 2)ans--;
			}
		}
	}
	puts(ans);

	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int main(){
  int X,A,B;
  string ans;
  cin>>X>>A>>B;
  if(B<=A) ans="delicious";
  else if(B<=A+X) ans="safe";
  else ans="dangerous";
  cout<<ans<<endl;
  return 0;
}

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

int main() {
  int a,b;
  cin>>a;
  vector<int> vec(a);
  
  for(int i=0;i<a;i++){
  	cin>>vec.at(i);
  }
  b=0;
  for(int i=1;i<a-1;i++){
  	if(vec.at(i-1)<vec.at(i)&&vec.at(i+1)>vec.at(i)){
    b++;
    }
    if(vec.at(i-1)>vec.at(i)&&vec.at(i+1)<vec.at(i)){
    b++;
    }
  }
  
  cout<<b<<endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int ctoi(char c) {return c-'0';}// char to int
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}//MAX
int lcm(ll a,ll b){return a*b/gcd(a,b);}//MIN
 
int  main(){
int n,a,b;
cin >> n >> a >> b;
string s;
cin >> s;
int chea=0,cheb=0,chebb = 0;
for(int i=0;i<n;i++){
    if(s.at(i)=='a'){
        if(a+b>chea+cheb){
            cout <<"Yes"<<endl;
            chea++;
        }
        else{
            cout <<"No"<<endl;
        }
    }
    else if(s.at(i)=='b'){
        if(a+b>chea+cheb&&chebb<b){
            cout <<"Yes"<<endl;
            cheb++;
        }
        else{
            cout <<"No"<<endl;
        }
        chebb++;
    }
    else cout <<"No"<<endl;
}
}
 


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


void solve(long long A, long long B){
    for(int i = 0;i < 1e7;i++){
        int _A = i*8 / 100;
        int _B = i*10 / 100;
        if(_A == A && _B == B){
            cout<<i<<endl;
            return;
        }
    }
    cout<<-1<<endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


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

int main(int argc, char *argv[])
{
    int gyo, retsu, h, w;
    int mas;
    int jokyo1, jokyo2;
    int kyo;
    int nokori;

    scanf("%d", &gyo);
    scanf("%d", &retsu);
    scanf("%d", &h);
    scanf("%d", &w);

    mas = gyo * retsu;
    jokyo1 = h * retsu;
    jokyo2 = w * gyo;
    kyo = h * w;
    nokori=mas-(jokyo1+jokyo2-kyo);
    
    printf("%d\n", nokori);

    return 0;
}

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

signed main() {
  int N;
  cin >> N;

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

  static int dp[101010];
  for (int i = 0; i < 101010; i++) {
    dp[i] = 1e18; // INF
  }

  dp[0] = 0; //初期化
  for (int i = 0; i < N; i++) {
    if (i + 1 < N) {
      dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]));
    }
    if (i + 2 < N) {
      dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]));
    }
  }

  cout << dp[N - 1] << endl;
  return 0;
}

Measured memory_bytes: 1792
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            out.println(n * n * n);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21460