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

using namespace std;

typedef long long ll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

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

//X*1.08=N;切り捨て
//X=N/1.08;


int main(){
    int n;
    cin>>n;
    double N=n;
    double X=ceil(N/1.08);
    if(floor(X*1.08)==n){
        cout<<X<<endl;
    }else{
        cout<<":("<<endl;
    }
    return 0;
}

//a=97,z=122

Measured memory_bytes: 256
N = int(input())
A = [int(x) for x in input().split()]

def main():
    A.sort(reverse=True)
    alist = [x for i, x in enumerate(A) if i % 2 == 0]
    blist = [x for i, x in enumerate(A) if i % 2 != 0]
    print(sum(alist) - sum(blist))

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
///https://www.youtube.com/watch?v=-tJYN-eG1zk&list=RD-tJYN-eG1zk&start_radio=1
const int MOD = 1e9 + 7;
#define ll long long int
#define pii pair<int, int>
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define vi vector<int>
#define vpii vector<pii>
#define si set<int>
#define mpii map<int, int>
#define prq priority_queue<int>
#define rnd(a, b) ((((rand()<<15)^rand())%((b)-(a) + 1))+(a))
#define FAST_IO ios_base::sync_with_stdio(false),cin.tie(NULL)
const int MXX = 1e5 + 5;

int main()
{

    FAST_IO;
    ll n;cin>>n;
    cout<<pow(n, 3);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;

ll gcd(ll x, ll y){
	if (x < y){
		ll temp = x;
		x = y;
		y = temp; 
	}
	if (x % y) return gcd(y, x%y);
	return y;
}

ll lcm(ll x, ll y){
	return x*y/gcd(x, y);
}

int main(){
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	a--;

	ll big = b - b/c - b/d + b/lcm(c, d);
	ll small = a - a/c - a/d + a/lcm(c, d);
	cout << big - small << endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
  int i,j,k,f,n=0,N,W,v[101],w[10001],dp[101][10001];
  scanf("%d %d",&N,&W);
  for(i=1;i<=N;i++)
    scanf("%d %d",&v[i],&w[i]);
  for(i=0;i<=N;i++)
    for(j=0;j<=W;j++){
      if(j == 0 || i == 0)
        dp[i][j] = 0;
      else if(j-w[i] >= 0)
        dp[i][j] = max(dp[i-1][j-w[i]]+v[i],dp[i-1][j]);
      else
        dp[i][j] = dp[i-1][j];
    }
  printf("%d\n",dp[N][W]);
  return 0;
}




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

using namespace std;

int mat[101][101];

int main() {
	int w, h, n, ans = 0;
	cin >> w >> h >> n;
	for(int i = 0; i < n; ++i){
        int x, y, a;
        cin >> x >> y >> a;
        if(a == 1){
            for(int j = 0; j < x; ++j){
                for(int k = 0; k < h; ++k){
                    mat[j][k] = 1;
                }
            }
        }else if(a == 2){
            for(int j = x; j < w; ++j){
                for(int k = 0; k < h; ++k){
                    mat[j][k] = 1;
                }
            }
        }else if(a == 3){
            for(int j = 0; j < w; ++j){
                for(int k = 0; k < y; ++k){
                    mat[j][k] = 1;
                }
            }
        }else{
            for(int j = 0; j < w; ++j){
                for(int k = y; k < h; ++k){
                    mat[j][k] = 1;
                }
            }
        }
	}
	for(int i = 0; i < w; ++i){
        for(int j = 0; j < h; ++j)if(!mat[i][j])ans++;
	}
	cout << ans;
	return 0;

}


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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
	is >> p.first >> p.second;
	return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
	os << p.first << " " << p.second;
	return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}
/*
typedef __int128_t Int;
std::ostream &operator<<(std::ostream &dest, __int128_t value) {
std::ostream::sentry s(dest);
  if (s) {
	__uint128_t tmp = value < 0 ? -value : value;
	char buffer[128];
	char *d = std::end(buffer);
	do {
	  --d;
	  *d = "0123456789"[tmp % 10];
	  tmp /= 10;
	} while (tmp != 0);
	if (value < 0) {
	  --d;
	  *d = '-';
	}
	int len = std::end(buffer) - d;
	if (dest.rdbuf()->sputn(d, len) != len) {
	  dest.setstate(std::ios_base::badbit);
	}
  }
  return dest;
}

__int128 parse(string &s) {
  __int128 ret = 0;
  for (int i = 0; i < s.length(); i++)
	if ('0' <= s[i] && s[i] <= '9')
	  ret = 10 * ret + s[i] - '0';
  return ret;
}
*/

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
template <class T> bool chmin(T &a, const T &b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N; cin >> N;
	vector<string>v(3); rep(i, 0, 3) { cin >> v[i]; }
	int ans = 0;
	rep(i, 0, N) {
		set<char>s;
		rep(j, 0, 3) {
			s.insert(v[j][i]);
		}
		ans += s.size() - 1;
	}
	cout << ans << endl;


	return 0;
}


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

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

typedef long long int ll;

ll INF = 1000000000000000000;
ll MOD = 1e9+7;

int main(){
    ll N;cin >> N;
    ll P = 0;
    int cnt = 1;
    for(int i = 1;i <= N;i++){
        if(P < N){
            P += i;
            cnt++;
        }else{
            break;
        }
    }
    for(int i = 1;i < cnt;i++){
        if(i != P - N){
            cout << i << endl;
        }
    }
}



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

