akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

template<typename T>
class SegmentTree{
	T def_value;
	int last_num;
	vector<T> element;
public:
	SegmentTree(vector<T>& vec,T def):def_value(def){
		int N=vec.size();
		last_num=1;
		while(last_num<N) last_num <<= 1;
		element.resize(2*last_num-1,def);

		for(int i=0;i<N;i++){
			element[i+last_num-1] = vec[i];
		}
		for(int i=last_num-2;i>=0;i--){
			element[i] = element[2*i+1]+element[2*i+2];
		}
	}
	void Update(int index,T x){
		int i=last_num+index-1;
		element[i] += x;
		while(i>0){
			i = (i-1)/2;
			element[i] = element[2*i+1]+element[2*i+2];
		}
	}
	T Find(int left,int right,int index=0,int vleft=0,int vright=-1){
		if(vright<0) vright = last_num;
		if(vright<=left || right<=vleft) return def_value;
		if(left<=vleft && vright<=right) return element[index];

		T res_left = Find(left,right,2*index+1,vleft,(vleft+vright)/2);
		T res_right = Find(left,right,2*index+2,(vleft+vright)/2,vright);
		return res_left+res_right;
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	auto N=in(),Q=in();
	vector<ll> A(N,0);
	SegmentTree<ll> tree(A,0);

	REP(i,Q){
		int q=in();
		if(q==1){
			int x=in()-1,y=in()-1;
			out(tree.Find(x,y+1));
		}
		else{
			int x=in()-1,y=in();
			tree.Update(x,y);
		}
	}
	
	return 0;
}


Measured memory_bytes: 5636
N, A, B = (int(i) for i in input().split()) 

def q1(N,A,B):
    maximum = min(A,B)
    if A + B <= N:
        minimum = 0
    else:
        minimum = A+B-N
    L = [maximum, minimum]
    return ' '.join(map(str, L))
    

print(q1(N,A,B))

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
public class ABC143A {
    public static void Main() {
        int A, B, ans = 0;
        string[] str = Console.ReadLine().Split(' ');
        A = int.Parse(str[0]);
        B = int.Parse(str[1]);
        ans = Math.Max(0, A - 2 * B);        
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13140
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
#define N 100010
int main()
{
    long long x,y,z;
    scanf("%lld%lld",&x,&y);
    if(x==y)
    {
        printf("-1\n");
        return 0;
    }
    for(long long i=2;i<=100000;i++)
    {
        z=x*i;
        if(z%y)
        {
            printf("%lld\n",z);
            return 0;
        }
    }
    printf("-1\n");
    return 0;
}


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

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
// #define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define eprintf(...) 42
#define dump(x) 42
#define debug(x) 42
#endif

typedef long long ll;

const ll MOD = 1e9 + 7;

ll solve(string& S) {
    ll answer = 0;

    int left = 0;

    while(left < S.size()-1) {
        if (S[left] != 'A' && !(S[left] == 'B' && S[left+1] == 'C')) {
            left++;
            continue;
        }

        int right = left;

        while (right < S.size()) {
            if (S[right] == 'A') right++;
            else if (right < S.size() - 1 && S[right] == 'B' && S[right+1] == 'C') right += 2;
            else break;
        }

        right--;

//        debug(S.substr(left, right-left+1));

        int i = right, countOfBC = 0;
        while (left <= i) {
            if (S[i] == 'A') {
                answer += countOfBC;
                i--;
            } else if (left < i && S[i-1] == 'B' && S[i] == 'C') {
                countOfBC++;
                i -= 2;
            } else {
                i--;
            }
        }

        left = right+1;
    }

    return answer;
}

signed main() {
    string S;
    cin >> S;

    ll answer = solve(S);

    cout << answer << '\n';
    
    return 0;
}



Measured memory_bytes: 640
use std::io::*;
use std::str::FromStr;

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

fn main() {
    let n = read::<usize>();
    let mut a = vec![(0, 0); n];

    for i in 0..n {
        a[i] = (read::<usize>(), i);
    }

    a.sort();
    for i in 0..n {
        print!("{} ", a[i].1+1);
    }
}

Measured memory_bytes: 6908
n, m = map(int, input().split())

t = [None] * n
invalid = False

for _ in range(m):
    s, c = map(int, input().split())
    if t[s-1] is None or t[s-1] == c:
        t[s-1] = c
    else:
        invalid = True

for i in range(n):
    if t[i] is None:
        if i == 0 and n > 1:
            t[i] = 1
        else:
            t[i] = 0

if invalid:
    print(-1)
else:
    if t[0] == 0 and n > 1:
        print(-1)
    else:
        v = 0
        for i in range(n):
            v += t[-1 - i] * 10 ** i
        print(v)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793
 
 
   
int main(){
  ll n,p;
  cin >> n >> p;
  if(n==1)cout << p << endl;
  else if(n>=50)cout << 1 << endl;
  else{
    ll i=0;
    ll ans;
    ll k=0;
    while(k<=p){
      i++;
      k=pow(i,n);
      if(p%k==0)ans=i;
    }
  cout << ans << endl;
  }
  
} 

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

using namespace std;
#define int long long
#define INF 1ll<<60
signed main(){
  int n,l,s=0,f=INF;
  cin>>n>>l;
  int vet[n];
  for(int i=0; i<n; i++){
    vet[i]=l+ i;
    s+= l+i;
    if(abs(l+i)<abs(f)){
      f=l+i;
    }
  }
  cout<<s - f<<endl;
  f=s - vet[0];


}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef pair<int,int> P;

int map[20][20];
P startp;
P goalp;
int W,H;

#define INF 1000000
enum{RIGHT,LEFT,UP,DOWN};
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

void dfs(int x,int y,int cost){
  if( x<0 || y<0 || x>=W || y>=H ||cost>11)return;
  if(x==goalp.first&&y==goalp.second)return;
  map[x][y]=cost;
  int mx=x,my=y;
  for(int i=0;i<4;i++){
    mx=x;my=y;
    mx+=dx[i];my+=dy[i];
    if(mx==goalp.first&&my==goalp.second)map[mx][my]=min(map[mx][my],cost+1);
    if( mx<0 || my<0 || mx>=W || my>=H) continue;
    if(map[mx][my]==-1)continue;
    while(1){
      mx+=dx[i];my+=dy[i];
      if(mx==goalp.first&&my==goalp.second)map[mx][my]=min(map[mx][my],cost+1);
      if( mx<0 || my<0 || mx>=W || my>=H){
	break;
      }
      if(map[mx][my]==-1){
	map[mx][my]=INF;
	dfs(mx-dx[i],my-dy[i],cost+1);
	map[mx][my]=-1;
	break;
      }
    }
  }
}
     

int main(){
  while(cin>>W>>H,W||H){
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
	int tmp;
	cin>>tmp;
	switch(tmp){
	case 0:
	  map[j][i]=INF;
	  break;
	case 1:
	  map[j][i]=-1;
	  break;
	case 2:
	  map[j][i]=INF;
	  startp=P(j,i);
	  break;
	case 3:
	  map[j][i]=INF;
	  goalp=P(j,i);
	  break;
	}
      }
    }

    dfs(startp.first,startp.second,0);
    /*for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
      if(map[j][i]!=INF)cout<<map[j][i];
      else cout<<"IN";
      }
      cout<<endl;
      }*/
    if(map[goalp.first][goalp.second]>10)cout<<-1<<endl;
    else cout<<map[goalp.first][goalp.second]<<endl;
  }
}

Measured memory_bytes: 864
#include <bits/stdc++.h>
using namespace std;
int fx4[] = {1 , -1 , 0 , 0};
int fy4[] = {0 , 0 , 1 , -1};
int Kfx[]= {-2,-2,2,2,1,1,-1,-1}; ///knight move x - exis
int Kfy[]= {1,-1,1,-1,2,-2,2,-2}; ///knight move y- exis
int fx8[]= {1,1,1,0,0,-1,-1,-1};
int fy8[]= {0,1,-1,1,-1,0,1,-1};
#define ll long long int
#define pii pair<int,int>
#define llu unsigned long long
#define inf 1<<28
#define gama 0.57721566490
#define PI              acos(-1.0)
#define INF             0x7fffffff
#define MOD             1000000007
#define EPS             1e-7
#define all(r)(r).begin(),(r).end()
/*
bool status[mx];
void sieve(){
   long long int  i,j;
    for(i=2;i<=mx;i++)
    {
        status[i]=0;
    }
    for( i=2;i<=sqrt(mx);i++){
        if(status[i]==0)
        {
            for(j=i*i;j<=mx;j+=i){
                status[j]=1;
            }
        }
    }
}*/
ll BM( ll a , ll b , ll m )
{
    if ( b == 0 ) return 1 ;
    ll x = BM(a,b/2,m);
    x = (( x % m) * (x % m))%m;

    if( b % 2 ) x = (( x % m) * (a %m)) % m ;
    return x ;
}
#define dd double
#define sc scanf
#define pr printf
#define VI vector<int>
#define VS vector<string>
#define VC vector<char>
#define VLL vector<long long int>
#define FILE freopen("input.txt","rt",stdin); freopen("output.txt","w",stdout);
#define p_b push_back
#define mem(x,y) memset(x,y,sizeof(x))
#define F(i,a,b) for(i=a;i<=b;i++)
#define sc1(a) scanf("%d",&a)
#define scL1(a) scanf("%lld",&a)
#define scL2(a,b) scanf("%lld%lld",&a,&b)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define scL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define fori(N)          for(int i = 0; i<(N); i++)
#define forj(N)         for(int j = 0; j<(N); j++)
#define fork(N)         for(int k = 0; k<(N); k++)
#define forl(N)         for(int l = 0; l<(N); l++)
#define ford(N)         for(int d = 0; d<(N); d++)
#define fori1(N)          for(int i = 1; i<=(N); i++)
#define forj1(N)         for(int j = 1; j<=(N); j++)
#define fork1(N)         for(int k = 1; k<=(N); k++)
#define ford1(N)         for(int d = 1; d<=(N); d++)
#define sqr(x)           (x)*(x)
#define TEST int test,te=0;cin>>test;
#define segment_tree int l=(n*2),r=(n*2)+1,mid=(l+r)/2
#define Mx 100005
#define mx 10005

int main()
{
ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);///Beware of use it, if u use it dont use scanf or printf
    int n,x;
    cin>>n>>x;
	(n*500)>=x?cout<<"Yes"<<endl:cout<<"No"<<endl;
}


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

