akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;
typedef signed long long ll;

mt19937 mt(time(nullptr));
// uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int n, k;
  cin >> n >> k;
  if (k==1) cout << 0 << endl;
  else {
    cout << n-k << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>

int main() {
	int N;
	std::cin >> N;

	std::string s;
	std::cin >> s;

	const int numRed = std::count(s.begin(), s.end(), 'R');
	const int numBlue = s.length() - numRed;
	
	const bool result = numRed > numBlue;

	std::cout << (result ? "Yes" : "No") << std::endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, k;
    cin >> n >> k;
    
    if ((n - 2 * (k - 1)) >= 1) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
    
    return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define REP(i, k, n) for(auto i = k; i != n; i++)
#define rrep(i, n) RREP(i, n, 0)
#define RREP(i, n, k) for(auto i = n; i != k; i--)
#define all(x, r) (x), (x)+(r)
#define ALL(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << " " << x << endl
#define exst(x, data) (data).find(x) != (data).end()
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define np next_permutation
#define b32 bitset<32>

using ll = long long;
using Pii = pair<int,int>;
using Tiii = tuple<int, int, int>;
template<class T>using V = vector<T>;

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

    int N; cin >> N;
    V<int> A(N+1); REP(i,1,N+1) cin >> A[i];

    ll ans = 0;
    int rest = 0;
    REP(i,1,N+1) {
        if(rest==1 && A[i]>0) { ans++; rest=0; A[i]--; }
        ans += A[i] / 2;
        rest = A[i] % 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#define print(n) std::cout << n << std::endl
#define print_no_indention(n) std::cout << n
using namespace std;


int main() {
    int n,k;
    cin >> n >> k;
    vector<int> h(n);

    for (int i = 0; i < n; ++i) {
        cin >> h.at(i);
    }

    int count = 0;

    for (int i = 0; i < n; ++i) {
        if(k <= h.at(i))count++;
    }

    print(count);
}

Measured memory_bytes: 640
import java.io.*;
import java.nio.CharBuffer;
import java.util.NoSuchElementException;

public class Main {

    public static void main(String[] args) {
        SimpleScanner scanner = new SimpleScanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);

        long s = scanner.nextLong();
//        long s = 999999999999999990L;
        long x1 = (long) Math.sqrt(s);
        long y2 = x1;
        if (x1 * y2 < s)
            ++y2;
        if (x1 * y2 < s)
            ++x1;
        long x2 = 1;
        long y1 = x1 * y2 - s;
        writer.println(0 + "  " + 0 + " " + x1 + " " + y1 + " " + x2 + " " + y2);

        writer.close();
    }

    private static class SimpleScanner {

        private static final int BUFFER_SIZE = 10240;

        private Readable in;
        private CharBuffer buffer;
        private boolean eof;

        SimpleScanner(InputStream in) {
            this.in = new BufferedReader(new InputStreamReader(in));
            buffer = CharBuffer.allocate(BUFFER_SIZE);
            buffer.limit(0);
            eof = false;
        }


        private char read() {
            if (!buffer.hasRemaining()) {
                buffer.clear();
                int n;
                try {
                    n = in.read(buffer);
                } catch (IOException e) {
                    n = -1;
                }
                if (n <= 0) {
                    eof = true;
                    return '\0';
                }
                buffer.flip();
            }
            return buffer.get();
        }

        void checkEof() {
            if (eof)
                throw new NoSuchElementException();
        }

        char nextChar() {
            checkEof();
            char b = read();
            checkEof();
            return b;
        }

        String next() {
            char b;
            do {
                b = read();
                checkEof();
            } while (Character.isWhitespace(b));
            StringBuilder sb = new StringBuilder();
            do {
                sb.append(b);
                b = read();
            } while (!eof && !Character.isWhitespace(b));
            return sb.toString();
        }

        int nextInt() {
            return Integer.valueOf(next());
        }

        long nextLong() {
            return Long.valueOf(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 22740
import std.stdio;
import std.algorithm;
import std.array;
import std.conv;
import std.string;
import std.uni;
import std.range;
import std.algorithm;

void main()
{
    while (!stdin.eof)
    {
        auto a = readln.strip;
        if (a == "-")
            break;
        auto m = readln.strip.to!int;
        foreach (x; iota(m).map!(x => readln.strip.to!int))
        {
            a = a[x..$] ~ a[0..x];
        }
        writeln(a);
    }
}



Measured memory_bytes: 2424
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

	public class Main {
		public static void main(String[] args) {
			FastScanner scan = new FastScanner();
			try (PrintWriter out = new PrintWriter(System.out);) {

				int n = scan.nextInt();

				int ret;

				if (n % 2 == 0) {
					ret = (n - 2) / 2;
				} else {
					ret = (n - 1) / 2;
				}

				out.println(ret);
				out.flush();
			}

		}

	}

	class FastScanner {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[ptr++];
			else
				return -1;
		}

		private static boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		public boolean hasNext() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr]))
				ptr++;
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		public int nextInt() {
			long nl = nextLong();
			if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
				throw new NumberFormatException();
			return (int) nl;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}
	}


Measured memory_bytes: 22996
# ABC 157 A
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nms = lambda: map(str, input().split())
nl = lambda: list(map(int, input().split()))
n=int(input())
if n%2==1:
    print(n//2+1)
else:
    print(n//2)


Measured memory_bytes: 3060
import sys
from itertools import product

input = sys.stdin.readline


def main():
    N, M = map(int, input().split())
    k = [None] * M
    s = [None] * M
    for i in range(M):
        k[i], *s[i] = map(int, input().split())
    p = list(map(int, input().split()))

    ans = 0
    for comb in product(range(2), repeat=N):
        are_on = True
        for i in range(M):
            n_on = 0
            for ss in s[i]:
                n_on += 1 if comb[ss - 1] == 1 else 0
            if n_on % 2 != p[i]:
                are_on = False
        ans += 1 if are_on else 0

    print(ans)


if __name__ == "__main__":
    main()


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

void solver(){
	int a , b , c;
	scanf("%d%d%d",&a,&b,&c);
	printf("%d\n",c-min(c,a-b));
	return ;
}

int main(){
	int q = 1;
	//scanf("%d",&q);
	while(q--){
		solver();
	}
	return 0;
}


Measured memory_bytes: 256
n,m = map(int, input().split())
arr = []
res = 0
count = 0
for i in range(n):
  arr.append(list(map(int, input().split())))
arr = sorted(arr)
i = 0
while count < m:
  count += arr[i][1]
  if count < m:
    res += arr[i][0] * arr[i][1]
  else:
    res += (arr[i][1] - count + m) * arr[i][0]
  i += 1
print(res)

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

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

int main() {
  int N, M;
  while(cin >> N >> M && (N|M)) {
    double p[N][N]; rep(i, N) rep(j, N) cin >> p[i][j];
    vector<double> dp(N, 1.0), next(N);
    rep(m, M-1) {
      rep(i, N) {
	rep(j, N) {
	  next[j] = max(next[j], dp[i]*p[i][j]);
	}
      }
      dp = next;
    }
    printf("%.2f\n", *max_element(dp.begin(), dp.end()));
  }
  return 0;
}

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

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
#define INF 100000000

vector<vector<ll> > dp(100002, vector<ll> (3,-1));
ll ara[100005][4];
ll n;
ll f(ll i , ll j){

    if(i==n-1) return dp[i][j] = ara[i][j];
    if(dp[i][j]!=-1) return dp[i][j];

    ll m=0;

    if(j==2)
    m= max(f(i+1,0),f(i+1,1))+ara[i][2];

    else if(j==1)
    m= max(f(i+1,0),f(i+1,2))+ara[i][1];

    else m= max(f(i+1,2),f(i+1,1))+ara[i][0];


    dp[i][j] = m;

    return dp[i][j];
}



int main(){
    cin>>n;
    for(ll i=0;i<n;i++){
            for(ll j=0;j<3;j++)
        scanf("%lld",&ara[i][j]);
    }
    f(0,0);
    f(0,1);
    f(0,2);

    ll m=max(dp[0][0],dp[0][1]);
    cout<<max(dp[0][2],m);
    return 0;
}


Measured memory_bytes: 13568
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>

using namespace std;

int main() {
    int N, X;
    cin >> N >> X;
    //vector<int> L(N);
    int l;
    int loc = 0;
    int counter = 1;
    for(int i=0; i<N; i++) {
        cin >> l;
        loc += l;
        if (loc > X) break;
        else counter++;
    }
    cout << counter << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>
using namespace std;
int main(){
  int n,m; cin>>n>>m;
  vector<long long> v(n+1);
  set<int> a;
  for(int i=0;i<m;i++) { int ai;cin>>ai;a.insert(ai); }
  v[0]=1;
  v[1]=a.count(1)?0:1;
  for(int i=2;i<=n;i++){
    v[i]=a.count(i)?0:(v[i-1]+v[i-2])%1000000007;
  }
  cout<<v[n]<<endl;
  return 0;
}


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

using namespace std;

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

    map<string, int> mp;
    int mx = 0;
    for (int i = 0; i < N; ++i) {
        string s;
        cin >> s;
        mp[s]++;
        mx = max(mx, mp[s]);
    }

    vector<string> res;
    for (auto &x:mp) {
        if (x.second == mx) {
            res.emplace_back(x.first);
        }
    }

    sort(res.begin(), res.end());
    for (auto &x:res) {
        cout << x << endl;
    }
    return 0;
}


Measured memory_bytes: 27380
//

#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

int main(){
	string S, T;
	cin >> S >> T;

	bool flag = false;

	for (int i = 0; i < S.length(); ++i){
		S = S.substr(1, S.length()-1) + S[0];

		if (S == T){
			flag = true;
			break;
		}
	}
	if (flag)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n = 0;
  int a[100] = {};
  int b[1000] = {};
  int i = 0;
  int j = 0;
  int cnt = 0;
  int flag = 1;
  int last = 0;
  int lastj = 0;
  int flagc = 0;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&b[i]);
  }
  //printf("$%d$",b[0]);
  for(i=0;i<n;i++){
    cnt = 1;
    flagc = 0;
    last = 0;
    lastj = 0;
    for(j=0;j<n;j++){
      if(b[j] != 0){
        if(b[j] == cnt){
          last = b[j];
          lastj = j;
          cnt++;
          flagc = 1;
        }else{
          cnt++;
        }
      }
    }
    a[i] = last;
    b[lastj] = 0;
    /*printf("%d/",lastj);
    
    for(j=0;j<n;j++){
      printf("%d",b[j]);
    }
    printf("\n");*/
  }
  
  if(a[n-1] == 0){
    printf("-1");
  }else{
    for(i=n-1;i >= 0;i--){
      printf("%d\n",a[i]);
    }
  }
  return 0;
}
        
  

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE char
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
	return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
	return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}
long long gcd(long long x,long long y){
	return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
	return x/gcd(x,y)*y;
}

// konoshita kara kaku

int main(void){
	int a=in(),b=in(),k=in(),i;
	rep(i,k){
		if(a+i>b)break;
		print(a+i);
	}
	rep(i,k){
		if(b-k+i+1<a+k)continue;
		print(b-k+i+1);
	}
	return 0;
}

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

int main()
{
    string s;

    cin >> s;

    int c = 0;

    for (int i = 0; s[i] != '\0'; i++)
    {
        if (s[i] == '9')
            c++;
    }

    if (c > 0) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>
 
using namespace std;
using namespace __gnu_pbds;
 
#define endl '\n'
 
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template<typename T>
static T randint(T lo, T hi){
	return uniform_int_distribution<T>(lo, hi)(rng);
}


int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 
	// freopen("settling.in", "r", stdin);
	// freopen("settling.out", "w", stdout);

	int n;
	cin >> n;

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

	int ans = 0;
	for(int i = 0; i < n; i++){
		for(int j = i + 1; j < n; j++){
			for(int k = j + 1; k < n; k++){
				vector<int> v = {a[i], a[j], a[k]};
				sort(v.begin(), v.end());
				if(v[0] != v[1] && v[0] != v[2] && v[1] != v[2] && v[0] + v[1] > v[2])
					ans++;
			}
		}
	}

	cout << ans << endl;

	return 0;
}


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

int main()
{
    int s;
    string a;
    cin >> a;
    for(int i =1; i < a.size(); i++) {
       if (a[i] !=a[i -1]) s++;
    }
    cout <<s;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll a, b, h, m;
  cin >> a >> b >> h >> m;
  double pi = acos(-1);
  double ans =
      a * a + b * b - 2 * a * b * cos(2 * pi * 33 / 36 * (60 * h + m) / 60);
  ans = sqrt(ans);
  cout << fixed << setprecision(15) << ans << "\n";
}

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

ll solve() {
    ll N, Q;
    cin >> N >> Q;
    vector<ll> T(Q), X(Q);
    for ( int i = 0; i < Q; i++ ) {
        cin >> T[i] >> X[i];
        T[i]--;
    }
    vector<map<ll,ll>> b(2);
    b[0][N] = N;
    b[1][N] = N;
    ll nw = 0;
    for ( int i = 0; i < Q; i++ ) {
        int t = T[i], tc = 1 - t;
        int x = X[i];
        nw += b[t].upper_bound(x)->second - 2;
        if ( x < b[t].begin()->first ) {
            b[t][x] = b[tc].begin()->first;
            b[tc].begin()->second = x;
        }
    }
    ll ans = (N-2)*(N-2) - nw;
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 18720
#include<stdio.h>
#include<math.h>

struct Point {double x, y;};

void koch(int n, Point a, Point b){
    if (n == 0) return;
    Point s, t, u;
    double th = M_PI * 60.0 / 180.0; // 度からラジアンへ単位を変換

    s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
    s.y = (2.0 * a.y + 1.0 * b.y) / 3.0 ;
    t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
    t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
    u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
    u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

    koch(n-1, a, s);
    printf("%.8f %.8f\n", s.x, s.y);
    koch(n - 1, s, u);
    printf("%.8f %.8f\n", u.x, u.y);
    koch(n - 1, u, t);
    printf("%.8f %.8f\n", t.x, t.y);
    koch(n - 1, t, b);
}
int main(){
    Point a, b;
    int n;

    scanf("%d", &n);

    a.x = 0;
    a.y = 0;
    b.x = 100;
    b.y = 0;

    printf("%.8f %.8f\n", a.x, a.y);
    koch(n, a, b);
    printf("%.8f %.8f\n", b.x, b.y);

    return 0;
}


Measured memory_bytes: 2708
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000



int main(){
	
	long long H,W;
	cin>>H>>W;
	
	if(H*W%3==0){
		cout<<0<<endl;
		return 0;
	}
	
	long long ans = min(H,W);
	
	for(int i=1;i<=H-1;i++){
		long long a = i*W;
		long long h = H-i;
		long long b = h*(W/2);
		long long c = h*((W+1)/2);
		
		long long d = max({a,b,c})-min({a,b,c});
		
		ans = min(ans,d);
	}
	
	for(int i=1;i<=W-1;i++){
		long long a = i*H;
		long long w = W-i;
		long long b = w*(H/2);
		long long c = w*((H+1)/2);
		long long d = max({a,b,c})-min({a,b,c});
		
		ans = min(ans,d);
	}
	
	cout<<ans<<endl;
		
	
	return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	private static Scanner in;
	
	private static int n;
	private static int[] a;
	private static long[][] dp;
	private static final int MOD = (int)1e9+7;
	
	public static void main(String[] args) {
		in = new Scanner(System.in);
		n = in.nextInt();
		a =  new int[n];
		for(int i=0; i<n; i++) {
			a[i] = in.nextInt();
		}
		
		dp = new long[n+1][n+1];
		
		for(int i=0; i<dp.length; i++)
			Arrays.fill(dp[i], -1);
		
		System.out.println(solve(0, n-1));
		
	}
	
	
	private static long solve(int l, int r) {
		if (l>=r) return 0;
		
		if (dp[l][r]!=-1) return dp[l][r];
		
		
		long sum = 0;
		for(int i=l; i<=r; i++) sum+=a[i];
		
		long ans = (long)1e15;
		for(int i=l; i<r; i++) {
			ans = Math.min(ans, solve(l, i)+solve(i+1, r)+sum);
		}
		
		return dp[l][r]=ans;
	}

}


Measured memory_bytes: 27200
x = int(input())

dp = [0]*200000
for j in range(6):
  dp[100+j] += 1

def max_sum():
  global dp
  for i in range(x):
    if dp[i] > 0:
      for j in range(6):
        dp[i+100+j] += 1
  return


max_sum()
print(min(dp[x], 1))

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

long long dp[101][100001];
long long n,w;
long long value[9999];
long long weight[9999];



long long ans(long long pos, long long we){

    long long profit,profit1;

    if(pos==n) return 0;
    if(dp[pos][we]!=-1) return dp[pos][we];

    if(we+weight[pos]<=w){
        profit=value[pos]+ans(pos+1,we+weight[pos]);
    }
    else profit=0;

    profit1=ans(pos+1,we);
    dp[pos][we]=max(profit,profit1);
    return max(profit,profit1);
}


int main()
{
    memset(dp,-1,sizeof(dp));
    cin>>n>>w;
    for(int i=0;i<n;i++){
        cin>>weight[i]>>value[i];
    }
    cout<<ans(0,0)<<endl;
}


Measured memory_bytes: 79104
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

int count(int x) {
  int res = 0;
  while(x % 100 == 0) {
    x /= 100;
    res++;
  }
  return res;
}

int main(void) {
  int D, N;
  cin >> D >> N;
  for(int i = 1; ; ++i) {
    if(count(i) == D) {
      --N;
      if(N == 0) {
        cout << i << endl;
        break;
      }
    }
  }
  return 0;
}



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

long long KS(vector<vector<int>> arr,long long k){
	int n=arr.size();
	long long dp[n+1][k+1];
	for(int i=0;i<=k;i++){
		dp[0][i]=0;
	}
	for(int i=0;i<=n;i++){
		dp[i][0]=0;
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=k;j++){
			if(j-arr[i-1][0]>=0){
				dp[i][j]=max(arr[i-1][1]+dp[i-1][j-arr[i-1][0]],dp[i-1][j]);
			}
			else
				dp[i][j]=dp[i-1][j];
		}
	}
//	for(int i=0;i<=n;i++){
//		for(int j=0;j<=k;j++){
//			cout<<dp[i][j]<<" ";
//		}
//		cout<<endl;
//	}
	return dp[n][k];
}

int main(){
	int N;
	long long k;
	cin>>N>>k;
	vector<vector<int>> arr;
	int val, wt;
	for(int i=0;i<N;i++){
		cin>>val>>wt;
		arr.push_back({val,wt});
	}
	cout<<KS(arr,k)<<endl;
	return 0;
}


Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
const long long inf = 1000000001; // const 書き換え禁止
const double PI = 3.14159265358979323846; //M_PI はライブラリ

int main(void){
    int n,d;
    cin >> n >> d;
    int range = (n+d) - (n-d) + 1;
    int hoge = range;
    int ans = 0 , flag = 0;
    for(int i=1;i<100;i++){
        ans++;
        if(range>=n){
            break;
        }
        range = range + hoge;
    }
    
    cout << ans << endl;
    
}

Measured memory_bytes: 3600
#include <iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
using namespace std;
int main() {
	long long int a=0,b=0,c=0,d=0,n=0,ans=0,count=100000000,h,w ,end=0,idx,m;
	string s;
	vector<long long int> x,l,xc,lc,p;
	vector<long long int>::iterator position;
	bool q=false;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a;
		p.push_back(a);
	}
	
	for (int i = 0; i < n; i++){
		if (p.at(i) < count) {
			ans++;
			count = p.at(i);
			continue;
		}
	}
		cout <<ans<< endl;
	
	
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a=1;
  int keisansu;
  int b;
   
  cin >> keisansu >>b;
  
  for (int i = 0; i < keisansu; i++) {
    if(a<=b){
      a*=2;}else{   
             a+=b;
           }
  }
  
  cout <<a <<endl;}

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

