akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
     
    using namespace std;
     
    #define all(a) a.begin(),a.end()
    #define F first
    #define S second
    #define pb push_back
    #define ll long long
    #define vi vector<int>
    #define pi pair<int,int>
    #define mp make_pair
     
    #ifdef LOCAL
    #include "debug.h"
    #else
    #define debug(...) 42
    #endif
     //~ #define int ll
    int mod=1e9+7;
     
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    template<typename A,typename B> istream& operator>>(istream&,pair<A,B>&);
    template<typename A> istream& operator>>(istream&,vector<A>&);
    void add(int&,int);
    int mul(int,int);
    int powz(int,int);
    int sub(int,int);
    template<typename A> ostream& operator<<(ostream&,vector<A>&);
     
    const int N=1000001;
     //~ int dp[13];
     int pz[N];
    void solve(){
    	string s;
    	cin>>s;
    	vi dp(13);
    	int n=s.length();
    	pz[0]=1;
    	//~ mod=13;
    	for(int i=1;i<=n;i++){
			pz[i]=pz[i-1]*10;
			pz[i]%=13;
		}
    	dp[0]=1;
    	for(int i=n-1;i>=0;i--){
			vector<int>dp2(13);
			for(int prev=0;prev<13;prev++){
				if(s[i]!='?'){
					add(dp2[(((int)(s[i]-'0')*pz[n-i-1])%13+prev)%13],dp[prev]);
					continue;
				}
				for(int cur=0;cur<10;cur++){
					add(dp2[((pz[n-i-1]*cur)%13+prev)%13],dp[prev]);
				}
			}
			dp=dp2;
		}
    cout<<dp[5];	
    }
     
    signed main(){
    	ios_base::sync_with_stdio(false);
    	cin.tie(0);
    	int tc=1;
    	//~ cin>>tc;
    	for(int _=0;_<tc;_++){
    		//cout<<"Case #"<<_+1<<": ";
    		solve();
    		if(_!=tc-1)
    		cout<<"\n";
    	}
    }
     
    int mul(int a,int b)
    {
    	return ((a)*1ll*(b))%mod;
    }
     
    void add(int &a,int b)
    {
    	a+=b;
    	if(a>=mod)a-=mod;
    }
     
    int sub(int a,int b){
    	a-=b;
    	if(a<0){
    		a+=mod;
    	}
    	return a;
    }
     
    int powz(int a,int b)
    {
    	int res=1;
    	while(b)
    	{
    		if(b&1)res=mul(res,a);
    		b/=2;
    		a=mul(a,a);
    	}
    	return res;
    }
     
    template <typename A, typename B>
    istream& operator>>(istream& input,pair<A,B>& x) {
    	input>>x.F>>x.S;
    	return input;
    }
     
    template <typename A>
    istream& operator>>(istream& input,vector<A>& x) {
    	for(auto& i:x)
    		input>>i;
    	return input;
    }
     
    template<typename A>
    ostream& operator<<(ostream& output,vector<A>& x) {
    	for(auto& i:x)
    	    output<<i<<' ';
    	return output;
    }


Measured memory_bytes: 848
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
using namespace std;

