akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int x2,y2,x3,y3,a,s=0,e=1000000000;
long long l;
int main()
{
	scanf("%lld",&l);
	while(s<=e) {
		int m=(s+e)/2;
		if((long long)(m)*m<l) s=m+1;
		else e=m-1;
	}
	a=s-1;
	if(l<=(long long)(a)*(a+1)) {
		x3=a;
		y2=a+1;
		x2=(long long)(a)*(a+1)-l;
		y3=1;
	}
	else {
		x3=y2=a+1;
		y3=1;
		x2=(long long)(a+1)*(a+1)-l;
	}
	printf("0 0 %d %d %d %d",x2,y2,x3,y3);
	return 0;
}

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

int main()
{
    int n, m;
    cin >> n >> m;
    vector< long long > a, b(m), c(m);
    map< long long, int > mp;
    for (int i = 0; i < n; i++) {
        long long A;
        cin >> A;
        if (mp.find(A) == mp.end()) {
            mp[A] = 1;
            a.push_back(A);
        } else {
            mp[A]++;
        }
    }

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

    sort(a.begin(), a.end());
    // cout << endl;
    // for (int i = 0; i < a.size(); i++) {
    //     cout << a[i] << " " << mp[a[i]] << endl;
    // }
    // cout << endl;

    for (int i = 0; i < m; i++) {
        if (mp.find(c[i]) == mp.end()) {
            a.push_back(c[i]);
            mp[c[i]] = b[i];
        } else {
            mp[c[i]] += b[i];
        }
    }

    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());

    // cout << endl;
    // for (int i = 0; i < a.size(); i++) {
    //     cout << a[i] << " " << mp[a[i]] << endl;
    // }
    // cout << endl;

    int cnt = 0;
    long long ans = 0;
    for (int i = 0; i < a.size(); i++) {
        cnt += mp[a[i]];
        if (cnt <= n) {
            ans += a[i] * mp[a[i]];
            if (cnt == n)
                break;
        } else {
            ans += a[i] * (mp[a[i]] - (cnt - n));
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define Rep(i,n) for(int i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const ll mod = 1e9+7;

int main(){
    
    int n, m;
    cin >> n >> m;
    V<bool> broken(n+1);
    rep(i,m) {
        int a;
        cin >> a;
        broken[a] = true;
    }

    ll dp[100005] = {};
    dp[0] = !broken[0];
    dp[1] = !broken[1];
    for(int i = 2; i <= n; i++) {
        if(broken[i]) continue;
        dp[i] = (dp[i-1] + dp[i-2]) % mod;
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 4352
#include <stdio.h>
int main(){
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  if (a <= b && b <= c){printf("%d %d %d\n",a,b,c);
  }else if(a <= c && c <= b){printf("%d %d %d\n",a,c,b);
  }else if(b <= a && a <= c){printf("%d %d %d\n",b,a,c);
  }else if(b <= c && c <= a){printf("%d %d %d\n",b,c,a);
  }else if(c <= a && a <= b){printf("%d %d %d\n",c,a,b);
  }else if(c <= b && b <= a){printf("%d %d %d\n",c,b,a);
  } 
 return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

int main(void){
	int32 N;
	int64 x = 0;
	int64 cnt = 0;
	cin >> N;
	REP(i, 32){
		if(x+(1LL << i) <= N){
			x += 1 << i;
			cnt++;
		}
	}
	cout << cnt << endl;
}


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

int main(){
    int h,w,n;
    cin >> h >> w >> n;
    int t;
    t=max(h,w);
    int ans;
    ans = n/t;
    if(n%t!=0)ans++;
    cout << ans << endl;
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(a) (a).begin(), (a).end()
#define forn(i,a,b) for (int i = a; i <= b; i++)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define rc(s) return cout<<s,0
#define pi pair <int, int>
#define sz(x) (int)((x).size())
#define int long long

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

const ll inf = 0x3f3f3f3f3f3f3f;
const ll mod = 1e9 + 7;
const ll INF64 = 3e18 + 1;
const int N = 2e5 + 11;

int n,h[N],C,dp[N];

struct line{
    int a,b;
    int val(int x){ return (a*x + b);}
    long double intersect(line l) { return (long double) (b - l.b) / (l.a - a); }
};

int32_t main(){
ios_base::sync_with_stdio(0); cin.tie(0); cerr.tie(0); cout.tie(0);


        cin >> n >> C;

        for(int i = 1; i <= n; i++)cin >> h[i];

        deque<line>dq;

        dq.push_back({-2*h[1], h[1]*h[1]});

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

            while(sz(dq)>=2 && dq[0].val(h[i]) >= dq[1].val(h[i]))dq.pop_front();

            dp[i] = dq.front().val(h[i]) + h[i]*h[i] + C;

            line cur = {-2*h[i], dp[i] + h[i]*h[i]};

            while(sz(dq)>=2 && cur.intersect(dq.back()) <= dq.back().intersect(dq[sz(dq)-2]))dq.pop_back();

            dq.push_back(cur);


        }

        cout << dp[n] << '\n';




return 0;
}


Measured memory_bytes: 5632
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL <<60;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}
// ここから開始
int a [502][502];
vector<pair<int,int> > v;

int main(){
  ll n;
  cin>>n;
  vector<int> v;
  for(int i = 1; i <= sqrt(n)+1; i++){
    if(n%i==0) v.push_back(i);
  }
  ll ans = 1e10;
  for(int i = 0; i < v.size(); i++){
    int t1 = log10(v[i])+1;
    int t2 = log10(n/v[i])+1;
    t1 = max(t1,t2);
    ans = min(t1,t2);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define ll long long
#define INF 0x3f3f3f3f 
#define MEM(x,y) memset(x,y,sizeof(x))
#define int long long
#define rep(i , a , b) for(int i = a ; i <= b ; i ++)
#define P pair<int,int>
#define  sc(a) scanf("%lld",&a)
#define pf(a) printf("%lld ",a)
using namespace std;
int a[200005];
signed main()
{       
   int q,w;
    sc(q);
    sc(w);
    for (int i = 0; i < q; i++)
        sc(a[i]);
    sort(a, a + q);
    int  l1 = -1e18 - 10;
    int r1 = 1e18 + 10;
    while (r1-l1>1) {
        int mid1 = (l1 + r1) / 2;
        int temp = 0;
        for (int i = 0; i < q; i++)
        {
            if (a[i] < 0) {
                int l = i, r = q;
                while (r-l>1)
                {
                    int mid = (l + r) / 2;
                    if (a[i] * a[mid] <= mid1) r = mid;
                    else l = mid;
                }
                temp += q - r;
            }
            else {
                int l = i, r = q;
                while (r-l>1)
                {
                    int mid = (l + r) / 2;
                    if (a[i] * a[mid] <= mid1) l = mid;
                    else r = mid;
                }
                temp += l - i;
            }
        }
        if (temp < w) l1 = mid1;
        else r1 = mid1;
    }
    pf(r1);

}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>
using namespace std;
typedef long long LL;

int main()
{ 
    string n;
    cin>>n;
    if(n[0]=='7'||n[1]=='7'||n[2]=='7'){
    cout<<"Yes"<<endl;}
    else{cout<<"No"<<endl;}
    return 0;
}

Measured memory_bytes: 3628
def main():
    l = input().strip().split(" ")
    n = int(l[0])
    k = int(l[1])

    h = [int(x) for x in input().strip().split(" ", n)]

    count = 0
    for x in h:
        if x >= k:
            count += 1

    print(count)


if __name__ == "__main__":
    main()


Measured memory_bytes: 11892
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

void YesNo(bool x) {
    if (x) cout << "Yes" << endl;
    else cout << "No" << endl;
}

int main() {
    string s; cin >> s;
    if (s == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <queue>
#include <tuple>
#include <stack>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define INF INT_MAX>>1 
#define SIZE 100001;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

typedef long long ll;

using namespace std;

int main(void){
	int a; cin >> a;
	cout << 3 * a * a << endl;
	return 0;
}

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

int N;
int K;
int d[200];
int A[200][200];
bool IsHave[200];

int main(){
    // 入力
    cin >> N;
    cin >> K;
    for(int i = 0;i < K;i++){

        cin >> d[i];
        for(int j =0;j < d[i];j++){
            cin >> A[i][j];
            A[i][j] -= 1;
        }

    }

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

        for(int j =0;j < d[i];j++){
            IsHave[A[i][j]] = true;
        }

    }

    int result = 0;
    for(int i = 0;i < N;i++){
        if(IsHave[i] == 0){
            result++;
        }
    }

    cout << result << endl;
}

Measured memory_bytes: 3708
from sys import stdin,stdout
def INPUT():return list(int(i) for i in stdin.readline().split())
def inp():return stdin.readline()
def out(x):return stdout.write(x)
import math
import random
J=int(1e9)+7

###############################################################################\n=17
def power(a,n):
    res=1
    while(n):
        if n&1:
            res=res*a
        a=a*a
        n//=2
        res%=J
        a%=J
    return res%J
n=int(input())
x=power(10,n)-2*power(9,n)+power(8,n)
print(x%J)



Measured memory_bytes: 76720
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B, K = MAP()

if B-A+2 <= 2*K:
	for i in range(A, B+1):
		print(i)
	exit()

for i in range(A, A+K):
	print(i)

for i in range(B-K+1, B+1):
	print(i)

Measured memory_bytes: 5200
#include <bits/stdc++.h>
using namespace std;
#define repr(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
#define mod 1000000007

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}

int main(){
    ll k,a,b;
    cin >> k >> a >> b;
    string ans="NG";
    for(int i=a;i<=b;i++){
        if(i%k==0) ans="OK";
    }
    cout << ans << endl;

    return 0;
}











Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; --i)
#define FOR(i, n, m) for (int i = m; i < n; i++)
#define MM(i, n, m) for (int i = m; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

typedef long long ll;

/**
 * C問以降は ll を使う.
 * double型にするのを忘れない.
 * nC2の求め方 (1/2)*n*(n-1)
 * vector<型> 変数名(要素数, 初期値)
 * pair<型, 型> 変数名
 * map<型, 型> 変数名  // 連想配列
 * priority_queue<型> 変数名  // 最大値から出てくるヒープ
*/
int main()
{
    int N;
    cin >> N;
    vector<int> V(N);
    vector<int> C(N);
    REP(i, N) {
        cin >> V.at(i);
    }
    REP(i, N) {
        cin >> C.at(i);
    }
    int min_x_y = 0;
    for (int bit = 0; bit < (1 << N); ++bit)
    {
        int x = 0, y = 0;
        for (int j = 0; j < N; j++) {
            if(bit & (1<<j)) {
                x += V.at(j);
                y += C.at(j);
            }
            min_x_y = max(min_x_y, x - y);
        }
    }
    cout << min_x_y << endl;
    return 0;
}

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

int main(void) {
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b + c != 17) {
        cout << "NO";
        return 0;
    }
    if ((a == 7 || a == 5) && (b == 7 || b == 5) && ( c == 7 || c == 5)) cout << "YES";
    else cout << "NO";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int  long long int
#define fi first
#define se second
#define pb push_back
#define soo(v) sort(v.rbegin(),v.rend())
#define so(v) sort(v.begin(),v.end())
#define lb(v,x) lower_bound(v.begin(),v.end(),x)
#define ub(v,x) upper_bound(v.begin(),v.end(),x)
//#define endl '\n'
#define dbv(v) cout<<endl;cout<<#v<<"-->> ";for(auto it:v){cout<<it<<" ";}cout<<endl;
#define dbm(m)cout<<endl;cout<<#m<<"-->> ";for(auto it:m){cout<<it.fi<<" "<<it.se.fi<<" "<<it.se.se<<endl;}
#define dbs(s)cout<<endl;cout<<#s<<"-->> ";for(auto it:s){cout<<it<<" ";}cout<<endl;
#define mod 1000000007
#define db1(x) cout<<#x<<"="<<x<<endl;
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl;
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<endl;
#define mx 1e18
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v)  *min_element(v.begin(),v.end())
#define double long double
#define re(s) reverse(s.begin(),s.end())
#define io std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
int powe(int x,int n)
{
  if(n==0)return 1;
  if(n%2==0)
    return powe((x%mod*x%mod)%mod,n/2)%mod;
  return (x%mod*powe((x%mod*x%mod)%mod,(n-1)/2))%mod;
}
int gcd(int A,int B)
{
  if(B==0)return A;
  return gcd(B,A%B);
}

int32_t main()
{
  io
int n;
cin>>n;
string s;
cin>>s;
vector<int>prer(n,0),preb(n,0),preg(n,0);
for(int i=n-1;i>=0;i--)
{
  if(i==n-1)
  {
    if(s[i]=='R')prer[i]=1;
    else if(s[i]=='G')preg[i]=1;
    else preb[i]=1;continue;
  }
  if(s[i]=='R')
  {
    prer[i]=prer[i+1]+1;
  }
  else
  {
    prer[i]=prer[i+1];
  }
  if(s[i]=='G')
  {
    preg[i]=preg[i+1]+1;
  }
  else
  {
    preg[i]=preg[i+1];
  }
  if(s[i]=='B')
  {
    preb[i]=preb[i+1]+1;
  }
  else preb[i]=preb[i+1];
}
//dbv(prer)
int ans=0;
for(int i=0;i<n-2;i++)
{
  for(int j=i+1;j<n-1;j++)
  {
     if(s[i]!=s[j])
     {
      
        char c='R'+'G'+'B'-s[i]-s[j];
        if(c=='R'){ans+=prer[j+1];if(2*j-i>=n)continue;if(s[2*j-i]=='R')ans--;}
        else if(c=='G'){ans+=preg[j+1];if(2*j-i>=n)continue;if(s[2*j-i]=='G')ans--;}
        else {ans+=preb[j+1];if(2*j-i>=n)continue;if(s[2*j-i]=='B')ans--;}
     }
  }
}
cout<<ans<<endl;
}

Measured memory_bytes: 3680
#include<stdio.h>

int main(void){
	int temp;
	int box[10]={0};
	int i=0;
	scanf("%d", &box[i++]);
	
	while(scanf("%d", &temp) != EOF){
	if(temp==0) printf("%d\n", box[--i]);
	else box[i++]=temp;
	};

	return (0);
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<int,ii>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)/2)
#define all(x) x.begin(),x.end()
#define inf 1000000005
#define MOD 1000000007 
#define N 300005
#define M 1000000
#define LOG 17
#define KOK 300
#define EPS 0.0000001
using namespace std;


int main() {

	int n;

	scanf("%d",&n);

	vector<int> v(n);

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

	sort(all(v));	
	
	vector<int> cnts;

	map<int,int> mp;

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

		int cur=1;

		while(i+1<n && v[i]==v[i+1]) {

			i++;
			cur++;

		}

		cnts.pb(cur);

		mp[v[i]]=cur;

	}

	if(v[0]==0) {

		if((sz(cnts)==2 && min(cnts[0],cnts[1])*2==max(cnts[0],cnts[1]) && mp[v[0]]==min(cnts[0],cnts[1])) || sz(cnts)==1) {

			printf("Yes");

		}
		else printf("No");

		exit(0);

	}

	if(sz(cnts)!=3 || cnts[0]!=cnts[1] || cnts[1]!=cnts[2] || cnts[0]!=cnts[2]) {

		printf("No");

	}
	else {
	
		int xx=0;

		for(auto x:mp) xx^=x.st;

		printf(xx?"No":	"Yes");

	}

}	

Measured memory_bytes: 4472
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int N;
string S;

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

  int tate=0,yoko=0;
  for(int i=0;i<N;i++){
    if(S[i]>='A'&&S[i]<='M') tate++;
    else if(S[i]>='N'&&S[i]<='Z') tate--;
    else if(S[i]>='a'&&S[i]<='m') yoko++;
    else yoko--;
  }

  string ans="";
  if(tate>0) ans+=string(tate,'A');
  else if(tate<0) ans+=string(-tate,'Z');

  if(yoko>0) ans+=string(yoko,'a');
  else if(yoko<0) ans+=string(-yoko,'z');

  cout<<ans.size()<<endl;
  cout<<ans<<endl;

  return 0;
}



Measured memory_bytes: 3312
R = lambda: map(int, raw_input().split())

n, d = R()
a = [R() for _ in xrange(n)]
ans = 0
for i in xrange(n):
    for j in xrange(i):
        dis = sum((a[i][k] - a[j][k]) ** 2 for k in xrange(d))
        ans += int(dis ** 0.5 + 0.1) ** 2 == dis


print ans


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

int main(){
	int n;
	int a[1000];

	cin >> n;

	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	for(int i = n - 1; i >= 0; i--){
		cout << a[i];
		if(i != 0){
			cout << " ";
		}
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 3108
// Template
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <cstring>

using namespace std;
const int MOD = 1000000007;

#define v_exists(elem, v) find(v.begin(),v.end(),elem)!=v.end()
#define s_exists(elem, s) s.find(elem)!=s.end()
#define mod_mul(x, y) x*y%MOD
#define mod_add(x, y) (x+y)%MOD
#define mod_sub(x, y) (x-y)%MOD

long gcd(long a, long b) {
    return b == 0 ? a : gcd(b, a % b);
}

long lcm( long m, long n ){
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;

    return ((m / gcd(m, n)) * n);
}


long nCr(long n, long r){
    if(n==r || r==0){
        return 1;
    } else {
        return mod_add(nCr(n-1,r),nCr(n-1,r-1));
    }
}

string s;
long long dp[100001][4];


int main(){
    cin >> s;
    
    memset(dp, 0, sizeof(dp[0][0])*100001*4);
    dp[0][0]=1;
    
    for(long i=0; i<s.length(); i++){
      for(int j=0; j<4; j++){
        
        // case dont include i th abc
        if(s[i]=='?') dp[i+1][j] = mod_add(dp[i+1][j],dp[i][j]*3);
        else dp[i+1][j] = mod_add(dp[i+1][j],dp[i][j]);     
        
      }
      
      // case when you do
        if(s[i]=='A' || s[i]=='?') dp[i+1][1] = mod_add(dp[i+1][1],dp[i][0]);
        if(s[i]=='B' || s[i]=='?') dp[i+1][2] = mod_add(dp[i+1][2],dp[i][1]);
        if(s[i]=='C' || s[i]=='?') dp[i+1][3] = mod_add(dp[i+1][3],dp[i][2]);
    }
    
    cout << dp[s.length()][3] << endl;
}

Measured memory_bytes: 3584
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
#define rep(i,n) for(i=0 ; i < (n); ++i)
#define rrep(i,n) for(i  1; i <= (n); ++i)
#define drep(i,n) for(i  (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z main.cpp
//./a.exe

bool isPrime(int x){
    int i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
int n,i,T;
int ans = INF;
 
cin >> n >> T;
int c[n],t[n];
rep(i,n){
    cin >> c[i] >> t[i];
}

rep(i,n){
    if(T>=t[i]){
        ans = min(ans,c[i]);
        
        }
        }
    

    if(ans == INF){
        cout << "TLE" << endl;
    }
    else{
        cout << ans << endl;
    }




///////////////////////////////////////////////////////
return 0;}

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

const double pi = 3.14159265358979323846;

int main(){
  int a,b;
  char op;
  while(true){
    cin >> a >> op >> b;
    switch(op){
      case '+': cout << a+b << endl; break;
      case '-': cout << a-b << endl; break;
      case '*': cout << a*b << endl; break;
      case '/': cout << a/b << endl; break;
    }
    if(op=='?') break;
  }

  return 0;
}

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

int main () {
  int n,k;
  cin >> n >> k;
  int ans=1;
  
  for(int i=0;i<n;i++){
    if(ans<=k){
      ans*=2;
    }
    else {
      ans+=k;
    }
  }
  cout << ans;
}

Measured memory_bytes: 256
// {{{ Boilerplate Code <--------------------------------------------------
// vim:filetype=cpp:foldmethod=marker:foldmarker={{{,}}}

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define ALL(A)     (A).begin(), (A).end()

using namespace std;

// }}}

int main(){
        long long N,Q;
        cin>>N>>Q;

        int sqn=sqrt(N);

        long long rev=0;

        int len[2][200000];
        int lensq[2][1000];

        FOR(i,0,N){
                len[0][i]=N-2;
                len[1][i]=N-2;
        }

        FOR(i,0,N){
                lensq[0][i]=N-2;
                lensq[1][i]=N-2;
        }

        FOR(i,0,Q){
                int dir,x;
                cin>>dir>>x;
                --dir;

                int opdir=1-dir;
                int sqx=x/sqn;

                int now=min(len[dir][x],lensq[dir][sqx]);

                rev+=now;

                now+=2;
                FOR(j,0,now/sqn){
                        lensq[opdir][j]=min(lensq[opdir][j],x-2);
                }
                FOR(j,(now/sqn)*sqn,now){
                        len[opdir][j]=min(len[opdir][j],x-2);
                }

        }


        cout<<(N-2)*(N-2)-rev<<endl;
}


Measured memory_bytes: 5104
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,k,n) for (ll i = k; i < n; ++i)
#define inputar(a,n) ll a[n];rep(i,0,n)cin>>a[i]
#define PI 3.14159265
const int MOD=1e9+7;
const int N=1e5+5;


#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a)  (a).begin(),(a).end()

#define test4(x,y,z,a) cerr<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
#define test3(x,y,z) cerr<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
#define test2(x,y) cerr<<"x is "<<x<<"		y is "<<y<<endl;
#define test1(x) cerr<<"x is "<<x<<endl;

ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 


int main()
{
    IOS;
    ll x,y,z,k;
    cin>>x>>y>>z>>k;
    ll a[x+10],b[y+10],c[y+10];
    vector<ll>v;
    for(int i=0;i<x;i++)
    {
        cin>>a[i];
    }
    for(int i=0;i<y;i++)
    {
        cin>>b[i];
    }
    for(int i=0;i<z;i++)
    {
        cin>>c[i];
    }
    sort(a,a+x,greater<ll>());
    sort(b,b+y,greater<ll>());
    sort(c,c+z,greater<ll>());
    for(int i=0;i<x;i++)
    {
        for(int j=0;j<y;j++)
        {
            for(int jj=0;jj<z;jj++)
            {
                if((i+1)*(j+1)*(jj+1)<=k)
                {
                    v.pb(a[i]+b[j]+c[jj]);
                }
            }
        }
    }
    sort(all(v),greater<ll>());
    for(int i=0;i<k;i++)
    {
        cout<<v[i]<<endl;
    }


    

}

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

class DisjointSet {
  public:
    vector<int> p;

  DisjointSet(int n){
    p = vector<int>(n, -1);
  }

  int root(int x){
    if ( p[x] < 0) return x;
    p[x] = root(p[x]);
    return p[x];
  }

  int size(int x){
    return -p[root(x)];
  }

  bool connect(int x, int y){
    x = root(x);
    y = root(y);
    if ( x == y){
      return false;
    }
    if ( size(x) < size(y))swap(x, y);
    p[x] += p[y];
    p[y] = x;
    return true;
  }
};

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

  long long ans[m];
  ans[m-1] = (long long)n * (n-1) / 2;
  DisjointSet ds = DisjointSet(n+1);
  for ( int i = m-1; i >= 1; i--){
    if ( ds.root(a[i]) != ds.root(b[i])){
      ans[i-1] = ans[i] - (long long)ds.size(a[i]) * ds.size(b[i]);
      ds.connect(a[i], b[i]);
    }
    else ans[i-1] = ans[i];
  }

  for ( int i = 0; i < m; i++){
    cout << ans[i] << endl;
  }

  return 0;
}


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

int main() {
	
	int n,m;
	cin>>n>>m;
	
	int res = n/((2*m)+1);
	if(n%(((2*m)+1)) ==0) cout<<res<<endl;
	else		  cout<<++res<<endl;
	return 0;
}

Measured memory_bytes: 256
#ifndef _WIN32
#include<iostream>
#endif

#include <complex>
#include <vector>
#include <utility>
#include <tuple>
using namespace std;


#define FOR(i,bg,ed) for(int i = (bg);<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back

#define IL inline
namespace geo{
	typedef double D;
	typedef bool B;
	typedef complex<D> P;
#define X real()
#define Y imag()
	B comp(const P& l, const P& r)
	{
		return (l.X == r.X) ? l.Y < r.Y : l.X < r.X;
	}
	typedef pair<P, P> L;
	typedef pair<P, P> LS;
	typedef pair<P, D> C;
	typedef vector<P> Poly;
	const D EPS = 1e-8;

	//Decomposition Macro
#define DCI(a,b,l) P(a),(b);tie(a,b)=l;
#define DCc(a,b,c) P(a);D(b);tie(a,b)=c;

	//A dot B
	IL D dot(P a, P b)
	{
		return a.X*b.X + a.Y*b.Y;
	}
	IL D cross(P a, P b)
	{
		return a.X*b.Y - a.Y*b.X;
	}
	IL D ccw(P a, P b, P c)
	{
		return cross(b - a, c - a);
	}

	IL int sgn(P a, P b, P c){
		if (cross(b - a, c - a) > EPS)return 1;
		if (cross(b - a, c - a) < -EPS)return -1;
		if (dot(b - a, c - a) < -EPS)return 2;
		if (dot(a - b, c - b) < -EPS)return -2;
		return 0;
	}
	IL D signed_distance_P_L(P p, L l){
		DCI(a, b, l);
		return cross(b - a, p - a) / abs(b - a);
	}
	IL D dinstance_P_L(P p, L l){
		return abs(signed_distance_P_L(p, l));
	}
	IL D distance_P_LS(P p, LS ls){
		DCI(a, b, ls);
		if (dot(b - a, p - a) < EPS)return abs(p - a);
		if (dot(a - b, p - b) < EPS)return abs(p - b);
		return abs(cross(b - a, p - a)) / abs(b - a);
	}

	IL B is_L_L(L p, L q){
		DCI(a, b, p);
		DCI(c, d, q);
		return abs(cross(a - b, c - d))>EPS ||
			abs(cross(a - b, d - b)) < EPS; 
	}
	IL B is_LS_LS(LS p, LS q){
		DCI(a, b, p);
		DCI(c, d, q);
		return sgn(a, b, c) * sgn(a, b, d) <= 0 &&
			sgn(c, d, a) * sgn(c, d, b) <= 0;
	}
}

using namespace geo;


int main()
{
	int n;

	cin >> n;
	while (n--){
		D x1, x2, x3, y1, y2, y3, x4, y4;

		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
		P a(x1 - x2, y1 - y2), b(x3 - x4, y3 - y4);

		P p(x1,y1),q(x2,y2),r(x3,y3),s(x4,y4);

		if (is_LS_LS({ p, q }, { r, s })){
			cout << 1 << endl;
			continue;
		}
		else{
			cout << 0 << endl;
			continue;
		}
	}
	return 0;
}

Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
int p[200];
int main() {
    int m,n_min,n_max;
    while(scanf("%d %d %d",&m,&n_min,&n_max),m) {
        for(int i=0;i<m;i++) {
            scanf("%d",&p[i]);
        }
        int max_gap=0;
        int ans=0;
        for(int i=n_min;i<=n_max;i++) {
            if(p[i-1]-p[i]>=max_gap) {
                max_gap=p[i-1]-p[i];
                ans=i;
            }
        }
        printf("%d\n",ans);
    }
}

Measured memory_bytes: 3136
S=input()
while True:
  if S=='':
    print('YES')
    break
  else:
    a = S[-5:] in ('dream', 'erase')
    b = S[-6:] in ('eraser')
    c = S[-7:] in ('dreamer')
    if not (a or b or c):
      print('NO')
      break
    elif a:
      S = S[:-5]
    elif b:
      S = S[:-6]
    elif c:
      S = S[:-7]

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

using namespace std;

typedef long long int LL;

#define st first
#define nd second
#define PLL pair <LL, LL>
#define PII pair <int, int>

const int N = 1e6 + 7;
const int MX = 1e9 + 7;
const LL INF = 1e18 + 9LL;

int main(){
	int h1, h2, m1, m2, k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	
	int diff = (h2 - h1) * 60 + m2 - m1;
	printf("%d\n", max(diff - k, 0));
	return 0;
}

Measured memory_bytes: 3692
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
//#include <bits/stdc++.h>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "Yes" : "No";
}



int main(){
    int n;cin >> n;
    
    int t[n+10],x[n+10],y[n+10];
    t[0] = x[0] = y[0] = 0;
    
    rep1(i,n) cin >> t[i] >> x[i] >> y[i];
    
    bool ans = true;
    for(int i=0; i<n;i++){
        int dt = t[i+1]-t[i];
        int dx = abs(x[i+1]-x[i]);
        int dy = abs(y[i+1]-y[i]);
        
        if(dt < dx+dy or dt%2 != (dx+dy)%2) {
            ans = false;
            break;
        }
    }
    
    cout << yn(ans) << endl;
}



Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    int a,b,c,x;
    cin>>a>>b>>c>>x;
    int cnt=0;
    rep(i,a+1)rep(j,b+1)rep(k,c+1){
        if(i*500+100*j+50*k==x) ++cnt;
    }
    cout<<cnt<<endl;
    return 0;
}

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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define lfs <<fixed<<setprecision(10)<<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>v,ll n){cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
template<typename T>
void emp(map<T,ll>&m, T x){m.emplace(x,0).first->second++;}

int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll n;cin>>n;
  cout<<n*(n-1)/2<<endl;
  return 0;
}