const int MAX_V = 111;
const int INF = (1 << 27);

typedef struct{
  int to;
  int cap, rev;
}edge;

vector<edge> node[MAX_V];
queue<int> que;
int v, e;
int nnode[MAX_V];
int iter[MAX_V];

void input();
int dfs(int s, int t, int f);
void bfs(int s);
int max_flow(int s, int t);

void debug();

int main(){
  ios_base::sync_with_stdio(false);

  input();

  cout << max_flow(0, v-1) << endl;
  
  return 0;
}


void input(){

  cin >> v >> e;

  for(int i=0;i<e;i++){
    int from, to, cap;
    cin >> from >> to >> cap;
    node[from].push_back((edge){to, cap, node[to].size()});
    node[to].push_back((edge){from, 0, node[from].size() - 1});
  }

  return;
}

int dfs(int s, int t, int f){
  //cout << s << " " << t << " " << f << endl;
  
  if(s == t)return f; 
  
  for(int &i=iter[s];i<node[s].size();i++){
    edge &now = node[s][i];

    if(now.cap > 0 && nnode[s] < nnode[now.to]){
      int d = dfs(now.to , t, min(f, now.cap));
      //cout << "d = " << d << endl;
      if(d > 0){
        now.cap -= d;
        node[now.to][now.rev].cap += d;
        return d;
      }
    }
  } 

  return 0; 
}

