akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int n, k;
string s[][7] = {{"aacd","bbcd","cdaa","cdbb"}, {"aa.ab",".bbab","a.cca","a.a.a","bbabb"}, {"aacd..","bbcd..","cd..aa","cd..bb","..aacd","..bbcd"},{"aacd...","bbcd...","cd.aa..","cd...bb","..a.baa","..a.b.b","..bbaab"}};
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	k = n%4;
	if(n < 3) cout << -1 << '\n';
	else if(n == 3) cout << "aab\nb.b\nbaa\n";
	else rep(i,n){
		string b(n,'.');
		if(i<n-k-4) b.replace(i/4*4,4,s[0][i%4]);
		else b.replace(n-k-4,k+4,s[k][i-n+k+4]);
		cout << b << '\n';
	}
}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second

Int INF = 1e18;
Int mod = 1e9+7;
//Int mod = 998244353;

int main() {
    Int x, y;
    cin >> x >> y;
    Int res = 0;
    if (x == 1) {
        res += 300000;
    }
    else if (x == 2) {
        res += 200000;
    }
    else if (x == 3) {
        res += 100000;
    }
    if (y == 1) {
        res += 300000;
    }
    else if (y == 2) {
        res += 200000;
    }
    else if (y == 3) {
        res += 100000;
    }
    if (x == 1 && y == 1) {
        res += 400000;
    }
    dump(res);
    return 0;
}

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

using namespace std;
typedef long long ll;
const int MAXN = 200100;

int N, P;
string S;
int d[MAXN];
int p10[MAXN];

int main()
{
    ios_base::sync_with_stdio(0);

    cin >> N >> P >> S;
    p10[0] = 1;
    for (int i = 0; i < N; i++)
    {
        d[i] = S[i] - '0';
        p10[i+1] = (10 * p10[i]) % P;
    }

    if (P == 2 || P == 5)
    {
        ll res = 0;
        for (int i = 0; i < N; i++)
        {
            if (d[i] % P == 0)
                res += (i + 1);
        }
        cout << res << "\n";
        return 0;
    }

    map <int, int> m;
    ll res = 0;
    m[0]++;

    ll cv = 0;
    for (int i = 0; i < N; i++)
    {
        cv += (d[i] * p10[N-1-i]);
        cv %= P;
        res += m[cv];
        m[cv]++;
    }
    cout << res << "\n";
}

Measured memory_bytes: 2452
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[a]; if (a != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	while (1) {
		int n, m;
		cin >> n >> m;
		if (!n)break;
		int r;
		cin >> r;
		vvi used(m, vi(1440, 0));
		vi cnt(m, 0);
		REP(i, r) {
			int t, a, b, s;
			cin >> t >> a >> b >> s;
			if (s == 0) {
				used[b - 1][t-1]--;
			}
			else {
				used[b - 1][t-1]++;
			}
		}
		
		REP(i, m) {
			REP(j, 1439) {
				used[i][j + 1] += used[i][j];
			}
		}
		int q;
		cin >> q;
		REP(i, q) {
			int s, e, m;
			cin >> s >> e >> m;
			s--; e--;
			int cnt = 0;
			FOR(j, s, e) {
				if (used[m - 1][j] > 0)cnt++;
			}
			cout << cnt << endl;
		}

	}
	return 0;
}

Measured memory_bytes: 57844
#include <stdio.h>

int main(){
	 long long int N = 0, M = 0;
	 long long int case_NN = 1, case_MM = 1;
	//奇数+奇数=偶数
	//偶数+偶数=偶数
	//N:偶数,M奇数
	scanf("%d %d", &N, &M);
	//nCr=n!/r!*(n-r)!=n*(n-1)*...*(n-r+1)/r!
	//NN
	for ( long long int i = N; i >= (N - 1); i--) case_NN = case_NN * i;
	case_NN = case_NN / 2;
	//MM
	for ( long long int i = M; i >= (M - 1); i--) case_MM = case_MM * i;
	case_MM = case_MM / 2;
	printf("%d\n", (case_NN + case_MM));
	return 0;
}

Measured memory_bytes: 128
// AtCoder154 C

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
#include <assert.h>
#include <string.h>
#include <memory.h>
#include <malloc.h>
#include <stdlib.h>

struct node_t {
    char s[11];
    struct node_t* left;
    struct node_t* right;
};

struct node_t* mallocNode(char* adds) {
    struct node_t* add;

    add = (struct node_t*)malloc(sizeof(struct node_t));
    if (add == NULL) {
        return NULL;
    }

    add->left = NULL;
    add->right = NULL;
    strcpy(add->s, adds);

    return add;
}

