akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int H1,H2,M1,M2,K;
  cin >> H1 >> M1 >> H2 >> M2 >> K;
  
  int time1, time2, result;
  
  time1 = H1*60 + M1;
  time2 = H2*60 + M2;
  
  result = time2 - time1 - K;
 
  cout << result << endl;  
}


Measured memory_bytes: 3588
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(){
    
    int N;
    cin >> N;
    vector<int>H(N);
    int ans = 0;
    for(int i = 0; i < N; i++){
        cin >> H[i];
        int flg = 1;
        for(int j = 0; j < i; j++){
            if(H[j] > H[i])flg = 0;
        }
        if(flg)ans++;
    }
    cout << ans << endl;


    return 0;
}

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

int main(){
    int numbers[10000];
    int i,j;
    int N;
    int r = 1;
    int c = 0;
    scanf("%d",&N);
    for( i = 0; i < N; ++i){
        scanf("%d", &numbers[i]);
    }
    for( i = 0; i < N; ++i){
        r = 1;
        if(numbers[i] == 2){
            c++;
        }
        else if(numbers[i]%2 == 0){}
        else{
            for( j = 3; r != 0 && j <= sqrt(numbers[i]); j = j + 2){
                r = numbers[i] % j;
            }
            if(r != 0){
                c++;
            }
        }
    }
    printf("%d\n",c);
    return 0;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
	ll n, m, k;
	cin >> n >> m >> k;
	vector<ll> a(n + 1, 0);
	vector<ll> b(m + 1, 0);

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

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

	int ans = 0;
	for(int i = 0; i <= n; ++i)
	{
		if (k - a[i] < 0) continue;
		auto b_iter = upper_bound(b.begin(), b.end(), k - a[i]);
		int b_ind = distance(b.begin(), b_iter);
		// cout << i << " " << b_ind << endl;
		ans = max(ans, i + b_ind - 1);
	}
	cout << ans;

}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 6364
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
int getDigit(long long n);      // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      ((a)/GCD((a),(b))*(b))
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;

// code
// ------------------------------------------------
int main() {

  ll n,k;
  cin >> n >> k;

  rep(i,n)
  {
    ll a;
    cin >> a;
  }

  ll ans = kiriage(n-1,k-1);

  cout << ans << endl;

  return 0;
}
// funcの実体
// ------------------------------------------------
int getDigit(ll n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 0)
      break;
    i++;
  }
  return i;
}
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
/*
    Problem 49
    https://onlinejudge.u-aizu.ac.jp/problems/DPL_2_A
*/
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 20;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
int V, E;
vector<vector<int>> dist(MAX, vector<int>(MAX, NIL));
/* function */
void solve1() {
    int upper = 1 << V;
    // dp[状態][最後に訪れた街] : min
    vector<vector<int>> dp(upper , vector<int>(V, INF));
    // 頂点0startとする
    dp[1][0] = 0;
    for (int b = 1; b < upper; b++) {
        for (int from = 0; from < V; from++) {
            if (dp[b][from] == INF) continue;
            // 配るDP
            for (int to = 0; to < V; to++) {
                // toがすでに訪れていたら次へ
                if (b & (1 << to)) continue;
                // 辺がないなら次へ
                if (dist[from][to] == NIL) continue;
                // 次の状態をbitで管理
                int nextB = b | (1 << to);
                dp[nextB][to] = min(dp[nextB][to], dp[b][from] + dist[from][to]);
            }
        }
    }
    // dp[1<<V-1][i]
    // 0 -> 4 -> ... -> i
    // 0からstartして最後にiに着くような全部の街を通る最短距離
    // i -> 0を足して 0 -> ... -> i -> 0の距離を求める
    int ans = INF;
    for (int i = 0; i < V; i++) {
        if (dist[i][0] == NIL) continue;
        ans = min(ans, dp[upper - 1][i] + dist[i][0]);
    }
    cout << ((ans == INF) ? -1 : ans) << '\n';
}
void solve2() {
    int upper = 1 << V;
    // dp[状態][最後に訪れた街] : min
    vector<vector<int>> dp(upper , vector<int>(V, INF));
    dp[0][0] = 0;
    for(int s = 0; s < upper ; s++) {
        for(int i = 0; i < V; i++) {
            if(dp[s][i] == INF) continue;
            for(int j = 0; j < V; j++) {
                if(i == j || dist[i][j] == NIL || (s & (1<<j)))   continue;
                int nextS = s | (1 << j);
                dp[nextS][j] = min(dp[nextS][j], dp[s][i]+dist[i][j]);
            }
        }
    }

    int ans = dp[upper - 1][0];
    if(ans == INF)  ans = -1;
    cout << ans << endl;
}
/* main */
int main(){
    cin >> V >> E;

    for (int i = 0; i < E; i++) {
        int a, b, w;
        a--, b--;
        cin >> a >> b >> w;
        dist[a][b] = w;
    }
    // solve1();
    solve2();

}


Measured memory_bytes: 6196
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <math.h>
#include <bits/stdc++.h>
#include <queue>
#include <map>

using namespace std;

#define INF (1ll<<60)
#define INFint (1<<30)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;
// typedef pair<ll,ll> P;

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

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

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

