akhauriyash/Code-Regression huggingface dataset:
N=int(input())
S = ['AC', 'WA', 'TLE', 'RE']
li=[]

for i in range(N):
  jud = input()
  li.append(jud)
a=li.count('AC')
w=li.count('WA')
t=li.count('TLE')
r=li.count('RE')

#print(li)
#print(a)

print('AC x '+str(a))
print('WA x '+str(w))
print('TLE x '+str(t))
print('RE x '+str(r))

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

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

using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll INF = (ll)1e14;

void Main() {
  int n, m, L;
  cin >> n >> m >> L;
  vector<vector<ll>> dp(n, vector<ll>(n, INF));
  rep(_, m) {
    int a, b, c;
    cin >> a >> b >> c;
    a--; b--;
    dp[a][b] = dp[b][a] = c;
  }

  int q;
  cin >> q;
  vector<P> st;
  rep(_, q) {
    int s, t;
    cin >> s >> t;
    st.emplace_back(s-1, t-1);
  }

  rep(i, n) {
    rep(k, n) REP(l, k+1, n) {
      dp[k][l] = min(dp[k][l], dp[k][i]+dp[i][l]);
      dp[l][k] = dp[k][l];
    }
  }

  vector<vector<int>> dp2(n, vector<int>(n, 1e5));
  rep(i, n) rep(j, n) if (dp[i][j] <= L)  dp2[i][j] = 1;
  rep(i, n) {
    rep(k, n) REP(l, k+1, n) {
      dp2[k][l] = min(dp2[k][l], dp2[k][i]+dp2[i][l]);
      dp2[l][k] = dp2[k][l];
    }
  }
  
  rep(i, st.size()) {
    int s = st[i].first;
    int t = st[i].second;
    if (dp2[s][t] < 1e5) 
      cout << dp2[s][t] - 1 << endl;
    else 
      cout << -1 << endl;
  }
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 2300
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//const int N = 1000000;
const ll mod = 1000000007;
//using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dh[8] = {0, 0, 1, 1, 1, -1, -1, -1};
const int dw[8] = {1, -1, 0, 1, -1, 0, 1, -1};
  
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * (B / gcd(A, B));
}
using Edge = pair<int,int>;
using Graph = vector<vector<Edge>>;
Graph G;
  
/*------------------------------------------------------------------*/

int main(){
    string s; cin >> s;
    int n = s.size();
    vector<int> ans(n);
    int l = 0, r = 0;
    rep(i, n){
        if(s[i] == 'R' and s[i + 1] == 'R'){
            ans[i] = 0;
            r++;
        }
        if(s[i] == 'R' and s[i + 1] == 'L'){
            ans[i] = r / 2 + 1;
            ans[i + 1] = r / 2 + r % 2 + 1;
            r = 0;
        }
    }
    for(int i = n - 1; i >= 0; i--){
        if(s[i - 1] == 'L' and s[i] == 'L'){
            ans[i] += 0;
            l++;
        }
        if(s[i - 1] == 'R' and s[i] == 'L'){
            ans[i - 1] += l / 2 + l % 2;
            ans[i] += l / 2;
            l = 0;
        }
    }
    rep(i, n){
        if(i == n - 1){
            cout << ans[i] << endl;
            return 0;
        }
        cout << ans[i] << " ";
    }
}


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

AB = [0]*N
for i in range(N):
    AB[i] = list(map(int, input().split()))

AB.sort(key=lambda x:x[1])
time = 0
for a,b in AB:
    time += a
    if time > b:
        print('No')
        quit()
print('Yes')

Measured memory_bytes: 53716
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String correct = scanner.next();
		String target = scanner.next();

		char[] targ = target.toCharArray();
		for (int i = 0; i < correct.length(); i++) {
			char[] converted = new char[correct.length()];
			for (int j = 0; j < correct.length(); j++) {
				int a = i + j;
				if (a >= correct.length()) {
					a = a - correct.length();
				}
				converted[j] = targ[a];
			}
			if (correct.equals(String.valueOf(converted))) {
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
	}

}


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

