akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
class Fruit {
  public:
    string name;
    double efficiency;
    Fruit(string _name, double _efficiency):
      name(_name),
      efficiency(_efficiency) {
    }
};
 
int main() {
  int N;
  while(cin >> N, N) {
    vector<Fruit> fruits;
    for(int n = 0; n < N; ++n) {
      string name;
      cin >> name;
      int seedCost;
      cin >> seedCost;
      int aTime = 0;
      int aFromLeafTime = 0;
      for(int i = 0; i < 5; ++i) {
        int t;
        cin >> t;
        aTime += t;
        if(i > 2) aFromLeafTime += t;
      }
      int nfruit;
      cin >> nfruit;
      int aFruitPrice;
      cin >> aFruitPrice;
      int ngrow;
      cin >> ngrow;
      int tTime;
      tTime = aTime + aFromLeafTime * (ngrow - 1);
      int price;
      price = aFruitPrice * nfruit * ngrow;
      int income;
      income = price - seedCost;
      double efficiency;
      efficiency = (double)income / (double)tTime;
      Fruit fruit(name, efficiency);
      fruits.push_back(fruit);
    }
    sort(fruits.begin(), fruits.end(), [](Fruit left, Fruit right) {
      if(left.efficiency == right.efficiency) return left.name < right.name;
      return left.efficiency > right.efficiency;
    });
    for(int i = 0; i < N; ++i) cout << fruits[i].name << endl; //cout << fruits[i].name << " " << fruits[i].efficiency << endl;
    cout << '#' << endl;
  }
  return 0;
}

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

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

    int minxy = min(2*x,2*y);
    int maxxy = max(2*x,2*y);

    int p = a*x + b*y;
    int q = c*minxy + a*(x-minxy/2) + b*(y-minxy/2);
    int r = c*maxxy;

    //cout << p << " " << q << " " << r << endl;

    cout << min(min(p,q),r) << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
#define mod 1000000007
#define INF 0x3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define endl "\n" 
#define pb push_back
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define mp make_pair
#define print(v); for(auto x:v) cout<<x<<" "; cout<<endl;
typedef long long int ll;
int main()
{
    fast;
    ll n, k;
    cin >> n >> k;
    if(n % k == 0){
        cout << 0 << endl;
    }
    else{
        ll ans = n - ((n / k) * k);
        if(abs(ans - k) < ans){
            ans = abs(ans - k);
        }
        cout << ans << endl;
    }


    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(int argc, char *argv[])
{
  int h, w;
  cin >> h >> w;
  vector<vector<string>> s(h, vector<string>(w));
  rep(i, h) {
    rep(j, w) {
      cin >> s.at(i).at(j);
    }
  }
  rep(i, h) {
    rep(j, w) {
      if (s.at(i).at(j) == "snuke") {
        cout << (char)('A' + j) << i+1 << endl;
      }
    }
  }
  return 0;
}


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

//Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

//Type Definitions:
typedef long long ll;
typedef unsigned long long ull;

//Constants:
const int INF = 2e9;
const int MOD = 1e9 + 7;

//Global Variables:

//Prototype Declarations:
int gcd(int, int);

//================ Main Loop ================
int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    ll ans = 1;
    ll c[3] = {0, 0, 0};
    for(int i = 0; i < n; i++) {
        /*if(c[1] == 0 && a[i] == 0) {
            c[1]++;
            ans *= 2;
        } else if(c[1] == 0 && a[i] == a[i - 1] + 1) {
            c[0]++;
        } else if(c[2] == 0 && a[i] == 0) {
            c[2]++;
        } else {*/
        if(i == 0 && a[i] != 0) {
            ans = 0;
            break;
        }
        int buff = 0;
        for(int j = 0; j < 3; j++) {
            if(a[i] == c[j]) {
                if(buff == 0) {
                    c[j]++;
                }
                buff++;
            }
        }
        if(buff == 0) {
            ans = 0;
            break;
        }
        //cout << "bf" << buff << endl;
        ans *= buff;
        ans %= MOD;
        //}
        //cout << c[0] << " " << c[1] << " " << c[2] << " " << ans << endl;
    }
    cout << ans % MOD << endl;
    return 0;
}
//===========================================

//Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>

using namespace std;

