akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin>>N>>M;
  if(M>0){
    vector<int>p(M);
    vector<string>a(M);
    for(int i=0;i<M;i++)cin>>p[i]>>a[i];
    int tl=0;
    int wr=0;
    vector<char>sub(N,'x');
    for(int i=0;i<M;i++){
      if(sub[p[i]-1]=='o')continue;
      else if(a[i]=="WA")wr++;
      else  if(a[i]=="AC"){
        tl++;
        sub[p[i]-1]='o';
      }
    }
      for(int i=0;i<M;i++){
        if(sub[p[i]-1]=='x' &&a[i]=="WA")wr--;
      }
    
    cout<<tl<<" "<<wr<<endl;
  }else{
    cout<<0<<" "<<0<<endl;
  }
}

Measured memory_bytes: 6784
void main()
{
    long n = rdElem;
    long k = rdElem;
    long[] x = rdRow;

    long total;
    foreach (y; x)
    {
        total += 2 * min(y, k-y);
    }

    total.writeln;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
#2020-03-18
while True:
    ta,yo = map(int,input().split())
    if ta == yo == 0:
        break
    
    for tate in range(ta):
        for yoko in range(yo):
            if (tate + yoko) % 2 == 0:
                print("#", end="")
            else:
                print(".", end="")
        print()
    print()


Measured memory_bytes: 7004
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cassert>
#define ll long long
using namespace std;
inline ll read(){
    ll re=0,flag=1;char ch=getchar();
    while(ch>'9'||ch<'0'){
        if(ch=='-') flag=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9') re=(re<<1)+(re<<3)+ch-'0',ch=getchar();
    return re*flag;
}
ll n,K,cnt,a[200010],b[200010],tmp[500010],seg[500010],L[200010],R[200010],dp[200010],sum[200010];
void push(ll num){
    if(!seg[num]) return;
    seg[num<<1]=seg[num<<1|1]=seg[num];
    seg[num]=0;
}
void change(ll l,ll r,ll ql,ll qr,ll num,ll val){
    if(ql>qr) return;
    if(l>=ql&&r<=qr){seg[num]=val;return;}
    push(num);
    ll mid=(l+r)>>1;
    if(mid>=ql) change(l,mid,ql,qr,num<<1,val);
    if(mid<qr) change(mid+1,r,ql,qr,num<<1|1,val);
}
ll query(ll l,ll r,ll num,ll pos){
    if(l==r) return seg[num];
    push(num);
    ll mid=(l+r)>>1;
    if(mid>=pos) return query(l,mid,num<<1,pos);
    else return query(mid+1,r,num<<1|1,pos);
}
ll ask(ll pos){
    ll choose=query(1,cnt,1,pos);
    if(!choose) return 0;
    return (dp[choose]+(tmp[L[choose]]-tmp[pos]+K)%K);
}
ll erfen(ll val){
    ll l=1,r=cnt,mid;
    while(l<r){
        mid=(l+r)>>1;
        if(tmp[mid]>=val) r=mid;
        else l=mid+1;
    }
    assert(val==tmp[l]);
    return l;
}
int main(){
    n=read();K=read();ll i;
    for(i=1;i<=n;i++) {
        a[i]=read();b[i]=read();
        sum[i]=(sum[i-1]+a[i]);
        if(b[i]==2) continue;
        if(2*a[i]>K){
            puts("-1");return 0;
        }
    }
    for(i=1;i<=n;i++){
        if(b[i]==1){
            L[i]=(-2ll*sum[i-1]%K+K)%K;
            R[i]=(-2ll*sum[i]%K+K)%K;
        }
        else L[i]=0,R[i]=K-1;
        tmp[++cnt]=L[i],tmp[++cnt]=R[i];
    }
    sort(tmp+1,tmp+cnt+1);
    cnt=unique(tmp+1,tmp+cnt+1)-tmp-1;
    for(i=n;i>=1;i--){
        L[i]=erfen(L[i]);
        R[i]=erfen(R[i]);
        dp[i]=ask(L[i]);
        if(L[i]>R[i]) change(1,cnt,R[i]+1,L[i]-1,1,i);
        else change(1,cnt,1,L[i]-1,1,i),change(1,cnt,R[i]+1,cnt,1,i);
    }
    ll ans=dp[1];
    for(i=1;i<=cnt;i++) ans=min(ans,ask(i));
    printf("%lld\n",ans+sum[n]*2ll);
}

Measured memory_bytes: 16000
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (n, k) = (v[0], v[1]);
    let p = read_vec::<i64>();

    if n == k {
        println!("1");
        return;
    }

    let spans_sorted = (1..n)
        .map(|i| if p[i] > p[i - 1] { 1 } else { 0 })
        .collect::<Vec<_>>();

    let mut sum = vec![0; n];
    for i in 0..n - 1 {
        sum[i + 1] += sum[i] + spans_sorted[i];
    }

    let mut ordered = vec![false; n - k + 1];
    // debug!(sum);
    let mut ans = 0;
    for i in 0..n + 1 - k {
        ordered[i] = sum[i + k - 1] - sum[i] == k - 1;
        if !ordered[i] {
            ans += 1;
        }
    }
    // debug!(ordered);

    if ordered.iter().any(|&x| x) {
        ans += 1;
    }

    let s_mins = slide_minimum(&p, k + 1);
    let s_maxs = slide_maximum(&p, k + 1);

    for i in 0..ordered.len() - 1 {
        if !ordered[i] && !ordered[i + 1] {
            if s_mins[i] == p[i] && s_maxs[i] == p[i + k] {
                ans -= 1;
            }
        }
    }

    println!("{}", ans);
}

fn slide_minimum(a: &Vec<i64>, k: usize) -> Vec<i64> {
    assert!(k <= a.len());
    let mut s = 0;
    let mut t = 0;
    let mut deq = vec![0; a.len()];
    let mut ans = vec![0; a.len() - k + 1];
    for i in 0..a.len() {
        while s < t && a[deq[t - 1]] >= a[i] {
            t -= 1;
        }
        deq[t] = i;
        t += 1;

        if i + 1 >= k {
            ans[i + 1 - k] = a[deq[s]];
            if deq[s] == i + 1 - k {
                s += 1;
            }
        }
    }
    ans
}

fn slide_maximum(a: &Vec<i64>, k: usize) -> Vec<i64> {
    assert!(k <= a.len());
    let mut s = 0;
    let mut t = 0;
    let mut deq = vec![0; a.len()];
    let mut ans = vec![0; a.len() - k + 1];
    for i in 0..a.len() {
        while s < t && a[deq[t - 1]] <= a[i] {
            t -= 1;
        }
        deq[t] = i;
        t += 1;

        if i + 1 >= k {
            ans[i + 1 - k] = a[deq[s]];
            if deq[s] == i + 1 - k {
                s += 1;
            }
        }
    }
    ans
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

#define ll long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define vi vector<int>
using namespace std;
int mod = 1'000'000'000 + 7;
namespace uf {
    vector<int> par, rank;

    void init(int n) {
        par.resize(n);
        rank.resize(n);
        for (int i = 0; i < n; i++) {
            par[i] = i;
            rank[i] = 0;
        }
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        } else {
            return par[x] = root(par[x]);
        }
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y)return;
        if (rank[x] < rank[y]) {
            par[x] = y;
        } else {
            par[y] = x;
            if (rank[x] == rank[y])rank[x]++;
        }
    }
}
namespace choose {
    vector<vector<ll>> v;
    vector<ll> vv;