int main(){
    int a,b;
    cin >> a >> b;
    int dif = b-a;
    int h = 0;
    rep(i,dif){
        h+=i;
    }
    cout << h - a << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define forn(i, n) for (llong i = 0ll; i < (llong) n; ++i)
#define fornn(i, l, r) for (llong i = (llong) l; i < (llong) r; ++i)
#define size(x) ((int) (x.size()))
 
using namespace std;
 
typedef long long llong;
const llong inf = (llong) 1e+9 + 7ll;
const llong linf = (llong) 1e+18 + 7ll;
const long double eps = (long double) 1e-9;
const long double pi = acosl((long double) -1.0);
const int alph = 26;

mt19937 mrand(random_device{} ()); 

template<typename T, typename U> inline llong umin(const T& a, const U& b) { return a < b ? a : b; }
template<typename T, typename U> inline llong umax(const T& a, const U& b) { return a > b ? a : b; }
 
static char buff[(int) 2e6 + 17]; // reads std::string
const int maxn = (int) 3e5 + 17;

int n;
int cnt[maxn];

bool read()
{
	if (scanf("%d", &n) != 1)
		return false;

	return true;
}

void solve()
{
	for (int i = 2; i <= n; ++i)
	{
		int p = i;

		for (int j = 2; j * j <= p; ++j)
			while (p % j == 0)
				p /= j, ++cnt[j];

		if (p != 1)
			++cnt[p];
	}

	llong ans = 1ll;

	forn (i, maxn)
		ans = ans * (cnt[i] + 1) % inf;

	printf("%lld\n", ans);
}

int main()
{
#if SEREZHKA
	freopen("file.in", "r", stdin);
#endif

	while (read())
		solve();

	return 0;
}


Measured memory_bytes: 256
s=input()
tt=[bin(2**(len(s)-1)+i)[3::] for i in range(2**(len(s)-1))]
ans=0
for t in tt:
    a=[]
    for i in range(len(t)):
        a.append(s[i])
        if t[i]=='1':
            a.append("+")
    a.append(s[-1])
    x="".join(a)
    ans+=eval(x)
print(ans)

Measured memory_bytes: 3064
import numpy as np
H, W = map(int, input().split())

cambus = []
for h in range(H):
    cambus.append(list(input()))


def judge(_cambus, w, h):
    global W, H
    now = _cambus[h][w]
    if now == '.':
        return True
    status = False
    for dx, dy in zip([-1, 1, 0, 0], [0, 0, 1, -1]):
        x = w + dx
        y = h + dy
        if x > -1 and x < W and y > -1 and y < H:
            if now == _cambus[y][x]:
                status = True
    return status


flag =  True
for w in range(W):
    for h in range(H):
        flag = judge(cambus, w, h)
        if not flag: break
    if not flag: break

if not flag: print('No')
else: print('Yes')

Measured memory_bytes: 17428
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>
#include <fstream>

using namespace std;

struct before_main{before_main(){cin.tie(0); ios::sync_with_stdio(false);}} before_main;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = (1e9) * 2;
int n;

int to_int(deque<int>& C) {
  int ret = 0;
  reverse(all(C));
  rep(i, C.size()) {
    ret *= 10;
    ret += C[i];
  }
  reverse(all(C));
  return ret;
}

int dfs(string& A, string& B, int K, int i, int borrow, deque<int>& C) {
  /*
テ」ツ??」ツ??.1. Aiテ「ツ按鍛orrowiテ「ツ可・Bi テ」ツ?ェテ」ツつ嘉」ツ?ーテ」ツ??Ci=Aiテ「ツ按鍛orrowiテ「ツ按達i テッツシツ?borrowi+1=0テ」ツ?ィテ」ツ?凖」ツつ凝」ツ??
テ」ツ??」ツ??.2. Aiテ「ツ按鍛orrowi<Bi テ」ツ?ェテ」ツつ嘉」ツ?ーテ」ツ??Ci=Aiテ「ツ按鍛orrowi+10テ「ツ按達i テッツシツ?borrowi+1=1テ」ツ?ィテ」ツ?凖」ツつ凝」ツ??
  */
  if(n == i) {
    return to_int(C);
  }

  int ret = -inf;

  if(A[i] - borrow >= B[i]) {
    C.push_back(A[i] - borrow - B[i]);
    maximize(ret, dfs(A, B, K, i+1, 0, C));
    C.pop_back();
  }
  else {
    C.push_back(A[i] - borrow + 10 - B[i]);
    maximize(ret, dfs(A, B, K, i+1, 1, C));
    if(K) maximize(ret, dfs(A, B, K-1, i+1, 0, C));
    C.pop_back();
  }
  return ret;
}

int main() {

  int A, B, K; cin >> A >> B >> K;
  string a = to_string(A), b = to_string(B);
  reverse(all(a)), reverse(all(b));
  n = max(a.size(), b.size());
  REP(i, a.size(), n) a.push_back('0');
  REP(i, b.size(), n) b.push_back('0');
  deque<int> C;
  cout << dfs(a, b, K, 0, 0, C) << endl;
  
  return 0;
}

Measured memory_bytes: 3252
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
using PP = pair<ll, P>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;
vector<ll> ans;


ll MONEY = 1e15;

vector<ll> dijkstra(ll start, vector<ll> *G, ll n) {
  priority_queue<P, vector<P>, greater<P>> pq;
  pq.push(P(0, start));

  vector<ll> dist(n);
  rep(i, n) dist[i] = INF;
  dist[start] =  0;

  while (! pq.empty()) {
    ll pos = pq.top().second;
    pq.pop();

    rep(i, int(G[pos].size())) {
      ll to = G[pos][i];
      //cout << "GraphSize: " << int(G[pos].size()) << endl;
      //cout << "pos: " << pos << endl;
      //cout << "to: " << to << " predist: " << dist[to] << endl;

      if (dist[to] > dist[pos] + 1) {
        dist[to] = dist[pos] + 1;
        //cout << "postdist: " << dist[to] << endl;
        pq.push(P(dist[to], to));
        ans[to] = pos + 1;
      }
    }
  }

  return dist;
}

int main() {
  ll n, m;
  cin >> n >> m;

  vector<ll> G[n];

  rep(i, m) {
    ll u, v;
    cin >> u >> v;
    u--; v--;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  /*
  cout << "Graph:" << endl;
  rep(i, n) {
    rep(j, ll(G[i].size())) {
      cout << G[i][j] << " ";
    }
    cout << endl;
  }
  */

  ans = vector<ll>(n);

  vector <ll> dist = dijkstra(0, G, n);

  // rep(i, n) cout << dist[i] << endl;

  if (find(dist.begin(), dist.end(), INF) != dist.end())
    cout << "No" << endl;

  else {
    cout << "Yes" << endl;
    reps1(i, n) {
      cout << ans[i] << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 14416
s = str(input())
n = len(s)
l = [0]*(n+1)
temp = 0
for i in range(n):
  if s[i] == '<':
    temp += 1
    l[i+1] = temp
  else:
    temp = 0
    l[i+1] = temp

r = [0]*(n+1)
temp = 0
for i in reversed(range(n)):
  if s[i] == '>':
    temp += 1
    r[i] = temp
  else:
    temp = 0
    r[i] = temp
#print(l)
#print(r)
ans = [0]*(n+1)
for i in range(n+1):
  ans[i] = max(l[i], r[i])
#print(ans)
print(sum(ans))

Measured memory_bytes: 54728
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
const int MOD=(int)1e9+7;
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    if(a>b) cout<<a-1<<endl;
    else cout<<a<<endl;
}

Measured memory_bytes: 256
/***************************************************
 * Problem Name : B.cpp
 * Problem Link :
 * OJ           :
 * Verdict      : Trying
 * Date         : 2020-05-10
 * Problem Type :
 * Author Name  : Saikat Sharma
 * University   : CSE, MBSTU
 ***************************************************/
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <cstdlib>
#include <deque>
#include <stack>
#include <bitset>
#include <cassert>
#include <map>
#include <set>
#include <cassert>
#include <iomanip>
#include <random>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;

#define __FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define __FileRead freopen ("input.txt", "r", stdin)
#define __FileWrite freopen ("output.txt", "w", stdout)
#define SET(a,v) memset(a,v,sizeof(a))
#define SZ(v) (int)v.size()
#define pii pair<int,int>
#define pil pair <int, ll>
#define pli pair <ll, int>
#define pll pair <ll, ll>
#define debug cout <<"######\n"
#define debug1(x) cout <<"### " << x << " ###\n"
#define debug2(x,y) cout <<"# " << x <<" : "<< y <<" #\n"
#define nl cout << "\n";
#define sp cout << " ";
#define sl(n) scanf("%lld", &n)
#define sf(n) scanf("%lf", &n)
#define si(n) scanf("%d", &n)
#define ss(n) scanf("%s", n)
#define pf(n) scanf("%d", n)
#define pfl(n) scanf("%lld", n)
#define all(v) v.begin(), v.end()
#define rall(v) v.begin(), v.end()
#define srt(v) sort(v.begin(), v.end())
#define r_srt(v) sort(v.rbegin(), v.rend())
#define rev(v) reverse(v.rbegin(), v.rend())
#define Sqr(x) ((x)*(x))
#define Mod(x, m) ((((x) % (m)) + (m)) % (m))
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define pb push_back
#define mk make_pair
#define F first
#define S second
#define MAX 100005
#define INF 1000000009
#define MOD 1000000007

template<class T>
using min_heap = priority_queue<T, std::vector<T>, std::greater<T>>;
template<typename T>
using ordered_set  = tree<T, null_type, less<T>, rb_tree_tag,
      tree_order_statistics_node_update>;

template <typename T> string toString ( T Number ) {
    stringstream ss;
    ss << Number;
    return ss.str();
}
template<typename T> int toInt (T str) {
    stringstream ss;
    ss << str;
    int num;
    ss >> num;
    return num;
}
ll lcm ( ll a, ll b ) {
    return ( a / __gcd ( a, b ) ) * b;
}
/************************************ Code Start Here ******************************************************/
int main () {
    __FastIO;
    //~ cout << setprecision (10) << fixed;
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    ll sum = min (k, a);
    k -= min (k, a);

    if (k > 0) {
        k -= min (k, b);

        if (k > 0) {
            sum -= min (k, c);
        }
    }

    cout << sum << "\n";
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
#include <deque>
#include <tuple>
#include <map> 
#include <set>
#include <stack>
#include <functional>
#define ll long long
using namespace std;

int main() {
	string s;
	cin >> s;
	int rCnt = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'R') rCnt++;
	}

	if (rCnt == 1) {
		cout << rCnt << endl;
		return 0;
	}
    if (rCnt == 2 && s[1] == 'R') {
		cout << rCnt << endl;
		return 0;
	}
	else if(rCnt==2) {
		cout << 1 << endl;
		return 0;
	}
	cout << rCnt << endl;
	return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		int[] nedan = {6000,4000,3000,2000};
		int i, s, mai;

		Scanner sc = new Scanner(System.in);
		for ( i = 0; i <= 3; i++) {
			s = sc.nextInt();
			mai = sc.nextInt();
			System.out.println(nedan[s-1] * mai);

		}

		// TODO 自動生成されたメソッド・スタブ

	}

}

Measured memory_bytes: 17316
N=int(input())
S=list(map(lambda x: ord(x),input()))
MOD = 10**9 + 7 # 1e9 + 7

# 各文字列について、出現回数+1(1つ取るか、一切とらない)
# それを全部かければ良い

AppearCount = [ 0 for _ in range(26)]

for n in range(N):
	AppearCount[S[n]-ord('a')] += 1

ans = 1
bFirst = True

for a in AppearCount:
	if a != 0:
		ans *= (a+1)
		while MOD < ans:
			ans -= MOD

ans -= 1

while MOD <= ans:
	ans -= MOD

print(ans)

Measured memory_bytes: 3956
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;




//D
public class Main {

    static int N;
    static int Q;
    static IntList[] v;
    static int[] ans;
    static int[] parent;
    public static void main(String[] args) {
        // TODO 自動生成されたメソッド・スタブ
        Scanner sc = new Scanner(System.in);

        N=sc.nextInt();
        Q=sc.nextInt();
        v=new IntList[N+1];
        ans=new int[N+1];
        parent=new int[N+1];
        for(int i=1;i<=N;i++) {
            v[i]=new IntList();
        }
        for(int i=1;i<=N-1;i++) {
            int a=sc.nextInt();
            int b=sc.nextInt();
            v[a].add(b);
            parent[b]=a;

        }

        for(int i=0;i<Q;i++) {
            int p=sc.nextInt();
            int q=sc.nextInt();
            ans[p]+=q;
        }


        for(int i=2;i<=N;i++) {

            int pi=parent[i];
            // System.err.println("i pi "+i+" "+pi);

            if(pi!=0) {ans[i]+=ans[pi];}

        }

        for(int i=1;i<=N;i++) {
            System.out.print(ans[i]+" ");
        }
        System.out.println();
    }
}

class IntList{
    private int[] array;
    private int size = 0;
    public IntList() {
        array = new int[256];
    }

    public IntList(int size) {
        array = new int[size];
    }

    public void add(int a) {
        if(size == array.length) {
            int newSize = Math.min(Integer.MAX_VALUE, size*2);
            array = Arrays.copyOf(array, newSize);
        }
        array[size++] = a;
    }

    public void addAll(IntList list) {
        for (int i = 0; i < list.size(); i++) {
            this.add(list.get(i));
        }
        // TODO convert to copyOf
//        int[] a = list.getArray();
//        int numNew = a.length;
//        if(size + numNew > array.length) {
//            int length = array.length;
//            while (size + numNew < length) {
//                length *= 2;
//            }
//            array = Arrays.copyOf(array, length);
//        }
//        System.arraycopy(a, 0, array, size, numNew);
//        size += numNew;
    }

    public int get(int i) {
        if(i >= size) {
            throw new ArrayIndexOutOfBoundsException(String.format("size=%d, i=%d", i, size));
        }
        return array[i];
    }

    public int size(){
        return size;
    }

    public int[] getArray() {
        return array;
    }
}

Measured memory_bytes: 464844
import itertools
import math


def get_primes(x):
    if x < 2:
        return []

    primes = [i for i in range(x)]
    primes[1] = 0

    for prime in primes:
        if prime > math.sqrt(x):
            break
        if prime == 0:
            continue
        for non_prime in range(2 * prime, x, prime):
            primes[non_prime] = 0

    return [prime for prime in primes if prime != 0]


N = int(input())
primes = get_primes(55555)
ans = []
i = 4

while len(ans) < N:
    p = primes[i]
    
    if p % 5 == 1:
        ans.append(p)

    i += 1

print(*ans)

Measured memory_bytes: 5296
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

import java.math.BigInteger;
import java.util.*;
import java.util.stream.Collectors;

public class Main {
    long MOD = (long) 1e9 + 7;

    InputStream in;
    OutputStream out;

    public Main() {
        this(System.in, System.out);
    }

    public Main(InputStream in, OutputStream out) {
        this.in = in;
        this.out = out;
    }

    void run() {
        Scanner sc = new Scanner(this.in);
        PrintWriter out = new PrintWriter(this.out);

        // write your code
        long n = sc.nextLong();
        LinkedList<String> ans = new LinkedList<>();

        do {
            n--;
            ans.addFirst("" + (char)('a' + n % 26));
            n /= 26;
        } while (n != 0);


        out.println(String.join("", ans));

        out.flush();
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

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

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

using ll = long long;
using ld = long double;
using P = pair<int, int>;
//using P = pair<double, double>;
using edge = struct {int to; ll cost;};

#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(a) (a).begin(), (a).end()

const int di[] = {-1, 0, 1, 0, 1, 1, -1, -1};
const int dj[] = {0, -1, 0, 1, 1, -1, 1, -1};
const int INF = 1e9+100;
const ll INF64 = 7e18l;

const int mod = 1000000007;
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*(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;
  }
};
struct combination
{
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1)
  {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i)
      fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i)
      ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k)
  {
    if (k < 0 || k > n)
      return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};



void solve()
{
  int a, b;
  cin >> a >> b;
  int ans;
  if(a <= b) ans = a;
  else ans = a-1;
  cout << ans << "\n";
}

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


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <algorithm>

typedef long long ll;

using namespace std;

int main() {
    ll A;
    double B;
    cin >> A >> B;
    ll b = B * 100 + 0.5;
    cout << A * b / 100 << endl;
    return 0;
}



Measured memory_bytes: 3704
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    char a[3],b[3];
    cin>>a[0];
    cin>>a[1];
    cin>>a[2];
    cin>>b[0];
    cin>>b[1];
    cin>>b[2];
    if(a[0]==b[2]&&a[1]==b[1]&&a[2]==b[0])cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int main()
{
	string out="APPROVED";
	int n,a;cin>>n;
	rep(i,n){
		cin>>a;
		if(a%2==0 && a%3>0 && a%5>0) out="DENIED";
	}
	cout<<out<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    vector<int> res(N);
    if(N % 2) {
        int cur = N / 2;
        int dif = 1;
        rep(i, N) {
            res[cur] = A[i];
            cur += dif;
            if(dif < 0)
                dif = dif * (-1) + 1;
            else
                dif = (dif + 1) * -1;
        }
    } else {
        int cur = N / 2;
        int dif = -1;
        rep(i, N) {
            res[cur] = A[i];
            cur += dif;
            if(dif < 0)
                dif = dif * (-1) + 1;
            else
                dif = (dif + 1) * -1;
        }
    }
    rep(i, N) cout << res[i] << (i == N - 1 ? "\n" : " ");
    return 0;
}

Measured memory_bytes: 3712
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
string a,b;
int j,k;
int main()
{
	cin>>a>>b;
	for(int i=0;i<a.size()+b.size();i++)
	{
		if(j<a.size()){cout<<a[j];j++;}
		if(k<b.size()){cout<<b[k];k++;}
	}	
	cout<<'\n';
	return 0;
}

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

#define int long long
#define ld long double

#define pb push_back
#define F first
#define S second
#define I insert
#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()

#define debug1(a) cerr<<" "<<#a<<" : "<<a<<"\n"
#define debug2(a,b) cerr<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<"\n"
#define debug3(a,b,c) cerr<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<"\n"
#define debug4(a,b,c,d) cerr<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<"\n"

#define INF (int)100000000000000000
#define PI (double)3.14159265358979
// #define M 421412341324321
#define MOD 998244353


vector <vector <pair <int, int>>> adj;

vector <int> v;
void dfs(int i, int src)
{
    for (auto j:adj[i])
    {
        v.pb(j.S);
        if (j.F != src)
            dfs(j.F, src);
    }
}

int mx_sum(int k)
{
    int n = sz(v);
    if (n==0)
        return -INF;

    if (n>=k)
    {
        int ans = v[0], s = v[0];
        for (int i=1;i<k;++i)
        {
            s += v[i];
            ans = max(ans, s);
        }   
        return ans;
    }
    else
    {
        int s1 = v[0];
        for (int i=1;i<n;++i)
        {
            s1 += v[i];
        }
        if (s1 > 0)
        {
            s1 = s1*((k/n) - 1);
            int x = k%n + n;
            int ans = 0, s = 0;
            if (x)
            {
                ans = v[0], s = v[0];
                for (int i=1;i<x;++i)
                {
                    s += v[i%n];
                    ans = max(ans, s);
                }   

            }
            int ans1 = ans + s1;

            return ans + s1;
        }
        else
        {
            int ans = v[0], s = v[0];
            for (int i=1;i<n;++i)
            {
                s += v[i];
                ans = max(ans, s);
            }   
            return ans;
        }
    }

}

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

    int n, k;
    cin>>n>>k;

    int a[n+1], b[n+1];
    adj.resize(n+1);
    for (int i=0;i<n;++i)
    {
        cin>>a[i+1];
    }
    for (int i=0;i<n;++i)
    {
        cin>>b[i+1];
    }
    for (int i = 1;i<=n;++i)
    {
        adj[i].pb({a[i], b[a[i]]});
        // debug3(i, a[i], b[a[i]]);
    }

    int ans = -INF;
    for (int i = 1;i<=n;++i)
    {
        v.clear();
        dfs(i, i);
        // debug1(sz(v));
        // for (auto j:v) debug1(j);
        ans = max(ans, mx_sum(k));
    }

    cout << ans << "\n";



    return 0;
}


