akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static String I = "IMPOSSIBLE";
	public static String B = "Bad";
	public static String G = "Good";
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		long numR = 0;
		long numG = 0;
		long numB = 0;
		long ans = 0;
		for (int i = 0; i < N; i++) {
			char c = S.charAt(i);
			if (c == 'R') {
				numR++;
			} else if (c == 'G') {
				numG++;
			} else {
				numB++;
			}
		}
		// 組み合わせの数を計算
		ans = numR * numG * numB;
		for (int a = 1; a < N; a++) {
			for (int sa = 1; a + sa * 2 <= N; sa++) {
				if (S.charAt(a - 1) != S.charAt(a + sa - 1) && S.charAt(a - 1) != S.charAt(a + sa * 2 - 1)
						&& S.charAt(a + sa - 1) != S.charAt(a + sa * 2 - 1)) {
					ans--;
				}
			}
		}
		System.out.println(ans);
	}

	/*
	 * 以下メソッド集
	 */
	static int ni() {
		return sc.nextInt();
	}

	static long nl() {
		return sc.nextLong();
	}

	static String n() {
		return sc.next();
	}

	static char[] nc() {
		return sc.next().toCharArray();
	}

	static int kaijo(int n) {
		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static int fib(int n) {
		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

	static long gcd(long a, long b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static int gcd(int a, int b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static void out(String info) {
		System.out.println(info);
	}

	static void out(int info) {
		System.out.println(info);
	}

	static void out(double info) {
		System.out.println(info);
	}

	static void out(long info) {
		System.out.println(info);
	}

	static void out(char info) {
		System.out.println(info);
	}

	static void outn(String info) {
		System.out.print(info);
	}

	static void outn(int info) {
		System.out.print(info);
	}

	static void outn(double info) {
		System.out.print(info);
	}

	static void outn(long info) {
		System.out.print(info);
	}

	static void outn(char info) {
		System.out.print(info);
	}

	static int max(int a, int b) {
		return Math.max(a, b);
	}

	static long max(long a, long b) {
		return Math.max(a, b);
	}

	static int min(int a, int b) {
		return Math.min(a, b);
	}

	static long min(long a, long b) {
		return Math.min(a, b);
	}
}


Measured memory_bytes: 36760
#include<stdio.h>
int main(void){
  int FizzBuzz;
  scanf("%d",&FizzBuzz);
  unsigned long sum=0;
  unsigned long i;
  for(i=1;i<=FizzBuzz;i++){
    if(i % 3 == 0 || i % 5 == 0){
      continue;
    }
    sum = sum + i;
  }
  printf("%ld",sum);
  return 0;
}

Measured memory_bytes: 1732
use std::io::prelude::*;
use std::str::FromStr;
pub struct Scanner<R: Read>(R);
impl<R: Read> Scanner<R> {
    pub fn new(reader: R) -> Self {
        Self(reader)
    }
    pub fn read<T: FromStr>(&mut self) -> T {
        let token = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| (b as char).is_whitespace())
            .take_while(|&b| !(b as char).is_whitespace())
            .collect::<Vec<u8>>();
        unsafe { std::str::from_utf8_unchecked(token.as_slice()) }
            .parse()
            .ok()
            .expect("Can't parse it.")
    }
    pub fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
fn main() {
    let (stdin, stdout) = (std::io::stdin(), std::io::stdout());
    let mut sc = Scanner::new(stdin.lock());
    let mut out = std::io::BufWriter::new(stdout.lock());
    solve(&mut sc, &mut out);
    out.flush().ok().unwrap();
}
fn solve(sc: &mut Scanner<std::io::StdinLock>, out: &mut std::io::BufWriter<std::io::StdoutLock>) {
    let N: usize = sc.read();
    let A: Vec<i32> = sc.vec(N);

    use std::collections::HashMap;
    let mut map: HashMap<i32, bool> = HashMap::new();

    for a in A.iter() {
        let _ = map.entry(*a).or_insert(true);
    }
    println!("{}", map.len());
}


Measured memory_bytes: 2184
N, M = map(int, input().split())
r = [0]*(N+1)
for _ in range(M):
    a, b = map(int, input().split())
    r[a-1] += 1
    r[b-1] += 1

for i in range(N-1):
    if r[i]%2==1:
        print("NO")
        break
else:
    print("YES")

Measured memory_bytes: 9492
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int x = sc.nextInt();
        int t = sc.nextInt();

        if (x > t) {
            System.out.println(x - t);
        } else {
            System.out.println(0);
        }
    }
}


Measured memory_bytes: 23124
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  int N, A, B;

  cin >> N >> A >> B;

  cout << min(A * N, B) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
string s;
char c[100];
int main(){
	cin>>s;
	int b='b';
	int d='d';
	int p='p';
	int q='q';
	c[b]='d';
	c[p]='q';
	c[q]='p';
	c[d]='b';
	int l=s.size();
	if(s.size()%2==1){
		cout<<"No"<<endl;
		return 0;
	}
	for(int i=l/2-1;i>=0;i--){
		if(c[s[i]]!=s[l/2+l/2-1-i]){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;
long long C[200000];
const long long MOD = 1000000007;

long long power(long long m, long long n){
    long long res = 1;
    while(n > 0){
        if(n & 1) {
            res = (res * m) % MOD;
        }
        m = (m * m) % MOD;
        n >>= 1;
    }
    return res;
}

long long inverse(long long a){
    return power(a, MOD - 2);
}

int main(void){
  int N;
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> C[i];
  }
  sort(C, C + N);
  long long expectation = 0;
  long long diff_prob = inverse(2);
  long long cumsum_C = 0;
  for(int i = 0; i < N; i++){
    expectation = (expectation + (diff_prob * C[i]) % MOD) % MOD;
    expectation = (expectation + (((diff_prob * diff_prob) % MOD) * cumsum_C) % MOD) % MOD;
    cumsum_C = (cumsum_C + C[i]) % MOD;
  }
  cout << ((expectation * power(2, 2 * N)) % MOD) % MOD << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define pb push_back
#define MOD 1000000007
#define INF 1000000000
#define EPS 0.0000000001
typedef long long ll;

ll n, q;
vector<vector<ll>> edge;
vector<ll> cost(n, 0);
vector<bool> check(n);

void dfs(ll current)
{
    check[current] = true;
    for (ll next : edge[current])
    {
        if (check[next])
        {
            continue;
        }
        cost[next] += cost[current];
        dfs(next);
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    //---------------------------------------------

    cin >> n >> q;
    ll a, b, p, x;
    cost.resize(n);
    edge.resize(n);
    rep(i, n - 1)
    {
        cin >> a >> b;
        a--;
        b--;
        edge[a].pb(b);
        edge[b].pb(a);
    }
    rep(i, q)
    {
        cin >> p >> x;
        cost[p - 1] += x;
    }
    check.resize(n);
    dfs(0); //dfs

    rep(i, n)
    {
        cout << cost[i] << " ";
    }
    cout << endl;
}


Measured memory_bytes: 24320
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
 
using namespace std;
 
typedef long long LL;
 
#define N 1000010
 
struct Data
{
    LL val, idx;
};
 
LL a[N],c[N],q[N];
LL Maxn[N*4];
Data b[N];
int n;
LL ans, d;
 
bool cmp(Data x,Data y)
{
    return (x.val<y.val );
}
 
void update(int o, int l,int r,int x ,LL v)
{
    if (l==x && r==x)
    {
        Maxn[o]=v;
        return;
    }
    int mid=(l+r)>>1;
    if (x<= mid )  update( o*2, l, mid , x, v);
    if (x> mid  )  update( o*2+1, mid+1,r, x, v);
    Maxn[o]=max( Maxn[o*2], Maxn[o*2+1] );
}
 
void query(int o, int l, int r ,int x, int y)
{
    if (x<=l&&r<=y)
    {
        ans=max( Maxn[o], ans);
        return ;
    }
    int mid=(l+r)>>1;
    if (x<= mid )  query( o*2, l, mid , x, y);
    if (y> mid  )  query( o*2+1, mid+1,r, x, y);
}
 
 
int main()
{
    cin>>n>>d;
        memset(Maxn,0,sizeof(Maxn));
        memset(q,0,sizeof(q));
        for (int i=0; i<n; i++)
        {
            cin>>a[i];
            b[i].val=a[i];  b[i].idx=i;
        }
 
        sort(b,b+n,cmp);
 
        for (int i=0; i<n; i++)
        {
            c[i]=b[i].val;
            q[ b[i].idx ]=i;
        }
        LL tot=1;
        for (int i=0; i<n; i++)
        {
            LL l=a[i]-d, r=a[i]+d;
            int ll= lower_bound(c, c+n, l) - c;
            int rr= upper_bound(c, c+n, r) - c - 1 ;
            ans=0;
            query( 1, 0, n-1, ll, rr);
            if (ans==0)
                update(1, 0, n-1, q[i], 1);
            else
            {
                update(1, 0, n-1, q[i], ans+1);
                if (ans+1>tot)  tot=ans+1;
            }
        }
        cout<<tot<<endl;
    return 0;
}

Measured memory_bytes: 52072
#include <stdio.h>
#define N 100


int main(void){

    int n, i, arr[N], temp, j;
    int count = 0;

    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%d", &arr[i]);
    }

    for(i = 1; i < n; i++){
        for (j = (n-1); j > 0; j--) {
            if(arr[j] < arr[j-1]) {
                temp = arr[j];
                arr[j] = arr[j-1];
                arr[j-1] = temp;
                count++;
            }
        }
    }

    for (i = 0; i < n-1; i++) {
        printf("%d ", arr[i]);
    }
    printf("%d\n", arr[n-1]);
    printf("%d\n", count);

    return 0;
}

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

using namespace std;

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

#define INF 1<<30
#define F first
#define S second

int n,m;
int w[105];
int v[105];
int dp[105][100005];
int expensive=0;

int main(){
  scanf("%d %d",&n,&m);
  for(int i=1;i<=n;i++){
    scanf("%d %d",&w[i],&v[i]);
  }

  fill(dp[0],dp[105],INF);
  for(int i=0;i<=n;i++){
    dp[i][0]=0;
  }

  for(int i=1;i<=n;i++){
    for(int j=0;j<=n*1000;j++){
      if(v[i]<=j){
	dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i]]+w[i]);
      }else{
	dp[i][j]=dp[i-1][j];
      }
      if(dp[i][j]<=m) expensive=max(expensive,j);
    }
  }

  printf("%d\n",expensive);
  
  return 0;
}


Measured memory_bytes: 41216
H, W, K = map(int,input().split())
S = [list(input()) for _ in range(H)]
#print(S)
cnt = 1
x = []
for i in range(H):
  if "#" not in S[i]:
    x.append(i)
    if i == H-1:
      for i in range(len(x)):
        print(*ans)
    continue
  j = 0
  std = 0
  ans = []
  while j < W:
    if S[i][j] == "#":
      for k in range(j-std+1):
        ans.append(cnt)
      #print(S[i][j:])
      if j < W - 1 and "#" not in S[i][j+1:]:
        for l in range(W-j-1):
          ans.append(cnt)
      std = j+1
      cnt += 1
    j += 1
  memo = ans
  print(*ans)
  while x:
    print(*ans)
    x.pop()
    

Measured memory_bytes: 4848
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = 1001002003004005006ll;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) {
		cin >> a[i];
		a[i]--;
	}
	int ans = 0;
	rep(i, n) {
		if (a[a[i]] == i) ans++;
	}
	cout << ans / 2 << endl;
	return 0;
}

