akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <queue>
#include <tuple>
#include <functional>
#include <cstring>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i < n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i < n; i++)

typedef long long ll;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<std::vector<bool> > v2_bool;
typedef std::pair<ll, ll> pll;

using namespace std;

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

    reverse(s.begin(), s.end());
    int n = s.size();
    
    string t = "";
    string v = "dreamer";reverse(v.begin(), v.end());
    string w = "dream";reverse(w.begin(), w.end());
    string x = "eraser";reverse(x.begin(), x.end());
    string y = "erase";reverse(y.begin(), y.end());
    
    int i = 0;
    while(i < n) {
        if(s[i] == 'r') { 
            if(s.substr(i, 7) == v) {
                t += v;
                i += 7;
            } else if(s.substr(i, 6) == x) {
                t += x;
                i += 6;
            } else {
                cout << "NO" << endl;
                return 0;
            }
        } else if (s[i] == 'm') {
            if(s.substr(i, 5) == w) {
                t += w;
                i += 5;
            } else {
                cout << "NO" << endl;
                return 0;
            }
        } else if (s[i] == 'e') {
            if(s.substr(i, 5) == y) {
                t += y;
                i += 5;
            } else {
                cout << "NO" << endl;
                return 0;
            }
        } else {
            cout << "NO" << endl;
            return 0;
        }
    }
    //cout << t << "," << s << endl;
    if(s == t) { 
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 764
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const int MOD = 1e9 + 7;



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

	vector<ll> v(n);

	rep(i,0,n) {
		cin >> v[i];
	}

	//dp[i][j][k]:i問の中からj問解いて合計得点をkにする通り数
	vector< vector< vector<ll> > >dp(n+1,vector< vector<ll> >(n+1,vector<ll>(50*n+1,0)));
	dp[0][0][0] = 1;

	rep(i,0,n) {
		rep(j, 0, i + 1) {
			rep(k, 0, 50 * n + 1) {
				if (k - v[i] >= 0) {
					dp[i + 1][j + 1][k] += dp[i][j][k - v[i]] + dp[i][j + 1][k];
				}
				else {
					dp[i + 1][j][k] += dp[i][j][k];
				}
			}
		}
	}

	ll ans = 0LL;
	rep(i,1,n+1) {
		ans += dp[n][i][i*a];
	}

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

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

int main(){
  int N;
  cin >> N;
  if(N <= 9){
    cout << N << endl;
  }
  else if(9 < N && N < 100){
    cout << 9 << endl;
  }
  else if(99 < N && N < 1000){
    cout << 9 + N - 99 << endl;
  }
  else if(999 < N && N < 10000){
    cout << 909 << endl;
  }
  else if(9999< N && N < 100000){
    cout << 909 + N - 9999 << endl;
  }
  else{
    cout << 90909 << endl;
  }
  
  return 0;
  
}

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

using namespace std;
typedef long long int ll;

int A,B,C,X,Y;

int main() {
  cin>>A>>B>>C>>X>>Y;
  int ans = 0;
  ans+=min(X,Y)*min(A+B,C*2);
  if(X>Y){
    ans+=(X-Y)*min(A,C*2);
  }else{
    ans+=(Y-X)*min(B,C*2);
  }
  cout<<ans<<endl;
  

  return 0;
}


Measured memory_bytes: 256
#%%
n = list(input())
n = n[::-1]
if n.count('1') == len(n):
    n = list('0' * len(n) + '1')
else:
    for i in range(len(n)):
        if n[i] == '0':
            n[i] = '1'
            point = i
            break
    for i in range(point):
        n[i] = '0'

n = n[::-1]
#print(n)

count = 0
ans = 0
mod = 10 ** 9 + 7

for i in range(len(n)):
    a = pow(2, count, mod)
    b = pow(3, len(n)-i-1, mod)
    if n[i] == '0':
        a, b = 0, 0 
    tmp = (a * b) % mod
    #print(a, b, tmp)
    if n[i] == '1':
        count += 1
        count %= mod
        ans += tmp
        ans %= mod

print(ans)

Measured memory_bytes: 4776
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(v) v.begin(),v.end()
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define MOD 998244353 

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

ordered_set<ll> ors;

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

ll power(ll a, ll n, ll m)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=(ans*a)%m;
        n>>=1;
        a=(a*a)%m;
    }
    return ans;
}

ll invmod(ll a, ll m)
{
    return power(a,m-2,m);
}

ll lp[10000001];

void prime()
{
    repf(i,1,10000001) lp[i]=i;
    repf(i,2,10000001)
    {
        if(lp[i]==i)
        {
            for(ll j=2*i;j<10000001;j+=i)
            {
                if(lp[j]==j) lp[j]=i;
            }
        }
    }
}

void solve(ll tt) {
    ll n;
    cin>>n;
    ll ans=0;
    repf(i,2,1000001) {
        ll c=0;
        while(n%i==0) {
            c++;
            n/=i;
        }
        ll id=1;
        while(c>=id) {
            c-=id;
            id++;
            ans++;
        }
    }
    if(n>1) ans++;
    cout<<ans<<endl;
}

int main()
{
    IOS;
    ll t;
    // cin>>t;
    t=1;
    repf(tt,1,t+1) {
        solve(tt);
    }
}     

