akhauriyash/Code-Regression huggingface dataset:
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
using namespace std;
#define fast_io() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

const long long maxn = 5e5 + 5;

int main()
{
    fast_io();
    long long A, B ,M;
    cin >> A >> B >> M;

    pair<long long, long long> arr[A];
    pair<long long, long long> arr1[B];

    long long qw1 = maxn, qw2 = maxn;

    

    for (long long i = 0; i < A; ++i)
    {
        cin >> arr[i].first;
        arr[i].second = i;
        qw1 = min(qw1, arr[i].first);


    }

     for (long long i = 0; i < B; ++i)
    {
        cin >> arr1[i].first;
        arr1[i].second = i;
        qw2 = min(qw1, arr1[i].first);
    }


    long long ans = qw1 + qw2;





   // cout << ans << "\n";

    for (long long i = 0; i < M; ++i)
    {
        long long a, b, c;
        cin >> a >> b >> c;
        a -= 1;
        b -= 1;

        ans = min(ans, arr[a].first + arr1[b].first - c);
        
    }

    cout << max(ans, 0LL);








    return 0;
}

// g++ -std=c++11


Measured memory_bytes: 3456
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int f[305][305],s[305][305],c[305][305];
int main(){
	int n,k,m;
	scanf("%d%d%d",&n,&k,&m);
	for(int i=0;i<=n;i++)
		for(int j=0;j<=i;j++)
			c[i][j]=(!j||j==i?1:c[i-1][j-1]+c[i-1][j])%m;
	for(int i=0;i<=k;i++)f[1][i]=1,s[1][i]=k-i+1;
	for(int i=2;i<=n+1;i++)
		for(int j=k;j>=0;j--){
			for(int l=1;l<i;l++)
				f[i][j]=(f[i][j]+1ll*s[l][j+1]*f[i-l][j]%m*c[i-2][l-1])%m;
			s[i][j]=(f[i][j]+s[i][j+1])%m;
		}
	printf("%d\n",f[n+1][0]);
}

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