// gcd
template<typename T>
T gcd(T a, T b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}

// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm( T m, T n ){
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;
    return ((m/gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}


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

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};

int cost[100010];
int main() {
    int N; cin >> N;
    vector<int>h(N);
    rep(i,N) cin >> h[i];
    Fill(cost, 0);

    cost[0]=0, cost[1]=abs(h[1]-h[0]);
    for(int i=2; i<N; i++){
        cost[i]=min(cost[i-1]+abs(h[i-1]-h[i]),
                    cost[i-2]+abs(h[i-2]-h[i]));
    }

    cout << cost[N-1] << endl;
    return 0;
}


Measured memory_bytes: 1024
let rec solve tList all b fList = 
  match fList with
  | 'a'::l -> if all > 0 then solve ("Yes"::tList) (all - 1) b l else solve ("No"::tList) all b l 
  | 'b'::l -> if all > 0 && b > 0 then solve ("Yes"::tList) (all - 1) (b - 1) l else solve ("No"::tList) all (b - 1) l 
  | _::l -> solve ("No"::tList) all b l 
  | [] -> tList
let [| _; a; b |] = stdin.ReadLine().Split(" ") |> Array.map int

stdin.ReadLine().ToCharArray() 
|> Array.toList 
|> solve [] (a + b) b 
|> List.rev
|> List.map (printfn "%s")

Measured memory_bytes: 46788
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>
#include <array>
#include <limits>
#define _USE_MATH_DEFINES
#include <cmath>

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define FORCLS(i,a,b) for(int i = (a); i <= (b); i++)
#define REPCLS(i,n) FORCLS(i,1,n)
// For debug
#ifdef _DEBUG
#define DD(x) cerr << #x << ":" << x << endl;
#define DDA(ary) \
cerr << #ary << ":" << endl;\
for (auto v : ary) { cerr << v << ","; }\
cerr << endl;
#else
#define DD(x)
#define DDA(ary)
#endif

const int MAX_LEN = 100005;

int main() {
	string board;
	cin >> board;
	int ans = 0;
	char prevC = ' ';
	for (char c : board) {
		if (c != prevC) ans++;
		prevC = c;
	}
	cout << ans - 1 << endl;

	return 0;
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Abc161B
    {
        public static void Main()
        {
            var nm = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            int n = nm[0];
            int m = nm[1];
            var a = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

            var sum = a.Sum();

            double threshold = sum / (double)(4 * m);

            if (a.Count(i => i >= threshold) >= m)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
    }
}


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

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

  vector<int> e(n), w(n);
  int et = 0, wt = 0;
  for (int i = 0; i < n; i++) {
    if (s[n - i - 1] == 'E') e[n - i - 1] = ++et;
    else e[n - i - 1] = et;
    if (s[i] == 'W') w[i] = ++wt;
    else w[i] = wt;
  }

  for (int i = 0; i < n; i++) {
    cerr << w[i] << " ";
  }cerr << endl;
  for (int i = 0; i < n; i++) {
    cerr << e[i] << " ";
  }cerr << endl;

  int mincnt = 1e9;
  for (int i = 0; i < n; i++) {
    // cerr << e[i] + w[i] << endl;
    mincnt = min(mincnt, e[i] + w[i]);
  }
  cout << mincnt - 1 << endl;

  return 0;
}

Measured memory_bytes: 3076
from collections import deque


def main():

    N, X, Y = map(int, input().split())
    G = [set() for _ in range(N)]
    for i in range(N - 1):
        G[i].add(i + 1)
        G[i + 1].add(i)
    G[X - 1].add(Y - 1)
    G[Y - 1].add(X - 1)

    ans = [0] * (N - 1)
    for i in range(N - 1):
        # bfs
        dist = [-1] * N
        dist[i] = 0
        q = deque([i])
        while len(q):
            v = q.pop()
            for nv in G[v]:
                if dist[nv] != -1:
                    continue
                q.appendleft(nv)
                dist[nv] = dist[v] + 1

        for j in range(i + 1, N):
            ans[dist[j] - 1] += 1

    for i in range(N - 1):
        print(ans[i])


if __name__ == '__main__':
    main()


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

//Main class start
public class Main {
    // solution starts here!!!
    public void solve() throws IOException {
        int a = in.ni();
        int b = in.ni();
        int c = in.ni();
        int d = in.ni();
    


        while(true){
            c = c - b;
            a = a - d;
            if(c<=0) {out.println("Yes");break;}
            else if(a<=0) {out.println("No");break;}

        }





    } //Solution ENDS Here !!!

