akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String []args) throws IOException {
    	FastScanner in  = new FastScanner(System.in);
    	PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), false);
    	solve(in, out);
    	in.close();
    	out.close();
    }
    static long gcd(long a, long b){ return (b==0) ? a : gcd(b, a%b); }
    static int gcd(int a, int b){ return (b==0) ? a : gcd(b, a%b); }
    static class FastScanner{
	BufferedReader reader;
	StringTokenizer st;
	FastScanner(InputStream stream){reader=new BufferedReader(new InputStreamReader(stream));st=null;}
	String next(){while(st == null || !st.hasMoreTokens()){try{String line = reader.readLine();if(line == null){return null;}
	     st = new StringTokenizer(line);}catch (Exception e){throw new RuntimeException();}}return st.nextToken();}
	String nextLine()  {String s=null;try{s=reader.readLine();}catch(IOException e){e.printStackTrace();}return s;}
	int    nextInt()   {return Integer.parseInt(next());}
	long   nextLong()  {return Long.parseLong(next());}
	double nextDouble(){return Double.parseDouble(next());}
	char   nextChar()  {return next().charAt(0);}
	int[]  nextIntArray(int n)         {int[] arr= new int[n];   int i=0;while(i<n){arr[i++]=nextInt();}  return arr;}
	long[] nextLongArray(int n)        {long[]arr= new long[n];  int i=0;while(i<n){arr[i++]=nextLong();} return arr;}
	int[]  nextIntArrayOneBased(int n) {int[] arr= new int[n+1]; int i=1;while(i<=n){arr[i++]=nextInt();} return arr;}
	long[] nextLongArrayOneBased(int n){long[]arr= new long[n+1];int i=1;while(i<=n){arr[i++]=nextLong();}return arr;}
	void   close(){try{reader.close();}catch(IOException e){e.printStackTrace();}}
    }
    
    /********* SOLUTION STARTS HERE ************/
    
    private static void solve(FastScanner in, PrintWriter out){
        out.println((int)Math.ceil(in.nextInt()/2.0));
    }
    
    /************* SOLUTION ENDS HERE **********/
}

Measured memory_bytes: 21460
#include <iostream>
#include <deque>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

typedef pair<int, int> P;

