akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define N 2007
#define mod 1000000007ll
using namespace std;
typedef long long ll;

inline int rd() {
  int x = 0;
  bool f = 0;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') f = 1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = x * 10 + (c ^ 48);
    c = getchar();
  }
  return f ? -x : x;
}

int n, f[N];

int main() {
  n = rd();
  f[0] = 1;
  for (int i = 3; i <= n; ++i)
    for (int j = 3; j <= i; ++j)
      f[i] = (f[i] + f[i - j]) % mod;
  printf("%d\n", f[n]);
  return 0;
}


Measured memory_bytes: 3740
#include<bits/stdc++.h>
#define modulo 10000;
using namespace std;

int dp[114][5][14];//day yesterday today
int pa[114];//pasta

int main(){
	int n,ka;
	cin>>n>>ka;
	for(int i=0;i<ka;i++){
		int a,b;
		cin>>a>>b;
		pa[a]=b;
		}
		
	if(pa[1]){
		for(int i=0;i<1;i++)dp[1][i][pa[1]-1]++;
		}
	else{
		for(int i=0;i<1;i++)
		for(int j=0;j<3;j++)dp[1][i][j]++;
		}	
		
	for(int x=2;x<=n;x++){
		if(pa[x]==1){
			for(int i=0;i<3;i++){
				for(int j=0;j<3;j++){
					if(i==j&&j==0)continue;
					dp[x][i][0]+=dp[x-1][j][i];//
					dp[x][i][0]%=modulo;
					}
				}
			}
		else if(pa[x]==2){
			for(int i=0;i<3;i++){
				for(int j=0;j<3;j++){
					if(i==j&&j==1)continue;
					dp[x][i][1]+=dp[x-1][j][i];//
					dp[x][i][1]%=modulo;
					}
				}
			}
		else if(pa[x]==3){
			for(int i=0;i<3;i++){
				for(int j=0;j<3;j++){
					if(i==j&&j==2)continue;
					dp[x][i][2]+=dp[x-1][j][i];//
					dp[x][i][2]%=modulo;
					}
				}
			}
		else{
			for(int i=0;i<3;i++){
				for(int j=0;j<3;j++){
					for(int k=0;k<3;k++){
						if(x!=2){
						if(i==j&&j==k)continue;}
						dp[x][i][j]+=dp[x-1][k][i];//
						dp[x][i][j]%=modulo;
						}
					}
				}
			}
			}	
	int ans=0;
		for(int i=0;i<3;i++)
		for(int j=0;j<3;j++)ans+=dp[n][i][j];
		ans%=modulo;
		cout<<ans<<endl;
		return 0;
	}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    string str;
    ll ans=0;
    cin>>str;
    for(int i=0;i<str.size();i++)
    {
        ans+=(str[i]-'0');
    }
    if(ans%9==0)
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }
    
    return 0;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<int> v;
typedef vector<ll> vll;
typedef pair<int, int> P;
using Graph = vector<vector<int>>;
const int INF = 1001001001;
// << fixed << setprecision(0) <<
// sort(ALL(),greater<int>());


