akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()

signed main(){
    int n, T;
    cin >> n >> T;
    vector<int> t(n);
    rep(i,n) cin >> t[i];
    
    int ans = T;
    rep(i,n-1){
        ans += min(t[i+1] - t[i], T);
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

#define ANS(f) if(f) cout << "YES" << endl; else cout << "NO" << endl;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
void debug(mat m){REP(i, m.size()){ REP(j, m[0].size()){ cout << m[i][j] << ","; } cout << endl; }}

class RMQ_segment_tree
{
    using data_type = int;

public:

    vector<data_type> dat;
    int N;
    data_type inf;

    RMQ_segment_tree(int n, data_type inf): inf(inf) {
        N = 1;
        while(n > N) N = N << 1;
        dat = vector<data_type>(2 * N - 1, inf);
    }

    //k番目の値をaに更新
    void update(int k, data_type a){
        k += N - 1;
        dat[k] = a;
        while(k > 0){
            k = (k - 1) / 2;
            dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
        }
    }

    //[a, b)の最小値
    data_type minval(int a, int b){
        return query(a, b, 0, 0, N);
    }

    data_type query(int a, int b, int k, int l, int r){
        if(r <= a || b <= l) return inf;
        if(a <= l && r <= b) return dat[k];
        else{
            data_type vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
            data_type vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
            return min(vl, vr);
        }
    }
};

signed main(){

    int N, Q, A, B; cin >> N >> Q >> A >> B;
    vec x(Q); readv(x);
    RMQ_segment_tree P(N + 1, INF), M(N + 1, INF);

    P.update(A, llabs(x[0] - B) + A);
    M.update(A, llabs(x[0] - B) - A);
    P.update(B, llabs(x[0] - A) + B);
    M.update(B, llabs(x[0] - A) - B);

    int ans = 0;
    FOR(i, 1, Q){
        int tmp = llabs(x[i] - x[i - 1]);
        ans += tmp;
        int mm = M.minval(0, x[i]) + x[i] - tmp;
        int mp = P.minval(x[i], N + 1) - x[i] - tmp;
        int v = P.minval(x[i - 1], x[i - 1] + 1) - x[i - 1];
        int m = min(v, min(mm, mp));
        P.update(x[i - 1], m + x[i - 1]);
        M.update(x[i - 1], m - x[i - 1]);
    }
    int m = INF;
    FOR(i, 1, N + 1) m = min(m, P.minval(i, i + 1) - i);
    ans += m;
    cout << ans;
    
    return 0;
}

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

#define rep(i,n) for(int i = 0; i < (int)(n); i++)

using namespace std;

int main(void){
  int x;

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

  return 0;
}


Measured memory_bytes: 3628
n=int(input())
l=[list(map(int,input().split()))for _ in[0]*n]
dp=l[0]
for i,s in enumerate(l):
    if not i:continue
    d=[]
    for i,t in enumerate(s):
        d.append(max(t for j,t in enumerate(dp)if i!=j)+t)
    dp=d
print(max(dp))

Measured memory_bytes: 68184
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<map>
#define eps 1e-7
using namespace std;
map<long long,int>f;
long long l[120000],r[120000]; 
long long tot,O[5200],p[5200];
long long prime[5200],n,a[120000];
int add(long long x,int o){
	l[o]=r[o]=1;
	for(int i=1;i<=tot&&O[i]<=x;i++){
		long long k=1;
		while(x%O[i]==0)x/=O[i];
		while(x%prime[i]==0)k*=prime[i],x/=prime[i];
		if(k!=1){
			l[o]*=k;
			r[o]*=O[i]/k;
		}
	}
	if(fabs(sqrt(x)-round(sqrt(x)))<eps){
		l[o]*=x;
		r[o]*=round(sqrt(x));
	}else{	
		l[o]*=x;
		r[o]*=x*x;
	}
	f[l[o]]++;
}
int pre(){
	for(int i=2;i<=5000;i++){
		if(p[i]==0)prime[++tot]=i,O[tot]=1LL*i*i*i;
		for(int j=1;j<=tot&&i*prime[j]<=5000;j++){
			p[i*prime[j]]=1;
			if(i%prime[j]==0)break;
		}
	}
}
int main(){
	pre();
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
	for(int i=1;i<=n;i++)add(a[i],i);
	long long ans=0;
	if(f[1]>1)f[1]=1;
	for(int i=1;i<=n;i++){
		ans+=max(f[l[i]],f[r[i]]);
		f[l[i]]=f[r[i]]=0;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 15232
#include<bits/stdc++.h>
#define ll long long
using namespace std;
void dfs(vector<int> g[],int vis[],int dis[],int node){
    if(vis[node]) return ;
    vis[node] = 1;
    for(int i = 0 ; i<g[node].size() ; i++){
        if(vis[g[node][i]]){
            dis[node] = max(dis[g[node][i]]+1,dis[node]);
        }
        else{
            dfs(g,vis,dis,g[node][i]);
            dis[node] = max(dis[g[node][i]]+1,dis[node]);
        }
    }
}
int main(){
    int n,m;
    scanf(" %d",&n);
    scanf(" %d",&m);
    //cin>>n>>m;
    int vis[n+1];
    int dis[n+1];
    for(int i = 0 ; i<=n; i++){
        vis[i] = 0;
        dis[i] = 0;
    }
    vector<int> g[n+1];
    for(int i = 1 ; i<=m ; i++){
        int x,y;
        scanf(" %d",&x);
    scanf(" %d",&y);
        //cin>>x>>y;
        g[x].push_back(y);
    }
    for(int i = 1 ; i<=n ; i++){
        if(vis[i]) continue;
        dfs(g,vis,dis,i);
    }
    int maxi = 0;
    for(int i = 1; i<=n; i++){
        maxi = max(maxi,dis[i]);
    }
    printf("%d\n",maxi);
    //cout<<maxi<<endl;
}

Measured memory_bytes: 9216
#include <iostream>
#include <stdio.h> //printf()

using namespace std;

int main(){
    int i, A[10], tmp, j;

    for (i = 0; i < 10; i++)
        cin >> A[i];

    //bubble sort
    //??????????????????

    j = 3;
    while (j-- > 0) {
        for (i = 0; i < 9; i++) {
            if (A[i] > A[i+1]) {
                tmp = A[i+1];
                A[i+1] = A[i];
                A[i] = tmp;
            }
        }
    }

    printf("%d\n", A[9]);
    printf("%d\n", A[8]);
    printf("%d\n", A[7]);

    return 0;
}

Measured memory_bytes: 3208
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var XY = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
            var X = XY[0];
            var Y = XY[1];
            var answer = 0;
            var tmp = X;
            while (tmp <= Y)
            {
                answer++;
                tmp *= 2;
            }
            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 28180
#include<bits/stdc++.h>
#define EM 100000000
using namespace std;
using LL = long long;
using P = pair<LL, LL>;
LL LINF = 1e18;
int INF = 1e9;
LL mod = 1e9+7;
using vint = vector<int>;
using vLL = vector<LL>;
using vvint = vector<vector<int>>;
using vvLL = vector<vector<LL>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	int N, D;
	cin >> N >> D;
	vector<vector<int>> a(N, vector<int>(D, 0));
	for(int i = 0;i < N;i++){
		for(int j = 0;j < D;j++){
			cin >> a[i][j];
		}
	}
	int ans = 0;
	for(int i = 0;i < N;i++){
		for(int j = i+1;j < N;j++){
			int d = 0;
			for(int k = 0;k < D;k++)	d += pow((a[i][k]-a[j][k]), 2.0);
			int sd = sqrt(d);
			if(sd*sd == d)	ans++;
		}
	}
	cout << ans << endl;
}

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

ans = 0

#front_numの初期値は最初の人
front_num = A[0]

for i in range(1,n):
  if front_num > A[i]:
    dif = front_num - A[i]
    ans += dif
  else:
    #もしA[i]が既存の中で最高だったら、front_numを更新する。
    front_num = A[i] 
    
print(ans)

Measured memory_bytes: 32220
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

//#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back


//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

struct Vec2{
    double x,y;

    Vec2(double x = 0, double y = 0): x(x),y(y) {};
    Vec2 operator+(const Vec2& v) const {return Vec2(x+v.x, y+v.y);}
    Vec2& operator+=(const Vec2& v) {x += v.x; y += v.y; return *this;}
    Vec2 operator-(const Vec2& v) const {return Vec2(x-v.x, y-v.y);}

    double dot(const Vec2& v) const {return x*v.x + y*v.y;}
    double cross(const Vec2& v) const {return x*v.y - y*v.x;}
    double norm2() const {return x*x + y*y;}
    double norm() const {return sqrt(norm2());}

    int ort() const{
        if(y > 0) return x > 0 ? 1 : 2;
        else return x > 0 ? 4 : 3;
    }

};

bool cmp_vec2arg(const Vec2& a, const Vec2& b){ // <を定義
    int ao = a.ort(), bo = b.ort();
    if(ao != bo) return ao < bo;
    else return a.cross(b) > 0;
}


signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);

    int N; cin >> N;

    vector<Vec2> v;
    REP(i,N){
        double x,y; cin >> x >> y;
        if(equals(x,0.0) && equals(y,0.0)) continue;

        v.eb(Vec2(x,y));

    }
    sort(v.begin(),v.end(), cmp_vec2arg);
    int vlen = SZ(v);
    dump(vlen)

    double ans = 0.0;

    REP(i,vlen){
        int r = i;
        Vec2 now;
        REP(j,vlen){
            now += v[r];
            ans = max(ans,now.norm());
            r = (r+1)%vlen;
        }
    }


    cout << ans << endl;



}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define INF 2e9
using namespace std;
typedef long long ll;

int main(){
  int N;
  cin>>N;
  int sum=0;
  vector<vector<int>> dp(210, vector<int>(210,0));
  for (int i=1;i<=200;i++){
    for (int j=1;j<=200;j++){
      dp[i][j]=gcd(i,j);
    }
  }

  for (int a=1;a<=N;a++){
    for (int b=a;b<=N;b++){
      for (int c=b;c<=N;c++){
        int g = dp[a][dp[b][c]];
        if (a==b && b==c) sum+=g;
        else if (a==b || b==c) sum+=(g*3);
        else sum+=(g*6);
      }
    }
  }
  
  cout<<sum<<endl;
  return 0;
} 

Measured memory_bytes: 3808
#include<stdio.h>
int main(){
  int a,b,c=40,d;
  scanf("%d",&a);
  for(int i=0; i<a; i++){
    scanf("%d",&b);
    d=0;
    while(b%2==0){b/=2;d++;}
    if(c>d){c=d;}
  }
  printf("%d",c);
  return 0;}

Measured memory_bytes: 128
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>

int main(){
  long long N,H;
  std::cin >> N >> H;

  std::vector<long long> b_arr(N);
  long long max_a = 0;

  for(int i = 0; i < N; i++){
    long long a;
    std::cin >> a >> b_arr[i];
    max_a = std::max(max_a, a);
  }

  std::sort(b_arr.begin(), b_arr.end(), std::greater<int>());

  long long ncount = 0;
  for(auto&& b: b_arr){
    if(b <= max_a) break;
    H -= b;
    ncount++;
    if(H <= 0){
      std::cout << ncount << std::endl;
      return 0;
    }
  }

  std::cout << ncount+(H+max_a-1)/max_a << std::endl;

  return 0;
}



Measured memory_bytes: 1024
import math

n = int(input())
csf = [list(map(int, input().split())) for i in range(n-1)]
ANS = []
for i in range(n):
  ans = 0
  for c,s,f in csf[i:]:
    if ans <= s:
      ans = s + c
    else:
      ans = s + math.ceil((ans-s)/f) * f + c
  ANS.append(ans)
for i in ANS:
  print(i)

Measured memory_bytes: 3188
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.*;
import java.util.NoSuchElementException;

class Main {
    public static void main(String[] args) throws Exception {
        new Main().run();
    }

    long f(long[] a,long[] b,long zero,long m) {
        //a_i*a_j<=mとなるものの数を数える。
        long ret=0;
        int t=a.length-1;
        for(int i=0;i<a.length;++i) {
            while(t>=0&&a[i]*a[t]>m)--t;
            ret+=Math.max(0, t-i);
        }
        t=0;
        for(int i=b.length-1;i>=0;--i) {
            while(t<b.length&&b[i]*b[t]>m)++t;
            ret+=Math.max(0, i-t);
        }
        t=0;
        for(int i=0;i<a.length;++i) {
            while(t<b.length&&a[i]*b[t]<=m)++t;
            ret+=Math.max(0, t);
        }
        if(m>=0)ret+=zero*(a.length+b.length)+zero*(zero-1)/2;
        return ret;
    }

    void run() {
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        long K=sc.nextLong();
        long[] A=new long[N];
        int plus=0,negative=0;
        for(int i=0;i<N;++i) {
            A[i]=sc.nextLong();
            if(A[i]>0)++plus;
            else if(A[i]<0)++negative;
        }
        Arrays.sort(A);
        long[] a=new long[plus];
        long[] b=new long[negative];
        long zero=N-plus-negative;
        int p=0,q=0;
        for(int i=0;i<A.length;++i) {
            if(A[i]>0)a[p++]=A[i];
            else if(A[i]<0)b[q++]=A[i];
        }
        long ok=(long)1e18+1;
        long ng=-(long)1e18-1;
        while(ok-ng>1) {
            long middle=(ok+ng)/2;
            if(f(a,b,zero,middle)>=K) {
                ok=middle;
            }else {
                ng=middle;
            }
        }
        System.out.println(ok);
    }

    static void tr(Object... objects) {
        System.out.println(Arrays.deepToString(objects));
    }

}



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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;




int main() {


	string s;
	cin >> s;
	sort(ALL(s));

	if (s[1] == s[2]) {
		cout << "No" << endl;
		return 0;
	}
	if (s[0] == s[1] && s[2] == s[3]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	

}

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

#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ffor(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(i, n) ffor(i, 0, n)
#define All(obj) (obj).begin(), (obj).end()
#define INF ((ll)1e9 + 7)
#define c(a) cout << a << "\n";
using namespace std;
const int N = 100005;

int main()
{
    speed;
    cout << fixed << setprecision(6);
    /*start*/
    string s;
    string t;
    int a, b;
    string u;
    cin >> s >> t >> a >> b >> u;
    if (u == s)
        a--;
    else if (u == t)
        b--;
    cout << a << " " << b;
    ed;
    return 0;
}

Measured memory_bytes: 256
// BEGINNING WITH THE NAME OF ALMIGHTY GOD ALLAH
// AUTHOR:: MOHAMMAD FAISAL
#include<bits/stdc++.h>
#include<string>
using namespace std;

int main()
{
	string a,b;
  	cin >> a >> b;
  	int x = stoi(a+b);
    
	for(int i=1;i<=10000;i++)
    {
      if(i*i == x)
      {
        cout<<"Yes";return 0;
      }
    }
  	cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
using namespace std;
int min (int a, int b){
  if(a<b) return a;
  else return b;
}
int max (int a, int b){
  if(a>b) return a;
  else return b;
}
int main(){
  int n,k;
  cin >>n>>k;
  int x[110];
  for(int i=0;i<n;i++)
  cin >>x[i];
  int sum=0;
  for(int i=0 ;i<n; i++)
  sum+= min(2*x[i],2*(k-x[i]));

  cout <<sum<<endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int IINF = INT_MAX;

int main() {
    int n, t[20][20] ,dp[1<<16];
    while(cin >> n, n){
        for(int i=0;i<n;i++){
            for(int j=0;j<n+1;j++){
                cin >> t[i][j];
            }
        }
        fill(dp,dp+(1<<n),IINF);
        dp[0] = 0;
        for(int i=0;i<(1<<n);i++){
            for(int j=0;j<n;j++){
                if((i>>j)&1)continue;
                int cost = t[j][0];
                for(int k=0;k<n;k++){
                    if((i>>k)&1){
                        cost = min(cost, t[j][k+1]);
                    }
                }
                dp[i|(1<<j)] = min(dp[i|(1<<j)], dp[i] + cost);
            }
        }
        cout << dp[(1<<n)-1] << endl;
    }
    return 0;
}


Measured memory_bytes: 3316
#include <stdio.h>

typedef long long ll;

int d[20][20];
ll dp[20][1<<20];

int main(){

	int N,M;

	scanf("%d %d",&N,&M);

	int i,j,mask;

	for(i=0;i<M;i++){
		int a,b;
		scanf("%d %d",&a,&b);
		a--;
		b--;
		d[a][b]=1;
		d[b][a]=1;
	}


	dp[0][1]=1;

	for(mask=0;mask<(1<<N);mask++){
		for(j=0;j<N;j++){
			if(!(mask>>j&1) ){
				int tmp=mask;
				for(i=0;i<N;i++){
					if(d[i][j]==1){
						dp[j][tmp|1<<j]+=dp[i][tmp];
					}
				}
			}
		}
	}

	ll ans=0ll;

	for(i=1;i<N;i++){
		ans+=dp[i][(1<<N)-1];
	}

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


	return 0;
}

Measured memory_bytes: 14464
#include <iostream>
#include <vector>
#include <string>

template<class T> void output(std::vector<T> & A) {
    const int n = A.size();
    for (int i = 0; i < n - 1; ++i) {
        std::cout << A[i] << " ";
    }
    std::cout << A[n - 1] << std::endl;
}

template <class T> struct Node {
    Node* prev;
    Node* next;
    T value;
};

template<class T> class MyLinkedList {
public:
    MyLinkedList(): m_size(0) {
        nill = new Node<T>;
        nill->prev = nill;
        nill->next = nill;
    };

    const long size() const { return m_size; };

    void insert(T x) {
        Node<T>* node = new Node<T>;
        node->value = x;
        // connecting the new node and the following node
        nill->next->prev = node;
        node->next = nill->next;
        // connecting the new node and the nill node
        nill->next = node;
        node->prev = nill;
        ++m_size;
    };
    void deleteNode(Node<T>* node) {
        node->prev->next = node->next;
        node->next->prev = node->prev;
        --m_size;
        delete node;
    };

    Node<T>* listSearch(T x) {
        Node<T>* node = nill->next;
        while (node != nill) {
            if (node->value == x) return node;
            node = node->next;
        }
        return nill;
    };
    void deleteKey(T x){
        Node<T>* node = listSearch(x);
        if (node == nill) return;
        deleteNode(node);
    };

    void deleteLast(){
        deleteNode(nill->prev);
    };
    void deleteFirst(){
        deleteNode(nill->next);
    };

    void display() const {
        Node<T>* node = nill->next;
        for (long i = 0; i < m_size - 1; ++i) {
            std::cout << node->value << " ";
            node = node->next;
        }
        std::cout << node->value << std::endl;
    }

private:
    Node<T>* nill;
    long m_size;
};

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

    int n; std::cin >> n;

    MyLinkedList<long> lst;

    for (int i = 0; i < n; ++i) {
        std::string S; std::cin >> S;
        if (S == "insert") {
            int value; std::cin >> value;
            lst.insert(value);
        }
        else if (S == "delete"){
            int value; std::cin >> value;
            lst.deleteKey(value);
        }
        else if (S == "deleteFirst") {
            lst.deleteFirst();
        }
        else {
            lst.deleteLast();
        }
    }

    lst.display();

    return 0;
}



Measured memory_bytes: 34408
r, g, b, n = map(int, input().split())

colors = [r, g, b]

cnt = 0

for num_r in range(n // r + 1):
  for num_g in range((n - r * num_r) // g + 1):
    if (n - r * num_r - g * num_g) % b == 0:
      cnt += 1

print(cnt)

Measured memory_bytes: 40300
#include<iostream>

using namespace std;


int main()
{
    int r,c;
    long    a[101][101]={0};

    cin>>r>>c;

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


    for(int i=0;i<=r;i++){
        for(int j=0;j<=c;j++){
            cout<<a[i][j];
            if(j!=c)    cout<<' ';
        }
        cout<<'\n';
    }
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
 
typedef pair<int,int > pp;
typedef long long ll;
 
#define sz(x) (int)x.size() 
int const N=5e5+10;

int main() {
	int n,d;
	cin>>n>>d;
	d*=2;
	d++;
	cout<<(n+d-1)/d<<endl;
    return 0;
}



Measured memory_bytes: 256
// 2011/07/27 Tazoe

#include <iostream>
using namespace std;

int main()
{
	int seg[11][7] = {{0,1,1,1,1,1,1},	// eÌf[^
	                  {0,0,0,0,1,1,0},
	                  {1,0,1,1,0,1,1},
	                  {1,0,0,1,1,1,1},
	                  {1,1,0,0,1,1,0},
	                  {1,1,0,1,1,0,1},
	                  {1,1,1,1,1,0,1},
	                  {0,1,0,0,1,1,1},
	                  {1,1,1,1,1,1,1},
	                  {1,1,0,1,1,1,1},
	                  {0,0,0,0,0,0,0}};	// seg[10]Íñ\¦

	while(true){
		int n;
		cin >> n;
		if(n==-1)
			break;

		int lst = 10;		// ¼OÌiúlÍñ\¦j
		int now;		// »ÝÌ
		for(int i=0; i<n; i++){
			cin >> now;
			for(int j=0; j<7; j++)
				cout << (seg[lst][j]+seg[now][j])%2;	// r¼I_a
			cout << endl;
			lst = now;
		}
	}

	return 0;
}

Measured memory_bytes: 0
/*
for (int i = 0; i < N; ++i){}

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
 

int main() {
	// 入力
	ll X, Y, Z;
	cin >>X>>Y>>Z;
 
	// 解法
	ll count = 0;
	ll wide = 0;
	while (true){
		if (count==0) wide = Y + 2*Z;
		else wide += Y+Z;
		if (wide<=X)count++;
		else break;
	}
	
	//出力
	cout << count << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
int n, m, s, g;
struct edge
{
    int to, dist, limit;
    edge(int to, int dist, int limit) : to(to), dist(dist), limit(limit) {};
};
struct info
{
    double nt;
    int to, v, pre;
    info(double nt, int to, int v, int pre) : nt(nt), to(to), v(v), pre(pre) {};
};
bool operator<(const info &a, const info &b) { return a.nt > b.nt; }
double solve(vector<edge> G[])
{
    priority_queue<info> que;
    que.push(info(0.0, s, 1, 0));
    double memo[40][40][40];
    for(int i = 0; i < 40; i++) for(int j = 0; j < 40; j++) for(int k = 0; k < 40; k++) memo[i][j][k] = INF;
    memo[s][1][0] = 0.0;
    while(que.size())
    {
        info p = que.top(); que.pop();
        //cout << p.nt << " " << p.to << " " << p.v << " " << p.pre << endl;
        if(p.to == g && p.v == 1) return p.nt;
        for(int u = 0; u < G[p.to].size(); u++)
        {
            edge e = G[p.to][u];
            if(p.pre == e.to) continue;
            if(p.to == s && p.nt == 0.0)
            {
                memo[e.to][p.v][p.to] = e.dist / (double)p.v;
                que.push(info(memo[e.to][p.v][p.to], e.to, p.v, p.to));
                continue;
            }
            for(int d = -1; d <= 1; d++)
            {
                if(p.v + d == 0 || p.v + d > e.limit) continue;
                double t = e.dist / (double)(p.v + d);
                if(memo[p.to][p.v][p.pre] + t < memo[e.to][p.v + d][p.to])
                {
                    memo[e.to][p.v + d][p.to] = memo[p.to][p.v][p.pre] + t;
                    que.push(info(memo[e.to][p.v + d][p.to], e.to, p.v + d, p.to)); 
                }
            }
        }
    }
    return -1.0;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(5);
    while(cin >> n >> m, n | m)
    {
        cin >> s >> g;
        vector<edge> G[n + 1];
        for(int i = 0; i < m; i++)
        {
            int x, y, d, c; cin >> x >> y >> d >> c;
            G[x].push_back(edge(y, d, c));
            G[y].push_back(edge(x, d, c));
        }
        double ans = solve(G);
        if(ans == -1.0) cout << "unreachable" << endl;
        else cout << ans << endl;
    }
    return 0;
}




Measured memory_bytes: 4128
#include<stdio.h>
#include<string.h>
 
int main(void)
{
	int a,c;
	char b[100];
	scanf("%d",&a);
	getchar(); 
	gets(b);
	c=strlen(b);
	if(a>=c)
		puts(b);
	else
		{
			for(int i=0;i<a;i++)
			{
				printf("%c",b[i]);
			}
			printf("...");
		}
	
	return 0;
 } 

Measured memory_bytes: 2140
N = int(input())
A = []
for i in range(N):
	A.append(int(input()))
c = 0
sold = 0
i = 0
while i<len(A):
	if A[i] == c+1:
		i+=1
		c+=1
	elif A[i]<=2*(c+1) and A[i]>c+1:
		i+=1
		sold+=1
		if c == 0:
			c = 1
	elif A[i]>2*(c+1) and A[i]>c+1:
		sold+=((A[i]-1)//(c+1))
		i+=1
		if c == 0:
			c = 1
	else:
		i+=1
print(sold)

Measured memory_bytes: 7084
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template<ll M = 1000000007>
struct modint{
    ll val;
    modint(): val(0){}
    template<typename T>
    explicit modint(T t){val = t%M; if(val < 0) val += M;}

    modint pow(ll k){
        modint res(1), x(val);
        while(k){
            if(k&1) res *= x;
            x *= x;
            k >>= 1;
        }
        return res;
    }
    template<typename T>
    modint& operator=(T a){ val = a%M; if(val < 0) val += M; return *this; }
    modint inv() {return pow(M-2);}
    modint& operator+=(modint a){ val += a.val; if(val >= M) val -= M; return *this;}
    modint& operator-=(modint a){ val += M-a.val; if(val >= M) val -= M; return *this;}
    modint& operator*=(modint a){ val = 1LL*val*a.val%M; return *this;}
    modint& operator/=(modint a){ return (*this) *= a.inv();}
    modint operator+(modint a) const {return modint(val) +=a;}
    modint operator-(modint a) const {return modint(val) -=a;}
    modint operator*(modint a) const {return modint(val) *=a;}
    modint operator/(modint a) const {return modint(val) /=a;}
    modint operator-(){ return modint(-val);}
    bool operator==(const modint a) const {return val == a.val;}
    bool operator!=(const modint a) const {return val != a.val;}
    bool operator<(const modint a) const {return val < a.val;}
};

using mint = modint<MOD>;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

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

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

    int cur = 0;
    vector<int> u;
    for (int i = 1; i <= n; ) {
        int j = n/i;
        if(i <= j) u.emplace_back(1), i++;
        else u.emplace_back(n/j-i+1), i = n/j+1;
        cur++;
    }
    auto dp = make_v(k+1, cur+1, mint(0));
    for (int i = 0; i <= cur; ++i) {
        dp[0][i] = 1;
    }
    for (int i = 0; i < k; ++i) {
        for (int j = 0; j < cur; ++j) {
            dp[i+1][j+1] = dp[i][cur-j]*mint(u[j]);
        }
        for (int j = 1; j <= cur; ++j) {
            dp[i+1][j] += dp[i+1][j-1];
        }
    }
    cout << dp[k][cur].val << "\n";
    return 0;
}

Measured memory_bytes: 51196
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;
using namespace std;
using LL = long long int;
using ULL = unsigned long long;

int main() {
    LL L, R;
    cin >> L >> R;
    LL ans = 2019;
    for (LL i = L; i <= L + 2019 * 2 - 1 and i <= R - 1; i++) {
        for (LL j = i + 1; j <= L + 2019 * 2 and j <= R; j++) {
            LL tmp = (i * j) % 2019;
            ans = min(ans, tmp);
        }

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


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,m,i,j;
  while(1){
    scanf("%d %d",&n,&m);
    if(n==0&&m==0) break;
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      if(i==0||j==0||j==m-1||i==n-1){
	printf("#");
      } else{
	printf(".");
      }
    }
    printf("\n");
  }
  printf("\n");
  }
  return(0);
}

Measured memory_bytes: 1000
#include <iostream>
#include <string.h>

#define NM 10

using namespace std;

//1:black 2:white
//black first

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

int f[NM][NM][NM];


int main(int argc, char const *argv[])
{
	int n,m;
	int p;
	int x,y,z;
	int bow;
	int cnt;

	while(1){
		memset(f,0,sizeof(f));

		cin>>n>>m>>p;
		if(n+m+p==0) break;

		cnt = 1;

		for(int i1=0;i1<p;i1++){
			cin>>x>>y;
		
			if(cnt<m) {
				if(i1%2==0) bow=1;
				else bow=2;

				for(z=1;z<=n;z++){
					if(f[z][y][x]==0) break;
				}
				
				f[z][y][x]=bow;

				for(int i3=0;i3<13;i3++){
					cnt=1;
					int tempx=x+dx[i3];
					int tempy=y+dy[i3];
					int tempz=z+dz[i3];
					while(f[tempz][tempy][tempx]==bow){
						tempx+=dx[i3];
						tempy+=dy[i3];
						tempz+=dz[i3];
						cnt++;
					}
					tempx=x-dx[i3];
					tempy=y-dy[i3];
					tempz=z-dz[i3];
					while(f[tempz][tempy][tempx]==bow){
						tempx-=dx[i3];
						tempy-=dy[i3];
						tempz-=dz[i3];
						cnt++;
					}

					if(cnt>=m) {


						if(bow==1) {
							cout<<"Black "<<i1+1<<endl;
						}
						else {
							cout<<"White "<<i1+1<<endl;
						}

						break;
					}
				}
			}
		}
		if(cnt<m) cout<<"Draw"<<endl;

	}
	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >>N;
  vector<vector<int>> A(N+1,vector<int>(3,0));
  for(int i=1; i<=N; i++){
    int t,x,y;
    cin >>t >>x >>y;
    A[i][0]=t;
    A[i][1]=x;
    A[i][2]=y;
  }
  string ans="No";
  for(int i=0; i<N; i++){
    int t,x,y;
    t=abs(A[i][0]-A[i+1][0]);
    x=abs(A[i][1]-A[i+1][1]);
    y=abs(A[i][2]-A[i+1][2]);
    if(t<x+y) break;
    else if(t>x+y){
      t-=x+y;
      if(t%2!=0) break;
    }
    if(i==N-1) ans="Yes";
  }
  cout <<ans <<endl;
}


Measured memory_bytes: 5760
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	var i int
	if sc.Scan() {
		if num, err := strconv.Atoi(sc.Text()); err == nil {
			i = num
		}
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	k := nextInt()
	var count int
	var backLunluns []int

	for i := 1; i < 10; i++ {
		backLunluns = append(backLunluns, i)
		count++
		if count == k {
			fmt.Println(i)
			return
		}
	}
	for d := 2; ; d++ {
		var lunluns []int
		for i := 0; i < len(backLunluns); i++ {
			str := strconv.Itoa(backLunluns[i])
			last := str[len(str)-1]
			num, _ := strconv.Atoi(string(last))
			v := backLunluns[i]*10 + num
			if v%10 == 0 {
				lunluns = append(lunluns, v)
				count++
				if count == k {
					fmt.Println(v)
					return
				}
				lunluns = append(lunluns, v+1)
				count++
				if count == k {
					fmt.Println(v + 1)
					return
				}
			} else if num == 9 {
				lunluns = append(lunluns, v-1)
				count++
				if count == k {
					fmt.Println(v - 1)
					return
				}
				lunluns = append(lunluns, v)
				count++
				if count == k {
					fmt.Println(v)
					return
				}
			} else {
				lunluns = append(lunluns, v-1)
				count++
				if count == k {
					fmt.Println(v - 1)
					return
				}
				lunluns = append(lunluns, v)
				count++
				if count == k {
					fmt.Println(v)
					return
				}
				lunluns = append(lunluns, v+1)
				count++
				if count == k {
					fmt.Println(v + 1)
					return
				}
			}
		}
		backLunluns = lunluns
	}
	fmt.Println(count)
}


Measured memory_bytes: 5900
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



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

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;cin>>n;
  string s;
  vector<int>ss(n);
  cin>>s;
  rep(i,n)ss[i]=s[i]=='x';
  rep(i,4){
    bitset<2>ti=i;
    vector<int>ft(n+1);
    ft[0]=ti[0];
    ft[1]=ti[1];
    rep(j,n-1){
      ft[j+2]=ft[j+1]^ss[j+1]^ft[j];
    }
    if(ft[n]==ft[0]&&ft[n-1]==(ft[0]^ss[0]^ft[1])){
      rep(j,n){
        if(!ft[j])cout<<"S";
        else cout<<"W";
      }
      cout<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;

  return 0;

}


Measured memory_bytes: 1280
#include <algorithm>
#include <cstring>
#include <iostream>

using namespace std;

class Dice {
public:
    Dice(int pips[]) {
        for (int i = 0; i < 6; i++) {
            this->pips[i] = pips[i];
        }
    }

    int getTopPip() {
        return pips[0];
    }

    void roll(char direction) {
        memcpy(tmpPips, pips, sizeof(int) * 6);
        if (direction == 'E') {
            pips[0] = tmpPips[3];
            pips[2] = tmpPips[0];
            pips[3] = tmpPips[5];
            pips[5] = tmpPips[2];
        } else if (direction == 'N') {
            pips[0] = tmpPips[1];
            pips[1] = tmpPips[5];
            pips[4] = tmpPips[0];
            pips[5] = tmpPips[4];
        } else if (direction == 'W') {
            pips[0] = tmpPips[2];
            pips[2] = tmpPips[5];
            pips[3] = tmpPips[0];
            pips[5] = tmpPips[3];
        } else {
            pips[0] = tmpPips[4];
            pips[1] = tmpPips[0];
            pips[4] = tmpPips[5];
            pips[5] = tmpPips[1];
        }
    }

    int getRightPip(int top, int front) {
        for (int i = 0; i < 6; i++) {
            for (int j = 0; j < 4; j++) {
                if (pips[check[i][j]] == top &&
                    pips[check[i][j + 1]] == front) {
                        return pips[i];
                    }
            }
        }
    }

    bool isSameAs(Dice dice) {
        string rollPolicy = "NNNNENNNENNNWNNNWNNNENNN";
        int *ptr = dice.getPipsPtr();
        for (int i = 0; i < rollPolicy.size(); i++) {
            roll(rollPolicy[i]);
            if (memcmp(pips, ptr, 6 * sizeof(int)) == 0) {
                return true;
            }
        }
        return false;
    }

    int* getPipsPtr() {
        return pips;
    }

private:
    int pips[6];
    int tmpPips[6];
    // top, frontの順番でラベルがマッチした時、外側のindexがrightのラベル
    int check[6][5] = {
        {3, 1, 2, 4, 3}, {5, 2, 0, 3, 5},
        {0, 1, 5, 4, 0}, {4, 5, 1, 0, 4},
        {3, 0, 2, 5, 3}, {4, 2, 1, 3, 4}};
};

int main() {
    int pips[6], num;
    string directions;

    for (int i = 0; i < 6; i++) {
        cin >> pips[i];
    }
    Dice dice1(pips);

    for (int i = 0; i < 6; i++) {
        cin >> pips[i];
    }
    Dice dice2(pips);

    if (dice1.isSameAs(dice2)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3204
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){
	string S; cin>>S;
	int a=0,b=0;
	for(int i=0;i<S.size();i++){
		if(S[i]=='0') a++;
		else b++;
	}

	cout<<2*min(a,b)<<endl;

	return 0;
}



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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

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

    int N;
    cin >> N;

    vi x(N), y(N);
    set<pair<int, int>> have;
    for (int i = 0; i < N; i++) {
        cin >> x[i] >> y[i];
        have.insert({ x[i], y[i] });
    }

    int ans = N;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (i == j) continue;
            int p = x[j] - x[i], q = y[j] - y[i];

            int cand = N;
            for (int k = 0; k < N; k++) {
                cand -= have.count({ x[k] - p, y[k] - q });
            }
            ans = min(ans, cand);
        }
    }

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



Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */

    int n = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();

    boolean[] blocked = new boolean[n + 1];

    String s = sc.next();
    for (int i = 0; i < n; i++){
      if (s.charAt(i) == '#') blocked[i + 1] = true;
    }
    boolean check = move(a, c, blocked) && move(b, d, blocked);
    if (a < b && b < d && d < c) {
      // special case. A might be blocked by B
      check = check && canJumpOver(b, d, blocked);
    }
    if (check) {
      os.println("Yes");
    } else {
      os.println("No");
    }
  }


  private static boolean canJumpOver(int from, int to, boolean[] blocked) {
    for (int i = from ; i <= to; i++) {
      if (!blocked[i - 1] && !blocked[i] && !blocked[i + 1]) return true;
    }
    return false;
  }

  private static boolean move(int from, int to, boolean[] blocked) {

    boolean[] reachable = new boolean[to + 1];
    reachable[from] = true;

    for (int i = from; i < to; i++) {
      if (reachable[i]) {
        if (i + 1 <= to && !blocked[i + 1]) {
          reachable[i + 1] = true;
        }
        if (i + 2 <= to && !blocked[i + 2]) {
          reachable[i + 2] = true;
        }
      }
    }
    return reachable[to];
  }
}

Measured memory_bytes: 25900
# -*- coding: utf-8 -*-
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
result = 0
for i in range(n):
    a = list(map(int, input().split()))
    score = 0
    for j in range(m):
        score += (a[j] * b[j])
    if (score + c > 0):
        result += 1
print(result)


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

int main()
{ios_base::sync_with_stdio(false);
int a,b,c,d,e,f;
cin>>a>>b>>c>>d>>e>>f;
ld mx=0,dis=e;
dis/=100;
int a1=0,a2=0;
rep(i,0,30)
{
	rep(j,0,30)
	{
		ld w=i*a+j*b;
		w*=100;
		if(w==0)continue;
		if(w>f)continue;
		rep(k,0,3000)
		{
			rep(l,0,3000)
			{
				ld s=k*c+l*d;
				if(s+w>f)break;
				if(s>dis*w)break;
				ld den = 100*s;
				den/=(s+w);
				if(den>=mx)
				{
					mx=den;
					a1=w,a2=s;
				}
			}
		}
	}
}
o2(a1+a2,a2);
return 0;
}



Measured memory_bytes: 256
a, b, c, x, y = map(int, input().split())
res = 0
if a+b > c*2:
    mi = min(x, y)
    res += c*2 * mi
    x -= mi
    y -= mi
res += x * min(a, c*2)
res += y * min(b, c*2)
print(res)

Measured memory_bytes: 3060
INTEGER N,T,A
INTEGER,ALLOCATABLE,DIMENSION(:)::H
INTEGER ANS
REAL S
READ*,N,T,A
ALLOCATE(H(N))
READ*,H
S=500
DO I=1,N
  IF(ABS( A-(T-H(I)*0.006) )>S) CYCLE
  S=ABS( A-(T-H(I)*0.006) )
  ANS=I
END DO
PRINT"(I0)",ANS
END

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

struct State{
    int at;
    ll cost;
    State(int a, ll c) : at(a), cost(c){}
    bool operator>(const State& s) const{
        return cost > s.cost;
    }
};

struct Edge{
    int to;
    ll cost;
    Edge(int t, ll c) : to(t), cost(c){}
};

using Graph = vector<vector<Edge> >;
const ll INF = 1e15;

void dijkstra(int s, const Graph& G, vector<ll>& minc){
    minc.assign(G.size(), INF);
    priority_queue<State, vector<State>, greater<State> > pq;
    pq.emplace(s, 0);
    minc[s] = 0;
    while(!pq.empty()){
        State cur = pq.top();
        pq.pop();
        if(minc[cur.at] < cur.cost) continue;
        for(const Edge& e : G[cur.at]){
            ll cost = cur.cost + e.cost;
            if(minc[e.to] <= cost) continue;
            minc[e.to] = cost;
            pq.emplace(e.to, cost);
        }
    }
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	Graph G(n);
	rep(i,n-1) G[i+1].emplace_back(i, 0);
	rep(i,m){
		int l, r;
		ll c;
		cin >> l >> r >> c;
		--l; --r;
		G[l].emplace_back(r, c);
	}
	vector<ll> dist;
	dijkstra(0, G, dist);
	if(dist[n-1] == INF) dist[n-1] = -1;
	cout << dist[n-1] << endl;
	return 0;
}

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

using namespace std;

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

  priority_queue<long long> q;

  for (int i = 0; i < n; ++i) {
    long long a;
    scanf("%lld", &a);
    q.push(a);
  }

  for (int i = 0; i < m; ++i) {
    long long ma = q.top(); q.pop();
    ma /= 2;
    q.push(ma);
  }

  long long ans = 0;
  while (!q.empty()) {
    ans += q.top(); q.pop();
  }
  printf("%lld\n", ans);
  return 0;
}



Measured memory_bytes: 1400
PROGRAM ATCODER

implicit none
integer :: w(6)
integer :: i, j, count(4), check1, check2

read(*,*) (w(i), i=1,6)

count = 0

do i = 1, 6
	do j = 1, 4
		if (w(i) == j) then
    		count(j) = count(j) + 1
		end if
    end do
end do

check1 = 0
check2 = 0
do i = 1, 4
  if (count(i) == 2) then
      check2 = check2 + 1
  else if (count(i) == 1) then
      check1 = check1 + 1
  end if
end do

if(check1 == 2 .and. check2 == 2) then
	write(*,'(a)') 'YES'
else
	write(*,'(a)') 'NO'
end if

END PROGRAM ATCODER


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

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  for(int i = 0; i<n ; i++){
    cin >> s.at(i);
  }
  
  int y = 0;
  
  for(int i = 0 ; i < n-1; i++){
    for(int j = i+1 ; j<n ; j++){
      if(s.at(i) == s.at(j)){
       y = 1;
       break;
      }   
    }
    if(y == 1){
      break;
    }
  }
  
  for(int i = 0 ; i<n-1; i++){
    int x;
    x = s.at(i).size();
    if(s.at(i).at(x-1) != s.at(i+1).at(0)){
      y = 1;
      break;
    }
  }
  
  if(y == 1){
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()
mod = 998244353
n, s = map(int, input().split())
a = [int(x) for x in input().split()]
dp = [[0]*(s + 1) for _ in range(n + 1)]
dp[0][0] = 1
for i in range(1, n + 1):
    for j in range(s + 1):
        dp[i][j] += dp[i - 1][j]*2
        dp[i][j] %= mod
        if j - a[i - 1] >= 0:
            dp[i][j] += dp[i - 1][j - a[i - 1]]
            dp[i][j] %= mod
print(dp[-1][-1])

Measured memory_bytes: 132396