int main() {
    int n, k;
    cin >> n >> k;
    vector<long long int> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    vector<long long int> ll(n+1,0);
    for (int i = 0; i < n; i++) {
        ll[i+1] = ll[i] + v[i];
    }
    vector<long long int> rr(n+1, 0);
    for (int i = n-1; i >= 0; i--) {
        rr[i] = rr[i+1] + v[i];
    }
    vector<P> pp;
    for (int i = 0; i < n; i++) {
        for (int j = i; j < n; j++) {
            pp.push_back(P(i, j));
        }
    }
    long long int ans = 0;
    vector<long long int> v2 = v;
    sort(v2.begin(), v2.end());
    int count = k-n;
    if (count >= 0) {
        ans = ll[n];
    }
    for (int i = 0; i < count; i++) {
        if (v2[i] < 0) {
            ans -= v2[i];
        }
    }
    for (int i = 0; i < pp.size(); i++) {
        int l = pp[i].first;
        int r = pp[i].second;
        long long int kans = ll[l]+rr[r+1];
        count = k-l-(n-r-1);
        //cout << l << ' ' << r << ' ' << count << endl;
        if (count >= 0) {
            //cout << l << ' ' << r << ' ' << kans << endl;
            vector<long long int> v3;
            for (int j = 0; j < l; j++) {
                v3.push_back(v[j]);
            }
            for (int j = n-1; j > r; j--) {
                v3.push_back(v[j]);
            }
            sort(v3.begin(), v3.end());
            if (v3.size() > 0) {
                int sz = v3.size();
                for (int j = 0; j < min(count, sz); j++) {
                    if (v3[j] < 0) {
                        kans -= v3[j];
                    }
                }
            }
            //cout << l << ' ' << r << ' ' << kans << endl;
            ans = max(ans, kans);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do{cout << "\033[32;1m" << #x << "->" ; err(x);} while(0)
void err(){cout << "\033[39;0m" << endl;}
template<template<typename...> class T,typename t,typename... A>
void err(T<t> a,A... x){for (auto v:a) cout << v << ' '; err(x...);}
template<typename T,typename... A>
void err(T a,A... x){cout << a << ' '; err(x...);}
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
        print(v[i],i==(int)(v.size())-1?suc:2);
}
const ll INF=0x3f3f3f3f3f3f3f3f;
const int maxn=1e5+7;
ll l[maxn],r[maxn];
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>l[i]>>r[i];
	multiset<ll> L,R;
	L.insert(-INF);
	R.insert(INF);
	ll ans=0;
	ll lb=0,rb=0;
	for(int i=0;i<n;i++)
	{
		if(i)
		{
			lb-=r[i]-l[i];
			rb+=r[i-1]-l[i-1];
		}
		if(l[i]-lb>=*L.rbegin())
		{
			if(l[i]-rb>=*R.begin())
			{
				ans+=l[i]-*R.begin()-rb;
				L.insert(*R.begin()+rb-lb);
				R.erase(R.begin());
				R.insert(l[i]-rb);
				R.insert(l[i]-rb);
			}
			else{
				L.insert(l[i]-lb);
				R.insert(l[i]-rb);
			}
		}
		else{
			ans+=*L.rbegin()+lb-l[i];
			R.insert(*L.rbegin()+lb-rb);
			L.erase(L.find(*L.rbegin()));
			L.insert(l[i]-lb);
			L.insert(l[i]-lb);
		}
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 11136
import sys
read = sys.stdin.readline

S = read()
len_s = len(S)-1
# print(S, len_s)
# ans0 = 0  # 0はじまり ->len_s-ans1で計算可能
ans1 = 0  # 1はじまり
for i, s in enumerate(S[:-1]):
    if i % 2:
        if s != '1':
            ans1 += 1
    else:
        if s != '0':
            ans1 += 1
    # print(i, ans1)

print(min(ans1, (len_s-ans1)))


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

int main(){
    int n, max;
    cin >> n;
    max = 0;
    vector<int> vec1(n);
    vector<int> vec2(n);

    for(int i = 0; i < n; i++){
        cin >> vec1.at(i);
    }
    for(int i = 0; i < n; i++){
        cin >> vec2.at(i);
    }

    for(int i = 0; i < n; i++){
        if(vec1.at(i) - vec2.at(i) >= 0){
            max += vec1.at(i) - vec2.at(i);
        }
    }
    cout << max << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    int A[50][50], B[50], C, i, j, M, N, Q, T;
    scanf("%d%d%d", &N, &M, &C);
    for (j=1;j<=M;j++) scanf("%d", &B[j]);
    for (i=1;i<=N;i++) for (j=1;j<=M;j++) scanf("%d", &A[i][j]);
    T = 0;
    for (i=1;i<=N;i++) {
        Q = 0;
        for (j=1;j<=M;j++) Q += A[i][j] * B[j];
        if (Q+C > 0) T++;
    }
    printf("%d\n", T);
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
       
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int i;
        for(i = 1; i <= a; i++){
            if(a % i == 0){
                for(int j = i; j <= a; j++){
                    if((i * j == a) && i>=1 && i <=9 && j>=1 && j <=9){
                        System.out.println("Yes");
                        System.exit(0);
                    }
                }
            }
        }
        if(i == a + 1){
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23124
def solve():
    c = [list(map(int, input().split())) for _ in range(3)]
    if c[0][0] + c[1][1] + c[2][2] == c[0][1] + c[1][2] + c[2][0] == c[0][2] + c[1][0] + c[2][1]:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

void pre(){


}
 
void solve(){
 
 
}

int s[12][1009];

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	pre();


    int h,w,k; cin>>h>>w>>k;

    rep(i,h){
        string t;cin>>t;
        rep(j,w) s[i][j] = t[j]-'0';
    }

    int ans=h*w+10;

    rep(m,(1<<(h-1))){
        vi b(1);
        rep(i,h-1) if( m & (1<<i) ) b.pb(i+1);
        b.pb(h);

        int a2=0;
        vi c(h+10),t(h+10);

        rep(i,w){
            repA(l,1,sz(b)-1){
                t[l] = 0;
                repA(j, b[l-1], b[l]-1) t[l] += s[j][i];
            }

            rep(i,h+1) if(c[i]+t[i]>k){
                a2++;
                if(t[i] > k) a2 = h*w+10;
                rep(i, h+1) c[i] = 0;
                break;
            }

            rep(i,h+1) c[i] += t[i];
        }

        ans=min(ans, a2+sz(b)-2);
    }
    cout<<ans;



	return 0;
}
 



Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int x,y; cin>>x>>y;
    cout<<(y%2==0 && y>=2*x && y<=4*x ? "Yes" : "No")<<endl;
}


Measured memory_bytes: 3672
def insertion_sort(r, n, g):
    global cnt
    for i in range(g, n):
        v = r[i]
        j = i - g
        while v < r[j] and j >= 0:
            r[j + g] = r[j]
            j = j - g
            cnt += 1
        r[j + g] = v


def shell_sort(r, n):
    global m
    global G
    h = 1
    while True:
        if h > n:
            break
        G.append(h)
        h = h * 3 + 1
    m = len(G)
    G.reverse()
    for i in range(m):
        insertion_sort(r, n, G[i])

cnt = 0
G = []
m = 0
N = int(input())
R = [int(input()) for i in range(N)]
shell_sort(R, N)
print(m)
print(*G)
print(cnt)
for i in range(N):
    print(R[i])

Measured memory_bytes: 47436
#include <iostream>

using namespace std;

int main()
{
  long N, K;
  cin >> N >> K;
  long s = N/K;
  if(K % 2 == 0){
    long k = K/2;
    long n = 0;
    for(int i = -1; K*(i+1) + k <= N; i++){
      n++;
    }
    cout << n*n*n + s*s*s;
  }else{
    cout << s*s*s;
  }
  return 0;
}

Measured memory_bytes: 256
def main():
    S = input()
    if len(S) < 26:
        exists = set()
        for c in S:
            exists.add(c)
        for i in range(26):
            x = chr(ord('a') + i)
            if x not in exists:
                print(S + x)
                return
    seen = []
    for i in range(25, -1, -1):
        last = None
        for x in seen:
            if S[i] < x:
                if last == None or x < last:
                    last = x
        if last:
            print(S[:i] + last)
            return
        seen.append(S[i])
    print(-1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define M_PI 3.14159265358979323846
#define ALL(X) (X).begin(),(X).end()

#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

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

int dx[]={1, 0, -1, 0, 0};
int dy[]={0, 1, 0, -1, 0};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
const int NIL = -1;
static mt19937 _g(time(nullptr));
 
std::string pad(int num){ char buffer[4]; std::snprintf(buffer, sizeof(buffer), "%03d", num); return buffer;}
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << "," << el.second << "] "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N,K;
ll S;

void input(){
    #ifdef __LOCAL
        fs::path path_to_file = __FILE__;
        fs::path input,output;
        input = output = path_to_file.parent_path();
        input += string("/input/") + string(path_to_file.stem()) + string(".txt");
        output += string("/output/") + string(path_to_file.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    cin >> N >> K >> S;
}

int solve(){
    input();
    // vector<ll> A(N,0);
    // REP(i,N) A[i] = S+10;
    // REP(i,K) A[i] = S;
    if(S!=1e9){
        REP(i,N){
            if(i<K) cout << S << " ";
            else cout << S+1LL << " ";
        }
        cout << endl;
    }
    else{
        REP(i,N){
            if(i<K) cout << S << " ";
            else cout << 1LL << " ";
        }
        cout << endl;
    }
    return 0;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 1280
object Main extends App{
  import scala.io.StdIn._
  val Array(k,n)=readLine().split(" ").map(_.toInt)
  var f=0;var l=new Array[Int](n);var b=0;
  val a=readLine().split(" ").map(_.toInt)
  for{i <- (0 until n)}{l(i)=a(i)-f;f=a(i)}
  l(0)+=k-a(n-1)
  for {i <- (0 until n)}{b=Math.max(l(i),b)}
  println(l.sum-b)
}

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

namespace ConsoleApp135 {
    class Program {
        static void Main(string[] args) {
            //入力
            string s = Console.ReadLine();

            long A = long.Parse(s.Split(' ')[0]);
            long B = long.Parse(s.Split(' ')[1]);
            long C = long.Parse(s.Split(' ')[2]);
            long D = long.Parse(s.Split(' ')[3]);

            //解答となる数値
            long ans = 0;

            //CとDが互いに倍数関係になっているかで場合分けする
            if (LCM(C, D) == C || LCM(C, D) == D) {
                ans = B / Math.Min(C, D) - (A - 1) / Math.Min(C, D);
            } else {
                ans = (B / C + B / D - B / LCM(C, D)) - ((A - 1) / C + (A - 1) / D - (A - 1) / LCM(C, D));
            }


            Console.WriteLine(B - A + 1 - ans);
        }
        //最小公倍数
        public static long LCM(long a, long b) {
            return a * b / GCD(a, b);
        }

        //最大公約数
        public static long GCD(long a, long b) {
            if (a < b) {
                return GCD(b, a);
            }

            while(b != 0) {
                long remainder = a % b;
                a = b;
                b = remainder;
            }
            return a;
        }
    }
}


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

#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back

using namespace std;

LL gcd(LL a,LL b){return b?gcd(b,a%b):a;}
LL lcm(LL a,LL b){return a/gcd(a,b)*b;}
LL powmod(LL a,LL b,LL MOD){LL ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
const int N = 2e5 +11;
LL a,b,c,d;
LL g(LL x){

	// 9-4-3+
	return x-(x/c+x/d-x/(lcm(c,d)));
}
int main(){
	ios::sync_with_stdio(false);
	cin>>a>>b>>c>>d;
	cout<<g(b)-g(a-1)<<endl;
	return 0;
}

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


using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i+=1)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define repv(arr)  for(auto it=arr[i].begin();it!=arr[i].end();it++)  
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vl vector<long long int>
#define ssortA(arr)   stable_sort(arr.begin(),arr.end())
#define search(arr,c)  binary_search(arr.begin(),arr.end(),c)
#define pb   push_back
#define ll long long
#define LCM(a,b) boost::math::lcm(a,b)
#define cl_bf cin.ignore(numeric_limits<streamsize>::max(), '\n');

int main(){

    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,m;
    ll k;
    cin>>n>>m>>k;
    vl arr(n+1),b(m+1);
    rep(i,1,n+1){
        cin>>arr[i];
    }
    rep(i,1,m+1){
        cin>>b[i];
    }
    int max=0;
    
    vl prea(n+1,0),preb(m+1,0);
    rep(i,1,n+1){
        prea[i]+=prea[i-1]+arr[i];
    }
   rep(i,1,m+1){
        preb[i]+=preb[i-1]+b[i];
    }
    int i=0,j=n;
    while(1){
        if(j<0||i>m){
            break;
        }
        else {
            if(prea[j]+preb[i]<=k){
            if(i+j>max)
            max=i+j;
            i++;
            }
            else{
                j--;
            }
        }
    }
    cout<<max<<endl;
}


Measured memory_bytes: 9528
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <cassert>
#include <string>
#include <queue>
#include <ctype.h>
#include <iomanip>
#include <algorithm>
#include <unordered_map>
using namespace std;
#define int long long
int a[200000];
signed main() {
//#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//#endif
	int n;
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	int ans = 1234567890123456789;
	int cur = 0;
	int sum = a[1];
	if (a[1] == 0) {
		cur = 1;
		sum = -1;
	}
	for (int i = 2; i <= n; ++i) {
		if (sum < 0) {
			if (sum + a[i] > 0) {
				sum += a[i];
			}
			else {
				int nado = -sum + 1;
				cur += abs(nado - a[i]);
				sum = 1;
			}
		}
		else {
			if (sum + a[i] < 0) {
				sum += a[i];
			}
			else {
				int nado = -sum - 1;
				cur += abs(a[i] - nado);
				sum = -1;
			}
		}
	}
	ans = min(ans, cur);
	cur = abs(a[1]) + 1;
	if (a[1] > 0) sum = -1;
	else sum = 1;
	for (int i = 2; i <= n; ++i) {
		if (sum < 0) {
			if (sum + a[i] > 0) {
				sum += a[i];
			}
			else {
				int nado = -sum + 1;
				cur += abs(nado - a[i]);
				sum = 1;
			}
		}
		else {
			if (sum + a[i] < 0) {
				sum += a[i];
			}
			else {
				int nado = -sum - 1;
				cur += abs(a[i] - nado);
				sum = -1;
			}
		}
	}
	ans = min(ans, cur);
	cout << ans << endl;
}

Measured memory_bytes: 1024
// きさま！ 見ているなッ！

#include<iostream>
#include<queue>
#include<memory>
#include<map>
#include<set>
#include<unordered_map>
#include<array>
#include<vector>
#include<algorithm>
#include<list>
#include<limits>
#include<stdio.h>
#include<math.h>
#include<string>
#include<thread>

using namespace std;
using ll = long long;
using vec = vector<int>;
using mat = vector<vec>;
using lst = list<ll>;

const ll MOD = 1000000007;


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

	return 0;
}



Measured memory_bytes: 3620
# 1st:0407,2nd-:0408

#ABC041-C
if False:
    N=int(input())
    A=[int(i) for i in input().split()]
    ans=[(i,a) for i,a in enumerate(A)]
    ans.sort(key=lambda x: x[1],reverse=True)
    for i in range(N): print(ans[i][0]+1)

#AGC017-A
if False:
    N,P=map(int,input().split())
    A=[int(i) for i in input().split()]
    flag=True # 偶数のみか
    for a in A:
        if a%2==1:
            flag=False
            break
    if flag:
        if P==0:
            print(2**N)
        else:
            print(0)
    else:
        print(2**(N-1))

#3rd: ABC155-A
if False:
    print('Yes' if len(set(input().split()))==2 else 'No')
#4th: ABC155-B
if False:
    N=int(input())
    A=[int(i) for i in input().split()]
    ans='APPROVED'
    for a in A:
        if a%2==0:
            if not(a%3==0 or a%5==0):
                ans='DENIED'
    print(ans)
#5th: ABC155-C
if True:
    # dictで数える
    def cnt(lis): # list を渡す
        ret={}
        for x in set(lis):
            ret[x]=0
        for e in lis:
            ret[e]+=1
        return ret

    # dictをタプルのリストにする
    def DtoL(dic):
        return list(zip(dic.keys(),dic.values()))

    N=int(input())
    S=[input() for _ in range(N)]
    RES=DtoL(cnt(S))
    # print(RES)
    MAX=max(RES,key=lambda x: x[1])
    ANS=[]
    for r in RES:
        if r[1]==MAX[1]:
            ANS.append(r)
    ANS.sort(key=lambda x: x[0])
    for ans in ANS:
        print(ans[0])
    


Measured memory_bytes: 49440
S = input()
S1 = S[::-1]
SL =len(S)
count = 0
if len(S) % 2 == 0:
    SL = int(len(S)/2)
    S = S[:SL]
    S1 = S1[:SL]
else:
    SL = int((SL - 1)/2)
    S = S[:SL]
    S1 = S1[:SL] 
for i in range(len(S)):
    if not S[i] == S1[i]:
        count += 1
print(count)

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

int main(){
  
  int h,w,n;
  cin>>h>>w>>n;
  int a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  
  int b[h][w];
  int aa=0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(i%2==0){
        if(a[aa]>0){
          b[i][j]=aa+1;
          a[aa]--;
        }
        else{
          aa++;
          b[i][j]=aa+1;
          a[aa]--;
        }
      }
      else{
        if(a[aa]>0){
          b[i][w-j-1]=aa+1;
          a[aa]--;
        }
        else{
          aa++;
          b[i][w-j-1]=aa+1;
          a[aa]--;
        }
      }
      
    }
  }
 
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cout<<b[i][j]<<" ";
    }
    cout<<endl;
  }
  
}

Measured memory_bytes: 384
while True:
    n = int(input())
    if n == 0:
        break
    d = {}
    e = []
    for i in range(n):
        tmp = list(map(int, input().split(' ')))
        if tmp[0] in d:
            d[tmp[0]] += tmp[1] * tmp[2]
        else:
            d[tmp[0]] = tmp[1] * tmp[2]
            e.append(tmp[0])
 
    if max(d.values()) < 1000000:
        print('NA')
    else:
        for k in e:
            if d[k] >= 1000000:
                print(k)

Measured memory_bytes: 7760
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons;
import std.math, std.numeric;

void main() {
    int n, q; scan(n, q);
    auto sd = SqrtDecomp(n);
    foreach (_ ; 0 .. q) {
        auto line = readln.split.to!(int[]);
        if (line[0] == 0) {
            sd.update(line[1], line[2] + 1, line[3]);
        }
        else {
            writeln(sd.getMin(line[1], line[2] + 1));
        }
        debug {
            sd.data.writeln;
            sd.bucketMin.writeln;
            sd.bucketChange.writeln;
        }
    }
}


struct SqrtDecomp {
    enum root = 512;
    int K, N;
    int[] bucketMin;
    int[] bucketChange;
    int[] data;

    this(int n) {
        K = (n + root - 1) / root;
        N = K * root;
        bucketMin = new int[](K);
        bucketChange = new int[](K);
        data = new int[](K * root);
        bucketMin[] = int.max;
        bucketChange[] = -1;
        data[] = int.max;
    }

    void update(int s, int t, int x) {
        foreach (k ; 0 .. K) {
            int lb = k * root, rb = (k + 1) * root;
            if (t <= lb || rb <= s) continue;
            if (s <= lb && rb <= t) {
                bucketChange[k] = x;
                bucketMin[k] = x;
            }
            else {
                bucketMin[k] = int.max;
                foreach (i ; lb .. rb) {
                    if (bucketChange[k] != -1) {
                        data[i] = bucketChange[k];
                    }
                    if (s <= i && i < t) {
                        data[i] = x;
                    }
                    bucketMin[k] = min(bucketMin[k], data[i]);
                }
                bucketChange[k] = -1;
            }
        }
    }

    int getMin(int s, int t) {
        int res = int.max;
        foreach (k ; 0 .. K) {
            int lb = k * root, rb = (k + 1) * root;
            if (t <= lb || rb <= s) continue;
            if (s <= lb && rb <= t) {
                res = min(res, bucketMin[k]);
            }
            else {
                foreach (i ; lb .. rb) {
                    if (bucketChange[k] != -1) {
                        data[i] = bucketChange[k];
                    }
                    if (s <= i && i < t) {
                        res = min(res, data[i]);
                    }
                }
                bucketChange[k] = -1;
            }
        }
        return res;
    }
}


void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}



Measured memory_bytes: 3724
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define INF 1e9
#define MAXN 100005
#define MAXM 100005
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

ll ans;
int A, B, T;

void solve(){
    cout << B*(T/A) << endl;
}

int main(){
    cin >> A >> B >> T;

    solve();
}


Measured memory_bytes: 256
S = input()
S = S.replace('BC', 'D').replace('B', 'E').replace('C', 'E')
S = S.split('E')

ans = 0
for s in S:
    temp = 0
    for c in s:
        if c == 'A':
            temp += 1
        else:
            ans += temp
print(ans)

Measured memory_bytes: 5412
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
#include <sstream>
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)
#define pb(a) push_back(a)
int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