Measured memory_bytes: 256
# include<stdio.h>

int main(void)
{
  char ch;
  int count[26]={},i;
  while(scanf("%c",&ch)!= EOF)
    {
      if('a' <= ch && ch <= 'z'){count[ch-'a']++;}
      else if('A'<= ch && ch <= 'Z'){count[ch-'A']++;}
    }
  for(i=0;i<26;i++)
    {printf("%c : %d\n",i+'a',count[i]);}
  return 0;
}

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

priority_queue<int> L;
priority_queue<int, vector<int>, greater<>> R;
ll sz, L_sum, R_sum, B;

signed main() {

    int Q;
    cin >> Q;

    function<void(int)> L_push = [&] (int val) { L_sum += val; L.push(val); ++sz; };
    function<void()>    L_pop  = [&] ()        { L_sum -= L.top(); L.pop(); --sz; };
    function<void(int)> R_push = [&] (int val) { R_sum += val; R.push(val); ++sz; };
    function<void()>    R_pop  = [&] ()        { R_sum -= R.top(); R.pop(); --sz; };

    while (Q--) {
        int q;
        cin >> q;
        if (q == 1) {
            int a, b;
            cin >> a >> b;
            if (sz == 0) {
                L_push(a);
            } else if (sz % 2 == 1) {
                int val = L.top();
                if (val > a) {
                    L_pop();
                    L_push(a);
                    R_push(val);
                } else {
                    R_push(a);
                }
            } else {
                int val = R.top();
                if (a > val) {
                    R_pop();
                    R_push(a);
                    L_push(val);
                } else {
                    L_push(a);
                }
            }
            B += b;
        } else if (q == 2) {
            int L_sz = (sz + 1) / 2;
            int R_sz = sz / 2;
            int mid = L.top();
            ll ans = B;
            ans += R_sum - (ll)mid * R_sz;
            ans += (ll)mid * L_sz - L_sum;
            cout << mid << ' ' << ans << endl;
        }
    }

}

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

