akhauriyash/Code-Regression huggingface dataset:
use std::io::{BufRead, Read};

pub struct Scanner<R>
where
    R: BufRead,
{
    reader: R,
}

impl<R> Scanner<R>
where
    R: BufRead,
{
    pub fn new(reader: R) -> Self {
        Self { reader }
    }

    pub fn next<T>(&mut self) -> T
    where
        T: ::std::str::FromStr,
        <T as ::std::str::FromStr>::Err: ::std::fmt::Debug,
    {
        self.reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .unwrap()
    }
}

use std::iter::*;

fn main() {
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let mut sc = Scanner::new(stdin);

    let (x1, y1) = (sc.next::<f64>(), sc.next::<f64>());
    let (x2, y2) = (sc.next::<f64>(), sc.next::<f64>());

    let d = ((x1 - x2).powi(2) + (y1 - y2).powi(2)).sqrt();
    println!("{}", d);

}


Measured memory_bytes: 5068
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int Na, Nb;
  cin >> Na;
  
  vector<string> s(Na);
  vector<int> num(Na);
  
  string word;
  
  for(int i = 0; i < Na; i++) {
    cin >> s.at(i);
  }
  cin >> Nb;
  vector<string> t(Nb);
  for(int i = 0; i < Nb; i++) {
    cin >> t.at(i);
  }
  for(int i = 0; i < Na; i++) {
    for(int j = 0; j < Na; j++) {
      if(s.at(i) == s.at(j)){
        num.at(i)++;
      }
    }
    for(int j = 0; j < Nb; j++) {
      if(s.at(i) == t.at(j)){
        num.at(i)--;
      }
    }
  }
  int answer;
  cout << max(answer = *max_element(num.begin(), num.end()), 0) << endl;
}


Measured memory_bytes: 256
n, k = (int(i) for i in input().split()) 


# 89 人　は一つしか貰えないが、１人は11個もらえる
 
others = k - 1  # 最大限に貰えないひとたちの人数
min_num = 1
max_num = n - others
 

if k < 2:
    print(0)
else:
    print(max_num - min_num)

Measured memory_bytes: 2940
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> void get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'; t=getchar());
	if(t=='-')neg=true,t=getchar();
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) get1(a),get1(b)
#define get3(a,b,c) get1(a),get2(b,c)
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<62;
const double pi=acos(-1.0);

const int mod=1e9+7;
pii p[200111];
int n,tl[200111],tr[200111],ord[200111];
bool cmp(int x,int y){return mp(tl[x],tr[x])<mp(tl[y],tr[y]);}

vector<int> vs;
int bit[200111],bmx[200111];
void add(int x,int v){for(;x<200111;x+=x&-x)bit[x]=(bit[x]+v)%mod;}
void modify(int x,int v){for(;x<200111;x+=x&-x)bmx[x]=max(bmx[x],v);}
int querymx(int x){int ret=-inf;for(;x>0;x-=x&-x)ret=max(ret,bmx[x]);return ret;}
int query(int x){int ret=0;for(;x>0;x-=x&-x)ret=(ret+bit[x])%mod;return ret;}
int main()
{
	get1(n);
	for(int i=1;i<=n;i++)get2(p[i].ss,p[i].ff);for(int i=1;i<=n;i++)vs.pb(p[i].ss);
	sort(p+1,p+n+1);sort(vs.begin(),vs.end());
	
	for(int i=0;i<200111;i++)bmx[i]=-inf;
	for(int i=1;i<=n;i++)
	{
		int id=upper_bound(vs.begin(),vs.end(),p[i].ss)-vs.begin();
		modify(n-id+1,-i);
		tl[i]=-querymx(n-id+1);
	}
	for(int i=0;i<200111;i++)bmx[i]=-inf;
	for(int i=n;i>=1;i--)
	{
		int id=upper_bound(vs.begin(),vs.end(),p[i].ss)-vs.begin();
		modify(id,i);
		tr[i]=querymx(id);
		ord[i]=i;
	}
	sort(ord+1,ord+n+1,cmp);
	int ans=0;
	for(int _=1;_<=n;_++)
	{
		int i=ord[_];
		int now=(tl[i]==1);
		now=(now+query(tr[i]))%mod;now=(now+mod-query(tl[i]-2))%mod;
		if(tr[i]==n)ans=(ans+now)%mod;
		add(tr[i],now);
	}
	printendl(ans);
	return 0;
}