struct Food{
  vector<int> num;
  double g;
  bool operator<(const Food& f) const{
    return g < f.g;
  }
};

int main(void){
  vector<int> num;
  vector<pair<int,int> > a;
  vector<string> name;
  int n;
  while(cin>>n,n){
    num.clear();
    a.clear();
    name.clear();
    rep(i,n){
      string f;
      int w,s;
      cin>>f>>w>>s;
      a.push_back(make_pair(w,s));
      name.push_back(f);
      num.push_back(i);
    }
    vector<Food> food;

    do{
      bool flag = true;
      rep(i,num.size() - 1){
	int count = 0;
	loop(j,i+1,num.size()){
	  count  += a[num[j]].first;
	}
	if(a[num[i]].second < count){
	  flag = false;
	}
      }
      if(flag){
	Food f;
	copy(num.begin(),num.end(),back_inserter(f.num));

	double t_a = 0, t_b = 0;
	int j = 1;
	rep(i,num.size()){
	  t_a += j*a[num[i]].first;
	  t_b += a[num[i]].first;
	  j ++;
	}
	f.g = t_a / t_b;
	food.push_back(f);
      }
    }while(next_permutation(num.begin(),num.end()));
    sort(food.begin(),food.end());
    rep(i,food[0].num.size())
      cout<<name[food[0].num[i]]<<endl;
  }

}

