akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;

long long dp[105][100005],valor[105],peso[105],n;

long long rec (long long item, long long aguenta){
    if(dp[item][aguenta]>-1) return dp[item][aguenta];
    if(aguenta<0) return 0;
    if(item>=n) return 0;
    if(aguenta-peso[item]>=0) return dp[item][aguenta]=max(valor[item]+rec(item+1,aguenta-peso[item]),rec(item+1,aguenta));
    return dp[item][aguenta]=rec(item+1,aguenta);
}
 
int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    long long m,p=0,i,j;
    cin>>n>>m;
    memset(dp,-1,sizeof(dp));
    for(i=0;i<n;i++){
        cin>>peso[i]>>valor[i];
    }
    cout<<rec(0,m)<<endl;
}

Measured memory_bytes: 85628
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<cassert>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<bitset>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
ll fact(ll x, ll k, ll p) {//最大値、個数、あまり
	ll sum = 1;
	for (int i = 0; i < k; i++) {
		sum *= (x--);
		sum %= p;
	}
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
short ctos(char a) {
	return (int)(a - '0');
}
#define int long long
const long long Inf = 4523372036854775807;
const int inf = 15000000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	int n;
	int a[100];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int ans = 0;
	for (int i = 0; i < n;) {
		int j = i;
		while (j < n&&a[i] == a[j]) {
			j++;
		}
		ans += floor((j - i) / 2.0);
		i = j;
	}
	cout << ans << endl;
}

Measured memory_bytes: 764
using System;

class Program
{
    static void Main(string[] args)
    {
        var nmc = Console.ReadLine().Split();
        var n = int.Parse(nmc[0]);
        var m = int.Parse(nmc[1]);
        var c = int.Parse(nmc[2]);

        var B = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var A = new int[n][];
        for (int i = 0; i < n; i++)
        {
            A[i] = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        }

        var ans = 0;
        for (int i = 0; i < n; i++)
        {
            var x = c;
            for (int j = 0; j < m; j++)
            {
                x += A[i][j] * B[j];
            }
            if (0 < x) ans++;
        }

        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13268
#include<iostream>
using namespace std;
#include<iomanip>
#include<map>
#define mod 998244353
#define int long long int
int memo[3005][3005];
int function(int arr[],int initial,int final,int s,int sum)
{
	if(sum==s)
	{
		return final-initial+2;
	}
    if(sum>s)
       return 0;
	if(initial>final)
	{
		   return 0;
	}
	if(memo[initial][sum]!=-1)
	    return memo[initial][sum];
	else
	{
		int x=function(arr,initial+1,final,s,sum+arr[initial]);
		int y=function(arr,initial+1,final,s,sum);
		memo[initial][sum]=(x+y)%mod;
		return memo[initial][sum];
	}
}
int32_t main()
{
	 ios_base::sync_with_stdio(false);
	 cin.tie(NULL);
	 cout.tie(NULL);
     int i,j;
     int n;
     cin>>n;
     int s;
     cin>>s;
     int arr[n];
     for(j=0;j<n;j++)
         cin>>arr[j];
     for(i=0;i<=3004;i++)
     {
		 for(j=0;j<=3004;j++)
		 {
			 memo[i][j]=-1;
		 }
	 }
	 int answer=0;
	 for(j=0;j<n;j++)
	 {
		 answer=answer+function(arr,j,n-1,s,0);
		 answer=answer%mod;
	 }
	 cout<<answer<<endl;
}


Measured memory_bytes: 71040
n, m = [int(item) for item in input().split()]
ks = [[int(item) for item in input().split()][1:] for _ in range(m)]
p = [int(item) for item in input().split()]

light_num = [0] * (m+1)
for i in range(2**n):
    light = 0
    for j in range(m):
        val = 0
        for k in ks[j]:
            if i & 1 << (k-1):
                val += 1
        if val % 2 == p[j]:
            light += 1
    light_num[light] += 1
print(light_num[m])

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#define INF 1e9
using namespace std;

int dp[100005];

int main(){
    int n,k; cin>>n>>k;
    vector<int> h(n);
    for(int i=0;i<n;i++){
        cin>>h[i];
        dp[i+1]=INF;
    }
    dp[1]=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=k&&i-j>0;j++){
            dp[i]=min(dp[i-j]+abs(h[i-j-1]-h[i-1]),dp[i]);
        }
    }
    cout<<dp[n]<<endl;
}

Measured memory_bytes: 1024
"use strict";