int addNode(struct node_t* root, char* tmps) {
    struct node_t* node;
    if (root == NULL) {
        root = mallocNode(tmps);
        return 1;
    }

    node = root;
    while (1) {
        if (strcmp(tmps, node->s) < 0) {
            if (node->left == NULL) {
                node->left = mallocNode(tmps);
                return 1;
            }
            node = node->left;
        }
        else if (strcmp(tmps, node->s) > 0) {
            if (node->right == NULL) {
                node->right = mallocNode(tmps);
                return 1;
            }
            node = node->right;
        }
        else {
            return 0;
        }
    }

    return 0;
}

int main() {

    int n, i, j;
    int* a; // 動的メモリの先頭アドレス用のポインタ
    char tmp_s[11];
    int cnt = 0;
    struct node_t* root;
    root = NULL;

    scanf("%d", &n);

    scanf("%s", tmp_s);
    root = mallocNode(tmp_s);
    cnt++;

    for (i = 0; i < n-1; i++) {
        scanf("%s", tmp_s);
        cnt += addNode(root, tmp_s);
    }
    printf("%d", cnt);
    return 0;
}

Measured memory_bytes: 11020
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<map>
#include<list>
#include<set>
using namespace std;

int main(){
  int t,a,ans,cnt;
  while(1){
    ans=0,cnt=0;
    cin >> t;
    if(t==0){
      break;
    }
    a=1000-t;
    if(500<=a){
      cnt=a/500;
      ans=a/500;
      a=a-(cnt*500);
    }


    if(100<=a){
      cnt=a/100;
      ans+=a/100;
      a=a-(cnt*100);
    }

    if(50<=a){
      cnt=a/50;
      ans+=a/50;
      a=a-(cnt*50);
    }

    if(10<=a){
      cnt=a/10;
      ans+=a/10;
      a=a-(cnt*10);
    }

    if(5<=a){
      cnt=a/5;
      ans++;
      a=a-5;
    }

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



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

using namespace std;

void Main()
{
	int a; cin >> a;
	string s; cin >> s;
	cout << (a >= 3200 ? s : "red") << endl;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


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

typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<LL> vl;
typedef vector<vl> vvl;
typedef long long ll;
double EPS = 1e-9;
int INF = 1000000005;
long long INFF = 1000000000000000005LL;
double PI = acos(-1);
int dirx[8] = { -1, 0, 0, 1, -1, -1, 1, 1};
int diry[8] = {0, 1, -1, 0, -1, 1, -1, 1};

#ifdef TESTING
#define DEBUG fprintf(stderr, "====TESTING====\n")
#define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define DEBUG
#define VALUE(x)
#define debug(...)
#endif

#define FOR(a, b, c) for (int(a) = (b); (a) < (c); ++(a))
#define FORN(a, b, c) for (int(a) = (b); (a) <= (c); ++(a))
#define FORD(a, b, c) for (int(a) = (b); (a) >= (c); --(a))
#define FORSQ(a, b, c) for (int(a) = (b); (a) * (a) <= (c); ++(a))
#define FORC(a, b, c) for (char(a) = (b); (a) <= (c); ++(a))
#define FOREACH(a, b) for (auto &(a) : (b))
#define REP(i, n) for (LL i = 1; i <= n; i++)
#define REPN(i, n) FORN(i, 1, n)
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define SQR(x) ((LL)(x) * (x))
#define RESET(a, b) memset(a, b, sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(v) v.begin(), v.end()
#define ALLA(arr, sz) arr, arr + sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr, sz) sort(ALLA(arr, sz))
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz))
#define PERMUTE next_permutation
#define TC(t) while (t--)



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




    double d, t, s;
    cin >> d >> t >> s;
    if (d / s <= t)
        cout << "Yes\n";
    else
        cout << "No\n";

    return 0;
}



Measured memory_bytes: 3704
import math
from collections import defaultdict
def r():
    return int(input())
def rm():
    return map(int,input().split())
def rl():
    return list(map(int,input().split()))

a,b=rm()
res=False
for i in range(a+1):
    t=a-i
    if b==i*2+t*4:
        res=True
        break
if res:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9480
#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <string.h>
#include <vector>