#ifdef local
#include "contest.h"
#else
#define dump(x) 
#endif

class range {
    struct iterator {
        int val, inc;
        int operator*() {return val;}
        bool operator!=(iterator& rhs) {return val < rhs.val;}
        void operator++() {val += inc;}
    };
    iterator i, n;
    public:
    range(int e) : i({0, 1}), n({e, 1}) {}
    range(int b, int e) : i({b, 1}), n({e, 1}) {}
    range(int b, int e, int inc) : i({b, inc}), n({e, inc}) {}
    iterator& begin() {return i;}
    iterator& end() {return n;}
};

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
inline bool valid(int x, int w) { return 0 <= x && x < w; }

void iostream_init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.setf(ios::fixed);
    cout.precision(12);
}
//}}}

int main(){
    iostream_init();
    int n;
    cin >> n;
    if(n == 0 || n == 2) {
        cout << 1 << endl;
    } else if(n == 1) {
        cout << 2 << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}

/* vim:set foldmethod=marker: */

Measured memory_bytes: 1192
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    List<Long> list = new ArrayList<>();

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        int k= sc.nextInt();

        for (int i=1; i<=9; i++) {
            bfs(i);
        }

        Collections.sort(list);

//        System.out.println(list);

        System.out.println(list.get(k-1));


    }

    void bfs(long s) {
        Queue<String> queue = new ArrayDeque<>();
        queue.add(String.valueOf(s));
        list.add(s);
        while (!queue.isEmpty()) {
            String t = ((ArrayDeque<String>) queue).peekFirst();
            if (t.charAt(t.length()-1)=='0') {
                if (t.length()<=9) {
                    queue.add(t+"0");
                    list.add(Long.parseLong(t+"0"));
                }
                if (t.length()<=9) {
                    queue.add(t+"1");
                    list.add(Long.parseLong(t+"1"));
                }
            } else if (t.charAt(t.length()-1)=='1' || t.charAt(t.length()-1)=='2'|| t.charAt(t.length()-1)=='3'|| t.charAt(t.length()-1)=='4'|| t.charAt(t.length()-1)=='5'|| t.charAt(t.length()-1)=='6'|| t.charAt(t.length()-1)=='7'|| t.charAt(t.length()-1)=='8') {
                String tmp = String.valueOf(t.charAt(t.length()-1));
                int num = Integer.parseInt(tmp);
                if (t.length()<=9) {
                    queue.add(t+String.valueOf(num-1));
                    list.add(Long.parseLong(t+String.valueOf(num-1)));
                }
                if (t.length()<=9) {
                    queue.add(t+String.valueOf(num));
                    list.add(Long.parseLong(t+String.valueOf(num)));
                }
                if (t.length()<=9) {
                    queue.add(t+String.valueOf(num+1));
                    list.add(Long.parseLong(t+String.valueOf(num+1)));
                }
            } else if (t.charAt(t.length()-1)=='9') {
                if (t.length()<=9) {
                    queue.add(t+"8");
                    list.add(Long.parseLong(t+"8"));
                }
                if (t.length()<=9) {
                    queue.add(t+"9");
                    list.add(Long.parseLong(t+"9"));
                }
            }
            queue.poll();
        }
    }



}


