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

using namespace std;

int main(){
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n; cin>>n;
	int a[n];
	int s = 0;
	for(int i = 0; i < n; i++){
		cin>>a[i];
		s ^= a[i];
	}
	for(int i = 0; i < n; i++){
		cout << (a[i]^s) << " ";
	}
	cout << "\n";
	return 0;
}

Measured memory_bytes: 4328
#! python 3
# distance_ii.py

import math

def minkovski(a, b, p):
    if p == 'inf':
        tmp_arr = [abs(x-y) for x, y in zip(a, b)]
        max_val = tmp_arr[0]
        for i in range(1, len(a)):
            if max_val < tmp_arr[i]:
                max_val = tmp_arr[i]
        return max_val
    else:
        dst = 0
        for x, y in zip(a, b):
            dst += pow(abs(x-y), p)
        dst = pow(dst, 1/p)
        return dst

n = int(input())
a = [int(x) for x in input().split(' ')]
b = [int(x) for x in input().split(' ')]

for p in [1, 2, 3, 'inf']:
    print('%.6f'%minkovski(a, b, p))



Measured memory_bytes: 5704
import fractions

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

g = fractions.gcd(a, b)

ans = 0
i = 2
while i * i <= g:
    if g % i == 0:
        ans += 1
        while g % i == 0:
            g //= i
    i += 1

if g > 1:
    ans += 1

print(ans + 1)

Measured memory_bytes: 5048
/* 実行時間1s制限の場合10^6 1,000,000 : 余裕をもって間に合う10^7
  10,000,000 : おそらく間に合う10^8 100,000,000 : 非常にシンプルな処理
  でないと厳しい
 */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#include <bits/stdc++.h>
using namespace std;

typedef long long ll; // long longはデータモデル(LLP64, LP64, ...)によらず64bit.
ll gcd(ll a, ll b) {return b ? gcd(b, a%b) : a;}  // Greatest Common Divisor ユークリッドの互除法（aが長辺）
vector<pair<ll,int>> factorize(ll n) {            // a,bの公約数 = GCD(a, b)の約数
    vector<pair<ll,int>> res;
    for (ll i = 2; i*i <= n; i++) { // √nまで探せばよい
        if (n%i) continue;
        res.emplace_back(i, 0);     // 割り切れたら
        while (n%i == 0) {
            n /= i;
            res.back().second++;
        }
    }
    if (n != 1) res.emplace_back(n, 1); // この時点で1でなかったら、残りは素数.
    return res;
}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}         // Least Commont Multiple オーバーフローしないように先に割る
ll ceil(ll a, ll b) {return (a+b-1)/b;}

const ll INF = LONG_MAX;
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; }

int main(int argc, char* argv[])
{
#ifdef LOCAL
    // 以降 cin の入力元が 'xxx.txt' になる
    // std::ifstream in(argv[1]);
    //std::cin.rdbuf(in.rdbuf());
    //std::ifstream in(string(argv[0]) + ".txt");
    std::ifstream in("in.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    int n;
    cin >> n;

    if (n%2) cout << n/2+1;
    else cout << n/2;


    return 0;
}

/*
  - 1e9 : 10^9
  - container一般
    - 合計
      accumulate(a.begin(), a.end(), 0LL)  0LLはオーバーフロー用
  - vector
    vector<int> A(N, 0); // 0で初期化(省略可)
    - loop
      for  (int i = 0; i < A.size(); i++) {}
      for  (int elem : A) {}
    - sort
      std::sort(v.begin(), v.end());  // 昇順
      std::sort(v.begin(), v.end(), std::greater<int>()); //降順
      - vector<vector<int>> cnt(h, vector<int>(w))
    - sort(struct)
        struct st_t {
            string name;
            int p;
            bool operator<(const st_t& another) const {
                if (name == another.name)
                {
                    return p > another.p;
                }
                return name < another.name;
            }
        };
        vector<st_t> st(n);
        sort(st.begin(), st.end());
  - pair
    - pairのソートの定義 : firstが優先的に比較。同じだったらsecond。
    - pair<pair<string,int>,int> p[110];
      std::sort(p,p+a);
        こうすると、first.first -> first.second -> secondの順にソートされる
    - sort
      - sort(a.begin(), cb.end(), greater<pair<int, int>>());
  - map
    - for (auto x : map) {}  // x.first:key  x.second:value.
  - priority_queue<int> q;
    - q.top()に最大値が入っている
  - string
    - loop
      for (char& c : s) {}
 */



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c,d,e;
  string s,ss,sss;
  cin>>s;
  bool hoge=true;
  for(int i=0;i<3;i++)
    if(s[i]==s[i+1])hoge=false;
  if(hoge)
  cout<<"Good"<<endl;
  else cout<<"Bad"<<endl;
  return 0;
}


Measured memory_bytes: 764
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use std::cmp::*;
use std::collections::*;
use std::mem::*;