const main = arg => {
    const N = parseInt(arg.split("\n")[0].split(" ")[0]);
    let   X = arg.split("\n")[0].split(" ")[1];
    const m = arg.split("\n").slice(1, N + 1).map(n=>parseInt(n));
    
    X = (X - m.reduce((m,n)=>m+n));
    
    console.log(Math.floor(X / Math.min(...m)) + N);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
use std::io::*;
use std::str::FromStr;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::HashSet;
use std::cmp;
use std::f64::consts;

fn main() {
    let n: i32 = read();
    let vec: Vec<i32> = (0..n).map(|_| read()).collect();
    let ans: i32 = vec.iter().fold(0, |a, b| a + b - 1);
    println!("{}", ans);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// 最大公約数
fn gcd(a: i32, b: i32) -> i32 {
    match b {
        0 => a,
        _ => gcd(b, a % b)
    }
}

// 最小公倍数
fn lcm(a: i32, b: i32) -> i32 {
    a * b / gcd(a, b)
}

// 階乗
fn kaijou(n: i32)->i32 {
    if n == 1 {
        return n;
    }
    return n * kaijou(n-1);
}

Measured memory_bytes: 4352
N = int(input())
prev_word = input()
count = {prev_word:1}
for i in range(1,N):
    cur_word = input()
    if cur_word in count:
        print("No")
        exit()
    count[cur_word] = 1
    if cur_word[0] == prev_word[-1]:
        prev_word = cur_word
        continue
    print("No")
    exit()
print("Yes")

Measured memory_bytes: 3064
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, isize1) => {
        read_value!($next, isize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      h: isize,
      w: isize,
      n: usize,
      sr: isize1,
      sc: isize1,
      ss: chars,
      ts: chars,
    }

    let mut left = 0;
    let mut right = w-1;
    let mut top = 0;
    let mut buttom = h-1;

    for i in (0..n).rev() {
        let s = ss[i];
        let t = ts[i];

        if i != n-1 {
            match t {
                'U' => buttom = min(buttom+1, h-1),
                'D' => top = max(top-1, 0),
                'R' => left = max(left-1, 0),
                'L' => right = min(right+1, w-1),
                _ => unreachable!()
            }
        }

        match s {
            'U' => top = top+1,
            'D' => buttom = buttom-1,
            'R' => right = right-1,
            'L' => left = left+1,
            _ => unreachable!()
        }

        if top >= h || buttom < 0 || left >= w || right < 0 {
            return println!("{}", "NO");
        }
        if top > buttom || left > right {
            return println!("{}", "NO");
        }
    }

    if sr >= top && sr <= buttom && sc >= left && sc <= right {
        println!("{}", "YES")
    } else {
        println!("{}", "NO")
    }
}


Measured memory_bytes: 6396
#include<iostream>
#include<vector>
#include<queue>
#include<cstdlib>
#include<string>
#include <sstream>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int k;
  cin >> k;
  vector<ll> a;
  for (int i = 1;i <= 9; i++) a.push_back(i);
  while (1) {
    if (k <= a.size()) {
      cout << a[k-1] << endl;
      return 0;
    }
    k -= a.size();
    vector<ll> old;
    swap(old,a);
    for (ll x : old) {
      for ( int i = -1; i<=1; i++) {
        int d = x%10 + i;
        if (d < 0 || d > 9) continue;
        ll nx = x*10 + d;
        a.push_back(nx);
      }
    }
  }

  return 0;
} 


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

