akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int n, a[100100], dp[100100];

signed main() {
	cin >> n;
	rep(i,n) cin >> a[i];
	reps(i,1,n) dp[i] = 1<<30;
	rep(i,n) reps(j,1,3) chmin(dp[i+j], dp[i] + abs(a[i]-a[i+j]));
	cout << dp[n-1] << endl;
}

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

long long h, w;

int main()
{
	cin >> h >> w;

	if (h == 1 || w == 1)
		cout << 1 << endl;
	else if (h % 2 == 0)
		cout << w * (h / 2) << endl;
	else
		cout << w * (h / 2) + (w + 1) / 2 << endl;
}


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

namespace lean
{
    class Program
    {
        static void Main()
        {
            string a = Console.ReadLine();
            if (a == "AAA" || a == "BBB")
            {
                Console.WriteLine("No");
            }
            else
            {
                Console.WriteLine("Yes");
            }
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
#include <stdint.h>
#include <string>
using namespace std;
#define mod 1000000007
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repx(i,x,n) for(int i=x;i<n;i++)


int main(){
    int n,k;
    cin>>n>>k;
    vector<__uint64_t> a(n);
    vector<__uint64_t> ans;
    for(int i=0;i<n;i++)cin>>a[i];
    __uint64_t mult=1;
    // for(int i=0;i<k-1;i++)mult*=a[i];
    int j=0;
    for(int i=k-1;i<n-1;i++){
        mult=a[i]*a[j];
        ans.push_back(mult);
        mult/=a[j];
        int x=i;
        x++;
        mult*=a[x];
        ans.push_back(mult);
        // mult/=a[j];
        j++;
    }
    // cout<<ans.size();
    for(int i=0;i<ans.size()-1;i+=2){
        // cout<<ans[i]<<" "<<ans[i+1]<<endl;
        if(ans[i+1]>ans[i])cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}


Measured memory_bytes: 8812
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

using pi = pair<int,int>;
using P = pair<int,pi>;

struct edge{int to,cost;};

const int N = 100;
const int INF = 123456789;
vector<edge> G[N];
int d[N][N];

int main(){
    int n,m,c;
    while(scanf(" %d %d %d", &n, &m, &c),n){
        rep(i,N) G[i].clear();
        fill(d[0],d[N],INF);

        rep(i,m){
            int f,t,w;
            scanf(" %d %d %d", &f, &t, &w);
            --f; --t;
            G[f].pb({t,w});
        }

        d[0][0]=0;
        priority_queue<P, vector<P>, greater<P>> pq;
        pq.push({0,{0,0}});
        while(!pq.empty()){
            P now = pq.top();
            pq.pop();
            int v = now.se.fi, num = now.se.se;
            if(d[v][num]<now.fi) continue;
            for(const auto &e:G[v]){
                if(num+1<N){
                    if(d[e.to][num+1] > d[v][num]){
                        d[e.to][num+1] = d[v][num];
                        pq.push({d[e.to][num+1], {e.to,num+1}});
                    }
                }

                if(d[e.to][num] > d[v][num]+e.cost){
                    d[e.to][num] = d[v][num]+e.cost;
                    pq.push({d[e.to][num], {e.to,num}});
                }
            }
        }

        int ans = 0;
        while(ans<N && d[n-1][ans]>c) ++ans;
        printf("%d\n", ans);
    }
    return 0;
}



Measured memory_bytes: 3276
module Main where
import Control.Monad
import Control.Applicative
import Data.Maybe
import Data.List
import qualified Text.Printf
import qualified Data.ByteString.Char8 as BC
import qualified Data.ByteString as BC

------------------------------------------

main :: IO ()
main = do
  n <- readInt
  xs <- replicateM n readInt
  print $ solve xs

solve :: [Int] -> Int
solve xs = go 0 1 xs
  where go acc _   [] = acc
        go acc dec (y:ys)
          | dec == 1 = go (acc + (y-1)) 2 ys
          | y == dec = go acc (dec + 1) ys
          | otherwise = go (acc + ((y-1) `div` dec)) dec ys

------------------------------------------

{- Int input -}

parseInt :: BC.ByteString -> Int
parseInt = fst . fromJust . BC.readInt

parseInts :: BC.ByteString -> [Int]
parseInts = map parseInt <$> BC.words

readInt :: IO Int
readInt = parseInt <$> BC.getLine

readInts :: IO [Int]
readInts = parseInts <$> BC.getLine

{- Double Formatting -}

doubleFormat :: Double -> String
doubleFormat = Text.Printf.printf "%.12f"


Measured memory_bytes: 21500
N=int(input())
A=list(map(int,input().split()))

long1=0
long2=0
A=sorted(A)
pair=1
for i in range(N-1):
    if A[i]==A[i+1] and pair==1:
        long2=long1
        long1=A[i]
        pair=0
    else:
        pair=1
if long2==0:
    ans=0
else:
    ans=long1*long2
print(ans)


Measured memory_bytes: 15148
N = int(input())
s = [""]*N
for i in range(N):
    tmp = list(input())
    tmp.sort()
    s[i] = "".join(tmp)
s.sort()
cnt = 0
ans = 0
for i in range(1,N):
    if s[i-1] == s[i]:
        cnt += 1
    else:
        ans += (cnt*(cnt+1))//2
        cnt = 0
ans += (cnt*(cnt+1))//2
print(ans)

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

using namespace std;

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

  int N; cin>>N;
  map<int, int> cards;
  for (int i = 0; i < N; i++) {
    int a; cin>>a;
    cards[a]++;
  }
  map<int, int> ccmap;
  for (auto& c : cards) {
    ccmap[c.second]++;
  }
  vector<int> cd(N+1);
  cd[0] = 0;
  vector<int> ckd(N+1);
  ckd[0] = 0;
  for (int i = 1; i < N+1; i++) {
    cd[i] = cd[i-1];
    ckd[i] = ckd[i-1];
    auto find = ccmap.find(i);
    if (find != ccmap.end()) {
	  cd[i] += find->second;
	  ckd[i] += i * find->second;
    }
  }

  auto max_len_div = [&](int div) {
    return floor(float(ckd[div] + div*(cd[N] - cd[div])) / div);
  };
  for (int k = 1; k <= N; k++) {
    int l = 1, r = N;
    int res = 0;
    while (l <= r) {
      int c = (l+r)/2;
      if (max_len_div(c) >= k) {
        l = c+1;
        res = c;
      } else {
        r = c-1;
      }
    }
    cout << res << endl;
  }

  return 0;
}


Measured memory_bytes: 16640
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define MAX_LEN 10000
#define MAX_NC 3333
char buff[MAX_LEN+1];
int comp(const void *a, const void *b){
    int c = *(int *)a;
    int d = *(int *)b;
    if(c<d) return -1;
    else  return 1;
}
int find_rp(int lp){
    int count=1;
    int rp=lp;
    char c;
    while(count){
        c=buff[++rp];
        if(c=='[') count++;
        else if(c==']') count--;
    }
    return rp;
}
int mc(int from, int to){
    int nv[MAX_NC];
    int nd;
    int v;
    int lp, rp;
    int i;
    if(buff[from+1]=='['){
        nd=0;
        lp=from+1;
        while(lp<to){
            rp=find_rp(lp);
            nv[nd++]=mc(lp,rp);
            lp=rp+1;
        }
        qsort(nv,nd,sizeof(int),comp);
        v=0;
        for(i=0; i<(nd+1)/2; i++) v+=nv[i];
        return v;
    }
    else{
        sscanf(&buff[from+1],"%d",&v);
        return (v+1)/2;
    }
}
int main(void){
    int n,i,ans;
    scanf("%d",&n);
    for(i=0; i<n; i++){
        scanf("%s",buff);
        ans=mc(0,strlen(buff)-1);
        printf("%d\n",ans);
    }
    return 0;
}



Measured memory_bytes: 2056
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <map>

using namespace std;

typedef long long ll;

void solver_main()
{
	string s, t;
	cin >> s;
	cin >> t;

	int sum = 0;
	for (int i = 0; i < 3; i++) {
		if (s[i] == t[i]) {
			sum++;
		}
	}
	cout << sum << endl;
}

int main(void)
{
	solver_main();
	return 0;
}

Measured memory_bytes: 256
n = int(input())
p = list(map(int, input().split()))
N = 0
for i in range(n - 2):
  l = [p[i], p[i + 1], p[i + 2]]
  if l.index(max(l)) != 1 and l.index(min(l)) != 1:
    N += 1
print(N)

Measured memory_bytes: 2940
#include <stdio.h>
#include <string.h>

int main()
{
	char s[22];
	scanf("%s",s);
	for(int i = 0; i < strlen(s); i++)
	{
		printf("%c",s[strlen(s) - i - 1]);
	}
	printf("\n");
	return 0;
}

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

int A, B, M;
vector<int> va, vb;

void input_init(void) {
	cin >> A >> B >> M;
	va.resize(A);
	for (int i = 0; i < A; ++i)
		cin >> va[i];
	vb.resize(B);
	for (int i = 0; i < B; ++i)
		cin >> vb[i];
}

int solve(void) {
	vector<int>::iterator itr;
	itr = min_element(va.begin(), va.end());
	int min_a = *itr;
	itr = min_element(vb.begin(), vb.end());
	int min_b = *itr;

	int min_val = min_a + min_b;
	for (int i = 0; i < M; ++i) {
		int x, y, c;
		cin >> x >> y >> c;
		--x;
		--y;
		int val = va[x] + vb[y] - c;
		if (val < min_val)
			min_val = val;
	}
	return min_val;
}

int main(void) {
	input_init();
	int ans = solve();
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
using namespace std;
//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}*/


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  int64_t n;
  cin >> n;
  if(n % 2 == 0){
    cout << n << endl;
  }else{
    cout << 2*n << endl;
  }
}

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

int main() {
  int N, A;
  cin >> N >> A;
  int amari = N % 500;
  
  if (amari > A) {
    cout << "No" << endl;
  }
  else if (amari <= A) {
    cout << "Yes" << endl;
  }
}


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

int main() {
	int n;
	cin >> n;
	pair <int, int> a[n];
	for (int i = 0; i < n; i++) cin >> a[i].second >> a[i].first;
	sort(a, a + n);
	const int INF = 100000000;
	int dp[1010][1010];
	for (int i = 0; i < 1010; i++) {
		for (int j = 0; j < 1010; j++) {
			dp[i][j] = INF;
		}
	}
	for (int i = 0; i < 1010; i++) {
		dp[i][0] = 0;
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			if (dp[i - 1][j - 1] + a[i - 1].second > a[i - 1].first) {
				dp[i][j] = dp[i - 1][j];
			}
			else {
				dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - 1] + a[i - 1].second);
			}
		}
	}
	int ans = 0;
	for (int i = n; i >= 0; i--) {
		if (dp[n][i] != INF && dp[n][i] != 0) {
			ans = i;
			break;
		}
	}
	cout << ans << endl;
}


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