int main()
{
    int n;
    cin >> n;
    if(n%2==0){
        cout << n;
    }else{
        cout << n*2;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <cstdlib>
#include <vector>
#include <algorithm>

int main() {
  size_t A, B, Q;
  scanf("%zu %zu %zu", &A, &B, &Q);

  intmax_t INF = 1e12;

  std::vector<intmax_t> s(A), t(B);
  for (auto& si: s) scanf("%jd", &si);
  for (auto& tj: t) scanf("%jd", &tj);

  s.insert(s.begin(), -INF);
  s.push_back(INF);
  t.insert(t.begin(), -INF);
  t.push_back(INF);

  for (size_t i = 0; i < Q; ++i) {
    intmax_t x;
    scanf("%jd", &x);

    auto si = std::lower_bound(s.begin(), s.end(), x);
    intmax_t s1 = *si;
    intmax_t s0 = *--si;

    auto ti = std::lower_bound(t.begin(), t.end(), x);
    intmax_t t1 = *ti;
    intmax_t t0 = *--ti;

    intmax_t res = std::min({std::abs(x-std::max(s1, t1)),
                             std::abs(x-std::min(s0, t0)),
                             std::abs(x-s1) + std::abs(s1-t0),
                             std::abs(x-s0) + std::abs(s0-t1),
                             std::abs(x-t1) + std::abs(t1-s0),
                             std::abs(x-t0) + std::abs(t0-s1)});
    printf("%jd\n", res);
  }
}


Measured memory_bytes: 2912
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1000000007;
string alp="abcdefghijklmnopqrstuvwxyz";

int main(){
    ll K;
    cin >> K;
    ll p=K/50,q=K%50;
    cout << 50 << endl;
    rep(i,q){
        cout << 100+p-q << ' ';
    }
    rep(i,50-q){
        cout << 49+p-q;
        if (i!=49-q){
            cout << ' ';
        }
        else {
            cout << endl;
        }
    }
}

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

#define reep(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) reep((i),0,(n))
#define F first
#define S second
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
#define PB push_back
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
const int INF = INT_MAX / 2;
const ll INFL = LLONG_MAX / 2;
map<string, int> item;
vector<pii> v;
vector<pii> pos;
vector<vector<pii>> shop;
int main() {
	int n, m, W, T;
	cin >> n >> m >> W >> T;
	v = vector<pii>(m);
	rep(i, m) {
		string s;
		pii a;
		cin >> s >> a.F >> a.S;
		item[s] = i;
		v[i] = a;
	}
	shop = vector<vector<pii>>(n);
	pos = vector<pii>(n);
	rep(i, n) {
		int L, x, y;
		cin >> L >> x >> y;
		pos[i] = pii(x, y);
		rep(j, L) {
			string s;
			int t;
			cin >> s >> t;
			shop[i].PB(pii(item[s], v[item[s]].S - t));
		}
	}
	vector<vector<int>> ti(1 << n, vector<int>(n, INF));
	ti[0][0] = 0;
	rep(i, n) {
		ti[1 << i][i] = abs(pos[i].F) + abs(pos[i].S);
	}
	rep(i, 1 << n) {
		rep(j, n) {
			if(ti[i][j] == INF) continue;
			if(!(i & (1 << j))) continue;
			// cout<<i<<" "<<j<<endl;
			rep(k, n) {
				if(i & (1 << k)) continue;
				mins(ti[i + (1 << k)][k], ti[i][j] + abs(pos[j].F - pos[k].F) + abs(pos[j].S - pos[k].S));
			}
		}
	}
	vector<ll> val(1 << n, 0);
	rep(i, 1 << n) {
		vector<pii> tmp;
		rep(j, n) {
			if(i & (1 << j)) {
				for(auto x : shop[j]) {
					tmp.PB(x);
				}
			}
		}
		vector<ll> w(W + 1, 0);
		rep(j, W) {
			for(auto x : tmp) {
				if(j + v[x.F].F > W) continue;
				maxs(w[j + v[x.F].F], w[j] + x.S);
			}
		}
		rep(j, W + 1) {
			maxs(val[i], w[j]);
		}
	}
	vector<pll> w(1 << n);
	vector<ll> res(T + 1, 0);
	ll ans = 0;
	rep(i, 1 << n) {
		if(!i) w[i] = pll(0, 0);
		else {
			ll t = INFL;
			rep(j, n) {
				mins(t, 0LL + ti[i][j] + abs(pos[j].F) + abs(pos[j].S));
			}
			w[i] = pll(t, val[i]);
			// cout<<i<<" "<<t<<" "<<val[i]<<endl;
		}
	}
	rep(i, T) {
		rep(j, w.size()) {
			if(i + w[j].F > T) continue;
			maxs(res[i + w[j].F], res[i] + w[j].S);
		}
	}
	rep(i, T + 1) maxs(ans, res[i]);
	cout << ans << endl;
}

Measured memory_bytes: 3312
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional> //operator[]
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

signed main(){
    ll h,w; cin >> h >> w;
    ll ans=h*w+1;
    ans/=2;
    if(h==1||w==1) ans=1;
    cout << ans << endl;
}


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

int main(){
  int A,B,C,K;

  cin >> A >> B >> C >> K;

  int n = 0;

  if(K<=A){
    n = K;
  }else if(K<= A+B){
    n = A;
  }else{
    n = A - (K- (A+B));
  }
  cout << n << endl;
}

Measured memory_bytes: 3612
N = int(input())
S = []
for _ in range(N):
    tmp = input()
    S.append(tmp)

begin_b = [False for _ in range(N)]
end_a = [False for _ in range(N)]
cnt = 0
for i, s in enumerate(S):
    for j in range(len(s)-1):
        if s[j:j+2] == 'AB':
            cnt += 1
        if s[0] == 'B':
            begin_b[i] = True
        if s[-1] == 'A':
            end_a[i] = True

cnt_ba = 0
cnt_b = 0
cnt_a = 0
for i in range(N):
    if begin_b[i] and end_a[i]:
        cnt_ba += 1
    elif begin_b[i]:
        cnt_b += 1
    elif end_a[i]:
        cnt_a += 1

if cnt_ba > 0:
    res_a = 0
    res_b = 0
    if cnt_a > 0:
        res_a = 1
        cnt_a -= 1
    if cnt_b > 0:
        res_b = 1
        cnt_b -= 1
    ans = cnt + (cnt_ba-1) + res_a + res_b + min(cnt_a, cnt_b)
else:
    ans = cnt + min(cnt_a, cnt_b)
print(ans)



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

const int V_MAX=100000;

struct edge{
	int to;
	int weight;
};

vector<edge> G[V_MAX];
int used[V_MAX]={};
int maxVertex;
int maxDist=0;

void dfs(int s, int dist){
	if(used[s]==1){return;}
	used[s]=1;
	for (int i=0;i<G[s].size();i++){
		if(used[G[s][i].to]==0){
			dfs(G[s][i].to,dist+G[s][i].weight);
		}
	}
	if(maxDist < dist){
		maxDist=dist;
		maxVertex=s;
	}
}

int main(){
	int V,E,s,t,w;
	edge e;
	cin>> V ;
	E=V-1;
	for (int i=0;i<E;i++){
		cin >> s >> t >> w;
		e.to=t;
		e.weight=w;
		G[s].push_back(e);
		e.to=s;
		e.weight=w;
		G[t].push_back(e);
	}
	
	dfs(0,0);
	
	for(int i=0;i<V;i++){
		used[i]=0;
	}
	
	maxDist=0;
	dfs(maxVertex,maxDist);
	
	cout << maxDist << endl;
	return 0;
}

Measured memory_bytes: 11748
#pragma GCC optimize("O3")

#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <string_view>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
using namespace std;

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout(a) cout << fixed << setprecision((int)(a))

//typedef===============
typedef long long       ll;
typedef long double     ld;
typedef pair<int, int>  Pii;
typedef pair<ll, ll>    Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ll MOD2   = 998244353;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define eb emplace_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (n); ++(i))
#define reps(i, n)      for(int i = 1; (i) <= (n); ++(i))
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; --(i))
#define repbit(bit, n)  for(int bit = 0; (bit) < (1 << (n)); ++(bit))
#define ifbit(bit, i)   if((bit) & (1 << (i)))
#define CtoI(c)         int((c)) - int('0')
#define ItoC(c)         char((c) + '0')