int main() {
  char c;
  cin >> c;
  for (auto x : {'a','i','u','e','o'}) {
    if (c == x) { cout << "vowel" << endl; return 0; }
  }
  cout << "consonant" << endl;
}

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

int n;

void dfs(string s, char mx){
  if(s.size() == n){
    cout << s << endl;
    return;
  }
  for(char c = 'a'; c <= mx+1; c++){
    string t = s;
    t += c;
    dfs(t, max(c, mx));
  }
}

int main(){
  cin >> n;
  dfs("", 'a'-1);
  return 0;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) (long long)((a).size())
const double pi = 3.14159265358979323846;

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	
    ll i,j,n;
    cin>>n;
    vector<ll> a(n);
    map<ll,ll> mp;
    for(i=0;i<n;i++) cin>>a[i],mp[a[i]]++;
    sort(all(a));
    vector<bool> dp(a[n-1]+1, true);
    for(i=0;i<n;i++)
    {
        if(mp[a[i]]>1) dp[a[i]]=false;
        ll j = 2;
        while(a[i]*j<=a[n-1]) {dp[a[i]*j] = false;j++;}
    }
    ll ans = 0;
    for(i=0;i<n;i++)
    {
        if(dp[a[i]]==true) ans++;
    }
    cout<<ans;
}

