akhauriyash/Code-Regression huggingface dataset:
while True:
    m, f, r = map(int, input().split())
    if m == -1 and f == -1 and r == -1:
        quit()
    elif m == -1 or f == -1:
        print("F")
    elif m + f >= 80:
        print("A")
    elif m + f >= 65:
        print("B")
    elif m + f >= 50:
        print("C")
    elif m + f >= 30 and r >= 50:
        print("C")
    elif m + f >= 30:
        print("D")
    else:
        print("F")


Measured memory_bytes: 5592
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<vpii> vvpii;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n;
  while (cin >> n, n) {
    vector<pair<double, string>> v;
    while (n--) {
      string l;
      int p, a, b, c, d, e, f, s, m;
      cin >> l >> p >> a >> b >> c >> d >> e >> f >> s >> m;
      int time   = a + b + c + (d + e) * m;
      int income = f * s * m - p;
      v.emplace_back(double(income) / double(time), l);
    }
    sort(all(v), [](pair<double, string> a, pair<double, string> b) {
      if (a.fi != b.fi) return a.fi > b.fi;
      return a.se < b.se;
    });
    rep(i, v.size()) cout << v[i].se << endl;
    cout << '#' << endl;
  }
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
int n,k;
ll dp[2005][2005];
ll modpow(ll x,ll n){
	ll res=1;
	while(n>0){
		if(n&1) res=res*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return res;
}
ll F[4000005],R[4000005];
void make(){
	F[0] = 1;
	for(int i=1;i<4000005;i++) F[i] = F[i-1]*i%mod;
	R[4000000] = modpow(F[4000000],mod-2);
	for(int i=4000000;i>=1;i--) R[i-1] = R[i]*1LL*i%mod;
}
ll C(int a,int b){
	return F[a]*R[b]%mod*R[a-b]%mod;
}
int main(){
	cin>>n>>k; if(k==1){puts("1");return 0;} make();
	dp[0][0] = 1;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=n;j++){
			if(dp[i][j] == 0) continue;
			if(i!=n) dp[i+1][j] = (dp[i+1][j]+dp[i][j])%mod;
			if(i>=j+1) dp[i][j+1] = (dp[i][j+1]+dp[i][j]*C(n*k-j*(k-1)-i-1,k-2)%mod)%mod;
		}
	}
	cout<<dp[n][n]*F[n]%mod<<endl;
}

Measured memory_bytes: 94080
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  int n, m;cin >> n >> m;
  vector<pair<int, int>> hoge(n);
  int a, b;
  rep_i(i, n){
    cin >> a >> b;
    hoge[i] = make_pair(a, b);
  }

  sort_v(hoge);

  ll sum = 0;
  int buttle_sum = 0;
  
  for (int i = 0; i < n; i++){
    buttle_sum += hoge[i].second;
    if(buttle_sum < m){
      sum += (ll)hoge[i].first*(ll)hoge[i].second;
    }else{
      sum += (ll)hoge[i].first*(ll)(m - (buttle_sum - hoge[i].second));
      break;
    }
  }
  say(sum);
}

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


signed main(){
    char c[3];
    cin >> c[0] >> c[1] >> c[2];
    sort(c,c+3);
    string K;
    REP(i,3){K+=c[i];}
    if(K=="abc"){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>

using namespace std;

#define ll long long

void solve()
{
    ll N;
    cin >> N;
    double answer = 0.0f;
    for (ll i = 0; i < N; i++)
    {
        ll a;
        cin >> a;
        answer += 1.0f / a;
    }

    cout << 1.0f / answer << endl;
}

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


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

///******************************** C o n t a i n e r ********************************///

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef map<int,int> mii;
typedef map<ll,int> mli;

///*********************************** C o n s t ***********************************///

const int       N=1e6+3;
const double    PI = acos(-1);
const ll        MOD=1000000007;  ///1e9+7

///********************************** M a r c o ***********************************///

#define pb push_back
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define mem(a,b) memset(a, b, sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

///*********************************** F u n c t i o n ***********************************///

ll powmod(ll a,ll b){ll p=MOD;a%=p;if(!a) return 0;ll pr=1;while(b>0){if(b&1){pr*=a;pr%=p;--b;}a*=a;a%=p;b/=2;}return pr;}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 or n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0 or n%(i+2)==0)return false;}return true;}
void seive(bool a[]){ll mx=sqrt(N),ii,jj;for(ii=3;ii<=mx;ii+=2)if(!a[ii])for(jj=ii*ii;jj<=N;jj+=2*ii)a[jj]=true;}
void numofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]++; else a[jj]+=2;}}}
void sumofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]+=ii; else a[jj]+=ii+jj/ii;}}}

///**************************************************** C o d e ****************************************************///
///-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=///



void _case()
{
    string a,b,c;
    map<string,int> m;
    cin>>a>>b;
    int n,k;
    cin>>n>>k;
    m[a]=n,m[b]=k;
    cin>>c;
    m[c]--;
    cout<<m[a] sp<<m[b] el;
}

main()
{
//    fastio();
//    test _case();
        _case();

}


///Thank you.


///Brainless_Loco Terminates Here!


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

const int N = 1005;
const int MOD = 1e9+7;

int dp[N][N];
int vis[N][N];
char grid[N][N];