fn main() {
    let (r, w, e) = (std::io::stdin(), std::io::stdout(), std::io::stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());
    assert_eq!(!0usize, std::usize::MAX); //🙊
    let n: i64 = io.read();
    // u,v <= n で
    // a ^ b == u  &&  a + b == v が何通りあるか

    // 2^60 くらいまで

    let mut dp = vec![vec![0i64; 3]; 61];
    dp[60][0] = 1;

    for d in (0..60).rev() {
        for s in 0..3 {
            for k in 0..3 {
                let ss = min(
                    2,
                    (2 * s + if ((n >> d) & 1) == 1 { 1 } else { 0 }) as i64 - k as i64,
                );
                if ss >= 0 {
                    let ss = ss as usize;
                    dp[d][ss] = (dp[d][ss] + dp[d + 1][s]) % MOD;
                }
            }
        }
    }

    io.writeln((dp[0][0] + dp[0][1] + dp[0][2]) % MOD);
}

static MOD: i64 = 1000000007;
static INF: i64 = std::i64::MAX >> 1;
// IO
use std::io::*;
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn chari(&mut self) -> Vec<i64> {
        self.chars()
            .iter()
            .map(|&c| (c as u8 - b'0') as i64)
            .collect::<Vec<i64>>()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
    fn debug3<S: std::fmt::Debug, T: std::fmt::Debug, U: std::fmt::Debug>(
        &mut self,
        val1: S,
        val2: T,
        val3: U,
    ) {
        writeln!(
            self.Error,
            "(debug3) {:?} -> {:?} -> {:?}",
            val1, val2, val3
        );
    }
}


Measured memory_bytes: 4352
def wczytaj_liste(): 
    wczytana_lista = input()
    lista_znakow = wczytana_lista.split()
    ostateczna_lista = []
    for element in lista_znakow:
        ostateczna_lista.append(int(element))
    return ostateczna_lista

def Double_Factorial():
    N = wczytaj_liste()[0]
    if N < 10: 
        print (0)
    elif N%2 == 1: 
        print(0)
    else:
        podzielnik = 10
        wynik = 0
        while podzielnik <= N:
            wynik += N//podzielnik
            podzielnik *= 5
        print(wynik)
            
Double_Factorial()

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

int main(){
  int n,m;
  int total=0;
  cin >> n >> m;
  vector<int> vote(n);
  for(int i=0;i<n;i++){
    cin >> vote.at(i);
    total+=vote.at(i);
  }
  sort(vote.begin(),vote.end());
  reverse(vote.begin(),vote.end());
  if(total>vote.at(m-1)*4*m) cout << "No" << endl;
  else cout << "Yes" << endl;
}

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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

//実行部
void Main()
{
  ll n, m; cin >> n >> m;
  if(m > n) swap(n, m);
  if(n >= 3&&m >= 3) fin((n - 2) * (m - 2))
  else if(n == 1&&m==1) fin(1)
  else if(n == 2&&m == 1) fin(0)
  else if(n == 2&&m == 2) fin(0)
  else if(n > 2&&m == 1) fin(n - 2)
  else if(n > 2&&m == 2) fin(0) 
  return;
}

//前処理
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
  int n, b, c;
  vector<int> a;
  cin >> n;
  for (int i = 0; i <= n; i++) {
    cin >> c;
    a.push_back(c);
  }
  c = 0;
  ll sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> b;
    if (a[i] <= c) {
      //前の勇者がすべて倒したケース
      sum += a[i];
      c = b;
    } else if (a[i] <= b + c) {
      //前の勇者と今の勇者で全て倒したケース
      sum += a[i];
      c = b + c - a[i];
    } else {
      //倒せなかったケース
      sum += b + c;
      c = 0;
    }
  }
  if (a[n] <= c) {
    //前の勇者がすべて倒したケース
    sum += a[n];
  } else {
    //倒せなかったケース
    sum += c;
  }
  cout << sum;
  return 0;
}


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

typedef long long ll;

int main()
{
	char c[4];
		for (int i = 0; i < 4; i++)
			c[i] = getchar();
		if (c[0] == c[1] && c[1] == c[2] || c[1] == c[2] && c[2] == c[3] )
			cout << "Yes";
		else cout << "No";
		string str;
		//cin >> str;
	return 0;
}

Measured memory_bytes: 256
"""
author : halo2halo
date : 24,Oct,2019
"""

import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

a, b = map(int, readline().rstrip().split())

print("Odd" if a*b % 2 == 1 else "Even")


Measured memory_bytes: 2940
(let ((a (read))
    (b (read))
    (k (read)))
    (if (> a k)
    (decf a k)
        (if (> (+ a b) k)
        (progn
        (decf b (- k a))
        (setq a 0)
        )
        (progn
        (setq a 0)
        (setq b 0))))
    (format t "~D ~D" a b)
)

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

