akhauriyash/Code-Regression huggingface dataset:
h,w=map(int,input().split())
lists=[]
for i in range(h):
    s=input()
    lists.append(s)
ylists=[]
for some in lists:
    some=some+"#"
    cnt=0
    add=[]
    for i in range(w+1):
        if some[i]=="#":
            if cnt==0:
                add.append(0)
                cnt=0
            else:
                add.extend([cnt]*cnt)
                add.append(0)
                cnt=0
                
        elif some[i]!="#":
            cnt+=1
    del add[-1]
    ylists.append(add)
    

            
lists1=[]
for i in range(w):
    adds=""
    for j in range(h):
        adds+=lists[j][i]
    lists1.append(adds)
    
tlists=[]
for some in lists1:
    some=some+"#"
    cnt=0
    add=[]
    for i in range(h+1):
        if some[i]=="#":
            if cnt==0:
                add.append(0)
                cnt=0
            else:
                add.extend([cnt]*cnt)
                add.append(0)
                cnt=0
                
        elif some[i]!="#":
            cnt+=1
    del add[-1]
    tlists.append(add)


maximum=0
for i in range(h):
    for j in range(w):
        if ylists[i][j]==0 or tlists[j][i]==0:
            continue
        else:
            maximum=max(maximum,ylists[i][j]+tlists[j][i]-1)
print(maximum)    


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

typedef long long ll;

ll tab[200010];
map<ll,ll> frek;

ll cei(ll x,ll n)
{
	return (x>=0 ? (x/n)+(x%n!=0) : (x/n)-(x%n!=0));
}

int main()
{
//	freopen("input.txt","r",stdin);
	ll n;
	cin>>n;
	ll sum=0ll;
	for (ll i=1;i<=n;i++)
	{
		ll a;
		cin>>a;
		tab[i]=a-i;
		sum+=tab[i];
		frek[tab[i]]++;
	}
	ll modus=-1e18;
	ll now=0ll;
	ll moduss=1e18;
	ll noww=0ll;
	for (int i=1;i<=n;i++)
	{
		if (frek[tab[i]]>now)
		{
			modus=tab[i];
			now=frek[tab[i]];
		}
		else
		if (frek[tab[i]]==now && tab[i]>modus)
		{
			modus=tab[i];
			now=frek[tab[i]];
		}
		if (frek[tab[i]]>noww)
		{
			moduss=tab[i];
			noww=frek[tab[i]];
		}
		else
		if (frek[tab[i]]==noww && tab[i]<moduss)
		{
			moduss=tab[i];
			noww=frek[tab[i]];
		}
	}
	ll bawah=sum/n;
	ll atas=bawah+1;
	ll satunya=bawah-1;
	ll ans;
	ll satu=0ll;
	ll dua=0ll;
	ll tiga=0ll;
	ll testes=0ll;
	ll wtf=0ll;
	for (int i=1;i<=n;i++)
	{
		satu+=llabs(tab[i]-bawah);
		dua+=llabs(tab[i]-atas);
		tiga+=llabs(tab[i]-satunya);
		testes+=llabs(tab[i]-modus);
		wtf+=llabs(tab[i]-moduss);
	}
//	cout<<satu<<" "<<dua<<" "<<tiga<<" "<<testes<<" "<<wtf<<"\n";
	ans=min(min(satu,dua),min(tiga,testes));
	ans=min(ans,wtf);
	ll tengah1,tengah2;
	sort(tab+1,tab+n+1);
	if (n%2==0)
	{
		tengah1=tab[n/2];
		tengah2=tab[(n/2)+1];
	}
	else
	{
		tengah1=tab[(n/2)+1];
		tengah2=tengah1;
	}
	ll asu1=0ll,asu2=0ll;
	for (int i=1;i<=n;i++)
	{
		asu1+=llabs(tab[i]-tengah1);
		asu2+=llabs(tab[i]-tengah2);
	}
	ans=min(ans,min(asu1,asu2));
	cout<<ans<<"\n";
}

Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n; cin>>n;
    int f; cin>>f;
    int jud=0,sum=0;
    for(int i=1;i<n;i++){
        int nw; cin>>nw;
        if(jud>0){
            if(nw<f){
                jud=0;
                sum++;
            }
        }
        else if(jud<0){
            if(nw>f){
                jud=0;
                sum++;
            }
        }
        else
            jud=nw-f;
        f=nw;
    }
    cout<<sum+1;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <algorithm>
#include <functional>

using namespace std;

#define rep(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define each(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)

bool rev(int a, int b){ return a > b; }

