akhauriyash/Code-Regression huggingface dataset:
if __name__ == '__main__':
	n = int(input())
	R = [int(input()) for i in range(n)]

	minv = R[0]
	maxv = R[1] - R[0]
	for j in range(1, n):
		if (maxv < R[j] - minv):
			maxv = R[j] - minv
		if (R[j] < minv):
			minv = R[j]
	print(maxv)

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

typedef unsigned long long ull;

#define REP(i, N) for (int i = 0; i < N; i++)
#define ANS(a) cout << a << endl;
#define SORT(V) sort(V.begin(), V.end())
#define RSORT(V) sort(V.rbegin(), V.rend())

int
main()
{
  int N; cin >> N; 	// 1<= N <= 100
  vector<int> H(N + 1);	// 1<= h <= 100
  REP(i, N) cin >> H[i];

  int num = 0;
  for (int h = 1; h <= 100; h++) {
    for (int i = 0; i < H.size(); i++) {
      if (H[i] >= h) {
	++num;
	while (i < H.size()) {
	  if (H[i] < h) break;
	  ++i;
	}
      }
    }
  }
  
  ANS(num);

  return 0;
}

/*
4
1 2 2 1
 */


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cctype>
#include <map>
#include <queue>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

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

    int ans = 0;
    for(int i = 0; i < n; i++)
    {
        int h;
        cin >> h;
        if(h >= k)
        {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
const int INF = 1e9;
using P = pair<int,int>;

int main(){
  int n, t;
  cin >> n >> t;
  int a[n], b[n];
  rep(i,n) cin >> a[i] >> b[i];
  vector<vector<P>> dp(n+1,vector<P>(t,P(-INF,0)));
  dp[0][0] = P(0,0);
  rep(i,n) {
    rep(j,t) {
      if(dp[i][j].first > dp[i+1][j].first) dp[i+1][j] = P(dp[i][j].first,max(dp[i][j].second,b[i]));
      if(j+a[i] < t && dp[i+1][j+a[i]].first < dp[i][j].first + b[i]) dp[i+1][j+a[i]] = P(dp[i][j].first + b[i],dp[i][j].second);
    }
  }
  int ans = 0;
  rep(k,t) ans = max(ans,dp[n][k].first+dp[n][k].second);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  long int answer = 0;
  cin >> n >> m;
  vector<int> x(m);
  for(int i = 0;i < m;i++) cin >> x.at(i);
  sort(x.begin(),x.end());
  vector<int> y(m-1);
  for(int i = 0;i < m-1;i++){
    y.at(i) = x.at(i+1)-x.at(i);
  }
  sort(y.begin(),y.end());
  for(int i = 0;i < m-n;i++){
    answer += y.at(i);
  }
  cout << answer << endl;
}

Measured memory_bytes: 1024
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num::clamp;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        n: usize,
        s: Chars,
    }

    for mask in 0..4 {
        let mut animals = vec![5; n+1];
        animals[0] = mask & 1;
        animals[1] = (mask>>1) & 1;
        
        for i in 1..n {
            if animals[i] == 0 && s[i] == 'o' || animals[i] == 1 && s[i] == 'x'{
                animals[i+1] = animals[i-1];
            } else {
                animals[i+1] = animals[i-1] ^ 1;
            }
        }

        if animals[0] != animals[n] {
            continue;
        }
        if animals[0] == 0 && s[0] == 'o' || animals[0] == 1 && s[0] == 'x' {
            if animals[1] != animals[n-1] {
                continue;
            }
        } else if animals[1] == animals[n-1] {
            continue;
        }

        for j in 0..n {
            let c = if animals[j] == 0 {
                'S'
            } else {
                'W'
            };
            print!("{}", c);
        }
        println!();
        return;
    }

    println!("-1");
}


Measured memory_bytes: 3012
import itertools
import numpy as np

n, m , x = map(int, input().split(" "))
l = []
for _ in range(n):
    l.append(list(map(int, input().split(" "))))

min_cost = 9999999999999999
for i in range(1, n + 1):
    for i in itertools.combinations(range(n), i):
        tmp = sum([ np.asarray(l[k]) for k in i])
        cost = tmp[0]
        min_alg = min(tmp[1:])
        if min_alg >= x:
            if min_cost > cost:
                min_cost = cost
if min_cost == 9999999999999999:
    print('-1')
else:
    print(min_cost)

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

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

