akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<cmath>
#include<queue>
#include<limits>
#include<cassert>
#include<set>
#include<tuple>
#include<map>
using namespace std;

int main() {
	int A, B, C, X;
	int counter = 0;
	cin >> A >> B >> C >> X;
	for (int i = 0; i <= A; ++i) {
		for (int j = 0; j <= B; ++j) {
			for (int k = 0; k <= C; ++k) {
				if (500*i + 100*j + 50*k == X) ++counter;
			}
		}
	}
	cout << counter << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int N; cin>>N;
    vector<int64_t> A(N);
    rep(n,0,N) cin>>A.at(n);

    sort(ToEnd(A));
    vector<int64_t> sumA(N+1,0);
    rep(n,1,N+1) sumA.at(n)=sumA.at(n-1)+A.at(n-1);

    int ans=0;
    rep(n,0,N){
        int64_t sz=sumA.at(n+1);
        auto preItr=next(A.begin(),n);

        while(1){
            auto itr=upper_bound(ToEnd(A),sz*2);
            if(itr==A.end()){
                ans=N-n;
                break;
            }
            if(preItr==itr) break;

            sz=sumA.at(distance(A.begin(),itr));
            preItr=itr;
        }

        if(ans) break;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 1792
until (given = $<.gets.split.map(&:to_i)) == [0]
  q1, b, c1, c2, q2 = given
  lim = [q2, b / c1].min
  str = "NA"
  lim.downto(1) do |aizu|
     tori = (b - aizu * c1) / c2
     if tori >= 0 and aizu + tori >= q1
       str = "#{aizu} #{tori}"
       break
     end
  end
  puts str
end


Measured memory_bytes: 6852
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define repd(i, a, b) for (int i = a; i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;

int main()
{
    int n;
    cin >> n;
    vector<int> s(n);
    int total = 0;
    rep(i, 0, n)
    {
        cin >> s[i];
        total += s[i];
    }
    sort(all(s));
    if (total % 10 == 0)
    {
        for (int i = 0; i < n; i++)
        {
            if (((total - s[i]) % 10) == 0)
                continue;
            else
            {
                total -= s[i];
                break;
            }
        }
    }
    if (total % 10 == 0)
        cout << 0 << endl;
    else
        cout << total << endl;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
 
using std::pair;
using std::vector;
using std::string;

typedef long long ll;
typedef pair<int, int> pii;
 
#define fst first
#define snd second
#define pb(a) push_back(a)
#define mp(a, b) std::make_pair(a, b)
#define debug(...) fprintf(stderr, __VA_ARGS__)
 
template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }
 
const int oo = 0x3f3f3f3f;
 
template<typename T> T read(T& x) {
    int f = 1; x = 0;
    char ch = getchar();
    for(;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48; 
    return x *= f;
}

int n, a, b;
int main() {
#ifdef Wearry
    freopen("in", "r", stdin);
    // freopen("out", "w", stdout);
#endif 

    read(n), read(a), read(b);

    if(std::abs(a - b) % 2 == 0) {
        puts("Alice");
    } else puts("Borys");

    return 0;
}


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

const ll INF = 1LL << 50;
ll wf[200][200];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	int N, M, R;
	cin >> N >> M >> R;

	vector<int> r(R);
	for(int i = 0; i < R; i++){
		cin >> r[i];
		r[i]--;
	}
	sort(r.begin(), r.end());


	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
			if(i != j) wf[i][j] = wf[j][i] = INF;
		}
	}
	for(int i = 0; i < M; i++){
		int a, b, c;
		cin >> a >> b >> c;
		a--, b--;
		wf[a][b] = wf[b][a] = c;
	}

	for(int k = 0; k < N; k++){
		for(int i = 0; i < N; i++){
			for(int j = 0; j < N; j++){
				wf[i][j] = min(wf[i][j], wf[i][k] + wf[k][j]);
			}
		}
	}


	ll ans = INF;
	do{
		ll sum = 0;
		for(int i = 0; i < R - 1; i++){
			sum += wf[r[i]][r[i + 1]];
		}
		ans = min(ans, sum);
	} while(next_permutation(r.begin(), r.end()));
	cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int n,k;
    int l[50];
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>l[i];
    sort(l,l+n);
    int mun=0;
    for(int i=n-1;i>=n-k;i--)
        mun+=l[i];
    cout<<mun;
}


Measured memory_bytes: 256
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    S = input()
    if 'RRR' in S:
        return 3
    if 'RR' in S:
        return 2
    if 'R' in S:
        return 1
    return 0


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 61692
#include <stdio.h>

int main (void){
    int i,ans=0;
    int T; 
    int A,B; 

    scanf("%d",&A);
    scanf("%d",&B);
  
    if(A>B){
        ans = A + A-1;
    }
    else if(A==B){
        ans = A+B;
    }
    else ans = B + B-1;

    printf("%d\n",ans);

    return 0;
}

Measured memory_bytes: 128
fun abs(n: Int) = if (n > 0) n else -n

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val ws = readLine()!!.split(" ").map { it.toInt() }
    println((0 until n).map { abs(ws.take(it).sum() - ws.drop(it).sum()) }.min()!!)
}