using namespace std;
int main() {
    int R;
    string ans;
    cin >> R;

    if(R<1200){
        ans="ABC";
    }else if(R<2800){
        ans="ARC";
    }else{
        ans="AGC";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>

#define Int register int

const int MAXN = 1e6;
int n;
char s[MAXN + 5];

inline void Work () {
	scanf ( "%d %s", &n, s + 1 );
	for ( Int i = 1; i <= n; ++ i ) s[i] ^= '1';
	bool ex1 = false;
	for ( Int i = 1; i <= n && ! ex1; ex1 |= s[i ++] & 1 );
	for ( Int i = 1; i <= n; ++ i ) {
		if ( ex1 ) s[i] &= 1;
		else s[i] >>= 1;
	}
	int Cnt = 0;
	for ( Int i = 1; i <= n; ++ i ) ( Cnt += s[i] * ( n - 1 == ( ( i - 1 ) | ( n - i ) ) ) ) &= 1;
	printf ( "%d\n", Cnt << ( ex1 ^ 1 ) );
}

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


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

int n, m, q;
vector<int> v, d, c;
class Edge{
public:
	long long cost;
	int from, to;
	Edge(long long c, int f, int t){
		cost = c;
		from = f;
		to = t;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
void readGraph(Graph &g, int E, bool D, bool C){ // E:NumofEdges, D:Directed, C:Costed
	for(int i=0; i<E; ++i){
		Edge e(0, 0, 0);
		if(!C) cin >> e.from >> e.to;
		else cin >> e.from >> e.to >> e.cost;
		g[e.from].push_back(e);
		if(!D){
			swap(e.from, e.to);
			g[e.from].push_back(e);
		}
	}
}
int ans[100010];
int rest[100010];
typedef pair<int, int> P;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n >> m;
	Graph g(n+1);
	readGraph(g, m, false, false);
	cin >> q;
	for(int i=0; i<q; ++i){
		int x, y, z;
		cin >> x >> y >> z;
		v.push_back(x);
		d.push_back(y);
		c.push_back(z);
	}
	for(int i=q-1; i>=0; --i){
		bool f = false;
		if(ans[v[i]] == 0){
			ans[v[i]] = c[i];
			rest[v[i]] = d[i];
			if(d[i] > 0) f = true;
		}else if(rest[v[i]] < d[i]){
			f = true;
		}
		if(!f) continue;
		queue<P> q;
		q.push(P(d[i], v[i]));
		while(!q.empty()){
			P p = q.front();
			q.pop();
//			cout << p.first << " " << p.second << "\n";
			for(int j=0; j<g[p.second].size(); ++j){
				if(ans[g[p.second][j].to] == 0){
					ans[g[p.second][j].to] = c[i];
				}else if(rest[g[p.second][j].to] >= p.first-1){
					continue;
				}
				rest[g[p.second][j].to] = p.first-1;
				if(p.first-1 > 0) q.push(P(p.first-1, g[p.second][j].to));
			}
		}
	}
	for(int i=1; i<=n; ++i)
		cout << ans[i] << "\n";
/*	for(int i=1; i<=n; ++i){
		cout << "from " << i << "\n";
		for(int j=0; j<g[i].size(); ++j)
			cout << g[i][j].to << (j+1 == g[i].size() ? "\n" : " ");
	}
*/
}

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

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

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

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

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

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

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

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

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

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

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize,
        a: [i64; n],
    }
    let s: i64 = a.iter().sum();
    let nn = n as i64;
    puts!("{}\n", s - nn * (nn + 1) / 2);
}

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



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


int bubbleSort(int A[],int N){
	int sw=0;
	bool flag=1;
	for(int i=0;flag;i++){
		flag=0;
		for(int j=N-1;j>=i+1;j--){
			if(A[j]<A[j-1]){
				
				swap(A[j],A[j-1]);
				flag=1;
				sw++;
			}
		}
	}
return sw;
}
int main(){
	int A[100],N,sw;
	cin>>N;
	for(int i=0;i<N;i++)cin>>A[i];
	sw=bubbleSort(A,N);
	for(int i=0;i<N;i++){
		if(i) cout << " ";
		cout << A[i];
	}
	cout << endl;
	cout << sw << endl;
	
	return 0;
}

Measured memory_bytes: 3032
#include "bits/stdc++.h"
#include <random>
#define REP(i, n) for (ll i = 0; i < ll(n); ++i)
#define RREP(i, n) for (ll i = ll(n) - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < ll(n); ++i)
#define RFOR(i, m, n) for (ll i = ll(n) - 1; i >= ll(m); --i)
#define ALL(v) (v).begin(), (v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h, w;
  cin >> h >> w;
  vector<string> v(h);
  REP(i, h)cin >> v[i];
  auto solve = [&](int sx, int sy) {
    vvi dist(h, vi(w, INF));
    dist[sx][sy] = 0;
    queue<pii> q;
    q.push({ sx,sy });
    while (!q.empty()) {
      auto p = q.front(); q.pop();
      REP(k, 4) {
        int x = p.first + dx[2 * k], y = p.second + dy[2 * k];
        if (x < 0 || x >= h || y < 0 || y >= w || v[x][y] == '#')continue;
        if (chmin(dist[x][y], dist[p.first][p.second] + 1)) {
          q.push({ x,y });
        }
      }
    }
    int ans = 0;
    REP(i, h)REP(j, w)if (dist[i][j] != INF)chmax(ans, dist[i][j]);
    return ans;
  };
  int ans = 0;
  REP(i, h)REP(j, w)if(v[i][j]=='.')chmax(ans, solve(i, j));
  cout << ans << endl;
}