int main(){
    int N,K;
    cin >> N >> K;
    int g = 0;
    int m = 0;
    rep(i,N){
        int a;
        cin >> a;
        g = gcd(a,g);
        m = max(m,a);
    }
    if(K%g == 0 && K <= m){
        cout << "POSSIBLE" << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }
   
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>


using namespace std;

int main(void){
    int a, b;
    int count = 0;

    cin >> a >> b;

    if(a <= 5){
        count = 0;
    }
    else if(a <= 12){
        count = b / 2;
    }
    else{
        count = b;
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
try: from typing import Any, Union, List, Tuple, Dict
except ImportError: pass
sys.setrecursionlimit(10**6)
def debug(*args): print(*args, file=sys.stderr)
def exit(): sys.exit(0)


N = int(input())
s = input()
t = input()


a = 0
for i in range(1, N+1):
    if s[N-i:] == t[:i]:
        a = i

print(2*N-a)


Measured memory_bytes: 38384
#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<vector>
#include<string>
#include<iostream>
#include<algorithm>
#include<map>
#include<iterator>
#include<set>
#include<stack>
#include<queue>
#include<fstream>
#include<iomanip>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include<cmath>
#include<list>
#include <sstream>
#define rep(i,m,n) for(int i = (m); i < (n); i++)
#define rep0(i, n) for(int i = (0); i < (n); i++)
#define repd(i,m,n) for(int i=(m); i > (n); i--)
#define ll long long
#define ull unsigned ll
#define pii pair<int,int>
#define pll pair<ll,ll>
#define plli pair<pll,int>
#define mp make_pair
#define endl '\n'
#define pb push_back
//#define x first
//#define y second
#define pt pair<ll,ll>
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vvll vector<vll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vpt vector<pt>
#define vb vector<bool>
#define vvb vector<vb>
#define pdd pair<long double, long double>
#define vpll vector<pll>
#define vpdd vector<pair<long double, long double> >
#define pq priority_queue
#define M_PI 3.14159265358979323846
#define INF 1000000000
using namespace std;

bool intersect(pll& p1, pll& p2) {
	if (p1.first <= p2.first && p2.second <= p1.second) {
		return true;
	}
	if (p2.first <= p1.first && p1.second <= p2.second) {
		return true;
	}
	return (p2.first <= p1.second && p2.second >= p1.second)
		||
			(p1.first <= p2.second && p1.second >= p2.second);
}

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

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

	ll n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;

	rep(i, 0, n) {
		pll up = { a+c*i, a+d*i };
		pll down = { up.first - (n - i-1)*d, up.second - (n - i-1)*c };
		if (down.first <= b && b <= down.second) {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
const long long MOD=1e09+7;



#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define pb push_back




ll factorial(ll i, ll n){
  if (n==0){
    return 1;
  }
  if (n==1){
    return i%MOD;
  }
  if (n%2==0){
    return (factorial(i,n/2)*factorial(i,n/2))%MOD;
  }
  if (n%2==1){
    return (((factorial(i,n/2)*factorial(i,n/2))%MOD)*i)%MOD;
  }
}



int main(){

  ll n,a,b;
  cin>>n>>a>>b;
  
  vector<ll> combi(b+1);
  combi.at(0)=1;
  
  for (int i=1;i<=b;i++){
    combi.at(i)=(((combi.at(i-1)*(n-i+1))%MOD)*factorial(i,MOD-2))%MOD;
  }
  
  ll answer;
  answer=factorial(2,n)-1-combi.at(a)-combi.at(b);
  
  while (answer<0){
    answer+=MOD;
  }
  
  cout<<answer<<endl;

  
}




















Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main()
{
    int n, m, x, a[100];
    scanf("%d%d%d", &n, &m, &x);
    int i;
    for (i=0; i<m; i++)
    {
        scanf("%d", &a[i]);
    }
    int left = 0;
    int right = 0;
    for (i=0; a[i]<x; i++) left ++;
    for (i=m; a[i-1]>x; i--) right ++;
    if (left<=right) printf("%d\n",left);
    else printf("%d\n", right);
    return 0;
}


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

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

P A[200005];

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  for(int i=0;i<n;i++) {
    int a; cin >> a;
    A[i] = P( a, i );    
  }
  int res[200005];
  sort(A,A+n);
  for(int i=0;i<n;i++){
    if( i < n/2 )
      res[A[i].second] = A[n/2].first;
    else
      res[A[i].second] = A[n/2-1].first;
  }
  for(int i=0;i<n;i++)
    cout << res[i] << endl;
}


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

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

  while(T--){
    int a, b, c;
    cin >> a >> b >> c;

    a *= a;
    b *= b;
    c *= c;

    if(a + b == c || a + c == b || b + c == a){
      cout << "YES" << endl;
    }
    else{
      cout << "NO" << endl;
    }
  }
}

Measured memory_bytes: 1152
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random,resource

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,m,k = LI()
    a = LI()
    b = LI()

    d = [0]
    for c in a:
        d.append(d[-1] + c)

    e = [0]
    for c in b:
        e.append(e[-1] + c)

    r = 0
    di = len(d) - 1
    for ei in range(len(e)):
        if e[ei] > k:
            break

        while d[di] + e[ei] > k:
            di -= 1

        t = ei + di
        if r < t:
            r = t

    return r


print(main())




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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

bool there[710][710] = {};
vector<int32> G[710];
int32 N, M;
int32 fr = 0;
int32 cc[2] = {};
int32 col[710];
vector<PII> a; // pair (sum, c0)

int32 dfs(int32 v=0, int32 c=0){
	if(col[v] != -1 && col[v] != c) return -1;
	else if(col[v] != -1) return 0;
	col[v] = c;
	cc[c]++;
	REP(i, G[v].size()){
		if(dfs(G[v][i], 1-c) == -1) return -1;
	}
	return 0;
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	memset(col, -1, sizeof col);
	cin >> N >> M;
	REP(i, M){
		int32 A, B;
		cin >> A >> B; A--; B--;
		there[A][B] = there[B][A] = 1;
	}
	REP(i, N){
		REP(j, N){
			if(i == j) continue;
			if(!there[i][j]) G[i].push_back(j);
		}
	}
	int32 sum = 0;
	REP(i, N){
		cc[0] = cc[1] = 0;
		if(col[i] == -1){
			if(dfs(i, 0) == -1){
				cout << -1 << endl;
				return 0;
			}
			a.push_back(PII(cc[0], cc[1]));
			sum += cc[0]+cc[1];
		}
	}
	vector<int32> dp(N+1, 0);
	dp[0] = 1;
	REP(i, a.size()){
		vector<int32> dp2(N+1, 0);
		REP(j, dp.size()){
			if(j+a[i].fs < dp.size()) dp2[j+a[i].fs] |= dp[j];
			if(j+a[i].sc < dp.size()) dp2[j+a[i].sc] |= dp[j];
		}
		dp = dp2;
	}
	int32 x = 0, y = INF;
	REP(i, N){
		if(abs(x-y) > abs(i-(N-i)) && dp[i]){
			x = i;
			y = sum-i;
		}
	}
	int64 res = INF_LL;
	REP(i, N-sum+1){
		res = min(res, (x+i)*(x+i-1)/2+(y+N-sum-i)*(y+N-sum-i-1)/2);
	}
	cout << res << endl;
}


Measured memory_bytes: 5888
#include <iostream>
#include <map>
using lld=long long int;
using namespace std;

int main(){
    lld N;
    cin >> N;
    lld A[N+1];
    lld count[N+1]={};
    for(int i=1;i<N+1;i++){
        cin >> A[i];
        count[A[i]]++;
    }
    lld sumAns=0;
    for(int i=1;i<N+1;i++){
        sumAns+=count[i]*(count[i]-1)/2;
    }
    for(int i=1;i<N+1;i++){
        cout << sumAns-count[A[i]]+1<<"\n";
    }
    return 0;
    return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	char c[1001];
	cin>>a>>b>>c;
	for(int i=0;i<strlen(c);i++){
		if((c[i]<'0'||c[i]>'9')&&i!=a){
			cout<<"No";
			return 0;
		}
	}
	if(c[a]!='-'){
		cout<<"No";
		return 0;
	}
	cout<<"Yes";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
	string s;
	cin >> s;
	vector<char> vec;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '0' || s[i] == '1') {
			vec.push_back(s[i]);
		}
		else {
			if (vec.size()) vec.resize(vec.size() - 1);
		}
	}
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i];
	}
	cout << endl;
	return 0;
}

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