void bfs(int s){

  fill(nnode, nnode+MAX_V, -1); 

  que.push(s);  
  nnode[s] = 0;
  while(!que.empty()){
    int now = que.front(); que.pop();

    //cout << "node[now].size() = " << node[now].size() << endl; 

    for(int i=0;i<node[now].size();i++){
      edge &now_node = node[now][i];

      //cout << now_node.cap << " " << nnode[now_node.to] << endl;

      if(now_node.cap > 0 && nnode[now_node.to] < 0){
        que.push(now_node.to);
        nnode[now_node.to] = nnode[now] + 1;
      }
    }
  }
  //cout << endl;
  return;
}

int max_flow(int s, int t){
  int flow = 0;

  while(true){
    //cout << "flow = " << flow << endl;
    bfs(s);  
    if(nnode[t] < 0)return flow;
    fill(iter, iter+MAX_V, 0); 
    int f;
    while((f = dfs(s, t, INF)) > 0){
      flow += f;
    }
  
    //debug();

  }
}

void debug(){
  cout << "debug" << endl;

  for(int i=0;i<e;i++){
    cout << i << ":" << node[i].size() << " " << nnode[i] << endl;
  }
  
  for(int i=0;i<e;i++){
    cout << i << ":";
    for(int j=0;j<node[i].size();j++){
      cout << "[" << node[i][j].to  << "," << node[i][j].cap << "]" << " ";
    }
    cout << endl;
  } 
  
  return;
}

