akhauriyash/Code-Regression huggingface dataset:
import Control.Monad

data YesNo = YES | NO deriving(Show)

isYes :: Bool -> YesNo
isYes boo
  | boo = YES
  | not boo = NO
  | otherwise    = NO

solver :: [Int] -> YesNo
solver (x:y:z:_) =
  let x1 = (x * x + y * y == z * z)
      x2 = (y * y + z * z == x * x)
      x3 = (z * z + x * x == y * y)
  in
      isYes $ x1 || x2 || x3
solver _ = NO

seqRead :: [String] -> [Int]
seqRead xs = map read xs :: [Int]


main :: IO()
main = do
  num <- getLine
  let n = read num :: Int
  line <- replicateM n getLine
  let line' = map words line :: [[String]]
      line'' = map seqRead line'
  mapM_ (print . solver) line''

Measured memory_bytes: 4304
import sys
sys.setrecursionlimit(2147483647)
INF = float("inf")
MOD = 10**9 + 7 # 998244353
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    n = int(input())
    # dp[i][j] : i まで見て末尾が j のもの (i <= j)
    dp = [1]
    for i, c in enumerate(input(), 1):
        S = [0] * (i + 1)
        for j in range(i):
            S[j + 1] = S[j] + dp[j]
            if S[j + 1] >= MOD:
                S[j + 1] -= MOD
        dp = [0] * (i + 1)
        if c == '<':
            # ndp[j] = dp[0] + ... + dp[j - 1] # j <= i
            for j in range(i + 1):
                dp[j] = S[j]
        elif c == '>':
            # ndp[j] = dp[j] + ... + dp[i - 1] # j <= i
            for j in range(i + 1):
                dp[j] = S[i] - S[j]
                if dp[j] < 0:
                    dp[j] += MOD

    print(sum(dp) % MOD)