int main(){
  int a, b, c, d;

  cin >> a >> b >> c >> d;

  int e = 0;
  int f;

  f = abs(c-a);
  // a < b < cにソート
  if(a > b){
    e = a;
    a = b;
    b = e;
  }
  if(b > c){
    e = b;
    b = c;
    c = e;
  }
  if(a > b){
    e = a;
    a = b;
    b = e;
  }

  if((b-a <= d && c-b <= d) || f <= d){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll=long long;
int main()
{
    ll n,ans=0;
    cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    rep(i,n) for(ll j=i+1;j<n;j++) ans+=a[i]*a[j];
    cout<<ans;
}

Measured memory_bytes: 3592
program i_miss_you___
  implicit none
  character(100) :: s
  integer :: n, i
  read(*,*) s
  n = len_trim(s)
  do i = 1, n
    s(i:i) = 'x'
  end do
  write(*,'(a)') trim(s)
end program i_miss_you___

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final int m = scanner.nextInt();
        if (m >= n) {
            System.out.println(n);
            return;
        }

        final String s = scanner.next();
        final List<Boolean> list = IntStream.range(1, n)
                .mapToObj(i -> s.charAt(i) == '0')
                .collect(Collectors.toList());

        int falseConstraint = 0;
        for (final boolean bool : list) {
            if (bool) {
                falseConstraint = 0;
                continue;
            }

            falseConstraint++;
            if (falseConstraint == m) {
                System.out.println(-1);
                return;
            }
        }

        Collections.reverse(list);
        int constraint = 0;
        int last = 0;
        final List<Integer> candidates = new ArrayList<>();
        for (int i = 0; i < list.size(); i++) {
            final boolean bool = list.get(i);
            constraint++;
            if (bool) {
                last = i;
            }
            if (constraint == m) {
                if (bool) {
                    candidates.add(m);
                    constraint = 0;
                } else {
                    candidates.add(m - (i - last));
                    constraint = i - last;
                }
            }
        }
        candidates.add(constraint + 1);
        Collections.reverse(candidates);

        final String answer = candidates.stream()
                .map(i -> Integer.toString(i))
                .collect(Collectors.joining(" "));
        System.out.println(answer);
    }
}


Measured memory_bytes: 37420
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V  = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int n; cin >> n;
  for (int i = 0; i < 1e5; i++) if ((i + 1) * (i + 1) > n) return cout << i * i << '\n', 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	vector<char> ans;
	
	for(int i=0;i<s.size();i++){
		if(s[i]=='0'){
			ans.push_back('0');
			
		}
		if(s[i]=='1'){
			ans.push_back('1');
			
		}
		if(ans.size()>=1&&s[i]=='B'){
			ans.pop_back();
			
		}
	}
	for(int i=0;i<ans.size();i++){
		cout<<ans[i];
	}
	cout<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
    int a,b,c; cin>>a>>b>>c;
    vector<int> x(3);
    x[0]=a; x[1]=b; x[2]=c;
    sort(all(x));
    cout<<x[0]+x[1]<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <map>
#include <cstring>
using namespace std;

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

struct rect {
	int t, b, l, r;
	rect() : t(100),b(0),l(100),r(0){}
};