Measured memory_bytes: 23364
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        String op = sc.next();
        int B = sc.nextInt();
        int ans;
        if(op.charAt(0)=='+') ans = A+B;
        else ans = A-B;
        System.out.println(ans);
    }
}


Measured memory_bytes: 21716
#include <iostream>
#include <string>
#include <array>

using namespace std;

int main(void)
{
    int n, k;
    cin >> n;
    cin >> k;
    std::array<bool, 100> is_have_list;
    is_have_list.fill(false);

    // お菓子の種類
    for(int s = 0;s < k;s++)
    {
        int d;
        cin >> d;
        for (int t = 0; t < d; t++)
        {
            int index;
            cin >> index;
            index--;
            is_have_list[index] = true;
        }
    }
    int can_num = 0;
    for (int i = 0; i < n; i++)
    {
        if(!is_have_list[i])
        {
            can_num++;
        }
    }
    cout << can_num;
}

Measured memory_bytes: 3580
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"strconv"
)

var sc *bufio.Scanner

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

type Heap []int

func (h Heap) Len() int {
	return len(h)
}

func (h Heap) Less(i, j int) bool {
	return h[i] > h[j] // reversed-Heap
}

func (h Heap) Swap(i, j int) {
	h[i], h[j] = h[j], h[i]
}

