akhauriyash/Code-Regression huggingface dataset:
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.util.InputMismatchException;
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();
            int a = in.nextInt();
            int b = in.nextInt();

            int max = Math.min(a, b);
            int min = Math.max(0, a + b - n);

            out.println(max + " " + min);
        }

    }

    static class InputReader {
        private BufferedReader br;
        private StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
            st = new StringTokenizer("");
        }

        public String nextString() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return st.nextToken();
        }

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

    }
}



Measured memory_bytes: 22868
using System;

public class Program
{
    private int M, D;

    public void Solve()
    {
        var sc = new Scanner();
        M = sc.NextInt();
        D = sc.NextInt();
        int ans = 0;
        for (int m = 1; m <= M; m++)
        {
            for (int d = 0; d <= D; d++)
            {
                int d1 = d % 10;
                int d10 = d / 10;
                if (d1 >= 2 && d10 >= 2 && d1 * d10 == m)
                {
                    ans++;
                }
            }
        }
        Console.WriteLine(ans);
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < int(n); i++)
#define rep1(i,n) for (int i = 1; i <= int(n); i++)
#define repR(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep1R(i,n) for (int i = int(n); i >= 1; i--)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#define cauto const auto
#ifdef LOCAL
#define dump(...) cerr << "[" << __LINE__ << ":" << __FUNCTION__ << "] ", _dmp_(#__VA_ARGS__, __VA_ARGS__);
void _dmp_(const char*) { cerr << endl; }
template <class T, class... U>
void _dmp_(const char *s, T const& x, U const& ...y) { const char *o = "({[", *e = "]})"; for (int i = 0; *s != '\0'; cerr << *s++) { if (count(o,o+3,*s)) i++; if (count(e,e+3,*s)) i--; if (!i && *s == ',') break; } cerr << " = " << x; if (*s == ',') cerr << ", ", s++; _dmp_(s, y...); }
#else
#define dump(...)
#endif
using ll = long long;
#define int ll
template <class T> using pque_max = priority_queue<T>;
template <class T> using pque_min = priority_queue<T, greater<T> >;
#define CONAINER_OUTPUT os << "{"; for (auto const& x : v) os << " " << x; return os << " }";
template <class T> ostream& operator<<(ostream& os, vector<T> const& v) { CONAINER_OUTPUT }
template <class T> ostream& operator<<(ostream& os, deque<T> const& v) { CONAINER_OUTPUT }
template <class T> ostream& operator<<(ostream& os, set<T> const& v) { CONAINER_OUTPUT }
template <class T, class U> ostream& operator<<(ostream& os, map<T,U> const& v) { CONAINER_OUTPUT }
#undef CONAINER_OUTPUT
template <class T> istream& operator>>(istream& is, vector<T>& v) { for (auto& x : v) is >> x; return is; }
template <class T, class S> ostream& operator<<(ostream& os, pair<T,S> const& p) { return os << "(" << p.first << ", " << p.second << ")"; }
template <class T, class S> istream& operator>>(istream& is, pair<T,S> const& p) { return is >> p.first >> p.second; }
struct _Init_ { _Init_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); } } _init_;

template <class T> void quit(T const& x) { cout << x << endl; exit(0); }
template <class T> bool chmin(T& x, T const& y) { if (x > y) { x = y; return true; } return false; }
template <class T> bool chmax(T& x, T const& y) { if (x < y) { x = y; return true; } return false; }
#define YesNo(c) ((c) ? "Yes" : "No")
////////////////////////////////

int32_t main() {
    int x,y; cin >> x >> y;
    cout << (abs(x-y) > 1 ? "Alice" : "Brown") << endl;
}


Measured memory_bytes: 256
A,B,M=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=min(a)+min(b)
for _ in range(M):
    x,y,c=map(int,input().split())
    ans=min(ans,a[x-1] + b[y-1] - c)
print(ans)

Measured memory_bytes: 18736
#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;

int main(){
	string s;
	cin >> s;
	int a = 0;
	int b = 0;
	rep(i,s.size()){
		if(s[i] == '0') a++;
		if(s[i] == '1') b++;
	}
	int ans = 2*min(a,b);
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mod 1000000007
// #define mod 998244353
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s, t;
	cin >> s;
	int n = s.length();
	for (int i = 0; i < n;)
	{
		if (n - i < 5)
		{
			cout << "NO" << endl;
			return 0;
		}
		if (n - i == 5)
		{
			if (s[i] == 'd')
			{
				t += "dream";
			}
			else
			{
				t += "erase";
			}
			break;
		}
		else if (n - i == 6)
		{
			t += "eraser";
			break;
		}
		else if (n - i == 7)
		{
			t += "dreamer";
			break;
		}
		else
		{
			if (s[i] == 'd')
			{
				if (s[i + 5] == 'e' && s[i + 6] == 'r' && s[i + 7] != 'a')
				{
					t += "dreamer";
					i += 7;
				}
				else
				{
					t += "dream";
					i += 5;
				}
			}
			else
			{
				if (s[i + 5] == 'r')
				{
					t += "eraser";
					i += 6;
				}
				else
				{
					t += "erase";
					i += 5;
				}
			}
		}
	}
	// cout << s.length() << endl;
	// cout << t.length() << endl;
	// for (int i = 0; i < n; i++)
	// {
	// 	if (s[i] != t[i])
	// 	{
	// cout << i << endl;
	// 	}
	// }
	if (s == t)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 3776
#include<stdio.h>

int main(){
  int n,i;
  char a[100],b[100];
  scanf("%d",&n);
  scanf("%s",a);
  scanf("%s",b);
  for(i=0;i<n;i++){
    printf("%c",a[i]);
    printf("%c",b[i]);
  }
}

Measured memory_bytes: 128
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto w = readln.chomp;
  auto r = 0;

  for (;;) {
    auto t = readln.chomp;
    if (t == "END_OF_TEXT") break;
    auto ti = t.split;
    r += ti.count!(a => icmp(a, w) == 0);
  }

  writeln(r);
}

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

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