int main() {
	int n;
	cin >> n;
	rep(nn, n) {
		int h, w;
		cin >> h >> w;
		map<char, rect> mp;
		vector<string> in(h);
		int f[50][50];
		memset( f, 0, sizeof(f) );
		rep(y, h) {
			cin >> in[y];
			rep(x, w) {
				mp[in[y][x]].t = min(mp[in[y][x]].t, y);
				mp[in[y][x]].b = max(mp[in[y][x]].b, y);
				mp[in[y][x]].l = min(mp[in[y][x]].l, x);
				mp[in[y][x]].r = max(mp[in[y][x]].r, x);
			}
		}
		bool safe = false;
		for(int i=0; i<7; i++) {
			bool allok = true;
			for(map<char,rect>::iterator it=mp.begin(); it!=mp.end(); it++) {
				rect r = it->second;
				bool ok = true;
				for(int y=r.t; y<=r.b; y++) {
					for(int x=r.l; x<=r.r; x++) {
						if( in[y][x] != it->first && in[y][x] != '*' ) {
							ok = false;
						}
					}
				}
				if(ok) {
					for(int y=r.t; y<=r.b; y++) {
						for(int x=r.l; x<=r.r; x++) {
							in[y][x] = '*';
						}
					}
				}
				allok &= ok;
			}
			if(allok) {
				safe = true;
				break;
			}
		}
		if(safe) {
			cout << "SAFE" << endl;
		} else {
			cout << "SUSPICIOUS" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1236
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;


#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, k, ans = 0;
    cin>>n>>k;
    while(n) {
    	n = n / k;
    	ans++;
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var X, A, B int
	fmt.Scan(&X, &A, &B)

	t := -A + B
	if t <= 0 {
		fmt.Println("delicious")
	} else if t <= X {
		fmt.Println("safe")
	} else {
		fmt.Println("dangerous")
	}
}


Measured memory_bytes: 512
/* ****Ragnar7 -SHINIGAMI- _Lawliet_**** */
/* First, solve the problem.Then write the code. */
#include<bits/stdc++.h>
#define ll          long long
#define ld 			long double
#define hell        1000000007
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifndef ONLINE_JUDGE
	freopen ("input.txt","r",stdin);
	// freopen ("output.txt","w",stdout);
	#endif
	ll t = 1;
	// cin>>t;
	while(t--)
	{
		ll n,k;
		cin>>n;
		ll a[n+1][4];
		memset(a,0,sizeof(a));
		for(ll i=1;i<=n;i++)
			for(ll j=0;j<3;j++)
				cin>>a[i][j];
		ll dp[n+1][4];
		memset(dp,0,sizeof(dp));
		for(ll i=1;i<=n;i++)
		{
			for(ll j=0;j<3;j++)
				for(ll k=0;k<3;k++)
					if(j!=k)
						dp[i][k]=max(dp[i][k],dp[i-1][j]+a[i][k]);
			for(ll j=0;j<3;j++)
			dp[i][3] = max(dp[i][3],dp[i][j]);
		}
		cout<<dp[n][3];
		
	}

	
	time
	return 0;
}

Measured memory_bytes: 9792
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,k = list(map(int, input().split()))
a = [int(input()) for _ in range(n)]
for i in range(n):
    a[i] -= k
def cumsum(a):
    """※ aを破壊する
    l[i] = sum(a[:i]) なるlを返す
    sum(a[i:j]) == l[j+1] - l[i]
    """
    c = 0
    n = len(a)
    a.insert(0, 0)
    for i in range(1, n+1):
        a[i] = a[i-1]+a[i]
    return a
cumsum(a)
l = [a[0]]
ans = 0
### BIT binary
def init(bit, values):
    for i,v in enumerate(values):
        add(bit,i+1,v)
#a1 ~ aiまでの和 O(logn)
def query(bit,i):
    res = 0
    while i > 0:
        res += bit[i]
        i -= i&(-i)
    return res

#ai += x(logN)
def add(bit,i,x):
    if i==0:
        raise RuntimeError
    while i <= len(bit)-1:
        bit[i] += x
        i += i&(-i)
    return

# a1,...,aiの和がv以上になる最小のindexを求める
def index(bit, v):
    i = 0
    k = 1
    n = len(bit)-1
    while 2*k<n:
        k *= 2
    while k>0:
        if i+k<n+1 and bit[i+k]<v:
            v -= bit[i+k]
            i += k
        k //= 2
    return i+1

from bisect import bisect_left
from bisect import bisect_left as bl, bisect_right as br

def press(l):
    # xs[inds[i]]==l[i]となる
    xs = sorted(set(l))
    inds = [None] * len(l)
    for i,item in enumerate(l):
        inds[i] = bisect_left(xs, item)
    return xs, inds
xs, inds = press(a)
bit = [0]*(len(inds)+1)
ans = 0
num = 0
for i in inds:
    ans += query(bit, i+1)
    add(bit, i+1, 1)
#     print(i, ii, xs[i])
    num += 1
print(ans)

Measured memory_bytes: 117372
/*
    Auther: ghoshashis545 Ashis Ghosh
    College: jalpaiguri Govt Enggineerin College
    Date:17/03/2020
*/
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define ll long long 
#define ld long double
#define ff first
#define ss string 
#define se second
#define alt(v) v.begin(),v.end()
#define pb emplace_back
#define mp make_pair
#define tc(t) cin>>t;while(t--)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define fab(i,a,b) for(ll i=(a);i<(b);i++)
#define fba(i,a,b) for(ll i=(b);i>=(a);i--)
#define arr(i,n) fab(i,0,n)
ll max(ll a,ll b){if(a>b)return a;else return b;} 
ll min(ll a,ll b){if(a<b)return a;else return b;}
const ll inf=0x3f3f3f3f;

vector<int>primeFactorization(int n)
{
    vector<int>prime_fact;
    for(int i=2;i<=sqrt(n);++i)
    {
        while(n%i==0)
        {
            prime_fact.push_back(i);
            n/=i;
        }
    }
    if(n!=1)
    prime_fact.push_back(n);
    return prime_fact;
}

vector<int>sieve(int n)
{
    bool primes[n+5];
    memset(primes,true,sizeof(primes));
    vector<int>res;//res vector all the prime no between 1 to n
    for(int i=2;i<=sqrt(n);++i)
    {
        if(primes[i]==true)
        {
            res.push_back(i);
            for(int j=i*2;j<=n;j+=i)
            primes[j]=false;
        }
    }
    return res;
}








ll const Mxn=1e5;
bool test=0;
void solve()
{
    ll n,x,f=0,q,c,ans=0,i,m,k,j;
    cin>>n>>k;
    vector<ll>h(n),dp(n);
    for(auto &x:h)
    cin>>x;
    dp[0]=0;
    fab(i,1,n)
    {
        x=inf;
        for(j=i-1;j>=max(0,i-k);--j)
        x=min(x,dp[j]+abs(h[i]-h[j]));
        dp[i]=x;
        // cout<<dp[i]<<" ";
    }
    cout<<dp[n-1];
}





























int main()
{
    fio;
    ll t=1,s;
    if(test)
    cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;

typedef pair<int, int> P;
const int INF = 10000;

int H, W;
queue<P> que;
char maze[50][50];
int d[50][50];
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

int bfs() {

  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      d[i][j] = INF;
    }
  }

   que.push(P(0, 0));
   d[0][0] = 0;

   while(que.size()) {
     P p = que.front();
     que.pop();
     if(p.first == H - 1 && p.second == W - 1) break;
     
     for(int i = 0; i < 4; i++) {
       int nx = p.first + dx[i], ny = p.second + dy[i];
       if(0 <= nx && nx < H && 0 <= ny && ny < W && maze[nx][ny] == '.' && d[nx][ny] == INF) {
         que.push(P(nx, ny));
         d[nx][ny] = d[p.first][p.second] + 1;
       }
     }

   }

   return d[H-1][W-1];

}


int main() {
  cin >> H >> W;
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      cin >> maze[i][j];
    }
  }

  int count = 0;

  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      if(maze[i][j] == '.') count++;
    }
  }


    int res = bfs();

    if(res != INF) {
      int ans = count - res - 1;
      cout << ans << endl;
    } else {
    cout << -1 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
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)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (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:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::collections::HashMap;

fn main() {
    input!{
        n: usize,
        s: chars
    }
    let d = 1000000007;
    let mut map: HashMap<char, usize> = HashMap::new();
    for c in s {
        *map.entry(c).or_insert(0) += 1;
    }
    let ans: usize = (map.values().map(|x| x + 1).fold(1, |acc, x| acc * x % d) + d - 1) % d;
    println!("{}", ans);
}


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

int main() {
	
	int N;
	cin >>N;
	
	vector<pair<int, int>> VC(N);
	
	for(int i=0; i<N; i++){
		
		cin >>VC.at(i).first;
		
	}
	for(int i=0; i<N; i++){
		
		cin >>VC.at(i).second;
		
	}
	
	vector<int> diff(N);
	
	for(int i=0; i<N; i++){
		
		diff.at(i)=VC.at(i).first-VC.at(i).second;
		
	}
	
	int result=0;
	
	for(int i=0; i<N; i++){
		
		if(diff.at(i)>0){
			
			result+=diff.at(i);
			
		}
		
	}
	
	cout <<result <<endl;
}

Measured memory_bytes: 256
import std.functional,
       std.algorithm,
       std.container,
       std.typetuple,
       std.typecons,
       std.bigint,
       std.string,
       std.traits,
       std.array,
       std.range,
       std.stdio,
       std.conv,
       std.format,
       std.math;

void main()
{
	auto ip = readln.split.to!(int[]), a=ip[0], b=ip[1], c=ip[2];
	if(a==b) writeln(c);
	else if(b==c) writeln(a);
	else writeln(b);
}

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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(a > b){
    swap(a,b);
  }if(b > c){
    swap(b,c);
  }if(a > b){
    swap(a,b);
  }
  cout << a << " " << b << " " << c << "\n";
  return 0;
}