Measured memory_bytes: 4480
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

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

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

long long int Sx[600000], a[600000], DP[1100000] = {}, DPs[1100000] = {};
long long int S0[600000], last[1100000] = {}, pre[600000];

int main(){
    int N;
    cin >> N;
    long long int num = 0;
    Sx[0] = 0;
    S0[0] = 1;
    for(int i = 1; i <= N; i++){
        cin >> a[i];
        num ^= a[i];
        Sx[i] = num;
        S0[i] = S0[i - 1];
        if(num == 0){
            S0[i] += 1;
        }
        pre[i] = last[num];
        last[num] = i;
    }
    for(int i = 1; i <= N; i++){
        num = Sx[i];
        if(num == 0){
            continue;
        }
        if(pre[i] == 0){
            DP[num] = 1;
            DPs[num] = 1;
        }else if(S0[i] - S0[pre[i]] > 0){
            DP[num] = (S0[i] - S0[pre[i]]) * DPs[num] + DP[num];
            DP[num] %= MOD;
            DPs[num] += DP[num];
            DPs[num] %= MOD;
        }else{
            DPs[num] += DP[num];
            DPs[num] %= MOD;
        }
    }
    if(Sx[N] != 0){
        cout << DP[Sx[N]] << endl;
    }else{
        long long int ans = 0;
        for(int i = 1; i < 1100000; i++){
            ans += DPs[i];
            ans %= MOD;
        }
        num = 1;
        for(int i = 0; i < S0[N] - 2; i++){
            num *= 2;
            num %= MOD;
        }
        ans += num;
        ans %= MOD;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 44032
#include<bits/stdc++.h>
using namespace std;
#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--)
typedef long long LL;
int N;
int par1[100031];
int rank1[100031];
//n要素で初期化
void init(int n){
   for(int i=0;i<n;i++){
       par1[i]=i;
       rank1[i]=0;
   }
}
//木の根を求める
int find(int x){
    if(par1[x] ==x){
         return x;
    }else{
         return par1[x]=find(par1[x]);
    }
}
//xとyの属する集合を併合
void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y) return;

    if(rank1[x]<rank1[y]){
         par1[x]=y;
    }else{
         par1[y]=x;
         rank1[x]++;
    }
}
//xとyが同じ集合に属するか否か
bool same(int x,int y){
     return find(x)==find(y);
}
int A[100001];
int B[100001];
int C[100001];
int D[100001];
int cc[100011];
LL ans[100011];
int main(){
	int M,K;
	cin>>N>>M>>K;
	init(N+10);
	REP(i,M){
		cin>>A[i]>>B[i];
		A[i]--;
		B[i]--;
		unite(A[i],B[i]);
	}
	REP(i,K){
		cin>>C[i]>>D[i];
		C[i]--;
		D[i]--;
	}
	REP(i,N+10){
		cc[i]=0;
	}
	REP(i,N){
		cc[find(i)]++;
	}
	REP(i,N){
		ans[i]=cc[find(i)]-1;
	}
	REP(i,M){
		ans[A[i]]--;
		ans[B[i]]--;
	}
	REP(i,K){
		if(same(C[i],D[i])){
			ans[C[i]]--;
			ans[D[i]]--;
		}
	}
	REP(i,N){
		cout<<ans[i];
		if(i==N-1){
			cout<<endl;
		}else{
			cout<<" ";
		}
	}
}

