akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int N, count = 0, a = 1;
    cin >> N;
        
        for (int i = a + 10; count < N; i += 10) {
            bool T = false;
            for (int j = 2; j * j <= i; j++) {
                if (i % j == 0) {
                    T = true;
                    break;
                }
            }
            if (T) {
                continue;
            }
            count++;
            cout << i << " ";
            a = i;
        }
    cout << endl;
}


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

int main(){
	int x,y,z;
	cin>>x>>y>>z;
	int xx=x;
	int res=0;
	while(true){
		x-=y+z;
		if(x>0){
			res++;
		}
		else break;
	}
	
	if(((y * res) + (z * res))+z <= xx){
		cout<<res;
	}
	else{
		cout<<res-1;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FFOR(i,a,b) for(int i=(a);i<=(b);i++)
#define REP(i,b) FOR(i,0,b)
#define RREP(i,b) FFOR(i,1,b)
#define PB push_back
#define F first
#define S second
#define BE(c) c.begin(),c.end()
using namespace std;
typedef long long LL;
typedef LL ut;
typedef long double ld;
typedef pair<ut,ut> pr;
typedef vector<pr> Vpr;
typedef vector<ut> VI;
typedef pair<pr, ut> ppr;
typedef priority_queue<pr,Vpr, greater<pr> > PQ;
const int SIZE=1e+5 + 10;
const ut INF=1<<30;
const ld eps=1e-6;
const LL mod=7+1e+9;

const int MAX_N = 100000;

int par[MAX_N + 1], r[MAX_N + 1];

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

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

void unite(int x, int y){
	x = find(x);
	y = find(y);
	if(x == y)
		return;
		
	if(r[x] < r[y]){
		par[x] = y;
	}
	else{
		par[y] = x;
		if(r[x] == r[y])
			r[x]++;
	}
}

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

vector<int> vec[SIZE], node[SIZE];
bool had[SIZE];
bool check[SIZE];

int N, M;
int main() {
	cin >> N >> M;
	int k, l;
	init(MAX_N);
	REP(i,N){
		scanf("%d", &k);
		REP(j,k){
			scanf("%d", &l);
			node[l].PB(i);
		}
	}
	FFOR(i,1,M){
		if(node[i].size() >= 2){
			FOR(j,1,node[i].size())
				unite(node[i][0], node[i][j]);
		}
	}
	bool ok = true;
	FOR(i,1,N){
		if(!same(0, i))
			ok = false;
	}
	if(ok)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 7680
#include <bits/stdc++.h>
using namespace std;
#define fast_io cin.tie(0);ios_base::sync_with_stdio(0);
string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
void debug_out() { cout << endl; }
void show() { cout << endl; }
void pret() { cout << endl; exit(0);}
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cout << " " << to_string(H); debug_out(T...);}
template <typename Head, typename... Tail> void show(Head H, Tail... T) {cout <<H<<" "; show(T...);}
template <typename Head, typename... Tail> void pret(Head H, Tail... T) {cout <<H<<" "; pret(T...);}
#define pr(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
typedef long long ll;
#define int ll
typedef long double ld;
typedef vector<int> vi;
#define disp(x) cout<<x<<" ";
#define rep(i,a,b) for(int i=a;i<(int)b;i++)
#define fo(i,a,b) for(int i=a;i<=(int)b;i++)
#define rf(i,a,b) for(int i=a;i>=(int)b;i--)
#define mp make_pair
#define pb emplace_back
#define F first
#define S second
#define endl '\n'
//cout.setf(ios::fixed);cout.precision(18)
const int MOD = 1e9+7;
const int maxn = 300000+10;

int32_t main(){
    fast_io;
    string s;
    cin >> s;
    int n = s.size();
    if(s[n - 1] == 's'){
        s += "es";
    }
    else s += "s";
    show(s);
    return 0;
}

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

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	ll n;
	cin>>n;
	int ans = 0;
	for(ll m = 2; m*m <= n; m++){
		if(n%m)continue;
		int cnt = 0;
		while(n%m == 0){
			n /= m;
			cnt++;
		}
		int mx = 1;
		for(int i = 1; i <= 50; i++){
			if(i*(i + 1)/2 <= cnt)mx = i;
		}
		// cout<<m<<" "<<mx<<endl;
		ans += mx;
	}
	if(n > 1)ans++;
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 3664
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cassert>
#include<vector>
#include<fstream>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include<cmath>
#include<typeinfo>

using namespace std;
#define rep(i,m,n) for(int i=m;i<n;++i)
#define repll(i,m,n) for(ll i=m;i<n;++i)
#define llinf 10000000000000000
#define inf 1000000000
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define all(v) v.begin(),v.end()


int main() {
	ll n;
	cin >> n;
	ll hoge = llinf;
	rep(i, 0, 5) {
		ll tmp;
		cin >> tmp;
		hoge = min(hoge, tmp);
	}
	ll ans = 5;
	ans += (n - 1) / hoge;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
require 'set'; require 'prime'
INF=Float::INFINITY; MOD=10**9+7
@n = gets.chomp.to_i

@alpha = "abcdefghij"
@ans = []
def solve(num, current)
  # p current
  if num == @n
    @ans.push current
    return
  end
  num += 1
  candi = current.split(//).uniq.size + 1
  candi.times do |i|
    solve(num, current + @alpha[i])
  end
end

solve(1, 'a')

@ans.each do |line|
  puts line
end

Measured memory_bytes: 13308
s=str(input())
li=[0]
for i in range(0,len(s)):
    if s[i]=="R":
        val=0
        for ii in range(i,len(s)):
            if s[ii]=="S":
                li.append(val)
                val=0
                break
            else:val+=1
        li.append(val)
print(max(li))

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

typedef long long ll;

int main(){
    int n;
    string s;
    cin >> n;
    cin >> s;
    long a=0, b=0, c=0;
    long ans;
    for(int i = 0; i < n; ++i){
        if(s[i]=='G'){
            ++a;
        }else if(s[i]=='R'){
            ++b;
        }else{
            ++c;
        }
    }
    ans = a*b*c;
    for(int i=0; i < n-1; i++){
        for(int j = i+1; j < n; j++){
            if(s[i]==s[j]){
                continue;
            }
            int k=2*j-i;
            if(k>=n || s[j]==s[k] || s[k]==s[i]){
                continue;
            }
            --ans;
        }
    }
    cout << ans << "\n";
    return 0;
}

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

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

    int S = 0;
    int tmp = N;
    while(tmp>0){
        S += tmp%10;
        tmp /= 10;
    }
    cout<<((N%S==0)?"Yes":"No")<<endl;

    return 0;
}

Measured memory_bytes: 256
_n, m = gets.split.map(&:to_i)
min, max = gets.split.map(&:to_i)
(m-1).times do
  l, r = gets.split.map(&:to_i)
  min = l if min < l
  max = r if max > r
end

ans = max - min + 1
if ans > 0
  puts ans
else
  puts 0
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
//数列v内に数nが存在するかどうか調べる
bool srt_knsk(vector<int> v,int n){
  for(int i=0; i<v.size(); i++){
    if(v.at(i) == n){
      return true;
    }
  }
  return false;
}
int main(){
  int s;
  int t;
  vector<int> v;
  cin >> s;
  v.push_back(s);
  while(true){
    if(s%2 == 0){
      t = s/2;
    }else{
      t = 3*s+1;
    }
    if(srt_knsk(v,t)==true){
      cout << v.size()+1 << endl;
      return 0;
    }
    v.push_back(t);
    //cout << s << endl;
    s = t;
  }
}

Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include<climits>
#include<cmath>
#include<cstdio>
#include<deque>
#include<map>
#include<set>
#include<vector>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<numeric>
#include<string>
#include<tuple>
using namespace std;
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define pt pop_front
#define pk pop_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}

inline void solve(void){
  long N,M;
  in(N,M);
  vector<bool>C(N+1);
  vector<int>B(N+1,1);
  C[1]=true;
  int x,y;
  rep(i,M){
    in(x,y);
    if(C[x])C[y]=true;
    B[x]--;
    B[y]++;
    if(B[x]==0)C[x]=false;
  }
  long ans=0;
  up(i,1,N)if(C[i]&&B[i]>0)ans++;
  out(ans);
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		System.out.println(lucas(n));
	}
	
	static long lucas(int n)
	{
		long a = 2, b = 1, c;

		if (n == 0)
			return a;

		for (int i = 2; i <= n; i++) {
			c = a + b;
			a = b;
			b = c;
		}
		return b;
	}
}


Measured memory_bytes: 21972
N=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
d=sum(b)
m=[]
for i in range(N-1):
  if a[i+1]-a[i]==1:
    m.append(c[a[i]-1])
e=sum(m)
print(d+e)

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

int main(int argc, char **argv) {
	string s;
	cin >> s;
	int res = 0;
	REP(i, s.length()) res += s[i] - '0';
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int N = 4000 + 10;
const int MOD = 1000000007;

int C[N][N];

int cal(int a, int b)
{
	if (a < b || a < 0 || b < 0) return 0;
	return C[a][b];
}

int main()
{
	int n, k, a, b, i, j;
	C[0][0] = 1;
	for (i=1; i<=4000; i++)
	{
		C[i][0] = C[i][i] = 1;
		for (j=1; j<i; j++) C[i][j] = (C[i-1][j-1] + C[i-1][j]) % MOD;
	}
	cin>>n>>k;
	if (n == k)
	{
		cout<<1<<endl;
		for (i=2; i<=k; i++) cout<<0<<endl;
		return 0;
	}
	for (i=1; i<=k; i++)
	{
		a = cal(k-1, i-1);
		b = (cal(n-k-1, i-1) * 2 % MOD + (cal(n-k-1, i-2) + cal(n-k-1, i)) % MOD) % MOD;
		cout<<1LL * a * b % MOD<<endl;
	}
	return 0;
}

Measured memory_bytes: 61440
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    string S;
    cin >> S;
    auto N = (int) S.size();

    vector<vector<int>> dp(N+1, vector<int>(13, 0));
    dp[0][0] = 1;

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 13; j++) {
            if (S[i] != '?') {
                int num = (S[i] - '0') + j * 10;
                int rest = num % 13;
                (dp[i + 1][rest] += dp[i][j]) %= MOD;
            } else {
                for (int k = 0; k < 10; k++) {
                    int num = k + j * 10;
                    int rest = num % 13;
                    (dp[i+1][rest] += dp[i][j]) %= MOD;
                }
            }
        }
    }

    cout << dp[N][5] << endl;

    return 0;
}