int main(){
  int i, in[10];

  rep(i,10) cin >> in[i];
  sort(in, in+10, rev);
  rep(i,3) cout << in[i] << endl;

  return 0;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
#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() {
  ll n, x, m;
  cin >> n >> x >> m;
  vector<int> id(m,-1);
  vector<int> a;
  int len = 0;
  ll tot = 0;
  while (id[x] == -1) {
    a.push_back(x);
    id[x] = len;
    len++;
    tot += x;
    x = (x*x)%m;
  }

  int c = len-id[x];
  ll s = 0;
  for (int i = id[x]; i < len; ++i) s += a[i];

  ll ans = 0;
  if (n <= len) {
    rep(i,n) ans += a[i];
  } else {
    ans += tot;
    n -= len;
    ans += s*(n/c);
    n %= c;
    rep(i,n) ans += a[id[x]+i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3960
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i=0; i<N; i++){
    cin >> a.at(i);
  }
  
  int instance;
  for (int i=0; i<N; i++){
    for (int j=i+1; j<N; j++){
      if (a.at(i) < a.at(j)){
        instance = a.at(i);
        a.at(i) = a.at(j);
        a.at(j) = instance;
      }
    }
  }
  int ans=0, flag=0;
  for (int i=0; i<N; i++){
    ans = flag==0 ? ans+a.at(i) : ans-a.at(i);
    flag = flag==0 ? 1 : 0;
  }
  cout << ans;
}

Measured memory_bytes: 3504
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <algorithm>
#include <set>

#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)
typedef long long ll;

using namespace std;

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

int main(){
    int N, X;
    cin >> N >> X;
    int prev = X;
    ll ans;
    rep(i, N){
        int x;
        cin >> x;
        if(i != 0){
            ans = gcd(ans, abs(x - prev));
        }else{
            ans = abs(x - prev);
        }
        prev = x;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int fib(int);

int dp[50];

int main(){
  int i,n;

  for(i=0; i<50; i++) dp[i]=-1;

  scanf("%d",&n);

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

  return 0;
}

int fib(int n){
  if (n==1 || n==0) return dp[n]=1;
  if (dp[n]!=-1) return dp[n];
  return dp[n]=fib(n-1) + fib(n-2);
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); ++i)
#define REPR(i, n) for (int i = static_cast<int>(n) - 1; i >= 0; --i)
#define FOR(i, a, b) \
  for (int i = static_cast<int>(a); i < static_cast<int>(b); ++i)
#define FORR(i, a, b) \
  for (int i = static_cast<int>(b) - 1; i >= static_cast<int>(a); --i)
#define ALL(f, x, ...) \
  ([&](auto& y) { return (f)(begin(y), end(y), ##__VA_ARGS__); })(x)
auto INDEX = [](auto& x, auto& xs) { return &x - &xs[0]; };
void async_io() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}
const auto inf = INT_MAX / 3;
const auto pi = 2 * std::acos(0.0);
const auto eps = 1e-14;
using ll = signed long long;
using ull = unsigned long long;

signed main() {
  async_io();
  int n;
  while (true) {
    cin >> n;
    if (n == 0) return 0;
    auto sum = 0;
    for (int i = 2;; i++) {
      auto base = i * (i + 1) / 2;
      if (base > n) break;
      if ((base - n) % i == 0) sum++;
    }
    cout << sum << "\n";
  }
}

Measured memory_bytes: 3148
//use itertools::Itertools;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

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)*}};}
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)*}};}
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, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        n: usize,
        m: usize,
        edge: [(usize1,usize1);m]
    }

    let mut tree = vec![vec![]; n];
    for (e, &(from, to)) in edge.iter().enumerate() {
        tree[from].push((to, e));
        tree[to].push((from, e));
    }

    //println!("{:?}", tree);

    let mut shirube = vec![0; n];

    let mut q: VecDeque<(usize, usize)> = VecDeque::new();
    q.push_back((0, MAX - 1));
    while q.len() > 0 {
        let (target, parent) = q.pop_front().unwrap();
        if shirube[target] > 0 {
            continue;
        }
        shirube[target] = parent + 1;

        for &(v, e) in &tree[target] {
            if shirube[v] > 0 {
                continue;
            }

            q.push_back((v, target));
        }
    }

    println!("Yes");

    for i in 1..n {
        println!("{}", shirube[i]);
    }
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 19060
def input_from_console():
    r, g, b, n = map(int, input().split())

    return r, g, b, n


def main():
    r, g, b, n = input_from_console()
    counter = 0
    r, g, b = sorted([r, g, b], reverse=True)
    for i1 in reversed(range(int(n / r) + 1)):
        n1 = n - r * i1
        for i2 in reversed(range(int(n1 / g) + 1)):
            n2 = n1 - g * i2
            if n2 % b == 0:
                counter += 1
    print(counter)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
N,K=gets.split.map(&:to_i)
A=[0]+gets.split.map(&:to_i)

d=[]
v=A[1]
i=1
until d[v]
  if i==K
    p v
    exit
  end
  d[v]=i
  i+=1
  v=A[v]
end
k=K-i
k%=i-d[v]
k.times do v=A[v] end
p v


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

using namespace std;
#define taskname "A"
#define pb	push_back
#define mp 	make_pair

typedef long double ld;
typedef long long ll;
typedef pair<int,int> ii;
const int maxn = 2e5 + 5;
int n, m;
ll k;
ll a[maxn],b[maxn];
vector<int> val;
vector<int> operator * (vector<int> a , vector<int> b){
    vector<int> res(n);
    for(int i = 0 ; i < n ; ++i){
        res[i] = a[b[i]];
    }
    return res;
}
vector<int> P(ll k){
    if(k == 1)return val;
    auto res = P(k / 2);
    if(k & 1)return res * res * val;
    else return res * res;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen(taskname".INP","r")){
		freopen(taskname".INP", "r",stdin);
		freopen(taskname".OUT", "w",stdout);
    }
    cin >> n;for(int i = 0 ; i < n ; ++i)cin >> a[i];
    val.resize(n);iota(val.begin(),val.end(),0);
    cin >> m >> k;
    while(m--){
        int a;cin >> a;--a;
        swap(val[a],val[a + 1]);
    }
    val = P(k);
    b[0] = a[0];
    for(int i = 1 ; i < n ; ++i){
        b[i] = b[i - 1] + (a[val[i]] - a[val[i] - 1]);
    }
    for(int i = 0 ; i < n ; ++i)cout << b[i] << '\n';
}


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