Measured memory_bytes: 6644
#include <functional>
#include <list>
#include <string>
#include <vector>
#include <climits>
#include <cstring>
#include <map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <set>
#include <deque>
#include <stack>
#include <cassert>
using namespace std;
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define ALL(x) (x).begin(),(x).end()
#define CASET2 int ___T, case_n = 1; scanf("%d ", &___T); while ((___T > 0 ? printf("Case #%d:\n", case_n++) : 0), ___T-- > 0)
#define CASET1 int ___T, case_n = 1; scanf("%d ", &___T); while ((___T > 0 ? printf("Case #%d: ", case_n++) : 0), ___T-- > 0)
#define CASET int ___T; scanf("%d ", &___T); while (___T-- > 0)
#define SZ(X) ((int)(X).size())
#define LEN(X) strlen(X)
#define REP(i,n) for(int i=0;i<int(n);i++)
#define REP1(i,a,b) for(int i=(a);i<=int(b);i++)
#define PER1(i,a,b) for(int i=(a);i>=(b);i--)
#define REPL(i,x) for(int i=0;x[i];i++)
#define PER(i,n) for(int i=(n)-1;i>=0;i--)
#define RI1(x) scanf("%d",&x)
#define RI2(x,y) RI1(x), RI1(y)
#define RI3(x,y...) RI1(x), RI2(y)
#define RI4(x,y...) RI1(x), RI3(y)
#define RI5(x,y...) RI1(x), RI4(y)
#define RI6(x,y...) RI1(x), RI5(y)
#define GET_MACRO(_1, _2, _3, _4, _5, _6, NAME, ...) NAME
#define RI(argv...) GET_MACRO(argv, RI6, RI5, RI4, RI3, RI2, RI1)(argv)
#define DRI(argv...) int argv;RI(argv)
#define WRI(argv...) while (RI(argv) != EOF)
#define DWRI(x...) int x; WRI(x)
#define RS(x) scanf("%s",x)
#define MP make_pair
#define PB push_back
#define MS0(x) memset(x,0,sizeof(x))
#define MS1(x) memset(x,-1,sizeof(x))
#define X first
#define Y second
#define V(x) vector<x >

typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long LL;
const int INF = 1000000000;

void print(int i) { printf("%d", i); }
void print(LL i);
template<class T> void PI(T i) { print(i); puts(""); }
template<class T> void PIS(T i) { print(i); printf(" "); }

template<class T>
void PV(T const &v, int N) {
    REP(i, N) {
        print(v[i]);
        printf("%c", i == N-1 ? '\n' : ' ');
    }
}

template<class T> void PV(T const &v) { PV(v, SZ(v)); }

template<class T, class S> bool has_bit(T mask, S i) { return (mask >> i) & 1; }
long long shift(int i) { return 1ll << i; }

template<class C> void mini(C&a4, C b4){a4=min(a4, b4); }
template<class C> void maxi(C&a4, C b4){a4=max(a4, b4); }
int popcount(int x) { return __builtin_popcount(x); } 
int popcount(long long x) { return __builtin_popcountll(x); } 

#include <unordered_set>
#include <unordered_map>
#define EB emplace_back
#define RL(x) scanf("%lld", &(x))
#define PL(x) printf("%lld\n", x)
#define DRL(x) LL x; RL(x)

int main() {
    DRI(N);
    VI A(N);
    REP(i, N) {
        RI(A[i]);
        A[i] -= i;
    }
    sort(ALL(A));
    LL ans = 0;
    REP(i, N) {
        ans += abs(A[i] - A[N / 2]);
    }
    PL(ans);
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define put(x) cout << x << endl;
using namespace std;
int main()
{
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    if (a >= k) {
        put(k);
    }
    else if (a + b >= k) {
        put(a)
    }
    else {
        put(a - (k - a - b))
    }
    
    return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, a[200001];

int main() {
	cin >> n;
	inc(i, n) { cin >> a[i]; }
	
	LL ans = 0;
	bool f = (a[0] == 0);
	dec(i, n) {
		if(a[i] + 1 < a[i + 1]) { f = false; }
		if(a[i] + 1 > a[i + 1]) { ans += a[i]; }
	}
	
	if(! f) { ans = -1; }
	cout << ans << endl;
	
	return 0;
}


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

const int MAX = 2 * 1e+6 ;
const int MOD = 1e+9 + 7;
long long fac[MAX], finv[MAX], inv[MAX];


void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    // cout << int(-1/3) << endl;
    int X, Y; cin >> X >> Y;
    if ((X+Y) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    } else if ((2*Y-X < 0) | (2*X-Y < 0)) {
        cout << 0 << endl;
        return 0;
    }

    // cout << mod << endl;
    int n, m;
    n = (2*Y-X)/3;
    m = (2*X-Y)/3;
    // cout << n << m << endl;

    COMinit();

    cout << COM((n+m), min(n, m)) << endl;
    return 0;
}

// 999999 999999
// 151840682
// 351200546

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

using namespace std;

const int maxn = 2*1e3+10;

vector<int> graph[maxn];

int main(){

	int n,x,y;

	cin >> n >> x >> y;

	vector<int> ans(n+1,0);

	for(int i=1;i<=n;++i){
		for(int j=i;j<=n;++j){
			int m_dist = min(abs(j-i),
				abs(x-i)+1+abs(y-j));
			ans[m_dist]++;
		}
	}

	for(int i=1;i<n;++i){
		cout << ans[i] << '\n';
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>

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

const int INF = 1<<30;

int main(){
  int n;cin>>n;
  map<int, int> mp;
  for(int i=0;i<n;i++){
    int a;cin>>a;mp[a]++;
  }
  vector<int> edge;
  for(auto itr=mp.begin();itr!=mp.end();itr++){
    if(itr->second>=2)edge.push_back(itr->first);
    if(itr->second>=4)edge.push_back(itr->first);
  }
  int a, b;a=b=0;
  for(int i=0;i<(int)edge.size();i++){
    int t=edge[i];
    if(t>a){
      b=a;a=t;
    }else if(t>b){
      b=t;
    }
  }
  cout<<ll(a)*ll(b)<<endl;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e18;
//const int INF=(1<<30);


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

  transform(a.begin(), a.end(), a.begin(), ::toupper);
  transform(b.begin(), b.end(), b.begin(), ::toupper);
  transform(c.begin(), c.end(), c.begin(), ::toupper);

  cout << a[0] << b[0] << c[0] << endl;

}



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

int main(void)
{
  int N;
  constexpr auto r = 1.08;
  cin >> N;
  int c = ceil((double)N / r);
  int f = floor((double)N /r);
  auto add_tax = [&r](int x){ return floor((double)x * r); };
  if ( add_tax(c) == N )
    cout << c;
  else if ( add_tax(f) == N )
    cout << f;
  else
    cout << ":(";
  cout << endl;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B1 solver = new B1();
        solver.solve(1, in, out);
        out.close();
    }

    static class B1 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long x = in.nextLong();
            long count = 0;
            double money = 100;
            while (money < x) {
                money = (long) (money * 1.01);
                count++;
            }

            out.println(count);
        }

    }

    static class Scanner {
        private final InputStream in;
        private final byte[] buffer;
        private int ptr;
        private int buflen;

        public Scanner(InputStream in) {
            this.in = in;
            this.buffer = new byte[1024];
            this.ptr = 0;
            this.buflen = 0;
        }

        private boolean hasNextByte() {
            if (ptr < buflen) return true;
            else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) return false;
            }
            return true;
        }

        private byte readByte() {
            if (hasNextByte()) return buffer[ptr++];
            return -1;
        }

        private boolean isPrintableChar(byte c) {
            return '!' <= c && c <= '~';
        }

        private void skipUnprintable() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
                ptr++;
            }
        }

        public boolean hasNext() {
            skipUnprintable();
            return hasNextByte();
        }

        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            byte b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while (true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

    }
}