Measured memory_bytes: 17576
from bisect import bisect_left
n = int(input())
a = sorted(list(map(int, input().split())))
r = bisect_left(a, a[-1]/2)
l = r-1 if r else 0
if abs(a[-1]/2 - a[l]) > abs(a[-1]/2 - a[r]):
    l,r = r,l
print(a[-1],a[l])

Measured memory_bytes: 14052
R=range
def F(a,b):A=len(a);return[all([len(set([a[i+j],b[j],'?']))<3for j in R(min(A-i,len(b)))])for i in R(A)]+[1]
def Z(X):
 i,j,k=X;A,B,C=[len(S[t])for t in X];q=1e5
 for l in R(A+1):
  if M[i][j][l]:
   for r in R(l,A+B+1):
    if(B<r-l or M[j][k][r-l])*M[i][k][min(A,r)]:q=min(q,max(A,l+B,r+C))
 return q
S=[input()for i in R(3)]
M=[[F(i,j)for j in S]for i in S]
from itertools import*;print(min([Z(i)for i in permutations(R(3))]))

Measured memory_bytes: 54236
#include <stdio.h>
#include <string.h>
#define MAX 1001

typedef struct{
  char X[MAX];
  char Y[MAX];
}Shuto;


int main()
{
  int n,xl,yl,i,j,k,c[MAX][MAX];

  scanf("%d",&n);
  if(n < 1 || n > 150)exit(1);

  Shuto kumi[n];

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

      scanf("%s",&kumi[i].X);
      scanf("%s",&kumi[i].Y);
    }

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

      xl = strlen(kumi[i].X);
      yl = strlen(kumi[i].Y);

      c[0][0] = 0;

      for(j = 1 ; j <= xl ; j++)c[j][0] = 0;
      for(j = 1 ; j <= yl ; j++)c[0][j] = 0;

      for(j = 1 ; j <= xl ; j++)
	{
	  for(k = 1 ; k <= yl ; k++)
	    {
	      if(kumi[i].X[j-1] == kumi[i].Y[k-1])
		{
		  c[j][k] = c[j-1][k-1] + 1;
		}
	      else if(c[j-1][k] >= c[j][k-1])
		{
		  c[j][k] = c[j-1][k];
		}
	      else
		{
		  c[j][k] = c[j][k-1];
		}
	    }
	}

      printf("%d\n",c[xl][yl]);
    }

  return 0;
}



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