    FastScanner in;
    FastWriter out;
    long maxLong = Long.MAX_VALUE  ,  minlong = Long.MIN_VALUE;
    int maxInt = Integer.MAX_VALUE ,  minInt = Integer.MIN_VALUE;
    double PI = 3.141592653589793238462643383279502884197169399;
    int digit(long s){int ans = 0;while(s>0){s/=10;ans++;}return ans;}
    long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}
    int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}
    int bit(long n){return (n==0)?0:(1+bit(n&(n-1)));}

    public void run() {
        try {
            in = new FastScanner();
            out = new FastWriter();

            solve();

            out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }


    class FastWriter extends PrintWriter {
        FastWriter() throws FileNotFoundException {
            super(System.out);
        }

        void printNext(int i) {
            print(i);
            print(' ');
        }

        void printNext(long i) {
            print(i);
            print(' ');
        }

        void printNext(char ch) {
            print(ch);
            print(' ');
        }


        <T extends Iterable<Integer>> void printIterable(T o) {
            for (Integer t : o) {
                printNext(t);
            }
        }

        void printlnArray(int[] a) {
            for (int i : a) {
                printNext(i);
            }
            println();
        }

        void printlnArray(long[] a) {
            for (long i : a) {
                printNext(i);
            }
            println();
        }


    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;


        boolean ready() throws IOException {
            return (br.ready() || st.hasMoreTokens());
        }

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

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        char nc(){
            return next().charAt(0);
        }

        double nd(){
            return Double.parseDouble(next());
        }

        int ni() {
            return Integer.parseInt(next());
        }

        long nl() {
            return Long.parseLong(next());
        }

    }

    public static void main(String[] arg) {
        new Main().run();
    }
}


Measured memory_bytes: 33032
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define mp make_pair
#define rlp(i,a,b) for(int i=a;i>b;i--)
#define ft first
#define sd second
#define pii pair<int,int>
#define all(vect) vect.begin(),vect.end()
#define rall(vect) vect.rbegin(),rend() 
const int num = 200001;
typedef long long ll;
ll pref[num];
int main()
{
	int n;
	string str;
	cin >> n;
	cin >> str;
	if(str[0]=='R')
		pref[0] = 1;
	rep(i,1,n)
	{
		int ans = 0;
		if(str[i]=='R')
			ans = 1;
		pref[i] = pref[i-1]+ans;	
	}
	int total = pref[n-1];
	int min1 = min(total,n-total);
	rep(i,0,n)
	{
		int val = i+1-pref[i];
		int left = total-pref[i];
		int mvs = max(val,left);
		//cout << val << " " << left << "\n";
		min1 = min(min1,mvs);
	}
	cout << min1 << "\n";



	return 0;
}

Measured memory_bytes: 5308
#include <bits/stdc++.h>
#define ll long long
using namespace std;
//const int MOD = 1189732207;
const int MOD = 1038294853;
int cnt[5001][10001];
int res[10001];
ll pow1(ll n, ll p, int MOD){
  ll r, c;
  r = 1;
  c = n;
  while(p){
    if(p & 1){
      (r *= c) %= MOD;
    }
    (c *= c) %= MOD;
    p /= 2;
  }
  return r;
}
int n, k;
int calc(int r[], int s, int MOD){

  int cnt1 = 0;
  for(int i = 0;i < k;i++)
    cnt1 += r[i], (cnt1 >= MOD && (cnt1 -= MOD));
  cnt1 = (pow1(2, s, MOD) - cnt1 + MOD) % MOD;
  return cnt1;
}
int main(){
  cin >> n >> k;
  int a[n + 1];
  for(int i = 1;i <= n;i++)
    cin >> a[i];
  cnt[0][0] = 1;

  for(int i = 1;i <= n;i++){
    for(int j = 0;j <= 10000;j++){
      cnt[i][j] = cnt[i - 1][j];
      if(a[i] <= j)
        cnt[i][j] += cnt[i - 1][j - a[i]];
      if(cnt[i][j] >= MOD)
        cnt[i][j] -= MOD;
    }
  }
  int cnt1 = calc(cnt[n], n, MOD);
//  int cnt11 = calc(cnt[n], n, MOD2);

  int ans = 0;
  for(int i = 1;i <= n;i++){
    for(int j = 0;j <= 10000;j++){
      res[j] = cnt[n][j];
    }
    for(int j = a[i];j <= 10000;j++){
      res[j] -= res[j - a[i]];
      if(res[j] < 0)
        res[j] += MOD;
    }
    int cnt2 = calc(res, n - 1, MOD);
//    int cnt22 = calc(res, n - 1, MOD2);
//    cout << cnt2 << endl;
    if(cnt2 * 2 % MOD == cnt1)
      ans++;
  }
  cout << ans;
}


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

using namespace std;

using int64 = long long;

int main() {
  int N;
  string S;

  cin >> N;
  cin >> S;
  int ret = 0;
  for(int i = 0; i + 1 < N; i++) {
    int add = 0;
    for(int k = 'a'; k <= 'z'; k++) {
      bool latte = false, malta = false;
      for(int j = 0; j <= i; j++) if(S[j] == k) latte = true;
      for(int j = i + 1; j < N; j++) if(S[j] == k)malta = true;
      add += latte & malta;
    }
    ret = max(ret, add);
  }

  cout << ret << endl;
}


Measured memory_bytes: 256
n,inc,dec=int(input()),[],[]
for _ in range(n):
  s,d,r=input(),0,0
  for c in s:
    d=d+(1 if c=='(' else -1)
    r=max(r,-d)
  (dec if d<0 else inc).append((d,r))