int main() {
  double w,h,x,y;
  cin >> w >> h >> x >> y;
  double sans=w*h/2;
  int cans=0;
  if(w/x==2&&h/y==2) cans=1;
  cout << sans << " " << cans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

struct ST {
  ll A, B;
  ll sum;
  int i;
};
bool operator<(const ST& a, const ST& b){
  return a.sum < b.sum;
}
  
int main(){
  int N;
  cin >> N;

  vector<ST> v;
  rep(i,N){
    ll a, b;
    cin >> a >> b;
    v.push_back((ST){a, b, a+b, i});
  }
  sort(ALLOF(v));
  reverse(ALLOF(v));
  
  ll ret = 0;
  rep(i,v.size()){
    if(i%2==0) ret += v[i].A;
    else ret -= v[i].B;
  }
 
  cout << ret << endl;
  
  return 0;
}

Measured memory_bytes: 6000
from itertools import accumulate

N = int(input())
A = list(map(int, input().split()))

A.sort()
a = list(accumulate(A))
answer = N

for i in range(N - 1):
    if a[i] * 2 < A[i + 1]:
        answer = N - (i + 1)

print(answer)

Measured memory_bytes: 14428
#include <stdio.h>

int main(void)
{
  int N, D, ans;
  
  scanf("%d%d", &N, &D);
  
  ans = N/(2*D+1);
  if(N%(2*D+1) != 0)
    ans++;
  printf("%d", ans);
  
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
using namespace std;
int main(){
    string s;
    cin >> s;
    string t="",h="";
    t = t + s[0] + s[1];
    h = h + s[2] + s[3];
    if(("01"<=t&&t<="12")&&("01"<=h&&h<="12")){
        cout << "AMBIGUOUS" << endl;
    }else if(("00"<=t&&t<="99")&&("01"<=h&&h<="12")){
        cout << "YYMM" << endl;
    }else if(("01"<=t&&t<="12")&&("00"<=h&&h<="99")){
        cout << "MMYY" << endl;
    }else{
        cout << "NA" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const ll LL_INF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  int x[100005];

  REP(i,N) cin >> x[i];
  sort(x, x + N);
  int start_pos = N;
  REP(i,N){
    if(x[i] >= 0){
      start_pos = i;
      break;
    }
  }
  int ans = INF;
  
  for(int i = N - 1; i >= 0; i--){
    int posi_w = max(0, i - start_pos + 1);
    int nega_w = max(0, K - posi_w);
    if(start_pos - nega_w < 0) continue;
    int a = posi_w == 0 ? 0 : x[i];
    int b = nega_w == 0 ? 0 : - x[start_pos - nega_w];
    if(a > b) swap(a, b);
    ans = min(a * 2 + b, ans);
    cerr << i << ' ' << i - K + 1 << endl;
    cerr << a << ' ' << b << ' ' << ans << endl;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int INF = 1e9 + 5;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;;
  vector<int> a(n);
  vector<int> dp(n, INF);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  dp[0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j <= i + k; j++) {
      if (j < n) {
        dp[j] = min(dp[j], dp[i] + abs(a[i] - a[j]));
      }
    }
  }
  cout << dp[n - 1] << "\n";
  return 0; 
}


Measured memory_bytes: 3968
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int V[100001] = {};
int n, k;

void base(int n, int k, vector<int>& vM) {
	int a = k;
	while (k < n) {
		vM.push_back(k);
		k *= a;
	}
	vM.push_back(k);
}

int main()
{
	scanf("%d", &n);

	vector<int> vM;
	vM.reserve(20);
	base(n, 6, vM);
	base(n, 9, vM);
	vM.push_back(1);
	sort(vM.begin(), vM.end());

	int s = vM.size();
	for (int i = 1; i <= n; ++i) {
		int min = 100;
		for (int j = 0; j < s; ++j) {
			k = i - vM[j];
			if (k < 0) break;			
			if (min > V[k])
				min = V[k];
		}
		V[i] = ++min;
	}

	printf("%d", V[n]);
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#define rep(i,s,N) for(int i=s;i<N;i++)
using namespace std;

int main(void)
{
	int N; cin >> N;
	string S; cin >> S;
	int count = 0;
	rep(i, 0, N - 2) {
		if (S.substr(i, 3) == "ABC")count++;
	}
	cout << count << endl;

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <queue>
#include <vector>
 
int main() {
  int N;
  std::cin >> N;
  
  std::priority_queue<double, std::vector<double>, std::greater<double>> queue;
  
  double temp;
  for (int i=0; i<N; ++i) {
  	std::cin >> temp;
    queue.push(temp);
  }
  while (queue.size() >= 2) {
    auto lhs = queue.top(); queue.pop();
    auto rhs = queue.top(); queue.pop();
    queue.push((lhs+rhs) / 2.0d);
  }
  std::cout << queue.top() << std::endl;
}

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

using namespace std;

#define pii pair<int,int> 
#define F first 
#define S second
#define int long long 
#define mpr make_pair
typedef long long ll;

const int maxn = 2e5+10;
const int mod = 1e9+7;
const ll inf = 1e18+10;

int n, m, k;
int p[maxn];
vector<int> g[maxn];

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

   cin>> n;
   cout<< ((n*360)/(__gcd(n,360ll)))/ n;
}



Measured memory_bytes: 8304
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    ll a, b, x;
    cin >> a >> b >> x;
    
    ll nb = 1 + b / x;
    ll na = a <= 0 ? 0 : 1 + (a - 1) / x;
    put(nb - na)
    return 0;
}

Measured memory_bytes: 3584
using System;
using System.Collections.Generic;
using System.Linq;

namespace abc085a
{
    class Program
    {
        static void Main(string[] args)
        {
           
            string s = Console.ReadLine();
            var splitted = s.Split('/');
            splitted[0] = "2018";
            //出力
            Console.WriteLine(String.Join("/",splitted));
        }
    }
}


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

using namespace std;

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define FOR(i,m,n) for(int i=(m) ; i<(n) ; i++)
#define FORR(i,m,n) for(int i=(m) ; i>=(n) ; i--)

#define ALL(x) (x).begin(),(x).end()
int GCD(int a,int b){ return b ? GCD(b,a%b) : a ;} 

typedef long long ll;
typedef unsigned long long ull;

const int INF = 1e9;

int main(){
   int n;
   cin >> n;
   vector<int> t(n);
   rep(i,n)cin >> t[i];
   int m;
   cin >> m;
   vector<pair<int,int>> px(m);
   rep(i,m){
      int tp,tx;
      cin >> tp >> tx;
      px[i] = make_pair(tp,tx);
   }
   int sum = accumulate(ALL(t),0);
   for(int i=0;i<m;i++){
      int sumt = sum;
      sumt += px[i].second;
      sumt -= t[px[i].first-1];
      cout << sumt << endl;
   }
   return 0;
}

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

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

	int n;
	cin >> n;
	if (n >= 1 && n <= 999) {
		cout << "ABC" << endl;
	}
	else if (n >= 1000 && n <= 1998){
		cout << "ABD" << endl;
	}

	return 0;
}

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

int main(){
    long long x, y;
    cin >> x >> y;
    long double x_, y_;
    x_ = log2((long double)x);
    y_ = log2((long double)y);
    cout << floor(y_ - x_) + 1 << endl;
    return 0;
}



Measured memory_bytes: 256
MOD = 998244353
k, n = map(int, input().split())

facts = [1]
invs = [1]
pow2 = [1]
for i in range(1, n+k):
    f = i*facts[i-1]%MOD
    facts.append(f)
    invs.append(pow(f, MOD-2, MOD))
    pow2.append(2**i%MOD)

def nCk(n, k):
    return (facts[n]*invs[k]*invs[n-k])%MOD
def nHk(n, k):
    return nCk(n+k-1, n-1)

ans = []
for i in range(2, k+2):
    p = i//2
    ans_i = 0
    for q in range(min(p+1, n+1)):
        if k-i+q < 0:
            continue
        if i%2 > 0: # odd
            ans_i = ans[-1]
            break
            # ans_iq = pow2[q]*nCk(p, q)*nHk(k-(i-1)+q, n-q)%MOD
        else: # even
            ans_iq = 0
            if q > 0 and k-i+q > 0:
                ans_iq = (ans_iq+pow2[q-1]*nCk(p-1, q-1)*nHk(k-(i-1)+(q-1), n-q))%MOD
            if q < p:
                ans_iq = (ans_iq+pow2[q]*nCk(p-1, q)*nHk(k-(i-1)+q, n-q))%MOD
            # print(ans_iq)
        ans_i = (ans_i + ans_iq)%MOD
    ans.append(ans_i)

for a in ans+ans[-2::-1]:
    print(a)


Measured memory_bytes: 3736
n, k = map(int, input().split())

########関数部分##############
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)
############################
 
 
#####関数をつかってみる．#####
######今回は二進数に変換######
x2 = Base_10_to_n(n, k)
print( len(x2) )#"100011"が表示される．

Measured memory_bytes: 3060
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        k: u32,
        a: u32,
        b: u32
    }
    let mut res = false;
    for i in a..b+1 {
        if i % k == 0 {
            res = true;
            break;
        }
    }
    println!("{}", if res {"OK"} else {"NG"});
}