Measured memory_bytes: 37840
#include<stdio.h>
int main()
{
    int n,a,ev_no=0,count=0,i;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a);
        if(a%2==0)
        {
            ev_no++;
            if(a%3==0 || a%5==0)
            {
                count++;
            }
        }
    }
    if(count == ev_no)
    {
        printf("APPROVED\n");
    }
    else
    {
        printf("DENIED\n");
    }
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

    private void execute() throws Exception {
        Scanner sc = new Scanner(System.in);
        String[] a = sc.nextLine().split(" ");
        int sum = 0;
        for (String sa : a) {
            sum += Integer.parseInt(sa);
        }
        if (sum <= 21) {
            System.out.println("win");
        } else {
            System.out.println("bust");
        }
    }

    public static void main(String[] args) {
        try {
            new Main().execute();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

}


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

	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int a=stdIn.nextInt();
		int b=stdIn.nextInt();

		int c=a+b;
		int d=a-b;
		int e=a*b;

		int max=c;
		if(max<d) {
			max=d;
		}
		if(max<e){
			max=e;
		}
		System.out.println(max);
	}

}


Measured memory_bytes: 22868
# D - Redistribution
S = int(input())
MOD = 10**9+7

# dp[i]: 3 以上の数字で i を作る組み合わせ
dp = [0]*(S+1)

if S <= 2:
    print(0)
elif S <= 5:
    print(1)
else:
    # 初期条件
    dp[3],dp[4],dp[5] = 1,1,1

    # i を作る組合わせ
    for i in range(6,S+1):
        dp[i] = dp[i-2] + dp[i-3] + dp[i-4]

    ans = (dp[S])%MOD
    print(ans)

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

#define all(x) x.begin(),x.end()
#define fi first
#define sd second
#define lson (nd<<1)
#define rson (nd+nd+1)
#define PB push_back
#define mid (l+r>>1)
#define MP make_pair
#define SZ(x) (int)x.size()

using namespace std;

typedef long long LL;

typedef vector<int> VI;

typedef pair<int,int> PII;

inline int read(){
    int res=0, f=1;char ch=getchar();
    while(ch<'0'|ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){res=res*10+ch-'0';ch=getchar();}
    return res*f;
}

const int MAXN = 200'005;

const int MOD = 1000000007;

void addmod(int& a, int b){a+=b;if(a>=MOD)a-=MOD;}
int mulmod(int a, int b){return 1ll*a*b%MOD;}

template<typename T>
void chmin(T a, T b){if(a>b)a=b;}

template<typename T>
void chmax(T a, T b){if(b>a)a=b;}


int main(){
    int n=read();
    int ans=0;

    for(int i=1;i<=n;++i){
        for(int j=1;j<=n;++j){
            for(int k=1;k<=n;++k){
                int t=__gcd(i,j);
                t=__gcd(t,k);
                ans+=t;
            }
        }
    }

    cout<<ans;

    return 0;
}


Measured memory_bytes: 3640
// May this submission get accepted
#pragma GCC optimize ("O3")
#pragma GCC target("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) { if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(DUMPALL_ITR, (q).size()) { cerr << (q)[DUMPALL_ITR] << (DUMPALL_ITR == DUMPALL_ITR_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using  ld = long double;
using namespace std;

// 標準入出力
struct inp {
    size_t sz;
    inp(size_t _sz = 1) : sz(_sz) {}
    template <typename T> operator T () const { T a; cin >> a; return a; }
    template <typename T> operator vector<T> () const { vector<T> a(sz); for (size_t i = 0; i < sz; i++) cin >> a[i]; return a; }
    template <typename T, typename U> operator pair<T, U> () const { T f; U s; cin >> f >> s; return pair<T, U>(f, s); }
};
inp inp1; // input one
template <typename T> void say(T &x, char end = '\n') { cout << x << end; }
template <typename T> void say(vector<T> &x, char sep = ' ', char end = '\n') { for (size_t i = 0, sz = x.size(); i < sz; i++) { cout << x[i] << (i == sz-1 ? end : sep); } }

// モジュール


// 処理内容
int main() {
    
    ios::sync_with_stdio(false); // stdioを使うときはコメントアウトすること
    cin.tie(nullptr);            // インタラクティブ問題ではコメントアウトすること
    
    ll a = inp1;
    ll b = inp1;

    ll n = b - a;
    ll b0 = n * (n + 1) / 2;
    cout << b0-b << endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

ll l, m, n, sum;
int f = 0;

int main(){
	while (cin >> l&&l){
		f = 0;
		sum = 0;
		REP(i, 12){
			cin >> m >> n;
			sum += m - n;
			if (f == 0){
				if (sum >= l)f = i + 1;
			}
		}
		if (f == 0)cout << "NA\n";
		else cout << f << endl;
	}
}

Measured memory_bytes: 1160
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());
		
		Long ans = 0l;
		
		for(int i = 1 ; i <= n ; i++) {
			if(i % 3 != 0  && i % 5 != 0) {
				ans += i;
			}
		}
		

		System.out.println(ans);
	}


}


Measured memory_bytes: 39592
N = int(input())
W = list(map(int,input().split()))

# Wの累積和と、残りの和を求める
cumulative_sum_W = 0
rest_sum = sum(W)
abs_list = []

for i in range(N):
    cumulative_sum_W += W[i]
    rest_sum -= W[i]
    abs_list.append(abs(cumulative_sum_W-rest_sum))

print(min(abs_list))

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>

using namespace std;

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