Measured memory_bytes: 3212
while 1:
	try:
		a=raw_input()
		cjoi=cioi=0
		for i in range(len(a)-2):
			if   a[i]=="J" and a[i+1]=="O" and a[i+2]=="I":cjoi+=1
			elif a[i]=="I" and a[i+1]=="O" and a[i+2]=="I":cioi+=1
		print cjoi
		print cioi
	except:
		break		

Measured memory_bytes: 4420
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> p;
    for(int i = 0; i < n; i++){
        int temp;
        cin >> temp;
        p.push_back(temp);
    }
    sort(p.begin(),p.end());
    int ans = 0;
    for(int i = 0; i < k; i++){
        ans += p[i];
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 3580
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
#include <assert.h>
typedef int64_t ll;
typedef uint64_t ull;
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)

#define MAXN (200001)
#define MOD (1000000007)

int p[20];
int main(void)
{
    int n;
    scanf("%d",&n);

    for(int i=0;i<n;i++)
    {
        scanf("%d",&(p[i]));
    }
    int ans = 0;
    for(int i=1;i<n-1;i++)
    {
        int pt[3] = {p[i-1],p[i],p[i+1]};
        qsort(pt,3,sizeof(int),acs);
        if(pt[1]==p[i]) ans++;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 128
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: chars,
    }
    let n = s.len();
    let mut zeros = 0;
    for i in 0..n {
        if s[i] == '0' {
            zeros += 1;
        }
    }
    let ones = n - zeros;
    println!("{}", n - (std::cmp::max(ones, zeros) - std::cmp::min(ones, zeros)));
}