Measured memory_bytes: 256
n, t = map(int, input().split())
costs=[]
time = []
for i in range(n):
    new_cost, new_time = map(int, input().split())
    if new_time<=t:
        costs.append(new_cost)
        time.append(new_time)
    else:
        continue
if costs ==[]:
    print('TLE')
else:
    print(min(costs))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ff        first
#define ss        second
#define ll        long long
#define int       long long
#define inf       ((ll)1e18)
#define mod       1000000007
#define double    long double
#define ull       unsigned long long
#define vi        vector<ll>
#define ppi       pair<int,int>
#define pii       pair<pair<int,int>,int>
#define pb        push_back
#define pi        2*acos(0.0)
#define rev       greater<int>()
#define pr(a,x,y) for(int i=x;i<y;i++){cout<<a[i]<<" ";}
#define ps(s)     for(auto i:s){cout<<i<<" ";}
#define sp(x,y)   fixed<<setprecision(y)<<x
#define w(x)      ll x; cin>>x; while(x--)
#define all(v)    v.begin(), v.end()
#define rall(v)   v.rbegin(), v.rend()
#define test      cout<<"This is test"<<endl;
#define str       string
#define endl      '\n'
#define e         cout<<'\n';
void kehsihba(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	/*#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif*/
}
void solve(){
	ll n;cin>>n;
	vi v(n);for(auto &x:v){cin>>x;}
	sort(all(v));
	int x=n/2;
	if(v[x-1]==v[x]){cout<<0;}
	else{cout<<v[x]-v[x-1];}
}
int32_t main(){
	kehsihba();
	//init();
	ll t=1;
	//cin>>t;
	for(int k=1;k<=t;k++){
		//cout<<"Case "<<k<<": ";
		solve();
		//e;
	}
}

Measured memory_bytes: 3988
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
			Scanner sc = new Scanner(System.in);
			int a = sc.nextInt();
			int b = sc.nextInt();
			System.out.printf("%d %d\n", a*b, (a+b)*2);
	}

}



Measured memory_bytes: 26344
#include<iostream>
#include<vector>
#include<cmath>

using namespace std;

int main(){
  string S;
  cin >> S;
  int A = 0;
  int a = 0;
  for(int i = S.size() - 1; i >= 0; i--){
    int j = S.size() - 1 - i;
    a += (int)(S[i] -'0');
    A += ((int)(S[i] - '0'))*pow(10,j);
  }
  if(A % a == 0) cout << "Yes";
  else cout << "No";
}


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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }

vector<pair<int, int>> runLengthEncoding(string s) {
    int n = s.size();
    vector<pair<int, int>> res;
    int pre = s[0];
    int cnt = 1;
    for (int i = 1; i < n; i++) {
        if (pre != s[i]) {
            res.pb({pre, cnt});
            pre = s[i];
            cnt = 1;
        }
        else cnt++;
    }
    res.pb({pre, cnt});
    return res;
}

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

    string s;
    cin >> s;
    vector<P> ns = runLengthEncoding(s);
    int cnt = 0;
    rep(i, ns.size()) {
        if (ns[i].se >= 2) {
            cout << cnt + 1 << ' ' << cnt + 2 << endl;
            return 0;
        }
        cnt += ns[i].se;
    }
    rep(i, s.size()-2) {
        if (s[i] == s[i+2]) {
            cout << i + 1 << ' ' << i + 3 << endl;
            return 0;
        }
    }
    cout << -1 << ' ' << -1 << endl;
    return 0;
}

Measured memory_bytes: 1608
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