Measured memory_bytes: 13696
class Plate:
    def __init__(self, h, w):
        self.h = h
        self.w = w

    def contains(self, plate):
        return self.h >= plate.h and self.w >= plate.w

N, H, W = list(map(int, input().split()))
need_plate = Plate(H, W)
plates = []


ret = 0
for i in range(N):
    if Plate(*list(map(int, input().split()))).contains(need_plate):
        ret += 1


print(ret)


Measured memory_bytes: 3060
#include "bits/stdc++.h"
#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;

template<class X> X gcd(X a, X b) {return b ? gcd(b,a%b):a;}

int main() {
    string s;
    cin >> s;
    int sum = 0;
    bool flag = true;
    int N = s.size();
    while(flag){
        flag = false;
        for(int i = 0; i < N; i++){
            if(s[i] != s[N - 1 - i]){
                s[i] = s[N - 1 - i];
                sum++;
                flag = true;
            }
        }
    }
    cout << sum << endl;
}

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

int main() {
	int A, B, K;
	
	cin >> A >> B >> K;
	
	vector<int> a(1,1);
	for(int i=2; i<=A; i++){
		if(A%i==0) a.push_back(i);
	}
	
	vector<int> b(1,1);
	for(int i=2; i<=B; i++){
		if(B%i==0) b.push_back(i);
	}
	
	vector<int> v(0);
	
	for(int i=0; i<a.size(); i++){
		for(int j=0; j<b.size(); j++){
			if(a[i] == b[j]) v.push_back(a[i]);
		}
	}
	reverse(v.begin(), v.end());
	
	if(v.size()==1) cout << v[0];
	else cout << v[K-1];
	cout << endl;
	
	return 0;
}

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

