akhauriyash/Code-Regression huggingface dataset:
package main

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

var sc = bufio.NewScanner(os.Stdin)

// var rdr = bufio.NewReaderSize(os.Stdin, 100000)
var rdr *bufio.Reader

func init() {
	sc.Split(bufio.ScanWords)
}

type Tuple struct {
	c int
	l int
}

type Tuples []Tuple

func (t Tuples) Len() int {
	return len(t)
}
func (t Tuples) Less(i, j int) bool {
	// asc
	if t[i].l == t[j].l {
		return t[i].c < t[j].c
	}
	// asc
	return t[i].l < t[j].l
}
func (t Tuples) Swap(i, j int) {
	t[i], t[j] = t[j], t[i]
}

func main() {
	solve()
}

func solve() {
	in := nextInt

	n := in()
	task := make(Tuples, n)
	for i := 0; i < n; i++ {
		task[i] = Tuple{in(), in()}
	}

	sort.Sort(task)

	isComp := true
	time := 0
	for _, t := range task {
		time += t.c
		if time > t.l {
			isComp = false
			break
		}
	}

	fmt.Println(anser(isComp, "Yes", "No"))
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextI64() int64 {
	sc.Scan()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

func max(a int, b int) int {
	if a > b {
		return a
	}
	return b
}

func maxi64(a int64, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func updateMax(a *int, b int) {
	if *a < b {
		*a = b
	}
}

func min(a int, b int) int {
	if a < b {
		return a
	}
	return b
}

func mini64(a int64, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func updateMin(a *int, b int) {
	if *a > b {
		*a = b
	}
}

func absi64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func anser(b bool, y string, n string) string {
	if b {
		return y
	}
	return n
}

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

int main() {
  int N,D,X;
  cin >> N >> D >> X;
  vector<int>vec(N);
  for(int i=0; i<N; i++){
    cin >> vec[i];
    X += (D-1)/vec[i]+1;
  }
  cout << X << endl;
}


Measured memory_bytes: 3548
/* 
    AtCoder Beginner Contest 088
    A:Infinite Coins
    
*/

#include <iostream>
using namespace std;

int main(void)
{
    int n, a;
    cin >> n >> a;


    if (n % 500 <= a)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL n, x, d[200001], INF = 8e18;

LL f(int k) {
	LL sum = n * x;
	bool f = true;
	inc(i, n) { if(! f) { break; }
	inc(j, k) {
		if(k * i + j == n) { f = false; break; }
		LL l = n - 1 - (k * i + j);
		sum += (i == 0 ? 5 * d[l] + x : (2 * i + 3) * d[l]);
	}
	}
	
	return sum;
}

int main() {
	cin >> n >> x;
	inc(i, n) { cin >> d[i]; }
	
	int l = 1, h = n;
	while(h - l >= 3) {
		int m1 = l + (h - l) / 3 * 1;
		int m2 = l + (h - l) / 3 * 2;
		
		if(f(m1) >= f(m2)) { l = m1; } else { h = m2; }
	}
	
	LL ans = INF;
	incII(i, l, h) { setmin(ans, f(i)); }
	
	cout << ans << endl;
	
	return 0;
}



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

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

    if(N % 2 == 0){
        cout << N << endl;
    } else {
        cout << 2 * N << endl;
    }
    

}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass : Scanner
{
    static void Main()
    {
        string x = RString();
        if (x == "1") WriteLine(0);
        else WriteLine(1);
    }
}



class Scanner
{
    public static string RString() => Console.ReadLine();
    public static int RInt() => ReadTuple<int>();
    public static long RLong() => ReadTuple<long>();
    public static double RDouble() => ReadTuple<double>();

    public static string[] RStrings() => Console.ReadLine().Split();
    public static int[] RInts() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
    public static long[] RLongs() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
    public static double[] RDoubles() => Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
    public static int[] RInts(Func<string, int> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static long[] RLongs(Func<string, long> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static double[] RDoubles(Func<string, double> func) => Console.ReadLine().Split().Select(func).ToArray();
    //public static string[] RStrings(Func<string, string> func) => Console.ReadLine().Split().Select(func).ToArray();

    public static T1 ReadTuple<T1>()
    {
        var r = RString();
        var r1 = (T1)Convert.ChangeType(r, typeof(T1));
        return r1;
    }
    public static (T1, T2) ReadTuple<T1, T2>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        return (r1, r2);
    }
    public static (T1, T2, T3) ReadTuple<T1, T2, T3>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        return (r1, r2, r3);
    }
    public static (T1, T2, T3, T4) ReadTuple<T1, T2, T3, T4>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        var r4 = (T4)Convert.ChangeType(r[3], typeof(T4));
        return (r1, r2, r3, r4);
    }
}


Measured memory_bytes: 25952
#include <bits/stdc++.h>
using namespace std;
#define LOCAL
#pragma region Macros
typedef long long ll;
#define ALL(x) (x).begin(),(x).end()
const long long MOD=1e9+7;
// const long long MOD=998244353;
const int INF=1e9;
const long long IINF=1e18;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
const char dir[4]={'D','R','U','L'};

template<typename T>
istream &operator>>(istream &is,vector<T> &v){
    for (T &x:v) is >> x;
    return is;
}
template<typename T>
ostream &operator<<(ostream &os,const vector<T> &v){
    for (int i=0;i<v.size();++i){
        os << v[i] << (i+1==v.size()?"": " ");
    }
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const pair<T,U> &p){
    cout << '(' << p.first << ',' << p.second << ')';
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const map<T,U> &m){
    os << '{';
    for (auto itr=m.begin();itr!=m.end();++itr){
        os << '(' << itr->first << ',' << itr->second << ')';
        if (++itr!=m.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}
template<typename T>
ostream &operator<<(ostream &os,const set<T> &s){
    os << '{';
    for (auto itr=s.begin();itr!=s.end();++itr){
        os << *itr;
        if (++itr!=s.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}

void debug_out(){cerr << '\n';}
template<class Head,class... Tail>
void debug_out(Head&& head,Tail&&... tail){
    cerr << head;
    if (sizeof...(Tail)>0) cerr << ", ";
    debug_out(move(tail)...);
}
#ifdef LOCAL
#define debug(...) cerr << " ";\
cerr << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << '\n';\
cerr << " ";\
debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<typename T> T gcd(T x,T y){return y!=0?gcd(y,x%y):x;}
template<typename T> T lcm(T x,T y){return x/gcd(x,y)*y;}

template<class T1,class T2> inline bool chmin(T1 &a,T2 b){
    if (a>b){a=b; return true;} return false;
}
template<class T1,class T2> inline bool chmax(T1 &a,T2 b){
    if (a<b){a=b; return true;} return false;
}
#pragma endregion

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<ll> X(N),Y(N),P(N);
    for (int i=0;i<N;++i) cin >> X[i] >> Y[i] >> P[i];
    vector<ll> ans(N+1,IINF);
    auto dfs=[&](auto self,int v,int cnt,vector<ll> &score)->void{
        if (v==N){
            ll sum=0;
            for (int i=0;i<N;++i) sum+=P[i]*score[i];
            chmin(ans[cnt],sum);
            return;
        }
        vector<ll> nxt=score;
        for (int i=0;i<N;++i) nxt[i]=min(score[i],abs(X[i]-X[v]));
        self(self,v+1,cnt+1,nxt);
        for (int i=0;i<N;++i) nxt[i]=min(score[i],abs(Y[i]-Y[v]));
        self(self,v+1,cnt+1,nxt);
        self(self,v+1,cnt,score);
    };
    vector<ll> v(N);
    for (int i=0;i<N;++i) v[i]=min(abs(X[i]),abs(Y[i]));
    dfs(dfs,0,0,v);
    for (int i=0;i<=N;++i) cout << ans[i] << '\n';
}

Measured memory_bytes: 3624
#include<stdio.h>
int main()
{
	int N;
	int sum=0;
	scanf("%d",&N);
	int number[N];
	int i,j;

	for(i=0;i<N;i++){
			scanf("%d",&number[i]);

	}
	int x;
	for(i=0;i<N;i++){
		for(x=i+1;x<N;x++){
			sum=sum+number[i]*number[x];
		}
	}
	printf("%d",sum);
	return 0;
 }


Measured memory_bytes: 128
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int temp = A;
		A = B;
		B = temp;
		temp = A;
		A = C;
		C = temp;
		System.out.println(A+" "+B+" "+C);
		
		
	}
	

}


Measured memory_bytes: 21972
#include <iostream> // cout, endl, cin
#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
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;

#define rep(i,N) for(ll i=0;i<(ll)N;++i)

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

#include <iostream>

int main()
{
    ll N, M;
    cin >> N >> M;

    vector<ll> H(N + 1);
    vector<ll> A(M), B(M);

    for (ll i = 1; i <= N; ++i) cin >> H[i];

    for (ll i = 0; i < M; ++i) cin >> A[i] >> B[i];

    deque<ll> C;

    rep(i, M) {
        if (H[A[i]] < H[B[i]]) { C.push_front(A[i]); }
        else if (H[A[i]] > H[B[i]]) { C.push_front(B[i]); }
        else { 
            C.push_front(A[i]);
            C.push_front(B[i]);
        }
    }

    sort(C.begin(), C.end());
    C.erase(unique(C.begin(), C.end()), C.end());

    ll s = C.size();

    cout << N-s << endl;

}

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

p = a[0]
cont_cnt = 1
to_chg = 0

for i in range(1, N) :
    if p == a[i] :
        cont_cnt += 1
        p = a[i]
    else :
        if cont_cnt >= 2 :
            to_chg += cont_cnt // 2
            p = a[i]
            cont_cnt = 1
        else :
            p = a[i]

if cont_cnt >= 2 :
    to_chg += cont_cnt // 2
    p = a[i]
    cont_cnt = 1

print(to_chg)
        

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
 
#define sf(n) scanf("%d", &n)
#define pd(n) printf("%.10lf", n)
#define pf(n) printf("%d", n)
#define p() printf("\n")
#define ps() printf(" ")
#define ll long long
#define ull unsigned long long
#define MAX 1e9
const int mod = 1000 * 1000 * 1000 + 7;
#define ex 1e18
#define dbl 2e09
#define qu(q) queue<int> q
#define pqu(q) priority_queue<int> q
#define len(s) s.length()
#define sz(x) int(x.size())
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define F first
#define S second
#define clr(x) x.clear()
#define LOG(x) std::cout << x << std::endl;
 
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = 3.14159265359;
 
int dx[6] = {-1,-1,0,0,1,1};
int dy[6] = {-1,0,-1,1,0,1};

const int N = 3e5+5;


int main(){
    int n,m;
    cin>>n>>m;
    cout<<(n*(n-1))/2 + ((m-1)*m)/2<<endl;
    return 0;
}

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

#define sz  size()
#define er  erase
#define ss  substr

class Emacs {
public:
    Emacs(){
        w = h = 0;
        buf.clear();
    }
    void appendLine(string line){ txt.push_back(line); }
    void execCommand(char code){
        switch (code){
          case 'a': A(); break;
          case 'e': E(); break;
          case 'p': P(); break;
          case 'n': N(); break;
          case 'f': F(); break;
          case 'b': B(); break;
          case 'd': D(); break;
          case 'k': K(); break;
          case 'y': Y(); break;
        }
    }
    void showText(){
        for (auto line : txt)
            cout << line << "\n";
    }
private:
    void A(){ w = 0; }
    void E(){ w = txt[h].sz; }
    void P(){ h = max(h - 1, 0); A(); }
    void N(){ h = min(h + 1, (int)txt.sz - 1); A(); }
    void F(){ if (w < txt[h].sz) w++; else if (h < txt.sz - 1) A(), h++; }
    void B(){ if (w > 0) w--; else if (h > 0) h--, E(); }
    void D(){ if (w < txt[h].sz) txt[h].er(w, 1); else if (h < txt.sz - 1) txt[h] += txt[h + 1], txt.er(txt.begin() + h + 1); }
    void K(){ if (w < txt[h].sz) buf = txt[h].ss(w), txt[h] = txt[h].ss(0, w); else if (h < txt.sz - 1) D(), buf = "\n"; }
    void Y(){ if (!buf.empty()) { if (buf == "\n") txt.insert(txt.begin() + h + 1, txt[h].ss(w)), txt[h].er(w), N(); else txt[h].insert(w, buf), w += buf.sz; }}
    vector<string> txt;
    string buf;
    int h, w;
};

int main()
{
    Emacs emacs;

    string in;
    while (getline(cin, in), in != "END_OF_TEXT") emacs.appendLine(in);

    char cmd;
    while (cin >> cmd, cmd != '-') emacs.execCommand(cmd);

    emacs.showText();

    return (0);
}

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

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

int main(){
    int k;
    int arr[3];
    cin >> arr[0] >> arr[1] >> arr[2] >> k;

    sort(arr, arr+3);

    cout << arr[0] + arr[1] + arr[2] * pow(2,k) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <cmath>
#include <cassert>
#include <cstdio>

using namespace std; using namespace placeholders;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector< int > VI;
typedef vector< vector< int > > VVI;
typedef vector< string > VS;
typedef stringstream SS;
typedef pair< int, int > PII;
typedef vector< pair< int, int > > VPII;
#define VT( T ) vector< T >
#define VVT( T ) vector< vector< T > >
#define LIM( T ) numeric_limits< T >

template < typename T > inline istream& operator>>( istream &s, vector< T > &v ){ for ( T &t : v ) { s >> t; } return s; }
template < typename T > inline ostream& operator<<( ostream &s, const vector< T > &v ){ for ( int i = 0; i < int( v.size() ); ++i ){ s << ( " " + !i ) << v[i]; } return s; }
template < typename T > inline T fromString( const string &s ) { T res; istringstream iss( s ); iss >> res; return res; };
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

#define REP2( i, n ) REP3( i, 0, n )
#define REP3( i, m, n ) for ( int i = ( int )( m ); i < ( int )( n ); ++i )
#define GET_REP( a, b, c, F, ... ) F
#define REP( ... ) GET_REP( __VA_ARGS__, REP3, REP2 )( __VA_ARGS__ )
#define FOR( e, c ) for ( auto &e : c )
#define ALL( c ) ( c ).begin(), ( c ).end()
#define AALL( a, t ) ( t* )a, ( t* )a + sizeof( a ) / sizeof( t )
#define DRANGE( c, p ) ( c ).begin(), ( c ).begin() + p, ( c ).end()

#define SZ( v ) ( (int)( v ).size() )
#define PB push_back
#define EM emplace
#define EB emplace_back
#define BI back_inserter

#define EXIST( c, e ) ( ( c ).find( e ) != ( c ).end() )

#define MP make_pair
#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

constexpr int MOD = 1000000007;

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

	int N, L;
	cin >> N >> L;

	VI xs( N ), as( N );
	cin >> xs >> as;

	VVI dp( L + 1, VI( N + 1, 0 ) );
	dp[0][0] = 1;

	REP( i, L )
	{
		REP( j, N + 1 )
		{
			( dp[ i + 1 ][j] += dp[i][j] ) %= MOD;
			if ( j < N && xs[j] <= i && ( xs[j] == i || as[j] && ( i - xs[j] ) % as[j] == 0 ) )
			{
				( dp[ i + 1 ][ j + 1 ] += dp[i][j] ) %= MOD;
			}
		}
	}

	cout << dp[L][N] << endl;

	return 0;
}

Measured memory_bytes: 98940
import sys
readline = sys.stdin.readline
from collections import Counter

def main():
    N = int(readline())
    A = list(map(int, readline().rstrip().split()))
    c = Counter(A)
    ans = 0
    for k, v in zip(c.keys(), c.values()):
        if v - k >= 0:
            ans += v - k
        else:
            ans += v
    
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 18676
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<string> vs;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

int main() {
    double t, x;
    cin >> t >> x;
    cout << setprecision(10) << t / x << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<iomanip>
#include<vector>
#include<algorithm>
typedef unsigned long long ull;
typedef signed long long sll;
using namespace std;

#define INF 0x7FFFFFFFFFFFFFFF
#define BIG_PRIME 1000000007

vector<vector<ull>> edge;
vector<vector<ull>> dp;

void calc_dp(ull x,ull before)
{
  dp[0][x]=dp[1][x]=1;
  for(ull i=0,n=edge[x].size();i<n;++i)
  {
    if(edge[x][i]!=before)
    {
      calc_dp(edge[x][i],x);
      dp[0][x]=(dp[0][x]*(dp[0][edge[x][i]]+dp[1][edge[x][i]]))%BIG_PRIME;
      dp[1][x]=(dp[1][x]*dp[0][edge[x][i]])%BIG_PRIME;
    }
  }
}

int main()
{
  ull i,j,N,x,y;
  cin >> N;
  dp.resize(2);
  dp[0].resize(N,0);
  dp[1].resize(N,0);
  edge.resize(N);
  for(i=0;i<N-1;++i)
  {
    cin >> x >> y;
    --x;
    --y;
    edge[x].push_back(y);
    edge[y].push_back(x);
  }
  calc_dp(0,N);
  cout << (dp[0][0]+dp[1][0])%BIG_PRIME;
  return 0;
}

Measured memory_bytes: 14208
using System;
using System.Linq;
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    string[] str=Console.ReadLine().Split(' ');
    int A=int.Parse(str[0]);
    int B=int.Parse(str[1]);
    int M=int.Parse(str[2]);
      
     string[] fr=Console.ReadLine().Split(' ');
    int[] frInt = fr.Select(int.Parse).ToArray();
      
     string[] ht=Console.ReadLine().Split(' ');
    int[] htInt = ht.Select(int.Parse).ToArray();
      int ans;
       ans=frInt.Min()+htInt.Min();

      for(int i=1;i<=M;i++){
        string[] dis=Console.ReadLine().Split(' ');
        int x=int.Parse(dis[0]);
        int y=int.Parse(dis[1]);
        int c=int.Parse(dis[2]);
        if((frInt[x-1]+htInt[y-1]-c)<ans){
          ans=frInt[x-1]+htInt[y-1]-c;
        }
      }
      Console.WriteLine(ans);
    }
    
  }

}

Measured memory_bytes: 52952
package main

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

type stack []int

func (s *stack) push(x int) {
	*s = append(*s, x)
}

func (s *stack) pop() int {
	old := *s
	n := len(old)
	item := old[n-1]
	*s = old[0 : n-1]
	return item
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	st := make(stack, 0, 128)
	for sc.Scan() {
		s := sc.Text()
		switch s {
		case "+":
			x := st.pop() + st.pop()
			st.push(x)
		case "-":
			x := -st.pop() + st.pop()
			st.push(x)
		case "*":
			x := st.pop() * st.pop()
			st.push(x)
		default:
			v, _ := strconv.Atoi(s)
			st.push(v)
		}
	}
	fmt.Println(st.pop())
}



Measured memory_bytes: 1116
#include <iostream>
  #include <string>
  #include <vector>
  #include <algorithm>
  #include <utility>
  #include <map>
  using namespace std;
  typedef long long ll;
  #define rep(i,n) for (int i=0;i < (int)(n);i++)

  int main(){
    ll a,b,c,d;
    string s;
    cin >> a >> b >> c >> d;
    cout << max({a*c,a*d,b*c,b*d}) << endl;
    

    return 0;
  }


Measured memory_bytes: 3628
N, K = map(int, input().split())
def main():
  for a in range(K+1, N+1):
    s = (a-K)*(N//a)+max(N%a-K, 0)
    s = s-1 if K==0 else s
    s = s+1 if N%a>=K else s
    yield s
print(sum(main()))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    int len;
    cin>>s;
    len=s.length();
    if(s.at(len-1)=='s')
    {
        s=s+"es";
    }
    else
    {
        s=s+'s';
    }
    cout<<s<<endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  ll n,m;
  cin >> n >> m;
  if(2*n>=m){
    cout << m/2;
  }else{
    ll ans=0;
    ans+=n;
    m-=2*n;
    ans+=m/4;
    cout << ans;
  }
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int N;
vector<pair<int,int>> g[1001][1001];
int deg[1001][1001] = {};
deque<pair<int,int>> res;
queue<pair<int,int>> ver;
bool tsort(){
	while(!ver.empty()){
		pair<int,int> v = ver.front(); ver.pop();
        res.push_front(v);
		for(pair<int,int> u:g[v.first][v.second]){
            int s = u.first;
            int t = u.second;
            deg[s][t]--;
			if(deg[s][t] == 0) ver.push({s, t});
		}
	}
	rep(i,1,N+1)rep(j,1,i)if(deg[i][j]) return false;
    return true;
}
int dfs(int v, int u){
    int res = 0;
    if(g[v][u].size() == 0) return 0;
    for(pair<int,int> p:g[v][u]){
        int s = p.first;
        int t = p.second;
        res = max(res, dfs(s, t));
    }return res + 1;
}
int main(){
	cin>>N;
	rep(i,1,N+1){
		int a,b; cin>>a;
		rep(j,2,N){
			cin>>b;
			g[max(i, a)][min(i, a)].push_back({max(i, b), min(i, b)});
            deg[max(i, b)][min(i, b)]++;
            a = b;
		}
	}
    rep(i,1,N+1)rep(j,1,i){
        if(deg[i][j] == 0) ver.push({i, j});
    }
    int dp[N+1][N+1];
    if(ver.size() && tsort()){
        rep(i,0,N * (N - 1) / 2){
            pair<int,int> v = res[i];
            if(g[v.first][v.second].size() == 0){ dp[v.first][v.second] = 0; continue; }
            int temp = 0;
            for(pair<int,int> p:g[v.first][v.second]) temp = max(temp, dp[p.first][p.second]);
            dp[v.first][v.second] = temp + 1;
        }
        int ans = 0;
        rep(i,1,N+1)rep(j,1,i) ans = max(ans, dp[i][j]);
        cout<<ans + 1<<endl;
        return 0;
    }cout<<-1<<endl;
}

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

	public static Scanner sc = new Scanner(System.in);
	
	public static int gx, gy, N, P;
 
	
	public static void main(String[] args) {
		N = sc.nextInt();
		while (N-- > 0) {
			gx = sc.nextInt();
			gy = sc.nextInt();

			boolean[][][][] road = new boolean[16][16][16][16];
			
			P = sc.nextInt();
			for (int i = 0; i < P; i++) {
				int x1 = sc.nextInt(), y1 = sc.nextInt(), 
				    x2 = sc.nextInt(), y2 = sc.nextInt();
				road[y1][x1][y2][x2] = road[y2][x2][y1][x1] = true;
			}
			
			int[][] dp = new int[16][16];
			dp[0][0] = 1;
			for (int y = 1; y <= gy; y++) {
				if (road[y][0][y - 1][0]) {
					dp[y][0] = 0;  
				} else {
					dp[y][0] = dp[y - 1][0];
				}
			}
			
			for (int x = 1; x <= gx; x++) {
				if (road[0][x][0][x - 1]) {
					dp[0][x] = 0;  
				} else {
					dp[0][x] = dp[0][x - 1];
				}
			}
			
			for (int y = 1; y <= gy; y++) {
				for (int x = 1; x <= gx; x++) {
					dp[y][x] = 0;
					if (!road[y][x][y][x - 1])
						dp[y][x] += dp[y][x - 1];
					if (!road[y][x][y - 1][x])
						dp[y][x] += dp[y - 1][x];
				}
			}
			
			if (dp[gy][gx] == 0) {
				System.out.println("Miserable Hokusai!");
			} else {
				System.out.println(dp[gy][gx]);
			}
		}
	}
}

Measured memory_bytes: 13000
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
import bisect

if __name__  == "__main__":
    a,b = map(int,input().split())
    print(a*b)    

Measured memory_bytes: 9604
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a<=b&&b<=c) cout<<a<<" "<<b<<" "<<c<<endl;
    else if(a<=c&&c<=b) cout<<a<<" "<<c<<" "<<b<<endl;
    else if(b<=a&&a<=c) cout<<b<<" "<<a<<" "<<c<<endl;
    else if(b<=c&&c<=a) cout<<b<<" "<<c<<" "<<a<<endl;
    else if(c<=a&&a<=b) cout<<c<<" "<<a<<" "<<b<<endl;
    else if(c<=b&&b<=a) cout<<c<<" "<<b<<" "<<a<<endl;
    return 0;
    
}


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

