akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		//		new Main().dPA();
		new Main().dPA2();

	}

	private void dPA() {
		Scanner scanner = null;
		int numFrog = 0;

		try {
			scanner = new Scanner(System.in);
			numFrog = scanner.nextInt();
			int[] heightArray = new int[numFrog];

			for (int i = 0; i < numFrog; i++) {
				heightArray[i] = scanner.nextInt();
			}

			int[] koufukuArray = new int[numFrog];
			for (int i = 0; i < heightArray.length; i++) {
				if (i != 0 && i != 1) {
					int val1 = Math.abs(heightArray[i] - heightArray[i - 1]);
					int val2 = Math.abs(heightArray[i] - heightArray[i - 2]);
					koufukuArray[i] = Math.min(koufukuArray[i - 1] + val1, koufukuArray[i - 2] + val2);
				} else if (i == 0) {
					koufukuArray[i] = 0;
				} else if (i == 1) {
					koufukuArray[i] = koufukuArray[i - 1] + Math.abs(heightArray[i] - heightArray[i - 1]);
				}

			}
			System.out.println(koufukuArray[koufukuArray.length - 1]);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void dPA2() {
		Scanner scanner = null;
		int numFrog = 0;
		int jump = 2;

		try {
			scanner = new Scanner(System.in);
			numFrog = scanner.nextInt();
			int[] heightArray = new int[numFrog];

			for (int i = 0; i < numFrog; i++) {
				heightArray[i] = scanner.nextInt();
			}

			int[] cost = new int[numFrog];
			Arrays.fill(cost, Integer.MAX_VALUE);

			cost[0] = 0;

			for (int i = 0; i < heightArray.length; i++) {

				for (int j = 1; j <= jump; j++) {
					if (i + j < heightArray.length) {
						cost[i + j] = Math.min(cost[i + j], Math.abs(heightArray[i + j] - heightArray[i]) + cost[i]);
					}
				}

			}
			System.out.println(cost[cost.length - 1]);
		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

Measured memory_bytes: 50080
#include<iostream>
#include<numeric>

int main(){
    int k;
    std::cin>>k;
    std::size_t tmp=0;
    for(int a=1;a<=k;++a)
        for(int b=1;b<=k;++b)
            for(int c=1;c<=k;++c){
                tmp+=std::gcd(std::gcd(a,b),c);
            }
    std::cout<<tmp;
}

Measured memory_bytes: 3636
#include <iostream>
#include <assert.h>
#include <algorithm>
#include <vector>
#include <cmath>

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

  int64_t N;
  std::cin >> N;
  if (N % 2 == 1) {
    std::cout << 0 << std::endl;
    return 0;
  }
  int64_t res = N / 10;
  int64_t divider = 5;
  while ( N > divider ) {
    res += N / (divider * 10);
    divider *= 5;
  }
  std::cout << res << std::endl;

  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func gtm(a, b int) int {
	if a < b {
		a, b = b, a
	}

	r := a % b
	for ;r != 0; {
		a = b
		b = r
		r = a % b
	}

	return b
}

func main() {
	var a, b int
	fmt.Scanf("%d %d", &a, &b)	

	lcm := a * b / gtm(a, b)
	fmt.Println(lcm)
}

Measured memory_bytes: 512
import itertools

n=int(input())
xy=[list(map(int,input().split())) for i in range(n)]


cnt=0
num=0
for v in itertools.permutations(xy):
  num+=1
  for i in range(n-1):
    a=(v[i][0]-v[i+1][0])**2+(v[i][1]-v[i+1][1])**2
    b=a**0.5
    cnt+=b

print(cnt/num)

Measured memory_bytes: 9460
#include <bits/stdc++.h>
using namespace std;
const int N=2e5+5;
long long arr[N];
long long cum[N];
int mod=1000000007;
int solve()
{
    int n;
    cin>>n;
    long long ans=0;
    for(int i=0;i<n;i++)
        cin>>arr[i];
    cum[n-1]=arr[n-1];
    for(int i=n-2;i>=0;i--)
        cum[i]=(arr[i]+cum[i+1])%mod;
   /* for(int i=0;i<n;i++)
        cout<<cum[i]<<" ";*/
    for(int i=0;i<n-1;i++)
        ans=(ans+arr[i]*cum[i+1])%mod;
    cout<<ans;
    return 0;
}

int main()
{

#ifndef ONLINE_JUDGE
    freopen("input.txt" ,"r" ,stdin);
    freopen("output.txt" ,"w" ,stdout);
#endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    // int t;
    // cin>>t;
    // while(t--)
    solve();

    return 0;
}

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

using namespace std;

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

#define FILL(ptr, value) FILL_((ptr), sizeof(ptr) / sizeof(value), (value))

template <typename T>
void FILL_(void* ptr, size_t size, T value) {
  std::fill((T*)ptr, (T*)ptr + size, value);
}

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

int main() {
  std::ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  int p[n] = {};
  for(int i=0;i<n;++i)
  {
    cin >> p[i];
  }
  sort(p, p + n);

  cout << accumulate(p, p + k, 0) << endl;

}

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

int main() {
  int N;
  cin >> N;
  vector<pair<int,int>> works(N);
  for (int i=0; i<N; i++) {
    int a, b;
    cin >> a >> b;
    works.at(i) = make_pair(b,a);
  }
  
  sort(works.begin(), works.end());
  int64_t time = 0;
  bool judge = true;
  for (int i=0; i<N; i++) {
    time += works.at(i).second;
    if (time > works.at(i).first) {
      judge = false;
      break;
    }
  }
  
  cout << (judge ? "Yes" : "No") << endl;
}

Measured memory_bytes: 1792
from collections import Counter

N = int(input())
D = list(map(int, input().split()))
MOD = 998244353

c = Counter(D)
tmp = 1
ans = 1
zero_flg = False

for dist in range(N):
    if dist == 0 and (c[0] != 1 or D[0] != 0):
        print(0)
        exit()
    elif c[dist] == 0:
        zero_flg = True
    elif c[dist] > 0 and zero_flg:
        print(0)
        exit()
    else:
        ans *= pow(tmp, c[dist], MOD)
        ans %= MOD
        tmp = c[dist]

print(ans)

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

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

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

  sort(a, a + n);
  reverse(a, a + n);

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

  string ans = "Yes";
  if (h > 0) {
    ans = "No";
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

struct Sieve {
    int n;
    vector<int> f, primes;
    Sieve(int n = 1) : n(n), f(n + 1) {
        f[0] = f[1] = -1;
        for (ll i = 2; i <= n; ++i) {
            if (f[i]) continue;
            primes.push_back(i);
            f[i] = i;
            for (ll j = i * i; j <= n; j += i) {
                if (!f[j]) f[j] = i;
            }
        }
    }
    bool isPrime(int x) { return f[x] == x; }
    vector<int> factorList(int x) {
        vector<int> res;
        while (x != 1) {
            res.push_back(f[x]);
            x /= f[x];
        }
        return res;
    }
    vector<P> factor(int x) {
        vector<int> fl = factorList(x);
        if (fl.size() == 0) return {};
        vector<P> res(1, P(fl[0], 0));
        for (int p : fl) {
            if (res.back().first == p) {
                res.back().second++;
            } else {
                res.emplace_back(p, 1);
            }
        }
        return res;
    }
    vector<pair<ll, int>> factor(ll x) {
        vector<pair<ll, int>> res;
        for (int p : primes) {
            int y = 0;
            while (x % p == 0) x /= p, ++y;
            if (y != 0) res.emplace_back(p, y);
        }
        if (x != 1) res.emplace_back(x, 1);
        return res;
    }
};

void solve(int N, std::vector<int> A) {
    Sieve sieve = Sieve(int(1e6) + 5);
    unordered_map<int, int> mp;

    bool isPairewise = true;
    for (int i = 0; i < N; i++) {
        if (!isPairewise) {
            break;
        }
        vector<P> factors = sieve.factor(A[i]);
        for (P p : factors) {
            if (mp.find(p.first) == mp.end()) {
                mp[p.first]++;
            } else {
                isPairewise = false;
                break;
            }
        }
    }
    if (isPairewise) {
        cout << "pairwise coprime" << endl;
        return;
    }

    //setwise coprime を調査

    ll g = A[0];
    for (int i = 1; i < N; i++) {
        g = gcd(g, A[i]);
    }
    if (g == 1) {
        cout << "setwise coprime" << endl;
        return;
    }
    cout << "not coprime" << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main() {
    int N;
    scanf("%d", &N);
    std::vector<int> A(N);
    for (int i = 0; i < N; i++) {
        scanf("%d", &A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 11752
#include<stdio.h>
#include<stdlib.h>

#define INFTY 1000000000

int count=0;

void merge(int A[],int left,int mid,int right){
 int n1,n2,i,j,k;
 int *L,*R;

 n1 = mid - left;
 n2 = right - mid;
 /*L[0...n1], R[0...n2] を生成*/
 L=(int *)malloc(sizeof(int)*(n1+1));
 R=(int *)malloc(sizeof(int)*(n2+1));
 for( i = 0; i<=n1-1; i++){
   L[i] = A[left + i];
 }

 for (j = 0; j<=n2-1; j++){
   R[j] = A[mid + j];
 }
   L[n1] = INFTY;
   R[n2] = INFTY;
   i = 0;
   j = 0;

 for( k = left; k<=right-1; k++){
     if( L[i] <= R[j]){
       A[k] = L[i];
       i = i + 1;
       count++;
     }

     else{
       A[k] = R[j];
       j = j + 1;
       count++;
     }
   }

   free(L);
   free(R);
 }

void mergeSort(int A[],int left,int right){
       int i,mid;

       if( left+1 < right){
   mid = (left + right)/2;
   mergeSort(A, left, mid);
 mergeSort(A, mid, right);
   merge(A, left, mid, right);
       }
     }

int main(){

  int A[5000000];
  int n,i;

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

  mergeSort(A,0,n);
  for(i=0; i<n; i++){
    printf("%d",A[i]);
    if(i<n-1) printf(" ");
       }

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



Measured memory_bytes: 5432
// B - Card Game for Two
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define allr(x) (x).rbegin(),(x).rend()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

int main(){
	int N; cin>>N;
	vi A(N); rpz(i, N) cin>>A[i];
	sort(allr(A));
	int ans = 0;
	rpz(i, N) ans += i&1? -A[i]: A[i];
	cout<< ans <<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a,a+3);
  if(a[2]==a[0])cout << "Yes" << endl;
  else cout << "No" << endl;
return 0;}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr int inf = 1<<30;
constexpr ll infl = 1ll<<62;

int main(){
    int n;
    cin>>n;
    vector<int> a(n),b(n);
    for(auto &t : a) cin>>t;
    for(auto &t : b) cin>>t;
    priority_queue<pair<int,int>> q;
    for(int i=0;i<n;++i)q.push({b[i],i});
    ll ret = 0ll;
    while(!q.empty()){
        auto cur = q.top();q.pop();
        int val = cur.first;
        int index = cur.second;
        int bef = (index-1+n)%n;
        int nex = (index+1)%n;
        if(val < a[index])break;
        if(val == a[index])continue;
        if(b[bef] + b[nex] == 0)break;
        int num = (val - a[index])/(b[bef]+b[nex]);
        val -= num*(b[bef]+b[nex]);
        if(num)q.push({val,index});
        b[index] = val;
        ret+=num;
    }
    for(int i=0;i<n;++i)if(a[i] != b[i])ret = -1;
    cout << ret << endl;
    return 0;
}



Measured memory_bytes: 3956
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define int long long int
constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::min();
using namespace std;

void solve() {
  int M;
  cin >> M;
  int ans = 0;
  int sum = 0;

  while (M--) {
    int c, d; cin >> d >> c;
    ans += c;
    sum += d*c;
  }

  ans -= 1;
  ans += (sum - 1)/9;

  cout << ans << endl;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;
using ll = long long;
using P = pair<int, int>;

void solve(ll N) {
  // assume A < B
  long A = floor(sqrt(N));
  while (A > 0)
    if (N % A == 0)
      break;
    else
      A--;
  long B = N / A;
  // cout << "A " << A << " B " << B << endl;
  cout << max(to_string(A).length(), to_string(B).length()) << endl;
}

int main(){
  // int 3E4  long 2E9  ll 9E18
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll N;
  cin >> N;
  solve(N);
  return 0;
}


Measured memory_bytes: 256
n = int(input())

numbers = [int(i) for i in input().split(" ")]

flag = 1

cnt = 0

while flag:
    flag = 0
    for j in range(n - 1, 0, -1):
        if numbers[j] < numbers[j - 1]:
            numbers[j], numbers[j - 1] = numbers[j - 1], numbers[j]
            flag = 1
            cnt += 1

numbers = map(str, numbers)
print(" ".join(numbers))

print(cnt)

Measured memory_bytes: 7708
S = list(input())

ans = [0 for _ in range(len(S))]

s_flag = 0
cnt = 0
for i, s in enumerate(S):
    if s == "R":
        s_flag = 1
        cnt += 1
    else:
        if s_flag and s == "L":
            ans[i] += cnt//2 
            ans[i-1] += cnt//2 + cnt%2
            cnt = 0
            s_flag = 0
# print(ans)

S.reverse()
ans.reverse()
# print(S)
# print(ans)

l_flag = 0
cnt = 0
for i, s in enumerate(S):
    if s == "L":
        l_flag = 1
        cnt += 1
    else:
        if l_flag and s == "R":
            ans[i] += cnt//2 
            ans[i-1] += cnt//2 + cnt%2
            cnt = 0
            l_flag = 0
    # print(ans)
ans.reverse()
print(*ans)

Measured memory_bytes: 7088
#include<iostream>
using namespace std;
int main() {
	string s1, s2;
	cin >> s1 >> s2;
	int len = s1.length(), count = 0;
	for(int i = 0; i < len; i++) {
		if(s1[i] != s2[i])
			count++;
	}
	cout << count;
	return 0;
}

Measured memory_bytes: 3920
////////////////////////////////////////////////
//  ********  *      *    *******    * *      //                 :
//  *         *      *   *       *   *   *    //     64 BITS     C     64 BITS
//  *****     *      *  *         *  *     *  //                 +
//  *         *      *  ***********  *     *  //:  20 - 6 - 2020 +   20 - 6 - 2020 :
//  *         *      *  *         *  *   *    //                 1
//  *         ********  *         *  * *      //     64 BITS     7     64 BITS
////////////////////////////////////////////////                 :
#define ll long long
#define ui unsigned int
#define ud unsigned double
#define mp make_pair
#define pii pair<int,int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pdi pair<double,int>
#define pb push_back
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
const double pi = acos(-1.0);
int main()
{
    char n;
    cin>>n;
    if (n == 'a'){
        puts("b\n");
    }
    else if (n == 'b'){
        puts("c\n");
    }
    else if (n == 'c'){
        puts("d\n");
    }
    else if (n == 'd'){
        puts("e\n");
    }
    else if (n == 'e'){
        puts("f\n");
    }
    else if (n == 'f'){
        puts("g\n");
    }
    else if (n == 'g'){
        puts("h\n");
    }
    else if (n == 'h'){
        puts("i\n");
    }
    else if (n == 'i'){
        puts("j\n");
    }
    else if (n == 'j'){
        puts("k\n");
    }
    else if (n == 'k'){
        puts("l\n");
    }
    else if (n == 'l'){
        puts("m\n");
    }
    else if (n == 'm'){
        puts("n\n");
    }
    else if (n == 'n'){
        puts("o\n");
    }
    else if (n == 'o'){
        puts("p\n");
    }
    else if (n == 'p'){
        puts("q\n");
    }
    else if (n == 'q'){
        puts("r\n");
    }
    else if (n == 'r'){
        puts("s\n");
    }
    else if (n == 's'){
        puts("t\n");
    }
    else if (n == 't'){
        puts("u\n");
    }
    else if (n == 'u'){
        puts("v\n");
    }
    else if (n == 'v'){
        puts("w\n");
    }
    else if (n == 'w'){
        puts("x\n");
    }
    else if (n == 'x'){
        puts("y\n");
    }
    else if (n == 'y'){
        puts("z\n");
    }
    return 0;
}

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

int main(){
	int A,B,C,X,Y; cin>>A>>B>>C>>X>>Y;
	cout<< ( A+B<=C*2? A*X + B*Y:
		C*2 * min(X, Y) + min((X>Y? A:B), C*2) * abs(X-Y) ) <<endl;
}

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

int main() {
  char t[128];
  t['A'] = 'T';
  t['T'] = 'A';
  t['C'] = 'G';
  t['G'] = 'C';
  
  char ch;
  cin >> ch;
  cout << t[ch] << endl;
}

Measured memory_bytes: 256
n = gets.to_i
h = {}
n.times do
  s = gets
  h[s.chomp]=0
end

for m in ["S", "H", "C", "D"] do
  for i in 1..13 do
    puts "#{m} #{i}" if !h.has_key?(m+" "+i.to_s)
  end
end


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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};



int main(){

  int n,a,b;
  cin >> n >> a >> b;
  cout << min(b,a*n) << endl;




  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    constexpr i64 mod = 1000000007;
    int n;
    std::cin >> n;
    std::vector<i64> a(n);
    std::vector<i64> b(61);
    for (auto &e : a) {
        std::cin >> e;
        for (i64 i = 0; i <= 60; i++) if (e & (1ll << i)) b[i]++;
    }

    i64 ret = 0;
    for (i64 i = 0; i <= 60; i++) {
        ret = (ret + (1ll << i) % mod * b[i] % mod * (n - b[i]) % mod) % mod;
    }

    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 2560
def shuntsu(x, y)
  if y <= 6
    for z in 0..2
      x[y+z] -= 1
    end
  end
  return x
end

gets.to_i.times{
  h_n = gets.split.map{|i| (i.to_i)-1}
  h_c = gets.split
  r, g, b = [0]*9, [0]*9, [0]*9
  
  for x in 0...9
    case h_c[x]
    when "R"; r[h_n[x]] += 1
    when "G"; g[h_n[x]] += 1
    when "B"; b[h_n[x]] += 1
    end
  end
  
  for x in [r, g, b]
    for y in 0...9
      case x[y]
      when 1
        x = shuntsu(x, y)
      when 2
        x = shuntsu(shuntsu(x, y), y)
      when 3
        x[y] -= 3
      when 4
        x[y] -= 3
        x = shuntsu(x, y)
      end
    end
  end
  
  if [r, g, b] == [[0]*9]*3
    puts 1
  else
    puts 0
  end
}

Measured memory_bytes: 6116
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N, M, K;
  cin >> N >> M >> K;
  vector<ll> A(N), B(M), sum_A(N + 1, 0), sum_B(M + 1, 0);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    sum_A[i + 1] = sum_A[i] + A[i];
  }
  for (int i = 0; i < M; i++) {
    cin >> B[i];
    sum_B[i + 1] = sum_B[i] + B[i];
  }
  ll ans = 0;
  ll j = M;
  for (int i = 0; i <= N; i++) {
    if (sum_A[i] > K) break;
    while (sum_B[j] > K - sum_A[i]) {
      j--;
    }
    ans = max(ans, (i + j));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 9592
package main

import (
  "fmt"
  "sort"
)

func main() {
  var n, k int 
  fmt.Scan(&n, &k)
  h := make([]int, n)
  for i := 0; i < n; i++ {
    fmt.Scan(&h[i])
  }
  sort.Ints(h)
  res := n - sort.SearchInts(h, k)
  fmt.Println(res)
}

Measured memory_bytes: 5504
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n,m,x,y; cin >> n >> m >> x >> y;
    VI a(n); VIin(a);
    SORT(a);
    int mini = a[n-1];
    VI b(m); VIin(b);
    SORT(b);
    int maxi = b[0];
    bool flag = false;
    FOR(i,mini+1,maxi+1) {
        if(x < i && i < y) flag = true;
    }
    if(flag) OUT("No War");
    else OUT("War");


    return 0;
}




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

swich = [0] * n

for i in range(m):
    _, *s = map(int, input().split())
    for j in range(len(s)):
        swich[s[j] - 1] += 1 << (i)
        # swich[s[j] - 1] ^= 1 << (i)
        # swich[s[j] - 1] |= 1 << (i)
    


p_list = list(map(int, input().split()))
p = 0
for i in range(m):
    if p_list[i] == 1: 
        p += 1 << i
    # p |= p_list[i] << i #上の処理と同じ

# print("++++++++++++++++++++++++")
# print(swich)
ans = 0
for i in range(1 << n):
    state_on_off = 0
    for index in range(n):
        if i >> index & 1 == 1:
            state_on_off ^= swich[index]
    if state_on_off == p:
        ans += 1
    # print(p, state_on_off,bin(i))
print(ans)

Measured memory_bytes: 9164
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    string a, b, c; cin >> a >> b >> c;
    string x = a + b + c + "+";

    sort(x.begin(), x.end());

    int maxi = 0;

    do {
        if (x[0] == '+' or x[3] == '+') continue;

        if (x[1] == '+') {
            int tmp = (x[0] - '0') + (x[2] - '0') * 10 + (x[3] - '0');
            maxi = max(maxi, tmp);
        } else {
            int tmp = (x[0] - '0') * 10 + (x[1] - '0') + (x[3] - '0');
            maxi = max(maxi, tmp);
        }

    } while (next_permutation(x.begin(), x.end()));
    cout << maxi << endl;
}


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

public class Main {
    public static void main(String[] args) throws IOException {
        FastScanner in = new FastScanner();
        int H = in.nextInt();
        int W = in.nextInt();
        int Rnum = W+2;

        String word [] = new String[H];

        for (int i  = 0; i < H; i++)
        {
            word[i] = in.nextLine();
        }
        System.out.println(String.join("", Collections.nCopies(Rnum, "#")));


        for (int j = 0; j<H; j++)
            {
                System.out.println("#"+word[j]+"#");
            }


        System.out.println(String.join("", Collections.nCopies(Rnum, "#")));
    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return null;
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

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


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

int main() {
    long double a, b, c;
    long double eps = 1.0E-14;
    cin >> a >> b >> c;
    if (sqrt(a) + sqrt(b) + eps < sqrt(c)){
    	cout << "Yes" << endl;
    }else{
    	cout << "No" << endl;
    }
} 

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
typedef long long ll;
typedef pair<int, int> P;
 
int main(){
  int n, k;
  cin >> n >> k;
  vector<int> d(k);
  vector<vector<int>> a(k, vector<int>(n, 0));

  rep(i, k){
    cin >> d[i];
    rep(j, d[i]) cin >> a[i][j]; 
  }

  vector<int> s(n, 0);

  rep(i,k){
    rep(j,d[i]){
      s[a[i][j]-1]++;
    }
  }

  int ct=0;
  rep(i,n){
    if(s[i]>0) ct++;
//    cout << s[i] << endl;
  }
  cout << n-ct << endl;
  return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

vl a={1,2,3,4,5,6,7,8,9};

ll search(int k){
    ll i = 0;
    while(k>=a.size()){
        ll tmp = a[i];
        repk(j,-1,2){
			ll d = tmp%10 +j; 
            if(d < 0 || 9 < d){continue;}
            a.pb(10*tmp + d);
        }
        i++;         
    }
    return a[k-1];
}


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

    int k;
    cin >> k;
    cout << search(k) << endl;
    return 0;
}
    

Measured memory_bytes: 1592
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  int N = S.length();
  string ans = "Yes";
  for(int i=0;i<(N-1)/2;i++){
    if(S[i]!=S[N-1-i])ans = "No";
  }
  for(int i=0;i<(N-1)/2;i++){
    if(S[i]!=S[(N-1)/2-1-i])ans = "No";
  }
  for(int i=(N+3)/2-1;i<N;i++){
    if(S[i]!=S[N-1-i])ans = "No";
  }
  cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
#include <cmath>
#define REP(i, n) for(int i = 0; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define RSORT(x) sort(x.begin(), x.end(), std::greater<int>())
#define swap(a, b) \
  do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0)
#define vi vector<int>
using namespace std;

const double EPS = 1e-10;
const double PI  = acos(-1.0);

int main() {
  
  long n, m;
  cin >> n >> m;
  cout << abs((n - 2) * (m - 2)) << endl;
  
}


Measured memory_bytes: 256
import java.util.*;
import java.util.Map.Entry;
 
class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
	 static int[] ans;
//	 static int mod = 998244353;
   public static void main(String[] args) {
	   
	   int H=(int) (Math.pow(10,5)+7);
       int[] m = new int[H];
       int[] p = new int[H];
       int k=0;
       for(int i=2;i<H;i++) {
       	if(m[i]==0) {
       		m[i]=-k-1;
       		p[k]=i;
       		k++;
       		for(int j=i;j<H;j=j+i) {
       			m[j]=k;
       		}
       	}
       }
       
	   Scanner sc = new Scanner(System.in);
       int  N = sc.nextInt();
       int  K = sc.nextInt();
       long[] a = new long[N];
       long max=0;
       long min= (int) (Math.pow(10,9)+7);
       for (int i=0 ; i<N; i++) {
           a[i] = Long.parseLong(sc.next());
           max=Math.max(max, a[i]);
           min=Math.min(min, a[i]);
           if(K==a[i]) {
        	   System.out.println("POSSIBLE");
        	   return;
           }
       }
       if(K>max) {
    	   System.out.println("IMPOSSIBLE");
    	   return;
       }
       long gcd=GCD(a[0],a[1]);
       for(int i=2;i<N;i++) {
    	   gcd=GCD(gcd,a[i]);
       }
       if(K%gcd==0) {
    	   System.out.println("POSSIBLE");
       } else{
    	   System.out.println("IMPOSSIBLE"); 
       }
       return;
   }
   static long GCD(long a,long b) {
		  long tmp;
		  long r;
		  if(a<b) {
			  tmp = a;
			  a = b;
			  b = tmp;				  
		  }
		  
		  r = a % b;
		  while(r!=0) {
			  a=b;
			  b=r;
			  r=a%b;
		  }
		  
		  return b;
	  }
	  
}

Measured memory_bytes: 50424
#include<bits/stdc++.h>
#define ll int
#define f first
#define s second
#define pb push_back
using namespace std;
ll dp[301][301][301],k;
string s;
inline ll solve(ll x,ll y,ll p){
    if(dp[x][y][p])return dp[x][y][p];
    if(x == y){
        dp[x][y][p] = 1;
        return dp[x][y][p];
    }
    if(x + 1 == y){
        if(s[x] == s[y] || p)dp[x][y][p] = 2;
        else dp[x][y][p] = 1;
        return dp[x][y][p];
    }
    if(p == 0){
        if(s[x] == s[y]){
            dp[x][y][p] = solve(x + 1 ,y - 1, p) + 2;
            return dp[x][y][p];
        }
        ll t = solve(x , y - 1 , p);
        ll r = solve(x + 1 , y , p);
        dp[x][y][p] = max(t,r);
        return dp[x][y][p];
    }
    if(s[x] == s[y]){
        dp[x][y][p] = solve(x + 1, y - 1 , p) + 2;
        return dp[x][y][p];
    }
    dp[x][y][p] = solve(x + 1 , y - 1 , p);
    ll t = solve(x , y - 1 , p);
    ll r = solve(x + 1 , y , p);
    ll q = solve(x + 1 , y - 1, p - 1) + 2;
    q = max(q , max(t , r));
    if(dp[x][y][p] < q)dp[x][y][p] = q;
    return dp[x][y][p];
}
int main(){
    ios::sync_with_stdio(false);
    cin >> s >> k;
    
    cout << solve(0 , (int)s.size() - 1 , k);
    
    
    
    return 0;
}


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

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

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



string s;
void solve(){
	cin >> s;
	int n = s.size();
	
	string t;
	for(int i = 0; i < n; i++){
		if(s[i] == 'x') continue;
		t += s[i];
	}
	
	int m = t.size();
	for(int i = 0; i < m/2; i++){
		if(t[i] != t[m-i-1]){
			cout << -1 << endl;
			return;
		}
	}
	int l = 0, r = n-1;
	int ans = 0;
	while(l < r){
		if(s[l] == s[r]){
			l++; r--;
			continue;
		}
		if(s[l] == 'x'){
			ans++;
			l++;
			continue;
		}
		if(s[r] == 'x'){
			ans++;
			r--;
			continue;
		}
	}
	cout << ans << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

int main() {
  int x, n;
  cin >> x >> n;
  vector<int> data;
  REP(i, n) {
    int tmp;
    cin >> tmp;
    data.push_back(tmp);
  }
  int min_diff = INT_MAX;
  int ans = x;
  for (int i = 101; i > -1; i--) {
    auto found_itr = find(data.begin(), data.end(), i);
    bool found = found_itr != data.end();
    if ((abs(x - i) <= min_diff) && !found) {
      min_diff = abs(x - i);
      ans = i;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
N,A = (int(T) for T in input().split())
X = [int(T)-A for T in input().split()]
DP = [[0]*(2*(50*N)+1) for TI in range(0,N+1)]
DP[0][50*N] = 1
for TI in range(0,N):
    for TS in range(0,2*50*N+1):
        if DP[TI][TS]!=0:
            DP[TI+1][TS] += DP[TI][TS]
            DP[TI+1][TS+X[TI]] += DP[TI][TS]
print(DP[N][50*N]-1)

Measured memory_bytes: 11380
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def main():
    N, M, C = map(int, input().split())

    B = list(map(int, input().split()))

    ans = 0
    for _ in range(N):
        A = list(map(int, input().split()))

        total = C
        for i in range(M):
            total += A[i] * B[i]

        ans += total > 0

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3956
import sys
input = sys.stdin.readline
import numpy as np

N = int(input())
AB = np.array([input().split() for _ in range(N)], dtype=np.int64)

A,B = AB.T
select = np.where(A > B)[0]
if len(select) == 0:
    answer = 0
else:
    answer = A.sum() - B[select].min()
print(answer)



Measured memory_bytes: 26396
#include <iostream>
#include <cstdio>
#include <cmath>
#define INF 100000000
using namespace std;

int main(){
  int D,E;
  while(1){
    cin>>D>>E;
    if(D==0&&E==0)break;
    double mini=INF;
    for(int i=0;i<=D/2;i++){
      mini=min(mini,max(0.0,abs(sqrt(i*i+(D-i)*(D-i))-E)));
    }
    printf("%.5f\n",mini);
  }
  
  return 0;
}

Measured memory_bytes: 3228
#include<bits/stdc++.h>
using namespace std;
#define int long long

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

  vector<int> v(1000001,1 << 30);
  const int n = 400;
  for(int x = 0; x < n; x++){
    for(int y = 0; y < n; y++){
      for(int z = 0; z < n; z++){
        if(x + y*y + z*z*z > 1000001) continue;
        v[x + y*y + z*z*z] = min(v[x + y*y + z*z*z],x + y + z);
      }
    }
  }

while(1){
  int e; cin >> e;
  if(e == 0) break;

  cout << v[e] << endl;
}

  return 0;
}



Measured memory_bytes: 10552
int left(int);
int right(int);

int main()
{
  int hs, i;
  int A[260];
  
  scanf("%d", &hs);
  for(i=1; i<=hs; i++){
	scanf("%d", &A[i]);
  }
  
  for(i=1; i<=hs; i++){
	printf("node %d: key = %d, ", i, A[i]);
	
	if(parent(i) != 0){
	  printf("parent key = %d, ", A[parent(i)]);
	}
	if(left(i) <= hs){
	  printf("left key = %d, ", A[left(i)]);
	}
	if(right(i) <= hs){
	  printf("right key = %d, ", A[right(i)]);
	}
	printf("\n");
  }
  return 0;
}

int parent(int i)
{
  return i/2; 
}

int left(int i)
{
  return 2*i;
}
int right(int i)
{
  return 2*i+1;
}

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

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

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


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

#define B

#ifdef B
int main(void) {
	int x, y;
	cin >> x >> y;
	while (x != y)
	{
		if (x > y)
			x -= y;
		else
			y -= x;
	}
	cout << x <<endl;
	return 0;
}
#endif // B

Measured memory_bytes: 3072
n, d = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(n)]
ans = 0
for i in range(n-1):
    for j in range(i+1, n):
        s = pow(sum([(X[i][k] - X[j][k])**2 for k in range(d)]), 1/2)
        if s.is_integer():
            ans +=1
print(ans)        

Measured memory_bytes: 3064
import java.util.*;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    //int N = sc.nextInt();
    //int[] count = new int[N];
    String[] str = new String[2];
    
    for(int i=0; i<2; i++){
            str[i] = sc.next();
    }
    
    if(str[0].equals("H")){
        if(str[1].equals("H")){
            System.out.println("H");
        }else{
            System.out.println("D");
        }
    }else{
        if(str[1].equals("H")){
            System.out.println("D");
        }else{
            System.out.println("H");
        }
    }
  }
}

Measured memory_bytes: 21844
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;


long long combi(long long n, long long k) {
  if (n == k || k == 0)
    return 1;
  else {
    return combi(n - 1, k - 1) + combi(n - 1, k);
  }
}

int main(){
    string s;cin>>s;
    int n = s.size();
    string t = s.substr(0,(n-1)/2),u = s.substr((n+3)/2-1,n-1);
    string ss = s,tt = t,uu = u;
    reverse(ALL(s));
    reverse(ALL(t));
    reverse(ALL(u));
    cout<<(s==ss&&t==tt&&u==uu?"Yes":"No");
}



Measured memory_bytes: 256
using static System.Console;

class Program {
	static void Main() {
		var N = NextInt();
		var a = new int[N];
		for (var i = 0; i < N; i++) {
			a[i] = NextInt();
		}
		var j = 1;
		for (var i = 1; i <= N; i++) {
			j = a[j - 1];
			if (j == 2) {
				WriteLine(i);
				return;
			}
		}
		WriteLine(-1);
	}

	static int NextInt() {
		return int.Parse(ReadLine());
	}
}

Measured memory_bytes: 15328
using System;
 
class Program {
	static void Main (string[] args) {
		string[] str = Console.ReadLine().Split(' ');
      	int a = int.Parse(str[0]);
      	int b = int.Parse(str[1]);
      	int c = int.Parse(str[2]);
      	if (a * c <= b) 
        {
          Console.WriteLine(c);
        }
      	else 
        {
          for (int cnt = 1; cnt <= c; cnt++) {
            if (a * cnt > b) {
              int ans = cnt - 1;
              Console.WriteLine(cnt - 1);
              break;
            }
          }
        }
	}
}

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

using namespace std;

#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define INF 1000000000
#define INFL (1LL << 60)
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

int main(){
  cout << "100 100" << endl;
  int a, b;
  cin >> a >> b;
  a--;
  b--;
  bool ans[100][100] = { };
  REP(i, 50)REP(j, 100) ans[i][j] = true;
  int cx = 51, cy = 0;
  while(a > 0){
    ans[cx][cy] = true;
    cy += 2;
    if(cy >= 100){
      cx += 2;
      cy = 0;
    }
    a--;
  }
  cx = 0;
  cy = 0;
  while(b > 0){
    ans[cx][cy] = false;
    cy += 2;
    if(cy >= 100){
      cx += 2;
      cy = 0;
    }
    b--;
  }
  REP(i, 100){
    REP(j, 100) cout << (ans[i][j] ? '.' : '#');
    cout << endl;
  }
	return 0;
}

Measured memory_bytes: 256
nb,na,level = map(int , input().split())
blevels = []
for i in range(nb):
    blevels.append(list(map(int , input().split())))
ans = float('inf')
#print(ans)
for i in range(1,2**nb):
    flag = 0
    levels_sum = [0]*na
    price_sum = 0
    for j in range(nb):
        if((1<<j) & i > 0):
            price_sum += blevels[j][0]
            for k in range(1,na+1):
                levels_sum[k-1] += blevels[j][k]
    #print(price_sum)
    #print(*levels_sum)
    for levels in levels_sum:
        if(levels < level):
         #   print("breaked")
            flag = 1
            break
    if(flag == 0 and ans > price_sum):
        ans = price_sum
        #print(ans)
if(ans != float('inf')):
    print(ans)
else:
    print("-1")


Measured memory_bytes: 9092
N,K=map(int,input().split())
R,S,P=map(int,input().split())
Ti=input()

def point(str1,str2): 
    if str1=="s" and str2=="r":
        return R
    elif str1=="r" and str2=="p":
        return P
    elif str1=="p" and str2=="s":
        return S
    else:
        return 0

T=[[] for i in range(K)]

for i in range(N):
    T[i%K].append(Ti[i])

ans=0
for i in range(K):
    L=len(T[i])
    DP=[[0]*3 for i in range(L+1)]
    for j in range(L):
        DP[j+1][0]=max(DP[j][1],DP[j][2])+point(T[i][j],"r")
        DP[j+1][1]=max(DP[j][2],DP[j][0])+point(T[i][j],"s")
        DP[j+1][2]=max(DP[j][0],DP[j][1])+point(T[i][j],"p")
    ans += max(DP[L])

print(ans)

Measured memory_bytes: 23392
#include <stdio.h>
#include <stdlib.h>

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

#define min(x,y) x<y?x:y
#define minch(x,y) x=min(x,y)

#define INF 999999999

int n,m,c,s,g;
int d[22][111][111];
int cost[22][22222];
int dc[111][111];
int i,j,k,cmp,dd;

int main(){
	//cin.sync_with_stdio(false);
	while(1){
		scanf("%d%d%d%d%d",&n,&m,&c,&s,&g);
		if(n==0)break;
		s--; g--;
		rep(i,22)rep(j,111)rep(k,111)d[i][j][k]=(j==k?0:INF);
		rep(i,m){
			int x,y,dd,cmp;
			scanf("%d%d%d%d",&x,&y,&dd,&cmp);
			x--; y--; cmp--;
			d[cmp][x][y]=d[cmp][y][x]=min(dd,d[cmp][x][y]);
		}
		int p[22];
		rep(i,c){
			scanf("%d",p+i);
			//dbg(p[i]);
		}
		rep(i,c){
			int q[55],r[55];
			rep(j,p[i]-1)scanf("%d",q+j);
			rep(j,p[i])scanf("%d",r+j);
			int nq=0;
			cost[i][0]=0;
			rep(dd,20010){
				if(nq<p[i]-1&&dd==q[nq])nq++;
				cost[i][dd+1]=cost[i][dd]+r[nq];
				//if(dd<10)dbg(cost[i][dd]);
			}
		}
		rep(cmp,c)rep(k,n)rep(i,n)rep(j,n)minch(d[cmp][i][j],d[cmp][i][k]+d[cmp][k][j]);
		rep(i,n)rep(j,n)dc[i][j]=(i==j?0:INF);
		rep(i,c)rep(j,n)rep(k,n)if(d[i][j][k]!=INF)minch(dc[j][k],cost[i][d[i][j][k]]);
		rep(k,n)rep(i,n)rep(j,n)minch(dc[i][j],dc[i][k]+dc[k][j]);
		if(dc[s][g]==INF)printf("-1\n");
		else printf("%d\n", dc[s][g]);
	}
	return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
const ll mod = 1e9 + 7;
const int INF = 1e9;

int main() {
	cin.sync_with_stdio(false);
	int N;
	cin >> N;
	vector<ll>T(N), A(N), M(N);

	rep(i, N) {
		cin >> T[i];
		if (i == 0)M[i] = T[i];
		if (i != 0 && T[i] > T[i - 1]) {
			M[i] = T[i];
		}
	}
	rep(i, N)cin >> A[i];

	for (int i = N - 1; i >= 0; i--) {
		if (M[i] != 0 && M[i] > A[i]) {
			cout << 0 << endl;
			return 0;
		}
		if (i == N - 1) {
			if (M[i] == 0 || M[i] == A[i])M[i] = A[i];
			else {
				cout << 0 << endl;
				return 0;
			}
		}
		else if (A[i] > A[i + 1]) {
			if (M[i] == 0 || M[i] == A[i])M[i] = A[i];
			else {
				cout << 0 << endl;
				return 0;
			}
		}
	}
	ll ans = 1;
	rep(i, N) {
		if (M[i] == 0)ans*= min(T[i], A[i]);
		ans %= mod;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<list>
#include<stack>
//#include<unordered_map>
using namespace std;
#define ll long long
#define dd cout<<endl
#define lll __int128
const int mod=1e9+7;
const int inf=1e9+7;

const int maxn=1e5+10;

typedef struct
{
	int time;
	int id;
}St;

St sum[maxn];

inline bool cmp(const St &a,const St &b)
{
	return a.time < b.time;
}

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    
    int n;
    cin>>n;
    
    for(int i=1;i<=n;i++)
    {
    	cin>>sum[i].time;
    	sum[i].id=i;
	}
	
	sort(sum+1,sum+n+1,cmp);

	cout<<sum[1].id;
	for(int i=2;i<=n;i++)
		cout<<" "<<sum[i].id;
	cout<<endl;
	
    return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

const int N = 100001;

int main() {
    int n;
    cin >> n;
    VI s(N+2);
    s[1] = 1;
    REP(i,n){
        int a, b;
        scanf("%d %d", &a, &b);
        s[a]++;
        s[b+1]--;
    }
    FOR(i,1,N) s[i] += s[i-1];
    int ans = 0;
    REP(i,N+1) if (s[i] >= i) ans = i;

    cout << ans-1 << endl;

    return 0;
}

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

void Main()
{
    int64_t A, B, C, D;
    cin >> A >> B >> C >> D;
    while(true)
    {
        C -= B;
        if(C <= 0)
        {
            cout << "Yes" << endl;
            return;
        }
        A -= D;
        if(A <= 0)
        {
            cout << "No" << endl;
            return;
        }
    }
}

int main()
{
    Main();
}


Measured memory_bytes: 3632