Measured memory_bytes: 25572
/*
h s, d't skp th si tll i's sved
 * ABC141 E
 * ABC145 D
 * ABC147 F
*/
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main()
{
int n;
cin>>n;
int a[n];
bool ok=0;
int k=1;
for(int i=0;i<n;i++)
{
cin>>a[i];
}
for(int i=0;i<n;i++)
{
if(a[i]==k)
{
k++;
ok=1;
}
}
if(!ok)
{
k=n+2;
}
cout<<n-k+1<<endl;
}

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


signed main(){
	int N,W;cin>>N>>W;
	vector<int>w(N),v(N);
	rep(i,N)cin>>w[i]>>v[i];
	vector<vector<int>>v4(4);
	vector<vector<int>>sm(4,vector<int>(101,0));
	int w0=w[0];
	rep(i,N){int x=w[i]-w0;v4[x].push_back(v[i]);}
	rep(i,4){sort(begin(v4[i]),end(v4[i]),greater<int>());}
	vector<int>sz(4);
	rep(i,4)sz[i]=v4[i].size();
	rep(i,4)rep(j,sz[i])sm[i][j+1]=sm[i][j]+v4[i][j];

	int ret=0,ans=0;
	rep0(i,sz[0])rep0(j,sz[1])rep0(k,sz[2])rep1(l,sz[3]){
		
		if(i*w0+j*(w0+1)+k*(w0+2)+l*(w0+3)>W)continue;
		ret=0;
		ret+=sm[0][i];ret+=sm[1][j];ret+=sm[2][k];ret+=sm[3][l];
		ans=max(ans,ret);
		break;
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;
struct edge { int to, cost; };

vector<vector<edge> >G;
int N, X, Y;
int d[3000];
void dikstra(int s) {
	priority_queue<pii, vector<pii>, greater<pii> >que;
	REP(i, N)d[i] = INF;
	d[s] = 0;
	que.push(pii(0, s));
	while (!que.empty()) {
		pii p = que.top();
		que.pop();
		int v = p.second;
		if (d[v] < p.first)continue;
		REP(i, G[v].size()) {
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(pii(d[e.to], e.to));
			}
		}
	}
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	
	cin >> N >> X >> Y;
	G.resize(N);
	X--; Y--;
	G[X].push_back((edge) { Y, 1 });
	G[Y].push_back((edge) { X, 1 });
	VI ans(N - 1, 0);
	REP(i, N - 1) {
		edge e, f;
		e.cost = f.cost = 1;
		e.to = i + 1;
		f.to = i;
		G[i].push_back(e);
		G[i + 1].push_back(f);
	}
	REP(i, N - 1) {
		dikstra(i);
		FOR(j, i + 1, N) {
			ans[d[j]-1]++;
		}
	}
	REP(i, N - 1)cout << ans[i] << endl;




	return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...) 0
#endif

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

    int r, c, n;
    cin >> r >> c >> n;
    vector<pair<pair<int, int>, pair<int, int>>> a;
    bool tate = false, yoko = false;
    rep(i, 0, n) {
        int x, y, z, w;
        cin >> x >> y >> z >> w;
        pair<pair<int, int>, pair<int, int>> p = {{x, y}, {z, w}};
        int cnt = 0;
        if (x % r == 0 || y % c == 0) cnt++;
        if (z % r == 0 || w % c == 0) cnt++;
        if (cnt == 2) {
            a.emplace_back(p);
        }
        if (x % r == 0 && z % r == 0 && y % c == 0 && w % c == 0) continue;
        if (x % r == 0 && z % r == 0 && x != z) tate = true;
        if (y % c == 0 && w % c == 0 && y != w) yoko = true;
    }
    n = a.size();
    if (tate & yoko) {
        cout << "NO" << endl;
        return 0;
    }
    rep(qq, 0, 4) {
        vector<pair<int, pair<int, int>>> z;
        rep(i, 0, n) {
            if (a[i].first.first == 0) {
                z.emplace_back(a[i].first.second, a[i].second);
            }
            if (a[i].second.first == 0) {
                z.emplace_back(a[i].second.second, a[i].first);
            }
        }
        int mx = 0;
        stack<int> tt;
        sort(z.begin(), z.end());
        debug(qq);
        rep(i, 0, z.size()) {
            int v = z[i].first;
            pair<int, int> p = z[i].second;
            if (p.first == 0) {
                if (p.second < v) {
                    if (tt.top() != p.second) {
                        cout << "NO" << endl;
                        return 0;
                    }
                    tt.pop();
                } else {
                    tt.push(v);
                }
            } else {
                if (tt.size() != 0) {
                    cout << "NO" << endl;
                    return 0;
                }
                int tmp = p.second;
                if (tmp == 0)
                    tmp = p.first;
                else if (tmp == c)
                    tmp += 2 * r - p.first;
                else
                    tmp += r;
                debug(z[i], tmp);
                if (tmp < mx) {
                    cout << "NO" << endl;
                    return 0;
                } else
                    mx = tmp;
            }
        }
        if (qq % 2 == 0) {
            rep(i, 0, n) {
                a[i].first.first = r - a[i].first.first;
                a[i].second.first = r - a[i].second.first;
            }
        }
        if (qq == 1) {
            swap(c, r);
            rep(i, 0, n) {
                swap(a[i].first.first, a[i].first.second);
                swap(a[i].second.first, a[i].second.second);
            }
        }
    }

    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 4308
#include <stdio.h>
#define Max 500000
#define INFTY 2000000000

int L[Max/2+2];
int R[Max/2+2];
int count =0;

void mergeA(int A[],int left,int mid,int right){
    int n1 = mid-left;
    int n2 = right-mid;
    
    int i,j,k;
    for(i=0; i<n1; i++) L[i]=A[left + i];
    for(i=0; i<n2; i++) R[i]=A[mid + i];
    L[n1] = INFTY;
    R[n2] = INFTY;
    i=0;
    j=0;
    for(k=left; k<right; k++){
        if(L[i]<=R[j]){
            A[k] = L[i];
            i++;
            count++;
        }else{
            A[k] = R[j];
            j++;
            count++;
        }
    }
    
    
}

void mergeSort(int A[],int left,int right){
    if(left+1<right){
        int mid =(left+right)/2;
        mergeSort(A,left,mid);
        mergeSort(A,mid,right);
        mergeA(A,left,mid,right);
    }
}




int main() {
    int n;
    int i;
    int A[Max];
    scanf("%d",&n);
    
    for(i=0; i<n; i++){
        scanf("%d",&A[i]);
    }
    mergeSort(A, 0, n);
    
    for(i=0; i<n; i++){
        printf("%d",A[i]);
        if(i<n-1) printf(" ");
    }
    printf("\n%d\n",count);
    
    return 0;
}

Measured memory_bytes: 4508
#include<iostream>
using namespace std;
int main(){
    int H,W;
    cin >>H >>W;
    while(H!=0){
        int I,J;
        for(I=0;I<H;I++){
            for(J=0;J<W;J++){
        cout <<'#';
            }
            cout << endl;
        }
        cout << endl;
        cin >>H >>W;
    }
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int  ,int > pii;
typedef pair<ll  ,ll > pll;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn  = 3e6;
const ll mod =1e9+7;
const ld PI = 4 * atan((ld) 1);

#define pb(x) push_back(x);
#define endl '\n'
#define dominance true
#define dokme(x) cout << x ;  return(0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
#define ms(x , y) memset(x , y , sizeof x);
ll pw(ll a, ll b, ll md = mod) {
    ll res = 1;while(b){if(b&1){res=(a*res)%mod;}a=(a*a)%mod;b>>=1;}return(res);
}

int n,k;
int h[maxn];
int dp[maxn];

int main(){
    migmig
    cin >> n >> k;
    for (int i = 1 ; i <= n ; i ++){
        cin >> h[i];
        if(i > 1){
            dp[i] = dp[i-1]+abs(h[i] - h[i-1]);
        }
        for(int j = 1 ; j <= k ; j ++){
            if(i > j){
                dp[i] = min(dp[i] ,dp[i-j]+abs(h[i] - h[i-j]));
            }
        }
    }
    cout << dp[n];
    return(0);
}

//When we hit our lowest point, we are open to the greatest change.
//If I try, I fail. If I don't try, I'm NEVER GOING TO GET IT.
//Sometimes, life is like this dark tunnel. You can't always see the light at the end of the tunnel. But if you just keep moving... you will come to a better place.
//It is important to draw wisdom from diffrent places. If you take it from only one place it becomes rigid and stale.
//kuxtal jach uts chuchul u u páajtal máak jach táaj meyajilo'ob le castigadas tumen ch'aik descansos.


Measured memory_bytes: 2688
#include <iostream>

using namespace std;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
#ifdef _debug
#define dout(i) cout << #i << ' ' << i << ' '
#else 
#define dout(i) 0 and 0
#endif
#define rout(i) (cout << i << '\n', 0)
using ll = long long;
using ull = unsigned long long;
using ul = unsigned;
using db = double;
template<typename T, typename S>
inline istream& operator >> (istream &in, const pair<T, S> &a){
	return in >> a.first >> a.second;
}
template<typename T, typename S>
inline ostream& operator << (ostream &ou, const pair<T, S> &b){
	return ou << b.first << ' ' << b.second;
}
#define int ll
const int maxn = 1001;
int n, a[maxn];
struct result{
	ll sum = 0;
	vector<int> step;
	bool operator < (const result &b)const{
		return sum < b.sum;
	}
	void print(){
		cout << sum << '\n' << step.size() << '\n';
		for(auto &i : step)cout << i << '\n';
	}
}res;
result give(deque<int> d, int s){
	result cur;
	if(s)cur.step.push_back(1);
	while(d.size() and d.back() < 0)cur.step.emplace_back(d.size()), d.pop_back();
	while(d.size() >= 2 and d.front() < 0)d.pop_front(), d.pop_front(), cur.step.emplace_back(1), cur.step.emplace_back(1);
	cur.sum = d.front();
	while(d.size() >= 3){
		if(d[2] >= 0){
			int v = d[2];
			cur.sum += v;
			cur.step.emplace_back(2);
			int o = d.front();
			d.pop_front();
			d.pop_front();
			d.pop_front();
			d.push_front(o+v);
		}
		else{
			if(d.size() == 3){
				cur.step.emplace_back(3);
				cur.step.emplace_back(2);
				return cur;
			}
			cur.step.emplace_back(3);
			int v = d.front();
			d.pop_front();
			d.pop_front();
			d.pop_front();
			d.pop_front();
			d.push_front(v);
			d.push_front(v);
		}
	}
	if(d.size() == 2)cur.step.emplace_back(2);
	return cur;
}
signed main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n;
	for(int i = 1;i <= n;++i)cin >> a[i];
	{
		int* ma = max_element(a+1, a+n+1);
		res.sum = *ma;
		for(int i = n;i > ma-a;--i)res.step.emplace_back(i);
		for(int i = 1;i < ma-a;++i)res.step.emplace_back(1);
	}
	if(res.sum > 0){
		res = max(res, give(deque<int>(a+1, a+1+n), 0));
		res = max(res, give(deque<int>(a+2, a+1+n), 1));
	}
	res.print();
}

Measured memory_bytes: 256
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right
from heapq import heappush, heappop

import re
# import numpy as np
from scipy.misc import comb

# 再帰がやばいとき
# import sys
# sys.setrecursionlimit(10**9)

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

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]