template <typename T>
inline T read(){
    T x=0,f=1;char c=getchar();
    while(!isdigit(c)){ if(c=='-') f=-f;c=getchar();}
    while(isdigit(c)){x=(x<<3)+(x<<1)+(c-48);c=getchar();}
    return x*f;
}

#define lint long long int
#define ulint unsigned lint
#define readint read<int>()
#define readlint read<lint>()
const lint inf=1e18+1e7,MAXN=1e5+1e1;

lint a[MAXN],b[MAXN];
lint n,ans=inf;

void Solve1(){
    lint res=0,now=0;
    for(int i=1;i<=n;i++) b[i]=a[i];
    for(int i=1;i<=n;i++){
        if((i&1) && b[i]+now<=0){
            b[i]+=now,res+=(1-b[i]),now+=(1-b[i]);
        }
        if(!(i&1) && b[i]+now>=0){
            b[i]+=now,res+=(b[i]+1),now-=(b[i]+1);
        }
    }
    ans=min(ans,res);
    return;
}

void Solve2(){
    lint res=0,now=0;
    for(int i=1;i<=n;i++) b[i]=a[i];
    for(int i=1;i<=n;i++){
        if((i&1) && b[i]+now>=0){
            b[i]+=now,res+=(b[i]+1),now-=(b[i]+1);
        }
        if(!(i&1) && b[i]+now<=0){
            b[i]+=now,res+=(1-b[i]),now+=(1-b[i]);
        }
    }
    ans=min(ans,res);
    return;
}

int main(void){

    // freopen("testdata.in","r",stdin);
    // freopen("testdata.out","w",stdout);

    scanf("%lld",&n);
    for(int i=1;i<=n;i++) a[i]=readlint;
    for(int i=1;i<=n;i++) a[i]+=a[i-1];
    Solve1(),Solve2();
    printf("%lld\n",ans);

    return 0;
}

Measured memory_bytes: 5324
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
#include <fstream>
#include <functional>
#define endl '\n'
#define ll long long
#define mod 1000000007
#define NCONS 1000000000
//#define NCONS 100001
//#define NCONS 1001
//#define NCONS 101
#define MCONS 2001
#define LIMIT 1000000000
#define TRUE 1
#define FALSE 0
#define toRadian(degree) ((degree) * (M_PI / 180.))
#define toDegree(radian) ((radian) * (180. / M_PI))
using namespace std;
struct Point{int x; int y;};
struct PPoint{Point x; Point y;};
inline ll gcd(ll a, ll b) { if(a < b) swap(a, b); if(b <= 0) return a; return gcd(b, a % b); }

struct El{int B; int C;};

int N, M;
vector<ll> A;
vector<El> vec;
ll ret;

int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    cin >> N >> M;
    for(int i = 0; i < N; i++)
    {
        ll a; cin >> a; A.push_back(a);
    }
    sort(A.begin(), A.end(), greater<ll>());
    
    while(M--)
    {
        int b, c; cin >> b >> c; vec.push_back(El{b, c});
    }
    
    sort(vec.begin(), vec.end(), [](El a, El b) { return a.C < b.C; });
    
    while(!vec.empty())
    {
        auto cur_vec = vec.back(); vec.pop_back();
        int times = cur_vec.B;
        while(!A.empty() && times--)
        {
            auto a = A.back(); A.pop_back();
            ret += max(a, (ll)cur_vec.C);
        }
        
    }
    
    while(!A.empty())
    {
        auto a = A.back(); A.pop_back();
        ret += a;
    }
    
    
    cout << ret << endl;
    return 0;
}


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

# define F first
# define S second
# define mp make_pair
// everything go according to my plan
# define pb push_back
# define sz(a) (int)(a.size())
# define vec vector
// shimkenttin kyzdary, dzyn, dzyn, dzyn...
# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right

using namespace std;

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

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const ll MXLL = 4e18;
const int Sz = 1110111;
// a pinch of soul
inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm ("rdtsc" : "=A"(seed));
  srand (seed);
}
void files (string problem) {
  if (fopen ((problem + ".in").c_str(),"r")) {
    freopen ((problem + ".in").c_str(),"r",stdin);
    freopen ((problem + ".out").c_str(),"w",stdout);
  }
}
void localInput (string in = "s") {
  if (fopen (in.c_str(), "r"))
    freopen (in.c_str(), "r", stdin);
  else
    cerr << "Input file not found" << endl;
}
const int N = 5e4 + 1;

int dp[N];

int n, m; 

int main()
{                
  cin >> n >> m;            
  fill (dp + 1, dp + n + 1, MX);
          
  for (int i = 1; i <= m; i++) {
  	int x; cin >> x;
  	for (int j = 0; j + x <= n; j++)
  		dp[j + x] = min (dp[j + x], dp[j] + 1);
  }        
  cout << dp[n];


  cout << endl;

  return 0;
}










// Coded by Z..



Measured memory_bytes: 3284
package main

import (
	"fmt"
)

const mod = 1e9 + 7

