akhauriyash/Code-Regression huggingface dataset:
def resolve():
    m,d=map(int, input().split())
    cnt=0
    for i in range(1,m+1):
        for j in range(22,d+1):
            if j//10>=2 and j%10>=2 and i==(j//10)*(j%10):
                cnt+=1
    print(cnt)
resolve()

Measured memory_bytes: 3060
use proconio::input;
use proconio::marker::{Chars, Usize1};
use std::iter::Iterator;
use std::collections::*;
use std::cmp::*;
use itertools::Itertools;

#[allow(unused_macros)]
macro_rules! max {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      max($x,max!($($xs)+))
    };
  }
  
  #[allow(unused_macros)]
  macro_rules! min {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      min($x,min!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
    b: char,
    }

    if b == 'A' {
      println!("T");
    }else if b == 'T' {
      println!("A");
    }else if b == 'C'{
      println!("G");
    }else {
      println!("C");
    }
    
}


Measured memory_bytes: 2124
func pow(_ x: Int, _ n: Int, mod: Int) -> Int {
    precondition(n >= 0 && mod > 1)
    if n == 0 { return 1 }

    var u = pow(x, n/2, mod: mod)
    u = u*u % mod
    if n%2 == 1 { u = u*x % mod }
    return u
}

//=============================================================================

let MOD = Int(1e9+7)

let line = readLine()!.split(separator: " ").map { Int($0)! }
let (N, M) = (line[0], line[1])

var modFactorial = [1]
for i in 1...M {
    modFactorial.append(modFactorial[i-1] * i % MOD)
}

func modinv(_ x: Int) -> Int {
    pow(x, MOD-2, mod: MOD)
}

func modperm(_ n: Int, _ k: Int) -> Int {
    modFactorial[n] * modinv(modFactorial[n-k]) % MOD
}

func modcomb(_ n: Int, _ k: Int) -> Int {
    modperm(n, k) * modinv(modFactorial[k]) % MOD
}

var sigma = 0
for i in 0...N {
    var x = 1
    x *= modcomb(N, i)
    x %= MOD
    x *= modperm(M, i)
    x %= MOD
    x *= modperm(M-i, N-i)
    x %= MOD
    x *= modperm(M-i, N-i)
    x %= MOD
    x *= i%2 == 0 ? 1 : -1
    sigma += x
}
sigma = sigma % MOD + (sigma < 0 ? MOD : 0)
print(sigma)


Measured memory_bytes: 12240
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Rishabhdeep Singh
 */

// doot diddly donger cuckerino Hahahahahah
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace __gnu_cxx;
using namespace std;

// @formatter:off
#define PB              push_back
#define EB              emplace_back
#define F               first
#define S               second
#define all(x)          begin(x), end(x)
#define rall(x)         rbegin(x), rend(x)
#define sz(x)           (long long) (x).size()
#define IOS             ios::sync_with_stdio(false);cin.tie(NULL); cout << fixed << setprecision(12);
#define IN_REP          int tt; cin >> tt; while(tt--)
#define sim             template<typename T
#define ris             return *this
#define dor             > debug & operator <<
#define eni(x)          sim > typename enable_if<sizeof dud<T>(0) x 1, debug&>::type operator<<(T i)
sim> struct rge { T b, e; };
sim> rge<T> range(T i, T j) { return rge<T>{i, j}; }
sim> auto dud(T *x) -> decltype(cerr << *x, 0);
sim> char dud(...);
struct debug {
#ifdef LOCAL
  ~debug() { cerr << endl; }
  eni(!=) { cerr << boolalpha << i; ris; }
  eni(==) { ris << range(all(i)); }
  sim, typename U dor(pair<U, T> d) { ris << "(" << d.first << ", " << d.second << ")"; }
  sim dor(rge<T> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
  sim dor(const T&) { ris; }
#endif
};
#define pr(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vb = vector<bool>;

using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const ll MOD = (ll) 1e9 + 7;
const ld PI = acos(-1);

template<typename T> T gcd(T x, T y) { return (y == 0) ? x : gcd(y, x % y); }
template<typename T> void mini(T& x, T y) { x = min(x, y); }
template<typename T> void maxi(T& x, T y) { x = max(x, y); }
template<typename T, typename U> string to_string(pair<T, U> p) { return to_string(p.F) + " " + to_string(p.S); }
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
// @formatter:on


class EDoubleFactorial {
  public:

    void solve(std::istream& cin, std::ostream& cout) {
        ll x;
        cin >> x;
        ll res = 0;
        if(x & 1){
            res = 0;
        }else{
            ll five = 10;
            while(five <= x){
                res += x / five;
                five *= 5;
            }
        }
        cout << res << '\n';
    }
};

int main() {
    IOS;
	EDoubleFactorial solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#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;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)

class Point {
  public:
  double x, y;
  Point(double x = 0, double y = 0): x(x), y(y) {}
  Point operator + (Point p) { return Point(x + p.x, y + p.y); }
  Point operator - (Point p) { return Point(x - p.x, y - p.y); }
  Point operator * (double a) { return Point(a * x, a * y); }
  Point operator / (double a) { return Point(x / a, y / a); }
  double norm() { return x*x + y*y; }
  double abs() { return pow(norm(), 0.5); }
  bool operator < (const Point &p) const {
    return x != p.x ? x < p.x : y < p.y;
  }
};
typedef Point Vector;
struct Segment {
  Point p1, p2;
};
double dot(Vector a, Vector b) {
  return a.x * b.x + a.y * b.y;
}
Point project(Segment s, Point p) {
  Vector base = s.p2 - s.p1;
  double r = dot(p-s.p1, base) / base.norm();
  return s.p1 + base * r;
}
Point reflect(Segment s, Point p) {
  return p + (project(s, p) - p) * 2.0;
}
double cross(Point a, Point b) {
  return a.x*b.y - a.y*b.x;
}
string ccw(Point p0, Point p1, Point p2) {
  Vector a = p1 - p0, b = p2 - p0;
  if (cross(a, b) > EPS) return "COUNTER_CLOCKWISE";
  if (cross(a, b) < -EPS) return "CLOCKWISE";
  if (dot(a, b) < -EPS) return "ONLINE_BACK";
  if (a.norm() < b.norm()) return "ONLINE_FRONT";
  return "ON_SEGMENT";
}
int main() {
  Point p0, p1;
  cin >> p0.x >> p0.y >> p1.x >> p1.y;
  ll n;
  cin >> n;
  rep(i, n) {
    Point p2;
    cin >> p2.x >> p2.y;
    cout << ccw(p0, p1, p2) << endl;
  }
}


Measured memory_bytes: 3280
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};
 
char big(char c) {
  return c + 'A' - 'a';
}

int main() {
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;
  cout << big(s1[0]) << big(s2[0]) << big(s3[0]) << endl;
  return 0;
}

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

int main(){
    while(1){
        stack<double> st;
        while(1){
            char tmp[128];
            if(scanf("%s", tmp) == EOF) return 0;
            if((tmp[0]=='+' || tmp[0]=='-' || tmp[0]=='*' || tmp[0]=='/')&& tmp[1] == '\0'){
                double a = st.top();
                st.pop();
                double b = st.top();
                st.pop();
                if(tmp[0] == '+') st.push(a+b);
                if(tmp[0] == '-') st.push(b-a);
                if(tmp[0] == '*') st.push(b*a);
                if(tmp[0] == '/') st.push(b/a);
            }else{
                double a;
                sscanf(tmp, "%lf", &a);
                st.push(a);
            }
            if(getchar() == '\n') break;
        }
        printf("%lf\n", st.top());
    }
    return 0;
}

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

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

    int odd=0,four=0;

    for(int i=0;i<N;i++){
        long long a;
        cin >> a;
        if(a%2!=0) odd++;
        if(a%4==0) four++;
    }

    if(odd<=four) cout << "Yes" << endl;
    else if(odd==four+1 && odd+four==N) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

int n;
ll k;
pair<int, int> in[100007];

int main()
{
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        scanf("%d %d", &in[i].first, &in[i].second);
    }

    sort(in, in+n);

    ll sum = 0;
    for (int i = 0; i < n; i++) {
        sum += in[i].second;
        if (sum >= k) {cout << in[i].first << endl; return 0;}
    }
}


Measured memory_bytes: 1024
// abc132d.cpp : Blue and Red Balls
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define rep(i,n) for(int i=0;i<(n);i++)
#define upto(i,s,e,d) for(int i=(s);i<(e);i+=(d))
#define downto(i,s,e,d) for(int i=(s);i>(e);i-=(d))
#define oute(x) cout<<(x)<<endl
#define out(x) cout<<(x)

const ll MOD = 1000000007;
ll c[2001][2001];

void init(int N){
  upto(i,0,N+1,1){
    upto(j,0,N-i,1){
      if(i==0 || j==0){
        c[i][j] = 1;
      }else{
        c[i][j] = (c[i][j-1] + c[i-1][j]) % MOD;
      }
    }
  }
}

ll comb(int n, int r){
  // cout<<"n,r,n-r => "<<n<<", "<<r<<", "<<n-r<<" c(n-r,r): "<<c[n-r][r]<<"\n";
  if(n<0) return 0;
  if(r<0) return 0;
  if(n<r) return 0;
  return c[n-r][r];
}

int main(){
  int N,K; cin>>N>>K;
  int red = N-K, blue = K;

  init(N+1);

  upto(i,1,blue+1,1){
    oute((comb(red+1,i) * comb(blue-1,i-1)) % MOD);
  }

}