using ll = long long;
#define REP(i, n) for(int (i)=0; (i)< (n); ++i)
#define REPR(i, n) for(int (i)=(n); (i)>=0; --i)
#define FOR(i, n, m) for(int (i)=(n); (i)<(m); ++i)
constexpr int INF = 1e9;
//constexpr ll INF = 1LL << 62;
constexpr int mod = 1e9+7;

ll N, A, B;
vector<ll> h;
bool isOk(ll key){
  ll damage = B * key;
  ll diff = A - B;
  ll cnt = 0;
  REP(i, N){
    ll hp = h[i] - damage;
    if(hp<= 0) continue;
    ll d = (hp+diff-1) / diff;
    cnt += d;
  }
  return cnt <= key; 
}
int lower_bound(){
  int ok = INF, ng = 0;
  while(abs(ok-ng)>1){
    int mid = (ok+ng) /2;
    if(isOk(mid)){
      ok = mid;
    }
    else{
      ng = mid;
    }
  }
  return ok;
}
int main(){
  cin >> N >> A >> B;
  h.resize(N);
  REP(i, N){
    cin >> h[i];
  }
  sort(h.rbegin(), h.rend());
  int ans = lower_bound();
  cout << ans << endl;  
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (a[i]%2 == 1) {
      cnt++;
    }
  }
  if (cnt%2 == 0) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
  return 0;
}

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