int main()
{
	int n;
	long long int h;
	cin >> n >> h;
	vector<long long int> v;
	int maxa_i = 0;
	long long int maxa = 0;
	long long int b_of_maxa = 0;
	for(int i = 0; i < n; i++){
		long long int a, b;
		cin >> a >> b;
		v.push_back(b);
		if(a > maxa){
			maxa = a;
			maxa_i = i;
			b_of_maxa = b;
		} else if(a == maxa && b < b_of_maxa){
			maxa_i = i;
			b_of_maxa = b;
		}
	}
	v.erase(v.begin() + maxa_i);
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	long long int ans = 0;
	for(int i = 0; i < v.size(); i++){
		if(h <= 0 || v[i] < maxa) break;
		if(h <= b_of_maxa){
			h -= b_of_maxa;
			ans++;
			break;
		}
		h -= v[i];
		ans++;
	}
	// cout << h << endl;
	if(h > 0){
		h -= b_of_maxa;
		ans++;
		if(h > 0){
			ans += (h - 1) / maxa + 1;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1400
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define endl "\n"
#define all(c) (c).begin(),(c).end()

signed main() {
	// freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
	/* stuff you should look for
	 * int overflow, array bounds
	 * special cases (n=1?)
	 * do smth instead of nothing and stay organized
	 * WRITE STUFF DOWN
	 * also remember to clear global variables on multitest problems
	 * also remember to switch INT_MAX -> LLONG_MAX after fixing overflow bugs
	 * don't get used to greedy, DP might actually be the solution
	 */
	std::ios::sync_with_stdio(false);
	cin.tie(0);

	int n;
	cin >> n;
	vector<int> freq(n);
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		freq[--x]++;
	}
	priority_queue<int> pq;
	for (int i = 0; i < n; i++)
		pq.push(freq[i]);

	int s = n;
	for (int k = 1, i = 0; k <= n; k++) {
		while (!pq.empty() and pq.top() > s/(k-i)) {
			s -= pq.top();
			i++;
			pq.pop();
		}
		cout << s/(k-i) << endl;
	}
	
	// you should actually read the stuff at the top
}


Measured memory_bytes: 6468
// "header" {{{
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <tuple>

using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int> 
#define int long long
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1e9+7;

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; }

inline double sqrt( const double &x) 
{
	double         xHalf = 0.5 * x;
	int64_t  tmp   = 0x5FE6EB50C7B537AAl - ( *(int64_t*)&x >> 1);
	double         xRes  = * (double*)&tmp;

	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	return xRes * x;
}
// }}}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	int k;
	cin >> s >> k;
	rep(i,s.size()){
		if(k > 1 && s[i] == '1') --k;
		else{
			cout << s[i] << '\n';
			return 0;
		}
	}
	return 0;	
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
#define llMAX 9223372036854775807
#define llMIN -9223372036854775808
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  ll ans=0;
  string s;cin>>s;
  if (s[1]=='B'){
    s[1]='R';
  }else{
    s[1]='B';
  }
  
  cout<<s<<endl;
  return 0;
}

Measured memory_bytes: 3592
from itertools import combinations
import sys
N=int(input())
flag=True
for k in range(1000):
    s=(k*(k+1))//2
    if s==N:
        flag=False
        break
if flag:
    print('No')
    sys.exit()
table=[[k] for i in range(k+1)]
s=1
for elem in combinations(range(k+1),2):
    table[elem[0]].append(s)
    table[elem[1]].append(s)
    s+=1
print('Yes')
print(k+1)
for i in range(k+1):
    print(' '.join(map(str,table[i])))



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

#define rep(i, a, b) for(ll i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define hash dhsjakhd
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;


unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
std::mt19937 eng(seed);

uniform_int_distribution<> DD(0, (1ll << 31));

ll random2(){
    return (ll(DD(eng))*(1ll << 31) + ll(DD(eng))) & ((1ll << 62ll)-1);
}

ll n,m,T,k,q;

const ll big = 1000000007;
const ll big2 = 1000000009;
const ll mod =  998244353;

const ll MAXN = 1000001;

ll FS[MAXN] = {0};
ll DP[MAXN] = {0};
ll FAC[MAXN] = {0};

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

    //freopen("input.txt","r",stdin);
   // freopen("autput.txt","w",stdout);

    ll a,b,c,d;
    ll h;
    ll t = 1;
    ll prev = -1;
    rep(c1,0,MAXN){
        FS[c1] = (prev+t)%big;
        FAC[c1] = t%big;
        prev = FS[c1];
        t *= (ll(c1+1));
        t %= big;
    }


    cin >> n >> h >> d;
    DP[h] = 1;
    ll sum = DP[h];
    ll r = h;
    for(int c1 = h-1; c1 >= 0; c1--){
        DP[c1] = (sum)%big;
       /* if(c1 == 0){
            DP[c1] = (FAC[n] * sum)%big;
        }*/
        //if(c1 < h-1)DP[c1] *= FS[n];
        DP[c1] %= big;
        sum += (DP[c1]*FS[n])%big;
        if(r-c1+1 > d){
            a = (DP[r]*FS[n])%big;
            if(r == h)a = DP[r];
            sum += big*2-a;
            sum %= big;
            r--;
        }
    }

    cout << (FAC[n]*DP[0])%big << "\n";

    return 0;
}


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

int main(){
    int n, m, a;
    cin >> n >> m;
    for(int i=0;i<m;i++){
        cin >> a;
        n -= a;
    }
    if(n>=0){
        cout << n << endl;
    }
    else{
        cout << -1 << endl;
    }

}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int x,a,b;
void solve()
{
    if (b-a<=0) cout<<"delicious";
    else if (b-a<=x) cout<<"safe";
    else cout<<"dangerous";
    cout<<endl;
}
int main()
{
    while(cin>>x>>a>>b)
        solve();
}

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

// ----------- define --------------
#define int long long
#define vi vector<int>
#define vc vector<char>
#define ii pair<int,int>
#define fi first
#define sc second
#define all(x) (x).begin(),(x).end()
#define get_bit(x, k) ((x >> k) & 1)
// ---------------------------------