//functions=============
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    int a, b; cin >> a >> b;
    cout << max(a + b, max(a - b, a * b)) << endl;

return 0;
}

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

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

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

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

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

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

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

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

fn solve(cs: Vec<char>, k: usize) {
    let one = {
        let mut count = 0;
        for c in &cs {
            if c == &'1' {
                count += 1;
            } else {
                break;
            }
        }
        count
    };
    if k - 1 < one {
        println!("1");
    } else {
        println!("{}", &cs[one]);
    }
}

fn main() {
    input! {
        cs: chars,
        k: usize
    }
    solve(cs, k)
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = LLONG_MAX;
/* テンプレートここまで */
ll dp[51][51][50*50 + 1] = {0};

int main() {
  ll N, A; cin >> N >> A;
  vector<ll> x(N); REP(i, N) cin >> x[i];

  dp[0][0][0] = 1;
  REP(i, N) REP(j, N) REP(k, 50*50+1){
    dp[i+1][j+1][k+x[i]] += dp[i][j][k];
    dp[i+1][j][k] += dp[i][j][k];
  }

  ll ans = 0;
  FOR(j, 1, N+1){
    ans += dp[N][j][j*A];
  }
  cout << ans << endl;
}


Measured memory_bytes: 50048
# 標準入力をリスト形式で取得取得
a = list(map(int, input().split()))
#print(a)

# リストを昇順ソート
a.sort()

#print(a)

# 直角三角形の面積は、１番目に短い辺*２番目に短い辺/2で求められる
print(int(a[0] * a[1] / 2))



Measured memory_bytes: 2940
import sys

input = sys.stdin.readline


def main():
    S = input().strip()
    T = input().strip()
    ans = list(S)

    for i in range(len(S) - len(T), -1, -1):
        for j in range(len(T)):
            if S[i + j] == T[j] or S[i + j] == "?":
                continue
            else:
                break
        else:
            m = 0
            for k in range(i, i + len(T)):
                ans[k] = T[m]
                m += 1
            for k in range(len(ans)):
                if ans[k] == "?":
                    ans[k] = "a"
            print("".join(ans))
            exit()
    else:
        print("UNRESTORABLE")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
int main(){
  char s[82];
  int i,j;
  while(fgets(s,80,stdin)){
    for(i=0;i<26;i++){
      for(j=0;s[j]-10;j++){
	if('a'<=s[j]&&s[j]<='z')s[j]++;
	if(s[j]=='z'+1)s[j]='a';
      }
      if(strstr(s,"the"))break;
      if(strstr(s,"that"))break;
      if(strstr(s,"this"))break;
    }
    printf("%s",s);
  }
  return 0;
}

Measured memory_bytes: 524
import sys
input=sys.stdin.readline
INF = 10**9

def main():
    n,m=map(int,input().split())
    cake=[list(map(int,input().split())) for _ in range(n)]
    
    op = [(1,1,-1),(1,-1,-1),(1,1,-1),(-1,-1,-1),(1,1,-1),(1,-1,-1),(1,1,-1)]

    ans =0 
    for i in range(8):
        cake.sort(key=lambda x:sum(x),reverse=True)
        t = 0
        for k in range(3):
            t += abs(sum([cake[j][k] for j in range(m)]))
        ans = max(ans,t)
        if i!=7:
            cake = [[cake[j][0]*op[i][0],cake[j][1]*op[i][1],cake[j][2]*op[i][2]] for j in range(n)]
    
    print(ans)  
if __name__=='__main__':
    main()


Measured memory_bytes: 3572
a,b = gets.split.map(&:to_i)

table = Array.new(50){"."*100}
table += Array.new(50){"#"*100}
ra,rb = a-1,b-1
pt = 0
while rb > 0
  table[1+(pt/100)*2][pt%100] = "#"
  pt += 2
  rb -= 1
end
pt = 0
while ra > 0
  table[51+(pt/100)*2][pt%100] = "."
  pt += 2
  ra -= 1
end
puts "100 100"
table.each do |s|
  puts s
end


Measured memory_bytes: 1788
//#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <deque>
#include <numeric>

using namespace std;

typedef long long int lo;
#define fast ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(0);
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define inf (lo)1e9
#define N (lo)1e5 * 5
#define all(x) (x).begin(), (x).end()
#define ii pair<lo,lo>
#define iii pair<lo, pair<lo,lo> >
#define si pair<string,lo>
#define vi vector <lo> 
#define vii vector <ii> 

int main() {
    fast
    lo n;
    cin >> n;
    set <string> seet;
    for(lo i = 0 ; i < n ; i++){
        string s;
        cin >> s;
        seet.insert(s);
    }
    cout << seet.size() << endl;
    return 0;
}

Measured memory_bytes: 19248
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <algorithm>
#include <typeinfo>
#define _USE_MATH_DEFINES
#include <cmath>

using namespace std;

int main(){

    int n1, n2, n3, tmp;
    cin >> n1 >> n2 >> n3;

    if(n2>n3){
        tmp = n2;
        n2 = n3;
        n3 = tmp;
    }

    if(n1>n2){
        tmp = n1;
        n1 = n2;
        n2 = tmp;
    }

    if(n2>n3){
        tmp = n2;
        n2 = n3;
        n3 = tmp;
    }


    cout << n1 << " " << n2 << " " << n3 << endl;

    return 0;
}



Measured memory_bytes: 3116
using System;
class Program
{
  static void Main(string[] args)
  {
    // スペース区切りの整数の入力
    string input = Console.ReadLine();
    bool t=true;;
    int[] chk = new int[3];
    for (int i = 0; i < 3; i++) {
      chk[i]=0;
    }

    for (int i = 0; i < 3; i++) {
      if (input[i] == 'a')chk[0]++;
      if (input[i] == 'b')chk[1]++;
      if (input[i] == 'c')chk[2]++;
    }

    for (int i = 0; i < 3; i++) {
      if (chk[i]>1)t=false;
    }


    if (t) {
      Console.WriteLine("Yes");
    } else {
      Console.WriteLine("No");
    }

  }


}

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  
  sort(A.begin(),A.end());
  
  int count=1;
  
  for(int i=0;i<N-1;i++){
    if(A[i]!=A[i+1]){
      count++;
    }
  }
  
  if(count%2==0){
    cout << count-1 << endl;
  }
  else{
    cout << count << endl;
  }
}
  
  
  
  

Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;