Measured memory_bytes: 1164
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n,m = li()

graph = [[] for _ in range(n)]
for _ in range(m):
    l,r,d = li()
    l -= 1
    r -= 1
    graph[l].append((d,r))
    graph[r].append((-d,l))
    
searched = [False]*n
dist = [float("inf") for _ in range(n)]

exist = True
for i in range(n):
    if not searched[i]:
        dist[i] = 0
        searched[i] = True
        stack = [(0,i)]
        
        while stack:
            cost, cur = stack.pop()
            for nex_cost, nex_node in graph[cur]:
                if searched[nex_node]:
                    if cost + nex_cost != dist[nex_node]:
                        exist = False
                        
                else:
                    stack.append((cost+nex_cost, nex_node))
                    dist[nex_node] = cost + nex_cost
                    searched[nex_node] = True
                    


print("Yes") if exist else print("No")

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

ll maxB(vector<ll>&h,vector<ll>&a){
	map<ll,ll> hv;
	vector<ll> dp(h.size());
	ll maxv=0;
	for(ll i=0;i<h.size();i++){
		auto it=hv.lower_bound(h[i]+1);
		if(it==hv.begin()){
			dp[h[i]]=a[i];
			hv[h[i]]=dp[h[i]];		
		}
		else{
			it--;
			dp[h[i]]=a[i]+it->second;
			hv[h[i]]=dp[h[i]];
		}
		auto It=hv.upper_bound(h[i]);
		while(It!=hv.end() && It->second<=dp[h[i]]){
			auto temp=It;
			temp++;
			hv.erase(It);
			It=temp;
		}
		maxv=max(maxv,dp[h[i]]);
	}
	return maxv;
}

int main(){
 ll n;
 cin>>n;
 vector<ll> h(n+1);
 vector<ll> a(n+1);
 for(ll i=0;i<n;i++){
 	cin>>h[i];
 }
 for(ll i=0;i<n;i++){
 	cin>>a[i];
 } 
 
 cout<<maxB(h,a);
 
 return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << ": " << x << '\n'

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

const long long INF = 3e18 + 12;
const int inf = 1e9;

ll gcd(ll x, ll y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}
ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

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

  int a, b;
  cin >> a >> b;

  cout << lcm(a, b) << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int i,j ,n,r,p=0,x,swap;
        n=scan.nextInt();
        int[] A=new int[n];
        for(i=0;i<n;i++){
        	A[i]=scan.nextInt();
        }
        
        r=n-1;
        x=A[r];
		i=p-1;
		for(j=p;j<r;j++){
			if(A[j]<=x){
				i=i+1;
				swap=A[i];
				A[i]=A[j];
				A[j]=swap;
			}
		}
		swap=A[i+1];
		A[i+1]=A[r];
		A[r]=swap;
		
        for(j=0;j<n;j++){
        	if(j==i+1){
        		System.out.print("["+A[j]+"]");
        	}
        	else{
        		System.out.print(A[j]);
        	}
        	if(j<n-1){
        		System.out.print(" ");
        	}
        	else{
        		System.out.println("");
        	}
        }
        scan.close();
    }
}