int n, m;
const int maxn = 1e5 + 5;
const int INF = 0x3f3f3f3f;
int x[maxn], y[maxn];

int dis[405][405];
bool vis[405];
vector<pi> G[405];

bool bfs(int st){
    queue<int> q;
    memset(dis[st], INF, sizeof(dis[st]));
    q.push(st);
    while(!q.empty()){
        int p = q.front();q.pop();
        for(auto e : G[p]){
            if(e.se < dis[st][p]){
                int to = e.fi;
                if(dis[st][to] != INF){
                    if(dis[st][to] != e.se){
                        return false;
                    }
                }else{
                    dis[st][to] = e.se;
                    q.push(to);
                }
            }
        }
    }
    return true;
}

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> m;
    for(int i = 1;i <= m;i++){
        cin >> x[i] >> y[i];
        G[x[i]].push_back(mp(y[i], i));
        G[y[i]].push_back(mp(x[i], i));
    }
    for(int i = 1;i <= n;i++){
        if(bfs(i))
            vis[i] = true;
        else
            vis[i] = false;
    }
    int ans = 0;
    for(int i = 1;i <= n;i++){
        if(!vis[i])
            continue;
        for(int j = i + 1;j <= n;j++){
            if(!vis[j])
                continue;
            if(dis[i][j] != INF or dis[j][i] != INF){
                continue;
            }
            bool flag = true;
            for(int k = 1;k <= n;k++){
                if(k == i or k == j)
                    continue;
                if(dis[i][k] != INF and dis[j][k] != INF){
                    if(dis[i][k] != dis[j][k])
                        flag = false;
                }
            }
            ans += flag;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7268
#include <iostream>

using namespace std;

int main(){
	int e;

	while(cin >> e && e>0){
		int m=e;
		for(int z=0; z*z*z<=e ; z++){
			for(int y=0; y*y<=e-z*z*z ; y++){
				int x=e-z*z*z-y*y;
				if(m>x+y+z){
					m=x+y+z;
				}
			}
		}
		cout << m << endl;
	}
	return 0;
}


Measured memory_bytes: 1160
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	log.SetFlags(log.Lshortfile)
	h := nextInt()
	a := nextInt()
	cnt := 0
	for h > 0 {
		h -= a
		cnt++
	}
	fmt.Println(cnt)
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type pair struct {
	a, b int
}

type pairs []pair

func (p pairs) Len() int {
	return len(p)
}
func (p pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
typedef long long ll;
 
int main() {

    int a,p;
    cin >> a >> p;
    
    cout<<(3*a+p)/2<<endl;

 return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	a := make([]int, n)
	var ac, wa int
	for i := 0; i < m; i++ {
		var (
			p int
			s string
		)
		fmt.Scan(&p, &s)
        p--
		if a[p] == -1 {
			continue
		}
		if s == "AC" {
			ac++
			wa += a[p]
			a[p] = -1
		} else {
			a[p]++
		}
	}
	fmt.Printf("%d %d\n", ac, wa)
}


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

typedef long long ll;

ll cost[4], num[4] = {2, 3, 5, 1};
map<ll, ll> dp;

ll dfs(ll sum) {
  // cout << sum << endl;
  if (sum == 0) return 0;
  if (sum == 1) return cost[3];
  if (dp.count(sum)) return dp[sum];
  ll res = 1e18;
  if (sum < res / cost[3]) res = sum * cost[3];
  for (int i = 0; i < 3; i++) {
    ll c1 = 0, c2 = 0;
    ll a = num[i];
    ll t = sum;
    while (t % a != 0) {
      c1 += cost[3];
      t--;
    }
    if (t != 0) {
      c1 += cost[i];
      t /= a;
    }
    c1 += dfs(t);
    t = sum;
    while (t % a != 0) {
      c2 += cost[3];
      t++;
    }
    c2 += cost[i];
    t /= a;
    c2 += dfs(t);
    res = min(res, min(c1, c2));
  }
  dp[sum] = res;
  return res;
}

int main()
{
  int t;
  cin >> t;
  while (t--) {
    dp.clear();
    ll n;
    cin >> n;
    for (int i = 0; i < 4; i++) {
      cin >> cost[i];
    }
    cout << dfs(n) << "\n";
  }
  return 0;
}

Measured memory_bytes: 3936
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

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

typedef pair<int, int> P;
#define mp make_pair
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort((v).begin(), (v).end());					//小さい順
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());		//大きい順
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define F first
#define S second
#define pb push_back
#define mod 1000000007LL
#define INF 12345678901234567

const int maxn = 1e5 + 10;


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

	ll n;
	cin >> n;

	vl a(n * 3);
	rep(i, n * 3) cin >> a[i];

	pair<ll, priority_queue<int, vi, greater<int>>> p;
	pair<ll, priority_queue<int, vi, less<int>>> q;
	p.first = 0;
	q.first = 0;

	vl b(n + 1), c(n + 1);

	rep(i, n)
	{
		p.first += a[i];
		p.second.push(a[i]);
	}

	b[0] = p.first;

	rep(i, n)
	{
		p.first += a[n + i];
		p.second.push(a[n + i]);
		ll x = p.second.top();
		p.second.pop();
		p.first -= x;
		b[i + 1] = p.first;
	}

	rep(i, n)
	{
		q.first += a[2 * n + i];
		q.second.push(a[2 * n + i]);
	}

	c[n] = q.first;

	rep(i, n)
	{
		q.first += a[2 * n - 1 - i];
		q.second.push(a[2 * n - 1 - i]);
		ll x = q.second.top();
		q.second.pop();
		q.first -= x;
		c[n - 1 - i] = q.first;
	}

	ll ans = -INF;
	rep(i, n + 1) chmax(ans, b[i] - c[i]);
	
	Print(ans);
	return 0;
	
}

Measured memory_bytes: 5368
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include<random>
#include<math.h>
#include<limits.h>
#include<iterator>
#include<queue>
#include<functional>
#define rep(i,a) for(int i=0;i<a;i++)
#define nrep(i,a,b) for(int i=a;i<b;i++)
#define mrep(i,a) for(int i=a;i>=0;i--)
#define ll long long
#define vl vector<ll> 
#define vvl vector<vector<ll> > 
#define vb vector<bool> 
#define vvb vector<vector<bool> > 
#define INF 11234567890123456789
using namespace std;

struct Root{
	ll one, two;
};

void dfs(Root cutRoot, ll index, vvl graph, vb &passMap){
	if (passMap[index]) return;
	passMap[index] = true;
	for (ll nextIndex : graph[index]){
		if (cutRoot.one == index && cutRoot.two == nextIndex || cutRoot.one == nextIndex && cutRoot.two == index) continue;
		dfs(cutRoot, nextIndex, graph, passMap);
	}
}

int main(){
	ll n, m; cin >> n >> m;
	vvl graph(n);
	vector<Root> root(m);
	rep(i, m){
		ll a, b; cin >> a >> b;
		graph[a - 1].push_back(b - 1);
		graph[b - 1].push_back(a - 1);
		root[i].one = a - 1;
		root[i].two = b - 1;
	}
	ll ans = 0;
	rep(i, m){
		vb passMap(n, false);
		dfs(root[i], 0, graph, passMap);
		bool isPlus = false;
		rep(i, n) if (!passMap[i]) isPlus = true;
		if(isPlus) ans++;
	}cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
import math

N, D = [int(x) for x in input().split(' ')]
points = []
for i in range(N):
    points.append([int(x) for x in input().split(' ')])

count = 0
for i in range(0, N):
    for j in range(i + 1, N):
        p1 = points[i]
        p2 = points[j]
        distance = 0
        for k in range(D):
            distance += math.pow(p1[k] - p2[k], 2)
        distance = math.sqrt(distance)
        if distance == int(distance):
            count += 1

print(count)

Measured memory_bytes: 3064
n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
ans=0
for i in range(n-1):
    if A[i]+1==A[i+1]:
        ans+=C[A[i]-1]
print(ans+sum(B))
    
    


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for (auto& x : a){
        cin >> x;
    }

    int i = 0; int j = n - 1;

    while (j >= 0){
        cout << a[j];
        if (i != n - 1){
            cout << " ";
        } else{
            cout << endl;
            return 0;
        }
        ++i;
        j -= 2;
    }

    j = (j == -1) ? 0 : 1;

    while (i < n){
        cout << a[j];
        if (i != n - 1){
            cout << " ";
        } else{
            cout << endl;
            return 0;
        }
        ++i;
        j += 2;
    }

    return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
int max(int a,int b,int c=INT_MIN)
{
    return (a>b ? ((a>c)?a:c) : (b>c)?b:c);
}
int main() {
    vector<vector<int> > arr;
    int n,t;
    cin>>n;
    arr.resize(n);
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            cin>>t;
            arr[i].push_back(t);
        }
    }
    vector<vector<int> > ans(n,vector<int> (3,0));
    for(int i=0;i<3;i++)
    ans[0][i]=arr[0][i];
    for(int i=1;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            if(j==0)
                ans[i][j]=arr[i][j]+max(ans[i-1][1],ans[i-1][2]);
            if(j==1)
                ans[i][j]=arr[i][j]+max(ans[i-1][0],ans[i-1][2]);
            if(j==2)
                ans[i][j]=arr[i][j]+max(ans[i-1][0],ans[i-1][1]);
        }
    }
    int m=INT_MIN;
    for(int i=0;i<3;i++)
    {
        if(m<ans[n-1][i])
        m=ans[n-1][i];
    }
    cout<<m;
	return 0;
}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
void fastIO(){
  ios_base::sync_with_stdio(0); cin.tie(0);
}