inc.sort(key=lambda x:x[1])
dec.sort(key=lambda x:x[0]+x[1])
p1,p2,ok=0,0,True
for s in inc:
  ok&=s[1]<=p1
  p1+=s[0]
for s in dec:
  ok&=p2>=s[0]+s[1]
  p2-=s[0]
ok&=p1==p2
print('Yes'if ok else'No')
    


Measured memory_bytes: 175252
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    long long n;
    cin>>n;
    long long num=100;
    long long ans=0;
    while(num<n)
    {
        num*=1.01;
        ans++;
    }
    cout<<ans;


}


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

using namespace std;

int gcd(int a, int b) {
    while (a > 0 && b > 0) {
        a %= b;

        swap(a, b);
    }

    return a + b;
}

int A, B, C;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie();
    cout.tie();

    cin >> A >> B >> C;

    if (C % gcd(A, B) == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
from bisect import bisect
GRADE = ["AAA","AA","A","B","C","D","E","NA"]
_500M = [3550,3750,4000,4300,5000,5500,7000]
_1000M = [7100,7700,8300,8900,10500,11600,14800]

while True:
    try:
        a,b = map(lambda a:int(float(a)*100),raw_input().split())
    except:
        break
    print GRADE[max(bisect(_500M,a),bisect(_1000M,b))]

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

vector<string> name;
vector<int> num;

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

    string tmp;
    cin >> tmp;
    name.push_back(tmp);
    num.push_back(1);

    for(int i=0; i < n-1; i++){
        cin >> tmp;
        int flag = 1;
        for(int j=0; j < (int)name.size(); j++){
            if(name[j] == tmp) {
                num[j] += 1;
                flag = 0;
            }
        }
        if(flag == 1){
            name.push_back(tmp);
            num.push_back(1);
        }
    }
//    cout << "size : " << name.size() << endl;

    cin >> m;
    for(int i=0; i < m; i++){
        cin >> tmp;
        for(int j=0; j < (int)name.size(); j++) if(name[j] == tmp) num[j] -= 1;
    }


    int ans = 0;
    for(int i=0; i < (int)name.size(); i++) ans = max(ans, num[i]);

    cout << ans << endl;


    //debug
    //for(int i=0; i<(int)name.size(); i++) cout << name[i] << " : " << num[i] << endl;

    return 0;
}


Measured memory_bytes: 256
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long int lo;
typedef pair< int,int > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t,vis[li];
int cev;
string s;
vector<int> v;

int main(void){
	cin>>s;
	for(int i=0;i<(int)s.size();i++){
		vis[s[i]]++;
		if(vis[s[i]]==2)cev++;
	}
	if(cev==2){cout<<"Yes\n";return 0;}
	cout<<"No\n";
	return 0;
}


Measured memory_bytes: 256
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes = "Yes", T no = "No") { cout << (val ? yes : no) << endl; }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}


#line 2 "abc164_c.cpp"

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

  int n;
  cin >> n;
  map<string, int> mp;
  REP(i, n) {
    string s;
    cin >> s;
    mp[s]++;
  }
  cout << mp.size() << endl;
}


Measured memory_bytes: 19200
#include <stdio.h>

int main(void)
{
	int x,y;
	scanf("%d %d",&x,&y);
	while(x!=0||y!=0){
		if(x>y){
			printf("%d %d\n",y,x);
			}
			else{
				printf("%d %d\n",x,y);
			}
		scanf("%d %d",&x,&y);
		}
	
	
	
	
	
	return 0;
}


Measured memory_bytes: 2032
import math
import bisect

x = int(input())
n = math.sqrt(x)

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    return divisors

li = make_divisors(x)
li.sort()
alpha = bisect.bisect_left(li,n,hi = len(li))

if int(n) ** 2 == x:
  print(2 * int(n) - 2)
else:
  print(li[alpha -1] + li[alpha] - 2)

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

template<typename T, typename E>
struct SegTree {
  typedef function<T(T, T)> F;
  typedef function<T(T, E)> G;
  typedef function<E(E, E)> H;
  typedef function<E(E, int)> P;
  int n;
  T td;
  E ed;
  F f;
  G g;
  H h;
  P p;
  vector<T> dat;
  vector<E> laz;
  SegTree(T td, E ed, F f, G g, H h, P p=[](E a, int b){return a*b;})
      : td(td), ed(ed), f(f), g(g), h(h), p(p) {}
  void init(int _n) {
    n = 1;
    while (n < _n) n *= 2;
    dat = vector<T>(2*n-1, td);
    laz = vector<E>(2*n-1, ed);
  }
  void build(vector<T> v) {
    int _n = v.size();
    init(_n);
    for (int i=0; i<_n; i++) dat[i+n-1] = v[i];
    for (int i=n-2; i>=0; i--)
      dat[i] = f(dat[2*i+1], dat[2*i+2]);
  }
  void eval(int len, int k) {
    if (laz[k] == ed) return;
    if (k*2+1 < n*2-1) {
      laz[2*k+1] = h(laz[2*k+1], laz[k]);
      laz[2*k+2] = h(laz[2*k+2], laz[k]);
    }
    dat[k] = g(dat[k], p(laz[k], len));
    laz[k] = ed;
  }
  T _update(int a, int b, E x, int k, int l, int r) {
    eval(r-l, k);
    if (b <= l || r <= a) return dat[k];
    if (a <= l && r <= b) {
      laz[k] = h(laz[k], x);
      return g(dat[k], p(laz[k], r-l));
    }
    T vl = _update(a, b, x, 2*k+1, l, (l+r)/2);
    T vr = _update(a, b, x, 2*k+2, (l+r)/2, r);
    return dat[k] = f(vl, vr);
  }
  T update(int a, int b, E x) { return _update(a, b, x, 0, 0, n); }
  T _query(int a, int b, int k, int l, int r) {
    eval(r-l, k);
    if (r <= a || b <= l) return td;
    if (a <= l && r <= b) return dat[k];
    T vl = _query(a, b, 2*k+1, l, (l+r)/2);
    T vr = _query(a, b, 2*k+2, (l+r)/2, r);
    return f(vl, vr);
  }
  T query(int a, int b) { return _query(a, b, 0, 0, n); }
};