Measured memory_bytes: 3572
'use strict';

function main(inputs) {
  let numbers = inputs.split('\n').map(num => parseInt(num, 10));
  let count = 0;
  for (let i = 0; i <= numbers[0]; i++) {
    for (let j = 0; j <= numbers[1]; j++) {
      for (let k = 0; k <= numbers[2]; k++) {
        if (i * 500 + j * 100 + k * 50 === numbers[3]) {
          count++;
        }
      }
    }
  }
  console.log(count);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a;
  cin >> a;
  if (a<1200) {
    cout << "ABC" << endl;
  }
  if (a>=1200 && a<2800) {
    cout << "ARC" << endl;
  }
  if (a > 2799) {
    cout << "AGC" << endl;
  }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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 <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}

int main()
{
    int N;
    const int MAX = 1e6 + 1;
    cin >> N;
    vll A(N);
    vector<bool> ok(MAX, true);
    vint cnt(MAX);
    for (size_t i = 0; i < N; i++)
    {
        cin >> A[i];
        cnt[A[i]]++;
        if (cnt[A[i]] >= 2)
        {
            ok[A[i]] = false;
        }
    }
    sort(all(A));
    A.erase(unique(all(A)), A.end());
    for (auto &&i : A)
    {
        for (ll j = 2; j * i < MAX; j++)
        {
            ok[j * i] = false;
        }
    }

    int ans = 0;
    for (auto &&i : A)
    {
        if (ok[i])
            ans++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 8760
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

template <typename T> void output(T, int);
int gcd(int a, int b);

int main() {
    // source
    int a, b, c;
    cin >> a >> b >> c;
    set<int> s;
    s.insert(a);
    s.insert(b);
    s.insert(c);

    cout << s.size() << endl;
    return 0;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}


Measured memory_bytes: 256
from scipy.sparse.csgraph import floyd_warshall


N, M, L = map(int, input().split())
graph = [[0] * N for _ in range(N)]
for _ in range(M):
    s, t, w = map(int, input().split())
    graph[s-1][t-1] = graph[t-1][s-1] = w
dist = floyd_warshall(graph, directed=False)
graph = [[0] * N for _ in range(N)]
for i in range(N):
    for j in range(i+1, N):
        if dist[i][j] <= L:
            graph[i][j] = graph[i][j] = 1
dist = floyd_warshall(graph, directed=False)

Q = int(input())
for _ in range(Q):
    s, t = map(int, input().split())
    ans = dist[s-1][t-1]
    if ans == float("inf"):
        print(-1)
    else:
        print(int(ans - 1))


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

void print(bitset<20> b) {
	for (int i = 0; i < 20; i++) {
		if (b.test(i)) {
			cout << " " << i;
		}
	}
}

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

	bitset<20> b1, b2;
	int n;

	cin >> n;
	int max = 1 << n;
	for (int i = 0; i < max; i++) {
		cout << i << ":";
		b2 = i;
		print(b2);
		cout << endl;
	}
}


Measured memory_bytes: 3156
#include "bits/stdc++.h"
using namespace std;

void push(int A);
int pop(void);

int S[1000];
int Top = 0;

int main(void) {

	char str[100];
	int a, b;
	Top = 0;
	while (scanf("%s", str) != -1) {

		if (str[0] == '+') {
			a = pop();
			b = pop();
			push(a + b);
		}
		else if (str[0] == '-') {
			b = pop();
			a = pop();
			push(a - b);
		}
		else if (str[0] == '*') {
			a = pop();
			b = pop();
			push(a * b);
		}
		else {
			push(atoi(str));
		}
	}
	printf("%d\n", pop());

	return 0;
}

void push(int A) {
	S[++Top] = A;
}

int pop(void) {
	Top--;
	return S[Top+1];
}


Measured memory_bytes: 3220
import java.util.Scanner;

public class Main {
	public static void main(String arg[]) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		int W[] = new int[N];
		int a = 0;
		int b = 0;
		int sumW = 0;
		int min = 1000000;

		for (int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
			sumW += W[i];
		}

		for (int i = 0; i < N - 1; i++) {
			a += W[i];
			b = sumW - a;

			if (min >= Math.abs(a-b)) {
				min = Math.abs(a-b);
			}
		}

		System.out.print(min);
	}
}

Measured memory_bytes: 22612
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

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

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

void main()
{
    long N = lread();
    writeln((1 + N) * N / 2);
}


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

m = 0
ans = 0
for i in range(n):
  if  a[i]<m:
    ans += m - a[i]
    a[i]=m
  else:
    m = a[i]
  #print(m)
  #print(ans)
  #print(" ")
print(ans)

Measured memory_bytes: 105208
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

int main()
{
	map<string, int> m;

	string s, t;
	cin >> s >> t;

	cin >> m[s];
	cin >> m[t];

	string u;
	cin >> u;

	m[u]--;

	cout << m[s] << " " << m[t];

	return 0;
}

Measured memory_bytes: 256
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int n,m,len,x,y,a[4],b[4];
string s,t;
map <char,pii> mp;

bool out(int xx,int yy)
{
	return xx<1||yy<1||xx>n||yy>m;
}

