akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define int ll

#define FOR(i, a, b) for (int i=a; i<b; i++)
#define For(i, a) for (int i=0; i<a; i++)
#define FORR(i,a,b) for (int i = a; i >= b; i--)
#define Forr(i,a) for (int i = a; i >= 0; i--)

#define deb(...) cerr << "[" << #__VA_ARGS__ << "] : [", DBG(__VA_ARGS__)
void DBG() { cerr << "]\n";}
template<typename T, typename ...Args> void DBG(T first, Args... args)
{cerr << first; if(sizeof...(args))cerr<<", "; DBG(args...); }

void solve(){
  int n; cin >> n;
  double p[n+1];
  For(i,n)cin >> p[i];
  double dp[2][2][n+2];
  memset(dp,0,sizeof(dp));
  dp[0][0][1] = p[0];
  dp[0][1][0] = (1.0-p[0]);
  int flag = 0;
  For(i,n){
    For(j,n){
      For(k,2){
        if(k==0){
          dp[1-flag][k][j+1] = p[i+1]*(dp[flag][k][j]+dp[flag][1-k][j]);
        }
        else{
          dp[1-flag][k][j] = (1.0-p[i+1])*(dp[flag][k][j]+dp[flag][1-k][j]);
        }
      }
    }
    flag = 1-flag;
  }
  long double ans = 0.0;
  FOR(i,n/2+1,n+1){
    For(j,2){
      ans += dp[1-flag][j][i];
    }
  }
  cout << fixed << setprecision(10) << ans <<"\n";
}

int32_t main(){
  ios_base:: sync_with_stdio(false);
  cin.tie(0);
  int t=1;
  for(int tt=1;tt<=t;tt++){
    solve();
  }
}

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)



int main(){
  
  ll a,b,bb;
  char dust;
  cin >> a >> b >> dust >> bb;
  cout << fixed << setprecision(20);
  cout << a*b+a*bb/100 << endl;
  
  
  
  
  return 0;
}


Measured memory_bytes: 3640
x,y=map(int,input().split())
if ((x in [1,3,5,7,8,10,12])&(y in [1,3,5,7,8,10,12]))|((x in [4,6,9,11])&(y in [4,6,9,11]))|((x==2)&(y==2)):
    print("Yes")
else:
    print("No")

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

int main(){
    int r,c;
    cin >> r >> c;
    
    vector<vector<int> > table(r+1,vector<int> (c+1,0));
    
    rep(i,r){
        rep(j,c){
            cin >> table[i][j];
        }
    }
    
    rep(i,r){
        rep(j,c){
            table[i][c] += table[i][j];
        }
    }
    
    rep(i,c){
        rep(j,r){
            table[r][i] += table[j][i];
        }
    }
    
    rep(i,c){
        table[r][c] += table[r][i];
    }
    
    rep(i,r+1){
        rep(j,c+1){
            if(j != c)cout << table[i][j] << " ";
            else cout << table[i][j] << endl;
        }
    }
    
}





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

int main() {
    int N;
    cin >> N;
    int ans = 0;
    int now = 0;
    int tmp = 0;
    rep(i, N) {
        int H;
        cin >> H;
        if (now >= H) {
            tmp += 1;
        } else {
            ans = max(ans, tmp);
            tmp = 0;
        }
        now = H;
    }
    ans = max(ans, tmp);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import itertools

def GenerateArray(number):
    data = []
    for i in range(number):
        data.append(i+1)
    return data

def CheckArrayOrder(data, Array, count=0):
    for i in itertools.permutations(data):
        count += 1
        if list(i) == Array:
            return count
    return False

number = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

data = GenerateArray(number)

print(abs(CheckArrayOrder(data, P) - CheckArrayOrder(data, Q)))

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

using namespace std;

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

	int c5=0, c7=0;
	int a, b, c;

	cin >> a >> b >> c;

	if (a == 5)
		c5++;
	if (a == 7)
		c7++;
	if (b == 5)
		c5++;
	if (b == 7)
		c7++;
	if (c == 5)
		c5++;
	if (c == 7)
		c7++;

	if (c5 == 2 & c7 == 1)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	return 0;

}

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

ll solve() {
    ll N, M;
    cin >> N >> M;
    string S;
    cin >> S;
    stack<int> st;
    for ( int i = 0; i < N; i++ ) {
        if ( S[i] == '0' ) st.push(i); 
    }
    int cur = N;
    vector<int> ansr;
    while ( !st.empty() ) {
        int v = -1;
        while ( !st.empty() && cur - st.top() <= M ) {
            v = st.top();
            st.pop();
        }
        if ( v == -1 ) return -1;
        ansr.push_back(cur - v);
        cur = v;
    }
    for ( int i = ansr.size()-1; i >= 0; i-- ) {
        cout << (i != ansr.size()-1 ? " " : "") << ansr[i];
    }
    cout << "\n";
    return 0;
}

int main() {
    auto ans = solve();
    if ( ans < 0 ) {
        cout << ans << "\n";
    }
    return 0;
}

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

int main(){
  int i,j,k,cnt=0;
  int h,w;
  cin>>h>>w;
  string s[h+1];
  for(i=0;i<h;i++)cin>>s[i];
  for(i=0;i<h;i++)s[i]+='#';
  s[h]="";
  for(i=0;i<=w;i++)s[h]+='#';
  int c[h][w];
  for(i=0;i<h;i++)for(j=0;j<w;j++)c[i][j]=0;
  for(i=0;i<h;i++){
    cnt=-1;
    for(j=0;j<=w;j++){
      if(s[i][j]=='#'){
        for(k=cnt+1;k<j;k++){
          c[i][k]+=j-cnt-1;
        }
        cnt=j;
      }
    }
  }
  for(i=0;i<w;i++){
    cnt=-1;
    for(j=0;j<=h;j++){
      if(s[j][i]=='#'){
        for(k=cnt+1;k<j;k++){
          if(c[k][i]==0)c[k][i]+=j-cnt-1;
          else c[k][i]+=j-cnt-2;
        }
        cnt=j;
      }
    }
  }
  int ma=0;
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      ma=max(ma,c[i][j]);
    }
  }
  cout<<ma;
}