int main(){
  string str;
  int check=0;
  cin>>str;

  for(int i=0;i<3;i++){
    if(str[i]=='a') check|=0x01;
    else if(str[i]=='b') check|=0x02;
    else if(str[i]=='c') check|=0x04;
  }

  if(check==0x07) cout<<"Yes\n";
  else cout<<"No\n";

  return 0;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) {

		// Listに標準入力の値を取得
		ArrayDeque<String> inputs = new ArrayDeque<>();
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			while (br.ready()) {
				String[] lineArray = br.readLine().split(" ");
				Arrays.<String> stream(lineArray).forEach(s -> inputs.add(s.trim()));
			}
		} catch (IOException e) {
			e.printStackTrace();
		}

		// 入力取得
		int sheeps = Integer.parseInt(inputs.pop());
		int wolves = Integer.parseInt(inputs.pop());

		if (wolves >= sheeps) {
			System.out.println("unsafe");
		} else {
			System.out.println("safe");
		}

	}
}


Measured memory_bytes: 33644
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
    static final int MAX = 100100;
    InputStream in = System.in;
    PrintStream out = System.out;
    // static int dp[][] = new int[MAX][MAX];

    public void _main(String[] args) {
        Scanner sc = new Scanner(in);
        int x = sc.nextInt();
        int a = sc.nextInt();
        out.println((x<a)?0:10);
    }

    public static void main(String[] args) {
        new Main()._main(args);
    }
}


Measured memory_bytes: 23636
#include<iostream>
#include<vector>
#include<cstring>
using namespace std;

#define inRange(x,a,b) (a <= x && x < b)

int rev[2][2][1000001], count[2][2][500] = {}, naname[2][2] = {};

void play(int id, int n, int x, int &cnt){
    int i = rev[id][0][x], j = rev[id][1][x];
    count[id][0][i]++;
    if(count[id][0][i] == n)    cnt++;
    count[id][1][j]++;
    if(count[id][1][j] == n)    cnt++;
    if(i == j){
        naname[id][0]++;
        if(naname[id][0] == n)  cnt++;
    }
    if(i+j == n-1){
        naname[id][1]++;
        if(naname[id][1] == n)  cnt++;
        if(n == 1)  cnt-=3;
    }
}

int main(){
    int n, u, v, m;
    cin >> n >> u >> v >> m;
    memset(rev, 0x3f, sizeof(rev));
    int x;
    for(int i = 0; i < 2; i++){
        for(int j = 0; j < n; j++){
            for(int k = 0; k < n; k++){
                cin >> x;
                rev[i][0][x] = j;
                rev[i][1][x] = k;
            }
        }
    }
    int usa = 0, cat = 0;
    while(m-- > 0){
        int x;  cin >> x;
        if(rev[0][0][x] < n)    play(0, n, x, usa);
        if(rev[1][0][x] < n)    play(1, n, x, cat);
        int judge = (usa >= u ? 2 : 0) + (cat >= v ? -3 : 0);
        if(judge == 2){
            cout << "USAGI" << endl;
            return 0;
        }else if(judge == -3){
            cout << "NEKO" << endl;
            return 0;
        }else if(judge == -1){
            break;
        }
    }
    cout << "DRAW" << endl;
    return 0;
}


Measured memory_bytes: 18752
N = gets.to_i
a = gets.split.map(&:to_i)

num4 = a.select { |x| x % 4 == 0 }.size
a = a.reject { |x| x % 4 == 0 }

num2 = a.select { |x| x % 2 == 0 }.size
if num2 > 0
  a = a.reject { |x| x % 2 == 0 }
  a << 2
end

if a.size <= num4 + 1
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 10116
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n,a[101],g,l=0;
    double h=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        h+=a[i];
    }
    h=h/n*1.0;
    if(h>int(h)+0.5){
        g=int(h+1);
    }
    else{
        g=int(h);
    }
    for(int i=0;i<n;i++){
        l+=(a[i]-g)*(a[i]-g);
    }
    cout<<l<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;