void solve(char fm,char sm,int val)
{
	int xx=x,yy=y;
	rep(i,len)
	{
		if(s[i]==fm)
		{
			xx+=mp[fm].fi;
			yy+=mp[fm].se;
			if(out(xx,yy))
			{
				puts("NO");
				//cout<<fm<<endl;
				exit(0);
			}
		}
		if(t[i]==sm)
		{
			if(!out(xx+mp[sm].fi,yy+mp[sm].se))
			{
				xx+=mp[sm].fi;
				yy+=mp[sm].se;
			}
		}
	}
}

int main()
{
	mp['U']={-1,0};
	mp['D']={1,0};
	mp['L']={0,-1};
	mp['R']={0,1};
	cin>>n>>m>>len>>x>>y>>s>>t;
	solve('U','D',x);
	solve('D','U',n-x+1);
	solve('L','R',y);
	solve('R','L',m-y+1);
	puts("YES");
	rt0;
}

Measured memory_bytes: 776
#include<bits/stdc++.h>
#define boost ios::sync_with_stdio(false); cin.tie(0)
#define ll              long long int
#define ld              long double
#define mk              make_pair
#define pb              push_back
#define f               first
#define s               second
#define fo(i,a,b)       for(i=a;i<b;i++)
#define foe(i,a,b)      for(i=a;i<=b;i++)
#define all(x)          x.begin(),x.end()
// #define vi               vector<int>
#define vl              vector <long long int>
// #define pii          pair <int,int>
#define pll             pair <long long int, long long int>
// #define vpii         vector< pair<int,int> >
#define vpll            vector < pair <long long int,long long int> >
#define MOD             1000000007
using namespace std;
const int inf = INT_MAX;
const ll inf64 = LLONG_MAX;


int main()
{
    boost;
    ll n;
    cin >> n;
    ll ans = (1000 - n % 1000);
    if (ans == 1000)cout << 0;
    else cout << ans;



    return 0;
}

Measured memory_bytes: 3636
import sys
from collections import deque

sys.setrecursionlimit(10**7)

def solve():
    def dfs1(u, path, visited):
        for w in Adj[u]:
            if not visited[w]:
                path.append(w)
                visited[w] = True
                dfs1(w, path, visited)
                return

    def dfs2(u, path, visited):
        for w in Adj[u]:
            if not visited[w]:
                path.appendleft(w)
                visited[w] = True
                dfs2(w, path, visited)
                return

    N, M = map(int, sys.stdin.readline().split())
    Adj = [[] for i in range(N)]

    for i in range(M):
        a, b = map(int, sys.stdin.readline().split())
        a, b = a-1, b-1
        Adj[a].append(b)
        Adj[b].append(a)

    if any(len(v) == 1 for v in Adj):
        for i, v in enumerate(Adj):
            if len(v) == 1:
                s = i
                break

        path = [s]
        visited = [False] * N
        visited[s] = True

        dfs1(s, path, visited)

        path = [i + 1 for i in path]

        print(len(path))
        print(*path)
    else:
        s = 0
        path = deque([0])

        visited = [False] * N
        visited[s] = True

        dfs1(s, path, visited)
        dfs2(s, path, visited)

        path = [i + 1 for i in path]

        print(len(path))
        print(*path)

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

if __name__ == '__main__':
    solve()

Measured memory_bytes: 130240
package main

import (
	"fmt"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	ar := make([]int, n)
	for i := range ar {
		fmt.Scan(&ar[i])
	}
	v := (n - 1) / (k - 1)
	if (n-1)%(k-1) > 0 {
		v++
	}
	fmt.Println(v)
}