var s []int

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	s = make([]int, n+2)
	for i := 1; i < n+2; i++ {
		s[i] = s[i-1] + i - 1
		s[i] %= mod
		if s[i] < 0 {
			s[i] += mod
		}
	}
	var ans int
	for i := k; i <= n+1; i++ {
		a := sum(n-i+1, n) - sum(0, i-1) + 1
		a %= mod
		if a < 0 {
			a += mod
		}
		ans += a
		ans %= mod
	}
	fmt.Println(ans)
}

func sum(a, b int) int {
	r := s[b+1] - s[a]
	r %= mod
	if r < 0 {
		r += mod
	}
	return r
}


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

const string YES = "Yes";
const string NO = "No";
int main(){
  string S; cin >> S;
  if (S == "AAA"|| S=="BBB")cout << NO << endl;
  else cout << YES << endl;
}


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

int main(){

  int N;
  long sum=0;
  cin >> N;

  vector<int> vec(N*3);
  for (int i=0; i<N*3; i++){
    cin >> vec.at(i);
  }

  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());

  for (int i=0; i<N; i++){
    vec.pop_back();
  }

  reverse(vec.begin(),vec.end());

  for (int i=0; i<2*N; i+=2){
    sum += vec.at(i);
  }

  cout << sum << endl;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long h,i=1,count=0;
  cin>>h;
  while(h>1)
  {
   
    for(int j=0;j<i;j++)
    count++;
   
    i*=2;
     h/=2;
  } 
  cout<<count+i;
  
}

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

#define REP(i,s,n) for(int (i)=s; (i)<(int)(n);(i)++)
#define RIT(it,c) for(__typeof(c.begin()) it = c.begin();it!=c.end();it++)
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int)(x).size()
#define MSET(m,v) memset(m,v,sizeof(m))


using namespace std;


typedef long long LL;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<LL> vL;
typedef vector<bool> vb;
typedef pair<int,vi> iv;
typedef pair<LL,LL> pLL; 
typedef long double LD;


int main(){
	int N;
	cin>>N;
	map<int,vi> cnt;
	for(int i=1;i<=N;++i){
		int A;
		cin>>A;
		cnt[-A].push_back(i);
	}
	vi v;
	for(auto p:cnt){
		if((int)p.second.size()>=2) v.push_back(-p.first);
		if((int)v.size()>=2){
			cout<< (LL)v[0]*v[1]<<endl;
			return 0;
		}
		if((int)p.second.size()>=4){
			cout<<(LL)p.first*p.first<<endl;
			return 0;
		}
	}
	cout<<0<<endl;
	return 0;
}


Measured memory_bytes: 11136
s  = input()

if s == "SUN":
    print(7)
elif s == "MON":
    print(6)
elif s== "TUE":
    print(5)
elif s == "WED":
    print(4)
elif s == "THU":
    print(3)
elif s == "FRI":
    print(2)
elif s == "SAT":
    print(1)

Measured memory_bytes: 3060
#include <stdio.h>

const int N = 1e5 + 10;

int n, a[N << 1], b[N << 1];

inline bool check(int x) {
	for (int i = 1; i < n << 1; ++ i) 
		b[i] = a[i] <= x;
	if (b[n - 1] == b[n] || b[n + 1] == b[n])
		return b[n];
	for (int i = 1; i < n - 1; ++ i) {
		if(b[n - i] == b[n - i - 1]) return b[n - i];
		if(b[n + i] == b[n + i + 1]) return b[n + i];
	}
	return b[1];
}

int main() {
	//freopen("pyramid.in", "r", stdin);
	//freopen("pyramid.out", "w", stdout);

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

	int l = 1, r = (n << 1) - 1, ans; 
	while (l <= r) {
		int mid = (l + r) >> 1;
		if (check(mid)) ans = mid, r = mid - 1;
		else l = mid + 1; 
	}
	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
//#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n, maxNum = 10000000,count=0;
    //vector<int>v1;
    cin>>n;
    for (int i = 0; i < n; i++)
    {
        int x;
        cin>>x;

        if (x<=maxNum)
        {
            count++;
        }
        maxNum = min(x,maxNum);
        

    }

    cout<<count<<endl;
    
}

Measured memory_bytes: 256
#include <ctime>
#include <iomanip>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdio>
#include <list>
#include <queue>
using namespace std;

#define int long long
#define INF 1e18
#define EPS 1e-9

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

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

signed main() {
    int n, w; cin >> n >> w;
    vector<vector<int>> wv(n, vector<int> (2));
    for(int i = 0; i < n; i++) for(int j = 0; j < 2; j++) cin >> wv[i][j];
    vector<vector<int>> dp(n + 1, vector<int> (w + 1, 0));

    for(int i = 0; i < n; i++) {
        for(int j = 0; j <= w; j++) {
            if(j - wv[i][0] >= 0) {
                chmax(dp[i + 1][j], dp[i][j - wv[i][0]] + wv[i][1]);
            }
            chmax(dp[i + 1][j], dp[i][j]);
        }
    }

    cout << dp[n][w] << endl;
}


Measured memory_bytes: 80256
n = int(input())
l = []

def func():
    pass

for i in range(n):
  if (i+1) % 3 == 0 and (i+1) % 5 == 0:
    pass
  elif (i+1) % 3 == 0:
    pass
  elif (i+1) % 5 == 0:
    pass
  else:
    l.append(i+1)
print(sum(l))

Measured memory_bytes: 30076
MAX = 100000


def parent(i):
    return i//2


