akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
template<int MOD> struct ModInt {
    static const int Mod = MOD; unsigned x; ModInt() : x(0) { }
    ModInt(signed sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    ModInt(signed long long sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    int get() const { return (int)x; }
    ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }
    ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
    ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
    ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
    ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
    ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }
    ModInt inverse() const { long long a = x, b = MOD, u = 1, v = 0;
        while (b) { long long t = a / b; a -= t * b; std::swap(a, b); u -= t * v; std::swap(u, v); }
        return ModInt(u); }
    bool operator==(ModInt that) const { return x == that.x; }
    bool operator!=(ModInt that) const { return x != that.x; }
    ModInt operator-() const { ModInt t; t.x = x == 0 ? 0 : Mod - x; return t; }
};
template<int MOD> ostream& operator<<(ostream& st, const ModInt<MOD> a) { st << a.get(); return st; };
template<int MOD> ModInt<MOD> operator^(ModInt<MOD> a, unsigned long long k) {
    ModInt<MOD> r = 1; while (k) { if (k & 1) r *= a; a *= a; k >>= 1; } return r; }
typedef ModInt<1000000007> mint;
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, C[201010];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 0, N) cin >> C[i];
	sort(C, C + N, greater<int>());

	mint ans = 0;
	rep(i, 0, N) ans += mint(i + 2) * C[i];
	rep(i, 0, N - 1) ans *= 4;
	cout << ans << endl;
}







Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    int a[n];
    int multiple2 = 0;
    int multiple4 = 0;
    REP(i,n){
        cin >> a[i];
        if(a[i]%4 == 0)multiple4++;
        if(a[i]%2 == 0)multiple2++;
    }
    multiple2 -= multiple4;
    if(multiple4+multiple2/2 >= n/2)cout<< "Yes"<<endl;
    else cout << "No"<<endl;
    
    return 0;
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

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

using ll = long long;

using namespace std;

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

int main() {
  in(ll, n);
  vector<ll> x(n), y(n), p(n);
  rep(i, n) cin >> x[i] >> y[i] >> p[i];
  vector<ll> ans(n + 1, numeric_limits<ll>::max());
  function<void(int, int, vector<ll>)> rec = [&](int depth, int k,
                                                 vector<ll> dist) {
    if (depth == n) {
      ll S = 0;
      rep(i, n) S += p[i] * dist[i];
      Setmin(ans[k], S);
      return;
    }
    rec(depth + 1, k, dist);
    {
      // x
      vector<ll> ndist = dist;
      rep(i, n) Setmin(ndist[i], abs(x[i] - x[depth]));
      rec(depth + 1, k + 1, ndist);
    }
    {
      // y
      vector<ll> ndist = dist;
      rep(i, n) Setmin(ndist[i], abs(y[i] - y[depth]));
      rec(depth + 1, k + 1, ndist);
    }
  };
  vector<ll> dist(n);
  rep(i, n) dist[i] = min(abs(x[i]), abs(y[i]));
  rec(0, 0, dist);
  for (int k = 0; k <= n; ++k) {
    out(ans[k]);
  }
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
const int N=2005;
int n,m,tot,Stack[N],a[N][N],up[N][N],down[N][N];
char s[N][N];
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++)scanf("%s",s[i]+1);
	for (int i=1;i<n;i++)
		for (int j=1;j<m;j++){
			int cnt=0;
			cnt+=s[i][j]=='.';
			cnt+=s[i+1][j]=='.';
			cnt+=s[i][j+1]=='.';
			cnt+=s[i+1][j+1]=='.';
			if (cnt==0||cnt==2||cnt==4)a[i][j]=1;
			else a[i][j]=0;
		}
	int ans=max(n,m);
	n--;m--;
	for (int i=1;i<=n;i++)
		for (int j=m;j;j--)
			if (a[i][j])a[i][j]+=a[i][j+1];
	for (int j=1;j<=m;j++){
		Stack[tot=1]=0;
		for (int i=1;i<=n;i++){
			while (tot&&a[i][j]<=a[Stack[tot]][j])tot--;
			up[i][j]=Stack[tot];Stack[++tot]=i;
		}
	}
	for (int j=1;j<=m;j++){
		Stack[tot=1]=n+1;
		for (int i=n;i;i--){
			while (tot&&a[i][j]<=a[Stack[tot]][j])tot--;
			down[i][j]=Stack[tot];Stack[++tot]=i;
		}
	}
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++)
			if (a[i][j])ans=max(ans,(a[i][j]+1)*(down[i][j]-up[i][j]));
	printf("%d\n",ans);
}


Measured memory_bytes: 51200
import itertools

s = input()
n = len(s)
num_list = [num for num in range(n-1)]
total = int(s)
for i in range(1,n):
    temp_list = list(itertools.combinations(num_list, i))
    temp_len = len(temp_list)
    for j in range(temp_len):
        temp_sum = 0
        for k in range(i):
            if k == 0:
                part1 = 0
            part2 = list(temp_list[j])[k]
            s_part = s[part1:part2+1]
            temp_sum += int(s_part)
            part1 = part2 + 1
            if k == i-1:
                temp_sum += int(s[part1:])
        total += temp_sum
print(total)