int main(){
  fastIO();
  int n;
  cin>>n;
  map<int,int>c;
  for(int i=0;i<n;i++){
  	int x;
  	cin>>x;
  	c[x]++;
  }
  int m;
  cin>>m;
  for(int i=0;i<m;i++){
  	int y;
  	cin>>y;
  	if(c[y]==0){
  		cout<<"NO"<<endl;
  		return 0;
  	}else{
  		c[y]--;
  	}
  }
  cout<<"YES"<<endl;
}




Measured memory_bytes: 9600
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vll a(n);
    REP(i,n)cin >> a[i];
    ll ans;
    {
        ll f = 0;
        ll tmp = 0;
        ll sum = 0;
        REP(i,n){
            sum+=a[i];
            if(f==0&&sum<=0){
                ll dif = 1 - sum;
                sum += dif;
                tmp += dif;
            }else if(f==1&&sum>=0){
                ll dif = sum + 1;
                sum -= dif;
                tmp += dif;
            }
            f = 1-f;
        }
        ans = tmp;
    }
    {
        ll f = 1;
        ll tmp = 0;
        ll sum = 0;
        REP(i,n){
            sum+=a[i];
            if(f==0&&sum<=0){
                ll dif = 1 - sum;
                sum += dif;
                tmp += dif;
            }else if(f==1&&sum>=0){
                ll dif = sum + 1;
                sum -= dif;
                tmp += dif;
            }
            f = 1-f;
        }
        ans = min(ans,tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int X,Y;
    cin >> X >> Y;
    if (Y%2!=0){
        cout << "No" << endl;
        return 0;
    }
    int T = (4*X-Y)/2;
    int K = X-T;
    if (((T>0)&&(T<=X)) || ((K>0)&&(K<=X))){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3584
#include <stdio.h>
#include <stdlib.h>
using namespace std;

int n,m,a,b,i,j,k;
int c[505][505];

int main()
{
	scanf("%d%d%d%d",&n,&m,&a,&b);
	if(n%a==0&&m%b==0)
	{
		printf("No\n");
		return 0;
	}
	printf("Yes\n");
	for(i=1;i<=n;++i)
	for(j=1;j<=m;++j)
	c[i][j]=1000000;
	if(n%a)
	{
		for(i=a;i<=n;i+=a)
		for(j=1;j<=m;++j)
		c[i][j]=-(a-1)*1000000-1;
	}
	else
	{
		for(j=b;j<=m;j+=b)
		for(i=1;i<=n;++i)
		c[i][j]=-(b-1)*1000000-1;
	}
	for(i=1;i<=n;++i)
	for(j=1;j<=m;++j)
	{
		printf("%d",c[i][j]);
		if(j==m)printf("\n");
		else printf(" ");
	}
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  int max=a>b&&a>c?a:b>c?b:c;
  int ans=a+b+c-max;
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

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

    static class DMixingExperiment {
        public void solve(int testNumber, Scanner in, PrintWriter out) {

            // A,Bの入る最大量は400g
            final int MAX = 400;
            final int INF = (int) 1e9 + 7;

        /*
        dp[i][j] = タイプAが i [g], タイプBが j [g]のものを作る最小コストを考えればいいことがわかる
         */

            int n = in.nextInt();

            // ma, mbは互いに素であるから大丈夫
            int ma = in.nextInt();
            int mb = in.nextInt();
            int[] a = new int[n];
            int[] b = new int[n];
            int[] c = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
                b[i] = in.nextInt();
                c[i] = in.nextInt();
            }

            int[][][] dp = new int[n + 1][MAX + 1][MAX + 1];

            ArrayUtil.fill(dp, INF);
            dp[0][0][0] = 0;

            for (int prod = 0; prod < n; prod++) {
                for (int i = 0; i <= MAX; i++) {
                    for (int j = 0; j <= MAX; j++) {
                        if (dp[prod][i][j] > 1e9) continue;
                        try {
                            dp[prod + 1][i][j] = Math.min(dp[prod + 1][i][j], dp[prod][i][j]);
                            dp[prod + 1][i + a[prod]][j + b[prod]] =
                                    Math.min(dp[prod + 1][i + a[prod]][j + b[prod]],
                                            dp[prod][i][j] + c[prod]);
                        } catch (ArrayIndexOutOfBoundsException ignored) {
                        }
                    }
                }
            }


            int min = Integer.MAX_VALUE;
            for (int i = 1; Math.max(ma * i, mb * i) <= MAX; i++) {
                min = Math.min(min, dp[n][ma * i][mb * i]);
            }
            out.println(min > 1e9 ? -1 : min);

        }

    }

    static class ArrayUtil {
        public static void fill(int[][][] array, int val) {
            for (int[][] ar : array) for (int[] a : ar) Arrays.fill(a, val);
        }

    }
}



Measured memory_bytes: 52564
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef double db;
#define pb(x) push_back(x)
#define mkp(x,y) make_pair(x,y)
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
//char buf[1<<21],*p1=buf,*p2=buf;
inline int read() {
	int x=0,f=1;char ch=getchar();
	while(!isdigit(ch)) {if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch))x=x*10+(ch^48),ch=getchar();
	return x*f;
}
const int N = 100005;
int n, a[N], p[N], b[N], ans, tr[N<<1];
LL k;
void add(int x, int d) {
	for (int i = x; i <= n * 2 + 1; i += i & -i) tr[i] += d;
}
int ask(int x) {
	int res = 0;
	for (int i = x; i > 0; i -= i & -i) res += tr[i];
	return res;
}
bool check(int mid) {
	memset (tr, 0, sizeof (tr));
	LL res = 0;
	for (int i = 1; i <= n; ++i) p[i] = a[i] >= mid ? 1: -1, p[i] += p[i-1], res += (p[i] >= 0);
	for (int i = 1; i <= n; ++i) p[i] += n + 1;
	for (int i = 1; i <= n; ++i) res += ask(p[i]), add(p[i], 1);
	return res > k / 2 - 1;
}
signed main() {
	n = read(), k = 1ll * n * (n+1) / 2;
	for (int i = 1; i <= n; ++ i) a[i] = b[i] = read();
	sort (b + 1, b + n + 1);
	int l = 1, r = n;
	while (l <= r) {
		int mid = (l + r) >> 1;
		if (check (b[mid])) ans = b[mid], l = mid + 1;
		else r = mid - 1;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 5688
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<vector>
#include<set>
#include<map>
using std::cin;using std::cerr;
using std::max;using std::min;
#define N 200005
#define ll long long
#define db double
#define pb push_back
#define dbg1(x) cerr<<#x<<"="<<(x)<<" "
#define dbg2(x) cerr<<#x<<"="<<(x)<<"\n"
int n,a,b,ecnt,last[N],fa[N],flag,top;ll Max1,Max2,l,r,mid;
struct node
{
	ll x,y;
	friend bool operator<(node t1,node t2) {return t1.x<t2.x||t1.x==t2.x&&t1.y<t2.y;}
}sta[N];
std::vector<node>S[N];
struct road{int to,v,nex;}e[N];
void adde(int u,int v,int w) {e[++ecnt]=(road){v,w,last[u]},last[u]=ecnt;}
void dfs(int x,ll d=0)
{
	if(d>Max1) Max2=Max1,Max1=d;
	else Max2=max(Max2,d);
	for(int k=last[x];k;k=e[k].nex) dfs(e[k].to,d+e[k].v);
}
void Solve(int x)
{
	if(flag) return;
	int to1=0,to2=0;S[x].clear();
	for(int k=last[x];k;k=e[k].nex)
	{
		to1?to2=e[k].to:to1=e[k].to;
		for(int i=0,sz=S[e[k].to].size();i<sz;i++)
			S[e[k].to][i].x+=e[k].v,S[e[k].to][i].y+=e[k].v;
	}
	if(!to1) return void(S[x].pb({0,0}));
	int sz1=S[to1].size(),sz2=S[to2].size();
	if(sz1>sz2) std::swap(to1,to2),std::swap(sz1,sz2);
	for(int i=0,j=0;i<sz1;i++)
	{
		for(;j<sz2&&S[to1][i].x+S[to2][j].y>mid;j++);
		if(j<sz2) sta[++top]={S[to2][j].x,S[to1][i].y};
	}
	for(int i=sz1-1,j=sz2-1;~i;i--)
	{
		for(;~j&&S[to1][i].y+S[to2][j].x>mid;j--);
		if(~j) sta[++top]={S[to1][i].x,S[to2][j].y};
	}
	if(!top) return void(flag=1);
	std::sort(sta+1,sta+1+top);
	node tmp;S[x].pb(tmp=sta[1]);
	for(int i=2;i<=top;i++) if(sta[i].x>tmp.x&&sta[i].y<tmp.y) tmp=sta[i],S[x].pb(tmp);
	top=0;
}
bool Judge()
{
	flag=0;
	for(int i=n;i;i--) Solve(i);
	return !flag;
}
int main()
{
	scanf("%d",&n);
	for(int i=2;i<=n;i++) scanf("%d%d",&a,&b),adde(a,i,b);
	dfs(1);
	for(l=0,r=Max1+Max2;l<r;) mid=l+r>>1,Judge()?r=mid:l=mid+1;
	printf("%lld\n",l);
	return 0;
}

Measured memory_bytes: 33260
import java.util.*;


class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        int N = sc.nextInt(), C = sc.nextInt(), K = sc.nextInt();
                        int[] T = new int[N];
                        for (int i = 0; i < N; i++) {
                                T[i] = sc.nextInt();
                        }
                        Arrays.sort(T);
                        long ans = 0, now = -1000000000, count = 0;
                        for (int i = 0; i < N; i++) {
                                if (now + K < T[i] || count >= C) {
                                        ans++;
                                        count=0;
                                        now=T[i];
                                }
                                count++;
                        }
                        if (count != 0) {
                                ans++;
                        }
                        System.out.println(ans - 1);
                }
        }
}

