akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n) { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x) { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};



int main() {
	
	vi nums;
	vi nums2;

	FOR(i, 1, 1000) {
		int num = i*(i + 1)*(i + 2) / 6;
		if (num > 1000000)
			break;
		nums.push_back(num);
		if (num % 2 == 1)
			nums2.push_back(num);
	}
	
	vi dp(1000000);
	vi dp2(1000000);
	
	REP(i, 1000000) {
		dp[i] = 1000000;
		dp2[i] = 1000000;
	}
	REP(i, nums.size())
		dp[nums[i]] = 1;
	REP(i, nums2.size())
		dp2[nums2[i]] = 1;

	FOR(i, 2, 1000000) {
		REP(j, nums.size())
			if (i - nums[j] > 0)
				dp[i] = min(dp[i], dp[i - nums[j]] + 1);
			else
				break;
		REP(j, nums2.size())
			if (i - nums2[j] > 0)
				dp2[i] = min(dp2[i], dp2[i - nums2[j]] + 1);
			else
				break;
	}
	
	int n;
	while (cin >> n, n) {
		cout << dp[n] << ' ' << dp2[n] << endl;
	}
}

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

#define MAX_N 100000

// int N = 3;
// int A[MAX_N] = {6, 2, 6};

int N;
int A[MAX_N];
int main() {
    cin >> N;
    rep(i, N) {
        cin >> A[i];
    }
    
    map<int, int> mp;

    rep(i, N) {
        mp[A[i]]++;
    }

    int result = 0;
    for(auto itr = mp.begin(); itr != mp.end(); itr++) {
        if (itr->second % 2 == 1) {
            result++;
        } 
    }

    cout << result << endl;
}

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

namespace AOJ_ITP_1_1_B
{
    class Program
    {
        static void Main(string[] args)
        {
            int x = int.Parse(Console.ReadLine());
            Console.WriteLine(x*x*x);
        }
    }
}


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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    sort(h.begin(), h.end());
    int ans = 1e9;
    rep(i,n-k+1) ans = min(ans, h[i+k-1] - h[i]);
    cout << ans << endl;
}

Measured memory_bytes: 3772
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


N,M = map(int,input().split())

ARR = []

for i in range(M):
    ARR.append(list(map(int,input().split())))

def calculate(n,m,arr):
    unionFind = UnionFind(n)

    for i in range(m):
        startNode = arr[i][0] - 1
        endNode = arr[i][1] - 1
        unionFind.union(startNode, endNode)

    result = 0
    for i in range(n):
        result = max(result,unionFind.size(i))
    print(result)



calculate(N,M,ARR)

Measured memory_bytes: 50148
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

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

    string name;
    char head;
    map<char, ll> march;
    for (int i = 0; i < N; i++)
    {
        cin >> name;
        head = name[0];
        if (head == 'M' || head == 'A' || head == 'R' || head == 'C' || head == 'H')
        {
            march[head]++;
        }
    }

    if (march.size() < 3)
    {
        printf("0\n");
        return (0);
    }

    ll ans = 0;
    string word = "MARCH";

    for (int i = 0; i < 5; i++)
    {
        for (int j = i + 1; j < 5; j++)
        {
            for (int k = j + 1; k < 5; k++)
            {
                ans += march[word[i]] * march[word[j]] * march[word[k]];
            }
        }
    }

    // for (auto itr = march.begin(); itr != march.end(); itr++)
    // {
    //     cout << itr->first << " : " << itr->second << endl;
    // }

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

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

using namespace std;
using ll = long long;

#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define REP(i,n) FOR(i, 0, n)
#define FORD(i,a,n) for(int i=(a); i>=(n); i--)
#define REPD(i,n) FOR(i, n, 0)

#define ALL(o) (o).begin(), (o).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T, vector<T>, greater<T> >;


int main(){
	ll n,m;
	cin >> n >> m;
    V<ll> h(n);
	V<ll> c(n);
	int t;

    for(int i = 0 ; i < n ; i++){
		cin >> t;
		h[i] = t;
		c[i] = 1;
    }

	int a,b;
    for(int i = 0 ; i < m ; i++){
		cin >> a >> b;
		if(h[a-1] > h[b-1]) {
			c[b-1] = 0;
		} else if(h[a-1] < h[b-1]) {
			c[a-1] = 0;
		} else {
			c[a-1] = 0;
			c[b-1] = 0;
		}
    }


	int ans = 0;
	REP(i,n) {
		if(c[i] == 1) {
			ans += 1;
		}
	}

	cout << ans << endl;

    return 0;
}



Measured memory_bytes: 4804
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
#define OUT(n) cout << (n) << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int n; cin >> n;
    vector<int> a1(n), a2(n);
    REP(i,n) cin >> a1[i];
    REP(i,n) cin >> a2[i];

    int ans = a1[0] + accumulate(ALL(a2),0);
    int cnt = ans;
    //cerr << ans <<endl;
    FOR(i,1,n) {
        //cerr << cnt-a2[i-1]+a1[i] << endl;
        cnt = cnt-a2[i-1]+a1[i];
        ans = max(ans, cnt);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
/*
 *  Author : Jun_SH
 *  Solution for sumitrust2019 146 C
 */
#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read(){
    int f=1,x=0;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return f*x;
}
int dp[10][100010]={};
main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int x;
    cin>>x;
    dp[0][0]=1;
    for(int i=1;i<=6;++i){
        for(int j=0;j<=x;++j){
            if(dp[i-1][j]){
                dp[i][j]=1;
                continue;
            }
            if(j>=i+99&&(dp[i-1][j-i-99]||dp[i][j-i-99])){
                dp[i][j]=1;
            }
        }
    }
    if(dp[6][x])cout<<(1)<<endl;
    else cout<<(0)<<endl;
}