Measured memory_bytes: 640
"use strict";
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var n = o.l();
  var n = o.l();
  return n[1] === 1 ? 1 : 0;
}

Measured memory_bytes: 22080
#include<bits/stdc++.h>
using namespace std;
int main() 
{
  int seq[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  
  cin>>k;
  cout<<seq[k-1];
  
  
}
  
  
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000];
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);   
    long long n,i,j,k,x,y,z;
    cin>>n;
    z=0;
    for (i=0;i<n;i++)
    {
    	cin>>arr[i];
	}
	sort (arr,arr+n);
	if (n==2)
	{
		cout<<arr[n-1]<<endl;
		return 0;
	}
	z=arr[n-1];
	x=1;
	for (i=(n-2);i>=0;i--)
	{
		z=z+arr[i]*2;
		x+=2;
		if (x==(n-1))
		{
			break;
		}
		if (x>(n-1))
		{
			z-=arr[i];
			break;
		}
	}
	cout<<z<<endl;
}

Measured memory_bytes: 5204
{-# LANGUAGE BangPatterns #-}

import Control.Monad
import Data.List
import Data.Maybe
import qualified Data.ByteString.Char8 as C8

type Pair = (Int, Int)

main :: IO ()
main = do
  [n,m] <- readInts
  ps <- sortOn fst <$> replicateM n readPair
  print $ solve (0,0) m ps


solve :: Pair -> Int -> [Pair] -> Int
solve (!s,_) _ [] = s
solve (!s,!n) m ((a,b):ps)
    | n == m    = s
    | c > m     = s+a*(m-n)
    | otherwise = solve (s+a*b,c) m ps
  where
    c = n+b

-- utils
readInts :: IO [Int]
readInts = map (fst . fromJust . C8.readInt) . C8.words <$> C8.getLine

readPair :: IO Pair
readPair = do
  [x,y] <- readInts
  return (x,y)

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

#define pb push_back
#define ll long long
int mo =  1e9+7;
// int dp[1000][1000];
using namespace std;


int main(int argc, char const *argv[])
{
	// ios::sync_withss_stdio(false);
	// cin.tie(0);
	// cout.tie(0);

	int n, k;
	scanf("%d %d", &n, &k);

	int a[n];
	for (int i = 0; i < n; ++i)
	{
		scanf("%d", &a[i]);
	}

	ll dp[n+1][k+1];

	memset(dp, 0, sizeof(dp));

	dp[0][0] = 1;

	std::vector<ll> sum(k+1);

	for (int i = 1; i <= n; ++i)
	{
		for (int j = 0; j <=k ; ++j)
		{
			sum[j] = j == 0 ? dp[i-1][j] : sum[j-1]+dp[i-1][j];
		}

		for (int j = 0; j <= k; ++j)
		{
			int t = min(j, a[i-1]);
			if(t == j){
				dp[i][j] = sum[j] %mo;
			}
			else{
				dp[i][j] = (sum[j] - sum[j-a[i-1]-1]+mo)%mo;
			}
		}
	}

	printf("%lld\n", dp[n][k]);

}




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

using namespace std;

typedef long long LL;
typedef pair<int,int> pi;
typedef vector<int> vi;
#define ST first
#define ND second
#define PB push_back
#define DET(a,b,c) (LL(b.x-a.x)*LL((c.y-a.y))-LL((c.x-a.x))*LL((b.y-a.y)))

const int MAXN = 100*1000+10;
int n,m,id=1;
vector<int>V[MAXN];
int topo[MAXN];
int dp[MAXN];
bool visited[MAXN];
int ans;

void dfs(int x) {
    visited[x]=1;
    for(auto nbh:V[x]) if(!visited[nbh]) dfs(nbh);
    topo[id++] = x;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n>>m;
    for(int a,b,i=0; i<m;i++) {
        cin>>a>>b;
        V[a].PB(b);
    }
    for(int i=1; i<=n;i++) {
        if(!visited[i]) dfs(i);
    }
    for(int i=n; i>=1;i--) {
        for(auto nbh:V[topo[i]]) {
            dp[nbh] = max(dp[nbh],dp[topo[i]]+1);
            ans=max(ans,dp[nbh]);
        }
    }
    cout<<ans;
}


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

int main() {
    int64_t H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;
    int64_t t1 = H1 * 60 + M1;
    int64_t t2 = H2 * 60 + M2;
    cout << t2 - t1 - K << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
void solve()
{
  ll n,k,q;
  cin>>n>>k>>q;
  ll arr[n]={0};
  
  for(ll i=0;i<n;i++)
  arr[i]=(k-q);
  
  
  for(ll i=0;i<q;i++)
  {
      ll num;
      cin>>num;
      arr[num-1]++;
  }
  
  
  
  for(ll i=0;i<n;i++)
  if(arr[i]>0)
  cout<<"Yes\n";
  else
  cout<<"No\n";
  
  return;
  
}

int main()
{
  solve();
  return 0;
}

Measured memory_bytes: 1408
N = int(input())

if N < 105:
  print(0)
  exit()

n = 107
count = 1
while n <= N:
  yakusu = 0
  for i in range(1, n+1):
    if n % i == 0:
      yakusu += 1
  if yakusu == 8:
    count += 1
  n += 2
print(count)

Measured memory_bytes: 63600
#include <iostream>
#include <numeric>
#include <algorithm>
#include <vector>
using namespace std;

int main()
{
    int N, Pc, Qc;
    cin >> N;
    vector<int> i(N), P(N), Q(N);
    for(int n=0; n<N; n++){
        cin >> P[n];
    }
    for(int n=0; n<N; n++){
        cin >> Q[n];
    }
    iota(i.begin(), i.end(), 1);
    int count = 0;
    do{
        if(i==P){
            Pc = count;
        }
        if(i==Q){
            Qc = count;
        }
        count++;
    }while(next_permutation(i.begin(), i.end()));

    cout << abs(Pc - Qc) << endl;
    
	return 0;
}


Measured memory_bytes: 256
N = int(input())
line = [int(x) for x in input().split(' ')]
count = 1
prev = line[0]
i = 0
while i < len(line):
  if prev == line[i]:
    i += 1
    continue
  elif prev < line[i]:
    for j in range(i,len(line)):
      if line[j] < prev:
        count+=1
        break
      prev = line[j]
    i = j
  elif prev > line[i]:
    for j in range(i,len(line)):
      if line[j] > prev:
        count += 1
        break
      prev = line[j]
    i = j
  prev = line[i]
  i+=1
print(count)


Measured memory_bytes: 14436
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

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

  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;

  int ans = LLINF;
  REP(i, max(x, y)+1) {
    // i*2枚をAB piza
    int tmp = i*c*2;
    if(x > i) tmp += (x-i)*a;
    if(y > i) tmp += (y-i)*b;
    chmin(ans, tmp);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 768
import java.util.*;


public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		
		for(;;){
			int n = scan.nextInt();
			if(n == 0){
				break;
			}
			int[] kou = new int[n];
			for(int i = 0; i < n; i++){
				kou[i] = scan.nextInt();
			}
			int max = Integer.MIN_VALUE;
			int sum = 0;
			for(int i = 0; i < n; i++){
				sum = kou[i];
				max = Math.max(sum, max);
				for(int j = i + 1;j < n; j++){
					sum += kou[j];
					max = Math.max(sum, max);
				}
				sum = 0;
			}
			System.out.printf("%d\n", max);
		}
	}
}

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

using namespace std;

int a[1000];

int main(){
	int b;
	cin >> b;
	for (int i = 0;i < b;i++){
		cin >> a[i];
	}
	int min = 1000, max = -1000;
	for (int i = 0 ;i < b;i++){
		if(a[i] < min){
			min = a[i];
		}
		if(max < a[i]){
			max = a[i];
		}
	}
	cout << max - min;
	return 0;
}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES 
#include <iomanip> 
#include <cmath>  
#include<iostream>
#include <fstream>
#include<vector>
#include<algorithm>
#include<bitset>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl

ll H, W, D, Q, L, R, ans;
struct P {
	ll x, y;
};
map<ll, P> MP;
ll sum[300 * 300 + 10];
bool visited[300 * 300 + 10];

void build() {
	repi(i, 1, H*W + 1) {
		P a, b;
		if (i <= D) {
			sum[i] = 0;
		}
		else {
			P curP = MP[i], tempP = MP[i - D];
			sum[i] = sum[i - D];
			sum[i] += abs(curP.x - tempP.x) + abs(curP.y - tempP.y);
		}
	}

}

int main() {
	cin >> H >> W >> D;
	repi(i, 1, H + 1) {
		repi(j, 1, W + 1) {
			ll A;
			cin >> A;
			P p;
			p.x = i, p.y = j;
			MP[A] = p;
		}
	}
	build();
	cin >> Q;
	repi(i, 0, Q) {
		ans = 0;
		cin >> L >> R;
		wrln(sum[R] - sum[L]);
	}

	return 0;
}

Measured memory_bytes: 7424
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin >> s >> t;
  int ans=t.size();
  for(int i=0;i<=(s.size() - t.size());i++){
    int diff=0;
    for(int j=0;j<t.size();j++){
      if(t[j] != s[i+j]){
        diff++;
      }
    }
    ans = min(ans,diff);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;


struct edge{
  	ll l, r, c;
};

bool comp(const edge& e1, const edge& e2){
  	return e1.l < e2.l;
}

const ll inf = 1e18;

int B = 320;
// バケット i は [i*B, (i+1)*B) の記録を持つ
// lazy[i] :=  バケットi の遅延を記録する
// 遅延が-1 ... 制約よりそんなことは発生しないことを利用して, これを遅延の単位元とできる
// i.e. lazy[i] == -1 def 消化時に何も伝播させないという遅延を与えるとみなす
vector<ll> lazy(B, -1), a(100010, inf);
 
// a_s, ..., a_t を x に変更する
void update(ll s, ll t, ll x)
{
    // s の属するバケット, t の属するバケット
    ll st = s / B, gt = t / B;

    // st や gt に遅延が存在するとき更新前に消化しておく
    // 遅延はパケットごとに考えるから, 遅延が存在⇔パケット内は全て等しい値で更新されている
    // 区間に被覆されるパケットについてはこのあと新しい値へ更新されるので消化しなくてOK
    if (lazy[st] != -1){
        for (ll i = st * B; i < (st + 1) * B; i++) a[i] = min(a[i], lazy[st]);
        lazy[st] = -1;
    }
    if (lazy[gt] != -1){
        for (ll i = gt * B; i < (gt + 1) * B; i++) a[i] = min(a[i], lazy[gt]);
        lazy[gt] = -1;
    }
    //... || ... s ... t ... || ...
    //更新が同一パケット内で済むなら直接更新しても間に合う
    if (st == gt){
        for (ll i = s; i <= t; i++) a[i] = min(a[i], a[s] + x);
    }

    //... s ... || (被覆されるパケット) || ... t ...
    else{
        //端が属するパケット内は直接更新
        for (ll i = s; i < (st + 1) * B; i++) a[i] = min(a[i], a[s] + x);
        for (ll i = gt * B; i <= t; i++) a[i] = min(a[i], a[s] + x);

        //区間に被覆されるパケットについては更新を遅延に残す
        for (ll i = st + 1; i < gt; i++){
            if (lazy[i] == -1) lazy[i] = a[s] + x;
            else lazy[i] = min(lazy[i], a[s] + x);
        }
    }
}
 
// a_i を返す
ll find(ll s){
    ll st = s / B;
    //遅延を処理する
    if (lazy[st] != -1){
        for (ll i = st * B; i < (st + 1) * B; i++) a[i] = min(a[i], lazy[st]);
        lazy[st] = -1;
    }
    return a[s];
}

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

    ll n, m;
    cin >> n >> m;
    ll l, r, c;
    vector<edge> ee;
    REP(i, m) {
        cin >> l >> r >> c;
        l--, r--;
        ee.push_back(edge{l, r, c});
    }
    sort(ee.begin(), ee.end(), comp);
    a[0] = 0;
    REP(i, m) {
        l = ee[i].l, r = ee[i].r, c = ee[i].c;
        // 頂点 0 からの最短距離を update
        update(l, r, c);
    }
    ll res = a[n - 1];
    if (res == inf) res = -1;
    cout << res << endl;
    return 0;
}

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

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

  vector<int> ans;
  for (int i = 0; i < k && i + a <= b; ++i) ans.push_back(i + a);
  for (int i = 0; i < k && b - i >= a; ++i) ans.push_back(b - i);

  sort(ans.begin(), ans.end());
  ans.erase(unique(ans.begin(), ans.end()), ans.end());

  for (auto &i : ans) cout << i << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=50+5;
int n;
double v[maxn];
double ans;
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
	return x*f;
}
int main(){
	n=read();
	for(int i=1;i<=n;i++)
	v[i]=read();
	sort(v+1,v+1+n);
	ans=v[1];
	for(int i=2;i<=n;i++)
	ans=(ans+v[i])/2;
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 256
A=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

a=int(input())

print(A[a-1])

Measured memory_bytes: 38256
#include <bits/stdc++.h>
 
using namespace std;
 
#define int long long 
#define INF 1e9
#define LINF 1e18

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<int, P> Pi;
typedef pair<P, P> PP;
 
const int MOD = 1e9 + 7;
const int dy[] = { 0, 0, 1, -1 };
const int dx[] = { 1, -1, 0, 0 };
 
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int N, d[100000];

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

    cin >> N;
    for(int i = 0; i < N; ++i) cin >> d[i];
    sort(d, d + N);
	cout << d[N / 2] - d[N / 2 - 1] << endl;
    return 0;
}