signed main() {
    int n;
    cin >> n;
    int x;
    x = n % 10;
    if(x == 2 || x == 4 || x == 5 || x == 7 || x == 9){
        cout << "hon" << endl;
    }else if(x == 3){
        cout << "bon" << endl;
    }else{
        cout << "pon" << endl;
    }
}

Measured memory_bytes: 3516
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define P pair<int, int>
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
const int MAX_N = 16;
const int Y = 3;
const int X = 3;

int N;
int my[] = {0, 0, -1, 1};
int mx[] = {1, -1, 0, 0};
double dp[Y][X][MAX_N];

int main() {
  map<char, P> m;
  m['A'] = P(0, 0);
  m['B'] = P(0, 1);
  m['C'] = P(0, 2);
  m['D'] = P(1, 0);
  m['E'] = P(1, 1);
  m['F'] = P(1, 2);
  m['G'] = P(2, 0);
  m['H'] = P(2, 1);
  m['I'] = P(2, 2);
  while(cin >>N && N){
    char S, T, B; cin >>S >>T >>B;
    REP(i, Y) REP(j, X) REP(k, MAX_N) dp[i][j][k] = 0.0;
    dp[m[S].first][m[S].second][0] = 1.0;
    REP(n, N)
      REP(y, Y)
        REP(x, X)
          REP(i, 4){
            int ny = y + my[i], nx = x + mx[i];
            if(ny >= 0 && nx >= 0 && ny < Y && nx < X && !(ny == m[B].first && nx == m[B].second)) dp[ny][nx][n + 1] += (dp[y][x][n] / 4);
            else dp[y][x][n + 1] += (dp[y][x][n] / 4);
          }
    printf("%.8lf\n", dp[m[T].first][m[T].second][N]);
  }
  return 0;
}

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