int main(){
  string S,a,b,c;
  a="Sunny";
  b="Cloudy";
  c="Rainy";
  string ans;
  cin>>S;
  if(S==a){
    ans=b;
  }
  else if(S==b){
    ans=c;
  }
  else{
    ans=a;
  }
cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

//a,bの最大公約数
template <class T>
T gcd(T a,T b) {
	if (b==0) return a;
	else return gcd(b,a%b);
}

//最小公倍数, 複数の時はlcm(a,lcm(b,c))みたいな感じで
template <class T>
T lcm(T a,T b){
	return a*(b/gcd(a,b));
}

template<typename Monoid,typename F>
class SegmentTree{
private:
    int n;
    vector<Monoid> node;
    const F op;//演算
    const Monoid e;//単位元
public:
    SegmentTree(int sz,const F op,const Monoid &e):op(op),e(e){
        n=1;
        while(n<sz) n*=2;
        node.assign(2*n,e);
    }
    void set(int k, const Monoid &x){
        node[k+n-1]=x;
    }
    void build(){
        for (int i=0;i<n-1;i++){
            node[i]=op(node[2*i+1],node[2*i+2]);
        }
    }
    void update(int k,const Monoid &x){
        k+=n-1;
        node[k]=x;
        while(k>0){
            k=(k-1)/2;
            node[k]=op(node[2*k+1],node[2*k+2]);
        }
    }
    Monoid query(int a,int b,int k=0,int l=0,int r=-1){
        if(r<0) r=n;
		if(r<=a || b<=l) return e;
		if(a<=l && r<=b) return node[k];
		else{
			Monoid vl=query(a,b,2*k+1,l,(l+r)/2);
			Monoid vr=query(a,b,2*k+2,(l+r)/2,r);
			return op(vl,vr);
		}
    }
    Monoid operator[](const int &k)const{
        return node[k+n];
    }
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	ll e=1;
	vector<ll> a(n);
	rep(i,n){
		cin>>a[i];
		e=lcm(e,a[i]);
	}
	auto f=[&](ll a,ll b){return gcd(a,b);};
	SegmentTree<ll,decltype(f)> seg(n+10,f,e);
	rep(i,n){
		seg.update(i,a[i]);
	}
	ll ans=0;
	rep(i,n){
		seg.update(i,e);
		chmax(ans,seg.query(0,n));
		seg.update(i,a[i]);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3072
import math


def resolve():
    import sys
    input = sys.stdin.readline
    # row = [int(x) for x in input().rstrip().split(" ")]
    # n = int(input().rstrip())
    a, b = [int(x) for x in input().rstrip().split(" ")]

    if(a > 0):
        print("Positive")
    elif(a == 0 or b == 0):
        print("Zero")
    elif(a < 0 and 0 < b):
        print("Zero")
    else:
        num = b - a + 1
        if num % 2 == 0:
            print("Positive")
        else:
            print("Negative")



if __name__ == "__main__":
    resolve()


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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"
#define debug(x) cout<<#x<<" = "<<x<<endl;

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

void solve()
{
    li n;

    cin>>n;

    li a[n];

    f(i,0,n-1)
    {
        cin>>a[i];
    }

    // sort(a,a+n);

    li cnt=0;

    f(i,0,n-1)
    {
        f(j,i+1,n-1)
        {
            f(k,j+1,n-1)
            {
                if(a[i]==a[j] || a[j]==a[k] || a[i]==a[k])
                    continue;

                if(a[i]+a[j]>a[k] && a[i]+a[k]>a[j] && a[j]+a[k]>a[i])
                    cnt++;
            }
        }        
    }

    cout<<cnt;
}

int main()
{    
    

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    li t=1;

    // cin>>t;

    while(t--)
    {
        solve();
    }

    return 0;
}

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

int main() {
    string X;
    cin >> X;
    stack<char> st;

    int n = X.size();
    for(int i=0; i<n; ++i) {
        if(X[i] == 'S') st.push('S');
        if(X[i] == 'T') {
            if(st.empty() || st.top() == 'T') st.push('T');
            else st.pop();
        }
    }
    cout << st.size() << endl;
}

Measured memory_bytes: 644
from typing import List


class DSU:
    def __init__(self, n: int) -> None:
        self._n = n
        self.parent_or_size = [-1] * n

    def merge(self, a: int, b: int) -> int:
        assert 0 <= a <= self._n
        assert 0 <= b <= self._n
        x, y = self.leader(a), self.leader(b)
        if x == y:
            return x
        if -self.parent_or_size[x] < -self.parent_or_size[y]:
            x, y = y, x
        self.parent_or_size[x] += self.parent_or_size[y]
        self.parent_or_size[y] = x
        return x

    def same(self, a: int, b: int) -> bool:
        assert 0 <= a <= self._n
        assert 0 <= b <= self._n
        return self.leader(a) == self.leader(b)

    def leader(self, a: int) -> int:
        assert 0 <= a < self._n
        if self.parent_or_size[a] < 0:
            return a
        result = self.leader(self.parent_or_size[a])
        self.parent_or_size[a] = result
        return result

    def size(self, a: int) -> int:
        assert 0 <= a <= self._n
        return -self.parent_or_size[self.leader(a)]

    def groups(self) -> List[List[int]]:
        leader_buf = [self.leader(i) for i in range(self._n)]
        group_size = [0] * self._n
        for i in leader_buf:
            group_size[i] += 1
        result = [[] for _ in range(self._n)]
        for i in range(self._n):
            result[leader_buf[i]].append(i)
        result = [i for i in result if i]
        return result


n, q = map(int, input().split())
dsu = DSU(n)

for _ in range(q):
    t, u, v = map(int, input().split())
    if t == 0:
        dsu.merge(u, v)
    else:
        print(1 if dsu.same(u, v) else 0)

Measured memory_bytes: 89800
#include<iostream>
using namespace std;
typedef long long LL;

int l2(LL a) {
	int ans = 0;
	while (a) {
		a /= 2;
		ans++;
	}
	return ans;
}
LL b2(int a) {
	LL ans = 1;
	for (int i = 0; i < a; i++)ans *= 2;
	return ans;
}

int main() {
	int n;
	cin >> n;
	for (int x = 0; x < n; x++) {
		LL s, d;
		cin >> s >> d;
		int ans = 0;
		while (s < d) {
			LL dif = d - s;
			for (int i = l2(dif); i > -1; i--) {
				LL a = b2(i);
				if (s%a == 0&&s+a<=d) {
					s += a;
					ans++;
					break;
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3108
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(void)
{
    char str1[10];

    scanf("%s", &str1);

    int length = strlen(str1);

    if (length == 6)
        printf("Rainy\n");
    else if (length == 5 && str1[0] == 'S')
        printf("Cloudy\n");
    else
        printf("Sunny\n");

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)

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

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

int main(){
  int n,m,mif;
  cin>>n;
  vector<int> a(n);
  vector<int> b(n);
  rep(i,0,n) {
    cin>>a.at(i);
    b.at(i)=a.at(i);
  }
  sort(b.begin(),b.end());
  reverse(b.begin(),b.end());
  m=b.at(0);
  mif=b.at(1);
  rep(i,0,n){
    if(a[i]!=m) cout<<m<<endl;
    else cout<<mif<<endl;
  }
}


Measured memory_bytes: 3200
/*
        karmany evadhikaras te
        ma phalesu kadacana 
        ma karma-phala-hetur bhur
        ma re sango'stv akarmani (B.G.-2.47)
 
Translation:
        Lord Krsna to Arjuna.
You have a right to perform your prescribed duty, 
but you are not entitled to the fruits of action. 
Never consider yourself the cause of the results of your activities, 
and never be attached to not doing your duty.    
*/
#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define int long long
const int N = 105;
const ll mod = 1e9+7;
#define ld long double
#define PI 3.14159265358979323846
const int INF = 10000000;

void flash()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(2);
}

//3. Structure or classes
//3. Ends here

//1. Data structures declaration here
//1. Ends here

//2. Extra Functions here
//2. Ends here


void solve();
int32_t main()
{
    flash();
    int t;
    t = 1;
    //cin>>t;
    while(t--){
        solve();
        //cout<<"\n";
    }
    return 0;
}

void solve()
{
    int n;
    cin>>n;

    if(n>=400 && n<=599){
        cout<<"8";
    }
    else if(n>=600 && n<=799){
        cout<<"7";
    }
    else if(n>=800 && n<=999){
        cout<<"6";
    }
    else if(n>=1000 && n<=1199){
        cout<<"5";
    }
    else if(n>=1200 && n<=1399){
        cout<<"4";
    }
    else if(n>=1400 && n<=1599){
        cout<<"3";
    }
    else if(n>=1600 && n<=1799){
        cout<<"2";
    }
    else if(n>=1800 && n<=1999){
        cout<<"1";
    }

    return;
}
// how r u bro

Measured memory_bytes: 3644
#include <iostream>

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

struct Node {
  int value;
  Node *parent, *left, *right;

  Node(int k, Node *p, Node *l, Node *r) {
    value = k;
    parent = p;
    left = l;
    right = r;
  }

  Node() {
    parent = nullptr;
    left = nullptr;
    right = nullptr;
  }
};

Node *root = nullptr;

void insert(int k) {
  Node *y = nullptr;
  Node *x = root;
  Node *z = new Node();
  z->value = k;

  while (x != nullptr) {
    y = x;
    if (k < x->value) {
      x = x->left;
    } else {
      x = x->right;
    }
  }

  z->parent = y;
  if (y == nullptr) {
    root = z;
    return;
  }
  if (k < y->value)
    y->left = z;
  else
    y->right = z;
}

void find(int k) {
  Node *x = root;
  while (x != nullptr) {
    if (x->value == k) {
      std::cout << "yes" << '\n';
      return;
    }
    if (k < x->value)
      x = x->left;
    else
      x = x->right;
  }
  std::cout << "no" << '\n';
}

void inorder(Node *n) {
  if (n == nullptr) return;
  inorder(n->left);
  std::cout << ' ' << n->value;
  inorder(n->right);
}

void preorder(Node *n) {
  if (n == nullptr) return;
  std::cout << ' ' << n->value;
  preorder(n->left);
  preorder(n->right);
}

int main() {
  int n;
  std::cin >> n;
  std::string com;
  int key;

  rep(i, n) {
    std::cin >> com;
    if (com == "insert") {
      std::cin >> key;
      insert(key);
    } else if (com == "print") {
      inorder(root);
      std::cout << '\n';
      preorder(root);
      std::cout << '\n';
    } else {
      std::cin >> key;
      find(key);
    }
  }
  return 0;
}



Measured memory_bytes: 21920
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  int x=0,y=0;
  cin>>s;
  for(int i=0;i<s.size();i++){
    if(s[i]=='0') x++;
    if(s[i]=='1') y++;
  }
  cout<<min(x,y)*2<<endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stdlib.h>
#include <time.h>
#include <queue>
#include <sstream>
using namespace std;

int main(void){
	int a, b, c;
	while(cin >> a){
	cin >> b >> c;
	if(a == b && b == c && a == 0)break;
	int N;
	cin >> N;
	int state[a+b+c];
	int result[N][4];
	fill_n(state, a+b+c, -1);
	for(int i = 0; i < N; i++){
		for(int j = 0; j < 4; j++){
			cin >> result[i][j];
		}
		for(int k = 0; k < 3; k++)
			if(result[i][3] == 1)state[result[i][k]-1] = 1;
	}
	for(int i = 0; i < N; i++){
		int zero_cnt = 0;
		int save;
		for(int j = 0; j < 3; j++){
			if(state[result[i][j]-1] != 1){
				save = result[i][j]-1;
				zero_cnt++;
			}
		}
		if(zero_cnt == 1){
			state[save] = 0;
		}
	}
	for(int i = 0; i < a+b+c; i++){
		if(state[i] == -1) state[i] = 2;
		cout << state[i] << endl;
	}
}
}

Measured memory_bytes: 1176
N,M,Q = map(int,input().split())
num = [[0 for i in range(N)] for j in range(N)]
for i in range(M):
    l,r = list(map(int,input().split()))
    l -= 1
    r -= 1
    num[l][r] += 1

for j in range(N):
    for i in range(N-1,0,-1):
        num[i-1][j] += num[i][j]
for i in range(N):
    for j in range(N-1):
        num[i][j+1] += num[i][j]
for i in range(Q):
    p,q = map(int,input().split())
    print(num[p-1][q-1])

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

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

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

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


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

  ll n,m;
  cin >> n >> m;
  vector<vector<pll>> e(n);
  ll l,r,d;
  REP(i, m){
    cin >> l >> r >> d;
    l--;
    r--;
    e[l].push_back(pll(r, d));
    e[r].push_back(pll(l, -d));
  }


  //bfs
  vll distance(n, -LLINF);
  REP(i, n){
    if(distance[i] != -LLINF)
      continue;
    queue<ll> que;
    que.push(i);
    distance[i] = 0;
    while(!que.empty()){
      ll now = que.front();
      que.pop();

      for(auto a : e[now]){
        if(distance[a.FI] == -LLINF){
          distance[a.FI] = distance[now]+a.SE;
          que.push(a.FI);
        }
        else if(distance[a.FI] != distance[now]+a.SE){
          cout << "No" << endl;
          return 0;
        }

      }

    }
  }

  cout << "Yes" << endl;

}


Measured memory_bytes: 14080
N = int(input())
A = list(map(int,input().split()))
count=0
for i in range(N):
  try:
    a = A[i]
    b = A[i+1]
    if a <= b:
      pass
    else:
      c = abs(a-b)
      A[i+1] = b+c
      count+=c
  except:
    pass
print(count)


Measured memory_bytes: 32228
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		String S = sc.next();
		sc.close();
		if(S.charAt(A) != '-') {
			System.out.println("No");
		}else {
			for(int i = 0; i < A + B + 1; i++) {
				if(i == A) continue;
				if(S.charAt(i) >= '0' && S.charAt(i) <= '9') {
					continue;
				}else {
					System.out.println("No");
					System.exit(0);
				}
			}
			System.out.println("Yes");
		}
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")

using namespace std;

typedef long long ll;

//#include<ext/pb_ds/assoc_container.hpp>
//#nclude<ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>pb_ds;

#define pi pair<int,int>
#define F first
#define S second
#define pb push_back
#define pp pop_back
#define mod 1000000007
#define pai acos(-1)
#define N 1000005


int main ()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
//    freopen("in.txt","r",stdin);
//   freopen("out.txt","w",stdout);
    int t,n,m,k,a,b,c,x;
    cin>>n;
    ll sum=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            for(int k=1;k<=n;k++){
                x=__gcd(i,j);
                x=__gcd(x,k);
                sum+=x;
            }
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3648
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

N = int(input())
K = int(input())
xx = inpl()
ans = 0
for x in xx:
	ans += min(x,K-x)*2

print(ans)


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

int main() {
  string s;
  cin>>s;
  int ans=0;
  if(s.size()==1){

  }else{

    rep(i,s.size()-1){
      if(s[i]==s[i+1]){
        ans++;
        if(s[i]=='0'){
          s[i+1]='1';
        }else{
          s[i+1]='0';
        }
      }
    }

  }
  cout<<ans<<endl;
}

Measured memory_bytes: 512
import sys
x, y, a, b, c = [int(x) for x in input().split()]
p = [int(x) for x in input().split()]
q = [int(x) for x in input().split()]
r = [int(x) for x in input().split()]
p.sort(key=lambda x: -x)
q.sort(key=lambda x: -x)
r.sort(key=lambda x: -x)
ri = 0
pi = x
qi = y
while ri < len(r) and (0 < pi or 0 < qi):
    if 0 < pi and p[pi - 1] < r[ri] and (qi <= 0 or p[pi - 1] <= q[qi - 1]):
        ri += 1
        pi -= 1
    elif 0 < qi and q[qi - 1] < r[ri] and (pi <= 0 or q[qi - 1] <= p[pi - 1]):
        ri += 1
        qi -= 1
    else:
        break
print(sum(p[:pi]) + sum(q[:qi]) + sum(r[:ri]))


Measured memory_bytes: 23644
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/rope>
#define VALHALLA cin.tie(0);ios_base::sync_with_stdio(false);cout<<fixed<<setprecision(13);cerr<<fixed<<setprecision(5);
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define debug(x) std::cerr << #x << ": " << (x) << '\n';
#define sz(x) (int)x.size()
#define fast(map_name) map_name.reserve(1024);map_name.max_load_factor(0.25);
using namespace std;
using namespace __gnu_cxx;
typedef long long int ll;
typedef pair<int,int> ii;
typedef complex<double> point;
const double epsilon=1e-9;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll mod=1e9+7;
/* VARIABLE DECLARATION START */
int globe[int(1e6)];
/*  FUCNTION TEMPLATE STARTS  HERE */
double dot(point a,point b){ return (conj(a)*b).real() ; }
double cross(point a,point b){ return (conj(a)*b).imag() ; }
double dist(point a, point b){ return abs(a-b); }
struct neal {
static uint64_t splitmix64(uint64_t x)
 {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
}
size_t operator()(uint64_t x) const
 {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
}
};
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return (size_t) x.first * 37U + (size_t) x.second;
  }
};
bool isprime(ll n) {
    if (n == 2 || n == 3) return true;
    if (n < 2 || n % 2 == 0 || n % 3 == 0) return false;
    for (ll i = 6; (i - 1) * (i - 1) <= n; i += 6) {
        if (n % (i - 1) == 0 || n % (i + 1) == 0) {
            return false;
        }
    }
    return true;
}
inline ll exp(ll a, ll b, ll mod) {
    ll n = 1;
    ll p = a;
    while (b > 0) {
        if (b % 2 == 1) {
            n *= p;
            n %= mod;
        }
        p *= p;
        p %= mod;
        b /= 2;
    }
    return n;
}

inline bool comp(double a,double b)
{
  return (fabs(a-b)<epsilon);
}
ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
/*  FUCNTION TEMPLATE ENDS HERE */
int main()
{
   VALHALLA
   int n;cin>>n;
   ll x;cin>>x;
   vector<ll> v(n);
   for(auto &x:v)cin>>x;
   ll init=accumulate(all(v),0ll);
   for(int i=1;i<sz(v);++i)
   {
       if(v[i]+v[i-1]>x)
       {
          ll element=v[i]+v[i-1]-x;
          if(element<=v[i])
          v[i]-=element;
          else
          {
            element-=v[i];
            v[i]=0;
            v[i-1]-=element;
          }
       }

   }
   ll final=accumulate(all(v),0ll);
   cout<<init-final<<endl;


   
}



Measured memory_bytes: 1024
a = []
a = input().split()

A1 = int(a[0])
A2 = int(a[1])
A3 = int(a[2])

tot = A1 + A2 + A3

if tot >= 22 :
  print('bust')
if tot <= 21 :
  print('win')

#print(a)
#print(A1)
#print(A2)
#print(A3)

Measured memory_bytes: 3060
from numba import njit


@njit
def fact(x):
    i = 1
    while i * i <= x:
        if x % i == 0:
            yield i
            yield x // i
        i += 1


def main():
    n = int(input())
    a = tuple(map(int, input().split()))

    c = [0] * (max(a) + 1)

    for e in a:
        c[e] += 1

    ans = n
    for e in a:
        c[e] -= 1
        for fct in fact(e):
            if c[fct]:
                ans -= 1
                break

        c[e] += 1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 122228
n, k = map(int, input().split())
A = list(map(int, input().split()))
A = [a-1 for a in A]

shown = [0]*n
shown[0] = 1
cur = 0
cur_idx = 1
len_to_loop = 0
loop_start = 0
while cur_idx<=n:
  nxt = A[cur]
  #print(shown, cur_idx, cur, nxt)
  if shown[nxt]>0:
    cur_idx += 1
    loop_start = nxt
    len_loop = cur_idx - shown[nxt]
    if cur==nxt:
      len_loop += 1
    len_to_loop = shown[nxt]-1
    break
  else:
    cur_idx += 1
    shown[nxt] = cur_idx
    cur = nxt
    

rest = k-len_to_loop
rest = rest%len_loop

if k<=n:
  cur = 0
  for i in range(k):
    nxt = A[cur]
    cur = nxt
else:  
  cur = loop_start
  for i in range(rest):
    nxt = A[cur]
    cur = nxt
  
print(cur+1)
  




Measured memory_bytes: 32244
package main

import "fmt"

var e [][]int
var n, m int

func dfs(v int, visited []bool) int {
	comp := true
	for i := 1; i < n+1; i++ {
		if !visited[i] {
			comp = false
			break
		}
	}

	if comp {
		return 1
	}

	count := 0
	for _, ne := range e[v] {
		if visited[ne] {
			continue
		}
		visited[ne] = true
		count += dfs(ne, visited)
		visited[ne] = false
	}
	return count
}

func main() {
	fmt.Scan(&n, &m)

	e = make([][]int, n+1)
	for i := 1; i < n+1; i++ {
		e[i] = make([]int, 0)
	}
	for i := 0; i < m; i++ {
		var a, b int
		fmt.Scan(&a, &b)
		e[a] = append(e[a], b)
		e[b] = append(e[b], a)
	}

	visited := make([]bool, n+1)
	visited[1] = true
	count := dfs(1, visited)
	fmt.Println(count)
}


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

int GetValue(int v, int per)
{
	return v * (per + 100) / 100;
}

int main()
{
	int x, y, s;
	while (cin >> x >> y >> s, x + y + s)
	{
		int ans = -9999;
		for (int i = 1; i <= s; i++)
		{
			for (int j = 1; j <= s; j++)
			{
				if (GetValue(i, x) + GetValue(j, x) == s)
					ans = max(ans, GetValue(i, y) + GetValue(j, y));
			}
		}
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
#include <type_traits>
#include <utility>
#include <cassert>
#include <iostream>
#include <functional>
#include <vector>
#include <string>
#include <algorithm>
namespace loquat {
template <int MOD>
class modulus_integer {
public:
	typedef modulus_integer<MOD> self_type;
private:
	int m_value;
	static self_type unsafe_construct(int x) noexcept {
		self_type y;
		y.m_value = x;
		return y;
	}
public:
	modulus_integer() noexcept
		: m_value(0)
	{ }
	modulus_integer(int x) noexcept
		: m_value(x % MOD)
	{
		if(m_value < 0){ m_value += MOD; }
	}
	int operator*() const noexcept { return m_value; }
	self_type& operator=(const self_type& x) noexcept {
		m_value = x.m_value;
		return *this;
	}
	self_type operator+(const self_type& x) const noexcept {
		const int y = m_value + x.m_value;
		return unsafe_construct(y >= MOD ? y - MOD : y);
	}
	self_type operator*(const self_type& x) const noexcept {
		return unsafe_construct(
			static_cast<long long>(m_value) * x.m_value % MOD);
	}
	self_type& operator+=(const self_type& x) noexcept {
		return (*this = *this + x);
	}
};
template <int MOD>
inline std::ostream& operator<<(
	std::ostream& os, const modulus_integer<MOD>& x)
{
	os << *x;
	return os;
}
}
namespace loquat {
class disjoint_set {
public:
	using value_type = size_t;
private:
	std::vector<value_type> m_parents;
	std::vector<value_type> m_ranks;
public:
	explicit disjoint_set(size_t n)
		: m_parents(n)
		, m_ranks(n)
	{
		for(size_t i = 0; i < n; ++i){
			m_parents[i] = i;
		}
	}
	value_type find(size_t x){
		if(m_parents[x] == x){ return x; }
		m_parents[x] = find(m_parents[x]);
		return m_parents[x];
	}
	value_type unite(size_t x, size_t y){
		x = find(x);
		y = find(y);
		if(x == y){ return x; }
		if(m_ranks[x] < m_ranks[y]){
			m_parents[x] = y;
			return y;
		}else if(m_ranks[x] > m_ranks[y]){
			m_parents[y] = x;
			return x;
		}else{
			m_parents[y] = x;
			++m_ranks[x];
			return x;
		}
	}
	bool same(size_t x, size_t y){
		return find(x) == find(y);
	}
};
}
using namespace std;
using ll = long long;
using tlii = tuple<ll, int, int>;
using mint = loquat::modulus_integer<1000000007>;
int main(){
	ios_base::sync_with_stdio(false);
	int n, m;
	ll x;
	cin >> n >> m >> x;
	vector<tlii> edges(m);
	for(int i = 0; i < m; ++i){
		int u, v;
		ll w;
		cin >> u >> v >> w;
		edges[i] = tlii(w, u - 1, v - 1);
	}
	sort(edges.begin(), edges.end());
	vector<ll> a(m);
	for(int i = 0; i < m; ++i){
		const auto ui = get<1>(edges[i]);
		const auto vi = get<2>(edges[i]);
		const auto wi = get<0>(edges[i]);
		loquat::disjoint_set ds(n);
		ds.unite(ui, vi);
		ll mst_sum = wi;
		for(int j = 0; j < m; ++j){
			const auto uj = get<1>(edges[j]);
			const auto vj = get<2>(edges[j]);
			const auto wj = get<0>(edges[j]);
			if(ds.same(uj, vj)){ continue; }
			ds.unite(uj, vj);
			mst_sum += wj;
		}
		a[i] = mst_sum;
	}
	sort(a.begin(), a.end());
	vector<mint> pow2_table(m + 1);
	pow2_table[0] = 1;
	for(int i = 1; i <= m; ++i){
		pow2_table[i] = pow2_table[i - 1] * 2;
	}
	mint answer = 0;
	for(int i = 1; i < m; ++i){
		if(a[i] != x){ continue; }
		answer += pow2_table[m - i - 1];
	}
	cout << answer * 2 << endl;
	return 0;
}


Measured memory_bytes: 384
from collections import deque

n,m=map(int,input().split())
A={int(input()) for _ in range(m)}
L=deque([1,1])
if 1 in A:L[1]=0
for i in range(2,n+1):
    if i in A:
        L.append(0)
    else:
        L.append(L[i-2]+L[i-1])
print(L[n]%(10**9 + 7))


Measured memory_bytes: 460364
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;

int main(){
  int i;
  double n,ans,j;
  while(1){
    cin >> n;
    if(n < 0) break; 
    j = 128;
    ans = 0.0;
    for(i=10000000;i>=1;i/=10){
      if(n - j >= 0.0){
	ans += (double)i;
	n -= j;
      }
      j /= 2.0;
    }
    j = 0.5;
    for(i=10;i<=10000;i*=10){
      if(n - j >= 0.0){
	ans += (double)1/i;
	n -= j;
      }
      j /= 2.0;
    }
    if(n == 0.0) printf("%013.4f\n",ans);
    else cout << "NA" << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please


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

	ll N, K;
	cin >> N >> K;

	map<int, ll> MAP;

	rep(i, N) {
		int a, b;
		cin >> a >> b;
		MAP[a] += b;
	}

	ll kazoeru = 0;
	for (auto itr : MAP) {
		kazoeru += itr.second;
		if (kazoeru >= K) {
			co(itr.first);
			break;
		}
	}

	Would you please return 0;
}

Measured memory_bytes: 4224
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1111111111;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	int a = 0;
	for (int i = 0; i <= 10; i++) {
		if ((1 << i) < N && N <= (1 << (i + 1))) a = i + 1;
	}
	DMP(a);

	vector<vector<int>> grid(N, vector<int>(N));
	for (int two = 1; two <= a; two++) {
		for (int i = 0; i < N; i++) {
			for (int j = i + 1; j < N; j++) {
				if (!grid[i][j] && (i % (1 << two) != j % (1 << two))) grid[i][j] = two;
			}
		}
	}

	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			cout << grid[i][j] << " ";
		}
		cout << "\n";
	}

	return 0;
}

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

using namespace std;

int main()
{
    int n,max1=-1;
    string s,ans;
    cin>>n;
    map<string,int>mat;
    map<string,int>::iterator it;
    set<string>se;
    set<string>::iterator it2;
    for(int i=0;i<n;i++)
    {
        cin>>s;
        mat[s]++;
    }
    //sort(mat.begin(),mat.end());
    for(it=mat.begin();it!=mat.end();it++)
    {
        if(it->second>max1)
        {
            ans=it->first;
            max1=it->second;
        }
    }
    se.insert(ans);
    for(it=mat.begin();it!=mat.end();it++)
    {
        if(it->second==max1)
        {
            se.insert(it->first);
        }
    }
    for(it2=se.begin();it2!=se.end();it2++)
        cout<<(*it2)<<"\n";
    return 0;
}


Measured memory_bytes: 34560
n = input()
num = len(n)
if int(n[num - 1]) == 2 or int(n[num - 1]) == 4 or int(n[num - 1]) == 5 or int(n[num - 1]) == 7 or int(n[num - 1]) == 9:
    str = 'hon'
elif int(n[num - 1]) == 3:
    str = 'bon'
else:
    str = 'pon'
    
print(str)
 

Measured memory_bytes: 9184
from itertools import accumulate

def burn(L, l_x):
    l_x.append(L)
    l_x.insert(0, 0)
    r_x = list(L - i for i in reversed(l_x))
    return max(burn_in(L, l_x, r_x), burn_in(L, r_x, l_x))


def burn_in(L, l_x, l_l):
    r_x = list(L - i for i in reversed(l_x))
    l = list(accumulate(l_x))
    r = list(accumulate(r_x))
    n_max = len(l_x)
    ret = 0
    for i in range(n_max - 2):
        n_r = (n_max - 2 - i) // 2
        n_l = n_max - n_r - 2
        res = l_x[n_l] if (n_max - i) % 2 == 1 else r_x[n_r]
        can = (l[n_l] - l[i] + r[n_r]) * 2 - res
        ret = max(ret, can)
    return ret


def main():
    L, N = map(int, input().split())
    x = [int(input()) for _ in range(N)]
    print(burn(L, x))
    
if __name__ == "__main__":
    main()

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


int N;
int cn = 0;
vector<int> P;

int solve(){
  int m = MINIMUM;  //j番目以下の数値の最大値
  for(int j = 0; j < N; j++){
    if(P[j] <= m){ cn++; m = P[j]; }
  }
  return cn;
}

int main(){
  cin >> N;

  int p;
  for(int i = 0; i < N; i++){
    cin >> p; P.push_back(p);
  }

  cout << solve() << endl;
  return 0;

}

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

ll n;

inline ll read(){
	ll s = 0, w = 1;
	char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) w *= ch == '-' ? -1 : 1;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) s = s * 10 + ch - '0';
	return s * w;
}

inline void work(){
	n = read(), n = n % 10;
	if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9) puts("hon");
	else if (n == 0 || n == 1 || n == 6 || n == 8) puts("pon");
		 else puts("bon");
}

int main(){
	work();
	return 0;
}

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

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

  int x=-1, y=-1, z=-1;
  for (int a = 0; a <= N; a++) {
    for (int b = 0; b <= N; b++) {
      int c = N - a - b;
      if (0 <= c) {
        int total = 10000*a + 5000*b + 1000*c;
        if (a + b + c == N && total == Y) {
          x=a, y=b, z=c;
        }
      }
    }
  }

  cout << x << ' ' << y << ' ' << z << endl;
  return 0;
}


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