int calc (int row , int col , int n ,int m) {
	if ( !(1<=row and row<=n and 1<=col and col<= m ) or grid[row][col] == '#') return 0; 
	if ( row == n and col == m ) return dp[row][col]=1;
	if (vis[row][col]) return dp[row][col];
	
	vis[row][col]=1;
	
	return dp[row][col] = ( calc ( row+1,col,n,m) % MOD + calc(row,col+1,n,m) %	MOD ) %MOD;	
}
int main () {
	
	int n,m;
	cin>>n>>m;
	
	for (int i=1;i<=n;i++) {
		for (int j=1;j<=m;j++) {
			cin>>grid[i][j];
		}
	}
	calc(1,1,n,m);
	cout<<dp[1][1]<<'\n';
}


Measured memory_bytes: 12520
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		while(s.hasNext()){
			int t = s.nextInt()%39;
			if(t==0) t=39;
			System.out.printf("3C%02d\n",t);
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  int N;
  cin >> N;
  map<int, int> m;
  int a;
  REP(i, N){
    cin >> a;
    m[a]++;
  }

  int ans = 1;
  for(auto p : m){
    if(p.second > 1) ans = 0;
  }

  if(ans) YES;
  else NO;

  return 0;
}

Measured memory_bytes: 12800
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC147A
{
    class Program
    {
        static void Main(string[] args)
        {
            var Ai = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            if (Ai[0]+Ai[1]+Ai[2]>=22)
            {
                Console.WriteLine("bust");
            }
            else
            {
                Console.WriteLine("win");
            }
            Console.Read();
        }
    }
}


Measured memory_bytes: 11348
import itertools

n=int(input())
list_a = list(map(int,input().split()))
list_b = list(map(int,input().split()))

list_0 = list(range(1, n+1))


i = 1
a = 0
b = 0
for v in itertools.permutations(list_0):
  if list(v) == list_a:
    a = i
  if list(v) == list_b:
    b = i
  i += 1
print(abs(a-b))



Measured memory_bytes: 3060
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func main() {
	sc.Split(bufio.ScanWords)
	s := strings.Split(next(), "/")
	y, _ := strconv.Atoi(s[0])
	m, _ := strconv.Atoi(s[1])
	d, _ := strconv.Atoi(s[2])
	h := false
	if y < 2019 {
		h = true
	} else if y == 2019 && m < 4 {
		h = true
	} else if y == 2019 && m == 4 && d <= 30 {
		h = true
	}
	if h {
		fmt.Println("Heisei")
	} else {
		fmt.Println("TBD")
	}
}


Measured memory_bytes: 640
#include<iostream>
#include<stdio.h>
using namespace std;

bool even(int number)
{
    if(number%2==0)
    {
        return true;
    }
    else
    {
        return false;
    }
}

int main()
{
    int k;
    int result;
    int store;

    scanf("%d", &k);

    if(even(k))
    {
        store=(k/2);
        result=store*store;
    }
    else
    {
        store=(k/2);
        result=store*(store+1);
    }
    printf("%d\n", result);
    return 0;
}



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

int main()
{
    double a,b,c,d,e,f;
    double x,y;
    
    while(cin >> a >> b >> c >> d >> e >> f){
      
      x = (c*e - b*f)/(a*e - b*d);
      y = (c*d - a*f)/(b*d - a*e);
  
      if(abs(x) < 0.001) x = 0;
      if(abs(y) < 0.001) y = 0;
      printf("%.3f %.3f\n",x,y);
      
    }
    return 0;
}

Measured memory_bytes: 1232
import fractions
import math


def gcd(a,b):
    return fractions.gcd(a, b)

# def gcd(a,b):
#     return math.gcd(a,b)

def calculate(arr):
    # L length (N)
    L = [arr[0]]*len(arr)

    # R length (N)
    R = [arr[-1]]*len(arr)

    for i in range(len(arr)):
        if i == 0:
            continue

        L[i] = gcd(L[i-1],arr[i])


        R[len(arr) - (i + 1)] = gcd(R[len(arr) - i],arr[len(arr) - (i + 1)])

    max = 0
    for i in range(len(arr)):

        if i == 0:
            max = R[i+1]

        elif i == len(arr) - 1:
            if max < L[i-1]:
                max = L[i-1]
        else:
            if max < gcd(L[i-1],R[i+1]):
                max = gcd(L[i-1],R[i+1])

    print(max)

N = int(input())
arr = [int(s) for s in input().split(" ")]
calculate(arr)

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

// Description: ????????????
// Verifyed: various problem 
const R INF = 1E40L;
const R PI = acos(-1.0L);
using P=complex<R>;
const P O=0.0L;
using L=struct{P s,t;};
using VP=vector<P>;
using C=struct{P p;R c;};

istream& operator >> (istream& is,P& p){ R x,y;is >> x >> y; p=P(x,y); return is;}
ostream& operator << (ostream& os,P& p){ os << real(p) << " " << imag(p); return os;}
auto cmp_x=[](P a,P b)->bool{return sgn(real(a)-real(b))?sgn(real(a)-real(b))<0:sgn(imag(a)-imag(b)<0);};

inline R dot(P o,P a,P b){return real(conj(a-o)*(b-o));}
inline R det(P o,P a,P b){return imag(conj(a-o)*(b-o));}
inline int sdot(P o,P a,P b){return sgn(dot(o,a,b));}
inline int sdet(P o,P a,P b){return sgn(det(o,a,b));}