Measured memory_bytes: 71856
#!/usr/bin/env python3
def gcd(x, y):
    if x<y: x, y = y, x
    while y: x, y = y, x%y
    return x

def lcm(x, y):
    return x * y // gcd(x, y)

a, b, c, d = map(int, input().split())
a -= 1
e = lcm(c, d)
print(b-a -b//c-b//d+b//e + a//c+a//d-a//e)


Measured memory_bytes: 3060
<?php
fscanf(STDIN, "%s", $s);
$x = null;
for ($i = 0; $i < strlen($s); $i++) {
	if ($s[$i] == 'B') {
		$x = substr($x, 0, -1);
	} else {
		$x .= $s[$i];
	}
}
echo $x, "\n";

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

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

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

    int N, X;
    cin >> N >> X;
    vector<int> a(N);
    REP(i, N) cin >> a[i];
    sort(a.begin(), a.end());

    int ans = 0;
    REP(i , N) {
        if (X >= a[i]) {
            ans++;
            X -= a[i];
        }
    }
    if (ans == N && X > 0) ans--;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
A, B, C, K = list(map(int, input().split()))

number_of_A = min(A, K)
remainder = K - number_of_A

number_of_B = min(B, remainder)
remainder = remainder - number_of_B

number_of_C = remainder

total = (number_of_A * 1) + \
    (number_of_B * 0) + \
    (number_of_C * -1)

print(total)


Measured memory_bytes: 9124
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <deque>
#include <numeric>
#include <sstream>
#include <iomanip>
#define ALL(X) X.begin(), X.end()
using lint = long long;
template <typename T>
void print_container(std::vector<T> vec)
{
    for (auto iter = vec.begin(); iter != vec.end(); ++iter)
    {
        std::cout << *iter << " ";
    }
    std::cout << std::endl;
}

int main()
{
    lint n;
    scanf("%lld", &n);

    std::string s;
    std::cin >> s;

    lint s_pc = 0;

    for (int i = 0; i < n; ++i)
    {
        if (s[i] == '1')
        {
            s_pc++;
        }
    }

    lint p1 = s_pc + 1;
    lint m1 = s_pc - 1;

    std::vector<lint> p1_rem_vec(n, 0);
    std::vector<lint> m1_rem_vec(n, 0);

    lint p1_rem = 1 % p1;
    p1_rem_vec[n - 1] = p1_rem;
    for (int i = n - 2; i >= 0; --i)
    {
        p1_rem = (p1_rem * 2) % p1;
        p1_rem_vec[i] = p1_rem;
    }

    if (m1 != 0)
    {
        lint m1_rem = 1 % m1;
        m1_rem_vec[n - 1] = m1_rem;
        for (int i = n - 2; i >= 0; --i)
        {
            m1_rem = (m1_rem * 2) % m1;
            m1_rem_vec[i] = m1_rem;
        }
    }

    std::vector<lint> pop_rem(n + 2, 0);
    for (int i = 1; i <= n + 1; ++i)
    {
        lint pop = 0;
        lint tmp = i;
        while (tmp > 0)
        {
            if (tmp % 2 == 1)
            {
                pop++;
            }
            tmp >>= 1;
        }
        lint out = i % pop;
        pop_rem[i] = pop_rem[out] + 1;
    }

    lint base_p1 = 0;
    lint base_m1 = 0;
    for (int i = 0; i < n; ++i)
    {
        if (s[i] == '1')
        {
            base_p1 += p1_rem_vec[i];
            base_m1 += m1_rem_vec[i];
        }
    }
    base_p1 %= p1;
    if (m1 != 0)
    {
        base_m1 %= m1;
    }

    for (int i = 0; i < n; ++i)
    {
        if (s[i] == '0')
        {
            lint cur_p1_rem = base_p1 + p1_rem_vec[i];
            cur_p1_rem %= p1;
            std::cout << pop_rem[cur_p1_rem] + 1
                      << "\n";
        }
        else
        {
            lint cur_m1_rem = base_m1 - m1_rem_vec[i];
            if (cur_m1_rem < 0)
            {
                cur_m1_rem += m1;
            }
            if (m1 == 0)
            {
                std::cout << 0 << "\n";
            }
            else
            {
                std::cout << pop_rem[cur_m1_rem] + 1 << "\n";
            }
        }
    }

    return 0;
}


Measured memory_bytes: 7876
#include <bits/stdc++.h>
using namespace std;
int main () {
    int N;
    cin >> N;
    vector<int> A(N);
    int x = 0;
    int s = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        s += abs(A[i]-x);
        x = A[i];
    }
    s += abs(x-0);
    A.push_back(0);
    x = 0;
    for (int i = 0; i < N; i++) {
        int res = s;
        res -= abs(A[i]-x);
        res -= abs(A[i]-A[i+1]);
        res += abs(A[i+1]-x);
        x = A[i];
        cout << res << endl;
    }
}