public class Main {
	private static void solve(){
		//Implement solution here.
		int n = ni();
		System.out.println(n % 2 == 0 ? 0.5D : 1 - (double)(n / 2) / n);
	}

	//Switch input source (stdin/file)
	private static BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args){
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		} 
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 21332
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

using namespace std;

int main() {
    ll N;
    cin >> N;
    ll P[N];
    rep(i,N){
        cin >> P[i];
        P[i] --;
    }
    ll Q[N];
    rep(i,N){
        Q[P[i]] = i;
    }
    ll maxConti = 0;
    ll tmp = 1;
    rep(i,N-1){
        if(Q[i] < Q[i + 1]){
            tmp++;
        }else{
            maxConti = max(maxConti,tmp);
            tmp = 1;
        }
    }
    maxConti = max(maxConti,tmp);
    cout << N - maxConti << endl;

}

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

int main() {
	string op;
	int A , B ,C=0;
    cin >> A >> op >> B;
  
  if (op=="+"){
  	C = A + B;
  		}else{
    C = A - B;
		}
      cout << C << endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <math.h>
#include <string>

#ifdef _MSC_VER
#pragma warning(disable:4996)
#endif

using namespace std;


int main() {
/*
	int n;
	cin >> n;
	vector<string> s(n);

	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	*/


	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int e = (c - 1) / b + 1;
	int f = (a - 1) / d + 1;
	cout << ((e <= f) ? "Yes" : "No");

	return 0;
}



Measured memory_bytes: 3596
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

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

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

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

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

    string s; cin>>s;
    
    if(s[0] == s[1] && s[1] == s[2]) cout << "No" << endl;
    else cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
const int N=2e5+5;
int n,a[N];
bool solve(int m)
{
    stack<pair<int,int> >s;
    for(int i=1;i<=n;i++)
    {
        if(s.empty()) s.push({a[i],1});
        else
        {
            if(a[i]>s.top().fi) s.push({a[i],1});
            else
            {
                if(m==1) return false;
                while(!s.empty()&&s.top().fi>a[i]) s.pop();
                if(s.empty()||s.top().fi<a[i]) s.push({a[i],2});
                else
                {
                    int now=s.top().fi;
                    while(!s.empty()&&s.top().fi==now&&s.top().se==m)
                    {
                        now--;s.pop();
                    }
                    if(s.empty()&&now==0) return false;
                    if(!s.empty()&&s.top().fi==now)
                    {
                        int p=s.top().se+1;s.pop();
                        s.push({now,p});
                    }
                    else s.push({now,2});
                }
            }
        }
    }
    return true;
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    int l=1,r=n,ans;
    while(l<=r)
    {
        int m=l+r>>1;
        if(solve(m)) ans=m,r=m-1;
        else l=m+1;
    }
    printf("%d\n",ans);
}


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

int main() {
	long long K, A[100000], L = 2, R = 2;
	cin >> K;
	for (int i = 0; i < K; i++) {
		cin >> A[i];
	}
	for (int i = K - 1; i >= 0; i--) {
		L = ((L + A[i] - 1) / A[i]) * A[i];
		R = (R / A[i] + 1) * A[i] - 1;
	}
	if (L <= R) cout << L << " " << R;
	else cout << -1;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
const int maxn = 30;
int cnt = 0;
int n;
void dfs(long long num,bool flag3,bool flag5,bool flag7){
	if(num > n) return;
	if(flag3&&flag5&&flag7) cnt++;
	dfs(num*10+3,true,flag5,flag7);
	dfs(num*10+5,flag3,true,flag7);
	dfs(num*10+7,flag3,flag5,true);
}
int main(){
	cin >> n;
	dfs(0,false,false,false);
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
import math
n=int(input())
ans=100
for i in range(1, int(math.sqrt(n))+1):
    if n%i != 0:
        continue
    b=n/i
    dig=1
    while True:
        b=int(b/10)
        if b==0:
            break
        dig+=1
    if ans>dig:
        ans=dig
print(ans)

Measured memory_bytes: 3060
import itertools

N, M, R = map(int, input().split())
cities = list(map(int, input().split()))
INF = 10**10
dp = [[INF] * (N+1) for _ in range(N+1)]
for _ in range(M):
  s, g, c = map(int, input().split())
  dp[s][g] = c
  dp[g][s] = c
for i in range(N+1):
  dp[i][i] = 0
for k in range(1, N+1):
  for i in range(1, N+1):
    for j in range(1, N+1):
      dp[i][j] = min(dp[i][j], dp[i][k]+dp[k][j])
patterns = itertools.permutations(cities, R)
ans = INF
for ptn in patterns:
  dis = 0
  for i in range(R-1):
    dis += dp[ptn[i]][ptn[i+1]]
  ans = min(ans, dis)
print(ans)

Measured memory_bytes: 47192
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 100005;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << min(a,b)+min(c,d) << endl;
}

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

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

int main(){
    std::ios::sync_with_stdio(false);
    char conso[9] = {'k', 's', 't', 'n', 'h', 'm', 'y', 'r', 'w'};
    string str;
    cin >> str;
    for(int i=0;i<(int)str.size();i++){
        if(i%2 == 0){
            if(str[i] != '1' && str[i] != '0'){
                cout << conso[str[i]-'0'-2];
            }else if(str[i] == '0'){
                if(str[i+1] != 'U'){
                    cout << "w";
                }
            }
        }else{
            if(str[i] == 'T'){
                cout << "a";
            }else if(str[i] == 'L'){
                cout << "i";
            }else if(str[i] == 'U'){
                if(str[i-1] == '0'){
                    cout << "nn";
                }else{
                    cout << "u";
                }
            }else if(str[i] == 'R'){
                cout << "e";
            }else{
                cout << "o";
            }
        }
    }
    cout << endl;
}

Measured memory_bytes: 1184
N = int(input())
As = []
Bs = []
for i in range(N):
    a,b = map(int, input().split())
    As.append(a)
    Bs.append(b) 

cnt = 0
for i in range(N-1,-1,-1):
    # print(i,As[i]+cnt, Bs[i],cnt)
    if (As[i]+cnt)%Bs[i] == 0:continue
    cnt += (Bs[i]-(As[i]+cnt)%Bs[i])
print(cnt)

Measured memory_bytes: 11040
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int k;
  cin >> k;
  if (k <= 9) {
    cout << k << endl;
    return 0;
  }
  bool end = false;
  queue<ll> que;
  for (int i = 1; i <= 9; ++i) que.push(i);
  ll cnt = 9;
  auto update = [&](ll y) {
    que.push(y);
    cnt++;
    if (cnt == k) {
      cout << y << endl;
      end = true;
    }
  };
  while(!end) {
    ll x = que.front(); que.pop();
    int last = x % 10;
    if (last == 0) {
      update(x*10 + last);
      update(x*10 + last+1);
    }
    else if (last == 9) {
      update(x*10 + last-1);
      update(x*10 + last);
    }
    else {
      update(x*10 + last-1);
      update(x*10 + last);
      update(x*10 + last+1);
    }
  }
  return 0;
}

Measured memory_bytes: 768
import java.util.*;
public class Main {
	int m,n;
	int [] x1,x2,y1,z2;
	int INF = 1 << 24;
	
	//SYAKYO
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			m = sc.nextInt();
			n = sc.nextInt();
			if((m | n) == 0) break;
			x1 = new int[m];
			y1 = new int[m];
			x2 = new int[n];
			z2 = new int[n];
			for(int i = 0 ; i < m; i++){
				x1[i] = sc.nextInt();
				y1[i] = sc.nextInt();
			}
			for(int i = 0 ; i < n; i++){
				x2[i] = sc.nextInt();
				z2[i] = sc.nextInt();
			}
			solve();
		}
	}
	private void solve() {
		int min1 = minAll(x1);
		int max1 = maxAll(x1);
		int min2 = minAll(x2);
		int max2 = maxAll(x2);
		ArrayList<Integer> xs = new ArrayList<Integer>();
		for(int i = 0 ; i < m; i++){
			xs.add(x1[i]);
		}
		for(int i = 0 ; i < n; i++){
			xs.add(x2[i]);
		}
		Collections.sort(xs);
		
		double res = 0;
		for(int i = 0 ; i + 1 < xs.size(); i++){
			double a = xs.get(i), b = xs.get(i+1), c = (a + b) / 2;
			if(min1 <= c && c <= max1 && min2 <= c && c <= max2){
				double fa = width(x1, y1, m, a) * width(x2, z2, n, a);
				double fb = width(x1, y1, m, b) * width(x2, z2, n, b);
				double fc = width(x1, y1, m, c) * width(x2, z2, n, c);
				res += (b-a) / 6 * (fa + 4 * fc + fb);
			}
		}
		System.out.printf("%.10f\n", res);
	}
	private double width(int[] X, int[] Y, int n, double x) {
		double lb = INF, ub = -INF;
		for(int i = 0 ; i < n; i++){
			double x1 = X[i], y1 = Y[i], x2 = X[ (i + 1) % n], y2 = Y[(i+1) % n];
			if((x1 - x) * (x2 - x) <= 0 && x1 != x2){
				double y = y1 + (y2 - y1) * (x - x1) / (x2 - x1);
				lb = Math.min(lb,  y);
				ub = Math.max(ub, y);
			}
		}
		return Math.max(0.0, ub - lb);
	}
	private int minAll(int[] x) {
		int res = x[0];
		for(int i = 1; i < x.length; i++){
			res = Math.min(res, x[i]);
		}
		return res;
	}
	
	private int maxAll(int[] x) {
		int res = x[0];
		for(int i = 1; i < x.length; i++){
			res = Math.max(res, x[i]);
		}
		return res;
	}
	
	public static void main(String [] args){
		new Main().doit();
	}
}