int n, m;
int a[23];
bool b[23];
bool fl = 1;

int main() {
	cin >> n >> m;
	while(m--) {
		int x, y;
		cin >> x >> y;
		if(a[x] != 0 && a[x] != y) {
			fl = 0;
			break;
		}
		a[x] = y;
		b[x] = 1;
	}
	if(!fl) {
		cout << "-1";
		return 0;
	}
	if(n != 1 && !a[1]) {
		if(b[1]) {
			cout << "-1";
			return 0;
		}
		else a[1] = 1;
	}
	for(int i = 1; i <= n; ++i)
		cout << a[i];
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a;
  cin>>a;
  int b=0;
  vector<int> vec(a);
  for(int i=0;i<a;i++){
    cin>>vec.at(i);
    if(i%2==0&&vec.at(i)%2==1){
      b+=1;
    }
  }
  cout<<b;
}

    

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N, K;
    cin >> N >> K;
    long long cnt[100001];
    fill_n(cnt, 100001, 0LL);
    for(int i=0; i<N; i++){
        long long a, b;
        cin >> a >> b;
        cnt[a] += b;
    }
    long long k = 0;
    for(int i=0; i<=100000; i++){
        k += cnt[i];
        if(k >= K){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 1024
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int r = sc.nextInt();

    BigDecimal l = new BigDecimal(r);
    BigDecimal ret = l.multiply(new BigDecimal(2))
        .multiply(new BigDecimal("3.141592"))
        .divide(new BigDecimal(100), 4, RoundingMode.DOWN)
        .multiply(new BigDecimal(100));

    System.out.println(ret.toString());
  }
}


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

