akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
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; }
const ll INF = 1e18;

ll n,a,b;
vector<ll>h;

bool enough(ll t){
    ll s = 0;
    rep(i,n){
        if(h[i]-b*t <= 0)continue;
        ll x = (h[i]-b*t+a-b-1)/(a-b);
        s += x;
    }
    if(s>t)return false;
    else return true;
}

// 汎用的な二分探索のテンプレ
int binary_search() {
    int ng = 0; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int ok = 1e9+5; // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (enough(mid)) ok = mid;
        else ng = mid;
    }
    return ok;
}


int main(){
    cin >> n >> a >> b;
    h.resize(n);
    rep(i,n)cin>>h[i];
    cout << binary_search() << endl;
    return 0;
}


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

int main()
{
  stack<int> trains;
  int i;
  do
  {
    cin >> i;
    if (i != 0) trains.push(i);
    else
    {
      if (trains.empty()) break;
      cout << trains.top() << endl;
      trains.pop();
    }
  } while (true);
  return 0;
}

Measured memory_bytes: 1200
Array.(Scanf.scanf" %d %d %d %d %d %d"@@fun a b c d e f->
	let r=ref (0.,(100*a,0)) in
	for i=0 to 32 do
		for j=0 to 32 do
			for k=0 to 103 do
				for l=0 to 103 do
					let w,s=100*a*i+100*b*j,c*k+d*l in
					if w+s<=f && w/100*e>=s && w+s<>0 then
						let d=100. *. (float s) /. (float w +. float s) in
						if d>fst !r then r:=(d,(w+s,s)) done;done;done;done;
	Printf.printf "%d %d\n" (fst@@snd !r) (snd@@snd !r))

Measured memory_bytes: 2688
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

# 
# a, b = map(int, input().split())
# 

n = int(input())
s = input()

r = 0
b = 0
for c in s:
    if c == "R":
        r += 1
    else:
        b += 1
if r > b:
    print("Yes")
else:
    print("No")


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

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

int main()
{
	string a, b, c;
	cin >> a >> b >> c;

	if(a[a.size()-1] == b[0] && b[b.size()-1] == c[0]) cout << "YES" << "\n";
	else cout << "NO" << "\n";

	return 0;

}

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

monsters = A[:]
while True:
    a_min = min(monsters)
    monsters = [m % a_min for m in monsters if m % a_min != 0]
    if len(monsters) == 0:
        print(a_min)
        break
    else:
        monsters.append(a_min)

Measured memory_bytes: 14224
S = str(input());T = str(input())
N = len(S)
M = len(T)
ans = M
for i in range(N-M+1):
  kouho = S[i:i+M]
  temp = 0
  #print(kouho,T)
  for j in range(M):
    if kouho[j] != T[j]:
      temp += 1
  ans = min(ans,temp)
print(ans)

Measured memory_bytes: 9068
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int c[3][3] = {0};
    rep(i, 3) rep(j, 3) cin >> c[i][j];
    int a[3] = {0};
    int b[3] = {0};
    a[0] = 0;
    b[0] = c[0][0] - a[0];
    b[1] = c[0][1] - a[0];
    b[2] = c[0][2] - a[0];
    a[1] = c[1][0] - b[0];
    a[2] = c[2][0] - b[0];
    int flg = 0;
    rep(i, 3) rep(j, 3) {
        if (a[i] + b[j] != c[i][j]) flg = 1;
        
    }
    if (flg == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <numeric>
using namespace std; 
 
int main(void){
    long long a,s,d ; cin >> a >> s >> d;
    if (a>=d){
        cout << a-d << " " << s << "\n";
    }
    else if (d<a+s){
        cout << "0" << " " << s-(d-a) << "\n";
    }
    else{
        cout << "0 0" << "\n";
    }
}

  


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=100005,p=1000000007;
int read(){
	int f=1,g=0;char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int n,fl,f[N],cur[3];
void check(int &x,int y){if ((x+=y)>=p) x-=p;}
char ch[N];
int main(){
	scanf("%s",ch+1);
	n=strlen(ch+1);fl=0;
	for (int i=1;i<n;i++)
	if (ch[i]==ch[i+1]) fl=1;
	if (!fl){puts("1");return 0;}
	f[0]=1;cur[0]=0;cur[1]=cur[2]=-1;
	int s=0;
	for (int i=1;i<=n;i++){
		s=(s+ch[i]-'a'+1)%3;
		cur[s]=i;
		if ((!s)&(i<n)) f[i]=1;
		if (cur[(s+1)%3]>=0) check(f[i],f[cur[(s+1)%3]]);
		if (cur[(s+2)%3]>=0) check(f[i],f[cur[(s+2)%3]]);
	}
	printf("%d\n",f[n]);
	return 0;
}

Measured memory_bytes: 768
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    public static bool f = false, t = true;
    static void Main(string[] args)
    {
        long n = long.Parse(Console.ReadLine());
        long[] a = Read.longs();
        long ans = (long)Math.Pow(3, n);
        long h = 1;
        for (int i = 0; i < a.Length; i++)
        {
            if (a[i] % 2 == 0) { h *= 2; }
        }
        Console.WriteLine(ans-h);
        
    }
    public static long gcd(long a, long b)
    {
        while (true)
        {
            if (a == 0) { return b; }
            if (b == 0) { return a; }
            if (a > b) { a -= b; }
            else { b -= a; }
        }
    }
    public static long lcm(long a, long b) { return a / gcd(a, b) * b; }
    public static bool IsPrime(long n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        for (long i = 2; i < n; i++) { if (n % i == 0) return false; }
        return true;
    }
}
public static class Read
{
    public static void outl(string n = "") { Console.WriteLine(n); return; }
    public static long Long() { return long.Parse(Console.ReadLine()); }
    public static long[] longs() { return Console.ReadLine().Split().Select(long.Parse).ToArray(); }
    public static int Int() { return int.Parse(Console.ReadLine()); }
    public static int[] ints() { return Console.ReadLine().Split().Select(int.Parse).ToArray(); }
    public static string Str() { return Console.ReadLine(); }
    public static string[] Strs() { return Console.ReadLine().Split(); }
}

Measured memory_bytes: 13524
while True:
    n,k=map(int,input().split())

    if n==k==0:
        break
    x=[int(input())]
    
    for i in range(n-1):
        y=int(input())
        x.append(x[i]+y)
    
    maxx=x[0]
    
    for i in range(n-k):
        maxx=max(maxx,x[i+k]-x[i])
    
    print(maxx)


Measured memory_bytes: 9648
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  int N, A = 0, B = 0;

  std::cin>> N;

  std::vector<int> a(N);

  for (auto& i : a)
    std::cin >> i;

  std::sort(ALL(a));
  
  for (int i = 0; ! a.empty(); i = (i + 1) % 2, a.pop_back())
    (i == 0 ? A : B) += a.back();

  std::cout << A - B << std::endl;

  return 0;
}


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