#define N 3000

int main(void) {
	bool table[N]; //table[i]がtrueならうるう年
	int a, b;
	bool first;
	bool flag; //a-b間にうるう年があったらtrue;
	
	table[0] = 1;
	for(int i = 1; i < N; ++i) {
		if(i % 4 == 0) {
			if(i % 400 == 0) {
				table[i] = true;
			} else if(i % 100 == 0) {
				table[i] = false;
			} else {
				table[i] = true;
			}
		} else {
			table[i] = false;
		}
	}
	
	
	first = true;
	while(cin >> a >> b) {
		if(a == 0 && b == 0) break;
		
		if(!first) cout << endl;
		
		flag = false;
		for(int i = a; i <= b; ++i) {
			if(table[i]) {
				cout << i << endl;
				flag = true;
			}
		}
		
		if(!flag) cout << "NA" << endl;
		
		first = false;
	}
	
	return 0;
}


Measured memory_bytes: 2984
#include <bits/stdc++.h>
//#define int long long

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

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = (int)1e9 + 7;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL x, y;
    cin >> x >> y;
    int ans = 0;
    while(x <= y){
        ans++;
        x *= 2;
    }
    cout << ans << endl;
}

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(10);

}

signed main() {
	ll n, m, a, b;
	ll ans = 0;

	cin >> n >> m;

	vector<pair<ll, ll>> v(n, make_pair(0, 0));

	REP(i, n) {
		cin >> a >> b;
		v[i] = make_pair(a, b);
	}

	sort(v.begin(), v.end());

	REP(i, n) {
		if (v[i].second < m) {
			ans += v[i].first * v[i].second;
			m -= v[i].second;
		}
		else {
			ans += v[i].first * m;
			break;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int mod=1e4+7;
const int inf=0x3f3f3f3f;
const double eps=1e-8;
//ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
map<int ,int >mp;
int a[100010];
int main(){
    int n,k;
    cin>>n>>k;
    int res=0,mn;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(i==1){
            mn=a[i];
            continue;;
        }
        if(a[i]>mn) res=max(a[i]-mn,res);
        mn=min(mn,a[i]);
    }
    if(res==0) return 0*puts("0");
    int ans=0;
    for(int i=1;i<=n;i++){
        mp[a[i]]++;
        if(mp[a[i]-res]) ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 9984
//  -- ILSH -- //
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
#define pb push_back 
#define pop pop_back
#define mp make_pair
#define ve vector
#define vii vector < int >
#define vll vector < ll > 
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpi vector < pii >
#define vpl vector < pll >
#define viii vector < vii >
#define vlll vector < vll >
#define fi first
#define sz size 
#define len length 
#define se second 
//const ll mod=998244353;
const ll mod = 1000000000+7;
const ll N=200000+6;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int a,b;
    cin>>a>>b;
    cout<<6-a-b<<'\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

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

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int k; cin >> k;
  vi a(k);

  rep(i, k) cin >> a[i];

  auto f = [&](ll x) {
    rep(i, k) x -= x % a[i];
    return x;
  };

  ll left = 0, right = 1e18;
  while (right - left > 1) {
    ll mid = (right + left) / 2;
    if (f(mid) >= 2) right = mid;
    else left = mid;
  }

  if (f(right) != 2) {
    cout << -1 << endl;
    return (0);
  }

  cout << left+1 << " ";

  left = 0, right = 1e18;
  while (right - left > 1) {
    ll mid = (right + left) / 2;
    if (f(mid) > 2) right = mid;
    else left = mid;
  }

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

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

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

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

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

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

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

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

// ---- ----

// G13E_5.cpp

const LL MOD = 1000000007;

void mat_prod(LL a[3][3], LL b[3][3], LL c[3][3]) { // a = b * c;
	static LL d[3][3];
	inc(i, 3) {
	inc(j, 3) {
		d[i][j] = (b[i][0]*c[0][j] + b[i][1]*c[1][j] + b[i][2]*c[2][j]) % MOD;
	}
	}
	
	inc(i, 3) {
	inc(j, 3) {
		a[i][j] = d[i][j];
	}
	}
}

void mat_exp(LL a[3][3], LL b[3][3], LL c) { // a = b ^ c;
	static LL t[60][3][3];
	static bool flag = true;
	
	if(flag) { // いいかげんな高速化
		inc(i, 3) {
		inc(j, 3) {
			t[0][i][j] = b[i][j];
		}
		}
		inc(i, 60 - 1) {
			mat_prod(t[i + 1], t[i], t[i]);
		}
		flag = false;
	}
	
	LL cc = c, d = 0;
	while(cc) { cc >>= 1; d++; }
	
	inc(i, 3) {
	inc(j, 3) {
		a[i][j] = 0;
	}
	}
	inc(i, 3) { a[i][i] = 1; }
	inc(i, d) {
		if((c >> i) & 1) {
			mat_prod(a, a, t[i]);
		}
	}
}

LL n, m, x[100002];

int main() {
	cin >> n >> m;
	inc1(i, m) { cin >> x[i]; }
	x[0] = 0;
	x[m + 1] = n + 1;
	
	LL a[3][3] = { { 2, 1, 1 }, { 2, 1, 0 }, { 1, 1, 1 } };
	LL b[3][3] = { { 1, 0, 0 }, { 2, 1, 0 }, { 1, 1, 1 } };
	LL c[3][3] = { { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 1 } };
	LL d[3][3];
	
	inc(i, m + 1) {
		if(i != 0) { mat_prod(c, b, c); }
		mat_exp(d, a, x[i + 1] - x[i] - 1);
		mat_prod(c, d, c);
	}
	
	cout << c[2][0] << endl;
	
	return 0;
}


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

using namespace std;

int main() {
    int h, w, k;
    cin >> h >> w >> k;

    vector<string> s(h);
    for (int i = 0; i < h; i++) {
        cin >> s[i];
    }

    vector<vector<int>> res(h, vector<int>(w, -1));
    for (int i = 0, r = 1; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (s[i][j] == '#') {
                res[i][j] = r;
                r++;
            }
        }
    }
    for (int i = 0; i < h; i++) {
        for (int j = 1; j < w; j++) {
            if (res[i][j] == -1) {
                res[i][j] = res[i][j - 1];
            }
        }
        for (int j = w - 2; j >= 0; j--) {
            if (res[i][j] == -1) {
                res[i][j] = res[i][j + 1];
            }
        }
    }
    for (int i = 0; i < w; i++) {
        for (int j = 1; j < h; j++) {
            if (res[j][i] == -1) {
                res[j][i] = res[j - 1][i];
            }
        }
        for (int j = h - 2; j >= 0; j--) {
            if (res[j][i] == -1) {
                res[j][i] = res[j + 1][i];
            }
        }
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cout << (j == 0 ? "" : " ") << res[i][j];
        }
        cout << endl;
    }
}


Measured memory_bytes: 1280
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner stdin = new Scanner(System.in);
        long n = stdin.nextLong();
        long a = stdin.nextLong();
        long b = stdin.nextLong();
        long c = stdin.nextLong();
        long d = stdin.nextLong();
        for (long i = 0; i < n; i++) {
            long max = a + i * d - (n - 1 - i) * c;
            long min = a + i * c - (n - 1 - i) * d;
            if (min <= b && b <= max) {
                System.out.println("YES");
                System.exit(0);
            }
        }
        System.out.println("NO");
    }
}


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