#define int long long int 

int32_t main()
{
  int a,b;
  cin>>a>>b;
  int pow=1;
  int ans=0;
  while(pow<=b && a)
  {
    pow*=2;
    ans++;
    a--;
  }
  if(a)
  {
    cout<<pow+a*b<<endl;
  }
  else
  cout<<pow<<endl;

  
}

Measured memory_bytes: 3572
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
#include <assert.h>
#include <deque>
#include <functional>
using namespace std;
typedef long long ll;

#define fi first
#define se second
#define rep(i, n) for (ll i = 0; i < n; i++)
#define debugA cerr << "AAAAA" << endl
#define debug_ cerr << "-------------" << endl
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v)                   \
    cout << #v << endl;                \
    for (int i = 0; i < v.size(); i++) \
    {                                  \
        cout << v[i] << " ";           \
    }                                  \
    cout << endl;
#define debug_vec2(v)                         \
    cout << #v << endl;                       \
    for (int i = 0; i < v.size(); i++)        \
    {                                         \
        for (int j = 0; j < v[i].size(); j++) \
        {                                     \
            cout << v[i][j] << " ";           \
        }                                     \
        cout << endl;                         \
    }

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

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

using Graph = vector<vector<int>>;
using P = pair<int, int>;
using P1 = pair<int, pair<int, int>>; // クラスカル法とかで、{cost, {from, to}}的に使う。
const ll LINF = 1001002003004005006ll;
const ll INF = 1001001001;
const double pi = acos(-1);