Measured memory_bytes: 4352
// ------------------------------------
// Date:2018/ 3/11
// Problem:ABC 074 CollectingBalls(Easy) b.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

static const int MOD = 1000000007;

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

  int N, K;
  cin >> N >> K;
  int ans = 0;
  REP(i, N) {
    int x;
    cin >> x;
    ans += 2 * min(x, K - x);
  }

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



Measured memory_bytes: 256
//abc069_b.cpp
//Wed Oct 31 22:45:05 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	string s;
	cin >> s;

	cout << s[0] << s.size()-2 << s[s.size()-1] << endl;
}

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

int main() {
  int N;
  cin >> N;
  int count = 0;
  int max_count = 0;
  FOR(i,0,N) {
    int x,y;
    cin >> x >> y;
    if(x == y) {
      count++;
      max_count = max(count, max_count);
    }
    else count = 0;
  }
  if(max_count >= 3) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3628
N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
if N < 3:
    print('0')
    exit()
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        for k in range(j + 1, N):
            if L[i] == L[j] or L[j] == L[k] or L[i] == L[k]:
                continue
            if L[k] < L[i] + L[j]:
                ans += 1
print(ans)

Measured memory_bytes: 9196
#include<stdio.h>

int main() {
	int person[4][3][10];
	int N;
	int inpt[4];

	//fill 0
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 10; k++) {
				person[i][j][k] = 0;
			}
		}
	}

	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d %d %d %d", &inpt[0], &inpt[1], &inpt[2], &inpt[3]);
		person[inpt[0]-1][inpt[1]-1][inpt[2]-1] += inpt[3];
	}

	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 10; k++) {
				printf(" %d", person[i][j][k]);
			}
			printf("\n");
		}
		if (i != 3)printf("####################\n");
	}


	return 0;
}