func (h *Heap) Push(x interface{}) {
	*h = append(*h, x.(int))
}

func (h *Heap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 0), 1000000001*3)
	sc.Split(bufio.ScanWords)
	n, m := nextInt(), nextInt()

	h := &Heap{}
	heap.Init(h)
	for i := 0; i < n; i++ {
		heap.Push(h, nextInt())
	}

	for j := 0; j < m; j++ {
		(*h)[0] /= 2
		heap.Fix(h, 0)
	}

	ans := 0
	for _, v := range *h {
		ans += v
	}
	fmt.Println(ans)
}


Measured memory_bytes: 7424
n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
time = [a,b,c,d,e]

ans = n // min(time) + 5


if n % min(time) == 0:
    print(ans -1) 
else:
    print(ans)


Measured memory_bytes: 3060
from collections import Counter
n = int(input())
l = list(map(int,input().split()))
c = Counter(l)
l = list(set(l))
ans = 0
l.sort()

n = len(l)
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if l[i]+l[j] > l[k] and l[i]+l[k] > l[j] and l[j]+l[k]>l[i]:
                ans += c[l[i]]*c[l[j]]*c[l[k]]
print(ans)

Measured memory_bytes: 9452
#include<iostream>
    #include<algorithm>
    #include<vector>
    #include<queue>
    #define lol(i,n) for(int i=0;i<n;i++)
    #define mod 100000007
    typedef long long ll;
    using namespace std;
    #define N 5010
    int n;
    typedef pair<ll,pair<ll,ll> >P;
    P a[N];
    ll dp[N][N];
    int main(){
        int n;
        cin>>n;
        lol(i,n){
    	ll x,y;cin>>x>>y;
    	a[i]=make_pair(x+y,make_pair(x,y));
        }
        sort(a,a+n);
        lol(i,n+1){
    	lol(j,n+1)dp[i][j]=(ll)mod*(ll)mod;
        }
        dp[0][0]=0;
        lol(i,n){
    	lol(j,n){
    	    dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
    	    if(dp[i][j]<=a[i].second.first){
    		dp[i+1][j+1]=min(dp[i+1][j+1],dp[i][j]+a[i].second.second);
    	    }
    	}
        }
        ll ans=0;
        lol(j,n+1){
    	lol(i,n+1)if(dp[i][j]!=(ll)mod*(ll)mod)ans=j;
        }
        cout<<ans<<endl;
        return 0;
    }


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