Measured memory_bytes: 4352
import copy
[n,x]=list(map(int,input().split()))
a=list(map(int,input().split()))
a0=copy.copy(a)
ans=0
if a[0]+a[1]>x and a[0]>x:
	ans+=a[0]-x
	a[0]-=a[0]-x
	if a[0]+a[1]>x:
		ans+=a[1]
		a[1]=0	
for i in range(n-1):
	if a[i]+a[i+1]>x:
		ans+=a[i]+a[i+1]-x
		a[i+1]-=a[i]+a[i+1]-x
		
print(ans)

Measured memory_bytes: 15324
#include<algorithm>
#include<string.h>
#include<iostream>
#include<stdio.h>
using namespace std;

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int m1,d1,m2,d2;
  cin>>m1>>d1>>m2>>d2;
  if(d2==1){
  	cout<<"1";
  }
  else{
  	cout<<"0";
  }
  return 0;
}

Measured memory_bytes: 256
n = int(input())
S = ["".join(sorted(input())) for _ in range(n)]
counters = {}

for s in S:
    if s in counters:
        counters[s] += 1
    else:
        counters[s] = 1

ans = 0
for v in counters.values():
    if v == 1: continue
    ans += int(v * (v - 1) / 2)
print(ans)

Measured memory_bytes: 23640
#!/usr/bin/env python3
 