INF = int(1e30)
MOD = int(1e9)+7 # 10^9 + 7

# field[H][W]
def create_grid(H, W, value = 0):
    return [[ value for _ in range(W)] for _ in range(H)]

########

def main():
    a = i_inpl()
    s = input()

    if 3200 <= a:
        print(s)
    else:
        print("red")

if __name__ == "__main__":
    main()


Measured memory_bytes: 25156
#include<bits/stdc++.h>
#include<string>
using namespace std;
typedef long long int ll;
#pragma GCC optimize "trapv"
#define fi first
#define sec second
#define pb push_back
//#define endl '\n'
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

void solve(){
	string a,b;
	cin>>a>>b;
	int len=a.size();
	int ans=0;
	for(int i=0;i<len;i++){
		if(a[i]!=b[i]){ans++;}
	}
	cout<<ans<<endl;
}
int main(){
	fio;
	int test;
	//cin>>test;
	test=1;
	while(test--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3824
#include<iostream>
using namespace std;
int main()
{
	int n, m, l, a[100][100] = { 0 }, b[100][100] = { 0 },s=0;
	long long c[100][100] = { 0 };
	cin >> n >> m >> l;
	for (int i = 0;i<n;i++){
		for (int k = 0;k<m;k++){
			cin >> a[i][k];
		}
	}
	for (int k = 0; k < m; k++){
		for (int j = 0;j < l; j++){
			cin >> b[k][j];
		}
	}
	for (int i = 0;i<n;i++){
		for (int j = 0; j < l; j++){
			for (int k = 0; k<m; k++){
				c[i][j] +=a[i][k]*b[k][j];
			}
		}
	}
	for (int i = 0; i < n; i++){
		for (int j = 0; j < l; j++){
			if (s == 1){
				cout << " ";
			}
			cout << c[i][j];
			s = 1;
		}
		cout << endl;
		s = 0;
	}
	return 0;
}

Measured memory_bytes: 3252
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
#define ll long long 
#define pb push_back
int main(){	
	fast;
		ll n,m; cin>>n>>m;
		ll p = n*(n-1);
		ll k=  m*(m-1);
		ll j=p+k;
		cout<<j/2;
		}
		
		
		
	
	

	
	
	
		

Measured memory_bytes: 256
N, M = list(map(int,input().split()))

b = [0]*(N+2)
b[0] = 1

for i in range(M):
    b[int(input())] = -1

for i in range(N):
    if b[i] != -1:
        if b[i+1] != -1:
            b[i+1] += b[i]
        if b[i+2] != -1:
            b[i+2] += b[i]
        b[i] %= 1000000007

print(b[N]%1000000007)

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



int main(int argc, char const *argv[]) {
  int n,m;
  cin >> n >> m;
  priority_queue<ll> pq;
  rep(i,n){
    int a;
    cin >> a;
    pq.push(a);
  }

  rep(i,m){
    ll x=pq.top();
    pq.pop();
    pq.push(x/2);
  }

  ll ans=0;

  rep(i,n){
    ll x=pq.top();
    ans+=x;
    pq.pop();
  }

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


Measured memory_bytes: 1400
import Control.Applicative
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)

isPrime :: Integral a => a -> Bool
isPrime n = let m = floor . sqrt $ fromIntegral n
              in
                  all ((/= 0) . mod n) [2..m]

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.lines <$> BC.getContents

main = do
    _ <- getLine
    readInts >>= print . length . filter isPrime

Measured memory_bytes: 5024
#include<bits/stdc++.h>
using namespace std;
int f[300],s[300];
int main(){
	int n,i,j;
	string a[100];
	cin>>n;
	for(i=0;i<n;i++)cin>>a[i];
	for(i=0;i<300;i++)s[i]=10000;
	for(i=0;i<n;i++){
		memset(f,0,sizeof(f));
		for(j=0;j<a[i].size();j++){
			f[a[i][j]]++;
		}
		for(j=0;j<300;j++){
			if(f[j]<s[j]){
				s[j]=f[j];
			}
		}
	}
	for(i=0;i<300;i++){
		for(j=0;j<s[i];j++){
			cout<<char(i);
		}
	}
	return 0;
}



Measured memory_bytes: 256
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    let mut ans = 0_u64;
    let mut cnt = 0_u64;
    for x in buf.trim().chars().rev() {
        if x == 'B' {
            ans += cnt;
        } else {
            cnt += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< int, ll > P;
#define FOR(i,N) for(i=0;i<N;i++)
int N,K;
vector <P> t;

bool pairCompareFirst(const P& firstElof, const P& secondElof){
  return firstElof.first > secondElof.first;
}


bool pairCompareSecond(const P& firstElof, const P& secondElof){
  return firstElof.second > secondElof.second;
}

int main(void){
  cin >> N >> K;
  t.resize(N);
  //k：食べる種類,k_max：食べる種類の最大値
  int i,k=0,k_max=0;
  int num[N+1];
  //種類iの最大か否か
  bool kind_max[N];

  vector<ll> base(N,0);
  ll sum = 0;
  ll max = 0;

  FOR(i,N+1) num[i] = 0;
  FOR(i,N){
    cin >> t[i].first >> t[i].second;
  }
  sort(t.begin(),t.end(),pairCompareSecond); 
  
  FOR(i,N){
    k_max+=num[t[i].first]==0;
    kind_max[i] = (num[t[i].first] == 0);
    if(i<K){
      sum += t[i].second;
      k+=num[t[i].first]==0;
    }
    num[t[i].first]++;
  }
  base[k-1] = sum;
  max = sum + (ll) k*k;

  int EM_index=K-1, NM_index=K;
  for(i=k;i < k_max && i < K ; i++){
    //交換可能な場所まで移動
    while(kind_max[EM_index]){
      EM_index--;
      if(EM_index < 0) break;
    }
    while(!kind_max[NM_index]){
      NM_index++;
      if(NM_index >= N) break;
    }
    //cout << EM_index << " " << NM_index << endl;
    base[i] = base[i-1] - t[EM_index].second + t[NM_index].second;
    if(base[i] + (ll)(i+1)*(i+1) > max) max = base[i] + (ll)(i+1)*(i+1);
    swap(t[EM_index],t[NM_index]);
    swap(kind_max[EM_index],kind_max[NM_index]);
    if(EM_index != 0) EM_index--;
    else break;
    if(NM_index != N-1) NM_index++;
    else break;
  }
  //cout << endl;
  //FOR(i,N) cout << t[i].first << " " << t[i].second << " " << kind_max[i] <<  endl;
  cout << max << endl;

  return 0;
}

Measured memory_bytes: 3072
#include <stdio.h>

int main(void){
  int x,y,s,i,j,max=0;
  while(1){
    scanf("%d%d%d",&x,&y,&s);
    if(x+y+s==0)break;
    max = 0;
    for(i=1;i<s;i++)for(j=i;j<s;j++)if((i*(100+x)/100+j*(100+x)/100)==s&&i*(100+y)/100+j*(100+y)/100>max)max=i*(100+y)/100+j*(100+y)/100;
    printf("%d\n",max);
  }
  return 0;
}


Measured memory_bytes: 2028
import heapq

n, m = [ int(v) for v in input().split() ]
demand = []
for i in range(m):
    l, r = [ int(v) for v in input().split() ]
    demand.append( (r,l) )
demand.sort()

right, left = heapq.heappop(demand)
ans = 1

for i in range(m-1):
    ri, li = heapq.heappop(demand)
    if li >= right:
        ans += 1
        right = ri

print(ans)


Measured memory_bytes: 64952
package main

import (
	"bufio"
	"fmt"
	"os"
)

const ASCII_A = 0x41
const ASCII_Z = 0x5a
const ASCII_a = 0x61
const ASCII_z = 0x7a

func count(text string, alphabet *[26]int) {
	data := []byte(text)

	for i := 0; i < len(data); i++ {
		if !((data[i] >= ASCII_a && data[i] <= ASCII_z) ||
			(data[i] >= ASCII_A && data[i] <= ASCII_Z)) {
			continue
		}
		idx := int(data[i]|0x20) - ASCII_a
		alphabet[idx] += 1
	}
}

func print_count(alpha_count [26]int) {
	var chr_a byte = 0x61

	for i := 0; i < len(alpha_count); i++ {
		fmt.Printf("%c : %d\n", chr_a, alpha_count[i])
		chr_a += 1
	}
}

func main() {
	var alphabet [26]int

	// 出現回数初期化
	for i := 0; i < len(alphabet); i++ {
		alphabet[i] = 0
	}
	stdin := bufio.NewScanner(os.Stdin)
	for stdin.Scan() {
		text := stdin.Text()
		count(text, &alphabet)
	}

	print_count(alphabet)
}


Measured memory_bytes: 1100
#include "bits/stdc++.h"
using namespace std;

int a, b;

int main(){
	scanf("%d %d", &a, &b);
	for(int i = 1; i <= 10; ++i){
		if(i != a && i != b){
			printf("%d\n", i);
			return 0;
		}
	}
}

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

int main(int argc, const char * argv[]) {



    cin.tie(0);
    ios::sync_with_stdio(false);

    /////////////////////
    // Write code below /
    /////////////////////
    int A,B,C;

    cin>>A>>B>>C;

    if(A*C<B){
        cout<<C<<endl;
    }
    else{
        cout<<B/A<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    ll n, m;
    cin >> n >> m;
    vi p(m);
    vector<string> s(m);
    // vector<int> cnt(n + 1, 0);
    vector<bool> ac(n + 1, false);
    vector<int> pen(n + 1, 0);
    for (int i = 0; i < m; ++i) {
        cin >> p[i] >> s[i];
    }
    int pena = 0;
    int acs  = 0;
    for (int i = 0; i < m; ++i) {
        if (s[i] == "AC") {
            if (!ac[p[i]]) {
                acs++;
                ac[p[i]] = true;
                pena += pen[p[i]];
            }
        } else {
            if (!ac[p[i]]) {
                pen[p[i]]++;
            }
        }
    }
    cout << acs << " " << pena << "\n";
    return 0;
}

Measured memory_bytes: 6528
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		Scanner sc= new Scanner(System.in);
		Integer M[]= new Integer[10];
		for(int i=0; i<M.length; i++) {
			M[i]=sc.nextInt();
		}
		Arrays.sort(M,Collections.reverseOrder());
		
		for(int i=0; i<3; i++) {
			System.out.println(M[i]);
		}
		
	}

}


Measured memory_bytes: 26232
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a[] = new int[n];
        for (int i=0; i<n; i++) {
            a[i]=sc.nextInt();
        }
        for (int i=1; i<n; i++) {
            System.out.print(a[n-i]+" ");
        }
        System.out.println(a[0]);
    }
}
            


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

using namespace std;

#define sz(s) ((int)s.size())

typedef long long ll;

const long double eps = 0.0000000001;
const int MOD = 998244353;
const int INF = 1000055555;
const long long LLINF = 1223372000000000555;
const int N = 2250555;
const int M = 2522;

vector<int> g[N];

bool used[N];

void dfs(int v){
    used[v] = true;
    for (int q : g[v]){
        if (!used[q]) dfs(q);
    }
}

void solve() {
    int n, m;
    cin >> n >> m;

    for (int i = 1; i <= m; i++){
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    int comp = 0;
    for (int i = 1; i <= n; i++){
        if (!used[i]) {
            dfs(i);
            comp++;
        }
    }

    cout << comp - 1;

}


int main() {
    ios_base::sync_with_stdio(false);
#ifdef dddxxz
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else

#endif

    int T = 1;
    //cin >> T;

    while (T--) {
        solve();
    }

    return 0;
}

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

int main() {
	int X, N;
	cin >> X >> N;
	vector<int> p(N);
	rep(i, N) cin >> p[i];

	int ans = 0;
	for(int i = 0; i <= 101; i++) {
		bool flag = true;
		rep(j, N) {
			if(i == p[j]) flag = false;
		}

		if(flag) {
			if(abs(ans - X) > abs(i - X)) ans = i;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashMap;
import java.util.StringTokenizer;

public class Main{

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter wr = new PrintWriter(System.out);
        String str = br.readLine().trim();
        
        int n = Integer.parseInt(str);
        str = br.readLine().trim();
        StringTokenizer stk = new StringTokenizer(str);
        int d = Integer.parseInt(stk.nextToken());
        int x = Integer.parseInt(stk.nextToken());
        int[] a = new int[n]; int total=n;
        for(int i=0;i<n;i++) {
        	a[i] = Integer.parseInt(br.readLine().trim());
        	if(a[i]==1) {
        		total+=(int)d/a[i];total--;
        	}
        	else total+=(int)((d-1)/(a[i]));
        	
        }
        System.out.println(total+x);
	}

}


Measured memory_bytes: 20564
n, m = map(int, input().split())
a = list(map(lambda x: [int(x),1], input().split()))

for i in range(m):
    b , c = map(int,input().split())
    a.append([c,b])
a.sort(reverse = True)

ans = 0
for x,y in a:
    if y < n:
        ans += x*y
        n = n-y
    elif y >=n:
        ans += x*n
        break
print(ans)

Measured memory_bytes: 33784
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int mxn = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    string s = "ACL";
    string ans = "";
    for(int i=0; i<n; i++){
        ans += s;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3616
def cardgame(animal1, animal2, taro, hanako):
    if animal1==animal2:
        return [taro+1, hanako+1]
    anim_list = sorted([animal1, animal2])
    if anim_list[0]==animal1:
        return [taro, hanako+3]
    else:
        return [taro+3, hanako]

n = int(input())
taro, hanako = 0, 0
for i in range(n):
    data = input().split()
    result = cardgame(data[0], data[1], taro, hanako)
    taro, hanako = result[0], result[1]
print(taro, end=" ")
print(hanako)



Measured memory_bytes: 5596
#include<stdio.h>
#include<math.h>
 
int main(){
    int a;
    scanf("%d",&a);
    int b=100000;
    for(int i=0;i<a;i++){
        b*=1.05;
        if(b%1000!=0)b=(b/1000+1)*1000;
    }
    printf("%d\n",b);
}


Measured memory_bytes: 2580
x = int(input())
rx = int(x**(1/2)) + 1
P = [2] + [2*i+1 for i in range(1, rx//2)]
while True:
    flag = True
    for i in P:
        if x % i == 0:
            flag = False
            break
    if flag or x == 2:
        print(x)
        break
    P.append(int(x**(1/2)+1))
    x += 1

Measured memory_bytes: 3064
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}
}

use input::*;

fn main() {
    let n: usize;
    input!(n);
    let s = str2vec(&input_line_str());
    let cr = s.iter().filter(|&&x| x == 'R').count();
    let cb = n - cr;
    if cr > cb {
        p("Yes");
    } else {
        p("No");
    }
}

Measured memory_bytes: 4352
import heapq
from sys import stdin
input = stdin.readline

#入力
# s = list(input()[0:-1])
# n = int(input())
N,P = map(int, input().split())
# a = list(map(int,input().split()))
# b = list(map(int,input().split()))
# w = [int(input()) for i in range(n)]

# ab=[]
# for i in range(N):
#     a,b = map(int, input().split())
#     ab.append((a,b))
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
def main():
    res = factorization(P)
    ans = 1
    for fac in res:
        p, index = fac[0],fac[1]
        ans *= (p)**(index//N)
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.stream.IntStream;

public class Main {
  private static PrintWriter out;

  public static void main(String[] args) {
    Main main = new Main();
    Runtime.getRuntime().addShutdownHook(new Thread(() -> out.close()));
    try {
      main.run(args);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }

  private void run(String[] arguments) throws Exception {
    MyScanner sc = new MyScanner();
    out = new PrintWriter(new BufferedOutputStream(System.out));
    int N = sc.nextInt(), K = sc.nextInt();
    int[] trees = new int[N];
    IntStream.range(0, N).boxed().forEach(i->trees[i]=sc.nextInt());
    Arrays.sort(trees);

    int shift = K-1;
    int ans = Integer.MAX_VALUE;
    for (int i = 0; i < N-shift; i++) {
        int min = trees[i];
        int max = trees[i+shift];
        int sub = max - min;
        if (sub<ans){
            ans = sub;
        }
    }
    System.out.println(ans);
  }

  /*          
   * Form: http://codeforces.com/blog/entry/7018
   */
  private class MyScanner {
    BufferedReader br;
    StringTokenizer st;

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

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

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

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

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

    String nextLine() {
      String str = "";
      try {
        str = br.readLine();
      } catch (IOException e) {
        e.printStackTrace();
      }
      return str;
    }
  }
}


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

#define MAX 25

class Task {
public:
  int d, lim;
  Task(int d = 0, int lim = 0) : d(d), lim(lim) {}
  bool operator < ( const Task &t ) const {
    if( lim == t.lim ) return d < t.d;
    return lim < t.lim;
  }
};

int main() {
  int n;
  Task T[MAX];
  bool success;
  int cur;

  while(cin >> n && n) {
    for(int i = 0; i < n; i++) {
      cin >> T[i].d >> T[i].lim;
    }
    sort(T, T+n);
    success = true;
    cur = 0;
    for(int i = 0; i < n && success; i++) {
      cur += T[i].d;
      if(T[i].lim < cur) success = false;
    }
    if(success) cout << "Yes" << endl;
    else cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 1156