akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <stdio.h>
#include <stdlib.h>

using namespace std;
struct node{
    struct node *right;
    struct node *left;
    struct node *parent;
    int key;
};

typedef struct node * Node;
#define NIL NULL
Node root;

void insert(int k){
    Node y = NIL;
    Node x = root;
    Node z;

    z = static_cast<Node>(malloc(sizeof(struct node)));
    z->key = k;
    z->left = NIL;
    z->right = NIL;
    while(x != NIL) {
        y = x;
        if (z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }
    z->parent = y;

    if(y == NIL){
        root = z;
    } else if (z->key < y->key) {
        y->left = z;
    }else{
        y->right = z;
    }
}

int Inorder(node *x) {
    if (x->left != NIL) {
        Inorder(x->left);
    }
    cout << " " << x->key;
    if (x->right != NIL) {
        Inorder(x->right);
    }
    return 0;
}

int Preorder(node *x) {
    cout << " " << x->key;
    if (x->left != NIL) {
        Preorder(x->left);
    }
    if (x->right != NIL) {
        Preorder(x->right);
    }
    return 0;
}


int main() {
    int n, tmp;
    string com;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> com;
        if (com == "insert") {
            cin >> tmp;
            insert(tmp);
        } else if (com == "print") {
            Inorder(root);
            cout << endl;
            Preorder(root);
            cout << endl;
        }
    }


    return 0;
}



Measured memory_bytes: 26604
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        int k = sc.nextInt();
        for (int i = 0; i < n; i++) {
            if(s.charAt(i) != s.charAt(k-1)) s = s.replace(s.charAt(i), '*');
        }

        System.out.println(s);
        sc.close();
    }

}


Measured memory_bytes: 23508
#include<iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i > 0; i--)
#define mod 1000000007
#define MOD 998244353
typedef long long int ll;
typedef pair<ll, ll> p;

string maxx(string x, string y) {
	return max(x, y);
}

int main() {
	string s;
	cin >> s;
	if (s==maxx(s,"2019/05/01")) {
		cout << "TBD";
		return 0;
	}
	else {
		cout << "Heisei";
		return 0;
	}
}



Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;
int a[10004];
int main()
{
    int n,ann = 0;;
    scanf("%d",&n);
    for(int i = 0; i < n; i++)
    {
        scanf("%d",&a[i]);
        int div = 2,cnt = 1,ans = 0;
        while(a[i]%div==0)
        {
            a[i] = a[i] / div;
            ans += cnt;
            div = div * 2;
            cnt++;
        }
        while(a[i]%2==0)
        {
            a[i] = a[i] / 2;
            ans++;
        }

        ann += ans;
    }
    printf("%d\n",ann);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define SIZE 8
int comp(const void* a, const void* b){ return *(int*)a - *(int*)b; }

int main(int argc, char *argv[]){
     int number[SIZE], n, max, min, i;

     scanf("%d",&n);

     while(n--){
	  for(i=0; i<SIZE; i++) scanf("%1d",&number[i]);
	  
	  qsort(number, SIZE, sizeof(int), comp);
	  
	  max=0, min=0;
	  for(i=0; i<SIZE; i++)
	       max=max*10+number[SIZE-i-1], min=min*10+number[i];
	  
	  printf("%d\n",max-min);
     }

     return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>

int main(){
  int n,i;
  int *a;
  scanf("%d", &n);
  a = (int *)malloc(sizeof(int) * n);

  for(i=0; i<n; i++)
    scanf("%d", &a[i]);

  for(i=n-1; i>=0; i--){
    printf("%d", a[i]);
    if(i != 0)
      putchar(' ');
  }
  putchar('\n');
  
  return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int K = sc.nextInt();
		int a[] = new int[n];
		for (int i = 0; i < n; i++) a[i] = sc.nextInt();
		int DP[] = new int[n];
		for (int i = 0; i < n; i++) DP[i] = (int)1e9;
		DP[0] = 0;
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n && j <= i + K; j++) {
				DP[j] = Math.min(DP[j], DP[i] + Math.abs(a[i] - a[j]));
			}
		}
		System.out.print(DP[n - 1]);
	}

}