import sys
import math
import bisect
# 以下を記述しないとTLEになる, 何故？
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
# ---- ここまで -----------------------

S = input()
T = input()
lenS = len(S)
lenT = len(T)
F1 = [False]*26
F2 = [False]*26
alpha = 'abcdefghijklmnopqrstuvwxyz'
for i in range(lenS):
    F1[alpha.index(S[i])] = True
for i in range(lenT):
    F2[alpha.index(T[i])] = True
for i in range(26):
    if not F1[i] and F2[i]:
        print(-1)
        sys.exit()

ind = S.index(T[0])
ans = ind+1
for i in range(1,lenT):
    S = S[ind+1:] + S[:ind+1]
    ind = S.index(T[i])
    ans += ind+1

print(ans)


Measured memory_bytes: 3984
a,b,k = map(int,input().split())
L = []
for i in range(a,min(a+k,b+1)):
    L.append(i)
for i in range(max(b-k+1,a),b+1):
    L.append(i)
l = list(set(L))
l.sort()
for i in l:
    print(i)


Measured memory_bytes: 3060
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

int main()
{
    long long int n;
    cin>>n;
    long long int m=n,sum=0;
    while(n!=0)
    {
        long long int t=n%10;
        sum=sum+t;
        n=n/10;
    }
    if(m%sum==0)
      cout<<"Yes";
      else
       cout<<"No";

    return 0;
}