int main() {
	vector<int> a(5);
	for (int i = 0; i < 5; i++) {
		cin >> a[i];
	}
	int k;
	cin >> k;
	if (a[4] - a[0] > k) {
		cout << ":(" << endl;
	}
	else {
		cout << "Yay!" << endl;
	}




	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
const int N=2e5+10;
int n,Q;
char s[N],t[N],d[N];
int Drop(int x)
{
	for(int i=1;i<=Q;i++)
	{
		if(s[x]==t[i]) x+=(d[i]=='R')?1:-1;
		if(x>n) return -1;
		if(x<1) return 1;
	}
	return 0;
}
int main()
{
	cin>>n>>Q;
	scanf("%s",s+1);
	for(int i=1;i<=Q;i++) cin>>t[i]>>d[i];
	int l=1,r=n,la=0,ra=n+1;
	while(l<=r)
	{
		int mid=(l+r)>>1;
		if(Drop(mid)==1) la=mid,l=mid+1;
		else r=mid-1;
	}
	l=1,r=n;
	while(l<=r)
	{
		int mid=(l+r)>>1;
		if(Drop(mid)==-1) ra=mid,r=mid-1;
		else l=mid+1;
	}
	cout<<ra-la-1<<endl;
}


Measured memory_bytes: 768
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
using namespace std;


int main() {
	long long int a = 0, b = 0, c = 0, memo = 0, s[500] = {},N,L,num;
	string str[105],min;
	cin >> N >> L;
	for (int i = 0; i < N; i++) {
		cin >> str[i];

	}
	for (int i = 0; i < N; i++) {
		memo = 0;
		for (int j = 0; j < N; j++) {
			if (memo == 0&&s[j]==0) {
				min = str[j];
				memo++;
				num = j;
			}
			else if (s[j] == 0 && str[j] < min) {
				min = str[j];

				num = j;
			}


		}
		cout << min;
		s[num] = 1;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[1000];
int main()
{
    int n;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    for(int i=n-1; i>=0; i--){
    if(i == 0){
     cout << a[i] << endl;;
    }else{
     cout << a[i] << " ";   
    }
    }
    return 0;
}


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

int main(){
  string  S, T;
  cin >> S >> T;
  if(S.size()+1 == T.size()){
    for(int i = 0; i < S.size(); i++){
      if(S.at(i) != T.at(i)){
        cout << "No";
        return 0;
      }
    }
    cout << "Yes";
    return 0;
  }
  cout << "No";
  return 0;
}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> P;

const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

ll n, a, b;
ll h[112345], tmp[112345];

int main() {
	cin >> n >> a >> b;
	REP(i, n) scanf("%lld", h + i);
	
	ll l = 0, r = 1e10;
	
	while (r - l > 1) {
		ll m = (l + r) / 2;
		
		copy(h, h + n, tmp);
		
		REP(i, n) tmp[i] -= b * m;
		
		ll cnt = 0;
		REP(i, n) if (tmp[i] > 0) cnt += (tmp[i] + a - b - 1) / (a - b);
		if (cnt > m) l = m;
		else r = m;
	}
	
	cout << r << endl;
	
	
	return 0;
}

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

typedef long long ll;

#define rep(i, a, n) for (ll i = a; i < (ll)n; ++i)
#define INF 10e12
#define MOD 1000000007
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define max(x) *max_element(all(x))
#define min(x) *min_element(all(x))

using namespace std;

int main(void)
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n, q;
    cin >> n >> q;
    vector<vector<ll>> g(n);
    rep(i, 0, n - 1)
    {
        ll a, b;
        cin >> a >> b;
        --a, --b;
        g[a].push_back(b), g[b].push_back(a);
    }
    map<ll, ll> mp;
    vector<ll> val(n, -1);
    rep(i, 0, q)
    {
        ll a, b;
        cin >> a >> b;
        --a;
        mp[a] += b;
    }
    queue<ll> que;
    que.push(0);
    val[0] = mp[0];
    while (!que.empty())
    {
        ll tmp = que.front();
        que.pop();
        for (auto i : g[tmp])
        {
            if (val[i] == -1)
                val[i] = val[tmp] + mp[i], que.push(i);
        }
    }
    rep(i, 0, n) cout << val[i] << endl;
}

Measured memory_bytes: 31404
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;

ll gcd(ll a,ll b){
    ll M=max(a,b);
    ll m=min(a,b);
    if(m==0){
        return M;
    }
    return gcd(m,M%m);
}

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    for(ll i=0;i<n;i++) cin>>a[i];
    vector<bool> sosuu(1001001,false);
    bool f=true;
    for(ll i=0;i<n;i++){
        ll x=a[i];
        for(ll j=2;j*j<=x;j++){
            if(x%j!=0) continue;
            if(sosuu[j]==true){
                f=false;
                break;
            }
            sosuu[j]=true;
            while(x%j==0) x/=j;
        }
        if(x!=1){
            if(sosuu[x]==true){
                f=false;
            }
            sosuu[x]=true;
            if(!f) break;
        }
    }
    if(f){
        cout<<"pairwise coprime"<<endl;
        return 0;
    }

    ll g=a[0];
    for(ll i=1;i<n;i++){
        g=gcd(g,a[i]);
    }

    if(g==1){
        cout<<"setwise coprime"<<endl;
    }else{
        cout<<"not coprime"<<endl;
    }
}

Measured memory_bytes: 11116
#include<bits/stdtr1c++.h>
#include<list>
#include<algorithm>
using namespace std;

int main(){
    int X,A,B;
    cin >> X >> A >> B;
    if (B <= A){
        cout << "delicious" << endl;
    }
    else if (B-A <= X){
        cout << "safe" << endl;
    }
    else{
        cout << "dangerous" << endl;
    }
}

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

using namespace std;

int main() {

  char a, b;

  cin >> a >> b;

  if(a == 'H')
    if(b == 'H')
      cout << 'H' << endl;
    else
      cout << 'D' << endl;
  else
    if(b == 'H')
      cout << 'D' << endl;
      else
      cout << 'H' << endl;

  return 0;
}


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

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    cout << min({A+C, A+D, B+C, B+D}) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int D;
  cin >> D;
  vector<int> c(26);
  vector<int> s(26);
  
  rep(i, D) {
  	cout << (i%26)+1 << endl;
  }
}


Measured memory_bytes: 3616
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
int main(){
    string s;
    cin>>s;
    string a, b;
    if(s.size()%2==0){
        a=s.substr(0, s.size()/2);
        b = s.substr(s.size()/2, s.size()/2);
    }
    else{
        a=s.substr(0, s.size()/2);
        b=s.substr(s.size()/2+1, s.size()/2);
    }
    if(s.size()==1) cout<<0;
    else{
        int diff =0;
        for(int i =0; i<a.size(); i++){
            if(a[i]!=b[b.size()-1-i]) diff++;
        }
        cout<<diff;
    }
    return 0;
}

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;
using pii = pair<int, int>;
using vi = vector<int>;
using vii = vector<vector<int>>;

int N, K;
string s;

int main(){
    cin >> K >> s;
    if(s.size() <= K) cout << s;
    else
    {
        rep(i,K){
            cout << s[i];
        }
        cout << "...";
    }
	return 0;
}

Measured memory_bytes: 3636
def solve():
  n,k=[int(i) for i in input().split()]
  h=[int(i) for i in input().split()]
  dp=[0]*n
  for i, hi in enumerate(h):
    if i==0: continue
    x = max(0, i - k)
    dp[i]=min([dpj + abs(hi-hj) for dpj, hj in zip(dp[x:i], h[x:i])])
    #スライサー[x:i]で[x]～[i-1]の部分リストを取得
  return dp[n-1]
print(solve())


Measured memory_bytes: 13980
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        //sc.nextLine();
        String s=sc.next();
       // sc.nextLine();
        int k=sc.nextInt();
        StringBuilder sb=new StringBuilder();
        char c=s.charAt(k-1);
        for(int i=0;i<n;i++)
        {
            if(s.charAt(i)==c)
            {
                sb.append(c);
            }
            else
            {
                sb.append("*");
            }
        }
        System.out.println(sb);
    }
}


Measured memory_bytes: 22996
package main

import (
	"fmt"

	"os"
	"io"
	"bufio"
	"bytes"

	"strings"
	"strconv"
)

//  長い入力を読む
func ReadLongLines(times int) ([]string, error) {
	result := make([]string, times)
	reader := bufio.NewReader(os.Stdin)
	buffer := bytes.NewBuffer(make([]byte, 0))
	readBytes := int64(2)
	for i := 0; i < times; i++ {
		for {
			readBuf, isPrefix, err := reader.ReadLine()
			// fmt.Printf("Reader.Read: %d\n", len(readBuf))
			readBytes += int64(len(readBuf) + 1)
			if err != nil {
				if err == io.EOF {
					fmt.Println("EOF")
					break
				} else {
					return result, err
				}
			}
			_, err = buffer.Write(readBuf)
			if err != nil {
				return result, err
			}
			// end of line
			if !isPrefix {
				result[i] = buffer.String()
				buffer.Reset()
				// reader = bufio.NewReader(os.Stdin)
				break
			}
		}
	}
	// 先読みしてしまうようなので、戻しておく
	os.Stdin.Seek(-int64(reader.Buffered()), os.SEEK_CUR)
	return result, nil
}