Measured memory_bytes: 5504
import sys
from collections import defaultdict

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def prime_numbers(n):
    if n < 2:
        return []

    m = (n + 1) // 2
    p = [1] * m
    for i in range(1, int((n ** 0.5 - 1) / 2) + 1):
        if p[i]:
            p[2 * i * (i + 1) :: 2 * i + 1] = [0] * (((m - 1) - 2 * i * (i + 1)) // (2 * i + 1) + 1)

    a = [2 * i + 1 for i in range(m) if p[i]]
    a[0] = 2
    return a


def prime_factorize(n):
    a = defaultdict(int)
    primes = prime_numbers(int(n ** 0.5) + 1)
    for p in primes:
        while n % p == 0:
            a[p] += 1
            n //= p
        if n == 1:
            break
    if n != 1:
        a[n] += 1
    return a


def main():
    N = int(readline())
    a = prime_factorize(N)

    ans = 0
    for power in a.values():
        ans += int(((1 + 8 * power) ** 0.5 - 1) / 2)

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 77096
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <climits>
using namespace std;

int main(void) {
    double _max, _min;
    double input;
    cin >> input;
    _max = input, _min = input;
    while(cin >> input) {
        _max = max(_max, input); _min = min(_min, input);
    }
    cout << _max - _min << endl;
    return(0);
}

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

typedef long long ll;

const int MOD = 1e9 + 7;
const int INF = 0x3F3F3F3F;
const ll INFLL = 0x3F3F3F3F3F3F3F3FLL;

int n, k;
int h[112345];
int ans[112345];

int main(){
	
	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	
	cin >> n >> k;
	
	for(int i = 1 ; i <= n ; i ++)
		cin >> h[i];
	
	memset(ans, INF, sizeof ans);
	ans[1] = 0;
	
	for(int i = 2 ; i <= n ; i ++)
		for(int j = max(1, i - k) ; j <= i - 1 ; j ++)
			ans[i] = min(ans[i], ans[j] + abs(h[i] - h[j]));
	
	cout << ans[n] << "\n";
	
	return 0;
}

Measured memory_bytes: 4484
from operator import mul
from functools import reduce
mod = 10 ** 9 + 7
def comb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

s = int(input())
ans = 0
for i in range(s // 3):
  d = s - (i + 1) * 3 # 球
  ans = (ans + comb(d + i, i)) % mod
print(ans)

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

int main() {

  int N;
  bool b;
  int temp;
  std::cin >> N;

  for(int i = 1; i <= N; ++i) {
    if( i % 3 == 0 ) {
      std::cout << " " << i;
    }
    else {
      temp = i;
      b = false;
      while( temp != 0 ) {
	if( temp % 10 == 3 ) {
	  b = true;
	  break;
	}
	temp /= 10;
      }
      if( b ) {
	std::cout << " " << i;
      }
    }

      
  }
  std::cout << std::endl;
  
  return 0;
}

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

long long dp[102][100002];

int main() {
    cin.sync_with_stdio(false);
    cin.tie();

    int N, W;
    vector<int> weights;
    vector<long long> values;

    cin >> N >> W;
    weights.reserve(N);
    values.reserve(N);
    for (int i = 0; i < N; ++i) {
        int w;
        long long v;
        cin >> w >> v;
        weights.emplace_back(w);
        values.emplace_back(v);
    }

    // for (int i = 0; i < N; ++i) {
    //     cout << weights[i] << " -> " << values[i] << endl;
    // }
    // return 1;

    for (int i = 0; i < N; ++i)
        dp[i][0] = 0;
    for (int i = 1; i < W; ++i)
        dp[0][i] = 0;

    for (int i = 1; i <= N; ++i) {
        for (int j = 1; j <= W; ++j) {
            if (weights[i - 1] <= j) {
                dp[i][j] = max(dp[i - 1][j], values[i - 1] + dp[i - 1][j - weights[i - 1]]);
            } else {
                dp[i][j] = dp[i - 1][j];
            }
        }
    }
    cout << dp[N][W] << endl;

    return 0;
}


Measured memory_bytes: 79232
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.T = function(T) local t={} for i=1,T do t[i]=read.n() end return t end
string.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
----
local function create_ndim_array(n, last_metatbl)
    local metatables = {}
    metatables[1] = last_metatbl
    for i=2,n do
        metatables[i] = {__index = function(parent, k)
            local child = setmetatable({}, metatables[i-1])
            rawset(parent, k, child)
            return child
        end}
    end
    return setmetatable({}, metatables[n])
end
-- E
local S = read.l():totable()
local T = {}
for i=1,#S do
    T[i] = tonumber(S[i])
end
local D = #T
local K = read.n()

local tbl = create_ndim_array(3, {__index = function() return 0 end})
tbl[0][true][0] = 1
for i=0, D-1 do
    for m, _ in pairs(tbl[i]) do
        for k, v in pairs(tbl[i][m]) do
            if v == 0 then
                goto continue_k
            end
            local ni = i+1
            local nd = T[ni]
            for d=0,9 do
                local nm
                if m == false then
                    nm = false
                else
                    if d > nd then
                        break
                    elseif d == nd then
                        nm = true
                    else
                        nm = false
                    end
                end
                local nk
                if d == 0 then
                    nk = k
                else
                    nk = k + 1
                end
                if nk > K then
                    goto continue_d
                end
                tbl[ni][nm][nk] = tbl[ni][nm][nk] + v
                ::continue_d::
            end
            ::continue_k::
        end
    end
end
local ans = tbl[D][false][K] + tbl[D][true][K]
print(ans)

Measured memory_bytes: 760
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

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

ll gcd(ll a,ll b){
   if(a%b==0){
       return(b);
   }
   else{
       return(gcd(b,a%b));
   }
}

ll lcm(ll a,ll b){
   return a/gcd(a,b)*b;
}

int main()
{
  ll N,M; cin>>N>>M;
  vector<ll> b(N); rep(i,N) {cin>>b[i]; b[i]/=2;}
  
  if(N==1){
    ll ans=M/b[0];
    ans=(ans+1)/2;
    cout<<ans<<endl;
    return 0;
  }
  
  //N>=2;
  vector<ll> cou(N);
  rep(i,N){
    ll sb=b[i];
    ll count=0;
    while(sb%2==0){
      sb/=2,count++;
    }
    cou[i]=count;
  }
  int judge=0;
  rep(i,N-1) if(cou[i]!=cou[i+1]) judge=1;
  
  if(judge){cout<<0<<endl; return 0;}
  
  ll B=1;
  rep(i,N) B=lcm(B,b[i]);
  ll ans=M/B;
  ans=(ans+1)/2;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 4820
def main():
  divisor = 10 ** 9 + 7
  h, w = map(int, input().split())
  a = [input() for _ in range(h)]
  dp = [[0] * w for _ in range(h)]
  dp[0][0] = 1
  dp0 = dp[0]
  a0 = a[0]
  for j in range(1, w):
    if a0[j] != '#':
      dp0[j] = dp0[j - 1]
  for i in range(1, h):
    dpi = dp[i]
    dpi1 = dp[i - 1]
    ai = a[i]
    if ai[0] != '#':
      dpi[0] = dpi1[0]
    for j in range(1, w):
      if ai[j] != '#':
        dpi[j] = (dpi1[j] + dpi[j - 1]) % divisor
  print(dp[h - 1][w - 1])
main()


Measured memory_bytes: 43632
#!/usr/bin/env python
import math


def main():
    a, b, k = [int(a) for a in input().split()]

    aaa = []

    for i in range(a, min(a + k, b)):
        if i not in aaa:
            aaa.append(i)
    for i in range(max(b - k + 1, a), b + 1):
        if i not in aaa:
            aaa.append(i)

    for a in aaa:
        print(a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <cstring>
#include <string>
#include <cctype>
#include <cassert>
#include <stack>

using namespace std;

#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,b,e) for(int i = (b); i <= (e); i++)
#define INF (1001001001)
#define EPS (1e-15)

#define pr(x) do{cout << (#x) << " = " << (x) << endl;}while(0)
#define pri(x,i) do{cout << (#x) << "[" << i << "] = " << (x[i]) << endl;}while(0)
#define pra(x,n) rep(__i,n) pri(x,__i);
#define prar(x,b,e) repr(__i,b,e) pri(x,__i);

typedef long long llint;
typedef pair<int, int> pint;
typedef vector<int> vint;

int in() {
	int a;
	scanf("%d ", &a);
	return a;
}

vint v;
int H, W;
int K;

int magic(int i, int k) {
	int ydist = min(i - 1, H - i);
	int xdist = min(k - 1, W - k);
	int dist = min(ydist, xdist);
	return (dist + K - 1) / K;
}

int main() {
	 H = in();
	 W = in();
	 K = in();
	vector<vint> v(810, vint(810, 0));
	for (int i = 0; i < H + 2; i++) v[i][0] = v[i][W + 1] = -1;
	for (int i = 0; i < W + 2; i++) v[0][i] = v[H + 1][i] = -1;
	int y = -1, x = -1;
	for (int i = 1; i <= H; i++) {
		// char temp[810];
		// gets(temp);
		string temp;
		cin >> temp;
		for (int k = 1; k <= W; k++) {
			char c = temp[k - 1];
			if (c == 'S') {
				y = i;
				x = k;
			}
			else if (c == '#') {
				// solid
				v[i][k] = 99;
			}
		}
	}
	assert(y >= 0 && x >= 0);
	int ans = magic(y, x);
	stack<pint> st;
	st.push(mp(y,x));
	for (int i = 0; i < K + 1; i++) {
		stack<pint> st2;
		while (! st.empty()) {
			pint p = st.top();
			st.pop();
			v[p.first][p.second] = 1;
			ans = min(ans, magic(p.first, p.second));
			for (int dy = -1; dy <= 1; dy++) {
				for (int dx = -1; dx <= 1; dx++) {
					if (dy * dx == 0 && v[p.first + dy][p.second + dx] == 0) {
						v[p.first + dy][p.second + dx] = 1;
						st2.push(mp(p.first + dy, p.second + dx));
					}
				}
			}
		}
		st = st2;
	}
	cout << ans + 1 << endl;
	return 0;
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<ll> vll;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz(a) ((int)(a).size())
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define trav(it, a) for(auto& it : a)
#define allin(it, a) for(auto it : a)
#define read(v, a, b) for(int i=(a); i<(b); i++) scanf("%d", &v[i]);
#define clr(a,v) memset(a, v, sizeof(a))
#define all(a) (a).begin(),(a).end()
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define db(x) cerr << #x << " == " << x << endl

const int maxn = 110, maxw = 1e5 + 100;

int n, W, w[maxn], v[maxn];
ll dp[maxn][maxw]; //max value we can take with items up to index i and total weight w

ll solve(int i, int used){ //index of the item - weight used
	if(i == n) return 0;
	if(dp[i][used] != -1) return dp[i][used];
	
	ll add = used + w[i] <= W? solve(i+1, used + w[i]) + v[i] : 0;
	ll not_add = solve(i+1, used);
	
	return dp[i][used] = max(add, not_add);	
}

int main(){
	scanf("%d %d", &n, &W);
	rep(i,0,n)
		scanf("%d %d", &w[i], &v[i]);
	clr(dp, -1);
	printf("%lld\n", solve(0,0));
}


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

int N;
double x;
vector<double> a;

signed main()
{
    cin >> N >> x;
    for(int i = 0; i < N; i++){
        double dx, dy;
        cin >> dx >> dy;
        a.push_back(dy / dx);
    }
    sort(a.begin(), a.end(), greater<double>() );
    printf("%.8lf\n", x * a[0]);

    return 0;
}



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

void solve(int n)
{
    vector<int> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }

    int sum = accumulate(v.begin(), v.end(), 0);
    double ave = double(sum) / n;
    sort(v.begin(), v.end());
    int count = upper_bound(v.begin(), v.end(), ave) - v.begin();
    cout << count << '\n';
}

int main()
{
    int n;
    cin >> n;
    while (n) {
        solve(n);
        cin >> n;
    }
}



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

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

	int arr[n];
	for(int i=0;i<n;i++){
		scanf("%d",&arr[i]);
	}

	int ans = 0;
	int f=0;
	
	for(int i=0;i<n;i++){
		for(int j=2;j<sqrt(arr[i])+1;j++){
			if(arr[i]%j==0 && arr[i] != 2){
				f = -1;
				break;
			}
		}
		if(f == 0){
			ans++;
		}
		f = 0;
	}

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

	return 0;
}



Measured memory_bytes: 2052
#include "bits/stdc++.h"
using namespace std;

int main(){
    long long k , a , b;
    scanf( "%lld%lld%lld" , &k , &a , &b );

    if( b <= a || k <= a ){
        printf( "%lld\n" , k + 1 );
        return 0;
    }
    else if( k == a + 1 ){
        printf( "%lld\n" , max( a + 2 , b ) );
        return 0;
    }

    if( b == a + 1 ){
        printf( "%lld\n" , k + 1 );
        return 0;
    }

    long long Ans = 0;
    long long Temp = k - a , extra;

    if( Temp % 2 == 0 ){
        extra = Temp / 2;
        Ans = extra * b - ( extra - 1 ) * a + 1;
    }
    else{
        extra = ( Temp + 1 ) / 2;
        Ans = extra * b - ( extra - 1 ) * a; 
    }

    printf( "%lld\n" , Ans );
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# vim:fenc=utf-8 ff=unix


def solv(N, A):
    A = [a for a in A if a % 2 == 0]
    for a in A:
        if (a % 3 != 0) and (a % 5 != 0):
            return "DENIED"
    return "APPROVED"


if __name__ == "__main__":

    # N
    # A_1 A_2 \dots A_N
    #
    N = int(input())
    A = map(int, input().split())
    ans = solv(N, A)

    print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    
    int h,m,h2, m2, k;
    cin>>h>>m>>h2>>m2>>k;
    
    int x2 = h2*60+m2;
    int x1= h*60+m;
    
    int divv = x2 -x1;
    int cnt=0;
    
    while(cnt+k<divv){
        cnt++;
    }
    
    
    cout<<cnt<<endl;
    
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define REP(i,b,a) for(int i=b;i<a;i++)
#define rep(i,a) REP(i,0,a) 
int Search(vector<int>,int,int);
int cnt;
int main(void){
	int i,num_first,num_second;
	vector<int> arr_first;
	//int *arr_second;
	//vector(int) arr_second;
	//cin >> 	num_first;
	//arr_first = malloc(sizeof(int) * num);
	//rep(i,num_first){
	//	cin >> arr[i];
	//}
	cin >> num_first;	
	rep(i,num_first){
		int temp;
		cin >> temp;
		arr_first.push_back(temp);
}	
	cin >> num_second;	
	rep(i,num_second){

		int temp_second;
		cin >> temp_second;
		Search(arr_first,num_first,temp_second);
	}
	cout << cnt << endl;
}
int Search(vector<int> arr,int num,int value){

	int left,right;
	right = num;
	left = 0;
	while(left < right){
		int mid;
		mid = (right + left) / 2;
	//	cout << mid << endl;
		if(arr[mid] == value){ cnt++; return 1;}
		else if(arr.at(mid) > value ){
			right = mid; 
			//cout << right << endl;
		}
		else{
			left = mid+1;
			//cout << left << endl;
		}
	}
}

Measured memory_bytes: 1932
fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

fn main() {
    proconio::input! {
        k: u64
    }
    let a = &k;
    let b = &k;
    let c = &k;
    let mut sum = 0;
    for i in 1..a+1{
        for l in 1..b+1{
            for j in 1..c+1{
                let x = gcd(i, l);
                let y = gcd(x, j);
                sum += y;
            }
        }    
    }
    
    println!("{}", sum);
    
}

Measured memory_bytes: 2120
//*********************************
//******problem C DP contest***

#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair

#define REP(i,n) for(i=0;i<(n);++i)
#define FOR(i,l,h) for(i=(l);i<=(h);++i)
#define FORD(i,h,l) for(i=(h);i>=(l);--i)

#define max(a,b) a>b?a:b
#define min(a,b) a>b?b:a
using namespace std;
int a[100007];
int b[100007];
int c[100007];
int n;
int memo[100007][3];
int mincost(int i , int previous){
    if(i==n) return 0;

    int &ret = memo[i][previous];
    if(ret != -1){
        return memo[i][previous];
    }
    int sum = INT_MIN;
    if(previous !=0)
          sum = max(sum,a[i]+mincost(i+1,0));
    if(previous !=1)
         sum = max(sum,b[i]+mincost(i+1,1));
    if(previous !=2)
          sum = max(sum,c[i]+mincost(i+1,2));

    memo[i][previous] = sum;
    return memo[i][previous];

}
int main(){
    ios_base::sync_with_stdio(false);
  	cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i]>>c[i];
    }
    memset(memo,-1,sizeof(memo));
    cout<<mincost(0,3);
    return 0;
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
#define v(T) vector<T>
#define yn {puts("Yes");}else{puts("No");}
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const double eps = 1e-10;

void solve() {
  int n, x, t;
  cin >> n >> x >> t;

  int ans = 0;
  for (; n > 0; n -= x) {
    ans += t;
  }

  cout << ans << endl;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout << fixed << setprecision(15);
  solve();
  return 0;
}


Measured memory_bytes: 3564
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;

void mainmain(){
	int n;
	while(cin>>n,n){
		int ans=0;
		int pos=1;
		int r=0;
		int l=0;
		rep(i,n){
			string s;
			cin>>s;
			if(s=="ru"){
				r=1;
			}
			else if(s=="rd"){
				r=0;
			}
			else if(s=="lu"){
				l=1;
			}
			else if(s=="ld"){
				l=0;
			}
			if(pos&&r&&l){
				pos=0;
				ans++;
			}
			else if(!pos&&!r&&!l){
				pos=1;
				ans++;
			}
		}
		cout<<ans<<endl;
	}
}



}
main() try{
    mainmain();
}
catch(...){
}

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

int main(int argc, const char * argv[]) {
    int a, b, c, i, n;
    n=0;
    
    cin >> a >> b >> c;
    
    for(i=a;i<=b;i++){
        if(c%i==0){
            n++;
        }
    }
    
    cout << n << endl;
    
    return 0;
}



Measured memory_bytes: 3136
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	fmt.Println(solve(n))
}

func solve(n int) string {
	if n == 0 {
		return ""
	}
	return solve((n-1)/26) + string([]byte{byte((n-1)%26) + 'a'})
}


Measured memory_bytes: 1772
#include <bits/stdc++.h>   
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
     
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
using Graph = vector<vector<int>>;
Graph G;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    vector<ll> b;

    bool flag = false;
    ll i = 0;
    while(i < n - 1){
        ll MAX = 0, MIN = 201;
        int now = i;
        if(!flag and a[i] <= a[i + 1]){
            while(i < n - 1 and a[i] <= a[i + 1]){
                i++;
                MAX = a[i];
            }
        }else if(flag and a[i] >= a[i + 1]){
            while(i < n - 1 and a[i] >= a[i + 1]){
                i++;
                MIN = a[i];
            }
        }
        if(!flag and MAX != 0){
            if(b.size() == 0) b.push_back(a[now]);
            b.push_back(MAX);
            flag = true;
        }else if(flag and MIN != 201){
            b.push_back(MIN);
            flag = false;
        }else{
            i++;
        }
    }
    ll ans = 1000;
    ll kabu = 0;
    rep(i, b.size()){
        if(i == b.size() - 1 and b.size() % 2 != 0) break;
        if(i % 2 == 0){
            kabu = ans / b[i];
            ans -= b[i] * kabu;
        }else{
            ans += b[i] * kabu;
            kabu = 0;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second

int n;
pp d[5010];
bool e[5010][5010];
ll dp[5010][5010];

int main()
{
	read(n);
	for(int i=1; i<=n; ++i){
		int x, y; read(x, y);
		d[i]={x, y};
	}
	sort(d+1, d+n+1, [](const pp& a, const pp& b){ return a.x+a.y<b.x+b.y; });
	e[0][0] = 1;
	const ll inf = 1ll<<60;
	for(int i=1; i<=n; ++i){
		e[i][0] = 1;
		for(int j=1; j<=i; ++j){
			ll ans = inf;
			if(e[i-1][j-1] && dp[i-1][j-1] <= d[i].x){
				ans = dp[i-1][j-1] + d[i].y;
			}
			if(e[i-1][j]){
				ans = min(ans, dp[i-1][j]);
			}
			if(ans != inf){
				e[i][j] = 1;
				dp[i][j] = ans;
			}
		}
	}
	for(int i=n; 0<=i; --i) if(e[n][i]){
		printf("%d\n", i);
		break;
	}
	return 0;
}


Measured memory_bytes: 219136
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/* 
 * File:   main.cpp
 * Author: Allen
 *
 * Created on January 12, 2019, 5:00 PM
 */

#include <cstdlib>
#include <iostream>
#include <stdio.h>
using namespace std;

/*
 * 
 */
int main(int argc, char** argv) {
    int n;
    cin>>n;
    int rock[n];
    for(int i=0;i<n;i++){
        cin>>rock[i];
    }
    int dp[n];
    dp[n-1]=0;
    dp[n-2]=abs(rock[n-2]-rock[n-1]);
    for(int i=n-3;i>=0;i--){
        dp[i]=min(dp[i+1]+abs(rock[i]-rock[i+1]),dp[i+2]+abs(rock[i]-rock[i+2]));
    }
    printf("%d",dp[0]);
    return 0;
}




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


int main () {

    string s;
    cin >> s;

    int f=0;
    for(auto c : s) {
	if( f == 0 and c == 'C' ) f++;
	if( f == 1 and c == 'F' ) f++;
    }
    if( f == 2 )
	cout << "Yes" << endl;
    else
	cout << "No" << endl;
       
    return 0;
}


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

struct Node {
  int key;
  Node *parent, *left, *right;
};

Node *root, *NIL;

void insert(int k) {
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while ( x != NIL ) {
    y = x;
    if ( z->key < x->key ) {
      x = x->left;
    } else {
      x = x->right;
    }
  }

  z->parent = y;
  if ( y == NIL ) {
    root = z;
  } else {
    if ( z->key < y->key ) {
      y->left = z;
    } else {
      y->right = z;
    }
  }
}

Node* find(Node *u, int k) {
  while ( u != NIL && u->key != k) {
    if ( k < u->key ) {
      u = u->left;
    } else if ( k > u->key ) {
      u = u->right;
    }
  }
  return u;
}

Node* treeMinimum(Node *x) {
  while ( x->left != NIL ) x = x->left;
  return x;
}

Node* treeSuccessor(Node *x) {
  if ( x->right != NIL ) return treeMinimum(x->right);
  Node *y = x->parent;
  while ( y != NIL && x == y->right ) {
    x = y;
    y = y->parent;
  }
  return y;
}

void deleteNode(Node *z) {
  Node *y;
  Node *x;

  if ( z->left == NIL || z->right == NIL ) y = z;
  else y = treeSuccessor(z);

  if ( y->left != NIL ) {
    x = y->left;
  } else {
    x = y->right;
  }

  if ( x != NIL ) {
    x->parent = y->parent;
  }

  if ( y->parent == NIL ) {
    root = x;
  } else {
    if ( y == y->parent->left ) {
      y->parent->left = x;
    } else {
      y->parent->right = x;
    }
  }

  if ( y != z ) {
    z->key = y->key;
  }

  free(y);
}

void inorder(Node *u) {
  if ( u == NIL ) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}

void preorder(Node *u) {
  if ( u == NIL ) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}

int main() {
  int n;
  int key;
  string com;

  cin >> n;
  for ( int i = 0; i < n; i++ ) {
    cin >> com;
    if ( com == "insert" ) {
      scanf("%d", &key);
      insert(key);
    } else if ( com == "find" ) {
      scanf("%d", &key);
      Node *t = find(root, key);
      if ( t != NIL ) {
        printf("yes\n");
      } else {
        printf("no\n");
      }
    } else if ( com == "delete" ) {
      scanf("%d", &key);
      deleteNode(find(root, key));
    } else if ( com == "print" ) {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}

Measured memory_bytes: 22012
#include<iostream>
#include<vector>
#include<string>
#include<iomanip>
using namespace std;
int main() {
	double r;
	cin >> r;
	cout <<fixed<<setprecision(6)<< r * r * 3.14159265359 << " " << (r + r) * 3.14159265359;
	return 0;
}


Measured memory_bytes: 3292
// The very basic /////////////////////////////////////////////////////////////
#include <bits/stdc++.h>
using namespace std;
#define ALL_H 1

// Debug it by D(x) ///////////////////////////////////////////////////////////
#define DEBUG 0
#if DEBUG
#define D(x) x
#else
#define D(x)
#endif

// Print elements of containers using << operator /////////////////////////////
// pair
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {
  return s << "(" << p.first << ", " << p.second << ")";}
// vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  for (auto &elem : v) {
    s << elem;
    if (&elem != &v.back()) s << " ";
  }
  return s;
}
// 2 dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  for (auto &elem : vv) {
    s << elem;
    if (&elem != &vv.back()) s << endl;
  }
  return s;
}
// map
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
  s << "{" << endl;
  for (auto &elem: m) {
    s << " " << elem.first << " : " << elem.second << endl;
  }
  s << "}";
  return s;
}
//set
template<typename T> ostream& operator<<(ostream& s, const set<T>& m) {
  s << "{ ";
  for (auto &elem: m) {
    s << elem << " ";
  }
  s << "}";
  return s;
}