Measured memory_bytes: 256
n=int(input())
def dsf(s):
  if int(s)>n:
    return 0
  else:
    if all(s.count(c)>0 for c in "753"):
      x=1
    else:
      x=0
    for c in "753":
      x+=dsf(s+c)
    return x
print(dsf("0"))


Measured memory_bytes: 2940
a = int(input())

if a <= 9:
  print(a)
elif a <= 99:
  print(9)
elif a <= 999:
  print(9 + (a - 99))
elif a <= 9999:
  print(9 + 900)
elif a <= 99999:
  print(9 + 900 + (a - 9999))
else:
  print(9 + 900 + 90000)

Measured memory_bytes: 2940
N,M=map(int,input().split())

L=[0]*M
R=[0]*M

for i in range(M):
  L[i],R[i]=map(int,input().split())

def prison(N,M,L,R):
  max_val=min(R)
  min_val=max(L)
  num=max_val-min_val+1
  if num<=0:
    num=0
  return(num)

print(prison(N,M,L,R))

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

#define INF 1LL << 60

using Weight = long long;
struct Edge {
	int src, dst;
	Weight weight;
	Edge(int src_, int dst_, Weight weight_) : src(src_), dst(dst_), weight(weight_) { }
};
bool operator<(const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : e.dst < f.dst;
}
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void edgesToGraph(const Edges &edges, int V, Graph &g) {
	g.resize(V);
	for (auto e : edges) g[e.src].push_back(e);
}