// go だと固定長配列とか辛いので無理だった
type Stack struct {
	arr [] int
	back int
}
func NewStack() Stack {
	return Stack{make([]int, 0, 10000), 0}
}

func (this *Stack)Push(i int) {
	if len(this.arr) - 1 < this.back {
		this.arr = append(this.arr, i)
		this.back++
	} else {
		this.arr[this.back] = i
		this.back++
	}
}

func (this *Stack)Top() int {
	return this.arr[this.back - 1]
}

func (this *Stack) Pop() {
	if this.back != 0 {
		this.back--
	}
}

func (this *Stack) Empty() bool {
	return this.back == 0
}



func main() {
	var n int
	var q int

	fmt.Scanf("%d %d", &n, &q)
	stacks := make([]Stack, n)
	for i := 0; i < n; i++ {
		stacks[i] = NewStack()
	}
	lines, _ := ReadLongLines(q)
	for _, line := range lines {
		args := strings.Split(line, " ")
		cmd := args[0]
		switch cmd {
		case "0":
			t, _ := strconv.Atoi(args[1])
			x, _ := strconv.Atoi(args[2])
			// fmt.Printf("push %d < %d\n", t, x)
			stacks[t].Push(x)
		case "1":
			t, _ := strconv.Atoi(args[1])
			// fmt.Printf("top %d\n", t)
			if !stacks[t].Empty() {
				fmt.Println(stacks[t].Top())
			}
		case "2":
			t, _ := strconv.Atoi(args[1])
			// fmt.Printf("pop %d\n", t)
			stacks[t].Pop()
		}
	}
}


Measured memory_bytes: 93456
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, k;
    long long h[200001][3];
    
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        for (int j = 0; j < 3; j++)
        scanf("%lld", &h[i][j]);
        
    long long dp[200001][3];
    for (int i = 1; i <= n; i++)
        for (int j = 0; j < 3; j++)
            for (int k = 0; k < 3; k++)
                if (j != k)
                    dp[i][j] = max(dp[i][j], dp[i - 1][k] + h[i][j]);
    long long ans = 0;
    for (int j = 0; j < 3; j++)
        ans = max(ans, dp[n][j]);
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 9344
#include <stdio.h>

int main(void)
{
	int i, t, n, sum;
	
	for (i = 0; i < 4; i++){
		scanf("%d %d", &t, &n);
		switch(t){
			case 1:
				sum = 6000 * n;
				break;
			case 2:
				sum = 4000 * n;
				break;
			case 3:
				sum = 3000 * n;
				break;
			case 4:
				sum = 2000 * n;
				break;
		}
		printf("%d\n", sum);
	}
	
	return 0;
}

Measured memory_bytes: 600
use std::cmp::max;
use std::io;
use std::io::prelude::*;

const DEBUG: bool = false;

fn main() {
    let stdin = io::stdin();
    let mut input = String::new();
    stdin.lock().read_line(&mut input).expect("read line!");
    let input: String = input;
    println!("{}", solve(&input.trim()))
}

#[derive(Eq, PartialEq, Copy, Clone, Debug)]
enum GL {
    GT,
    LT,
}
impl GL {
    fn from_char(c: char) -> Option<Self> {
        match c {
            '>' => Some(GL::GT),
            '<' => Some(GL::LT),
            _ => None,
        }
    }
}

fn solve(input: &str) -> u64 {
    let mut signs = input
        .chars()
        .map(|c| GL::from_char(c).expect(&format!("invalid! {}", c)));
    let mut ups_and_downs: Vec<(GL, u64)> = vec![];
    if let Some(init) = signs.next() {
        let mut streak = 1;
        let mut current = init;
        for sign in signs {
            if sign == current {
                streak += 1;
            } else {
                ups_and_downs.push((current, streak));
                streak = 1;
                current = sign;
            }
        }
        ups_and_downs.push((current, streak));
    };
    let ups_and_downs = ups_and_downs;
    if DEBUG {
        println!("{:?}", ups_and_downs);
    }
    let mut sum: u64 = 0;
    let mut current_bound: u64 = 0;
    for &(sign, streak) in &ups_and_downs {
        if DEBUG {
            println!("++NEXT! {:?} {:?}", sign, streak);
        }
        let s = streak as u64;
        match sign {
            GL::GT => {
                sum += max(current_bound, s);
                if DEBUG {
                    println!("GT adds\t\t\t {}", max(current_bound, s));
                    println!("GT adds sequence of {}\t that's {}", s, s * (s - 1) / 2);
                }
                sum += s * (s - 1) / 2;
                current_bound = 0;
            }
            GL::LT => {
                current_bound = s;
                sum += s * (s - 1) / 2;
                if DEBUG {
                    println!("LT {}\t {}", s, s * (s - 1) / 2);
                    println!("LT adds sequence of {}\t that's {}", s, s * (s - 1) / 2);
                }
            }
        }
    }
    sum += current_bound;
    sum
}