targ = N
while targ > 1:
    l = 0
    r = targ
    #
    while l < r:
        m = l + (r - l) // 2
        # print("#", targ, (l, r), m * (m - 1) // 2, targ - m)
        if m * (m - 1) // 2 >= targ - m:
            r = m
        else:
            l = m + 1
    #
    print(l)
    targ -= l

if targ > 0: print(targ)

Measured memory_bytes: 3316
S = str(input())
ans = [0] * len(S)
flag = -1
ch = 0
for i in range(1, len(S)):
  if S[i-1] == "R" and S[i] == "L":
    flag = i
  if (S[i-1] == "L" and S[i] == "R") or i == len(S)-1:
    if i == len(S)-1:
      i = len(S)
    a = i - ch
    ans[flag-1] = a//2 + (flag-ch) % 2 * (a%2)
    ans[flag] = a//2 + (i-flag) % 2 * (a%2)
    ch = i
print(*ans)

Measured memory_bytes: 6400
#include <cstdio>
#include <cctype>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <stdexcept>

#define fprintf(...) void(0)

const std::string chs="01+-*()";

bool next_assignment(std::vector<size_t> &d) {
  for (size_t i=d.size(); i--;) {
    if (d[i] < 6) {
      ++d[i];
      return true;
    }
    d[i] = 0;
  }
  return false;
}