Measured memory_bytes: 1656
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const ll INF = ll(1e15)+10;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;


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;}

int main() {
	ll A, B; cin >> A >> B;
	cout << lcm(A, B) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm> 
using namespace std;

int main()
{
	int a,b,c;
	cin>>a>>b;
	c=b-a+1;
	if((a>0&&b>0)||((a<0)&&(b<0)&&(c%2==0)))
	{
		cout<<"Positive"<<endl;
	}
	else 
	{
		if(a<0&&b>0)
		{
			cout<<"Zero"<<endl;
		}
		else cout<<"Negative"<<endl;
	}
	
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }
template<class T> inline void printYesNo(const T& t) { cout << (t ? "Yes" : "No") << CRLF; }
template<class T = int64_t> T modpow(T N, T P, T M) { T ret{1}; N %= M; while (P) { if (P & 0x01) { ret *= N; ret %= M; } P >>= 1; N *= N; N %= M; } return ret; }

/** code for assert debug begin */
int gErr = 0;
#define ASSERT(p) if(!(p)){ gErr = 1; }else{ ; }
/** code for assert debug end */

struct Tmp
{
public:
  int N;
  Tmp(int N)
  : N(N)
  {}
};

void solve(void)
{
  int N, M; cin >> N >> M;
  vector<int> memo(N);
  for (int _ = 0; _ < M; ++_) {
    int a, b; cin >> a >> b;
    --a; --b;
    ++memo[a]; ++memo[b];
  }
  auto cnt = boost::count_if(memo, [](int a){ return a % 2 != 0; });
  auto ans = cnt == 0;
  cout << (ans ? "YES" : "NO") << CRLF;
  return;
}

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

  solve();

  return 0;
}


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

int main()
{
    int n,x;
    cin>>n>>x;
    int a[n+1];
    int dp[n+1] = {0};
    int cnt = 1;
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
      dp[i] = dp[i-1] + a[i];
      if(dp[i]<=x)
        cnt++;
    }
    cout<<cnt;
    return 0;
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


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

  ll h, w;
  cin >> h >> w;

  vector<vector<char>> a(h, vector<char>(w));
  REP(i, h){
    REP(j, w)
      cin >> a[i][j];
  }



  ll cnt = 0;
  REP(i, h){
    REP(j, w){
      if(a[i][j] == '#')
        cnt++;
    }
  }

  if(cnt == h+w-1)
    cout << "Possible" << endl;
  else
    cout << "Impossible" << endl;
}


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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,29)-1;