int n;
bool f;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n;
	for(int i=0; i<n; ++i){
		int t;
		cin >> t;
		if(t % 2 == 1) f = true;
	}
	if(f) cout << "first\n";
	else cout << "second\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int ma=0;
    for(int i=0;i<2;i++){
        int sum=0;
        for(int j=0;j<4;j++){
            int a;
            cin>>a;
            sum+=a;
        }
        ma=max(ma,sum);
    }
    cout<<ma<<endl;
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <sstream>

using namespace std;

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

    int t[N + 1], x[N + 1], y[N + 1];
    t[0] = x[0] = y[0] = 0;
    for(int cnt0 = 1; cnt0 < N + 1; cnt0++){
        cin >> t[cnt0] >> x[cnt0] >> y[cnt0];
    }

    for(int cnt0 = 0; cnt0 < N ;cnt0++){
        int dx = abs(x[cnt0 + 1] - x[cnt0]);
        int dy = abs(y[cnt0 + 1] - y[cnt0]);
        int dt = t[cnt0 + 1] - t[cnt0];
        if(dx + dy <= dt && (dt - (dx + dy)) % 2 == 0){

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

    cout << "Yes" << endl;
    return 0;
}

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

signed main(){
  string s; cin >> s;
  ll ans = 0;
  int n = s.size();
  for(int bit = 0; bit < (1 << n - 1); bit++){
    string t = "";
    t += s[0];
    for(int i = 0; i < n - 1; i++){
      if(bit & (1 << i)){
        ans += stoll(t);
        t = s[i + 1];
      }
      else{
        t += s[i + 1];
      }
    }
    ans += stoll(t);
  }
  printf("%lld\n", ans);
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Maxn 4000007
const int INF = 1e9 + 5;
const int  N = 2e5 + 314;
void foo(){
    int n, k;
    cin>>n>>k;
    vi v;
    while (n>0)
    {
        v.pb(n%k);
        n/=k;
    }
    cout<<v.size();
}
int main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)foo();
}

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

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    ll n,m,s,t; cin >> n >> m >> s >> t;
    s--; t--;
    vector<pair<ll,ll>> ea[n], eb[n];
    REP(i,m){
        ll u,v,a,b; cin >> u >> v >> a >> b;
        u--; v--;
        ea[u].emplace_back(a,v);
        ea[v].emplace_back(a,u);
        eb[u].emplace_back(b,v);
        eb[v].emplace_back(b,u);
    }

    vector<ll> da(n,LL_INF), db(n,LL_INF);
    priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>> q;
    
    q.push(pair<ll,ll>(0,s));
    while(q.size()){
        auto p = q.top(); q.pop();
        ll cost = p.first, to = p.second;
        if(chmin(da[to], cost)){
            for(auto pp : ea[to]){
                ll c = pp.first, d = pp.second;
                q.push(pair<ll,ll>(da[to]+c, d));
            }
        }
    }

    q.push(pair<ll,ll>(0,t));
    while(q.size()){
        auto p = q.top(); q.pop();
        ll cost = p.first, to = p.second;
        if(chmin(db[to], cost)){
            for(auto pp : eb[to]){
                ll c = pp.first, d = pp.second;
                q.push(pair<ll,ll>(db[to]+c, d));
            }
        }
    }

    vector<ll> ans(n,LL_INF);
    ans[n-1] = da[n-1]+db[n-1];
    RREP(i,n-1) ans[i] = min(da[i]+db[i], ans[i+1]);

    REP(i,n){
        cout << 1000000000000000-ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 19832
#include <bits/stdc++.h>
#include <stdint.h>
#include <algorithm>
#include <utility>

using namespace std;

int main() {
	int N;
	cin >> N;
	
	vector<int> V(N),C(N);
	
	for (int i = 0; i < N; i++) {
		cin >> V.at(i);
	}
	
	for (int i = 0; i < N; i++) {
		cin >> C.at(i);
	}
	
	int ans = 0;
	
	for (int i = 0; i < N; i++) {
		if ((V.at(i) - C.at(i)) > 0) {
			ans += (V.at(i) - C.at(i));
		}
	}
	
	
	cout << ans << endl;
	
	
	
	return 0;
}


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


int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ll x,t;
	cin>>x;
	t=x/11;
	t*=2;
	x%=11;
	if (x>=7){
		t+=2;
	}
	else if (x>0){
		t++;
	}
	cout<<t;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <cassert>
//#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

vector < vector<pair<int, int> > > g;  // to, edgeid
vector<int> ans;
vector<int> vis;
vector<int> flag;

void dfs(int curr, bool& ret)
{
    vis[curr] = 1;
    ret = flag[curr];
    int i;
    for (i = 0; i < (int)g[curr].size(); i++) {
        int next = g[curr][i].first;
        int edgeid = g[curr][i].second;
        if (vis[next]) continue;

        bool ret0 = false;
        dfs(next, ret0);
        if (ret0) ans.push_back(edgeid);
        ret ^= ret0;
    }

    return;
}

void solve()
{
    int n,m;
    scanf("%d%d", &n, &m);
    vector<pair<int,int> > z(n);
    int i;
    for (i = 0; i < n; i++) {
        int a, b;
        scanf("%d%d", &a, &b);
        z[i]=make_pair(a, b);
    }
    sort(z.begin(), z.end());

    flag.resize(n + 1);
    for (i = 0; i < n + 1; i++) {
        if (i == 0) {
            flag[i] = z[0].second;
        }
        else if (i == n) {
            flag[i] = z[n - 1].second;
        }
        else {
            flag[i] = (z[i].second == z[i - 1].second? 0: 1);
        }
    }

    set<pair<int, int> > s;
    g.resize(n + 1);
    vis.resize(n + 1);
    for (i = 0; i < m; i++) {
        int l, r;
        scanf("%d%d", &l, &r);

        int k0 = lower_bound(z.begin(), z.end(), make_pair(l, -INF)) - z.begin();
        if (k0 == n) {
            continue;
        }
        int k1 = lower_bound(z.begin(), z.end(), make_pair(r+1, -INF)) - z.begin();

        if (k0 != k1 && s.insert(make_pair(k0,k1)).second) {
            g[k0].push_back(make_pair(k1, i));
            g[k1].push_back(make_pair(k0, i));
        }
    }

    for (i = 0; i < n + 1; i++) {
        if (vis[i]) continue;
        bool rev = 0;
        dfs(i, rev);
        if (rev) {
            printf("-1\n"); return;
        }
    }
    sort(ans.begin(), ans.end());
    printf("%d\n", (int)ans.size());
    for (i = 0; i < (int)ans.size(); i++) {
        printf("%d", ans[i]+1);
        if (i < (int)ans.size() - 1) printf(" ");
    }
    printf("\n");

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}



Measured memory_bytes: 23936
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
//#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);


 int main(){

    //IOS;
	
   #ifndef ONLINE_JUDGE
     freopen("input1.txt","r",stdin);
     freopen("output1.txt","w",stdout);
   #endif
int n,t,s;
   		
      
   		cin>>n>>t>>s;
   		
   		float f=(float)n/s;
   int p=ceil(f);
   if(p<=t)
     cout<<"Yes";
   else cout<<"No";
   

   return 0;
 }   


Measured memory_bytes: 3620
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    N,K=map(int,readline().split())
    flags=[False]*N
    for i in range(K):
        d=int(readline())
        A=list(map(int,readline().split()))
        for a in A:
            a-=1
            flags[a]=True

    res=0
    for i in range(N):
        if flags[i]==False:
            res+=1

    print(res)

if __name__=="__main__":
    main()

Measured memory_bytes: 9204
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
// #include <numeric> // gcdとかlcmとか C++17から
#include <time.h> // time_t timer; time(&timer); でtimerに現在時刻が代入される．
#include <unistd.h> // sleep関数．引数は秒単位．
using namespace std;

typedef long long ll;

ll my_gcd(ll a, ll b){
	return (b==0) ? a : my_gcd(b, a%b);
}

ll my_lcm(ll a, ll b){
	return a*b / my_gcd(a,b);
}

ll factorial(ll a){
	ll ans = 1;
	for(ll i=a; i>0; i--){
		ans *= i;
	}
	return ans;
}

ll pow(ll a, ll b) {
	ll a_powered = 1;
	for (int i=0; i<b; i++) { a_powered *= a;
	}
	return a_powered;
}


int main(int argc, char *argv[]){
	int r;
	cin >> r;

	cout << 3*r*r << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef pair<pl, ll> ppl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, k, n) for(ll i = ll(k); i <= ll(n); i++)
#define rep3(i, n, k) for(ll i = ll(n); i >= ll(k); i--)
#define all(v) (v).begin(), (v).end()
ll mod(ll a, ll b) {if(b == 0) return 0; return (a % b + b) % b;}
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll x;
  cin >> x;
  cout << 1-x << newl;
  return 0;
}