def left(i):
    return 2*i


def right(i):
    return 2*i+1


def main():
    global H
    H = int(input())
    A = [0] * (MAX+1)

    v_s = input().split(' ')

    for i in range(H):
        A[i+1] = int(v_s[i])

    for i in range(1, H+1):
        s = 'node {}: key = {},'.format(i, A[i])
        if parent(i) >= 1:
            s += ' parent key = {},'.format(A[parent(i)])
        if left(i) <= H:
            s += ' left key = {},'.format(A[left(i)])
        if right(i) <= H:
            s += ' right key = {},'.format(A[right(i)])
        print(s + ' ')


if __name__ == '__main__':
    main()



Measured memory_bytes: 6400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e9;
const static ll MOD = 1e9+7;



 
int main(){
    ll N, A, B; cin >> N >> A >> B;
    if(A > B){cout << 0 << endl; return 0;}
    if(N == 1 && A != B) { cout << 0 << endl; return 0;}
    cout << B*(N-2) - A*(N-2) + 1 << endl;
}


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

int main()
{
    int bit[64];

    for( int i = 0; i < 64; i++ )
        bit[i] = 0;

    int n;
    cin >> n;

    vector<int> mask[n];

    for( int i = 0; i < n; i++ )
    {
        int j, b;
        cin >> j;
        for( int k = 0; k < j; k++ )
        {
            cin >> b;
            mask[i].push_back( b );
        }
    }

    int q, query, m, cnt;
    bool judge;

    cin >> q;

    while( q-- )
    {
        cin >> query >> m;

        switch( query )
        {
            case 0:
                if( bit[m] == 0 )
                    cout << 0 << endl;
                else
                    cout << 1 << endl;
                break;
            case 1:
                for( int i = 0; i < mask[m].size(); i++ )
                    bit[mask[m][i]] = 1;
                break;
            case 2:
                for( int i = 0; i < mask[m].size(); i++ )
                    bit[mask[m][i]] = 0;
                break;
            case 3:
                for( int i = 0; i < mask[m].size(); i++ )
                {
                    if( bit[mask[m][i]] == 0 )
                        bit[mask[m][i]] = 1;
                    else
                        bit[mask[m][i]] = 0;
                }
                break;
            case 4:
                judge = true;
                for( int i = 0; i < mask[m].size(); i++ )
                    if( bit[mask[m][i]] == 0 )
                        judge = false;
                cout << judge << endl;
                break;
            case 5:
                judge = false;
                for( int i = 0; i < mask[m].size(); i++ )
                    if( bit[mask[m][i]] == 1 )
                        judge = true;
                cout << judge << endl;
                break;
            case 6:
                judge = true;
                for( int i = 0; i < mask[m].size(); i++ )
                    if( bit[mask[m][i]] == 1 )
                        judge = false;
                cout << judge << endl;
                break;
            case 7:
                cnt = 0;
                for( int i = 0; i < mask[m].size(); i++ )
                    if( bit[mask[m][i]] == 1 )
                        cnt++;
                cout << cnt << endl;
                break;
            case 8:
                unsigned long long sum = 0;
                unsigned long long z = 1;
                unsigned long long val[64];
                for( int i = 0; i < 64; i++ )
                {
                    val[i] = z;
                    z *= 2;
                }
                for( int i = 0; i < mask[m].size(); i++ )
                    if( bit[mask[m][i]] == 1 )
                        sum += val[mask[m][i]];
                cout << sum << endl;
                break;
        }
    }
    return 0;
}


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

vector<long long> enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) res.push_back(N/i);
        }
    }
    // 小さい順に並び替える
    sort(res.begin(), res.end());
    return res;
}


int main(){
    int N; cin >> N;
    const auto &res = enum_divisors(N);
    
    for (int i = 0; i < res.size(); ++i){
        for(int a=0;a<sqrt(N);++a){
            if(pow(a,5) - pow(a-res[i],5) == N){
            cout << a << ' ' << a-res[i] << endl;
            return 0;
        }
        if(pow(a,5) - pow(res[i]-a,5) == N){
            cout << a << ' ' << res[i]-a << endl;
            return 0;
        }

        }
        
    }
    return 0;
}

Measured memory_bytes: 4124
public class Main {
  private static void solve() {
    int d = ni();
    int n = ni();

    int cnt2 = 0;
    for (int i = 1; ;i ++) {
      int cnt = 0;
      int x = i;
      while (x % 100 == 0) {
        x /= 100;
        cnt ++;
      }
      if (cnt == d) {
        cnt2 ++;
        if (cnt2 == n) {
          System.out.println(i);
          return;
        }
      }
    }
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

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

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}




Measured memory_bytes: 23248
#include<stdio.h>

int IsPrime(int);
main(){
  int N[10000],n,i,a,count;
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%d",&N[i]);
  }
  
  count = 0;
  
  for(i=0;i<n;i++){
    a = IsPrime(N[i]);
    if(a == 1) count++;
  }
  
  printf("%d\n",count);
  
  return 0;
}

  int IsPrime(int x){
    int i;
    
    if(x<2) return 0;
    
    else if(x == 2) return 1;
    
    if(x%2 == 0) return 0;
    
    for(i = 3;i <= x / i;i += 2){
      
      if(x % i == 0) return 0;
      
    }
    return 1;
  }

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 0
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

int N;
int A[MAX_N] = {};
bool isChecked[MAX_N] = {};