    void init_simple(int N) {
        vv.resize(1);
        vv[0] = 1;
        v.push_back(vv);
        for (int i = 1; i <= N; i++) {
            vv.resize(i + 1);
            for (int j = 1; j < i; j++) {
                vv[j] = v[i - 1][j - 1] + v[i - 1][j];
            }
            vv[i] = 1;
            v.push_back(vv);
        }
    }

    ll simple(int p, int q) {
        return v[p][q];
    }
}
namespace prime {
    vector<bool> is_not_prime{1, 1, 0};

    void make_is_not_prime(int N) {
        int l = is_not_prime.size();
        if (l >= N + 1) {
            return;
        }
        is_not_prime.resize(N + 1);
        for (int i = 2; i <= N; i++) {
            if (!is_not_prime[i]) {
                for (int j = max(((l + i - 1) / i) * i, i + i); j <= N; j += i) {
                    is_not_prime[j] = 1;
                }
            }
        }
    }

    vector<ll> list(ll a, ll b) {
        //{a, b)
        a = max(2LL, a);
        set<ll> st;
        for (ll i = a; i < b; i++) {
            st.insert(i);
        }
        ll l = sqrt(b);
        make_is_not_prime(l);
        for (ll i = 2; i <= l; i++) {
            if (!is_not_prime[i]) {
                for (ll j = max(((a + i - 1) / i) * i, i + i); j < b; j += i) {
                    st.erase(j);
                }
            }
        }
        vector<ll> res;
        for (auto x:st) {
            res.push_back(x);
        }
        return res;
    }
}

ll pow_mod(ll n, ll k, ll m) {
    ll r = 1;
    for (; k > 0; k >>= 1) {
        if (k & 1) r = (r * n) % m;
        n = (n * n) % m;
    }
    return r;
}

ll Manhattan(ll a, ll b, ll c, ll d) {
    return abs(a - c) + abs(b - d);
}

ll Manhattan(pair<ll, ll> a, pair<ll, ll> b) {
    return abs(a.first - b.first) + abs(a.second - b.second);
}

ll gcd(ll a, ll b) {
    if (b == 0)return a;
    return gcd(b, a % b);
} // C++17
void COME_LET_THE_GAMES_BEGIN() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(20);
}

ll N;

int main() {
    COME_LET_THE_GAMES_BEGIN();
    cin >> N;
    int i;
    for (i = 1; i <= N; i *= 2) {

    }
    cout << i / 2 << endl;

}

Measured memory_bytes: 256
#include <stdio.h>          // printf(), scanf()
#include <math.h>           // ceil()
#include <stdbool.h>

int
main(int argc, char **argv)
{
	                         //   1    2    3    4    5    6    7 x
	const int toll_t[7][7] = {{   0, 300, 500, 600, 700,1350,1650},  // 1x
	                          { 300,   0, 350, 450, 600,1150,1500},  // 2x
	                          { 500, 350,   0, 250, 400,1000,1350},  // 3x
	                          { 600, 450, 250,   0, 250, 850,1300},  // 4x
	                          { 700, 600, 400, 250,   0, 600,1150},  // 5x
	                          {1350,1150,1000, 850, 600,   0, 500},  // 6x
	                          {1650,1500,1350,1300,1150, 500,   0}}; // 7x

	                         // 1   2   3   4   5   6   7 x
	const int dist_t[7][7] = {{ 0,  6, 13, 18, 23, 43, 58},  // 1x
	                          { 6,  0,  7, 12, 17, 37, 52},  // 2x
	                          {13,  7,  0,  5, 10, 30, 45},  // 3x
	                          {18, 12,  5,  0,  5, 25, 40},  // 4x
	                          {23, 17, 10,  5,  0, 20, 35},  // 5x
	                          {43, 37, 30, 25, 20,  0, 15},  // 6x
	                          {58, 52, 45, 40, 35, 15,  0}}; // 7x

	const int time1 = 17 * 60 + 30;
	const int time2 = 19 * 60 + 30;

	while (true)
	{
		int d;
		scanf("%d", &d);
		if (d == 0)
			break;

		d--;
		int h, m;
		scanf("%d%d", &h, &m);
		int t_src = 60 * h + m;

		int a;
		scanf("%d", &a);
		a--;
		scanf("%d%d", &h, &m);
		int t_dest = 60 * h + m;

		int dist = dist_t[d][a];
		int toll;
		if (((time1 <= t_dest && t_dest <= time2) || (time1 <= t_src && t_src <= time2)) && dist <= 40)
		{
			double b = toll_t[d][a] / (2.0 * 50.0);
			toll = ceil(b) * 50;
		}
		else
			toll = toll_t[d][a];

		printf("%d\n", toll);
	}

	return 0;
}