bool all_same(string S){
  for(int i = 0; i < S.size(); i++){
    if(S[0] != S[i]){
      return false;
    }
  }
  return true;
}

int main(){
    int N;
    int K;
    string S;

    cin >> N >> K;
    cin >> S;

    if(all_same(S)){
      cout << N - 1 << endl;
      return 0;
    }
    
    int happy_num = 0;
    for(int i = 0; i < S.size(); i++){
      if(S[i] == 'R'){
        if(i < S.size() - 1 && S[i + 1] == 'R'){
          happy_num ++;
        }
      } else {
        if(i > 0 && S[i - 1] == 'L'){
          happy_num ++;
        }
      }
    }

    int ans = 0;
    int left_K = K;
    int tmp_ans = happy_num;

    bool first_ended = false;
    bool in_r = false;
    for(int i = 0; i < S.size(); i++){
      if(!first_ended){
        if(S[i] == 'L'){
          first_ended = true;
        }
      } else {
        if(S[i] == 'R'){
          in_r = true;
        } else {
          if(in_r){
            in_r = false;
            if(left_K > 0){
              tmp_ans += 2;
              left_K --;
            }
          }
        }
      }
      if(left_K <= 0){
        break;
      }
    }
    if(S[S.size() - 1] == 'R' && left_K > 0){
      tmp_ans ++;
      left_K --;
    }
    if(S[0] == 'R' && left_K > 0){
      tmp_ans ++;
    }
    ans = max(ans, tmp_ans);


    left_K = K;
    tmp_ans = happy_num;
    first_ended = false;
    bool in_l = false;
    for(int i = 0; i < S.size(); i++){
      if(!first_ended){
        if(S[i] == 'R'){
          first_ended = true;
        }
      } else {
        if(S[i] == 'L'){
          in_l = true;
        } else {
          if(in_l){
            in_l = false;
            if(left_K > 0){
              tmp_ans += 2;
              left_K --;
            }
          }
        }
      }
      if(left_K <= 0){
        break;
      }
    }
    if(S[0] == 'L' && left_K > 0){
      tmp_ans++;
      left_K --;
    }
    if(S[S.size() - 1] == 'L' && left_K > 0){
      tmp_ans ++;
    }
    ans = max(ans, tmp_ans);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int (i) = 0, i_len = n; (i) < (i_len); ++(i))
#define repp(i,n) for(int (i) = 1, i_len = n; (i) <= (i_len); ++(i))
#define per(i,n) for(int (i) = n-1; (i) >= 0; --(i))
#define perr(i,n) for(int (i) = n; (i) > 0; --(i))
#define sz(x) ((int)(x).size())
#define popcnt __builtin_popcount
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define Pi 3.1415926535
#define MOD = 1e9+7;
using namespace std;
using ll = long long;
using pint = pair<int,int>;
using itn = int;
using vint = vector<int>;
template<class T,class S> inline bool chmax(T& a, S b){if(a<b){a = b; return true;} return false;}
template<class T,class S> inline bool chmin(T& a, S b){if(a>b){a = b; return true;} return false;}
template<class T> T gcd(T a, T b){return b?gcd(b,a%b):a;}
template<class T> T lcm(T a, T b){return a*b/gcd(a,b);}

int solve(){
    int n,d,x; cin >> n >> d >> x;
    vint a(n); rep(i,n) cin >> a[i];

    int ans = x+n;
    rep(i,n){
        int days = 2;
        while(days <= d){
            if((days-1)%a[i] == 0){
                ++ans;
            }
            ++days;
        }
    }
    cout << ans << endl;

    return 0;
}

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


Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d", $a, $b);
if ($a > $b) {
    echo ($a + ($a - 1)).PHP_EOL;
} elseif ($a < $b) {
    echo ($b + ($b - 1)).PHP_EOL;
} elseif ($a == $b) {
    echo ($a + $b).PHP_EOL;
}