void MAIN() {
  int n; cin >> n;
  vector<int> a(n + 1);
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    ans += max(0ll, a[i] - a[i - 1]);
  }
  cout << ans << '\n';
}

signed main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3660
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int A[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int K; cin >> K;
    cout << A[K - 1] << endl;

    return 0;
}


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

#define int long long

signed main(){
	int money = 100;
	int ans = 0;
	int x; cin >> x;
	while(money < x){
		money *= 1.01;
		ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string S[3];
  for (int i = 0; i < 3; i++)
    cin >> S[i];
  queue<int> Q[3];
  for (int i = 0; i < 3; i++)
  {
    for (int j = 0; j < S[i].size(); j++)
    {
      if (S[i][j] == 'a')
        Q[i].push(0);
      else if (S[i][j] == 'b')
        Q[i].push(1);
      else
        Q[i].push(2);
    }
  }
  int i = 0;
  while (Q[i].size())
  {
    int t = Q[i].front();
    Q[i].pop();
    i = t;
  }
  if (i == 0)
    cout << "A" << endl;
  else if (i == 1)
    cout << "B" << endl;
  else
    cout << "C" << endl;
  return 0;
}


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

using namespace std;

vector<long long>vp;


long long dp[3010][3010];
bool visit[3010][3010];
long long dpp(int i,int j)
{

    if(i>j)
    return 0;


    if(visit[i][j])
    return dp[i][j];
    visit[i][j]=1;


    long long ans=vp[i]-dpp(i+1,j);
    ans=max(ans,vp[j]-dpp(i,j-1));

    return dp[i][j]=ans;

}

int  main()
{

  int n;
  cin>>n;
  for(int i=1;i<=n;i++)
  {
     long long x;
     cin>>x;
     vp.push_back(x);
  }
  cout <<dpp(0,n-1);


}


Measured memory_bytes: 78592
i, o, t, j, l, s, z = map(int, input().split())
ans = o + (i // 2) * 2 + (j // 2) * 2 + (l // 2) * 2
if l * i * j != 0:
    l -= 1
    i -= 1
    j -= 1
    ans2 = o + (i // 2) * 2 + (j // 2) * 2 + (l // 2) * 2 + 3
    ans = max(ans, ans2)
print(ans)

Measured memory_bytes: 9132
#include <iostream>
using namespace std;
int main(void){

 int a, b, c, temp;
  cin >> a >> b >> c;
 
  if(a > b){ 
    temp = a;
    a = b;
    b = temp;
  }
  if(a > c){
    temp = c;
    c = a;
    a = temp;
  }
  if(b > c){
    temp = b;
    b = c;
    c = temp;
  }
 
  cout << a << " " << b <<  " " << c << endl;
   
 
  return 0;
}


Measured memory_bytes: 3068
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define mu vector<vector<int> >
using namespace std;
int n,m,a,b,c,t;
mu kei(mu A,mu B){
  mu C(n,vector<int>(n));
  r(i,n)r(j,n)r(k,n){
    C[i][j]+=A[i][k]*B[k][j];
    C[i][j]=C[i][j]%m;
  }
  return C;
}
mu M(mu s,int x){
  mu p(n,vector<int>(n));
  r(i,n)p[i][i]=1;
  while(x>0){
    if(x&1)p=kei(p,s);
    s=kei(s,s);
    x>>=1;
  }
  return p;
}
int main(){
  while(cin>>n>>m>>a>>b>>c>>t,n){
    int s1[n],ans[n]={};
    mu s2(n,vector<int>(n));
    r(i,n)cin>>s1[i];
    r(i,n)r(j,n){
      if(j==i-1)s2[i][j]=a;
      if(j==i)s2[i][j]=b;
      if(j==i+1)s2[i][j]=c;
    }
    mu p=M(s2,t);
    r(i,n){
      int sum=0;
      r(j,n)sum+=p[i][j]*s1[j];
      ans[i]=sum;
    }
    r(i,n){
      if(i)cout<<' ';
      cout<<ans[i]%m;
    }
    cout<<endl;
  }
}

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

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int i=0; i<n; i++)
#define FOR1(i, n) for(int i=1; i<=n; i++)
#define FORI(i, n) for(int i=n-1; i>=0; i--)
template<class T, class U> void umin(T& x, const U& y){ x = min(x, (T)y);}
template<class T, class U> void umax(T& x, const U& y){ x = max(x, (T)y);}
template<class T, class U> void init(vector<T> &v, U x, size_t n) { v=vector<T>(n, (T)x); }
template<class T, class U, typename... W> void init(vector<T> &v, U x, size_t n, W... m) { v=vector<T>(n);  for(auto& a : v) init(a, x, m...); }

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);

    string s;
    cin >> s;
    int sum = 0;
    for(char c : s) sum += c-'0';
    if (sum%9 == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    if (argc == 2 && atoi(argv[1]) == 123456789) cout << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}



Measured memory_bytes: 3748
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, S, E) for (int(X) = (S); (X) < (E); ++(X))
#define rrep(X, S, E) for (int(X) = (E)-1; (X) >= (S); --(X))
#define itrep(X, Y) for (auto(X) = (Y).begin(); (X) != (Y).end(); (X)++)
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll INF = 9 * 1e18;
const ll MOD = 1e9 + 7;