resolve()

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N,T;
    Scd2(N,T);

    vii a(N);

    Rep(i,N){
        Scd2(a[i].first, a[i].second );
    }
    sort( a.begin(), a.end() );

    vi dp(T+3000);

    Rep(ni,N){
        RRep(ti,T){
            dp[ti+a[ni].first] = max( dp[ti+a[ni].first], dp[ti] + a[ni].second );
        }
    }

    int ans = 0;
    Rep(i,T+3000){
        ans = max( dp[i], ans );
    }

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

    return 0;
}





Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int n = s.length();
		long ans = 0;
		for(int mask = 0 ; mask < 1<<(n - 1) ; mask++) {
			String temp = "";
			for(int i = 0 ; i < n ; i++) {
				if(i != n - 1 && (mask&(1<<i)) >= 1) {
					temp += s.charAt(i) + "+";
				} else {
					temp += s.charAt(i);
				}
			}
			String[] split = temp.split("\\+");
			long ret = 0;
			for(int i = 0 ; i < split.length ; i++) {
				ret += Long.valueOf(split[i]);
			}
			ans += ret;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
#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 For(i,a,b) for(auto i=(a);i<=(b);++i)
#define rFor(i,a,b) for(auto i=(b);i>=(a);--i)
#define call(var) cerr<<#var<<"="<<var<<"\n";
#define dup(x,y) (((x)+(y)-1)/(y))
#define all(x) (x).begin(),(x).end()
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
const double pi = acos(-1);
template<class t,class u> inline bool chmax(t&a,u b){if(a<b){a=b;return true;}return false;}
template<class t,class u> inline bool chmin(t&a,u b){if(b<a){a=b;return true;}return false;}
template<class T> istream& operator>>(istream& is, vector<T>& a){rep(i,a.size()) is >> a[i]; return is;}
template<class T> ostream& operator<<(ostream& os, vector<T>& a){rep(i,a.size()) os << a[i] << " "; return os;}
template<class T, class U> istream& operator>>(istream& is, pair<T,U>& p){is >> p.first >> p.second; return is;}
template<class T, class U> ostream& operator<<(ostream& os, const pair<T,U>& p){os << "("<< p.first << "," << p.second << ")"; return os;}
template<class T, class U> ostream& operator<<(ostream& os, const map<T,U>& mp){for(auto& t : mp) os << t.first << " " << t.second << "\n"; return os;}

int main(){
    int x;cin >> x;
    if(x >= 30){
        cout << "Yes\n";
    }else{
        cout << "No\n";
    }
}

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

#define ll long long
#define ar array

const int M=1e9+7;
int n, a, b;
ll iv[200001];

ll nck(int n, int k) {
	ll ans=1;
	for(int i=1; i<=k; ++i)
		ans=ans*(n-i+1)%M*iv[i]%M;
	return ans;
}

ll powM(ll b, int p) {
	ll r=1;
	for(; p; b=b*b%M, p/=2)
		if(p&1)
		r=r*b%M;
	return r;
}

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

	iv[1]=1;
	for(int i=2; i<=200000; ++i)
		iv[i]=M-M/i*iv[M%i]%M;
	cin >> n >> a >> b;
	ll ans=powM(2, n);
	cout << (ans+2*M-nck(n, a)-nck(n, b)+M-1)%M;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
constexpr double eps = 1e-12;
double deg2rad(double x) { return x / 360 * (2 * M_PI); }
double frem(double x, double y) { return fmod(fmod(x, y) + y + eps, y); }
enum face_t { ABC, ACD, ADB, BCD };
 
face_t get_face() {
    string xy; int d, l; cin >> xy >> d >> l;
    double face_theta =
        xy == "BC" ? 0 :
        xy == "CD" ? 60 :
        xy == "DB" ? 120 :
        NAN;
    double theta = deg2rad(face_theta + d);
    double x = l * cos(theta);
    double y = l * sin(theta);
    double z60 = x + y / sqrt(3);
    double z120 = - x + y / sqrt(3);
    z60 = frem(z60, 2);
    z120 = frem(z120, 2);
    double w = (z60 + z120) * (sqrt(3) / 2);
    return
        w < sqrt(3) / 2 ?
            ACD :
        w < sqrt(3) ?
            z60 > 1 ? ABC :
            z120 > 1 ? ADB :
            BCD :
        w < 3 * sqrt(3) / 2 ?
            z60 < 1 ? ABC :
            z120 < 1 ? ADB :
            BCD :
        ACD;
}
 
int main() {
    face_t a = get_face();
    face_t b = get_face();
    cout << (a == b ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 3492
import itertools
while True:
    n,x=map(int,input().split())
    if n==0 and x==0:
        break
    else:
         s=list(range(1,n+1))
         l=list(itertools.combinations(s,3))
         c=0
         for i in l:
              if sum(i) == x:
                   c+=1
         print(c)

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

int main() {
  LL a, b;
  cin >> a >> b;
  LL fee;
  if (a >= 13) fee = b;
  else if (a >= 6) fee = b / 2;
  else fee = 0;

  cout << fee << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long
#define pb                      push_back
#define rep(i,a,b,c)            for(ll i=(a);i<=(b);i+=(c))
#define repb(i,a,b,c)           for(ll i=(a);i>=(b);i-=(c))
#define MOD                     1000000007
#define inf                     3e18
#define ld                      long double
#define mp                      make_pair
#define vpll                    vector<pair<ll,ll> >
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define ln                      cout<<"\n";
#define endl                    "\n"
#define test                    ll T;cin>>T;while(T--)
#define isvowel(a)              (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define show(w,size)            for(ll i=0;i<size;i++) cout<<w[i]<<" ";
#define prll(a)                 cout<<a<<"\n";
#define mset(dp,no)             memset(dp,no,sizeof(dp))
#define input(a,n)              rep(i,0,n-1,1) cin>>a[i];
#define countbit                __builtin_popcount                                           //Number of setbits in decimal notation
#define lb(v,cur)               lower_bound(all(v),cur)-v.begin()
#define ub(v,cur)               upper_bound(all(v),cur)-v.begin()
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
long long pows(long long a, long long b) {
  long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll powm(ll x,ll y,ll m=MOD){x=x%m;ll res=1;while(y){if(y&1)res=res*x;res%=m;y=y>>1;x=x*x;x%=m;}return res;}
ll modInverse(ll a, ll m=MOD){return powm(a,m-2,m);}
int main()
{
fastIO
ll n,m,i,j,k,x,y,z,t,e,f,p,q,g,l,r,o,w,h,count1=0,prod=1,a,b,c,d,index,x1,x2,y1,y2,diff,ans=0,sum=0,sum1=0,sum2=0,flag=0,flag1=0,flag2=0;
string s,s1,s2;
cin>>d>>a>>b;
ld pp=(d*1.0)/b;
if(pp<=a)
{
  cout<<"Yes\n";
}
else
{
  cout<<"No\n";
}
}


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


int main(){
    int N;cin>>N;
    vector<int> A(N),B(N),T(N),I(N);
    for(int i=0;i<N;i++) cin>>A[i]>>B[i];
    for(int i=0;i<N;i++) T[i] = A[i] + B[i];
    for(int i=0;i<N;i++) I[i] = i;
    sort(I.rbegin(), I.rend(), [&T](int &lhs, int &rhs) { return T[lhs] < T[rhs]; });
    long long at = 0,bt = 0;
    for(int i=0;i<I.size();i+=2) at += A[I[i]];
    for(int i=1;i<I.size();i+=2) bt += B[I[i]];
    cout<<at - bt<<endl;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main(){
    char s[5];
    scanf("%s",s);
    int counr=0;
    for(int i=0;i<3;i++){
        if(s[i]==s[i+1])
            counr++;
    }
    if(counr==0)
        puts("Good");
    else
        puts("Bad");
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include<string>
#include<set>

using namespace std;
int main(void){
    int N,M;
    cin>>N>>M;
    
    int d[51]={};
    
    int m;
    for(int i=0;i<2*M;i++){
        
        cin>>m;
        d[m]=d[m]+1;
    
    }
    for(int i=1;i<=N;i++){
        cout<<d[i]<<endl;
   }
   
    
     
    
    
    return 0;
    
}

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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

// 長さn+1は最低限歩く必要があってそこに(後退する距離)*2を足したものが総距離 これを最小化したい
// 重なってる辺は全部まとめたほうがいい 重なってなければすぐ戻った方がいい

int n, m, c[500], d[500], imo[2345];

signed main() {
	cin >> n >> m;
	rep(i,m) {
		cin >> c[i] >> d[i];
		c[i] *= 2, d[i] *= 2;
		imo[c[i]]++, imo[d[i]+1]--;
	}
	int res = n+1, l = 0;
	repst(i,1,2020) {
		imo[i] += imo[i-1];
		if (imo[i]>0) l++;
		else if (l) res += l-1, l = 0;
	}
	cout << res << ln;
}


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

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		Paper paper = new Paper();
		while(true){
			String tmpStr = br.readLine();

			if(tmpStr == null){
				break;
			}

			String[] tmpArray = tmpStr.split(",");
			paper.dropInk(Integer.parseInt(tmpArray[0]), Integer.parseInt(tmpArray[1]), Integer.parseInt(tmpArray[2]));
		}
		System.out.println(paper.countBlank());
		System.out.println(paper.findMax());

	}

}

class Paper {
	int[][] square;

	public Paper() {
		square = new int[10][10];
	}

	public void dropInk(int x, int y, int size){
		square[x][y]++;
		if(x - 1 >= 0) square[x - 1][y]++;
		if(x + 1 < 10) square[x + 1][y]++;
		if(y - 1 >= 0) square[x][y - 1]++;
		if(y + 1 < 10) square[x][y + 1]++;

		if(size == 2 || size == 3){
			if(x - 1 >= 0 && y - 1 >= 0) square[x - 1][y - 1]++;
			if(x + 1 < 10 && y + 1 < 10) square[x + 1][y + 1]++;
			if(x - 1 >= 0 && y + 1 < 10) square[x - 1][y + 1]++;
			if(x + 1 < 10 && y - 1 >= 0) square[x + 1][y - 1]++;
		}

		if(size == 3){
			if(x - 2 >= 0) square[x - 2][y]++;
			if(x + 2 < 10) square[x + 2][y]++;
			if(y - 2 >= 0) square[x][y - 2]++;
			if(y + 2 < 10) square[x][y + 2]++;
		}
	}

	public int countBlank(){
		int result = 0;
		for(int i = 0; i < 10 ; i++){
			for(int j = 0; j < 10 ; j++){
				if(square[i][j] == 0){
					result++;
				}
			}
		}

		return result;
	}

	public int findMax(){
		int max = 0;
		for(int i = 0; i < 10 ; i++){
			for(int j = 0; j < 10 ; j++){
				if(square[i][j] > max){
					max = square[i][j];
				}
			}
		}

		return max;

	}
}

Measured memory_bytes: 24388
#include<bits/stdc++.h>
using namespace std;
#define what_is(x) cerr<<#x <<" is "<<x<<endl;
#define ll long long 
#define gcd(a,b) __gcd(a,b)
#define pi 2*acos(0.0)
#define endl "\n"
//use emplace_back() instead of push_back()
const ll mod=1e9+7;
template<typename T>
void print(T t)
{
    for(const auto& e:t)cout<<e<<" ";
    cout<<endl;
}
ll power(ll x, ll y, ll p) 
{ 
    int res = 1;
    x = x % p;
    while (y > 0) 
    {
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;
        x = (x*x) % p;   
    } 
    return res; 
} 
vector<int>g[1000001];
int vis[1000001];    
int in[100001];
int low[100001];
int timer=0;
vector<pair<int,int> >v;
int f;
void dfs(int n,int p)
{
    vis[n]=1;
    low[n]=in[n]=timer++;    
    if(timer!=1)v.push_back({p,n});
    for(auto ch:g[n])
    {
        if(ch==p)continue;
        if(vis[ch])
        {
            low[n]=min(low[n],in[ch]);
            if(in[n]>in[ch])v.push_back({n,ch});
        }
        else
        {
            dfs(ch,n);
            if(in[n]<low[ch]){f=1;return;}            
            low[n]=min(low[n],low[ch]);
        }
    }    
}
ll josephus(ll n) 
{
    ll p = 1; 
    while (p <= n) 
        p *= 2; 
    return (2 * n) - p + 1; 
}

bool isprime(ll n)
{
    if(n==1)return false;
    for(ll i=2;i*i<=n;i++)
    if(n%i==0)return false;
    return true;
}
vector<ll>aa;
void printallpf(ll n)
{
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            while(n%i==0)
            {
                aa.push_back(i);
                if(i!=n/i)
                if(isprime(n/i))aa.push_back(n/i),n=i;
                n=n/i;
            }
            
        }
    }    
}
void primeFactors(int n)  
{
       while (n % 2 == 0)  
    {  
        cout << 2 << " ";  
        n = n/2;  
    }  
  for (int i = 3; i <= sqrt(n); i = i + 2)  
    {    
        while (n % i == 0)  
        {  
            cout << i << " ";  
            n = n/i;  
        }  
    }
    if (n > 2)  
        cout << n << " ";  
}  
int dsu[100001];
void dsuunion(int u,int v)
{
	dsu[v]+=dsu[u];
	dsu[u]=v;
}
ll find(int a)
{
	if(dsu[a]<0)return a;
	else
	return dsu[a]=find(dsu[a]);
}
ll nod(ll x)
{
	ll cnt=0;
	while(x)
	{
		x=x>>1;
		cnt++;
	}
	return cnt;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,k,d,x;
    cin>>n>>k;
    map<ll,ll>m;
    while(k--)
    {
		cin>>d;
		while(d--)
		{
			cin>>x;
			m[x]++;
		}
	}
	ll cnt=0;
	for(ll i=1;i<=n;i++)
	{
		if(m[i]==0)cnt++;
	}
	cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 27132
mod=10**9+7
comb1=1
comb2=1
N,K=map(int,input().split())
k=min(K,N-1)
x=0
for i in range(k):
 comb1=(comb1*(N-i)*pow(i+1,mod-2,mod))%(mod)
 comb2=(comb2*(N-1-i)*pow(i+1,mod-2,mod))%(mod)
 x+=(comb1*comb2)%(mod)
print((x+1)%(mod))


Measured memory_bytes: 41580
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
/******************************************
* AUTHOR : PANDRAVISAM SHIVA SANTHOSH *
* Handle : santhosh_80 *
* INSTITUTION : IIT Palakkad *
******************************************/
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
#define ll long long int 
#define mod 1000000007
#define rep(i,a,b) for(int i=a;i<b;i++)
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define S(x) scanf("%d",&(x))
#define P(x) printf("%d\n",(x))
#define Sl(x) scanf("%lld",&(x))
#define Pl(x) printf("%lld\n",(x))
#define pb push_back
#define f first
#define s second


int main() {
	ll x,y,a,b,c ; cin >> x >> y >> a >> b >> c ;
	vector<ll> ai(a),bi(b),ci(c) ;
	for(int i = 0; i < a ; i++)cin>>ai[i];
	for(int i = 0; i < b ; i++)cin>>bi[i];
	for(int i = 0; i < c ; i++)cin>>ci[i];
	sort(ai.begin(),ai.end(),greater<ll>());
	sort(bi.begin(),bi.end(),greater<ll>());
	sort(ci.begin(),ci.end());
	vector<ll> comb ;
	for(int i = 0; i < x ; i++)comb.pb(ai[i]);
	for(int i = 0; i < y ; i++)comb.pb(bi[i]);
	sort(comb.begin(),comb.end(),greater<ll>()) ;

	for(int i = 0; i < comb.size() ; i++){

		int index = upper_bound(ci.begin(),ci.end(),comb[i]) - ci.begin() ;
		//cout << index << " " ;
		int num_of_elements = c-index;

		if(num_of_elements >= (x+y-i)){
			
			int k = 1;
			for(int j = i ; j < comb.size() ; j++){
				comb[j] = ci[c-k] ;
				k++;
			}
			break ;
		}
	}

	
	ll ans = 0 ;
	for(auto x : comb)ans+=x;
	cout << ans ;
	return 0 ;
}

Measured memory_bytes: 4724
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define U 998244353
#define N 1000005
#define int long long
#define sz(c) (int)c.size()
#define fr first
#define ll long long 
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a ; i<n ; i++)
#define r0 return 0;
#define endl '\n'
#define INF (int)1e15
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
signed main()
{
	ios_base::sync_with_stdio(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{   
		int n,s;
		cin >> n >> s;
		int a[n];
		rep(i,0,n) cin >> a[i];
		int dp[s]={};
		int ans = 0;
		rep(i,0,n){
			for(int j=s-a[i]; j>=1; j--){
				if(j+a[i]<s) dp[j+a[i]]=(dp[j+a[i]]+dp[j])%U;
				else if(j+a[i]==s) {
					ans += ((n-i)*(dp[j]%U))%U;
				}
				// trace(sz(dp[j]));
			}
			// cout << endl;
			if(a[i]<s) dp[a[i]]=(dp[a[i]]+i+1)%U;
			else if(a[i]==s){
				ans += (n-i)*(i+1);
				ans %= U;
			}
		}
		ans %=U;
		cout << ans;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
    int N, L, ans, sm, smi; cin >> N >> L;
    ans = smi = 0;
    sm = N_MAX;
    int tastes[N];
    for (int i = 0; i < N; i++)
    {
        tastes[i] = L+i;
        if (sm > abs(tastes[i]))
        {
            sm = abs(tastes[i]);
            smi = i;
        }
    }
    for (int j = 0; j < N; j++)
    {
        if (j != smi)
        {
            ans += tastes[j];
        }
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    long int W, H, x, y;
    long double area;

    scanf("%ld%ld%ld%ld", &W, &H, &x, &y);

    area = (long double)(W * H) / 2;

    printf("%Lf ", area);

    if (2 * x == W && 2 * y == H)
        printf("1\n");
    else 
        printf("0\n");

    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <inttypes.h>

int D;
int64_t G;
int p[16];
int64_t c[16];

int main(void) {
	int i;
	int search;
	int hayamisaori = 99999999;
	if (scanf("%d%" SCNd64, &D, &G) != 2) return 1;
	for (i = 0; i < D; i++) {
		if (scanf("%d%" SCNd64, &p[i], &c[i]) != 2) return 1;
	}
	for (search = 0; search < (1 << D); search++) {
		int64_t mizuhasu = 0;
		int asumisu = 0;
		for (i = 0; i < D; i++) {
			if ((search >> i) & 1) {
				mizuhasu += (i + 1) * INT64_C(100) * p[i] + c[i];
				asumisu += p[i];
			}
		}
		for (i = D - 1; i >= 0; i--) {
			if (!((search >> i) & 1)) {
				int64_t tomatu = G - mizuhasu;
				int64_t inorinn = (i + 1) * INT64_C(100);
				if (tomatu > 0) {
					int64_t sumipe = (tomatu + inorinn - 1) / inorinn;
					int mikakosi = sumipe >= p[i] ? p[i] - 1 : (int)sumipe;
					mizuhasu += inorinn * mikakosi;
					asumisu += mikakosi;
				}
			}
		}
		if (mizuhasu >= G && asumisu < hayamisaori) hayamisaori = asumisu;
	}
	printf("%d\n", hayamisaori);
	return 0;
}


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

signed main(){
    int n;
    ll a,b;
    cin >> n >> a >> b;
    ll x[n];
    REP(i,n){
        cin >> x[i];
    }
    ll ans = 0;
    REP(i,n - 1){
        if(x[i + 1] - x[i] <= b / a) ans += a * (x[i + 1] - x[i]);
        else ans += b;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
import java.io.*
import java.util.*
import java.lang.Math.*


fun main() {
    val (N,M) = rd.readIntArray()
    val egs = edge<Int>(N)
    for (i in 0 until M) {
        var (A, B) = rd.readIntArray()
        A--;B--
        egs[A].add(B)
        egs[B].add(A)
    }

    val que = ArrayDeque<Int>()
    que.push(0)
    val dist = IntArray(N){INF}
    dist[0] = 0
    val pre = IntArray(N){-1}
    while (que.isNotEmpty()) {
        val x = que.removeFirst()

        for (nx in egs[x]) {
            if (dist[nx] > dist[x] + 1) {
                dist[nx] = dist[x] + 1
                pre[nx] = x
                que.addLast(nx)
            }
        }
    }

    println("Yes")
    for (i in 1 until N) {
        println(pre[i]+1)
    }
}


//val rd = debug.Reader("abc", "168", "d", "sample-1")
val rd = Reader()
fun main(args: Array<String>) {
    Thread(null, MainThread(), "mainThread", 128 * 1024 * 1024).start()
}


const val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2
val EPS = 1e-9; fun DBLEQ(a: Double, b: Double): Boolean {return abs(a - b) < EPS}
data class IntPair(val first: Int, val second: Int)
data class To(val idx: Int, val cost: Long)
fun <T>edge(V: Int): Array<ArrayList<T>> { return Array(V){ArrayList<T>()} }
val errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }
class MainThread : Runnable {
    override fun run() { main() }
}
class Reader {
    private val br = BufferedReader(InputStreamReader(System.`in`))
    val readString: () -> String = { br.readLine() }
    val readInt: () -> Int = { br.readLine().toInt() }
    val readLong: () -> Long = { br.readLine().toLong() }
    val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }
    val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }
    val readListInt: () -> List<Int> = { br.readLine().split(' ').map { it.toInt() } }
    val readListLong: () -> List<Long> = { br.readLine().split(' ').map { it.toLong() } }
}


Measured memory_bytes: 78092
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr ll mod = 1e9 + 7;

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

/*-------------------------------------------*/

struct Point {
    double x, y;
    Point(double x = 0, double y = 0) : x(x), y(y) {}
    Point operator+(const Point &p) { return Point{x + p.x, y + p.y}; }
    Point operator-(const Point &p) { return Point{x - p.x, y - p.y}; }
    Point operator*(const double k) { return Point{x * k, y * k}; }
    Point operator/(const double k) { return Point{x / k, y / k}; }

    double norm() { return x * x + y * y; }
    double abs() { return sqrt(norm()); }
};
typedef Point Vector;
struct Segment {
    Point p1, p2;
};
typedef Segment Line;
struct Circle {
    Point c;
    double r;
    Circle(Point c = Point(), double r = 0) : c(c), r(r) {}
};
typedef vector<Point> Polygon;

double norm(Vector v) { return v.x * v.x + v.y * v.y; }
double abs(Vector v) { return sqrt(norm(v)); }

double dot(Vector a, Vector b) { return a.x * b.x + a.y * b.y; }
double cross(Vector a, Vector b) { return a.x * b.y - a.y * b.x; }

double getDistanceLP(Line l, Point p) {
    return abs(cross(l.p2 - l.p1, p - l.p1) / abs(l.p2 - l.p1));
}
double getDistanceSP(Segment s, Point p) {
    if(dot(s.p2 - s.p1, p - s.p1) < 0) return abs(p - s.p1);
    if(dot(s.p1 - s.p2, p - s.p2) < 0) return abs(p - s.p2);
    return getDistanceLP(s, p);
}

bool isOrthogonal(Vector a, Vector b) { return dot(a, b) == 0; }
bool isOrthogonal(Point a1, Point a2, Point b1, Point b2) {
    return isOrthogonal(a1 - a2, b1 - b2);
}
bool isOrthogonal(Line l1, Line l2) {
    return isOrthogonal(l1.p2, l1.p1, l2.p2, l2.p1);
}

bool isParallel(Vector a, Vector b) { return cross(a, b) == 0; }
bool isParallel(Point a1, Point a2, Point b1, Point b2) {
    return isParallel(a1 - a2, b1 - b2);
}
bool isParallel(Line l1, Line l2) {
    return isParallel(l1.p1, l1.p2, l2.p1, l2.p2);
}

Point project(Line l, Point p) {
    Vector base = l.p2 - l.p1;
    double r = dot(p - l.p1, base) / base.norm();
    return l.p1 + base * r;
}
Point reflect(Line l, Point p) { return p + (project(l, p) - p) * 2; }

static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;
string ccw(Point p0, Point p1, Point p2) {
    Vector a = p1 - p0;
    Vector b = p2 - p0;
    if(cross(a, b) > 0) return "COUNTER_CLOCKWISE";
    if(cross(a, b) < 0) return "CLOCKWISE";
    if(dot(a, b) < 0) return "ONLINE_BACK";
    if(a.norm() < b.norm()) return "ONLINE_FRONT";
    return "ON_SEGMENT";
}

int main() {
    Point p0, p1;
    cin >> p0.x >> p0.y >> p1.x >> p1.y;
    int n;
    cin >> n;
    while(n--) {
        Point p2;
        cin >> p2.x >> p2.y;
        cout << ccw(p0, p1, p2) << endl;
    }
}


Measured memory_bytes: 3276
#include <stdio.h>
#include <math.h>
int cnt[1000000];
int main(void){
    long long n,i,j,ans=0;
    scanf("%lld",&n);
    for(i=2;i<sqrt(n);i++){
        if(n==1) break;
        j = 1;
        while(n%i==0){
            n/=i;
            cnt[i-1]++;
            if(cnt[i-1]==j){
                ans++;
                j++;
                cnt[i-1]=0;
            }
        }
    }
    if(n!=1) ans++;
    printf("%lld",ans);
}

Measured memory_bytes: 2084
n=int(input())
a=list(map(int,input().split()))
sum=a[0]
max=a[0]
min=a[0]
for i in range(1,n):
    if max<a[i]:
        max=a[i]
    if min>a[i]:
        min=a[i]
    sum+=a[i]
print(min,max,sum)


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

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      for (int k = 1; k <= n; k++) {
        ans += (long long)__gcd(i, __gcd(j, k));
      }
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector<int>
#define vll vector<ll>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pb  push_back
#define ppb pop_back
#define mp  make_pair
int main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	ll n;
	cin>>n;
	string str;
	cin>>str;
	ll cnt=0;
	for(ll i=0;i<n-2;++i){
		if(str[i]=='A'&&str[i+1]=='B'&&str[i+2]=='C'){
			cnt++;
			i=i+2;
		}
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, fractions, itertools

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(N: int, M: int, A: "List[str]", B: "List[str]"):
    f = False
    for i in range(N-M+1):
        for j in range(N-M+1):
            flag = True
            for k in range(M):
                for l in range(M):
                    if A[i+k][j+l] != B[k][l]:
                        flag = False
            if flag:
                f = True
    if f:
        print('Yes')
    else:
        print('No')
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [ next(tokens) for _ in range(N) ]  # type: "List[str]"
    B = [ next(tokens) for _ in range(M) ]  # type: "List[str]"
    solve(N, M, A, B)

if __name__ == '__main__':
    main()


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

#define boost ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)

using namespace std;
using LL = long long;

constexpr int MAXN = 2e5 + 5;

template <typename T>
inline void read(T &x) {
    int f = 1;
    x = 0;
    char ch = getchar();
    while (!isdigit(ch)) f = (ch == '-') ? -1 : 1, ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();
    x *= f;
}

int n, m, h[MAXN], cnt;
vector<int> G[MAXN];

int main() {
    // freopen("test.in", "r", stdin);
    // freopen("test.out", "w", stdout);
    boost;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) cin >> h[i];
    for (int i = 1, u, v; i <= m; i++) {
        cin >> u >> v;
        G[u].push_back(v), G[v].push_back(u);
    }
    for (int i = 1; i <= n; i++) {
        cnt++;
        for (auto &to: G[i]) {
            if (h[i] <= h[to]) {
                cnt--;
                break;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

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

int main()
{
	int  S,h,m,s;
	cin >> S;

	h = S/(60*60);
	m = (S-h*60*60)/60;
	s = (S-h*60*60)-m*60;

	cout << h << ":" << m  << ":" << s << endl;

	return 0;
}

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

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

    sort(a.begin(),a.end());
    cout << a.back() - a.front() << endl;
}

Measured memory_bytes: 256
<?php
// E
fscanf(STDIN, '%d %d %d %d %d', $x, $y, $a, $b, $c);
$p = array_map('intval', explode(' ', trim(fgets(STDIN))));
$q = array_map('intval', explode(' ', trim(fgets(STDIN))));
$r = array_map('intval', explode(' ', trim(fgets(STDIN))));

rsort($p);
rsort($q);

$pp = array_splice($p, 0, $x);
$qq = array_splice($q, 0, $y);

$arr = array_merge($pp, $qq, $r);

rsort($arr);
$arr = array_splice($arr, 0, $x + $y);

$ans = array_sum($arr);
echo $ans;

Measured memory_bytes: 41468
#include <iostream>
#include<algorithm>
#include <vector>
#include<string>
#include<cmath>
#include<cstdio>
using namespace std;
typedef long long ll;
#define max(x,y) (((x)>(y)) ? x:y)
#define min(x,y) (((x)<(y)) ? x:y)
#define FOR(a,b,c) for(b=(c);b<(a);b++)
#define zettaiti(a) ((a) > 0 ? a : -a)
int kakuinowa(long x);
int main() {
	int n;
	cin >> n;
	if (n % 2 == 0) {
		cout << n;
	}
	else {
		cout << 2 * n;
	}
	return 0;
}
int kakuinowa(long x) {
	int y = 0;
	while (x>10)
	{
		y += x % 10;
		x /= 10;
	}
	y += x;
	return y;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <string>
#include <typeinfo>
#include <random>
#include <vector>
//#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;
 
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define all(a) (a).begin(), (a).end()

int main()
{
	int h,w;
	cin>>h>>w;
	vs board(h);
	rep(i,h){
		cin>>board.at(i);
	}
	bool ok;
	vvb checked(h,vb(w,false));
	vi dx{1,0,-1,0};
	vi dy{0,-1,0,1};
	rep(i,h){
		rep(j,w){
			ok=false;
			if(board.at(i).at(j)=='#'){
				rep(k,4){
					if(i+dy.at(k)<0 || i+dy.at(k)>h-1 || j+dx.at(k)<0 || j+dx.at(k)>w-1){
						continue;
					}else{
						if(board.at(i+dy.at(k)).at(j+dx.at(k))=='#'){
							ok=true;
						}
					}
				}
				if(!ok){
					goto A;
				}
			}
		}
	}
	
	cout<<"Yes"<<endl;
	return 0;
	
	A:
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys
import os
import math

N = int(input())

A = [None] * N
for i in range(N):
    id, num = map(int, input().split())
    id -= 1
    A[id] = num

max_value = max(A)
max_index = A.index(max_value)
print(max_index + 1, max_value)

Measured memory_bytes: 7692
#include <iostream>

int main() {
    int n ;
    int a[ 100 ] ;
    
    std::cin >> n ;
    
    for( int i = 0 ; i < n ; i++ ) {
        std::cin >> a[ i ] ;
    }
    
    for( int ii = n - 1 ; ii >= 0 ; ii-- ) {
        std::cout << a[ ii ] ;
        if( ii != 0 ) std::cout << " " ;
    }
    std::cout << std::endl ;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define maxn 100005
using namespace std;
int dp[maxn][3];
int main(){
	ios::sync_with_stdio ( false );
	cin.tie(0);
	int n, a, b, c;
	cin >> n;
	for ( int i=1; i<=n; ++i ){
		cin >> a >> b >> c;
		dp[i][0] = max(dp[i-1][1], dp[i-1][2])+a;
		dp[i][1] = max(dp[i-1][0], dp[i-1][2])+b;
		dp[i][2] = max(dp[i-1][0], dp[i-1][1])+c;
	}
	cout << max(max(dp[n][0], dp[n][1]), dp[n][2]) << '\n';
	return 0;
}


Measured memory_bytes: 1408
import collections
N=int(input())
A=list(map(int,input().split()))

A1=[]
A2=[]
for i in range(len(A)):
    if i%2==0:
        A1.append(A[i])
    else:
        A2.append(A[i])
        
B1=collections.Counter(A1)
B2=collections.Counter(A2)

if N==2:
    print(0)

elif B1.most_common(2)[0][1]==B2.most_common(2)[0][1] and B1.most_common(2)[0][1]==int(N/2):
    if B1.most_common(1)==B2.most_common(1):
        print(int(N/2))
    else:
        print(0)
else:
    
    
    if B1.most_common(1)==B2.most_common(1):
        
        if B1.most_common(2)[1][1]>=B2.most_common(2)[1][1]:
            ans=N-B1.most_common(2)[1][1]-B2.most_common(2)[0][1]
        else:
            ans=N-B2.most_common(2)[1][1]-B1.most_common(2)[0][1]
    elif B1.most_common(2)[0][0]==B2.most_common(2)[0][0]:
        if B1.most_common(2)[0][1]>=B2.most_common(2)[0][1]:
            ans=N-B1.most_common(2)[0][1]-B2.most_common(2)[1][1]
        else:
            ans=N-B2.most_common(2)[0][1]-B1.most_common(2)[1][1]
    else:
        ans=N-B1.most_common(2)[0][1]-B2.most_common(2)[0][1]
    print(ans)


Measured memory_bytes: 19168
N, K = map(int, input().split())
S = input()

ans = 0
RL = 0
LR = 0

for i in range(N-1):
    if S[i] == S[i+1]:
        ans += 1
    elif S[i] == "R" and S[i+1] == "L":
        RL += 1
    elif S[i] == "L" and S[i+1] == "R":
        LR += 1
if RL != 0 and LR != 0 and LR <= RL:
    ans += 2 * min(K, LR)
elif RL != 0 and LR != 0 and LR-RL == 1:
    ans += min(2*K, 2*RL+1)
elif RL != 0 and LR != 0:
    ans += 2 * min(K, RL+1)
else:
    ans = N-1
print(ans)

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

#define ll long long
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    ll n, d, a;
    cin >> n >> d >> a;
    vector < pair < ll,ll> > v;
    for(int i = 1; i <= n ; i++){
        int x, h;
        cin >> x >> h;
        v.push_back({x, h});
    }
    set < pair <ll,ll > > st;
    sort(v.begin(), v.end());
    ll sum = 0 ;
    ll ans = 0;
    for(int i = 0 ; i < n ; i++) {
        while(st.size() && st.begin()->first < v[i].first) {
            sum -= st.begin()->second;
            st.erase(st.begin());
        }
        if (sum >= v[i].second) continue;
        ll tmp = (abs(sum - v[i].second) + a - 1) / a;
        ans += tmp;
        sum += tmp * a;
        st.insert({v[i].first + 2 * d, tmp * a});
    }
    cout << ans;
    return 0;
}


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

int main()
{
	int n;cin >> n;
	double x;string u ;
	double s=0;
	for(int i=0;i<n;i++){
		cin >> x >> u ;
		if(u=="BTC") s+=x*380000.0;
		else s+=x;
	}
	cout <<s;
	return 0;
}

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())

void Yes(){
	cout<<"Yay!"<<endl;
}
void No(){
	cout<<":("<<endl;
}

signed main(){

	lli n;
	cin>>n;

	REP(i,0,100000){
		if(i*108/100 == n){
			cout<<i<<endl;
			return 0;
		}
	}

	No();

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define REP(name, start, stop) for (auto(name) = (start); (name) < (stop); (name)++)
using ll = long long;
using vi = vector<ll>;

int main(void) {
    ll l;
    cin >> l;
    double w, h;
    w = h = l / 3.0;
    double d = double(l) - (w + h);
    double ans = w * h * d;
    cout << fixed << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<bitset>
#include<set>
#define N (3010)
#define P ()
#define M ()
#define inf (0x7f7f7f7f)
#define rg register int
#define Label puts("NAIVE")
#define spa print(' ')
#define ent print('\n')
#define rand() (((rand())<<(15))^(rand()))
#define file(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
typedef long double ld;
typedef long long LL;
typedef unsigned long long ull;
using namespace std;
namespace fastIO1{
	inline char read(){
		static const int IN_LEN=1000000;
		static char buf[IN_LEN],*s,*t;
		return (s==t?t=(s=buf)+fread(buf,1,IN_LEN,stdin),(s==t?-1:*s++):*s++);
	}
	template<class T>
	inline void read(T &x){
		static bool iosig;
		static char c;
		for(iosig=false,c=read();!isdigit(c);c=read()){
			if(c=='-')iosig=true;
			if(c==-1)return;
		}
		for(x=0;isdigit(c);c=read())x=((x+(x<<2))<<1)+(c^'0');
		if(iosig)x=-x;
	}
	inline char readc(char &c){
		for(c=read();!isalpha(c)&&!isdigit(c);c=read())
		if(c==-1)return 0;
	}
	const int OUT_LEN = 10000000;
	char obuf[OUT_LEN],*ooh=obuf;
	inline void print(char c){
		if(ooh==obuf+OUT_LEN)fwrite(obuf,1,OUT_LEN,stdout),ooh=obuf;
		*ooh++=c;
	}
	template<class T>
	inline void print(T x){
		static int buf[30],cnt;
		if(x==0)print('0');
		else{
			if(x<0)print('-'),x=-x;
			for(cnt=0;x;x/=10)buf[++cnt]=x%10+48;
			while(cnt)print((char)buf[cnt--]);
		}
	}
	inline void flush(){fwrite(obuf,1,ooh-obuf,stdout);}
}
namespace fastIO2{
	template<class T>
	inline void read(T &x){
		static bool iosig;
		static char c;
		for(iosig=false,c=getchar();!isdigit(c);c=getchar()){
			if(c=='-')iosig=true;
			if(c==-1)return;
		}
		for(x=0;isdigit(c);c=getchar())x=((x+(x<<2))<<1)+(c^'0');
		if(iosig)x=-x;
	}
}
using namespace fastIO1;
#define int long long
int n,L,a[N];
ld sx,sy;
ld PI=acos(-1);
signed main(){
	read(n),read(L),L*=2;
	for(int i=1;i<=n;i++)read(a[i]),a[i]*=2;
	for(int i=1;i<=n;i++)
	for(int j=i+1;j<=n;j++){
		//cout<<i<<" dd "<<j<<endl;
		int m1=(a[i]+a[j])/2;
		int m2=(a[j]+(L-(a[j]-a[i]))/2)%L;
		ld xa=cos(m1/(ld)L*2.0*PI),xb=cos(m2/(ld)L*2.0*PI);
		ld ya=sin(m1/(ld)L*2.0*PI),yb=sin(m2/(ld)L*2.0*PI);
		//printf("%d %d (%.10Lf,%.10Lf),(%.10Lf,%.10Lf)\n",m1,m2,xa,ya,xb,yb);
		//cout<<n-(j-i)-1<<" "<<j-i-1<<endl;
		sx+=(xa*(n-(j-i)-1)+xb*(j-i-1)),sy+=(ya*(n-(j-i)-1)+yb*(j-i-1)); 
	}
	//cout<<n*(n-1)*(n-2)/6;
	printf("%.15Lf %.15Lf",sx/(1ll*n*(n-1)*(n-2)/6),sy/(1ll*n*(n-1)*(n-2)/6));
} 

Measured memory_bytes: 2560
X, Y, Z, K = map(int, input().split())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))

AB = sorted([a + b for a in A for b in B])[-1:-K-1:-1]
ABC = sorted([ab + c for ab in AB for c in C])[-1:-K-1:-1]
print('\n'.join(map(str, ABC)))


Measured memory_bytes: 142072
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<sstream>
#include<vector>
using namespace std;

double data[11][11];
double dp[1<<12][12];
int INF = 1 << 15;

int main(){
	for(int i=3;i<=10;i++){
		for(int j=3;j<=10;j++){
			data[i][j] = sqrt((double)((j+i)*(j+i)-(j-i)*(j-i)));
		}
	}
	int len;
	while( cin >> len ){
		string s;
		getline( cin, s );

		vector<int> cur;
		stringstream ss( s );
		while( !ss.eof() ){
			int r;
			ss >> r;
			cur.push_back( r );
		}
		int n = cur.size();

		for(int i=0;i<(1<<12);i++){
			fill(dp[i],dp[i]+12,INF);
		}
		for(int i=0;i<cur.size();i++){
			dp[1<<(i)][i]=cur[i];
		}

		for(int i=0;i<(1<<n);i++){
			for(int j=0;j<n;j++){
				if(dp[i][j] != INF){
					for(int k=0;k<n;k++){
						if(k==j){
							continue;
						}
						if(!(i&(1<<k))){
							if((i|(1<<k)) == ((1<<n)-1)){
								dp[i|(1<<k)][k] = min( dp[i|(1<<k)][k] , dp[i][j]+data[cur[k]][cur[j]]+cur[k]);
							}else{
								dp[i|(1<<k)][k] = min( dp[i|(1<<k)][k] , dp[i][j]+data[cur[k]][cur[j]]);
							}
						}
					}
				}
			}
		}
		bool flag = false;
		for(int i=0;i<n;i++){
			if(dp[(1<<n)-1][i] <= len){
				flag = true;
			}
		}
		if(flag){
			cout << "OK" << endl;
		}else{
			cout << "NA" << endl;
		}
	}
}

Measured memory_bytes: 1616
#include <iostream>
#include <cstdio>
#include<stdio.h>
#include<string.h>
#include <algorithm>

using namespace std;

int main()
{
    int i,j,n;

   char s[101];
   int sum,max=0,k;
   scanf("%d",&n);
   scanf("%s",s);

   for (i=0;i<n;i++)
   {
  int a[101]={0};
   int b[101]={0};
    for (k=0;k<=i;k++)
    a[s[k]-'a']=1;
    for(j=i+1;j<n;j++)
    b[s[j]-'a']=1;
         sum=0;
       for(j=0;j<26;j++)
        {
            if(a[j]==1&&b[j]==1)
            sum++;
        }
 if(sum>max)
    max=sum;
   }
   printf("%d",max);

return 0;

   }



Measured memory_bytes: 384
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
typedef long long ll;

//素因数分解
map<int64_t, int> prime_factor(int64_t n) {
    map<int64_t, int> ret;
    for(int64_t i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1)
        ret[n] = 1;
    return ret;
}

int main() {
    ll N;
    cin >> N;
    ll res = 1e17;
    for(ll i = 1; i * i <= N; i++) {
        if(N % i == 0)
            res = min((i - 1) + ((N / i) - 1), res);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>		//UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>		//do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)
#define ALL(u) (u).begin(),(u).end()

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

typedef pair<int, int> PII;

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;

const int MR = 60;
const int MOD = 1e9 + 7;

char s[2][MR];

int dp[MR][3];

int main()
{
	int N;
	scanf("%d%s%s", &N, s[0], s[1]);

	int st = 1, res = 3;
	if (s[0][0] != s[1][0])
	{
		st = 2;
		res = 6;
	}

	for (int i = st; i < N;)
	{
		if (s[0][i] == s[1][i])
		{
			if (s[0][i - 1] == s[1][i - 1])
				res = (res * 2) % MOD;

			i++;
		}
		else
		{
			if (s[0][i - 1] == s[1][i - 1])
				res = (res * 2) % MOD;
			else
				res = (res * 3LL) % MOD;

			i += 2;
		}
	}

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

	return 0;
}

Measured memory_bytes: 256