Measured memory_bytes: 3064
#include<stdio.h>
int main(void){
    char c[10];
    int i,cnt=0,ans,minus;
    scanf("%s",c);
    for(i=0;i<4;i++){
        if(c[i]=='+'){
            cnt++;
        }
    }
    minus=4-cnt;
    printf("%d\n",cnt-minus);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char a[3];
	int cnt=0;
	cin >> a;

	vector<int> vec(3);
	for(int i=0;i<3;i++){
		if(a[i]=='R'){
			cnt++;
		}
	}

	if(cnt==2 && a[1]=='S'){
		cout<<1;
	}else{
		cout<<cnt;
	}
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod=1000000007;
const int INF=1001001001;

int main() {
  int64_t N,H;
  cin>>N>>H;
  vector<int64_t>a(N),b(N);
  for(int i=0;i<N;i++){
    cin>>a[i]>>b[i];
  }
  sort(b.rbegin(),b.rend());
  sort(a.rbegin(),a.rend());
  int64_t sum=H;
  int cnt=0;
  for(int i=0;i<N;i++){
    if(b[i]<a[0]){continue;}
    if(H-b[i]<=0){cnt++;H-=b[i];break;}
    else{cnt++;H-=b[i];}
  }
  if(H>0){cnt+=(H+a[0]-1)/a[0];}
  cout<<cnt<<endl;
  return 0;  
}

Measured memory_bytes: 4776
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  char x, y;
  cin >> x >> y;
  if (x > y) {
    cout << ">" << endl;
  } else if (x < y) {
    cout << "<" << endl;
  } else {
    cout << "=" << endl;
  }
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }

int main(){
    ll N,A,B,C; cin>>N>>A>>B>>C;
    string s[N];
    REP(i,N){
        cin >> s[i];
    } 
    string ans[N];
    bool ok = true;
    int x = A+B+C;
    if(x==0){ ok = false;}
    else if(x==2){
        REP(i,N){
            if(s[i]=="AB"){
                if(A+B==0){ ok = false; break;}
                if(A<B){ ++A; --B; ans[i]="A";}
                else if(A==B && i+1<N){
                    if(s[i+1]=="AC"){ ++A; --B; ans[i]="A";}
                    else{ ++B; --A; ans[i]="B";}
                }
                else { ++B; --A; ans[i] = "B";}
                
            }else if(s[i]=="AC"){
                if(A+C==0){ ok = false; break;}
                if(A<C){ ++A; --C; ans[i]="A";}
                else if(A==C && i+1<N){
                    if(s[i+1]=="AB"){ ++A; --C; ans[i]="A";}
                    else{ ++C; --A; ans[i]="C";}
                }
                else { ++C; --A; ans[i] = "C"; }
            }else{
                if(B+C==0){ ok = false; break;}
                if(B<C){ ++B; --C; ans[i] = "B";}
                else if(B==C && i+1<N){
                    if(s[i+1]=="AB"){ ++B; --C; ans[i]="B";}
                    else{ ++C; --B; ans[i]="C";}
                }
                else { ++C; --B; ans[i] = "C";}
            }
        }
    } else{
        REP(i,N){
            if(s[i]=="AB"){
                if(A+B==0){ ok = false; break;}
                if(A<B){ ++A; --B; ans[i]="A";}
                else{ ++B; --A; ans[i] = "B";}
            }else if(s[i]=="AC"){
                if(A+C==0){ ok = false; break;}
                if(A<C){ ++A; --C; ans[i]="A";}
                else{ ++C; --A; ans[i] = "C"; }
            }else{
                if(B+C==0){ ok = false; break;}
                if(B<C){ ++B; --C; ans[i] = "B";}
                else{ ++C; --B; ans[i] = "C";}
            }
        }
    }
    if(ok){
        cout << Liny;
        REP(i,N){
            cout << ans[i] << "\n";
        }
    }else{
        cout << Linn;
    }
}

Measured memory_bytes: 9860
#include <bits/stdc++.h>
using namespace std;
using Vi = vector<unsigned>;
using VVi = vector<Vi>;
#define rep(i, ns, ne) for (unsigned i = ns; i < ne; ++i)

unsigned N, M, X;
VVi v;
Vi p;