signed main()
{
    cin >> N;
    REP(i, N) {
        cin >> A[i];
        A[i]--;
    }
    int cnt = 0;
    REP(i, N) {
        if(isChecked[i]) { continue; }
        if(i == A[A[i]]) {
            cnt++;
            isChecked[A[i]] = true;
        }
        isChecked[i];
    }
    printf("%lld\n", cnt);

    return 0;
}


Measured memory_bytes: 1152
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[] for _ in range(num)]
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

C = str(input())

print(chr(ord(C)+1))

Measured memory_bytes: 38384
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define MOD (ll)(998244353)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
ll gcd(ll a,ll b){if(!b)return a;else return gcd(b,a%b);}
const int MAXN = 4e5+5;
vector<ll>t(4*MAXN,1);
vector<ll>s(4*MAXN,0);
vector<ll>powah(4*MAXN);
vector<ll>L(4*MAXN,-1),R(4*MAXN,-1);
ll n;
void build(int v,int tl,int tr){
	L[v] = tl;
	R[v] = tr;
	if(tl == tr){
		t[v] = powah[tl];
		return;
	}
	int tm = (tl+tr)/2;
	build(2*v,tl,tm);
	build(2*v+1,tm+1,tr);
	t[v] = (t[2*v]+t[2*v+1])%MOD;
}
void pushdown(int v){
	if(s[v]){
	  s[2*v] = s[v];
	  s[2*v+1] = s[v];
	  if(2*v <= 4*n && L[2*v] != -1){
		  ll add1 = (powah[L[2*v]] - powah[R[2*v]+1]+MOD)%MOD;
		  t[2*v] = (s[2*v]*add1)%MOD;
      }
      if(2*v+1 <= 4*n && L[2*v+1] != -1){
		  ll add2 = (powah[L[2*v+1]] - powah[R[2*v+1]+1]+MOD)%MOD;
		  t[2*v+1] = (s[2*v+1]*add2)%MOD;
      }
      s[v] = 0;
    }
}
void upd(int v,int l,int r,int tl,int tr,ll d){
    if(l > r)return;
    if(tl == l && r == tr){
		ll add = (powah[L[v]] - powah[R[v]+1]+MOD)%MOD;
		t[v] = d*add%MOD;
		s[v] = d;
		return;
	}
	pushdown(v);
	int tm = (tl+tr)/2;
	upd(2*v,l,min(tm,r),tl,tm,d);
	upd(2*v+1,max(tm+1,l),r,tm+1,tr,d);
	t[v] = (t[2*v]+t[2*v+1])%MOD;
}
int main()
{
	owo
	int q;
	cin>>n>>q;
	powah[n] = 1;
	for(int i=n-1;i>0;i--){
		powah[i] = powah[i+1]*10;
		powah[i]%=MOD;
	}
	build(1,1,n);
	for(int i=n;i>0;i--){
		powah[i]+=powah[i+1];
		powah[i]%=MOD;
	}
	//cout<<t[1]<<'\n';
	while(q--){
		int l,r,d;
		cin>>l>>r>>d;
		upd(1,l,r,1,n,d);
		cout<<t[1]%MOD<<'\n';
	}
}



Measured memory_bytes: 65640
# D - Maze Master
from collections import deque


def bfs(start: int):
    queue = deque([start])
    dist = [0] * (H * W)
    dist[start] = 1
    while queue:
        x = queue.popleft()
        for nx in (x + 1, x - 1, x + W, x - W):
            if maze[nx] == "." and not dist[nx]:
                dist[nx] = dist[x] + 1
                queue.append(nx)
    return max(dist) - 1


def main():
    global H, W, maze
    H, W = map(int, input().split())
    H, W = H + 2, W + 2
    maze = "#" * W
    for _ in range(H - 2):
        maze += "#" + input().rstrip() + "#"
    maze += "#" * W
    ans = max(bfs(i) for i, c in enumerate(maze) if c == ".")
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3316
def check(k, W, p):
    s = 0
    count = 1
    for w in W:
        if s + w > p:
            count += 1
            s = 0
        s += w
    return count <= k

n, k = map(int, input().split())
W = [int(input()) for _ in range(n)]