Measured memory_bytes: 50296
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void solve() {
	int n, r; cin >> n >> r;
    if(n >= 10) {
        cout << r << endl;
    } else {
        cout << r + 100 * (10 - n) << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

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

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

template <int M> class ModInt {
    int x;

  public:
    constexpr ModInt() : x(0) {}
    constexpr ModInt(int64_t y) : x(y >= 0 ? y % M : (M - (-y) % M) % M) {}
    constexpr ModInt &operator+=(const ModInt &p) {
        if((x += p.x) >= M) x -= M;
        return *this;
    }
    constexpr ModInt &operator-=(const ModInt &p) {
        if((x += M - p.x) >= M) x -= M;
        return *this;
    }
    constexpr ModInt &operator*=(const ModInt &p) {
        x = (int)(1LL * x * p.x % mod);
        return *this;
    }
    constexpr ModInt &operator/=(const ModInt &p) {
        *this *= p.inverse();
        return *this;
    }
    constexpr ModInt operator-() const { return ModInt(-x); }
    constexpr ModInt operator+(const ModInt &p) const {
        return ModInt(*this) += p;
    }
    constexpr ModInt operator-(const ModInt &p) const {
        return ModInt(*this) -= p;
    }
    constexpr ModInt operator*(const ModInt &p) const {
        return ModInt(*this) *= p;
    }
    constexpr ModInt operator/(const ModInt &p) const {
        return ModInt(*this) /= p;
    }
    constexpr bool operator==(const ModInt &p) const { return x == p.x; }
    constexpr bool operator!=(const ModInt &p) const { return x != p.x; }
    constexpr ModInt inverse() const {
        int a = x, b = M, u = 1, v = 0, t = 0;
        while(b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }
    constexpr ModInt pow(int64_t n) const {
        ModInt ret(1), mul(x);
        while(n > 0) {
            if(n & 1) ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }
    constexpr friend ostream &operator<<(ostream &os, const ModInt &p) {
        return os << p.x;
    }
    constexpr friend istream &operator>>(istream &is, ModInt &a) {
        int64_t t = 0;
        is >> t;
        a = ModInt(t);
        return (is);
    }
};
using modint = ModInt<mod>;

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

    int n;
    cin >> n;

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

    vector<modint> sum(n + 1);
    FOR(i, 1, n + 1) sum[i] = sum[i - 1] + modint(1) / modint(i);

    modint ret(0);
    rep(i, n) ret += (sum[i + 1] + sum[n - i] - sum[1]) * a[i];
    FOR(i, 1, n + 1) ret *= i;

    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), d = sc.nextInt();
		sc.close();
		int tmp = 2 * d + 1;
		int r = n % tmp;
		int ans = n /tmp;
		if(r != 0)
			ans++;

		System.out.println(ans);
	}
}


Measured memory_bytes: 22612
bingo = Array.new
(0..2).each{gets.chomp.split(" ").map(&:to_i).each{|b| bingo.push(b)}}
a = gets.chomp.to_i
a.times do
	b = gets.chomp.to_i
	bingo.map!{|bin| bin = bin == b ? -114514 : bin}
end

f3 = true
f4 = true
3.times do |i|
	flag = true
	f2 = true
	3.times do |j|
		flag = false if bingo[i * 3 + j] != -114514 
		f2 = false if bingo[i + 3 * j] != -114514
	end
	f3 = false if bingo[4 * i] != -114514
	f4 = false if bingo[2 * (i+1)] != -114514
	if flag || f2 then
		puts "Yes"
		exit
	end
end
if f3 || f4 then
	puts "Yes"
else 
	puts "No"
end


#p bingo


Measured memory_bytes: 1788
#include<cstdio>  
#include<cmath>  
#include<iostream>  
#include<cstring>  
#include<iostream>  
#include<cstdlib>  
#include<string> 
using namespace std;
const int m=100007;

long long x[m],v[m];
long long a[m],b[m];
int main()
{
	
	long long n,c;
	 scanf("%lld %lld", &n, &c);
	for (int i=1;i<=n;i++)
	 scanf("%lld %lld", &x[i], &v[i]);  
	
	for (long long i=1;i<=n;i++)
	    a[i]=a[i-1]+v[i]-(x[i]-x[i-1]);
	x[n+1]=c;
	for (long long i=n;i>=1;i--)
	    b[i]=b[i+1]+v[i]-(x[i+1]-x[i]);
	    
	for (long long i=2;i<=n;i++)
	    a[i]=max(a[i-1],a[i]);
	for (long long i=n-1;i>=1;i--)
	    b[i]=max(b[i],b[i+1]);
	long long ans=0;
	for (long long i=1;i<=n;i++)
	{
		ans=max(ans,a[i]-x[i]+b[i+1]);
		ans=max(ans,b[i]-(c-x[i])+a[i-1]);
		ans=max(ans,b[i]);
		ans=max(ans,a[i]);
	}
	 printf("%lld\n", ans);  
}

Measured memory_bytes: 3328
#写経
import bisect
A, B, Q = map(int,input().split())
INF = 10 ** 18
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]
for q in range(Q):
    x = int(input())
    b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
    res = INF
    for S in [s[b - 1], s[b]] :
        for T in [t[d - 1], t[d]] :
            d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(T - S)
            res = min(res, d1, d2)
    print(res)


Measured memory_bytes: 12800
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		sc.close();
		int C = 1;
		int D = 0;

		while (B > C) {
			C += A - 1;
			D++;
		}
		System.out.println(D);
	}
}


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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

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

    priority_queue<string, vector<string>, greater<string>> Q;
    rep(i, N) {
        string S; cin >> S;
        Q.push(S);
    }

    while (Q.size()) {
        string s = Q.top(); Q.pop();
        cout << s;
    }
    cout << endl;
}