Measured memory_bytes: 50312
#include<bits/stdc++.h>
#define ll                long long int
#define ld                long double
#define F                 first
#define S                 second
#define C                 continue
#define G                 goto done
#define pb                push_back
#define pf                push_front
#define ppb               pop_back
#define ppf               pop_front
#define sz                size()
#define pi                acos(-1.0)
#define mod               1000000007
#define maxe              *max_element
#define mine              *min_element
#define min3(a,b,c)       min(a,min(b,c))
#define max3(a,b,c)       max(a,max(b,c))
#define min4(a,b,c,d)     min(a,min(b,min(c,d)))
#define max4(a,b,c,d)     max(a,max(b,max(c,d)))
#define mem(a,b)          memset(a,b,sizeof(a))
#define all(a)            (a).begin(),(a).end()
#define gcd(a,b)          __gcd(a,b)
#define lcm(a,b)          ((a)*((b)/gcd(a,b)))
#define case(a)           cout<<"Case "<<(a)<<": "
#define point(a)          fixed<<setprecision(a)
#define get(a)            for(auto &x:a) cin>>x;
#define print(a)          for(auto x:a) cout<<x<<" "; cout<<endl;
#define uniq(a)           sort(all(a)); (a).erase(unique((a).begin(),(a).end()),(a).end())
#define big(a)            transform((a).begin(),(a).end(),(a).begin(),::toupper)
#define small(a)          transform((a).begin(),(a).end(),(a).begin(),::tolower)
#define ischar(a)         (('a'<=a&&a<='z')('A'<=a&&a<='Z'))
#define isvowel(a)        (a=='a'||a=='e'||a=='i'||a=='o'||a=='u'||a=='A'||a=='E'||a=='I'||a=='O'||a=='U')
#define fast              ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define tc                int test; cin>>test; while(test--)
using namespace std;
int main()
{
    ll n; cin>>n; ll a[n]; get(a);
    ll s=0;
    for(ll i=0;i<n;i++)
    {
        s=(s%mod+a[i]%mod)%mod;
    }
    ll ans=0;
    for(ll i=0;i<n-1;i++)
    {
        s=(s-a[i]+mod)%mod;
        ans=(ans%mod + s%mod*a[i]%mod)%mod;
    }
    cout<<ans;
}




