int main()
{
	char a;
	int b=0;
	for(int i=1;i<=4;i++)
	{
		cin>>a;
		if(a=='+')
			b++;
		else
			b=b-1;
	}
	cout<<b;
} 

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

int main()
{
  int res, alice_start, alice_end, bob_start, bob_end;

  cin >> alice_start >> alice_end >> bob_start >> bob_end;

  if (alice_end < bob_start || alice_start > bob_end) res = 0;
  else if (alice_start < bob_start && bob_end < alice_end) res = bob_end - bob_start;
  else if (bob_start <= alice_start && alice_end <= bob_end) res = alice_end - alice_start;
  else if (bob_start < alice_start && bob_end < alice_end) res = bob_end - alice_start;
  else res = alice_end - bob_start;
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3628
using System.Linq;
using static System.Math;
using System.Collections.Generic;
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = long.Parse(line[0]);
        var p = long.Parse(line[1]);
        if (n == 1) { Console.WriteLine(p); goto exit; }
        if (p == 1) { Console.WriteLine(1); goto exit; }
        var rp = (int)Sqrt(p);
        var a = GeneratePrime(rp + 1);
        var ans = getAns(a, n, p);
        Console.WriteLine(ans);
        exit:;
    }
    static long getAns (List<int> a , long n , long p)
    {
        var ans = 1L;
        var p2 = p;
        foreach (var x in a)
        {
            var count = 0;
            if (p2 < x) break;
            while (true)
            {
                if (p2 % x == 0) { count++; p2 /= x; }
                else break;
            }
            var cn = count / n;
            ans *=(long)Pow(x, cn);
        }
        return ans;
    }
    public static List<int> GeneratePrime(int m)
    {
        var a = new List<int>();
        int p;
        var sqrtMax = Math.Sqrt(m);
        var s = Enumerable.Range(2, m - 1).ToList();
        do
        {
            p = s.First();
            a.Add(p);
            s.RemoveAll(n => n % p == 0);
        }
        while (p < sqrtMax);
        a.AddRange(s);
        return a;
    }
}

Measured memory_bytes: 20576
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, k; cin >> n >> k;
	vector<int> h(n);
	for(auto &i:h) cin >> i;
	sort(h.begin(), h.end());
	k = min(k, n);
	cout << accumulate(h.begin(), h.begin()+n-k, 0ll) << "\n";
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
#define Max(a) (*max_element(ALL(a)))
#define Min(a) (*min_element(ALL(a)))
using namespace std;
ll cnt[111111];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  vi A(n);
  ll ans = 0;
  for(auto &a:A){cin>>a;cnt[a]++;ans += a;}
  ll q;cin>>q;
  while(q--){
    ll b,c;cin>>b>>c;
    ans += (c-b)*cnt[b];
    cout<<ans << endl;
    cnt[c] += cnt[b];
    cnt[b] = 0;
  }
  return 0;
}


Measured memory_bytes: 4748
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define vpii vector<pii>
#define vpipii vector<pipii>
#define vpiipi vector<piipi>
#define pb push_back
#define pob pop_back
#define pii pair<int,int>
#define pipii pair<int,pii>
#define piipi pair<pii,int>
#define pld pair<long double,long double>
#define mod 1000000007
// #define mod 1000000009
// #define mod 163577857 
// #define mod 998244353
#define rep(i,n) for (int i = 0; i < n; i++)
#define repp(i,a,b) for(int i = a ; i<b ; i++)
#define reppr(i,a,b) for(int i = a-1 ; i>=b ; i--)
#define repr(i,n) for (int i = n - 1; i >= 0; i--)
#define ff first
#define ss second
#define pc putchar_unlocked
#define gc getchar_unlocked
#define inf 9223372036854775807
#define infn -9223372036854775807
#define pi 3.14159265358979323846
#define eps 0.0000000001
#define sp << " " <<
#define setprec(x) cout << fixed << setprecision(x);
#define REVERSE(a) reverse(all(a));
#define SORT(a) sort(all(a));
#define all(n) n.begin(),n.end()

//GCD and LCM
    int gcd (int a, int b) { return b ? gcd (b, a % b) : a; }
    int lcm (int a, int b) { return a / gcd(a, b) * b; }
 
//Modular Exponentiation
    int powmod(int x,int y) 
    { 
        if (y == 0) return 1; 
        int p = powmod(x, y/2) % mod; 
        p = (p * p) % mod;   
        return (y%2 == 0)? p : (x * p) % mod; 
    }
 
//Modular Inverse
    int inverse(int a) 
    { 
       return powmod(a,mod-2); 
    }

//Binomial Coefficients
    const int limbin = 500001;
    int fact[limbin], factinv[limbin] , coefficientflag = 0;
    void Util_nCr()
    {
        fact[0] = 1 , factinv[0] = 1;
        repp(i,1,limbin)
        {
            fact[i] = (fact[i-1] * i)%mod;
            factinv[i] = (factinv[i-1] * inverse(i))%mod;
        }
    }
    int nCr(int n , int r)
    {
        if(!coefficientflag) coefficientflag = 1 , Util_nCr();
        if(n<r) return 0;             
        return ((fact[n] * inverse(fact[n-r]) % mod * inverse(fact[r]))%mod) ;
    }