Measured memory_bytes: 2684
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;
using ld = long double;



int main()
{
    int N, M;
    cin >> N >> M;
    vector<vector<int>> edges(N), revs(N);
    vector<pair<int, int>> edgep;
    rep(i, M) {
        int s, t;
        cin >> s >> t;
        s--; t--;
        edges[s].push_back(t);
        revs[t].push_back(s);
        edgep.push_back({ s,t });
    }

    vector<ld> prob(N, 0);
    prob[0] = 1;
    REP(i, 1, N) {
        for (int bef : revs[i]) {
            prob[i] += prob[bef] / edges[bef].size();
        }
    }

    vector<ld> esti(N, 1);
    esti[N - 1] = 0;
    for (int i = N - 1; i >= 0; i--) {
        for (int next : edges[i]) {
            esti[i] += esti[next] / edges[i].size();
        }
    }

    ld bestscore = 0;
    pair<int, int> bestedge = { -1,-1 };

    for (auto edge : edgep) {
        int s, t;
        tie(s, t) = edge;
        if (edges[s].size() <= 1)continue;
        ld befscore = esti[s];
        ld siz = edges[s].size();
        ld aftscore = (befscore - 1 - esti[t] / siz)*siz / (siz - 1) + 1;
        ld diff = befscore - aftscore;
        ld score = prob[s] * diff;
        if (score > bestscore) {
            bestscore = score;
            bestedge = edge;
        }
        //cout << s << "->" << t << ": " << befscore << "->" << aftscore << ":" << score << endl;
    }

    if (bestedge.first != -1) {
        int s, t;
        tie(s, t) = bestedge;
        edges[s].erase(find(edges[s].begin(), edges[s].end(), t));
    }
    esti = vector<ld>(N, 1);
    esti[N - 1] = 0;
    for (int i = N - 1; i >= 0; i--) {
        for (int next : edges[i]) {
            esti[i] += esti[next] / edges[i].size();
        }
    }
    cout << fixed << setprecision(12) << esti.front() << endl;
    return 0;
}