Measured memory_bytes: 5144
from collections import Counter

N, M = map(int, input().split())

l = []

for _ in range(M):
    a, b = input().split()
    l.append(str(a))
    l.append(str(b))

# c = Counter(l)
# c = sorted(dict(c).items(), key=lambda x:x[0])


nums = [str(i) for i in range(1, N + 1, 1)]

for num in nums:
    print(l.count(num))

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define mod ((ll)1e9+7)
#define inf 0x3f3f3f3f
#define infl 0x3f3f3f3f3f3f3f3f
#define Ninf -0x3e3e3e3f
#define Ninfl -0x3e3e3e3e3e3e3e3f
#define maxx ((ll)1e5+5)
#define endl "\n"
#define time(i) cout<<"\nTime Elapsed "<<i<<" : " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
#define usefile freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
ll exp(ll x,ll y,ll p){ ll res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
ll expm(ll x,ll y){ ll res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}
ll add(ll x, ll y) { x += y; if (x >= mod) return x-mod; return x;}
ll sub(ll x, ll y) { x -= y; if (x < 0) return x + mod; return x;}
ll mult(ll x, ll y) { return (x * y) % mod;}
ll rev(ll x) { return expm(x, mod - 2);}
/*
bool sv[maxx]={0};    // returns 0 if a num is prime
int sp[maxx]={0};     // gives smallest prime factor of the number
void Sieve() {for(int i= 2; i< maxx; i+= 2) sv[i]=1,sp[i] = 2;sv[2]=0;for(ll i = 3; i < maxx; i += 2){if (!sv[i]){sp[i] = i;for (ll j = i; (j*i) < maxx; j += 2){if (!sv[j*i])sv[j*i] = true, sp[j*i] = i;}}}}
ll fact[maxx]={0}; // returns factorial of that number
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<maxx;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncrm(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(expm(fact[r],mod-2)))%mod; res=(res*(expm(fact[n-r],mod-2)))%mod; return res;}
ll inv[maxx];   // returns the modular inverse of number
void inversify( ll m){inv[1]=1;for(int i=2;i<maxx;i++){inv[i]= m- m/i*inv[m%i]%m;}}
ll ncr(ll n,ll r,ll m){int ans=1;for (int i = 0; i < r; i++){ans=ans*(n-i)%m*inv[i+1]%m;}return ans;}
*/
signed main(){
  fast;
  //test
  {
    int x;
    cin>>x;
    for(int i=0;i<=1000;i++){
        for(int j=-1000;j<=1000;j++){
            if(pow(i,5)-pow(j,5)==x)
            {
                cout<<i<<" "<<j;
                return 0;
            }
        }
    }
  }
  return 0;
}

Measured memory_bytes: 4088
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int Q = sc.nextInt();
		int[] List = new int[N];
		for(int i=0;i<N;i++){
			List[i]= K-Q;
		}
		for(int i=0;i<Q;i++){
			List[sc.nextInt()-1] += 1;
		}
		for(int i=0;i<N;i++){
			if(List[i]>0){System.out.println("Yes");}
			else{System.out.println("No");}
		}
		sc.close();
	}
		
}