Measured memory_bytes: 1024
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)
	
	cPrice := 4
	dPrice := 7
	
	cMax := 100 / cPrice
	dMax := 100 / dPrice
	
	judge := "No"
	for c := 0; c <= cMax; c++ {
		for d := 0; d <= dMax; d++ {
			if c * cPrice + d * dPrice == N {
				judge = "Yes"
			}
		}
	}
	fmt.Println(judge)
}

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

int main() {
  int l,r;
  cin>>l>>r;
      if(l - r > 2019){
        cout << 0 << endl;
        return 0;
      }

  int ans=2000000;
  
  
  for(int i=l;i<r;i++){
  	for(int j=i+1;j<=r;j++){
      int ii =i%2019;
      int jj =j%2019;
      ans=min(ans,ii*jj%2019);
      if(ans==0)break;

        }
    if(ans==0)break;
    }
  
  
  cout<<ans%2019<<endl;
  }


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
using namespace std;
 
int main(){
    int n,x,c=0;
    cin>>n>>x;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    sort(ALL(a));
    rep(i,n){
        if (i<n-1) {
            if (x>=a[i]) {
                    x -= a[i];
                    c++;
                }
                else break;
            }
        else if(i==n-1) if (x==a[n-1]) c++;
        }
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define pb push_back

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)
 
// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
 
// two of the same numbers xor is 0 and 0 xor k = k
// so 1...m(except k) k m...1(except k) k
// if you xor all numbers from 1..(2^m)-1 except k you get k because
// that is the only powers of 2 with odd parity only true if k is < (2^m)
// xor(1, 2, ..., 2^M-1) = 0 is only true for M >= 2.

void solve(){
	ll m,k; cin >> m >> k;
	if(k==0){
		FOR(i,pow(2,m)) cout << i << " " << i << " ";
	} else if(m==1){
		cout << -1;
	} else if(pow(2,m) <= k){
		cout << -1;
	} else{
		FOR(i,pow(2,m)){
			if(i==k) continue;
			else cout << i << " ";
		}
		cout << k << " ";
		for(ll i = pow(2,m)-1; i>=0; --i){
			if(i == k) continue;
			else cout << i << " ";
		} 
		cout << k;
	}
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	solve();
	return 0;
}
 


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll N;
string S;
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	if(N==0) return _P("0\n");
	
	ll v=1;
	while(N) {
		if(N%(2*abs(v))) {
			S+='1';
			N-=v;
		}
		else {
			S+='0';
		}
		v*=-2;
	}
	reverse(ALL(S));
	cout<<S<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <fstream>
#include <stdlib.h>
#include <ctime>
typedef long long ll;
typedef long double ld;