typedef long double ld;

int n, m, d;

int main()
{
	cin >> n >> m >> d;
	int x = n - d;
	if (d != 0) x *= 2;
	ld res = ld(x) * (m - 1) / ld(n) / ld(n);
	cout << fixed << setprecision(10) << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define double long double 
using namespace std;
typedef complex<double> P;
typedef pair<P,P> L; //Line, Segment
typedef pair<P,bool> PP;

const double EPS = 1e-8;

namespace std {
  bool operator < (const P& a, const P& b){
    return fabs(real(a)-real(b)) < EPS ? imag(a) < imag(b) : real(a) < real(b);
  }
}

double dot(P a, P b){ return real(conj(a)*b); }

double cross(P a, P b){ return imag(conj(a)*b); }

int ccw(P a, P b, P c){
  b -= a;
  c -= a;
  if(cross(b,c) > EPS) return 1;   // ????????????(b-a)????????´???????????????(c-a)????????¨?????????
  if(cross(b,c) < -EPS) return -1; // ????????????(b-a)????????´???????????????(c-a)????????¨?????????
  if(dot(b,c) < -EPS) return 2;
  if(norm(b) < norm(c)) return -2;
  return 0;
}

vector<PP> convex_hull(vector<PP> ps) {
  int n = ps.size(), k = 0;
  sort(ps.begin(), ps.end());
  vector<PP> ch(2*n);
  for (int i = 0; i < n; ch[k++] = ps[i++]) // lower-hull
    while (k >= 2 && ccw(ch[k-2].first, ch[k-1].first, ps[i].first) <= 0) --k;
  for (int i = n-2, t = k+1; i >= 0; ch[k++] = ps[i--]) // upper-hull
    while (k >= t && ccw(ch[k-2].first, ch[k-1].first, ps[i].first) <= 0) --k;
  ch.resize(k-1);
  return ch;
}

bool isIntersect(L s1, L s2){
  return ( ccw(s1.first,s1.second,s2.first) * ccw(s1.first,s1.second,s2.second) <= 0 &&
           ccw(s2.first,s2.second,s1.first) * ccw(s2.first,s2.second,s1.second) <= 0 );
}

bool check(vector<PP> v,P s,P g){
  bool res=0;
  int n=v.size();
  for(int i=0;i<n;i++)res|=isIntersect(L(v[i%n].first,v[(i+1)%n].first),L(s,g));
  return res;
}

double ref(P a,P b,P s,P g){
  double l=0,r=abs(a-b);
  int cnt=100;
  b-=a,s-=a,g-=a,b/=abs(b);
  while(cnt--){
    double m=(l+r)/2;
    P p1=m*b,p2=(m+EPS)*b;
    if(abs(s-p1)+abs(g-p1)<abs(s-p2)+abs(g-p2))r=m;
    else l=m;
  }
  b*=l;
  return abs(b-s)+abs(b-g);
}

int main(){
  double x,y;
  P s,g;
  cin>>x>>y;
  s=P(x,y);
  cin>>x>>y;
  g=P(x,y);
  int n;
  cin>>n;
  vector<PP> v;
  for(int i=0;i<n;i++)cin>>x>>y,v.push_back(PP(P(x,y),0));
  double ans=1e9;
  if(check(v,s,g)){
    v.push_back(PP(s,1));
    v.push_back(PP(g,1));
    v=convex_hull(v);
    int n=v.size();
    double sum=1e9;
    for(int i=0;i<2*n;i++){
      if(v[i%n].second)ans=min(ans,sum),sum=0;
      sum+=abs(v[i%n].first-v[(i+1)%n].first);
    }
  }
  else{
    for(int i=0;i<n;i++)
      ans=min(ans,ref(v[i].first,v[(i+1)%n].first,s,g));
  }
  printf("%.8Lf\n",ans);
  return 0;
}

Measured memory_bytes: 3388
N = int(input())
LRs = [list(map(int,input().split())) for i in range(0,N)]

L,R = zip(*LRs)
Lp = max(L)
Rq = min(R)

A = [max(0, r-Lp+1) for r in R]
B = [max(Rq-l+1, 0) for l in L]
AB = sorted(zip(A,B))
A2,B2 = zip(*AB)

mlr = max(r-l for l,r in LRs) + 1
m = max(0, Rq - Lp + 1) + mlr
mt = B2[0]
for i,a in enumerate(A2[0:-1:]):
    mt = min(mt, B2[i])
    ms = A2[i+1]
    m = max(m, ms+mt)

print(m)

Measured memory_bytes: 52708
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll N, K;
    cin >> N >> K;
    ll a = N % K;
    ll b = abs(K - a);
    if (a < b)
    {
        cout << a << endl;
    }
    else
    {
        cout << b << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,m,d,e,g,i,j,k,f,t,x,y,p,q;
long long A,B,C,X,Y,Z;
long long MIN ,ans,mid,MAX,num;
long long a[200050],b[200050],s[20000];
char str[200050];


int main()
{
    int flag=0;
    scanf("%s",str);
    n=strlen(str);
    for(i=0;i<(n-1)/2;i++)
    {
        if(str[i]!=str[n-1-i])
        {
            flag=1;
            break;
        }
    }
    if(flag) cout <<"No"<< "\n";
    else
    {
        flag=0;
        for(i=0;i<(n-1)/2;i++)
        {
            if(str[i]!=str[(n-1)/2-1-i])
            {
                flag=1;
                break;
            }
        }
        if(flag) cout <<"No"<<"\n";
        else
        {
            flag=0;
            for(i=(n+3)/2-1;i<n;i++)
            {
                if(str[i]!=str[(3*n-1)/2-i])
                {
                    flag=1;
                    break;
                }
            }
            if(flag) cout <<"No"<<"\n";
            else cout <<"Yes"<<"\n";
        }
        
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
using namespace std;
 
 
int main(){
    int n,k; cin >> n >> k;
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    int ans=0;

    rep(i,n+1)rep(j,n+1){
        if(i+j>k) continue;
        vector<int> miner;
        int tmp=0;
        rep(s,i){
            tmp+=v[s];
            if(v[s]<0) miner.push_back(v[s]);
        }
        rep(t,j){
            if(i+t+1>n) break;
            tmp+=v[n-t-1];
            if(v[n-t-1]<0) miner.push_back(v[n-t-1]);
        }
        int can=k-(i+j);
        sort(all(miner));
        rep(s,can){
            if(s>=miner.size()) break;
            tmp-=miner[s];
        }
        //cout << i << j << ' ' << tmp << endl;
        ans=max(ans,tmp);
    }
    cout << ans << endl;
return 0;
}

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

#define M 1000000007
#define MM 998244353 
#define ll long long 
#define pb push_back
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define PI 3.1415926536
#define INF 2e18
#define endl "\n"

ll power(ll b,ll e,ll m)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b%m,e/2,m)%m;
	return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b,e/2);
	return power(b*b,e/2);
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	ll h;
	cin>>h;
	ll k=log2(h);
	cout<<power(2,k+1)-1;

	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n,m;
vvi g;
vi a;

void dfs(int v){
	a[v]++;
	for(auto u:g[v]) if(!a[u]) dfs(u);
}

int main(){
	while(1){
		cin>>n>>m;
		if(!n) break;
		g=vvi(n);
		a=vi(n);
		for(int i=0;i<m;i++){
			int u,v;
			cin>>u>>v;
			u--;v--;
			g[u].push_back(v);
			g[v].push_back(u);
		}
		int t=1;
		for(int i=0;i<n;i++) if(!a[i]) dfs(i),(t*=2)%=mod;
		cout<<t+(m?1:0)<<endl;
	}
}


Measured memory_bytes: 11504
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int m = scanner.nextInt();
        int n = scanner.nextInt();
        int si = scanner.nextInt() - 1;
        int sj = scanner.nextInt() - 1;
        int ei = scanner.nextInt() - 1;
        int ej = scanner.nextInt() - 1;
        char[][] grid = new char[m][n];
        scanner.nextLine();
        for (int i = 0; i < m; i++) {
            String s = scanner.nextLine();
            for (int j = 0; j < s.length(); j++) {
                grid[i][j] = s.charAt(j);
            }
        }
        PriorityQueue<int[]> queue = new PriorityQueue<>(Comparator.comparing(i -> i[2]));
        queue.add(new int[]{si, sj, 0});
        int[][] dir = new int[][]{{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
        int[][] dp = new int[m][n];
        for (int i = 0; i < m; i++) Arrays.fill(dp[i], 100000000);
        dp[si][sj] = 0;
        while (!queue.isEmpty()) {
            int[] poll = queue.poll();
            int x = poll[0];
            int y = poll[1];
            int cost = poll[2];
            if (x == ei && y == ej) {
                System.out.println(cost);
                return;
            }
            for (int[] d : dir) {
                int nx = x + d[0];
                int ny = y + d[1];
                if (nx >= 0 && nx < m && ny >= 0 && ny < n && grid[nx][ny] != '#' && cost < dp[nx][ny]) {
                    dp[nx][ny] = cost;
                    queue.add(new int[]{nx, ny, cost});
                }
            }
            for (int i = Math.max(0, x - 2); i <= Math.min(x + 2, m - 1); i++) {
                for (int j = Math.max(0, y - 2); j <= Math.min(y + 2, n - 1); j++) {
                    if ((i == x && j == y) || (grid[i][j] == '#') || (dp[i][j] <= cost + 1)) continue;
                    dp[i][j] = cost + 1;
                    queue.add(new int[]{i, j, cost + 1});
                }
            }
        }
        System.out.println(-1);
    }
}


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

using namespace std;
using ll = long long;

const ll MOD = 1e9 + 7;

inline void normal(ll &a) { if (a >= MOD) a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) {normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) {normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) {normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; } //if MOD is prime, modPow(b, p % (MOD-1))
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

int main() {
    int n, k; scanf("%d %d", &n, &k);
    vector <ll> pos, neg;

    int z = 0;
    for (int i = 0; i < n; i++) {
        ll x; scanf("%lld", &x);
        if (x > 0) pos.push_back(x);
        if (x < 0) neg.push_back(x);
        if (x == 0) z++;
    }

    sort(pos.begin(), pos.end(), greater <ll>());
    sort(neg.begin(), neg.end());

    ll ans = 1;
    int ip = 0, jn = 0;

//    int psz = pos.size(), nsz = neg.size();
    if (k & 1) {
//        psz--;
        if (pos.empty()) {
            if (z > 0) {
                cout << 0 << endl;
                return 0;
            } else {
                reverse(neg.begin(), neg.end());
                for (int i = 0; i < k; i++) ans = modMul(ans, neg[i]);
                cout << ans << endl;
                return 0;
            }
        } else {
            ans = modMul(ans, pos[0]);
            ip++;
            k--;
        }
    }

    while (k > 0) {
        if (ip + 1 >= pos.size() and jn + 1 >= neg.size()) {
            if (ip < pos.size()) {
                ans = modMul(ans, pos[ip]);
                ip++;
                k--;
                continue;
            }

            if (z > 0) {
                cout << 0 << endl;
                return 0;
            }

            if (jn < neg.size()) {
                ans = modMul(ans, neg[jn]);
                jn++;
                k--;
                continue;
            }

        }

        if (ip + 1 >= pos.size()) {
            ll negmul = neg[jn] * neg[jn + 1];
            jn += 2;
            k -= 2;
            ans = modMul(ans, negmul);
            continue;
        }

        if (jn + 1 >= neg.size()) {
            ll posmul = pos[ip] * pos[ip + 1];
            ip += 2;
            k -= 2;
            ans = modMul(ans, posmul);
            continue;
        }

        ll posmul = pos[ip] * pos[ip + 1];
        ll negmul = neg[jn] * neg[jn + 1];

        if (posmul > negmul) {
            ans = modMul(ans, posmul);
            ip += 2;
            k -= 2;
        } else {
            ans = modMul(ans, negmul);
            jn += 2;
            k -= 2;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 5516
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	//予備
	s := Scan()
	t := Scan()
	a := iScan()
	b := iScan()
	u := Scan()
	if u == s {
		fmt.Println(a-1, b)
	} else if u == t {
		fmt.Println(a, b-1)
	} else {
		fmt.Println(a, b)
	}
}


Measured memory_bytes: 1772
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);

		while (true) {
			int n = sc.nextInt();
			if (n == 0) {
				break;
			}
			int[] x = new int[n];
			int[] y = new int[n];

			int l, r, t, b;
			l = r = t = b = 0;

			x[0] = y[0] = 0;
			for (int i = 1; i < n; i++) {
				int k = sc.nextInt();
				int d = sc.nextInt();
				int nx = x[k];
				int ny = y[k];
				if (d == 0) l = Math.min(l, --nx);
				if (d == 1) b = Math.min(b, --ny);
				if (d == 2) r = Math.max(r, ++nx);
				if (d == 3) t = Math.max(t, ++ny);
				x[i] = nx;
				y[i] = ny;
			}
			int w = r - l + 1;
			int h = t - b + 1;
			System.out.println(w + " " + h);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

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

int main()
{
  string str;
  cin >> str;
  int size1 = str.size();
  int size2 = (size1-1)/2;
  for(int i=0;i<size1/2;i++){
    if(str[i] != str[size1-1-i]){
      cout << "No" << endl;
      return 0;
    }
  }
  for(int i=0;i<size2/2;i++){
    if(str[i] != str[size2-1-i]){
      cout << "No" << endl;
      return 0;
    }
  }
  for(int i=(size1+3)/2;i<size1;i++){
    if(str[i] != str[size1-1-i]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <variant>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin>>n;
  n %= 1000;
  if (n == 0) {
    cout<<0<<endl;
  } else {
    cout<<1000-n<<endl;
  }
  return 0;
}


Measured memory_bytes: 3508
import sys

L,R = map(int,input().split())

l = L % 2019
r = R % 2019

if l >= r or R - L > 2019:
    print(0)
    sys.exit(0)

min = 2019

for i in range(l,r + 1):
    for j in range(l,r + 1):
        if i < j:
            calc = (i * j) % 2019
            if min > calc:
                min = calc

print(min)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
    vector<string> strings;
    for(int i(0); i < 3; ++i) {
        string tmp; cin >> tmp;
        strings.push_back(tmp);
    }

    string ret = "";
    for(int i(0); i < strings.size(); ++i) {
        ret += (strings.at(i)).at(0);
    }

    cout << ret << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

void koch(int n, double p1_x, double p1_y, double p2_x, double p2_y);

int main(int argc, char *argv[])
{
  int n;
  double p1[2], p2[2];

  p1[0] = 0;
  p1[1] = 0;
  p2[0] = 100;
  p2[1] = 0;

  scanf("%d", &n);

  printf("%f %f\n", p1[0], p1[1]);
  koch(n, p1[0], p1[1], p2[0], p2[1]);

  return 0;
}

void koch(int n, double p1_x, double p1_y, double p2_x, double p2_y)
{
  double s[2], t[2], u[2];
  double r3 = sqrt(3.0);

  if (n == 0) {
    printf("%f %f\n", p2_x, p2_y);
    return;
  } else {
    s[0] = p1_x + (p2_x - p1_x)/3.0;
    s[1] = p1_y + (p2_y - p1_y)/3.0;
    t[0] = p1_x + 2*(p2_x - p1_x)/3.0;
    t[1] = p1_y + 2*(p2_y - p1_y)/3.0;
    u[0] = s[0] + (-s[0] + r3*s[1] + t[0] - r3*t[1])/2.0;
    u[1] = s[1] + (-r3*s[0] - s[1] + r3*t[0] + t[1])/2.0;
    
    koch(n - 1, p1_x, p1_y, s[0], s[1]);
    koch(n - 1, s[0], s[1], u[0], u[1]);
    koch(n - 1, u[0], u[1], t[0], t[1]);
    koch(n - 1, t[0], t[1], p2_x, p2_y);
  }
}

Measured memory_bytes: 636
use std::io;
use std::str::FromStr;
use std::cmp;


fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn main(){
    let num:Vec<u32> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let num_1 = num[1] / 100;
    println!("{}", u32::pow(100, num[0])*(num[1]+num_1));
}


Measured memory_bytes: 4352
import copy

def can_empty(A,hh,ww):
    A[hh][ww],A[hh][ww+1] = A[hh][ww+1],A[hh][ww]
    while 1:
        # Fall processing
        for w in xrange(W):
            seq = ("".join(A[h][w] for h in xrange(H))).replace(".","")
            seq += "."*(H-len(seq))
            for h in xrange(H):
                A[h][w] = seq[h]

        # Banish processing
        B = [[0]*W for _ in xrange(H)]
        for h in xrange(H):
            cnt = 1
            for w in xrange(1,W):
                if A[h][w] == A[h][w-1]: cnt += 1
                else:
                    if cnt >= n and A[h][w-1] != ".":
                        for wi in xrange(w-cnt,w): B[h][wi] = 1
                    cnt = 1
            if cnt >= n and A[h][W-1] != ".":
                for wi in xrange(W-cnt,W): B[h][wi] = 1
        for w in xrange(W):
            cnt = 1
            for h in xrange(1,H):
                if A[h][w] == A[h-1][w]: cnt += 1
                else:
                    if cnt >= n and A[h-1][w] != ".":
                        for hi in xrange(h-cnt,h): B[hi][w] = 1
                    cnt = 1
            if cnt >= n and A[H-1][w] != ".":
                for hi in xrange(H-cnt,H): B[hi][w] = 1

        banish = False
        for h in xrange(H):
            for w in xrange(W):
                if B[h][w]:
                    A[h][w] = "."
                    banish = True
        if not banish: return False
        if A == goal: return True
        

# Entry point
H,W,n = map(int,raw_input().split())
_A = [list(raw_input()) for _ in xrange(H)][::-1]
goal = [["."]*W for _ in xrange(H)]
ans = False
for h in xrange(H):
    A = copy.deepcopy(_A)
    for w in xrange(W-1):
        if A[h][w] == A[h][w+1]: continue
        if can_empty(copy.deepcopy(A),h,w):
            ans = True
            break
    if ans: break
print "YES" if ans else "NO"

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

int main() {
	string ges_s[] = { "Rock", "Fire", "Scissors", "Snake", "Human", "Tree", "Wolf", "Sponge", "Paper", "Air", "Water", "Dragon", "Devil", "Lightning", "Gun" };
	int n;
	while (cin>>n,n){
		vector<int> ges;
		bool used[15] = { false };
		REP(i, n){
			string s;
			cin >> s;
			REP(j,15){
				if (s == ges_s[j]){
					ges.push_back(j);
					used[j] = true;
				}
			}
		}
		bool make[15] = { false };
		REP(i,n){
			for (int j = ges[i] + 1; j < ges[i] + 8; j++){
				make[j % 15] = true;
			}
		}
		int ans = -1;
		int used_n = 0;
		REP(i, 15){
			if (used[i])used_n++;
		}
		REP(i, 15){
			if (!make[i]&&used[i]){
				if (ans == -1){
					ans = i;
				}
				else{
					ans = -2;
				}
			}
		}
		if (ans < 0||used_n==1)
			cout << "Draw" << endl;
		else
			cout << ges_s[ans] << endl;
	}
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  int n;
  cin>>n;
  double t[n];
  double T = 0.0;
  REP(i,n){
    cin>>t[i];
    T += t[i];
  }
  double v[n+2];
  v[0] = 0;
  v[n+1] = 0;
  REPP(i,n){
    cin>>v[i];
  }
  
  double l[n+2];
  double r[n+2];
  REPP(i,n){
    if(i==1){
      l[i] = 0;
      r[i] = t[i-1];
    }else{
      l[i] = r[i-1];
      r[i] = l[i] + t[i-1];
    }
  }
  l[0] = r[0] = 0.0;
  l[n+1] = r[n+1] = T;
  
  double real_v[2*(int)T+1];
  double temp;
  REP(j,2*(int)T+1){
    REP(i,n+2){
      if(i==0){
        temp = (double)j/2.0;
      }else if(i==n+1){
        temp = min(temp,T-(double)j/2.0);
      }else{
        if((double)j/2.0 < l[i]){
          temp = min(temp, v[i]+l[i]-(double)j/2.0);
        }else if((double)j/2.0 > r[i]){
          temp = min(temp, v[i]+(double)j/2.0-r[i]);
        }else{
          temp = min(temp, v[i]);
        }
      }
    }
    real_v[j] = temp;
  }
  
  double ans = 0.0;
  double min_v;
  REP(j,2*(int)T){
    ans += 0.25*(real_v[j]+real_v[j+1]);
  }
  cout << fixed << setprecision(4) << ans << endl;
  return 0;
}


Measured memory_bytes: 512