akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for (int i = (a); i <= (b); ++i)
#define REPD(i,a,b) for (int i = (a); i >= (b); --i)
#define FORI(i,n) REP(i,1,n)
#define FOR(i,n) REP(i,0,int(n)-1)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define SZ(x) int((x).size())
#define DBG(v) cerr << #v << " = " << (v) << endl;
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define fi first
#define se second

const int N = 200200;

int n,m[2];
vi g[N];
int vis[2][N];

void dfs(int u, int q, int c) {
	vis[q][u] = c;
	FOR(i,SZ(g[u])) if (!vis[q][g[u][i]]) dfs(g[u][i], q, c);
}

map<pii, int> M;

void test() {
	int c=0;
	scanf("%d%d%d", &n, &m[0], &m[1]);
	FOR(q,2) {
		FOR(i,n) g[i].clear();
		FOR(i,m[q]) {
			int a,b;
			scanf("%d%d", &a, &b);
			a--; b--;
			g[a].push_back(b);
			g[b].push_back(a);
		}
		FOR(i,n) if (!vis[q][i]) dfs(i, q, ++c);
	}
	FOR(i,n) M[mp(vis[0][i], vis[1][i])]++;
	FOR(i,n) printf("%d ", M[mp(vis[0][i], vis[1][i])]);
	printf("\n");
}

int main() {
	int ttn=1;
	//scanf("%d", &ttn);
	while (ttn--) test();
	return 0;
}


Measured memory_bytes: 22272
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define mod 1000000007ll
#define mod1 998244353ll
#define endl '\n'
#define inf ((ll)1e18+1)
#include<chrono>
using namespace chrono;
mt19937_64 rng(high_resolution_clock::now().time_since_epoch().count());
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define debr(x,y) {cout<<"-->  "<<#x<<" to "<<#y<<" :  "; auto itr=x; while(itr!=y) cout<<(*itr++)<<' '; cout<<endl; }
#define deba(x) {cout<<"-->  "<<#x<<" :  "; for(auto ele:(x)) cout<<ele<<"  "; cout<<endl; }
#define deb(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s);istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout<<endl;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a <<"  ,  ";
    err(++it, args...);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n,k;
    cin>>n>>k;
    vector<ll> ar(n);
    for(ll x=0;x<n;x++){
        cin>>ar[x];
    }
    for(ll x=k;x<n;x++){
        if(ar[x]>ar[x-k]){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }
    return 0;

}


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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)
#define VAR(Type, ...) Type __VA_ARGS__; IN(__VA_ARGS__)

#ifdef DEBUG
#define dump(...) _dump(#__VA_ARGS__, __VA_ARGS__);
#else
#define dump(...)
#endif

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// IN
void IN() {}
template <class Head, class... Tail>
void IN(Head&& head, Tail&&... tail) {
  cin >> head;
  IN(forward<Tail>(tail)...);
}

// OUTS
void OUTS() {}
template <class Head, class... Tail>
void OUTS(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  OUTS(forward<Tail>(tail)...);
}