Measured memory_bytes: 13000
x, y = map(int, input().split())

num = abs(y) - abs(x)

if num == 0:
    ans = 1
elif num > 0:
    if x >= 0 and y >= 0:
        ans = num
    elif x < 0 and y < 0:
        ans = num + 2
    else:
        ans = num + 1
elif num < 0:
    if x > 0 and y > 0:
        ans = -num + 2
    elif x <= 0 and y <= 0:
        ans = -num
    else:
        ans = -num + 1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <numeric>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

inline int read(){
	int x=0,f=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=x*10+c-'0';c=getchar();}
	return x*f;
}

int cnt[1000001];
int main(){
  int n = read();
  int o = 0, g;
  for(int i=0;i<n;i++){
    int num = read();
    if(num==1) o++;
    if(i==0) g = num;
    else g = std::gcd(g, num);
    cnt[num]++;
  }

  if(n - o > 80000){
    if(g==1) printf("setwise coprime\n");
    else printf("not coprime\n");
    return 0;
  }

  int max_S = 0;
  for(int i=2;i<=1000000;i++){
    int S = 0;
    for(int j=i;j<=1000000;j+=i) S += cnt[j];
    if(max_S<S) max_S = S;
  }
  if(max_S<2) printf("pairwise coprime\n");
  else if(max_S != n) printf("setwise coprime\n");
  else printf("not coprime\n");
}