/**
 * A Pair of Prizes
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			int N = parseInt(line);
			if (N == 0) break;

			int ans = 0;
			boolean a = false;

			StringTokenizer st = new StringTokenizer(br.readLine());

			while (st.hasMoreTokens()) {
				int k = parseInt(st.nextToken());
				if (k > 0) ans++;
				if (k > 1) a |= true;
			}

			System.out.println(a ? ans + 1 : "NA");
		}
	}
}

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

using namespace std;
using ll = long long;
using ull = unsigned 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 ALL(x) (x).begin(),(x).end()
#define MOD 1000000007


int main(){

  int n,m,x;
  cin >> n >> m >> x;
  vector<ll> c(n);
  vector<vector<ll>> v(n,vector<ll>(m));
  rep(i,n){
    cin >> c[i];
    rep(j,m)cin >> v[i][j];
  }
  ll res = 1ll << 60;
  for(int bit = 1;bit < (1 << n);bit++){
    vector<ll> sum(m,0);
    ll kk = 0;
    rep(i,n){
      if(bit >> i & 1){
        kk += c[i];
        rep(j,m)sum[j] += v[i][j];
      }
    }
    bool is = true;
    rep(i,m)if(sum[i] < x)is = false;
    if(is)res = min(res,kk);
  }
  if(res != (1ll << 60))cout << res << endl;
  else cout << -1 << endl;





  

  return 0;
}

Measured memory_bytes: 3636
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

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

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize,
        a: [i64; n],
        b: [i64; n],
    }
    let mut pool = vec![];
    for a in a {
        pool.push((a, 0));
    }
    for b in b {
        pool.push((b, 1));
    }
    pool.sort();
    const MOD: usize = 1_000_000_007;
    let mut ans = 1;
    let mut t = [0; 2];
    for &(_, i) in &pool {
        t[i] += 1;
        if t[0] > 0 && t[1] > 0 {
            ans *= t[0] * t[1];
            ans %= MOD;
            t[0] -= 1;
            t[1] -= 1;
        }
    }
    puts!("{}\n", ans);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int64_t abs(int64_t n) {
  if (n < 0) {
    n = -n;
  }
  return n;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
int64_t factorial(int64_t n) {
  if (n == 1) {
    return 1;
  }
  int64_t ans = factorial(n-1);
  return ans*n;
}

int main() {
  int n, m;
  cin >> n >> m;
  int64_t a = 1, b = 1;
  int64_t num = (int64_t)pow(10, 9)+7;
  if (n == m) {
    for (int i = 1; i <= n; i++) {
      a *= i;
      a %= num;
    }
    cout << (2*(a*a)%num)%num << endl;
  } else if (abs(n-m) == 1) {
    for (int i = 1; i <= n; i++) {
      a *= i;
      a %= num;
    }
    for (int i = 1; i <= m; i++) {
      b *= i;
      b %= num;
    }
    cout << (a*b)%num << endl;
  } else {
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
#define LLINF 2000000000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
// #define int long long

signed main(){
	int r;
	cin >> r;
	cout << r*r*3 << endl;
}


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

using namespace std;

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

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

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
    ll a,b;
    cin>>a>>b;
    ll x = gcd(a,b);
    cout<<a*b/x<<endl;
	return 0;
}

Measured memory_bytes: 256
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
inline bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
inline bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

ll cnt[10][10];

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll n;
  cin >> n;
  repr(i, 1, n+1){
    ll ii = i;
    ll j = 0;
    ll k = ii % 10;
    while(ii > 0){
      j = ii % 10;
      ii /= 10;
    }
    cnt[j][k]++;
  }
  ll ans = 0;
  rep(i, 10)rep(j, 10){
    ans += cnt[i][j]*cnt[j][i];
  }
  print(ans);
}


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

int main() {
    int a, b, c, d, sum = 0;
    cin >> a >> b >> c >> d;
    for(int i = a; i <= b; i++) {
        for(int j = c; j <= d; j++) {
            if(i == j) sum++;
        }
    }
    if(sum > 0) sum--;

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define MOD3 1000000000
#define MOD2 998244353 
float PHI = 1.6180339;
const float  PI_F=3.14159265358979f;
#define MAX 1000 m
#define endl "\n"    
#define manhunt 32 
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define pi 3.1415926535897932384626433
//typedef long long float;
#define int long long
//#define double long double
typedef pair<int, int> pii;
//#define float unsigned long long
#define FAST ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define CHAR_SIZE 26 

int modpow(int x, int n, int m) { if (n == 0) return 1%m; long long u = modpow(x,n/2,m); u = (u*u)%m; if (n%2 == 1) u = (u*x)%m; return u; } 


int add(int x, int y,int m) 
{
	x += y;
	if (x >= m) return x - m;
	return x;
}
int sub(int x, int y) 
{
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
int inv(int a, int m = MOD2)
{
	return modpow(a, m - 2, m);
}
int mul(int a, int b,int m) 
{
	return (long long) a * b % m;
}


int nCrModp(int n, int r, int p) 
{ 
    int C[r+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1; 
    for (int i = 1; i <= n; i++) 
    { 
        for (int j = min(i, r); j > 0; j--) 
            C[j] = (C[j] + C[j-1])%p; 
    } 
    return C[r]; 
} 

bool sortinrev(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 
       return (a.first > b.first); 
}

int32_t main()
{
    /* freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout); */
    FAST
    cout << fixed << setprecision(12);

    char ch;
    cin>>ch;
    int x=ch-'A';
    if(x>=0 && x<=26)
    cout<<"A"<<endl;
    else
    cout<<"a"<<endl;
    
    
    return 0;
}





Measured memory_bytes: 3640
n=int(input())
c=[]
s=[]
f=[]
for i in range(n-1):
  ci, si, fi=map(int, input().split())
  c.append(ci)
  s.append(si)
  f.append(fi)