void solve();
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int t = 1;
    // cin >> t; 
    rep(i,t)
    {
        // cout << "Case #" << i+1 << ": ";
        solve();
    }
}


void solve()
{ 
    string s;
    cin >> s;
    int ans = 0 , cnt[26] = {} , n = s.length();
    rep(i,n)
    {
        ans += i - cnt[s[i]-'a'];
        cnt[s[i]-'a']++;
    }
    cout << ans + 1;
}

Measured memory_bytes: 3664
N, K = map(int, input().split())
V = list(map(int, input().split()))
ans = 0
for k in range(K+1):
    for n in range(k+1):
        if n >= N or k > N:
            break
        A = V[:n]
        A.extend(V[N-k+n:])
        A.sort()
        
        c = sum(A)
        for i in range(min(K-k, k)):
            if A[i] <= 0:
                c -= A[i]
        #print(k, n, c)
        ans = max(ans, c)
print(ans)

Measured memory_bytes: 3064
program B087
    implicit none
    integer(8) :: A, B, C, X
    integer(8) :: i, j, k, sum

    read(5,*) A
    read(5,*) B
    read(5,*) C
    read(5,*) X

    sum = 0
    do i = 0, A
        do j = 0, B
            do k = 0, C
                if (500*i+100*j+50*k == X) then
                    
                    sum = sum + 1
                end if

            end do
        end do
    end do

    write(6,*) sum


end program B087


Measured memory_bytes: 2828
n=int(input())
x =list(map(int,input().split()))
xx=sorted(x)

l=len(x)
c1=xx[l//2-1]
c2=xx[l//2]

for i in range(n):
    if x[i] > c1:
        print(c1)
    else:
        print(c2)


Measured memory_bytes: 25748
#!/usr/bin/python3
# -*- coding:utf-8 -*-

import numpy
from math import factorial

def main():
  n = int(input())
  pos = [list(map(int, input().strip().split())) for _ in range(n)]
  pos = numpy.array(pos)
  dists = numpy.zeros((n, n))
  for i in range(n):
    for j in range(i+1, n):
      dists[i, j] = numpy.linalg.norm(pos[i] - pos[j]) 
#   print(dists)
  print(numpy.sum(dists) / n * 2 )

if __name__=='__main__':
  main()



Measured memory_bytes: 12380
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    ll X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    vector<ll> A(X+1), B(Y+1), C(Z+1);
    for (int i = 0; i < X; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < Y; i++) {
        cin >> B[i];
    }
    for (int i = 0; i < Z; i++) {
        cin >> C[i];
    }
    A[X] = -100000000000;
    B[Y] = -100000000000;
    C[Z] = -100000000000;
    sort(ALL(A), greater<ll>());
    sort(ALL(B), greater<ll>());
    sort(ALL(C), greater<ll>());


    priority_queue<pair<ll,pair<int,iint>>> q;
    q.push(make_pair(A[0] + B[0] + C[0], make_pair(0, make_pair(0, 0))));

    pair<ll, pair<int, iint>> x;
    map<pair<int, iint>, bool> g;
    int a,b,c;
    for (int i = 0; i < K; i++) {
        x = q.top();
        q.pop();
        while(q.size() != 0 && q.top() == x){
            q.pop();
        }
        a = x.second.first;
        b = x.second.second.first;
        c = x.second.second.second;
        printf("%lld\n", x.first);
        
        if(a <= X-2 && !g.count(make_pair(a+1, make_pair(b, c)))){
            q.push(make_pair(A[a+1] + B[b] + C[c], make_pair(a+1, make_pair(b, c))));
            g[make_pair(a+1, make_pair(b, c))] = true;
        }
        if(b <= Y-2 && !g.count(make_pair(a, make_pair(b+1, c)))) {
            q.push(make_pair(A[a] + B[b+1] + C[c], make_pair(a, make_pair(b+1, c))));
            g[make_pair(a, make_pair(b+1, c))] = true;
        }
        if(c <= Z-2 && !g.count(make_pair(a, make_pair(b, c+1)))) {
            q.push(make_pair(A[a] + B[b] + C[c+1], make_pair(a, make_pair(b, c+1))));
            g[make_pair(a, make_pair(b, c+1))] = true;
        }
    }



}

Measured memory_bytes: 4116
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int h, w, d;
	cin >> h >> w >> d;
	vector<int> x(h * w + 1), y(h * w + 1);
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			int a;
			cin >> a;
			x[a] = i;
			y[a] = j;
		}
	}

	vector<int> cost(h * w + 1);
	for (int i = d + 1; i <= h * w; i++) {
		cost[i] = cost[i - d] + abs(x[i] - x[i - d]) + abs(y[i] - y[i - d]);
	}

	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		int l, r;
		cin >> l >> r;

		cout << cost[r] - cost[l] << endl;
	}

	return 0;
}

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

int main()
{
  string s1,s2;
  
  cin >> s1;
  if(s1 == "Sunny")
  {
    s2 = "Cloudy";
  }
  else if(s1 == "Cloudy")
  {
    s2 = "Rainy";
  }
  else if(s1 == "Rainy")
  {
    s2 = "Sunny";
  }
  
  cout << s2 << endl;
  
  return 0;
}

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

using namespace std;

const int N = 1e2 + 10;

char s[N];
int S[N];
int top;

void push(int x)
{
    S[++top] = x;
}