right = sum(W)
left = max(right // k, max(W)) - 1
while right - left > 1:
    p = (left + right) // 2
    if check(k, W, p):
        right = p
    else:
        left = p
print(right)


Measured memory_bytes: 9560
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>
#include <string>

#define INF 99999999
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

using namespace std;

int main(void){
    int64_t a,b,x;
    cin >> a >> b >> x;
    
    int64_t c,d;
    
    c = a / x + (a%x==0?0:1);
    d = b / x;
    
    cout << (d-c+1) << endl;
    
    return 0;
}


Measured memory_bytes: 256
import math
import numpy
A, B, H, M = map(int,input().split())

#tannsinn
s = 6 * M

#長針の進む角
l = 30 * H + 0.5 * M


theta = max(s,l)-min(s,l)
kakudo = min(360-theta, theta)


ansans = B**2 + A**2 - (2 * B * A * math.cos(math.radians(kakudo)))

ans = math.sqrt(ansans)

print(ans)

Measured memory_bytes: 27204
from collections import Counter
from sys import exit, stdin
N = int(stdin.readline().rstrip())
A = [int(_) for _ in stdin.readline().rstrip().split()]
CA = Counter(A)
d = dict()
for k, v in CA.items():
    d[k] = v*(v-1)/2
ans = sum(d.values())
for i in range(N):
    v, a = CA[A[i]], A[i]
    print(int(ans - d[a] + (v-1)*(v-2)/2))

Measured memory_bytes: 91344
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
ll Ceil(ll x, ll y){
   return (x+y-1)/y;
}
int main() {
   cin.tie(nullptr); ios::sync_with_stdio(false);
   int t; cin >> t;

   while(t--){
      ll n, a, b, c, d, ans = 0;
      cin >> n >> a >> b >> c >> d;
      map<ll,ll> abc;
      abc[2] = a;abc[3] = b;abc[5] = c;
      ll x = 1;
      map<ll,ll> m;
      rep(i,61){
         ll xi = x;
         rep(j,41){
            ll xj = xi;
               rep(k,31){
                  if (n/xj > INT_MAX){
                     m[Ceil(n,xj)] = INT64_MAX;
                     m[n/xj] = INT64_MAX;
                     xj *= 5;
                     continue;
                  }
                  m[Ceil(n,xj)] = d * Ceil(n,xj);
                  m[n/xj] = d * (n/xj);
                  xj *= 5;
               }
            xi *= 3;
            }
         x *= 2;
      }
      for (auto &&i : m){
         for (ll j : {2,3,5}){
            i.second = min(i.second, abs(i.first-j*(i.first/j))*d + abc[j] + m[i.first/j]);
            i.second = min(i.second, abs(i.first-j*Ceil(i.first,j))*d + abc[j] + m[Ceil(i.first,j)]);
         }
      }
      cout << m[n] << endl;
   }
}

Measured memory_bytes: 4460
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define mid ((l+r)>>1)
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
using namespace std;
template<class T>il read(T &x){
	int f=1;char k=getchar();x=0;
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=x*10+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x>=10) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
ll mul(ll a,ll b,ll mod){long double c=1.;return (a*b-(ll)(c*a*b/mod)*mod)%mod;}
it qpow(int x,int k,int mod){
	int res=1,bas=x;
	while(k){
		if(k&1) res=1ll*res*bas%mod;
		bas=1ll*bas*bas%mod,k>>=1;
	}
	return res;
}
int n,k;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(n),read(k);
	if(n==1){
		if(k==0) printf("0 0 1 1");
		else printf("-1");
		return 0;
	}
	int S=(1<<n)-1;
	if(k>S) return puts("-1"),0;
	for(ri i=0;i<=S;++i) if(i^k) printf("%d ",i);
	printf("%d ",k);
	for(ri i=S;i>=0;--i) if(i^k) printf("%d ",i);
	printf("%d ",k);
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    while(1){
        C-=B;
        if(C<=0){
            cout << "Yes";
            break;
        }
        A-=D;
        if(A<=0){
            cout << "No";
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3624
#include <stdio.h>
int main(){
  int i ,go=0 ,cho=0 ,pa=0 ,pattern[5];
  while( scanf( "%d" ,&pattern[0] ) ){
    if( pattern[0] == 0 ){
      break;
    }

    if( pattern[0] == 1 ){
      go++;
    }
    
    else if( pattern[0] == 2 ){
      cho++;
    }
    
    else if( pattern[0] == 3 ){
      pa++;
    }
    
    for( i=1 ; i<=4 ; i++ ){
      scanf( "%d" ,&pattern[i] );
      if( pattern[i] == 1 ){
	go++;
      }
      
      else if( pattern[i] == 2 ){
	cho++;
      }
      
      else if( pattern[i] == 3 ){
	pa++;
      }
    }
    
    
    if( go != 0 && cho != 0 && pa != 0 ){
      for( i=0 ; i<5 ; i++ ){
	pattern[i] = 3;
      }
    }

    else if( cho != 0 && pa != 0 ){
      for( i=0 ; i<5 ; i++ ){
	if( pattern[i] == 2 ){
	  pattern[i] = 1;
	}
	else{
	  pattern[i] = 2;
	}
      }
    }

    else if( pa != 0 && go != 0 ){
      for( i=0 ; i<5 ; i++ ){
	if( pattern[i] == 3 ){
	  pattern[i] = 1;
	}
	else{
	  pattern[i] = 2;
	}
      }
    }

    else if( go == 5 || cho == 5 || pa == 5 ){
      for( i=0 ; i<5 ; i++ ){
	pattern[i] = 3;
      }
    }

    for( i=0 ; i<5 ; i++ ){
      printf( "%d\n" ,pattern[i] );
    }
    go = 0;
    cho = 0;
    pa = 0;
  }

  return 0;
}

Measured memory_bytes: 600
n=int(input())
L_lst=sorted(list(map(int,input().split())))
cnt=0
for j in range(n-1,1,-1):
    i=j-1
    x=0
    while x<i:
        if L_lst[i]+L_lst[x]>L_lst[j]:
            cnt+=i-x
            i-=1
        else:
            x+=1
print(cnt)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5;
int a[N];
ll ans;
int n;
int main(){
    ios::sync_with_stdio(false);
    cin>>n;
    for (int i=1;i<=n;i++)
        cin>>a[i],ans+=abs(a[i]-a[i-1]);
    ans+=abs(a[n]);
    for (int i=1;i<=n;i++)
        cout<<ans-abs(a[i]-a[i-1])-abs(a[i]-a[i+1])+abs(a[i-1]-a[i+1])<<endl;
    return 0;
}

Measured memory_bytes: 1664
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
  int A,B;
  cin >> A >> B;
  cout << max(0,A-2*B) << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#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>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#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>
#endif

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)

typedef long long ll;

const int Inf = 100100100;
const double EPS = 1e-9;

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

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;  cin >> n;
    int ans = 0;
    if (n % 2 == 0) n--;
    while (n > 0) {
      int count = 0;
      FOR(i, 1, n + 1) {
        if (n % i == 0) {
          count++;
        }
      }
      if (count == 8) ans++;
      n -= 2;
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int c[26];
string s;
int main()
{
    // your code goes here
    cin>>s;
    for(int i=0;i<s.size();++i)
        c[s[i]-'a']++;
    for(int i=0;i<26;++i)
    {
        if(c[i]%2!=0)
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
   int a, i;
   double A, s;
   while(scanf("%lf", &A) != EOF){
   s = A;
   for(i = 2; i < 11; i++){
      if(i % 2 == 1){
         A = A / 3;
         s = s + A;
      }else if(i % 2 == 0){
         A = A * 2;
         s = s + A;
      }
   }
   printf("%.8f\n", s);
   }
   return 0;
}
  

Measured memory_bytes: 1852
#include<bits/stdc++.h>
using namespace std;
int main() {
    int a,b;cin>>a>>b;
    if(a>1&&b>1&&a>b||a==1&&b>1)cout<<"Alice"<<endl;
    else if(a>1&&b>1&&b>a||b==1&&a>1)cout<<"Bob"<<endl;
    else if(a==b)cout<<"Draw"<<endl;
}

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

signed main(void){
    int n,m,a,b,c;
    cin>>n>>m;
    int ans=0;
    if(n-m*2>0)
    ans=n-m*2;
    
    
    cout<<ans<<endl;
    
    
    
    
}


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

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

    int ans = n / 2 + n % 2;

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


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

int main() {
    int K, S;
    cin >> K >> S;

    int count = 0;
    for (int i = 0; i <= K; i++) {
        for (int j = 0; j <= K; j++) {
            if (i + j <= S && S- (i + j) <= K) {
                count ++;
            }
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    static int mod = 1000_000_007;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        int k = sc.nextInt();
        int[][] dp = new int[h + 1][w + 1];
        dp[0][1] = 1;
        for (int i = 0; i < h; i++) {
            for (int j = 1; j <= w; j++) {
                if (j != 1) dp[i + 1][j - 1] = (int) ((dp[i + 1][j - 1] + (long) dp[i][j] * func(j - 3) * func(w - j - 1)) % mod);
                dp[i + 1][j] = (int) ((dp[i + 1][j] + (long) dp[i][j] * func(j - 2) * func(w - j - 1)) % mod);
                if (j != w) dp[i + 1][j + 1] = (int) ((dp[i + 1][j + 1] + (long) dp[i][j] * func(j - 2) * func(w - j - 2)) % mod);
            }
        }
        System.out.println(dp[h][k]);
    }
    public static int func(int x) {
        if (x <= 0) return 1;
        int[][] dp = new int[x + 1][2];
        dp[0][0] = 1;
        for (int i = 0; i < x; i++) {
            dp[i + 1][0] = dp[i][0] + dp[i][1];
            dp[i + 1][1] = dp[i][0];
        }
        return dp[x][0] + dp[x][1];
    }
}

Measured memory_bytes: 22996
//<--sbhmsh-->//

#include <bits/stdc++.h>
#include <iostream>
#define FASTIO std::ios::sync_with_stdio(false);
using namespace std;
#define lli long long int
#define endl '\n'
#define deb cout<<"sab_badhiya"<<endl;
// const long long INF = 1000 * 1000 * 1000 * 1ll * 1000 * 1000 * 1000;
const long INF = 1000 * 1000 * 1000;
const long long int mod = 1000000007;
int dp[100005][3], a[100005], b[100005], c[100005];
int main() {
  FASTIO
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>dp[i][0]>>dp[i][1]>>dp[i][2];
    if(i>0){
      dp[i][0]+=max(dp[i-1][1], dp[i-1][2]);
      dp[i][1]+=max(dp[i-1][0], dp[i-1][2]);
      dp[i][2]+=max(dp[i-1][1], dp[i-1][0]);
    }
  }
  cout<<max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]))<<endl;
}


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

#define ll long long
#define mod 1000000007

using namespace std;



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll x,y,x2,y2,a,b;
    cin>>x>>y>>x2>>y2;
    a=x2-x,b=y2-y;
    cout<<(x2-b)<<" "<<(y2+a)<<" ";
    cout<<(x-b)<<" "<<(y+a)<<endl;
}


Measured memory_bytes: 3580
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int ab = sc.nextInt();
        int aa = sc.nextInt();
        int bb = sc.nextInt();
        int price = 0;
        if(a/2 > ab){
            a = ab*2;
        }
        if(b/2 > ab){
            b = ab*2;
        }
        if(a + b >= ab*2){
            if(aa<bb){
                price += aa*ab*2 + (bb-aa)*b;
            }else if(aa>bb){
                price += bb*ab*2 + (aa-bb)*a;
            }else{
                price += bb*ab*2;
            }
        }
        else{
            price += aa*a + bb*b;
        }
        System.out.println(price);
    }
}

Measured memory_bytes: 23760