const string YES = "Yes";
const string NO = "No";

void solve(long long N, long long M, long long K) {
  rep(i, 0, N + 1) {
    rep(j, 0, M + 1) {
      if (N * M - i * j - (M - j) * (N - i) == K) {
        print("Yes");
        return;
      }
    }
  }
  print("No");
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  long long K;
  scanf("%lld", &K);
  solve(N, M, K);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
 ll n; 
 cin>>n;
 ll mod=1e9+7;
 vector<int>v;
 vector<int>w(n,0);

 REP(i,n) {
     int x;
     cin>>x;
     v.push_back(x);
 } 
 REP(i,n){
     w[v[i]]++;
 }
 //cout<<w[0]<<endl;
 if(n%2==1){
     if(w[0]>=2) {
         cout<<0<<endl;
       return 0;
     }
 }
 ll sum=1;
 REP(i,n){
     if(w[i]>=3){
         cout<<0<<endl;
         return 0;
     }
     if(w[i]!=0) {
         sum*=w[i]%mod;
         sum%=mod;
 }
 }
    cout<<sum<<endl;

    return 0;
}

Measured memory_bytes: 1276
N,M=map(int,input().split())
a=[0]*N
b=[0]*N
c=[0]*M
d=[0]*M
for i in range(N):
  a[i],b[i] = map(int,input().split())
for j in range(M):
  c[j],d[j] = map(int,input().split())

e=[0]*N
for k in range(N):
  dist=float("inf")
  pos=0
  for l in range(M):
    tmp = abs(c[l]-a[k])+abs(d[l]-b[k])
    if dist>tmp:
      dist=tmp
      pos=l
  e[k]=pos+1
  
for ans in e:
  print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstring>

#define max(x,y) (x)>(y) ? (x) : (y)

using namespace std;

int main()
{
	int cj,co,ci,level=0;
	char input[1000001];
	cin>>input;
	for (int i=0; i<strlen(input); i++) {
		if (input[i]=='J') {
			cj=1,i++;
			while (input[i]=='J') cj++,i++;
			if (input[i]!='O') {
				i--;
				continue;
			} else {
				co=1,i++;
				while (input[i]=='O') co++,i++;
			}
			if (input[i]!='I') {
				i--;
				continue;
			} else {
				ci=1,i++;
				while (input[i]=='I') ci++,i++;
			}
			if (cj>=co&&co<=ci) level=max(level,co);
			i--;
		}
	}
	cout<<level<<endl;
}

Measured memory_bytes: 2116
N=int(input())
ans=set()
def saiki(A):
    if len(A)>0:
        B="".join(A)
        count=set(A)
        #print(count)
        if eval(B)<=N:
            if len(count)==3:
                ans.add(B)
        else:
            return
    for i in [3,5,7]:
        A.append(str(i))
        saiki(A)
        A.pop()
saiki([])
print(len(ans))

Measured memory_bytes: 6984
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(int i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
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; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, a, b;
    cin >> n >> a >> b;
    vector<ll> h(n);
    rep (i, n) cin >> h[i];
    sort(all(h), greater<ll>());
    ll ok = 0, ng = h[0] / b + 2;
    while (ng - ok > 1) {
        ll med = (ng + ok) / 2, tmp = 0;
        rep (i, n) {
            if (h[i] > med * b) tmp += ((h[i] - med * b) - 1) / (a - b) + 1;
        }
        if (tmp <= med) ng = med;
        else ok = med;
    }
    cout << ng << "\n";
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};
 
// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ---------------------------------------------------------------------------

int main(){
  ll N,A,B;
  cin >> N >> A >> B;
  ll cnt = N/(A+B);
  N -= cnt * (A+B);
  cout << cnt*A + min(N,A) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <numeric>

using namespace std;
long long l[87];

int main(){
   int n;
   cin>>n;
   l[0]=2;
   l[1]=1;
   for(int i=2;i<=n;i++){
      l[i]=l[i-1]+l[i-2];
   }
   cout<<l[n]<<endl;

}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        ArrayList<dish> li = new ArrayList<>();
        for(int i = 0; i < 5; i++){
            dish d = new dish(sc.nextInt());
            li.add(d);
        }
        li.sort((a,b) -> a.rem-b.rem);
        int ans = 0;
        for(int i = 0; i < 5; i++){
            ans += li.get(i).time;
            if(i != 4){
                ans += li.get(i).rem;
            }
        }
        System.out.println(ans);
    }
}