using namespace std;
long double pi2=2*acos(-1);
long double pi=acos(-1);
long double ang(pair<ll,ll> a){
    long double  an=acos((long double)a.first/sqrt((long double)a.first*a.first+(long double)a.second*a.second));
    if(a.second < 0) an=pi2-an;
    return an;
}
bool cmp(pair<ll,ll> a,pair<ll,ll> b){
    return ang(a)<ang(b);
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << setprecision(100);
  //  freopen("input.txt","r",stdin);
    ll n;
    cin>>n;

    vector <pair<ll,ll>> a;
    for(ll i=0;i<n;i++){
        pair<ll,ll> aa;
        cin>>aa.first>>aa.second;
        if(aa.first == 0 && aa.second == 0){
        }
        else{
            a.push_back(aa);
        }
    }
    n=a.size();
    sort(a.begin(),a.end(),cmp);
    long double ans=0;
    //cout<<n;
    for(ll i=0;i<n;i++){
        ll x=0;
        ll y=0;
        for(ll j=i;j<i+n;j++){
            x+=a[j%n].first;
            y+=a[j%n].second;
            ld sx=x;
            ld sy=y;
            if(ans<sqrt(sx*sx+sy*sy))ans=sqrt(sx*sx+sy*sy);
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
public static void main(String[] args){
Scanner scan=new Scanner(System.in);
int nn=scan.nextInt();
int kk=scan.nextInt();
  
int na=Math.max(nn,kk);
int nb=Math.min(nn,kk);

int sum=0;
int i=0;
for(i=0;i<na;i++){
  sum=sum+nb*(int)Math.pow(10,i);
}
  
System.out.println(sum);
}
}


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

const int INF = 9999999;

int n, m;
vector<int> issues(100010, INF);

//なるべく東の方の橋を落とす
int main(){
  cin >> n >> m;
  int a, b;
  //ある島と争ってる別の島のうち、最も西のものだけ記録する。
  rep(i, m){
    cin >> a >> b; a--; b--;
    issues.at(a) = min(issues.at(a), b);
  }
  //
  int left = issues.at(0); //次に橋を落とす島
  int cnt = 0;
  for(int i = 1; i < n; i++){
    //橋を落とす場合
    if(i == left){
      cnt++;
      left = issues.at(i);
      continue;
    }
    left = min(left, issues.at(i));
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<iostream>
#include<ctime>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
	int x,y;
	scanf("%d%d",&x,&y);
	printf("%d",x<=y?0:x-y);
	return 0;
}


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

#n = int(input())
#l = list(map(int, input().split()))

'''
a=[]
b=[]
for i in range():
    A, B = map(int, input().split())
    a.append(A)   
    b.append(B)'''
n=int(input())
a=list(map(int, input().split()))

cnt=0
for i in range(1,n):
    if a[i-1]>a[i]:
        cnt+=a[i-1]-a[i]
        a[i]+=a[i-1]-a[i]
    #print(a)
print(cnt)

Measured memory_bytes: 31128
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int a,b,c,d;
cin>>a>>b>>c>>d;
if(d<=a)
cout<<d;
else
{
long long sum(a);
if(d-a<=b)
cout<<sum;
else
cout<<sum+(d-a-b)*(-1);
}
}


Measured memory_bytes: 3628
#include <iostream>
#include <ostream>
#include <vector>

const int index_max_size = 500000;
int       left_tmp[index_max_size / 2 + 2];
int       right_tmp[index_max_size / 2 + 2];
const int SEN = 2000000000;//番兵
int cnt;

void merge_sort(int* data, int n, int left, int right);
void merge(int* data, int n, int left, int mid, int right);

int main(int argc, char const* argv[]) {
  int n;
  int data[index_max_size];
  cnt = 0;

  std::cin >> n;

  for (int i = 0; i < n; i++) { std::cin >> data[i]; }

  merge_sort(&(data[0]),  n, 0, n);

  for (int i = 0; i < n; i++) {
    std::cout << data[i];
    if (i != n - 1) { std::cout << " "; }
  }

  std::cout << std::endl;
  std::cout << cnt << std::endl;

  return 0;
}

void merge_sort(int* data,  int n, int left, int right) {
  if (left + 1 < right) {
    int mid = (left + right) / 2;
    merge_sort(data,  n, left, mid);
    merge_sort(data, n, mid, right);
    merge(data,  n, left, mid, right);
  } 
};

void merge(int* data,  int n, int left, int mid, int right) {
  int       n1 = mid - left;
  int       n2 = right - mid;

  for (int i = 0; i < n1; i++) { left_tmp[i] = data[left + i]; }
  for (int i = 0; i < n2; i++) { right_tmp[i] = data[mid + i]; }

  left_tmp[n1] =  SEN;
  right_tmp[n2] = SEN;

  int i1 = 0;
  int i2 = 0;
  for (int i = left; i < right; i++) {
    cnt++;
    if (left_tmp[i1] <= right_tmp[i2]) {
      data[i] = left_tmp[i1++];
    } else {
      data[i] = right_tmp[i2++];
    }
  }
};



Measured memory_bytes: 6904
#include <bits/stdc++.h>
using namespace std;
string s;
long long y,z;
int main()
{
    /*
    BWBWBW
    WBWBWB 3
    WWBWBB 5
    WWWBBB 6
    */
    cin>>s;
    for (int i=0;i<s.size();i++)
    {
        if (s[i]=='W')
        {
            z+=i;
            z-=y;
            y++;
        }
    }
    cout<<z;
    return 0;
}


Measured memory_bytes: 640
#include <cstdio>

using namespace std;

int main()
{
	int l[10];
	int v1,v2;
	
	while(scanf("%d,",&l[0])!=EOF){
		for(int i=1;i<10;i++){
			scanf("%d,",&l[i]);
		}
		scanf("%d,%d",&v1,&v2);
		double sum=0;
		for(int i=0;i<10;i++){
			sum+=l[i];
		}
		double ld=((double)(sum/(v1+v2)))*(double)v1;
		int result=0;
		for(int i=0;i<10;i++){
			if(ld>l[i]){
				ld-=l[i];
				result++;
			}
			else{
				result++;
				break;
			}
		}
		printf("%d\n",result);
	}
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;
 

ll sum[200010];

ll A(ll x){
    if(x>=0)return x;
    else return -x;
}

int main(void){
    ll n;
    cin>>n;
    vector<ll>a(n);
    for(ll i=0;i<n;i++)cin>>a[i];
    sum[0]=0;
    ll ans = (ll)INF;
    for(ll i=0;i<n;i++)sum[i+1]=sum[i]+a[i];
    for(ll i=1;i<=n-1;i++){
        ll s  =sum[i];
        ll ara =sum[n]-sum[i];
        ans = min(ans,A(s-ara));
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 3328
#include <stdio.h>
#include <string.h>

static char str[100000];

void call(int *n)
{
    int i = 1;
    while ( ++i <= *n ) {
        int x = i;
        char buf[8] = {0};
        if ( x % 3 == 0 ){
            sprintf(buf, " %d", i);
            strcat(str, buf);
        } else {
            while ( x ) {
                if ( x % 10 == 3 ) {
                    sprintf(buf, " %d", i);
                    strcat(str, buf);
                    break;
                }
                x /= 10;
            }
        }
    }
    printf("%s\n", str);
}

int main(void)
{
    int n;
    
    scanf("%d", &n);
    
    call(&n);
    
    return 0;
}


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

int main() {
  int D;
  cin >> D;
  
  if(D==22) {
    cout << "Christmas Eve Eve Eve" << endl;
  } else if(D==23) {
    cout << "Christmas Eve Eve"  << endl;
  } else if(D==24) {
    cout << "Christmas Eve" << endl;
  } else {
    cout << "Christmas" << endl;
  }
  
  return 0;
  
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<ios>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<string>
#include<list>
#include<utility>
#include<tuple>
#include<map>
#include<unordered_map>
#include<complex>
using namespace std;
typedef long long llong;
llong gcd(llong a, llong b) {
	if (a < b) std::swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}
llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}
//ここまで共通
int N;
vector<int>V;
int A[100050] = { 0 }, B[100050] = { 0 };
pair<int, int>A1, A2, B1, B2;
int main(void) {
	cin >> N;
	for (int i = 0; i < N; i++) {
		int v;
		cin >> v;
		V.push_back(v);
	}
	for (int i = 0; i < V.size(); i++) {
		if (i % 2 == 0) {
			A[V[i]]++;
		}
		else {
			B[V[i]]++;
		}
	}

	int maxA = 0;
	for (int i = 0; i <= 100000; i++) {
		maxA = max(maxA, A[i]);
	}
	for (int i = 0; i <= 100000; i++) {
		if (maxA == A[i]) {
			A1.first = maxA;
			A1.second = i;
			break;
		}
	}
	maxA = 0;
	for (int i = 0; i <= 100000; i++) {
		if (i == A1.second) continue;
		maxA = max(maxA, A[i]);
	}
	for (int i = 0; i <= 100000; i++) {
		if (i == A1.second) continue;
		if (maxA == A[i]) {
			A2.first = maxA;
			A2.second = i;
			break;
		}
	}

	int maxB = 0;
	for (int i = 0; i <= 100000; i++) {
		maxB = max(maxB, B[i]);
	}
	for (int i = 0; i <= 100000; i++) {
		if (maxB == B[i]) {
			B1.first = maxB;
			B1.second = i;
			break;
		}
	}
	maxB = 0;
	for (int i = 0; i <= 100000; i++) {
		if (i == B1.second) continue;
		maxB = max(maxB, B[i]);
	}
	for (int i = 0; i <= 100000; i++) {
		if (i == B1.second) continue;
		if (maxB == B[i]) {
			B2.first = maxB;
			B2.second = i;
			break;
		}
	}

	if (A1.second != B1.second) {
		cout << N - A1.first - B1.first << endl;
	}
	else {
		int ans = min(N - A1.first - B2.first, N - A2.first - B1.first);
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1656
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll n,m,q;
Vi a,b,c,d;

ll calc(ll aa,Vi v,ll dep){
    ll ans = 0;
    if(dep==0){
        rep(i,a.size()){
            if(v[b[i]-1]-v[a[i]-1]==c[i]){
                ans += d[i];
            }
        }
        return ans;
    }else{
        repi(i,aa,m+1){
            Vi vv = v;
            vv.pb(i);
            chmax(ans,calc(i,vv,dep-1));
        }
    }
    return ans;
}


int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>n>>m>>q;
    a.resize(q);
    b.resize(q);
    c.resize(q);
    d.resize(q);
    rep(i,q){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
    }
    Vi vv;
    vv.pb(1);
    ll ans = 0;
    ans = calc(1,vv,n);
    print(ans);
    return 0;
}

Measured memory_bytes: 3656
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

const int MAX_N = 100000;
const int INF = TEN(7);
int n, m;
vi g[MAX_N];
int par[MAX_N];
bool vis[MAX_N];
int d[MAX_N];

int main() {
    fastio();

    cin >> n >> m;
    forn(i, m) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    fill_n(d, n, INF);

    queue<pii> q;
    q.emplace(0, 0);
    par[0] = -1;
    vis[0] = true;

    while (!q.empty()) {
        auto [cur, u] = q.front();
        q.pop();

        for (int v : g[u]) {
            if (vis[v]) continue;
            par[v] = u + 1;
            vis[v] = true;
            q.emplace(cur + 1, v);
        }
    }

    cout << "Yes\n";
    forn1(i, n - 1) {
        cout << par[i] << "\n";
    }

    return 0;
}

Measured memory_bytes: 11260
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define M1 					1000000007
#define M2 					998244353
#define ll 					long long int
#define pll 				pair<ll,ll>
#define mll 				map<ll,ll>
#define F 					first
#define S 					second
#define PB 					push_back
#define mp 					make_pair
#define lb 					lower_bound
#define ub 					upper_bound
#define V(a) 				vector<a>
#define endl 				'\n'
#define test(t) 			while(t--)
#define PI 					acos(-1.0)
#define rep(i,a,b) 			for(ll i=a;i<b;i++)
#define repp(i,b,a) 		for(ll i=b-1;i>=a;i--)
#define clr(ar, val)		memset(ar, val, sizeof(ar))
#define setbits(x) 			__builtin_popcountll(x)
#define zrobits(x) 			__builtin_ctzll(x)
#define ps(y) 				fixed << setprecision(y)
#define all(x) 				begin(x),end(x)
#define allr(x) 			rbegin(x),rend(x)
const int inf= 				0x3f3f3f3f;
const ll INF= 				0x3f3f3f3f3f3f3f3f;
const int dx[4]= 			{ 0, -1, 0, 1 };
const int dy[4]= 			{ -1, 0, 1, 0 };

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename T>
#define o_set(T) tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

ll CalculateMex(set<ll> Set){
    ll Mex = 0;
    while(Set.find(Mex)!=Set.end()){
        Mex++;
    }
    return Mex;
}

ll floor_div(ll a, ll b) {
	return a / b - (((a ^ b) < 0) and a % b);
}
ll ceil_div(ll a, ll b){
    return a / b + (((a ^ b) >= 0) and a % b);
}

inline void INP()
{
	#ifndef ONLINE_JUDGE
	    freopen("input.txt","r",stdin);   
	    freopen("output.txt","w",stdout);
	#endif 
}

void solve()
{
    ll n,m;
    cin>>n>>m;
    ll sum = 0;
    rep(i,0,m){
        ll x;
        cin >> x;
        sum += x;
    }
    if (sum > n) cout << -1 << endl;
    else cout << n - sum << endl;

}

int32_t main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    test(t){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3648
while True:
    try:
        d, w, h = list(map(int, input().split()))
        if d == w == h == 0:
            break
        n = int(input())
        r = []
        for i in range(n):
            r = int(input())
            if r ** 2 > (d ** 2 + w ** 2) / 4 \
                or r ** 2 > (d ** 2 + h ** 2) / 4 \
                or r ** 2 > (h ** 2 + w ** 2) / 4 :
                print("OK")
            else:
                print("NA")
    except EOFError:
        break

Measured memory_bytes: 7548