Measured memory_bytes: 31104
#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
int main(){
  int N;
  cin >> N;
  vector<long long> C(N);
  for (int i = 0; i < N; i++){
    cin >> C[i];
  }
  sort(C.begin(), C.end());
  long long ans = 0;
  for (int i = 0; i < N; i++){
    ans += C[i] * (N - i + 1) % MOD;
  }
  for (int i = 0; i < N * 2 - 2; i++){
    ans *= 2;
    ans %= MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4840
package main

import "fmt"

func scanNums(len int) (nums []int) {
    var num int
    for i := 0; i < len; i++ {
        fmt.Scan(&num)
        nums = append(nums, num)
    }
    return
}

func main() {
	var N, X int
	fmt.Scan(&N)
	fmt.Scan(&X)

	a := scanNums(N)

	var d, n int
	for i, v := range(a){
		d += v
		if d > X {
			break
		}
		n = i + 1 
	}
	fmt.Println(n + 1)
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
using namespace std;
typedef long long ll;
#define INF 2000000000
ll a[200005] = { 0 };
ll b[200005] = { 0 };
int main() {
	ll n, k, i, ans = 0, t;
	cin >> n >> k;
	for (i = 1; i <= n; i++) {
		a[i] += a[i - 1] + i;
	}
	b[n] = n;
	for (i = n-1; i >= 0; i--) {
		b[i] = b[i + 1] + i;
	}
	for (i = k; i <= n + 1; i++) {
		if (k < 1)break;
		t = b[n - i + 1] - a[i - 1] + 1;
		ans += t;
		ans %= 1000000007;
	}
	cout << ans;
}

Measured memory_bytes: 6644
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

const int N = 60;

int n, k;
char s[N];

int main()
{
    cin >> n >> k;
    cin >> s;
    for (int i = 0; i <= n; ++i)
    {
        if (i == k - 1)
        {
            int j = s[i] - 'A';
            if (j == 0) s[i] = 'a';
            if (j == 1) s[i] = 'b';
            if (j == 2) s[i] = 'c'; 
            break;
        }
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
def judge(S):
    a=int(S[:2])
    b=int(S[2:])
    if 1<=a<=12 and 1<=b<=12:
        return "AMBIGUOUS"
    elif 1<=a<=12:
        return "MMYY"
    elif 1<=b<=12:
        return "YYMM"
    else:
        return "NA"

S=input()
print(judge(S))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
signed main(){
    char a,b;
    cin>>a>>b;
    if(a>b)cout<<'>'<<endl;
    else if(a==b)cout<<'='<<endl;
    else cout<<'<'<<endl;
}


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

using namespace std;

int main(){
while(1){
	string s;
	cin>>s;
	if(s=="0"){
		break;
	}
	int a=0,b=0;
	for(int i=1;i<s.size();i++){
		if(s[i]=='A'){
			a++;
		}else{
			b++;
		}
	}
	if(a>b){
		a++;
	}else{
		b++;
	}
	cout<<a<<' '<<b<<endl;
}
	return 0;
}

Measured memory_bytes: 1188
import math
import copy

n = int(input())
ls_p = list(map(int, input().split()))
ls_q = list(map(int, input().split()))

ls_pc = copy.copy(ls_p)
ls_qc = copy.copy(ls_q)

s = 0
t = 0

ansp = 0
ansq = 0

for i in range(n):
    s = ls_pc[i]
    ls_ps = sorted(ls_p)
    j = ls_ps.index(s)
    ansp += math.factorial(n - i - 1) * j
    ls_p.remove(s)
    
    t = ls_qc[i]
    ls_qs = sorted(ls_q)
    k = ls_qs.index(t)
    ansq += math.factorial(n - i - 1) * k
    ls_q.remove(t)

print(abs(ansp - ansq))

Measured memory_bytes: 3444
while(True):
    x, y, z = map(int, input().split())
    if(x==-1 and y==-1 and z==-1):
        break
    if (x == -1 or y == -1):
        print("F")
        continue
    if (x + y >= 80):
        print("A")
        continue
    if (x + y >= 65):
        print("B")
        continue
    if (x + y >= 50):
        print("C")
        continue
    if (x + y >= 30):
        if(z >= 50):
            print("C")
            continue
        else:
            print("D")
            continue
    else:
        print("F")



Measured memory_bytes: 5592
#line 1 "test/algebra/primefactors.test.cpp"
#define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=NTL_1_A"

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

#line 1 "test/algebra/../../library/algebra/primefactors.cpp"
// list up all prime factors, including how many times does it have the prime
template <typename T = int>
void primeFactors(T a, map<T, int> &facs) {
    double sqrtA = sqrt(a);
    for (int i = 2; i <= sqrtA + 1e-10; ++i) {
        while (a % i == 0) {
            facs[i]++;
            a /= i;
        }
    }
    if (a > sqrtA)
        facs[a]++;
    return;
}
#line 8 "test/algebra/primefactors.test.cpp"

int main() {
    lint n;
    cin >> n;
    map<lint, int> facs;
    primeFactors(n, facs);
    cout << n << ":";
    for (auto &p : facs) {
        for (int i = 0; i < p.second; ++i) {
            cout << " " << p.first;
        }
    }
    cout << endl;
    return 0;
}



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

int main(){
  int N,M,Q;
  cin>>N>>M>>Q;
  int i,j,x,y,p,q;
  int num[N][N],ans[N][N];
  for(i=0;i<N;i++){
	for(j=0;j<N;j++){
	num[i][j]=0;
	}
  }
  for(i=0;i<M;i++){
	cin>>x>>y;
	num[x-1][y-1]+=1;
  }

  for(i=0;i<N;i++){
	for(j=0;j<N-i;j++){
	if(i==0) ans[j][j]=num[j][j];
	else if(i==1) ans[j][j+1]=num[j][j]+num[j+1][j+1]+num[j][j+1];
	else ans[j][j+i]=num[j][j+i]+ans[j][j+i-1]+ans[j+1][j+i]-ans[j+1][j+i-1];
	}
  }

  for(i=0;i<Q;i++){
	cin>>p>>q;
	cout<<ans[p-1][q-1]<<endl;
  }
  return 0;
}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
 
template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 1e9+7;
constexpr long long inf = 3e18;

signed main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int a[2],b[2];
	cin>>a[0]>>a[1]>>b[0]>>b[1];
	int ans=-inf;
	rep(i,2)rep(j,2)chmax(ans,a[i]*b[j]);
	cout<<ans<<"\n";
}

Measured memory_bytes: 3636
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::cin >> N;
  std::array<std::string, 3> ABC;
  tools::read(ABC);

  i64 answer = 0;
  for (i64 x = 0; x < N; ++x) {
    std::unordered_map<char, i64> map;
    for (i64 y = 0; y < 3; ++y) {
      ++map[ABC[y][x]];
    }
    answer += 3 - std::max_element(map.begin(), map.end(), [](const std::pair<char, i64>& x, const std::pair<char, i64>& y) { return x.second < y.second; })->second;
  }

  std::cout << answer << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int s;
    cin >> s;
    
    int a = s;
    vector<bool> check(1000010);
    for(int i = 1; i <= 1000000; i++) {
        if(check.at(a)) {
            cout << i << endl;
            break;
        }
        check.at(a) = true;
      	a = (a%2==0 ? a/2 : 3*a+1);
    }
}


Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;
public class Main{
	public static void main(String[] args) throws IOException {
		Stack<String> stack = new Stack<String>();
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str="";
		while((str = br.readLine())!=null){
			if(str.equals("0")){
				System.out.println(stack.pop());
			}
			else{
				stack.push(str);
			}
		}
	}
}

Measured memory_bytes: 16864
use ::proconio::input;

fn main() {
    input! {
        a: i64,
        b: i64,
        _c: i64,
        k: i64
    }
    if a >= k {
        println!("{}", k);
    } else {
        if a + b >= k {
            println!("{}", k - b);
        } else {
            println!("{}", 2 * a + b - k);
        }
    }
}


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

int main()
{
	int n, characters[26]{};
	std::fill(characters, characters + 26, 100);
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		std::string s;
		int tmp_table[26]{};
		std::cin >> s;
		for (auto &c: s)
			tmp_table[c - 'a']++;
		for (int i = 0; i < 26; i++)
			characters[i] = std::min(characters[i], tmp_table[i]);
	}
	for (int i = 0; i < 26; i++)
		for (int j = 0; j < characters[i]; j++)
			printf("%c", i + 'a');
	printf("\n");

	return 0;
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {

  // 1行目がinput[0], 2行目がinput[1], …に入る
  let inputArray = input.split("\n");
  let input1 = inputArray[0].split(" ");
  let n = Number(input1[0])
  let d = Number(input1[1])
  let xy = inputArray.slice(1).map(v1 => v1.split(" ").map(v2 => Number(v2)))
  // var n = Number(input1[0].split(' ')[0])
  // var k = Number(input1[0].split(' ')[1])
  // var nums = input1[1].split(' ').map(function (v) { return Number(v) })

  let ans = 0

  xy.forEach(el => {
    let distance = Math.sqrt(el[0]**2 + el[1]**2)
    if(distance<=d) ans++
  });

  // console.log(n, d, xy)

  // let n = Number(input)

  // console.log(input1
  //   , n
  //   , k
  //   , nums)

  // var results = 0
  // var arrayNum = 0

  // for (var i = nums.length; i > 0; i--) {
  //   arrayNum += i
  // }

  // const retArr2 = new Array(arrayNum).fill(0).map(function (v, idx) {
  //   var getNum = 1

  //   var idx2 = idx
  //   // console.log('bg', idx, getNum)
  //   while ((idx2 - (nums.length - getNum + 1)) >= 0) {

  //     getNum++
  //     // console.log(idx2)
  //     idx2 = idx2 - (nums.length - getNum + 1)
  //     // console.log(idx2, nums.length, getNum, (nums.length - getNum + 2))
  //   }
  //   console.log('ed', idx2, getNum)


  //   const retArr = new Array(getNum).fill(null).map(function (v99, idx3) {
  //     return nums[idx2 + idx3]
  //   })


  //   if (getNum > 3) {
  //     throw new Error()
  //   }

  //   return {
  //     getNum: getNum,
  //     sum: retArr//.reduce(function (prev, curr) { return prev + curr }, 0)
  //   }
  // })

  // console.log(retArr2)

  // while (getNum < nums.length) {

  //   for (var n1 = 0; n1 < nums.length - getNum + 1; n1++) {
  //     var n = nums.length - getNum + 1
  //     var sumNums = new Array(n).fill(0)

  //     sumNums = sumNums.map(function (v, idx) {
  //       return new Array(getNum).fill(0).map(function (v2, idx2) {
  //         return nums[n1 + idx2]
  //       }).reduce(function (prev, curr) { return prev + curr }, 0)
  //     })

  //     console.log("sumNums1", sumNums)

  //     sumNums = sumNums.map(function (v3) {
  //       if ((v3 % k) === getNum) {
  //         return 1
  //       } else {
  //         return 0
  //       }
  //     }).reduce(function (prev, curr) { return prev + curr }, 0)
  //     console.log("sumNums2", sumNums)

  //     console.log("sumNums", sumNums, results)
  //     results += sumNums
  //   }

  //   getNum++
  //   console.log("getNum", getNum, nums.length, results)
  // }

  // //文字列から10進数に変換するときはparseIntを使います
  // // var a = parseInt(i[0], 10);
  // // var b = parseInt(i[1], 10);
  // // var c = parseInt(i[2], 10);
  // var i1 = i.map(v => parseInt(v, 10))

  // if (n >= 30) {
  //   console.log("Yes");
  // } else {
  //   console.log("No");
  // }

  //出力
  console.log(ans);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

const int MAX_N = 200005;

int N, cnt, u, v, L, R;
long long ans, w, A[MAX_N], SUM[MAX_N][2];
priority_queue<pair<long long, pair<int, int>>> pq;
set<int> unused;

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

	cin >> N;

	for (int i = 1; i <= N; i++)
	{
		cin >> A[i];
	}

	for (int i = 1; i <= N; i++)
	{
		pq.push({ A[i], {i, i + 1} });
	}

	for (int i = 0; i <= N + 2; i++)
	{
		unused.emplace(i);
	}

	for (int i = 1; i <= N + 2; i++)
	{
		SUM[i][0] = SUM[i - 1][0];
		SUM[i][1] = SUM[i - 1][1];
		SUM[i][i & 1] += A[i];
	}

	while (cnt < N / 2)
	{
		w = pq.top().first;
		u = pq.top().second.first;
		v = pq.top().second.second;
		pq.pop();

		if (unused.find(u) != unused.end() && unused.find(v) != unused.end())
		{
			unused.erase(u);
			unused.erase(v);
			cnt++;
			ans += w;
			L = *prev(unused.lower_bound(u));
			R = *unused.lower_bound(v);
			if (1 <= L && R <= N + 1)
			{
				pq.push({ (SUM[R - 1][L & 1] - SUM[L - 1][L & 1]) - (SUM[R - 1][(L & 1) ^ 1] - SUM[L - 1][(L & 1) ^ 1]), {L, R} });
			}
		}
	}

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

Measured memory_bytes: 20316
<?php
  fscanf(STDIN, '%s', $str);
  $len = strlen($str);
  $count = $len / 2;
  $res = 0;
  for($i = 0; $i < $count; $i++) {
    $j = $len - $i - 1;
    if ($str[$i] !== $str[$j]) {
      $res++;
    }
  }
  echo $res;
  

Measured memory_bytes: 4728
#include <stdio.h>

int main(void)
{
	int n, x, c ;
	int i, j, k;

	while (1)
	{
		scanf("%d %d", &n, &x);
		if ((n == 0) && (x == 0))
		{
			break;
		}
		c = 0;
		for (i = 1;i <= n;i++)
		{
			for (j = i + 1;j <= n;j++)
			{
				for (k = j + 1;k <= n;k++)
				{
					if (i + j + k == x)
					{
						c++;
					}
				}
			}
		}
		printf("%d\n", c);
	}
	return 0;
}


Measured memory_bytes: 2112
// 0160
#include <iostream>
using namespace std;

int delivery_fee(int x, int y, int h, int w){
	if((x+y+h <= 60) && (w <= 2))
		return 600;
	else if((x+y+h <= 80) && (w <= 5))
		return 800;
	else if((x+y+h <= 100) && (w <= 10))
		return 1000;
	else if((x+y+h <= 120) && (w <= 15))
		return 1200;
	else if((x+y+h <= 140) && (w <= 20))
		return 1400;
	else if((x+y+h <= 160) && (w <= 25))
		return 1600;
	else
		return 0;
}

int main(){
	while(1){
		int n, x, y, h, w, price = 0;
		cin>>n;

		if(n == 0)
			break;

		for(int i=0;i<n;i++){
			cin>>x>>y>>h>>w;
			price += delivery_fee(x, y, h, w);
		}

		cout<<price<<endl;
	}
	return 0;
}

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

ll gcd(ll x,ll y){
    if(y==0)return x;
    x=x%y;
    gcd(y,x);
}
int main()
{
    ll n;
    cin>>n;
    vector<ll>a(n);
    rep(i,n) cin>>a[i];

    vector<ll>r(n);
    vector<ll>l(n);
    r[0]=a[0];
    for(int j=0;j<n-1;j++){
        r[j+1]=gcd(r[j],a[j+1]);
    }
    l[n-1]=a[n-1];
    for(int q=n-1;q>0;q--){
        l[q-1]=gcd(l[q],a[q-1]);
    }
    ll ans=0;
    rep(i,n){
        if (i == 0) {
            ans = max(ans, l[1]);
        } else if (i == n - 1) {
            ans = max(ans, r[n - 2]);
        } else {
            ans = max(ans, gcd(r[i - 1], l[i + 1]));
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2560
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
//#define MOD 998244353
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define popcount(x) __builtin_popcountll(x)

const int M=1000000007;
const int MM=998244353;


 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  if(m<=1)return 0;
  a%=m;
  ll ans=1LL;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}


 
ll poww(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;

}

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

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

const ll N=1e5+5;

ll sp[N];

void fill(){
  for(int i=1;i<N;i++)sp[i]=i;

    for(int i=2;i<N;i++){
      for(int j=i;j<N;j+=i){
        if(sp[j]==j)sp[j]=i;
      }
    }
}

vl f(N);


int main()
{ 

IOS;

ll n;cin>>n;

//fill();
vl a(n+1);

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

ll flag=0;

ll ans=0;

if(n&1){

if(f[0]!=1){
  cout<<0;
  return 0;
}

for(int i=2;i<=n-1;i+=2){
  if(f[i]!=2){
    cout<<0;
    return 0;
  }
}

cout<<powM(2,n/2,M);
return 0;

}

else {

  for(int i=1;i<=n-1;i+=2){
    if(f[i]!=2){
      cout<<0;
      return 0;
    }
  }

  cout<<powM(2,n/2,M);
  return 0;

}




return 0;
 
}


Measured memory_bytes: 4740
/*
 * main.cpp
 *
 *  Created on: 2020/05/13
 *      Author: yamashhi
 */
#include <iostream>

//動的配列<vector>の使用記述
#include <vector>
#include <deque>

using namespace std;


int main(){

	int roop;

	cin >> roop;
//	cout << roop << "回繰り返します" <<endl;

	deque<int> deq;
	deque<int> popdeq;

	while(roop){
		int insert;
		cin >> insert;

		switch (insert) {

		//dequeに挿入
		case 0:
			int fbchk,innum;
			cin >> fbchk >> innum;

			//(0)front or (1)back
			if(fbchk){
				//末尾に追加
				deq.push_back(innum);
//				cout << "末尾追加" << endl;
			}
			else{
				//先頭に追加
				deq.push_front(innum);
//				cout << "先頭追加" << endl;
			}
			break;

			//出力用deqに格納
		case 1:
			int popnum;
			cin >> popnum;
//			cout << deq[popnum] << endl;
			popdeq.push_back(deq[popnum]);
			break;

			//deque削除
		case 2:
			int delfbchk;
			cin >> delfbchk;

			//(0)front or (1)back
			if(delfbchk){
				//末尾を削除
				deq.pop_back();
//				cout << "末尾削除" << endl;
			}
			else{
				//先頭を削除
				deq.pop_front();
//				cout << "先頭削除" << endl;
			}
			break;

			break;
		default:
			break;
		}
		roop--;

	}

	int outnum = popdeq.size();
	int outren = 0;

	while(outnum){

		cout << popdeq[outren] << endl;

		outren++;
		outnum--;
	}



}



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

int main(){
  string s;
  cin>>s;
  
  bool ans = false;
  for(int i =0;i < s.length();i++)
    if(s[i] == '7') ans = true;
  
  if(ans)
    cout<<"Yes";
  else
    cout<<"No";
  return 0;
}

Measured memory_bytes: 3620
# coding: utf-8
def getLnInputs():
    return input().split()


def getLnIntInputs():
    return list(map(int, getLnInputs()))


def main():
    N = getLnIntInputs()[0]
    power = 1
    for i in range(1, N + 1):
        power *= i
        power %= 1000000007

    print(power)
    return


main()


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

using namespace std;

#define int long long

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

	int a, b, t, ans = 0;
	cin >> a >> b >> t;
	for (int i = 1; i * a <= t; i++)
		ans += b;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	while(1){
		int n;
		scanf("%d",&n);
		if(n==0)return 0;
		int i=0,sum=0;
		while(i<n/4){
			i++;
			int a;
			
			scanf("%d",&a);
			sum+=a;
		}
		printf("%d\n",sum);
	}
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
#define REP(i,N) for(ll i=0;i<N;++i)

int main() {
	ll a, b;
	cin >> a >> b;
	bool sum, multi;
	sum = (a+b) == 15;
	multi = (a*b) == 15;
	if (sum) cout << "+" << endl;
	else if (multi) cout << "*" << endl;
	else cout << "x" << endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i,a,b) for(register sign i=(sign)(a);i<=(sign)(b);++i)
#define Fordown(i,a,b) for(register sign i=(sign)(a);i>=(sign)(b);--i)
const int N=4e3+5;
template<typename T>bool cmax(T &a,T b){return (a<b)?a=b,1:0;}
template<typename T>bool cmin(T &a,T b){return (a>b)?a=b,1:0;}
template<typename T>T read()
{
	T ans=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')f=-1,ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch-'0'),ch=getchar();
	return ans*f;
}
template<typename T>void write(T x,char y)
{
	if(x==0)
	{
		putchar('0'),putchar(y);
		return;
	}
	if(x<0)
	{
		putchar('-');
		x=-x;
	}
	static char wr[20];
	int top=0;
	for(;x;x/=10)wr[++top]=x%10+'0';
	while(top)putchar(wr[top--]);
	putchar(y);
}
void file()
{
#ifndef ONLINE_JUDGE
	freopen("D.in","r",stdin);
	freopen("D.out","w",stdout);
#endif
}
const int mo=924844033;
int n,k;
void input()
{
	n=read<int>(),k=read<int>();
}
int ed[N];
int dp[N][N][2];
int g[N],mc[N];
void add(int &x,int y){x+=y;x-=(x>=mo?mo:0);}
void work()
{
	int now=0;
	For(i,1,k)For(j,0,1)
	{
		for(int l=i;l<=n;l+=k)now++;
		ed[now]=1;
	}
	//cerr<<now<<endl;
	dp[1][0][0]=1;
	For(i,1,n*2-1)For(j,0,min(i,n-1))
	{
		if(!ed[i])dp[i+1][j+1][1]=dp[i][j][0];
		add(dp[i+1][j][0],(dp[i][j][0]+dp[i][j][1])%mo);
	}
	For(i,1,n)g[i]=(dp[n*2][i][0]+dp[n*2][i][1])%mo;
	mc[0]=1;
	For(i,1,n)mc[i]=1ll*mc[i-1]*i%mo;
	int ans=mc[n];
	For(i,1,n)
	{
		if(i&1)add(ans,mo-1ll*g[i]*mc[n-i]%mo);
		else add(ans,1ll*g[i]*mc[n-i]%mo);
	}
	write(ans,'\n');
}
int main()
{
	//file();
	input();
	work();
	return 0;
}


Measured memory_bytes: 123648
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

type Card struct{ Number, Stock int }
type Cards []Card

func (c Cards) Len() int           { return len(c) }
func (c Cards) Swap(i, j int)      { c[i], c[j] = c[j], c[i] }
func (c Cards) Less(i, j int) bool { return c[i].Number > c[j].Number }

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	as := make([]int, n)
	var sum int64 = 0
	for i := range as {
		sc.Scan()
		as[i], _ = strconv.Atoi(sc.Text())
		sum += int64(as[i])
	}
	sort.Ints(as)

	var cs Cards = make([]Card, m)
	for i := range cs {
		sc.Scan()
		cs[i].Stock, _ = strconv.Atoi(sc.Text())
		sc.Scan()
		cs[i].Number, _ = strconv.Atoi(sc.Text())
	}
	sort.Sort(cs)

	var p int
lb:
	for _, v := range cs {
		for i := 0; i < v.Stock; i++ {
			if p >= len(as) || v.Number < as[p] {
				break lb
			}
			sum += int64(v.Number - as[p])
			p++
		}
	}
	fmt.Println(sum)
}


Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
//#include <bits/stdc++.h>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "Yes" : "No";
}



int main(){
    int k; cin >> k;
    if(k%2 == 0){
        cout << (k/2)*(k/2) << endl;
    }else{
        cout << ((k+1)/2)*((k-1)/2) << endl;
    }
}



Measured memory_bytes: 256
N, U, V = gets.split.map(&:to_i)
edges = (N - 1).times.map { gets.split.map(&:to_i) }
graph = Array.new(N) { [] }
edges.each do |(a, b)|
  a -= 1
  b -= 1
  graph[a].push(b)
  graph[b].push(a)
end

def bfs(graph, start)
  depths = Array.new(N)
  # u, parent, depth
  queue = [[start, nil, 0]]
  while !queue.empty?
    u, parent, depth = queue.shift
    depths[u] = depth
    graph[u].each do |v|
      next if v == parent
      queue.push([v, u, depth + 1])
    end
  end
  depths
end

t_depths = bfs(graph, U - 1)
a_depths = bfs(graph, V - 1)

ans = 0
N.times do |i|
  if t_depths[i] <= a_depths[i]
    depth = a_depths[i] - 1
    ans = depth if depth > ans
  end
end
puts ans


Measured memory_bytes: 20092
import java.util.*;
import java.util.ArrayList;

public class Main {

	public static class SparseGraph {
		private int n, m;
		private boolean directed;
		private ArrayList<ArrayList<Weight>> g;

		SparseGraph(int n, boolean directed) {
			this.n = n;
			this.m = 0;
			this.g = new ArrayList<>();
			this.directed = directed;
			for (int i = 0; i < n; i++) {
				g.add(i, new ArrayList<>());
			}
		}

		private void checkOutOfRange(int v) {
			if (v > n || v < 0) {
				throw new IllegalArgumentException("v is out of range");
			}
		}

		public int V() {
			return this.n;
		}

		public int E() {
			return this.m;
		}

		public void addEdge(int v, Weight weight) {
			if (this.hasEdge(v, weight)) {
				return;
			}
			g.get(v).add(weight);
			if (!directed) {
				int b = weight.getB();
				g.get(b).add(new Weight(b, v, (-1)*weight.getWeight()));
			}
			m++;
		}

		public boolean hasEdge(int v, Weight weight) {
			return g.get(v).contains(weight);
		}

		public List<Weight> adj(int v) {
			return g.get(v);
		}
	}

	private static List<Long> getStrings(Scanner sc, int num) {
		List<Long> stringList = new ArrayList<>();
		while(num>0) {
			long nextInt = sc.nextLong();
			stringList.add(nextInt);
			num--;
		}
		return stringList;
	}

	private static List<Ab> getEdge(Scanner sc, int num) {
		List<Ab> stringList = new ArrayList<>();
		while(num>0) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			stringList.add(new Ab(a ,b));
			num--;
		}
		return stringList;
	}

	private static class Weight{
		private int a;
		private int b;
		private long weight;

		public Weight(int a, int b, long weight) {
			this.a = a;
			this.b = b;
			this.weight = weight;
		}

		public int getA() {
			return a;
		}

		public void setA(int a) {
			this.a = a;
		}

		public int getB() {
			return b;
		}

		public void setB(int b) {
			this.b = b;
		}

		public long getWeight() {
			return weight;
		}

		public void setWeight(long weight) {
			this.weight = weight;
		}
	}

	private static class Ab{
		private int a;
		private int b;

		public Ab(int a, int b) {
			this.a = a;
			this.b = b;
		}

		public int getA() {
			return a;
		}

		public void setA(int a) {
			this.a = a;
		}

		public int getB() {
			return b;
		}

		public void setB(int b) {
			this.b = b;
		}
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		List<Long> hs = getStrings(sc, n);
		List<Ab> abs = getEdge(sc, m);
		SparseGraph sparseGraph = new SparseGraph(n+1, false);
		for (int i = 0; i < abs.size(); i++) {
			int aindex = abs.get(i).a;
			int bindex = abs.get(i).b;
			sparseGraph.addEdge(abs.get(i).a, new Weight(aindex, bindex, hs.get(bindex-1)- hs.get(aindex-1)));
		}
		int sum = 0;
		for (int i = 1; i <= n; i++) {
			List<Weight> list = sparseGraph.adj(i);
			if (list.isEmpty()) {
				sum++;
				continue;
			} else {
				boolean flag = false;
				for (int j = 0; j < list.size(); j++) {
					if (list.get(j).getWeight() >= 0) {
						flag = true;
						break;
					}
				}
				if (!flag) {
					sum++;
				}

			}
		}
		System.out.println(sum);
	}

}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)

#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define _repis(i,a,b,s) for(int i=a, i##_len(b); i<i##_len; i+=s)
#define REP(...) _overload3(__VA_ARGS__,_repis,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)

#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))

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

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl
#define POSS(n) cout<<((n)?"POSSIBLE":"IMPOSSIBLE")<<endl



int main(){
    string s;
    cin>>s;
    int mi=INF;

    set<char> cnt;
    REP(i,'a','z'){
        string t=s;
        int c=0;
        while(t.size()>1){
            cnt.clear();
            REPARR(j,t){
                cnt.insert(t[j]);
            }
            if(cnt.size()==1)break;

            string u;
            REP(j,sz(t)-1){
                if(t[j]==i){
                    u+=i;
                }else{
                    u+=t[j+1];
                }
            }
            t=u;
            c++;

        }
        chmin(mi,c);
    }
    cout<<mi<<endl;
    return 0;
}


Measured memory_bytes: 764
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

const pi = math.Pi

var mod int = pow(10, 9) + 7
var Umod uint64 = 1000000007
var ans int

func main() {
	reader.Split(bufio.ScanWords)
	N, _ := strconv.Atoi(read())
	M, _ := strconv.Atoi(read())
	A := make([]int, N)
	BC := make(SortBy, M)

	for i := 0; i < N; i++ {
		A[i], _ = strconv.Atoi(read())
	}

	for i := 0; i < M; i++ {
		BC[i].b, _ = strconv.Atoi(read())
		BC[i].c, _ = strconv.Atoi(read())

	}
	sort.Ints(A)
	sort.Sort(BC)

	for i := 0; i < N && 0 < len(BC); i++ {
		if A[i] < BC[0].c {
			A[i] = BC[0].c
			BC[0].b--
			if BC[0].b == 0 {
				BC = BC[1:]
			}
		} else {
			BC = BC[1:]
		}
	}

	for _, value := range A {
		ans += value
	}
	fmt.Println(ans)
}

/*  ----------------------------------------  */

var reader = bufio.NewScanner(os.Stdin)

func read() string {
	reader.Scan()
	return reader.Text()
}

func lcm(x, y int) int {
	return (x / gcd(x, y)) * y
}

func gcd(x, y int) int {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

var fac [1000000]int
var finv [1000000]int
var inv [1000000]int

func combination_init() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1

	// invは a^(-1) mod p
	// pをaで割ることを考える

	// p/a*(a) + p%a = p
	// p/a*(a) + p%a = 0          (mod p)
	// -p%a = p/a*(a)             (mod p)
	// -p%a *a^(-1)= p/a          (mod p)
	// a^(-1)= p/a * (-p%a)^(-1)  (mod p)
	// a^(-1) =

	for i := 2; i < 1000000; i++ {
		fac[i] = fac[i-1] * i % mod
		inv[i] = mod - inv[mod%i]*(mod/i)%mod
		finv[i] = finv[i-1] * inv[i] % mod
	}
}

func combination(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[y] * finv[x-y] % mod) % mod
	//return fac[x] / (fac[y] * fac[x-y])
}

func permutation(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[x-y] % mod) % mod
	//return fac[x] / fac[x-y]
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }
func ceil(x int) int   { return int(math.Ceil(float64(x))) }