Measured memory_bytes: 4604
#include<bits/stdc++.h>
#define int long long
#define fast ios::sync_with_stdio(false); cin.tie(NULL);
#define loop(i,n) for(int i=0;i<n;i++)
#define double long double
#define mod 1000000007
#define F first
#define S second
#define pb push_back

using namespace std;

signed main()
{
	fast;
	int test=1;
	// cin>>test;
	for(int index=0;index<test;index++)
	{
		int n;
		cin>>n;
		vector<int> v(n);
		vector<int> freq(n,0);
		v[0]=1;
		for(int i=1;i<n;i++)
		{
			cin>>v[i];
		}
		for(int i=1;i<n;i++)
		{
			freq[v[i]-1]++;
		}
		loop(i,n)
		{
			cout<<freq[i]<<endl;
		}

	}
}



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

struct Card {
  char mark, num;
};

void print(struct Card A[], int N){
  for(int i =0; i <N; i++){
    if(i == N-1){
      cout << A[i].mark << A[i].num << endl;
      break;
    }
    cout << A[i].mark << A[i].num << " ";
  }
}

void BubbleSort(struct Card A[],int N){
  for(int i=0; i < N; i++){
    for(int j = N-1; j > 0; j--){
      if(A[j].num < A[j-1].num)swap(A[j],A[j-1]);
    }
  }
}

void SelectionSort(struct Card A[],int N){
  for(int i=0; i <N ;i++){
    int minj = i;
    for(int j = i; j< N; j++){
      if(A[j].num < A[minj].num){
        minj = j;
      }
      
    }
    Card t = A[i];
    A[i] = A[minj];
    A[minj] = t;

  }
}

int main(){
  int N;
  cin >> N;
  Card C1[100];
  Card C2[100];
  for(int i =0; i <N ;i++){
    cin >> C1[i].mark >> C1[i].num;//入力
  }
  for(int i =0; i<N; i++) C2[i] = C1[i]; //コピー
  
  BubbleSort(C1,N);
  print(C1,N);
  cout << "Stable" << endl;
  
  SelectionSort(C2,N);
  print(C2,N);
  
  bool flag = 0;
  for(int i=0; i<N; i++){
    if(C1[i].mark != C2[i].mark){

      flag = 1;
    }
  }
  if(flag){
    cout <<"Not stable"<< endl;
    return 0;
  }
  cout << "Stable"<<endl;
  
}


Measured memory_bytes: 3088
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

s=input()
n=len(s)
anslst=[0]*n

cnt=0
for i in range(n):
    if s[i]=="R":
        cnt+=1
    else:
        anslst[i]+=cnt//2
        anslst[i-1]+=(cnt+1)//2
        cnt=0

for i in range(n):
    if s[-i-1]=="L":
        cnt+=1
    else:
        anslst[-i-1]+=cnt//2
        anslst[-i]+=(cnt+1)//2
        cnt=0

print(*anslst)

Measured memory_bytes: 79904
n,y=map(int,input().split())
for i in range(n+1):
  for j in range(n+1):
    if (n-i-j) >= 0 and i*10000 + j*5000 + (n-i-j)*1000 == y:
      print(*[i,j,(n-i-j)])
      quit()
print("-1 -1 -1")

Measured memory_bytes: 67788
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

int main(){
	int a,b; cin >> a>> b;
	int ana= max({a+b,a-b,a*b});
	cout << ana << endl;
}

Measured memory_bytes: 256
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

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

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

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int n; cin >> n;
	vector<ll> a(n), v(2 * 100100);
	rep(i, n)
	{
		cin >> a[i];
		++v[a[i]];
	}
	ll res = 0;
	rep(i, 200010)res += v[i] * (v[i] - 1) / 2;
	rep(i, n)cout << res - (v[a[i]] - 1) << endl;
}

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

using namespace std;

#define ll long long 

const int N = 3e5+5;
const ll P = 998244353;
ll fac[N], p2[N];

ll pow(ll a, ll n) {
	ll b = 1;
	while (n) {
		if (n & 1LL) (b *= a) %= P;
		n >>= 1LL;
		(a *= a) %= P;
	}
	return b;
}

ll C(int n, int i) {
	if (n == i || i == 0) return 1;
	return fac[n] * pow(fac[i], P-2) % P * pow(fac[n-i], P-2) % P;
}

int main() {
	ll n, A, B, K;
	cin >> n >> A >> B >> K;

	if (K == 0) return puts("1"), 0;

	p2[0] = fac[0] = 1;
	for (int i = 1; i <= n; i++) {
		p2[i] = p2[i-1] * 2 % P;
		fac[i] = fac[i-1] * i % P;
	}
	
	ll ans = 0;
	for (int i = 0; i <= n; i++) {
		int j = (K - A * i) / B;
		if (j < 0 or j > n or A * i + B * j != K) continue;
		(ans += C(n, i) * C(n, j)) %= P;
	}

	cout << ans << endl;

	return 0;
}


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