int main(){
	long long int n, k;
	
	P p[100000];
	cin >> n >> k;
	for(int i = 0; i < n; i++){
		cin >> p[i].first >> p[i].second;
	}
	sort(p, p+n);
	
	int ans;
	for(int i = 0; i < n; i++){
		ans = p[i].first;
		k -= p[i].second;
		if(k <= 0) break;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <map>
#include <iomanip>

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

using namespace std;
using lli = long long int;
using ll = long long;

int main() {
    lli a, b;
    cin >> a >> b;

    string aStr;
    for (lli i = 0; i < a; ++i) {
        aStr += to_string(b);
    }

    string bStr;
    for (lli i = 0; i < b; ++i) {
        bStr += to_string(a);
    }

    if (aStr < bStr) {
        cout << aStr << endl;
    } else {
        cout << bStr << endl;
    }
}




Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
A.sort()
import collections
count_A = collections.Counter(A)
# print(count_A.values())
count_1 = 0
count_2 = 0
for v in count_A.values():
    if v == 1:
        count_1 += 1
    elif v == 2:
        count_2 += 1
    else:
        if v % 2 == 0:
            count_2 += 1
        else:
            count_1 += 1
# print(count_1, count_2)
if count_2 % 2 == 0:
    print(count_1+ count_2)
else:
    print(count_1+ count_2-1)

Measured memory_bytes: 61548
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

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

Measured memory_bytes: 256
'use strict';
(function(stdin) {
  var lines  = stdin.toString().split('\n');
  var result = (function(data) {
  	var Calc = {
  		'+':function(a,b){return a + b;}
  		,'-':function(a,b){return a - b;}
  		,'*':function(a,b){return a * b;}
  		,'/':function(a,b){return ~~(a / b);}
  	};
  	var result = [];
  	var tmp;
  	var index = 0;
  	while (true) {
  		tmp = data[index++].split(' ');
  		if (tmp[1] === '?') break;
  		result.push(Calc[tmp[1]](parseInt(tmp[0],10),parseInt(tmp[2],10)));
  	}
  	return result.join('\n');
  }(lines
  ));
  console.log(result);
}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 7904
#include <bits/stdc++.h>
#include <cmath>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP1(i,n) for(int i = 1; i < n+1 ;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 INF 2e9
#define ALL(v) v.begin(), v.end()
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
typedef long long ll;

int main(){
  int N;
  cin >> N;
  int i, cp = 0;
  for (i == 0; i < N ; i++){
    int l, r;
    cin >> l >> r;
    cp += r - l + 1;
  }
  cout << cp << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<double, double> Pdd;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;

const ll mod = 1e9+7;
const int INF = 2e9;
const double epsilon = 1e-7;
const double PI = 3.1415926535;

ll mi(ll x, ll y){
    if(x<y)return x;
    return y;
}
ll a[100000];
int main(void){
    int n; cin >> n; ll sum = 0;
    for(int i = 0;i < n;i++){cin >> a[i]; sum += a[i];}
    ll m0 = sum;
    for(int i = 1;i < n;i+=2){
        m0 -= a[i]*2;
    }
    printf("%lld", m0);
    for(int i = 1;i < n;i++){
        m0 = (a[i-1] - m0/2)*2;
        printf(" %lld", m0);
    }
	return 0;
}


Measured memory_bytes: 2048
/*author* Priyanshu Shrivastav (from IIT Palakkad) *
 * *_ __ ___  _ ______ ___  _ ____   ___  ___| |_  *
 * | '_ ` _ \| '__/ __/ _ \| '_ \ \ / / |/ __| __| *
 * | | | | | | | | (_| (_) | | | \ V /| | (__| |_  *
 * |_| |_| |_|_|(_)___\___/|_| |_|\_/ |_|\___|\__| *
When I wrote this, only God and I understood what I was doing
 ** * * * * * * * Now, only God knows * * * * * * */
#include         <bits/stdc++.h>
using namespace std;
#pragma GCC      optimize ("Ofast")
#pragma GCC      optimize ("unroll-loops")
#pragma GCC      target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define IOS      ios_base::sync_with_stdio(false); cin.tie (nullptr)
#define PREC     cout.precision (10); cout << fixed
#define bg(x)    " [ " << #x << " : " << (x) << " ] "
#define x        first
#define y        second
using ll = long long;
using ff = long double;
using pii = pair<int,int>;

#define debug(args...) { \
/* WARNING : do NOT compile this debug func calls with following flags: // \
 * // -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -D_FORTIFY_SOURCE=2*/ \
   string _s = #args; replace(_s.begin(), _s.end(), ',', ' ');\
   stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); \
}
void err(istream_iterator<string> it) { it->empty();
   cerr << " (Line : " << __LINE__ << ")" << '\n';
}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << fixed << setprecision(15) << " [ " <<  *it << " : " << a  << " ] "<< ' ';
	err(++it, args...);
}

const int N = (int)1e5 + 10, infi = (int) 1e9;

int dp[N][3], abc[N][3];
int n;

void solve() {
   for (int i = 1; i <= n; ++i) for (int j = 0; j < 3; ++j)
      dp[i][j] = infi;
   dp[1][0] = abc[1][0], dp[1][1] = abc[1][1], dp[1][2] = abc[1][2];

   for (int i = 2; i <= n; ++i) for (int j = 0; j < 3; ++j)
   {
      int mx = max(dp[i-1][(j+1)%3], dp[i-1][(j+2)%3]);
      dp[i][j] = mx + abc[i][j];
   }

   int mx_val = -infi;
   for (int j = 0; j < 3; ++j) {
      mx_val = max(mx_val, dp[n][j]);
   }
   cout << mx_val << '\n';
}

signed main() {
   IOS; PREC;

   cin >> n;
   for (int i = 1; i <= n; ++i) for (int k = 0; k < 3; ++k)
      cin >> abc[i][k];
   solve();

   return EXIT_SUCCESS;
}


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

int main(void)
{
  string S, T;
  
  getline(cin, S);
  getline(cin, T);
  
  int changes = 0;
  
  for(int i = 0; i < S.length(); ++i)
  {
    if(S.at(i) != T.at(i))
      ++changes;
  }
  
  cout << changes << endl;
  
  return 0;
}

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

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> num(N);
  
  for(int i=0;i<2*M;i++){
    int S;
    cin >> S;
    num.at(S-1)+=1;
  }
  
  for(int i=0;i<N;i++){
    cout << num.at(i) << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;

	int ans = 0;
	rep(i, n - 1) {
		string s1 = s.substr(0, i + 1);
		string s2 = s.substr(i + 1, n - i - 1);
		set<char> m1, m2;
		for (char c : s1) {
			m1.insert(c);
		}
		for (char c : s2) {
			m2.insert(c);
		}
		int cnt = 0;
		for (char c : m1) {
			if (m2.find(c) != m2.end()) cnt++;
		}
		ans = max(ans, cnt);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int squ = 1;
    while(n/2 >= squ){
      squ *= 2;
    }
    System.out.println(squ);
  }
}


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

int main(){
  int sum = 0;
  rep(i,3){
    int A;
    cin >> A;
    sum += A;
  }
  
  if(sum >= 22) cout << "bust" << endl;
  else cout << "win" << endl;
}

Measured memory_bytes: 256
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n=int(input())
a=[0]*n
b=[0]*n
l=[0]*n
for i in range(n):
    x,y=mp()
    a[i]=x
    b[i]=y
    l[i]=[x,y,x+y]
l=sorted(l,key=lambda X: X[2],reverse=True)
ans=0
for i in range(n):
    if i%2==0:
        ans+=l[i][0]
    else:
        ans-=l[i][1]
print(ans)

Measured memory_bytes: 28844
# D - 11

n = int(input())
a = list(map(int, input().split()))
MOD = 10**9 + 7

# a//b (MOD p)
def div_mod(a, b, p):
    return (a * pow(b, p-2, p)) % p

factorial_memo = [1]
for i in range(1, n+2):
    factorial_memo.append((factorial_memo[-1] * i) % MOD)

def comb_mod(n, r, mod):
    if n < r:
        return 0
    return div_mod(div_mod(factorial_memo[n], factorial_memo[n-r], mod), factorial_memo[r], mod)


indices = [-1] * (n+1)
for i in range(n+1):
    if indices[a[i]] == -1:
        indices[a[i]] = i
    else:
        f_idx = indices[a[i]]
        s_idx = i
        break

for k in range(1, n+2):
    all_pattern = comb_mod(n+1, k, MOD)
    dup_pattern = comb_mod(f_idx + (n - s_idx), k-1, MOD)
    print((all_pattern - dup_pattern) % MOD)

Measured memory_bytes: 16484
def main():
    N = int(input())
    H = list(map(int, input().split()))
    ans, streak = 0, 0
    for i in range(N - 1):
        if H[i] < H[i + 1]:
            ans = max(ans, streak)
            streak = 0
        else:
            streak += 1
    print(max(ans, streak))


if __name__ == '__main__':
    main()


Measured memory_bytes: 63856
def f(s,i,m):
    m = m%26
    if ord(s[i])+m <= 122:
        s[i] = chr(ord(s[i])+m)
    else:
        t = ord(s[i])+m-122
        s[i] = chr(96+t)
    return s

def judge(c,n):
    if ord(c)+n > 122:
        return (123 - ord(c))%26
    else:
        return 0
        
s = list(input())
n = int(input())
l = len(s)

for i in range(0,l):
    if i == l-1:
        s = f(s,i,n)
    else:
        d = judge(s[i],n)
        s = f(s,i,d)
        n = n - d

print(''.join(s))

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

#define ll long long
const int mod = 1e9+7 ;

int main(){
	string s , t ; cin >> s >> t ; 
	t.pop_back() ;
	if( s == t ){
		cout << "Yes" << endl ;
	}
	else cout << "No" << endl ;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define N 17
using namespace std;
double x[N][N],memo[(1<<N)][N];
int m,n;

double dfs(int a,int b){
  if(memo[a][b]>=0)return memo[a][b];
  if(b==n)return memo[a][b]=1;
  double res=0;
  for(int i=0;i<m;i++){
    if(a&(1<<i))continue;
    double sum=0,X=1;
    for(int j=0;b+j<=n;j++){
      sum+=X*(1-x[i][b+j])*dfs(a|(1<<i),b+j);
      X*=x[i][b+j];
    }
    res=max(res,sum);
  }
  return memo[a][b]=res;
}

int main(){
  cin>>m>>n;
  for(int i=0;i<m;i++)
    for(int j=0;j<n;j++)
      cin>>x[i][j];
  for(int i=0;i<(1<<m);i++)
    for(int j=0;j<=n;j++)
      memo[i][j]=-1;
  printf("%.10f\n",dfs(0,0));
  return 0;
}

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

long long n, a, b;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> a >> b;
    if(a>b||(n==1&&a!=b)) {
        cout << 0;
        return 0;
    }
    if(a==b) {
        cout << 1;
        return 0;
    }

    cout << (b-a)*(n-2)+1;

    return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{VecDeque, HashMap, BTreeMap, HashSet, BTreeSet};
#[allow(unused_imports)]
use std::io::{stdout, Write, BufWriter};
#[allow(unused_imports)]
use proconio::marker::{Isize1, Usize1, Bytes, Chars};
#[proconio::fastout]
fn main() {
    proconio::input!{
        n: usize,
        m: usize,
        x: i32,
        ca: [[i32; m + 1]; n],
    }
    let mut ans = std::i32::MAX;
    for bit in 0..(1 << n) {
        let mut price = 0;
        let mut v = vec![0; m];
        for i in 0..n {
            if 1 << i & bit != 0 {
                price += ca[i][0];
                for j in 0..m { v[j] += ca[i][j + 1]; }
            }
        }
        if v.iter().all(|y| *y >= x) { ans = min(ans, price); }
    }
    if ans == std::i32::MAX { println!("-1"); }
    else { println!("{}", ans); }
}


Measured memory_bytes: 2208
#include <bits/stdc++.h>
#define int long long
#define pb       push_back
#define io    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define all(a)      (a).begin(),(a).end()
#define endl        '\n'
#define F    first
#define S second
#define mod 1000000007 
#define N 100005
#define pii pair<int,int>
using namespace std;
vector<int> v[N];
stack<int> s;
vector<bool> vis(N,false);
vector<int> dist(N,0);

void dfs(int x)
{
    vis[x]=true;
    for(auto i: v[x])
    {
        if(!vis[i])
            dfs(i);
            
         dist[x]=max(dist[x],1+dist[i]);
    }
}
void solve()
{
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        v[a].pb(b);
    }
    for(int i=1;i<=n;i++)
    {
        if(!vis[i])
        {
            dfs(i);
        }
    }
    cout<<*max_element(all(dist));
}

signed main(){
    io;
    int t=1;
    //cin>>t;
    while(t--){
      solve();
    }
    return 0;
}

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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = x ; i < n ; ++i)
#define rep(i, n) for(int i = 0 ; i < n ; ++i)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())