int main() {
  int N, K; cin >> N >> K;
  int sq = floor(sqrt(N));
  int l = (sq*(sq+1)<=N) ? sq*2 : sq*2-1;
  ll dp[K][l]={};
  ll num[l] = {};
  rep(i,l) {
    if (pow(i+1,2)<=N) num[i] = 1;
    else num[i] = N/(l-i) - N/(l-(i-1));
  }
  // rep(i,l) cout << num[i] << " "; cout << endl;
  rep(i,K) {
    if (i==0) dp[i][l-1] = 1;
    else rep(j,l) dp[i][j] = dp[i-1][(l-1)-j];
    for (int j=l-1; j>=0; j--) {
      if (j!=0) dp[i][j-1] += dp[i][j];
      dp[i][j] *= num[j];
      dp[i][j] %= MOD;
    }
  }
  // rep(i,K) { rep(j,l) cout << dp[i][j] << " "; cout << endl; }
  ll result = 0;
  rep(i,l) result += dp[K-1][i];
  result %= MOD;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 50176
using System;
using System.Collections.Generic;
using System.Linq;

namespace oasobi
{
    static class MainClass
    {
        public static void Main()
        {
            int K = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');
            int A = int.Parse(input[0]);
            int B = int.Parse(input[1]);
            bool aaaa = false;

            for(int i = A; i <= B;  ++i)
            {
                if(i % K == 0)
                {
                    Console.WriteLine("OK");
                    aaaa = true;
                    break;
                }
            }

            if(aaaa == false)
            {
                Console.WriteLine("NG");
            }
        }
    }
}

Measured memory_bytes: 27496
i = 1

while i == 1:
    x = raw_input()
    a, op, b = x.split(" ")
    a = int(a)
    b = int(b)
    
    if op == "?":
        i = 0
    elif op == "+":
        print ("%d" %(a+b))
    elif op == "-":
        print ("%d" %(a-b))
    elif op == "*":
        print ("%d" %(a*b))
    else:
        print("%d" %(a/b))

Measured memory_bytes: 6456
#include <iostream>
#include <unordered_set>
#include <sstream>
using namespace std;
bool isRight(char);

int main() {
  string buff;
  while(cin >> buff, buff != "#") {
    stringstream word;
    word << buff;
    int count = 0;
    char c;
    word >> c;
    bool isLastRight = isRight(c);
    while(word >> c) {
      if(isLastRight != isRight(c)) ++count;
      isLastRight = isRight(c);
    }
    cout << count << endl;
  }
  return 0;
}

bool isRight(char c) {
  unordered_set<char> rights{'y', 'u', 'i', 'o', 'p', 'h', 'j', 'k', 'l', 'n', 'm'};
  return (rights.find(c) != rights.end());
}

Measured memory_bytes: 1224
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, W = na()
w = []
v = []
for i in range(n):
    x,y = map(int,input().split())
    w.append(x)
    v.append(y)

dp = [[0]*(W+1) for i in range(n+1)]

for i in range(n):
      for j in range(W+1):
        if j < w[i]:
        	dp[i+1][j] = dp[i][j]
        else:
          dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]]+v[i])

print(dp[n][W])
      

Measured memory_bytes: 120300
from sys import stdin


# 最大化問題
def chmax(a,b):
    if a < b: return b
    else: return a


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N, W = list(map(int,_in[0].split(' ')))  # type:list(int)
    w_v_arr = []
    for i in range(N):
        _ = list(map(int,_in[i+1].split(' ')))  # type:list(int)
        w_v_arr.append(_)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    dp = [[0] * (W+1) for _ in range(N+1)] # 最大化問題 (初期条件 dp=0)
    
    # 配るDP
    for i in range(N):
        for w in range(1,W+1):
            if w >= w_v_arr[i][0]:
                dp[i+1][w] = chmax(dp[i+1][w],dp[i][w-w_v_arr[i][0]]+w_v_arr[i][1])
            dp[i+1][w] = chmax(dp[i+1][w],dp[i][w])
    cnt = dp[N][W]
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)


Measured memory_bytes: 120300
#include<stdio.h>

int main(){
int A[102]={0};
int i,x,n;
int max=-1;

while(scanf("%d",&x)!=EOF){A[x]=A[x]+1;}

for(i=1;i<101;i++){if(max<A[i]){max=A[i];}}
for(i=1;i<101;i++){if(A[i]==max){printf("%d\n",i);}}

return 0;
}
 

Measured memory_bytes: 1700
#include "bits/stdc++.h"
#define MOD 1000000007
#define INF 1234567890
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int H, W;
std::string a[112];

int main()
{
     in >> H >> W;
     rep(i, H) { in >> a[i]; }
     
     rep(i, W + 2) { out << '#'; }
     out << std::endl;
     rep(i, H) { out << '#' << a[i] << '#' << std::endl; }
     rep(i, W + 2) { out << '#'; }
     out << std::endl;
     return 0;
}

Measured memory_bytes: 256
N=int(input())
d={}
for _ in range(N):
    s=input()
    d[s]=d.get(s,0)+1