void edgesToGraphUndir(const Edges &edges, int V, Graph &g) {
	g.resize(V);
	for (auto e : edges) {
		g[e.src].push_back(e);
		g[e.dst].push_back(Edge(e.dst, e.src, e.weight));
	}
}

bool bellmanford(const Graph g, int start,
	vector<Weight> &dist, vector<int> &prev) {
	int V = g.size();
	dist.assign(V, INF); dist[start] = 0;
	prev.assign(V, -2);
	bool negative_cycle = false;
	for (int k = 0; k < V; ++k) for (int i = 0; i < V; ++i) for (auto e : g[i]) {
		if (dist[e.src] == INF) continue;
		if (dist[e.dst] > dist[e.src] + e.weight) {
			dist[e.dst] = dist[e.src] + e.weight;
			prev[e.dst] = e.src;
			if (k == V - 1) {
				dist[e.dst] = -INF;
				negative_cycle = true;
			}
		}
	}
	return negative_cycle;
}

vector<int> buildPath(const vector<int> &prev, int end) {
	vector<int> path;
	for (int u = end; u >= 0; u = prev[u])
		path.push_back(u);
	reverse(path.begin(), path.end());
	return path;
}

int main(void) {
	int V, E, r;
	cin >> V >> E >> r;
	Edges edges;
	for (int i = 0; i < E; ++i) {
		long long s, t, d;
		cin >> s >> t >> d;
		edges.emplace_back(s, t, d);
	}
	Graph g;
	edgesToGraph(edges, V, g);

	vector<Weight> dist;
	vector<int> prev;
	bool nc = bellmanford(g, r, dist, prev);
	if (nc) {
		cout << "NEGATIVE CYCLE" << endl;
		return 0;
	}
	for (auto d : dist) {
		if (d >= INF)cout << "INF" << endl;
		else cout << d << endl;
	}
	return 0;
}



Measured memory_bytes: 3248
#include<bits/stdc++.h>
using namespace std;
int main(){
long long n;
cin>>n;
long long a[n];
for(long long i=0;i<n;i++){
    cin>>a[i];
}
long long dp[n+1]={0};
for(long long i=0;i<n;i++){
    dp[a[i]]++;
}
long long sum=0;
for(long long i=0;i<=n;i++){
    sum+=(dp[i]*(dp[i]-1))/2;
}
for(long long i=0;i<n;i++){
    cout<<sum-(dp[a[i]]-1)<<endl;
}
    return 0;
}

Measured memory_bytes: 5760
i = input()

a, b, c, d= i.split()
a = int(a)
b = int(b)
c = int(c)
d = int(d)

while (a > 0) or (c > 0):
    c = c - b
    if (a < 1) or (c < 1):
        break
    a = a - d

if a < 1:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 8980
#include <bits/stdc++.h>
using namespace std;
#define N (int)2e5
int n,a[N],b[N],c[N],memo[N][10];

// a = 0, b = 1, c = 2
int dp(int curr , int last) {
    if (curr > n) return 0;
    int &sol = memo[curr][last];
    if (sol != -1) return sol;
    if (last == 0) {
        sol = max(
            dp(curr + 1 , 1) + b[curr] ,
            dp(curr + 1 , 2) + c[curr]
        );
    } else if (last == 1) {
        sol = max(
            dp(curr + 1 , 0) + a[curr] ,
            dp(curr + 1 , 2) + c[curr]
        );
    } else {
        sol = max(
            dp(curr + 1 , 0) + a[curr] ,
            dp(curr + 1 , 1) + b[curr]
        );
    }
    return sol;
}

int main() {
    scanf("%d" , &n);
    for (int i = 1 ; i <= n ; i++)
        scanf("%d%d%d" , &a[i] , &b[i] , &c[i]);
    memset (memo , -1 , sizeof memo);
    printf("%d\n" , max(dp(2 , 0) + a[1] , max(dp(2 , 1) + b[1] , dp(2 , 2) + c[1])));
}