for i in range(n):
  ans=0
  for j in range(i, n-1):
    if ans<s[j]:
      ans=s[j]
    ans=(ans+f[j]-1)//f[j]*f[j]+c[j]
  print(ans)

Measured memory_bytes: 3064
N = int(input())
W = []
W = list(map(int,input().split()))
S = sum(W)
temp = sum(W)/2
count = 0
for i in range(N):
    count += W[i]
    diff = S/2 - count
    if temp >= abs(diff):
        temp = abs(diff)
print(int(temp*2))

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <cstdlib>
#include <utility>
#include <map>
#include <set>
#include <ios>
#include <iomanip>
#include <functional>

using namespace std;

int main(){
    int n;
    cin >> n;
    int long long a[5] = {0, 0, 0, 0, 0};

    for(int i = 0; i < n; i++){
        string x;
        cin >> x;
        if(x[0] == 'M'){
            a[0]++;
        }
        else if(x[0] == 'A'){
            a[1]++;
        }
        else if(x[0] == 'R'){
            a[2]++;
        }
        else if(x[0] == 'C'){
            a[3]++;
        }
        else if(x[0] == 'H'){
            a[4]++;
        }
    }
    long long int ans = 0;
    for(int i = 0; i < 3; i++){
        if(i == 0){
            for(int j = 0; j < 3; j++){
                ans += a[i] * a[1] * a[2 + j];
            }
            for(int j = 0; j < 2; j++){
                ans += a[i] * a[2] * a[3 + j];
            }
            ans += a[i] * a[3] * a[4];
        }
        else if(i == 1){
            for(int j = 0; j < 2; j++){
                ans += a[i] * a[2] * a[3 + j];
            }
            ans += a[i] * a[3] * a[4];
        }
        else{
            ans += a[i] * a[3] * a[4];
        }
    }
    cout << ans;
    
}

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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF             2e9
#define INF_LL          1LL<<60
#define ll              long long
#define Ceil(x, n)      (((((x))+((n)-1))/n))
#define CeilN(x, n)     (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)    ((x)-(x)%(n))
#define ALL(x)          (x).begin(),(x).end()
typedef pair<ll, ll>    P;

int main() {
    int h, w;
    cin >> h >> w;
    vector<int> cnt(26, 0);
    REP(i, h) {
        string s;
        cin >> s;
        REP(j, s.size()) {
            cnt[s[j]-'a']++;
        }
    }   

    int tmp = 0;
    int tmp2 = 0;
    REP(i, 26) {
        tmp += cnt[i] / 4;
        cnt[i] -= cnt[i] / 4 * 4;
        tmp2 += cnt[i] / 2;
    }

    /* 上下埋めていく */
    REP(i, h/2) {
        tmp -= (w/2);
        if(w % 2 == 1) {
            tmp2--;
        }
    } 
    //cout << tmp << endl;

    if(h % 2 == 1) {
        tmp2 -= w/2;
    }
    //cout << tmp << endl;

    if(tmp < 0) {
        cout << "No" << endl;
        return 0;
    }

    if(tmp*2 + tmp2 < 0) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N,x,y;
    cin>>N;
    if(N%1000==0) cout<<"0"<<endl;
    else
    {
        y=N/1000;
         cout<<(y+1)*1000-N<<endl;
    }
    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }

vector<pll> G[100010]; 
ll ans[100010];

void dfs(int v, int p, ll dep){
  ans[v]=dep%2;
  for(auto pp:G[v]){
    if(pp.fi==p) continue;
    dfs(pp.fi, v, pp.se+dep);
  }
}

int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  rep(i,n-1){
    ll a,b,c;
    cin >> a >> b >> c;
    a--,b--;
    G[a].pb({b,c});
    G[b].pb({a,c});
  }
  dfs(0,-1,0);
  rep(i,n) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 10240
#include<bits/stdc++.h>
#define int long long 
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define all(a) a.begin(),a.end()
#define ld long double
#define ub upper_bound
#define lb lower_bound
#define pii pair<int,int>
using namespace std;
const int N = 2e3+1;
int vis[N];
signed main(){
    fast;
    int n,x,y;
    cin>>n>>x>>y;
    int mp[N+5]={};
    int dis[n+1][n+1];
    for(int i = 1;i<=n;i++){
        for(int j = 1;j<=n;j++){
            if(i == j){
                dis[i][i] = 0;
            }
            else{
                dis[i][j] = 1e18;
                dis[j][i] = 1e18;
            }
        }
    }
    for(int i = 1;i<n;i++){
        for(int j = i+1;j<=n;j++){
            int d1 = j - i;
            //cout<<i<<" "<<j<<" "<<d1<<" "<<d2<<endl;
            dis[i][j] = d1;
            dis[j][i] = dis[i][j];
        }
    }
    for(int i = 1;i<n;i++){
        for(int j = i+1;j<=n;j++){
            int d3 = dis[i][x] + (int)1 + dis[y][j];
            dis[i][j] = min(dis[i][j],d3);
            dis[j][i] = dis[i][j];
        }
    }
    for(int i = 1;i<n;i++){
        for(int j = i+1;j<=n;j++){
           // cout<<i<<" "<<j<<"->"<<dis[i][j]<<endl;
            mp[dis[i][j]]++;    
        }
    }
    for(int i = 1;i<=n-1;i++){
        cout<<mp[i]<<"\n";
    }
    return 0;
}