int main() {
  string S,u,p;
  long long a,b,X,ans,g;
  cin>>S;
  g=0;
  p="keyence";
  a=S.size();
  for(int i=0;i<7;i++){
    u=S;
    for(int j=i;j<a-7+i;j++){
      u[j]='0';
    }
    for(int j=0;j<a;j++){
      if(u[j]=='0'){
        continue;
      }
      else if(u[j]!=p[g]){
        g=0;
        break;
      }
      else{
        g++;
        if(g==7){
          cout<<"YES"<<endl;
          return 0;
        }
      }
    }
  }
  cout<<"NO"<<endl;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const ll INF = 10e16;
const int maxN = 200010;
const int maxD = 15;
const int maxH = 100; 
const int MOD = 1000000007;


vector<string> ans;
vector<int> p;


int n,k;
ll a[maxN];
int b[maxN];
ll power(ll x,ll p)
{
	if(p == 0)
	{
		return 1;
	}
	ll t = power(x,p/2);
	t = t*t%MOD;
	if(p%2 == 1)
	{
		t = t*x%MOD;
	}
	return t;
}
int main()
{
	scanf("%d%d",&n,&k);
	ll tmp = power(10,100);
	for(int i=1;i<=n+1;i++)
	{
		a[i] = (tmp+i-1 + MOD)%MOD;
	}
	ll ans = 0;
	for(int i=k;i<=n+1;i++)
	{
		ll L = (ll)(i-1)*i/2;
		ll R = (ll)(2*n-i+1)*i/2;
		ans += (R-L+1);
		ans %= MOD;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5252
import sys
import bisect

if sys.platform in ['ios','win32','darwin']:
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

N = INT()
A = MAP()
A.sort()

amax = A.pop()
amid = bisect.bisect_left(A, amax/2)
if amid >= N-2:
	amid -= 1
# print(amax, A, amid)
a = A[amid]
b = A[amid-1]
if abs(amax/2 - A[amid]) < abs(amax/2 - A[amid-1]):
	print(amax, A[amid])
else:
	print(amax, A[amid-1])

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

int count(int x){
    int res = 0;
    while(x > 0){
        res++; x /= 10;
    }
    return res;
}

//ABC136
signed main(void){

    int n; cin >> n;
    int ans = 0;
    for(int i = 1; i <= n; i++){
        if(count(i) % 2 == 1)ans++;
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
int main(){
	int n;
	cin>>n;
	int a[n+2];
	a[0]=0;
	for (int i = 0; i < n; ++i)
	{
		scanf("%d",&a[i+1]);
	}	
	a[n+1]=0;
	int ans=0;
	for (int i = 1; i < n+2; ++i)
	{
		ans+=abs(a[i]-a[i-1]);
	}
	for (int i = 1; i < n+1; ++i)
	{
		printf("%d\n", ans-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1]));
	}
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#include <iterator>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(v) begin(v), end(v)
#define rreps(i, a, n) for (ll i = (a); i <= (ll)(n); ++i)
#define rrep(i, n) rreps(i, 0, n)
#define reps(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) reps(i, 0, n)
#define each(i, n) for (auto&& i : n)
#define fill(x, y) memset(x,y,sizeof(x))
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <typename T> inline void print(const T& x) {cout << x << '\n';}

signed main()
{ 
  int n; cin>>n;
  vi p(n);
  each(v,p) cin>>v;
  vi q(n);
  rep(i,n) q[p[i]-1]=i;
  int ans=1, tmp=1;
  rep(i,n-1)
  {
    if(q[i]<q[i+1]) 
    {
      tmp++;
      chmax(ans,tmp);
    }
    else tmp=1;
  }
  print(n-ans);

  return 0;
}


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

using ll=long long; 

void solve(){
	int n,m,x;
	cin>>n>>m>>x;
	vector<int> a(m);
	vector<bool> cost(n+1);
	for(int i=0; i<n+1; i++)cost[i]=0;
	for(auto&e:a){
		cin>>e;
		cost[e]=1;
	}
	int ans=0;
	for(int i=x+1; i<n+1; i++){
		ans+=cost[i];
	}
	int ans1=0;
	for(int i=x-1; i>=0; i--){
		ans1+=cost[i];
	}
	cout<<min(ans, ans1)<<endl;
}

signed main(){
	//while(1)
	solve();
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){

	int a[100],i,n;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(i=n-1;i>=0;i--){
		printf("%d",a[i]);
		if(i!=0)	printf(" ");
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 600
x,y,z,k = input().strip().split(' ')
x,y,z,k = [int(x), int(y),int(z),int(k)]
aList = list(map(int, input().strip().split(' ')))
bList = list(map(int, input().strip().split(' ')))
cList = list(map(int, input().strip().split(' ')))
ansList = []
# aList.sort(reverse = True)
# bList.sort(reverse = True)
# cList.sort(reverse = True)

abList = []
for i in range(len(aList)):
        for j in range(len(bList)):
                abList.append(aList[i] + bList[j])
abList.sort(reverse = True)
abcList = []
for s in range(min(len(abList),k)):
        for t in range(len(cList)):
                abcList.append(abList[s] + cList[t])
abcList.sort(reverse = True)
for a in range(min(len(abcList),k)):
        print(abcList[a])


Measured memory_bytes: 147904
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(998244353)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

// 素数かどうかの判定
bool IsPrime(ll num){
    if(num<2) return false;
    else if(num==2) return true;
    else if(num%2==0) return false; // 偶数はあらかじめ除く
    double sqrtNum = sqrt(num);
    for(ll i=3; i<=sqrtNum; i+=2){
        if(num%i==0) return false;
    }
    return true;
}


signed main() {
	string s,t; cin>>s>>t;
	int n=s.size();
	int ans=0;
	rep(i,n){
		if(s[i]!=t[i]) ans++;
	}
	cout<<ans<<endl;
	return 0;
}


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

typedef long long ll;
const ll mod=1e9+7;
const int N=200000;

void Run()
{
     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
int a[N];
set<int>v;
const double PI=acos(-1.0);

int main()
{
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    double th = (60*h+m)/720*2*PI;
    double tm = 2*PI*m/60;
    double ans = a*a + b*b - 2*a*b*cos(th-tm);
    ans = sqrt(ans);
    printf("%.10f\n", ans);

    return 0;
}



Measured memory_bytes: 4224
import java.util.*;
import java.io.*;
import java.math.BigInteger;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author prem_cse
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solution solver = new Solution();
        solver.solve(1, in, out);
        out.close();
    }

    static class Solution{
  
    	
        public void solve(int testNumber, FastReader sc, PrintWriter out) {
        
        	int n = sc.nextInt();
        	
        	int[] l = new int[n];
        	for(int i=0;i<n;++i) l[i] = sc.nextInt();
        	int ans = 0;
        	for(int i=0;i<n;++i) {
        		for(int j=i+1;j<n;++j) {
        			for(int k=j+1;k<n;++k) {
        				int a = l[i];
        				int b = l[j];
        				int c = l[k];
        				if(a!=b && b!=c && a!= c) {
        					if(a+b > c && a+c > b && b+c > a) ++ans;
        				}
        			}
        		}
        	}
        	out.print(ans);
        }

	
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader(InputStream stream) {
            br = new BufferedReader(new
                    InputStreamReader(stream), 32768);
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}



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

using namespace std;

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

#define ll long long

int main()
{
	int n, a, b;
	cin >> n;
	if (n == 1)
		cout << "Hello World" << endl;
	else {
		cin >> a >> b;
		cout << a + b << endl;
	}
}



Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

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

	if (K % 2 == 0) {
		cout << (K / 2) * (K / 2) << endl;
	}
	else {
		cout << (K / 2) * (K / 2 + 1) << endl;
	}
}


Measured memory_bytes: 3640
A,B,C,D,E,F = map(int,input().split())

water = [0] * (F//100 + 1)
water[0] = 1
for i in range(F//100 + 1):
  if water[i]:
    if i + A < F//100 + 1: water[i+A] = 1
    if i + B < F//100 + 1: water[i+B] = 1
water[0] = 0
#print(water)

suger = [0] * (F + 1)
suger[0] = 1
for i in range(F + 1):
  if suger[i]:
    if i + C < F + 1: suger[i+C] = 1
    if i + D < F + 1: suger[i+D] = 1
#print(suger)

max_sol = -1
answer = [0, 0]
for i in range(len(water)):
  if water[i] == 0:
    continue
  #print(i)
  for j in range(len(suger)):
    if suger[j] and i*100 + j <= F and j / (i*100 + j) <= E / (100 + E):
        if max_sol < 100 * j / (i*100 + j):
          max_sol = 100 * j / (i*100 + j)
          answer = [i*100 + j, j]
print(*answer)

Measured memory_bytes: 39664
/*
    WRITER:kakitamasziru
*/
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
//#include <unordered_map> // unordered_map
//#include <unordered_set> // unordered_set
#include <bitset> // bitset
//#include <cctype> // isupper, islower, isdigit, toupper, tolower
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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; }
const int INF = 1001001000;
const int MOD = 1000000007;
typedef pair<long,long> P;
//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}
long long nCr(long long n, long long r) {
    long long A = 1, B = 1;
    //Aが分子Bが1/r!
    //n!はi = 1;i<=nでする
    for (long long i = n-r+1; i <= n; i++) {
        A = A * i % MOD;
    }
    for (long long i = 1; i <= r; i++) {
        B = B * i % MOD;
    }
    B = mod_pow(B, MOD - 2);
    B %= MOD;
    //Bは割るのではなく掛ける
    return (A * B) % MOD;
}

int main() {
    int N;cin >> N;
    vector<int> retu(N);
    for(int i = 0;i<N;i++) cin >> retu.at(i);
    int ans = 0;
    int minimum = 11451419;
    for(int i = 0;i<N;i++){
        if(retu.at(i) < minimum){
            minimum = retu.at(i);
            ans++;
        }
        else if(retu.at(i) == 1) break;
    }
    cout << ans << endl;
    /*
    g++ abc.cpp
    ./a.out
    */
    return 0;
}

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

int cost[9]={2,5,5,4,5,6,3,7,6};

bool strCmpInt(string a,string b){
    if(a.length()>b.length()){
        return 0;
    }else if(a.length()<b.length()){
        return 1;
    }else{
        int n=a.length();
        for(int i=0;i<n;i++){
            if(a[i]>b[i]){
                return 0;
            }else if(a[i]<b[i]){
                return 1;
            }
        }
    }
    return 0;
}

int main(){
    int N,M;
    vector<int> canUse;
    cin>>N>>M;
    canUse.resize(M);
    for(int i=0;i<M;i++)cin>>canUse[i];
    vector<string> dp(N+1,"0");
    dp[0]="";
    for(int i=0;i<=N;i++){
        vector<string> candi;
        for(int m=0;m<M;m++){
            if(i>=cost[canUse[m]-1]&&dp[i-cost[canUse[m]-1]]!="0"){
                candi.push_back(dp[i-cost[canUse[m]-1]]+to_string(canUse[m]));
            }
        }
        if(candi.size()>0)dp[i]=*max_element(candi.begin(),candi.end(),strCmpInt);
    }
    cout<<dp[N]<<endl;
}


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

using namespace std;

struct BIT{
  vector<int>node;
  int sz;
  BIT(int sz):sz(sz){
    node.resize(sz,0);
  }
  int sum(int i){
    int res=0;
    for(i--;i>=0;i=(i&(i+1))-1)res+=node[i];
    return res;
  }
  void add(int i,int x){
    for(;i<sz;i|=i+1)node[i]+=x;
  }
  int sum(int l,int r){
    return sum(r)-sum(l);
  }
};

signed main(){
  int N;
  string S;
  cin>>N>>S;
  vector<BIT>bits;
  for(int i=0;i<26;i++)bits.push_back(BIT(N));
  for(int i=0;i<N;i++){
    bits[S[i]-'a'].add(i,1);
  }
  int Q;
  cin>>Q;
  for(int i=0;i<Q;i++){
    int q;
    cin>>q;
    if(q==1){
      int index;
      char c;
      cin>>index>>c;
      index--;
      bits[S[index]-'a'].add(index,-1);
      bits[c-'a'].add(index,1);
      S[index]=c;
    }
    if(q==2){
      int l,r;
      cin>>l>>r;
      l--,r--;
      int ans=0;
      for(auto&it:bits){
        ans+=min(it.sum(l,r+1),1);
      }
      cout<<ans<<endl;
    }
  }
  return 0;
}


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

int n,pd[100002],k;
bool seen[100002];
vector<int> A;
inline void mmin(int &a,int b){
    a = min(a,b);
}
int dp(int id){
    if(id==n-1) return 0;
    if(seen[id]) return pd[id];
    for(int j=1;j<=k and j+id<=n-1;j++)
        mmin(pd[id],dp(id+j)+abs(A[id]-A[id+j]));
    seen[id]=true;
    return pd[id];
}

int main(){
    memset(pd,63,sizeof pd);
    cin >> n >> k;
    A = vector<int> (n);
    for(auto &a:A) cin >> a;
    cout << dp(0) << '\n';
}


Measured memory_bytes: 5888
#include "bits/stdc++.h"
using namespace std;
#define rep(i, N) for (int (i) = 0; (i) < (N); (i)++)
typedef pair<long long, long long> P;

int main() {
	long long A, B, C; cin >> A >> B >> C;
	long long K; cin >> K;
	long long ans = 0;
	ans += min(K, A);
	if (K <= A) {
		cout << ans << endl;
		return 0;
	}
	K -= A;
	if (K <= B) {
		cout << ans << endl;
		return 0;
	}
	K -= B;
	if (K <= C) {
		cout << ans - K << endl;
		return 0;
	}
}

Measured memory_bytes: 3636
N, W = [int(x)for x in input().split()]
items = []
for i in range(N):
    items.append(tuple(int(x) for x in input().split()))
dp = [0]*(W+1)
# print(items)
for i in range(N):
    v, w = items[i]
#     print(W,w-1)
    for j in range(w,W+1):
        dp[j] = max(dp[j],dp[j-w]+v)
       

print(dp[-1])
    


Measured memory_bytes: 5724
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
	int n,t,a,h,ans;
	double ans1=100000;
	cin>>n>>t>>a;
	for(int i=0;i<n;i++){
		cin>>h;
		if(ans1>abs(a-(t-h*0.006))){
			ans=i+1;
			ans1=abs(a-(t-h*0.006));
		}
	}
	cout<<ans<<endl;
	return(0);
}

Measured memory_bytes: 3576
nums = [int(e) for e in input().split()]
W = nums[0]
H = nums[1]
x = nums[2]
y = nums[3]
r = nums[4]
if 0 + r <= x and 0 + r <= y and W - r >= x  and H - r >= y:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 5604
a = list(input())
b = list(input())
c = list(input())
x = a[0]
a.pop(0)
while True:
    if x == "a" and len(a) > 0:
        x = a.pop(0)
    elif x == "a":
        print("A")
        exit()
    elif x == "b" and len(b) > 0:
        x = b.pop(0)
    elif x == "b":
        print("B")
        exit()
    elif x == "c" and len(c) > 0:
        x = c.pop(0)
    elif x == "c":
        print("C")
        exit()

Measured memory_bytes: 3064
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
#include <numeric>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define vi vector<int>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define fi first
#define se second

void print(bool a)
{
    if (a == true)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

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

int main()
{
    int a, b;

    cin >> a >> b;

    if (a == b)
        cout << 2 * a << endl;
    else
        cout << 2 * max(a, b) - 1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

const int big = 10000;
int main(){
  int n, T;
  cin >> n >> T;
  int cost = big;
  rep(i, n){
    int s, t;
    cin >> s >> t;
    if (t <= T) cost = min(cost, s);
  }
  if (cost == big) cout << "TLE" << endl;
  else cout << cost << endl;
  
  return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define sz 300005
#define faster_io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;


int main()
{
    faster_io;
    int n,l,sum=0,sum1;
    cin>>n>>l;
    int a[n+5];

    for(int i=1;i<=n;i++){
//        cout<<a[i]<<" ";
        sum+=(l+i-1);
        a[i] = l+i-1;
    }

//    cout<<sum<<endl;
    int mn = abs(sum),ans;
    for(int i=1;i<=n;i++){
        sum1 = sum-a[i];
//        cout<<sum<<" "<<sum1<<endl;
        if(abs(sum1-sum)<=mn){
            mn = abs(sum1-sum);
            ans = sum-a[i];
        }
    }

    cout<<ans<<endl;




    return 0;
}






Measured memory_bytes: 256