Measured memory_bytes: 2124
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
using namespace std;

int main (void) {
  int K, s;
  cin >> K >> s;
  int ans=0;
  for (int i=0; i<=K; i++) {
    for (int j=0; j<=K; j++) {
      if (s-K <=i+j && i+j <=s) ans= ans+1;
    }
  }
  cout << ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1e9+7
#define LINF (long long)4e18


int main(){
    int D,N;
    cin >> D >> N;
    int ans = 0;
    if(D == 0){
        if(N != 100){
            ans = N;
        }
        else ans = N+1;
    }
    else{
        int now = 1;
            rep(i,D){
                now *= 100;
            }
        if(N != 100){
            ans = now * N;
        }
        else{
            ans = now * (N+1);
        }

    }
    cout << ans << endl;
} 

Measured memory_bytes: 256
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=100;

int n;
int x[MAXN];

void run() {
	scanf("%d",&n); REP(i,n) scanf("%d",&x[i]);
	int sum=0; REP(i,n) sum+=x[i];
	int mn=INT_MAX; REP(i,n) if(x[i]%10!=0&&x[i]<mn) mn=x[i];
	if(sum%10!=0) printf("%d\n",sum); else if(mn!=INT_MAX) printf("%d",sum-mn); else printf("0\n");
}

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <chrono>
#include <vector>
#include <map>
#include <random>
#include <set>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <stdio.h>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <deque>
#include <cassert>
#include <stack>
using namespace std;
 
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ppb pop_back
#define ll long long
#define ull unsigned long long
#define cntbit(x) __builtin_popcount(x)
#define endl '\n'
#define uset unordered_set
#define umap unordered_map
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define ld long double
#define pll pair<long long, long long>

template <typename T> void Min(T &a, T b) {
    a = min(a, b);
}
 
template <typename T> void Max(T &a, T b) {
    a = max(a, b);
}

ostream &operator << (ostream &cout, vector <int> &a) {
	cout << "{";
	for (auto & it : a) cout << it << ", ";
	cout << "}";
	return cout;
}

ostream &operator << (ostream &cout, set <int> &a) {
	cout << "{";
	for (auto & it : a) cout << it << ", ";
	cout << "}";
	return cout;
}

inline bool lie(int l, int x, int r) {
	return l <= x && x <= r;
}

const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 4e3 + 15;
int n, m, a[N], c[N];

int pos[2][N];

int dp[N][N]; // i white and j black

int val[2][N][N];

// val[own_number >= x][number] - number of balls with own_number >= x with pos < number

main() {
	memset(dp, 0x3f, sizeof(dp));
	dp[0][0] = 0;
	ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);
	cin >> n;
	for(int i = 1; i <= 2 * n; ++i) {
		char ch;
		cin >> ch;
		int x;
		cin >> x;
		pos[ch == 'B'][x] = i;
		a[i] = x;
		c[i] = (ch == 'B');
	}
	// val[own_number >= x][number] - number of balls with own_number >= x with pos < number
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j < 2 * n; ++j)
			for(int t = 0; t < 2; ++t)
				val[t][i][j + 1] = val[t][i][j] + (a[j] >= i && c[j] == t);
	dp[0][0] = 0;
	for(int i = 0; i <= n; ++i) {
		for(int j = 0; j <= n; ++j) {
			Min(dp[i+1][j], dp[i][j] + val[0][i + 1][pos[0][i+1]] + val[1][j + 1][pos[0][i+1]]);
			Min(dp[i][j+1], dp[i][j] + val[0][i + 1][pos[1][j+1]] + val[1][j + 1][pos[1][j+1]]);
		}
	}
	cout << dp[n][n] << endl;
	return 0;
}

Measured memory_bytes: 131840
n = int(input())
pea = [[] for _ in range(n + 1)]
for _ in range(n - 1):
    u, v, w = map(int, input().split())
    w %= 2
    pea[u].append([v, w])
    pea[v].append([u, w])
ans = [-1] * (n + 1)
ans[1]=1
nodes=[1]
used=set()
used.add(1)
ansi=1
while nodes:
    nn=[]
    for i in nodes:
        ansi=ans[i]
        for u,w in pea[i]:
            if u in used:continue
            ans[u]=(ansi+w)%2
            used.add(u)
            nn+=[u]
    nodes=nn