Measured memory_bytes: 19968
// 雑 推敲してない
package main

import "fmt"

func main() {
	var X, A, B int
	fmt.Scan(&X, &A, &B)
	if A-B >= 0 {
		fmt.Println("delicious")
	} else if X >= B-A {
		fmt.Println("safe")
	} else {
		fmt.Println("dangerous")
	}
}


Measured memory_bytes: 512
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

typedef unsigned long long ULLONG;
typedef long long LLONG;

template <class _T> static _T tp_abs(const _T& a) {
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void getint(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}
static void getstring(char* buff) {
	if (scanf(" %s", buff) < 0) {
		printf("getstr error!\n");
	}
}
static const long long MOD_NUM = 1000000007LL;
template <class _T> static _T tp_pow(int base, int exp)
{
	_T ans = 1;

	for (int i = 0; i < exp; i++) {
		ans *= base;
	}
	return ans;
}

static void B_task();

int main()
{
	B_task();
	fflush(stdout);
	return 0;
}

static void B_task()
{
	int N;
	getint(N);

	std::vector<LLONG> an(N, 0);
	for (int i = 0; i < N; i++) {
		std::cin >> an[i];
		if (an[i] == 0) {
			printf("%d\n", 0);
			return;
		}
	}

	long double total = 1.0;
	LLONG tmax = tp_pow<LLONG>(10, 18);

	for (int i = 0; i < N; i++) {
		LLONG digit1 = 0, digit2 = 0;
		LLONG tmp = total;
		while (tmp) {
			digit1++;
			tmp /= 10;
		}
		tmp = an[i];
		while (tmp) {
			digit2++;
			tmp /= 10;
		}

		if ((digit1 + digit2 - 2) > 18) {
			total = -1;
			break;
		}


		total *= an[i];
		if (total > (long double)tmax) {
			total = -1;
			break;
		}
		
	}
	printf("%lld\n", (LLONG)total);
}


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


/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'

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


/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())


/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;


/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;


class mint {
  private: 
    ll x;

  public:
    constexpr mint(const ll x = 0) noexcept : x((x % mod + mod) % mod) {}
    constexpr ll value() noexcept { return x; }
    constexpr mint operator += (const mint right) noexcept {
      if ((x += right.x) >= mod) x -= mod;
      return *this;
    }
    constexpr mint operator -= (const mint right) noexcept {
      if ((x += mod - right.x) >= mod) x -= mod;
      return *this;
    }
    constexpr mint operator *= (const mint right) noexcept {
      x = x * right.x % mod;
      return *this;
    }
    constexpr mint operator /= (const mint right) noexcept {
      return *this *= right.inv();
    }
    constexpr mint operator + (const mint right) const noexcept {
      return mint(*this) += right;
    }
    constexpr mint operator - (const mint right) const noexcept {
      return mint(*this) -= right;
    }
    constexpr mint operator / (const mint right) const noexcept {
      return mint(*this) /= right;
    }
    constexpr mint operator * (const mint right) const noexcept {
      return mint(*this) *= right;
    }
    constexpr mint inv() const {
      return pow(mod-2);
    }
    constexpr mint pow(ll n) const {
      if (n == 0) return 1;
      mint a = pow(n>>1);
      a *= a;
      if (n & 1) a *= *this;
      return a;
    }
};

mint nCr(ll n, ll r) {
  mint ret = 1;

  rep(i, r) ret *= n - i;
  rep(i, r) ret /= (i + 1);

  return ret;
}

signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);
  
  ll n, a, b; cin >> n >> a >> b;
  mint ans = mint(2).pow(n) - 1;

  ans -= nCr(n, a);
  ans -= nCr(n, b);

  cout << ans.value() << endl;
}


Measured memory_bytes: 3600
#include<algorithm>
#include<cmath>
#include<deque>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<set>
#include<string>
#include<vector>

#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<queue>
#include<stack>
#include<tuple>
#include<utility>
typedef long long ll;
#define rep(i,n) for(ll i=0; i<n; i++)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define mod 1000000007
using namespace std;