class dish{
    int time;
    int rem;
    public dish(int t){
        this.time = t;
        this.rem = (10-(t%10))%10;
    }
}

Measured memory_bytes: 29520
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
#define REP(i, x, y) for(ll i = x; i < y; i++)
#define PER(i, x, y) for(ll i = x; i > y; i--)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

int main() {
    ll N, M;
    cin >> N >> M;
    ll A[N];
    REP(i, 0, N) {
        cin >> A[i];
        A[i] %= M;
    }
    REP(i, 0, N - 1) {
        A[i + 1] = (A[i + 1] + A[i]) % M;
    }
    sort(A, A + N);
    ll ans = 0;
    ll tmp = -1;
    ll num = 0;
    REP(i, 0, N) {
        if (tmp != A[i]) {
            if (tmp == 0) {
                ans += num * (num - 1) / 2 + num;
            } else {
                ans += num * (num - 1) / 2;
            }
            tmp = A[i];
            num = 1;
        } else {
            num++;
        }
    }
    if (tmp == 0) {
        ans += num * (num - 1) / 2 + num;
    } else {
        ans += num * (num - 1) / 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <algorithm>
#include <functional>
#include <utility>
#define typeof(x) __typeof__(x)
#define int long long int
#define mod(x) ((x % MOD) + MOD) % MOD
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);--i)

#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SZ(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin())
#define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin())
#define COUNT(c,x) UB(c,x)-LB(c,x)
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define PB push_back
#define MP make_pair
#define vec vector

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

using namespace std;

typedef pair<int,int> P;
struct edge {
  int to, cost;
};

const int INF = 1e18;
const int MOD = 1e9+7;

template<typename T> ostream& operator << (ostream& s, const vector<T>& v) {
  int len = v.size();
  s << "[";
  for (int i = 0; i < len; i++) {
    s << v[i]; if (i < len - 1) s << " ";
  }
  s << "]";
  return s;
}


signed main()
{
  int N; cin >> N;
  vec<int> A(N);
  rep(i, 0, N) {
    cin >> A[i];
  }

  UNIQUE(A);

  if ((N - SZ(A)) % 2 == 1) {
    cout << SZ(A) - 1 << endl;
  } else {
    cout << SZ(A) << endl;
  }

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;


int main(void)
{
    int N,K;
    vector<ll> v;
    cin >> N >> K;
    v.assign(N,0);
    REP(i, N){
        cin >> v[i];
    }

    ll ans = 0;
    for (int i = 0; i <= N; i++) {
        for (int j = 0; j <= N; j++) {
            if(i+j>K || i+j>N)break;
            vector<ll> vt;
            REP(a, i)vt.pb(v[a]);
            REP(b, j)vt.pb(v[N-b-1]);
            for (int k = 0; k <= K-(i+j); k++) {
                SORT(vt);
                ll tmp_ans = 0;
                for (int t = k; t < i+j; t++) {
                    tmp_ans += vt[t];
                }
                ans = max(ans, tmp_ans);
            }
        }
    }
    pr(ans);
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>

using namespace std;


int main()
{
  int n, m;
  cin >> n >> m;
  vector<bool> broken(n+1);

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

vector<int> dp(n+2);
const int mod = 1000000007;
dp[n] = 1;
for(int i = n-1; i >= 0; i--)
{
  if(broken[i])
  {
    dp[i] = 0;
    continue;
  }
  dp[i] = (dp[i+1] + dp[i+2]) % mod;
}

cout << dp[0] << endl;

  return 0;
}


Measured memory_bytes: 640
from math import floor
N=int(input())
l=[0]*41
ans=""
for i in range(40,-1,-1):
    #print(i,pow(-2,i),N,N/abs(pow(-2,i)))
    n=abs(N/abs(pow(2,i)))
    if n>=1:
        if N/abs(pow(-2,i))<0:#Nは0未満
            N=N+abs(pow(-2,i))
            if i%2==0:
                l[i]=-1
            else:
                l[i]=1
        else:
            N = N - abs(pow(-2, i))
            if i%2==0:
                l[i]=1
            else:
                l[i]=-1
#print(l)
for i in range(40):
    if l[i]==-1:
        l[i]=1
        l[i+1]=l[i+1]+1
    elif l[i]==2:
        l[i]=0
        l[i+1]=l[i+1]-1
    elif l[i]==-2:
        l[i]=0
        l[i+1]=l[i+1]+1
flag=0
#print(l)
for i in range(40,-1,-1):
    if l[i]==1:
        flag=1
        ans="".join((ans,str(l[i])))
    elif flag==1:
        ans = "".join((ans,str(l[i])))
if len(ans)==0:
    ans="0"
print(ans)

Measured memory_bytes: 38384