int main()
{
  ll N; cin >> N;
  ll D; cin >> D;
  ll A; cin >> A;
  vector<ii> f;
  for (int i=0; i<N; i++){
    ll x, h; cin >> x >> h;
    f.push_back(make_pair(x, h));
  }
  sort(f.begin(),f.end());

  ll d = 2*D;
  vector<ll> X(N, 0);
  vector<ll> H(N, 0);
  for (int i=0; i<N; i++) {
    X[i] = f[i].first;
    H[i] = f[i].second;
  }
  SegTree<ll, ll> st(0, 0,
        [](ll a, ll b){return a+b;},
        [](ll a, ll b){return a+b;},
        [](ll a, ll b){return a+b;});
  st.build(H);

  int l = 0;
  ll ans = 0;
  while (l < N) {
    ll h = st.query(l, l+1);
    if (h < 1) {l++; continue;}
    int r = upper_bound(X.begin(), X.end(), X[l]+d) - X.begin();
    ll c = (h+A-1)/A;
    ans += c;
    st.update(l, r, -A*c);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 17004
#include <cstdio>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <vector>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <chrono>
#include <sstream>
#include <iomanip>
#define INF 1 << 30
#define MOD 1000000007;
#define pi 3.14159265358979
#define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r) for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r) for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define D(x) cout << x << endl
#define d(x) cout << x
#define all(x) (x).begin(), (x).end()
#define pub(x) push_back(x)
#define pob() pop_back()
#define puf(x) push_front(x)
#define pof() pop_front()
#define mp(x, y) make_pair((x), (y))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }
static const int dx[] = {0, 0, 1, -1};
static const int dy[] = {-1, 1, 0, 0};

int main() { 
  int n, k;
  cin >> n >> k;
  ll ans = 1;
  for (int i = 0; i < n; i++) {
    if (i == 0) {
      ans *= k;
    } else {
      ans *= k - 1;
    }
  }
  D(ans);
  return 0;
}



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

int main() {
    int N, T;
    cin>>N>>T;
    int c, t;
    int ans = 10000;
    for(int i=0;i<N;++i){
        cin>>c>>t;
        if(t <= T){
            if(c < ans)ans = c;
        }
    }
    if(ans==10000)cout<<"TLE"<<endl;
    else cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool check_palindrome(string s)
{
    int i=0;
    int n=s.length();
    while(i<=n/2)
    {
        if(s[i]==s[n-i-1])i++;
        else return false;
    }
    return true;
}



int main()
{
    
    string s;
    cin>>s;
    int n=s.length();
    string x=s.substr(0,(n-1)/2 );
    string y=s.substr((n+3)/2-1,n-1);
    
    if(check_palindrome(s)&&check_palindrome(x)&&check_palindrome(y))
        cout<<"Yes";
    else cout<<"No";
    

    return 0;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define lld long double
#define MOD 1000000007
#define CAP 10000000
#define inf 1000000000000000000LL
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define sz(v) v.size()
#define all(v)    v.begin(),v.end()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
ll power(ll x,ll y, ll md=MOD){ll res = 1;x%=md;while(y>0){if(y&1)res = (res*x)%md;x = (x*x)%md;y = y>>1;}return res%md;}
#define dbg(x) cout <<#x<<":"<<x<<endl;
 
#define int ll
 
ll min1() {return inf;}
ll max1() {return -inf;}
 
template<typename... Args>
int min1(int a, Args... args) {return min(a,min1(args...));}
template<typename... Args>
int max1(int a, Args... args) {return max(a,max1(args...));}

unordered_map<ll,ll> res;
map<ll,ll> cnt;

ll fen[101][64000];

void update(ll index, ll k, ll val){
	index++;
	while(index<=64000){
		fen[k][index] += val;
		index+=(index)&(-index);
	}
}

ll query(ll index, ll k){
	index++;
	ll ans = 0;
	while(index>0){
		ans+=fen[k][index];
		ans%=MOD;
		index-=(index)&(-index);
	}
	return ans%MOD;
}

signed main() {
	fast;
	
	ll n,k;
	cin>>n>>k;

	ll root = sqrt(n)+1;

	cnt[1] = n-(n/2);
	for(int i=2;i<=root;++i){
		ll temp = (n/i) - (n/(i+1));
		if(temp) cnt[i] = temp;
	}

	ll lim = n/(root+1);
	
	for(int i=1;i<=lim;++i){
		ll count = n/i;
		cnt[count]++;
	}

	int i = 0;
	for(map<ll,ll>::iterator it = cnt.begin(); it!=cnt.end(); ++it, ++i){
		res[i] = it->s;
	}

	ll tot = i;

	update(0,1,1);

	for(int i=2;i<=k;++i){
		for(int j=0;j<tot;j++){
			ll value = query(j,i-1);
			update(tot-j-1,i,(value*res[j])%MOD);
		}
	}

	ll ans = 0;
	for(int i=0;i<tot;++i){
		ans += (res[i]*query(i,k))%MOD;
		ans %= MOD;
	}
	ans%=MOD;
	cout<<ans;
	
}

Measured memory_bytes: 56740
fn input() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim().to_string()
}

fn main() {
    let line = &input();
    let seg: Vec<i32> = line
        .split_whitespace()
        .map(|s| s.parse::<i32>().unwrap())
        .collect();
    divisors(seg);
}

fn divisors(v: Vec<i32>) {
    let count = (v[0]..(v[1] + 1)).filter(|i| v[2] % i == 0).count();
    println!("{}", count);
}


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

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

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

int left(int i)
{
    return 2 * i;
}

void maxHeapify(vector<int>& A, int i)
{
    int l = left(i), r = right(i), largest;
    if (l < A.size() && A.at(l) > A.at(i)) {
        largest = l;
    } else {
        largest = i;
    }
    if (r < A.size() && A.at(r) > A.at(largest)) {
        largest = r;
    }
    if (largest != i) {
        swap(A.at(i), A.at(largest));
        maxHeapify(A, largest);
    }
}

void buildMaxHeap(vector<int>& A)
{
    for (int i = (A.size() - 1)/2; 0 < i; i--) {
        maxHeapify(A, i);
    }
}

int main()
{
    int H;
    cin >> H;
    vector<int> A(H + 1);
    for (int i = 1; i <= H; i++) {
        cin >> A.at(i);
    }
    buildMaxHeap(A);
    for (auto itr = A.begin() + 1; itr != A.end(); ++itr)
        cout << " " << *itr;
    cout << endl;
    return 0;
}

Measured memory_bytes: 4700
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int a, b, c;
  cin >> a >> b >> c;

  if (c > a + b + 1) {
    cout << a + b * 2 + 1 << endl;
  } else {
    cout << b + c << endl;
  }

  return 0;
}


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

string s;
 

int main(){
  int ans=0;
   cin>>s;
  int t[s.size()];
  for(int i=0;i<s.size();i++){
    t[i]=s[i]-'0';
  }
  if(s[0]=='1'){
    for(int i=0;i<s.size();i++){
      if(i%2==0){
        if(t[i]!=1){
          ans++;
        }
      }
      if(i%2==1){
        if(t[i]!=0){
          ans++;
        }
      }
    }
  }
  else{
    for(int i=0;i<s.size();i++){
      if(i%2==1){
        if(t[i]!=1){
          ans++;
        }
      }
      if(i%2==0){
        if(t[i]!=0){
          ans++;
        }
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 896
import java.awt.List;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Deque;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	private static final boolean TEST = false;

	public static void main(String[] args) {

		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n, k;
		if (TEST) {
			n = (int) (Math.random() * 50 + 2);
			k = (int) (Math.random() * (n - 2) + 2);
		} else {
			n = in.nextInt();
			k = in.nextInt();
		}
		int[] p = new int[n];
		if (TEST) {
			for (int i = 0; i < n; i++)
				p[i] = i + 1;
			int c = (int) (Math.random() * n);
			for (int i = 0; i < c; i++) {
				int a = (int) (Math.random() * n);
				int b = (int) (Math.random() * n);
				int t = p[a];
				p[a] = p[b];
				p[b] = t;
			}
			for (int i = 0; i < n; i++)
				System.out.print(p[i] + " ");
			System.out.println();
		} else {
			for (int i = 0; i < n; i++)
				p[i] = in.nextInt();
		}
		int r = 0;
		if (TEST) {
			r = testSolve(n, k, p);
			System.out.println(r);
			r = solve(n, k, p);
		} else
			r = solve(n, k, p);
		System.out.println(r);
		in.close();
	}

	private static int testSolve(int n, int k, int[] p) {
		int[][] t = new int[n - k + 1][n];
		for (int i = 0; i < t.length; i++) {
			t[i] = p.clone();
			Arrays.sort(t[i], i, i + k);
		}
		int r = 0;
		boolean[] f = new boolean[n - k + 1];
		for (int i = 0; i < t.length; i++)
			if (f[i])
				continue;
			else {
				r++;
				for (int j = i + 1; j < t.length; j++) {
					if (f[j])
						continue;
					f[j] = true;
					for (int x = 0; x < n; x++)
						if (t[i][x] != t[j][x]) {
							f[j] = false;
							break;
						}
				}
			}
		return r;
	}

	private static int solve(int n, int k, int[] p) {
		Deque<Integer> min = new ArrayDeque<>();
		Deque<Integer> max = new ArrayDeque<>();
		for (int i = 0; i < k; i++) {
			addMin(i, p, min);
			addMax(i, p, max);
		}
		boolean seq = false;
		if (min.size() == k)
			seq = true;
		int r = 1;
		for (int i = 0, j = k; j < n; i++, j++) {
			if (min.peekFirst() == i)
				min.pollFirst();
			if (max.peekFirst() == i)
				max.pollFirst();
			addMin(j, p, min);
			addMax(j, p, max);
			if (p[i] < p[min.peekFirst()] && j == max.peekFirst())
				continue;
			if (min.size() == k && seq)
				continue;
			r++;
			if (min.size() == k)
				seq = true;
//			System.out.println("-- " + i + " " + r);
		}
		return r;
	}

	private static void addMax(int e, int[] p, Deque<Integer> max) {
		while (!max.isEmpty()) {
			int r = max.peekLast();
			if (p[r] < p[e])
				max.pollLast();
			else
				break;
		}
		max.add(e);
	}

	private static void addMin(int e, int[] p, Deque<Integer> min) {
		while (!min.isEmpty()) {
			int r = min.peekLast();
			if (p[r] > p[e])
				min.pollLast();
			else
				break;
		}
		min.add(e);
	}
}

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

int binarySearch(int A[], int n, int key) {
  int left = 0;
  int right = n;
  int mid {0};
  while (left < right) {
    mid = (left + right) / 2;
    if (key < A[mid]) {
      right = mid;
    } else if (key > A[mid]) {
      left = mid + 1;
    } else {
      return mid;
    }
  }
  return -1;
}

const int MAX {100000};
int S[MAX];
int T[MAX];
int n, q;

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> S[i];
  cin >> q;
  for (int i = 0; i < q; i++) cin >> T[i];

  int ans {0};
  for (int i = 0; i < q; i++) {
    if (binarySearch(S, n, T[i]) != -1) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3564
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	int n;
	cin >> n;
	vector<pair<pair<string, int>, int>> p(n);
	rep(i,n){
		int t;
		string s;
		cin >> s >> t;
		p[i] = make_pair(make_pair(s, -1*t), i);
	}
	sort(all(p));
	for(const auto& x : p){
		cout << x.second+1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
#define PI 3.141592653589793
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}
const int INF = 1<<30;
const int MOD = 1000000007;
int dx[4] = {0,0,-1,1};
int dy[4] = {-1,1,0,0};

const int V = 100005;
vector<int> g[V*2];//0~100004はx,100005~200009はy
bool visited[V*2];
vector<int> cnt;

void dfs(int v){
  if(visited[v]) return;
  visited[v] = true;
  cnt[v/V]++; //vが100005未満だったらxの座標(0),それ以上ならyの座標(1)
  for(int u: g[v]) dfs(u);
}

int main(){
  int n; cin >> n;
  rep(i,n){
    int x,y; cin >> x >> y;
    y += V; //y座標は修正する
    g[x].push_back(y);
    g[y].push_back(x);
  }
  ll ans = 0;
  rep(i,V*2){
    if(visited[i]) continue;
    cnt = vector<int>(2);
    dfs(i);
    ans += (ll)cnt[0]*cnt[1];
  }
  ans -= n;
  cout << ans << endl;
  
  return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
///1<<3シフト演算子 とは　0001の1を三つずらして1000にする, これは8を表しておりつまりbitは0から7まで
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define CST(x) cout<<fixed<<setprecision(x)
#define PI 3.14159265359
#define MOD 1000000007
using namespace std;
using ll = long long;
using ld = long double;

//条件式 ? 真の場合の文 : 偽の場合の文
//string S  S,at(i),S += T,S += c,S.size(),S.substr(l)l文字目から最後まで,
///S.substr(l, r)l文字目からl+r-1文字目 n文字目から0個で空列を返せる
//*min_element(all(x)) *max_element(all(x))
//vi x; x.back(),x.front(),x.push_back(),x.pop_back()
//gcd(a, b)最大公約数
//sort(all(x)),reverse(all(x)),sort(x.begin()+l,a.begin()+r)lからrまで
//stack<int> a; a.push(x),a.pop(),a.top(),a.empty()bool
//queue<int> b; b.push(x),b.pop(),b.front(),b.empty()bool,b.size() 要素が小さい順
//priority_queue<int, vector<int>, greater<int>> c,c.top()
//map<int, int> M1; 変数[key] = value; 変数.erase(key); 変数.at(key); 変数.count(key)所属判定　変数.size()
//find(all(x), key)boolソート済みのベクトル
//*lower_bound(all(x),k)以上の最小の要素,*uppper_bound(all(x),k)より大きい最小の要素
//char('0'+cnt) 数字cntからcharへの変換
//int(char-'0') charからintへの変換
//binary_search(all(p),x) bool型

int main(){

    string s;
    cin >> s;
    int len = s.size();
    vector<int> a(len+1,0);
    rep(i,len) if(s.at(i) == '<') a.at(i+1) = a.at(i)+1;  
    for(int i = len-1; i >= 0; i--) if(s.at(i) == '>') a.at(i) = max(a.at(i) , a.at(i+1)+1);
    ll sum = 0;
    rep(i,a.size()) sum += a.at(i);
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 2820
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64,i64> P;
#define rep(i,s,e) for(int i = (s);i <= (e);i++)

int n;
int ma;
int mb;

int a[50];
int b[50];
int c[50];

int dp[50][500][500];

int main()
{
    rep(i,0,49) rep(j,0,499) rep(k,0,499)
        dp[i][j][k] = 1e9;
    dp[0][0][0] = 0;
    cin >> n >> ma >> mb;
    rep(i,1,n)
    {
        cin >> a[i] >> b[i] >> c[i];
    }
    rep(i,1,n) rep(j,0,450) rep(k,0,450)
    {
        //not take
        dp[i][j][k] = min(dp[i][j][k],dp[i - 1][j][k]);
        //take
        if(j - a[i] >= 0 && k - b[i] >= 0)
            dp[i][j][k] = min(dp[i][j][k] , dp[i - 1][j - a[i]][k - b[i]] + c[i]);
    }  
    int result = 1e9;
    int le = ma;
    int ri = mb;
    while(le <= 450 && ri <= 450)
    {
        result = min(result , dp[n][le][ri]);
        le += ma;
        ri += mb;
    }

    if(result == 1e9) result = -1;
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 49024
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	//n := r.nextInt()
	r.Scan(true)
	h := r.nextStringArray().toInts()

	maxInt := func(a int, vs ...int) int {
		for i := range vs {
			v := &vs[i]
			if a < *v {
				a = *v
			}
		}
		return a
	}

	ans := 0
	hw := -1
	hcnt := 0
	for _, hi := range h {
		if hw < hi {
			ans = maxInt(ans, hcnt)
			hcnt = 0
		} else {
			hcnt++
		}
		hw = hi
	}
	ans = maxInt(ans, hcnt)
	fmt.Fprintln(stdout, ans)
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
string alpha = "abcdefghijklmnopqrstuvwxyz";
const int mod = 1e9+7;
const int mod1 = 998244353;
const int inf = 2e18+5;
const int nax = 200005;
const int mxm = 1e12;
int a[nax],f[nax];
int n,k;
void solve()
  {
   cin>>n>>k;
   loop(i,0,n)
    cin>>a[i];
   loop(i,0,n)
    cin>>f[i];
   sort(a,a+n);
   sort(f,f+n,greater<int>());
   int lo = 0,hi = mxm;
   int ans = 0;
   while(lo<=hi){
    int mid = (lo+hi)/2;
    int temp = 0;
    loop(i,0,n)
     temp += max(0ll,a[i]-mid/f[i]);
   if(temp<=k)
     hi = mid - 1;
   else
     lo = mid + 1;
   }
   cout<<lo;
  }
signed main()
 {
   
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0); 
 
       solve();    
  //cerr<<END<<1.0*clock();
  return 0;
} 

Measured memory_bytes: 6668
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
from bisect import bisect_left, bisect_right
import random
from itertools import permutations, accumulate, combinations
import sys
import string



INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7



n = I()
L = [(0, 0)] + sorted([(k, v) for k, v in Counter(Counter(LI()).values()).items()])
m = len(L)
acc = [0] * m
ret = 0
for j in range(m):
    k, v = L[j]
    ret += k * v
    acc[j] = ret


v_acc = [0] * m
ret = 0
for l in range(m - 1, -1, -1):
    ret += L[l][1]
    v_acc[l] = ret


v_acc += [0]



for i in range(1, n + 1):
    ok = 0
    ng = n // i + 1
    while ng > ok + 1:
        mid = (ng + ok) // 2
        lower_num = bisect_right(L, (mid, INF))
        if acc[lower_num - 1] + v_acc[lower_num] * mid >= i * mid:
            ok = mid
        else:
            ng = mid
    print(ok)

Measured memory_bytes: 122520
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new java.util.Scanner(System.in);
        int n = scan.nextInt();
        int[] a = new int[n];
        boolean b = false;
        for(int i = 0; i < n; i++){
            a[i] = scan.nextInt();
        }
        Arrays.sort(a);
        for(int i = 0; i < n - 1; i++){
            if(a[i] == a[i + 1]){
                b = true;
                break;
            }
        }
        if(!b){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
    }
}

Measured memory_bytes: 87064
#include <iostream>

using namespace std;

int main() {
    int H, W;

    while (1) {
        cin >> H >> W;
        if (H == 0 && W == 0) break;
        else {
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    if ((i + j) % 2 == 0) {
                        cout << "#";
                    }
                    else {
                        cout << ".";
                    }
                }
                cout << endl;
            }
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3096
N,x = map(int,raw_input().split())
a = map(int,raw_input().split())
a.sort()
if sum(a)<x:
  print N-1
else:
  ans = 0
  for i in range(N):
    if x >= a[i]:
      x -= a[i]
      ans += 1
  print ans

Measured memory_bytes: 2568