int main(){
  int n,k;
  cin >> n >> k;
  string s;
  cin >> s;
  s[k-1] += 'a' - 'A';
  cout << s;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"

using namespace std;

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

    int value = 0;

    for(int i = 0; i < str.size(); i ++)
    {
        char ch = str.at(i);
        int num = ch - '0';

        value += num;
    }

    if(value % 9 == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3720
#![allow(unused_imports, unused_variables, dead_code)]

use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;
use std::io::Write;

trait InputValue {
    fn parse(s: &str) -> Self;
}

fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

fn readvec<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

fn readlines<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

fn main() {
    let n: usize = read();
    let s: Vec<String> = readvec();
    let mut set = HashSet::new();
    for si in s {
        set.insert(si);
    }

    if set.len() == 3 {
        println!("Three");
    } else {
        println!("Four");
    }
}

Measured memory_bytes: 4352
N = int(input())
s = [input() for _ in range(N)]
M = int(input())
t = [input() for _ in range(M)]
ss = set(s)
b = 0
for i in ss:
    a = 0
    for l in s:
        if l == i:
            a += 1
    for l in t:
        if l == i:
            a -= 1
    if a > b:
        b = a
print(b)



Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int a;
    int nino = 0, yono = 0;
    for(int i = 0; i < n; i++){
        cin >> a;
        if(a % 2 == 0 && a % 4 != 0)
            nino ++;
        else if(a % 4 == 0)
            yono ++;
    }
    if(n / 2 <= nino / 2 + yono)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

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

int main(){
	int N; std::cin >> N;
	std::vector<long long> A(N);
	for (auto& r : A) std::cin >> r;
	long long ans{ 0 };
	for (auto i{ 1 }; i < N; ++i) {
		if (A.at(i - 1) > A.at(i)) {
			ans += (A.at(i - 1) - A.at(i));
			A.at(i) = A.at(i - 1);
		}
	}

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 4856
import math
def is_prime(a):
    j=2
    while(math.sqrt(a)>=j):
        if a%j==0:
           
            return 0
        j+=1
    return 1


N=int(input())
A=[int(input())for i in range(N)]
ans=0

for a in A:
    ans+=is_prime(a)
print(ans)



Measured memory_bytes: 6012
s = input()

flag = 0
cnt = 0
n = int(input())

que_ar = [input() for _ in range(n)]

f_x = ["" for _ in range(n)]
b_x = ["" for _ in range(n)]


f = n-1
b = 0

for i in range(n):
    que = que_ar[i]
    if(len(que) == 1):
        cnt += 1
    else:
        que = que.split()
        if(cnt%2 == 0):
            if(que[1]=="1"):
                f_x[f] = que[2]
                f -= 1
            else:
                b_x[b] = que[2]
                b += 1
        else:
            if(que[1]=="1"):
                b_x[b] = que[2]
                b += 1
            else:
                f_x[f] = que[2]
                f -= 1

s = "".join(f_x)+s+"".join(b_x)             
                
if(cnt%2 == 0):
    print(s)
else:
    print(s[::-1])



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

typedef long long lint;
typedef unsigned long long ulint;
const int MOD=1000000007;

pair<lint,pair<lint,lint>> triple(lint i, lint j, lint k){
    return make_pair(i,make_pair(j,k));
}
typedef pair<lint,pair<lint,lint>> tp;

tp operator+(tp a,tp b){
    return triple(a.first+b.first,a.second.first+b.second.first,a.second.second+b.second.second);
}

int sign(int a){
    if(a==0) return 1;
    else return -1;
}

int main(){
    int N,M;
    cin >> N >> M;
    lint x[1001],y[1001],z[1001];
    for(int i=1;i<=N;i++) cin >> x[i] >> y[i] >> z[i];

    tp dp[2][2][2][1001][1001];
    for(int i=0;i<2;i++){
        for(int j=0;j<2;j++){
            for(int k=0;k<2;k++){
                for(int l=0;l<=N;l++){
                    dp[i][j][k][0][l]=triple(0,0,0);
                }
                for(int l=0;l<=N;l++){
                    dp[i][j][k][l][0]=triple(0,0,0);
                }
            }
        }
    }
    for(int i=0;i<2;i++){
        for(int j=0;j<2;j++){
            for(int k=0;k<2;k++){
                for(int l=1;l<=N;l++){
                    for(int m=1;m<=M;m++){
                        if(m<l){
                            tp a=dp[i][j][k][l-1][m];
                            tp b=dp[i][j][k][l-1][m-1]+triple(x[l],y[l],z[l]);
                            lint pointA=0,pointB=0;
                            pointA=a.first*sign(i)+a.second.first*sign(j)+a.second.second*sign(k);
                            pointB=b.first*sign(i)+b.second.first*sign(j)+b.second.second*sign(k);
                            if(pointA>pointB) dp[i][j][k][l][m]=a;
                            else dp[i][j][k][l][m]=b;
                        }else if(m==l){
                            dp[i][j][k][l][m]=dp[i][j][k][l-1][m-1]+triple(x[l],y[l],z[l]);
                        }else{
                            dp[i][j][k][l][m]=triple(0,0,0);
                        }
                    }
                }
            }
        }
    }

    lint mx=0;
    for(int i=0;i<2;i++){
        for(int j=0;j<2;j++){
            for(int k=0;k<2;k++){
                tp a=dp[i][j][k][N][M];
                mx=max(mx,a.first*sign(i)+a.second.first*sign(j)+a.second.second*sign(k));
            }
        }
    }

    cout << mx << endl;
    return 0;
}

Measured memory_bytes: 188160
N = int(input())
A = list(map(int, input().split()))

A.sort()
yakusu_0 = []
i = 1
while i <= A[0]**0.5:
	if A[0] % i == 0:
		yakusu_0.append(i)
		yakusu_0.append(A[0]//i)
	i += 1

one = set()
yakusu_0.sort()
max_y = 1
for j in range(len(yakusu_0)-1, -1, -1):
	num = 0
	for i in A:
		if i % yakusu_0[j] != 0:
			num += 1
		if num >= 2:
			break
	if num <= 1:
		max_y = yakusu_0[j]
		break

A = A[1:]
yakusu_0 = []
i = 1
while i <= A[0]**0.5:
	if A[0] % i == 0:
		yakusu_0.append(i)
		yakusu_0.append(A[0]//i)
	i += 1

one = set()
yakusu_0.sort()
max_z = 1
for j in range(len(yakusu_0)-1, -1, -1):
	num = 0
	for i in A:
		if i % yakusu_0[j] != 0:
			num += 1
			break
	if num == 0:
		max_z = yakusu_0[j]
		break

print(max(max_y, max_z))

Measured memory_bytes: 63984
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main(){
  int n,s;
  cin >> n >> s;
  vector<int> a(n);
  rep(i,n)cin >> a[i];
  vector<vector<mint>> dp(n+1,vector<mint>(s+1));
  dp[0][0]=1;
  rep(i,n){
    rep(j,s+1){
      dp[i+1][j]+=dp[i][j]*2;
      if(j-a[i]>=0)dp[i+1][j] += dp[i][j-a[i]];
    }
  }
  cout << dp[n][s] << endl;
  // rep(i,n+1){
  //   rep(j,s+1){
  //     cout << dp[i][j];
  //   }
  //   cout << endl;
  // }
}

Measured memory_bytes: 73680
import java.util.*;


public class Main {
    public static void main(String[] args){

        Scanner s = new Scanner(System.in);
        int a = s.nextInt();
        int b = s.nextInt();

        int n = Math.abs(a-b);

        if (n >= 2) {
          System.out.println(Math.max(a, b)+Math.max(a, b)-1);
        // } else if (n == 1){
        //   System.out.println(a + b);
        } else {
          System.out.println(a + b);
        }

    }
}

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

signed main () {
	int q,h,s,d,n;
	cin >> q >> h >> s >> d >> n;
	int one = min({q*4,h*2,s});
	int two = min(one * 2,d);
	cout << (n/2) * two + (n%2) * one << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
s_m, c_m = [], []
for i in range(m):
    s_m.append(0)
    c_m.append(0)
    s_m[i], c_m[i] = map(int, input().split())

def test():
    result = [0]*n
    for i in range(m):
        if s_m[i] == 1 and c_m[i] == 0 and n != 1:
            print(-1)
            return 0          
        for j in range(i+1, m):
            if s_m[i] == s_m[j] and c_m[i] != c_m[j]:
                print(-1)
                return 0
        result[s_m[i]-1] = c_m[i]
    if n == 1 and result[0] == 0:
        print(0)
        return 0
    elif result[0] == 0:
        result[0] = 1
    for ans in result:
        print(ans, end='')
    print()
    return 0
test()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  int n,m,x;
  int a[100],b;
  rep(i,100) a[i]=0;
  cin>>n>>m>>x;
  rep(i,m){
    cin>>b;
    a[b-1]++;
  }
  int r,l;
  r=l=0;
  repi(i,x,n) r+=a[i];
  repn(i,x-1) l+=a[i];
  cout<<min(r,l)<<endl;
  return 0;
}



Measured memory_bytes: 256
#include <map>
#include <list>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
string s;
int ans;
int main()
{
	fast;
	cin>>s;
	for (int i=0;i<=s.size()-1;i++)
	   if (s[i]=='1')
	      ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
class Point(object):
    def __init__(self, x, y):
        self.x = x
        self.y = y
    def __str__(self):
        return "x = {0}, y = {1}".format(self.x, self.y)

class Line(Point):
    eps = 10**(-10)
    def __init__(self, p1, p2):
        self.p1 = p1
        self.p2 = p2

    def isParallel(self, another_p):
        try:
            angle1 = (self.p1.y - self.p2.y) / (self.p1.x - self.p2.x)
            angle2 = (another_p.p1.y - another_p.p2.y) / (another_p.p1.x - another_p.p2.x)
            if angle1 >= angle2-self.eps and angle1 <= angle2+self.eps:
                return True
            else:
                return False
        except ZeroDivisionError:
            if self.p1.x == self.p2.x and another_p.p1.x == another_p.p2.x:
                return True
            else:
                return False


n = int(input())
for i in range(n):
    x1, y1, x2, y2, x3, y3, x4, y4 = map(float, input().split())
    A = Point(x1, y1)
    B = Point(x2, y2)
    C = Point(x3, y3)
    D = Point(x4, y4)

    AB = Line(A, B)
    CD = Line(C, D)

    if AB.isParallel(CD):
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 6800
#include<stdio.h>
int main()
{
    int a,b;
    char op;
    scanf("%d %c %d",&a,&op,&b);
    if(op=='+'){
        printf("%d\n",a+b);
    }
    else if(op=='-'){
        printf("%d\n",a-b);
    }
    else
        printf("%c\n",op);
    return 0;


}


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

int main() {
    int a, b;
    cin >> a >> b;
    if (a >= b) {
        rep(i, a) { cout << b; }
        cout << endl;
    } else if (a < b) {
        rep(i, b) { cout << a; }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3500
function Main(input) {
  input = input.split("\n");
  input = input[0];
  if(input == 'RSS' || input == 'SRS' || input == 'SSR' || input == 'RSR'){
  	console.log('1');
  }else if(input == 'SRR' || input == 'RRS'){
  	console.log('2');
  }else if(input == 'RRR'){
  	console.log('3');
  }else{
  	console.log('0')
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29632
n,k = gets.split.map(&:to_i)
s = []
n.times do
  s << gets.split.map(&:to_i)
end

#上からk個
slc = []
cnt = [0]*(n+1)
s.sort_by!{|a| a[1]}.reverse!
k.times do |i|
  slc << s[i]
  cnt[s[i][0]] += 1
end
slc.sort_by!{|a| [a[0],a[1]]}.reverse!

#種類数カウント
kind = 0
1.upto(n) do |i|
  kind += 1 if cnt[i] > 0
end

ext = []
prev = 0
sum = 0
slc.each do |a|
  ext << a[1] if prev == a[0]
  sum += a[1]
  prev = a[0]
end
ext.sort!

ans = [sum + kind ** 2]

k.upto(n-1) do |i|
  if ext.empty?
    break
  end
  if cnt[s[i][0]] == 0
    ans << sum - ext[0] + s[i][1] + (kind+1)**2
    sum = sum - ext[0] + s[i][1]
    ext.shift
    kind += 1
    cnt[s[i][0]] += 1
  end
end
p ans.max


Measured memory_bytes: 16800
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define re register
#define gc getchar
#define pc putchar
#define cs const
#define st static
#define mp make_pair
#define emplace_back push_back

inline
void outint(int a){
	st char ch[13];
	if(a==0)pc('0');
	while(a)ch[++ch[0]]=(a-a/10*10)^48,a/=10;
	while(ch[0])pc(ch[ch[0]--]);
}

vector<pair<pair<int,int> ,int > > e;

int main(){
	int L;
	cin>>L;
	int n=0,tmp=L;
	while(tmp){
		++n,tmp>>=1;
	}
	for(int re i=1;i<n;++i){
		e.emplace_back(mp(mp(i,i+1),0));
		e.emplace_back(mp(mp(i,i+1),1<<(i-1)));
	}
	int w=1<<(n-1),cnt=1;
	while(L^1){
		if(L&1){
			e.emplace_back(mp(mp(cnt,n),w));
			w|=1<<(cnt-1);
		}
		L>>=1;
		++cnt;
	}
	outint(n),pc(' '),outint(e.size()),pc('\n');
	for(vector<pair<pair<int,int>,int> >:: iterator it=e.begin();it!=e.end();++it){
		outint(it->first.first),pc(' '),outint(it->first.second),pc(' '),outint(it->second),pc('\n');
	}
	return 0;
}

Measured memory_bytes: 256
N, M, Q = list(map(int,input().split()))
conditions = [list(map(int,input().split())) for q in range(Q)]

def make_list(len_, max_, list_):
    min_ = list_[-1]
    lists = [list_ + [i] for i in range(min_, max_+1)]
    if len(list_)+1 == len_:
        return lists
    else:
        return_lists = []
        for l in lists:
            return_lists += make_list(len_, max_, l)
        return return_lists

all_lists = []
for j in range(1, M+1):
    all_lists += make_list(N, M, [j])

points = []
for A in all_lists:
    point = 0
    for a,b,c,d in conditions:
        if A[b-1]-A[a-1]==c:
            point += d
    points.append(point)
    
print(max(points))

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

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

  string t = "keyence";
  if (s == t) {
    cout << "YES" << endl;
    return 0;
  }

  for (int i = 0; i < s.size(); i++) {
    for (int j = 0; j < s.size(); j++) {
      string ss;
      for (int k = 0; k < s.size(); k++) {
        if (i <= k && k <= i + j) continue;
        ss += s[k];
      }
      if (ss == t) {
        cout << "YES" << endl;
        return 0;
      }
    }
  }
  cout << "NO" << endl;
  return 0;
}

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

namespace _20180305_AOJ
{
    class ALDS1_5C
    {
        static double cos60 = Math.Cos(Math.PI / 3.0);
        static double sin60 = Math.Sin(Math.PI / 3.0);
        static void Main(string[] args)
        {
            for (;;)
            {
                string line = Console.ReadLine();
                if (string.IsNullOrEmpty(line))
                {
                    break;
                }

                int n = int.Parse(line);
                Point p1 = new Point(0, 0);
                Point p2 = new Point(100, 0);

                WritePoint(p1);
                Koch(n, p1, p2);
                WritePoint(p2);
            }
        }

        static void WritePoint(Point p)
        {
            Console.WriteLine(string.Format("{0} {1}", p.X, p.Y));
        }

        static void Koch(int n, Point p1, Point p2)
        {
            if (n == 0)
            {
                return;
            }

            Point s = new Point();
            Point t = new Point();
            Point u = new Point();

            s.X = (2 * p1.X + p2.X) / 3.0;
            s.Y = (2 * p1.Y + p2.Y) / 3.0;
            t.X = (p1.X + 2 * p2.X) / 3.0;
            t.Y = (p1.Y + 2 * p2.Y) / 3.0;

            u.X = (t.X - s.X) * cos60 - (t.Y - s.Y) * sin60 + s.X;
            u.Y = (t.X - s.X) * sin60 + (t.Y - s.Y) * cos60 + s.Y;

            Koch(n - 1, p1, s);
            WritePoint(s);
            Koch(n - 1, s, u);
            WritePoint(u);
            Koch(n - 1, u, t);
            WritePoint(t);
            Koch(n - 1, t, p2);
        }
    }

    class Point
    {
        public double X { get; set; }
        public double Y { get; set; }

        public Point()
        {

        }
        public Point(double x, double y)
        {
            X = x;
            Y = y;
        }
    }
}



Measured memory_bytes: 9428
function main(input) {
    var args = input.trim().split(" ");
    var A = Number(args[0]);
    var B = Number(args[1]);
    var C = Number(args[2]);

    var rest = A - (B + C);
    if (rest > 0) {
        console.log(0);
        return;
    }
    console.log(Math.abs(rest));
}

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



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

int main() 
{
    string S;
    cin >> S;
    //cout << S.length() << endl;

    int first_cnt = 0;
    int second_cnt = 0;
    string sf = S;
    string sc = S;

    // first
    for (int i = 0; i < S.length() - 1; i++) {
        //cout << S[i] << endl;
        if (sf[i] == sf[i + 1]) {

            if (sf[i] == '0') {
                sf[i] = '1';
            } else {
                sf[i] = '0';
            }

          

            first_cnt += 1;
        } 
        //cout << sf << endl;
        if (i > 0) {
            if (sf[i - 1] == sf[i]) {
                first_cnt = 10000000;
                break;
            }
        }
    }



    for (int i = 0; i < S.length() - 1; i++) {
        //cout << S[i] << endl;
        if (sc[i] == sc[i + 1]) {

            if (sc[i + 1] == '0') {
                sc[i + 1] = '1';
            } else {
                sc[i + 1] = '0';
            }
            second_cnt += 1;
        } 
        
        if (i < S.length()) {
            if (sc[i] == sc[i + 1]) {
                second_cnt = 10000000;
                break;
            }
        }

    }
    //cout << first_cnt << endl;
    //cout << sf << endl;
    //cout << second_cnt << endl;
    //cout << sc << endl;

    cout << min(first_cnt, second_cnt) << endl;
}

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

int c[100];
int main() {
	int a, b;
	while (cin >> a >> b) {
		if (a == 0 && b == 0) {
			bool k = c[0] % 2 == 1 && c[1] % 2 == 1;
			for (int i = 2; i < 100; i++) {
				if (c[i] & 1)k = false;
			}
			if (k)puts("OK");
			else puts("NG");
			memset(c, 0, sizeof(c));
		}
		else {
			a--; b--;
			c[a]++; c[b]++;
		}
	}
}

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

typedef long long ll;
const ll MOD = 1000000007;

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    int d;
    cin >> s >> d;
    int n = s.length();
    vector<vector<vector<ll> > > dp(n + 1, vector<vector<ll> >(d, vector<ll>(2, 0)));
    dp[0][0][1] = 1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < d; j++) {
            // r == 1
            int digit = s[i] - '0';
            for (int k = 0; k < digit; k++) {
                dp[i + 1][(j + k) % d][0] += dp[i][j][1];
                dp[i + 1][(j + k) % d][0] %= MOD;
            }
            dp[i + 1][(j + digit) % d][1] += dp[i][j][1];
            dp[i + 1][(j + digit) % d][1] %= MOD;
            // r == 0
            for (int k = 0; k < 10; k++) {
                dp[i + 1][(j + k) % d][0] += dp[i][j][0];
                dp[i + 1][(j + k) % d][0] %= MOD;
            }
        }
    }

    cout << (dp[n][0][0] + dp[n][0][1] + MOD - 1) % MOD;
    return 0;
}

Measured memory_bytes: 55424
#include<bits/stdc++.h>
using namespace std;
int h1,h2,m1,m2,hm1,hm2,k;
int main()
{
    ios::sync_with_stdio(0);
    cin>>h1>>m1>>h2>>m2>>k;
	hm1=h1*60+m1;
	hm2=h2*60+m2;
	int k2=abs(hm2-hm1);
    k2>k? cout<<k2-k:cout<<0; 
	return 0;
}


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

using namespace std;

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

#define int ll

const ll mod = 1e9 + 7;


main(){
	int n;
	cin >> n;
	
	vector<int> a(n);
	vector<bool>  b(n), c(n);
	for(int i=0;i<n;i++) cin >> a[i];
	
	fill(b.begin(),b.end(),false);
	fill(c.begin(),c.end(),false);
	
	for(int i=0;i<n-1;i++){
		if(a[i]<a[i+1]) b[i] = true;
		if(a[i]>a[i+1]) c[i] = true;
		c[n-1] = true;
	}

	int money = 1000;
	int kabu = 0;
	for(int i=0;i<n;i++){
		if(c[i]){
			money += a[i]*kabu;
			kabu = 0;
		}
		if(b[i]){
			kabu += money/a[i];
			money %= a[i];
		}
	}

	cout << money << endl;
	

	return 0;
}


Measured memory_bytes: 3624
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
	    int n = scan.nextInt();
	    char a[]=new char[n];
	    for(int i=0;i<n;i++) {
	    	a[i]=scan.next().charAt(0);
	    }
	    scan.close();
	    int check=0;
	    for(int i=0;i<n;i++) {
	    	if(a[i]=='Y') {
	    		check=1;
	    		break;
	    	}
	    }
	    System.out.println((check==1)? "Four":"Three");
	}

}

Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
int n,k,d,r;
bool a[101];
int main()
{ cin.tie(0);
  ios_base::sync_with_stdio(0);
  cin>>n>>k;
  for(int j=1;j<=k;j++)
  { cin>>d;
    for(int i=1;i<=d;i++)
    { int x;
      cin>>x;
      a[x]=1;
    }
  }
  r=n;
  for(int i=1;i<=n;i++)
    r-=a[i];
  cout<<r<<'\n';
  return 0;
}


Measured memory_bytes: 3656
#include "bits/stdc++.h"
using namespace std;
int main() {
	int H,pazzle[10][5];
	while(scanf("%d",&H),H) {
		for(int i=0;i<H;i++) {
			for(int j=0;j<5;j++) {
				scanf("%d",&pazzle[i][j]);
			}
		}
		int ans=0;
		while(1) {
			bool ok=0;
			for(int i=0;i<H;i++) {
				int len=1,add=0;
				for(int j=1;j<5;j++) {
					if(pazzle[i][j]==pazzle[i][j-1]) {
						len++;
					}else {
						if(len>=3) {
							add=pazzle[i][j-1]*len;
							for(int k=0;k<len;k++) pazzle[i][j-1-k]=0;
						}
						len=1;
					}
				}
				if(len>=3) {
					add=pazzle[i][4]*len;
					for(int k=0;k<len;k++) pazzle[i][4-k]=0;
				}
				if(add>0) ans+=add,ok=1;
			}
			if(!ok) break;
			for(int j=0;j<5;j++) {
				int pos=H-1;
				for(int i=H-1;i>=0;i--) {
					if(pazzle[i][j]>0) pazzle[pos--][j]=pazzle[i][j];
				}
				for(int i=pos;i>=0;i--) pazzle[i][j]=0;
			}
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 3220
import itertools

n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

permutation_list = []

# nまでの順列要素のリスト作成
for i in range(1, n+1):
    permutation_list.append(int(i))

# 順列のペアを全て含んだリストの作成
# ただし各ペアはタプルであることに注意
permutations_pair = list(itertools.permutations(permutation_list))

for index, pair in enumerate(permutations_pair):
    # タプルのペアをリストに変換
    pair = list(pair)
    if pair == p:
        index_p = index
    # elifだと分岐になって、同じindexのときに定義されなくなるのでifにする
    if pair == q:
        index_q = index

print(abs(index_p - index_q))

Measured memory_bytes: 8052
n = int(input())

c = [1]
for i in [6,9]:
    j = i
    while j<10**5:
        c.append(j)
        j *= i
c.sort()
k = len(c)
dp = [float('inf') for i in range(n+1)]
dp[0] = 0

for cc in c:
    for j in range(cc,n+1):
        dp[j] = min(dp[j-cc]+1, dp[j])
print(dp[-1])


Measured memory_bytes: 7064
#include <iostream>
#include <cmath>
using namespace std;
 
int N, cost[100005], memo[500005];
 
int minCost(int v) {
  if (memo[v] != -1) return memo[v];
  if (v <= 0) return 0;
  
  int a = minCost(v - 1) + abs(cost[v] - cost[v - 1]);
  int b;
  if (v == 1) {
    b = 1000000000;
  }
  else {
    b = minCost(v - 2) + abs(cost[v] - cost[v - 2]);
  }
  
  
  memo[v] = min(a, b);
  
  return (min(a, b));
}
 
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) cin >> cost[i];
  
  for (int i = 0; i < 500005; i++) memo[i] = -1;
  
  cout << minCost(N - 1) << "\n";
  return 0;
}

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

int main() {
  string x;
  cin >> x;
    
  cout << x[0] << x[1] << x[2] << x[3] << x[4] << " " << x[6] << x[7] << x[8] << x[9] << x[10] << x[11] << x[12] << " " << x[14] << x[15] << x[16] << x[17] << x[18] << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

class Main {

    public static void main( final String[] args ) {

		final Scanner stdin = new Scanner( System.in );
		int n = stdin.nextInt();
		int[] ary = new int[ n ];
		for ( int i = 0; i < n; i++ ) {
			ary[ i ] = stdin.nextInt();
		}
		long[] ans = new long[ 21 ];
		long[] before = new long[ 21 ];
		before[ ary[ 0 ] ] = 1L;
		
		for ( int i = 1; i < n - 1; i++ ) {
			Arrays.fill( ans, 0L );
			for ( int j = 0; j <= 20; j++ ) {
				final int pval = j + ary[ i ];
				if ( 0 <= pval && pval <= 20 ) {
					ans[ pval ] += before[ j ];
				}
				final int sval = j - ary[ i ];
				if ( 0 <= sval && sval <= 20 ) {
					ans[ sval ] += before[ j ];
				}
			}
			System.arraycopy( ans, 0, before, 0, ans.length );
		}
		System.out.println( ans[ ary[ n - 1 ] ] );
    }    
}

Measured memory_bytes: 18188
#include <iostream>

using namespace std;

int main(){
	int n;
	int a=0,b=0,c=0,d=0;
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		string s;
		cin >> s;
		if(s=="AC")a++;
		else if(s=="WA")b++;
		else if(s=="TLE")c++;
		else d++;
	}

	printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n",a,b,c,d);
}

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

#define rep(i, a, b) for (int i = a; i <= b; i++)
#define per(i, a, b) for (int i = a; i >= b; i--)
#define dbg(x) cout << #x << ": " << x << endl;
#define gkd ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;

using namespace std;

const int N = 1e5 + 10;
int a[N];
map<int, int> cnt;

int main() {
    int n, k;
    cin >> n >> k;
    rep(i, 1, n) cin >> a[i];
    ll ans = 0, pre = 0;
    cnt[0] = 1;
    rep(i, 1, n) {
        pre += a[i];
        pre %= k;
        ans += cnt[pre];
        cnt[pre]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define ll long long
#define dbg(x) cout<<#x<<": "<<x<<endl;
#define N 300005
#define M 1000000007
#define pii pair<ll,ll>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
main()
{
     ll n,q;
     cin>>n;
     ll a[n];
     map<ll,ll>mp;
     ll sum=0;
     for(ll i=0;i<n;i++)
     {
         cin>>a[i];
         mp[a[i]]++;
         sum+=a[i];
     }
     cin>>q;
     while(q--)
     {
         ll b,c;
         cin>>b>>c;
         sum-=b*mp[b];

         mp[c]+=mp[b] ;
         sum+=c*mp[b];
         mp[b]=0;
         cout<<sum<<'\n';
     }

}


Measured memory_bytes: 10228
N, M = map(int, input().split())
Lmax = 0
Rmin = N
for i in range(M):
  L, R = map(int, input().split())
  Lmax = max(Lmax, L)
  Rmin = min(Rmin, R)
print(max(0, Rmin-Lmax+1))


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int a = x / 500;
        int a1 = x % 500;
        int b = a1 / 5;
        int h = a * 1000 + b * 5;
        System.out.println(h);

    }
}

Measured memory_bytes: 23764
#include <iostream>
using namespace std;
int main(void){
    int W,H,x,y,r;
    cin>>W>>H>>x>>y>>r;
    if(W<x||H<y||W<x+r||H<y+r||0>x||0>y||0>x-r||0>y-r){
        cout<<"No"<<endl;
    }
    else cout<<"Yes"<<endl;
}




Measured memory_bytes: 3096
# input = sys.stdin.readline
from bisect import *
from collections import *
from heapq import *
# import functools
# import itertools
# import math
N,K=map(int,input().split())
A=list(map(int,input().split()))
F=list(map(int,input().split()))
A.sort()
F.sort(reverse=True)
def main(x):
    _K=K
    for i in range(N):
        a=A[i]-x//F[i]
        if a>0:
            _K-=a
            if _K<0:
                return(0)
    return(1)


end=10**12
if main(0):
    print(0)
    exit()
else:
    st=0

while end-st>1:
    now=(end+st)//2
    if main(now):
        end=now
    else:
        st=now

if main(st):
    print(st)
else:
    print(end)


Measured memory_bytes: 119500
#include <iostream>

using namespace std;

void call(int n);

int main()
{ 
    int n;
  
    do {
        cin >> n;
    } while (n < 3 || n > 10000);

    call(n);

    return (0);
}

void call(int n)
{
     int i = 1;
     int x;

     while (++i <= n) {
            x = i;
 
            if (x % 3 == 0) {
                cout << " " << i;	                    
            } else { 
	        while (x != 0) {                
                       if (x % 10 == 3) {
                           cout << " " << i;
                           break;
                       }

                       x /= 10;
                }
            }
     }

     cout << endl;
}

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

#define watch(x) cerr << (#x) << ": " << (x) << endl

int32_t main() {

    int n; cin >> n;
    vector<int> v(n), c(n);
    for(int i = 0; i < n; ++i) cin >> v[i];
    for(int i = 0; i < n; ++i) cin >> c[i];

    int ans = 0;
    for(int i = 0; i < n; ++i) {
        ans += max(0, v[i]-c[i]);
    }

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


Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

using namespace std;
using ll = long long;
using ull = unsigned long long;

#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection)  (collection).begin(), (collection).end()		// begin to end
#define rep(i, begin, end) for (ll i = begin; i < end; i++)				// repeat
#define repr(i, begin, end) for (ll i = begin - 1; end <= i; i--)		// repeat reverse

#endif


class AGC034A
{
public:
	AGC034A()
	{
		cin >> n >> a >> b >> c >> d;
		a--; b--; c--; d--;
		cin >> s;
	}
	void Run(void)
	{
		if (Check())
			cout << "Yes";
		else
			cout << "No";
	}
private:
	bool Check(void)
	{
		bool ans = true;

		if (d < c && !Space3(b - 1, d))
			ans = false;

		if (Sharp2(a, c))
			ans = false;
		else if (Sharp2(b, d))
			ans = false;

		return ans;
	}
	/**
	@brief 3連続の空白マスを検索する関数
	@note
	 範囲[l,r)で空白マスが3つ連続していたらtrue, なければfalseを返す。
	**/
	bool Space3(ll l, ll r)
	{
		rep(i, l, r)
		{
			if (i + 2 >= (ll)s.size())
				break;

			if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.')
				return true;
		}

		return false;
	}
	/**
	@brief 2連続の#マスを検索する関数
	@note
	 範囲[l,r)で#マスが2連続していたらtrue, なければfalseを返す。
	**/
	bool Sharp2(ll l, ll r)
	{
		rep(i, l, r)
		{
			if (i + 1 >= (ll)s.size())
				break;

			if (s[i] == '#' && s[i + 1] == '#')
				return true;
		}
		return false;
	}
	ll n;
	ll a;
	ll b;
	ll c;
	ll d;
	string s;
};


int main(void)
{
	AGC034A agc034a;
	agc034a.Run();

	return 0;
}

Measured memory_bytes: 640
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

typedef long long ll;

char sl[(1<<20)+5];

int n, k;

string best = "x";

//~ pair<int,int> pre[1<<20][

void consider(string s) {
	reverse(s.begin(), s.end());
	if(best == "x" || s.length() > best.length() || (s.length() == best.length() && s < best))
		best = s;
}

void rec(const vector<int> & w, int S, string already) {
	if(S < k) return;
	consider(already);
	for(int bit : {0, 1}) {
		int s_here = 0;
		vector<int> w2(w.size() / 2);
		for(int L = 0; (1 << L) < (int) w.size(); ++L)
			for(int i = 0; i < (1 << L); ++i) {
				int times = w[(1<<L)+i];
				if(!times) continue;
				int len = L;
				int x = i;
				while(len > 0 && (x % 2 != bit)) {
					x /= 2;
					--len;
				}
				if(!len) continue;
				--len;
				x /= 2;
				debug() << imie(len);
				debug() << imie(1 << len) imie(x) imie(w2.size());
				w2[(1<<len)+x] += times;
				s_here += times;
			}
		already += '0' + bit;
		rec(w2, s_here, already);
		already.pop_back();
	}
}

int main() {
	scanf("%d%d", &n, &k);
	++n;
	vector<int> w(1 << (n + 1));
	//~ vector<pair<int,int>> w;
	int S = 0;
	for(int len = 0; len < n; ++len) {
		scanf("%s", sl);
		assert((int) strlen(sl) == (1 << len));
		for(int i = 0; i < (1 << len); ++i) if(sl[i] == '1') {
			++w[(1<<len)+i];
			++S;
		}
			//~ w.push_back({len, i});
	}
	debug() << imie(w.size());
	rec(w, S, "");
	cout << best << endl;
}


Measured memory_bytes: 36080