Measured memory_bytes: 57428
#include <cstdio>
#include <algorithm>

#define MAX 200000

int main()
{
	int N, B[MAX], ans=0;
	scanf("%d", &N);
	for(int i=0; i<N-1; i++){
		scanf("%d", &B[i]);
	}
	ans += B[0];
	for(int i=0; i<N-2; i++){
		ans += std::min(B[i], B[i+1]);
	}
	ans += B[N-2];
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
inline ll read(){
    ll x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9'){
        if(c=='-')f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9'){
        x=(x<<3)+(x<<1)+c-'0';
        c=getchar();
    }
    return x*f;
}
ll _gcd(ll a,ll b){
	if(b==0)return a;
	return _gcd(b,a%b);
}
ll a,b,ans;
int main(){
	a=read(),b=read();
	ll d=_gcd(a,b);
	for(ll i=2;i*i<=d;i++){
		if(d%i==0){
			ans++;
			while(d%i==0){
				d/=i;
			}
		}
	}
	if(d>1)ans++;
	printf("%lld\n",ans+1);
	return 0;
}


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

#define next '\n'
#define rep(i, n) for(int (i) = (0); (i) < (n); (i++))
using ll = long long;

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

    string s; cin >> s;
    int ans = 0;

    if(s == "SUN") {
        ans = 7;
    }
    else if(s == "MON") {
        ans =  6;
    }
    else if(s == "TUE") {
        ans =  5;
    }
    else if(s == "WED") {
        ans =  4;
    }
    else if(s == "THU") {
        ans =  3;
    }
    else if(s == "FRI") {
        ans =  2;
    }
    else if(s == "SAT") {
        ans =  1;
    }

    cout << ans << next;
}

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