// Convenient macros //////////////////////////////////////////////////////////

// types
#define ll long long
#define ull unsigned long long
#define ld long double
#define int ll
#define Pi pair<int, int>
#define Graph vector<vector<int>>
#define WeightGraph vector<vector<Pi>>

// other
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

// update max or min //////////////////////////////////////////////////////////

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; }

// gcd
int gcd(int a,int b){return b?gcd(b,a%b):a;}

// for grids
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

///////////////////////////////////////////////////////////////////////////////
//                             Start Coding Here                             //
///////////////////////////////////////////////////////////////////////////////

signed main() {
  vector<int> L(90);
  L[0] = 2LL; L[1] = 1LL;
  int N; cin >> N;
  rep(i, N+1) {
    if (i == 0 || i == 1) continue;
    L[i] += (L[i-1] + L[i-2]);
  }
  D(cout << L << endl);
  cout << L[N] << endl;
  return 0;
}


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

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

    int N, M;

    cin >> N >> M;

    int left = 0, right = N;

    for(int i = 0; i < M; i++)
    {
        int l, r;

        cin >> l >> r;

        if(l > left)
        {
            left = l;
        }
        if(r < right)
        {
            right = r;
        }
    }

    int ans = right - left + 1;

    if(ans <= 0)
    {
        cout << 0 << endl;
    } else {
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int[] a = new int[N];
            for (int i = 0; i < N; i++) {
                a[i] = in.nextInt();
            }

            int min = (int) 1e9;
            int max = (int) -1e9;
            for (int i = 0; i < N; i++) {
                min = Math.min(min, a[i]);
                max = Math.max(max, a[i]);
            }

            System.out.println(max - min);
        }
    }
}


Measured memory_bytes: 23124