Measured memory_bytes: 69324
#include<bits/stdc++.h>
#define int long long
using namespace std;
template<class T> inline bool chmax(T& a, T b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b){ if(a>b){ a=b; return 1; } return 0; }

int N;
double dp[310][310][310];

double rec(int i,int j,int k)
{
    if(dp[i][j][k]>=0) return dp[i][j][k];
    if(i==0 and j==0 and k==0) return 0.0;

    double res=0.0;
    if(i>0) res+=1.0*rec(i-1,j,k)*i/(i+j+k);
    if(j>0) res+=1.0*rec(i+1,j-1,k)*j/(i+j+k);
    if(k>0) res+=1.0*rec(i,j+1,k-1)*k/(i+j+k);
    res+=1.0*N/(i+j+k);
    return dp[i][j][k]=res;
}

signed main()
{
    cin>>N;
    int a=0,b=0,c=0;
    for(int i=0;i<N;i++){
        int x; cin>>x;
        if(x==1) a++;
        if(x==2) b++;
        if(x==3) c++;
    }
    memset(dp,-1,sizeof(dp));
    cout<<fixed<<setprecision(10)<<rec(a,b,c)<<endl;
}


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

int main(){
  int N,K,x=1;
  cin >> N >> K;
  
  for(int i=0;i<N;i++){
  	if(x < K){
      x *= 2;
    }
    else
    x+=K;
      
  }
  cout << x;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++ i) 
const int N = 6005 ;
using namespace std ;

int n, a[N], e, ter[N], lnk[N], nxt[N] ;

void add(int x, int y) {
	ter[++ e] = y, nxt[e] = lnk[x], lnk[x] = e ;
}

bool dfs(int p, int las) {
	bool res = false ;
	for (int i = lnk[p] ; i; i = nxt[i]) if (ter[i] != las && a[ter[i]] < a[p])
		res |= !dfs(ter[i], p) ;
	return res ;
}

int main() {
	scanf("%d", &n) ;
	rep(i, 1, n) scanf("%d", &a[i]) ;
	int x, y ;
	rep(i, 1, n - 1) {
		scanf("%d%d", &x, &y) ;
		add(x, y), add(y, x) ;
	}
	rep(i, 1, n) if (dfs(i, 0)) printf("%d ", i) ; puts("") ;
	return 0 ; 
}

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

string s1,s2,s3,s4,s5,s6;
bool legal = 1;

int main() {
	cin >> s1;
	for (int a = s1.length()-1; a >= 0; a--) s2 = s2 +s1[a];
	if (s1 != s2) legal = 0;
	for (int a = 0; a < (s1.length()-1)/2; a++) s3 = s3 +s1[a];
	for (int a = s3.length()-1; a >= 0; a--) s4 = s4 +s3[a];
	if (s3 != s4) legal = 0;
	if (legal == 1) printf("Yes\n"); else printf("No\n");
}

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

// #include <boost/algorithm/string/join.hpp>
// using boost::algorithm::join;
//
// #include "boost/multi_array.hpp"
// boost::multi_array<int, 3> dp;
// dp.resize(boost::extents[10][9][8]);
//
// #include <boost/multiprecision/cpp_dec_float.hpp>  // quite slowly
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision; // mp::log10
// using bigint = boost::multiprecision::cpp_int;
// using rational = mp::cpp_rational;  // double d = static_cast<double>(r);

typedef long long ll;
typedef unsigned long long ull;
//typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

//constexpr ll MOD = 1e9+7;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/4;
constexpr int INF=inf<int>;
constexpr ll LINF=inf<ll>;

#define Sort(x) sort(begin(x),end(x))
#define Reverse(x) reverse(begin(x),end(x))
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ull<<(n))
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,(v).size())

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
#define endl "\n"
  }
} before_main_function;

// ========== end of template ==========

int main(int argc, char** argv) {
  int N;
  cin >> N;
  vi A(N);
  for (auto& a : A) {
    cin >> a;
  }

  ll ret = LINF;
  REP(target, -100, 100+1) {
    ll tmp = 0;
    REP(j, N) {
      tmp += (target-A[j])*(target-A[j]);
    }

    chmin(ret, tmp);
  }

  cout << ret << endl;

  return 0;
}