int main()
{
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] != t[i])
        {
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

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

# define F first
# define S second
# define mp make_pair
// everything go according to my plan
# define pb push_back
# define sz(a) (int)(a.size())
# define vec vector
// shimkenttin kyzdary, dzyn, dzyn, dzyn...
# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right

using namespace std;

typedef pair <int, int> pii;
typedef long long ll;
typedef long double ld;

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const ll MXLL = 4e18;
const int Sz = 1110111;
// a pinch of soul
inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm ("rdtsc" : "=A"(seed));
  srand (seed);
}
void files (string problem) {
  if (fopen ((problem + ".in").c_str(),"r")) {
    freopen ((problem + ".in").c_str(),"r",stdin);
    freopen ((problem + ".out").c_str(),"w",stdout);
  }
}
void localInput (bool local, string in = "s") {
	if (!local)
		return;

  if (fopen (in.c_str(), "r"))
    freopen (in.c_str(), "r", stdin);
  else
    cerr << "Input file not found" << endl;
}
const int N = 5e4 + 1;

int dp[N];

int n, m; 

int main()
{
	localInput (false);   
	Read_rap();             
  cin >> n >> m;            
  fill (dp + 1, dp + n + 1, MX);
          
  for (int i = 1; i <= m; i++) {
  	int x; cin >> x;
  	for (int j = 0; j + x <= n; j++)
  		dp[j + x] = min (dp[j + x], dp[j] + 1);
  }        
  cout << dp[n];


  cout << endl;

  return 0;
}