int main() {
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
  int N;
  cin>>N;
  vector<int> h(N);
  rep(i,N)
    cin>>h[i];
  int answer=0;
  int max=0;
  rep(i,N){
    if(max<h[i])
      max=h[i];
  }
  while(max!=0){
    rep(i,N){
      if(h[i]==max){
        answer++;
        int j=i;
        while(h[i]==max){
          i++;
        }
        for(int k=j;k<i;k++)
          h[k]--;
      }
    }
    max--;
  }
  cout<<answer;
}
   

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define reg register
using namespace std;
const int MN=2e5+5;
typedef __int128 ll;
int n,X;
long long a[MN];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cin>>n>>X;
	for(reg int i=1;i<=n;i++)cin>>a[i],a[i]+=a[i-1];
	ll ans=1e18,s;
	for(reg int i=1,j;i<=n;i++){
		s=2*(a[n]-a[n-i])+1ll*(n+i)*X;
		for(j=1;i*j<=n;j++)
			s+=(ll)(2*j+1)*(a[n-i*j+i]-a[n-i*j]);
		s+=(ll)(2*j+1)*a[n-i*j+i];
		ans=min(ans,s);
	}
	cout<<(long long)ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll n,m;
  cin>>n>>m;
  if(n==1&&m==1) cout<<1<<endl;
  else if(n==1) cout<<m-2<<endl;
  else if(m==1) cout<<n-2<<endl;
  else cout<<(n-2)*(m-2)<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 200010;
const int MAXK = 110;
const int MAXQ = 200010;

int n;

struct Line {
    int x, y;
    Line(int x = 0, int y = 0) : x(x), y(y) {}
};

bool operator< (Line a, Line b) {
    return atan2(a.y, a.x) < atan2(b.y, b.x);
}

Line a[MAXN];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    FOR(i,0,n-1) cin >> a[i].x >> a[i].y;
    sort(a, a+n);
    ld res = 0;
    FOR(i,0,n-1) {
        II now = II(0, 0);
        FOR(j,i,n+i-1) {
            now.FI += a[j % n].x;
            now.SE += a[j % n].y;
            res = max(res, sqrt((ld) now.FI * now.FI + (ld) now.SE * now.SE));
        }
    }
    cout << fixed << setprecision(15) << res;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a, b, c, x, res = 0;
    cin >> a >> b >> c >> x;
    for (int i = 0; i <= a; i++) {
        for (int j = 0; j <= b; j++) {
            int sum = 500 * i + 100 * j;
            if (sum > x) continue;
            if ((x - sum) % 50 != 0) continue;
            if ((x - sum) / 50 <= c) res++;
        }
    }
    cout << res << endl;
}


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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

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

    if((c > a && c < b) || (c > b && c < a))
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}




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

int main(){
 int n,m,c;
 cin >> n >> m >> c;

 int count = 0;
 int B[m];

 for(int i = 0;i < m;++i)
   cin >> B[i];

 int A[n][m];

 for(int j = 0;j < n;++j){
   for(int i = 0;i < m;++i){
     cin >> A[j][i];
   }
 }

 for(int j = 0;j < n;++j){
   int sum = 0;
   for(int i = 0;i < m;++i){
     sum += A[j][i]*B[i];
     }
   if(sum + c > 0) ++count;
 }
  
 cout << count << endl;
}




Measured memory_bytes: 256
import sys
from collections import deque

H, W = map(int, sys.stdin.readline().split())

grid = []
for _ in range(H):
    grid.append(sys.stdin.readline().strip())

black = 0
for i in range(H):
    for j in range(W):
        if grid[i][j] == "#":
            black += 1

q = deque()
q.append((0, 0, 0))
visited = set()
while q:
    x, y, c = q.popleft()
    if x == W-1 and y == H-1:
        break
    if (x, y) in visited:
        continue
    visited.add((x, y))

    for dx, dy in ((1, 0), (-1, 0), (0, 1), (0, -1)):
        nx = x + dx
        ny = y + dy
        if 0 <= nx < W and 0 <= ny < H and grid[ny][nx] != "#":
                q.append((nx, ny, c+1))

if x == W-1 and y == H-1:
    print(H*W - black - c - 1)
else:
    print(-1)

Measured memory_bytes: 9544
input = gets.split(' ').map(&:to_i)
n = input[0]
y = input[1]

def answer(n, y)
  (0..n).each do |i|
    a = i
    (0..(n-i)).each do |j|
      b = j
      c = n - i - j
      if (a * 10 + b * 5 + c * 1) == (y / 1000)
        return "#{a} #{b} #{c}"
      end
    end
  end
  "#{-1} #{-1} #{-1}"
end