int apply(int lhs, char op, int rhs) {
  if (op == '+') {
    lhs += rhs;
  } else if (op == '-') {
    lhs -= rhs;
  } else if (op == '*') {
    lhs *= rhs;
  }
  if (!(0 <= lhs && lhs < 1024))
    throw std::logic_error("overflow");

  return lhs;
}

int parse(
    const std::string &s, size_t &i, size_t preced=0) {

  static const std::vector<std::string> ops={"+-", "*"};

  if (preced == ops.size()) {
    if (s[i] == '(') {
      fprintf(stderr, "starting from %zu\n", i);
      size_t j=i;
      parse(s, ++j, preced);
      int res=parse(s, ++i);
      if (!(i < s.length() && s[i] == ')'))
        throw std::logic_error("mismatch parentheses");
      fprintf(stderr, "i: %zu, j: %zu\n", i, j);
      if (i == j)
        throw std::logic_error("redundant parentheses");
      ++i;
      return res;
    }
    if (isdigit(s[i])) {
      int res=s[i]-'0';
      while (++i < s.length() && isdigit(s[i])) {
        res = res*2+s[i]-'0';
        if (res >= 1024) throw std::logic_error("overflow");
      }
      return res;
    }
    throw std::logic_error("unexpected");
  }

  int res=parse(s, i, preced+1);
  while (i < s.length()) {
    char op=s[i];
    if (!std::count(ops[preced].begin(), ops[preced].end(), op)) break;
    int tmp=parse(s, ++i, preced+1);
    res = apply(res, op, tmp);
  }
  return res;
}

int parse(const std::string &s, std::vector<size_t> &d) {
  std::string t;
  size_t i=0;
  for (char ch: s) {
    if (ch == '.') {
      t += chs[d[i++]];
      continue;
    }
    t += ch;
  }
  i = 0;
  fprintf(stderr, "%s\n", t.c_str());
  int res=parse(t, i);
  fprintf(stderr, "[%zu]\n", i);
  if (i < t.length())
    throw std::logic_error("garbage");
  return res;
}

int main() {
  char buf[128];
  scanf("%s", buf);
  std::string s=buf;
  size_t dot=std::count(s.begin(), s.end(), '.');
  std::vector<size_t> d(dot);

  int res=-1;
  do {
    try {
      res = std::max(res, parse(s, d));
    } catch (std::logic_error &e) {
      fprintf(stderr, "failed: %s\n", e.what());
    }
  } while (next_assignment(d));
  printf("%d\n", res);
}



Measured memory_bytes: 3044
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
static const int INF (1<<30);

bool isPrime(ll x) {
  if (x <= 2LL) return true;

  if (x % 2 == 0) return false;

  ll i = 3LL;
  while (i <= sqrt(x)) {
    if (x % i == 0) return false;
    i = i + 2;
  }

  return true;
}

int main() {
  ll A, B; cin >> A >> B;
  set<ll> ca, cb;
  ca.insert(1LL);
  cb.insert(1LL);

  ll i = 2LL;
  ll lim = sqrt(A);
  bool added = false;
  while (i <= lim) {
    if (A % i == 0) {
      ca.insert(i);
      ca.insert(A/i);
      A /= i;
      added = true;
      //i++;
      continue;
    } else {
      i++;
    }
  }
  if (!added) ca.insert(A);

  i = 2LL;
  lim = sqrt(B);
  added = false;
  while (i <= lim) {
    if (B % i == 0) {
      cb.insert(i);
      cb.insert(B/i);
      B /= i;
      added = true;
      //i++;
      continue;
    } else {
      i++;
    }
  }
  if (!added) cb.insert(B);

  int ans = 0;
  for (auto x : ca) {
    if (isPrime(x) && cb.count(x) == 1) ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define SIZE_OF_ARRAY(ar) (sizeof(ar)/sizeof(ar[0])) 
int main(){
  int h,w,n,a=0;
  cin>>h>>w>>n;
  int hw[h][w];
  int m[n];
  rep(i,n)
     cin>>m[i];
  rep(i,h)rep(j,w){
     if(!m[a])
       a++;
     hw[i][j]=a+1;
     m[a]--; 
  }
  rep(i,h/2+h%2)
    reverse(hw[i*2],hw[i*2]+SIZE_OF_ARRAY(hw[i*2]));
  rep(i,h){
    rep(j,w)
      printf("%d ",hw[i][j]);
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define debug(x) cerr<<#x<<": "<<x<<endl;
#define MOD 1000000007ULL;
#define rep(i,n) for(int i=0;i<n;i++)


int main() {
	ll L,R,d;
  	cin>>L>>R>>d;
  	
  	
  
  	cout<<R/d-(L-1)/d  <<endl;
}

Measured memory_bytes: 3564