/* vim: set expandtab shiftwidth=2 softtabstop=2 : */


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int>> vvint;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<int, vector<int>, greater<int>> spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int>> bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;        //大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


int INF = 1e9;
int NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
double EPS = 1e-9;
double PI = M_PI;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}
//-----------------------------------------

//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::chrono::system_clock::time_point start,end;
    start = std::chrono::system_clock::now();
    ll x ;
    cin >> x ;
    ll y = lcm(x,360) ;
    cout << y/x <<endl;


    end = std::chrono::system_clock::now();
    auto elapsed = std::chrono::duration_cast< std::chrono::milliseconds >(end - start).count();
    //std::cout << elapsed <<"ms"<< std::endl;

    

    return 0;
}



Measured memory_bytes: 3652
n, m = map(int, input().split())
can_open = []
cost = []
for _ in range(m):
    a, b = map(int, input().split())
    cost.append(a)
    can_open.append(sum(1 << (c-1) for c in map(int, input().split())))

n_bit = 1 << n
INF = 10**18
dp = [INF]*n_bit
dp[0] = 0

for x, y in zip(can_open, cost):
    for j in range(n_bit):
        m = j | x
        z = dp[j]+y
        if dp[m] > z:
            dp[m] = z

print(dp[-1] if dp[-1] != INF else -1)


Measured memory_bytes: 3188
def main
  h, n = gets.chomp.split.map(&:to_i)
  a = gets.chomp.split.map(&:to_i).sort.reverse
  
  sum = 0
  isWin = false
  a.each do |v|
    sum += v
    if sum >= h
      isWin = true
      break
    end
  end
  
  return isWin
end

puts main ? 'Yes' : 'No'


Measured memory_bytes: 10232
#![allow(unused_mut, non_snake_case,unused_imports)]
use std::iter;
use std::cmp::{max, min, Ordering};
use std::mem::{swap};
use std::collections::{HashMap,BTreeMap,HashSet,BTreeSet,BinaryHeap,VecDeque};
use std::iter::FromIterator;

//　高速 EOF要
//macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();input_inner!{iter, $($r)*}};($($r:tt)*) => {let mut s = {use std::io::Read;let mut s = String::new();std::io::stdin().read_to_string(&mut s).unwrap();s};let mut iter = s.split_whitespace();input_inner!{iter, $($r)*}};}
//macro_rules! input_inner {($iter:expr) => {};($iter:expr, ) => {};($iter:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($iter, $t);input_inner!{$iter $($r)*}};}
//macro_rules! read_value {($iter:expr, ( $($t:tt),* )) => {( $(read_value!($iter, $t)),* )};($iter:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()};($iter:expr, chars) => {read_value!($iter, String).chars().collect::<Vec<char>>()};($iter:expr, usize1) => {read_value!($iter, usize) - 1};($iter:expr, $t:ty) => {$iter.next().unwrap().parse::<$t>().expect("Parse error")};}
// 低速 EOF不要
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:ty) => {$next().parse::<$t>().expect("Parse error")};}

// 非常時
fn read_line() -> String{ let mut s = String::new(); std::io::stdin().read_line(&mut s).unwrap(); s.trim().to_string() }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */
fn main(){
    input!(A:i64,B:i64,K:i64);
    let mut A:i64 = A;
    let mut B:i64 = B;
    let mut C = 0;
    while C!=K{
        if C%2==0{
            if A%2==1{ A-=1; }
            B += A/2;
            A/=2;
        }else{
            if B%2==1{ B-=1; }
            A += B/2;
            B/=2;
        }
        C+=1;
    }
    println!("{} {}",A,B);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
#define all(v) v.begin(), v.end()
const int INF = 1<<30;
const long long LINF = 1LL << 60;
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//ミョ(-ω- ?)
int main() {
    cin.tie(nullptr) ;
    ios::sync_with_stdio(false) ;

    ll n;
    cin >> n;
    ll res = 0;
    for (ll r = 1; r*r <= n; ++r) {
        if ((n-r) % r == 0 && (n-r)/r > r) res += (n-r)/r;
    }
    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 3656
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<utility>
#include<string>
#include<queue>
#include<stack>
#include<math.h>
#include<array>
#include<algorithm>
using namespace std;
typedef long long ll;
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define CHMIN(a,b) (a) = min((a),(b))
#define CHMAX(a,b) (a) = max((a),(b))

int main()
{
    char s[10]={};
    scanf("%s",s);
    if(s[0]=='S'){
        printf("Cloudy\n");
    }
    else if(s[0]=='C'){
        printf("Rainy\n");
    }
    else{
        printf("Sunny\n");
    }
    return 0;
}

Measured memory_bytes: 256
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)*}
    };
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
use std::collections::HashMap;
use std::cmp::{max,min};
fn main(){
    input!{
        n:usize,
        an:[i64;n],
    }
    let mut an:Vec<_> = an;
    let ans = an.iter().fold(0,|y,x|gcd(y, *x));
    println!("{}",ans);
}
fn calc(a:&i64,b:&i64) -> i64{
    let mut n = a.clone();
    let mut m = b.clone();
    while (n-m).abs() !=0 {
        if n >= m {
            n -= m;
        } else {
            m -= n;
        }
    }
    min(n,m)
}

