akhauriyash/Code-Regression huggingface dataset:
import java.util.*; 
import java.io.*; 
import java.lang.Math; 
public class Main
{
     public static void main(String []args)
     {
        Scanner in=new Scanner(System.in);
        int d,t,s;
        d=in.nextInt();
        t=in.nextInt();
        s=in.nextInt();
        if(t*s>=d)
        {
          System.out.println("Yes");
        }
        else
        {
          System.out.println("No");
        }
     }
}



Measured memory_bytes: 35632
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define vvvel vector<vvel>
void mmin(int &a, int b) { a = min(a, b); }
void mmax(int &a, int b) { a = max(a, b); }
void sor(vel &v) { sort(v.begin(), v.end()); }
void m1(int &a) { a = a % 10000; }
int sign(int n) {
	if (n == 0)return n;
	return n / abs(n);
}
int zero() { return 0; }
int zi(vel a, int mo, vel rui) {
	int ke = a.size();
	int ans = 9 / mo;
	if (ke == 0)return 0;
	if (ke == 1)return a[0]/mo;
	vvvel ze(2,vvel(10, vel(mo, 0)));
	vvvel dp0 = ze;
	vvvel dp1 = ze;
	for (int i = 0; i < 10; i++) {
		dp0[0][i][i%mo]++;
		if (i <= a[0])dp1[0][i][i%mo]++;
	}
	dp0[1] = dp0[0];
	dp1[1] = dp1[0];
	int di;
	di = 1;
	for (int k1 = 1; k1 < ke; k1++) {
		int r1 = rui[k1];
		vvvel odp0 = dp0;
		vvvel odp1 = dp1;
		dp0 = ze; dp1 = ze;
		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < mo; j++) {
				for (int k = 0; k < 10; k++) {
					int xx = (r1*k) % mo;
					xx = (xx + j) % mo;
					int ty = sign(i-k)*di;
					if (ty != 0) {
						ty = (ty + 1) / 2;
						dp0[ty][k][xx] += odp0[ty][i][j];
						m1(dp0[ty][k][xx]);
						if (k < a[k1]) {
							dp1[ty][k][xx] += odp0[ty][i][j];
							m1(dp0[ty][k][xx]);
						}
						else if (k == a[k1]) {
							dp1[ty][k][xx] += odp1[ty][i][j];
							m1(dp1[ty][k][xx]);
						}
					}
				}
			}
		}
		if (k1 + 1 < ke) {
			for (int i = 1; i < 10; i++) {
				ans += dp0[0][i][0] + dp0[1][i][0];
				m1(ans);
			}
		}
		else {
			for (int i = 1; i < 10; i++) {
				ans += dp1[0][i][0] + dp1[1][i][0];
				m1(ans);
			}
		}
		di *= -1;
	}
	return ans;
}
signed main() {
	string ka;
	string kb;
	cin >> ka >> kb;
	int m; cin >> m;
	int n = ka.size();
	vel a; int fl = 1;
	for (int i = 0; i < n; i++) {
		if ((i != 0 or ka[i] != '1') and (i == 0 or ka[i] == '0')) fl = 0;
	}
	if (fl == 1) { n--; a = vel(n, 9); }
	else {
		a = vel(n);
		for (int i = 0; i < n; i++) a[i] = ka[i] - 48;
		reverse(a.begin(), a.end());
		for (int i = 0; i < n; i++) {
			if (a[i] == 0) { a[i] = 9; }
			else { a[i]--; break; }
		}
	}
	int si = kb.size();
	vel rui(si, 1); int sum = a[0];
	for (int i = 1; i < si; i++) {
		rui[i] = (rui[i - 1] * 10) % m;
	}
	vel b(si);
	for (int i = 0; i < si; i++) { b[i] = kb[si - i - 1] - 48; }
	cout << (zi(b, m, rui) - zi(a, m, rui)+10000)%10000 << endl;
	return 0;
}



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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int main(){
	int w,a,b;
	cin >> w>>a >>b;
	if(b <=a+w && b >=a-w) cout << 0;
	else if(b < a-w) cout << a-w-b;
	else if(b >a+w) cout << b-a-w ;

	return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::str::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($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:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let cin = stdin();
    let cin = cin.lock();
    let s: String = cin
        .bytes() // Bytes
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace()) // c が whitespace である限り skip
        .take_while(|c| !c.is_whitespace()) // c が whitespace でない限り要素を返す
        .collect();
    s.parse().ok().expect("failed parsing")
}