type BC struct {
	b, c int
}
type SortBy []BC

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return a[i].c > a[j].c }

type PriorityQueue []int

func (h PriorityQueue) Len() int            { return len(h) }
func (h PriorityQueue) Less(i, j int) bool  { return h[i] < h[j] }
func (h PriorityQueue) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *PriorityQueue) Push(x interface{}) { *h = append(*h, x.(int)) }
func (h *PriorityQueue) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


Measured memory_bytes: 4992
#include<stdio.h>

int main(void)
{
	int H,W,i,j;
	while(1){
		scanf("%d %d",&H,&W);
		if(H==0 && W==0){
			break;
		}
		for(i=1;i<=H;i++){
			for(j=1;j<=W;j++){
				if(i==1||j==1||i==H||j==W){
					printf("#");
				}else{
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
import java.util.*;

class Main {
	
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		Integer[] num = new Integer[5];
		
		for(int i = 0; i < 5; i++) {
			num[i] = scan.nextInt();
		}
		
		Arrays.sort(num, Collections.reverseOrder());
		
		System.out.println(num[0] + " " + num[1] + " " + num[2] + " " + num[3] + " " + num[4]);
	}
}

Measured memory_bytes: 17180
// ABC144E2.cpp
#include <iostream>
#include<vector>
#include<algorithm>
#define rep(i,n) for (int i = 0; i < (n); i++) // 読み込みループ

using namespace std;

int main()
{
	int N;
	long long K;
	cin >> N >> K;
	vector<long long>A(N);
	vector<long long>F(N);
	vector<long long>AxF(N);
	/*
	for (int i = 0; i < N; i++)
	{
		cin >> A.at(i);
	}
	*/
	rep(i, N) cin >> A.at(i);
	sort(A.begin(), A.end()); // 昇順
	/*
	for (int i = 0; i < N; i++)
	{
		cin >> F.at(i);
	}
	*/
	rep(i, N) cin >> F.at(i);
	sort(F.begin(), F.end(), greater<long long>()); // 降順
	long long MAX = 0;
	for (int i = 0; i < N; i++)
	{
		AxF.at(i) = A.at(i) * F.at(i);
		MAX = max(MAX, AxF.at(i));
	}
	//
	long long  left = 0;
	long long right = MAX;
	long long ans = MAX;
	while (left < right) {
		bool goal = true;
		long long count = 0;
		long long mid = (left + right) / 2;
		for (int i = 0; i < N; i++)
		{
			count += max(0LL,A.at(i) - mid / F.at(i));
			if (count > K)
			{
				goal = false;
				break;
			}
		}
		if (goal == true)
		{
			ans = min(ans, mid);
			right = mid;
			mid = (left + right) / 2;
		}
		else {
			left = mid + 1;
			mid = (left + right) / 2;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 4992
def solve():
  ar = raw_input().split(' ')
  A = ar[0]
  B = ar[1]
  C = ar[2]
  if A[-1] == B[0] and B[-1] == C[0] : return 'YES'
  else: return 'NO'

if __name__ == '__main__' :
  print solve()

Measured memory_bytes: 2568
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
namespace mp = boost::multiprecision;
// 任意長整数型
using bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using real1024 = mp::number<mp::cpp_dec_float<1024>>;
// ついでに有理数型
using rat = boost::rational<bint>;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()

void solve(std::vector<long long> x){
  ll ans = 0;
  for (int i = 0; i < 5; i++) {
    if(x[i] == 0){
      ans = i+1;
    }
  }
  cout << ans << endl;
}

int main(){
    std::vector<long long> x(5);
				for(int i = 0 ; i < 5 ; i++){
								scanf("%lld",&x[i]);
				}
    solve(std::move(x));
    return 0;
}


Measured memory_bytes: 3696