template <class T>
void OUTS(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void OUTS(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// OUTL
void OUTL() {}
template <class Head, class... Tail>
void OUTL(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  OUTL(forward<Tail>(tail)...);
}

template <class T>
void OUTL(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// OUTN
void OUTN() {}
template <class Head, class... Tail>
void OUTN(Head&& head, Tail&&... tail) {
  cout << head;
  OUTN(forward<Tail>(tail)...);
}

template <class T>
void OUTN(vector<T> &vec) { for (auto &e : vec) cout << e; }

// DEGUG
template <class T>
void _dump(const char *s, T&& x) {
  clog << '{';
  while(*s != '\0') clog << *(s++);
  clog << ": " << x << '}' << "\n";
}

template <class Head, class... Tail>
void _dump(const char *s, Head&& head, Tail&&... tail) {
  clog << '{';
  while(*s != ',') clog << *(s++);
  clog << ": " << head << "}, ";
  for (++s; !isgraph(*s); ++s);
  _dump(s, forward<Tail>(tail)...);
}
// }}} End

string s, t;

bool isIt(int i) {
  for (int j = 0; j < t.length(); ++j) {
    if (s[j+i] != t[j] && s[j+i] != '?') return false;
  }
  return true;
}

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

  IN(s, t);

  if (s.length() < t.length()) {
    OUTL("UNRESTORABLE"); return 0;
  }

  for (int i = s.length() - t.length(); i >= 0; --i) {

    if (isIt(i)) {
      rep(j, s.length()) s[j] = (s[j] == '?' ? 'a' : s[j]);
      rep(j, t.length()) s[i+j] = t[j];

      OUTL(s);
      return 0;
    }
  }

  OUTL("UNRESTORABLE");
  return 0;
}


Measured memory_bytes: 256
#include <queue>
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>

using namespace std;

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

#include <complex>

typedef double D;
typedef complex<D> P;
typedef pair<P, P> L;
typedef vector<P> VP;

#define X real()
#define Y imag()

const D EPS = 1e-9;
const D INF = 1e12;

#define EQ(n,m) (abs((n) - (m)) < EPS)
#define EX P(INF,INF)

D cs(P a, P b) {
	return (conj(a) * b).Y;
}

D dt(P a, P b) {
	return (conj(a) * b).X;
}

int ccw(P a, P b, P c) {
	b -= a, c -= a;
	if (cs(b, c) > EPS)return 1;
	if (cs(b, c) < -EPS)return -1;
	if (dt(b, c) < -EPS)return +2;
	if (norm(b) < norm(c))return -2;
	return 0;
}

P cpLL(P a1, P a2, P b1, P b2) {
	D d1 = cs(b2 - b1, b1 - a1);
	D d2 = cs(b2 - b1, a2 - a1);
	if (EQ(d2, 0))return EX;
	return a1 + d1 / d2 * (a2 - a1);
}

bool isor(P a1, P a2, P b1, P b2) {
	return EQ(dt(a1 - a2, b1 - b2), 0.0);
}
bool ispa(P a1, P a2, P b1, P b2) {
	return EQ(cs(a1 - a2, b1 - b2), 0.0);
}

int main() {
	int n;
	cin >> n;
	VP v;
	D tx = 0.0, ty = 0.0;
	rep(i, n) {
		D x, y;
		cin >> x >> y;
		v.push_back(P(x, y));
		tx += x; ty += y;
	}
	tx /= double(n), ty /= double(n);
	if (n % 2) {
		cout << "NA" << endl;
		return 0;
	}
	int h = n / 2;
	rep(i, h) {
		L l0 = L(v[i], v[i + 1]);
		L l1 = L(v[(i + h) % n], v[(i + h + 1) % n]);
		
		double dist0 = abs(l0.first - l0.second);
		double dist1 = abs(l1.first - l1.second);

		if (!EQ(dist0, dist1) ||
			!ispa(l0.first, l0.second, l1.first, l1.second)) {
			cout << "NA" << endl;
			return 0;
		}
	}
	cout << fixed << setprecision(30) << tx << " " << ty << endl;

	return 0;
}

Measured memory_bytes: 3340
#include <iostream>
#include <cstdlib>
#include <string>
using namespace std;
#define numof(array) (sizeof(array)/sizeof *(array))

bool InputAndSearch(int* pnData, int nNumOf);
int BinSearch(int *sData,int n,int* tData,int q);

int main()
{
    int s[100000],t[100000];
	int n,q;

	cin>>n;
	for(int i=0;i<n;i++) cin>>s[i];//*(sData+i)ともかけたはず
	
	cin>>q;
	for(int i=0;i<q;i++) cin>>t[i];

	cout<<BinSearch(s,n,t,q)<<endl;


    
}

int BinSearch(int *sData,int n,int* tData,int q){
	int first,last;
	int cnt=0;
	int comp;//比較要素
	
	
	for(int j=0;j<q;j++){
	   first=0;
	   last=n-1;

		while((last-first)>=0){
			comp=(first+last)/2;
			if(tData[j]==sData[comp]){
				
				cnt++;
				break;
			}
			else if(tData[j]<sData[comp]){//求めたい数より小さい場合
				last=comp-1;
			}
			else{
				first=comp+1;
			}
			
		}


	}

	return cnt;
}



Measured memory_bytes: 3652
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"


int main() {
	int D, L; cin >> D >> L;
	int ans = D / L + (D%L);
	cout << ans << endl;
}

Measured memory_bytes: 3080
using System;

public class Program
{
    private int N;
    private int[] A, B;
    private int[] Diff;

    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        A = sc.IntArray();
        B = sc.IntArray();
        Diff = new int[N];
        for (int i = 0; i < N; i++)
        {
            Diff[i] = A[i] - B[i];
        }

        Array.Sort(Diff);
        int ans = 0;

        long minus = 0;


        for (int i = 0; i < N; i++)
        {
            if (Diff[i] < 0)
            {
                minus += -Diff[i];
                ans++;
            }
            else
            {
                break;
            }
        }

        long plus = 0;

        for (int i = N - 1; i >= 0; i--)
        {
            if (plus >= minus)
            {
                Console.WriteLine(ans);
                return;
            }

            if (Diff[i] > 0)
            {
                plus += Diff[i];
                ans++;
            }
            else
            {
                Console.WriteLine(-1);
                return;
            }
        }
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

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

using namespace std;

//typedefリスト
typedef vector<int> vint;
typedef vector<string> vstr;




int main(void) {
	int N,Acou,Bcou;
	Acou = 0;
	Bcou = 0;
	string s;
	cin >> N;
	cin >> s;
	for (int i = 0; i < N; i++) {
		if (s[i] == 'R')Acou++;
		else Bcou++;
	}
	if (Acou > Bcou)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll n;cin>>n;
    double arr[n+1];
    for(ll i=1;i<=n;i++)
        cin>>arr[i];
    double dp[n+1][n+1];

    memset(dp,0.0,sizeof(dp));

    dp[0][0]=1.0;

    for(ll i=1;i<=n;i++)
    {
        for(ll j=0;j<=n;j++)
        {
            if(j==0)
                dp[i][j]=(1.0-arr[i])*dp[i-1][j];
            else
            {
                dp[i][j]=arr[i]*dp[i-1][j-1]+(1.0-arr[i])*dp[i-1][j];
            }
        }
    }
    double ans=0.0;
    for(ll i=(n/2)+1;i<=n;i++)
    {
        ans+=dp[n][i];
    }
    cout<<setprecision(9)<<ans<<endl;
}


Measured memory_bytes: 70528
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdio>
using namespace std;

#define int long long

signed main() {
    int h, w; cin >> h >> w;
    vector<string> a(h + 2);
    for(int i = 1; i <= h; i++) {
        cin >> a[i];
        a[i].insert(0, "#");
        a[i].insert(a[i].size(), "#");
    }

    for(int i = 0; i < w + 2; i++) {
        a[0] += "#";
        a[a.size() - 1] += "#";
    }

    for(int i = 0; i < h + 2; i++) {
        cout << a[i] << endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX 200010


int main()
{
    int n;
    int i,j;
    int k=0;
    int a[MAX];
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&(a[i]));
    }
    for(j=0;j<n;j++)
    {
        if(a[j]==(k+1))k++;
    }
    if(k==0)printf("-1");
    else printf("%d",n-k);
}



Measured memory_bytes: 1024
main() {
	char S[12]; scanf( "%s", &S );
	char T[13];
	int si, ti;
	for( si=ti=0; si<12; ){
		if( ti==4 ) { T[ti] = ' ';   ti++;      }
		else        { T[ti] = S[si]; ti++; si++;}
	}
	
	 printf( "%s\n", T );
	 return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int w, h, x, y, r;

int main(void) {
    scanf("%d%d%d%d%d", &w, &h, &x, &y, &r);
    
    if (x >= r && x <= w - r && y >= r && y <= h - r) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    
    return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, Q; cin >> N >> Q;
  string S; cin >> S;
  vector<int> a(N, 0);
  REP(i, N){
    if(i){
      if(S[i-1] == 'A' && S[i] == 'C'){
        a[i] = a[i-1] + 1;
      }else{
        a[i] = a[i-1];
      }
    }else{
      a[i] = 0;
    }
  }
  vector<int> ans;
  REP(i, Q){
    int l, r; cin >> l >> r; l--; r--;
      ans.push_back(a[r]-a[l]);
  }
  for(auto &i : ans) cout << i << endl;
}


Measured memory_bytes: 1864
#include <iostream>
#include <cstdlib>

using namespace std;

char s[200005], t[200005];
int x, y, n, l, c;

void incearcaSus();
void incearcaJos();
void incearcaDreapta();
void incearcaStanga();

int main()
{
    int i;

    cin >> l >> c >> n;
    cin >> x >> y;
    int cx=x, cy=y;
    cin >> s >> t;
    x = cx; y = cy;
    incearcaSus();
    x = cx; y = cy;
    incearcaJos();
    x = cx; y = cy;
    incearcaDreapta();
    x = cx; y = cy;
    incearcaStanga();
    cout << "YES\n";
    return 0;
}

void incearcaSus()
{
    for (int i=0;i<n;i++)
    {
        if (s[i] == 'U')
            x--;
        if (x == 0)
        {
            cout << "NO\n";
            exit(0);
        }
        if (t[i] == 'D' && x < l)
            x++;
    }
}
void incearcaJos()
{
    for (int i=0;i<n;i++)
    {
        if (s[i] == 'D')
            x++;
        if (x == l+1)
        {
            cout << "NO\n";
            exit(0);
        }
        if (t[i] == 'U' && x > 1)
            x--;
    }
}
void incearcaStanga()
{
    for (int i=0;i<n;i++)
    {
        if (s[i] == 'L')
            y--;
        if (y == 0)
        {
            cout << "NO\n";
            exit(0);
        }
        if (t[i] == 'R' && y < c)
            y++;
    }
}
void incearcaDreapta()
{
    for (int i=0;i<n;i++)
    {
        if (s[i] == 'R')
            y++;
        if (y == c+1)
        {
            cout << "NO\n";
            exit(0);
        }
        if (t[i] == 'L' && y > 1)
            y--;
    }
}

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

int main() {
    int N; cin >> N;
    using P = pair<int, int>;
    vector<P> S(N);
    rep(i, 0, N) {
        int x, y;
        cin >> x >> y;
        S[i] = make_pair(x, y);
    }
    function<double(double)> f = [&](double r) {
        double res = r * 180 / M_PI;
        return res;
    };
    function<int(int, int)> pos = [&](int x, int y) {
        if(x >= 0) {
            if(y >= 0) return 1;
            else return 4;
        } else {
            if(y >= 0) return 2;
            else return 3;
        }
    };
    function<double()> solve = [&]() {
        int x = 0, y = 0;
        vector<double> T = {0};
        S.push_back(make_pair(0, 0));
        rep(i, 0, N + 1) {
            int vx = S[i].first - x, vy = S[i].second - y;
            double t = atan((double)vy / vx);
            t = f(t);
            if(pos(vx, vy) != 1) t += 180;
            if(pos(vx, vy) == 4) t += 180;
            T.push_back(t);
            x = S[i].first;
            y = S[i].second;
        }
        S.pop_back();
        double res = 0;
        rep(i, 0, N + 1) {
            double add = abs(T[i + 1] - T[i]);
            if(add > 180) add = 360 - add;
            res += add;
        }
        return res;
    };
    double ans = 1e9;
    sort(S.begin(), S.end());
    do {
        ans = min(ans, solve());
    } while(next_permutation(S.begin(), S.end()));
    printf("%.10lf\n", ans);
    return 0;
}



Measured memory_bytes: 3548
#include <iostream>

int main(int argc, char const *argv[]) {
  int n=0,m=0;
  std::cin >> n >> m;

  int a[n][m];
  int b[m];

  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      int x=0;
      std::cin >> x;
      a[i][j] = x;
    }
  }
  for(int i=0;i<m;i++){
    int x=0;
    std::cin >> x;
    b[i] = x;
  }
  for(int i=0;i<n;i++){
    int result = 0;
    for(int j=0;j<m;j++){
      result += a[i][j] * b[j];
    }
    std::cout << result << std::endl;
  }
  return 0;
}

Measured memory_bytes: 3124
N = list(map(int, list(input())))

counter = 0
temp = N[0]
yes = 0

for i in range(len(N)):
    if temp == N[i]:
        counter += 1
    else:
        temp = N[i]
        counter = 1
    
    if counter == 3:
        print("Yes")
        yes = 1
        break
        
if yes == 0:
    print("No")

Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
char map[60][60];
bool used[60][60];
int h, w;
 
void dfs(int x, int y) {
    if (x < 0 || y < 0 || 50 < x || 50 < y){
        return;
    }
    if(used[x][y])
        return;
    if (map[x][y] == '.') {
        int count = 0;
        for(int i = -1; i != 2; i++){
            for(int j = -1; j != 2; j++){
                if(0 <= x + i && x + i < h && 0 <= y + j && y + j < w)
                    count += map[x + i][y + j] == '#';
            }
        }  
        map[x][y] = '0' + count;
    }
    used[x][y] = true;
    dfs(x, y + 1);
    dfs(x, y - 1);
    dfs(x + 1, y);
    dfs(x - 1, y);
}
 
int main() {
  cin >> h >> w;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> map[i][j];
    }
  }
  dfs(0, 0);
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cout << map[i][j];
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 512
n = int(input())
m = []
for i in range(n):
    m.append(input())
    
if len(set(m)) != len(m):
    print("No")
    exit()

for j in range(n-1):
    if m[j][-1] != m[j+1][0]:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 9052
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
using namespace std;

int main(){

  int x, a, b;
  cin >> x >> a >> b;

  int ans=x-a;

  cout << ans%b << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';


template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  Int n;
  cin>>n;
  vector<Int> as(n+1);
  for(Int i=0;i<=n;i++) cin>>as[i];

  if(n==0){
    if(as[0]==1) drop(1);
    drop(-1);
  }
  if(as[0]>=1) drop(-1);

  const Int INF = 1e15;
  vector<Int> dp(n+1,1);
  for(Int i=1;i<=n;i++){
    dp[i]=dp[i-1]*2;
    chmin(dp[i],INF);
    if(dp[i]<as[i]) drop(-1);
    dp[i]-=as[i];
  }

  Int ans=0,res=0;
  for(Int i=n;i>0;i--){
    res+=as[i];
    chmin(res,dp[i-1]*2);
    ans+=res;
  }
  ans+=1;
  cout<<ans<<newl;
  return 0;
}


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

#define FILE
#define fr first
#define se second

using namespace std;

const long long N = 2e5 + 7;
const long long inf = 1e9 + 7;
const long long mod = 1e9 + 7;

int can(string s){
    string t = s;
    reverse(t.begin(), t.end());
    return (t == s);
}
int main()
{
    #ifdef FILEs
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);

    string s;
    cin >> s;
    int n = (int)s.size();
    if(can(s) && can(s.substr(0, ((n - 1) / 2))) && can(s.substr((n + 3) / 2 - 1))){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int n;
    cin>>n;
    vector<pair<ll,ll>> pii;
    rep(i,n){
        int a,b;
        cin>>a>>b;
        pii.push_back({b,a});
    }
    sort(pii.begin(),pii.end());
    int now = 0;
    rep(i,n){
        now+=pii[i].second;
        if(now>pii[i].first){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 6256
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

int a[100];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> a[i];

    sort(a, a + n);
    cout << unique(a, a + n) - a;
}


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

int main(){
  int X,A,B;

  cin >> X >> A >> B;
  if (A - B >= 0){
    cout << "delicious" <<endl;
  }else{
    if(X + (A - B) >= 0){
      cout << "safe" <<endl;
    }else{
      cout << "dangerous"<<endl;
    }
  }
}


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

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

    vector<string> week = {"SUN","MON","TUE","WED","THU","FRI","SAT"};

    auto i = find(week.begin(), week.end(), S);
    
    cout << 7 - (i - week.begin()) <<endl;
}

Measured memory_bytes: 256
/* Bismillahir Rahmanir Rahim */

#include <bits/stdc++.h>

#define rep(i, n)	for(int i=0;i<n;i++)
#define repn(i, n)	for(int i=1;i<=n;i++)
#define set(i, n)	memset(i, n, sizeof(i))

#define mx		1000007
#define pb		push_back
#define inf 	(1 << 30)

#define f	first
#define s 	second

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

int n, m;
string str[10];
bool flag = true;

void dfs(int x, int y){
	if(str[x][y] != '#'){
		flag = false;
		return;
	}
	if(x == n-1 && y == m-1){
		return;
	}
	int r1 = 0, r2 = 0;
	for(int i=y+1;i<m;i++) r1 += (str[x][i] == '#');
	for(int i=x+1;i<n;i++) r2 += (str[i][y] == '#');
	if(r1 && r2){
		flag = false;
		return;
	}
	if(r1) dfs(x, y+1);
	else dfs(x+1, y);
}

int main(){
	cin >> n >> m;
	rep(i, n) cin >> str[i];
	dfs(0, 0);
	if(flag) printf("Possible\n");
	else printf("Impossible\n");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll n,q,c,up,low,t,x,y,arr[1000000],a,b;
double ff;
bool f;

int main()
{
    cin >> a;
    c=1;
    x=1;
    while (a!=1)
    {
        a/=2;
        c*=2;
        x+=c;
    }
    cout << x << endl;
}


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

int main() {
  double a,b,c,d,e,f;
  double y,x;
  while(cin >> a >> b >> c >> d >> e >> f) {
    y = (c*d - a*f) / (d*b - a*e);
    x = (c - b*y) / a;

    cout << fixed << setprecision(3) << x << " " << y << endl;
  }
  return 0;
}


Measured memory_bytes: 3284
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int from,to,i,j,k,n;

void print(){printf("%s%d",i==from ? "" : " ",i);}

int main(){
	for(scanf("%d",&n);n>0;n--){
		scanf("%d %d",&from,&to);
		if(from>5){
			i=from;
			while(i!=to){
				print();
				if(i>5){i++;if(i>9)i=5;}
				else i--;
				if(i==0)break;
			}
			while(i!=to){
				print();i++;
			}
			printf(" %d\n",to);
		}
		else{
			if(from>to){for(i=from;i>=to;i--){print();}printf("\n");}
			else{for(i=from;i<=to;i++){print();}printf("\n");}
		}
	}
	return 0;
}

Measured memory_bytes: 604
#英小文字からなる文字列 S が与えられます。T が空文字列である状態から始めて、以下の操作を好きな回数繰り返すことで S=T とすることができるか判定してください。
#T の末尾に "dream", "dreamer", "erase", "eraser" のいずれかを追加する。


s=input()
s1="dream"
s2="dreamer"
s3="erase"
s4="eraser"
l=len(s)

rest="NO"

while l>4:
	if s[-5:]==s1 or s[-5:]==s3:
		s=s[0:-5]
		l=l-5
	elif s[-6:]==s4:
		s=s[0:-6]
		l=l-6
	elif s[-7:]==s2:
		l=l-7
		s=s[0:-7]
	else:
		break

if l==0:
	rest="YES"

print(rest)

Measured memory_bytes: 3188
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
from math import cos,sin,tan,sqrt
import cmath as cma
import copy as cp
import sys
import re
import bisect as bs
sys.setrecursionlimit(10**7)
EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf
MOD = 10**9 + 7

def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
def adj(n): return [[] for _ in range(n)]

h,w,k = imap()
grid = np.array([[int(elm=="#") for elm in sinput()] for i in range(h)])

ans = 0
for i in range(2**h):
    for ii in range(2**w):
        g = cp.deepcopy(grid)
        for j in range(h):
            if i>>j &1: g[j,:] = 0
        for jj in range(w):
            if ii>>jj &1: g[:,jj] = 0
        cnt = np.count_nonzero(g)
        if cnt == k: ans += 1
print(ans)


Measured memory_bytes: 37752
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <bitset>
#include <map>
#include <vector>
#include <cstdlib>
#include <stack>
#include <queue>
#include <list>
#include <set>
using namespace std;
#define llong long long int

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s; cin >> s;
    if (s.size() == 1) {
        cout << 0 << endl;
        return 0;
    }

    int last_W_pos = 0;
    for (int i = s.size() - 1; i >= 0; --i) {
        if (s[i] == 'W') {
            last_W_pos = i;
            break;
        }
    }
    if (last_W_pos == 0) {
        cout << 0 << endl;
        return 0;
    }

    llong ans = 0;
    llong accum_B = 0;
    for (int i = last_W_pos; i >= 0; --i) {
        if (s[i] == 'B') {
            ans += last_W_pos - i - accum_B;
            ++accum_B;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 720
#include <iostream>
using namespace std; 
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rep2(i,a,b) for(int i=a;i>=b;i--)
#define ll long long
int fg[200005],fg2[200005];
int main(int argc, char** argv) {
	string s;
	cin>>s;
	ll p=0,ans=0;
	rep2(i,s.length()-1,0)
	{
		if(s[i]=='B'||(s[i]=='C'&&s[i-1]!='B'))
		{
			p=0;
			continue;
		}
		if(s[i]=='A')
		{
		ans+=p;	
		}
		else
		{
			p++;
			i--;
		}
		
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 832
#include<iostream>
using namespace std;
long long n,a,b,more;
int main(){
	cin >> n >> a >> b;
	long long h[n];
	for(int i=0;i<n;i++){
		cin >> h[i];
		more=max(more,h[i]);
	}
	long long lo=0,hi=more,mid;
	for(;;){
		if(lo>hi){
			hi++;
			break;
		}
		long long j=0;
		mid=(lo+hi)/2;
  		for(int i=0;i<n;i++){
    		long long c=h[i]-b*mid;
    		long long d=(c+a-b-1)/(a-b);
    		if(d>0)j+=d;
    	}
    	if(j>mid)lo=mid+1;
    	else hi=mid-1;
	}
	cout << hi;
	return 0;
}

Measured memory_bytes: 1024
function Main(input) {
    const [k, s] = input.split(" ").map(str => Number(str));
    let result = 0;
    for (let x = 0; x <= k; x++) {
        for (let y = 0; y <= k; y++) {
            const z = s - (x + y);
            if (0 <= z && z <= k) {
                result++;
            } 
        }
    }
    console.log(result);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long work, n, min, max, sum;
		n = scan.nextInt();
		work = scan.nextInt();
		min = max = sum = work;
		for (int i = 1; i < n; i++) {
			work = scan.nextInt();
			if (min > work) min = work;
			if (max < work) max = work;
			sum += work;
		}
		System.out.println(min + " " + max + " " + sum);
	}
}

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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = 1e9 + 100;
const long long LLINF = 2e18 + 129;
const long long MOD = 1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

    int a, b;
    cin >> a >> b;

    if(b % a == 0){
        cout << a + b << endl;
    }else{
        cout << b - a << endl;
    }

    return 0;
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split(' ');
        var a = int.Parse(input[0]);
        var b = int.Parse(input[1]);
        
        Console.WriteLine((a * b) % 2 == 0 ? "Even" : "Odd");
    }
}

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

int main() {
    int n;
    cin >>n;
    vector<int> R(n, 0);
    for (int i=0; i<n; i++)
        cin >>R.at(i);
    int D=-2000000000;
    int M=R.back();
    for (int i=n-2; i>=0; i--) {
        D=max(D, M-R.at(i));
        M=max(M, R.at(i));
    }
    cout <<D <<endl;
    return 0;
}


Measured memory_bytes: 3620
// https://atcoder.jp/contests/abc088/tasks/abc088_a
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, a;
    cin >> n >> a;
    cout << (n % 500 <= a ? "Yes\n" : "No\n");
    return 0;
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1e17 - 10;
const double PI = acos(-1);
#define fir first
#define sec second
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, s, t, q, ans, sum, a[200001];
struct Edge { LL to,cost; };
string str, ss;
char c[10000000];
bool f[30];
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
int main() {
	cin >> n;
	rep(i, n) {
		cin >> str;
		if (str[0] == 'M')a[0]++;
		if (str[0] == 'A')a[1]++;
		if (str[0] == 'R')a[2]++;
		if (str[0] == 'C')a[3]++;
		if (str[0] == 'H')a[4]++;
	}
	rep(i, 5) {
		int AA = a[i];
		for (int j = i + 1; j < 5; j++) {
			int BB = AA*a[j];
			for (int s = j + 1; s < 5; s++) {
				ans += BB*a[s];
			}
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
  int N;
  cin>>N;
  vector<int> V(N);
  for(int i=0;i<N;i++){
    cin>>V.at(i);
  }
  sort(V.begin(),V.end());
  int sum=0;
  for(int i=0;i<N-1;i++){
    if(V.at(i)<V.at(i+1)){
      sum++;
    }
  }
  cout<<sum+1<<endl;
}

Measured memory_bytes: 256
A, B, C = map(int, input().split())

count = 0
A_org = A
A = 0
for i in range(1000):
    if count < C:
        if A + A_org <= B:
            A += A_org
            count += 1
        else:
            break
    else:
        break
    
print(count)

Measured memory_bytes: 9032
n,m=map(int,input().split())
a=[input() for _ in range(n)]
b=[input() for _ in range(m)]

r=any([r[j:j+m] for r in a[i:i+m]]==b for i in range(n-m+1) for j in range(n-m+1))

print('Yes' if r else 'No')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define rrep(i,n) for(int i=int(n);i>0;i--)
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+5  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
using PPI=pair<P,int>;
//ll const mod=998244353;
ll const mod=1e9+7;
const ll MAX=1000005;
using vi=vector<int>;
using vl=vector<ll>;
using vc=vector<char>;
using vd=vector<double>;
using vs=vector<string>;
using vp=vector<P>;
using vb=vector<bool>;
using vvi =vector<vector<int>>;
using vvl =vector<vector<ll>>;
using vvd=vector<vector<double>>;
using vvc=vector<vector<char>>;
using vvp =vector<vector<P>>;
using vvb=vector<vector<bool>>;
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}

ll gcd(ll a,ll b){
    if(b==0)return a;
    return gcd(b,a%b);
}
//////////////////////////////////////
void print(vi a){
    int n=a.size();
    rep(i,n){
        if(a[i]==0)cout<<"S";
        else cout<<"W";
    }
    cout<<endl;
}
bool get_v(string s,int p,int f){
    int n=s.size();
    vi tmp(n);
    tmp[0]=p;
    int next=f;
    arep(i,1,n){
        tmp[i]=next;
        if((s[i]=='o'&&next==0)||(s[i]=='x'&&next==1)){
            next=tmp[i-1];
        }
        else if((s[i]=='o'&&next==1)||(s[i]=='x'&&next==0)){
            next=1-tmp[i-1];
        }      
    }
    int last=0;
    if((s[0]=='o'&&p==0)||(s[0]=='x'&&p==1)){
        last=f;
    }
    else if((s[0]=='o'&&p==1)||(s[0]=='x'&&p==0)){
        last=1-f;
    }
    if(next==p&&last==tmp[n-1]){
        print(tmp);
        return true;
    }
    else return false;
}

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

    if(get_v(s,0,0))return 0;
    if(get_v(s,0,1))return 0;
    if(get_v(s,1,0))return 0;
    if(get_v(s,1,1))return 0;
    cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 4004
#include <stdio.h>

int main(void)
{
    int n, m, l;
    scanf("%d %d %d", &n, &m, &l);
    
    int a[n][m], b[m][l];
    long c[n][l];
    int i, j, k;
    
    /*init*/
    for (i = 0; i < n; ++i) {
        for (j = 0; j < m; ++j) {
            scanf("%d", &a[i][j]);
        }
    }
    
    for (i = 0; i < m; ++i) {
        for (j = 0; j < l; ++j) {
            scanf("%d", &b[i][j]);
        }
    }
    
    for (i = 0; i < n; ++i) {
        for (j = 0; j < l; ++j) {
            c[i][j] = 0;
        }
    }
    
    /*calc*/
    for (i = 0; i < n; ++i) {
        for (j = 0; j < l; ++j) {
            for (k = 0; k < m; ++k) {
                c[i][j] += a[i][k] * b[k][j];
            }
        }
    }
    
    /*output*/
    for (i = 0; i < n; ++i) {
        for (j = 0; j < l; ++j) {
            printf("%ld", c[i][j]);
            if (j < l - 1) printf(" ");
        }
        printf("\n");
    }
    
    return 0;
}

Measured memory_bytes: 1188
import sys
import math
import bisect

def solve(a, b, c, d):
    cur = 0
    while True:
        if cur == 0:
            c -= b
            if c <= 0:
                return True
        else:
            a -= d
            if a <= 0:
                return False
        cur = (cur + 1) % 2
    return None

def main():
    a, b, c, d = map(int, input().split())
    if solve(a, b, c, d):
        print('Yes')
    else:
        print('No')

if __name__ == "__main__":
    main()


Measured memory_bytes: 9188
a, b = map(int, input().split(' '))

c = int(a / 0.08)
d = int(b / 0.1)
if c == d:
  print(c)
  exit()

for i in range(min(c, d), 10000):
  if (a == int(i * 0.08)) & (b == int(i * 0.1)):
    print(i)
    exit()
    
print(-1)

Measured memory_bytes: 3188
#include <stdio.h>
#include <stdlib.h>
  
#define WHITE 0 
#define GRAY 1   
#define BLACK 2  
#define N 101
char Adj[N][N];
int n, d[N],f[N],color[N],time;        
  
 
 
void visit(int r) {
  int v;
  
  color[r] = GRAY;   
  d[r] = ++time; 
  
  for( v = 0 ; v < n ; v++ ) {
    if( Adj[r][v] == 1 && color[v] == WHITE ) {
      visit(v);                            
    }
  }
  color[r] = BLACK;
  f[r] = ++time;
}
 
void dfs() {
  int i;
  
  for( i = 0 ; i < n ; i++ ) {
    if( color[i] == WHITE ) {
      visit(i);
    }
  }
}

  
  
main() {
  
  int i,j,u,k,v;
  
  scanf( "%d",&n );
  
  for( i = 0 ; i < n ; i++ ) {
    for( j = 0 ; j < n ; j++ ) {
      Adj[i][j] = 0;
    }
  }
  
  
  for( i = 0 ; i < n ; i++ ) {
    scanf( "%d%d", &u,&k );
      
    for( j = 0  ; j < k; j++ ) {
      scanf( "%d",&v );
      Adj[u-1][v-1] = 1;
}
    
  }
  
  dfs();
  
  for( i=0; i<n; i++ ) {
    printf("%d %d %d\n", i+1, d[i], f[i] );
  }
 
  return 0;
  
}

Measured memory_bytes: 604
while True:
    n=int(input())
    if n>0:
        x=1000-n
        a=x//500
        b=(x%500)//100
        c=(x%100)//50
        d=(x%50)//10
        e=(x%10)//5
        f=x%5
        print(a+b+c+d+e+f)
    else:
        break


Measured memory_bytes: 5592
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <cstring>
#include <string>
#include <cctype>
#include <cassert>
#include <queue>

using namespace std;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,b,e) for(int i = (b); i <= (e); i++)
#define INF (1001001001)
#define EPS (1e-15)

#define pr(x) do{cerr << (#x) << " = " << (x) << endl;}while(0)
#define pri(x,i) do{cerr << (#x) << "[" << i << "] = " << (x[i]) << endl;}while(0)
#define pra(x,n) rep(__i,n) pri(x,__i);
#define prar(x,b,e) repr(__i,b,e) pri(x,__i);

typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;

ll MOD = 1000000007;

int in() {
	int a;
	scanf("%d ", &a);
	return a;
}

typedef long double ld;

int main() {
	ll N;
	scanf("%lld", &N);
	repr(a,1,3500)repr(b,1,3500) {
		ld x = (ld)4 / N - (ld)1 / a - (ld)1 / b;
		if (x < (ld)1 / 3510) continue;
		if (x > 1) continue;
		ld t = 1 / x;
		int hoge = t + EPS;
		if (x - EPS < (ld)1 / hoge && (ld)1 / hoge < x + EPS) {
			printf("%d %d %d\n", a, b, hoge);
			return 0;
		}
	}
	
	return 0;
}


Measured memory_bytes: 256
x,y = input().split()
dic = {
    "A":1,
    "B":2,
    "C":3,
    "D":4,
    "E":5,
    "F":6,
}
if dic[x] < dic[y]:
    print("<")
elif dic[x] == dic[y]:
    print("=")
else:
    print(">")

Measured memory_bytes: 3060
from itertools import permutations
from math import factorial

n, m = map(int, input().split(' '))
edge = []

for i in range(m):
    ai, bi = map(int, input().split(' '))
    edge.append([ai,bi])


x = [i for i in range(1,n+1)]
ls = list(permutations(x))
ans = 0
for l in range(factorial(n-1)):
    cnt = 0
    for i in range(n-1):
        for j in range(m):
            if (ls[l][i] in edge[j]) and (ls[l][i+1] in edge[j]):
                cnt += 1
    if cnt == n-1:
        ans += 1


print(ans)


Measured memory_bytes: 13872
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <string.h>
//#include <unordered_set>
//#include <unordered_map>
//#include <bits/stdc++.h>

#define MP(A,B) make_pair(A,B)
#define PB(A) push_back(A)
#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define fi first
#define se second

using namespace std;

template<typename T>inline bool upmin(T &x,T y) { return y<x?x=y,1:0; }
template<typename T>inline bool upmax(T &x,T y) { return x<y?x=y,1:0; }

typedef long long ll;
typedef unsigned long long ull;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod eps=1e-11;
const lod pi=acos(-1);
const int oo=1<<30;
const ll loo=1ll<<62;
const int mods=998244353;
const int MAXN=200005;
const int INF=0x3f3f3f3f;//1061109567
/*--------------------------------------------------------------------*/
inline int read()
{
	int f=1,x=0; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') f=-1; c=getchar(); }
	while (c>='0'&&c<='9') { x=(x<<3)+(x<<1)+(c^48); c=getchar(); }
	return x*f;
}
int a[MAXN],b[MAXN],c[MAXN],ans=INF;
int main() 
{
//	freopen("a.in","r",stdin);
//	freopen("a.out","w",stdout);
	int n=read(),k=read(),m=read();
	for (int i=1;i<=n;i++) a[i]=read();
	for (int i=1;i<=n;i++)
	{
		int num=0;
		for (int j=1;j<=n;j++) b[j]=a[j];
		for (int j=1,lst=0;j<=n+1;j++)
			if (a[j]<a[i])
			{
				if (!lst) continue;
				sort(b+lst,b+j);
				for (int t=1;t<=j-lst-k+1;t++) c[++num]=b[t+lst-1];
				lst=0; 
			}
			else if (!lst) lst=j;
		if (num<m) continue;
		sort(c+1,c+num+1);
		upmin(ans,c[m]-c[1]);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3780
#include<iostream>
#include<math.h>
#include<stdio.h>
using namespace std;
int main(){
  int d,i,j,k;
  cin >> d;
  double a[1000]={},b[1000]={};
  for(i=0;i<d;i++) cin >> a[i];
  for(i=0;i<d;i++) cin >> b[i];
  double o1=0,o2=0,o3=0,oe=0;
  for(i=0;i<d;i++){
    o1+=fabs(a[i]-b[i]);
    o2+=fabs(a[i]-b[i])*fabs(a[i]-b[i]);
    o3+=fabs(a[i]-b[i])*fabs(a[i]-b[i])*fabs(a[i]-b[i]);
    oe=max(oe,fabs(a[i]-b[i]));
  }
  printf("%.6f\n",o1);
  printf("%.6f\n",sqrt(o2));
  printf("%.6f\n",pow(o3,1.0/3.0));
  printf("%.6f\n",oe);
  return 0;
}



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

int main() {
    int n;
    cin >> n;
    while (n--) {
        int gx, gy;
        cin >> gx >> gy;
        pair<int, pair<bool, bool> > field[16][16];
        for (int y = 0; y <= gy; y++) {
            for (int x = 0; x <= gx; x++) {
                field[y][x] = make_pair(0, make_pair(true, true));
            }
        }
        int p;
        cin >> p;
        while (p--) {
            int x[2], y[2];
            cin >> x[0] >> y[0] >> x[1] >> y[1];
            if (x[0] == x[1]) {
                field[min(y[0], y[1])][x[0]].second.second = false;
            } else {
                field[y[0]][min(x[0], x[1])].second.first = false;
            }
        }
        field[0][0].first = 1;
        for (int y = 0; y <= gy; y++) {
            for (int x = 0; x <= gx; x++) {
                if (x > 0 && field[y][x - 1].second.first) {
                    field[y][x].first += field[y][x - 1].first;
                }
                if (y > 0 && field[y - 1][x].second.second) {
                    field[y][x].first += field[y -1][x].first;
                }
            }
        }
        if (field[gy][gx].first > 0) {
            cout << field[gy][gx].first << endl;
        } else {
            cout << "Miserable Hokusai!" << endl;
        }
    }
}

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

using namespace std;

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

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	int n, k;
	cin >> n >> k;
	vector<int> h(n);
	rep (i, n) cin >> h[i];
	sort(h.rbegin(), h.rend());
	ll res = 0;
	FOR (i, k, n) res += h[i];
	cout << res << endl;
    
    return 0;
}



Measured memory_bytes: 3948
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int x,y;
  cin>>x>>y;
  int vec[13]={0,1,3,1,2,1,2,1,1,2,1,2,1};
  if(vec[x]==vec[y]){
      cout<<"Yes"<<endl;
    }
  else{
      cout << "No" << endl;
    }
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define SZ(x) (int)(x).size()
#define ALL(x) begin(x), end(x) 
#define REP(i, n) for (int i = 0; i < n; ++i) 
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define RFOR(i, a, b) for (int i = a; i >= b; --i)

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    int N, K; cin >> N >> K;
    int A[N];
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }

    map<int, deque<int> > ft;
    ll cur = 0;
    for (int i = 0; i < N; ++i) {
        cur = ((ll)cur + A[i] - 1 + K) % K;
        ft[cur].push_back(i);
    }

    cur = 0;
    ll ans = 0;
    for (int i = 0; i < N; ++i) {
        ans += lower_bound(ft[cur].begin(), ft[cur].end(), i+K-1) - ft[cur].begin();
        cur = ((ll)cur + A[i] - 1 + K) % K;
        ft[cur].pop_front();
    }

    cout << ans << '\n';
}



Measured memory_bytes: 144768