fn main() {
    input! {a:usize,b:usize}
    println! {"{}",(a + b)/2 + (a + b) % 2}
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define IN freopen("dichromatic.in","r",stdin)
#define OUT freopen("dichromatic.out","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2
#define sq(x)  ((x)*(x))

using namespace __gnu_pbds;
using namespace std ;

#define maxn 200005

vector <int> g[maxn] ;
queue<int> q ;
int dis[maxn] ;

pair<int,int> bfs(int src)
{
    memset(dis,-1,sizeof(dis)) ;
    q.push(src) ;
    dis[src] = 0 ;

    pair<int,int> ans = mp(src,0) ;

    while( !q.empty() )
    {
        int u = q.front() ;
     //   printf("--%d\n",u) ;
        q.pop() ;
        for(int i=0 ; i<g[u].size() ; i++ )
        {
            int v = g[u][i] ;
            if( dis[v]==-1 )
            {
                dis[v] = dis[u]+1 ;
                q.push(v) ;
                ans = mp(v,dis[v]) ;
            }
        }
    }
    return ans ;
}

int main()
{
    int n ;

    scanf("%d",&n) ;
    for(int i=1 ; i<n ; i++)
    {
        int u , v ;
        scanf("%d %d",&u,&v) ;
        g[u].pb(v) ; g[v].pb(u) ;
    }

    pair<int,int> ans = bfs(1) ;
 //   printf("%d %d\n",ans.xx,ans.yy) ;
    ans = bfs(ans.xx) ;

    if((ans.yy+1)%3==2) printf("Second\n") ;
    else printf("First\n") ;

    return 0 ;
}


Measured memory_bytes: 13556
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define MOD 1000000007
int main()
{
    int A,B;
    cin>>A>>B;
    if(A>=13) cout<<B;
    else if(A>5) cout<<B/2;
    else cout<<0;
   
    return 0;

    
}

Measured memory_bytes: 256
import javax.xml.crypto.Data;
import java.util.*;
import java.io.*;

public class Main {
    static int C = 1000000007;

    public static void main(String[] args) throws IOException{

        //入力
        /*
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        */
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();


        // 出力
        long ans = (factorial(N) * factorial(M)) % C;

        if(N == M){
            System.out.println((2 * ans) % C);
        }
        else if(M == N + 1 || N == M + 1){
            System.out.println(ans);
        }
        else{
            System.out.println(0);
        }

    }

    static long factiter(int n, long product) {
        if (n == 1) return product;
        return factiter(n - 1, n * product % C);
    }
    static long factorial(int n){
        long product = 1;
        for(int i = 1; i <= n; i++){
            product = product * i % C;
        }
        return product;
    }
}

Measured memory_bytes: 21332
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int h, w; cin >> h >> w;
	vector<string> in(h); rep(i, h) cin >> in[i];
	
	vector<vi> d1(h), d2(h - 1), dp(h - 1, vi(w - 1));
	rep(i, h) rep(j, w - 1) d1[i].pb(in[i][j] != in[i][j + 1]);
	rep(i, h - 1) rep(j, w - 1) d2[i].pb(d1[i][j] != d1[i + 1][j]);
	
	//rep(i, h - 1) dbg(d2[i]);
	
	ll ans = max(h, w);
	rep(i, h - 1){
		vi ls(w - 1), rs(w - 1), q;
		rep(j, w - 1){
			dp[i][j] = d2[i][j] ? 0 : (i ? dp[i - 1][j] : 0) + 1;
			ls[j] = j;
			while(q.size() && dp[i][q.back()] >= dp[i][j]){
				ls[j] = ls[q.back()];
				q.pop_back();
			}
			q.pb(j);
		}
		q.clear();
		for(int j = w - 2; j >= 0; j--){
			rs[j] = j;
			while(q.size() && dp[i][q.back()] >= dp[i][j]){
				rs[j] = rs[q.back()];
				q.pop_back();
			}
			q.pb(j);
			ans = max(ans, (rs[j] - ls[j] + 2ll) * (dp[i][j] + 1ll));
		}
		//dbg(i, ls);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 54400
#include <iostream>

using namespace std;

typedef long long ll;

// ll lucas(ll n){
//     if (n == 0) return 1;
//     if (n == 1) return 2;
//     else return lucas(n - 1) + lucas(n - 2);
// } 

int main(){

    ll n;
    cin >> n;

    n -= 1;

    ll l1 = 1, l2 = 2;

    ll ans = 0;
    if (n == -1){
        cout << 2 << endl;
    }
    else if (n == 0){
        cout << 1 << endl;
    }
    else if (n == 1){
        cout << 3 << endl;
    }
    else if (n == 2){
        cout << 4 << endl;
    }
    else {
        for (ll i = 1; i <= n; i++){
            ans = (l1 + l2);
            l2 = l1;
            l1 = ans;
        } 

        cout << ans << endl;
    }


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(long long i=a; i<b; i+=1)
#define repr(i,a,b) for(long long i=a; i<=b; i+=1)
#define vec vector<ll>
#define pb push_back
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())

using namespace std;
int main() {
  ll N;
  cin>>N;
  vec A(N);
  rep(i,0,N) cin>>A[i];
  sort(A);
  reverse(A);
  bool ans=true;
  rep(i,0,N-1) {
    if(A[i]==A[i+1]) {
      ans=false;
      cout<<"NO"<<endl;
      break;
    }
  }
  if(ans)
    cout<<"YES"<<endl;
  
}
  


Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
swap(int *a, int *b) {
	int temp;
	temp = *a;
	*a = *b;
	*b = temp;
}

int main() {
	int i, a;
	int x_array[3000], y_array[3000];

	for (i = 0; i < 3000; i++) {
		scanf("%d %d", &x_array[i], &y_array[i]);
		if (x_array[i] > y_array[i]) {
			swap(&x_array[i], &y_array[i]);
		}
		else if (x_array[i] == 0 && y_array[i] == 0) {
			break;
		}
		
	}
	for (i = 0; i < 3000; i++) {
		if (x_array[i] == 0 && y_array[i] == 0) {
			break;
		}
		printf("%d %d\n",x_array[i],y_array[i]);
	}
		return 0;
}


Measured memory_bytes: 1932
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<list>

using namespace std;
using ll = long long;

int main(){
    int n;
    cin>>n;
    vector<int> d(n);
    map<int,int> memo;
    for(int i=0;i<n;i++){
        cin>>d[i];
        memo[d[i]]++;
    }
    int m;
    cin>>m;
    vector<int> t(m);
    bool ok=true;
    for(int i=0;i<m;i++){
        cin>>t[i];
        memo[t[i]]--;
        if(memo[t[i]]<0) ok=false;
    }

    if(ok) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

int main(){
	int X,Y;
	cin>>X>>Y;
	int ans;
	if (X>=0 && Y>=0 || X<=0 && Y<=0){
		if (X<=Y){
			ans=Y-X;
		}else{
			ans=X-Y+2;
			if (X==0) ans--;
			if (Y==0) ans--;
		}
	}else{
		if (X<0) X*=-1;
		if (Y<0) Y*=-1;
		ans=abs(X-Y)+1;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<list>
#include<map>
#include<vector>

using namespace std;


#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long

#define IMIN INT_MIN;
#define IMAX INT_MAX;


int main(){
    int N, W;
    cin >> N >> W;
    vector<ll> w(N), v(N);
    rep(i, N) cin >> w[i] >> v[i];
    // dp[i][j]: max total value using weights until the i-1 th one, with max weight of j
    ll dp[N+10][W+10];
    rep(i, N+10) rep(j, W+10) dp[i][j] = -1;
    rep(j, W) dp[0][j] = 0;
    rep(i, N+1) {
        rep(j, W+1) {
            // use or don't use
            dp[i+1][j] = (j >= w[i]) ? max(dp[i][j], dp[i][j-w[i]] + v[i]) : dp[i][j];
        }
    }
    /*
    rep(i, N+1) {
        rep(j, W+1) cout << dp[i][j] << ' ';
        cout << endl;
    }
    */
    cout << dp[N][W] << endl;


	return 0;
}


Measured memory_bytes: 86144
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

const ll INF = LONG_LONG_MAX;

vector<int> as;

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

    as.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> as[i];
        as[i] -= (i + 1);
    }
    sort(as.begin(), as.end());

    int center = as[N / 2];
    ll acc = 0;
    for (auto a : as) {
        acc += abs(a - center);
    }
    cout << acc << endl;

    return 0;
}


Measured memory_bytes: 4012
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void main()
{
    auto a = aryread();
    // a.sort();
    bool b = a[2] == a[0] && a[0] == a[1];
    writeln(b ? "Yes" : "No");
}


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

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

	vector<ll> A(n);
	map<ll, ll> m;
	for(int i=0; i<n; i++){
		cin >> A[i];
		m[i-A[i]]++;
	}

	ll cnt = 0;
	for(int i=0; i<n; i++){
		m[i-A[i]]--;
		if(m.count(i+A[i])){
			cnt += m.at(i+A[i]);
		}
	}

	cout << cnt << endl;
}


Measured memory_bytes: 16336
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 9 * 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}

int main() {
    string S;
    cin >> S;
    bool ret = false;
    for(int i = 0;i < S.size() + 1;i++) {
        for(int j = i;j < S.size() + 1;j++) {
            if(i + S.size() - j == 7) {
                string A = S.substr(0,i);
                string B = S.substr(j,S.size() - j);
                A += B;
                if(A == "keyence") {
                    ret = true;
                }
            }
        }
    }
    if(ret == true) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

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


int Find(vector<string> _S, string s){
  
  int i = 0;
  
  for (i = 0; i < _S.size(); i++){
    
    if(_S.at(i) == s){
      return i;
    }
  }
  return -1;
}

int main(){
  
  vector<string> Si = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  
  string S;
  cin >> S;
  
  int Num;
  
  Num = Find(Si, S);
  
  cout << 7 - Num << endl;
  
  
  return 0;
}

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


using namespace std;
typedef long long LL;
const int maxn = 100005;
int a[maxn], fa[maxn], mi[maxn], id[maxn], vis[maxn];
int n, m;

void Init()
{
    for(int i = 0; i <= n; i++)
    {
        fa[i] = i;
        mi[i] = a[i];
        id[i] = i;
    }
}

int Find(int x)
{
    return fa[x] == x ? x : fa[x] = Find(fa[x]);
}

void Merge(int x, int y)
{
    int fx = Find(x), fy = Find(y);
    fa[fx] = fy;
    if(mi[fy] > mi[fx])
    {
        mi[fy] = mi[fx];
        id[fy] = id[fx];
    }
}

int main()
{
    scanf("%d%d", &n, &m);
    multiset<int> s;
    for(int i = 1; i <= n; i++)
    {
        scanf("%d", &a[i]);
        s.insert(a[i]);
    }
    Init();
//    multiset<int>::iterator it;
//    for(it = s.begin(); it != s.end(); it++)
//    {
//        printf("%d ", *it);
//    }
//    printf("\n");
    for(int i = 1; i <= m; i++)
    {
        int u, v;
        scanf("%d%d", &u, &v);
        Merge(u + 1, v + 1);
    }
    int num = 0;
    LL ans = 0;
    for(int i = 1; i <= n; i++)
    {
//        printf("%d %d %d\n", i, Find(i), mi[fa[i]]);
        if(Find(i) == i)
        {
            num++;
            ans += mi[fa[i]];
            multiset<int>::iterator it = s.find(mi[fa[i]]);
            s.erase(it);
        }
    }
    if(n < 2 * num - 2)
        printf("Impossible\n");
    else if(num == 1)
        printf("0\n");
    else
    {
        int cnt = 0;
        multiset<int>::iterator it;
        for(it = s.begin(); it != s.end() && cnt < num - 2; it++)
        {
            cnt++;
            ans += *it;
        }
        printf("%lld\n", ans);
    }
    return 0;
}


Measured memory_bytes: 6528
a, b = (int(i) for i in input().split())
ans = 0
for i in range(a,b+1):
    s = str(i)
    pv = len(s)//2
    rs = s[::-1]
    if not(len(s)%2==0) and s[:pv]==rs[:pv]:
        ans += 1
    elif len(s)%2==0 and s[:pv]==rs[:pv]:
        ans += 1
print(ans)


Measured memory_bytes: 41964
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int A,B;
    cin>>A>>B;
    int ans=1;
    if(B==1)
    {
        cout<<0<<endl;
        return 0;
    }
    if(A>=B)
    {
        cout<<ans<<endl;
        return 0;
    }

    int c=(B-A);
    double z = (double) c/(A-1);
    double x = ceil(z);
    cout<<(x+ans)<<endl;
}


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

public class Main {
    public static void main(String args[]) throws IOException {

	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String array[] = br.readLine().split(" ");
	int A = Integer.parseInt(array[0]);
	int B = Integer.parseInt(array[1]);
	System.out.println(A * B);

	
    }
}

Measured memory_bytes: 32648
#include<iostream>
#include<climits>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;
int main(){

	int n,x;
	cin >> n >> x;
	vector< int > a(n);

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

	sort(a.begin(), a.end());
	
	int ans = 0;
	
	for(int i = 0; i < n-1; i++)
	{
		x -= a[i];
		if(x >= 0){
			ans ++;
		}else{
			break;
		}
	}
	if (a[n-1] == x){
		ans++;
	}
	cout << ans << endl;
	

		
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
//i64 mod = 1000000007;
i64 mod = 998244353;
int int_max = 2147483647;
i64 INF = 1e16;
int max_n = 1e5;


int main(int argc, char **argv) {
    int x, n;
    cin >> x >> n;
    unordered_set<int> ps;
    for (int i=0; i<n; ++i) {
        int p;
        cin >> p;
        ps.insert(p);
    }

    int min_diff = 1000;
    int ans{0};
    for (int i=-100; i<200; ++i) {
        if (ps.find(i) != ps.end()) continue;
        if (min_diff > abs(x-i)) {
            min_diff = abs(x-i);
            ans = i;
        }
    }

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


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

using namespace std;
int v[100010];
int memo[100010];
int c;

int f(int i)
{

    if(memo[i]!=-1)
        return memo[i];

    if(i == 0)
        return memo[0] = 0;

    if(i == 1)
        return memo[1] = abs(v[0] - v[1]);

    return memo[i] = min(abs(v[i] - v[i-1]) + f(i-1), abs(v[i] - v[i-2]) + f(i-2));
}

int main()
{
    ios_base::sync_with_stdio(false);
    memset(memo, -1, sizeof(memo));
    cin>>c;

    for(int i = 0; i<c; i++)
    {
        cin>>v[i];
    }

    cout<<f(c-1)<<endl;

    return 0;
}

Measured memory_bytes: 2560
#include <iostream>

using namespace std;

int L[100'000], R[100'000];
int main()
{
    int n, m;

    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        cin >> L[i] >> R[i];
        L[i]--;
        R[i]--;
    }

    int min = 0;
    int max = n;
    for (int i = 0; i < m; i++)
    {
        if (R[i] < min || max < L[i])
        {
            cout << "0" << endl;
            return 0;
        }

        min = (L[i] > min) ? L[i] : min;
        max = (R[i] < max) ? R[i] : max;
    }

    cout << (max - min + 1) << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<algorithm>
#include<math.h>
#include<iostream>
#include<stdio.h>
#include<string.h>
typedef long long ll;
using namespace std;
char a[100005];
int main()
{
    ll i,j,n,flag=1,ans=0;
    scanf("%lld",&n);
    getchar();
    for(i=1;i<=n;i++)
    {
        scanf("%c",&a[i]);
    }
    if(n%2==1)
    {
        printf("No\n");
    }
    else
    {
        for(i=1;i<=n/2;i++)
          {
            if(a[i]!=a[n/2+i])
                flag=0;
          }
          if(flag==1)
          {
              printf("Yes\n");
          }
          else
          {
            printf("No\n");
          }
    }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<fstream>
#define ll long long
#define F first
#define S second
#define mp make_pair
#define mod 1000000007
#define All(v) v.begin(),v.end()

using namespace std;

string s[51];
vector<int> v[10];
int n;
bool vis[10];

int backtracking(int node,int cnt)
{
    if(cnt == n)
            return 1;

    ll res = 0;

    for(auto i:v[node])
    {
        if(!vis[i])
        {
            vis[i] = 1;
            res += backtracking(i,cnt+1);
            vis[i] = 0;
        }
    }
    return res;
}

int main()
{
    int m;
    cin >> n >> m;
    for(int i=0; i<m; i++)
    {
        int x,y;
        cin >> x >> y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
     vis[1] = 1;
    cout << backtracking(1,1) << endl;









    return 0;
}



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

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    int dif = max({A, B, C}) * 3 - (A + B + C);
    if (dif % 2) dif += 4;
    cout << dif / 2 << endl;
}

Measured memory_bytes: 256
#include <cstdio>
int main(){
  int w,a,b;
  scanf("%d%d%d",&w,&a,&b);
  if(a<b)printf("%d\n",a+w<b?b-a-w:0);
  else printf("%d\n",b+w<a?a-b-w:0);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(ll (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrrep(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k,q;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
set<P> st; 

//------ Believe yourself as a genius!!!!!! ------
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>n;
    rrep(i,1,n){
        tmp=i;tmpp=n-i;
        if(tmp==tmpp)continue;
        if(tmpp>=tmp)swap(tmp,tmpp);
        st.insert({tmp,tmpp});
    }
    Cout(Size(st));
    return 0;
}

Measured memory_bytes: 31488
import sys
readline = sys.stdin.readline


def solve(writer):
    N, A, B, C = map(int, input().split())

    variables = {
        'A': A,
        'B': B,
        'C': C
    }

    queries = (list(readline().strip()) for _ in range(N))

    next_q = next(queries)

    for i in range(N):

        let_1, let_2 = next_q
        next_q = next(queries) if i < N - 1 else ()

        if variables[let_1] == variables[let_2] == 0:
            return False

        if variables[let_1] == variables[let_2] == 1 and let_2 in next_q \
                or variables[let_1] > variables[let_2]:
            let_1, let_2 = let_2, let_1

        variables[let_1] += 1
        variables[let_2] -= 1

        writer.append(let_1)

    return True


def main():
    
    writer = list()
    ok = solve(writer)
    
    if ok:
        print('Yes')
        for w in writer:
            print(w)
    else:
        print('No')


if __name__ == "__main__":
    main()


Measured memory_bytes: 9712
#include<bits/stdc++.h>//author::@whohet-->Het Patel
#define fasterthanlight ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define int long long
#define uint unsigned long long
#define ld long double
#define pii pair<int,int>
#define vi vector<int>
#define vs vector<string>
#define vvi vector<vector<int>>
#define mii map<int,int>
#define msi map<string,int>
#define mis map<int,string>
#define pb push_back
#define mod 1000000007
#define PI 3.141592653589793238

using namespace std;

//author::@whohet-->Het Patel

signed main()
{
	fasterthanlight;
	string s;int flag1=0,flag2=0;
	
	
		cin>>s;
		if(s[2]==s[3])
			flag1=1;
		
	
			if(s[5]==s[4])
			flag2=1;
		
	
	if(flag1 && flag2)
cout<<"Yes\n";
else
cout<<"No\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main() {
    int a, z, c = 0;
    string s;
    cin >> s;
    int S = s.size();
    for (int i = 0; i < S; i++) {
        if (s[i] == 'A' && c == 0) {
            a = i;
            c++;
        }
        if (s[i] == 'Z') {
                z = i;
        }
    }
    int A = a+1, Z = z+1;
    cout << Z - A + 1 << endl;
    return 0;
}

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

using namespace std;

int main()
{
	string N;
	cin >> N;
	
	int count = 0;
	for (int i = 0; i < N.length(); i++) {
		if (N[i] == '2') {
			count++;
		}
	}

	cout << count << endl;

}





Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
using PP = pair<long, long>;
const int INF = 1e9;
template <class T> T Next() { T buf; cin >> buf; return buf; }
 
int n;
PP p[4000];
int DP[2001][2001];
int s[4001][2001];
int t[4001][2001];
int inv[2][2000];

int main() {
  cin >> n;
  for (int i = 0; i < 2 * n; ++i) {
    int a = Next<char>() == 'B';
    int b = Next<int>() - 1;
    p[i] = PP(a, b);
    inv[a][b] = i;
  }
  
  for (int i = 0; i < 2 * n; ++i) {
    for (int j = 0; j <= n; ++j) {
      bool a = p[i].first == 0 && p[i].second >= j;
      bool b = p[i].first == 1 && p[i].second >= j;
      s[i + 1][j] = s[i][j] + a;
      t[i + 1][j] = t[i][j] + b;
    }
  }
  
  for (int i = 0; i <= n; ++i) {
    for (int j = 0; j <= n; ++j) {
      DP[i][j] = INF;
    }
  }
  DP[0][0] = 0;
  
  for (int i = 0; i <= n; ++i) {
    for (int j = 0; j <= n; ++j) {
      if (i < n) {
        int k = inv[0][i];
        DP[i + 1][j] = min(DP[i + 1][j], DP[i][j] + s[k][i] + t[k][j]);
      }
      
      if (j < n) {
        int l = inv[1][j];
        DP[i][j + 1] = min(DP[i][j + 1], DP[i][j] + s[l][i] + t[l][j]);
      }
    }
  }
  
  cout << DP[n][n] << endl;
  return 0;
}

Measured memory_bytes: 78592
#include <stdio.h>

int main(void)
{
	int a, b, sum, i;
	
	while (scanf("%d %d", &a, &b) != EOF){
		sum = a + b;
		for (i = 0; sum != 0; i++){
			sum /= 10;
		}
		
		printf("%d\n", i);
		
	}
	
	return (0);
}

Measured memory_bytes: 600
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
ans = 0
b = -1
for a in A:
    if b+1==a:ans+=C[b-1]
    b = a
    ans+=B[b-1]
print(ans)

Measured memory_bytes: 3064
open Batteries
let x = read_int ()

let rec loop a =
  let rec loop2 b =
    if b >= 1000 then (0, 0) else
    if ((a * a * a * a * a) - (b*b*b*b*b)) = x then (a, b) else loop2 (b+1)
  in if a >= 1000 then (0, 0) else (
  let a_, b_ = loop2 (-1000) in
  if a_ = 0 && b_ = 0 then loop (a+1) else (a_, b_)
)
let a, b = loop (-1000)
let _ = Printf.printf "%d %d\n" a b



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

int main(){
	int a, c;
	char b;
	for(int i =0; ;i++){
		cin>>a>>b>>c;
		if(b=='?')
			break;
		else if(b=='+')
			cout<<a+c<<endl;
		else if(b=='/')
			cout<<a/c<<endl;
		else if(b=='-')
			cout<<a-c<<endl;
		else if(b=='*')
			cout<<a*c<<endl;
	}

	return 0;
}


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

int isACGT(int idx) {
    return s[idx] == 'A' || s[idx] == 'C'
        || s[idx] == 'G' || s[idx] == 'T';
}

int req(int idx) {
    if (idx == s.length()) return 0;
    if (!isACGT(idx)) return 0;
    
    return req(idx+1) + 1;
}

int main() {
    cin >> s;

    int cnt = 0;
    for (int i = 0;i < s.length();i++) {
        int tmp = req(i);
        if (cnt < tmp) cnt = tmp;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int32_t main(){
	fastio();
	int n , m ;
	cin >> n >> m;
	n==m ? cout << "Yes" : cout << "No";
}

Measured memory_bytes: 3652
//
// Created by 今村秀明 on 2017/01/20.
//

#include <stdio.h>

int main(){
    int a,b,c,d;
    int s,t;
    scanf("%d %d %d %d", &a, &b, &c, &d);
    s = a * b;
    t = c * d;
    if(s==t){
        printf("%d", s);
    }else if (s > t) {
        printf("%d", s);
    }else{
        printf("%d", t);
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll n, m, v, p;
string s;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> n >> m >> v >> p;
	vector<ll> a;
	rep(i, 0, n){
		ll buf;
		cin >> buf;
		a.push_back(buf);
	}
	sort(a.rbegin(), a.rend());
	
	ll ng = n;
	ll ok = p-1;
	while(ng-ok > 1){
		ll mid = (ng+ok)/2;
		ll b = a[mid]+m;
		if(b < a[p-1]){
			ng = mid;
		}
		else{
			ll badget = v*m - p*m;
			
			rep(i, p-1, n-1){
				badget -= min(b-a[i], m);	
			}
			if(badget <= 0){ok = mid;}
			else{ng = mid;}
		}
	}
	print(ok+1)
	return 0;
}

Measured memory_bytes: 1400
// 2020-09-09 22:00:08
// clang-format off
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

// clang-format on
void answer() {
  string s;
  cin >> s;
  int sz = s.size();
  vector<int> a(sz + 2, 0);
  rep(i, sz) a[i + 1] = s[i] - '0';
  int ans = sz;
  repc(i, sz) if (a[i] ^ a[i + 1]) chmin(ans, max(i, sz - i));
  cout << ans << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 3848
#include <iostream>
#include <set>

using namespace std;

int main()
{
    set<string> si;
    bool open = false;

    int n;
    cin >> n;
    while (n--) {
        string u;
        cin >> u;
        si.insert(u);
    }

    int m;
    cin >> m;
    while (m--) {
        string t;
        cin >> t;
        if (si.find(t) == si.end()) {
            cout << "Unknown " << t << endl;
        } else {
            if (open)
                cout << "Closed by " << t << endl;
            else
                cout << "Opened by " << t << endl;
            open = !open;
        }
    }
    return 0;
}

Measured memory_bytes: 3204
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x) {
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x) {
    int f = 0;
    cerr << '{';
    for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
    __print(t);
    if (sizeof...(v)) cerr << ", ";
    _print(v...);
}
#ifdef LOCAL
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif

#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin >> N;
    vector<pair<ll, ll>> vec(N);  //終点、始点のpair
    REP(i, N) {
        ll X, L;
        cin >> X >> L;
        vec[i].first = X + L;
        vec[i].second = X - L;
    }
    sort(vec.begin(), vec.end());
    debug(vec);
    ll pointer = -1e10;
    ll ans = 0;
    REP(i, N) {
        if (vec[i].second >= pointer) {
            pointer = vec[i].first;
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
a = list(map(int, readline().split()))
b = list(map(int, readline().split()))
monster = sum(a)
for i in range(n):
    if a[i] - b[i] >= 0:
        a[i] -= b[i]
    else:
        a[i+1] = max(a[i+1] - (b[i]-a[i]),0)
        a[i] = 0
print(monster-sum(a))

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

using namespace std;

typedef long long ll;

int main() {
    int n;
    ll c, k;
    cin >> n >> c >> k;
    vector<ll> t(n);
    for (int i = 0; i < n; ++i) {
        cin >> t[i];
    }
    sort(t.begin(), t.end());

    int cnt = 1, cur = t[0], num = 1;
    int i = 1;
    while(i < n){
        if (num == c || t[i] > cur + k){
            ++cnt;
            cur = t[i];
            num = 1;
        }else{
            ++num;
        }

        ++i;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
using namespace std;
 
int main(){
  string S;
  cin >> S;
  
  if (S[0]==S[1] or S[1]==S[2] or S[2]==S[3]) {
    cout << "Bad" << endl;
  } else {
    cout << "Good" << endl;
  }
  return 0;
}

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

int ar[1001][1001];
bool mp[1001][1001];
using namespace std;

int main()
{
    int h,w;
    cin >> h >> w;
    for (int i=0;i<=h;i++)
    for (int j=0;j<=w;j++){
            mp[i][j]=false;
            ar[i][j]=0;
    }

    for (int i=1;i<=h;i++){
        string s;
        cin >> s;
        for (int j=1;j<=w;j++){
            if (s[j-1]=='.')
                mp[i][j]=1;
        }
 //       cout << endl;
    }

    ar[1][1]=1;
    for (int i=1;i<=h;i++){
        for (int j=1;j<=w;j++){
            if (mp[i-1][j] && mp[i][j-1])
                ar[i][j]=(ar[i][j]+(ar[i-1][j]+ar[i][j-1])%1000000007)%1000000007;
            else if (mp[i-1][j])
                ar[i][j]=(ar[i][j]+ar[i-1][j])%1000000007;
            else if (mp[i][j-1])
                ar[i][j]=(ar[i][j]+ar[i][j-1])%1000000007;


   //         cout << ar[i][j] << " ";
        }
     //   cout << endl;
    }

    cout << ar[h][w] << endl;
}



Measured memory_bytes: 5120
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)

# Debug output
def chkprint(*args):
    names = {id(v):k for k,v in inspect.currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

# Binary converter
def to_bin(x):
    return bin(x)[2:]

# --------------------------------------------

dp = None

def main():
    a, b = [int(_) for _ in input().split()]

    if a + b == 15:
        print("+")
    elif a * b == 15:
        print("*")
    else:
        print("x")

main()


Measured memory_bytes: 5436
while True:
    n = input()
    if n==0: break
    s = raw_input()
    ba = 0; p = [0]*n
    for i in range(100):
        if s[i] == 'M':
            p[i%n] += 1
        elif s[i] == 'L':
            p[i%n] += ba+1; ba=0;
        else:
            ba += p[i%n]+1; p[i%n]=0;
    print " ".join(map(str, sorted(p))), str(ba)

Measured memory_bytes: 4224
#include <iostream>
#include <array>
#include <vector>
#include <map>
#include <utility>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <string>

using namespace std;

int main(int argc, const char * argv[]) {
    
    string str;
    cin >>str;
    int k;
    cin >> k;
    
    int len = (int)str.length();
    
    for (int i = 0; i <len; i++) {
        char ch = str[i];
        if (ch == 'a') {
            continue;
        }
        int s ='z' + 1 - ch;
        if (s > k) { //  ch + k < z+1
            continue;
        }else{
            if (k >= s) {
                str[i] = 'a';
                k -= s;
            }else{
                continue;
            }
        }
    }
    while (k) {
        char ch = str[len-1];
        if (ch == 'z') {
            str[len-1] ='a';
        }else{
            str[len-1] = ch + 1;
        }
        k--;
    }
    
    cout<< str <<endl;
    
    return 0;
}


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

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    long count[] = new long[100000 + 1];
    long ans = 0;
    for (int i = 0; i < n; i++) {
      int a = Integer.parseInt(sc.next());
      ans += a;
      count[a]++;
    }
    int q = Integer.parseInt(sc.next());
    for (int i = 0; i < q; i++) {
      int b = Integer.parseInt(sc.next());
      int c = Integer.parseInt(sc.next());
      int diff = c - b;
      ans += count[b] * diff;
      count[c] += count[b];
      count[b] = 0;
      pw.println(ans);
    }
  }
}


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

using namespace std;

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9 + 10;
//const ll INF = 1e18 + 10LL;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
const double EPS = 1e-10;
bool cmp(P a, P b) { return a.second < b.second; } //End sort (Interval scheduling problem)
ll MOD = 1e9 + 7;

//http://drken1215.hatenablog.com/entry/2019/07/07/235600 写経

int n;
vector<ll> a;

int main(void){
	cin>>n;
	a.resize(n);
	for (int i = 0; i < n; i++) cin>>a[i], a[i] *= 2;

	ll offset = 0;
	for (int i = 0; i < n; i++) offset = a[i] - offset;
	ll x = offset / 2;

	ll cur = x;
	for (int i = 0; i < n; i++) {
		cout << cur << " ";
		cur = a[i] - cur;
	}cout<<endl;
	
	return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
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 N, Q;
string S;
char t[200010], d[200010];

int binary_searchL() {
    int ok = -1;
    int ng = N;
    while(abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;
        bool ok1 = true;
        int x = mid;
        rep(i, Q) {
            if(x < 0) continue;
            if(S[x] == t[i]) {
                if(d[i] == 'L') x--;
                else x++;
            }
            if(x >= N) {
                ok1 = false;
                break;
            }
        }
        if(ok1) ok = mid;
        else ng = mid;
        //cout << mid << " " << ok << " " << ng << " " << ok << endl;
    }
    return ok;
}

int binary_searchR() {
    int ok = N;
    int ng = -1;
    while(abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;
        bool ok1 = true;
        int x = mid;
        rep(i, Q) {
            if(x >= N) continue;
            if(S[x] == t[i]) {
                if(d[i] == 'L') x--;
                else x++;
            }
            if(x < 0) {
                ok1 = false;
                break;
            }
        }
        if(ok1) ok = mid;
        else ng = mid;
        //cout << mid << " " << ok << " " << ng << " " << ok << endl;
    }
    return ok;
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> N >> Q;
    cin >> S;
    rep(i, Q) {
        cin >> t[i] >> d[i];
    }
    cout << binary_searchL() - binary_searchR()  + 1<< endl;



    return 0;
}


Measured memory_bytes: 4132
# coding: utf-8
class Case01

  def initialize
    @whthers = { 'Sunny' => 'Cloudy',
                 'Cloudy' => 'Rainy',
                 'Rainy' => 'Sunny'}
  end

  def show
    p self.instance_variables
        .map{ |sym| [sym, self.instance_variable_get(sym)] }
        .to_h
  end
  
  # 実行する
  def execute
    read
    solve
    output
  end

  # 読込
  def read
    @s = gets.chomp
  end

  # 回答
  def solve
    @result = @whthers[@s]
  end
  
  # 出力
  def output
    puts @result
  end

end

Case01.new.execute if $0 == __FILE__



Measured memory_bytes: 1788
/*
One of the common strategy to prove the maximum value is to show that:
1. the value can be achieved
2. it cannot be exceeded
*/
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
const int maxn = 2e5 + 5;

int N, A[maxn];

int main() {
    cin >> N;
    for(int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    sort(A, A + N);
    ll ans = 0;
    for(int i = 0; i < N-1; ++i) {
        ans += A[N-(i+3)/2];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4412