Measured memory_bytes: 3956
#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 rrep(i, n) for(int i = (int)(n-1); i >= 0; 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,m;
  cin>>n>>m;
  vector<int>dp(n),num(n,1);
  dp[0]=1;
  rep(i,m){
    int x,y;cin>>x>>y;
    x--;y--;
    num[x]--;num[y]++;
    if(dp[x])dp[y]=1;
    if(num[x]==0)dp[x]=0;
  }
  int cnt=0;
  rep(i,n){
    if(dp[i]&&num[i]>0)cnt++;
  }
  cout<<cnt<<endl;


  return 0;

}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define lli long long int
using namespace std;
lli n,m,k;
lli ip[200001],ap[200001];
lli pp1[200001],pp2[200001];
bool predicate(lli in)
{
	lli val=1e18;
	for(lli i=0;i<=in;i++)
	{
		if(i<=n&&in-i<=m)
		val=pp1[i]+pp2[in-i];
	//	cout<<val<<endl;
		if(val<=k)
		return true;
	}
	return false;
}
lli BSLL(lli l,lli r)
{
//	cout<<l<<" "<<r<<endl;
	if(l==r)
	return l;
	lli mid=(l+r+1)/2;
	if(predicate(mid))
	return BSLL(mid,r);
	return BSLL(l,mid-1);
}
int main()
{
//	cout<<"Yes"<<endl;
	cin>>n>>m>>k;
	ip[0]=0;
	ap[0]=0;
	for(lli i=1;i<=n;i++)
	{
		cin>>ip[i];
		pp1[i]=pp1[i-1]+ip[i];
//		cout<<pp1[i]<<" ";
	}
//	cout<<endl;
	for(lli i=1;i<=m;i++)
	{
		cin>>ap[i];
		pp2[i]=pp2[i-1]+ap[i];
//		cout<<pp2[i]<<" ";
	}
//	cout<<endl;
//	cout<<"Yes"<<endl;
	lli ans;
	if(pp1[n]+pp2[m]<=k)
	{
	//	cout<<"Yes"<<endl;
			ans=n+m;
	}
	else
	ans=BSLL(0,n+m);
	cout<<ans<<endl;
}

Measured memory_bytes: 9804
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int main() {
    string S; cin >> S;
    int N = (int)S.size();
    string A;
    string B;
    for(int i=0; i<N; i++){
        if(i%2){
            A += '0';
            B += '1';
        }else{
            A += '1';
            B += '0';
        }
    }
    
    int cnt1 = 0;
    int cnt2 = 0;
    
    for(int i=0; i<N; i++){
        if(S[i]!=A[i]) cnt1++;
        if(S[i]!=B[i]) cnt2++;
    }
    cout << min(cnt1, cnt2) << endl;
    return 0;
    
}


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

int main()
{
    double a, b, h, m;
    std::cin >> a >> b >> h >> m;
    double aArg = h * 30 + m / 2;
    double bArg = m * 6;
    double rot = 0.0;
    if (aArg > bArg)
    {
        rot = aArg - bArg;
    }
    else
    {
        rot = bArg - aArg;
    }
    if (rot > 180)
    {
        rot = 360 - rot;
    }
    rot = rot * M_PI / 180;
    double ans = sqrt(a * a + b * b - 2 * a * b * cos(rot));
    
    std::cout << std::fixed;
    std::cout << std::setprecision(20) << ans << std::endl;
    return 0;
}

Measured memory_bytes: 4164
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <ctype.h>

using namespace std;
using ll=long long;