const int N = 3e5 + 9;

int32_t main()
{
    long long n, ans = 0;
    cin >> n;
    ans += n / 500 * 1000;
    n %= 500;
    while(n >= 5) ans += 5, n-= 5;
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<limits.h>
#define MAX 101

int p[MAX];
int min[MAX][MAX];
int mini(int,int);
void cal(int);
int main(){
  int n,i,j,m,num;
  scanf("%d",&num);
  for(i=0;i<num;i++){
    p[i]=0;
  }
  for(i=0;i<num;i++){
    scanf("%d %d",&n,&m);
    if(i==num-1){
      p[i]=n;
      p[i+1]=m;
    }
    else{
      p[i]=n;
}
}

cal(num);
 
printf("%d\n",min[1][num]);  
return 0;
}
void cal(int s){
  int i,j,l,k,q;
  for(i=1;i<=s;i++){
    min[i][i]=0;
  }

  for(l=2;l<=s;l++){
    for(i=1;i<=s-l+1;i++){
      j=i+l-1;
      min[i][j]=INT_MAX;
      for(k=i;k<=j-1;k++){
	q=min[i][k]+min[k+1][j]+p[i-1]*p[k]*p[j];

	min[i][j]=mini(min[i][j],q);
      }
    }
  }
}
int mini(int a,int b){
  if(a>b){
    return b;
  }

}



Measured memory_bytes: 2108
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;

int main(){
   int n;cin>>n;
   vector<int> v(n),dp(n,2e9);
   for(int i=0;i<n;i++)cin>>v[i];
   dp[0]=0;
   for(int i=1;i<n;i++){
     dp[i]=min(dp[i-1]+abs(v[i]-v[i-1]),dp[i]);
     if(i-2>=0)dp[i]=min(dp[i],dp[i-2]+abs(v[i-2]-v[i]));
   }
   cout<<dp[n-1];
    
}

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

using namespace std;

const long long MOD = 1e9 + 7;

int main(){
  string S;
  cin >> S;
  int n = S.size();

  vector<long long> p3(n + 1);
  p3[0] = 1;
  vector<long long> a(n, 0);
  vector<long long> c(n, 0);
  vector<long long> q(n, 0);
  for(int i = 0; i < n; i++){
    p3[i + 1] = p3[i] * 3 % MOD;
    if(S[i] == 'A') a[i] = 1;
    if(S[i] == 'C') c[i] = 1;
    if(S[i] == '?') q[i] = 1;
  }
  for(int i = 1; i < n; i++){
    a[i] += a[i - 1];
    c[i] += c[i - 1];
    q[i] += q[i - 1];
  }
  
  long long count = 0;
  for(int i = 1; i < n - 1; i++){
    if(S[i] == 'B' || S[i] == '?'){
      int bq = S[i] == '?' ? 1 : 0;
      count += a[i - 1] * (c[n - 1] - c[i]) % MOD * p3[q[n - 1] - bq] % MOD;
      count %= MOD;
      count += q[i - 1] * (c[n - 1] - c[i]) % MOD * p3[q[n - 1] - 1 - bq] % MOD;
      count %= MOD;
      count += a[i - 1] * (q[n - 1] - q[i]) % MOD * p3[q[n - 1] - 1 - bq] % MOD;
      count %= MOD;
      count += q[i - 1] * (q[n - 1] - q[i]) % MOD * p3[q[n - 1] - 2 - bq] % MOD;
      count %= MOD;
    }
  }
  
  cout << count << endl;
  
  return 0;
}

Measured memory_bytes: 3584
n, m = map(int, input().split())
p = []
s = []

for i in range(0, m):
    pi, si = map(str, input().split())
    p.append( int(pi) )
    s.append( si )


done = []
for i in range(0,n):
    done.append(False)
wa_num = []
for i in range(0,n):
    wa_num.append(0)

ac = 0
for i in range(0, m):
    num = p[i] - 1
    if not done[num]:
        if s[i] == 'WA':
            wa_num[num] += 1
        else: # 'AC':
            ac += 1
            done[num] = True

wa = 0
for i in range(0,n):
    if done[i]:
        wa += wa_num[i]

print(ac, wa)


Measured memory_bytes: 15008
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int N;
  cin >> N;
  VEC<LL> A(N);
  REP(i, 0, N) cin >> A[i];
  VEC<LL> cs(N, 0);
  VEC<LL> rcs(N, 0);
  cs[0] = A[0];
  rcs[0] = A[N - 1];
  REP(i, 1, N) {
    cs[i] = cs[i - 1] + A[i];
    rcs[i] = A[N - 1 - i] + rcs[i - 1];
  }
  LL ans = LLONG_MAX;
  REP(i, 1, N) {
    LL c = abs(cs[i - 1] - rcs[N - i - 1]);
    ans = min(ans, c);
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 5504
H, W = map(int, input().split())
a, b = [], []
ans = 0
for _ in range(H):
    a += [0 if x == '.' else 1 for x in input()]
for i in range(H*W):
    if a[i] == 0:
        if i % W != 0: ans += a[i-1]
        if (i+1) % W != 0: ans += a[i+1]
        if i < (H-1)*W: ans += a[i+W]
        if i < (H-1)*W and i % W != 0: ans += a[i+W-1]
        if i < (H-1)*W and (i+1) % W != 0: ans += a[i+W+1]
        if W <= i: ans += a[i-W]
        if i % W != 0 and W <= i: ans += a[i-W-1]
        if W <= i and (i+1) % W != 0: ans += a[i-W+1]
        b += [str(ans)]
        ans = 0
    else:
        b += ['#']
        
for i in range(H):
    print(''.join(b[W*i:W*(i+1)]))



Measured memory_bytes: 9256
using System;


class Game
{
	static public void Main(string[] args)
	{
		string s = Console.ReadLine();
		if(s[0] == s[s.Length-1])
		{
			if(s.Length % 2 == 0)
			{
				Console.WriteLine("First");
			}
			else
			{
				Console.WriteLine("Second");
			}
		}
		else
		{
			if(s.Length % 2 == 0)
			{
				Console.WriteLine("Second");
			}
			else
			{
				Console.WriteLine("First");
			}
		}
	}
}


Measured memory_bytes: 13280
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

int main()
{
   int x,a,b;
   cin >> x >> a >>b;
   if(b-a<=0)
   {
      cout<<"delicious"<<endl;
      return 0;
   }
   if(b-a>x)
   {
      cout<<"dangerous"<<endl;
   }
   else
   {
      cout<<"safe"<<endl;
   }
   
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

double a,b,n,m;

int main(){
	cin>>a>>b>>n>>m;
	double x=a*cos(2*pi*(n*60+m)/720),y=a*sin(2*pi*(n*60+m)/720);
	double X=b*cos(pi*m/30),Y=b*sin(pi*m/30);
	x=fabs(x-X),y=fabs(y-Y);
	cout<<syosu(11)<<sqrt(x*x+y*y)<<endl;
}

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

using namespace std;

typedef pair<int,int> pi;

int main() {
    int n;
    cin >> n;
    int tmp;
    vector<int> a;

    for(int i = 0; i < n; i++) {
        cin >> tmp;
        if(a.size() == 0 || tmp != a[a.size()-1]) {
            a.push_back(tmp);
        }
    }

    priority_queue<pi, vector<pi>, greater<pi>> minmax;
    for(int i = 0; i < a.size(); i++) {
        if(i >= 2) {
            if(a[i-2] < a[i-1] && a[i] < a[i-1]) {
                minmax.emplace(i-1, -1);
            }else if(a[i-2] > a[i-1] && a[i] > a[i-1]) {
                minmax.emplace(i-1, 1);
            }
        }
    }

    if(a[0] < a[1]) minmax.emplace(0, 1);

    if(a[a.size()-1] > a[a.size()-2]) minmax.emplace(a.size()-1, -1);

    long long m = 1000;
    long long stock = 0;
    while(!minmax.empty()) {
        auto [pos, sign] = minmax.top();
        minmax.pop();
        if(sign > 0 && !minmax.empty()) {
            stock += m / a[pos];
            m = m % a[pos];
        }else {
            m += stock * a[pos];
            stock = 0;
        }
    }

    cout << m << endl;
}

Measured memory_bytes: 3624
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next(), t = sc.next();
		int N = s.length();
		HashMap<Character, Character> StoT = new HashMap<>(s.length());
		HashMap<Character, Character> TtoS = new HashMap<>(t.length());
		for (int i = 0; i < N; i++) {
			// First Observation for every character in S they can only map to one unique
			// character of T
			if (StoT.containsKey(s.charAt(i)) && StoT.get(s.charAt(i)) != t.charAt(i)) {
				System.out.println("No");
				return;
			}
			// Second Observation for every character in T they can only map to one unique
			// character of S
			if (TtoS.containsKey(t.charAt(i)) && TtoS.get(t.charAt(i)) != s.charAt(i)) {
				System.out.println("No");
				return;
			}
			StoT.put(s.charAt(i), t.charAt(i));
			TtoS.put(t.charAt(i), s.charAt(i));
		}
		System.out.println("Yes");
	}
}

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

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  for (int i=0; i<n; i++) {
    cin >> h.at(i);
  }
  for (int i=n-1; i>0; i--) {
  	if (h.at(i-1) == h.at(i)+1) {
    	h.at(i-1) -= 1;
    }else if (h.at(i-1) > h.at(i)) {
    	cout << "No" << endl;
      	return 0;
    }
  }
  
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 640
use proconio::input;
use std::f64::consts::PI;

#[proconio::fastout]
fn main() {
    input! {
    A:f64,
    B:f64,
    H:f64,
    M:f64,
    }
    let radH = 2.0 * PI * (60.0 * H + M) / (12.0 * 60.0);
    let radM = 2.0 * PI * M / 60.0;
    let drad = (radH - radM).abs();
    //(A,0) (B*cos,B*sin)
    let dx = (A - B * drad.cos()).abs();
    let dy = B * drad.sin().abs();
    let ans = (dx * dx + dy * dy).sqrt();
    println!("{}", ans);
}


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

int main() {
  int a,b,c;
  cin >>a>>b>>c;

  if (a==b) {
    cout <<c<< endl;
  }
  else if(a==c){
  cout <<b<< endl;
  }
  else if(b==c){
    cout<<a<<endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>

void insertion(int a[], int n)
{
	int i, j, k;
	for(i=1;i<n;i++){
		int tmp=a[i];
		for(j=i;j>0&&a[j-1]>tmp;j--){
			a[j]=a[j-1];
		}
			a[j]=tmp;
			for(k=0;k<n;k++){
				if(k<n-1)
					printf("%d ",a[k]);
				else
					printf("%d\n", a[k]);
			}
	}
}
//#define N 6
int main()
{
	int N, i;
	scanf("%d", &N);
	int a[N];
	
	
	for(i=0;i<N;i++){
		scanf("%d", &a[i]);
	}
	
	for(i=0;i<N;i++){
		if(i<N-1)
			printf("%d ", a[i]);
		else
			printf("%d\n", a[i]);
	}
	
	insertion(a, N);
	
	return 0;
}


Measured memory_bytes: 2060
#include<stdio.h>

void swap(int& a, int& b) {
    int tmp = a;
    a = b;
    b  = tmp;
}

int main() {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    
    if (a > b) swap(a, b);
    if (b > c) swap(b, c);
    if (a > b) swap(a, b);
    
    printf("%d %d %d\n", a, b, c);
}


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

int main(){
    int N; cin >> N;
    string S; cin >> S;
    int ans = 0;
    rep(i,N-2){
        if(S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C') ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    // Your code here!
    int N;
    int num[1001]={};
    long long ans = 1;
    
    scanf("%d",&N);
    
    for(int i = 2;i<=N;i++){
        int n = i;
        int j = 2;
        while(n != 1){
            while(n % j == 0){
                num[j]++;
                n /= j;
            }
            j++;
        }
    }
    
    for(int i = 2;i<=N;i++){
        if(num[i] > 0){
            //printf("i-%d:%d\n",i,num[i]);
            ans = (ans * (num[i]+1)) % 1000000007;
            
        }
    }
    
    printf("%lld\n",ans);
}


Measured memory_bytes: 128
def solve():
    S = list(input())
    T = list(input())

    tmp_S = S

    num = 0

    for k in range(len(S) - len(T) + 1):
        tmp_n = 0
        for i in range(len(T)):
            if tmp_S[i] == T[i]:
                tmp_n += 1
        #        print(tmp_n)
        if num <= tmp_n:
            num = tmp_n
        del tmp_S[0]

    ans = len(T) - num

    print(ans)

if __name__ == "__main__":
    solve()

        


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

int main() {
  ll N;
  cin >> N;
  vector<ll> MARCH(5,0);
  for (ll i = 0; i < N; i++) {
    string s;
    cin >> s;
    if (s[0] == 'M') MARCH[0] += 1;
    if (s[0] == 'A') MARCH[1] += 1;
    if (s[0] == 'R') MARCH[2] += 1;
    if (s[0] == 'C') MARCH[3] += 1;
    if (s[0] == 'H') MARCH[4] += 1;
  }
  ll pat = 0;
  for (int i = 0; i < 5; i++) {
    for (int j = i+1; j < 5; j++) {
      for (int k = j+1; k < 5; k++) {
        pat += MARCH[i]*MARCH[j]*MARCH[k];
      }
    }
  }
  cout << pat << endl;
}

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

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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second　//pairの二つ目の要素


int main(){
    int h1,m1,h2,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    int st=h1*60+m1;
    int en=h2*60+m2-k;
    cout<<en-st<<endl;
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <cstring>
#include <queue>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cstdlib>

using namespace std;

//#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

typedef long long ll;
typedef pair<ll, ll> P;

//const int MAX = 700000;
//static const ll MOD = 1000000007;
//static const ll INF = 100000000;

int main() {
    ll m1, m2, d1, d2;


    // input
    cin >> m1 >> d1 >> m2 >> d2;

    // process
    if (m1 != m2) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>  // std::unique
#include <cmath>
#include <limits.h>
#include <unordered_map>
using namespace std;

using ll = long long;
constexpr auto PrimeBigNum10_9_7 = 1000000007;

// 素数判定
template <typename T>
bool IsPrimeNumber(T value) {

	for (int i = 2; i * i <= value; ++i) {
		if ((value % i) == 0) {
			return true;
		}
	}
	return false;
}

// 桁数判定
template <typename T>
T GetFigureLength(T value) {
	T figure = 1;
	while (value >= 10) {
		value /= 10;
		++figure;
	}
	return figure;
}

// 素因数分解結果
template <typename T>
map<T, T> GetPrimeFactorize(T value) {

	map<T, T> res;

	for (T i = 2; i * i <= value; ++i) {
		if ((value%i) != 0)	continue;

		T count = 0;
		while ((value % i) == 0) {
			value /= i;
			++count;
		}

		res[i] = count;
	}

	if (value != 1) {
		res[value] = 1;
	}
	return res;
}

struct ReferenceBook {
	int price;
	vector<ll> understandings;

	bool isUnderstandOK(ll understand) {
		for (auto itr = understandings.begin(); itr != understandings.end(); ++itr) {
			if (*itr < understand)	return false;
		}

		return true;
	}
	void Print() {
		cout << price << endl;
	}
};

ll ansPrice = LLONG_MAX;

void func(ll index, const vector<ReferenceBook>& referenceBooks, ReferenceBook& ans, ll understand) {

	if (ans.isUnderstandOK(understand)) {
		//ans.Print();
		if (ansPrice > ans.price) {
			ansPrice = ans.price;
		}
		return;
	}
	if (index >= referenceBooks.size())	return;

	func(index + 1, referenceBooks, ans, understand);

	auto tmpAns = ans;
	tmpAns.price += referenceBooks[index].price;
	for (int i = 0; i < referenceBooks[index].understandings.size(); ++i) {
		tmpAns.understandings[i] += referenceBooks[index].understandings[i];
	}
	func(index + 1, referenceBooks, tmpAns, understand);

}

void test() {
	int n = 5;

	// {0, 1, ..., n-1} の部分集合の全探索
	for (int bit = 0; bit < (1 << n); ++bit) {
		vector<int> S;
		for (int i = 0; i < n; ++i) {
			if (bit & (1 << i)) { // 列挙に i が含まれるか
				S.push_back(i);
			}
		}

		cout << bit << ": {";
		for (int i = 0; i < (int)S.size(); ++i) {
			cout << S[i] << " ";
		}
		cout << "}" << endl;
	}
}

int main(void) {

	//test();
	
	string n;
	cin >> n;
	vector<ll> values;

	for (int i = 0; i < n.size(); ++ i) {
		values.push_back(n[i] - '0');
	}

	ll point = values.size()-1;

	ll ans = 0;
	for (ll bit = 0; bit < (1U << point); ++bit) {
		std::vector<bool> s(point, false);
		for (int i = 0; i < point; ++i) {
			if (bit & (1U << i)) {
				s[i] = true;
			}
		}

		ll tmp = 0;
		for (int i = 0; i < point; ++i) {
			tmp += values[i];
			if (s[i]) {
				ans += tmp;
				tmp = 0;
			}
			tmp *= 10;
		}
		tmp += values[point];
		ans += tmp;

		/*cout << bit << ": {";
		for (int i = 0; i < (int)s.size(); ++i) {
			cout << (s[i]?"+" :" ") << " ";
		}
		cout << "}" << endl;*/
	}

	auto output = ans;
	cout << output;

	return 0;
}


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

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

using namespace std;
using ll = long long;
int mod = 1000000007;

int main(void){
    int N; ll lim;
    cin >> N >> lim;
    vector<int> val[4];
    ll w1;
    rep(i, N){
        ll w; int v; cin >> w >> v;
        if(i == 0) w1 = w;
        val[w-w1].push_back(v);
    }
    sort(val[0].begin(), val[0].end(), greater<int>());
    sort(val[1].begin(), val[1].end(), greater<int>());
    sort(val[2].begin(), val[2].end(), greater<int>());
    sort(val[3].begin(), val[3].end(), greater<int>());
    int accX[val[0].size()+1] = {};
    int accY[val[1].size()+1] = {};
    int accZ[val[2].size()+1] = {};
    int accW[val[3].size()+1] = {};
    for(int i = 1; i <= val[0].size(); i++) accX[i] = accX[i-1]+val[0][i-1];
    for(int i = 1; i <= val[1].size(); i++) accY[i] = accY[i-1]+val[1][i-1];
    for(int i = 1; i <= val[2].size(); i++) accZ[i] = accZ[i-1]+val[2][i-1];
    for(int i = 1; i <= val[3].size(); i++) accW[i] = accW[i-1]+val[3][i-1];
    //たとえばw_0の重さをk個使うときはaccX[k]の価値になる

    int ans = 0;
    rep(X, val[0].size()+1){
        rep(Y, val[1].size()+1){
            rep(Z, val[2].size()+1){
                rep(W, val[3].size()+1){
                    ll weight = X*w1 + Y*(w1+1) + Z*(w1+2) + W*(w1+3);
                    int val = accX[X] + accY[Y] + accZ[Z] + accW[W];
                    if(weight <= lim && val > ans){
                        ans = val;
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
	int64_t L, R;
	scanf("%lld%lld", &L, &R);
	if (L / 2019 < R / 2019)
	{
		L %= 2019;
		R %= 2019;
		R += 2019;
	}
	else
	{
		L %= 2019;
		R %= 2019;
	}
	int64_t min{1000000};
	for (int64_t i{L}; i < R; i++)
		for (int64_t j{i + 1}; j <= R; j++)
			min = std::min(min, i * j % 2019);
	printf("%lld\n", min);

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
#define MAX 1000000


int main(){
	bool work[MAX];
	int num;

	// 初期化
	for(int i = 0; i < MAX; i++){
		if(i < 2){
			work[i] = false;
		}else{
			work[i] = true;
		}
	}

	// エラトネスのふるい
	for(int i = 2; i < sqrt((double)MAX) + 1; i++){
		if(work[i] == true){
			for(int j = i * 2; j < MAX; j += i){
				work[j] = false;
			}
		}
	}

	// 入力
	while( cin >> num){
		int ans = 0;

		// 計算
		for(int i = 0; i <= num; i++){
			if(work[i] == true){
				ans++;
			}
		}
		// 出力
		cout << ans << endl;

	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <iostream>
#include <string.h>
using namespace std;
int main(void)
{
    long long int a;
    double b;
    cin >> a;
    cin >> b;
    long long int bi = (long long int)(( b + 0.00001) * 100);

    cout << (a * bi / 100);
}

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

using namespace std;
typedef long long ll;

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

  int ans = 0;
  for (int i = 1000; i <= 1999; ++i) {
    int cur = -1;
    string tmp = to_string(i);
    for (int j = 1; j <= 3; ++j) {
      cur++;
      while (cur < n) {
	if ((s[cur]) == tmp[j]) break;
	cur++;
      }
    }
    if (cur < n) ans++;
  }

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


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
    int r,g,b;
    int res;
    cin >> r >> g >> b;
    
    res = 100*r + 10*g + b;
    
    if(res % 4 ==0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3532
#include <bits/stdc++.h>
using namespace std;
int getComp(vector<int>& comp,int i){
  if(comp[i] != i) comp[i] = getComp(comp,comp[i]);
  return comp[i];
}
void merge(vector<int>& comp,vector<int>& level,int a,int b){
  a = getComp(comp,a);
  b = getComp(comp,b);
  if(level[a] > level[b]) swap(a,b);
  else if(level[a] == level[b]) ++level[b];
  comp[a] = b;
}
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n,m,x,y,z;
  cin >> n >> m;
  vector<int> comp(n+1),level(n+1);
  iota(begin(comp),end(comp),0);
  while(m--){
    cin >> x >> y >> z;
    merge(comp,level,x,y);
  }
  set<int> st;
  for(int i = 1; i <= n; ++i) st.insert(getComp(comp,i));
  cout << st.size();
  return 0;
}


Measured memory_bytes: 5760
#include<iostream>
using namespace std;
int n, m, a, b, p[30000];
int main() {
	while (true) {
		cin >> n >> m >> a >> b; if (n == 0)break;
		for (int i = 0; i < 30000; i++)p[i] = 0;
		int L = 10, R = n;
		for (int i = 0; i < 30000; i++) { p[i] += L / R; L = L%R; L *= 10; }
		if (a == 1) {
			for (int i = 1; i < n; i++) {
				int L = 10, R = i*n;
				for (int j = 0; j < 30000; j++) { p[j] += L / R; L = L%R; L *= 10; }
			}
		}
		for (int i = 29999; i > 0; i--) { p[i - 1] += p[i] / 10; p[i] %= 10; }p[0] %= 10;
		if (n - a < 2)cout << "1."; else cout << "0.";
		for (int i = 0; i < b; i++)cout << p[i]; cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3196
import re
import math

if __name__ == '__main__':

    h, w = [int(x) for x in input().split()]
    s = list()
    for i in range(h):
        tmp = list(input())
        s.append(tmp)

    for i in range(h):
        for j in range(w):
            if s[i][j] == '#':
                flg_none = True
                if i != 0 and s[i-1][j] == '#': 
                    continue
                if i != h-1 and s[i+1][j] == '#':
                    continue
                if j != 0 and s[i][j-1] == '#':
                    continue
                if j != w-1 and s[i][j+1] == '#':
                    continue

                print('No')
                exit(0)

    print('Yes')




Measured memory_bytes: 3316
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

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

int main() {
  int n,sum=0;
  cin>>n;
  int A[n];
  rep(i,n){
    int x;
    cin>>x;
    A[i]=x;
    sum+=x;
  }
  
  int min=10010;
  int sum1 = 0;
  for(int i=0;i<n-1;i++){
    sum1 += A[i];
    chmin(min,abs(sum-sum1*2));
  }
  
  cout << min <<endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  	int input;
  	cin >> input;
  	int output = 0;
  	while (input>=500) {
    	output += 1000;
      	input -= 500;
    }
  	while (input>=5) {
    	output += 5;
      	input -= 5;
    }
  	cout << output << endl;
	return 0;
}

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

int gcd(int a, int b) {
  int r;
  r = b%a;
  while (r != 0) {
    b = a;
    a = r;
    r = b%a;

  }
  return a;
}

int main() {
  int N, X;
  int A[100000];
  int tmp;

  cin >> N >> X;

  for (int i = 0; i < N; i++) cin >> A[i];
  for (int i = 0; i < N; i++) A[i] = abs(A[i] - X);

  sort(A, A+N);
  tmp = A[0];

  for (int i = 0; i < N - 1; i++) {
    tmp = gcd(tmp, A[i + 1]);
  }

  cout << tmp << endl;
  return 0;
}


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

int main(){

	int N,K;
	cin>>N>>K;
	
	vector<double> p(N+1,0.0);
	
	for(int i=1;i<=N;i++){
		cin>>p[i];
		p[i] = (1.0+p[i])/2.0;
		p[i] += p[i-1];
	}
	double ans = 0.0;
	for(int i=K;i<=N;i++){
		ans = max(ans,p[i] - p[i-K]);
	}
	
	cout<<fixed<<setprecision(10)<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	string t,s,u;
	cin>>t>>s;
	int a,b;
	cin>>a>>b;
	cin>>u;
	if(t==u)a--;
	if(s==u)b--;
	cout<<a<<" "<<b;
	// your code goes here
	return 0;
}

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

bool is_p(string s, int a, int b) {
  while (a <= b) {
    if (s[a] != s[b])
      return false;
    a++;
    b--;
  }
  return true;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  int ini = 0;
  int len = s.size();
  int fin = len - 1;
  int mid1 = (len - 1) / 2 - 1;
  int mid2 = (len + 3) / 2 - 1;
  if (is_p(s, ini, mid1) && is_p(s, mid2, fin) && is_p(s, ini, fin) )
    cout << "Yes\n";
  else
    cout << "No\n";
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/python
# -*- coding: utf-8 -*-

import numpy as np
from collections import deque


def int_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(map(int,input().split())))
    return np.array(x)

N = int(input())

nowN = 26
start = 1
order = 1

for i in range(1,1000):
    if N <= nowN:
        break
    order += 1
    start = nowN+1
    nowN = nowN + 26**(i+1)

item = [chr(i) for i in range(97, 97+26)]
ans = []

for i in range(0,order):
    for j in range(1,27):
        if N <= start-1 + j*26**(order-i-1):
            start = start + (j-1)*26**(order-i-1)
            ans.append(item[j-1])
            break


print("".join(ans))
    


    






Measured memory_bytes: 27152
n=int(input())
h=[int(i) for i in input().split()]
h=h[::-1]

ans='Yes'
for i in range(n-1):
    if h[i+1]-h[i] >=2:
        ans = 'No'
        break
    elif h[i+1]-h[i] ==1:
        h[i+1]-=1
    
print(ans)    
        

Measured memory_bytes: 14224
#include<iostream>
using namespace std;
int main(){
    int H,W;
    while(1){
        cin>>H>>W;
        if(H==0&&W==0)break;
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                cout<<"#";
            }
            cout<<"\n";
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3060
N,M = map(int,input().split())
A = [0]*N
B = [0]*N
C = [0]*M
D = [0]*M
result = [0]*N
for i in range(N):
	A[i],B[i] = map(int,input().split())
for i in range(M):
	C[i],D[i] = map(int,input().split())
for i in range(N):
	Cnt = 0
	Dist = float('inf')
	x = A[i]
	y = B[i]
	for j in range(M):
		if abs(x-C[j])+abs(y-D[j]) < Dist:
			#print(i,j,Dist)
			Dist = abs(x-C[j])+abs(y-D[j])
			Cnt = j+1
	result[i]=Cnt
 
for i in range(N):
	print(result[i])
    

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = 10e10;
const ll MINF = -10e10;
const int INF = INT_MAX;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;
const int mod = 1000000007;
//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
typedef tuple<int, int, int> Q;


int main() {
    int n;
    cin >> n;
    ll ans = 0;
    rep(i, n) {
        int a;
        cin >> a;
        ans += a - 1;
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll maxn=1e5+50;
const ll m=1e18;
ll s[maxn];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%lld",&s[i]);
    ll mx=s[0],res=s[0];
    for(int i=1;i<n;i++){
        if(s[i]==0){
            printf("0");
            return 0;
        }
    }
    for(int i=1;i<n;i++){
        res*=s[i];
        if(res<mx||res>m){
            printf("-1");
            return 0;
        }
        mx=res;
    }
    printf("%lld",res);
    return 0;
}


Measured memory_bytes: 4592
N, K = [int(i) for i in input().split()]
Okashi = [[] for _ in range(K + 1)]

snuke_have_sweets = [False] * (N + 1)
for _ in range(K):
    D = int(input())
    A = [int(i) for i in input().split()]
    for a in A:
        snuke_have_sweets[a] = True

print(N - sum(snuke_have_sweets[1:]))


Measured memory_bytes: 9116
N = int(input())
x = [list(input().split()) for i in range(N)]
ans = 0
for i in range(N):
  if x[i][1] == "JPY":
    ans += int(x[i][0])
  elif x[i][1] == "BTC":
    ans += float(x[i][0]) * 380000
print(ans)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Diagnostics;
using static System.Console;
using static System.Math;


namespace AtCoder
{
    class Atriaaaaaaa
    {
        static void Main(string[] args)
        {
            int n = int.Parse(ReadLine());
            for (int i = 1; i < 10; i++)
            {
                for (int j = 1; j < 10; j++)
                {
                    //条件にあった時
                    if (i * j == n)
                    {
                        WriteLine("Yes");
                        return;
                    }
                }
            }
            WriteLine("No");
        }
    }
}


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

using namespace std;

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

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

    int max_profit = INT_MIN;
    int temp_min = INT_MAX;
    for (int i = 0; i < n; ++i) {
        max_profit = max(max_profit, r[i] - temp_min);
        temp_min = min(temp_min, r[i]);
    }

    cout << max_profit << endl;
    return 0;
}


Measured memory_bytes: 3876
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

a,b,c,d,e,f = inpl()
water = set()
sugar = set()
for i in range(f//(a*100)+10):
    for j in range(f//(b*100)+10):
        w = a*100*i + b*100*j
        if w > f:
            break
        water.add(w)
for i in range(f//c+10):
    for j in range(f//d+10):
        s = c*i + d*j
        if s > f:
            break
        sugar.add(s)
water = sorted(list(water))
sugar = sorted(list(sugar))
# print(water)
# print(sugar)

max_cons = 0
res_to = 0
res_s = 0
for w in water:
    for s in sugar:
        if w+s > f:
            break
        if w == 0 and s == 0:
            continue
        cons = s/(w+s)
        # print(w,s)
        if cons > e/(100+e):
            continue
        if cons >= max_cons:
            res_to = w+s
            res_s = s
            max_cons = cons
print(res_to,res_s) 


Measured memory_bytes: 65516
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		String s = sc.next();
		
		Main redOrBlue = new Main();
		System.out.println(redOrBlue.judgeRedOrBlue(N, s));
	}
	
	private String judgeRedOrBlue(int n, String s) {
		if(n < 1 || n > 100 || s == null || s.length() != n) return "No";
		
		char r = 'R', b = 'B';
		int countR = 0, countB = 0;
		for(char c : s.toCharArray()){
			if(c == r) countR++;
			if(c == b) countB++;
		}
		
		if(countR > countB) return "Yes";
		else return "No";
	}
}


Measured memory_bytes: 22864
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
	string s;
	cin>>s;
	int ans =0;
	if (s[0]=='1')
		++ans;
	
	if (s[1]=='1')
    	++ans;
	
	if (s[2]=='1')
	   	++ans;
	printf("%d\n",ans );
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 500000001000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

int ans,cnt;

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

	int N;
	cin >> N;

	rep(i,N){
		int v;
		cin >> v;
		if(v % 2 == 0){
			if(v % 3 != 0 && v % 5 != 0){
				cout << "DENIED" << endl;
				return 0;
			}
		}
	}

	cout << "APPROVED" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <chrono>
#include <random>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <iomanip>
#include<string>
#include <complex>
using namespace std;

#define ll long long
#define f first
#define s second
typedef pair<int , int > pii;
const ll MOD = 1e9+7;


void min_self(ll &a , ll b){
    a=min(a,b);
}

void max_self(ll &a, ll b){
    a=max(a,b);
}

ll add(ll x, ll y)
{
    return (x + y) % MOD;
}

ll sub(ll x, ll y)
{
    return add(x, MOD - y);
}

ll mul(ll x, ll y)
{
    return (x * 1ll * y) % MOD;
}

ll binpow(ll x, ll y)
{
    ll z = 1;
    while(y > 0)
    {
        if(y % 2 == 1)
            z = mul(z, x);
        x = mul(x, x);
        y /= 2;
    }
    return z;
}

ll inv(ll x)
{
    return binpow(x, MOD - 2);
}
const int MXN = 1e6+10;
ll fact[MXN];
void fac_pre()
{
    fact[0]=1;
    for(ll i=1; i<MXN; i++){
        fact[i]=mul(fact[i-1],i);
    }
}
ll C(ll n, ll k)
{
    return mul(fact[n], inv(mul(fact[k], fact[n - k])));
}

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

}
// BIT //
const int MAXN=2*1e5+10;
vector<int> bit(MAXN,0);
int sump(int idx) {
    int ret = 0;
    for (++idx; idx > 0; idx -= idx & -idx)
        ret += bit[idx];
    return ret;
}

int sum(int l, int r) {
    return sump(r) - sump(l - 1);
}

void upd(int idx, int delta) {
    for (++idx; idx < MAXN; idx += idx & -idx)
        bit[idx] += delta;
}
/////-----//////

int  main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    /* KEEP IN MIND
     * take care when sorting a 1 based indexed vector
     * const int N is defined way above in the starting
    */

    for(int i=0; i<5; i++) {
        int x; cin>>x;
        if( x == 0) cout<<i+1;
    }
    return 0;
}








Measured memory_bytes: 3836
#include<stdio.h>

int main(void){


int a,b,c,i,s;


s=0;


scanf("%d %d %d",&a,&b,&c);


for(i=a;i<=b;i++){


if(c%i==0){


s=s+1;


}


}


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


return 0;


}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define FOR(i,l,r) for(int i=(l);i<=(r);++i)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
const int maxn=1e5+2;
const LL MOD=1e9+7;

int h,w;
char C[310][310];
LL val[310][310],dp[310][310];
LL cl(int a,int b) {
	for (int i=1;i<=h;i++)
		for (int j=1;j<=h;j++) {
			val[i][j]=val[i-1][j-1]+(C[i][a]==C[j][b]);
			dp[i][j]=min(dp[i-1][j],dp[i][j-1])+val[i][j];
		}
	return dp[h][h];
}
int main() {
	scanf("%d%d",&h,&w);
	for (int i=1;i<=h;++i) scanf("%s",C[i]+1);

	LL ans=0;
	for (int i=1;i<w;i++) ans+=cl(i,i+1);
	cout<<ans<<endl;
	return 0;
}


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

#define MAX 1000
// 最大入力値
#define VMAX 10001

int n;
//数列入力用
int A[MAX];
// 入力数列の中の最小値
int s;
// 入力したAをソートした配列
int B[MAX];
// 数値をINDEXとしてソートした数列がどの位置に置かれるのかを記録する
int T[VMAX];

int solve(){
    // コスト
    int ans = 0;
    // 交換終了フラグ
    bool V[MAX] = {};
    for(int i = 0;i < n;++i){
        B[i] = A[i];
    }
    // Bをソートする
    sort(B,B + n);
    
    for(int i = 0;i < n;++i){
        // ソートされた並び順ごとに順番を入れておく
        // ソートされた数列が1 3 5 7 9とするとT[1] = 0,T[3] = 1のように順番が入る
        T[B[i]] = i;
    }
    
    for(int i = 0;i < n;++i){
        if(V[i]) continue;
        // 初回は0が対象になる
        int cursor = i;
        // 1サイクルでかかるコスト
        int S = 0;
        // 1サイクルにおける最小コスト、取りうる最大数値にしておく
        int m = VMAX;
        // サイクルの長さ
        int an = 0;
        // 1サイクル処理
        while(1){
            // ソート済みフラグ
            V[cursor] = true;
            an++;
            // 対象のコスト
            int v = A[cursor];
            // 最小コスト
            m = min(m,v);
            // コストに加算
            S += v;
            // 対象が置かれるべき位置を割り出すT[v]に置かれるべき1を入れています。
            cursor = T[v];
            // サイクルが終了していたら、次に移る
            if(V[cursor]) break;
        }
        // サイクル内の最小値を利用したコスト計算
        int cost1 = S + (an - 2) * m;
        // 数列の最小コストを借りた場合のコスト
        int cost2 = m + S + (an + 1) * s;
        // 最小値のコストを外から借りた場合とコストを比較する
        ans += min(cost1,cost2);
    }
    return ans;
}

int main(){
    cin >> n;
    // 最小値
    s = VMAX;
    for(int i = 0;i < n;++i){
        cin >> A[i];
        s = min(s,A[i]);
    }
    int ans = solve();
    cout << ans << endl;
}



Measured memory_bytes: 3180
function main(input) {
  var data = input.split(/\s|\n/);

  var N = data[0];
  var K = data[1];
  var S = data[2];

  var str = S.split("");

  str[K - 1] = str[K - 1].toLowerCase();

  var hoge = str.join("");

  console.log(hoge);
}

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


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

typedef long long int   ll;
#define cases           int t;cin>>t;while(t--)
#define FIO             ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define scan(n)         scanf("%d",&n)
#define pb              push_back
#define vi              vector<int>
#define ii              pair<int,int>

using namespace std;

int main(){
    int n,s;
    cin>>n>>s;
    if(s>=n)cout<<"unsafe"<<endl;
    else cout<<"safe";
}


Measured memory_bytes: 3632
import sys
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
 
    if temp!=1:
        arr.append([temp, 1])
 
    if arr==[]:
        arr.append([n, 1])
 
    return arr
 
def renzoku(n):
    x = (-1+(1+8*n)**(0.5))//2
    return int(x)
      
N = int(input())
if N == 1:
  print("0")
  sys.exit()
oriN = N*1
A = factorization(N)
#print(A)
M = len(A)
 
ans = 0
for i in range(M):
  temp = A[i][1]
  f = renzoku(temp)
  ans += f
print(ans)

Measured memory_bytes: 63572