void input() {
  cin >> N >> M >> X;
  v.resize(N, (Vi(M)));
  p.resize(N);
  rep(i, 0, N) {
    cin >> p[i];
    rep(j, 0, M) { cin >> v[i][j]; }
  }
}
void solve() {
  // bit 全探索

  int ans = 1e9;
  for (int bit = 0; bit < (1 << N); ++bit) {
    int sum = 0;
    Vi t(M, 0);
    rep(i, 0, N) {
      if (bit & (1 << i)) {
        sum += p[i];
        rep(j, 0, M) { t[j] += v[i][j]; }
      }
    }
    // 判定
    bool ok = true;
    rep(i, 0, M) if (t[i] < X) ok = false;
    // 最小値更新
    if (ok) ans = min(ans, sum);
  }
  if (ans == 1e9) ans = -1;
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  input();
  solve();
  getchar();
  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

vector<long long> divisor(long long n) {
  vector<long long> res;
  for (long long i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res.push_back(i);
      if (n / i != i) res.push_back(n / i);
    }
  }
  sort(res.begin(), res.end());
  return res;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  auto div = divisor(n);
  ll num = div[div.size()/2], ans = 0;
  while (num) {
    num /= 10;
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	int N;
	cin >> N;

	ll L[100];
	rep(i, N) cin >> L[i];

	int kotae = 0;
	rep(i, N) rep(j, i) rep(k, j) {
		if (L[i] != L[j] && L[j] != L[k] && L[k] != L[i]) {
			ll kei = L[i] + L[j] + L[k];
			ll saidai = max(max(L[i], L[j]), L[k]);
			ll sonota = kei - saidai;

			if (sonota > saidai) kotae++;
		}
	}

	co(kotae);



	Would you please return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define _GLIBCXX_DEBUG
#define V vector<ll>
using namespace std;
using ll = long long;


int main(){
    int d,n;
    cin>>d>>n;
    if(d==0){
        if(n==100)cout<<101<<endl;
        else cout<<n<<endl;
    }
    if(d==1){
        if(n==100)cout<<10100<<endl;
        else cout<<n*100<<endl;
    }
    if(d==2){
        if(n==100)cout<<1010000<<endl;
        else cout<<n*10000<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long A[1001],B[1001],C[1001];
int main(void){
	int X,Y,Z,K;
	cin >> X >> Y >> Z >> K;
	for(int i=0;i<X;i++)cin >>A[i];
	for(int i=0;i<Y;i++)cin >>B[i];
	for(int i=0;i<Z;i++)cin >>C[i];
	vector<long long> v,w;
	for(int i=0;i<X;i++){
		for(int j=0;j<Y;j++){
			v.push_back(A[i]+B[j]);
		}
	}
	sort(v.begin(),v.end(),greater<>());
	for(int i=0;i<min(3000,X*Y);i++){
		for(int j=0;j<Z;j++){
			w.push_back(v[i]+C[j]);
		}
	}
	sort(w.rbegin(),w.rend());
	for(int i=0;i<K;i++)cout << w[i] << endl;
}
	

Measured memory_bytes: 43236
#include <stdio.h>
int main(void)
{
	int a,b;
        int d,r;
	double f;
	
	scanf("%d",&a);
	scanf("%d",&b);
	
	d = a/b;
	r = a%b;
	f = (double)a/b;
	
	printf("%d %d %lf",d,r,f);
	
	return 0;
}

Measured memory_bytes: 636
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<map>
#include<algorithm>
#include<string>
#include<cmath>

using namespace std;

int gcd(int a, int b) {
	if(a>b)swap(a,b);
	int c;
	while (a != 0) {
		c = a;
		a = b % a;
		b = c;
	}
	return b;
}

bool isPrime(int n){
	for(int i=2;i<=sqrt(n);i++){
		if(n%i==0)return false;
	}
	return true;
}

int main(void){
	int n;cin >> n;
	int cnt=0;
	for(int i=0;i<n;i++){
		int a;cin >> a;
		if(isPrime(a))cnt++;
	}
	cout <<cnt << endl;
	return 0;
}

Measured memory_bytes: 1160
import java.util.*;

class Main {
	Scanner sc;

	Main() {
		sc = new Scanner(System.in);
	}
	
	void calc() {
		int A = sc.nextInt();
		int B = sc.nextInt();
		if (A > 9 || B > 9) System.out.println(-1);
		else System.out.println(A*B);
	}

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

Measured memory_bytes: 21716
#[allow(dead_code)]
fn rd() -> String {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).unwrap();
    input.trim().to_owned()
}

/// 1行の文字を空白で分割してVec<T>にする。
#[allow(dead_code)]
fn rd_vec<T : std::str::FromStr>() -> Vec<T> {
    rd().split_whitespace().map(|x| x.parse().ok().unwrap()).collect()
}

/// 1つの要素を入力で受け取る
#[allow(dead_code)]
fn rd_one<T : std::str::FromStr>() -> T {
    rd().parse().ok().unwrap()
}

/// 複数回read_splitを行う
#[allow(dead_code)]
fn rd_vec_mul<T : std::str::FromStr>(count : i64) -> Vec<Vec<T>> {
    (0..count).map(|_| rd_vec()).collect()
}

/// Vecを1列で出力する
#[allow(dead_code)]
fn op_vec<T : std::fmt::Display>(item : Vec<T>, splitter : char) {
    let cnt = item.len();
    let mut c = 0;
    for i in item.iter() {
        c+=1;
        if cnt > c {print!("{}{}", i, splitter);} else {println!("{}", i);}
    }
}



/// dfs 深さ優先探索
/// point : 探索中の深さ
/// a : aに想定されている長さ
/// b : bに想定されている長さ
/// c : cに想定されている長さ
/// aに採用、bに採用、cに採用、いずれにも採用しないの4つのパターンを8つの竹にすべてに試す
/// 竹の数は深さとなる
fn dfs(point : usize, a : i64, b : i64, c : i64, finpoint : usize, ln_vec : &Vec<i64>, clofn : &Fn(i64, i64, i64) -> i64) -> i64 {
    if point == finpoint {
        return clofn(a, b, c);
    }

    let mut answer : i64 = std::i64::MAX;

    answer = std::cmp::min(answer, dfs(point + 1, a, b, c, finpoint, ln_vec, clofn));

    answer = std::cmp::min(answer, dfs(point + 1, a + ln_vec[point], b, c, finpoint, ln_vec, clofn) + if a == 0 {0} else {10});
    answer = std::cmp::min(answer, dfs(point + 1, a, b + ln_vec[point], c, finpoint, ln_vec, clofn) + if b == 0 {0} else {10});
    answer = std::cmp::min(answer, dfs(point + 1, a, b, c + ln_vec[point], finpoint, ln_vec, clofn) + if c == 0 {0} else {10});

    answer
}

fn main() {
    let input : Vec<i64> = rd_vec();
    let n = input[0] as usize;
    let (la, lb, lc) = (input[1], input[2], input[3]);
    let mut ln : Vec<i64> = rd_vec();
    for _ in 1..n {
        ln.push(rd_one());
    }
    println!("{}", dfs(0, 0, 0, 0, n, &ln, 
        &|a, b, c| 
        if a == 0 || b == 0 || c == 0 {std::i64::MAX - (n * 10) as i64} 
        else {(la - a).abs() + (lb - b).abs() + (lc - c).abs()}));
}


Measured memory_bytes: 4476
# include <bits/stdc++.h>
#define INF 1e9
using namespace std;

int main(){

  int N; cin >> N;
  int ans;
  for(int i=1; i < N+1; i++){
    string s;
    s = to_string(i);
    if(s.size() % 2 == 1){
      ans++;
    }
  }
  cout << ans << endl;

}


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

int main(){
    int n;cin>>n;double sum=0.0;
    for(int i=0;i<n;i++){
        int a;cin>>a;
        double b=pow(a,-1);
        sum+=b;
    }
    double ans=pow(sum,-1);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {


	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		double debt = 100000/1000;
		
		for(int i = 0; i < n; i++) {
			debt = Math.ceil(debt * 1.05);
		}
		
		int result = (int) (debt * 1000);
		System.out.println(result);
	}

}

Measured memory_bytes: 17156
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;
 
int main() {
  ll n,t;
  cin >> n >> t;
  vector<pll> s(n);
  for(ll i=0;i<n;i++) {
    ll a,b;
    cin >> a >> b;
    s[i]=pll(a,b);
  }
  sort(s.begin(),s.end());
  mat dp(n+1,vec(6001));
  for(ll i=0;i<n;i++) {
    for(ll j=0;j<t;j++) {
      dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
      if(j+s[i].first<t) {
        dp[i+1][j+s[i].first]=max(dp[i+1][j+s[i].first],dp[i][j]+s[i].second);
      }
      else {
        dp[n][j+s[i].first]=max(dp[n][j+s[i].first],dp[i][j]+s[i].second);
      }
    }
  }
  ll ans=0;
  for(ll i=0;i<dp[n].size();i++) {
    ans=max(ans,dp[n][i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 141184
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import bisect

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))

N,K,Q = LI()
A = [0 for i in range(Q)]
for i in range(Q):
    A[i] = int(input()) - 1

cnt = {}

for i in range(N):
    cnt[i] = 0

for a in A:
    cnt[a] += 1

for i in range(N):
    if K - Q + cnt[i] > 0:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 21456
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;

int main(){
    ll n; cin >> n;
    ll sum = 0, unit = 0;
    reps(i,n)unit += i;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
        sum += a[i];
    }
    a.emplace_back(a[0]);
    bool ok = true;
    if(sum % unit != 0)ok = false;
    ll num = sum / unit;
    ll num_sum = 0;
    reps(i,n){
        ll dis = a[i] - a[i-1];
        if((num - dis) % n != 0)ok = false;
        if(num - dis < 0) ok = false;
        num_sum += (num - dis) / n;
    }
    ok &= (num_sum == num);
    cout << (ok ? "YES" : "NO") << endl;
}

Measured memory_bytes: 1792
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author lstd
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <bitset>
#include <random>
#include <chrono>
#include <complex>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <ctime>

using namespace std;

#define sqr(x) ((x)*(x))
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define RE(i, n) FOR(i,1,n)
#define REP(i,n) FOR(i, 0, (int)(n)-1)
#define fst first
#define snd second

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

string to_string(string s) {
    return '"' + s + '"';
}

string to_string(const char* s) {
    return to_string((string) s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}



void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

int XMOV[4] = {0, 0, 1, -1};
int YMOV[4] = {1, -1, 0, 0};

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

using namespace std;

class BOneClue {
public:
	void solve(std::istream& in, std::ostream& out) {
		int k, x;
		in >> k >> x;

		for (int i = k-1; i >= 0; i--){
		    if (x-i >= -1000000)
			out << x-i << " ";
		}
//		out << x << " ";
		for (int i = 1; i <= k-1; i++){
			if (x+i <= 1000000)
			 out << x+i << " ";
		}

	}
};

int main() {
	BOneClue solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

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

template <class T>
inline void read(T &x) {
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar()) f ^= c == '-';
    for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x) {
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    T y = 1;
	int len = 1;
    for (; y <= x / 10; y *= 10) ++len;
    for (; len; --len, x %= y, y /= 10) putchar(x / y + 48);
}

int n, m, bit;

inline void printEdge(int u, int v) {
	write(u);
	putchar(' ');
	write(v);
	putchar('\n');
}

int main() {
	read(n);
	for (int i = 0; (1 << i) <= n; ++i)
		if (n == (1 << i)) {
			puts("No");
			return 0;
		}
	puts("Yes");
	printEdge(1, 2), printEdge(2, 3), printEdge(3, n + 1);
	printEdge(n + 1, n + 2), printEdge(n + 2, n + 3);
	for (int i = 4; i < n; i += 2) {
		printEdge(1, i), printEdge(i, i + 1);
		printEdge(1, i + n + 1), printEdge(i + n + 1, i + n);
	}
	if (!(n & 1)) {
		for (int i = 0; (1 << i) <= n; ++i)
			if (n & (1 << i)) bit = i;
		printEdge(((1 << bit) ^ 1) + n, n), printEdge(n ^ (1 << bit), n << 1);
	}
	return 0;
}

Measured memory_bytes: 2304
/*  ***  In The Name of God ... ***  */
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define bug() cout << "BUG" << endl ;
#define X first
#define Y second
#define per(how) cout << fixed << setprecision(how)
#define bit(a , b) (a >> b) & 1
#define all(v) v.begin() , v.end()
#define LB(x) (x & -x)
typedef long long ll;
typedef long double ld;
const ll INF = 1e18 , MOD = 1e9 + 7 , SQRT = 350 ;
inline void smin(ll &x , ll y) { x = min(x , y) ; }
inline void smax(ll &x , ll y) { x = max(x , y) ; }

ll n;
string s , t;
ll res = 0;

int main ()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> s >> t;
	for(ll i = 0 ; i <= n ; i++)
	{
		bool fl = 1;
		for(ll j = i ; j < n ; ++j)		if(s[j] != t[j - i])	fl = 0;
		if(fl)	return cout << n + i << '\n' , 0;
	}
	cout << '\n';
	return 0;
}



Measured memory_bytes: 256
MOD = 10 ** 9 + 7

def fact(n)
  @memo ||= []
  @memo[n] ||= (n==0) ? 1 : (n * fact(n-1)) % MOD;
end

def modpow(x,n)
  ret = 1
  while n > 0
    ret = (ret * x) % MOD if n&1 == 1
    x = (x*x) % MOD
    n >>= 1
  end
  return ret
end

def combin(n,k)
  return (((fact(n) * modpow(fact(n-k),MOD-2)) % MOD) * modpow(fact(k),MOD-2)) % MOD
end

n,m = gets.split.map(&:to_i)

n.times do |i|
  fact(i)
end

exp = []
2.upto((m**0.5).to_i) do |i|
  e = 0
  while m % i == 0
    e += 1
    m /= i
  end
  exp << e
end
exp << 1 if m != 1

ans = 1
exp.each do |k|
  ans = (ans * combin(n+k-1,k)) % MOD
end
p ans

Measured memory_bytes: 2884
n = int(input())
f = [list(map(int, input().split())) for i in range(n)]
p = [list(map(int, input().split())) for i in range(n)]

ans = - 10**10
for i in range(1, 1<<10):
    tmp_ans = 0
    for j in range(n):
        c = 0
        for k in range(10):
            if f[j][k] == 1 and (i >> k) & 1 == 1:
                c += 1
        tmp_ans += p[j][c]
    ans = max(ans, tmp_ans)

print(ans)


Measured memory_bytes: 3064
s=input()
t=input()
ans=len(t)
for i in range(len(s)-len(t)+1):
	p=s[i:i+len(t)]
	cur = 0
	for j in range(len(t)):
		if t[j] != p[j]:
			cur += 1
	ans=min(ans,cur)
print(ans)


Measured memory_bytes: 9044
from collections import defaultdict as dd
from collections import deque
import bisect
import heapq

def ri():
    return int(input())

def rl():
    return list(map(int, input().split()))


def solve():
    n = ri()
    neg_dm = []
    pos_dm = []
    for i in range(n):
        S = input()
        depth = 0
        max_depth = 0
        for c in S:
            if c == '(':
                depth -= 1
            else:
                depth += 1
                max_depth = max(max_depth, depth)
        if depth < 0:
            neg_dm.append([max_depth, depth])
        else:
            pos_dm.append([max_depth, depth])

    neg_dm.sort()
    pos_dm.sort(key = lambda x : [x[1]-x[0], -x[0]])

    # print (neg_dm)
    # print (pos_dm)
    curr_depth = 0
    for m, d in neg_dm:
        if m > -curr_depth:
            print ("No")
            return
        curr_depth += d

    for m, d in pos_dm:
        if m > -curr_depth:
            print ("No")
            return
        curr_depth += d

    if curr_depth == 0:
        print ("Yes")
    else:
        print ("No")


mode = 's'

if mode == 'T':
    t = ri()
    for i in range(t):
        solve()
else:
    solve()


Measured memory_bytes: 233120
//Thanks for your anserws!!
#include<stdio.h>
#include<stdlib.h>

int compare(const void *a, const void *b){
	return *(int *)a - *(int *)b;
}

int main(void){
  int N, M, *X, *difference;
  int i, j, k, answer = 0;

  scanf("%d %d", &N, &M);
  
  if(N >= M){
    printf("0\n");
    return 0;
  }
  
  X = (int *)malloc(M * sizeof(int));
  difference = (int *)malloc(M * sizeof(int));
  
  for(i = 0; i < M; i++){
    scanf("%d", &X[i]);
  }
  
  qsort(X, M, sizeof(int), compare);
  
  for(j = 0; j < M -1; j++){
	difference[j] = X[j + 1] - X[j];
  }
  
  qsort(difference, M-1, sizeof(int), compare);
  
  for(k = 0; k < M - N; k++){
  	answer = answer + difference[k];
  }

  printf("%d\n", answer);
  
  free(X);
  free(difference);
  return 0;
}

Measured memory_bytes: 1396
#include<stdio.h>
#include<string.h>

int main() 
{
	char c[] = { " ',-.?ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?" };
	char w[][9] = {
		"101"     ,
		"000000"  ,
		"000011"  ,
		"10010001",
		"010001"  ,
		"000001"  ,
		"100101"  ,
		"10011010",
		"0101"    ,
		"0001"    ,
		"110"     ,
		"01001"   ,
		"10011011",
		"010000"  ,
		"0111"    ,
		"10011000",
		"0110"    ,
		"00100"   ,
		"10011001",
		"10011110",
		"00101"   ,
		"111"     ,
		"10011111",
		"1000"    ,
		"00110"   ,
		"00111"   ,
		"10011100",
		"10011101",
		"000010"  ,
		"10010010",
		"10010011",
		"10010000"
	};
	char n[102];
	int i, j;

	while (fgets(n, 101, stdin) != NULL) 
	{
		char s[920] = { 0 };
		for (i = 0; n[i + 1]; i++) 
		{
			for (j = 0; n[i] != c[j]; j++)
			{
				;
			}
			strcat(s, w[j]);
		}
		//printf("%s\n",s);
		for (i = j = 0; s[i]; i++) 
		{
			j *= 2;
			if (s[i] == '1')
			{
				j++;
			}
			if (i % 5 == 4) 
			{
				printf("%c", c[j + 6]);
				j = 0;
			}
		}
		if (i % 5) 
		{
			for (; i % 5 != 0; i++)
			{
				j *= 2;
			}
			printf("%c", c[j + 6]);
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<ll, ll> P;
const ll INF = (1LL<<58);


int main() {
    ll X, D;
    cin>>X>>K>>D;
    if(abs(X) / D >= K){
        cout<<abs(X) - K * D<<endl;
    }else{
        ll num = abs(X) / D;
        cout<<((K - num)&1 ? (num + 1) * D - abs(X) : abs(X) - num * D)<<endl;
    }
}

Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main() {
    string input;
    int flag = 1;
    cin >> input;

    for(int i=0; i < input.size() - 1; i++){
        for(int j = i + 1; j < input.size(); j++){
            if(input[i] == input[j]){
                flag = 0;
            }
        }
    }

    if(flag){
        cout << "yes" << endl;
    }
    else{
        cout << "no" << endl;
    }



    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int  n;
  cin>>n;
  int d=n/2*2;
  vector<pair<int ,int>> vp;
  for(int  i=1;i<=n;i++)
  {for(int j=i+1;j<=n;j++)
    {
    if(i+j==d+1)continue;
    vp.push_back(make_pair(i,j));
    
    }}
  cout<<(int) vp.size()<<'\n';
  for(auto e:vp)
    cout<<e.first<<" "<<e.second<<'\n';
  return 0;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

void judge(int N) {
    if (N % 10 == 2 || N % 10 == 4 || N % 10 == 5 || N % 10 == 7 || N % 10 == 9)
    {
        cout << "hon" << endl;
    }
    else if (N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8)
    {
        cout << "pon" << endl;
    }
    else
    {
        cout << "bon" << endl;
    }
}

int main() {
    int N;
    cin >> N;
    judge(N);
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
deque <char> q;
char c;
string sa;
int n,f,t,rev;
int main()
{
	cin>>sa>>n;
	for(int i=sa.size()-1;i>=0;i--)
		q.push_front(sa[i]);
	for(int i=0;i<n;i++)
	{
		cin>>t;
		if(t==1)
			rev=(rev+1)%2;
		else
		{
			cin>>f>>c;
			if((f+rev)%2)
				q.push_front(c);
			else
				q.push_back(c);
		}
	}
	while(!q.empty())
	{
		char p;
		if(rev)
		{
			p=q.back();
			q.pop_back();
		}
		else
		{
			p=q.front();
			q.pop_front();
		}
		cout<<p;
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <string.h>
#include <stdlib.h>

using namespace std;
// vector push_back push front top empty pop make_pair long long insert begin end  
typedef long long ll;
typedef vector<int> vi;
typedef vector<pair <int,int> > vpi;
typedef vector<long long> vll;
typedef pair<int,int> pi;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define B begin()
#define RB rbegin()
#define E end()
#define RE rend()
#define Z size()
#define REP(i,a,b) for (int i = a; i < b; i++)
#define L length()
#define show(a) cerr << " *** " << a << endl;
#define show1(a) cerr << " /// " << a << endl;
#define valid(a,b,c) (a >= b && a < c ? 1 : 0)
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int mod = (int)1e9 + 7;
ll gcd(ll a, ll b) {return (b==0? a:gcd(b,a%b));}
ll egcd(ll a, ll b, ll & x, ll & y) {if (a == 0){x = 0;y = 1;return b;}ll x1, y1;ll d = egcd(b % a, a, x1, y1);x = y1 - (b / a) * x1;y = x1;return d;}
ll mbinp(ll a, ll b){a %= mod;if (b == 0)return 1;ll ans = mbinp(a, b/2);ll tmp = (ans * ans) % mod;if (b % 2)return ((tmp * a) % mod);return ((tmp) % mod);}
ll binp(ll a, ll b){if (b == 0)return 1;ll ans = binp(a, b/2);ll tmp = (ans * ans);if (b % 2)return ((tmp * a));return ((tmp));}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,k;
	cin >> n >> k;
	vi all(n);
	REP(i,0,n)
		cin >> all[i];
	vi rer(k+1,0);
	REP(i,0,k+1)
	{
		REP(j,0,n)
		{
			if (valid(i-all[j],0,k) && rer[i-all[j]] == 0)
				rer[i] = 1;
		}
	}	
	cout << (rer[k] == 1 ? "First"  : "Second");
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int X,N;
  cin>>X>>N;
  vector<int> p(N);
for (int i = 0; i < N; i++) {
  cin >> p.at(i);
}
  int sw=200;
  int sw1;
  int sw2=0;
  int sw3=X;
  for(int i=0;i<102;i++){
    if(X-i<0){
      sw1=i-X;
    }else{
      sw1=X-i;
    }
    
    if(sw1<sw){
      for(int j=0;j<N;j++){
        if(p.at(j)==i){
          sw2=1;
        }
      }
      if(sw2==0){
        sw3=i;
        sw=sw1;
      }
      sw2=0;
    }
  }
  
  cout<<sw3<<endl;
}




Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF 2147483647//int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
    string s;
    cin >> s;
    int n = s.length();
    if(n == 1 || n%2 == 1){cout << "No" << endl;return 0;}
    rep(i,n-1){
        if(s[i] != 'h' || s[i+1] != 'i'){
            cout << "No" << endl;
            return 0;
        }
        i++;//2トビ
    }
    cout << "Yes" << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  vector<string> omoji;
  omoji = {"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"};
  vector<string> komoji;
  komoji = {"a","b","c","d","e","f","g","h","i","j","K","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
  for (int i = 0;i < 26;i++) {
    if (s == omoji.at(i)){
      cout << "A" << endl;
    }
    else if (s == komoji.at(i)){
      cout << "a" << endl;
    }
  }
} 

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e3;

int main(){
	int n;
	cin>>n;
	if(n<1200){
		cout<<"ABC"<<endl;
		return 0;
	}else if(n<2800){
		cout<<"ARC"<<endl;
		return 0;
	}else{
		cout<<"AGC"<<endl;
	}
	
	
	return 0;
}


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

int main(){
  int A,B,C,D;
  cin>>A>>B>>C>>D;

  int a,b,c,d;
  if(A<=C){
    a=A;
    b=B;
    c=C;
    d=D;
  }
  else{
    a=C;
    b=D;
    c=A;
    d=B;
  }

  int ans;
  if(b<=c){
    ans=0;
  }
  else if(b<=d){
    ans=b-c;
  }
  else{
    ans=d-c;
  }

  cout<<ans<<endl;

}


Measured memory_bytes: 256
N = int(input())
list_a = list(map(int, input().split()))
list_b = list(map(int, input().split()))
list_c = list(map(int, input().split()))

ans = sum(list_b)

for i in range(N-1):
    if(list_a[i+1] == list_a[i]+1 ):
        ans = ans + list_c[list_a[i]-1]

print(ans)

Measured memory_bytes: 3064
n,x=map(int,input().split())
A=list(map(int,input().split()))

A.sort()
ans=0
for i,a in enumerate(A):
  if i==n-1 and x-a>0:
    break
  elif x-a<0:
    break
  x-=a
  ans+=1
print(ans)

Measured memory_bytes: 3060
def main():
    N = int(input())
    *A, = map(int, input().split())

    money = 1000

    low = A[0]
    p = A[0]
    for x in A:
        if p > x:
            money += (p - low) * (money // low)
            low = x
        p = x

    money += max(0, p - low) * (money // low)

    print(money)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9180
dice = list(input().split(' '))
a = list(input())
for i in a:
    if i == 'W':
        dice = [dice[2],dice[1],dice[5],dice[0],dice[4],dice[3]]
    elif i == 'S':
        dice = [dice[4],dice[0],dice[2],dice[3],dice[5],dice[1]]
    elif i == 'N':
        dice = [dice[1],dice[5],dice[2],dice[3],dice[0],dice[4]]
    elif i == 'E':
        dice = [dice[3],dice[1],dice[0],dice[5],dice[4],dice[2]]
print(dice[0])


Measured memory_bytes: 5564
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;

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

int main(){
    long long int n,f=0;
    cin>>n;
    vector<long long int>a(10000);

    for(long long int i=0;i<=1000;i++){
        for(long long int j=0;j<=1000;j++){
            if(i*i*i*i*i-j*j*j*j*j==n){
                cout<<i<<" "<<j<<endl;
                f=1;
                break;
            }
            else if(i*i*i*i*i+j*j*j*j*j==n){
                cout<<i<<" "<<-j<<endl;
                f=1;
                break;
            }
            
        }
        if(f==1){
            break;
        }
    }

    return 0;
}

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

int main(){
  int a, b, c, n=0;
  cin >> a >> b >> c;

  for (int x = a; x<=b; x++){
    if( c % x == 0){
      n += 1;
    }
  }

  cout << n << endl;

  return 0;
}

Measured memory_bytes: 3084
import sys

def parse(inp):
    anntena = [int(next(inp).split()[0]) for _ in range(5)]
    k=int(next(inp).split()[0])
    return anntena,k
  
def main(inp):
    anntena,k=inp
    
    for i in range(4):
        for j in range(i+1,5):
            if(abs(anntena[i]-anntena[j])>k):
                return """:("""
    return """Yay!"""
  
print(main(parse(sys.stdin)))

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
#include <list>
#include <cctype>

using namespace std;

#define Int int64_t

void printVec(std::vector<int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

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

int vector_finder(std::vector<string> vec, string number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

#include <sstream> 
std::vector<std::string> StringSplit(const std::string& str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a * b / gcd(a, b);
}

int main() {
	int n; cin >> n;
	vector<int> t(n);
	for (int i = 0; i < n; i++) {
		cin >> t[i];
	}

	int m; cin >> m;
	vector<int> p(m),x(m);
	for (int i = 0; i < m; i++) {
		cin >> p[i] >> x[i];
	}

	int cnt = 0;

	for (int i = 0; i < m; i++) {
		cnt = 0;
		for (int j = 0; j < n; j++) {
			if (j == p[i] - 1) cnt += x[i];
			else cnt += t[j];
		}
		cout << cnt << endl;
	}




	


	cout << endl;
	return 0;
}

Measured memory_bytes: 256
# nikkei2019-2-qualB - Counting of Trees
from collections import Counter


def main():
    N, *D = map(int, open(0).read().split())
    MOD = 998244353
    cnt = Counter(D)
    if D[0] != 0 or cnt[0] > 1:
        ans = 0
    else:
        ans = 1
        for i in D[1:]:
            ans = (ans * cnt[i - 1]) % MOD
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 18988
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 200005;
const int mod = 998244353;

ll p[maxn];
ll sp[maxn];
struct ST {
  int l,r,d;
  ll val;
}st[maxn*4];
void up(int id){
  st[id].val = (st[id<<1].val * p[st[id<<1|1].r-st[id<<1|1].l+1]%mod + st[id<<1|1].val)%mod;
}
void build(int id, int l, int r){
  st[id].l=l,st[id].r=r,st[id].d = 0, st[id].val = 0;
  if(l==r){
    st[id].d = 1;
    st[id].val = 1;
    return;
  }
  int m = (l+r)>>1;
  build(id<<1,l,m);
  build(id<<1|1,m+1,r);
  up(id);
}
void down(int id){
  if(!st[id].d)return;
  int d = st[id].d;
  st[id].d = 0;
  st[id<<1].d = d;
  st[id<<1].val = sp[st[id<<1].r-st[id<<1].l]*d%mod;
  st[id<<1|1].d = d;
  st[id<<1|1].val = sp[st[id<<1|1].r-st[id<<1|1].l]*d%mod;
}
void add(int id, int l, int r, int val){
  if(st[id].l==l&&st[id].r==r){
    st[id].d = val;
    st[id].val = sp[r-l] * val % mod;

    return;
  }
  down(id);
  int m = (st[id].l+st[id].r)>>1;
  if(r<=m)add(id<<1,l,r,val);
  else if(l>m)add(id<<1|1,l,r,val);
  else {
    add(id<<1,l,m,val);
    add(id<<1|1,m+1,r,val);
  }
  up(id);
}

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int n,q;
  cin>>n>>q;
  p[0] = 1, sp[0] = 1;
  for(int i=1;i<maxn;i++){
    p[i] = p[i-1]*10%mod;
    sp[i] = (sp[i-1] + p[i])%mod;
  }
  build(1,1,n);
  while(q--){
    int l,r,d;
    cin>>l>>r>>d;
    add(1,l,r,d);
    cout<<st[1].val<<endl;
  }
  return 0;
}

Measured memory_bytes: 19004
N = int(input())
B_LIST = list(map(int, input().split(' ')))
ans = 0
for i in range(N):
  if i == 0:
    ans += B_LIST[i]
  else:
    if i == N - 1:
        ans += B_LIST[i - 1]
    else:
        if B_LIST[i - 1] > B_LIST[i]:
            ans += B_LIST[i]
        else:
            ans += B_LIST[i - 1]
print(ans)

Measured memory_bytes: 38504
s=list(input())
flag = "i"
count = 0
for i in range(len(s)):
  if flag =="h":
    if s[i] != "i":
      print("No")
      break
    else:
      flag = "i"
  elif flag =="i":
    if s[i] != "h":
      print("No")
      break
    else:
      flag = "h"
  if i == len(s)-1:
    if s[i]=="i":
      print("Yes")
    else:
      print("No")

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

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

Measured memory_bytes: 3628
// https://abc085.contest.atcoder.jp/tasks/abc085_c
#include <iostream>
#include <tuple>
using namespace std;

tuple<int, int, int> solve(int N, int Y)
{
    for (int tens = 0; tens <= N; ++tens)
    {
        for (int fives = 0; fives <= N; ++fives)
        {
            int ones = (Y - 10000 * tens - 5000 * fives) / 1000;
            if ((0 <= ones) && (ones + fives + tens == N))
                return make_tuple(tens, fives, ones);
        }
    }
    return make_tuple(-1, -1, -1);
}

int main()
{
    int N, Y;
    cin >> N >> Y;
    auto res = solve(N, Y);
    cout << get<0>(res) << " " << get<1>(res) << " " << get<2>(res) << endl;
    return 0;
}


Measured memory_bytes: 256