int main()
{
    int N, K, X, Y;
    
    cin >> N >> K >> X >> Y;
    
    int fee;
    if (K >= N)
    {
        fee = N * X;
    }
    else
    {
        fee = K * X + (N - K) * Y;
    }

    printf("%d\n", fee);
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 210
#define ll long long
#define db double
#define For(i,x,y) for(int i=(x);i<=(y);++i)
#define Rof(i,x,y) for(int i=(x);i>=(y);--i)
#define Edge(x) for(int i=head[x];i;i=e[i].nxt)
#define lson l,mid,o<<1
#define rson mid+1,r,o<<1|1
#define mset(x,y) memset(x,y,sizeof(y))
#define mcpy(x,y) memcpy(x,y,sizeof(x))
#define p_b push_back
#define mod 998244353
using namespace std;
ll _2[N];
int x[N],y[N];
int main(){
	int n;
	scanf("%d",&n);_2[0]=1;
	For(i,1,n) _2[i]=(_2[i-1]+_2[i-1])%mod;
	ll ans=_2[n]-1-n-n*(n-1)/2;
	while(ans<0) ans+=mod;
	For(i,1,n) scanf("%d%d",&x[i],&y[i]);
	For(i,1,n) For(j,i+1,n){
		int tmp=0;
		For(k,j+1,n) if(1ll*(1ll*y[j]-y[i])*(1ll*x[k]-x[j])==1ll*(1ll*y[k]-y[j])*(1ll*x[j]-x[i])) tmp++;
		(ans+=mod+1-_2[tmp])%=mod;
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(std::unique(all(x)), x.end());
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=acos(-1);
using namespace std;
vector<int> dx={1,0,-1,0};
vector<int> dy={0,1,0,-1};
template<class T>bool chmax(T &a, const T &b) { if (a<=b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<=a) { a=b; return 1; } return 0; }
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

double p;
double f(double x) {
    return x+p/pow(2,x/1.5);
}
int main() {
    int n;
    ll a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    b-=a;
    ll l=-(n-1)*d;
    ll r=-(n-1)*c;
    rep(i,n) {
        if(l<=b&&b<=r) {
            cout<<"YES"<<endl;
            return 0;
        }
        l+=c+d;
        r+=c+d;
    }
    cout<<"NO"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int a, b ,c;
    cin >> a >> b >> c;
    if(a != b && b != c && a != c) cout << 3 << endl;
    else if(a == b && b == c) cout << 1 << endl;
    else cout << 2 << endl;
    return 0;
}

Measured memory_bytes: 3608
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

template <typename Monoid>
struct RMQ {
  RMQ(int sz, const Monoid UNITY) : UNITY(UNITY) {
    init(sz);
    dat.assign((n << 1) - 1, UNITY);
  }

  RMQ(const vector<Monoid> &a, const Monoid UNITY) : UNITY(UNITY) {
    int a_sz = a.size();
    init(a_sz);
    dat.resize((n << 1) - 1);
    REP(i, a_sz) dat[n - 1 + i] = a[i];
    for (int i = n - 2; i >= 0; --i) dat[i] = max(dat[(i << 1) + 1], dat[(i << 1) + 2]);
  }

  void update(int node, Monoid val) {
    node += n - 1;
    dat[node] = val;
    while (node > 0) {
      node = (node - 1) >> 1;
      dat[node] = max(dat[(node << 1) + 1], dat[(node << 1) + 2]);
    }
  }

  Monoid query(int a, int b) const { return query(a, b, 0, 0, n); }

  int find(int a, int b, Monoid val) const { return find(a, b, val, 0, 0, n); }

  Monoid operator[](const int idx) const { return dat[idx + n - 1]; }

private:
  int n = 1;
  const Monoid UNITY;
  vector<Monoid> dat;

  void init(int sz) { while (n < sz) n <<= 1; }

  Monoid query(int a, int b, int node, int left, int right) const {
    if (right <= a || b <= left) return UNITY;
    if (a <= left && right <= b) return dat[node];
    return max(query(a, b, (node << 1) + 1, left, (left + right) >> 1), query(a, b, (node << 1) + 2, (left + right) >> 1, right));
  }

  int find(int a, int b, Monoid val, int node, int left, int right) const {
    if (dat[node] < val || right <= a || b <= left) return -1;
    if (right - left == 1) return node - (n - 1);
    int res_l = find(a, b, val, (node << 1) + 1, left, (left + right) >> 1);
    return res_l == -1 ? find(a, b, val, (node << 1) + 2, (left + right) >> 1, right) : res_l;
    // int res_r = find(a, b, val, (node << 1) + 2, (left + right) >> 1, right);
    // return res_r == -1 ? find(a, b, val, (node << 1) + 1, left, (left + right) >> 1) : res_r;
  }
};

int main() {
  int n, q; cin >> n >> q;
  vector<int> a(n); REP(i, n) cin >> a[i];
  RMQ<int> rmq(a, -INF);
  while (q--) {
    int t; cin >> t;
    if (t == 1) {
      int x, v; cin >> x >> v; --x;
      rmq.update(x, v);
    } else if (t == 2) {
      int l, r; cin >> l >> r; --l; --r;
      cout << rmq.query(l, r + 1) << '\n';
    } else if (t == 3) {
      int x, v; cin >> x >> v; --x;
      int j = rmq.find(x, n, v);
      cout << (j == -1 ? n + 1 : j + 1) << '\n';
    }
  }
  return 0;
}


Measured memory_bytes: 5952
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        x: i32,
        a: i32,
    }
    let ans = if x<a {0} else {10};
    puts!("{}\n", ans);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define rep3(i, s, n) for (int i = s; i > (int)(n); i--)
#define all(obj) obj.begin(), obj.end()
#define db(x) cerr << #x << ":" << x << " "
#define dbl(x) cerr << #x << ":" << x << "\n"
#define dbv(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define dbvv(vv) cerr << #vv << ":\n"; for (auto vec : vv) { for (auto e : vec) cerr << e << " "; cerr << endl; }
#define YN(f) cout << (f ? "YES" : "NO") << endl
#define Yn(f) cout << (f ? "Yes" : "No") << endl
#define yn(f) cout << (f ? "yes" : "no") << endl
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main() {
	int N; cin >> N;
	cout << N * (N + 1) / 2 << endl;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <sstream>
using namespace std;

int main()
{
	string str;
	
//	ifstream ifs(stdin);
	getline(cin, str);
	
	int len = str.size();
	for (int i = 0; i < len; i++){
		if (str.substr(i, 5) == "apple"){
			str.replace(i, 5, "peach");
		}
		else if (str.substr(i, 5) == "peach"){
			str.replace(i, 5, "apple");
		}
	}
	
	cout << str << endl;
	
	return 0;
}

Measured memory_bytes: 1188