const int IINF = 1e9 + 10;
const long long LLINF = (long long)1e18 + 10;
const long long MOD = (long long)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

int main(){
    int n;
    cin >> n;
    int rank = 0, point = IINF;
    rep(i, n){
        int a, b;
        cin >> a >> b;
        if(rank < a){
            rank = a;
            point = b;
        }
    }
    int ans = rank + point;
    cout << ans << endl;
    return 0;
}

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

int main(){
    int s;
    cin >> s;
    vector<int> a;
    a.push_back(s);
    for(int i = 1;; i++)
    {
        if ((a.at(i - 1) % 2) == 0) {
            a.push_back(a.at(i - 1) / 2);
        }
        else
        {
            a.push_back(3 * a.at(i - 1) + 1);
        }

        for(int j = 0; j < i; j++)
        {
            if (a.at(i) == a.at(j)) {
                cout << i + 1 << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define EPS 1e-10
#define INF 1000000000
#define mp make_pair
#define pb push_back

typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int,int> pii;
typedef long long ll;

int main() {
  int N;
  cin >> N;
  if (N == 0) {
    puts("1");
  } else if (N == 1) {
    puts("2");
  } else if (N == 2) {
    puts("1");
  } else {
    puts("0");
  }
}

Measured memory_bytes: 1120
N = int(input())
A = [int(i) for i in input().split()]
dif = abs(A[0]) + abs(A[N-1])
for i in range(N-1):
    dif += abs(A[i]-A[i+1])
ans = [dif] * N

for i in range(1, N-1):
    
    ans[i] += - abs(A[i-1] - A[i]) -abs(A[i] - A[i+1]) + abs(A[i-1] - A[i+1])
ans[0] = ans[0] - abs(A[0]) + abs(A[1]) -abs(A[0] - A[1])
ans[N-1] = ans[N-1] - abs(A[N-1]) + abs(A[N-2])  - abs(A[N-1]-A[N-2])

for i in ans:
    print(i)

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

int main(){
	const int MAX_w = 30;
	int w, n, a, b, c, p;
	int lots[MAX_w + 1];
	string str;
	
	for(int i = 1; i <= MAX_w; i++){
		lots[i] = i;
	}
	
	cin >> w >> n;
	
	for(int i = 0; i < n; i++){
		a = 0; b = 0;
		cin >> str;
		
		p = 0;
		while(str[p] != ','){
			a = a * 10 + (str[p] - 48);
			p++;
		}
		p++;
		while(p < str.size()){
			b = b * 10 + (str[p] - 48);
			p++;
		}
		
		c = lots[a];
		lots[a] = lots[b];
		lots[b] = c;
	}
	
	for(int i = 1; i <= w; i++){
		cout << lots[i] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1200
#include<iostream>
#include<cmath>
#include<cstdio>
#define earth 6378.1
using namespace std;
int main(){
	double n1, n2, e1, e2;
	while(cin >> n1 >> e1 >> n2 >> e2){
		if(n1==-1&&n2==-1&&e1==-1&&e2==-1) break;
		double disAB, disBC, disCA, cosC;
		disBC = M_PI*(90-n1)/180;
		disCA = M_PI*(90-n2)/180;
		cosC = cos(M_PI*(e2-e1)/180);
		disAB = acos(cos(disBC)*cos(disCA)+sin(disBC)*sin(disCA)*cosC);
		printf("%.f\n",(disAB*earth));
	}
	return 0;
}

Measured memory_bytes: 0
n = int(input().strip())
s = [input().strip() for _ in range(n)]
num_m = len([True for _s in s if _s[0] == "M"])
num_a = len([True for _s in s if _s[0] == "A"])
num_r = len([True for _s in s if _s[0] == "R"])
num_c = len([True for _s in s if _s[0] == "C"])
num_h = len([True for _s in s if _s[0] == "H"])
print(num_m * num_a * num_r + num_m * num_a * num_c + num_m * num_a * num_h + num_m * num_r * num_c
      + num_m * num_r * num_h + num_m * num_c * num_h + num_a * num_r * num_c +
      num_a * num_r * num_h + num_a * num_c * num_h + num_r * num_c * num_h)

Measured memory_bytes: 10540
#import pysnooper
import os,re,sys,operator,math,heapq,string
#from collections import Counter,deque
#from operator import itemgetter
#from itertools import accumulate,combinations,groupby,combinations_with_replacement
from sys import stdin,setrecursionlimit
#from copy import deepcopy

setrecursionlimit(10**6)
input=stdin.readline

n,a,b=map(int,input().split())
x=[int(i) for i in input().split()]
ans=0
for i in range(1,n):
    now=x[i]-x[i-1]
    ans+=min(now*a,b)
    #print(ans,min(now*a,b))
print(ans)

Measured memory_bytes: 15660
import numpy as np

n = int(input())
l = []
r = []
for i in range(n):
    li, ri = map(int, input().split())
    l.append(li)
    r.append(ri+1)

arglmax = l.index(max(l))
argrmin = r.index(min(r))
num = 0
for i in range(n):
    num = max(r[i] - l[i], num)
ans1 = num + max(0, r[argrmin]-l[arglmax])

lst = [l, r]
lst = list(np.array(lst).T)
lst = sorted(lst, key=lambda x: (x[0]), reverse=True)
lst = sorted(lst, key=lambda x: (x[1]))
lst = list(np.array(lst).T)
sorted_l = list(lst[0])
sorted_r = list(lst[1])

sorted_r_minus_lmax = list(np.array(sorted_r)-l[arglmax])
mini = sorted_r_minus_lmax[n-1]
for i in range(1, n):
    mini = min(mini, sorted_r_minus_lmax[n-1-i])
    sorted_r_minus_lmax[n-1-i] = mini
rmin_minus_sorted_l = list(r[argrmin]-np.array(sorted_l))
mini = rmin_minus_sorted_l[0]
for i in range(1, n):
    mini = min(mini, rmin_minus_sorted_l[i])
    rmin_minus_sorted_l[i] = mini

ans2 = 0
for i in range(n-1):
    ai = max(0, sorted_r_minus_lmax[i+1])
    bi = max(0, rmin_minus_sorted_l[i])
    ans2 = max(ans2, ai+bi)

print(max(ans1, ans2))

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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
typedef pair<int, int> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, a, b, c, d, e;
  cin >> n >> a >> b >> c >> d >> e;
  long double neck = min({a, b, c, d, e});
  ll res = 4;
  res += ceil(double(n) / neck);
  cout << res << endl;
}


Measured memory_bytes: 256
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#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 <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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; }
const long long INF = 100100100100;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}

int main() {
    string S;cin >> S;
    for(int i = 0;i<S.size();i++){
        if(S.at(i) == '?') S.at(i) = 'D';
    }
    cout << S << endl;
}


Measured memory_bytes: 3712
/**
 *    author:  morato
 *    created: 25.08.2020 20:21:42
**/
#include <bits/stdc++.h>

using namespace std;

const int N = 1e6 + 5;

int dp[N][2], n;
string s;

int solve(int i, int carry) {
  if (i == n) {
    return carry;
  }
  if (dp[i][carry] != -1) {
    return dp[i][carry];
  }
  int cur = (s[i] - '0') + carry;
  if (cur == 10) {
    return dp[i][carry] = solve(i + 1, 1);
  } 
  if (cur == 0) {
    return dp[i][carry] = solve(i + 1, 0);
  }
  return dp[i][carry] = min(solve(i + 1, 1) + 10 - cur, solve(i + 1, 0) + cur);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  memset(dp, -1, sizeof dp);
  cin >> s;
  n = s.size();
  reverse(s.begin(), s.end());
  cout << solve(0, 0) << '\n';
  return 0;
}

Measured memory_bytes: 58956
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <utility>
#include <vector>

using namespace std;

double dis(double x1, double y1, double x2, double y2) {
	return sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
}

int main() {
	cout << fixed;
	cout << setprecision(numeric_limits<double>::max_digits10);

	int N;
	cin >> N;

	vector<int> x(N);
	vector<int> y(N);
	for(int i = 0; i < N; i++) {
		cin >> x[i] >> y[i];
	}

	// 距離の和
	double sumDis = 0;
	for(int i = 0; i < N; i++) {
		for(int j = i; j < N; j++) {
			const double d = dis(x[i], y[i], x[j], y[j]);
			sumDis += d;
		}
	}

	const double result = (2 * sumDis) / N;
	cout << result << endl;

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define qmax(x,y) (x=max(x,y));
using namespace std;

typedef long long ll;
const int Maxn=11000;
const ll mod=1000000007;

char a[Maxn];
int k,f[Maxn][110],ans;

int main() {
	scanf("%s",a);
	scanf("%d",&k);
	int n=strlen(a);
	f[0][0]=1;
	for(int i=1;i<n;i++)
		for(int l=0;l<=9;l++)
		for(int j=0;j<=k;j++) f[i][(j+l)%k]=(f[i][(j+l)%k]+f[i-1][j])%mod;
	int sum=0;
	for(int i=0;i<n;sum=(sum+a[i]-'0')%k,i++)
		for(int j=0;j<a[i]-'0';j++) {
			ans+=f[n-i-1][(k-(sum+j)%k)%k];
			ans%=mod;
		}
	if(sum==0) ans++;ans--;ans+=mod;
	ans%=mod;
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
int vis[4][4];
int main() {
	int a[4][4];
	for(int i=1;i<=3;i++)
		for(int j=1;j<=3;j++) cin>>a[i][j];
	int n; cin>>n;
	int flag=0;
	while(n--){
		int x; cin>>x;
		for(int i=1;i<=3;i++)
		for(int j=1;j<=3;j++)
			if(a[i][j]==x) vis[i][j]=1;
	}
	for(int i=1;i<=3;i++){
		int x=0;
		for(int j=1;j<=3;j++) x+=vis[i][j];
		if(x==3) flag=1;
	}
	for(int i=1;i<=3;i++){
		int x=0;
		for(int j=1;j<=3;j++) x+=vis[j][i];
		if(x==3) flag=1;
	}
	if(vis[1][1]+vis[2][2]+vis[3][3]==3) flag=1;
	if(vis[1][3]+vis[2][2]+vis[3][1]==3) flag=1;
	if(!flag) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int n;
    int i;
    int min, max;
    long sum;

    scanf("%d", &n);
    /*n = 0 のとき min, max, sum 定義なし*/
    if (n == 0){
        printf("undefined\n");
    /*n != 0 のとき*/
    }else{
        /*値をひとつ読み込む*/
        int a_1 = 0;
        scanf("%d", &a_1);
        min = max = sum = a_1;
        /*2つ目の値から比較開始*/
        for (i = 2; i <= n; i++){
            int a_i = 0;
            scanf("%d", &a_i);
            /*minの比較;大きくない方をminに代入*/
            if (min <= a_i){
                ;
            }else{
                min = a_i;
            }
            /*maxの比較;小さくない方をmaxに代入*/
            if (max >= a_i){
                ;
            }else{
                max = a_i;
            }
            /*sumにa_iを足していく*/
            sum += a_i;
        }

        printf("%d %d %ld\n", min, max, sum);
    }
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end()) // ユニークなvectorにする。連続した値を除去して切り出す。
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  ll A, B, C, D;
  cin >> A >> B >> C >> D;
  ll S1 = A * B;
  ll S2 = C * D;
  if (S1 > S2) {
    cout << S1 << endl;
  } else {
    cout << S2 << endl;
  }
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
use std::cmp::{max, min};

fn read<T: FromStr> () -> T {
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let N: usize = read();
    let mut B: Vec<usize> = vec![0; N];
    for i in 1..N {
        B[i] = read();
    }

    let mut ans: usize = 0;
    ans += B[1];
    for i in 2..N {
        ans += std::cmp::min(B[i], B[i-1]);
    }
    ans += B[N-1];
    println!("{}", ans);
}


Measured memory_bytes: 4352
import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

def main():
    A,B,C,D = map(int,(input().split()))

    A_num = (A-1)//C + (A-1)//D - (A-1)//lcm(C, D)
    B_num = B//C + B//D - B//lcm(C, D)
    return (B-(A-1))-(B_num - A_num)


if __name__ == '__main__':
    print(main())

Measured memory_bytes: 5048
N, Q = map(int, input().split())
S = input().rstrip()
cnt = 0
tmp = 0
res = [0]*N
for i, s in enumerate(S):
    if s == "A":
        tmp = 1
    elif s=="C" and tmp == 1:
        tmp = 0
        cnt += 1
    else:
        tmp = 0
    res[i] = cnt
for _ in range(Q):
    l, r = map(int, input().split())
    l -= 1
    r -= 1
    print(res[r] - res[l])

Measured memory_bytes: 76476
def solve():
    N = int(input())
    dp = [[0] * 3 for i in range(N+1)]
    A = [list(map(int, input().split())) for i in range(N)]
    for i in range(N):
        for j in range(3):
            for k in range(3):
                if j == k: continue
                dp[i+1][k] = max(dp[i+1][k], dp[i][j] + A[i][k])
    return max(dp[N])

print(solve())


Measured memory_bytes: 50332
import java.io.*;
import java.nio.CharBuffer;
import java.util.NoSuchElementException;

public class Main {

    private static final int MOD = 998244353;

    public static void main(String[] args) {
        SimpleScanner scanner = new SimpleScanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);

        int m = scanner.nextInt();
        int d = scanner.nextInt();
        int ans = 0;
        for (int i = 1; i <= m; ++i) {
            for (int j = 20; j <= d; ++j) {
                if (j % 10 < 2)
                    continue;
                if (i == (j / 10) * (j % 10)) {
//                    writer.println(i + " " + j);
                    ++ans;
                }
            }
        }
        writer.println(ans);

        writer.close();
    }

    private static class SimpleScanner {

        private static final int BUFFER_SIZE = 10240;

        private Readable in;
        private CharBuffer buffer;
        private boolean eof;

        SimpleScanner(InputStream in) {
            this.in = new BufferedReader(new InputStreamReader(in));
            buffer = CharBuffer.allocate(BUFFER_SIZE);
            buffer.limit(0);
            eof = false;
        }


        private char read() {
            if (!buffer.hasRemaining()) {
                buffer.clear();
                int n;
                try {
                    n = in.read(buffer);
                } catch (IOException e) {
                    n = -1;
                }
                if (n <= 0) {
                    eof = true;
                    return '\0';
                }
                buffer.flip();
            }
            return buffer.get();
        }

        private void checkEof() {
            if (eof)
                throw new NoSuchElementException();
        }

        private char nextChar() {
            checkEof();
            char b = read();
            checkEof();
            return b;
        }

        private String next() {
            char b;
            do {
                b = read();
                checkEof();
            } while (Character.isWhitespace(b));
            StringBuilder sb = new StringBuilder();
            do {
                sb.append(b);
                b = read();
            } while (!eof && !Character.isWhitespace(b));
            return sb.toString();
        }

        private int nextInt() {
            return Integer.valueOf(next());
        }

        private long nextLong() {
            return Long.valueOf(next());
        }

        private double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 22100
a = [int(input())]
def fc(n):
    if n%2:
        p = 3*n+1
    else:
        p = n//2
    return p

for i in range(1000000):
    f = fc(a[i])
    if f in a:
        m = i+2
        break
    else:
        a.append(f)
print(m)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,t;
  cin >> n >> t;
  vector<pair<int,int> >food(n);
  int i;
  for(i=0;i<n;i++){
    cin >> food[i].first >> food[i].second;
  }
  vector<long>dp(t+5000,0);
  sort(food.begin(),food.end());
  priority_queue<int>que;
  que.push(0);
  for(i=0;i<n;i++){
    set<int>tmp;
    while(!que.empty()){
      int tmpp = que.top();
      que.pop();
      tmp.insert(tmpp);
      if(food[i].first + tmpp < t){
        tmp.insert(tmpp+food[i].first);
      }
      dp[tmpp+food[i].first] = max(dp[tmpp+food[i].first],dp[tmpp]+food[i].second);
    }
    for(auto j:tmp)que.push(j);
  }
  long maxx = 0;
  for(i=0;i<dp.size();i++){
    if(maxx<dp[i])maxx = dp[i];
  }
  cout << maxx << endl;
}


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

using namespace std;

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    #ifdef FUN

        freopen("input.txt", "r",stdin);
        freopen("output.txt", "w",stdout);
    #else
        #define endl '\n'
    #endif // FUN
    int x,y;
    cin>>x>>y;
    if ( x == y )
    {
        cout<<"0\n";
    }
    if ( x == 0 )
    {
        if ( y > 0 ) cout<<y<<"\n";
        else cout<<abs(y)+1<<"\n";
    }
    else if ( y == 0 )
    {
        if ( x < 0 ) cout<<abs(x)<<"\n";
        else cout<<abs(x)+1<<"\n";
    }
    else if ( x < y )
    {
        if ( x < 0 && y > 0 ) cout<<abs(y+x)+1<<"\n";
        else cout<<abs(y-x)<<"\n";
    }
    else if ( x > y )
    {
        if ( y < 0 && x > 0 ) cout<<abs(y+x)+1<<"\n";
        else cout<<2+abs(y-x)<<"\n";
    }
    else{
        cout<<"0\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<utility>
#include<algorithm>
using namespace std;
using ll = long long int;

int n, ret = 0;
vector<int> p;

inline void pswap(int i, int j) {
	int tmp = p[i] + 1;
	p[i] = p[j] - 1;
	p[j] = tmp;
}

int main(void) {
	cin >> n;
	for (int i = 0; i < n; i++) {
		int pi;
		cin >> pi;
		p.push_back(pi - i - 1);
	}

	for (int i = 0; i < n; i++) {
		if (p[i] == 0) {
			pswap(i, i+1);
			ret++;
		}
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
const int nmax=200005;
long long a[nmax],n,m,i,med,sum;
long long abss(long long x)
{
    if(x<0) return -x;
    return x;
}
int main()
{
    cin>>n;
    for(i=1;i<=n;i++)
        cin>>a[i],a[i]-=i;
    sort(a+1,a+n+1);
    med=(n+1)/2;
    for(i=1;i<=n;i++)
        sum+=abss(a[i]-a[med]);
    cout<<sum;
    return 0;
}

Measured memory_bytes: 1792
let split str =
  let rec split_inner ct b=
    if String.length str = ct then [(int_of_string b)]
    else
      match str.[ct] with
        ' ' -> (int_of_string b)::split_inner (ct+1) ""
      | c -> split_inner (ct+1) (b^(Char.escaped c))
  in split_inner 0 "";;

let () =
  let (n,k) = match split (read_line ()) with
        [n;k] -> (n,k)
      | _ -> raise Not_found
  in
  let ws = Array.init n (fun _ -> read_int ()) in
  let l = Array.fold_left (fun x y->max x y) 0 ws and
       r = 100000*100000
  in
  let rec search ((i,j,s,p):int*int*int*int) =
    if i=n || j=k then i
    else
      if s+ws.(i) <= p then
        search ((i+1), j, (s+ws.(i)), p)
      else
        search (i,(j+1),0,p)
  in
  let rec loop (left:int) (right:int) =
    if left < right then
      let mid = (left+right)/2 in
      if search (0,0,0,mid) >= n then loop left mid
      else loop (mid+1) right
    else right
  in
  Printf.printf "%d\n" (loop l r)
;;

Measured memory_bytes: 5648