int main() {
  char str[202];
  char temp[202];
  while(1){
    for(int a = 0;a<202;a++)str[a] = '0';
    int count,length = 0;
    cin >> str;
    if(str[0] == '-')break;
    for(int a = 0;str[a] != '0';a++)length++;
    length--;
    //cout << "length "<<length<<endl;
    //for(int a = 0;a<length;a++)cout << str[a];
    cin >> count;
    for(;count > 0;count--){
      int frame;
      cin >> frame;
      //cout << "frame " << frame<<endl;
      for(int a = 0;a<frame;a++)temp[a] = str[a];
      //cout << "temp ";
      //for(int a = 0;a<frame;a++)cout << temp[a];
      //cout << endl;
      for(int a = 0;a<length-frame;a++)str[a] = str[a+frame];
      for(int a = 0;a<frame;a++)str[length -frame + a] = temp[a];

      //for(int a = 0;a<length;a++)cout << str[a];
      //cout << endl;
    }
    for(int a = 0;a<length;a++)cout << str[a];
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 3080
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>
#define _USE_CMATH_DEFINES

const long INF = (1l << 30);
const long LINF = (1l << 60); //1.15*10^18
const long MOD = 2019;

std::string s;

int main(){
    std::cin >> s;
    std::vector<long> v(s.length() + 1);
    v[0] = 0;
    long dig = 1;
    for(int i = 1; i <= s.length(); i++){
        v.at(i) = v[i-1];
        v.at(i) += (s[s.length() - i] - '0') * dig;
        v.at(i) %= MOD;
        dig *= 10;
        dig %= MOD;
    }
    std::map<long, long> mp;
    for(int i = 0; i < v.size(); i++){
        mp[v[i]]++;
    }
    long ans = 0;
    for(auto it = mp.begin(); it != mp.end(); it++){
        long num = it -> second;
        ans += num * (num-1) / 2;
    }
    printf("%ld\n", ans);
}


Measured memory_bytes: 5072
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const ll INF = 1LL<<60;

vector<vector<int>> g;
vector<int> ans;

int main(){
  int n; cin >> n;
  vector<int> v(n), c(n);
  for(int i = 0; i < n; ++i) cin >> v[i];
  for(int i = 0; i < n; ++i) cin >> c[i];
  int ans = 0;
  for(int bit = 0; bit < (1<<n); ++bit){
    int a = 0, b = 0;
    for(int i = 0; i < n; ++i){
      if((bit >> i) & 1){
        a += v[i]; b += c[i];
      }
    }
    ans = max(ans, a - b);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <cstdlib>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	int n; cin >> n;
	vector<queue<int>> q(n + 1, queue<int>());
	for (int i = 1; i <= n; ++i)
	{
		rep(j, n - 1)
		{
			int a; cin >> a;
			q[i].push(a);
		}
	}
	queue<int> can;
	for (int i = 1; i <= n; ++i)can.push(i);
	int cnt = 0;
	bool gameExist = true;
	while (gameExist)
	{
		gameExist = false;
		vector<bool> played(n + 1);
		int i = can.size();
		while (i--)
		{
			int a = can.front();
			can.pop();
			if (q[a].empty())continue;
			if (played[a])continue;
			int b = q[a].front();
			if (played[b])continue;
			if (q[b].front() == a)
			{
				q[a].pop();
				q[b].pop();
				can.push(a);
				can.push(b);
				played[a] = true;
				played[b] = true;
				gameExist = true;
			}
		}
		++cnt;
	}
	bool finished = true;
	for (int i = 1; i <= n; ++i)if (!q[i].empty())finished = false;
	if (finished)cout << cnt - 1 << endl;
	else cout << -1 << endl;
}


Measured memory_bytes: 4736
H, W = map(int,input().split())
s = [[i for i in list(input())] for j in range(H)]
dx = [0,0,-1,1]
dy = [-1,1,0,0]
 
for i in range(H):
    for j in range(W):
        if s[i][j] == ".": continue
 
        # 上下左右の4方向
        for k in range(4):
            ni = i + dy[k]
            nj = j + dx[k]
 
            if ni < 0 or ni >= H: continue
            if nj < 0 or nj >= W: continue
 
            if s[ni][nj] == "#": break
            if k == 3:
                print("No")
                exit()
 
print("Yes")

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    int x, a, b;
    cin >> x >> a >> b;

    if(abs(x-a)<abs(x-b)) cout << "A" << endl;
    else cout << "B" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){

   int H, W;
   cin>> H>> W;
   string s[H][W];
   for(int i=0; i<H; i++){
      for(int j=0; j<W; j++){
         cin>> s[i][j];
      }
   }

   for(int i=0; i<H; i++){
      for(int j=0; j<W; j++){
         if(s[i][j]=="snuke"){
            cout<< (char)('A'+j)<< i+1<< endl;
         }
      }
   }
   return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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) {
    int N;
    cin >> N;

    vector<int> as(N + 1);
    for (int i = 1; i <= N; i++) {
        cin >> as[i];
    }

    int ans = 0;

    for (int i = 1; i <= N; i++) {
        if (i % 2 == 1 && as[i] % 2 == 1) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

int main()
{
   int i,j,k,n;
   cin>>n;
   vector<int> a,b;
   a.resize(n);
   for(i=0;i<n;i++) cin>>a[i];
   b.resize(n+1);
   int l=1;
   int r=n;
   for(i=n-1;i>=0;i--){
    if((i-n-1)%2==0){
    b[l]=a[i];
    l++;
    }else{
    b[r]=a[i];
    r--;
    }
   }
   for(i=1;i<=n;i++) cout<<b[i]<<" ";
}

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
const ll INF = 1e15;

ll mod_pow(ll x, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}

int main() {
  ll n;
  cin >> n;
  vector<ll> d(n);
  map<ll, ll> mp;
  REP(i, n) {
    cin >> d[i];
    mp[d[i]]++;
  }

  ll mx = mp.size();
  if (!(mp[0] == 1 && d[0] == 0)) {
    cout << 0 << endl;
    return 0;
  }
  REP(i, mx) {
    if (mp[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }

  ll ans = 1;
  const ll MOD = 998244353;
  FOR(i, 1, mx) {
    ans *= mod_pow(mp[i - 1], mp[i], MOD);
    ans %= MOD;
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 7296
use std::io::*;

fn main() {
  let stdin = stdin();
  let stdout = stdout();
  let mut stdout = BufWriter::new(stdout.lock());

  for line in stdin.lock().lines() {
    let line = line.unwrap();
    if line == "0 0" { break; }

    let mut args = line.split_whitespace().map(|s| s.parse::<usize>().unwrap());
    let n = args.next().unwrap();
    let x = args.next().unwrap();

    if x < 6 {
      writeln!(stdout, "0").unwrap();
      continue;
    }

    let max = std::cmp::min(n + 1, x - 2);
    let min = (x as f64 / 3.0).ceil() as usize + 1;
    let mut count = 0;

    for i in (min..max).rev() {
      count += (x - i - 1) / 2;
      if i * 2 < x { count -= x - i * 2 }
    }

    writeln!(stdout, "{}", count).unwrap();
  }
}



Measured memory_bytes: 5112
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

bool comp(int a, int b){
    int wa = (10 - a % 10 == 10 ? 0 : 10 - a % 10);
    int wb = (10 - b % 10 == 10 ? 0 : 10 - b % 10);
    return wa < wb;
}

int main(int argc, char const *argv[])
{
    vector<int> T;
    int tmp;
    for (int i = 0; i < 5; i++)
    {
        cin >> tmp;
        T.emplace_back(tmp);
    }
    sort(T.begin(), T.end(), comp);

    for (int i = 0; i < 4; i++)
    {
        if (T[i] % 10 != 0)
        {
            T[i] = T[i] + (10 - T[i] % 10);
        }
        
    }
    
    int sum = accumulate(T.begin(), T.end(), 0);
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		    Scanner sc = new Scanner(System.in);

		    int n = Integer.parseInt(sc.next());
		    String[] s = new String[n];
		    String[] ss = new String[n];
		    for(int i=0; i<n;i++) {
		    	s[i] = sc.next();
		    	char[] chars = new char[10];
		    	chars = s[i].toCharArray();
		    	Arrays.sort(chars);
		    	ss[i] = new String(chars);
		    }
		    Arrays.sort(ss);

		    long cnt = 0;
		    long cnt1 = 0;
		    for(int i=0;i<n-1;i++) {
		    	if(ss[i].equals(ss[i+1])) {
		    		cnt1++;
		    		cnt+=cnt1;
		    	}else {
		    		cnt1=0;
		    	}
		    }
		    System.out.println(cnt);

		    sc.close();
	}
}


Measured memory_bytes: 55260
#include <bits/stdc++.h>
using namespace std;
int main() {
 int n,k;
  cin>>n>>k;
  vector <int> v(n);
  int tmp;
  for (int i=0; i<n;i++){
   cin >> v.at(i);
  }
  sort (v.begin()
        ,v.end());
  int b=0;
  for (int i=0; i<k;i++){
    b=v.at(i)+b;
  }
    cout<<b<<endl;
}


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

int dp[101][4][4][4];
const int mod = 1000000007;

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

    dp[0][3][3][3] = 1;

    for (int i = 0; i < N; i++) {
        for (int c1 = 0; c1 < 4; c1++) {
            for (int c2 = 0; c2 < 4; c2++) {
                for (int c3 = 0; c3 < 4; c3++) {
                    for (int c4 = 0; c4 < 4; c4++) {
                        if (c2 == 0 && c3 == 1 && c4 == 2) continue; // AGC
                        if (c2 == 1 && c3 == 0 && c4 == 2) continue; // GAC
                        if (c2 == 0 && c3 == 2 && c4 == 1) continue; // ACG
                        if (c1 == 0 && c3 == 1 && c4 == 2) continue; // A?GC
                        if (c1 == 0 && c2 == 1 && c4 == 2) continue; // AG?C

                        dp[i + 1][c2][c3][c4] += dp[i][c1][c2][c3];
                        dp[i + 1][c2][c3][c4] %= mod;
                    }
                }
            }
        }
    }

    int ans = 0;
    for (int c1 = 0; c1 < 4; c1++) {
        for (int c2 = 0; c2 < 4; c2++) {
            for (int c3 = 0; c3 < 4; c3++) {
                ans += dp[N][c1][c2][c3];
                ans %= mod;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

string s;
deque<char> d;
int q;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>s;
    int n = s.length();
    for(int i = 0; i < n; i++){
        d.push_back(s[i]);
    }
    int flag = 1;
    cin>>q;
    while(q--){
        int inst;
        cin>>inst;
        if(inst == 2){
            int order;
            cin>>order;
            char nxt;
            cin>>nxt;
            if(order == 1){
                if(flag == 1) d.push_front(nxt);
                else d.push_back(nxt);
            } else {
                if(flag == 1) d.push_back(nxt);
                else d.push_front(nxt);
            }
        } else {
            if(flag == 1) flag = 2;
            else flag = 1;
        }
        
    }
    string ans = "";
    while(!d.empty()){
        if(flag == 1) {
            ans += d.front();
            d.pop_front();
        } else {
            ans += d.back();
            d.pop_back();
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1368
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>

using namespace std;

int main(){
   int a,b,c,x;
   cin>>a>>b>>c>>x;
   int ans=0;
   for(int i=0;i<a+1;i++){
      for(int j=0;j<b+1;j++){
         for(int k=0;k<c+1;k++){
            if(500*i+100*j+50*k==x)ans++;
         }
      }
   }
   cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        int x = a * b;
        int y = 2*a + 2*b;
        
        System.out.println(x + " " + y);
    }
}


Measured memory_bytes: 26004
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

string s;
V<int> v;
V<char> c;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> s;
  s = "a"+s+"a";
  FOR(i, 0, sz(s)) if(s[i]!='x'){
    c.pb(s[i]);
    v.pb(i);
  }
  int l = 0, r = sz(v)-1;
  int ans = 0;
  while(l<r){
    if(c[l]!=c[r]){
      cout << -1 << endl;
      return 0;
    }
    ans += abs((v[l+1]-v[l])-(v[r]-v[r-1]));
    l++; r--;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1132
import sys

input_methods=['clipboard','file','key']
using_method=1
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

dd={}
def get_f(v):
	global dd
	if v == 0:
		return 0
		
	if v in dd:
		return dd[v]
	
	pn = bin(v).count('1')
	ret = 1+get_f(v % pn)
	dd[v] = ret
	return ret
	
def bb(n, s):
	saigo = int(s[-1])
	for i, c in enumerate(s[:-1]):
		if c == '0':
			print(get_f(saigo)+1)
		else:
			print(0)
			
	if saigo == 0:
		print(get_f(1)+1)
	else:
		print(0)
		

def main():
	n = int(input())
	#b , c = tin()
	s = input()
	sa=s[::-1]
	n_one=s.count('1')
	if n_one == 1:
		bb(n,s)
		return 
	#pa(n_one)
	#pa(s)
	amari_p = 0
	amari_n = 0
	for i, c in enumerate(sa):
		if c == '1':
			amari_p += pow(2,i,n_one+1)
			amari_n += pow(2,i,n_one-1)
			amari_p %= n_one+1
			amari_n %= n_one-1
		
	#pa(amari_p)
	#pa(amari_n)
	for i, c in enumerate(s):
		keta = n - i - 1
		if c == '1':
			ta = amari_n
			ta -= pow(2,keta,n_one-1)
			ta %= n_one-1
		else:
			ta = amari_p
			ta += pow(2, keta, n_one+1)
			#pa(('q',ta))
			ta %= n_one+1
		#pa((keta,pow(2,keta),ta))
		print(get_f(ta)+1)
		
		
	
		
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 80796
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int a, b, c; cin >> a >> b >> c;
  int ans = min(
    min(abs(a-b)+abs(b-c), abs(a-c)+abs(b-c)),
  	abs(b-a)+abs(c-a));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
//SOLVE


void solve (void)
{
  string str;cin>>str;
  int N = str.size();
  for (int i = 1; i <= N/2; i++)
  {
    string s = str.substr(0,N - 2*i);
    string s1 = s.substr(0,s.size()/2);
    string s2 = s.substr(s.size()/2,s.size()/2);
    if(s1 == s2)
    {
      cout<<s.size()<<endl;
      return;
    }
  }
  
  

  
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


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

int dp[1001][1001];
int v[1001], w[1001];
int main() {
	int W, N;
	int cnt = 1;
	while (scanf("%d", &W), W) {
		scanf("%d", &N);
		rep(i, N)scanf("%d,%d", &v[i], &w[i]);
		for (int i = 0; i < N; i++) {
			for (int j = 0; j <= W; j++) {
				if (j < w[i]) dp[i + 1][j] = dp[i][j];
				else dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
			}
		}
		int Max = 0, Min = 0;
		for (int i = 0; i <= W; i++) {
			if (Max < dp[N][i]) { Max = dp[N][i]; Min = i; }
		}
		printf("Case %d:\n%d\n%d\n", cnt, Max, Min);
		cnt++;
	}
	return 0;
}

Measured memory_bytes: 7012
"""
AtCoder Educational DP Contest
https://atcoder.jp/contests/dp/tasks/dp_g

G - Longest path

"""
import collections
import functools
import sys
sys.setrecursionlimit(1000000)


def get_adj_list(pairs):
    adj = collections.defaultdict(list)
    for (i, j) in pairs:
        adj[i].append(j)
    return adj


def solve(pairs):
    adj_list = get_adj_list(pairs)

    @functools.lru_cache(1000000)
    def dfs(u):
        res = -1
        for v in adj_list[u]:
            res = max(res, dfs(v))
        return 1 + res

    # depths = [dfs(u) for u in range(1, N+1)]
    # print(depths)
    depths = (dfs(u) for u in range(1, N+1))
    return max(depths, default=0)


N, M = map(int, input().split())
pairs = [[int(s) for s in input().split()] for _ in range(M)]
res = solve(pairs)
print(res)


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

int main(){
  int n, y;
  cin >> n >> y;
  for (int i = 0; i <= y / 10000; i++) {
    for (int j = 0; j <= (y - i * 10000) / 5000; j++) {
      int k = n - i - j;
      if (k < 0) continue;
      if (i * 10000 + j * 5000 + k * 1000 == y) {
        cout << i << " " << j << " " << k << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
  return 0;
}


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

int main() {
    int a[3][3];
    rep(i, 3) rep(j, 3) cin >> a[i][j];

    int N,t;
    bool b[3][3]={false};
    cin >> N;
    rep(i,N){
        cin >> t;
        rep(j,3)rep(k,3){
            if(a[j][k]==t)
                b[j][k] = true;
        }
    }

    bool ans = false, flag = true;
    rep(i, 3) {
        flag = true;
        rep(j, 3) {
            if (!b[i][j])
                flag = false;
        }
        if(flag)
            ans = true;
    }
    rep(i, 3) {
        flag = true;
        rep(j, 3) {
            if (!b[j][i])
                flag = false;
        }
        if (flag)
            ans = true;
    }

    flag = true;
    rep(i, 3) {
        if(!b[i][i])
            flag = false;
    }
    if(flag)
        ans = true;

    flag = true;
    rep(i,3){
        if(!b[i][2-i])
            flag = false;
    }
    if(flag)
        ans = true;

    ans ? cout << "Yes" : cout << "No";
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
def main():
    n,k = map(int,input().split())
    s = 0
    if k==0:
        s = n*n
    else:
        for k_ in range(k,n):
            for q in range((n-k_)//(k_+1)+1):
                if q==0:
                    s += n-k_
                else:
                    s += (n-k_)//q-k_
    print(s)
            
if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#pragma GCC optimize("Ofast","unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace::std;
__attribute__((constructor))
void init(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(15);
}
auto call=[](auto f,auto... args){return f(f,args...);};
auto call_memo=[](auto f,auto&& memo,auto... args){
	auto g=[&memo,f](auto g,auto... args)->decltype(auto){
		if(memo.count(make_tuple(args...)))return memo[make_tuple(args...)];
        else return memo[make_tuple(args...)]=f(g,args...);
    };
	return call(g,args...);
};

int main(){
	int n;
	cin>>n;
	auto f=[&](auto f,int t)->int{
		return t>=2?f(f,t-1)+f(f,t-2):1;
	};
	cout<<call_memo(f,map<tuple<int>,int>(),n)<<endl;
}


Measured memory_bytes: 3184
// AOJ 1226: Fishnet
// 2017.10.14 bal4u@uu

#include <stdio.h>
#include <math.h>

typedef struct { double x, y; } PP;
PP tbl[35][35];
double a[4][35];

void intersection(PP *p, PP *p1, PP *p2, PP *p3, PP *p4)
{
	double bo, ua;
	bo = (p4->y-p3->y)*(p2->x-p1->x)-(p4->x-p3->x)*(p2->y-p1->y);
	ua = (p4->x-p3->x)*(p1->y-p3->y)-(p4->y-p3->y)*(p1->x-p3->x);
	p->x = p1->x + ua/bo * (p2->x-p1->x);
	p->y = p1->y + ua/bo * (p2->y-p1->y);
}

double calc_area(PP *pp)
{
	int i;
	double s;
	for (s = 0, i = 0; i < 4; i++) s += (pp[i].x-pp[i+1].x) * (pp[i].y+pp[i+1].y);
	return fabs(s)/2;
}

int main()
{
	int n, i, j;
	double ans, s;
	PP t[5];

	while (scanf("%d", &n) && n > 0) {
		for (j = 0; j < 4; j++) for (i = 1; i <= n; i++) scanf("%lf", &a[j][i]);
		n++;
		tbl[0][0].x = 0, tbl[0][0].y = 0;
		for (i = 1; i < n; i++) tbl[i][0].x = a[0][i], tbl[i][0].y = 0;
		tbl[n][0].x = 1, tbl[n][0].y = 0;

		tbl[0][n].x = 0, tbl[0][n].y = 1;
		for (i = 1; i < n; i++) tbl[i][n].x = a[1][i], tbl[i][n].y = 1;
		tbl[n][n].x = 1, tbl[n][n].y = 1;

		for (j = 1; j < n; j++) tbl[0][j].x = 0, tbl[0][j].y = a[2][j];
		for (j = 1; j < n; j++) tbl[n][j].x = 1, tbl[n][j].y = a[3][j];

		for (j = 1; j < n; j++) for (i = 1; i < n; i++)
			intersection(&tbl[i][j], &tbl[i][0], &tbl[i][n], &tbl[0][j], &tbl[n][j]);

		ans = 0;
		for (j = 1; j <= n; j++) for (i = 1; i <= n; i++) {
			t[0] = t[4] = tbl[i-1][j-1], t[1] = tbl[i][j-1];
			t[2] = tbl[i][j], t[3] = tbl[i-1][j];
			if ((s = calc_area(t)) >= ans) ans = s;
		}

		printf("%.6lf\n", ans);
	}
    return 0;
}

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

int main(){
  int a,b;
  cin >> a >> b;
  if(a%3==0||b%3==0||(a+b)%3==0){
    cout << "Possible" << endl;
  }
  else{
    cout << "Impossible" << endl;
  }
}

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

int main(){

  string S,T;
  cin >> S >> T;
  int count=0;

  for(int i=0;i<S.length();i++){
    if(S[i]==T[i]) count++;
    else break;
  }

  if(count==S.length() && T.length()==S.length()+1) cout << "Yes" << endl;
  else cout << "No"<< endl;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int n = sc.nextInt();
        int[] in = new int[w];
        
        for(int i=0;i<w;i++){
            in[i] = i+1;
        }

        for(int i=0;i<n;i++){
            String line = sc.next();
            String[] ab = line.split(",");
            int a = Integer.parseInt(ab[0])-1;
            int b = Integer.parseInt(ab[1])-1;
            int f = in[a];
            in[a] = in[b];
            in[b] = f; 
        }
        for(int i=0;i<w;i++){
            System.out.println(in[i] );
        }            
        sc.close();
    }
}


Measured memory_bytes: 26256
#127_D
n, m = map(int, input().split())
a = list(map(int, input().split()))
bc = [(1, a[i]) for i in range(n)]+[tuple(map(int, input().split())) for _ in range(m)]
bc.sort(key= lambda x: -x[1])

tmp = 0
ans = 0
for b, c in bc:
    x = min(b, n-tmp)
    ans += c * x
    tmp += x
    
    if tmp == n:
        break

print(ans)    

Measured memory_bytes: 38016
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>

using namespace std;
int n, c[505], s[505], f[505];

int func(int tm, int i) {

	int nn = 0;
	for (; ;) {
		//cout << "i2->" << i << " tm2->" << tm << endl;
		
		//if (tm < s[i + 1]) {
		if (tm > s[i + 1] + nn) {
			//tm += f[i + 1];
			nn += f[i + 1];
		}
		else {
			tm = s[i + 1] + nn;
			break;
		}

	}

	return tm;
}

int main() {
	int i, j, k;
	int his[505];

	cin >> n;

	for (i = 0; i < n-1; i++) {
		cin >> c[i] >> s[i] >> f[i];
	}


	for (j = 0; j < n - 1; j++) {
		int tm = 0;
		tm += s[j];
		//his[0] = 0;

		for (i = j; i < n - 1; i++) {

			tm += c[i];

			//his[i] = tm;

			if (i == n - 2) break;

			if (tm < s[i + 1]) {
				//tm = func(tm, i);
				tm = s[i + 1];
			}
			else if (tm > s[i + 1]) {

				tm = func(tm, i);
			}

			//cout << "i->" << i << " tm->" << tm << endl;

		}

		his[j] = tm;

	}

	for (i = 0; i < n-1; i++) {
		//cout << tm - his[i] << endl;
		cout << his[i] << endl;
	}

	cout << 0 << endl;









	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<set>
#define ll long long
#define maxn 300010
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static int buf[20],len; len=0;
	if(x<0)x=-x,putchar('-');
	for(;x;x/=10)buf[len++]=x%10;
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]+'0');
}
inline void writeln(ll x){write(x); putchar('\n');}
inline void writesp(ll x){write(x); putchar(' ');}
std::multiset<int>st;
int a[maxn],b[maxn];
int n;
int main()
{
	n=read();
	int mx=0;
	for(int i=1;i<=1<<n;i++){
		a[i]=read();
		mx=std::max(mx,a[i]);
		st.insert(a[i]);
	}
	b[1]=mx; st.erase(st.lower_bound(mx));
	for(int k=1;k<1<<n;k<<=1)
		for(int i=k+1;i<=(k<<1);i++){
			auto iter=st.lower_bound(b[i-k]);
//			printf("%d %d %d %d\n",i,k,*iter,b[i-k]);
			if(iter==st.begin()){
				puts("No"); return 0;
			}
			b[i]=*(--iter); st.erase(iter);
		}
	puts("Yes");
//	for(int i=1;i<=1<<n;i++)
//		printf("%d %d\n",i,b[i]);
	return 0;
}

Measured memory_bytes: 14592
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

ll use[3005][3005];
ll yet[3005][3005];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,t;
	cin>>n>>t;
	vl a(n),b(n);
	rep(i,n)cin>>a[i]>>b[i];
	rep(i,3005)rep(j,3005)yet[i][j]=use[i][j]=0ll;
	rep(i,n){
		rep(j,3002){
			chmax(yet[i+1][j],yet[i][j]);
			chmax(use[i+1][j],use[i][j]);
			if(j-a[i]>=0)chmax(yet[i+1][j],yet[i][j-a[i]]+b[i]);
			if(j-a[i]>=0)chmax(use[i+1][j],use[i][j-a[i]]+b[i]);
			if(j-1>=0)chmax(use[i+1][j],yet[i][j-1]+b[i]);
		}
	}
	puta(use[n][t]);
}


Measured memory_bytes: 141440
'use strict;'
function main() {
  const input = require("fs").readFileSync("/dev/stdin", "utf-8").trim();
  const lines = input.split('\n');
  const totalNum = lines[0].split(' ')[0];
  const dislikeNum = lines[1].split(' ');
  const likeNum = [];
  for(var i = 0; i < 10; i++) {
    if(dislikeNum.indexOf(i + '') === -1) {
      likeNum.push(i + '');
    }
  }
  // var res = totalNum;
  // while(1) {
  //  var noMatch = false;
  //  for(var i = 0; i < res.length; i++) {
  //    if(dislikeNum.indexOf(res[i]) > -1) {
  //      res = parseInt(res) + 1;
  //      res = res + '';
  //      noMatch = true;
  //      break;
  //    }
  //  }
  //  if(!noMatch) {
  //    break;
  //  }
  // }
  // console.log(res);
  const res = getResult(totalNum, likeNum);
  if(res.flag) {
    console.log(likeNum[0] === '0' ? likeNum[1] + res.str : likeNum[0] + res.str);
  } else {
    console.log(res.str);
  }
}

function getResult(sourceNum, likeNum) {
  const item = sourceNum[0];
  const resObj = sourceNum.length - 1 ? getResult(sourceNum.slice(1), likeNum) : {};
  const resStr = resObj.str || '';
  const flag = resObj.flag;
  if(!flag) {
    if(likeNum.indexOf(item) > -1) {
      return {
        str: item + resStr,
        flag: false
      };
    } else {
      var bigger = getBigger(likeNum, item);
      if(bigger) {
        var str = '';
        for(var i = 0; i < resStr.length; i++) {
          str += likeNum[0];
        }
        return {
          str: bigger + str,
          flag: false
        };
      } else {
        var str = '';
        for(var i = 0; i < resStr.length; i++) {
          str += likeNum[0];
        }
        return {
          str: likeNum[0] + str,
          flag: true
        };
      }
    }
  } else {
    var bigger = getBigger(likeNum, item);
    if(bigger) {
      var str = '';
      for(var i = 0; i < resStr.length; i++) {
        str += likeNum[0];
      }
      return {
        str: bigger + str,
        flag: false
      };
    } else {
      var str = '';
      for(var i = 0; i < resStr.length; i++) {
        str += likeNum[0];
      }
      return {
        str: likeNum[0] + str,
        flag: true
      };
    }
  }
}

function getBigger(arr, num) {
  for(var i = 0; i < arr.length; i++) {
    if(arr[i] > num) {
      return arr[i] + ''
    }
  }
  return null;
}

main();


Measured memory_bytes: 7500
a=[]
b=[]
for i in range(5):
    x=int(input())
    a.append(x)
    if x%10!=0:
        b.append(10-x%10)
if a[0]%10==0 and a[1]%10==0 and a[2]%10==0 and a[3]%10==0 and a[4]%10==0:
    print(sum(a))
else:
    b.sort()
    print(sum(a)+sum(b)-max(b))
    


Measured memory_bytes: 3060
N,K=[int(i) for i in input().split()]
Vs=[int(i) for i in input().split()]
def maxchoice(N,K,Vs,acquire):
	maxval=0
	for ac in range(acquire+1):
		acVs=sorted(Vs[:ac]+Vs[-1:-(acquire-ac+1):-1],reverse=True)
		maxval=max(maxval,sum(acVs))
		for i in range(K-acquire):
			
			if acVs==[]:
				break
			if acVs[-1]<0:
				del acVs[-1]
				maxval=max(maxval,sum(acVs))
			else:
				maxval=max(maxval,sum(acVs))
				break
			
	return maxval

res=0
for acquire in range(1,min(N+1,K+1)):
	res=max(res,maxchoice(N,K,Vs,acquire))
print(res)

Measured memory_bytes: 3064