//projection verify AOJ CGL_1_A
P proj(L l,P p){ R u=real((p-l.s)/(l.t-l.s)); return (1-u)*l.s+u*l.t;}

// convex_hull Verify AOJ CGL_4_A
VP convex_hull(VP pol){
	int n=pol.size(),k=0;
	sort(begin(pol),end(pol),cmp_x);
	VP res(2*n);

	// down
	rep(i,n){
		while(k>1&&sdet(O,res[k-1]-res[k-2],pol[i]-res[k-1])>=1) k--;
		res[k++]=pol[i];
	}
	
	// up
	int t=k;
	rrep(i,n-1){
		while(k>t&&sdet(O,res[k-1]-res[k-2],pol[i]-res[k-1])>=1) k--;
		res[k++]=pol[i];
	}
	res.resize(k-1);
	return res;
}

int main(void){
	int n;
	cin >> n;
	VP pol;
	rep(i,n){
		P p;
		cin >> p;
		pol.push_back(p); 
	}
	VP res=convex_hull(pol);
	int m=res.size(),idx=0;
	rep(i,m){
		if(imag(res[i])<imag(res[idx])) idx=i;
		if(imag(res[i])==imag(res[idx])&&real(res[i])<real(res[idx])) idx=i;
	}
	cout << m << endl;
	rep(i,m) cout << res[(idx-i+m)%m] << endl;
	return 0;
}

Measured memory_bytes: 15524
n = int(input())
aa = list(map(int, input().split()))
bb = list(map(int, input().split()))
a = [[-1,-1] for i in range(n)]
b = [[-1,-1] for i in range(n)]

nowa = 0
nowb = 0
for i in range(n):
    if(aa[i]>nowa):
        a[i] = [aa[i],aa[i]]
        nowa = aa[i]
    else:
        a[i] = [1,aa[i]]
    if(bb[n-1-i]>nowb):
        b[n-1-i] = [bb[n-1-i],bb[n-1-i]]
        nowb = bb[n-1-i]
    else:
        b[n-1-i] = [1,nowb]
#print(a)
#print(b)
for i in range(n):
    a[i][0] = max(a[i][0],b[i][0])
    a[i][1] = min(a[i][1],b[i][1])
    
ans = 1
for i in range(n):
    ans *= max(0, a[i][1]-a[i][0]+1)
    ans%= 1000000007
print(ans)

Measured memory_bytes: 115300
X, K, D = map(int, input().split())
if X == 0:
    if K % 2 == 0:
        print(0)
    else:
        print(D)
else:
    X = abs(X)
    if X > K * D:
        print(X - K * D)
    else:
        d, m = divmod(X, D)
        K -= d
        if K % 2 == 0:
            print(m)
        else:
            print(D - m)

Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;