Measured memory_bytes: 9284
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
using namespace std;
int main(){
    long long n,a,b,ans=0,d;
    cin>>n>>a>>b;
    for(int i=1;i<=n;i++){
        d=i/10000+(i/1000)%10+(i%1000)/100+(i%100)/10+i%10;
        if(d>=a&&d<=b){
            ans+=i;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

#define int long long

signed main(void){
    int n; cin >> n;
    vector<int>a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    int sum_a = accumulate(a.begin(),a.end(),(int)0);
    vector<int>r(n,0),l(n,0);
    for(int i=2;i<n;i++){
        r[i] += r[i-2] + a[i-2];
    }

    l[n-2] = a[n-1];
    for(int i=n-3;0<=i;i--){
        l[i] += l[i+2] + a[i+1];
    }

    // for(int i=0;i<n;i++){
    //     cout << r[i] << ' ';
    // }cout << endl;
    // for(int i=0;i<n;i++){
    //     cout << l[i] << ' ';
    // }cout << endl;

    for(int i=0;i<n;i++){
        cout << sum_a - 2*(r[i]+l[i]);
        if(i!=n-1)cout << ' ';
    }cout << endl;
    return 0;
}



Measured memory_bytes: 3712
package main

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

var sc = bufio.NewScanner(os.Stdin)
var ReadString func() string
var ReadLine func() string
var ReadInt64 func() int64
var ReadInt func() int
var ReadIntSlice func(int) []int
var ReadInt64Slice func(int) []int64
var GetIntAbs func(int) int
var Atoi func(string) int
var FindMin func([] int) int
var FindMax func([] int) int

func init() {
	ReadString = newReadString()
	ReadLine = readLine
	ReadInt64 = readInt64
	ReadInt = readInt
	ReadIntSlice = readIntSlice
	FindMin = findMin
	FindMax = findMax
}

func main() {
	a := ReadInt()
  b := ReadInt()

  if a * b % 2 == 0 {
    fmt.Println("Even")
  } else {
    fmt.Println("Odd")
  }
}

/*------ scan ------*/

func newReadString() func() string {
	sc.Buffer(make([]byte, 1024), 2048)
	sc.Split(bufio.ScanWords)
	return func() string {
		if !sc.Scan() {
			panic("scanできなかった")
		}
		return sc.Text()
	}
}

func readLine() string {
	if !sc.Scan() {
		panic("line をscanできなかった")
	}
	return sc.Text()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		fmt.Println("parseInt失敗")
		panic(err.Error())
	}
	return int64(i)
}

func readInt() int {
	i := ReadInt64()
	return int(i)
}

func readIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ReadInt()
	}
	return arr
}

func readInt64Slice(n int) []int64 {
	arr := make([]int64, n)
	for i := 0; i < n; i++ {
		arr[i] = ReadInt64()
	}
	return arr
}

/*------ number util ------*/

func getIntAbs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

func atoi(a string) int {
	i, err := strconv.Atoi(a)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func findMin(arr []int) int {
	if len(arr) == 0 {
		return 0
	}
	min := arr[0]
	for _, v := range arr {
		if v < min {
			min = v
		}
	}
	return min
}

func findMax(arr []int) int {
	if len(arr) == 0 {
		return 0
	}
	max := arr[0]
	for _, v := range arr {
		if v > max {
			max = v
		}
	}
	return max
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <unistd.h>
#define ll long long
#define ull unsigned long long
#define inf 1000000007
#define inf16 0x3f3f3f3f
#define INF 1000000000000000007LL
#define VI vector<int>
#define VPII vector<pair<int, int> >
#define VLL vector<ll>
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
#define flush fflush(stdout)
using namespace std;

#define N 100007

int n;

int a[N];

int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);

	cin >> n;

	for(int i = 1; i <= n; ++i)
	{
		cin >> a[i];
	}

	sort(a+1, a+1+n);

	if(a[1]+1<a[n])
		cout << "No";
	else if(a[1]==a[n])
	{
		if(n>=2*a[1] || a[1]==n-1)
			cout << "Yes";
		else
			cout << "No";
	}
	else
	{
		int i = 1;

		while(a[i+1]==a[i])
			++i;

		if(a[i]>=i && n-i>=2*(a[i]-i+1) && i!=n-1)
			cout << "Yes";
		else
			cout << "No";
	}
}


Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;

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

int main() {
	int H, W;
	cin >> H >> W;

	string s[101];

	REP(i, H) {
		cin >> s[i];
	}

	REP(i, H + 2) {

		REP(j, W + 2) {
			if (i == 0 || i == H + 1) {
				cout << "#";
				continue;
			}
			if (j == 0 || j == W + 1) {
				cout << "#";
				continue;
			}
			
			cout << s[i - 1][j - 1];
		}
		cout << endl;
	}

	return 0;
}

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

ll cnt = 0;

int insertionSort(vector<int>& A, int n, int g) {
    for (int i = g; i < n; i++) {
        int v = A[i];
        int j = i - g;
        while (j >= 0 && A[j] > v) {
            A[j + g] = A[j];
            j = j - g;
            cnt++;
        }
        A[j + g] = v;
    }
    return 0;
}

int shellSort(vector<int>& A, int n) {
    vector<int> G;
    for (int h = 1; h <= n; h = 3*h + 1) {
        G.push_back(h);
    }
    cout << G.size() << endl;
    for (int i = G.size() - 1; i >= 0; i--) {
        if (i != 0) cout << G[i] << " ";
        else cout << G[i] << endl;
        insertionSort(A, n, G[i]);
    }
    cout << cnt << endl;
    return 0;
}

int main() {
    int n;
    cin >> n;
    vector<int> A(n);
    rep(i, n) scanf("%d", &A[i]);
    shellSort(A, n);
    rep(i, n) cout << A[i] << endl;
    return 0;
}