tmp=sorted(d.items(), key=lambda x: (x[0])) 
l=sorted(tmp, key=lambda x: x[1], reverse=True) 
c=l[0][1]

for s,v in l:
  if v==c: print(s)
  else: break

Measured memory_bytes: 49432
n=int(input())
h=list(map(int,input().split()))
high=0
s=0
for i in range(n-1):
  if h[i+1]-h[i]<=0:
    s+=1
  else:
    high=max(high,s)
    s=0
high=max(high,s)
print(high)

Measured memory_bytes: 14224
#include <iostream>
#include <vector>
#include <algorithm>

typedef long long ll;

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

#define debug(x) cout << #x << "=" << x << endl;

using namespace std;

int main(void){

    string str;
    int n;

    cin >> str;
    cin >> n;

    vector<string> vec;
    REP(i,str.size()){
        FOR(width,1,n+1){
            if(i+width <= str.size())
                vec.push_back(str.substr(i,width));
        }
    }

    sort(vec.begin(), vec.end());
    unique(vec.begin(), vec.end());
    cout << vec[n-1] << endl;

    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<pair<ll,ll>> a(n);
    rep(i,n) cin >> a.at(i).second >> a.at(i).first;
    long long t=0;
    sort(a.begin(),a.end());
    for (int i=0;i<n;i++){
        t+=a.at(i).second;
        if (t>a.at(i).first) {cout << "No" << endl;return 0;}
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3328
import sys

def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    S = [[int(a) for a in input().split()] for _ in range(N)]
    C = [[int(c) for c in input().split()] for _ in range(M)]
    Ans = [1] * N
    for i in range(N):
        a, b = S[i]
        dist = abs(a - C[0][0]) + abs(b - C[0][1])
        for j in range(1, M):
            tdist = abs(a - C[j][0]) + abs(b - C[j][1])
            if tdist < dist:
                dist = tdist
                Ans[i] = j + 1
    print(*Ans, sep="\n")
    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3064
from operator import itemgetter

n = int(input())
guide = []
for i in range(1, n + 1):
    s, p = input().split()
    guide.append((s, int(p), i,))
guide.sort(key=itemgetter(1), reverse=True)
guide.sort(key=itemgetter(0))
[print(g[2]) for g in guide]

Measured memory_bytes: 3060
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cstring>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };
 
int MOD = 1000000007;

int main() {
	int S; cin >> S;
	cout << S / 3600 << ':' << S % 3600 / 60 << ':' << S % 60 << endl;
}

Measured memory_bytes: 1160
from itertools import accumulate

N = int(input())
ps = list(map(int, input().split()))

ds = [0] * N
for i, p in enumerate(ps):
    ds[p - 1] = N - i

As = accumulate([1] + ds[:-1])
Bs = reversed(list(accumulate([1] + ds[1:][::-1])))
print(' '.join(map(str, As)))
print(' '.join(map(str, Bs)))


Measured memory_bytes: 7384
open Printf
open Scanf

let () =
  let n, q = scanf "%d %d " (fun x y -> (x, y)) in
  let st = Array.make 300000 0 in
  let update x y =
    let rec iter k l r =
      if l = x && r = (x+1) then begin
          st.(k) <- st.(k) + y;
        end
      else
        let m = (l + r) / 2 in
        if x < m then
          iter (2*k) l m
        else
          iter (2*k+1) m r;
        st.(k) <- st.(2*k) + st.(2*k+1);
    in iter 1 0 n
  in
  let query x y =
    let rec iter k l r =
      if y <= l || r <= x then 0
      else
        if x <= l && r <= y then st.(k)
        else
          let m = (l + r) / 2 in
          (iter (2*k) l m) + (iter (2*k+1) m r)
    in iter 1 0 n
  in
  let rec loop i =
    if i = 0 then ()
    else
      begin
        let com, x, y = scanf "%d %d %d " (fun a b c -> (a, b, c)) in
        if com = 0 then
          update (x-1) y
        else
          printf "%d\n" (query (x-1) y);
        loop (i-1)
      end
  in
  loop q

Measured memory_bytes: 6996
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
using ll = long long;
ll inf = 100000000007ll;

int main(void)
{
  int n, t;
  cin >> n >> t;
  vector<int> a(n), b(n);
  REP(i,n) cin >> a[i] >> b[i];
  vector<vector<int>> dpl(n,vector<int>(t));
  vector<vector<int>> dpr(n,vector<int>(t));
  REP(i,n-1) {
    REP(j,t) dpl[i+1][j] = max(dpl[i+1][j], dpl[i][j]);
    FOR(to,a[i],t) {
      dpl[i+1][to] = max(dpl[i+1][to], dpl[i+1][to-1]);
      dpl[i+1][to] = max(dpl[i+1][to], dpl[i][to-a[i]]+b[i]);
    }
  }
  REP(i,n-1) {
    REP(j,t) dpr[i+1][j] = max(dpr[i+1][j], dpr[i][j]);
    FOR(to,a[n-1-i],t) {
      dpr[i+1][to] = max(dpr[i+1][to], dpr[i+1][to-1]);
      dpr[i+1][to] = max(dpr[i+1][to], dpr[i][to-a[n-1-i]]+b[n-1-i]);
    }
  }
  int answer = 0;
  REP(i,n) REP(j,t) {
    answer = max(answer, dpl[i][j] + dpr[n-1-i][t-1-j] + b[i]);
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 70784
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <numeric>
#include <climits>
#include <math.h>
#include <memory.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;
int N, M;
int cnt = 0;
ll ans = 0LL;
int i_index;
ll tmp;
int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0, -1};
string board[64];
int main(){
    int H, W;
    cin >> H >> W;
    rep(i, H) cin >> board[i];
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            tmp = 0;
            if(board[i][j] == '#'){
                cnt++;
                for(int k = 0; k < 4; k++){
                    int x = i + dh[k];
                    int y = j + dw[k];
                    if(x <= H && y <= W && x >= 0 && y >= 0 && board[x][y] == '#')
                        tmp++;
                }
                if(tmp >= 1)
                    continue;
                else{
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

using namespace std;

int main()
{
	std::ios::sync_with_stdio(false);
	int a,b,c;
	cin>>a>>b>>c;
	if(b-a == c-b)
		cout<<"YES";
	else
		cout<<"NO";
	
	
	return 0;
}

Measured memory_bytes: 256
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
n = int(input())
print(a[n-1])

Measured memory_bytes: 3060
import { readFileSync } from 'fs'

const LOG_MIN_SIZE = 1
const LOG_MAX_SIZE = 1e9

const binarySearch = (min: number, max: number, fn: (value: number) => boolean) => {
  let left = min
  let right = max

  while (left < right) {
    const middle = Math.floor((left + right) / 2)
    const result = fn(middle)

    if (result) {
      right = middle
    }
    else {
      left = middle + 1
    }
  }

  return left
}

function main(input: string) {
  const [n, k, ...logs] = input.split(/\s/).map(Number)

  const result = binarySearch(LOG_MIN_SIZE, LOG_MAX_SIZE, x => {
    // 各丸太の長さが`x`以下になるのに必要なカット回数
    const cuts = logs.reduce((sum, v) => sum + Math.ceil(v / x) - 1, 0)

    return cuts <= k
  })

  console.log(result)
}

main(readFileSync('/dev/stdin', 'utf8').trim())


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

int main() {
    map<int, int> mp;
    int N; cin >> N;
    rep(i,N){ int s; cin >> s; mp[s]++;}
    int counter = 0;
    for (auto itr : mp){
//      cout << itr.first << "-" << itr.second << endl;
      if (itr.second%2 == 1) counter++;
    }
    cout << counter << endl;
    return 0;
}

Measured memory_bytes: 8196
#include <iostream>
#include <cstring>
#include <algorithm>
#include <stack>
#include <vector>
#include <set>
#include <unordered_map>
#include <map>
#include <cmath>

#define MP make_pair
#define F first
#define S second
#define PB push_back

using namespace std;

const int maxn = 1e5 + 100;
int c[maxn], s[maxn], f[maxn];

int main(){
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    cout << 48 -  n << endl;
}

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

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

total = 0
ans_m = 0
ans_p = 0

hugo = 1
for i in range(n):
    total += a[i]
    if hugo == -1 and total <= 0:
        ans_p = ans_p + (1-total)
        total = 1
        hugo = 1
    elif hugo == -1 and total > 0:
        hugo = 1
    elif hugo == 1 and total >= 0:
        ans_p = ans_p + (1+total)
        total = -1
        hugo = -1
    elif hugo == 1 and total < 0:
        hugo = -1

total = 0
hugo = -1

for i in range(n):
    total += a[i]
    if hugo == -1 and total <= 0:
        ans_m = ans_m + (1-total)
        total = 1
        hugo = 1
    elif hugo == -1 and total > 0:
        hugo = 1
    elif hugo == 1 and total >= 0:
        ans_m = ans_m + (1+total)
        total = -1
        hugo = -1
    elif hugo == 1 and total < 0:
        hugo = -1

print(min(ans_m, ans_p))

Measured memory_bytes: 14332
import heapq

MAX = 2500

n, m, s = map(int, input().split())
s = min(s, MAX)

# 頂点リスト : [node, silver, time]
edge = [[] for i in range(n)]
for i in range(m):
    u, v, a, b = map(int, input().split())
    edge[u-1].append([v-1, a, b])
    edge[v-1].append([u-1, a, b])
for i in range(n):
    c, d = map(int, input().split())
    edge[i].append([i, -c, d])

# dp[i][silver] : 頂点iにいて銀貨をsilver枚持っているような状況を作るために必要な最小時間
dp = [[float("inf")]*(MAX+1) for _ in range(n)]
dp[0][s] = 0

# 優先度付きキュー : (time, node, silver)
edgelist = [(0, 0, s)]

while edgelist:
    time, node, silver = heapq.heappop(edgelist)

    for to, silver_cost, time_cost in edge[node]:
        res_silver = min(silver - silver_cost, MAX)
        if res_silver < 0:
            continue
        
        dp_next_value = time + time_cost
        if dp[to][res_silver] <= dp_next_value:
            continue

        dp[to][res_silver] = dp_next_value
        heapq.heappush(edgelist, (dp_next_value, to, res_silver))

print(*[min(d) for d in dp[1:]], sep="\n")

Measured memory_bytes: 98692
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	var t string
	s := wordScanner(100001)
	scanStrings(s, &t)

	ans := 0
	for i := 0; len(t) > i+1; {
		if d := t[i : i+2]; d == "01" || d == "10" {
			ans += 2
			t = t[:i] + t[i+2:]
			if i > 0 {
				i--
			}
		} else {
			i++
		}
	}

	fmt.Println(ans)
}

func wordScanner(n int) *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	b := make([]byte, n)
	s.Buffer(b, n)
	return s
}

func scanStrings(s *bufio.Scanner, vals ...*string) {
	for i := range vals {
		s.Scan()
		*vals[i] = s.Text()
	}
}


Measured memory_bytes: 11904
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(long long (i)=0, i_bound = (long long)(n); (i)<i_bound; ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
int main(){
    cin.tie(0);
    cout.sync_with_stdio(false);
    int a, b, c, d;
    bool ok = false;
    cin >> a >> b >> c >> d;
    if(abs(a-c)<=d) ok = true;
    if(abs(a-b)<=d and abs(b-c)<=d) ok = true;
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

vector<P> xy;
set<P> sxi, syi;
vector<bool> used;
set<P> edges;

void add_edge(int i){
    auto it = sxi.upper_bound(P(xy[i].first, i));
    if(it != sxi.end()){
        int ni = it->second;
        edges.emplace(min(abs(xy[ni].first - xy[i].first), abs(xy[ni].second - xy[i].second)), ni);
    }
    if(it != sxi.begin()){
        auto nit = next(it, -1);
        int ni = nit->second;
        edges.emplace(min(abs(xy[ni].first - xy[i].first), abs(xy[ni].second - xy[i].second)), ni);
    }
    it = syi.upper_bound(P(xy[i].second, i));
    if(it != syi.end()){
        int ni = it->second;
        edges.emplace(min(abs(xy[ni].first - xy[i].first), abs(xy[ni].second - xy[i].second)), ni);
    }
    if(it != syi.begin()){
        auto nit = next(it, -1);
        int ni = nit->second;
        edges.emplace(min(abs(xy[ni].first - xy[i].first), abs(xy[ni].second - xy[i].second)), ni);
    }
}

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

    for(int i=0;i<N;i++){
        int x, y;
        cin >> x >> y;
        xy.emplace_back(x, y);
        sxi.emplace(x, i);
        syi.emplace(y, i);
    }

    used.assign(N, false);

    sxi.erase(P(xy[0].first, 0));
    syi.erase(P(xy[0].second, 0));
    add_edge(0);
    used[0] = true;

    int count = 1;
    ll ans = 0;
    while(count < N){
        auto it = edges.begin();
        P p = *it;
        edges.erase(it);
        if(used[p.second]) continue;
        used[p.second] = true;
        ans += p.first;
        sxi.erase(P(xy[p.second].first, p.second));
        syi.erase(P(xy[p.second].second, p.second));
        add_edge(p.second);
        count++;
    }

    cout << ans << endl;

    return 0;
}

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

#define int long long
#define CASET int _T; cin >> _T; REP(caset, 0, _T)
#define REP(i, l, r) for (int i=(l); i<(r); ++i)
#define RREP(i, r, l) for (int i=(r); i>(l); --i)
#define sq(x) (x)*(x)
#define vi vector<int>
#define vb vector<bool>
#define pii pair<int,int>
#define t3i tuple<int,int,int>
#define t4i tuple<int,int,int,int>
#define mii map<int,int>

const int INF = 1LL<<60;
const int MOD = 998244353;

template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
string to_string(string s) {return s;}
string to_string(bool b) {return b?"true":"false";}
template <typename A, typename B>
string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> t) {return "(" + to_string(get<0>(t)) + ", " + to_string(get<1>(t)) + ", " + to_string(get<2>(t)) + ")";}
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> t) { return "(" + to_string(get<0>(t)) + ", " + to_string(get<1>(t)) + ", " + to_string(get<2>(t)) + ", " + to_string(get<3>(t)) + ")";}
template <typename A>
string to_string(vector<A> v) {
    bool first = true;
    string result = "[";
    for (A i : v) {
        if (!first) result += ", ";
        first = false;
        result += to_string(i); 
    }
    return result + "]";
}
string bin_string(int x) {
    const int d = 32;
    string result(d, ' ');
    REP(i, 0, d) result[d-1-i] = '0'+(x>>i & 1LL);
    return result;
}

int powa(int base, int exp) {
    int res = 1;
    while (exp) {
        if (exp&1) res = res*base % MOD;
        base = base*base % MOD;
        exp >>= 1;
    }
    return res;
}

main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    
    int n,k,r,s,p; string t;
    cin >> n >> k >> r >> s >> p >> t;
    map<char,int> mp;
    mp['r'] = p;
    mp['p'] = s;
    mp['s'] = r;

    int res=0;
    REP(x, 0, k) {
        res += mp[t[x]];
        for (int u=x+k; u<n; u+=k) {
            if (t[u] != t[u-k]) res += mp[t[u]];
            else t[u] = '#';
        }
    }
    cout << res;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
int main(){
  std::string S;
  std::cin >>S;
  for (int i=0;i<3;i++){
    if (S[i]==S[i+1]){
      std::cout <<"Bad" << std::endl;
      exit(0);
    }
  }
  std::cout <<"Good"<< std::endl;
}  

Measured memory_bytes: 256