fn gcd(a:i64,b:i64) -> i64{
    if b == 0 {
        a
    } else {
        gcd(b,a%b)
    }
}

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

int main() {
	int n; cin >> n;
	int64_t a[n], b[n];
	{
		bool flg = true;
		for(int i = 0; i < n; ++i) {
			cin >> a[i] >> b[i];
			if(a[i] != b[i]) flg = false;
		}
		if(flg) {
			cout << 0 << '\n';
			return 0;
		}
	}
	int64_t ans = 0, mini = 1e18;
	for(int i = 0; i < n; ++i) {
		ans += a[i];
		if(a[i] > b[i]) {
			mini = min(mini, b[i]);
		}
	}
	cout << ans - mini << '\n';
	return 0;
}

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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORE(i, a, b) for (int i = (a); i <= (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define SP cout << fixed << setprecision(10)
typedef pair<int, int> P;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

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

    int n;
    cin >> n;
    ll a[n];
    rep(i, n) cin >> a[i];

    ll l = -1LL, r = (ll)2e9 + (ll)10;
    while (1) {
        long double mid = (l + r) / 2;
        long double b[n];
        long long memo[n];
        rep(i, n) b[i] = 0;
        b[n - 1] += mid / 2;
        b[0] += mid / 2;
        memo[0] = mid;
        rep(i, n - 1) {
            long double rain = (long double)a[i] - b[i];
            b[i] += rain;
            b[i + 1] += rain;
            memo[i + 1] = rain * 2;
        }
        if (a[n - 1] == b[n - 1]) {
            rep(i, n) {
                if (i == n - 1)
                    cout << memo[i] << endl;
                else
                    cout << memo[i] << " ";
            }
            return 0;
        } else if (a[n - 1] > b[n - 1]) {
            l = mid;
        } else {
            r = mid;
        }
    }

    return 0;
}

Measured memory_bytes: 4608
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
    int n; cin >> n;
    vector<int>p(n);
    vector<int>a(n,0),b(n);
    for(auto & e : p) cin >> e;
    int base = 40000;
    for(int i = 0; i < n;i++){
        a[i] += base*(i+1);
        b[i] =  base*(n-i-1)+1;
        a[p[i]-1] += (i+1);
    }
    for(int i = 0; i < n;i++)
        cout << a[i] << (i != n-1 ? " " : "\n");
    for(int i = 0; i < n;i++)
        cout << b[i] << (i != n-1 ? " " : "\n");
}


Measured memory_bytes: 896
def confirm(a, b, c):
    for i in range(3):
        for j in range(3):
            if a[i] + b[j] != c[i][j]:
                return False
    return True


def main():
    c = [list(map(int, input().split())) for i in range(3)]

    for a1 in range(101):
        for a2 in range(101):
            for a3 in range(101):
                a = (a1, a2, a3)
                b = (c[0][0] - a1, c[0][1] - a1, c[0][2] - a1)
                if confirm(a, b, c):
                    return 'Yes'
    return 'No'


if __name__ == '__main__':
    ans = main()
    print(ans)


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main(void)
{
	int W, H, x, y, r;
	
	std::cin >> W >> H >> x >> y >> r;

	if( W < ( x + r ) || H < ( y + r ) || ( x - r ) < 0 || ( y - r ) < 0 )
		std::cout << "No" << std::endl;
	
	else 
		std::cout << "Yes" << std::endl;
	
	return 0;
}


Measured memory_bytes: 3100
S = input()

while len(S) > 0:
    if S[-7:] == 'dreamer':
        S = S[:-7]
    elif S[-6:] == 'eraser':
        S = S[:-6]
    elif S[-5:] == 'dream':
        S = S[:-5]
    elif S[-5:] == 'erase':
        S = S[:-5]
    else :
        break

if len(S) > 0:
    print('NO')
else :
    print('YES')


Measured memory_bytes: 9208
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repf(i, j, n) for (int i = (j); i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)

signed main() {
  int n, x;
  cin >> n >> x;
  vector<int> l(n);
  for (auto&& u : l) cin >> u;
  int ret = 0, cnt = 0;
  for (auto&& u : l) {
    ret += u;
    cnt++;
    if (ret > x) cout << cnt, exit(0);
  }
  cout << 101 << endl;
}

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

using namespace std;