Measured memory_bytes: 1748
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<time.h>
#include<math.h>
#include<assert.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384
int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int nHr(int a,int b){return nCr(a+b-1,b);}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int dsum(int x){int r=0;while(x){r+=(x%10);x/=10;}return r;}
int dsumb(int x,int b){int r=0;while(x){r+=(x%b);x/=b;}return r;}
int sankaku(int x){return ((1+x)*x)/2;}
void swap(int *a,int *b){int c;c=(*a);(*a)=(*b);(*b)=c;}
//小さい順
int compareInt(const void* a, const void* b){int aNum = *(int*)a;int bNum = *(int*)b;return aNum - bNum;}

long long _gcd(long long a,long long b){
    long long c;
    while(b!=0){c=a%b;a=b;b=c;}
    return a;
    
}
long long _lcm(long long a,long long b){long long c=_gcd(a,b);a/=c;return a*b;}

int main(void){
    int N;
    int sum=0;
    scanf("%d",&N);
    int p[N];
    for(int i=0;i<N;i++){
        scanf("%d",&p[i]);
    }
    for(int i=0;i<N;i++){
        if(p[i]!=i+1){
            sum++;
        }else{
            ;
        }
    }
    if(sum<=2){
        printf("YES");
        return 0;
    }else{
        printf("NO");
    }
}
    


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    string n;
    cin >> n;
    rep(i, n.size()) {
        if(n[i]=='7') {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3628
i = input().split()
a = int(i[0])
b = int(i[1])
k = int(i[2])
if a >= k:
  a = a - k
else:
  if (k - a) >= b:
    a = 0
    b = 0
  else:
    b = b - (k - a)
    a = 0
print(a," ",b)

Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <limits>
#include <ios>
#include <iomanip>
#include <stdio.h>
using namespace std;

#define rep(i,N) for(int i=0; i<N; i++)
#define revrep(i,N) for(int i=N-1; i>=0; i--)
#define coutline cout<<"------------ ("<<__LINE__<<")"<<endl;

typedef long long ll;

int main(void)
{

    string S;
    cin >> S;

    string sub1 = S.substr(0,2);
    string sub2 = S.substr(2,2);
    int num1 = atoi(sub1.c_str());
    int num2 = atoi(sub2.c_str());

    if (1 <= num1 && num1 <= 12 &&
        1 <= num2 && num2 <= 12) {

        cout << "AMBIGUOUS" << endl;
    } else if (1 <= num1 && num1 <= 12) {
        cout << "MMYY" << endl;
    } else if (1 <= num2 && num2 <= 12) {
        cout << "YYMM" << endl;
    } else {
        cout << "NA" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
S = input()
L = [-1]*len(S)
R = [-1]*len(S)

## L方向
l_idx = 0
for idx,s in enumerate(S):
  if s == "R":
    l_idx = 0
  else:
    L[idx] = l_idx
    l_idx += 1

r_idx = 0
for idx,s in enumerate(reversed(S)):
  if s == "L":
    r_idx = 0
  else:
    R[len(S)-idx-1] = r_idx
    r_idx += 1


ans = [0]*len(S)
for idx,l in enumerate(L):
  if l>=0:
    ans[idx -((l+1)//2)*2 ] += 1
for idx,r in enumerate(R):
  if r>=0:
    ans[idx + ((r+1)//2)*2 ] += 1
print(" ".join(list(map(str,ans))))


Measured memory_bytes: 51440
/**
 *    author:  nasimnoob
**/

#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<math.h>
using namespace std;

typedef long long                       ll;
typedef unsigned long long              ull;
typedef long double                     ld;


#define      PI                         3.141592654


int main()
{
    //string ;
    ll a,b,c,n,d;
    cin>>n>>a>>b;
    c = a+b;
    ll k = a*(n/c);
    k  += min(n%c,a);
    cout<<k<<endl;
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define forn(i,n)for(ll i=0;i<(n);i++)
#define forn_rev(i,n)for(ll i=(n)-1;i>=0;i--)
#define for1n(i,n) for(ll i=1;i<=(n);i++)
#define ARRAY_SIZE(a) sizeof(a)/sizeof(*a)
#define INF 1e9+5
using namespace std;


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);cout.tie(NULL);
    ll N,K;
    cin>>N>>K;
    vector<ll> height(N+1);
    forn(i,N) cin>>height[i];
    vector<ll> dp(N+1,INF);
    dp[0]=0;
    //General case. Start main i from zero.
    for(ll i=0;i<N;i++){
        for(ll j=i+1;j<=i+K && j<N;j++)//Take j as variable looping through all possible paths
            dp[j]=min(dp[j],dp[i]+abs(height[i]-height[j]));//find minimum if that dp[j] exists otherwise 
            //take my main i and o that add that height at which j is present
    }
    cout<<dp[N-1];
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
string a;
int main(){
	cin>>a;
	bool flag=false;
	for(int i=0;i<a.size();i++){
		if(a[i]=='C')flag=true;
		if(flag&&a[i]=='F'){
			cout<<"Yes"<<endl;
			exit(0);
		}
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=100100;
int i,j,k,n,ch,ff;
int a[N];
void R(int &x) {
	ff=x=0;ch=getchar();
	while (ch<'0' || '9'<ch) { if (ch=='-') ff=1;ch=getchar();}
	while ('0'<=ch && ch<='9') x=x*10+ch-'0',ch=getchar();
	if (ff) x=-x;
}
int main() {
	R(n);
	for (i=1;i<=n;i++) R(a[i]);
	sort(a+1,a+n+1);
	for (i=1;i+i<=n;i++) swap(a[i],a[n-i+1]);
	int x=1;
	while (a[x+1]>=x+1) x++;
	int u=a[x]-x+1,r=1;
	while (x<=a[x+r]) r++;
	if (!(u&1) || !(r&1)) puts("First");
	else puts("Second");
}

Measured memory_bytes: 512
import java.util.*;

class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        int N = sc.nextInt();
                        String S = sc.next();
                        int now = 0, ans = 0;
                        for (int i = 0; i < N; i++) {
                                if (S.charAt(i) == 'I') {
                                        now++;
                                        ans = Math.max(now, ans);
                                } else {
                                        now--;
                                }
                        }
                        System.out.println(ans);
                }
        }
}

Measured memory_bytes: 9804
#include <bits/stdc++.h>
#define ff first
#define ss second
#define endl '\n'
using namespace std;
const long long INF = (long long) 1e18;
const int mod = (int) 1e9+7;
const int MAXN = (int) 3e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);cout.tie(nullptr);

    #ifdef Local
        freopen("../IO/int.txt","r",stdin);
        freopen("../IO/out.txt","w",stdout);
    #endif

    cin>>n;


    cout<<n*n;

    #ifdef Local
        cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
    #endif
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <numeric>
#include <limits>
#include <cmath>
#include <iomanip>
 
#define ALL(a)  (a).begin(),(a).end()
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

 
int main() {
    ll n, ans = 0;
    vector<double> a;
    
    cin >> n;

    for (int i = 0; i < n; i++) {
        int temp;
        cin >> temp;
        a.push_back (temp);
    }

    double rev = 0.0;

    for (int i = 0; i < n; i++) {
        rev += 1.0 / a[i];
    }

    cout << setprecision(10) << 1.0 / rev << endl;

    
    
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
const int maxn = 1e5+5;
const int mod = 3;
string s,t;
int q,a,b,c,d;
int suma[maxn],sumb[maxn];
/*
void up(int &a, int b){
    a+=b;
    if(a>=mod) a-=mod; 
}*/
int main()
{
    cin >> s>>t;
    for(int i = 1; i <= s.length(); i++)
    {
        suma[i] = suma[i - 1] + ((s[i-1] == 'A')? 1:2);
 //       cout << suma[i]<<endl;
    }
    for(int i = 1; i <= t.length(); i++)
    {
        sumb[i] = sumb[i - 1] +( (t[i-1] == 'A')? 1:2);
    }

    cin >>q;
    while(q--){
        cin >> a >> b >> c >> d;
        int A,B;
        A = (suma[b] - suma[a-1]) % mod;
        B = (sumb[d] - sumb[c-1]) % mod;
        if(A == B) cout  << "YES" << endl;
        else cout << "NO" << endl;
    } 
    return 0;
}

Measured memory_bytes: 1664
//苦手 解説AC
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;
const ll MOD = 1000000007;
// const ll INF = 1000000000000000000LL;

int main(){
    int sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;
    int dx = tx-sx;
    int dy = ty-sy;
    string m1;
    string m2;
    string m3;
    string m4;
    if(dx>0)
        rep(i,dx){
            m1+='R';
            m2+='L';
            m3+='R';
            m4+='L';
        }
    else if(dx<0)
        rep(i,-dx){
            m1+='L';
            m2+='R';
            m3+='L';
            m4+='R';
        }
    if(dy>0)
        rep(i,dy){
            m1+='U';
            m2+='D';
            m3+='U';
            m4+='D';
        }
    else if(dy<0)
        rep(i,-dy){
            m1+='D';
            m2+='U';
            m3+='D';
            m4+='U';
        }
    m3.insert(0,"DR");
    m3.insert(m3.size(),"UL");
    m4.insert(0,"UL");
    m4.insert(m4.size(),"DR");
    cout << m1 << m2 << m3 << m4 << endl;
	return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define fastio {ios_base::sync_with_stdio(false); cin.tie(NULL);}
typedef long long ll;
using namespace std;
const ll mx = 1000000007;

vector<ll> dp;

int main() {
	fastio;
	int n;	cin>>n;
	vector<vector<int>> mat(n, vector<int>(n));
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++)	cin>>mat[i][j];
	}
	dp.resize(1<<n);
	dp[0]=1;
	ll ans=0;
	for(int i=0; i<(1<<n); i++){
		for(int j=0; j<n;j++){
			int count = __builtin_popcount(i);
			if(mat[j][count]==0 || (i&(1<<j)))	continue;
			dp[i|(1<<j)]+=dp[i];
			dp[i|(1<<j)]%=mx;
		}
	}
	cout<<dp[(1<<n)-1]<<"\n";
	return 0;
}

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){cout << (v[i]) << " ";} cout << endl;
typedef long long int ll;

int main(void) {

  string s;
  cin >> s;

  int md = 2019;

  int now = 0;
  int ten = 1;
  map<ll, ll> mp;
  for(int i = s.size()-1; i >= 0; i--){
    (now += (s[i] - '0') * ten) %= md;
    mp[now]++;
    (ten *= 10) %= md;
  }

  ll ans = mp[0];
  for(auto m : mp) {
    ans += m.second * (m.second - 1) / 2;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
 
using namespace std;
 
#define mp make_pair
#define endl '\n'
using ll=long long;
 
const int INF=1e9+5;
const ll lim=(ll)3e16;
const int N=100005;
const int mod=1e9+7;
const ll oo=1e18+5;
			

int main(){
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
	char a;
	cin>>a;
	cout<<(char)(a+1);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
typedef long long ll;
using namespace std;
int main(){
	ll n,a,b,r,ans=0;
	cin>>n>>a>>b;
	r=n/(a+b);
	ans+=r*a;
	ll cnt=0;
	if(r*(a+b)+a<=n){
		ans+=a;
		cout<<ans;
		return 0;
	}
	else{
		cnt=n-(r*(a+b));
		ans+=cnt;
		cout<<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);

    int x1 = sc.nextInt();
    int y1 = sc.nextInt();
    int x2 = sc.nextInt();
    int y2 = sc.nextInt();

    int x3 = (x2 - y2) + y1;
    int y3 = (x2 - x1) + y2;
    int x4 = (x3 - y3) + y2;
    int y4 = (x3 - x2) + y3;

    System.out.println(x3 + " " + y3 + " " + x4 + " " + y4);

  }
}

Measured memory_bytes: 39768
#include <bits/stdc++.h>
using namespace std;
int main(){
    string inp;
    bool a=true,b=true;
    cin >> inp;
    for(int i = 0; i<inp.size(); i +=2 ){
        if((inp[i]!='R')&&(inp[i]!='U')&&(inp[i]!='D')){
            a = a&&false; 
        }
        else{
            a= a&&true;
        }
    }
    for(int i = 1; i<inp.size(); i +=2 ){
        if((inp[i]!='L')&&(inp[i]!='U')&&(inp[i]!='D')){
            b = b&&false; 
        }
        else{
            b= b&&true;
        }
    }
    if(b&&a){
        cout<<"Yes";
    }
    else{
        cout << "No";
    }
}



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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second

int a[100100];
int n;

int main() {
	cin >> n;
	int ans = 1;
	int f = 0;
	int g = 0;
	REP(i, n) {
		cin >> a[i];
	}
	REP(i, n - 1) {
		if (f == 1) {
			if (a[i] > a[i + 1]) {
				if (g == -1) f = -1;
				else {
					g = -1;
					ans++;
				}
			}
			else if (a[i] < a[i + 1])g = 1;
		}
		else if (f == -1) {
			if (a[i] < a[i + 1]) {
				if (g == 1)f = 1;
				else {
					g = 1;
					ans++;
				}
			}
			else if (a[i] > a[i + 1])g = -1;
		}
		else {
			if (a[i] < a[i + 1]) {
				f = 1;
				g = 1;
			}
			else if (a[i] > a[i + 1]) {
				f = -1;
				g = -1;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
/**
  * @file pb.cpp
  * @brief atcoder

  *

  * @author yao
  * @date 2018-09-23
  */
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#define N 262144
#define INF ((int)1e9)
#ifdef DBG
#   define dbg_pri(x...) fprintf(stderr,x)
#else
#   define dbg_pri(x...) 0
#endif //DBG

typedef unsigned int uint;
typedef long long int lli;
typedef unsigned long long int ulli;

char s[N],t[N];
char mps[128],mpt[128];

int main()
{
    strtok(fgets(s,sizeof(s),stdin)," \t\r\n");
    strtok(fgets(t,sizeof(t),stdin)," \t\r\n");
    for(char *p=s,*q=t; *p; ++p,++q)
    {
        dbg_pri("poi 1: %c %c %c %c\n",*p,*q,mps[*p],mpt[*q]);
        if(mps[*p] && mps[*p]!=*q || mpt[*q] && mpt[*q]!=*p ) goto tag_no;
        mps[*p]=*q, mpt[*q]=*p;
    }
    return puts("Yes"),0;
tag_no:
    return puts("No"),0;
}


Measured memory_bytes: 512
/*
      HET PAGHADAR
      DA-IICT
      @HET262
*/
 
#include<bits/stdc++.h>
using namespace std;
 
typedef long double ld;
typedef long long ll;
 
typedef vector<ll> vec;
#define INF LLONG_MAX
 
#define P pair<ll,ll>
#define int long long int
 
#define ff first
#define ss second
 
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
 
#define N 3005
#define MOD 1000000007

ll dp[N][N];
string s,t,ans="";

ll solve(ll n,ll m)
{
      if(n<1 || m<1)
            return 0;
            
      ll &ans=dp[n][m];
      
      if(ans!=-1)
            return ans;
            
      if(s[n]==t[m])
            ans=max(ans,1+solve(n-1,m-1));
      else
            ans=max(solve(n,m-1),solve(n-1,m));
            
      return ans;
}

void getpath(ll n,ll m)
{
      if(n==1)
      {
            if(dp[1][m]==1)
                  ans+=s[1];
            reverse(ans.begin(),ans.end());
            cout<<ans;
            exit(0);
      }
      if(m==1)
      {
            if(dp[n][1]==1)
                  ans+=t[1];
            reverse(ans.begin(),ans.end());
            cout<<ans;
            exit(0);
      }
      
      ll tt=max({dp[n-1][m-1],dp[n-1][m],dp[n][m-1]});
      
      if(dp[n-1][m-1]==tt)
      {
            if(1+tt==dp[n][m])
                  ans+=s[n];
            getpath(n-1,m-1);
      }
      if(dp[n-1][m]==tt)
      {
            if(1+tt==dp[n-1][m])
                  ans+=s[n];
            getpath(n-1,m);
      }
      if(dp[n][m-1]==tt)
      {
            if(1+tt==dp[n][m-1])
                  ans+=s[n];
            getpath(n,m-1);
      }
      
}

signed main()
{
      FAST;
      
      cin>>s>>t;
      
      s='a'+s;
      t='a'+t;
      memset(dp,-1,sizeof(dp));
      
      solve(s.size()-1,t.size()-1);
      
      for(int i=1;i<s.size();i++)
      {
            for(int j=1;j<t.size();j++)
                  solve(i,j);
      }
      
      getpath(s.size()-1,t.size()-1);
      
}

Measured memory_bytes: 71168
/*  "Sahand Alitanloo"  */
#include <bits/stdc++.h>
#define F first
#define S second
#define fast() ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define per(i) cout<<fixed<<setprecision(i)
#define pb push_back
#define all(v) begin(v),end(v)
using namespace std;
typedef pair<int,int> pii;
typedef long double ld;
typedef long long ll;
const int MAX_N = 1e5+10;
const ll mod = 1e9+7;
const ll INF = 1e9;
inline ll bpow(ll t,ll n){ll ans=1;while(n>0){if(n&1)ans=(ans*t)%mod;t=(t*t)%mod,n>>=1;}return ans;}
/*
ll fact[MAX_N],ifact[MAX_N];
inline ll c(ll n,ll k){if(k>n||k<0)return 0;return (fact[n]*ifact[k]%mod*ifact[n-k])%mod;}
inline void get_fact(){fact[0]=1;ifact[0]=1;for(ll i=1;i<MAX_N;i++)fact[i]=(fact[i-1]*i)%mod,ifact[i]=bpow(fact[i],mod-2);}
*/

int dp[4000][4000];
int a,b,c,d,e,f;
pair<int,int> ans;
void dfs(int w,int s){
    if(w>0&&100*(s)/ld(w)>e){
        return;
    }
    if(w+s>f)
        return;
    if(dp[w][s])
        return;
    //cout<<w<<" "<<s<<" "<<s/ld(w)<<endl;
    if(w!=0)
        if(ans.S/ld(ans.F)<s/ld(w)||(ans.F==0&&ans.S==0))
            ans={w,s};
    dp[w][s]=true;
    int dx[]={0,100*a,100*b};
    int dy[]={0,c,d};
    for(int i=0;i<3;i++)
        for(int j=0;j<3;j++)
            dfs(w+dx[i],s+dy[j]);
}
main(){
    fast();per(6);
    //get_fact();
    cin>>a>>b>>c>>d>>e>>f;

    if(e==0)
        return cout<<"0 0",0;
    dfs(0,0);
    cout<<ans.F+ans.S<<" "<<ans.S;
}


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

items = [list(map(int, input().split())) for _ in range(N)]

dp = [[0] * (W+1) for _ in range(N+1)]

for i in range(1,N+1):
    for j in range(W+1):
        dp[i][j] = dp[i-1][j]
        if items[i-1][0] <= j:
            dp[i][j] = max(dp[i][j], dp[i-1][j-items[i-1][0]] + items[i-1][1])

print(dp[N][W])


Measured memory_bytes: 120172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll n;
    cin >> n;
    if(n == 0){
        cout << 0 << endl;
        return 0;
    }

    vector<ll> ans;
    while(n != 1){
        if(n < 0){
            ans.push_back((-n)%2);
            n = (-n+1)/2;
        }else{
            ans.push_back(n%2);
            n = -(n/2);
        }
    }
    ans.push_back(1);
    reverse(ans.begin(),ans.end());
    rep(i, 0, ans.size()) cout << ans[i];
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(int argc, const char** argv) {
	int a,b,c,k;
  	cin>>a>>b>>c>>k;
  	if(k < a)
      cout<<k;
  	else if(k < a+b)
      cout<<a;
  	else
      cout<<a - (k-a-b);
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
typedef long long lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	lint a, b, x;
	lint ans;
	cin >> a >> b >> x;
	ans = a % x == 0 ? 1 : 0;
	ans += b / x - a / x;
	cout << ans << endl;

	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

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

typedef pair<int,int> P;
const int INF = 1e+8;
int h, w, n;
char c[1001][1001];
int d[1001][1001];
int dx[4] = {0,0,-1,1};
int dy[4] = {-1,1,0,0};

int bfs(char s){
	int sx, sy, gx, gy;
	for(int y=0 ; y < h ; y++ ){
		for(int x=0 ; x < w ; x++ ){
			d[y][x] = INF;
			if( c[y][x] == 'S' ) c[y][x] = '0';
			if( c[y][x] == s ) sx = x, sy = y;
			if( c[y][x] == s+1 ) gx = x, gy = y;
		}
	}
	d[sy][sx] = 0;
	queue<P> q;
	q.push( P(sx,sy) );
	int res = INF;
	while( !q.empty() ){
		int x = q.front().first;
		int y = q.front().second;
		q.pop();
		
		if( x == gx && y == gy ){
			res = d[y][x];
			break;
		}
		for(int i= 0 ; i < 4 ; i++ ){
			int mx = x + dx[i];
			int my = y + dy[i];
			if( mx < 0 || my < 0 || w <= mx || h <= my ) continue;
			if( c[my][mx] == 'X' ) continue;
			
			if( d[my][mx] == INF ){
				d[my][mx] = d[y][x] + 1;
				q.push( P(mx,my) );
			}
		}
	}
	return res;
}

int main(){
	cin >> h >> w >> n;
	for(int y = 0 ; y < h ; y++ ){
		cin >> c[y];
	}
	int ans = 0;
	for(int i=0 ; i < n ; i++ ){
		ans += bfs(i+'0');
	}
	cout << ans << endl;
}

Measured memory_bytes: 6112
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N,A=map(int,input().split())
    x=list(map(int,input().split()))
    dp=[[[0]*2501 for _ in range(N+1)] for _ in range(N+1)]
    dp[0][0][0]=1
    for i in range(N):
        for j in range(i+1):
            for k in range(2501):
                dp[i+1][j][k]+=dp[i][j][k]
                if k-x[i]>=0 and j<=i:
                    dp[i+1][j+1][k]+=dp[i][j][k-x[i]]
    ans=0
    for i in range(1,N+1):
        ans+=dp[-1][i][i*A]
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 91484
#!/usr/bin/env python3
import sys


def solve(M: int):
    ret = 48 - M
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    M = int(next(tokens))  # type: int
    solve(M)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
n=int(input())
a=[list(map(int, input().split())) for _ in range(2)]
result=[]
for i in range(n):
  total = 0
  for j in range(i+1):
    total = total + a[0][j]
  for m in range(i, n):
    total = total + a[1][m]
  result.append(total)
print(max(result))

Measured memory_bytes: 3064
/* Just_Do_It ___________ICARUS__________________*/
	                 
	#include <bits/stdc++.h>
	using namespace std;
	       
	typedef long long ll;
	#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	#define rep(i,a,n) for(ll i=a;i<n;i++)
	#define per(i,a,n) for (ll i=n-1;i>=a;i--)
	#define te ll t; std::cin >> t; while(t--)
	#define SZ 100001
	//# define M_PIl  3.141592653589793238462643383279502884L 
	/*   Proceed with CAUTION   */

	int main(){
		fastio;
		ll n; string s; char st;
		cin>>n;
		map<string,ll> m;
		cin>>s;
		m[s]++;
		st = s[s.length()-1];
		rep(i,1,n){
			cin>>s;
			m[s]++;
			if(m[s]>1 || s[0]!=st){
				cout<<"No"<<endl;
				return 0;
			}
			st = s[s.length()-1];
		}
		cout<<"Yes"<<endl;
	}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
//#include"Bignum/bignum.h"
//#define lll bignum
#define ls(x) ( x << 1 )
#define rs(x) ( x << 1 | 1 )
//#define mid ( ( l + r ) >> 1 )
#define lowbit(x) ( x & -x )
#define debug(x) (cout << "#x = " << (x) << endl)
#define Set(x, i) memset (x, i, sizeof(x))
#define re register
#define For(i, j, k) for(re int i = (j); i <= (k); ++i)
#define foR(i, j, k) for(re int i = (j); i >= (k); --i)
#define Cross(i, j, k) for(re int i = (j); i; i = (k))
using namespace std;
typedef long long ll;
const ll N = 100011;
const ll inf = 0x3f3f3f3f3f3f;

ll n, Ans = 0, a[N], Suf[N], Pre[N];

namespace IO {

	#define dd ch = getchar()
	inline ll read() {
		ll x = 0; bool f = 0; char dd;
		for (; !isdigit (ch); dd) f ^= (ch == '-');
		for (; isdigit (ch); dd)  x = (x << 3) + (x << 1) + (ch ^ 48);
		return f? -x: x;
	}
	#undef dd

	inline void write( ll x ) {
		if ( x < 0 ) putchar ('-'), x = -x;
		if ( x > 9 ) write ( x / 10 ); putchar ( x % 10 | 48 );
	}

	inline void wrn ( ll x ) { write (x); putchar (' '); }

	inline void wln ( ll x ) { write (x); putchar ('\n'); }

	inline void wlnn ( ll x, ll y ) { wrn (x), wln (y); }

}

using namespace IO;

inline ll gcd ( ll a, ll b ) { return !b? a: gcd (b, a % b); }

int main()
{
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);
	ll f = 0, GCD; n = read(); 
	For ( i, 1, n ) a[i] = read();
	Pre[1] = a[1]; Suf[n] = a[n];
	For ( i, 2, n ) Pre[i] = gcd (Pre[i - 1], a[i]);
	foR ( i, n - 1, 1 ) Suf[i] = gcd (Suf[i + 1], a[i]);
	For ( i, 1, n ) {
		if ( i == 1 ) Ans = max (Ans, Suf[i + 1]);
		if ( i == n ) Ans = max (Ans, Pre[i - 1]);
		if ( i != 1 && i != n ) 
			Ans = max ( Ans, gcd (Pre[i - 1], Suf[i + 1]) );
	}
	return wln (Ans), 0;
}

/*
4
2 4 7 8

4
7 6 8 8

4
4 6 32 64
*/



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

int main() {
  ll n, ans;
  cin >> n;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ans = i + n / i - 2;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a[200005],dp[5][200005];
int main()
{
	long long n,i;
	cin>>n;
	for(i=1;i<=n;i++)
		cin>>a[i];
	for(i=1;i<=n;i++)
	{
		dp[0][i]=dp[0][i-1]+a[i];
		dp[1][i]=min(dp[0][i-1],dp[1][i-1])+a[i]%2+2*(a[i]==0);
		dp[2][i]=min(dp[0][i-1],min(dp[1][i-1],dp[2][i-1]))+(a[i]+1)%2;
		dp[3][i]=min(dp[0][i-1],min(dp[1][i-1],min(dp[2][i-1],dp[3][i-1])))+a[i]%2+2*(a[i]==0);
		dp[4][i]=min(dp[0][i-1],min(dp[1][i-1],min(dp[2][i-1],min(dp[3][i-1],dp[4][i-1]))))+a[i];
	}
	cout<<min(dp[0][i-1],min(dp[1][i-1],min(dp[2][i-1],min(dp[3][i-1],dp[4][i-1]))))<<'\n';
}


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

typedef long long ll;

int main() {        
	ll a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	if (a + b <= 2 * c) {
		cout << 1LL * a * x + 1LL * y * b;
	}else {
		ll ans = min(x,y) * 2 * c;
		if (x < y) {
			if (b <= 2 * c) {
				ans += (y - x) * b;
			}else {
				ans += (y - x) * 2 * c;
			}
		}else {
			if (a <= 2 * c) {
				ans += (x - y) * a;
			}else {
				ans += (x - y) * 2 * c;
			}	
		}
		cout << ans;
	}
}








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

vector<int> parent;
vector<long long> position;

int root(int i) {
    if (i == parent[i]) return i;
    else {
        auto r = root(parent[i]);
        position[i] += position[parent[i]];
        return parent[i] = r;
    }
}
long long weight(int i) {
    root(i);
    return position[i];
}
void unit(int i, int j, long long d) {
    d += weight(i) - weight(j);
    parent[(j = root(j))] = (i = root(i));
    position[j] = d;
}

int N, M;

int main() {
    cin >> N >> M;

    parent.resize(N);
    iota(parent.begin(), parent.end(), 0);

    position.resize(N, 0);

    bool ans = true;

    for (int i = 0; i < M; ++i) {
        int l, r, d;
        cin >> l >> r >> d;
        --l, --r;
        if (root(l) == root(r)) {
            if (weight(r) - weight(l) != d) {
                ans = false;
                break;
            }
        } else {
            unit(l, r, d);
        }
        // for (int i = 0; i < N; ++i) {
        //     cout << position[i] << ' ';
        // } cout << endl;
    }

    cout << (ans ? "Yes" : "No") << endl;
}


Measured memory_bytes: 1536
#include <stdio.h>

int sum(int n){
  int i, j, k, l, x = 0;

  for(i=0;i<=9;i++){

    for(j=0;j<=9;j++){

      for(k=0;k<=9;k++){

        for(l=0;l<=9;l++){

          if(n == i + j + k + l){

            x = x + 1;

          }

        }

      }

    }

  }

  return x;
}

int main(){
  int n;

  while(scanf("%d", &n)!=-1){

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

  }

  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
const int maxn=3009;
const long long Mod=1000000007ll,_two=500000004ll;
int n,q,x,y,ans;
long long a[maxn],p[maxn][maxn],pp[maxn][maxn];

int main()
{
	cin>>n>>q;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			p[i][j]=(a[i]>a[j]);
	for(int i=0;i<q;i++)
	{
		cin>>x>>y;
		for(int j=1;j<=n;j++) 
			if(j==x||j==y) continue;
			else p[x][j]=p[y][j]=(p[x][j]+p[y][j])*_two%Mod,p[j][y]=p[j][x]=(p[j][y]+p[j][x])*_two%Mod;
		p[x][y]=p[y][x]=(p[x][y]+p[y][x])*_two%Mod;
	}
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			ans=(ans+p[i][j])%Mod;
	for(int i=0;i<q;i++) ans=ans*2%Mod;
	cout<<ans;
}

Measured memory_bytes: 74220
#include<stdio.h>

int solve(int,int);
int n,A[20];

int main(){
  int i,q,m[200];

  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&A[i]);

  scanf("%d",&q);
  for(i=0;i<q;i++)
    scanf("%d",&m[i]);

  for(i=0;i<q;i++){
    if(solve(0,m[i]))printf("yes\n");
    else printf("no\n");
  }
  return 0;
}

int solve(int i,int m){
  int res;
  if(m<0)return 0;
  if(m==0)return 1;
  if(i==n)return 0;
  res = solve(i + 1, m) || solve(i + 1, m - A[i]);
  return res;
}

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


#pragma region user_defined
#define CLR(arr,val) memset(arr,val,sizeof(arr))
#define CLR0(arr)  memset(arr,0,sizeof(arr))
#define LL long long
#define VECTOR vector<LL>
#define VECTOR_IT vector<LL>::iterator
#define LIST list<LL>
#define LIST_IT list<LL>::iterator
#define A(n) n.begin(),n.end()
#pragma endregion


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 //start time:2016/10/2 14:07:15
void Solve() {
#ifdef LOCAL_DEBUG  
	freopen("A Barricade_input.txt", "r", stdin);
//freopen("A Barricade_output.txt", "w", stdout);
#endif 
	int N; cin >> N;
	int A; cin >> A;
	int B; cin >> B;
	int cnt = 0;
	for (int i = 0; i < N; i++)
	{
		int tmp;
		cin >> tmp;
		if (tmp < A) cnt++;
		if (tmp >= B) cnt++;
	}

	cout << cnt << endl;


}
 

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

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

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

    for (size_t i = 1; i <= n; i++)
    {
        if (i % 3 == 0)
        {
            cout << " " << i;
            continue;
        }

        ll x = i;
        while (true)
        {
            if (x % 10 == 3)
            {
                cout << " " << i;
                break;
            }
            x /= 10;
            if (!x)
            {
                break;
            }
        }
    }
    cout << endl;
}



Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1'000'000'007;
const ll inf=1'000'000'000'000'000'00;
const int INF=1'000'000'000;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int h,w,k;
	cin>>h>>w>>k;
	vector<string> g(h);
	rep(i,h){
		cin>>g[i];
	}
	vector<vector<int>> ans(h,vector<int>(w,-1));
	int now=0;
	rep(i,h){
		bool flag=false;
		rep(j,w){
			if(g[i][j]=='#'){
				now++;
				rep(k,j+1){
					if(ans[i][k]==-1){
						ans[i][k]=now;
					}
				}
				flag=true;
			}else{
				if(flag){
					ans[i][j]=now;
				}
			}
		}
	}
	FOR(i,1,h){
		if(ans[i][0]!=-1) continue;
		rep(j,w){
			ans[i][j]=ans[i-1][j];
		}
	}	
	for(int i=h-2;i>=0;i--){
		if(ans[i][0]!=-1) continue;
		rep(j,w){
			ans[i][j]=ans[i+1][j];
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3924
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  string s, t;
  cin >> N >> s >> t;
  for(int l=N; l<=2*N; l++) {
    string S(l, ' ');
    rep(i, N) S[i] = s[i];
    bool ok = true;
    rep(i, N) if(S[l-N+i] != ' ' && S[l-N+i] != t[i]) ok = false;
    if(ok) {
      cout << l << "\n";
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N, Y;
    cin >> N >> Y;

    int x, v, i;
    
    for (x = N; x >= 0; x--) {
        for (v = N - x; v >= 0; v--) {
            i = N - x - v;
            if (10000 * x + 5000 * v + i * 1000 == Y) {
                goto OK;
            }
        }
    }
    x = v = i = -1;
OK:
    cout << x << " " << v << " " << i << endl;

    return 0;
}


Measured memory_bytes: 256