Measured memory_bytes: 13952
#include <iostream>

using namespace std;

int main()
{
	int a;
	int answer = 0;

	for (int i = 0; i < 2; i++) {
		cin >> a;

		if (a <= 3) {
			answer += (4 - a) * 100000;
		}
	}

	if (answer >= 600000) answer += 400000;

	cout << answer << endl;

	return 0;
}

Measured memory_bytes: 256
N,M = map(int, input().split())
ab = []
for m in range(M):
    a,b = map(int, input().split())
    ab.append((a,b))

ab = sorted(ab, key=lambda x: x[1])

cnt = 0
last = -1
for a, b in ab:
    if a < last:
        continue
    else:
        cnt += 1
        last = b

print(cnt)

Measured memory_bytes: 18972
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

k = inn()
if False and k==0:
    print('2')
    print('0 0')
    exit()
n = 50
p = k//n
r = k%n
if False and p==0:
    print(k+1)
    for i in range(k+1,1,-1):
        printn(str(i)+' ')
    print(0)
    exit()
a = list(range(p+n-1,p-1,-1))
for i in range(r):
    a[i] += 1
print(50)
for i in range(49):
    printn(str(a[i])+' ')
print(a[49])


Measured memory_bytes: 38384
import java.util.*;

public class Main
{
    public static void main(String... args)
    {
        final Scanner scanner = new Scanner(System.in);
        final ArrayList<Integer> heights = new ArrayList<Integer>();
        for (int i = 0; i < 10; i++) {
            heights.add(scanner.nextInt());
        }

        Collections.sort(heights, new Comparator<Integer>()
        {
            @Override
            public int compare(Integer height1, Integer height2)
            {
                return height1.compareTo(height2) * -1;
            }
        });

        for (int i = 0; i < 3; i++) {
            System.out.println(heights.get(i));
        }
    }
}

Measured memory_bytes: 17180
N, M = gets.split.map(&:to_i)

ans = 0
(1..(M**(0.5))).each do |n|
  next if M % n != 0

  if (N * n) <= M
    ans = [ans, n].max
  end

  m = M / n
  if (N * m) <= M
    ans = [ans, m].max
  end
end

puts ans


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int a,b,x;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  cin >> a >> b >> x;
  if (x < a) cout << x%MOD << endl;
  else cout << (x%MOD+((x-b)/(a-b)%MOD)*(b%MOD)%MOD)%MOD << endl;

  return 0;
}


Measured memory_bytes: 3216
#include<bits/stdc++.h>
#define int long long
using namespace std;
int N;
void a(string S,char C){
  if(S.size()==N){
    cout<<S<<endl;
    return;
  }
  for(char c='a';c<C;c++)a(S+c,C);
  a(S+C,C+1);
}
signed main(){
  cin>>N;
  a("",'a');
}

Measured memory_bytes: 3632
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}

ll gcd(ll(a), ll(b)) {
	ll k = a;
	ll l = b;
	ll j = 0;
	while (l != 0) {
		j = k % l;
		k = l;
		l = j;
	}
	return k;
}



int main() {

	ll N;
	cin >> N;
	vector<ll> vec(N);
	ll an = 1;
	for (ll i = 0; i < N; i++) {
		cin >> vec.at(i);
		an = an/(gcd(an, vec.at(i)))*vec.at(i);
		
	}
	cout <<an<< endl;
	
	
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll x;cin>>x;
  ll sum=0;
  for(int i=1;;i++){
    sum+=i;
    if(sum>=x){
      cout<<i<<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int i,N,l,r,t=0;
  cin >> N;
  for(i=0;i<N;i++){
    cin >> l >> r;
    t+=(r-l+1);
    if(i+1==N){
      cout << t << endl;
    }
  }
}
    
    

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int a,b,c,d,e;
	cin >> a;if(a<40)a=40;
	cin >> b;if(b<40)b=40;
	cin >> c;if(c<40)c=40;
	cin >> d;if(d<40)d=40;
	cin >> e;if(e<40)e=40;
	int sum=a+b+c+d+e;
	cout << sum/5 << endl;
	return 0;
}

Measured memory_bytes: 1164
import java.util.*;
import java.util.Collections;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        long[] a = new long[N+1];
        long[] b = new long[N];
        
        for(int i = 0; i < N+1; i++) {
            a[i] = Long.parseLong(sc.next());
        }
        
        for(int i = 0; i < N; i++) {
            b[i] = Long.parseLong(sc.next());
        }
        
        long count = 0;
        
        for(int i = 1; i < N+1; i ++) {
            if(a[i-1] >= b[i-1]) {
                a[i-1] -= b[i-1];
                count += b[i-1];
            }else {
                if(a[i] >= b[i-1] - a[i-1]) {
                    count += b[i-1];
                    a[i] -= b[i-1] - a[i-1];
                    a[i-1] = 0;
                }else {
                    count += a[i-1] + a[i];
                    a[i-1] = 0;
                    a[i] = 0;
                }
            }
            
        }
        
        System.out.println(count);
        
    }
}

Measured memory_bytes: 56300
N, C, K = map(int, input().split())
l = []

for i in range(N):
    l.append(int(input()))
l.sort()

i = 0
result = 0
while(i < N):
    cur = l[i]
    psg = 0
    while(i < N and cur + K >= l[i] and psg < C):
        i += 1
        psg += 1
    result += 1

print(result)

Measured memory_bytes: 7384