Measured memory_bytes: 7512
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
ll x[100001] = {};
ll y[100001] = {};
const ll mod = (int)1e9 + 7;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n, m;
    cin >> n >> m;

    for(int i = 0; i < n; ++i)
        cin >> x[i];
    ll width = x[n - 1] - x[0];
    
    for(int i = 0; i < m; ++i)
        cin >> y[i];
    ll height = y[m - 1] - y[0];

    ll sum1 = 0, sum2 = 0;
    for(int i = 0; i < n - 1; ++i){
        sum1 = (sum1 + ((x[i + 1] - x[i]) * ((i + 1) * (n - i - 1)) % mod) % mod) % mod;
    }
    for(int i = 0; i < m - 1; ++i){
        sum2 = (sum2 + ((y[i + 1] - y[i]) * ((i + 1) * (m - i - 1)) % mod) % mod) % mod;        
    }
    cout << (sum1 * sum2) % mod << endl;

    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main() {
  vector<tuple<string, int, int>> a;
  int n;
  cin >> n;
  rep(i,n)
  {
    string s;
    int p;
    cin >> s >> p;
    a.push_back(make_tuple(s, p, i + 1));
  }
  sort(a.begin(), a.end(),
      []( const auto &x, const auto &y )
      {
        return get<0>( x ) == get<0>( y ) ? get<1>( x ) > get<1>( y ) : get<0>( x ) < get<0>( y );
      });
  rep(i,n)
    cout << get<2>(a[i]) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define vi_a vector<int>a;
#define p_b push_back
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define m_p make_pair
#define fast_io cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
#define getfiles ifstream cin("input.txt");ofstream cout("output.txt");
#define closefiles cin.close();cout.close();
#define all(x) x.begin(),x.end()
#define sset ordered_set
#define sqr(x) (x)*(x)
#define pw(x) (1ll << x)
#define sz(x) (int)x.size()
#define endl "\n"
using namespace std;

signed main()
{
    ll n,w;
    cin>>n>>w;
    vector<ll>dp(1e5);
    ll sum=0;
    vector<pll>a(n);
    ll sum_w=0;
    for(ll i=0;i<n;i++){
        cin>>a[i].fi>>a[i].se;
        sum+=a[i].se;
        sum_w+=a[i].fi;
    }
    dp.assign(sum+1,INT_MAX);
    dp[0]=0;
    for(ll i=0;i<n;i++){
        for(ll j=sum-a[i].se;j>=0;j--){
            dp[j+a[i].se]=min(dp[j+a[i].se],dp[j]+a[i].fi);
//            cout<<dp[j+a[i].se]<<" "<<dp[j];
        }
    }
    ll ans=0;
    for(ll i=sum;i>=0;i--){
        if(dp[i]<=w){
            ans=max(ans,i);
        }
    }
    cout<<ans;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <stdbool.h>
typedef struct {
	long int d0[100010], d1[100010], d2[100010], d3[100010];
	bool n0[100010], n1[100010], n2[100010], n3[100010];
}memo;
long int dep(int i, int j, char A[], memo* memo);
long int dep0(int i, char A[], memo* memo);
long int dep1(int i, char A[], memo* memo);
long int dep2(int i, char A[], memo* memo);
long int dep3(int i, char A[], memo* memo);
int main()
{
	char A[100010];
	memo memop;
	scanf("%s", A);
	dep(0, 0, A, &memop);
	printf("%ld", memop.d0[0]);
	return 0;
}
long int dep(int i, int j, char A[], memo* memo) {
	if (j == 0) {
		if (!memo->n0[i])memo->d0[i] = dep0(i, A, memo); 
		return memo->d0[i];
	}
	if (j == 1) {
		if (!memo->n1[i])memo->d1[i] = dep1(i, A, memo);
		return memo->d1[i];
	}
	if (j == 2) {
		if (!memo->n2[i])memo->d2[i] = dep2(i, A, memo);
		return memo->d2[i];
	}
	if (j == 3) {
		if (!memo->n3[i])memo->d3[i] = dep3(i, A, memo); 
		return memo->d3[i];
	}
	return 0;
}
long int dep0(int i, char A[], memo* memo) {
	if (A[i] == 0) {
		memo->d0[i] = 0;
	}
	else {
		if (A[i] == '?') {
			memo->d0[i] = (3 * dep(i + 1, 0, A, memo) + dep(i + 1, 1, A, memo)) % 1000000007;
		}
		else {
			if (A[i] == 'A') memo->d0[i] = (dep(i + 1, 0, A, memo) + dep(i + 1, 1, A, memo)) % 1000000007;
			else memo->d0[i] = dep(i + 1, 0, A, memo) % 1000000007;
		}
	}	memo->n0[i] = 1;
	return memo->d0[i];
}
long int dep1(int i, char A[], memo * memo) {
	if (A[i] == 0) {
		memo->d1[i] = 0;
	}
	else {
		if (A[i] == '?') {
			memo->d1[i] = (3 * dep(i + 1, 1, A, memo) + dep(i + 1, 2, A, memo)) % 1000000007;
		}
		else {
			if (A[i] == 'A' + 1)memo->d1[i] = (dep(i + 1, 1, A, memo) + dep(i + 1, 2, A, memo)) % 1000000007;
			else memo->d1[i] = dep(i + 1, 1, A, memo) % 1000000007;
		}
	}	memo->n1[i] = 1;
	return memo->d1[i];
}
long int dep2(int i, char A[], memo * memo) {
	if (A[i] == 0) {
		memo->d2[i] = 0;
	}
	else {
		if (A[i] == '?') {
			memo->d2[i] = (3 * dep(i + 1, 2, A, memo) + dep(i + 1, 3, A, memo)) % 1000000007;
		}
		else {
			if (A[i] == 'A' + 2) memo->d2[i] = (dep(i + 1, 2, A, memo) + dep(i + 1, 3, A, memo)) % 1000000007;
			else memo->d2[i] = dep(i + 1, 2, A, memo) % 1000000007;
		}
	}	memo->n2[i] = 1;
	return memo->d2[i];
}
long int dep3(int i, char A[], memo * memo) {
	if (A[i] == 0) {
		memo->d3[i] = 1;
	}
	else {
		if (A[i] == '?')memo->d3[i] = (3 * dep(i + 1, 3, A, memo)) % 1000000007;
		else memo->d3[i] = dep(i + 1, 3, A, memo) % 1000000007;
	}	memo->n3[i] = 1;
	return memo->d3[i];
}


Measured memory_bytes: 10240
#include<bits/stdc++.h>
//***** Jai Gurudev *****//
#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define all(x) x.begin(),x.end()
#define vii vector<pair<int,int> >
#define vll vector<pair<ll,ll> >
#define pb push_back
#define fi first
#define se second
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define PI 3.1415926535897932384626433832795
#define inf 1e18+5
#define mod 1000000007
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
bool isprime(ll n) {bool flag=true;for(ll i=2; i<=sqrt(n);i++){if(n%i==0){flag=false;break;}}return flag;}
using namespace std;
int main()
{
	char c;
	cin>>c;
	if(isupper(c))
	cout<<"A";
	else
	cout<<"a";
	return 0;
}


Measured memory_bytes: 3560
/* A - Rainy Season */

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

int main(){
  string S;
  cin >> S;
  int ans = 0, cnt = 0, len = S.size();
  for(int i = 0; i < len; i++){
    if(S.at(i) == 'R'){
      cnt++;
    }else{
      if(cnt > ans) ans = cnt;
      cnt = 0;
    }
  }
  if(cnt > ans) ans = cnt;
  cout << ans << endl;
}


Measured memory_bytes: 3624
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<int>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;
const Int INF = 1LL << 61;

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

    int n, k;
    string s;
    cin >> n >> k >> s;

    int ans = 0;
    int cnt = 0;
    for (int i = 1; i < n; i++) {
        if (s[i] == s[i - 1]) {
            ans++;
        } else {
            cnt++;
        }
    }

    if (cnt & 1) {
        if ((cnt + 1) / 2 <= k) {
            ans = n - 1;
        } else {

            ans += 2 * k;
        }
    } else {
        if (cnt / 2 <= k) {
            ans = n - 1;
        } else {
            ans += 2 * k;
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
    int n, d, x;
    cin >> n >> d >> x;

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

    for(int i = 0; i < n; i++){
        for(int j = 0; j >= 0; j++){
            if(d < 1 + a[i] * j){
                break;
            }else{
                x++;
            }
        }
    }

    cout << x << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
 
using namespace std;
int a,b;

int main()
{
  int i;
  char sa[10], sb[10];
  string stra, strb;

  cin >> a >> b;

  for(i=0; i<b; i++) {
    sa[i] = '0'+a;
  }
  sa[i] = '\0';
  stra = sa;
  for(i=0; i<a; i++) {
    sb[i] = '0'+b;
  }
  sb[i] = '\0';
  strb = sb;

  if (stra < strb)
    cout << stra;
  else
    cout << strb;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,i,b[100],c[100],x,y,z,j,max,cnt;
	char a[100][100];
	scanf("%d",&n);
	cnt=0;
	while(n!=0){
		if(0<cnt) printf("\n");
		for(i=0;i<n;i++) b[i]=0;
		for(i=0;i<n;i++){
			scanf("%s %d %d %d",a[i],&x,&y,&z);
			b[i]=x*3+z;
		}
		for(i=0;i<n;i++){
			max=-1;
			for(j=0;j<n;j++){
				if(max<b[j]) max=b[j];
			}
			for(j=0;j<n;j++){
				if(max==b[j]){
					printf("%s,%d\n",a[j],b[j]);
					b[j]=-2;
				}
			}	
		}
		cnt++;
		scanf("%d",&n);
	}
	return 0;
}

Measured memory_bytes: 2532
import java.util.*;
public class Main {

    public static void main(String[] args) {
       Scanner sc = new Scanner(System.in);
       String code = sc.nextLine();
       boolean result = false;
       for(int i=0; i< code.length(); i++){
           if(code.charAt(i) == 'c' || code.charAt(i) == 'C'){
               result = true; 
           }
           
           if((code.charAt(i) == 'f' || code.charAt(i) == 'F') && result){
               System.out.println("Yes");
               break;
           }
           if(i == code.length()-1){
                System.out.println("No");
           }
       }
       
    }
}


Measured memory_bytes: 10064
# include <bits/stdc++.h>
using namespace std;
const int N=2005;
char s[N][N];
int n, m, a[N], b[N];

int main()
{
	scanf("%d%d",&n,&m);
	int ans=max(n,m);
	for(int i=0;i<n;i++) scanf("%s",s[i]);
	for(int i=0;i<n;i++) {
		for(int j=0;j<m-1;j++) {
            if(i&&!(s[i-1][j+1]^s[i][j]^s[i-1][j]^s[i][j+1])) a[j]++;
            else a[j]=1;
		}
		int t=0;
		for(int j=0;j<=m-1;j++) {
			while(t&&a[b[t-1]]>=a[j]) {
				int x=b[--t];
				if(t==0) ans=max(ans,(j+1)*a[x]);
				else ans=max(ans,(j-b[t-1])*a[x]);
			}
			b[t++]=j;
		}
	}
	printf("%d\n",ans);
	return 0;
}


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

#define int long long
#define ll long long
#define pb push_back

main(){
    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    cout << max((ll)0, (c * 60 + d - a * 60 - b) - e);
}


Measured memory_bytes: 3636
N,M = map(int,input().split())
H = [int(i) for i in input().split()]
nlst = [1 for i in range(N)]
for i in range(M):
    a,b =map(int,input().split())
    c = min(H[a-1],H[b-1])
    if c == H[a-1]:
        nlst[a-1] = 0
    if c == H[b-1]:
        nlst[b-1] = 0
print(sum(nlst))


Measured memory_bytes: 20052
input=[input().split() for i in range(2)]
num=int(input[0][0])
length=int(input[0][1])
list=[]
for i in range(length):
    list.append(int(input[1][i]))
i=0
flg=True
while (flg):
    ret=num-i
    flg=ret in list
    if(flg):
        ret=num+i
        flg=ret in list
        if(flg):
            i=i+1
        else:
            print(ret)
    else:
        print(ret)

Measured memory_bytes: 9204
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstring>

using namespace std;

#define REP(i, x) for(int i=0;i<(int)(x);i++)
#define REPS(i, x) for(int i=1;i<=(int)(x);i++)
#define RREP(i, x) for(int i=(int)(x)-1;i>=0;i--)
#define RREPS(i, x) for(int i=(int)(x);i>0;i--)
#define FOR(it, x) for(auto it=x.begin();it!=x.end();++it)
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
int d[4][2] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
template<class T>
ostream &operator<<(ostream &os, const vector<T> &v){
        os << "[";
        FOR(it, v) os << *it << ", ";
        return os << "]";
}

int u[35][35];
int sum[35][35];
int H, W, s;
int dp[35][35][35][35];

inline int f(int x1, int y1, int x2, int y2){
        return sum[y2][x2] - sum[y2][x1] - sum[y1][x2] + sum[y1][x1];
}
inline int g(int group, int power){
        return (group<<16) | (s - power);
}

inline int comb(int x, int y){
        if(x == -1 || y == -1) return -1;
        return (((x>>16) + (y>>16)) << 16) + min(x&65535, y&65535);
}

int main(){
        while(cin >> H >> W >> s, H){
                memset(u, 0, sizeof(u));
                memset(sum, 0, sizeof(sum));
                REP(i, H)REP(j, W) cin >> u[i][j];
                REPS(i, H)REPS(j, W){
                        sum[i][j] = u[i-1][j-1] + sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1];
                }
                int all = sum[H][W];
                memset(dp, -1, sizeof(dp));
                REPS(w, W)REPS(h, H)REP(y, H-h+1)REP(x, W-w+1){
                        int &tar = dp[y][x][y+h][x+w];
                        if(all - f(x, y, x+w, y+h) <= s) tar = g(1, all - f(x, y, x+w, y+h));
                        for(int m=1;m<w;m++){
                                tar = max(tar, comb(dp[y][x][y+h][x+m], dp[y][x+m][y+h][x+w]));
                        }
                        for(int m=1;m<h;m++){
                                tar = max(tar, comb(dp[y][x][y+m][x+w], dp[y+m][x][y+h][x+w]));
                        }
                }
                cout << (dp[0][0][H][W] >> 16) <<" " << (dp[0][0][H][W] & 65535) << endl;
        }
        return 0;
}

Measured memory_bytes: 7044
#include<stdio.h>
#include<stdlib.h>
int main(){
  int n=0;
  int total=0;
  int s1=0;
  int s2=0;
  int s3=0;
  int w[100];
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&w[i]);
    total=w[i]+total;
  }
  int ans=total;
  for(int i=0;i<n;i++){
    s1=s1+w[i];
    s2=total-s1;
    s3=abs(s2-s1);
    if(s3<ans){
      ans=s3;
      //printf("%d\n",ans);
    }
    else {}
  }
  
  printf("%d",ans);
  return 0;
}

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

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
 
typedef long long ll;
using namespace std;
 
int main(){
  int n,k,a = 1;
  cin >> n >> k;
  
  rep(i,0,n){
    a = min(2*a,a+k);
  }
  printf("%d\n",a);
  return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "vector"
#include "string"
#include "map"
#include "algorithm"
#include "functional"
#include "set"
#include "numeric"

using namespace std;

const long long int MOD = 1000000007;

int N, M, K, H, W, L, R;

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

	cin >> N >> K;
	vector<long long int>dp(N + 1);
	dp[1] = 1;
	if (K <= N)dp[K] = 1;
	for (int i = 1; i <= N; i++) {
		if (i + 2 <= N) {
			dp[i + 2] += dp[i];
		}
		if (i + K + 1 <= N)dp[i + K + 1] += dp[i];
	}
	cout << accumulate(dp.begin(), dp.end(), 0LL) << endl;
	return 0;
}


Measured memory_bytes: 3204
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

total = 0
for i in range(N):
    c = min(A[i], B[i])
    B[i] -= c
    A[i] -= c
    total += c
    c = min(A[i + 1], B[i])
    B[i] -= c
    A[i + 1] -= c
    total += c
print(total)


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

int main(){
    long long int n;
    cin >> n;
    long long int min = 1000000000001;
    for(int i = 1; i < sqrt(n)+1; i++){
        if(n % i == 0){
            if(min > (i + n / i)){
                min = i + n / i;
                }
            }
        }
    cout << min - 2 << endl;
    return 0;
}

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

int main() {
    string x;
    cin >> x;
    stack<char> ST;

    for (int i = 0; i < x.size(); i++) {
        if (x.at(i) == 'S') ST.push('S');
        else if (x.at(i) == 'T' && (ST.empty() || ST.top() == 'T')) ST.push('T');
        else ST.pop();
    }

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

Measured memory_bytes: 644
#include<bits/stdc++.h>
using namespace std;
#define rkc ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
#define fl(i,a,b) for(ll i=a;i<b;i++)
#define rfl(i,a,b) for(ll i=a;i>b;i--)
#define pb push_back
#define mp make_pair
#define test ll t;cin>>t;while(t--)
#define lld long double
#define vpp vector<pair<ll,ll>>
#define ff first
#define ss second
const ll M = 1e9 + 7;
const double pi  =3.141592653589793238463;

ll a[100005][5],b[100005][5];
int main()
{
    rkc;
    ll n;
    cin>>n;
    fl(i,1,n+1)
    {
        cin>>a[i][1]>>a[i][2]>>a[i][3];
        b[i][1]=max(b[i-1][2],b[i-1][3])+a[i][1];
        b[i][2]=max(b[i-1][1],b[i-1][3])+a[i][2];
        b[i][3]=max(b[i-1][2],b[i-1][1])+a[i][3];
    }
    cout<<max(b[n][1],max(b[n][2],b[n][3]));
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799;
 
int main(){
  int n;
  int l[100];
  cin >> n;
  rep(i, n) cin >> l[i];
  sort(l, l+n);
  reverse(l, l+n);
  int a = l[0], b = 0;;
  rep(i, n-1) b += l[i+1];
  if(a < b) cout << "Yes" <<endl;
  else cout << "No" <<endl;
}

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

using namespace std;

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)

int main(){
    int A,B;

    scanf("%d%d",&A,&B);

    if(A<=5)
        printf("%d\n",0);
    else if(A<=12)
        printf("%d\n",B/2);
    else
        printf("%d\n",B);

    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [100001] * N
B = list(map(int, input().split()))

if N == 2:
  print(B[0]*2)
else: 
  for i in range(N-1):
    A[i] = B[i]
  for i in range(N-2):
    if A[i+1] > B[i]:
      A[i+1] = B[i]

  A[-1] = B[-1]

  print(sum(A))

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

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

int main(){
  int r,g,b,n;
  cin >> r >> g >> b >> n;
  int ans=0;
  
  rep(i,n+1){
    rep(j,n+1){
      int rest = n-r*i-g*j;
      if(rest%b==0&&rest>=0) ans++;
    }
  }

  cout << ans;
}

Measured memory_bytes: 3596