Measured memory_bytes: 3648
# N:駅の数
# Ci:i駅から i+1 駅への移動にかかる時間(cost)
# Si:i駅の最初の発車時間(start)
# Fi:i駅の発車スパン(frequency)
# Si % Fi = 0

N = int(input())
C = [0 for i in range(N)]
S = [0 for i in range(N)]
F = [0 for i in range(N)]
C[0], S[0], F[0] = 0, 0, 0


for i in range(N-1):
    C[i+1], S[i+1], F[i+1] = (int(i) for i in input().split())

for s in range(1, N+1):
    # print("start=", s)
    if s == N:
        t = 0
        pass
    else:
        t = 0
        for i in range(s, N):
            if t < S[i]:
                t = S[i]

            elif t % F[i] == 0:
                pass

            else:
                t = t + F[i] - (t % F[i])

            t += C[i]
    print(t)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=1e9+7;
const int INF=2e9;
const double PI=acos(-1);


map<ll,int> prime_factor(ll n) {
    map<ll,int> res;
    repr(i,2,sqrt(n)+1) {
        while (n%i==0) {
            ++res[i];
            n/=i;
        }
    }
    if(n!=1) ++res[n];
    return res;
}


int main() {
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<int> cnt(n+1);
    repr(i,2,n+1) {
        map<ll,int> pf=prime_factor(i);  
        repitr(itr,pf) cnt[itr->first]+=itr->second;
    }
    int p2=0,p4=0,p14=0,p24=0,p74=0;
    rep(i,n+1) {
        if (cnt[i]>=2) ++p2;
        if (cnt[i]>=4) ++p4;
        if (cnt[i]>=14) ++p14;
        if (cnt[i]>=24) ++p24;
        if (cnt[i]>=74) ++p74;
    }
    ll ans=0;
    ans+=p4*(p4-1)/2*(p2-2);
    ans+=p14*(p4-1);
    ans+=p24*(p2-1);
    ans+=p74;
    cout << ans << endl;

    return 0;   
}

Measured memory_bytes: 3652