// Coded by Z..



Measured memory_bytes: 3336
import math

N, M = map(int, input().split())

if N%2 == 1:
  a = 1
  b = N
  for i in range(M):
    print(a,b)
    a += 1
    b -= 1
else:
  m = N//2 - 1
  a = N//4
  b = a + 1
  c = N//2 + N//4
  d = c + 2
  for i in range(M):
    if i%2 == 0:
      print(a,b)
      a -= 1
      b += 1
    else:
      print(c,d)
      c -= 1
      d += 1 

Measured memory_bytes: 69696
#include <cstdio>
#include <map>

int main()
{
    std::map<long long, int> cnt;
    cnt[0] ++;
    long long result = 0;
    int n;
    scanf("%d", &n);
    long long sum = 0;
    for (int i = 0, a; i < n; ++ i) {
        scanf("%d", &a);
        sum += a;
        result += cnt[sum];
        cnt[sum] ++;
    }
    printf("%lld\n", result);
}


Measured memory_bytes: 12800
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7
flag = True
c = Counter(a)
#print(c)
if n % 2 == 1:
    if c[0] != 1:
        flag = False
    for i in range(1, n//2+1):
        if c[i*2] != 2:
            flag = False
            break
    if flag:
        print(2**(n//2) % mod)
    else:
        print(0)
elif n % 2 == 0:
    for i in range(n//2):
        if c[i*2+1] != 2:
            flag = False
            break
    if flag:
        print(2**(n//2) % mod)
    else:
        print(0)

Measured memory_bytes: 55532
#include<stdio.h>
int main(void){
    int a,b,c,X;
    scanf("%d%d%d",&a,&b,&c);
    if(a>b){
        X=a;
        a=b;
        b=X;
    }
    if(b>c){
        X=b;
        b=c;
        c=X;
    }
    if(a>b){
        X=a;
        a=b;
        b=X;
    }
    printf("%d %d %d\n",a,b,c);
    return 0;
}


Measured memory_bytes: 2052
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 1; i <=(n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2147483647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
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;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int two(int n){
	ll ans=1;
	rep(i,n){
		ans*=2;
	}
	return ans;
}
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);


string s;
cin>>s;
string t;
for(int i=0;i<(int)s.size();i+=2){
    cout<<s[i];
}
cout<<endl;
}

Measured memory_bytes: 3764
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int c = sc.nextInt();
        int[] b = new int[m];
        for(int i = 0; i < m; i++){
            b[i] = sc.nextInt();
        }
        int[][] a = new int[n][m];
        for(int i = 0; i < n; i++){
            for(int j = 0; j < m; j++){
                a[i][j] = sc.nextInt();
            }
        }
        int sum = 0;
        int count = 0;
        for(int i = 0; i < n; i++){
            for(int j = 0; j < m; j++){
                sum = sum + a[i][j] * b[j];
            }
            if(sum + c > 0){
                count++;
            }
            sum = 0;
        }
        System.out.print(count);
    }
}

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

typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
 
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;

int n,q;
string s;
char t[1000000],d[1000000];

int move(int pos) {
    for (int i=0;i<q;i++) {
        if (s[pos] == t[i]) {
            if (d[i] == 'R') pos++;
            else pos--;
            // cout << "pos " << pos << endl; 
        }
        if (pos==n || pos==-1) return pos;
    }
    return 0;
}

int judge_r(int right, int left) {
    // right
    while(right - left > 1) {
        int mid = (right + left) / 2;
        if (move(mid)==n) right = mid;
        else left = mid;
    }
    return right;
}

int judge_l(int right, int left) {
    while(right - left > 1) {
        int mid = (right + left) / 2;
        if (move(mid)==-1) left = mid;
        else right = mid;
    }
    return left;
}

int main() {
    cin >> n >> q >> s;
    for (int i=0;i<q;i++) {
        cin >> t[i] >> d[i];
    }
    int left = -1, right = n;
    int r = n - judge_r(right, left);
    int l = 1 + judge_l(right, left);
    
    int ans = n-r-l;
    // cout << "r " << r << endl;
    // cout << "l " << l << endl;
    cout << ans << endl;
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b;
	c=a+b;
	if(a%3==0||b%3==0||c%3==0)
	cout<<"Possible"<<endl;
	else
	cout<<"Impossible"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
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;
}

int main() {
  ll h,w;cin>>h>>w;
  if(h==1||w==1){
    cout<<1<<endl;
    return 0;
  }
  if(h%2){
    if(w%2){
      cout<<ll(w/2+1)*ll(h/2+1)+ll(h/2)*ll(w/2)<<endl;
    }else{
      cout<<w/2*h<<endl;
    }
    
  }else{
    cout<<h/2*w<<endl;
  }
  return 0;
}

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

ll N, A, B;

int main() {
  cin >> N >> A >> B;
  if (A > B) swap(A, B);
  if ((A + B) % 2) {
    cout << min(B - (-A + 1), (N + (N - B + 1)) - A) / 2 << endl;
  } else {
    cout << (B - A) / 2 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;



/* Name of the class has to be "Main" only if the class is public. */
public class Main
 
 
{
    static Scanner in = new Scanner(System.in);
    
    public static void solve()
    {
      int a =in.nextInt(),b=in.nextInt(),c=in.nextInt(),k=in.nextInt();
      
      if(a>=k)
      {
          System.out.println(k);
      }
      else if(a+b>=k)
      {
          System.out.println(a);
      }
      else
      {
          
          k=k-a-b;
          System.out.println(a-(k));
      }
    }
    

    
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		
		int t=1;
	//	in.nextLine();
		
		while(t>0)
		{
		    
		    solve();
		    t--;
		}
		
		
	
	//	System.out.println(x);
	}
}


Measured memory_bytes: 35764
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct X{
	int id;
	int No;
};
bool Comp(X&l,X&r){
	if (l.No<r.No){
		return true;
	}else{
		return false;
	}
}
int main(int argc, char* argv[])
{
	int N,i;
	cin>>N;
	vector<X> A(N);
	for (i=0;i<N;i++){
		A[i].id=i+1;
		cin>>A[i].No;
	}
	sort(A.begin(),A.end(),Comp);
	for (i=0;i<N;i++){
		if (i>0){
			cout<<" ";
		}
		cout<<A[i].id;
	}

	return 0;
}

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

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



Measured memory_bytes: 3068
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    bool e = true;
    while(1){
        if(e){
            c-=b;
        }else{
            a-=d;
        }
        if(c<=0){
            cout<<"Yes\n";
            return 0;
        }
        if(a<=0){
            cout<<"No\n";
            return 0;
        }
        e = !e;
    }
    return 0;
}

Measured memory_bytes: 3688
N, X = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
if(A[0] > X):
  ans += (A[0]-X)
  A[0] = X
for i in range(1,N):
  S = A[i-1] + A[i]
  if(S > X):
    ans += S-X
    A[i] -= S-X
print(ans)

Measured memory_bytes: 14252
<?php
while(1){
  $stdin = fgets(STDIN);
  if ($stdin===false) break;
  $e = explode(' ', $stdin);
  $sum = $e[0] + $e[1];

  $quotient = 0;
  $digit = 1;
  while(1){
    $quotient = (int)($sum/10);
    if ($quotient===0) break;
    $digit++; 
    $sum = $quotient;
  }
  
  echo $digit.PHP_EOL;
}

Measured memory_bytes: 6604
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,h[100004];
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",&h[i]);
    bool flag=0;
    for(int i=n-1;i>=1;i--){
        if(h[i]<=h[i+1])continue;
        else if(h[i]-1<=h[i+1]){
            h[i]--;
        }
        else{
            flag=1;
            break;
        }
    }
    if(!flag)puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 640
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int N, M;
    cin >> N >> M;
    int A[M];
    for (int i = 0; i < M; i++) cin >> A[i];
    sort(A, A + M);

    int cost[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};

    int dp[N+1]; // コストiで最大何桁形成できるか
    fill(dp, dp + N+1, -INF);
    dp[0] = 0;

    for (int i = 1; i <= N; i++) {
        for (int j = 0; j < M; j++) {
            if (i - cost[A[j]] >= 0) dp[i] = max(dp[i], dp[i - cost[A[j]]] + 1);
        }
    }

    int remain_cost = N;
    string ret = "";

    while (remain_cost > 0) {
        for (int i = M - 1; i >= 0; i--) {
            if (remain_cost - cost[A[i]] < 0) continue;
            if (dp[remain_cost] == dp[remain_cost - cost[A[i]]] + 1) {
                ret += to_string(A[i]);
                remain_cost -= cost[A[i]];
                break;
            }
        }
    }

    cout << ret << endl;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(void)
{
	int sum[300] = { 0 }, ruio = 0, hideo = 0, masao = 0, nagase, a[300][300], temp = 0;
	scanf("%d", &nagase);
	for (int j = 1; j <= nagase; j++) {
		for (int i = 1; i <=3; i++) {
			scanf("%d", &a[j][i]);
		}
	}
	for (int j = 1; j <= nagase; j++) {
		for (int i = 1; i <=nagase; i++) {
			for (int x = 1; x <= nagase; x++) {
				if (a[i][j] != a[x][j]) {
					temp++;
				}
			}
			if (temp ==nagase-1) {
				sum[i] += a[i][j];
			}
			temp = 0;
		}
	}
	for (int i = 1; i <= nagase; i++) {
		printf("%d\n", sum[i]);
	}
}

Measured memory_bytes: 2964
#include <stdio.h>
#include <stdlib.h>
#define min(x,y) (((x)<(y))?(x):(y))

int main(){
    int N;
    scanf("%d",&N);
    int *B = malloc(sizeof(int)*(N-1));
    int *A = malloc(sizeof(int)*N);
    int i;
    for(i=0;i<N-1;i++) scanf("%d",&B[i]);
    A[0]=B[0];
    A[N-1]=B[N-2];
    for(i=1; i<N-1; i++) A[i] = min(B[i-1],B[i]);
    int sum=0;
    for(i=0; i<N; i++) sum+=A[i];
    printf("%d\n",sum);
}

Measured memory_bytes: 1732
#include <iostream>
#include <boost/multiprecision/cpp_int.hpp>
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
namespace mp = boost::multiprecision;
using namespace std;
using ull = unsigned long long;
using ld = long double;
//using ll = boost::multiprecision::cpp_int;
using ll = long long;
#define FORi(N) for(ll i = 0; i < N; ++i)
#define FORj(N) for(ll j = 0; j < N; ++j)
#define FORk(N) for(ll k = 0; k < N; ++k)
//using int = ll;
ll gcd(ll m, ll n) {
    if(n == 0)
        return abs(m);
    return (gcd(n, m % n));
}
void putYN(bool b) {
    if(b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
void swap(ll &a, ll &b) {
    ll tmp = a;
    a = b;
    b = tmp;
}
ll combi(ll n, ll k) {
    ll r = 1 ,rr =1;
    for(ll i=0;i<k;++i) {
      r*=(n-i);
      rr*=(i+1);
      //r %= 1000000007;
      //rr %= 1000000007;
    }
    r/=rr;
    //r %= 1000000007;
    return r;
}

int main() {
  ll N;
  cin>>N;
  vector<vector<ll>> AB(N);
  FORi(N){
    vector<ll> tmp(2);
    cin>>tmp[0]>>tmp[1];
    AB[i]=tmp;
  }
  sort(AB.begin(),AB.end(),[](vector<ll> a,vector<ll> b){
    return a[1]<b[1];
  });
  ll t=0;
  bool flag = true;
  FORi(N){
	t+=AB[i][0];
    if(t>AB[i][1]){
      flag=false;
      break;
    }
  }
  putYN(flag);
  return 0;
}


Measured memory_bytes: 11264
#include<iostream>
#include<cstdio>
using namespace std;
long long n,i,er[40],tot[40],tot2,j,k,ans,K;
bool shan[100005];
struct la
{
	long long w,v;
}wp[100005];

int main()
{
	scanf("%lld",&n);scanf("%lld",&K);
	er[0]=1;
	for(i=1;i<=30;i++)
	er[i]=er[i-1]*2;
	for(i=1;i<=n;i++)
	{
		scanf("%lld%lld",&wp[i].w,&wp[i].v);
		tot2+=wp[i].v;
		for(j=0;j<=30;j++)
		{
			if((er[j]&wp[i].w)==0)
			{
			tot[j]+=wp[i].v;			
			}		
		}
	}
	
	for(i=30;i>=0;i--)
	{
		if((K&er[i])==0)
		{
			for(j=1;j<=n;j++)
			{
			if(wp[j].w&er[i])
			{
			if(shan[j]==0)
			{
				shan[j]=1;
				for(k=0;k<=30;k++)
				if((er[k]&wp[j].w)==0)
				{tot[k]-=wp[j].v; }
				tot2-=wp[j].v;
			}
			}
			}
			//	ans=max(ans,tot[i]);
		}else
		{
	ans=max(ans,tot[i]);
		}
	}
	if((K&1)==1)ans=max(ans,tot2);
	else ans=max(ans,tot[0]);
	printf("%lld",ans);	
}

Measured memory_bytes: 1920
#line 1 "/home/parallels/kyopro/cplib/template.cpp"
#include<bits/stdc++.h>
using namespace std;

#define REP(i,n) for(int i = 0;i < n;i++)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;
using vpi = vector<Pi>;
using vpl = vector<Pl>;

void lyn(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}

#line 1 "/home/parallels/kyopro/cplib/debug.cpp"
#define debug(arr) cout << #arr << " = " << arr << '\n'
#define debug2(a,b) cout << "[" << #a << "," << #b << "] = " << "[" << a << "," << b << "]" << '\n'
template<class T> ostream &operator << (ostream& out, const vector<T>& arr) {
	cout << "{"; for (int i = 0; i < arr.size(); i++)cout << (!i ? "" : ", ") << arr[i]; cout << "}";
	return out;
}
template<class T> ostream &operator << (ostream& out, const vector<vector<T> >& arr) {
	cout << "{\n"; for (auto& vec : arr)cout << "  " << vec << ",\n"; cout << "}";
	return out;
}
template<class S,class T> ostream &operator << (ostream& out, const pair<S,T>& p){
  cout << "{" << p.first << "," << p.second << "}" << '\n';
  return out;
}
template<class T> istream &operator >> (istream& in, vector<T>& arr) {
	for (auto& i : arr)cin >> i; return in;
}
#line 2 "main.cpp"

int main(int argc, char const* argv[])
{
  lyn();
  int d,t,s;cin >> d >> t >> s;
  if (d <= t * s) {
    cout << "Yes" << '\n';
  }else{
    cout << "No" << '\n';
  }
  return 0;
}


Measured memory_bytes: 3608