int main(){
  int N;
  cin>>N;
  vector<int> num(100,0);
  for(int i=0;i<N;i++){
    int d;
    cin>>d;
    num.at(d-1)=1;
  }
  int ans=0;
  for(int i=0;i<100;i++){
    ans+=num.at(i);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
/* This code is written by Nemlit */
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define re register
#define debug printf("Now is Line : %d\n",__LINE__)
#define file(a) freopen(#a".in","r",stdin);freopen(#a".out","w",stdout)
#define rep(i, a, b) for(re int i = (a); i <= (b); ++ i)
#define drep(i, a, b) for(re int i = (b); i >= (a); -- i)
#define Next(i, u) for(re int i = head[u]; i; i = e[i].next)
#define mem(k, p) memset(k, p, sizeof(k))
#define int long long
#define D double
#define inf 1023456789
#define mod 1000000007
#define lb(x) (x)&(-(x))
il int read() {
    re int x = 0, f = 1; re char c = getchar();
    while(c < '0' || c > '9') { if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - 48, c = getchar();
    return x * f;
}
il int Mul(int a, int b) { return 1ll * a * b % mod; }
il int Inc(int a, int b) { return (a += b) >= mod ? a - mod : a; }
il int Dec(int a, int b) { return (a -= b) < 0 ? a + mod : a; }
il int qpow(int a, int b) { int r = 1; while(b) { if(b & 1) r = Mul(r, a); a = Mul(a, a), b >>= 1; } return r; }
#define ls k * 2
#define rs k * 2 + 1
#define maxn 200005
namespace Graph {
	int head[maxn], cnt;
	struct edge { int v, next; }e[maxn << 1];
	il void add(int u, int v) { e[++ cnt] = (edge){v, head[u]}, head[u] = cnt; }
}
//using namespace Graph;
int n, m, x;
char c[maxn];
signed main() {
	scanf("%s", c + 1), n = strlen(c + 1);
	rep(i, 1, n) {
		if(c[i] == 'A') ++ x;
		else if(c[i] == 'B') {
			++ i;
			if(c[i] == 'C') m += x;
			else x = (c[i] == 'A');
		}
		else if(c[i] == 'C') x = 0;
	}
	cout << m;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <math.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)
#define INF 1<<29;

int main()
{
    int n;
    cin >> n;
    vector<int> l(n);
    rep(i,n) cin >> l[i];
    
    sort(l.begin(),l.end());
    int sum_len = 0;
    rep(i,n-1) sum_len += l[i];
    if(l.back() < sum_len)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# n,m = map(int,sys.stdin.readline().split())
# a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = tuple(sys.stdin.readline() for _ in range(n)) # multi line with single param
# a = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
# s = sys.stdin.readline().rstrip()
# n = int(sys.stdin.readline())
# INF = float("inf")
import sys,collections

S = sys.stdin.readline().rstrip()
T = sys.stdin.readline().rstrip()

if T.startswith(S):
    print('Yes')
    exit()
print('No')


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

typedef long long ll;
const int mod=998244353;
const int inv2=499122177;

ll qpow(ll a,ll n){
    ll res=1;
    while(n){
        if(n&1)res=res*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return res;
}

int n,s,a[3005];
ll dp[3005][3005];

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>s;
    dp[0][0]=1;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        for(int j=0;j<=s;j++){
            dp[i][j]=dp[i-1][j]*2%mod;
            if(j>=a[i])dp[i][j]=(dp[i][j]+dp[i-1][j-a[i]])%mod;
        }
    }
    cout<<dp[n][s]<<endl;

    return 0;
}

Measured memory_bytes: 74040
struct box{
	int ball;
	int red;
	int white;
};
i,j,source,target,N,M;main(){
	scanf("%d%d",&N,&M);
	struct box b[N];
	for(;i<N;i++){
		b[i].ball=1;
		b[i].red=!i?1:0;
		b[i].white=!i?0:1;
		// printf("%d: %d\t%d\t%d\n",i, b[i].ball,b[i].red,b[i].white);
	}
	for(i=0;i<M;i++){
		scanf("%d%d",&source,&target);
		source--;target--;
		if(b[source].red==1){
			b[target].red=1;
			if(b[source].ball==1)b[source].red=0;
		}
		if(b[source].white==1){
			b[target].white=1;
			if(b[source].ball==1)b[source].white=0;
		}
		b[source].ball--; b[target].ball++;
		// printf("%d: %d\t%d\t%d\n",source,b[source].ball,b[source].red,b[source].white);
		// printf("%d: %d\t%d\t%d\n",target,b[target].ball,b[target].red,b[target].white);
	}
	for(j=i=0;i<N;i++)
	{if(b[i].red==1)j++;
	}
	printf("%d\n",j);
}


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

int main(){
  ll n, k, min, max, ans=0;
  cin >> n >> k;
  
  vector<ll> sum(n+1,0);
  for(int i = 0; i < n+1; i++){
    if(i == 0) sum.at(i) = i;
    else sum.at(i) = sum.at(i-1) + i;
  }
  
  for(int i = k; i <= n+1; i++){
    ll min = sum.at(i-1);
    if(n-i >= 0) max = sum.at(n) - sum.at(n-i);
    else max = sum.at(n);
    ans += max - min + 1;
  }
  
  cout << ans%(10*10*10*10*10*10*10*10*10+7) << endl;
  
  return 0;
}

Measured memory_bytes: 4652
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
    //ABC 丼： 調理時間 A
    //ARC カレー： 調理時間 B
    //AGC パスタ： 調理時間 C
    //APC ラーメン： 調理時間 D
    //ATC ハンバーグ： 調理時間 E
    class Program
    {

        static void Main(string[] args)
        {

            //var input = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            var a = double.Parse(Console.ReadLine());
            var b = double.Parse(Console.ReadLine());
            var c = double.Parse(Console.ReadLine());
            var d = double.Parse(Console.ReadLine());
            var e = double.Parse(Console.ReadLine());

            var uniList = new Dictionary<int, double>();
            uniList.Add(0, a % 10);
            uniList.Add(1, b % 10);
            uniList.Add(2, c % 10);
            uniList.Add(3, d % 10);
            uniList.Add(4, e % 10);

            if (uniList.All(x => x.Value == 0))
            {
                Console.WriteLine((a+b+c+d+e).ToString());
                return;
            }

            var minUniKey = uniList.Where(x => x.Value != 0)
                                .OrderBy(x => x.Value)
                                .FirstOrDefault().Key;
            double result = 0;
            if (minUniKey == 0)
            {
                result = Math.Ceiling(b / 10) * 10
                         + Math.Ceiling(c / 10) * 10
                         + Math.Ceiling(d / 10) * 10
                         + Math.Ceiling(e / 10) * 10;
                result += a;
            }
            if (minUniKey == 1)
            {
                result = Math.Ceiling(a / 10) * 10
                         + Math.Ceiling(c / 10) * 10
                         + Math.Ceiling(d / 10) * 10
                         + Math.Ceiling(e / 10) * 10;
                result += b;
            }
            if (minUniKey == 2)
            {
                result = Math.Ceiling(a / 10) * 10
                         + Math.Ceiling(b / 10) * 10
                         + Math.Ceiling(d / 10) * 10
                         + Math.Ceiling(e / 10) * 10;
                result += c;
            }
            if (minUniKey == 3)
            {
                result = Math.Ceiling(a / 10) * 10
                         + Math.Ceiling(b / 10) * 10
                         + Math.Ceiling(c / 10) * 10
                         + Math.Ceiling(e / 10) * 10;
                result += d;
            }
            if (minUniKey == 4)
            {
                result = Math.Ceiling(a / 10) * 10
                         + Math.Ceiling(b / 10) * 10
                         + Math.Ceiling(c / 10) * 10
                         + Math.Ceiling(d / 10) * 10;
                result += e;
            }
            Console.WriteLine(result.ToString());
        }
    }
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

struct event{
	ll X, S, T;
	bool operator<(const event& right)const{
		return X < right.X;
	}
};

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

    ll N, Q;
    cin >> N >> Q;

    vector<event> Es;
    REP(i, N){
    	ll S, T, X;
    	cin >> S >> T >> X;
    	event e = {X, S, T};
    	Es.push_back(e);
    }
    sort(Es.begin(), Es.end());

    set<pll> Ds;
    REP(i, Q){
    	ll D;
    	cin >> D;
    	Ds.insert({D, i});
    }

    vector<ll> res(Q, -1);
    REP(i, N){
    	auto itr = Ds.lower_bound({Es[i].S-Es[i].X, -1});
    	while(itr != Ds.end()){
    		if(itr->first >= Es[i].T - Es[i].X) break;
    		res[itr->second] = Es[i].X;
    		itr = Ds.erase(itr);
    	}
    }

    REP(i, Q) cout << res[i] << endl;
    return 0;
}

Measured memory_bytes: 21228
var
	n,i:Longint;
	s:String;
	a:array[0..99999]of Boolean;
function f(x,y:Boolean):Boolean;
var j:Longint;flag:Boolean;
begin
	a[0]:=x;
	a[1]:=y;
	for j:=1 to n-2 do if(s[j+1]='x')xor a[j]then a[j+1]:=a[j-1]else a[j+1]:=not a[j-1];
	flag:=true;
	if(s[1]='x')xor a[0]then flag:=flag and(a[n-1]=a[1])else flag:=flag and(a[n-1]<>a[1]);
	if(s[n]='x')xor a[n-1]then flag:=flag and(a[n-2]=a[0])else flag:=flag and(a[n-2]<>a[0]);
	f:=flag;
end;
procedure print();
var j:Longint;
begin
	for j:=0 to n-1 do if a[j] then write('S')else write('W');
	writeln;
end;
begin
	readln(n);
	readln(s);
	if f(true,true)then print()else if f(true,false)then print()else if f(false,true)then print()else if f(false,false)then print()else writeln(-1);
end.


Measured memory_bytes: 384
#include<iostream>
#include<cmath>

using namespace std;

int main()
{

	int N,A,B;
	int max_ans,min_ans;

	cin >> N >> A >> B;

	if(A > B)
	{
		max_ans = B;
		int tmp = N - A;
		if(tmp > B)
		{
			min_ans = 0;
		}
		else
		{
			min_ans = B - tmp;
		}
	}
	else
	{
		max_ans = A;
		int tmp = N - B;
		if(tmp > A)
		{
			min_ans = 0;
		}
		else
		{
			min_ans = A - tmp;
		}
	}

	cout << max_ans << " " << min_ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll L[100009];
ll M[100009];
ll ans;
ll s[100009];
ll a[100009];
ll mod = 1e9 + 7;
ll f[100009];
ll inv[100009];
ll inf[100009];
ll C(ll n, ll m){
    if(m > n || m < 0) return 0;
    return f[n] * inf[m] % mod * inf[n - m] % mod;
}
main(){
    ll n;
    cin >> n;
    ll S = 0;
    for(ll i = 1; i <= n; i++){
        cin >> a[i];
        s[i] = (s[i - 1] + a[i])%mod;
    }
    inv[0] = 1; inv[1] = 1;
    f[0] = 1; inf[0] = 1;
    for(ll i = 1; i <= n; i++){
        if(i > 1) inv[i] = inv[mod%i] *(mod - mod / i) % mod;
        f[i] = f[i-1] * i % mod;
        inf[i] = inf[i-1] * inv[i] % mod;
    }
    ll ans = s[n] * f[n];
    for(ll i = 1; i < n; i++)
        L[i] = C(n, i+1) *f[i] % mod*f[n - i - 1] %mod;
    for(ll i = 1; i < n-1; i++){
        M[i] = 2 * f[i] %mod * C(n, i+2) % mod *f[n - i -2] % mod;
    }
    for(ll i = 1; i < n; i++)
    {
        ans = (ans + s[i] * L[i])% mod;
        ans = (ans + (s[n] - s[n - i] + mod) * L[i])% mod;
    }
    S = 0;
    for(ll i = 1; i <= n - 2; i++){
        S = (S + s[n - i] - s[i] +mod)% mod;
        ans = (ans + M[i] * S % mod) % mod;
    }
    cout << ans << endl;
}
/*
111111
122221
123321
1
*/


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

int main() {
  string s;
  cin >> s;
  bool ans = true;
  rep(i,s.size()) {
    if (i%2 == 0) {
      if (s[i] == 'L') {
        ans = false;
        break;
      }
    }
    else {
      if (s[i] == 'R') {
        ans = false;
        break;
      }
    }
  }
  if (ans) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define N 1000000007
#define pll pair<ll,ll>

int main() {

    ll n;
    cin>>n;

    vector<ll> A(n),B(n-1);
    for(int i=0;i<n-1;i++)
    	cin>>B[i];

    A[n-1] = B[n-2];
    A[n-2] = B[n-2];

    for(int i=n-2;i>=0;i--) {
    	if(B[i]<A[i+1]) {
    		A[i+1] = B[i];
    	}
    	A[i] = B[i];
    }

    ll sum = 0;
    for(int i=0;i<n;i++)
    	sum += A[i];
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    int D = sc.nextInt();
    
    int ans = Math.min(B, D) - Math.max(A, C);
    System.out.println(ans > 0 ? ans : 0);
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;

#define f first
#define se second
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pi pair<int, int>
#define all(x) x.begin(), x.end()
#define lp(i, n) for (int i = 0; i < n; i++)
#define mem(a, v) memset(a, v, sizeof(a))
#define X real()
#define Y imag()
#define angle(a) (atan2(a.Y, a.X))
#define vec(a, b) ((b) - (a))
//#define length(a) (hypot(a.Y , a.X))
#define normalize(a) (a) / length(a)
#define dotP(a, b) ((conj(a) * b).X)
#define crossP(a, b) ((conj(a) * b).Y)
#define same(p1, p2) (dotP(vec(p1, p2), vec(p1, p2)) < EPS)
#define lengthSqr(a) dotP(a, a)
#define rotate0(p, ang) ((p)*exp(point(0, ang)))
#define rotateA(p, ang, about) (rotate0(vec(about, p), ang) + about)
#define reflect0(v, m) conj(v / m) * m
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
const double PI = acos(-1.0);
const double EPS = (1e-10);
const long long int INF = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
typedef long long int ll;
typedef unsigned long long ull;
typedef complex<double> point;
long long fastpow(ll n, ll x) {
  if (!x)
    return 1;
  if (x % 2)
    return n * fastpow(n, x - 1);
  ll p = fastpow(n, x / 2);
  p %= mod;
  p *= p;
  p %= mod;
  return p;
}

ll my_mod(ll num, ll mod) {
  ll ret = num % mod;
  while (ret < 0)
    ret += mod;
  return ret;
}

ll gcd(ll a, ll b) { return !a ? b : gcd(b % a, a); }
long double dist(pair<ll, ll> &a, pair<ll, ll> &b) {
  return sqrt(
      ((a.f - b.f) * (a.f - b.f) * 1.0 + (a.se - b.se) * (a.se - b.se)));
}
/*vector<int> ap;
bool np[MX];
void s(){
    mem(np , 1);
    np[1] = np[0] = 0;
    for(ll i = 2 ; i*i<= MX ;i++){
        if(np[i]){
            for(ll j= i*i ; j <MX; j+=i) np[j] = 0;
        }
    }
    for(ll i = 2 ; i< MX ; i++) if(np[i]) ap.pb(i);
}*/
const ll MX = 1e5+5;

int main()
{
    IO;
    int n;
    cin>>n;
    vector<double> dp(n+1);
    dp[0] = 1;
    for(int i = 1; i <= n ;i++){
		double ph;
		cin>>ph;
		for(int j = i ; j>= 0; j--){
			dp[j] = (!j ? 0 : dp[j-1]*ph) + dp[j]*(1-ph);
		}
	}
	double ans = 0;
	for(int i = 0 ; i<= n ; i++){
		int ot = n - i;
		if(i > ot) ans += dp[i];
	}
	cout<<fixed<<setprecision(10)<<ans;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;

int dp[100005];

int main(){
  int n; cin>>n;
  string s; cin>>s;
  vector<int> l(26,0);
  vector<int> r(26,0);
  rep(i,s.size()){
    r[s[i]-'a']++;
  }
  // rep(j,26){
  //   cout<<"l "<<l[j]<<" r "<<r[j]<<endl;
  // }
  int ans=0;
  rep(i,s.size()){
    // cout<<"i "<<i<<endl;
    int c=0;
    rep(j,26){
      if(l[j]>0&&r[j]>0)
      c++;
       // cout<<"l "<<l[j]<<" r "<<r[j]<<endl;
    }
    ans=max(ans,c);
    l[s[i]-'a']++;
    r[s[i]-'a']--;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
import itertools
import math

N, d = map(int, input().split())
P = [list(map(int, input().split())) for i in range(N)]
num = 0

for p in itertools.combinations(P, 2):
  length = [(p[0][f] - p[1][f]) ** 2 for f in range(d)]
  if math.sqrt(sum(length)).is_integer():
    num += 1
print(num)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ.Volume0
{
    class Program0009
    {
        static void Main(string[] args)
        {
            string input;
            Queue<int> results = new Queue<int>();

            while ((input = Console.ReadLine()) != null)
            {
                int n = int.Parse(input);

                results.Enqueue(GetPrimeNumbersNum(n));
            }

            foreach (var result in results)
            {
                Console.WriteLine(result);
            }

        }

        static int GetPrimeNumbersNum(int n)
        {
            bool[] isPrime = new bool[n + 1];

            //nが2までの時は初期化できないので
            if (n < 2)
            {
                return 0;
            }
            else if (n == 2)
            {
                return 1;
            }

            //初期化
            isPrime[0] = false;
            isPrime[1] = false;
            isPrime[2] = true;
            for (int i = 3; i <= n; i++)
                isPrime[i] = i % 2 != 0;


            for (int i = 2; i <= n; i++)
            {
                if (isPrime[i])
                {
                    int current = i * 2;

                    while (current <= n)
                    {
                        isPrime[current] = false;
                        current += i;
                    }
                }
            }

            return isPrime.Count(b => b);
        }
    }
}

Measured memory_bytes: 7456
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
        cerr <<fixed<<setprecision(12);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static constexpr const signed int INF = 0x3f3f3f3f;
static constexpr const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static constexpr const signed int SMOD = 1000000007;
static constexpr const signed int NMOD = 998244353;
static constexpr const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static constexpr const signed int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a=max(a,b))==b;}
template<class T>bool chmin(T &a, const T &b){return(a=min(a,b))==b;}
inline int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int r[4040];
int g[4040];
int b[4040];
signed main() {

    int n;
    string s;

    cin >> n >> s;

    for(int i = n-1; i >= 0; i--) {
        r[i] = r[i+1];
        g[i] = g[i+1];
        b[i] = b[i+1];
        if(s[i] == 'R') r[i]++;
        else if(s[i] == 'G') g[i]++;
        else b[i]++;

    }
    
    ll sum = 0;
    for(int i = 0; i < n; i++) {
        for(int j = i+1; j < n; j++) {
            if(s[i]=='R' and s[j]=='G' or s[j]=='R' and s[i]=='G') 
                sum += b[j] - (s[j + j - i] == 'B');
            if(s[i]=='G' and s[j]=='B' or s[j]=='G' and s[i]=='B')
                sum += r[j] - (s[j + j - i] == 'R');
            if(s[i]=='R' and s[j]=='B' or s[j]=='R' and s[i]=='B')
                sum += g[j] - (s[j + j - i] == 'G');
        }
    }
    
    cout << sum << endl;
  
    return 0;
}



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

using ll = long long;
using namespace std;
const int INFint = 2e9+1;
const ll INFll = 2e18+1;
ll MOD=1e9+7;

int main(){
  int N;
  cin>>N;
  map<char,int> cnt;
  for(int i(0);i<N;i++){
    string s;
    cin>>s;
    if(s[0] == 'M' || s[0] == 'A' || s[0] == 'R' || s[0] == 'C' || s[0] == 'H'){
      cnt[s[0]]++;
    }
  }
  vector<int> cnta;
  for(auto m:cnt){
    cnta.push_back(m.second);
  }
  int cnti = int(cnt.size());

  ll ans(0);
  for(int bit(0);bit<(1<<cnti);bit++){
    int keta(0);
    for(int i(0);i<cnti;i++){
      if (((bit>>i) & 1)){
        keta++;
      }
    }
    if(keta == 3){
      ll tmp(1);
      for(int i(0);i<cnti;i++){
        if (((bit>>i) & 1)){
          tmp *= cnta[i];
        }
      }
      ans += tmp;
    }
  }
  cout << ans << endl;
  //cout << cnti << endl;
  //ll ans(cnti*(cnti-1)*(cnti-2)/6);
  //for(auto m:cnt){
    //ans *= m.second;
  //}
  //cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <stdlib.h>
#include <vector>

using namespace std;


int main(){
	int a[5];

	for(int i=0 ; i<5 ; i++){
		cin >> a[i];
	} 

	for(int i=0 ; i<5 ; i++){
		for(int j=i; j<5 ; j++){
			if(a[i] < a[j] ){
				int temp;
				temp = a[i];
				a[i] = a[j];
				a[j] = temp;
			}
		}
	}

	for(int i=0 ; i<4 ; i++){
		cout << a[i] << ' ';
	}
	cout << a[4] << endl;
	return 0;
}

Measured memory_bytes: 1160
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>

using namespace std;

const int mod = 1e9 + 7;
void add(int &a, int b){
    a += b;
    if(a >= mod)
        a -= mod;
}

const int maxn = 1e3 + 5;

int fac[maxn], inv[maxn];

int qpow(int a, int n){
    int ret = 1;
    while(n > 0){
        if(n & 1){
            ret = 1LL * ret * a % mod;
        }
        a = 1LL * a * a % mod;
        n >>= 1;
    }
    return ret;
}

void pre_comb(){
    fac[0] = 1;
    for(int i = 1;i < maxn;i++){
        fac[i] = 1LL * fac[i - 1] * i % mod;
    }
    inv[maxn - 1] = qpow(fac[maxn - 1], mod - 2);
    for(int i = maxn - 2;i >= 0;i--){
        inv[i] = 1LL * inv[i + 1] * (i + 1) % mod;
    }
}

int comb(int n, int m){
    if(m > n or m < 0) return 0;
    return 1LL * fac[n] * inv[m] % mod * inv[n - m] % mod;
}

int n, a, b, c, d;

int dp[maxn][maxn];

int main(){
    cin >> n >> a >> b >> c >> d;
    memset(dp, 0, sizeof(dp));
    dp[n][a] = 1;
    pre_comb();
    for(int i = n;i >= 0;i--){
        for(int j = a;j <= b;j++){
            add(dp[i][j + 1], dp[i][j]);
            for(int k = c;k <= d and k * j <= i;k++){
                int tmp = 1LL * dp[i][j] * fac[i] % mod * inv[i - k * j] % mod * inv[k] % mod;
                tmp = 1LL * qpow(inv[j], k) * tmp % mod;
                add(dp[i - k * j][j + 1], tmp); 
            }
        }
    }
    cout << dp[0][b + 1] << endl;
    return 0;
}



Measured memory_bytes: 4224
def solve_e(n, a_list):
    days = 0
    ind_list = [0] * n
    match_count = 0
    queue = list(range(n))
    stack = dict()
    while len(queue) > 0:
        days += 1
        new_queue = []
        for p in queue:
            if ind_list[p] < n - 1:
                q = a_list[p][ind_list[p]] - 1
                k = str(min(p, q)) + "_" + str(max(p, q))
                if k in stack.keys():
                    ind_list[p] += 1
                    ind_list[q] += 1
                    # print(days, p, q)
                    new_queue.append(p)
                    new_queue.append(q)
                    match_count += 1
                else:
                    stack[k] = 1
        queue = new_queue
    if match_count == n * (n - 1) // 2:
        return days - 1
    else:
        return -1


def test():
    n = 1000
    a_list = []
    for i in range(n):
        a_list.append(list(range(1, i + 1)) + list(range(i + 2, n + 1)))
    print(solve_e(n, a_list))


def main():
    n = int(input())
    a_list = []
    for _ in range(n):
        a_list.append(list(map(int, input().split())))
    print(solve_e(n, a_list))


if __name__ == "__main__":
    main()


Measured memory_bytes: 91400
#include<iostream>
using namespace std;
int main()
{
    long long jj,a,b;
    cin>>jj>>a>>b;
    if(jj>1&&b>=a||jj==1&&a==b)
    
     cout<<(jj-2)*(b-a)+1<<endl;
     
    else
        cout<<0<<endl; 
 } 

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void){
	
	int a,b,c,x;
	
	scanf("%d %d %d",&a,&b,&c);
	
	if(a > c || a + b < c){
		printf("NO\n");
	} else {
		printf("YES\n");
	}
	
	return 0;
}


Measured memory_bytes: 128
main = do
  (a:b:c:d:_) <- getLine >>= return . (map read) . words :: IO [Int]
  print $ f a b c d
  where
    f a b c d
      | a < c =
        if b <= c then
          0
        else if c < b && b <= d then
          b-c
        else
          d-c
      | otherwise =
        if d <= a then
          0
        else if a < d && d <= b then
          d-a
        else
          b-a


Measured memory_bytes: 508
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <list>
#include <numeric>
#include <math.h>
#include <cstdlib>
#include <queue>
#include <iterator>
#include <limits>
#include <string>
#include <sstream>
#include <iomanip>
#include <bitset>
#include <mutex>
#include <condition_variable>
#include <atomic>
#include <stack>
#include <memory>
#include <deque>
#include <string_view>
#include <random>
#include <chrono>
#include <cstring>

using namespace std;

static int my_speed_up = []() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); return 0; }();
using ll = long long; using ull = unsigned long long;
template<class T> using v = vector<T>;
template<class T> using vv = vector<vector<T>>;
template<class T> using vvv = vector<vector<vector<T>>>;
template<class T> using vvvv = vector<vector<vector<vector<T>>>>;
#define for_b(i, b) for (int i = 0; i < (b); ++i)
#define for_ab(i, a, b) for (int i = a; i < (b); ++i)
#define what_is(x) cout << #x << " = " << x << endl;
#define what_are(x,y) cout << #x << " = " << x << ", " << #y << " = " << y << endl;
#define pad(x) for_b(i, x) cout << "  ";
#define show_1d(___x) cout << #___x << " = "; for (auto& ___num : ___x) cout << ___num << ", "; cout << endl;
#define show_2d(___x) cout << #___x << endl; for (auto& ___row : ___x) { for (auto ___num : ___row) cout << ___num << ", "; cout << endl; }
#define show_3d(___x) cout << #___x << endl; for (auto& ___row : ___x) { for (auto& ___row2 : ___row) { for (auto ___num : ___row2) cout << ___num << ", "; cout << endl; }cout << endl; }

vv<int> d4 = {{1,0},{-1,0},{0,1},{0,-1}};
vv<int> d8 = {{1,0},{-1,0},{0,1},{0,-1},{1,1},{1,-1},{-1,1},{-1,-1}};
bool is_valid_pos(const vv<int>& tb, int x, int y) {
    return x >= 0 && x < tb.size() && y >= 0 && y < tb[0].size();
}


int main()
{
    int D, T, S;
    cin >> D >> T >> S;
    
    
    bool res = ((double)D/(double)S) > T;
    cout << (!res ? "Yes" : "No") << endl;
    
    
    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef vector<vector<ll> > Graph;
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 ll INF = 1e18;


int main(){
    ll n;
    cin >> n;
    vector<ll>p(n);
    rep(i,n){
        cin>>p[i];
        p[i]--;
    }
    vector<ll>idx(n);
    rep(i,n){
        idx[p[i]]=i;
    }
    set<ll>s;
    ll ans = 0;
    for(ll i=n-1;i>=0;i--){
        int x = idx[i];
        s.insert(x);
        auto it = s.find(x);
        vector<ll>l(2,-1);
        rep(j,2){
            if(it==s.begin())break;
            it--;
            l[j]=*it;
        }
        it = s.find(x);
        vector<ll>r(2,n);
        rep(j,2){
            it++;
            if(it==s.end())break;
            r[j]=*it;
        }
        
        ll c;
        c = (x-l[0])*(r[1]-r[0])+(r[0]-x)*(l[0]-l[1]);
        c *= (i+1);
        ans += c;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6528
#include<iostream>
using namespace std;
int main(){
    int N;
    cin>>N;
    int A[N];
    for(int i=0;i<N;++i)cin>>A[i];

    int count=0;
       for(int i=0;i<N;){
               while(A[i]==A[i+1]){
                    ++i;
               }

           if(A[i]<A[i+1]){
               while(A[i]<=A[i+1]){
                   ++i;
               }
           }else if(A[i]>A[i+1]){
               while(A[i]>=A[i+1]){
                   ++i;
               }
           }
           
           ++i;
           ++count;
       } 
    cout<<count;
}



Measured memory_bytes: 3500