Measured memory_bytes: 6760
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    string s; cin >> s;
    int ans = 0, cur = 0;
    for (auto ch : s) {
        if (ch == 'R') {
            cur ++;
        } else {
            cur = 0;
        }
        ans = max(ans, cur);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3148
a ,b, k = map(int,input().split())
ans = []
if (b - a) // 2 < k:
    for i in range(a , b + 1):
        print(i)
else:
    for i in range(k):
        ans.append(a + i)
    for i in range(k):
        i = k - i -1
        ans.append(b - i)
    ans = sorted(set(ans))
    for i in ans:
        print(i)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int m, d;
  cin >> m >> d;
  int ans = 0;
  rep2(i, 1, m+1){
    rep2(j, 11, d+1){
      int d1 = j % 10, d2 = j / 10;
      if(d1 < 2 || d2 < 2) continue;
      if(d1 * d2 == i){
        // cerr << d1 << " " << d2 << " " << i << endl;
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
    long long N, A, B; cin >> N >> A >> B;
    if (A > B) cout << 0 << endl;
    else if (N == 1) cout << (A == B ? 1 : 0) << endl;
    else cout << (N-2) * (B-A) + 1 << endl;
}


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

int main()
{
  int n;
  cin >> n;
  int dp[n+1];
  dp[0] = 1;
  dp[1] = 1;
  for(int i=2;i <= n;i++){
      dp[i] = dp[i-1]+dp[i-2];
  }
  
  printf("%d\n",dp[n]);
  return 0;
}



Measured memory_bytes: 3220
#include <sstream>
#include <fstream>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <bitset>
#include <cstdlib>
#include <ctime>
#include <cstdio>


#include <stdlib.h>
#include <iostream>
#include <chrono> //clock
#include <vector>
#include <string>
#include <iomanip>  //setprecision function
#include <cmath>	//math
#include <cstdio>
#include <vector>	//vector array
#include <algorithm>	//STL algorithm
#include <set> //STL library set
#include <sstream> // for stringstream


using namespace std;
using namespace std::chrono; 


int main() {
	stringstream ss;
	//ss<<"akhil";
	//cout<<ss.str()<<endl;
	cout<<setprecision(16);
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	
	 // TESTCASE KO DEKH KA BHAUT SARA CONDITION GENERATE MAT KRO 
	 // PAPER PD CONFIRM HO JAO THORA JADA TIME HI KYU NA LGA
	 
	 // WHILE DOING THE QUESTION OF DYNAMIC PROGRAMMING GREEDY KA TRAH SOCHNA BAND KRO
	 // DP M DATA KA BHI USE KRNA PDTA HA BE BHULO MT 
	 // DP BHI WO LEETCODE WALE MATRIX KA QUESTION KI TARAH HA
	 // CONSTRAIN WILL BE THE DIMENSION OF DP


	int N;
	cin>>N;
	int mat[N][3];
	for(int i=0;i<N;i++){
		for(int j=0;j<3;j++){
			cin>>mat[i][j];
		}
	}


	int dp[N+1][3];// i have created 2d dp  first is for no of days and
										 //second is for last activities
	for(int i=0;i<3;i++){
		dp[0][i]=0;
	}
	
	for(int days=1;days<=N;days++){
		for(int act=0;act<3;act++){
			if(act==0)
				dp[days][act]=max(dp[days-1][1],dp[days-1][2])+mat[days-1][act];
			else if(act==1)
				dp[days][act]=max(dp[days-1][0],dp[days-1][2])+mat[days-1][act];
			else
				dp[days][act]=max(dp[days-1][0],dp[days-1][1])+mat[days-1][act];
		}
	}
	
	int a=max(dp[N][0],dp[N][1]);
	cout<<max(a,dp[N][2])<<endl;
	
	
	
	return 0;
}





























Measured memory_bytes: 2560
import itertools
import math
N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]
sum = 0
for i in itertools.permutations(xy, N):
    for j in range(N-1):
       sum += ((i[j][0]-i[j+1][0])**2+(i[j][1]-i[j+1][1])**2)**0.5
print(sum/math.factorial(N))


Measured memory_bytes: 74404
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int a, b, c;
    cin >> a >> b >> c;
    if(a < b && b < c) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}



Measured memory_bytes: 3096
#include <iostream>
#include<algorithm>
#include<string>
#include<vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
using namespace std;


int main()
{
	string sO, sE, ans = {""};
	cin >> sO >> sE;
	for (int i = 0; i < max(sO.length(),sE.length()); i++) {
		if(sO[i] != NULL)ans += sO[i];
		if(sE[i] != NULL)ans += sE[i];
	}
	cout << ans << endl;
}

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

if N==0:
    print(0)
else:
    answer=[]
    while N != 0:

        if N % (-2) == 0:
            N=N//(-2)
            answer.append(0)
        else:
            N=N//(-2)+1
            answer.append(1)

    print(''.join(list(map(str, reversed(answer)))))


Measured memory_bytes: 38256
import bisect

def main():
    N = int(input())
    L = list(map(int, input().split()))

    L = sorted(L)
    
    ans = 0
    for i in range(N-1):
        for j in range((i+1), N):    
            c = bisect.bisect_left(L, L[i] + L[j], j+1)
            ans += c - j - 1

    print(ans)


if __name__ == '__main__':
    main()



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

int main()
{
  long long n;

  cin >> n;

  vector<long long> a(n);

  long long sum = 0;

  long long MOD = 1000000007;
  long long ans = 0;

  rep(i, n)
  {
    cin >> a.at(i);
    ans += a.at(i);
    ans %= MOD;
  }
  // cout << ans << endl;

  for (int i = 0; i < n; i++)
  {
    ans -= a.at(i);
    if (ans < 0)
      ans += MOD;
    sum += (a.at(i) * ans);
    sum %= MOD;
  }

  cout << sum;
}


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

using namespace std;

int read() {
  int res = 0, w = 1; char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-') c = getchar(), w = -1;
  while (isdigit(c)) res = (res << 1) + (res << 3) + c - '0', c = getchar();
  return res * w;
}

struct Dsu {
  vector<int> fa;

  void init(int n) {
    fa.resize(n + 3);
    for (int i = 1; i <= n; i++) fa[i] = i;
  }

  int find(int x) {
    return x == fa[x] ? x : fa[x] = find(fa[x]);
  }

  bool merge(int x, int y) {
    x = find(x), y = find(y);
    if (x == y) return 0;
    fa[x] = y;
    return 1;
  }
} dsu;

const int N = 5e5 + 10;

int n, m, q, Mod;
int u[N], v[N], w[N];

int main() {
  n = read(), m = read(), q = read(), Mod = read();
  int g = Mod;
  for (int i = 1; i <= m; i++) {
    u[i] = read(), v[i] = read(), w[i] = read();
    if (i != 1) {
      g = __gcd(g, abs(w[i] - w[1]));
    }
  }
  if ((Mod / g) % 3 == 0) Mod = g * 3;
  else Mod = g;
  int z = w[1] % g;
  dsu.init((n + 2) * 6);
  for (int i = 1; i <= m; i++) {
    int p = (w[i] - z) / g % 3;
    for (int j = 0; j < 3; j++) {
      dsu.merge(u[i] * 6 + j * 2 + 0, v[i] * 6 + (2 * j + p) % 3 * 2 + 1);
      dsu.merge(u[i] * 6 + j * 2 + 1, v[i] * 6 + (2 * j + p) % 3 * 2 + 0);
      dsu.merge(v[i] * 6 + j * 2 + 0, u[i] * 6 + (2 * j + p) % 3 * 2 + 1);
      dsu.merge(v[i] * 6 + j * 2 + 1, u[i] * 6 + (2 * j + p) % 3 * 2 + 0);
    }
  }
  vector<vector<bool> > can(2, vector<bool>(Mod));
  for (int i = 0, j = z; i < g * 2; i++, j = j * 2 % Mod) {
    can[i & 1][j] = 1;
  }
  while (q--) {
    int s = read(), t = read(), r = read();
    bool ans = 0;
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 2; j++) {
        if (dsu.find(t * 6) == dsu.find(s * 6 + i * 2 + j)) {
          if (can[j][(r + z + (3 - i) * g) % Mod]) {
            ans = true;
          }
        }
      }
    }
    if (ans) puts("YES");
    else puts("NO");
  }
  return 0;
}


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