Measured memory_bytes: 5632
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <map>
#include <iomanip>

using namespace std;
#define MAX 1LL << 60
#define MOD 1000000007

typedef long long ll;

#define rep(i, s, e) for(ll i = s; i < e; i++)
#define repR(i, s, e) for(ll i = s; i > e; i--)
#define reft0(i, j) setfill('0') << setw(i) << j

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

int main(){
    ll N;
    cin >> N;
    ll max = (ll)pow(N, 0.5) + 1;
    ll cnt = MAX;
    rep(i, 1, max){
        if ((N % i) != 0) continue;
        ll temp = N / i;
        ll tempCnt = (i - 1) + (temp - 1);
        if (cnt > tempCnt){
            cnt = tempCnt;
        }
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=100001;
typedef long long ll;
/*void new_arr(ll **&a,int m,int n){
a=new ll*[m+1];
for(int i=0;i<=m;i++)
    a[i]=new ll[n+1];
for(int i=1;i<=m;i++)
    for(int j=1;j<=n;j++)
    scanf("%lld",a[i]+j);
}*/
int main()
{
    int n;
    cin>>n;
    ll map[301][301];
    //new_arr(map,n,n);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
        scanf("%lld",&map[i][j]);
    ll ans=0,flg=0;
    for(int i=1;i<=n;i++)
    for(int j=i+1;j<=n;j++){
        ll ans1=0x3f3f3f3f;
        for(int k=1;k<=n;k++){
            if(k==i||k==j)continue;
            ans1=min(map[i][k]+map[k][j],ans1);
        }
            if(ans1==map[i][j])continue;
            if(ans1>map[i][j]){ans+=map[i][j];//cout<<map[i][j]<<endl;
            }
            if(ans1<map[i][j])flg=1;
    }
    if(flg)cout<<-1<<endl;
    else cout<<ans<<endl;
   // delete map;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>

#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ll long long
using namespace std;

int main(){
  int N;
  cin >> N;
  int a[110];
  //int a[]={1,4,6,3,5};
  FOR(i, 0, N) cin >> a[i];
  
  sort(a, a+N);
  
  cout << a[N-1] - a[0] << endl;

}

Measured memory_bytes: 256
from sys import stdin
from itertools import repeat
def main():
    n, e, t = map(int, stdin.readline().split())
    x = [0] + map(int, stdin.readline().split(), repeat(10, n)) + [e]
    dp = [0] * (n + 1)
    f = [0] * (n + 1)
    f[0] = -x[1] * 2
    j = 0
    for i in xrange(1, n + 1):
        while j < i - 1 and (x[i] - x[j+1]) * 2 > t:
            j += 1
        dp[i] = dp[j] + t
        if j > 0 and dp[i] > f[j-1] + x[i] * 2:
            dp[i] = f[j-1] + x[i] * 2
        f[i] = dp[i] - x[i+1] * 2
        if i and f[i] > f[i-1]:
            f[i] = f[i-1]
    print dp[n] + e
main()


Measured memory_bytes: 12204
void main() {
	((N, a) => iota(-100, 101).map!(i => a.map!(e => (e - i)^^2).sum).reduce!min.writeln)(ri, readAs!(int[]));
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;
int main(){
   int n;
   cin>>n;
   vector<int> t(n);
   rep(i,n){
      cin>>t[i];
   }
   int m;
   cin>>m;
   rep(i,m){
      int p,x;
      cin>>p>>x;
      int sum=0;
      rep(j,n){
         if(j==p-1){
            sum+=x;
         }
         else{
            sum+=t[j];
         }
      }
      cout<<sum<<endl;
   }
return 0;
}


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

int main(void){
  int n;  
  
  cin >> n;
  cin.ignore();
  for (int i=0; i<n; i++){
    string str;
    string::size_type pos;
    getline(cin, str);
    while ((pos = str.find("Hoshino")) != string::npos){
      str[pos+6] = 'a';
    }
    cout << str << endl;
  }
  return 0;
}


Measured memory_bytes: 3128
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
typedef long long int ll;
const int maxn=1e5+5;
ll aa[maxn];
ll q[maxn],h[maxn];
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
int main(){
	int n;cin>>n;rep(i,1,n)cin>>aa[i];
	if(n==1)cout<<1000000000ll<<endl;else{
		q[1]=aa[1];h[n]=aa[n];
		rep(i,2,n)q[i]=gcd(q[i-1],aa[i]);
		for(int i=n-1;i;i--)h[i]=gcd(h[i+1],aa[i]);
		ll ans=max(h[2],q[n-1]);
		rep(i,2,n-1)ans=max(ans,gcd(q[i-1],h[i+1]));
		cout<<ans<<endl;}
	return 0;}


Measured memory_bytes: 2560
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int main()
{
    string s;
    int a, ans=1000;
    cin >> s;
    for(int i=0; i<s.size()-2; i++)
    {
        a=abs(753-(100*(s[i]-'0')+10*(s[i+1]-'0')+(s[i+2]-'0')));
        ans=min(ans,a);
    }
    cout << ans << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define db double
#define Hzy(o) freopen(o".in", "r", stdin), freopen(o".out", "w", stdout)
using namespace std;
const int INF = 1 << 30;
const LL inf = 1LL << 60;
const int N = 200010;
int t[N];
int sum(int x) {
	int res = 0 ;
	for(; x < N; x += x & -x)
		res += t[x];
	return res;
}
void add(int x, int d) {
	for(; x; x -= x & -x)
		t[x] += d;
}
int a[N], n, ans1, ans2 = 1;
vector <int> Q[N], ins[N];
int read() {
	int w(0), f(0); char c = getchar();
	while((c < '0' || c > '9') && c != '-') c = getchar();
	if(c == '-') f = 1, c = getchar();
	while(c >= '0' && c <= '9') w = w * 10 + c - '0', c = getchar();
	return f ? -w : w;
}
int main() {
	n = read();
	int x, y;
	for(int i = 1; i <= n; ++i) {
		x = read(), y = read();
		a[x]++, a[y]--;
		Q[y].push_back(x);
		ins[x].push_back(y);
	}
	int now = 0;
	for(int i = 0; i < N; ++i) {
		now += a[i];
		ans1 = max(ans1, now);
	}
	for(int i = 0; i < N; ++i) {
		for(int x : Q[i])
			ans2 = max(ans2, sum(x + 1));
		for(int x : ins[i])
			add(x, 1);
	}
	printf("%d %d\n", ans2, ans1);
	return 0;
}


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

int main(){
	int H, W;
	int i = 1;
	while (1){
		cin >> H >> W;
		if (H == 0 && W == 0)break;
		if (i)i = 0;
		else cout << endl;
		for (int i = 0; i < H; i++){
			for (int j = 0; j < W; j++){
				if (i >0 && i <H-1){
					if (j>0 && j<W-1)
					cout << '.';
					else cout << '#';
				}
				else{ cout << '#'; }
			}
			cout << endl;
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
typedef long long ll;
using namespace std;

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

	int cnt = 0;
	bool flag = false;

	while (1)
	{
		for (int i = 0; i < n; i++)
		{
			if (a[i] % 2 == 0)
			{
				a[i] /= 2;
			}
			else flag = true;
		}

		if (flag) break;
		else cnt++;

	}
	cout << cnt << endl;
}

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

int main(){
  int a,b;
  cin>>a>>b;
  if((a*b)%2==0){cout<<"Even"<<endl;}
  else{cout<<"Odd"<<endl;}
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = int64_t;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define all(v)    begin(v), end(v)
#define in        []{lint n; cin>>n; return n;}()

const int SUP_N = 3000;
double dp[SUP_N][SUP_N] = {0};

int main() { cin.tie(0); ios::sync_with_stdio(false);
    int N = in;
    vector<double> P(N);
    rep( i, N ) cin >> P[i];
    rep( i, N+1 ) dp[i][0] = 1.0;
    for( int i=1; i<=N; i++ ) for( int j=1; j<=N; j++ ) {
        dp[i][j] = dp[i-1][j-1] * P[i-1] + dp[i-1][j] * (1-P[i-1]);
    }
    printf( "%.10f\n", dp[N][N/2+1] );
}


Measured memory_bytes: 70528
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#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 Per(i,sta,n) for(int i=n-1;i>=sta;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 long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

ll n,k;

void solve(){
    cin >> n >> k;
    n=n%k;
    cout << min(n,k-n) << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

Measured memory_bytes: 256
import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.List
import qualified Data.Map.Strict as Map
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Set as Set
import qualified Data.IntSet as IntSet
import Data.Functor
import Data.Array

main :: IO ()
main = do
  n <- readLn :: IO Int
  ss <- fmap (map read . words) getLine :: IO [Int]
  print $ solve ss

solve :: [Int] -> Int
solve hs 
  | all (==0) hs = 0
  | otherwise = 1 + (solve $ deleteSucceeding i m hs)
  where 
    (i, m) = maximumIndex hs
    deleteSucceeding :: Int -> Int -> [Int] -> [Int]
    deleteSucceeding i m hs = a ++ (delete b)
      where
        (a,b) = splitAt i hs
        delete [] = []
        delete (b:bs)
          | b == m = (b-1):(delete bs)
          | otherwise = (b:bs)
  
maximumIndex :: [Int] -> (Int, Int)
maximumIndex xs = go 0 0 0 xs
  where
    go _ i m [] = (i, m)
    go currentIndex i m (y:ys)
      | m < y = go (currentIndex + 1) currentIndex y ys
      | otherwise = go (currentIndex + 1) i m ys

Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using piii = pair<pair<int, int>, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

ll search(ll mul) {
    ll ok = 0, ng = 1e9 + 1;
    while (abs(ok - ng) > 1) {
        ll mid = (ok + ng) >> 1;
        (mid * mid <= mul ? ok : ng) = mid;
    }
    return ok;
}

ll calc(ll A, ll B) {
    if (A == 1 && B == 1)
        return 0;

    ll mul = A * B - 1;
    ll res = search(mul);
    ll cnt = 0;

    if (min(A, B) <= res)
        cnt--;
    if (mul / res == res)
        cnt++, res--;
    cnt += 2 * res;

    return cnt;
}

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

    int Q;
    cin >> Q;

    for (int i = 0; i < Q; ++i) {
        ll A, B;
        cin >> A >> B;
        cout << calc(A, B) << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a*b>c*d){
		cout<<a*b<<endl;
	}else if(a*b<c*d){
		cout<<c*d<<endl;
	}else if(a*b==c*d){
		cout<<a*b<<endl;
	}
}



Measured memory_bytes: 256
N = int(input())

work = []
for _ in range(N):
    work.append(list(map(int, input().split())))

s_w = sorted(work,key=lambda x: x[1])

s_w_l = list(map(lambda x: x[1], s_w))
s_w_c = list(map(lambda x: x[0], s_w))

import numpy as np
if all(np.cumsum(np.array(s_w_c)) <= np.array(s_w_l)):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 67504
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int N;
      cin >> N;
      int k=N;
      int f=0;
      
      // ここにプログラムを追記
      for(int i=9;i>0;i--){
        if(k/(int)pow(10,i-1) != 0){
          f+=k/(int)pow(10,i-1);
          k=k%(int)pow(10,i-1);
        }
      }
      
      if(N%f==0){
        cout << "Yes" << endl ;
      }else{
        cout << "No" << endl ;
      }
    }

Measured memory_bytes: 3884
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define fo(i,a) for(ll i=0;i<a;i++)
#define fo1(i,a) for(ll i=1;i<a;i++)
#define Fo(i,a,n) for(ll i=a; i<n; i++)

using namespace std;
void solve();
const int N = 1e5+2;
ll dp[N];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
  /*  int t;
    cin >> t;
    while(t--)*/
        solve();
    return 0;
}

void solve(){
    int n;
    cin >> n;
    vi h(n+1,0);
    fo(i,n) cin>>h[i];
    dp[1] = abs(h[1] - h[0]);
    dp[2] = min(dp[1] + abs(h[2]-h[1]), (ll)abs(h[0]-h[2]));
    Fo(i,3,n){
        dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
    }
    cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1408
#include<iostream>
#include<string>

using namespace std;

int main(void) {
	long long a, b, c = 0;
	long long temp;
	long long temp2;
	int count = 0;
	long long i = 1;

	cin >> a >> b;

	c = a;

	temp = a;

	while (c*i <= b) {
		c = temp * i;
		if (c%temp == 0) {
			count++;
			temp = c;
			i = 2;
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>; using vvi = vector<vector<int>>;
using vl = vector<ll>; using vvl = vector<vector<ll>>;
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
//#define int ll
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
int gcd(int a,int b){//ユークリッドの互除法
  while(b){
    a %= b;
    swap(a,b);
  }
  return a;
}
signed main(){
  int n;
  cin >> n;
  int ans;
  cin >> ans;
  REP(i,n-1){
    int t;
    cin >> t;
    ans = gcd(ans,t);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define NEXTP(x) next_permutation(x.begin(),x.end())
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
const ll INF=1e18+7;
const ll MOD=1e9+7;

class comb{
	vector<ll> f,fr;
	ll MOD;
	public:
	//a^(p-1) = 1 (mod p)(p->Prime numbers)
	//a^(p-2) = a^(-1)
	ll calc(ll a,ll b,ll p){//a^(b) mod p   
		if(b==0)return 1;
		ll y = calc(a,b/2,p);y=(y*y)%p;
		if(b & 1) y = (y * a) % p;
		return y;
	}
	void init(ll n,ll mod){//input max_n
		MOD = mod;
		f.resize(n+1);
		fr.resize(n+1);
		f[0]=fr[0]=1;
		for(ll i=1;i<n+1;i++){
			f[i] = (f[i-1] * i) % mod;
			fr[i] = calc(f[i],mod-2,mod);
		}
	}
	ll nCr(ll n,ll r){
		return f[n] * fr[r] % MOD * fr[n-r] % MOD;
	}
};


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n,k;
	ll ans = 0;
	cin >> n >> k;
	comb co;
	co.init(n+k-1,MOD);
	cout << co.nCr(n+k-1,k-1) << endl;
}


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

int n;

#define MAX 1000002

int pos[MAX];
char buf[MAX];

string s;

vector<int> p[MAX];

int im[MAX];


inline int get_f(int l,int r){
	if(l>r)return 0;
	if(l)return im[r]-im[l-1];
	return im[r];
}
inline int f(int val){
	if(val==0)return 0;
	if(val==2){
		return 1;
	}
	else{
		return 2;
	}
}
vector<int> nex[MAX];
int ans[MAX];

int main(){
	if(true){
	cin>>n;
	scanf("%s",buf);
	s=buf;
}
else{
	n=12;
	for(int i=0;i<200000;i++){
		if(rand()%2){
		s.push_back('R');
	}
	else{
		s.push_back('S');
	}
	}
}
int m=pow(3,n);
int k=1;
	for(int i=0;i<s.size();i++){
		if(s[i]=='R'){
			p[0].push_back(i);
		}
		else{
			im[i]++;
		}
		if(i)im[i]+=im[i-1];
	}
	for(int i=0;i<n;i++){
		//cerr<<i<<endl;
		for(int j=0;j<k;j++){
			int tmp=ans[j];
			for(int g=0;g<3;g++){
				int cur=g;
				int tim=0;
				for(int el:p[j]){
					int z=get_f(tim,el);
					tim=el+1;
					if(z%2){
						cur=f(cur);
					}
					cur++;
					if(cur==3){
						nex[k*g+j].push_back(el);
						cur=0;
					}
				}
				int z=get_f(tim,s.size()-1);
				if(z%2)cur=f(cur);
				ans[k*g+j]=tmp+cur*k;
			}
		}
		for(int j=0;j<k*3;j++){
			swap(nex[j],p[j]);
			nex[j].clear();
		}
		k*=3;
	}
	for(int i=0;i<m;i++){
		if(i)printf(" ");
		printf("%d",ans[i]);
	}
	return 0;
}


Measured memory_bytes: 76440
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		long n = sc.nextLong();

		long t = 0L;
		for ( int a=1; a<=n; a++ ) {
			long first = n/2;
			long b = nibutan((long)a, first, n, 0L, n);

			t += b;
		}

		System.out.println(t);
	}

	private static long nibutan(long a, long b, long n, long mi, long mx) {
		if ( mi>=b ) return mi;

		long ok = (b+mx)/2;
		long ng = (b+mi)/2;
		if ( a*b<n )	return nibutan(a, ok, n, b, mx);
		else		return nibutan(a, ng, n, mi, b);
	}
}

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

int main(){
    int n,k;
    cin >> n >> k;
    vector<ll> num(k,0);
    for(int i=1;i<=n;i++) num[i%k]++;
    ll ans = 0;
    for(int a=0;a<k;a++){
        int b = (k-a)%k;
        int c = (k-a)%k;
        if((b+c)%k != 0) continue;
        ans += num[a]*num[b]*num[c];
    }
    cout << ans << endl;
}



Measured memory_bytes: 1792
#include<algorithm>
#include<cstring>
#include<stdio.h>
using namespace std;
int main(){
	int n;
	scanf("%d",&n);
	if(n<1200)printf("ABC\n");
	else{
		if(n>=1200&&n<2800)printf("ARC\n");
		else printf("AGC\n");
	}
	return 0;
}


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

namespace ConsoleApp5
{
    class Program
    {

        static void Main(string[] args)
        {         
            String S = Console.ReadLine();
            String[] line = S.Split(' ');
            int N = int.Parse(line[0]);
            int K = int.Parse(line[1]);
            int[] p = new int[N];
            double[] ave = new double[N];

            S = Console.ReadLine();
            line = S.Split(' ');

            for (int i=0; i<N; i++)
            {
                p[i] = int.Parse(line[i]);
                ave[i] = (p[i] + 1) / 2.0;
            }
            double ans = 0;
            double res = 0;

            for(int i=0; i<N; i++)
            {
                if(i < K)
                {
                    ans += ave[i];
                    res = ans;
                }
                else
                {
                    res -= ave[i - K];
                    res += ave[i];
                    if(res > ans)
                    {
                        ans = res;
                    }
                }

            }

            Console.WriteLine(ans);

        }
    }
}

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

int main(void){

    int x, y, z; cin >> x >> y >> z;
    int ans = 0;
    
    x -= z;

    while(x >= y+z){
        ans++;
        x -= y+z;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

vector <vector <int> > g;
int ans=0;
void dfs(int s,vector <bool> &visited,set <int> &v);

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt(),m=nxt();
    vector <int> row;
    g.resize(n+1,row);
    while(m--)
    {
        int u=nxt(),v=nxt();
        g[u].push_back(v);
        g[v].push_back(u);
    }

    vector <bool> visited;
    visited.resize(n+1,0);
    set <int> v;
    for(int i=1;i<=n;i++)
        v.insert(i);
    dfs(1,visited,v);
    cout<<ans<<endl;

    
    return 0;   
}

void dfs(int s,vector <bool> &visited,set <int> &v)
{
    v.erase(s);
    visited[s]=1;
    if(v.size()==0)
        ans++;
    else
    {
        for(auto x:g[s])
        {
            if(!visited[x])
            {
                dfs(x,visited,v);
            }
        }
    }
    visited[s]=0;
    v.insert(s);

}




 
 


Measured memory_bytes: 256
#include <iostream>

int main(){
    int sumStayDay, normalStayDay, lodgingCost, extensionCost;
    std::cin >> sumStayDay >> normalStayDay >> lodgingCost >> extensionCost;

    int sumMoney = 0;
    if(sumStayDay < normalStayDay){
        sumMoney = sumStayDay * lodgingCost;
    } else {
        sumMoney = normalStayDay * lodgingCost + extensionCost * (sumStayDay - normalStayDay);
    }

    std::cout << sumMoney << std:: endl;
}

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

using namespace std;

struct RES {
  int idx, val;
  RES(int i, int v) : idx(i), val(v) {}
};  

RES parse(string& line, int idx, int p, int q, int r) 
{
  char c = line[idx];
  if (c == '0') return RES(idx+1, 0);
  if (c == '1') return RES(idx+1, 1);
  if (c == '2') return RES(idx+1, 2);
  if (c == 'P') return RES(idx+1, p);
  if (c == 'Q') return RES(idx+1, q);
  if (c == 'R') return RES(idx+1, r);
  if (c == '-') {
    RES r1 = parse(line, idx+1, p, q, r);
    return RES(r1.idx, 2 - r1.val);
  }
  if (c == '(') {
    RES  r1 = parse(line, idx+1, p, q, r);
    char op = line[r1.idx];
    RES  r2 = parse(line, r1.idx+1, p, q, r);
    if (op == '*') {
      if (r1.val == 2 && r2.val == 2) return RES(r2.idx + 1, 2);
      if (r1.val > 0 && r2.val > 0)   return RES(r2.idx + 1, 1);
      return RES(r2.idx + 1, 0);
    }
    else if (op == '+') {
      if (r1.val == 0 && r2.val == 0) return RES(r2.idx + 1, 0);
      if (r1.val < 2 && r2.val < 2)   return RES(r2.idx + 1, 1);
      return RES(r2.idx + 1, 2);
    }
    else
      cout << "error at " << r1.idx << " (" << line[r1.idx] << ")" << endl;
  }
  else
    cout << "error at " << (idx+1) << " (" << c << ")" << endl;
}

void compute(string& line) 
{
  int models = 0;
  for (int p=0; p <= 2; p++)
    for (int q=0; q <= 2; q++)
      for (int r=0; r <= 2; r++)
        if (parse(line, 0, p, q, r).val == 2)
          models++;
  cout << models << endl;
}

int main(void) 
{
  string line;
  while (cin >> line) {
    if (line[0] == '.') break;
    compute(line);
  }

  return 0;
}

Measured memory_bytes: 3052
#include <iostream>

using namespace std;

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


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    String sdata = sc.nextLine();
		String []svdata = sdata.split(" ");
	    try{
	    	Integer i1data = Integer.parseInt(svdata[0]);
	    	Integer i2data = Integer.parseInt(svdata[1]);
	    	System.out.println(i1data*i2data + " " + ((i1data*2) + (i2data*2)));
	    } catch (Exception e) {
	    	e.printStackTrace();
	    }
	}
}


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

#define rep(i,n) for(int i=0; i<(n); ++i)
#define rrep(i,n) for(int i=1; i<=(n); ++i)
#define drep(i,n) for(int i=(n)-1; i>=0; --i)
#define foreach(it, v) for(typeof(v.begin()) it=v.begin(); it!=v.end(); ++it)
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second

typedef unsigned int uint;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef set<int> si;

//MOD//
const ll MOD = 1000000007;
struct big;
big ex(big a, ll tms);
typedef struct big{
  ll val;
  big():val(0){}
  big(ll val):val((val%MOD+MOD)%MOD){}
  big& operator += (const big& obj){ (val+=obj.val)%=MOD; return *this;}
  big& operator -= (const big& obj){ (val+=MOD-obj.val)%=MOD; return *this;}
  big& operator *= (const big& obj){ (val*=obj.val)%=MOD; return *this;}
  big& operator /= (const big& obj){ (val*=ex(obj,MOD-2).val)%=MOD; return *this;}
  big operator + (const big& obj)const{ return big(*this) += obj;}
  big operator - (const big& obj)const{ return big(*this) -= obj;}
  big operator * (const big& obj)const{ return big(*this) *= obj;}
  big operator / (const big& obj)const{ return big(*this) /= obj;}
  bool operator < (const big& obj)const{ return val < obj.val;}
  bool operator == (const big& obj)const{ return val == obj.val;}
} big;
istream& operator >> (istream& i, big& obj){ i>>obj.val; return i;}
ostream& operator << (ostream& o, const big& obj){ o<<obj.val; return o;}
big ex(big obj, ll tms){
  if(!tms) return 1;
  big ret = ex(obj, tms/2);
  ret *= ret;
  return (tms&1) ? ret*obj : ret;
}
//MOD//

ll pow(ll n, int m){
  if(!m) return 1;
  ll ret = pow(n, m/2);
  ret *= ret;
  return (m&1) ? ret*n : ret;
}

template <class F, class T>
void convert(const F &f, T &t){
  stringstream ss;
  ss << f;
  ss >> t;
}

int N;

int main(){

  scanf("%d",&N);
  vi a(N);
  rep (i, N) {
    scanf("%d",&a[i]);
  }
  vi ans;
  rep (i, N) {
    int f = -1;
    for (int j=a.size()-1; j>=0; --j) {
      if (a[j]==j+1) {
        f = j+1;
        a.erase(a.begin()+j);
        break;
      }
    }
    if (f < 0) {
      cout << "-1\n";
      return 0;
    }
    ans.pb(f);
  }
  reverse(ans.begin(), ans.end());

  rep (i, N) cout << ans[i] << endl;

  return 0;
}

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

using namespace std;
int cost[100001][3];
long long dp[100001][3];

int main()
{
   int n;scanf("%d",&n);
   for(int i=0;i<n;++i){
       for(int j=0;j<3;++j){
           scanf("%d",&cost[i][j]);
       }
   }
   dp[0][0]=cost[0][0];
   dp[0][1]=cost[0][1];
   dp[0][2]=cost[0][2];
   for(int i=1;i<=n;++i){
       for(int j=0;j<3;++j){
           if(j==0){
               dp[i][j] += max(dp[i-1][1],dp[i-1][2])+cost[i][j];
           }
           if(j==1){
               dp[i][j] += max(dp[i-1][2],dp[i-1][0])+cost[i][j];
           }
           if(j==2){
               dp[i][j] += max(dp[i-1][0],dp[i-1][1])+cost[i][j];
           }
       }
   }
   printf("%lld\n",max({dp[n][0],dp[n][1],dp[n][2]}));
   
   
   return 0;
}

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

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<long long> A(N);
	for (auto &x : A) {
		cin >> x;
	}

	long long abs_sum = 0;
	long long abs_min = 1LL << 40;
	int neg = 0;
	for (auto x : A) {
		abs_sum += abs(x);
		abs_min = min(abs_min, abs(x));
		if (x < 0) {
			++neg;
		}
	}

	if (neg % 2 == 0) {
		cout << abs_sum << endl;
	}
	else {
		cout << abs_sum - 2 * abs_min << endl;
	}
}


Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;


int main() {
	int h, w;
	string a[110];
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < h; i++) {
		int count = 0;
		for (int j = 0; j < w; j++) {
			if (a[i][j] == '.') {
				count++;
			}
		}
		if (count == w) {
			for (int j = 0; j < w; j++) {
				a[i][j] = '*';
			}
		}
	}
	for (int j = 0; j < w; j++) {
		int count = 0;
		for (int i = 0; i < h; i++) {
			if (a[i][j] != '#') {
				count++;
			}
		}
		if (count == h) {
			for (int i = 0; i < h; i++) {
				a[i][j] = '*';
			}
		}
	}
	for (int i = 0; i < h; i++) {
		int count = 0;
		for (int j = 0; j < w; j++) {
			if (a[i][j] != '*') {
				cout << a[i][j];
				count = 1;
			}
		}
		if (count == 1) {
			cout << endl;
		}
	}
}

Measured memory_bytes: 256
import numpy as np

mod = 10 ** 9 + 7

N = int(input())
 
AList = np.array(input().split(), dtype=np.int64)
count = 0
for i in range(60):
    Plus = np.count_nonzero(AList >> i & 1)
    count += 2 ** i * (Plus * (N - Plus))
print(count % mod)

Measured memory_bytes: 62776
S = list(input())
zeroone = 0
onezero = 0
for i in range(len(S)):
    if i % 2 == 0 and S[i] == '1':
        zeroone += 1
    elif i % 2 == 1 and S[i] == '0':
        zeroone += 1
for i in range(len(S)):
    if i % 2 == 0 and S[i] == '0':
        onezero += 1
    elif i % 2 == 1 and S[i] == '1':
        onezero += 1

print(min(zeroone, onezero))

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<long long,long long>
#define lg length()
#define pb push_back
ifstream in("file.in");
ofstream out("file.out");
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005

int n,c,k,x[100005];

bool good(int t){
    int a=1,b=1;
    while(a<=n){
        while(b<=n && x[b]-x[a]<=k && b-a+1<=c) b++;
        t--; a=b;
    }
    if(t<0) return 0;
    else return 1;
}

int32_t main(){
    ios_base :: sync_with_stdio(0);
    cin >> n >> c >> k;
    for(int i=1;i<=n;i++) cin >> x[i];
    sort(x+1,x+n+1);
    int p=1;
    for(int k=(1<<30);k;k/=2){
        if(good(p+k)) continue;
        else p+=k;
    }
    if(!good(p)) p++;
    cout << p;
}


Measured memory_bytes: 640
from random import randrange

def score(c,s,t):
    ans = 0
    scorelast = [0] * 26
    for i in range(d,365):
        ans += s[i][t[i]]
        scorelast[t[i]] = i + 1
        for j in range(26):
            ans -= c[j] * (i + 1 - scorelast[j])
    return ans

def diffscore(old,q,c,s,t):
    cq = c[q]
    scorelast = [0] * 2
    diff = 0
    for i in range(365):
        if t[i] == q:
            diff += s[i][q]
            scorelast[0] = i + 1
        elif t[i] == old:
            diff += s[i][old]
            scorelast[1] = i + 1
        diff -= cq * (i + 1 - scorelast[0])
        if cq != old:
            diff -= c[old] * (i + 1 - scorelast[1])

    return diff
D = int(input())
c = list(map(int,input().split()))
s = []
for i in range(D): s.append(list(map(int,input().split())))
d = 0
t = []
last = [-1] * 26
for i in range(D):
    maximum = 0
    maxs = 0
    for j in range(26):
        if maximum < s[i][j] + c[j] * (i - last[j]):
            maxs = j
            maximum = s[i][j] + c[j] * (i - last[j])
    last[maxs] = i
    t.append(maxs)

for i in range(40000):
    d = randrange(D)
    q = randrange(26)
    old = t[d]
    before = diffscore(old,q,c,s,t)
    t[d] = q
    if before > diffscore(old,q,c,s,t): t[d] = old
for i in t: print(i + 1)


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



int main() 
{
  string sa,sb,sc;
  cin>>sa>>sb>>sc;
  char card='a';
  char winner;
  rep(i,301)
  {
    if(card=='a')
    {
      if(sa.size()==0)
      {
        winner='A';
        break;
      }
      card=sa.at(0);
      sa.erase(sa.begin()+0);
      continue;
    }
    if(card=='b')
    {
      if(sb.size()==0)
      {
        winner='B';
        break;
      }
      card=sb.at(0);
      sb.erase(sb.begin()+0);
      continue;
    }
    if(card=='c')
    {
      if(sc.size()==0)
      {
        winner='C';
        break;
      }
      card=sc.at(0);
      sc.erase(sc.begin()+0);
      continue;
    }
  }
  cout<<winner<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string S;
    cin>>S;
    char ch;
    ch=getchar();
    int i,j,k;
    if(S[2]==S[3] && S[4]==S[5])
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 256
function main()
  
  S = collect(chomp(readline()))
  T = collect(chomp(readline()))
  
  reverse!(S)
  reverse!(T)
  
  len_S = length(S)
  len_T = length(T)
  
  check = 0
  check2 = 
  ans = false
  
  for i in 1:len_S - len_T + 1
    for j in 1:len_T
      if S[i + j - 1] == T[j] || S[i + j - 1] == '?'
        check += 1
      else
        check = 0
        break
      end
    end
    if check != 0
      check2 = i
      ans = true
      break
    end
  end

  String_ans = []
  num = 1
  
  if ans
    for i in 1:len_S
      if i < check2 || check2 + len_T - 1 < i
        if S[i] == '?'
          push!(String_ans, 'a')
        else
          push!(String_ans, S[i])
        end
      else
        push!(String_ans, T[num])
        num += 1
      end
    end
  else
    push!(String_ans, "UNRESTORABLE")
  end
  
  reverse!(String_ans)
  
  println(join(String_ans))
  
end

main()

Measured memory_bytes: 123068
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include <numeric>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=(int)1e9+7;
const llint big=(llint)(2.19e15+1);
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int main(void){
	int n,i;cin>>n;
	vector<int>a(n);
	for(i=0;i<n;i++){cin>>a[i];}
	REV(a);
		for(i=0;i<n;i++){cout<<a[i];if(i<n-1){cout<<" ";}else{cout<<endl;}}
	RE;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	double t, x;
	cin>>t>>x;
	cout<<t/x<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int a, b;
	cin >> a >> b;
	if (a + b == 15) puts("+");
	else if (a*b == 15) puts("*");
	else puts("x");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll md = 1e9+7;
const ll mx = 2e5;
vector<ll> fact(mx+1);
vector<ll> invfact(mx+1);
ll pow(ll a, ll b)
{
	if (b == 0)
	{
		return 1LL;
	}
	ll ans = pow(a,b/2);
	ans = (ans * ans)%md;
	if (b%2==1)
	{
		ans = (ans * a)%md;
	}
	return ans;
}

ll choose(ll a, ll b)
{
	if (b > a)
	{
		return 0LL;
	}
	return (((fact[a]*invfact[b]) % md)*invfact[a-b])%md;
}

int main()
{
	fact[0] = 1;
	invfact[0] = 1;
	for (ll q = 1; q <= mx; q++)
	{
		fact[q] = (fact[q-1] * q) % md;
		invfact[q] = pow(fact[q], md-2);
	}
	ll h,w,n;
	cin >> h >> w >> n;
	vector<pair<ll,ll>> walls;
	for (int q = 0; q < n; q++)
	{
		ll a,b;
		cin >> a >> b;
		walls.emplace_back(a,b);
	}
	walls.emplace_back(h,w);
	sort(walls.begin(), walls.end());
	vector<ll> dp(n+1);
	for (int q = 0; q <= n; q++)
	{
		dp[q] = choose(walls[q].first+walls[q].second-2, walls[q].first-1);
	}
	for (int q = 1; q <= n; q++)
	{
		for (int w = 0; w < q; w++)
		{
			if (walls[w].second > walls[q].second)
			{
				continue;
			}
			ll dx = walls[q].first-walls[w].first;
			ll dy = walls[q].second-walls[w].second;
			dp[q] = (dp[q] - ((dp[w] * choose(dx+dy, dx))%md))%md;
		}
	}
	cout << ((dp[n]%md)+md)%md << "\n";
	return 0;
}


Measured memory_bytes: 3456
n = int(input())
h = list(map(int, input().split()))

dp = [0 for _ in range(n)]
dp[0] = 0
dp[1] = abs(h[1] - h[0])

for i in range(2, n):
    dp[i] = min(
        dp[i-2] + abs(h[i-2] - h[i]),
        dp[i-1] + abs(h[i-1] - h[i]),
    )

print(dp[n-1])

Measured memory_bytes: 13928