int pop()
{
    top--;
    return S[top + 1];
}

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

    while(cin >> s)
    {
        if(s[0] == '+')
        {
            int b = pop();
            int a = pop();
            push(a + b);
        }
        else if(s[0] == '-')
        {
            int b = pop();
            int a = pop();
            push(a - b);
        }
        else if(s[0] == '*')
        {
            int b = pop();
            int a = pop();
            push(a * b);
        }
        else
        {
            push(atoi(s));
        }
    }
    cout << pop() << endl;

    return 0;
}


Measured memory_bytes: 3164
import math
n=int(input())
def sosu(x):
    a=1
    for i in range(2,int(math.sqrt(x))+1):
        if x%i==0:
            a=i#素数でない場合は最後のaが出力される
    return a
a=sosu(n)
if a==1:
    print(n-1)
else:
    b=n//a
    ans=(a-1)+(b-1)
    print(ans)

Measured memory_bytes: 3188
#include<stdio.h>

int A[2000001],B[1000001],C[2000001],i,j,n;

int main() {
  scanf("%d",&n);

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

  for(i=1;i<10001;i++)B[i]+=B[i-1];

  /*
  for(i=1;i<n+1;i++)printf("%d ",A[i]);
  printf("\n");
  for(i=0;i<10;i++)printf("%d ",B[i]);
  printf("\n");
  */

  for(i=n;i>0;i--){
    C[B[A[i]]]=A[i];
    B[A[i]]--;
  }

  for(i=1;i<n+1;i++){
 
    if(i<n) printf("%d ",C[i]);
    else  printf("%d\n",C[i]);
    }
  return 0;
}

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

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

  vector<int> a(n);
  rep(i,n) cin >> a[i];

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

    maxv = max(maxv, a[i]);
  }

  cout << ans << '\n';
}

Measured memory_bytes: 4840
#include <iostream>
using namespace std;
#define MAX 2000000

int H, A[MAX + 1];

void maxHeapify(int i) {
	int l, r, largest;
	l = 2 * i;
	r = 2 * i + 1;

	if (l <= H && A[l] > A[i]) largest = l;
	else largest = i;
	if (r <= H && A[r] > A[largest]) largest = r;

	if (largest != i) {
		swap(A[i], A[largest]);
		maxHeapify(largest);
	}
}

int main() {
	cin >> H;

	for (int i = 1; i <= H; i++) cin >> A[i];
	for (int i = H / 2; i >= 1; i--) maxHeapify(i);
	for (int i = 1; i <= H; i++) {
		cout << " " << A[i];
	}

	cout << endl;

	return 0;
}



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

#if DEBUG && !ONLINE_JUDGE
  #include "header.h"
#else
  #define debug(args...)
#endif

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long lli;
typedef long double ld;

#define pb push_back
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x).size()
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(auto i=(a);i<b;i++)

#define INF (int)1e9
#define EPS 1e-9
#define MOD 1000000007
void preprocess(void) {
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(20);
  preprocess();
  int a, b; cin>>a>>b;
  lli g = __gcd(a, b);
  lli ans = (a * 1LL * b)/g;
  cout<<ans<<endl;
}



Measured memory_bytes: 256
import std.stdio, std.algorithm, std.range, std.conv, std.string, std.math;
import core.stdc.stdio;
// foreach, foreach_reverse, writeln

void main() {
	int q;
	scanf("%d", &q);
	foreach (i; 0..q) {
		int a, b;
		scanf("%d%d", &a, &b);
		if (a > b) swap(a,b);
		int l = 0, r = b;
		while (l+1 < r) {
			int x = (l+r)/2;
			bool judge(long a, long b, long x) {
				// (x..1) * (a+1..a+x) < a*b
				if (x*(a+1) >= a*b) return false;
				if (1*(a+x) >= a*b) return false;
				long l = (x+a+1)/2;
				long r = (x+a+1)-l;
				if (l > x) return true;
				if (r < a+1) return true;
				if (l*r >= a*b) return false;
				return true;
			}
			if (judge(a, b, x)) l = x;
			else r = x;
		}
		writeln(l + (a-1));
	}
}


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


int main(){

  int d,g;
  cin>>d>>g;
  
  vector<int> p(d);
  vector<int> c(d);
  
  
  for (int i=0;i<d;i++){
    int pi,ci;
    cin>>pi>>ci;
    p.at(i)=pi;
    c.at(i)=ci;
  }
  

  int withoutsum=0;
  
  for (int i=0;i<d;i++){
   
    withoutsum+=100*(i+1)*(p.at(i)-1);
  }
  
  int answer=1000;
  
  for (int i=0;i<(1<<d);i++){
    bitset<10> s(i);
    
    int sum=withoutsum;
    
    for (int j=0;j<d;j++){
      if (s.test(j)){
        sum+=100*(j+1)+c.at(j);
      }
    }
   
    if (sum<g){
      continue;
    }
    
    else {
      int count=0;
      
      int tmpsum=0;
 
      for (int j=d-1;j>=0;j--){
        
        if (s.test(j)){
          tmpsum+=(100*(j+1)*p.at(j)+c.at(j));
          count+=p.at(j);
        }
      }
      
      
      for (int j=d-1;j>=0;j--){
        if (tmpsum<g and s.test(j)==0){
          int tmp=min(p.at(j)-1,(g-tmpsum+100*j+99)/(100*(j+1)));
          count+=tmp;
          tmpsum+=100*(j+1)*tmp;
        }
        
        if (tmpsum>=g){
          break;
        }
        
        

      }
      

    
    answer=min(answer,count);
    }
    
    

  }

  cout<<answer<<endl;
  

  
}

Measured memory_bytes: 3628