int main()
{
    int N,A,B;
    cin >> N >> A >> B;
    int Y=0;
    for(int i=1;i<=N;i++){
      int X=0,Z=i;
      for(int j=0;j<5;j++){
        X+=Z%10;
        Z/=10;
        }
    if(X>=A && X<=B){
        Y+=i;
        }
    }
    cout << Y << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
typedef long long ll;
using namespace std;
int main(){
    ll a, b, k;
    cin >> a >> b >> k;
    if(a > k){
        a -= k;
    }else{
        k -= a;
        a = 0;
        
        if(b > k){
            b-= k;
        }else{
            b = 0;
        }
    }
    cout << a << " " << b << endl;
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    int p[n];
    int index[n+1];
    index[0] = 0;
    for(int i=0; i<n; i++){
        cin >> p[i];
        index[p[i]] = i+1;
    }
    int t = 0;
    int cnt = 0;
    for(int i=1; i<=n; i++){
        if(index[i] > index[i-1]){
            cnt++;
        }
        else{
            t = max(t,cnt);
            cnt = 1;
        }
    }
    t = max(t,cnt);
    cout << n-t << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>

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

    if (N < 1000) {
        std::cout << "ABC" << std::endl;
    }
    else {
        std::cout << "ABD" << std::endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <random>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
#define mod 1e18 + 7;

int main()
{
	ios_base::sync_with_stdio(false); 
	cin.tie(nullptr); 
	cout.tie(nullptr); 
	cout.setf(ios::fixed); 
	cout.precision(20);

	ll n;
	string s;
	cin >> n >> s;
	ll x = 0;
	REP(i, 1, n-1) {
		ll nx = 0;
		sort(s.begin(), s.begin() + i);
		rep(j, i) {
			bool x = false;
			REP(k, i, n) {
				if (s[j] == s[k]) x = true;
			}
			if (x && j == 0) nx++;
			else if (x && s[j] != s[j - 1]) {
				nx++;
			}
		}
		x = max(x, nx);
	}
	cout << x << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <iostream>
#include <vector>
#include <map>
using namespace std;

int main() {
	int num;
	std::cin >> num;
	int count = 0;
	map<string,int> keihinn;

	for (int i = 0;i < num;i++) {
		string tmp;
		std::cin >> tmp;
		if (keihinn.find(tmp) != keihinn.end())keihinn[tmp] = 1;
		else keihinn[tmp]++;
	}
	cout << keihinn.size() << endl;

	return 0;
}

Measured memory_bytes: 19064
import java.io.*;
public class Main {
 static int h[];
 public static void main(String[] args) {   
   h = new int[1000];
   //for(int i=0;i<1000;i++)h[i]=100;
   BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
   try{
    while(true){
     String str[]=br.readLine().split(" ");
     int w=Integer.parseInt(str[0]);
     int q=Integer.parseInt(str[1]);
     if(w+q==0)break;
     for(int i=0;i<w;i++)h[i]=-1;
     for(int i=0;i<q;i++){
      str=br.readLine().split(" ");
      char ch=str[0].charAt(0);
      if(ch=='s'){
       int id=Integer.parseInt(str[1]);
       int cw=Integer.parseInt(str[2]);
       sleep(id,cw,w);
      }
      else{
       int id=Integer.parseInt(str[1]);
       wake(id,w);
      }
     }
    System.out.println("END");
    }
   }
   catch(Exception e){
System.out.println("err");
   }
 }

 public static void sleep(int id, int cw , int w){
  int s=0, b=0,f=0;
  for(int i=0;i<w;i++){
   if(f==1)break;
   if(h[i]==-1){
    b=i;
    for(int j=i;j<i+cw;j++){
     if(h[j]!=-1 || f==1){s=0;b=0;break;} 
     s++;
     if(s==cw){
      for(int k=b;k<b+cw;k++)h[k]=id;
      System.out.println(b);
      f=1;
     }
    }
   }
  }
  if(f==0)System.out.println("impossible");
 }

 public static void wake(int id, int w){
  for(int i=0;i<w;i++)
    if(h[i]==id)h[i]=-1;
 }
}
 


Measured memory_bytes: 24328
/********************************************************
  **░██████╗██╗░░░░░░█████╗░██╗░░░██╗██╗░█████╗░░██████╗░**
  **██╔════╝██║░░░░░██╔══██╗██║░░░██║██║██╔══██╗██╔════╝░**
  **╚█████╗░██║░░░░░███████║╚██╗░██╔╝██║██║░░╚═╝██║░░██╗░**
  **░╚═══██╗██║░░░░░██╔══██║░╚████╔╝░██║██║░░██╗██║░░╚██╗**
  **██████╔╝███████╗██║░░██║░░╚██╔╝░░██║╚█████╔╝╚██████╔╝**
  **╚═════╝░╚══════╝╚═╝░░╚═╝░░░╚═╝░░░╚═╝░╚════╝░░╚═════╝░**
  *********************************************************/

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


#define ll                          long long
#define ld                          long double

#define forn(i,n)                   for(int i=0;i<n;++i)
#define all(v)                      v.begin(), v.end()
#define rall(v)                     v.rbegin(),v.rend();
#define isSubstring(s1,s2)          s1.find(s2) != std::string::npos
	
#define pb                          push_back
#define pf                          push_front
#define mp                          make_pair
#define fr                          first
#define sc                          second

#define vpi                         vector<pair<int,int>>
#define vi                          vector<int>
#define sz(a)                       (int)a.size()

#define   endl                       "\n"
#define     nl                       cout<<"\n";
#define fastio                       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define MN                           INT_MIN
#define MX                           INT_MAX

bool isPrime(ll n){if(n<2)return false;for(ll x = 2;x*x <=n;x++){if(n%x == 0)return false;}return true;}
bool isPerfectSquare(long double x){long double sr=sqrt(x);return((sr-floor(sr))==0);}
int gcd(int a, int b){if(a==0)return b;if(b==0) return a;if(a==b)return a;if(a>b)return gcd(a-b,b);return gcd(a,b-a);}

int32_t main()
{
	int n;
	cin >> n;
	string s[n+1];
	int p[n+1];
	vector<pair<pair<string,int>, int>> v;
	for(int i = 1;i<=n;i++){
		cin >> s[i] >> p[i];
		v.pb(mp(mp(s[i],-p[i]),i));
	}
	sort(all(v));
	for(auto x: v)
		cout << x.second << endl;
}
	

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define Rep(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(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());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    ll int k;
    cin >> n >> k;
    P a[n];
    rep(i, n) cin >> a[i].first >> a[i].second;
    sort(a, a + n);
    //reverse(a, a + n);
    //rep(i, n) cout << a[i].first << " " <<a[i].second << endl;
    int g = 0;
    while(k != 0){
        if(k > a[g].second) {
            k -= a[g].second;
            g ++;
        }
        else k = 0;

    }
    //cout << g << endl;
    cout << a[g].first << endl;



}

Measured memory_bytes: 1024
<?php
$n = trim(fgets(STDIN));
$p = explode(" ", trim(fgets(STDIN)));
$count = 0;

for ($i = 0; $i < $n - 2; $i++) {
  $three  = array($p[$i], $p[$i+1], $p[$i+2]);
  if (!isUniqueArray($three)) continue;
  $_three = $three;
  sort($_three);
  if ($three[1] == $_three[1]) $count++;
}
echo $count,PHP_EOL;

// 配列内の全ての値が一意かチェックする
function isUniqueArray ($target_array) {
  $unique_array = array_unique($target_array);
  if (count($unique_array) === count($target_array)) {
    return true;
  }
  else {
    return false;
  }
}

Measured memory_bytes: 4728
#include<stdio.h>
int main(void){
	int n,m,i,j;
	int a[100][100]={0};
	int b[100]={0};
	int c=0;
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			scanf("%d",&a[i][j]);
		}
	}
	for(i=0;i<m;i++){
		scanf("%d",&b[i]);
	}
	for(i=0;i<n;i++){
		c=0;
		for(j=0;j<m;j++){
			c+=a[i][j]*b[j];
		}
		printf("%d\n",c);
	}
	return 0;
}

Measured memory_bytes: 2724
//
// Created by yamunaku on 2020/01/26.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main(){
    // CFS;
    int h,n;
    cin >> h >> n;
    int x;
    rep(i,n){
        cin >> x;
        h-=x;
    }
    if(h<=0) CYES;
    else CNO;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int sum[35][100009];
vector<int> s(100009),t(100009),c(100009);

int main() {
  int N,C;
  cin >> N >> C;
  for(int i=0;i<N;i++)cin >> s[i] >> t[i] >> c[i];
  for(int i=0;i<N;i++){
    for(int j=s[i];j<=t[i];j++){sum[c[i]][j]++;}
  }
  for(int i=1;i<=C;i++){
    for(int j=0;j<=100000;j++){if(sum[i][j])sum[i][j]=1;}
  }
  int ans=0;
  for(int j=0;j<=100000;j++){
    int cnt=0;
    for(int i=1;i<=C;i++){cnt+=sum[i][j];}
    ans=max(ans,cnt);
  }
  cout << ans << endl;
}

Measured memory_bytes: 13312
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "
#define fi first
#define se second

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  ll b=mod, u=1, v=0;
  while(b){
    ll t=a/b;
    a-=t*b; swap(a, b);
    u-=t*v; swap(u, v);
  }
  u%=mod;
  if(u<0)u+=mod;
  return u;
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll n, h, w;
  cin >> n >> h >> w;
  cout << max(n-h+1, 0LL) * max(n-w+1, 0LL)<<endl;
  return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
int main(int argc, char const *argv[])
{
    int n;
    int l;
    cin >> n >> l;
    vector<int> a(n, 0), b(n + 1, 0);
    b[0] = 0;
    a[0] = l;
    rep(i, n)
    {
        a[i] = l + i;
        b[i + 1] = b[i] + a[i];
    }
    int ans = -1;
    int best = (1 << 30);
    rep(i, n)
    {
        if (abs(a[i]) < best)
        {
            ans = i;
            best = abs(a[i]);
        }
    }
    cout << b[n] - a[ans] << endl;
    return 0;
}


Measured memory_bytes: 256
(N,P) = map(int, raw_input().split())
A = map(int, raw_input().split())
n_even = 0
m_odd = 0
for i in range(N):
	if A[i] % 2==0:
		n_even += 1
	else:
		m_odd += 1
N = 2**n_even
def calC(a,b):
	l1 = 1
	l2 = 1
	l3 = 1
	for i in range(a):
		l1 *= (i+1)
	for i in range(b):
		l2 *= (i+1)
	for i in range(a-b):
		l3 *= (i+1)
	return l1/l2/l3
M = 0
i = 0	
while i*2+P <= m_odd:
	M += calC(m_odd, i*2+P)
	i += 1

print N*M

Measured memory_bytes: 2696
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;
 
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int listnum(vector<int> list)
{
    int num = 0;
    int digit = 1;
    REPR(i,list.size()-1){
        num += digit * list[i];
        digit *= 10;
    }
    return num;
}

int main(void)
{
    int n;
    cin >> n;
    vector<int> p(n);
    vector<int> q(n);
    vector<int> jun(n);
    vector<int> junnum;

    iota(all(jun), 1);
    do{
        int digit = 1;
        junnum.push_back(0);
        for (int i = n - 1; i >= 0; i--)
        {
            junnum[junnum.size() - 1] += digit * jun[i];
            digit *= 10;
        }
    } while (next_permutation(all(jun)));

    REP(i,n){
        cin >> p[i];
    }
    REP(i,n){
        cin >> q[i];
    }

    int pnum = listnum(p);
    int qnum = listnum(q);

    sort(all(junnum));

    int a = 0;
    int b = 0;
    REP(i, junnum.size())
    {
        if(junnum[i] == pnum){
            a = i;
        }
        if(junnum[i] == qnum){
            b = i;
        }
    }

    cout << abs(a - b) << endl;

    return 0;
}

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

int main() {
  char s[100010];
  cin >> s;
  
  int n = strlen(s);
  for (int i = 0; i < n; i++) {
    if (!(i % 2)) cout << s[i];
  } cout << endl;
  
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main(){
    cin>>N>>K;
    ll ans = 0;
    if(K != 0) {
        reps(i, K + 1, N + 1) {
            ll temp = N;
            temp -= K * (N / i) + min(K - 1, N - (N / i) * i);
            ans += temp;
            //cout<<i<<' '<<temp<<endl;
        }
    }else{
        ans = N*N;
    }
    cout<<ans<<endl;
}

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

long long comb(int n, int m){
    long long c=1;
    for(int i=1; i<=m; i++){
        c *= n-i+1;
        c /= i;
    }
    return c;
}

int main(void)
{
  int k, s;
  cin >> k >> s;
  int count = 0;
  
  for(int x=0; x<=s && x<=k; x++){
      for(int y=0; x+y<=s && y<=k; y++){
          int z = s - x - y;
          if(z >= 0 && z <= k)
            count++;
      }
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

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

#define debug(s) cout<< #s <<" = "<< s <<endl
#define all(v) (v).begin(), (v).end()
#define KeepUnique(v) (v).erase( unique(all(v)), v.end() )
#define MEMSET(a,val) memset(a, val, sizeof a)
#define PB push_back
#define endl '\n'

inline int myrand(int l, int r) {
	int ret = rand(); ret <<= 15; ret ^= rand();
	if(ret < 0) ret = -ret; ret %= (r-l+1); ret += l;
	return ret;
}
template <typename F, typename S>
ostream& operator << (ostream& os, const pair< F, S>& p) {
    return os<<"(" <<p.first<<", "<<p.second<<")"; }

typedef pair<int, int> ii;
template<typename T> using min_pq =
	priority_queue<T, vector<T>, greater<T> >;

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

int n;
int a[500005];

bool chex() {
	if(a[1] != 0) return false;
	for(int i=1; i<n; i++) {
		if(a[i+1] > a[i]) {
			if(a[i] != a[i+1]-1)
				return false;
		}
	} return true;
}

int32_t main () {
	//freopen("in", "r", stdin);
	//freopen("output.out", "w", stdout);
	cin>>n;
	for(int i=1; i<=n; i++) {
		cin>>a[i];
	}
	if(!chex()) {
		cout<<"-1"<<endl;
		return 0;
	}
	long long ret = 0;
	for(int i=1; i<n; i++) {
		if(a[i] >= a[i+1]) {
			ret += a[i];
		}
	} ret += a[n];
	cout<<ret<<endl;
}

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

#define all(s) s.begin(), s.end()
#define pb push_back
#define ii pair<int, int>
#define x first
#define y second
#define bit(x, y) ((x >> y) & 1)    

const int N = 100005;

int nx[20][N];
int a[N];
int n, l, q;

int main() {
    ios::sync_with_stdio(false); cin.tie(0); 
    cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    a[n + 1] = 1e9 + 1;
    cin >> l;
    for (int i = 1; i <= n; i++) {
        nx[0][i] = upper_bound(a + 1, a + n + 2, a[i] + l) - a - 1;
    }
    nx[0][n + 1] = n + 1;
    for (int i = 1; i < 20; i++) {
        for (int j = 1; j <= n + 1; j++) {
            nx[i][j] = nx[i - 1][nx[i - 1][j]];
        } 
    }
    cin >> q;
    while (q--) {
        int l, r;
        cin >> l >> r;
        if (l > r) swap(l, r);
        int ans = 0;
        for (int i = 19; i >= 0; i--) {
            if (nx[i][l] < r) {
                // cout << l << ' ' << ' ' << r << ' ' << i << endl;
                l = nx[i][l];
                ans += (1 << i);
            } 
        }
        cout << ans + 1 << '\n';
    }
    return 0;
}

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

int MOD = 1000 * 1000 * 1000 + 7;

int main() {
	
	int n, k;
	cin >> n >> k;
	int limit[n+1];
	for (int i=1; i<=n; i++) cin >> limit[i];
	
	int ways[n+1][k+1];
	ways[0][0] = 1;
	for (int i=1; i<=k; i++) {
		ways[0][i] = 0;
	}
	
	for (int child=1; child<=n; child++) {
		int pf[k+1];
		pf[0] = ways[child-1][0];
		for (int candies=1; candies<=k; candies++) {
			pf[candies] = pf[candies-1] + ways[child-1][candies];
			pf[candies] %= MOD;
		}
		int lim = limit[child];
		ways[child][0] = 1;
		for (int candies=1; candies<=k; candies++) {
			int low = max(0, candies-lim);
			int lva;
			if (low == 0) lva = 0;
			else lva = pf[low-1];
			int hva = pf[candies];
			ways[child][candies] = hva - lva;
			ways[child][candies] %= MOD;
			ways[child][candies] += MOD;
			ways[child][candies] %= MOD;
		}
	}
	
	cout << ways[n][k] << endl;
	
}


Measured memory_bytes: 40064
import java.util.Scanner;

class B {
    public static void main(String... args) {
        final Scanner sc = new Scanner(System.in);
        final String S = sc.next().intern();
        System.out.println(S.replaceAll(".", "x"));
    }
}

public class Main {
    public static void main(String... args) {
        B.main();
    }
}


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

using namespace std;
#define int long long
#define endl '\n'



int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n; cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.rbegin(), a.rend());
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        if (i == 0) {
            if (n > 1) cnt += a[0];
            continue;
        }
        if (2 * i < n) cnt += a[i];
        if (2 * i + 1 < n) cnt += a[i];
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 4768
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
	long n, m, k;
	cin >> n >> m >> k;
	for(int i = 0; i <= n; i++){
		for(int j = 0; j <= m; j++){
			if((m - j) * i + (n - i) * j == k){
				cout << "Yes";
				return 0;
			}
		}
	}
	cout << "No";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define P pair<int,int>
#define PP pair<P,int>
#define F first
#define S second
#define f(i,n) for(int i=0;i<(n);i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define mod (int)(1000000007)
#define pie 3.141592653589793238462643383279
#define Bpri priority_queue
#define Spri priority_queue<P,vector<P>,greater<P>>
using namespace std;
signed main(){
	int a,b,ans=INF;
	bool bo=false;
	cin>>a>>b;
	if(b-a>=2019)bo=true;
	a%=2019;
	b%=2019;
	if(a>=b)b+=2019;
	if(bo)b+=2019;
	for(int i=a;i<b;i++){
		for(int j=i+1;j<=b;j++){
			ans=min(ans,i*j%2019);
		}
	}
	cout<<ans<<endl;
}


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

int main(){
    int n;
    std::cin >> n;
    
    std::vector<int> a(n);
    for(int i = 0; i < n; i++){
        std::cin >> a[i];
    }
    
    for(int j = n-1; j >= 0; j--){
        if(j == 0){
            std::cout << a[0] << std::endl;
            return 0;
        }
        else{
            std::cout << a[j] << " ";
        }
    }
}


Measured memory_bytes: 3080
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try(Scanner scan = new Scanner(System.in)) {
			int n = scan.nextInt();
			scan.nextLine();
			for(int i=0; i<n; i++) {
				String x = scan.nextLine();
				String y = scan.nextLine();
				int ans = solve(x, y);
				System.out.println(ans);
			}
		}
	}
	
	private static int solve(String x, String y) {
		int[][] dp = new int[x.length()+1][y.length()+1];
		for(int i=1; i<=x.length(); i++) {
			for(int j=1; j<=y.length(); j++) {
				if(x.charAt(i-1) == y.charAt(j-1)) {
					dp[i][j] = dp[i-1][j-1] + 1;
				} else {
					dp[i][j] = Math.max(dp[i][j-1], dp[i-1][j]);
				}
			}
		}
		return dp[x.length()][y.length()];
	}
}



Measured memory_bytes: 64296
#!/mnt/c/Users/moiki/bash/env/bin/python
N = int(input())
T, A = list(map(int, input().split()) )

H = map(int, input().split())
H = list(H)

# print(H, len(H))

temps = []
for h in H:
    temps.append(T-h*0.006)
    temps[-1] =  abs(
        temps[-1] - A
    )

import numpy as np
# print(temps, A)
print(np.array(temps).argmin()+1)

Measured memory_bytes: 20160
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}

// index が条件を満たすかどうか
int main() {
	int k, x;
	cin >> k >> x;
	if (k * 500 >= x) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

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

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void){
  int sx, sy, tx, ty;
  cin >>sx>>sy>>tx>>ty;
  int dx = tx - sx;
  int dy = ty - sy;
  REP(i, 0, dx) cout << "R";
  REP(i, 0, dy) cout << "U";
  REP(i, 0, dx) cout << "L";
  REP(i, 0, dy) cout << "D";
  cout << "D";
  REP(i, 0, dx + 1) cout << "R";
  REP(i, 0, dy + 1) cout << "U";
  cout << "LU";
  REP(i, 0, dx + 1) cout << "L";
  REP(i, 0, dy + 1) cout << "D";
  cout << "R" << endl;
}


Measured memory_bytes: 256
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2014
// 問題文が良くない。
/*

このとき，格子 (i, j) が黒い杭に拡大隣接していて，さらに白い杭に  拡大隣接  していないとき，またそのときに限って，格子 (i, j) が黒い杭に囲まれているという．

が正しい。

 */

#include <iostream>
#include <stdio.h>
#include <queue>
#include <algorithm>

using namespace std;

struct Point {
  int x, y;
};

const int dir[4][2] = { {0, 1}, {0, -1}, {1, 0}, {-1, 0} };

int main() {
  int w, h;
  while (scanf("%d%d", &w, &h) != EOF && w) {
    char c;
    queue<Point> Q[2]; // 0がB、1がW。
    bool isempty[60][60];
    //    bool isnb[2][60][60];
    fill(&isempty[0][0], &isempty[0][0]+60*60, false);
    //    fill(&isnb[0][0][0], &isnb[0][0][0]+2*60*60, false);
    for (int i=1; i<=h; i++) {
      for (int j=1; j<=w; j++) {
	Point p = { j, i };
	scanf(" %c", &c);
	switch(c) {
	case 'B':
	  Q[0].push(p);
	  /* for (int l=0; l<4; l++) {
	    isnb[0][j+dir[l][0]][i+dir[l][1]] = true;
	    } */
	  break;
	case 'W':
	  Q[1].push(p);
	  /* for (int l=0; l<4; l++) {
	    isnb[1][j+dir[l][0]][i+dir[l][1]] = true;
	    } */
	  break;
	default:
	  isempty[j][i] = true;
	}
      }
    }
    bool isnbh[2][60][60];
    fill(&isnbh[0][0][0], &isnbh[0][0][0]+2*60*60, false);
    for (int k=0; k<2; k++) {
      while(! Q[k].empty()) {
	Point now = Q[k].front();
	Q[k].pop();
	for (int i=0; i<4; i++) {
	  int tx = now.x + dir[i][0];
	  int ty = now.y + dir[i][1];
	  if (isempty[tx][ty] && !isnbh[k][tx][ty]) {
	    isnbh[k][tx][ty] = true;
	    Point temp = {tx, ty};
	    Q[k].push(temp);
	  }
	}
      }
    }
    int ans[2] = {0, 0};
    for (int k=0; k<2; k++) {
      for (int i=1; i<=h; i++) {
	for (int j=1; j<=w; j++) {
	  if (isnbh[k][j][i] && !isnbh[(k+1)%2][j][i]) ans[k]++;
	}
      }
    }
    printf("%d %d\n", ans[0], ans[1]);
    /* cerr << "Empty:" << endl;
    for (int i=1; i<=h; i++) {
      for (int j=1; j<=w; j++) {
	cerr << isempty[j][i];
      }
      cerr << endl;
    }
    cerr << "Neighborhood of Black:" << endl;
    for (int i=1; i<=h; i++) {
      for (int j=1; j<=w; j++) {
	cerr << isnb[0][j][i];
      }
      cerr << endl;
    }
    cerr << "Neighborhood of White:" << endl;
    for (int i=1; i<=h; i++) {
      for (int j=1; j<=w; j++) {
	cerr << isnb[1][j][i];
      }
      cerr << endl;
    }
    cerr << "Extended Neighborhood of Black:" << endl;
    for (int i=1; i<=h; i++) {
      for (int j=1; j<=w; j++) {
	cerr << isnbh[0][j][i];
      }
      cerr << endl;
    }
    cerr << "Extended Neighborhood of White:" << endl;
    for (int i=1; i<=h; i++) {
      for (int j=1; j<=w; j++) {
	cerr << isnbh[1][j][i];
      }
      cerr << endl;
    }
    cerr << "Black's Area:" << endl;
    for (int i=1; i<=h; i++) {
      for (int j=1; j<=w; j++) {
	cerr << (isnbh[0][j][i] && !isnbh[1][j][i]);
      }
      cerr << endl;
    }
    cerr << "White's Area:" << endl;
    for (int i=1; i<=h; i++) {
      for (int j=1; j<=w; j++) {
	cerr << (isnbh[1][j][i] && !isnbh[0][j][i]);
      }
      cerr << endl;
    } */
  } 
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
using namespace std;
int main(){
    long long n,ans=0,maxa=0;
    cin>>n;
    long long a[n];
    cin>>a[0];
    f(i,1,n){
        cin>>a[i];
        if(a[i]<=a[i-1]){
            ans++;
        }
        else{
            maxa=max(maxa,ans);
            ans=0;
        }
    }
    maxa=max(maxa,ans);
    cout<<maxa<<endl;
    return 0;
}


Measured memory_bytes: 4424
#include <cstdio>
#include <cmath>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <cassert>
#include <string>
#include <cstring>
#include <queue>

using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define S2(x,y) scanf("%d%d",&x,&y)
#define P(x) printf("%d\n",x)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second

typedef long long int LL;
typedef pair<int, int > pii;
typedef vector<int > vi;

const int N = 100005;
int A[N];

int main() {
  int n,L;
  S2(n,L);
  LL sum = 0;
  rep(i,1,n+1) {
    S(A[i]);
    sum += A[i];
  }

  vi ans;
  bool ok = false;
  rep(i,1,n) if(A[i] + A[i+1] >= L) {
    ok = true;
    rep(j,1,i) ans.push_back(j);
    for(int j = n - 1; j > i; j--) ans.push_back(j);
    ans.push_back(i);
    break;
  }
  if(!ok) {
    printf("Impossible\n");
    return 0;
  }
  printf("Possible\n");
  rep(i,0,ans.size()) P(ans[i]);
  return 0;
}

Measured memory_bytes: 1656
ans = []
n = int(input())
while n > 0:
    i = n % 26
    if i == 0:
        i += 26
    ans.append(chr(i + 96))
    if n % 26 == 0:
        n = n // 26 - 1
    else:
        n //= 26
ans.reverse()
print("".join(ans))

Measured memory_bytes: 61748
N, M = map(int, input().split())

nodes, checks = [], []
for i in range(N):
    nodes.append(list(map(int, input().split())))

for j in range(M):
    checks.append(list(map(int, input().split())))

for i in range(N):
    argMin, distMin = None, float('inf')
    for j in range(M):
        dist = abs(nodes[i][0] - checks[j][0]) + abs(nodes[i][1] - checks[j][1])
        if dist < distMin: argMin, distMin = j, dist
    print(argMin + 1)

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

int main() {
    int x;
    cin >> x;
    if (x == 7 || x == 5 || x == 3) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int N,K;
int V[105];

int main(){

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

	for(int i = 0; i < N; i++){

		scanf("%d",&V[i]);
	}

	int ans = -BIG_NUM;

	vector<int> work;

	for(int L = 0; L <= min(K,N); L++){ //左から取り出す個数
		for(int R = 0; L+R <= min(K,N); R++){ //右から取り出す個数

			work.clear();

			int sum = 0;

			for(int i = 0; i < L; i++){

				work.push_back(V[i]);
				sum += V[i];
			}

			for(int i = 0; i < R; i++){

				work.push_back(V[(N-1)-i]);
				sum += V[(N-1)-i];
			}

			sort(work.begin(),work.end());

			//捨てられる限り負の石を捨てる
			for(int i = 0; i < min(L+R,K-(L+R)); i++){
				if(work[i] >= 0)break;

				sum -= work[i];
			}
			ans = max(ans,sum);
		}
	}

	printf("%d\n",ans);

	return 0;
}


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

int main(){
    string N;
    cin >> N;
    int count=0,cmax=0;
    N+="0";
    for(int i:N){
        if(!('A'==i||'G'==i||'C'==i||'T'==i)){
            cmax=max(cmax, count);
            count=0;
            continue;
        }
        count++;
    }
    cout << cmax << endl;
}


Measured memory_bytes: 3600
#include <cstdio>
#include <cstdlib>
typedef long long int64;
static const int MAXN = 1e5 + 4;
template <typename T> inline int sign(const T x) { return x > 0 ? 1 : -1; }

int n, a[MAXN];

int64 calc()
{
    int64 sum = a[0];
    int64 ans = 0;
    for (int i = 1; i < n; ++i) {
        int last_sign = sign(sum);
        sum += a[i];
        if (sum * last_sign >= 0) {
            ans += std::abs(-last_sign - sum);
            sum = -last_sign;
        }
    }
    return ans;
}

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

    if (a[0] == 0) {
        int64 a1, a2;
        a[0] = 1;  a1 = calc() + 1;
        a[0] = -1; a2 = calc() + 1;
        printf("%lld\n", a1 < a2 ? a1 : a2);
    } else {
        int64 a1, a2;
        a1 = calc();
        int orig_a0 = a[0];
        a[0] = -sign(a[0]); a2 = calc() + std::abs(orig_a0) + 1;
        printf("%lld\n", a1 < a2 ? a1 : a2);
    }

    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x); i<=(y); i++)
#define per(i,x,y) for (int i=(x); i>=(y); i--)
#define ll long long
#define N 500010
using namespace std;
ll read(){
	char ch=getchar(); ll x=0; int op=1;
	for (; !isdigit(ch); ch=getchar()) if (ch=='-') op=-1;
	for (; isdigit(ch); ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
	return x*op;
}
int n,Q,a[N],d[N],f[N];
int main(){
	n=read(); a[0]=read();
	rep (i,1,n){
		d[i]=read();
		a[i]=min(a[i-1],abs(a[i-1]-d[i]));
	}
	f[n+1]=1;
	per (i,n,1) if (d[i]>=2*f[i+1]) f[i]=f[i+1]; else f[i]=f[i+1]+d[i];
	Q=read();
	while (Q--){
		int x=read();
		if (a[x-1]<f[x+1]) puts("NO"); else puts("YES");
	}
	return 0;
}

Measured memory_bytes: 7808
N = int(input())
h = list(map(int,input().split()))
count = 0
h_len = len(h)

while(sum(h) != 0):
  l = -1
  r = -1
  min_h = 0
  #print("")
  #print(h)
  #print("")
  for i in range(h_len):
    if h[i] > 0:
      l = i
      break
  if l == -1:
    #print("l -1 break")
    break
  #print("l : "+str(l))
  
  for j in range(l,h_len):
    if h[j] > 0:
      r = j+1
      #print("for j break")
    else:
      break
  if r == -1:
    #print("r -1 break")
    break
  #print("r : "+str(r))
  
  min_h = min(h[l:r])
  h[l:r] = [h[k] - min_h for k in range(l,r)]
  count += min_h

print(count)

Measured memory_bytes: 3064
#include<stdio.h>
int main(void)
{
	int n,m;
	int i,j;
	int mas[1001],sai[1001];
	int ba,cnt;
	
	scanf("%d %d",&n,&m);
	while(n!=0 && m!=0){
		for(i=1;i<=n;i++){
			scanf("%d",&mas[i]);
		}
		for(i=1;i<=m;i++){
			scanf("%d",&sai[i]);
		}
		ba=1;
		cnt=0;
		i=1;
		while(ba<n){
			cnt++;
			ba=ba+sai[i];
			i++;
			ba=ba+mas[ba];
		}
		printf("%d\n",cnt);
		scanf("%d %d",&n,&m);
	}
	return 0;
}

Measured memory_bytes: 1036
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<stdio.h>
using namespace std;
typedef long long ll;
double *dp;




void solve(){
	
	long long  A, B;
	cin >>  A >> B;
	
	if (A < 2 * B) {
		cout << 0 << endl;
	}
	else {
		cout << A - 2 * B << endl;
	}

}


int main() {
	solve();

}

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

using namespace std;

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

    int H, W, h, w;
    cin >> H >> W >> h >> w;

    cout << (H * W) - (h * W + w * H - h * w);

    return 0;
}


Measured memory_bytes: 256