int main()
{
  int K, X;
  cin >> K >> X;
  for (int i = X - (K - 1); i <= X + (K - 1); i++)
  {
    cout << i << " ";
  }
  cout << endl;
  return 0;
}


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

#define SUBTASK 2

using ll = long long;

const ll XMAX = 1.1e17;

const int MAXN = 1.1e5;
int N;
pair<ll, ll> P[MAXN];

bool checkPt(ll Y) {
	bool res = 0;
	for (int i = 0; i < N; i++) {
		res ^= (((Y - P[i].second) | P[i].first) == P[i].first);
	}
	return res;
}

pair<ll, ll> ptToBounds(ll Y) {
	assert(checkPt(Y));
	ll lo = Y, hi = Y;
	for (int l = 59; l >= 0; l--) {
		if (checkPt(hi + (1ll << l))) {
			hi += (1ll << l);
		}
		if (checkPt(lo - (1ll << l))) {
			lo -= (1ll << l);
		}
	}
	return {hi - lo, lo};
}

pair<ll, ll> goSub1() {
	return ptToBounds(XMAX);
}

bool checkRng(ll Ymin, ll v3) {
	bool res = 0;
	for (int i = 0; i < N; i++) {
		ll curMin = max(0ll, Ymin - P[i].second);

		// must be strictly greater than curMin
		bool dp[3] = {0,0,0};

		for (int l = 59; l >= 0; l--) {
			if (!(P[i].first & (1ll << l))) continue; // must be 0

			{
				bool ndp[3] = {0,0,0};
				for (int z = 0; z < 3; z++) {
					ndp[z] = dp[z];
				}
				for (int z = 0; z < 3; z++) {
					ndp[(z+(1ll << l)) % 3] ^= dp[z];
				}
				for (int z = 0; z < 3; z++) {
					dp[z] = ndp[z];
				}
			}

			if (!(curMin & (1ll << l))) {
				// we can increment and be bigger
				ll val = ((curMin >> l) | 1) << l;
				if ((val | P[i].first) == P[i].first) {
					dp[(val + P[i].second) % 3] ^= 1;
				}
			}
		}

		if ((curMin | P[i].first) == P[i].first) {
			dp[(curMin + P[i].second) % 3] ^= 1;
		}

		res ^= dp[v3];
	}
	return res;
}

pair<ll, ll> go() {
	ll v3 = 0;
	while (!checkRng(0, v3)) {
		v3++;
		assert(v3 < 3);
	}

	ll mi = 0;
	ll ma = ll(1e18);
	while (ma - mi > 1) {
		ll md = (mi + ma) / 2;
		if (checkRng(md, v3)) {
			mi = md;
		} else {
			ma = md;
		}
	}

	return ptToBounds(mi);
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> P[i].first >> P[i].second;
		P[i].first += XMAX;
		P[i].second += XMAX;
		assert(P[i].first >= 0);
		assert(P[i].second >= 0);
	}

#if SUBTASK == 1
	auto ans = goSub1();
#else
	auto ans = go();
#endif
	ans.first -= XMAX;
	ans.second -= XMAX;

#if SUBTASK == 1
	cout << ans.first << '\n';
#else
	cout << ans.first << ' ' << ans.second << '\n';
#endif

	return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define ff first
#define ss second
#define ll long long
#define vi vector<int>
#define vii vector<vi>
#define vs vector<string>
#define vss vector<vs>
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define repr(i, a, n) for (int i = (n); i >= (a); --i)
using namespace std;
const int INF(1 << 30);
const ll LLINF(1LL << 55LL);
const int pi = 3.1415926536;
const int MOD = 1000000007;
const int MAX = 510000;

void Main() {
  int x, t;
  cin >> x >> t;
  if (x < t)
    cout << 0 << endl;
  else
    cout << x - t << endl;
}

int main() {
  std::cin.tie(nullptr);                  // 標準入出力高速化
  std::ios_base::sync_with_stdio(false);  // SとS++の入出力出力を非同期
  std::cout << std::fixed << std::setprecision(15);  // 小数を10進数表示
  Main();
}

Measured memory_bytes: 256