akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <bitset>
#include <functional>
#include <queue>
#include <utility>
#include <map>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<string, PII> PSI;
const int INF = 1 << 29;	// 十分大きい値にする, INT_MAX にしないのはオーバーフロー対策

void solve()
{
	const int MAX_N = 100;
	int N;
	string S[MAX_N];
	int P[MAX_N];

	priority_queue<PSI, vector<PSI>, function<bool(PSI, PSI)>> que([](PSI a, PSI b) {
		if (a.first == b.first)
			return a.second.first < b.second.first;
		return a.first > b.first;
	});

	cin >> N;
	FOR(i, 0, N) {
		cin >> S[i] >> P[i];
		que.push(PSI(S[i], PII(P[i], i + 1)));
	}

	while (!que.empty()) {
		cout << que.top().second.second << endl;
		que.pop();
	}

}

int main(void)
{
	solve();

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
#define ll long long

int main()
{
    ll a, b, c , d;
    cin >> a >> b >> c >> d;
    
    ll t1 = a*c;
    ll t2 = a*d;
    ll t3 = b*c;
    ll t4 = b*d;
    
    cout << max(max(t1, t2), max(t3, t4));
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  double T;
  double A;
  cin >> N >> T >> A;
  vector<int> H(N);
  REP(i, N) cin >> H[i];
  int ans = -1;
  double mnd = 10000000;
  for(int i = 0; i < N; i++) {
    double meant;
    meant = T - H[i] * 0.006;
    if(mnd > abs(meant - A)) {
      mnd = abs(meant - A);
      ans = i;
    }
  }

  cout << ans + 1 << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream> 
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <sstream>
#include <vector>

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++)

int main() {
	int n, a;
	cin >> n >> a;
	if (n * a % 2 != 0) {
		cout << "Odd" << endl;

	}
	else {
		cout << "Even" << endl;
	}
	return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
//#define int long long

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

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int n;


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];

    int ans = 0;
    REP(i, n){
        while(a[i] % 2 == 0){
            ans++;
            a[i] /= 2;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
package main

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

var (
	rdr   = bufio.NewReaderSize(os.Stdin, 1000000)
	reply string
)

func main() {
	var h string
	fmt.Scan(&h)
	solve([]string{h})
}

func solve(buf []string) {
	h, _ := strconv.Atoi(buf[0])
	if h == 0 {
		fmt.Println(0)
		return
	}
	var ans int = 1
	for i := 0; ans <= h; i++ {
		ans *= 2
	}
	reply = strconv.Itoa(ans - 1)
	fmt.Println(reply)
}

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func nextSlice() []string {
	return strings.Split(readLine(), " ")
}

func atoi(a []string) (b []int) {
	b = make([]int, len(a))
	for i := range a {
		b[i], _ = strconv.Atoi(a[i])
	}
	return
}

func atof(a []string) (b []float64) {
	b = make([]float64, len(a))
	for i := range a {
		b[i], _ = strconv.ParseFloat(a[i], 64)
	}
	return
}

func scanSlice2(n int) (a []int, b []int) {
	a = make([]int, n)
	b = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

func scanFloatSlice2(n int) (a []float64, b []float64) {
	a = make([]float64, n)
	b = make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

// ---------------------------------------------------

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

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

func min(a ...int) int {
	min := a[0]
	for i := 1; i < len(a); i++ {
		if min > a[i] {
			min = a[i]
		}
	}
	return min
}

func max(a ...int) int {
	max := a[0]
	for i := 1; i < len(a); i++ {
		if max < a[i] {
			max = a[i]
		}
	}
	return max
}

func sum(a []int) (ans int) {
	for i := range a {
		ans += a[i]
	}
	return
}

// ---------------------------------------------------

func yesOrNo(b bool) {
	if b {
		reply = "Yes"
		fmt.Println(reply)
		return
	}
	reply = "No"
	fmt.Println(reply)
}

func yesorNO(b bool) {
	if b {
		reply = "Yes"
		fmt.Println(reply)
		return
	}
	reply = "No"
	fmt.Println(reply)
}

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

using ll = long long;
using ull = unsigned long long;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define bzero(p, n) memset(p, 0, n)
#define all(a) begin(a),end(a)
template<class T> inline void sort_uniq(T& c) { sort(ALL(c)); c.erase(unique(ALL(c)), c.end()); }
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
inline int powi(int x,int y) {int p=1; while(y--) p*=x; return p;}
inline ll powll(ll x,ll y) {ll p=1; while(y--) p*=x; return p;}
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    int N, M; cin >> N>>M;
    // cout << FMT2(N, M) << endl;
    vector<int> s(M);
    int k, _s;
    rep(i, M) {
        cin >> k;
        rep(j, k) {
            cin >> _s; 
            s[i] |= 1 << (_s - 1);
        }
        // cout << FMT2(i, s[i]) <<", "<<bitset<10>(s[i])<< endl;
    }
    vector<int> p(M); cin >> p;
    // cout<<"p:"<<endl; cout_h(p);

    int ans = 0;
    for (int sw = 0; sw < powi(2, N); sw++) {
        bool all_on = true;
        for (int i = 0; i < M; i++) {
            int masked = sw & s[i];
            int n_on = 0;
            for (int b = 0; b < N; b++) {
                if (masked & (1<<b)) n_on++;
            }
            if (n_on % 2 != p[i]) {
                all_on = false;
                break;
            }
        }
        if (all_on)
            ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    vi a(5);
    rep(i, 5) cin >> a[i];
    
    int ans = 10000;
    rep(i, 5) {
        int sum = 0;
        rep(j, 5) {
            if (i == j) {
                sum += a[j];
            } else {
                sum += ((a[j]+9)/10)*10;
            }
        }
        chmin(ans, sum);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b, c = LI()
    if a == b + c:
        print("Yes")
    elif b == a + c:
        print("Yes")
    elif c == a + b:
        print("Yes")
    else:
        print("No")
    return

#B
def B():
    W, H, n = LI()
    wh = [[0, W], [0, H]]
    for _ in range(n):
        x, y, a = LI()
        wha = wh[a > 2]
        x = y if a > 2 else x
        wha[0] = max(x, wha[0]) * (a % 2) or wha[0]
        wha[1] = wha[1] * (a % 2) or min(x, wha[1])
        if wha[0] >= wha[1]:
            print(0)
            return
    print(max(0, (wh[0][1] - wh[0][0]) * (wh[1][1] - wh[1][0])))
    return

#C
def C():
    return

#D
def D():
    return

#Solve
if __name__ == '__main__':
    B()


Measured memory_bytes: 38640
// When you are hungry for something and you're determined and you're focused 
// and you're committed to something it's hard to surrender, isn't it?

#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define ll long long 
#define int ll
#define mod 1000000007
#define mod1 1000000006
#define modi 998244353
#define setbit(x) __builtin_popcount(x)
#define fff(i,n) for(int i=0;i<n;i++)
#define ff first
#define ss second
#define pb push_back
vector<ll> vi[300005];
int color[100005];
ll pa[500005];
ll si[500005];
#define pb push_back
bool visi[1000005]={false};
bool is[100005];
ll fac[10000001];
ll prime[400005];
ll bit[100005];
const long double eps = 1.0e-14;      // allowable error
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
 
 
void fact(){
    fac[0]=1;
    for(int i=1;i<=10000000;i++){
        fac[i]=(fac[i-1]*i)%mod;
    }
    return ;
}
void sieve(){
    prime[0]=0;
    prime[1]=0;
    for(int i=2;i<400005;i++){
        prime[i]=1;
    }
    for(int i=2;i*i<400005;i++){
        if(prime[i]==1){
            for(int j=i*i;j<400005;j+=i){
                prime[j]=0;
            }
        }
    }
    
}
 
ll power(ll n , ll p ){
    if(p==0)
        return 1;
    
    ll res = power((n*n)%mod,p/2);
    if(p%2==1)
        res = (n*res)%mod;
    
    return res;
}
 
 
void upd(ll i,ll val,ll n) {
    for(;i<=n;i+=i&(-i))
        bit[i]+=val;
}
 
ll qry(ll i) {
    ll sum=0;
    for(;i>0;i-=i&(-i))
        sum+=bit[i];
    return sum;
}
 
 
ll fin(ll u) {
    if(pa[u]==u)
        return u;
    return fin(pa[u]);
}
 
void uni(ll u,ll v) {
    ll p1=fin(u);
    ll p2=fin(v);
    if(p1==p2)
        return;
    if(si[p1]<si[p2])
        swap(p1,p2);
    si[p1]+=si[p2];
    pa[p2]=p1;
    return;
}
 
int32_t main() {
    fio
    
    int n;
    cin >> n;
    map<int,int> m;
    
    fff(i,n) {
        int x;
        cin >> x;
        if(m[x]>0) {
            cout << "NO" << endl;
            return 0;
        }
        m[x]=1;
    }
    cout << "YES" << endl;


	return 0;
    
}

Measured memory_bytes: 21376
#include <iostream>
#include <math.h>
using namespace std;
 
int main(void){
  int a,b,c;
  cin >> a >> b >> c;
  int maxi = max(max(a,b),max(a,c));
  printf("%d\n",maxi*10+a+b+c-maxi);
  return 0;
}

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

int main(){
    int n, W;
    cin >> n >> W;
    vector<long long> w(n), v(n);
    for (int i = 0; i < n; i++) cin >> w[i] >> v[i];

    long long sum_value = 0;
    for (int x : v) sum_value += x;
    //vector<long long> dp(sum_value + 1,INF);
    long long dp[n][sum_value + 1];
    for (int i = 0; i < n; i++) for (int j = 0; j <= sum_value; j++) dp[i][j] = INF;
    //for (int i = 0; i <= sum_value; i++) dp[0][i] = 0;
    dp[0][0] = 0;
    dp[0][v[0]] = w[0];

    for (int i = 1; i < n; i++){
        for (int j = 0; j <= sum_value; j++){
            dp[i][j] = min(dp[i][j], dp[i -1][j]);
            if (j - v[i] >= 0)
                dp[i][j] = min(dp[i][j], dp[i - 1][j - v[i]] + w[i]);
        }
    }
    //cout << dp[1][6] << endl;
    for (int i = sum_value; i >= 0; i--) //cout << dp[n - 1][i] << " ";
    if (dp[n -1][i] <= W) {
        cout << i << " ";
        break;
    }

}


Measured memory_bytes: 78336
#include <iostream>
using namespace std;
#include <vector>
 
int main() {
	// your code goes here
  int n,m;
  cin>>n>>m;
  vector<vector<char>> edges (n , vector<char> (m , '.'));
  for(int i=0;i<n;i++){
  	for(int j=0;j<m;j++){
  		cin>>edges[i][j];
  		//cout<<edges[i][j]<<endl;
  	}
  }
  vector<vector<long long>> dp (n , vector<long long> (m , 0));
  int start=n-2;
  while(start>=0 && edges[start][m-1]=='.'){
  	dp[start][m-1]=1;
  	
  	start--;
  }
  start=m-2;
  while(start>=0 && edges[n-1][start]=='.'){
  	dp[n-1][start]=1;
  	
  	start--;
  }
  int mod=1000000007;
  for(int i=n-2;i>=0;i--){
  	for(int j=m-2;j>=0;j--){
  		if(edges[i][j]=='#'){
  			dp[i][j]=0;
  		}
  		else{
  			dp[i][j]=((dp[i+1][j])%mod+(dp[i][j+1]%mod))%mod;
  		}
  	}
  }
  cout<<dp[0][0]<<endl;
	return 0;
}

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

int main(){
    int n;cin>>n;
    int arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    sort(arr,arr+n);
    if(n%2!=0){cout<<"0\n";return 0;}
    cout<<arr[(n/2)]-arr[n/2-1]<<"\n";
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;

#define F            first
#define S            second
#define pb(x)        push_back(x)
#define mp(a,b)      make_pair(a,b)
#define mt(a,b,c)    make_tuple(a,b,c);
#define sz           size()
#define all(A)       A.begin(), A.end()
#define mem(a, b)    memset(a, b, sizeof(a))   // all elements of A are b=0 or b=-1 else don't work
#define f0(i,b)      for(ll i=0;i<(b);i++)
#define f1(i,b)      for(ll i=1;i<=(b);i++)
#define f2(i,a,b)    for(ll i=(a);i<=(b);i++)
#define f3(i,b,a)    for(ll i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(ll i=(a);i!=(b);i+=(c))

#define mod          10000
#define PI acos(-1.0)

#define whilee(i,t)  while(i!=t)
#define  sl(a)       scanf("%lld",&a)
#define  pl(a)       printf("%lld\n",a)

#define scan(x)      do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;

//for(auto it =A.begin(); it!=A.end(); it++)
//sort(A.begin(),A.end()); //sort(A, +n, greater<int>());
//binary_search(A.begin(),A.end(),x);
//reverse(A.begin(), A.end());
//cout << *max_element(A.begin(), A.end());
//cout << *min_element(A.begin(), A.end());
//count(A.begin(), A.end(), X); //counts the occurrences of X
//distance(A.begin(),A.end());  //distance between first to last element
//accumulate(A.begin(), A.end(), 0); //add
//next_permutation(A.begin(), A.end());
//prev_permutation(A.begin(), A.end());
//swap(S[0], T[0]);

//scanf("%lld",&x);
//printf("%lld\n",x);
//while (scanf("%lld %lld", &a, &b) == 2)
//printf("Case %lld: %lld\n", t++, a);

//vector <ll> A;
//deque <ll> A;
//queue <ll> A;
//stack <ll> A;
//list <int> A;
//set <ll> A;
//map <ll,ll> A;
//pair <ll,ll> A ;
//tuple <ll, ll, ll> A;
//vector <pair <ll,ll>> A ;
//bitset<32> bset1;
//bool ok = true;
//char ch;
string S, T, U;
ll i=0, j=0, k=0, a, b, c, d, e, f, g, h, l, m, n, o, p, q, r, s, t=1, u, v, w, x, y, z, maxx=INT_MIN, minn=INT_MAX, ans=0, sum=0, cnt=0;

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

    //scan(n);
    cin>>S>>T;

    f0(i,3)
    {
        if(S[i]==T[i])
        {
            cnt++;
        }
    }

    cout<<cnt<<endl;
    return 0;
}


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

Asum_li = [0]
Asum = 0
Bsum_li = [0]
Bsum = 0

for A_ in A:
    Asum = Asum + A_
    Asum_li.append(Asum)

for B_ in B:
    Bsum = Bsum + B_
    Bsum_li.append(Bsum)

cnt_max = 0
cnt_b = M

for cnt_a in range(N+1):

    if Asum_li[cnt_a] > K : break

    while (Bsum_li[cnt_b] + Asum_li[cnt_a]) > K:
        cnt_b = cnt_b - 1
        if cnt_b < 0: break

    if (cnt_max < cnt_a + cnt_b): cnt_max = cnt_a + cnt_b


print(cnt_max)



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

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


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

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

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};


int main()
{
  ll k, a, b;
  cin >> k >> a >> b;
  if(b-a > 2) {
    ll ans = a + (k-a+1)/2*(b-a) + (k-a+1)%2;
    cout << ans << endl;
  }
  else cout << k+1 << endl;
}

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

int main()
{
    long long n, a[200001]={0}, i, cnt[200001]={0}, b[200001]={0}, j=0, m=0;
    long long f=0;
    cin >> n;
    for(i=1;i<=n;i++){
        cin >>a[i];
    }
    for(i=n;i>0;i--){
        if(cnt[i]%2 != a[i]){
            m++;
            b[i]++;
            for(j=1;j*j<=i;j++){
                if(i%j==0){
                    cnt[j]++;
                    if(j*j!=i) cnt[i/j]++;
                }
            }
        }
    }
    cout << m <<endl;
    for(i=1;i<=n;i++){
        if(b[i]==1){
            cout << i << " ";
            f=1;
        }
    }
    if(f==1) printf("\n");
    return 0;
}


Measured memory_bytes: 5760
def main():
    '''
    A => 0
    C => 1
    G => 2
    T => 3
    '''
    N = int(input())
    MOD = 10 ** 9 + 7
    dp = [[[[0] * 4 for _ in range(4)] for _ in range(4)] for _ in range(105)]
    
    dp[0][3][3][3] = 1

    for n in range(N):
        for i in range(4):
            for j in range(4):
                for k in range(4):
                    for new in range(4):
                        if j == 0 and k == 2 and new == 1:
                            continue
                        if j == 2 and k == 0 and new == 1:
                            continue
                        if j == 0 and k == 1 and new == 2:
                            continue
                        if i == 0 and k == 2 and new == 1:
                            continue
                        if i == 0 and j == 2 and new == 1:
                            continue

                        dp[n+1][j][k][new] += dp[n][i][j][k]
                        dp[n+1][j][k][new] %= MOD

    ans = 0
    for i in range(4):
        for j in range(4):
            for k in range(4):
                ans += dp[N][i][j][k]
                ans %= MOD

    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 44912
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    ll N;
    cin >> N;
    vector<ll> p(N), b(N);
    rep(i, N) cin >> p[i];

    rep(i, N - 1) cout << 1 + N * i << " ";
    cout << 1 + N * (N - 1) << endl;

    ll li = N * (N - 1) + 1;

    rep(i, N) {
        b[p[i] - 1] = (li + i + 1) - (1 + N * (p[i] - 1));
    }

    rep(i, N - 1) cout << b[i] << " ";
    cout << b[N - 1] << endl; 
    return 0;
}

Measured memory_bytes: 896
package main

import (
	"fmt"
)

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

	as := make([]int, n+1)
	bs := make([]int, n)
	for i := 0; i < n+1; i++ {
		fmt.Scan(&as[i])
	}
	for i := 0; i < n; i++ {
		fmt.Scan(&bs[i])
	}

	count := 0
	for i := 0; i < n; i++ {
		if bs[i] > as[i] {
			count += as[i]
			bs[i] -= as[i]

			if bs[i] > as[i+1] {
				count += as[i+1]
				as[i+1] = 0
			} else {
				count += bs[i]
				as[i+1] -= bs[i]
			}
		} else {
			count += bs[i]
			as[i] -= bs[i]
		}
	}
	fmt.Print(count)
}


Measured memory_bytes: 7424
#include <iostream>
#include <algorithm>
#define int long long
using namespace std;

int n, t;
int h[100001];

signed main() {
	int i;
	
	cin >> n >> t;
	for (i = 0; i < n; i++) cin >> h[i];
	
	int rem = t, maxi = h[0];
	for (i = 0; i < n; i++) {
		cout << max((rem + maxi - h[i]) / maxi, 0LL) + 1 << endl;
		rem -= h[i];
		maxi = max(maxi, h[i + 1]);
	}
	return 0;
}

Measured memory_bytes: 3872
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int n, m, num[20], dp[20][70007], fac[70007], inv[70007], res = 0;
int add(int& a, int b)
{
	a += b;
	if (a >= mod)a -= mod;
	return 0;
}
int c(int a, int b)
{
	return 1LL * fac[a] * inv[b] % mod * inv[a - b] % mod;
}
int main()
{
	cin >> n >> m;
	for (int i = 1; i <= m; i++)
		cin >> num[i];
	fac[0] = fac[1] = inv[0] = inv[1] = 1;
	for (int i = 2; i <= (1 << n); i++)
		fac[i] = 1LL * fac[i - 1] * i % mod;
	for (int i = 2; i <= (1 << n); i++)
		inv[i] = 1LL * (mod - mod / i) * inv[mod % i] % mod;
	for (int i = 2; i <= (1 << n); i++)
		inv[i] = 1LL * inv[i - 1] * inv[i] % mod;
	sort(num + 1, num + m + 1);
	dp[m + 1][0] = 1;
	for (int i = m; i >= 1; i--)
		for (int j = 0; j < (1 << n); j++)
		{
			add(dp[i][j], dp[i + 1][j]);
			int t = (1 << n) - j - num[i];
			for (int k = 0; k < n; k++)
				if (!((j >> k) & 1))
				{
					if (t < (1 << k) - 1)break;
					add(dp[i][j | (1 << k)], 1LL * dp[i + 1][j] * c(t, (1 << k) - 1) % mod * fac[1 << k] % mod) % mod;
				}
		}
	for (int i = 0; i < (1 << n); i++)
	{
		int c = 1;
		for (int j = 0; j < n; j++)
			if ((i >> j) & 1)c *= -1;
		add(c, mod);
		res = (res + 1LL * c * dp[1][i] % mod * fac[(1 << n) - i - 1] % mod) % mod;
	}
	cout << 1LL * res * (1 << n) % mod << endl;
	return 0;
}

Measured memory_bytes: 4992
#include<stdio.h>

int main() {
	int a[3], buff;
	scanf("%d %d %d", &a[0], &a[1], &a[2]);
	for (int i = 0; i < 2; i++) {
		if (a[i] > a[i + 1]) {
			buff = a[i];
			a[i] = a[i + 1];
			a[i + 1] = buff;
		}
	}
	if (a[0] > a[1]) {
		buff = a[0];
		a[0] = a[1];
		a[1] = buff;
	}
	printf("%d %d %d\n", a[0], a[1], a[2]);

	return 0;
}


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

int main()
{
    double d,t,s;
    cin>>d>>t>>s;
    double x=d/s;
    if(x<=t)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3696
package main

import (
	"fmt"
///	"strings"
///	"strconv"
)

func ShiftOnly(integers []int) int {
	var integer int
	tmparray := []int{}
	for {
		for _, str:=range integers {
			if str%2 != 0 {
				return integer
			} else {
				tmparray = append(tmparray,str/2)
			}
        	}
		integer += 1
	        integers = tmparray	
		tmparray = []int{}
	}	
}



func main() {
        var a int
        var b int
        fmt.Scan(&a)
	tmparray := []int{}
        
	for i:=0; i < a; i++  {
        	fmt.Scan(&b)
		tmparray = append(tmparray,b)

        }

        defer fmt.Println(ShiftOnly(tmparray))
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if(a+b>16)
	{
		cout<<":("<<endl;
		return 0;
	}
	int x,y;
	if(a>=b)
	{
		x=a;
		y=b;
	}
	else
	{
		x=b;
		y=a;
	}
	int ans=x-y;
	int ans1=16-y*2;
	if(ans1%2==1)
	{
		ans1++;
	}
	ans1/=2;
	if(ans1>=ans)
	{
		cout<<"Yay!"<<endl;
	}
	else
	{
		cout<<":("<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
//#include <cassert>
//#include <array>
//#include <queue>
//#include <stack>
#include <vector>
//#include <map>
//#include <set>
#include <unordered_map>
//#include <unordered_set>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP1(i, n) for (int i = 1; i <= (int)(n); i++)

std::vector<int> sieve_of_eratosthenes(int n) {
	std::vector<int> primes(n + 1);
	for (int i = 2; i <= n; ++i)
		primes[i] = i;
	for (int i = 2; i*i <= n; ++i)
		if (primes[i])
			for (int j = i * i; j <= n; j += i)
				primes[j] = 0;
	return primes;
}
unsigned int pow_mod(unsigned long long x, unsigned int k, unsigned int mod) { //x^k (mod mod) 
	if (k == 0)     return 1;
	if (k % 2 == 0) return pow_mod(x*x % mod, k / 2, mod);
	else            return x * pow_mod(x, k - 1, mod) % mod;
}

std::vector<unsigned int> get_fact(unsigned int n, unsigned int mod) {
	std::vector<unsigned int> fact(n + 1);
	fact[0] = 1;
	for (unsigned int i = 1; i <= n; i++)
	{
		fact[i] = (long long)fact[i - 1] * i % mod;
	}
	return fact;
}

std::vector<unsigned int> get_rev_fact(unsigned int n, unsigned int mod, unsigned int fact_n_mod) {
	std::vector<unsigned int> rev_fact(n + 1);
	rev_fact[n] = pow_mod(fact_n_mod, mod - 2, mod);
	for (int i = n - 1; i >= 0; i--)
	{
		rev_fact[i] = (long long)rev_fact[i + 1] * (i + 1) % mod;
	}
	return rev_fact;
}

std::vector<unsigned int> get_rev_fact(unsigned int n, unsigned int mod, std::vector<unsigned int> fact) {
	return get_rev_fact(n, mod, fact[n]);
}

unsigned int combination_mod_precalculation(unsigned int n, unsigned int r, unsigned int mod, std::vector<unsigned int> fact, std::vector<unsigned int> rev_fact) {
	return (long long)fact[n] * rev_fact[r] % mod * rev_fact[n - r] % mod;
}

#define MOD 1000000007
#define M_MAX 1000000000

using namespace std;

int N, M;
unordered_map<int, int> um;

void solve() {
	cin >> N >> M;

	vector<int> primes = sieve_of_eratosthenes((int)sqrt(M));
	for (int factor = 2; factor*factor <= M; factor++)
	{
		if (primes[factor] == 0) {
			continue;
		}
		if (M%factor == 0) {
			um[factor]++;
			M /= factor;
			if (M == 1) {
				break;
			}
			else {
				factor--;
			}
		}
	}
	if (M != 1) {
		um[M]++;
	}

	const int exponent_max = (int)log2(M_MAX);
	vector<unsigned int> fact = get_fact(N - 1 + exponent_max, MOD);
	vector<unsigned int> rev_fact = get_rev_fact(N - 1 + exponent_max, MOD, fact);
	unsigned long long ans = 1;
	for (const auto &e : um) {
		ans *= combination_mod_precalculation(N - 1 + e.second, e.second, MOD, fact, rev_fact);
		ans %= MOD;
	}

	cout << ans << endl;

	return;
}

int main() {
	solve();
	//int n, r, m;
	//cin >> n >> r >> m;
	//cout << combination_mod_straightforward(n, r, m) << endl;
	return 0;
}


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

using namespace std;

int main() {
  // ios::sync_with_stdio(false);
  // cin.tie(0);
  int n;
  cin >> n;
  vector<vector<int>> G(n + 1);
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  vector<int> deep(n + 1);
  function<void(int, int, int)> dfs;
  dfs = [&](int cur, int fa, int depth) -> void {
    deep[cur] = depth;
    for (auto nx: G[cur]) {
      if (nx == fa) continue;
      dfs(nx, cur, depth + 1);
    }
  };
  dfs(1, 0, 0);
  vector<int> cnt(2);
  for (int i = 1; i <= n; i++) ++cnt[deep[i] % 2];
  vector<int> have(3);
  for (int i = 1; i <= n; i++) ++have[i % 3];
  vector<int> v{3, 1, 2};
  auto print = [&](int v1, int v2) -> void {
    if (v[v1] <= n) {
      cout << v[v1] << " ";
      v[v1] += 3;
    } else {
      if (v[v2] <= n) {
      // assert(v[v2] <= n);
        cout << v[v2] << " ";
        v[v2] += 3;
      } else {
        assert(v1 && v2);
        cout << v[0] << " ";
        v[0] += 3;
      }
    }
  };
  if (have[1] <= cnt[0] && have[2] <= cnt[1]) {
    for (int i = 1; i <= n; i++) {
      if (deep[i] % 2 == 0) print(1, 0); else print(2, 0);
    }
  } else if (have[2] <= cnt[0] && have[1] <= cnt[1]) {
    for (int i = 1; i <= n; i++) {
      if (deep[i] % 2 == 0) print(2, 0); else print(1, 0);
    }
  } else {
    int min_cnt = min(cnt[0], cnt[1]);
    for (int i = 1; i <= n; i++) {
      if (cnt[deep[i] % 2] == min_cnt) print(0, 0);
      else print(1, 2);
    }
  }
  cout << "\n";
  return 0;
}

Measured memory_bytes: 22144
#include <iostream>
#include <algorithm>
#include <vector> //動的配列
#include <string>
#include <list> //双方向リスト
#include <map> //連想配列
#include <set> //集合
#include <stack>
#include <queue>
#include <deque>
#include <cmath>
#include <bitset>


//小さい順から取り出すヒープ
//priority_queue<ll, vector<ll>, greater<ll> > pque1;

typedef long long ll;


using namespace std;

typedef pair<int, int> P;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)



ll fast_pow(ll x,ll n,ll mod){
    if (n==0) return 1;
    ll res=fast_pow(x*x %mod,n/2,mod);
    if (n&1) res=res*x%mod;
    return res;
}

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}



int main(){
    int n,m;
    cin>>n>>m;
    int a[n];
    fill(a,a+n,0);
    int l,r;
    rep(i,m){
        cin>>l>>r;
        a[l-1]+=1;
        a[r]-=1;
    }
    for (int i=1;i<n;i++){
        a[i]+=a[i-1];
    }
    int cnt=0;
    rep(i,n){
        if (a[i]==m) cnt++;
    }
    cout<<cnt;
}

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

int main() {
  string S; cin >> S;
  int N = S.size();
  int sc = 0;
  int I = 0;
  for (; I < N - (N/2); I++) {
    if (S[I] == 'p') sc--;
  }
  for (; I < N; I++) {
    if (S[I] == 'g') sc++;
  }
  cout << sc << endl;
}

Measured memory_bytes: 3708
// I - Coins

#include <bits/stdc++.h>
using namespace std;

#define MOD 1000000007

int n;
double p[3005]; // c[i] - P(heads)
double dp[3005][3005];
// dp[i][k] - i coins, k heads

int main(int argc, char **argv) {
    scanf("%d", &n);
    for(int i = 0; i < n; i++) {
        scanf("%lf", &p[i]);
    }

    dp[0][0] = 1;
    for(int i = 1; i <= n; i++) {
        dp[i][0] = dp[i-1][0] * (1-p[i-1]);
        for(int j = 1; j <= i; j++) {
            dp[i][j] = dp[i-1][j]*(1-p[i-1]) + dp[i-1][j-1]*(p[i-1]);
        //  i total, j heads
        //1.last one was tail, so still j heads
        //2.last one was head, so j-1 heads
        }
    }

    // i tails
    double sol = 0;
    for(int i = n; i > (n-i); i--) {
        sol += dp[n][i];
    }

    printf("%.12f\n", sol);
}


Measured memory_bytes: 68992
import java.util.Scanner;

//Altair and Vega
public class Main {

	public static class Point {
		public double x;
		public double y;
		public Point(double x_, double y_) {
			x = x_; y=y_;
		}
	}
	public static Point sub(Point p1, Point p2) {
		return new Point(p1.x-p2.x, p1.y-p2.y);
	}
	public static double extp(Point p1, Point p2) {
		return p1.x*p2.y - p2.x*p1.y;
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		while(t--!=0){
			Point[] p = new Point[3];
			for(int i=0;i<3;i++)p[i]=new Point(sc.nextDouble(), sc.nextDouble());
			Point p1 = new Point(sc.nextDouble(), sc.nextDouble());
			Point p2 = new Point(sc.nextDouble(), sc.nextDouble());
			boolean in1 = false;
			boolean in2 = false;
			boolean right = true;
			boolean left = true;
			boolean right2 = true;
			boolean left2 = true;
			for(int i=0;i<3;i++){
				Point base = sub(p[(i+1)%3], p[i]);
				Point bec = sub(p1, p[i]);
				Point bec2 = sub(p2, p[i]);
				if(extp(base, bec)<0) left = false;
				else right = false;
				if(extp(base, bec2)<0) left2 = false;
				else right2 = false;
			}
			in1 = left|right;
			in2 = left2|right2;
			System.out.println(in1!=in2?"OK":"NG");
		}
	}
}

Measured memory_bytes: 114720
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const double EPS = 1e-7;

//2点間の距離
double dist(double x1,double y1,double x2,double y2){
    return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
}
long long dist2(long long x1, long long y1, long long x2, long long y2){
   return (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1);
}

int bitnum(int n){
    int ret = 0;
    while(n > 0){
        ret += (n & 1); n >>= 1;
    }
    return ret;
}

bool used[1LL << 24];

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    while(cin >> n, n){
        vector<double> x(n), y(n), r(n);
        vector<int> c(n);
        vector<int> d[4]; 
        rep(i, 0, n){
            cin >> x[i] >> y[i] >> r[i] >> c[i];
            c[i]--;
            d[c[i]].push_back(i);
        }
        bool f[25][25] = {};
        rep(i, 0, n){
            rep(j, i + 1, n){
                double tmp = dist(x[i], y[i], x[j], y[j]);
                // cout << tmp << endl;
                if(tmp < r[i] + r[j] - EPS){
                    f[i][j] = true;
                }
            }
        }
        int ans = 0;
        memset(used, false, sizeof(used));
        queue<int> q;
        q.push(0);
        used[0] = true;
        while(!q.empty()){
            int mask = q.front(); q.pop();
            ans = max(ans, bitnum(mask));
            rep(k, 0, 4){
                rep(i, 0, d[k].size()){
                    int x = d[k][i];
                    if(mask & (1LL << x)) continue; 
                    bool flag = false;                   
                    rep(j, 0, x){
                        int z = j;
                        if(!(mask & (1LL << z)) && f[z][x]){
                            flag = true; break;
                        } 
                    }
                    if(flag) continue;
                    rep(j, i + 1, d[k].size()){
                        int y = d[k][j];
                        if(mask & (1LL << y)) continue;
                        bool flag1 = false;
                        rep(l, 0, y){
                            int u = l;
                            if(!(mask & (1LL << u)) && f[u][y]){
                                flag1 = true; break;
                            }
                        }
                        if(flag1) continue;
                        int nxt = mask | (1LL << x) | (1LL << y);
                        if(used[nxt]) continue;
                        used[nxt] = true;
                        q.push(nxt);
                    }
                }
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 22260
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}


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


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a.at(i);
	vector<int> b(n + 2),c(n + 2);
	rep(i,n){
		b.at(i + 1) = gcd(a.at(i), b.at(i));
	}
	rep(i,n){
		c.at(n - i) = gcd(a.at(n - i - 1), c.at(n - i + 1));
	}
	int ans = 1;
	rep(i,n){
		ans = max(ans, gcd(b.at(i), c.at(i + 2)));
	}
	cout << ans << endl;
}


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



int main() {
	int N, K, Q;
	cin >> N >> K >> Q;
	vector<int> A(Q);
	vector<int> B(N,K-Q);


	for (int i = 0; i < Q; i++) {
		cin >> A.at(i);
	}

	for (int i = 0; i < Q; i++) {
		B.at(A.at(i)-1)++;
	}

	for (int i = 0; i < N; i++) {
		if (B.at(i) > 0) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define MAX 100
#define vmax 10000
#define sentinel 2000000000
#define INF (1<<30)
constexpr long long int inf = 100000000000000000;
constexpr long long int rinf = -(INT64_MAX);
static const int NIL=-1;

//cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);

struct edge{
    int from,to,cost;
};

vector<edge> es;
vector<ll> d;
int V,E;

bool bell(int s){
    d.resize(V);
    fill(d.begin(),d.end(),inf);
    d[s]=0;
    for(int i=0;i<V;i++){
        for(auto e:es){
            if(d[e.from]!=inf&&d[e.from]+e.cost<d[e.to]){
                if(i==V-1) return false;
                d[e.to]=d[e.from]+e.cost;
            }
        }
    }
    return  true;
}

int main() {
    int r,s,t,c;
    cin>>V>>E>>r;
    for(int i=0;i<E;i++){
        cin>>s>>t>>c;
        es.push_back({s,t,c});
    }

    if(bell(r)){
       for(int i=0;i<V;i++){
            if(d[i]==inf){
                cout<<"INF"<<endl;
            }else{
                cout<<d[i]<<endl;
            }
        }
    }else{
       cout<<"NEGATIVE CYCLE"<<endl;
   }

    return 0;
}






Measured memory_bytes: 3164
#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() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

  ll n;
  cin >> n;
  ll ans;
  for (ll i = 1; i <= n/2; ++i) {
    ll a = i;
    ll b = n - a;
    if (a == b) continue; 
    ans++;
  }
  cout << ans << endl;
  return 0;
}


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

typedef stack<int> S;

int main(void)
{
	int n, r;
	while (cin >> n >> r && n && r) {
		S s, s1, s2;
		int p, c;
		for (int i = 1; i < n+1; i++) s.push(i);
		for (int j = 0; j < r; j++) {
			cin >> p >> c;
			for (int i = 0; i < p-1; i++) {
				s1.push(s.top());
				s.pop();
			}
			for (int i = 0; i < c; i++) {
				s2.push(s.top());
				s.pop();
			}
			for (int i = 0; i < p-1; i++) {
				s.push(s1.top());
				s1.pop();
			}
			for (int i = 0; i < c; i++) {
				s.push(s2.top());
				s2.pop();
			}
		}
		cout << s.top() << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1204
// ========================================================================================================
// Library
// ========================================================================================================
#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>
using namespace std;

// competitive macro
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i ,n) for (int i = (n) - 1; i >= 0; i--)
#define LL long long
#define ULL unsigned long long

void fastIOS()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
}
// ========================================================================================================
// ========================================================================================================

int main()
{
	fastIOS();

    int n; cin >> n;
    int array[n];
    int max1 = INT_MIN , max2 = INT_MIN;
    
    for(int i = 0; i< n; i++)
    {
        cin >> array[i];
        
        if(array[i] > max1)
        {
            max2 = max1;
            max1 = array[i];
        }
        
        else if(array[i] > max2)
        {
            max2 = array[i];
        }
    }
    
    for(int i = 0; i< n; i++)
    {
        if(array[i] != max1)
        {
            cout << max1 << endl;
        }
        else{
            cout << max2 << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int b[222222];
int vis[6222];
int a[6666];

vector<ll> S;

void dfs(int u, ll s)
{
	if(vis[u]) return ;
	vis[u]=1;
	s+=b[u];
	S.pb(s);
	dfs(a[u],s);
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n,k; cin>>n>>k;
	for(int i=0;i<n;i++) 
	{
		cin>>a[i]; a[i]--;
	}
	for(int i=0;i<n;i++) 
	{
		cin>>b[i]; 
	}
	ll ans = -ll(1e18);
	for(int i=0;i<n;i++)
	{
		memset(vis,0,sizeof(vis));
		dfs(i,0);
		if(S.back()>0&&k>=int(S.size()))
		{
			ll q = k/int(S.size());
			if(q>=1)
			{
				ll mx = -ll(1e18);
				if(q-1>0) mx=0;
				for(int i=0;i<int(S.size());i++)
				{
					mx=max(mx,S[i]);
				}
				ans=max(ans,(q-1)*S.back()+mx);
			}
			
			{
				int r = k%int(S.size());
				ll mx = 0;
				for(int i=0;i<r;i++)
				{
					mx=max(mx,S[i]);
				}
				ans=max(ans,mx+q*S.back());
			}
		}
		else
		{
			for(int j=1;j<=k;j++)
			{
				if(j-1<S.size()) ans=max(ans,S[j-1]);
				else break;
			}
		}
		S.clear();
	}
	cout<<ans<<'\n';
}


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

char c[4]={'E','W','N','S'};

int main(){
	int t,n;
	string s;
	//cin>>t;
	vector<pair<int,bool>> v;
	//int n;
	cin>>t>>n;
	if(n>=t) cout<<"unsafe";
	else cout<<"safe";
	cout<<endl;

}


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

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<long long int> A(N);
    for(int n=0; n<N; n++) {
        cin >> A[n];
    }
    
    sort(A.begin(), A.end());
    
    vector<long long int> SumA(N+1, 0);
    for(int n=0; n<N; n++) {
        SumA[n+1] = SumA[n]+A[n];
    }
    
    int cnt=1;
    for(int n=N-1; n>0; n--) {
        if(SumA[n]*2>=A[n]) {
            cnt++;
        } else {
            break;
        }
    }
    
    cout << cnt << endl;

    return 0;
    
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int N;
int pr[1<<17],sz[1<<17];
long sum[1<<17];
main()
{
	cin>>N;
	vector<pair<int,pair<int,int> > >E(N-1);
	for(int i=0;i<N-1;i++)
	{
		int a,b,c;cin>>a>>b>>c;
		a--,b--;
		E[i]=make_pair(c,make_pair(a,b));
	}
	for(int i=0;i<N;i++)
	{
		pr[i]=i;
		sz[i]=1;
	}
	sort(E.begin(),E.end());
	reverse(E.begin(),E.end());
	for(pair<int,pair<int,int> >e:E)
	{
		int a=e.second.first,b=e.second.second;
		while(pr[a]!=a)a=pr[a];
		while(pr[b]!=b)b=pr[b];
		if(sz[a]<sz[b])swap(a,b);
		sum[a]+=(long)e.first*sz[b];
		sum[b]+=(long)e.first*sz[a];
		sum[b]-=sum[a];
		sz[a]+=sz[b];
		pr[b]=a;
	}
	for(int i=0;i<N;i++)
	{
		int t=i;
		long ans=sum[t];
		while(pr[t]!=t)
		{
			t=pr[t];
			ans+=sum[t];
		}
		cout<<ans<<endl;
	}
}


Measured memory_bytes: 4480
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
	string s; cin >> s;
	ll x, y; cin >> x >> y;
	queue<ll> q[2];
	bool mode = 1;
	ll sf = 0;
	s += 'T';
	while(s[sf] != 'T'){
		--x;
		++sf;
	}
	ll po = 0;
	for(ll i = sf + 1; i < s.size(); ++i){
		if(s[i] == 'T'){
			q[(int)mode].push(po);
			mode = !mode;
			po = 0;
		}else{
			++po;
		}
	}
	for(ll count = 0; count <= 1; ++count){
		ll dpsub[16000 + 1] = {};
		ll *dp = dpsub + 8000;
		dp[0] = 1;
		while(q[count].size()){
			ll yo = q[count].front();
			q[count].pop();
			ll dpsubnext[16000 + 1] = {};
			ll *dpnext = dpsubnext + 8000;
			for(ll i = -8000; i <= 8000; ++i){
				if(dp[i]){
					dpnext[i - yo] = dpnext[i + yo] = 1;
				}
			}
			for(ll i = -8000; i <= 8000; ++i) dp[i] = dpnext[i];
		}
		if(!dp[(count ? y : x)]){
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
	return 0;
}

Measured memory_bytes: 512
n = int(input())
h = [int(i) for i in input().split()]

dp = [float('inf')] * n
dp[0] = 0

for i in range(1, n):
    dp[i] = min(dp[i], dp[i-1] + abs(h[i] - h[i-1]))
    if i > 1:
        dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2]))

print(dp[-1])

Measured memory_bytes: 13980