puts answer(n, y)


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define N 501
#define M 50001
#define MAX_N N
#define rank Asdfiasofsad
using namespace std;

class UF{
public:
  int par[MAX_N],rank[MAX_N];
  UF(){for(int i=0;i<MAX_N;i++)par[i]=i,rank[i]=0;}
  UF(int n){for(int i=0;i<n;i++)par[i]=i,rank[i]=0;}
  
  int find(int x){
    if(par[x]==x)return x;
    return par[x]=find(par[x]);
  }
  
  void unite(int x,int y){
    x=find(x), y=find(y);
    if(x==y)return;
    if(rank[x]<rank[y])par[x]=y;
    else{
      par[y]=x;
      if(rank[x]==rank[y])rank[x]++;
    }
  }

  bool same(int x,int y){return find(x)==find(y);}
};

typedef pair<int,int> P;
typedef pair<int,P> PP;
vector<PP> edge;
int n,m;

int kruskal(int used[M]){
  UF U;
  int res=0;
  for(int i=0;i<m;i++){
    int a=edge[i].second.first;
    int b=edge[i].second.second;
    int c=edge[i].first;
    if(U.same(a,b)||used[i])continue;
    used[i]=1;
    U.unite(a,b);
    res+=c;
  }
  for(int i=0;i<n;i++)if(!U.same(0,i))return -1;
  return res;
}

int main(){
  cin>>n>>m;
  int sum=0;
  for(int i=0,a,b,c;i<m;i++){
    cin>>a>>b>>c;
    edge.push_back(PP(c,P(a-1,b-1)));
    sum+=c;
  }

  sort(edge.begin(),edge.end());
  int used[M]={},cnt=m,mncost=kruskal(used);
  for(int i=0;i<m;i++){
    int used2[M]={};
    used2[i]=1;
    if(!used[i]||kruskal(used2)==mncost)cnt--,sum-=edge[i].first;
  }
  cout<<cnt<<" "<<sum<<endl;
  return 0;
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define all(x) begin(x), end(x)
typedef long long ll;
typedef pair<int, int> pii;
const int inf=1010001000;
const ll  INF=1001000100010001000;
const int mod=(int)1e9+7;

int main(){
    int x,y;
    cin>>x>>y;
    bool ch = false;
    rep(i,0,x+1){
        if(i*2+(x-i)*4==y){
            ch=true;
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    if(!ch)cout<<"No"<<endl;
return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <functional>
#include <cmath>
#define REP(i,n) for(lint i{}, i##_len=(n); i<i##_len; ++i)
#define DOUBLE_LOOP(i, h, j, w) for(lint i{}; i < (lint)(h); ++i)for(lint j{}; j < (lint)(w); ++j)
#define DOUBLE_LOOP2(i, j, n) for(lint i{}; i < (lint)(n - 1); ++i)for(lint j{i + 1}; j < (lint)(n); ++j)
#define SZ(x) ((lint)(x).size())
using lint = long long; lint N, M, H, W;
using namespace std;
const long long INF{ 1LL << 60 };
const long double PI{ 3.1415926535897932 };
const long long NUM97{ 1000000007 };
template<class T> inline bool chmax(T& x, T y) { if (x < y) { x = y; return 1; } return 0; }
template<class T> inline bool chmin(T& x, T y) { if (x > y) { x = y; return 1; } return 0; }
std::vector<std::string> field;
std::vector<std::vector<bool>> seen(H, std::vector<bool>(W));
const std::vector<int> dx { 1, 0, -1, 0 };
const std::vector<int> dy { 0, 1, 0, -1 };
lint DP_1_Memoization(lint i, std::vector<lint> dp, std::vector<lint> h) {
	if (dp[i] < INF) { return dp[i]; } if (i == 0) { return 0; }
	lint ans{ INF }; chmin(ans, DP_1_Memoization(i - 1, dp, h) + std::abs(h[i] - h[i - 1]));
	if (i > 1) { chmin(ans, DP_1_Memoization(i - 2, dp, h) + std::abs(h[i] - h[i - 2])); }
	return dp[i] = ans;} // memoization
void DP_1(){lint n;  std::cin >> n;
	std::vector<lint> dp; dp.resize(N);  for (auto& r : dp) r = INF;
	std::vector<lint> h; h.resize(n); for (auto& r : h) std::cin >> r;
	dp[0] = 0; for (int i = 1; i < N; ++i) {
		chmin(dp[i], dp[i - 1] + std::abs(h[i] - h[i - 1]));
		if (i > 1) { chmin(dp[i], dp[i - 2] + std::abs(h[i] - h[i - 2])); }}
	std::cout << dp[N - 1] << DP_1_Memoization(N - 1, dp, h) << std::endl;}

int main() { lint N, M; std::cin >> N >> M;
	std::vector<bool> issafe(N + 1, true);
	std::vector<lint> dp(N + 1, 0);
	for (int i = 0; i < M; ++i) { int a; cin >> a; issafe[a] = false; }
	dp[0] = 1; if (issafe[1] == true) dp[1] = 1;
	for (int i = 2; i <= N; ++i) {
		if (issafe[i - 1]) dp[i] += dp[i - 1];
		if (issafe[i - 2]) dp[i] += dp[i - 2];
		dp[i] %= NUM97; // 1000000007 で割る
	}
	std::cout << dp[N] << std::endl;
	return 0;
}

Measured memory_bytes: 4000