Measured memory_bytes: 256
require 'pp'

# 入力値を数値で返却する
def gets_i()
  gets.chomp.to_i
end

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end

N = gets_i
a_list = gets_i_list

report_list = a_list.inject(Hash.new(0)){|h, e| h.tap{|h| h[e] += 1}}

(1..N).each do |i|
  puts report_list[i].to_i
end


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int a;
    cin >> a;
    int r = a;
    r += a * a;
    r += a * a * a;
    cout << r<< endl;
    return 0;
}



Measured memory_bytes: 3596
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

#define CLR(a) memset((a), 0 ,sizeof(a))

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


int main(void){
  int N, A, B;
  cin >> N >> A >> B;
  string S;
  cin >> S;

  int num = 0;
  int rank = 1;

  for(int i=0;i<S.size();i++){
    if(S[i] == 'a'){
      if(num < A+B){
        num++;
        cout << "Yes" << endl;
      }
      else{
        cout << "No" << endl;
      }
    }
    else if(S[i] == 'b'){
      if(num < A+B && rank <= B){
        num++;
        rank++;
        cout << "Yes" << endl;
      }
      else{
        rank++;
        cout << "No" << endl;
      }
    }
    else{
      cout << "No" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define all(v) (v).begin(),v.end()
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
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 (a>b) { a=b; return 1; } return 0; }
map<int,int> mp;
ll dp[10][10];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int h,w;
cin>>h>>w;
int V=10;
for(int i=0;i<10;i++){
    for(int j=0;j<10;j++)cin>>dp[i][j];
}
        for(int k=0;k<V;k++)
                for(int i=0;i<V;i++)
                   for(int j=0;j<V;j++)
                      dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
ll sum=0;
for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
        int a;cin>>a;
        if(a==-1)continue;
        else{
            sum+=dp[a][1];
        }
    }
}
cout<<sum<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
__attribute__((constructor))void init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}
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 (a>b) { a=b; return 1; } return 0; }
bool dp[5005];
int main(){
int n,k;
cin>>n>>k;
V<ll> a(n);
ll sum=0;
for(int i=0;i<n;i++){
    cin>>a[i];
    sum+=a[i];
}
dp[0]=true;
sort(all(a),greater<ll>());
int ans=0;
for(int i=0;i<n;i++){
    bool ok=false;
    for(int j=0;j<k;j++){
        if(dp[j]&&j+sum>=k){
            ok=true;
            break;
        }
    }
    if(!ok)ans++;
    else{
        sum-=a[i];
        for(int j=k-a[i]-1;j>=0;j--){
            dp[j+a[i]]|=dp[j];
        }
    }
}
cout<<ans<<"\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int K, X; cin >> K >> X;

    bool fst = true;
    rep(i, -(K - 1), K){
        cout << (fst ? "":" ") << X + i;
        fst = false;
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
import itertools
import bisect

def main():
    N = int(input())
    L = [int(x) for x in input().split()]
    ans = 0
    L_sorted = sorted(L)
    for i in range(N - 2):
        a = L_sorted[i]
        for j in range(i + 1, N - 1):
            b = L_sorted[j]
            r = bisect.bisect_left(L_sorted, a + b, lo=j + 1)
            ans += r - j - 1

    print(ans)



    

if __name__ == '__main__':
    main()



Measured memory_bytes: 44344
#include <iostream>
using namespace std;
int main() {
  int a, b;cin >> a >> b;
  while(b) {
    bool flag = 1;
    for (int i = a; i <= b; ++i) {
      if ((i % 400 == 0) ||
          (i % 4 ==0 && i % 100 != 0)) {
        cout << i << endl;
        flag = 0;
      }
    }
    if (flag) cout << "NA" << endl;
    cin >> a >> b;
    if (b) cout << endl;
  }
}


Measured memory_bytes: 3092
import statistics
n = int(input())
a_list = []
b_list = []
for i in range(n):
  a, b = map(int, input().split())
  a_list.append(a)
  b_list.append(b)
a_median = statistics.median(a_list)
b_median = statistics.median(b_list)
if n % 2 == 0:
  c = int((b_median - a_median)*2) + 1
else:
  c = int(b_median - a_median) + 1
print(c)

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

int main()
{
    int a, b;
    char op;
    while (true)
    {
        scanf("%d %c %d", &a, &op, &b);
        if (op == '?')
            break;
        switch (op)
        {
        case '+':
            printf("%d\n", a + b);
            break;
        case '-':
            printf("%d\n", a - b);
            break;
        case '*':
            printf("%d\n", a * b);
            break;
        default:
            printf("%d\n", a / b);
            break;
        }
    }
}


Measured memory_bytes: 3236
#include<iostream>
#include<map>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
typedef pair< int,int> P;
typedef pair< int , P > road;
main(){
  while(1){
    int c,n,m,s,d;
    int a,b,f;
    vector< P > bus[120];
    int min_cost[120][12];
    queue< road > que;
    road r;
    P p;
    cin>>c>>n>>m>>s>>d;//c waribiki n mati m rosen s start d goal
    if(c==0&&n==0&&m==0&&s==0&&d==0)break;
    for(int i=1;i<=n;i++){
      for(int j=0;j<=c;j++){
	min_cost[i][j]=1<<21;
      }
    }
    for(int i=0;i<m;i++){
      cin>>a>>b>>f;
      p.first=b;
      p.second=f;
      bus[a].push_back(p);
      p.first=a;
      p.second=f;
      bus[b].push_back(p);
    }
    r.first=c;
    r.second.first=s;
    r.second.second=0;
    que.push(r);
    while(!que.empty()){
      road now=que.front();
      int size=bus[now.second.first].size();
      for(int i=0;i<size;i++){
	if(bus[now.second.first][i].second+now.second.second<min_cost[bus[now.second.first][i].first][now.first]){
	  min_cost[bus[now.second.first][i].first][now.first]=bus[now.second.first][i].second+now.second.second;
	  r.first=now.first;
	  r.second.first=bus[now.second.first][i].first;
	  r.second.second=bus[now.second.first][i].second+now.second.second;
	  que.push(r);
	}
	if(now.first!=0&&bus[now.second.first][i].second/2+now.second.second<min_cost[bus[now.second.first][i].first][now.first-1]){
	  min_cost[bus[now.second.first][i].first][now.first-1]=bus[now.second.first][i].second/2+now.second.second;
	  r.first=now.first-1;
	  r.second.first=bus[now.second.first][i].first;
	  r.second.second=bus[now.second.first][i].second/2+now.second.second;
	  que.push(r); 
	}
      }  
      que.pop();
    }
    while(!que.empty()){
      que.pop();
    }
    int mins=1<<21;
    for(int i=0;i<c;i++){
      mins=min(mins,min_cost[d][i]);
    }
    cout<<mins<<endl;
  }
}

Measured memory_bytes: 1280
#include <iostream>
#include <cstdio>

using namespace std;

int n, c, mx;
string s;
int main()
{
    int i;
    cin >> n >> s;
    for(i=0; i<n; i++) {
        if(s[i] == 'I') {
            c++;
        }
        else {
            c--;
        }
        if(c>mx) {
            mx = c;
        }
    }
    cout << mx << endl;
    return 0;
}


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

inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;
}
//const int INF = 0x3f3f3f3f;
//const int mod=1e9+7;
//const double pi=3.14159265359;
//###################################################################

int main(){
    int n=D();
    int a[n];
    for(int i=0;i<n;i++)a[i]=D();
    int cnt=0;
    sort(a,a+n);
    for(int i=0;i<n-2;i++){
        for(int j=i+1;j<n-1;j++){
            for(int k=j+1;k<n;k++){
                if(a[i]!=a[j]&&a[j]!=a[k]&&a[i]+a[j]>a[k])cnt++;
            }
        }
    }
    cout<<cnt;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define print(ele) cout << ele << endl
#define print10(ele) cout << fixed << setprecision(10) << ele << endl

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

int main() {
  ll n, k;
  cin >> n >> k;
  ll ans = 0;
  while (n > 0) {
    ans++;
    n /= k;
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <omp.h>
#include<memory>
#include <cstdio>

using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long int ll;
const int MOD=1000000007;
int main(){
	int X, Y;
  	cin >> X >> Y;
	string ans = "No";
	rep(i, X+1){
    	if ((2*i + 4*(X-i)) == Y){
          ans = "Yes";
        }
    }
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
typedef long long  ll;
typedef long double ld;
typedef pair<ll ,ll > pll;
typedef pair<int ,int > pii;
const ld pi=3.14159265359;
const int maxn=2e5+7;
const int mod=1e9+7;
const ll INF=9223372036854775807;
const int inf=2e9+7; 
/*Almost copy pasted part :)*/

//additional
#define int long long 
//	

int a[maxn];
int p[maxn];

int32_t main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	int sum=0;
	for(int i=1;i<=n;i++){
		int b;
		cin>>b;
		a[i]=a[i]-b;
		sum+=a[i];
	}
	if(sum<0){
		cout<<-1<<endl;
		return 0;
	}
	sort(a+1,a+1+n);
	for(int i=1;i<=n;i++){
		p[i]=a[i];
	}
	int i=1,j=n;
	while(i<j){
		if(a[i]==0){
			i++;
		}
		if(a[j]==0){
			j--;
		}
		if(!(i<j))
			break;
		if(a[i]>=0)
			break;
		int p=abs(a[i]);
		int dec=min(a[j],p);
		p-=dec;
		a[j]-=dec;
		a[i]=-p;
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		if(a[i]!=p[i]){
			ans++;
		}
	}
	cout<<ans<<endl;

}

Measured memory_bytes: 1792
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;

int main(){
    double a,b,h,m;

    cin >> a >> b >> h >> m;

    double ta,tb;

    ta=(2*M_PI*((h*60)+m))/(12*60);
    tb=(2*M_PI*m)/60;
    
    cout << fixed << setprecision(20) << sqrt((a*a) + (b*b) - (2*a*b*cos(ta-tb))) << endl;        
}

Measured memory_bytes: 4192
const input = require('fs').readFileSync('/dev/stdin', 'utf8').split(/\n/);
let dice= input[0].split(' ').map(Number);
let direction = input[1].split('');
roll(direction[1], dice);
function roll(direc, arr) {
    let d1 = arr[0];
    let d2 = arr[1];
    let d3 = arr[2];
    let d4 = arr[3];
    let d5 = arr[4];
    let d6 = arr[5];
    let result = [];
     if (direc === 'N') {
       result = [d2, d6, d3, d4, d1, d5];
      }
    if (direc === 'S') {
       result = [d5, d1, d3, d4, d6, d2];
    }
    if (direc === 'W') {
       result = [d3, d2, d6, d1, d5, d4];
    }
    if (direc === 'E') {
       result = [d4, d2, d1, d6, d5, d3];
    }
    return result;
}
for (let i=0; i<direction.length; i++) {
    dice = roll(direction[i], dice);
}

console.log(dice[0]);


Measured memory_bytes: 15444
#include <cstdio>
int n, p, c[20005];
int main() {
	int i;
	scanf("%d", &n);
	for(i=1; i<=n; i++) scanf("%d", &p), c[p] = i;
	for(i=1; i<=n; i++) printf("%d ", i*30000);
	for(i=1, puts(""); i<=n; i++) printf("%d ", (n-i)*30000 + c[i]);
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <iostream>
#include <math.h>
#define eps 1e-9
using namespace std;
long long int gcd(long long int a,long long int b)
{
    return b?gcd(b,a%b):a;
}
int main()
{
    long long int x,y;
    while(cin >> x >> y)
    {
        cout << gcd(x,y) << " " << x*y/gcd(x,y) << endl;
    }
    return 0;
}

Measured memory_bytes: 1156
object Main extends App{
  var n = scala.io.StdIn.readInt
  var s = scala.io.StdIn.readLine
  var length = s.length
  if (length-n <= 0){
    printf("%s",s)
  }else{
    for(i <- 1 to n){
      printf("%s",s.apply(0))
      s=s.drop(1)
    }
    printf("...")
  }
}


Measured memory_bytes: 54792
#include<bits/stdc++.h>
using namespace std;
typedef long long       ll;
#define MOD ((int)1e9+7)
#define N ((int)2e5+123)
void reads(string& x){ char kk[N]; scanf("%s",kk); x = kk;}

ll n, aux;
string ans;
void solve(){
    scanf("%lld",&n);
    ans = "";
    while(n){
        n--;
        ans=char('a'+n%26)+ans;
        n/=26;
    }
    printf("%s\n", ans.data());
}

int main(){
    ios_base::sync_with_stdio(0);
    int t = 1;// scanf("%d",&t);
    for(int caso=1;caso<=t;caso++){
        solve();
    }
}

Measured memory_bytes: 3756
#include<stdio.h>
 
int main(void){
  char s[11] = {};
 
  scanf("%s", s);
  s[0] = '2';
  s[1] = '0';
  s[2] = '1';
  s[3] = '8';
  printf("%s\n", s);
  return 0;
}

Measured memory_bytes: 128
object Main extends App {
  val ab = scala.io.StdIn.readLine()
  val abArray = ab.split(" ")

  val a = abArray(0).toLong
  val b = if (abArray(1).toDouble == 0d) { 0L } else {
    abArray(1).replaceAll("0\\.0", "").replaceAll("0\\.", "").replaceAll("\\.", "").toLong
  }
  println(a / 100L * b + a % 100L * b / 100L)
}

Measured memory_bytes: 54708
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);

		String str = scan.next();
		str = str.replaceAll("0", "");
		System.out.println(str.length());
	}

}


Measured memory_bytes: 21844
//
//  main.cpp
//  Test
//
//  Created by Nag on 2017/08/18.
//  Copyright ?? 2017??´ Nag. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <sstream>
#include <string>
#include <cstdio>

using namespace std;

int main(void) {

    double x1, x2, y1, y2, dist;
    
    cin >> x1 >> y1 >> x2 >> y2;
    dist = sqrt( pow((x1-x2),2) + pow((y1-y2),2) );
    
    cout << fixed << setprecision(6) << dist << endl;
    
    return 0;
    
}

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

S=readline().rstrip()
N=len(S)
if S==S[::-1] and S[:(N-1)//2]==(S[:(N-1)//2])[::-1] and S[N//2+N%2:]==(S[N//2+N%2:][::-1]):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <time.h>
#include <bitset>
#include <assert.h>
#include <complex.h>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define FILL(A,val) memset(A,val,sizeof(A))

#define ALL(V) V.begin(),V.end()
#define SZ(V) (int)V.size()
#define PB push_back
#define MP make_pair

typedef long long Int;
typedef unsigned long long UInt;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double Pi = acos(-1.0);
const int INF = 1000000000;
const Int INF2 = Int(INF) * 5000;
const Int INF3 = Int(INF) * INF;
const int MAX = 307;
const int MAXE = 2007000;
const int MAXV = 5000;
const int BASE = 1000000000;
const int ST = 1000000007;

const int MOD = 1000000007;




int main()
{
    //freopen("in.txt", "r", stdin);
    
    int n, k;
    cin >> n >> k;
    
    cout << (n - 1 + k - 2) / (k - 1) << endl;
    
    
    
    
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int sum[1002100];

int main(){
  int n,d;
  int m[1111];
  while(cin >> n >> d , n){
    memset(sum,0,sizeof(sum));
    for(int i=1;i<=n;i++){
      cin >> m[i];
    }
    m[0] = 0;
    n++;
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	sum[i*n+j] = m[i] + m[j];
      }
    }
    sort(sum,sum+n*n);
    
    int res = 0;
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	int ab = m[i] + m[j];
	if(ab <= d){
	  int h = d - ab;
	  int tmp = sum[upper_bound(sum,sum+n*n,h)-sum-1] + ab;
	  if(tmp <= d){
	    res = max(res,tmp);
	  }
	}
      }
    }
    cout << res << endl;
  }
}

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

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main(){
    int n; cin >> n;
    vector<pair<int,int>> ab;
    for(int i=0; i<n; i++){
        int a, b; cin >> a >> b;
        ab.push_back(make_pair(a,b));
    }
    sort(ab.begin(), ab.end(), compare_by_b);

    int time=0;
    for(int i=0; i<n; i++){
        time += ab[i].first;
        if(time > ab[i].second){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 5304
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
using pii = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1 << 29;
const int N =  1e5 + 10;
 
struct IOsetup{
  IOsetup(){
   ios_base::sync_with_stdio(false);
   cin.tie(nullptr);
   cout.tie(nullptr);
   cout << fixed << setprecision(8);
  }
}IO;

int32_t main(){
 int n, k;
 cin >> n >> k;
 vector<int> a(n);
 for (int i = 0; i < n; i++) cin >> a[i];
 sort(a.begin(), a.end(), greater<int>());
 int moves = 0;
 for (int i = k; i < n; i++){
  moves += a[i];
 }
 cout << moves << endl;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define LL long int


int main(){
    int n;
    cin >> n;
    vector<int> v(n + 1,0);
    vector<int> w(n + 1);
    for(int i = 1; i <= n; ++i){
        cin >> v[i];
        w[v[i]]++;
    }

    vector<unsigned long int> x(n + 1);
    unsigned LL ans = 0;
    for(int i = 1; i <= n; ++i){
        x[i] = (unsigned long int)w[i] * (unsigned long int)(w[i] - 1) / 2;
        ans += x[i];
    }

    //for(int i = 1; i <= n; ++i){
        //cout << w[i] << endl;
    //}

    for(int i = 1; i <= n; ++i){
        ans -= x[v[i]];
        //cerr << "a" << ans << "b" << x[v[i]] << w[v[i] - 1] << endl;
        ans += (unsigned long int)(w[v[i]] - 1) * (unsigned long int)(w[v[i]] - 2) / 2;
        cout << ans << endl;
        ans -= (unsigned long int)(w[v[i]] - 1) * (unsigned long int)(w[v[i]] - 2) / 2;
        ans += x[v[i]];
    }

    return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> e(m);
  for (auto& x : e) {
    cin >> x.first >> x.second;
    x.first--;
    x.second--;
  }
  vector<int> par(n, -1);
  auto root = [&](int t) {
    if (par[t] < 0) return t;
    for (int i = t;; i = par[i])
      if (par[i] < 0) return par[t] = i;
  };
  vector<ll> ans;
  ll a = (ll)n * (n - 1) / 2;
  for (int i = m; i--;) {
    ans.push_back(a);
    int r1 = root(e[i].first), r2 = root(e[i].second);
    if (r1 != r2) {
      a -= (ll)par[r1] * par[r2];
      if (par[r1] > par[r2]) swap(r1, r2);
      par[r1] += par[r2];
      par[r2] = r1;
    }
  }
  reverse(ans.begin(), ans.end());
  for (auto x : ans) cout << x << endl;
}


Measured memory_bytes: 3444
#https://qiita.com/k-tokitoh/items/8fc1a2de8b110a043ea2
#模写、ｄｐ
N = int(input())
dp = [0]
for i in range(1, N + 1):
    Q = []
    Q.append(1 + dp[i - 1])
    
    p6 = 1
    p9 = 1
    while i >= 6 ** p6:
        Q.append(1 + dp[i - 6 ** p6])
        p6 += 1
    while i >= 9 ** p9:
        Q.append(1 + dp[i - 9 ** p9])
        p9 += 1
    dp.append(min(Q))


print(dp[N])

Measured memory_bytes: 3860
#include<iostream>

long int gcd(long int a, long int b){
  long int k;
  if(b>a){
    k=b;
    b=a;
    a=k;
  }
  k = a % b;
  if(k==0){
    return b;
  }
  while(k!=0){
    k = a % b;
    a = b;
    b = k;
  }
  return a;
}

int main(){
  long int a, b, k;

  while(std::cin >> a >> b){
    k = (a*b)/gcd(a,b);
    std::cout << gcd(a,b) << " " << k << std::endl;
  }
}

Measured memory_bytes: 3012
def f
  n = gets.chomp.to_i
  a = gets.chomp.split.map(&:to_i)
  puts a.join(" ")
  for i in 1..n-1
    v = a[i]
    j = i-1
    while j >= 0 && a[j] > v
      a[j+1] = a[j]
      j -= 1
    end
    a[j+1] = v
    puts a.join(" ")
  end
end

f


Measured memory_bytes: 6892
#include <bits/stdc++.h>
// atoi : atoi(str.c_str())
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)

int main(){
  int n;
  cin >> n;
  cout << n*n*n << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define endl '\n'
#define minimum(a,b) if(a>b) a=b;
typedef vector<vector<ll>> matrix;
const ll INF = 1e18;
const int MAX = 2e5+4;
const int MOD = 1e9+7;
//vector<vector<ll>> dp(MAX,vector<ll>(3));
vector<ll> dp(MAX,INF);
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n,w;
	cin >> n >> w;
	vector<int> a(n+1);
	ll ans=0;
	dp[0]=0;
	for(int i=1;i<=n;i++)
	{
		int a,b;
		cin >> a >> b;
		for(int j=100000;j>=b;j--)
		{
			dp[j]=min(dp[j],dp[j-b]+1LL*a);
		}
	}
	for(int i=0;i<=100000;i++)
	{
		if(dp[i]<=w) ans=max(ans,1LL*i);
//		cout << dp[i] <<  " " << i <<endl;
}
	cout << ans;
	return 0;
}

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

int main(void){
	int n, r, ans;
	cin >> n >> r;
	if(n >= 10){
		ans = r;
	} else {
		ans = r+100*(10-n);
	}
	cout << ans << endl;
	return 0;
}


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

#define ll long long int

int main()
{
  ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll n;
    cin >> n;
    map <string,int>m;
   while(n--)
   {
     string s;
     cin>>s;
     m[s]++;
   }
   cout<<"AC x "<<m["AC"]<<endl;
    cout<<"WA x "<<m["WA"]<<endl;
     cout<<"TLE x "<<m["TLE"]<<endl;
      cout<<"RE x "<<m["RE"]<<endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 510000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
lli gcd(lli num1, lli num2){
    return num2 != 0 ? gcd(num2, num1 % num2) : num1;
}
lli lcm(lli num1, lli num2){
    return num1 / gcd(num1, num2) * num2;
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,F,N,M,K,L,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> A >> B >> C >> D;
  A--;
  Out(B-B/C-B/D+B/lcm(C,D)-A+A/C+A/D-A/lcm(C,D));
}


Measured memory_bytes: 256
object Main extends App {
  val tempList: Seq[Seq[String]] = {
    for(line <- io.Source.stdin.getLines()) yield {
      line.split(' ').toSeq
    }
  }.toSeq

  val X: Int = tempList(0)(0).toInt
  val Y: Int = tempList(0)(1).toInt
  var judge: Boolean = true

  if(Y % 2 != 0) println("No")
  else {
    val turtleNum = Y/2 -X
    if (turtleNum < 0) println("No")
    else {
      if(turtleNum > X) println("No")
      else println("Yes")
    }
  }
}

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

double calc(int num, int K)
{
    double res = 1.;
    while(num < K)
    {
        res *= 0.5;
        num *= 2;
    }
    return res;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, K;
    cin >> N >> K;

    double ans = 0.;
    for(int i=1; i<=N; i++)
    {
        ans += calc(i, K) / N;
    }
    cout << fixed << setprecision(10) << ans << endl;

    return 0;
}


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

#define int long long

#define R first

#define C second

using namespace std;

int h, w, n;

vector<vector<int>> p;

int32_t main() {

  ios_base::sync_with_stdio(0);

  cin >> h >> w >> n;
  swap(h, w) ;

  p.resize(h);

  map<pair<int, int>, int> M;

  for (int i = 0; i < n; ++i) {

    int r, c;

    cin >> r >> c;
    swap(r, c) ;

    r--; c--;

    p[r].push_back(c);

    M[make_pair(r, c)] = 1;

  }

  for (int i = 0; i < h; ++i) {

    sort(begin(p[i]), end(p[i]));

  }

  vector<int> cs;

  int c = 0;

  int r = 0;

  cs.push_back(c);

  for (; r < h; ++r) {

    if (c + 1 < w && M[make_pair(r, c + 1)]) {

      //cerr << "A\n";

      break;

    }

    c++;

    while ((r + 1 == h || M[make_pair(r + 1, c)]) && (c + 1 < w && !M[make_pair(r, c + 1)])) {

      c++;

    }

    //cerr << "c=" << c << "\n";

    if (!(r + 1 == h || M[make_pair(r + 1, c)])) {

      cs.push_back(c);

    } else {

      //cerr << "B\n";

      break;

    }

  }

  int res = w + h;

  for (int i = 0; i < cs.size(); ++i) {

    //cerr << "i = " << i << ", cs = " << cs[i] << "\n";

    int c = cs[i];

    int q = lower_bound(begin(p[i]), end(p[i]), c + 1) - begin(p[i]);

    int t = w - 1;

    if (q < p[i].size()) {

      t = p[i][q] - 1;

    }

    int r = t;

    if (c == t) {

      r = t;

    } else {

      r += 1;

    }

    //cerr << "t = " << t << ", r = " << r << "\n";

    res = min(res, t + 1);

  }

  

  cout << res << "\n";

  //  ...

  //  ...

  //  .#.

  return 0;

}



Measured memory_bytes: 48112
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h> //works like magic, but at cost.
using namespace std;
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout<<x<<endl;
#define fo(i, n) for(int i=0; i<n; i++)
#define fk(i, k, n) for(int i=k; i<n; i++)
#define fn(i, n) for(int i=n-1;i>=0;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define lli long long int
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<lli, lli>	pl;
typedef vector<int>		vi;
typedef vector<lli>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;

int main() {
    int s;
    vector<int> v;
    fo(i, 5){
        cin>>s;
        v.push_back(s);
        if(s==0){
            cout<<i+1<<"\n";
            return 0;
        }
    }
    
    
    return 0;
}

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

	cin >> n;
	while(n-->0){
		int hits = 0;
		int inningScore = 0;
		int outNum = 0;
		while( outNum < 3 ){
			string s;
			cin >> s;
			if( s.compare("HIT") == 0 ){
				hits++;
				if( hits == 4 ){
					inningScore++;
					hits = 3;
				}
			}else if( s.compare("HOMERUN") == 0 ){
				inningScore += hits + 1;
				hits = 0;
			}else if( s.compare("OUT") == 0 ){
				outNum++;
				/* inning end */
				if( outNum == 3 ) break;
			}
		}
		cout << inningScore << '\n';
	}
	return 0;
}

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


int main(){
    long long H;
    cin >> H;

    int count = 0;

    while(H){
        H = H/2;
        count++;
    }

    long long answer = 0;

    for(int i=0; i<count; i++){
        answer = answer + pow(2,i);   
    }

    cout << answer;

    return 0;
}

Measured memory_bytes: 384
S = input()

cnt = 0

if S[0] != 'A':
    print('WA')
else:
    for i, s in enumerate(S[2:-1]):
        if s == 'C':
            cnt += 1
            c_idx = i
    if cnt == 1:
        c_idx += 2
        part_str = S[1:c_idx] + S[c_idx+1:]
        if part_str.islower():
            print('AC')
        else:
            print('WA')
    else:
        print('WA')


Measured memory_bytes: 3060
def print_rectangle(H, W):
    
    for i in range(H):
        for j in range(W):
            if i % 2 == 0 :
                if j % 2 == 0:
                    print("#",end="")
                else:
                    print(".",end="")

            else:
                if j % 2 == 0:
                     print(".",end="")
                else:
                    print("#",end="")
        print()
    print()



if __name__ == "__main__":

    while(1):

        param = input().split(" ")
        h = int(param[0])
        w = int(param[1])

        if h != 0 and w != 0:
            print_rectangle(h, w)
        else:
            break


Measured memory_bytes: 7008
#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;
    }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int A,B;
    cin >> A >> B;
    for(int i = 0;i < max(A,B);i++){
        if(abs(A - i) == abs(B - i)){
            cout << i << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
}


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

using namespace std;
const int N = 1e5 + 5;
int cnt[N];

int main() {
	memset(cnt, 0, sizeof(cnt));
    int n, a;
    int maxx = 0;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) {
        scanf("%d", &a);
        cnt[a] ++, cnt[a + 1] ++, cnt[a - 1] ++;
        maxx = max(maxx, a);
    }
    int res = 0;
    for(int i = 0; i <= maxx; i ++) res = max(res, cnt[i]);
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  string ans = "No";
  for(int i = 0; i <= (N+6)/7; i++){
    if((N-7*i) % 4 == 0 && (N-7*i) >= 0){
    ans = "Yes";
    break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256