for x in ans[1:]:
    print(x)

Measured memory_bytes: 47200
N, k = map(int, input().split())
string = input()

mojiretu_list = [0 for _ in range(N)]
for i in range(N):
    mojiretu_list[i] = string[i]

if mojiretu_list[k-1] == 'A':
    mojiretu_list[k-1] = 'a'

if mojiretu_list[k-1] == 'B':
    mojiretu_list[k-1] = 'b'

if mojiretu_list[k-1] == 'C':
    mojiretu_list[k-1] = 'c'

ans = ''
for i in range(N):
    ans += mojiretu_list[i]

print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
    int A,B,C,D,x,p,q;
    scanf("%d %d %d %d",&A,&B,&C,&D);
    p=B-A,q=D-C;
    if(A<C)
    {
        if(B<=C) x=0;
        else {if(B-C<q) x=B-C;
              else x=q;}
    }
    else if(A==C)
        {
            if(B<D) x=p;
            else x=q;
        }
    else {
        if(D<=A) x=0;
        else { if(D-A<p) x=D-A;
               else x=p;}
    }
    printf("%d",x);
    return 0;
}


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

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


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);

int main() {
    ll a, b, ans=0;
    cin >> a >> b;
    if(a == b) cout << a << endl;
    else {
        if((a%2) == 1) {
            ans ^= a;
            a++;
        }
        if((b%2) == 0) {
            ans ^= b;
            b--;
        }
        if(a > b) cout << ans << endl;
        else if(((b-a+1)/2)%2 == 0) {
            cout << ans << endl;
        }
        else {
            ans ^= 1;
            cout << ans << endl;
        }

    }
    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

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

ll inv(ll a) {
    return a_n(a, MOD-2);
}



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

int main(){
  int c = 0, n; cin>>n;
  // for(int i=1;i<=n;i++) if((int)log10(i)%2==0) c++;
  // for(int i=1;i<=n;i++) if(to_string(i).size()%2) c++;
  c = min(9,n)+min(900,max(0,n-99))+min(90000,max(0,n-9999));
  cout<< c <<endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 12 18:08:28 2020

@author: Kanaru Sato
"""

s = list(input())
N = len(s)

rf = 0
lf = 0
lis = []
i = 0

for i in range(N):
    if rf == 0 and s[i] == "R":
        if lf == 1:
            lf = 0
            lis.append(i-1)
        lis.append(i)
        rf = 1
    elif rf == 1 and s[i] == "R":
        if s[i+1] == "L":
            lis.append(i)
            rf = 0
        else:
            continue
    elif lf == 0 and s[i] == "L":
        if rf == 1:
            rf = 0
            lis.append(i-1)
        lis.append(i)
        lf = 1
    elif lf == 1 and s[i] == "L":
        if i == N-1:
            lis.append(i)
        else:
            if s[i+1] == "R":
                lis.append(i)
                lf = 0
            else:
                continue

if len(lis)%4 != 0:
    lis.append(lis[-1])

##print(lis)

n = 0
anslist = []
for cell in range(N):
    if cell > lis[4*n+3]:
        n += 1
    
    In = lis[4*n+0]
    Jn = lis[4*n+1]
    Kn = lis[4*n+2]
    Ln = lis[4*n+3]
    
    if cell < Jn:
        ans = 0
    elif cell == Jn:
        ans = (Ln-Jn)//2 + (Jn-In)//2 + 1
    elif cell == Kn:
        ans = (Ln-Kn)//2 + (Kn-In)//2 + 1
    else:
        ans = 0
    
    anslist.append(ans)

anslist = list(map(str, anslist))

print(" ".join(anslist))

Measured memory_bytes: 18896
class BinaryTree
  class Node
    attr_accessor :key, :left, :right, :parent

    def initialize(key)
      @key = key
      @left = nil
      @right = nil
      @parent = nil
    end

    def add_left(node)
      @left = node
      node.parent = self
    end

    def add_right(node)
      @right = node
      node.parent = self
    end

    def remove
      if (@parent.left != nil && @parent.left.key == @key) then
        @parent.left = nil
      elsif (@parent.right != nil && @parent.right.key == @key) then
        @parent.right = nil
      end
    end
  end

  attr_accessor :count

  def initialize
    @count = 0
    @root = nil
  end

  def insert(z)
    y = nil
    x = @root
    while x != nil do
      y = x
      if z.key < x.key then
        x = x.left
      else
        x = x.right
      end
    end
    
    if y == nil then
      @root = z
    elsif z.key < y.key
      y.add_left(z)
    else
      y.add_right(z)
    end
  end

  def find(z)
    x = @root
    while x != nil do
      if z == x.key then
        return x 
      elsif z < x.key then
        x = x.left
      elsif z > x.key then
        x = x.right
      end
    end
    return nil
  end

  def delete(z)
    children = [z.left, z.right].compact
    case children.size
    when 0 then
      z.remove
    when 1 then
      children[0].parent = z.parent
      if (z.parent.left != nil && z.parent.left.key == z.key) then
        z.parent.left = children[0]
      elsif (z.parent.right != nil && z.parent.right.key == z.key) then
        z.parent.right = children[0]
      end
      z.remove
    else
      next_node = get_next_inorder(z)
      z.key = next_node.key
      delete(next_node)
    end
  end

  def get_next_inorder(node)
    array_inorder = inorder
    next_node_key =  array_inorder[array_inorder.index(node.key)+1]
    return find(next_node_key)
  end

  def inorder
    node = @root
    array = []
    do_inorder(node, array) unless node == nil
    return array
  end

  def preorder
    node = @root
    array = []
    do_preorder(node, array) unless node == nil
    return array
  end

  def print
    print_inorder
    print_preorder
  end

  def print_inorder
    node = @root
    array = []
    do_inorder(node, array) unless node == nil
    puts " #{array.join(' ')}"
  end

  def print_preorder
    node = @root
    array = []
    do_preorder(node, array) unless node == nil
    puts " #{array.join(' ')}"
  end

  private

  def do_inorder(node, array)
    do_inorder(node.left, array) if node.left != nil
    array << node.key
    do_inorder(node.right, array) if node.right != nil
  end

  def do_preorder(node, array)
    array << node.key
    do_preorder(node.left, array) if node.left != nil
    do_preorder(node.right, array) if node.right != nil
  end
end


# main
tree = BinaryTree.new
n = gets.chomp.to_i
(n).times do
  command, key = gets.chomp.split
  if command == "insert" then
    tree.insert(BinaryTree::Node.new(key.to_i))
  elsif command == "find" then
    puts "#{tree.find(key.to_i) != nil ? 'yes' : 'no'}"
  elsif command == "delete" then
    tree.delete(tree.find(key.to_i))
  elsif command == "print" then
    tree.print
  end
end

Measured memory_bytes: 85616
import scala.io.StdIn.readLine

case class Dice(var d:Array[String]) {

  def rotate(dir:Char)  =
    dir match {
      case 'S' => Array(4,0,2,3,5,1)
      case 'N' => Array(1,5,2,3,0,4)
      case 'W' => Array(2,1,5,0,4,3)
      case 'E' => Array(3,1,0,5,4,2)
    }

  def roll(dirs:String) = d = dirs.foldLeft(Array(0,1,2,3,4,5)) { (x,y) => rotate(y).map(x) }.map(d)

  override def toString() = d(0)
}

object Main extends App {
  val faces = readLine.split(" ")
  val dice = Dice(faces)
  dice.roll(readLine)

  println(dice)
}

Measured memory_bytes: 44148
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

	public static void main(String[] args) {

        try {
            BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
            String inputData;
            inputData = reader.readLine();
			String[] strNumber = inputData.split(" ");
			int aa = Integer.parseInt(strNumber[0]);
			int bb = Integer.parseInt(strNumber[1]);
			int cc = Integer.parseInt(strNumber[2]);
			int count = 0;
			for(int i = aa ; i < bb + 1 ; i++){
				if(cc % i == 0){
					count++;
				}
			}

            System.out.println(count);

        } catch (IOException e) {
            e.printStackTrace();
        }


	}

}

Measured memory_bytes: 24212
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define reps(i, n) for (int i = 1; i <= (n); ++i)
#define repd(i, n) for (int i = (n)-1; i >= 0; --i)
#define repds(i, n) for (int i = (n); i > 0; --i)
#define loop(i, x, n) for (int i = (x); i < (n); ++i)
#define loops(i, x, n) for (int i = (x); i <= (n); ++i)
#define loopd(i, x, n) for (int i = (x); i > (n); --i)
#define loopds(i, x, n) for (int i = (x); i >= (n); --i)
#define itrep(i, a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i, a) for (auto i = rbegin(a); i != rend(a); ++i)
#define each(i, x) for (auto &&i : x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(a) ((int)a.size())
#define pow2(n) (n * n)
#define int ll
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
template <class T>
using p_queue = priority_queue<T, vector<T>, greater<T>>;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
constexpr double eps = 1e-8;
ll mod = static_cast<ll>(1e9 + 7);
template <class T, class... Args>
constexpr void mins(T &a, Args... args) { a = min<T>({a, args...}); }
template <class T, class... Args>
constexpr void maxs(T &a, Args... args) { a = max<T>({a, args...}); }
template <class F>
class FixPoint : private F {
public:
    explicit constexpr FixPoint(F &&f) : F(std::forward<F>(f)) {}
    template <class... Args>
    constexpr decltype(auto) operator()(Args &&... args) const { return F::operator()(*this, std::forward<Args>(args)...); }
};
template <class F>
constexpr decltype(auto) funcs(F &&f) { return FixPoint<F>{std::forward<F>(f)}; }
template <class T>
std::vector<T> vecs(int n, T &&val) { return std::vector<T>(std::forward<int>(n), std::forward<T>(val)); }
template <class... Args>
decltype(auto) vecs(int n, Args &&... args) { return std::vector<decltype(vecs(std::forward<Args>(args)...))>(std::forward<int>(n), vecs(std::forward<Args>(args)...)); }
template <class V, class T>
void fill(V &x, const T &val) { x = val; }
template <class V, class T>
void fill(vector<V> &vec, const T &val) {
    for (auto &&v : vec)
        fill(v, val);
}

void solve() {
    string s;
    cin >> s;

    s += 'S';
    auto n = sz(s);
    int ans = 0;
    int res = 0;
    rep(i, n) {
        if (s[i] == 'R')
            ++res;
        else
            res = 0;
        maxs(ans, res);
    }
    cout << ans << endl;
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout.flush();
    return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
int main(void)
{
		int n,i,h[101],k,j,t[101],w[101],flg;
	while(1) {
	flg=0;
		scanf("%d",&n);
		if(n==0)  break;
		for(i=0;i<n+1;i++) scanf("%d",&h[i]);
		for(i=0;i<n+1;i++){
			for(j=0;j<n;j++){
				if(j>=i) t[j]=h[j+1];
				else t[j]=h[j];
			}	
			for(j=0;j<n-1;j++){
				w[j]=t[j+1]-t[j];
			}
			for(j=0;j<n-2;j++){
				if(w[j]!=w[j+1]){
				flg=0;	break;
			}
			if(w[j]==w[j+1]) flg=1;
			}
			if(flg==1){
				k=h[i];
				i=110;
			}
		}	
		printf("%d\n",k);
	}	
		return 0;
}

Measured memory_bytes: 2660
//bismillahir rahmanir rahim            //Author:Fayed Anik

#include <bits/stdc++.h> 

using namespace std;


#define         ll                         long  long
#define         lf                         double 
#define         pb(x)                      push_back(x)
#define         ull                        unsigned long long
#define         sfl(a)                     scanf("%lld",&a)
#define         sf(a)                      scanf("%d",&a)
#define         pf(a)                      printf("%d\n",a)
#define         pfl(a)                     printf("%lld\n",a)
#define         pdl(a)                     printf("%llf\n",a)
#define         FOR(x,n)                   for(ll x=1;x<=n;++x)
#define         vii                        vector< ll > v
#define         pi                         3.14159265359
#define         mex                        10000000
#define         pii                        pair< ll , ll >
#define         mem(m,a)                   memset( m, a,sizeof m)
#define         mp(a,b)                    make_pair(a,b)
#define         maxn                       100000
#define         mod                        1000000007
#define         INF                        1e17
#define         f1                         first
#define         f2                         second
#define         all(v)                     v.begin(),v.end()
#define         PI                         acos(-1)
#define         printminusone              printf("-1\n")
#define         bug                        printf("bug")

vector <ll>pos,neg;
int main(){
	ll n,x;
	sfl(n);
	for(ll i=1;i<=n;i++){
		sfl(x);
		if(x<0) neg.pb(x);
		else pos.pb(x);
	}

	sort(all(neg));
	sort(all(pos));	
	ll sz=neg.size();
	ll ans=0;
	ll val=INF;
	if(sz&1){
		for(ll i=0;i<sz;i++){
			if(i<sz-1){
				ans += abs(neg[i]);
			}
			else{
				val=neg[i]*(-1);
			}
		}
	}

	else{
		for(ll i=0;i<sz;i++){
			ans += abs(neg[i]);
		}
	}

	if(val==INF){
		for(ll i=0;i<pos.size();i++){
			ans += pos[i];
		}

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

	sz=pos.size();

	if(sz){
		if(val>pos[0]){
			ans += val;
			ans -= pos[0];
			for(ll i=1;i<sz;i++){
				ans += pos[i];
			}
		}
		else{
			ans -= val;
			for(ll i=0;i<sz;i++){
				ans += pos[i];
			}
		}
	}
	else{
		ans -= val;
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 1656
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp mak_pair
#define pb push_back
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,x[200000];
	cin>>n;
	ll res=0;
	for(int i=0;i<n;i++)cin>>x[i];
	for(int i=1;i<n;i++){
		if(x[i]<x[i-1]){
			res+=(x[i-1]-x[i]);
			x[i]=x[i-1];
		}
	}
	cout<<res;
	return 0;
}

Measured memory_bytes: 4392
#include <stdio.h>

int main(){

  int n,i,j,k,b,f,r,v;
  int home[4][3][10]={0};

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d %d %d %d",&b,&f,&r,&v);
    home[b-1][f-1][r-1]+=v;
  }
    for(i=0;i<4;i++){
      for(j=0;j<3;j++){
        for(k=0;k<10;k++){
          printf(" %d",home[i][j][k]);
          if(k==9) printf("\n");
        }
      }
      if(i!=3) printf("####################\n");
    }
    return 0;
}


Measured memory_bytes: 612
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef long double D;
const ll mod=1e9+7;
const ll inf=(1ll<<62);
ll POW(ll x,ll y){
    if(y==0)return 1;
    if(y==1)return x;
    ll ans=POW(x,y/2)%mod;
    ans*=ans;
    ans%=mod;
    if(y%2)ans*=x;
    return ans%mod;
}
const int MX=3e5+9;
int n,a;
int main(){
    cin>>n>>a;
    n%=500;
    if(a>=n){puts("Yes");}
    else puts("No");
}


Measured memory_bytes: 256
n = gets.to_i
x = gets.to_s
x = x.split(" ").map(&:to_i)
sum = 0
ans = []
count = x.min
while count <= x.max
  x.each do |x|
    sum += (x - count) ** 2
  end
  ans << sum
  sum = 0
  count += 1
end

puts "#{ans.min}"


Measured memory_bytes: 1788
var s:string;
tot,nn:longint;
a:array[1..10]of integer;
b:array[1..10]of 0..1;
procedure dfs(n,x:longint);
var num,i:longint;
begin 
	if (n>=4) and (x<=nn) then 
	begin 
		{for i:=1 to n-1 do write(a[i]);
		writeln;}
		fillchar(b,sizeof(b),0);
		for i:=1 to n-1 do b[a[i]]:=1;
		if (b[3]=1) and (b[5]=1) and(b[7]=1) then inc(tot);
		
	end;
	if n>length(s) then exit;
		a[n]:=3;
		dfs(n+1,x*10+3);
		a[n]:=5;
		dfs(n+1,x*10+5);
		a[n]:=7;
		dfs(n+1,x*10+7);
end;
begin 
    readln(s);
	val(copy(s,1,length(s)),nn);
    fillchar(a,sizeof(a),0);
    tot:=0;
    dfs(1,0);
    write(tot);
end.

Measured memory_bytes: 128
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000001
using namespace std;

ll* uniformity,*partial;
ll N = 1;

void init(ll first_N){
	while(N < first_N)N *= 2;
}

void add_and_updateNodes(ll left,ll right,ll value,ll node_id,ll node_left,ll node_right){

	if(right < node_left || left > node_right)return;
	else if(left <= node_left && right >= node_right){
		uniformity[node_id] += value;
	}else{
		partial[node_id] += (min(right,node_right)-max(left,node_left)+1)*value;
		add_and_updateNodes(left,right,value,2*node_id+1,node_left,(node_left+node_right)/2);
		add_and_updateNodes(left,right,value,2*node_id+2,(node_left+node_right)/2+1,node_right);
	}
}

ll getSum(ll left,ll right,ll node_id,ll node_left,ll node_right){
	if(right < node_left || left > node_right)return 0;
	else if(left <= node_left && right >= node_right){
		return (node_right-node_left+1)*uniformity[node_id]+partial[node_id];

	}else{
		ll sum = (min(right,node_right)-max(left,node_left)+1)*uniformity[node_id];

		sum += getSum(left,right,2*node_id+1,node_left,(node_left+node_right)/2);
		sum += getSum(left,right,2*node_id+2,(node_left+node_right)/2+1,node_right);
		return sum;
	}
}

int main(){

	ll first_N,Q,command,left,right,value;
	scanf("%lld %lld",&first_N,&Q);

	init(first_N);

	uniformity = new ll[270000];
	partial = new ll[270000];

	for(ll i = 0; i <= 2*N-2; i++){
		uniformity[i] = 0;
		partial[i] = 0;
	}

	for(ll i = 0; i < Q; i++){
		scanf("%lld",&command);

		if(command == 0){
			scanf("%lld %lld %lld",&left,&right,&value);
			left--;
			right--;
			add_and_updateNodes(left,right,value,0,0,N-1);
		}else{
			scanf("%lld %lld",&left,&right);
			left--;
			right--;
			printf("%lld\n",getSum(left,right,0,0,N-1));
		}
	}

	return 0;
}

Measured memory_bytes: 6800
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  int n, k, x, y; cin >> n >> k >> x >> y;
  if(n <= k){
    cout << n*x << endl;
  }
  else cout << k*x+y*(n-k) << endl;
  system("pause");
}

Measured memory_bytes: 504
import java.util.*;
class Main 
{ 

	
	 
	public static void main(String args[]) 
	{ 
		Scanner s = new Scanner(System.in);
		char[] c = s.next().toCharArray();
		int one=0;
		for(int i=0;i<c.length;i++)
		{
			if(c[i]=='1')
			{
				one++;
			}
			else
			{
				one--;
			}
		}
		System.out.println(c.length-Math.abs(one));

		
		
		
	}
} 


Measured memory_bytes: 28196
def main():
    a = [int(input()) for _ in range(5)]
    a.sort(key=lambda x: x % 10)

    ans = 0
    picked = False  # 最後に据える候補を選択済み
    for x in a:
        if (not picked) and (x % 10 != 0):
            ans += x
            picked = True
        else:
            ans += (x + 9) // 10 * 10
    print(ans)


if __name__ == '__main__':
    main()

# 最後だけ一の位を切り上げずに済む
# 1 <- 10 ... 9得
# 2 <- 10 ... 8
# ...
# 9 <- 10 ... 1
# 0 <- 0  ... 0
# 下一桁が1,2,3,...,9,0で左に来る数を最後に据えればよい


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

typedef long long ll;
typedef vector<int> vi;            typedef vector<vi> vii;
typedef vector<ll> vl;             typedef vector<vl> vll;
typedef pair<int,int> pi;          typedef pair<pi,int> pii;
typedef pair<ll,ll> pl;            typedef pair<pl,ll> pll;
typedef pair<int,bool> pib;        typedef pair<ll,bool> plb;

#define F first
#define S second
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define in insert
#define er erase
//user-defined hash table for pairs --------------------------------------------------------------------------------------------------
struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
}; 

//returns (a^n mod p)---------------------------------------------------------------------------------------------------------------
ll power(ll a,ll n,ll p)
{
	if(n == 0)
	{
		return 1;
	}
	else if(n%2 == 0)
	{
		ll ans = power(a,n/2,p);
		return (ans*ans)%p;
	}
	else 
	{
		ll ans = power(a,n-1,p);
		return (ans*a)%p;
	}
}

//returns (a^-1 mod p)(if p is prime)----------------------------------------------------------------------------------------------
ll inverse(ll a,ll p)
{
   return power(a,p-2,p);
}
//----------------------------------------------------------------------------------------------------------------------------------


void solve()
{
   int a,b,c;
   cin>>a>>b>>c;
   int k;
   cin>>k;
   int cnt = 0;
   while(a >= b)
   {
   	  b *= 2;
   	  cnt++;
   }
   while(b >= c)
   {
   	  c *= 2;
   	  cnt++;
   }
   if(cnt > k)
   {
   	 cout<<"No"<<endl;
   }
   else
   {
   	  cout<<"Yes"<<endl;
   }
}


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef PAVANSAI006
    freopen("inp.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("err.txt", "w", stderr);
#endif
    ll t = 1;
    //cin>>t;
    while(t--)
    {
    	solve();
    }
    
}

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod (int)(1e9 +7);

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef string ss;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}

vll binary_convert(ll n){
    vll s;
    ll size = 0;

    while(n / (ll)(pow(2,size)) > 0)size++;
    rep(i,size + 1){
        s.pb(n / (ll)(pow(2,i)));
        n %= (ll)(pow(2,i));
    }

    return s;
}

ll fib(ll n){
    vll a(n+1);
    a[0] = 1;
    a[1]  = 1;

    REP(i,2,n+1){
        a[i] = a[i-1] + a[i-2];
        a[i] %= mod;
    }

    return a[n-1];
}

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

    vll tas(n);
    ll sum = 0,abm = M,mn;
    rep(i,n){
        tas[i] = l + i;
        sum += tas[i];

        if(abm > abs(tas[i])){
            abm = abs(tas[i]);
            mn = i;
        }

        //cout << tas[i] << " ";
    }

    //cout << endl;

    cout << sum - tas[mn] << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(20000)

n, k, l = map(int, input().split())
a = [list() for _ in range(n)]
b = [list() for _ in range(n)]
for _ in range(k):
    p, q = [int(x) - 1 for x in input().split()]
    a[p].append(q)
    a[q].append(p)
for _ in range(l):
    r, s = [int(x) - 1 for x in input().split()]
    b[r].append(s)
    b[s].append(r)

def g(a, b, i, k):
    b[i] = k
    for e in a[i]:
        if b[e] is not None: continue
        g(a, b, e, k)

def f(a, b):
    k = 0
    for i in range(n):
        if b[i] is not None: continue
        g(a, b, i, k)
        k += 1

c = [None] * n
f(a, c)
d = [None] * n
f(b, d)
e = {}
for i in range(n):
    k = (c[i], d[i])
    e[k] = e.get(k, 0) + 1

print(' '.join([str(e[(c[i], d[i])]) for i in range(n)]))


Measured memory_bytes: 130160
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<algorithm>
#include<cmath>

using namespace std;

int main(){

    int N;
    cin >> N;

    vector<int> tako(N);
    vector<int> heal(N*(N-1));

    for(int i=0; i<N; i++) cin >> tako.at(i);

    int index = 0;
    for(int i=0; i<N-1; i++){
        for(int j=i+1; j<N; j++){

            heal.at(index) = tako.at(i) * tako.at(j);
            index++;
        }
    }

    int ans = accumulate(heal.begin(), heal.end(), 0);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 504
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <memory>
#include <string>
#include <cstdlib>
#include <set>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
#include <cmath>
#include <map>
#include <iterator>
#include <climits>
#include <numeric>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <array>
#include <valarray>
#include <complex>
#include <random>
#include <functional>
#include <cassert>
#include <chrono>
#include <memory>

using namespace std;

#define int long long
//region TEMPLATE
////@formatter:off
#define double long double
typedef long long ll;
typedef unsigned long long ull;
template<typename T>void __read(T &a) { cin >> a; }
template<typename T, typename ... Args> void __read(T &a, Args &... args) { cin >> a;__read(args...);}
#define make(t, ...) t __VA_ARGS__; __read(__VA_ARGS__)
#define makev(a, n) VI a(n); FOR(n) cin >> a[i]
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FORIT(p) for(auto it = p.begin(); it != p.end(); it++)
#define FOR(b) for(signed i = 0; i <(b); i++)
#define FORE(i, l, r) for(int i = (l); i < (r); i++)
#define NFOR(i, n) for(int i = (((int) n)-1); i >= 0; i--)
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<pair<int, int>, int> PPII;
constexpr ll M7 = 1000000007ll;
constexpr ll M9 = 1000000009ll;
constexpr ll MFFT = 998244353ll;
template<class T> void outv(T &a) { for (auto &x : a) cout << x << ' '; }
static mt19937 rnd(static_cast<unsigned>(chrono::steady_clock::now().time_since_epoch().count())); // NOLINT(cert-err58-cpp)
auto __fast_io__ = (ios_base::sync_with_stdio(false), cin.tie(nullptr)); // NOLINT(cert-err58-cpp,cppcoreguidelines-interfaces-global-init)
////@formatter:on
//endregion



int32_t main() {
    make(int, n, m);
    VVI g(n);
    for(int i = 0; i < m; ++i){
        make(int, v, u);
        g[v - 1].push_back(u - 1);
    }
    VI dp(n, -1);
    function<void(int)> dfs = [&](int v){
        dp[v] = 0;
        for(auto& u : g[v]){
            if (dp[u] == -1){
                dfs(u);
            }
            dp[v] = max(dp[v], dp[u] + 1);
        }
    };
    for(int v = 0; v < n; ++v){
        if (dp[v] == -1){
            dfs(v);
        }
    }
    cout << *max_element(ALL(dp));

    return 0;
}

Measured memory_bytes: 9216
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int a,b,c;
    cin >> a >> b >> c;
    int sum = a + b + c;
    cout << sum - max({a,b,c}) << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<bool> primes(55555 + 1, true);
    primes[0] = primes[1] = false;
    for (int i = 2; i * i < primes.size(); ++i) {
        if (!primes[i]) continue;
        for (int j = i * 2; j < primes.size(); j += i) {
            primes[j] = false;
        }
    }
    vector<vector<int>> hist(5);
    for (int i = 0; i < primes.size(); ++i) {
        if (!primes[i]) continue;
        hist[i % 5].push_back(i);
    }
    for (auto &ps : hist) {
        if (n > ps.size()) continue;
        for (int i = 0; i < n; ++i) {
            cout << ps[i] << " ";
        }
        cout << endl;
        break;
    }
    return 0;
}


Measured memory_bytes: 256
#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())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

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

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

int main() {
    string S;
    cin >> S;

    if (S[2] == S[3] && S[4] == S[5]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256