int main(){
    int N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    string S;
    cin >> S;

    if(C<D){
        bool r = false;
        for(int i=B; i<=D; ++i){
            if(S[i-1]=='#'){
                if(r){
                    cout << "No" << endl;
                    return 0;
                }
                r = true;
            }
            else r = false;
        }
        r = false;
        for(int i=A; i<C; ++i){
            if(S[i-1]=='#'){
                if(r){
                    cout << "No" << endl;
                    return 0;
                }
                r = true;
            }
            else r = false;
        }
        cout << "Yes" << endl;
    }
    else{
        bool r = false;
        bool w = false;
        for(int i=B; i<=D; ++i){
            if(S[i-2]!='#' && S[i-1]!='#' && S[i]!='#') w = true;
            if(S[i-1]=='#'){
                if(r){
                    cout << "No" << endl;
                    return 0;
                }
                r = true;
            }
            else r = false;
        }
        if(!w){
            cout << "No" << endl;
        }
        else{
            r = false;
            for(int i=A; i<C; ++i){
                if(S[i-1]=='#'){
                    if(r){
                        cout << "No" << endl;
                        return 0;
                    }
                    r = true;
                }
                else r = false;
            }
            cout << "Yes" << endl;
        }
    }
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
    int n;
    cin>>n;
    string s;
    cin>>s;
    int ans=0;
    for(int i=0; i<n-2; i++){
        if(s.substr(i,3)=="ABC") ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.math.*;
class Main{
    public static void main(String[] args){
    BufferedReader sc=new BufferedReader(new InputStreamReader(System.in));
    try {
	String st;
	while((st=sc.readLine())!=null){
	String out = "NA";
	root:
	for(int i=0; i<=9; i++){
		String sp = st.replaceAll("X",Integer.toString(i));
		String[] ap = sp.split("[^0-9]+");
		
		if((ap[0].length()>1 && ap[0].charAt(0)=='0') || (ap[1].length()>1 && ap[1].charAt(0)=='0') || (ap[2].length()>1 && ap[2].charAt(0)=='0'))
			continue;
		BigInteger a = new BigInteger(ap[0]);
		BigInteger b = new BigInteger(ap[1]);
		BigInteger c = new BigInteger(ap[2]);
		a = a.add(b);
		if(a.compareTo(c)==0){
			out = Integer.toString(i);
			break root;
			}
	}	
	System.out.println(out);
	}
    }catch(Exception e){
        System.out.println("Error");
    }
    }
}

Measured memory_bytes: 23564
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1001001001001001;
const int MOD = 1000000007;

template <typename T>
void print(const T &v);

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    ll ans = 0;
    int front = a[0];
    int back = a[n - 1];
    int left = 0;
    int right = n - 1;

    ans += abs(back - front);

    while (right - left > 1)
    {
        int fl = abs(front - a[left + 1]);
        int fr = abs(front - a[right - 1]);
        int bl = abs(back - a[left + 1]);
        int br = abs(back - a[right - 1]);

        // front-leftの絶対値が最大である時
        if (fl > fr && fl > bl && fl > br)
        {
            ++left;
            ans += abs(front - a[left]);
            front = a[left];
        }
        // front - rightの絶対値が最大である時
        else if (fr > bl && fr > br)
        {
            --right;
            ans += abs(front - a[right]);
            front = a[right];
        }
        // back - leftの最大値が最大である時
        else if (bl > br)
        {
            ++left;
            ans += abs(back - a[left]);
            back = a[left];
        }
        // back - rightの最大値が最大である時
        else
        {
            --right;
            ans += abs(back - a[right]);
            back = a[right];
        }
    }
    cout << ans << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}

Measured memory_bytes: 4064
n = int(input())
a = list(map(int, input().split()))

def cost(a, neg=False):
    sign = -1 if neg else 1
    if sign * a[0] > 0:
        ret = 0
        cum = a[0]
    else:
        ret = abs(a[0] - sign)
        cum = sign
    for i in range(1, n):
        sign *= -1
        cum += a[i]
        if cum * sign > 0:
            continue
        else:
            ret += abs(cum - sign)
            cum = sign
    return ret

print(min(cost(a, False), cost(a, True)))


Measured memory_bytes: 14332
/* Alohomora */
#include<bits/stdc++.h>
#define ll         long long
#define fl(i,n)    for(i=0;i<n;i++)
#define fld(i,a,b) for(i=a;i>b;i--)
#define fli(i,a,n) for(i=a;i<n;i++)
#define inp(i,a,n) for(i=0;i<n;i++) {cin>>a[i];}
#define op(i,a,n)  for(i=0;i<n;i++) {cout<<a[i]<<" ";}
#define pb         push_back
#define mp         make_pair
#define F          first 
#define S          second
#define mod        998244353
#define all(x) 	   x.begin(),x.end()	
#define speedup    ios_base::sync_with_stdio(false),cin.tie(0)
using namespace std;
void comp()
{
	ll i,j,k,n,m;
	string s;
	cin>>s;
	if(s[2]==s[3] && s[4]==s[5])
	{
		cout<<"Yes\n";
	}
	else
	{
		cout<<"No\n";
	}
}

int main()
{
    speedup;
    ll i=0,t;
    ll n;
    //cin>>t;
    t=1;
	while(t--)
    {
        comp();
    }
    return 0;
}


Measured memory_bytes: 256