Measured memory_bytes: 31616
import bisect
from collections import defaultdict

N, K = map(int, input().split())
A_raw = list(map(int, input().split()))

A = [(a-1) % K for a in A_raw]
acc = [0] * (N+1)
for i in range(N):
    acc[i+1] = (acc[i] + A[i]) % K

cnt = defaultdict(list)
cnt[0].append(-1)
ans = 0
for i, a in enumerate(acc[1:]):
    if cnt[a]:
        ans += len(cnt[a]) - bisect.bisect_left(cnt[a], i - K+1)
        # print(bisect.bisect_right(cnt[a], i - K+1), i, i-K+2, ans)
        # print(i, len(cnt[a]) - bisect.bisect_left(cnt[a], i - K+1))
    cnt[a].append(i)
# print(cnt)
print(ans)


Measured memory_bytes: 128152
#include <iostream>
#include <vector>
#include <algorithm>

int main() {
  int N, i, j;
  std::cin >> N;
  
  int X[N];
  for (i = 0; i < N; i++) {
    std::cin >> X[i];
  }
  
  std::vector<int> vec;
  int k;
  for (i = 1; i <= 100; i++) {
    k = 0;
    for (j = 0; j < N; j++) {
      k += (X[j] - i) * (X[j] - i);
  	}
    vec.push_back(k);
  }
  
  int min = *std::min_element(vec.begin(), vec.end());
  std::cout << min << std::endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define case(i) cout<<"Case #"<<i<<": "
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pr;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 1e18;


int main() {
	int n, k; cin >> n >> k;
	vector<int> a(n), b(n);
	rep(i, 0, n) cin >> a[i] >> b[i];
	ll ans = 0;
	rep(i, 0, n) {
		if ((k & a[i]) == a[i]) ans += b[i];
	}
	rep(i, 0, 31) {
		int j = 30 - i;
		if ((k >> j) & 1) {
			int l = k - (1 << j);
			l |= (1 << j) - 1;
			ll sub = 0;
			rep(i, 0, n) {
				if ((l & a[i]) == a[i]) sub += b[i];
			}
			ans = max(ans, sub);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
N = int(input())
S = input()
def check(l):
  D = {}
  for i in range(N-l+1):
    s = S[i:i+l]
    if s not in D:
      D[s] = i
      continue
    if D[s]+l <= i:
      return True
  return False
a = 1
b = N
while a < b:
  i = (a + b)//2
  if not check(i):
    b = i
  else:
    if a == i:
      break
    a = i
r = b-1
print(r)


Measured memory_bytes: 9504
#include <stdio.h>
#include <iostream>
#include <vector>
using namespace std;

int main(void) {
	int n=0;
	vector<int> r;
	while (scanf("%d",&n) != EOF)
	{
		r.push_back((1+n)*n/2+1);
	}
	for (int i; i<r.size(); i++)
	{
		cout << r[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#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>;

int main() {
  int i, j, k, A,B,C,X,Y,yen=0;
  
  cin >> A >> B >> C >> X >> Y;
  
  
  
  if(2*C<A && 2*C<B){
    if(X>Y){
      cout << 2*C*X;
    }else{
      cout << 2*C*Y;
    }
    return 0;
  }
  
  if(2*C<A){
    yen+=2*C*X;
    if(Y>X){
      Y-=X;
      cout << yen+Y*B;
    } else {
      cout << yen;
    }
    return 0;
  }
  
  if(2*C<B){
    yen+=2*C*Y;
    if(X>Y){
      X-=Y;
      cout << yen+X*A;
    } else {
      cout << yen;
    }
    return 0;
  }
  
  if(2*C >= A+B){
    cout << A*X+B*Y;
    return 0;
  }
  
  if(2*C < A+B){
    if(X<Y){
      yen+=2*C*X;
      Y-=X;
      cout << yen+B*Y;
    } else {
      yen+=2*C*Y;
      X-=Y;
      cout << yen+A*X;
    }
    return 0;
  }
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;

int main(){
    int ans = 0;
    int n;
    cin >> n;

    if(n < 1000) {
        cout << "ABC" << endl;
    } else {
        cout << "ABD" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
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; }
const long long INF = 1LL << 60;

int main()
{
    int n;
    cin >> n;
    vector<int> p(n), q(n);
    rep(i,n) cin >> p.at(i);
    rep(i,n) cin >> q.at(i);

    vector<int> a(n);
    rep(i,n) a[i] = i+1;

    map<vector<int>,int> mp;

    do{
        mp[a] = mp.size();
    } while(next_permutation(a.begin(), a.end()));

    int ans;
    ans = abs(mp[p] - mp[q]);

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

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

using i64 = int64_t;

constexpr i64 MOD = 10000;

i64 dp[102][4][4]={0};

int main(){
    int n, k;
    cin >> n >> k;
    vector<pair<int, int>> v;
    for(int i=0;i<k;++i){
        int a, b;
        cin >> a >> b;
        v.emplace_back(a, b);
    }
    sort(v.begin(), v.end());
    dp[0][0][0] = 1;
    int d = 0;
    for(int i=1;i<=n;++i){
        for(int j=0;j<4;++j){
            for(int k=0;k<4;++k){
                if(v[d].first == i){
                    if(j == k && k == v[d].second)continue;
                    dp[i][k][v[d].second] += dp[i-1][j][k];
                    dp[i][k][v[d].second] %= MOD;
                }else{
                    for(int l=1;l<4;++l){
                        if(j == k && k == l)continue;
                        dp[i][k][l] += dp[i-1][j][k];
                        dp[i][k][l] %= MOD;
                    }
                }
            }
        }
        if(v[d].first == i)d++;
    }

    i64 ans = 0;
    for(int i=1;i<4;++i){
        for(int j=1;j<4;++j){
            ans += dp[n][i][j];
            ans %= MOD;
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3100
#include <stdio.h>




void sort(int *, int *, int *);
void swapd(int *,int *);

int main(void){
	
	int N;
	int a[1000], b[1000], c[1000];
	int i=0;

	do {
		scanf("%d", &N);
	} while (N > 1000);

	while (i < N) {
		scanf("%d%d%d", &a[i], &b[i], &c[i]);
		if (((1 <= a[i]) && (a[i] <= 1000)) && ((1 <= b[i]) && (b[i] <= 1000)) && ((1 <= c[i]) && (c[i] <= 1000))) {
			i++;		
		}

	}
	

	for (i = 0; i < N; i++) {
		sort(&a[i], &b[i], &c[i]);
		if ((c[i] * c[i]) == (a[i] * a[i] + b[i] * b[i])) {
			printf("YES\n");
		}
		else {
			printf("NO\n");
		}
	}

	return 0;
}

void swapd(int *x, int *y) {
	int tmp = *x;
	*x = *y;
	*y = tmp;
}

void sort(int *a, int *b, int *c) {
	if (*a > *b) swapd(a, b);
	if (*b > *c) swapd(b, c);
	if (*a > *b) swapd(a, b);
}

Measured memory_bytes: 588
#include <cassert>
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <cstdint>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;
  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0))return 0;
  long long x = 1;
  while (b > 0) {
    if (b & 1)x = (mod!=-1)?(x * a) % mod:x*a;
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

const long long MOD = 998244353;
// const long long MOD = 1e9 + 7;

using ll = long long;
using P=std::pair<long long,long long>;

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

  ll n,m;
  std::cin>>n>>m;

  std::vector<std::vector<ll>> swi(m);

  rep(i,0,m){
    ll k;
    std::cin>>k;
    rep(j,0,k){
      ll s;
      std::cin>>s;
      s--;
      swi[i].push_back(s);
    }
  }

  std::vector<ll> on(m);
  rep(i,0,m)std::cin>>on[i];

  ll ans=0;

  rep(bit,0,1ll<<n){
    bool isok=true;
    rep(i,0,m){
      ll cnt=0;
      for(auto e:swi[i])if((bit>>e)&1)cnt++;
      if(cnt%2!=on[i])isok=false;
    }
    if(isok)ans++;
  }

  std::cout<<ans<<"\n";

  return 0;
}


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

long long fact(long long m){
	long long x=1;
	for(long long i=1; i<=m; i++){
		x *= i;
		x %= 1000000007;
	}
	return x;
}
int main(void){
	long long n, m, ans=0;
	cin >> n >> m;
	if(abs(n-m)<2){
		ans = fact(n)*fact(m);
		ans %= 1000000007;
		if(n==m) ans *= 2;
		ans %= 1000000007;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
 
#define endl '\n'
#define loop(i, m, n) for (ll i = m; i < n; i++)
#define loope(i, m, n) for (ll i = m; i <= n; i++)
#define epool(i, m, n) for (ll i = m; i >= n; i--)
#define mod 1000000007
#define mod2 998244353
#define vi vector<ll>
#define pll pair<ll, ll>
#define fi first
#define se second
#define pb push_back
#define MP make_pair
#define empf emplace_front
#define empb emplace_back
#define ret(x) return cout << x,0;
#define all(v) v.begin(),v.end()
#define maxheap priority_queue<ll>
#define minheap priority_queue<ll,vector<ll>,greater<ll>>
const ll INF=1e18;
const double PI=4*atan(1);

#define SpeedForce                    \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

ll mpow(ll base,ll exp);
ll POW(ll base,ll exp);
ll gcd(ll a,ll b);
ll modInverse(ll n);
ll nCr(ll n, ll r);
ll myxor(ll a,ll b);

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

void solve(){
    ll n,x,t;
    cin  >> n >> x >> t;
    ll ans=n/x;
    if(n%x!=0) ans++;
    cout << ans*t << endl;

}

int32_t main(){
    SpeedForce
    ll i = 0,j = 0;

    int t;
    t=1;
    //cin >> t;
    while (t--){
        //cout << fixed << setprecision(10);
        solve();
    }
}

ll POW(ll base,ll exp){
    ll result = 1;
    while (exp > 0){
        if (exp & 1)
            result = ((ll)result * base);
        base = ((ll)base * base);
        exp >>= 1;
    }
    return result;
}

ll mpow(ll base, ll exp){
    base %= mod;
    ll result = 1;
    while (exp > 0){
        if (exp & 1)
            result = ((ll)result * base) % mod;
        base = ((ll)base * base) % mod;
        exp >>= 1;
    }
    return result;
}

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

ll modInverse(ll n) { 
    return mpow(n, mod-2); 
}
 
ll nCr(ll n, ll r){ 
   if (r==0) 
      return 1; 
    ll fac[n+1]; 
    fac[0] = 1; 
    for (int i=1 ; i<=n; i++) 
        fac[i] = (fac[i-1]*i)%mod; 
    return ((fac[n]* modInverse(fac[r]) % mod * 
            modInverse(fac[n-r]) % mod)%mod)%mod; 
}

ll myxor(ll a,ll b){
    return (a|b)&(~a|~b);
}

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


typedef long long LL;
const int INF = 0x3f3f3f3f;
const LL mod = 1e9 + 7;
const int N = 100005;
int dig[30];
LL dp[30][30];




LL dfs(int u, int pre, bool l) {
    if (u < 0) return 1;

  if (!l && pre != -1 && dp[u][pre] != -1) return dp[u][pre];
  
  LL res = 0;
  
  int ed = l ? dig[u] : 9;
  
  
  for (int i = 0; i <= ed; i++) {
  
    if (pre != -1 && abs(i - pre) > 1) continue;
    
    res += dfs(u - 1, i == 0 && pre == -1 ? -1 : i, l && i == ed);
    
  }
  
  if (!l && pre != -1) dp[u][pre] = res;
  
  return res;
}




LL solve(LL x) {

  int n = 0;
  
  while (x > 0) {
  
    dig[n++] = x % 10;
    
    x /= 10;
    
  }
  
  memset(dp, -1, sizeof dp);
  
  return dfs(n - 1, -1, 1);
}


int main() {

  
  LL k, n;
  
  cin >> k;
  
  n = 0;
  
  LL t = solve(n);
  
  LL l = n + 1, r = LLONG_MAX;

  while (l < r) {
  
    LL mid = l + (r - l) / 2;
    
    if (solve(mid) - t >= k)
    
      r = mid;
      
    else
    
      l = mid + 1;
    }
  
  
  cout << l << endl;
  
  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

X = int(input())

ans = 0

fv = X // 500
ans += fv * 1000

X -= fv * 500

five = X // 5
ans += five * 5

print(ans)


Measured memory_bytes: 2940
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    S = input()
    n = len(S)
    acgt = ['A', 'C', 'G', 'T']
    cnt = 0
    maxlen = 0
    for i in range(n):
        if S[i] in acgt:
            cnt += 1
            maxlen = max(maxlen, cnt)
        else:
            cnt = 0
    print(maxlen)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define nl cout<<'\n';
int main()
{
    int p,q;
    cin>>p>>q;
    if(p>=0&&p<=5)
      cout<<0;
    else if(p>=6&&p<=12)
      cout<<q/2;
    else
      cout<<q;
    nl;
    return 0;
}


Measured memory_bytes: 256
require 'pp'

x, y = gets.chomp!.split(" ").map(&:to_i)

z = {
    3 => 100000,
    2 => 200000,
    1 => 300000,
}

if x == 1 && y == 1
    puts 400000 + 600000
else
    puts z.fetch(x, 0) + z.fetch(y, 0)
end


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

int main(void){
  int i,N;
  cin >> N;
  int x,max=0,count=0;
  REP(i,N){
    cin >> x;
    if(max<=x){
      max = x;
      count++;
    }
  }
  cout << count << endl; 
  return 0;
}


Measured memory_bytes: 256
s=input()
n=len(s)
count=0
if s[0]=='0':
    for i in range(1,n):
        if i%2==1 and s[i]=='0':
            count+=1
        elif i%2==0 and s[i]=='1':
            count+=1
else:
    for i in range(1,n):
        if i%2==1 and s[i]=='1':
            count+=1
        elif i%2==0 and s[i]=='0':
            count+=1
print(count)

Measured memory_bytes: 3188
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> l(N);
  REP(i, N) cin >> l.at(i);
  sort(all(l));
  reverse(all(l));
  int sum = 0;
  REP(i, K) sum += l.at(i);
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
A,B,C,D,E,F = map(int,input().split())
c_max = 0
sw_max = 0
s_max = 0

for a in range(F//100*A+1):
    for b in range((F-a*A*100)//100*B+1):
        water = 100*(a*A+b*B)
        limit = F-water
        for c in range(limit//C+1):
            for d in range((limit-c*C)//D+1):

                sugar = c*C + d*D

                if water == 0 or sugar == 0:
                    continue
                conc = sugar / (sugar + water)
                if sugar/(water//100) <= E and conc > c_max:
                    c_max = conc
                    sw_max = sugar + water
                    s_max = sugar
if c_max ==0:
    sw_max = 100*A
    s_max=0
print(sw_max,s_max)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
const ll MOD = 1000000007;//998244353;
const int MAX_N = 1e5;
int dp[MAX_N];
vector<vector<int>> G(MAX_N);
int dfs(int v){
   if (dp[v] != -1)return dp[v];
   for (auto &&i : G[v]){
      dp[v] = max(dp[v], dfs(i)+1);
   }
   if (G[v].size()==0)dp[v]=0;
   return dp[v];
}
int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   int n, m; cin >> n >> m;
   rep(i,n)dp[i] = -1;
   rep(i,m){
      int x, y; cin >> x >> y;
      x--;y--;
      G[x].push_back(y);
   }
   int ans = 0;
   rep(i,n) ans = max(ans, dfs(i));
   cout << ans << endl;
}

Measured memory_bytes: 10952
import sys

inf = float('inf')

n, m, x = map(int, sys.stdin.readline().split())
C = []
A = []
for _ in range(n):
    c, *a = map(int, sys.stdin.readline().split())
    C.append(c)
    A.append(a)

def main():
    ans = inf
    for i in range(1 << n):
        res = [0] * m 
        cost = 0
        for j in range(n):
            if i >> j & 1:
                cost += C[j]
                for k in range(m):
                    res[k] += A[j][k]
        for r in res:
            if r < x: break
        else:
            ans = min(ans, cost)
    if ans == inf:
        print(-1)
    else:
        print(ans)


                
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 9232
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#pragma warning(disable: 4996)
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;


int main() {
	
	int H,A;

	cin >> H >> A;
	
	if(H%A!=0){
		cout << (H / A) + 1 << endl;
	}
	else {
		cout << H / A << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;


int main(void){
  int i;
  string s;
  
  cin >> s;
  
  if (s.size()==2) cout << s << endl;
  else{
    for (i=0;i<3;i++) cout << s[s.size()-i-1];
    cout << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; inline void fileio(const char* in, const char* out) { freopen(in, "r", stdin); freopen(out, "w", stdout); } 
#define TD typedef
#define forx(i,n) for(int i = 0; i < (n); ++i)
TD long long ll; TD long double ld; TD pair<int,int> pii; TD pair<ll, ll> pll; TD vector<int> VI; TD vector<bool> VB; TD vector<ll> VL;
const char nl = '\n'; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fll; const ld EPS = 1e-9, PI = acos(-1);
#define ff first
#define ss second

int main() {
  atexit([](){ cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << nl; });
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  // Emily <3
  int a,b,c;
  cin >> a >> b >> c;
  cout << ((a == b && b == c) ? "Yes" : "No") << nl;
  
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007


void solve()
{
	string s;
	cin>>s;
	if(s[0]==s[1] || s[1]==s[2] || s[2]==s[3])
		cout<<"Bad";
	else
	cout<<"Good";
    return;
}

int main()
{
        fast;
        ll q;
        q=1;
        // cin>>q;
        while(q--)
        	solve();
        
        return 0;
}

Measured memory_bytes: 3568