akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define int ll

string s;


signed main(){
  cin>>s;

  int i=0,j=0;

  int ans=0;
  while(i<s.size()){
    if(s[i]=='W'){
      ans+=i-j;
      j++;
    }
    i++;
  }

  cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = (int)1.01e9;
const int N = 1 << 19;
const int MOD = (int)1e9 + 7;


int main() {
#ifdef HOME
    freopen("in", "r", stdin);
#endif

    int n, m, d;
    while (cin >> n >> m >> d) {
        string Z = "RGYB";
        vector<vector<char> > ans(n, vector<char>(m));

        if (d % 2 == 1) {
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    ans[i][j] = Z[(i + j) % 2];
                }
            }
        } else {
            auto ok = [&](int x, int y) {
                return 0 <= x && x < n && 0 <= y && y < m;
            };

            auto g = [&](int x, int y, int c) {
                if (!ok(x, y)) return false;
                ans[x][y] = Z[c];
                return true;
            };

            set<pair<int, int> > st;
            function<void(int, int, int)> paint = [&](int x, int y, int c) {
                if (st.find({x, y}) != st.end()) return;
                st.insert({x, y});
                bool f = 0;
                for (int i = 0; i < d / 2; i++) {
                    for (int j = 0; j < d / 2; j++) {
                        f |= g(x + i + j, y + i - j, c);
                    }
                }
                if (!f) return;
                paint(x + d / 2, y + d / 2, c ^ 1);
                paint(x - d / 2, y - d / 2, c ^ 1);
                paint(x + d / 2, y - d / 2, c ^ 2);
                paint(x - d / 2, y + d / 2, c ^ 2);
            };

            paint(0, 0, 0);
            paint(0, 1, 0);
        }

        for (int i = 0; i < n; i++) {
            string s = "";
            for (char c : ans[i]) s += c;
            cout << s << endl;
        }
    }

#ifdef HOME
    cerr << clock() / (double)CLOCKS_PER_SEC << endl;
#endif
    return 0;
}

Measured memory_bytes: 23040
#pragma G++ optimize (2)
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <queue>
#define INF 0x3f3f3f3f
#define NO 30005
#define MO 100005
typedef long long ll;
typedef double db;
using namespace std;
inline ll read()
{
	char ch = ' ', last;
	ll ans = 0;
	while (ch < '0' || ch > '9')
		last = ch, ch = getchar();
	while (ch >= '0' && ch <= '9')
		ans = ans * 10 + int(ch - '0'), ch = getchar();
	if (last == '-')
		return -ans;
	return ans;
}
void write(ll x)
{
	if (x >= 10)
		write(x / 10);
	putchar(x % 10 + '0');
}
//head

string x;
int n, k;
//variable

void init()
{
	n = read(), k = read();
	cin >> x;
}
//functions

int main()
{
	init();
	x[k - 1] -= 'A' - 'a';
	cout << x << endl;
	return 0;
}
//main

Measured memory_bytes: 256
"use strict";
function main(input) {
  let kari = input[0].trim().split(" ");

  let h = parseInt(kari[0]);
  let w = parseInt(kari[1]);
  if(h===1 || w ===1){
    console.log(1);
  }else{
    console.log(((h*w)%2===0)?parseInt(h*w/2):parseInt(Math.floor(h*w)/2 +1));
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));

Measured memory_bytes: 23476
#include<cstdio>
#include<iostream>
int n,q;
const int N=2e5+5;
char s[N],t[N],d[N];
bool check(int x,int p=0) {
    for(int i=1;i<=q&&x>0&&x<=n;i++) {
        if(t[i]==s[x]) d[i]=='L'?x--:x++;
    }
    return x==p;
}
int main() {
    scanf("%d%d",&n,&q);
    scanf("%s",s+1);
    for(int i=1;i<=q;i++) {
        getchar();
        scanf("%c %c",t+i,d+i);
    }
    int low,upp,l=0,r=n+1,mid;
    while(r-l>1) {
        mid=(l+r)>>1;
        if(check(mid)) l=mid;
        else r=mid;
    }
    low=l;l=1,r=n+1;
    while(l<r) {
        mid=(l+r)>>1;
        if(check(mid,n+1)) r=mid;
        else l=mid+1;
    }upp=r;
    printf("%d\n",upp-low-1);
    return 0;
}


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


int main()
{
    int a,b,i,t=1;
    char c,d[5],e[5];
    scanf("%d %d",&a,&b);
    getchar();
    for(i=0;i<a;i++)
    {
        d[i]=getchar();
        if(d[i]<'0'||d[i]>'9')
            t=0;
    }
    c=getchar();
    if(c!='-')
        t=0;
    for(i=0;i<b;i++)
    {
       e[i]=getchar();
        if(e[i]<'0'||e[i]>'9')
            t=0;
    }
    if(t==1)
        printf("Yes");
    else
        printf("No");
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll=long long;

int main(){
    ll H, W;
    cin >> H >> W;
    ll ans = H * W;
    ll tmp1, tmp2, tmp3, tmph, tmpw, mintmp, maxtmp;
    for(ll i = 1; i < H; ++i){
        if(H % 3 == 0 || H % 3 == 2) tmph = H / 3;
        else tmph = (H / 3) + 1;
        tmp1 = tmph * W;
        tmp2 = (H-tmph) * W / 2;
        mintmp = min(tmp1, tmp2);
        maxtmp = max(tmp1, tmp2);
        if(maxtmp - mintmp < ans) ans = maxtmp - mintmp;
    }
    for(ll i = 1; i < W; ++i){
        if(W % 3 == 0 || W % 3 == 2) tmph = W / 3;
        else tmph = (W / 3) + 1;
        tmp1 = tmph * H;
        tmp2 = (W-tmph) * H / 2;
        mintmp = min(tmp1, tmp2);
        maxtmp = max(tmp1, tmp2);
        if(maxtmp - mintmp < ans) ans = maxtmp - mintmp;
    }
    for(ll i = 1; i < H; ++i){
        ll tmp1 = i * W;
        ll tmpw;
        if(W % 2 == 0) tmpw = W / 2;
        else tmpw = (W+1) / 2;
        ll tmp2 = (H-i) * tmpw;
        ll tmp3 = (H-i) * (W - tmpw);
        ll mintmp = min(tmp1, min(tmp2, tmp3));
        ll maxtmp = max(tmp1, max(tmp2, tmp3));
        if(maxtmp - mintmp < ans) ans = maxtmp - mintmp;
    }
    for(ll i = 1; i < W; ++i){
        ll tmp1 = i * H;
        ll tmpw;
        if(H % 2 == 0) tmpw = H / 2;
        else tmpw = (H+1) / 2;
        ll tmp2 = (W-i) * tmpw;
        ll tmp3 = (W-i) * (H - tmpw);
        ll mintmp = min(tmp1, min(tmp2, tmp3));
        ll maxtmp = max(tmp1, max(tmp2, tmp3));
        if(maxtmp - mintmp < ans) ans = maxtmp - mintmp;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int main()
{
    ios::sync_with_stdio(false);
    string a ; cin >> a;
    if(a[0] == '7' || a[1] == '7' || a[2] == '7')
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
						
#define fast_cin() ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define endl '\n'
#define int long long
				
int32_t main() {
	fast_cin();  
	int n; cin >> n;
	map<string, int> cnt;
	cnt["AC"] = 0, cnt["WA"] = 0, cnt["TLE"] = 0, cnt["RE"] = 0;
	while (n--) {
		string s; cin >> s;
		++cnt[s];
	}
	cout << "AC x " << cnt["AC"] << endl;
	cout << "WA x " << cnt["WA"] << endl;
	cout << "TLE x " << cnt["TLE"] << endl;
	cout << "RE x " << cnt["RE"] << endl;
	return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,p[20];
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>p[i];
	int ans=0;
	for(int i=1;i+1<n;i++)
		if(p[i-1]<p[i]&&p[i]<p[i+1]||p[i-1]>p[i]&&p[i]>p[i+1])
			ans++;
	cout<<ans<<endl;
}


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

using namespace std;
const int maxn = 5e5 + 20;
int a[maxn];
int r[maxn];
int c[maxn];
bool ans[maxn];

int main(){
  int n; cin >> n;
  int D; cin >> D;
  for(int i=0;i<n;i++){
    int t; cin >> t;
    a[i] = t;
  }
  r[n] = 1;
  for(int i = n-1; i >= 0; i--){
    if(a[i] >= 2 * r[i+1]){
      r[i] = r[i+1];
    }
    else{
      r[i] = min(D+10, r[i+1] + a[i]);
    }
  }
  //compute stopping point
  int curr = D;
  int win = -1;
  for(int i=0;i<n;i++){
    c[i] = curr;
    if(a[i] >= 2 * curr) continue;
    if(a[i] - curr >= 0) curr = a[i] - curr;
    else curr = curr - a[i];
    if(curr == 0){
      win = i;
      break;
    }
  }
  int Q; cin >> Q;
  for(int qq=0;qq<Q;qq++){
    int i; cin >> i; i--;
    if(win == -1){
      cout << "YES\n";
      continue;
    }
    if(i > win){
      cout << "NO\n";
      continue;
    }
    if(r[i+1] <= c[i]){
      cout << "YES\n";
    }
    else cout << "NO\n";
  }
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, s, e) for (int i = (int)(s); i < (int)(e); i++)
#define _rep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define _REP(i, e, s) for (int i = (int)(e - 1); i >= (int)(s); i--)

#define yes cout << "yes" << endl;
#define Yes cout << "Yes" << endl;
#define YES cout << "YES" << endl;

#define no cout << "no" << endl;
#define No cout << "No" << endl;
#define NO cout << "NO" << endl;

#define AC cout << "AC" << endl;
#define WA cout << "WA" << endl;

#define out(s) cout << s << endl;

#define ll long long
#define ull unsigned long long

const unsigned int BIT_FLAG_0 = (1 << 0);  // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1);  // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2);  // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3);  // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4);  // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5);  // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6);  // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7);  // 0000 0000 1000 0000

const double PI = 3.14159265358979323846;

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

#define H_MAX 500
#define W_MAX 500
#define INF 1e9 + 7

int main() {
    int X;
    cin >> X;
    if (X >= 30) {
        Yes;
    } else {
        No;
    }
}


Measured memory_bytes: 3596
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<list>
#include<map>
#include<vector>

using namespace std;


#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long

#define IMIN INT_MIN;
#define IMAX INT_MAX;

int maxelem(vector<int> src) {
	int dst = IMIN;
	rep(i, src.size()) {
		dst = (dst > src[i]) ? dst : src[i];
	}
	return dst;
}

int secondelem(vector<int> src) {
	int dst = IMIN;
	int dst2 = IMIN;
	rep(i, src.size()) {
		if (dst < src[i]) {
			dst2 = dst;
			dst = src[i];
		}
		else if (dst2 < src[i]) {
			dst2 = src[i];
		}
	}
	return dst2;
}

vector<int> count(vector<int> a) {
	int ma = maxelem(a);
	vector<int> count(ma+1, 0);
	rep(i, a.size()) {
		count[a[i]]++;
	}
	return count;
}

int find(vector<int> a, int b) {
	rep(i, a.size()) {
		if (a[i] == b) return i;
	}
	return -1;
}

int main(){
	int D;
	cin >> D;
	D -= 25;
	cout << "Christmas";
	rep(i, -1 * D) cout << " Eve";
	cout << endl;



	return 0;
}




Measured memory_bytes: 256
def dfs(memo,w,h,m,o,map,tw,th,nest)
  return 1e9 if o<=1
  return 1e9 if th <= 0 || h < th
  return 1e9 if tw <= 0 || w < tw
  return [0,-map[th][tw]].max if h==th
  return memo[[th,tw,o,map[th]]] if memo[[th,tw,o,map[th]]]

  cell = map[th][tw]
  map[th][tw] = 0
  ans = if cell > 0
    [ dfs(memo,w,h,m,[o-1+cell,m].min,map,tw,th+1,nest+1),
      dfs(memo,w,h,m,[o-1+cell,m].min,map,tw-1,th,nest+1),
      dfs(memo,w,h,m,[o-1+cell,m].min,map,tw+1,th,nest+1) ].min
  else
    [ dfs(memo,w,h,m,o-1,map,tw,th+1,nest+1)-cell,
      dfs(memo,w,h,m,o-1,map,tw-1,th,nest+1)-cell,
      dfs(memo,w,h,m,o-1,map,tw+1,th,nest+1)-cell ].min
  end
  map[th][tw] = cell

  return memo[[th,tw,o,map[th]]] = ans
end

while (w,h=gets.split.map(&:to_i))!=[0,0]
  f,m,o=gets.split.map(&:to_i)
  map = [[0]*(w+2)]+(1..h).map{[0]+gets.split.map(&:to_i)+[0]}+[[0]*(w+2)]
  memo={}
  cost = (1..w).map{|tw|dfs(memo,w,h,m,o,map,tw,1,0)}.min
  puts (cost>f)?"NA":cost
end

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

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

    int n = int(s.size());

    for (int begin = 0; begin < n; begin++)
    {
        for (int end = begin; end <= n; end++)
        {
            string t = "";
            // [begin, end] の区間を切り取り、それ以外の部分の文字列でtを作る
            for (int i = 0; i < n; i++)
            {
                if (begin <= i && i < end)
                {
                    continue;
                }
                else
                {
                    t.push_back(s.at(i));
                }
            }

            if (t == "keyence")
            {
                cout << "YES" << endl;
                return 0;
            }
        }
    }

    cout << "NO" << endl;
    return 0;
}

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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

using namespace std;
using ll = long long;
using pii = pair<int, int>;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    for(int i = 0; i < n; ++i){
        cin >> h[i];
    }
    vector<int> dp(n);
    for(int i = 1; i < n; ++i){
        dp[i] = INF;
        for(int j = max(0, i - k); j < i; ++j){
            dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
        }
    }

    cout << dp[n-1] << "\n";
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define int long long
#define P pair<int,int>
#define all(vec) vec.begin(),vec.end()

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n;
int ans = 1;
int cnt;

signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a; cin >> a;
		if (a <= 2 * cnt)ans = (ans*(cnt + 1)) % mod;
		else cnt++;
	}
	for (int i = 1; i <= cnt; i++)ans = (ans*i) % mod;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <iostream>
#include <climits>
#include <cstring>
#include <functional>

using namespace std;

//using ll = long long;

#define rep(i, N) for(int i = 0;i < (int)N;i++)
#define LARGE INT_MAX / 2



int main() {
	int n, cnt = 0;
	while (1) {
		cnt++;
		cin >> n;
		if (n == 0) break;
		else {
			cout << "Case " << cnt << ": " << n << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3008
#include <limits.h>
#include <stdio.h>
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <sstream>
#include <string>
#include <vector>

#include <bits/stdc++.h>

namespace test {
std::string to_string(char val) {
    return std::string(1, val);
    // return std::string{val};
}
}  // namespace test

using namespace std;

int main(void) {
    int n; cin >> n; int *h; h = new int[n]; for(int i = 0; i < n; i++) cin >> h[i];
    int result = 0;
    int maxHeight = 0;
    for(int i = 0; i < n; i++){
        if(h[i] >= maxHeight){
            result++;
            maxHeight = h[i];
        }
    }

    cout << result << endl;

    return 0;
}

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

int main(){
    int a[3],k;
    cin >> a[0] >> a[1] >> a[2] >> k;
    sort(a, a+3);
    cout << a[0] +a[1] +a[2]*(1<<k) << endl;
    return 0;
}

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

int main()
{
    int l,r; cin >> l >> r;
    int ans = 2018;

    if (r-l <= 2019)
    {
        for (int i = l; i <= r; ++i)
        {
            for (int j = i+1; j <= r; ++j)
                ans = min(ans, ((i%2019)*(j%2019))%2019);
        }
        cout << ans;
        return 0;
    }

    cout << 0;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define N 200010
using namespace std;
struct Info{int nu,ne,qu;}a[N*2];
int w1[N],w2[N],p[N],q[N],s,t,n,ans,b[N],cur[N],di[N],li[N],num=1;
void jb(int x,int y,int p,int q){
	a[++num].nu=y;a[num].ne=b[x];b[x]=num;a[num].qu=p;
	a[++num].nu=x;a[num].ne=b[y];b[y]=num;a[num].qu=q;
}
bool bfs(){
	for (int i=1;i<=t;i++)di[i]=INF;
	di[s]=0;int l=1,r=1;li[l]=s;
	while (l<=r){
		for (int y=b[li[l]];y;y=a[y].ne){
			if (di[a[y].nu]==INF&&a[y].qu){li[++r]=a[y].nu;di[a[y].nu]=di[li[l]]+1;}
		}
		l++;
	}
	return (di[t]!=INF);
}
int dinic(int x,int sh){
	if (x==t){ans-=sh;return sh;}
	int n1=0,n2;
	for (int y=cur[x];y;y=a[y].ne){
		cur[x]=y;
		if (di[a[y].nu]==di[x]+1&&a[y].qu){
			n2=dinic(a[y].nu,min(a[y].qu,sh-n1));
			n1+=n2;a[y].qu-=n2;a[y^1].qu+=n2;
			if (n1==sh) return n1;
		}
	}
	return n1;
}
int main(){
	cin>>n;
	ans=n;s=n+n+1,t=n+n+2;
	for (int i=1;i<=n;i++){cin>>p[i];p[i]++;}
	for (int i=1;i<=n;i++){cin>>q[i];q[i]++;}
	for (int i=1;i<=n;i++)if (!w1[i]){for (int j=i;w1[j]==0;j=p[j])w1[j]=i;}
	for (int i=1;i<=n;i++)if (!w2[i]){for (int j=i;w2[j]==0;j=q[j])w2[j]=i+n;}
	for (int i=1;i<=n;i++){
		if (p[i]==i&&p[i]==q[i])ans--;
		else{
			if (p[i]==i)jb(w2[i],t,1,0);
			else{
				if (q[i]==i)jb(s,w1[i],1,0);
				else{
					if (p[i]==q[i])jb(w1[i],w2[i],1,1);else jb(w2[i],w1[i],1,0);
				}
			}
		}
	}
	while (bfs()){for (int i=1;i<=t;i++)cur[i]=b[i];dinic(s,INF);}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 14080
from itertools import permutations
import sys

sys.setrecursionlimit(10 ** 6)
from bisect import *
from collections import *
from heapq import *

def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def SI(): return sys.stdin.readline()[:-1]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
int1 = lambda x: int(x) - 1
def MI1(): return map(int1, sys.stdin.readline().split())
def LI1(): return list(map(int1, sys.stdin.readline().split()))
p2D = lambda x: print(*x, sep="\n")
dij = [(1, 0), (0, 1), (-1, 0), (0, -1)]

def main():
    def ok(a):
        t=str(a)
        for c,d in zip(t,dd):
            if d!=-1 and int(c)!=d:return False
        return True

    n,m=MI()
    dd=[-1]*n
    for _ in range(m):
        s,c=MI()
        if dd[s-1]!=-1 and dd[s-1]!=c:
            print(-1)
            exit()
        dd[s-1]=c
    if n==1 and dd[0]<1:
        print(0)
        exit()
    for a in range(10**(n-1),10**n):
        if ok(a):
            print(a)
            exit()
    print(-1)

main()


Measured memory_bytes: 3444
#include <iostream>
using namespace std;
int main()
{
	int n,s[100001];
	int a[100001];
	char s1;
	cin >> n;
	for(int i = 0;i < n;i++)
	{
		cin >> s1;
		if(s1 == 'o')
		{
			s[i] = 1;
		}
		else if(s1 == 'x')
		{
			s[i] = 0;
		}
		else
		{
			cout << "Error1" << endl;
			return 0;
		}
	}
	a[0] = 1;
	a[1] = 1;
	for(int i = 1;i<(n - 1);i++)
	{
		if(((a[i] + s[i]) % 2) == 0)
		{
			a[i + 1] = a[i - 1];
		}
		else
		{
			if(a[i - 1])
			{
				a[i + 1] = 0;
			}
			else
			{
				a[i + 1] = 1;
			}
		}
	}
	if((((a[n - 1] + s[n - 1] + a[n - 2] + a[0]) % 2) == 0) && (((a[0] + s[0] + a[n - 1] + a[1]) % 2) == 0))
	{
		for(int i = 0;i < n;i++)
		{
			if(a[i] == 1)
			{
				cout << 'S';
			}
			else
			{
				cout << 'W';
			}
		}
		cout << endl;
		return 0;
	}
	a[0] = 1;
	a[1] = 0;
	for(int i = 1;i<(n - 1);i++)
	{
		if(((a[i] + s[i]) % 2) == 0)
		{
			a[i + 1] = a[i - 1];
		}
		else
		{
			if(a[i - 1])
			{
				a[i + 1] = 0;
			}
			else
			{
				a[i + 1] = 1;
			}
		}
	}
	if((((a[n - 1] + s[n - 1] + a[n - 2] + a[0]) % 2) == 0) && (((a[0] + s[0] + a[n - 1] + a[1]) % 2) == 0))
	{
		for(int i = 0;i < n;i++)
		{
			if(a[i] == 1)
			{
				cout << 'S';
			}
			else
			{
				cout << 'W';
			}
		}
		cout << endl;
		return 0;
	}
	a[0] = 0;
	a[1] = 1;
	for(int i = 1;i<(n - 1);i++)
	{
		if(((a[i] + s[i]) % 2) == 0)
		{
			a[i + 1] = a[i - 1];
		}
		else
		{
			if(a[i - 1])
			{
				a[i + 1] = 0;
			}
			else
			{
				a[i + 1] = 1;
			}
		}
	}
	if((((a[n - 1] + s[n - 1] + a[n - 2] + a[0]) % 2) == 0) && (((a[0] + s[0] + a[n - 1] + a[1]) % 2) == 0))
	{
		for(int i = 0;i < n;i++)
		{
			if(a[i] == 1)
			{
				cout << 'S';
			}
			else
			{
				cout << 'W';
			}
		}
		cout << endl;
		return 0;
	}
	a[0] = 0;
	a[1] = 0;
	for(int i = 1;i<(n - 1);i++)
	{
		if(((a[i] + s[i]) % 2) == 0)
		{
			a[i + 1] = a[i - 1];
		}
		else
		{
			if(a[i - 1])
			{
				a[i + 1] = 0;
			}
			else
			{
				a[i + 1] = 1;
			}
		}
	}
	if((((a[n - 1] + s[n - 1] + a[n - 2] + a[0]) % 2) == 0) && (((a[0] + s[0] + a[n - 1] + a[1]) % 2) == 0))
	{
		for(int i = 0;i < n;i++)
		{
			if(a[i] == 1)
			{
				cout << 'S';
			}
			else
			{
				cout << 'W';
			}
		}
		cout << endl;
		return 0;
	}
	cout << "-1" << endl;
}

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

#define lli long long int

/*** vector ***/

#define v vector<int>;
#define vp vector<int,int>;

/*** map ***/

#define mi map<int>;
#define md map<double>;
#define mc map<char>;
#define ms map<string>;

int dice[6]={1,5,3,2,4,6};

void changeN(void){
  swap(dice[0],dice[3]);
  swap(dice[3],dice[5]);
  swap(dice[5],dice[1]);
}

void changeE(void){
  swap(dice[0],dice[4]);
  swap(dice[4],dice[5]);
  swap(dice[5],dice[2]);
}

void changeS(void){
  swap(dice[0],dice[1]);
  swap(dice[1],dice[5]);
  swap(dice[5],dice[3]);
}

void changeW(void){
  swap(dice[0],dice[2]);
  swap(dice[2],dice[5]);
  swap(dice[5],dice[4]);
}

void changeR(void){
  swap(dice[1],dice[4]);
  swap(dice[4],dice[3]);
  swap(dice[3],dice[2]);
}

void changeL(void){
  swap(dice[1],dice[2]);
  swap(dice[2],dice[3]);
  swap(dice[3],dice[4]);
}

int main(){

  int n,sum=1;
  string com;

  while(cin >> n,n){
    for(int i=0;i<n;i++){
      cin >> com;
      if(com[0]=='N'){
	changeN();
	sum+=dice[0];
      }
      if(com[0]=='E'){
	changeE();
	sum+=dice[0];
      }
      if(com[0]=='W'){
	changeW();
	sum+=dice[0];
      }
      if(com[0]=='S'){
	changeS();
	sum+=dice[0];
      }
      if(com[0]=='L'){
	changeL();
	sum+=dice[0];
      }
      if(com[0]=='R'){
	changeR();
	sum+=dice[0];
      }      
    }
    cout << sum << endl;
    sum=1;
    dice[0]=1; dice[1]=5; dice[2]=3; dice[3]=2; dice[4]=4; dice[5]=6; 
  }
  
  return 0;
}

Measured memory_bytes: 3172
#include<bits/stdc++.h>
#define mo 1000000007
using namespace std;
struct mat
{
	int a[2][2];
	friend mat operator *(mat a,mat b)
	{
		mat c=(mat){0,0,0,0};
		for (int i=0;i<=1;i++)
		for (int j=0;j<=1;j++)
		for (int k=0;k<=1;k++)
			c.a[i][j]=(c.a[i][j]+(long long)a.a[i][k]*b.a[k][j])%mo;
		return c;
	}
};
mat getmi(mat a,long long x)
{
	mat ans=(mat){1,0,0,1};
	while (x)
	{
		if (x&1) ans=ans*a;
		a=a*a;
		x>>=1;
	}
	return ans;
}
int getmi(int a,long long x)
{
	int ans=1;
	while (x)
	{
		if (x&1) ans=(long long)ans*a%mo;
		a=(long long)a*a%mo;
		x>>=1;
	}
	return ans;
}
int a[2010][2010];
int main()
{
	int n,m,js=0;long long k;scanf("%d%d%lld\n",&n,&m,&k);
	for (int i=1;i<=n;i++)
	for (int j=1;j<=m;j++)
	{
		a[i][j]=(getchar()=='#');js+=a[i][j];
		if (j==m) scanf("\n");
	}
	int row=0,col=0;
	for (int i=1;i<=n;i++) row+=(a[i][1]&&a[i][m]);
	for (int i=1;i<=m;i++) col+=(a[1][i]&&a[n][i]);
	if ((col)&&(row)) printf("1\n");
	else if ((!col)&&(!row)) printf("%d\n",getmi(js,k-1));
	else if ((row)&&(!col))
	{
		int p=0;
		for (int i=1;i<=n;i++)
		for (int j=1;j<m;j++) p+=(a[i][j]&&a[i][j+1]);
		mat d=getmi((mat){js,mo-p,0,row},k-1);
		printf("%d\n",(d.a[0][0]+d.a[0][1])%mo);
	}
	else
	{
		int p=0;
		for (int i=1;i<n;i++)
		for (int j=1;j<=m;j++) p+=(a[i][j]&&a[i+1][j]);
		mat d=getmi((mat){js,mo-p,0,col},k-1);
		printf("%d\n",(d.a[0][0]+d.a[0][1])%mo);
	}
}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	

Measured memory_bytes: 8448
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <ctime>
#include <stack>
#include <set>
#include <map>
using namespace std;
#define rg register
#define LL long long
#define __space putchar(' ')
#define __endl putchar('\n')
template <typename qwq> inline void read(qwq &x)
{
	x = 0;
	rg int f = 1;
	rg char c = getchar();
	while (c < '0' || c > '9')
	{
		if (c == '-') f = -1;
		c = getchar();
	}
	while (c >= '0' && c <= '9')
	{
		x = (x << 1) + (x << 3) + (c ^ 48);
		c = getchar();
	}
	x *= f;
}
template <typename qaq> inline void print(qaq x)
{
	if (x < 0)
	{
		putchar('-');
		x = -x;
	}
	if (x > 9) print(x / 10);
	putchar(x % 10 + '0');
}
int a, b, c;
int main()
{
	read(a), read(b), read(c);
	rg int ans = c - a + b;
	if (ans < 0) ans = 0;
	print(ans);
	return 0;
}

Measured memory_bytes: 256
main(i){float a,b,c,d,e,f,g,h;while(~scanf("%f%f%f%f%f%f%f%f",&a,&b,&c,&d,&e,&f,&g,&h))puts(!(a>g||a>h||c<e||d<f)?"YES":"NO");exit(0);}

Measured memory_bytes: 608
#include <iostream>
#include <algorithm>

int main() {
    using namespace std;

    string s, t;
    cin >> s >> t;
    
    if (s.length() < t.length() && s == t.substr(0, s.length())) {
        cout << "Yes" << endl;
        return 0;
    } else {
        for (int i=0; i<s.length(); i++) {
            char a = s[i];
            for (int j=0; j<t.length(); j++) {
                char b = t[j];
                if (a < b) {
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
    }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int x1,x2,a;
	scanf("%d %d",&x1,&x2);
	if(x1<x2){
		a=x2-x1;
	}
	else if(x1>x2){
		a=x1-x2;
	}
	printf("%d\n",a);
	return 0;
}


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

using namespace std;

const int N = 4e6 + 5;

typedef long long ll;

const ll mod = 1e9 + 7;

int n, m, ans = 1e9, a[305][305];
int ct[305];
bool used[305];

void rec() {
    memset(ct, 0, sizeof(ct));
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (!used[a[i][j]]) {
                ct[a[i][j]]++;
                break;
            }
        }
    }
    int j = 0;
    for (int i = 1; i <= m; i++) {
        if (ct[j] < ct[i]) {
            j = i;
        }
    }
    used[j] = 1;
    if (j == 0)
        return;
    ans = min(ans, ct[j]);
    rec();
}

main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            cin >> a[i][j];
        }
    }
    rec();
    cout << ans;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline void chmax(S &a, T b){
  if(a<b){
    a=b;
  }
}
int N, W, gain[4][100], sum[4][101], sz[4], v[100], w[100];
int main(){
  int a, b, c, d, res=0, tmp;
  long long minw, r;
  rd(N);
  rd(W);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<N;Lj4PdHRW++){
      rd(w[Lj4PdHRW]);
      rd(v[Lj4PdHRW]);
    }
  }
  minw = w[0];
  {
    int KL2GvlyY;
    for(KL2GvlyY= 0;KL2GvlyY< (N-1) + 1;KL2GvlyY++){
      w[KL2GvlyY] -= minw;
    }
  }
  {
    int Q5VJL1cS;
    for(Q5VJL1cS= 0;Q5VJL1cS< (N-1) + 1;Q5VJL1cS++){
      gain[w[Q5VJL1cS]][sz[w[Q5VJL1cS]]++] = v[Q5VJL1cS];
    }
  }
  {
    int e98WHCEY;
    for(e98WHCEY= 0;e98WHCEY< (3) + 1;e98WHCEY++){
      sort(gain[e98WHCEY], gain[e98WHCEY]+sz[e98WHCEY], greater<int>());
    }
  }
  {
    int cTE1_r3A;
    for(cTE1_r3A= 0;cTE1_r3A< (3) + 1;cTE1_r3A++){
      {
        int RZTsC2BF;
        for(RZTsC2BF= 1;RZTsC2BF< (sz[cTE1_r3A]) + 1;RZTsC2BF++){
          sum[cTE1_r3A][RZTsC2BF] += sum[cTE1_r3A][RZTsC2BF - (1) + (0)] + gain[cTE1_r3A][RZTsC2BF - (1) + (0)];
        }
      }
    }
  }
  for(a=0;a<sz[0]+1;a++){
    for(b=0;b<sz[1]+1;b++){
      for(c=0;c<sz[2]+1;c++){
        r = W - (long long)minw*a - (long long)(minw+1)*b - (long long)(minw+2)*c;
        if(r < 0){
          break;
        }
        d = min(r / (minw+3), (long long)sz[3]);
        chmax(res, sum[0][a] + sum[1][b] + sum[2][c] + sum[3][d]);
      }
    }
  }
  wt_L(res);
  putchar_unlocked('\n');
  return 0;
}
// cLay varsion 20170429-1

// --- original code ---
// int N, W, w[100], v[100];
// int gain[4][100], sum[4][101], sz[4];
// {
//   int res = 0, tmp;
//   int a, b, c, d;
//   ll r, minw;
//   rd(N, W, (w,v)(N));
//   minw = w[0];
//   w[0..N-1] -= minw;
//   gain[w[0..N-1]][sz[w[0..]]++] = v[0..];
//   sort(gain[0..3], gain[0..]+sz[0..], greater<int>());
// 
//   sum[0...3][1..sz[0...]] += sum[0...][0..] + gain[0...][0..];
// 
//   rep(a,sz[0]+1) rep(b,sz[1]+1) rep(c,sz[2]+1){
//     r = W - (ll)minw*a - (ll)(minw+1)*b - (ll)(minw+2)*c;
//     if(r < 0) break;
//     d = min(r / (minw+3), (ll)sz[3]);
//     res >?= sum[0][a] + sum[1][b] + sum[2][c] + sum[3][d];
//   }
//   wt(res);
// }


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<long long>L(N + 1);
    L[0] = 2, L[1] = 1;
    for (int i = 2; i <= N; i++) {
        L[i] = L[i - 1] + L[i - 2];
    }

    cout << L[N] << endl;

    return 0;
}

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

using namespace std;

int main()
{
	int n, c, a, l;
	cin>>c>>n;
        if(c>n) {l=c;a=n;}
        else   {l=n; a=c;}
	while(l--)
	{
		cout<<a;
	}
	cout<<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 REP1(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
using ll = long long;
const ll mod = 1e9 + 7;

int main() {
  string s, t;
  cin >> s >> t;
  if (s == t.substr(0, SZ(s))) {
	  cout << "Yes" << endl;
	} else {
	  cout << "No" << endl;
	}
  return 0;
}


Measured memory_bytes: 3624
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int Bstock =0;
    String ans = "";
    for(int i=s.length()-1;i>=0;i--){
      if(s.substring(i,i+1).equals("B")){
        Bstock++;
      }else if(Bstock>0){
        Bstock--;
      }else{
        ans=s.substring(i,i+1)+ans;
      }
    }
    System.out.println(ans);
        
  }
  

  
}

Measured memory_bytes: 21716
import java.io.*;

public class Main {

  static String s;

  public static void main(String[] args) throws Exception {
    
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    //String[] in = br.readLine().split(" ");
    s = br.readLine();

    br.close();
    boolean hasSeven = false;
    for(int i = 0; i < 3; i++){
      if(s.charAt(i) == '7') hasSeven = true;
    }

    System.out.println(hasSeven ? "Yes" : "No");

  }
}

Measured memory_bytes: 32544
def dijkstra(s):
    color = ["white" for i in range(n)]

    d = [inf for i in range(n)]

    p = [-1 for i in range(n)]

    d[s] = 0

    while True:
        mincost = inf

        for i in range(n):
            if color[i] != "black" and d[i] < mincost:
                mincost = d[i]
                u = i

        if mincost == inf:
            break

        color[u] = "black"

        for v in range(n):
            if color[v] != "black" and ci[u][v] != inf:
                if d[u] + ci[u][v] < d[v]:
                    d[v] = d[u] + ci[u][v]
                    p[v] = u
                    color[v] = "gray"
    return d


inf = 10 ** 9
n = int(input())
ci = [[inf for i in range(n)] for j in range(n)]

for i in range(n):
    data = list(map(int, input().split()))
    u = data[0]
    k = data[1]

    for j in range(0, 2*k, 2):
        v, w = data[j+2], data[j+3]
        ci[u][v] = w

dList = dijkstra(0)

for i, d in enumerate(dList):
    print(i, d)



Measured memory_bytes: 5864
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,t = map(int,input().split())
A = list(map(int,input().split()))
B = [0] * n
acumin = A[0]
for i in range(n):
  acumin = min(acumin,A[i])
  B[i] = A[i] - acumin
C = collections.Counter(B)
print(C[max(B)])

Measured memory_bytes: 69744
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
	if(was_output)cout << " ";
	cout << a;
	was_output = true;
}
void outendl(){
	was_output = false;
	cout << endl;
}

double func(int n){
	ll res = 0;
	vector<pii> man(n);
	foreach(i, man)cin>>i.first>>i.second;
	sort(all(man));
	vector<pii> p[2];
	int slowest[2]={0, 0};

	//time side needtime needcount
	using T = tuple<int, int, int, int>;
	priority_queuer<T> pq;
	foreach(i, man){
		pq.emplace(i.first, 1, i.first, i.second*2-1);
		chmax(slowest[1], i.first);
	}
	while(pq.size()){
		int ntime = get<0>(pq.top());
		chmax(res, (ll)ntime);
		while(pq.size()&&ntime==get<0>(pq.top())){
			T d = pq.top();
			pq.pop();
			int lane = get<1>(d);
			int needtime = get<2>(d);
			int needcount = get<3>(d);
			if(needcount){
				p[lane].emplace_back(needtime, needcount);
			}
		}
		rep(i, 2){
			sort(all(p[i]));
			foreach(j, p[i]){
				int needtime = max(slowest[!i], ntime+j.first);
				slowest[!i] = needtime;
				pq.emplace(needtime, !i, j.first, j.second-1);
			}
			p[i].clear();
		}
	}

	return res;
}

int main(){
	int n;
	while(cin>>n&&n){
		cout << func(n) << endl;
	}
	return 0;
}



Measured memory_bytes: 3140
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]
    MOD = 10**9+7
    from math import factorial
    N = II()
    X = LMIIS()
    f = factorial(N-1) % MOD
    def calc(k,slimes):
        r = 0
        for k in range(N-1):
            r += (slimes[-1]-slimes[-2-k]) * f * pow((N-k-1),MOD-2,MOD)
            r %= MOD
        return r
    print(calc(0,X))


if __name__ == '__main__':
    main()

Measured memory_bytes: 62576
import sys
sys.setrecursionlimit(10**7)

n = int(input())
l=[list(input()) for _ in range(n)]
es = [[] for _ in range(n)]
for i in range(n):
    for j in range(n):
        if l[i][j]=="1":
            es[i].append(j)
colors = [0 for _ in range(n)]

def dfs(v,color):
    colors[v] = color
    for to in es[v]:
        if colors[to] == color:
            return False
        if colors[to] == 0 and not dfs(to, -color):
            return False
    return True

def is_nibu():
    return dfs(0,1)

if not is_nibu():
    print(-1)
    exit()



d = [[float("inf") for i in range(n)] for i in range(n)]

for i in range(n):
    for j in range(n):
        if l[i][j]=="1":
            d[i][j]=1

for i in range(n):
    d[i][i] = 0

def warshall_floyd(d):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

ans=0
dd=warshall_floyd(d)
for i in range(n):
    ans=max(ans,max(dd[i]))

print(ans+1)


Measured memory_bytes: 57820
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n = ni()
a=nl()

ans = [0]
for i in range(n): 
  if i%2==0:
    ans[0]+=a[i]
  else:
    ans[0]-=a[i]

print(ans[0])
for i in range(1,n):
  an = 2*a[i-1]-ans[i-1]
  print(an)
  ans.append(an)


Measured memory_bytes: 20736
#include <iostream>
#include <vector>
#include <map>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> s(n+1);
    for (int i = 1; i <= n; ++i) {
        int st;
        cin >> st;
        s[st] = i;
    }

    for (int i = 1; i <= n; ++i){
        cout << s[i] << ' ';
    }
}


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

int N,M,X;
int cnt1,cnt2;

int main()
{
    scanf("%d%d%d",&N,&M,&X);
    for(int i = 0; i < M; i++)
    {
        int a;
        scanf("%d",&a);
        if(0 <= a && a <= X)cnt1++;
        if(X <= a && a <= N)cnt2++;
    }
    printf("%d\n",min(cnt1,cnt2));
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
	ll N, K;
	cin >> N >> K;
	if (K % 2 == 1) {
		ll a = N / K;
		cout << (ll)pow(a, 3) << endl;
		return 0;
	}
	else {
		ll a = N / K;
		ll b = N % K;
		ll x = a;
		if (b >= K / 2) {
			x++;
		}
      	
		cout << (ll)pow(a, 3) + (ll)pow(x, 3) << endl;
		return 0;
	}
}

Measured memory_bytes: 384
/* ex3_3
    nnasy */

#include <stdio.h>

int main(void) {
    int number, baseNumber;    //整数変数の宣言
    scanf("%d %d", &number, &baseNumber);    //number, baseNumberに入力

    int count = 0;    //numberをbaseNumberで割れる回数(=numberをbaseNumber進数にした時の桁数)を表現する整数変数を宣言
    while (number>0){    //割れる回数(=count)を調べる
        number = number/baseNumber;
        count++;
    }
    printf("%d\n", count);    //求める桁数(=count)を出力

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int n,x;
int odd,even,four; 
int main(){
	cin>>n;
	while(n--){
		cin>>x;
		if(x%4==0)four++;
		else if(x%2==0) even++;
		else odd++;
	}
	string ans;
	if(even==0){
		if(odd<=four+1)ans="Yes";
		else ans="No";
	}else{
		if(odd<=four)ans="Yes";
		else ans="No";
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		long mod = (long)(1e9+7);
		Scanner input = new Scanner(System.in);
		double a = input.nextDouble();
		double b = input.nextDouble();
		double x = input.nextDouble();
		double V=a*a*b;
		x/=a; //Converting from prism to rectangle
		V/=a;
		double baseleg = 2*x/b;
		if (baseleg<=a) {
			double theta = Math.toDegrees(Math.atan(b/baseleg));
			System.out.println(theta);
		}else {
			double remainingVol = V-x;
			double y = 2*remainingVol/a;
			double theta = Math.toDegrees(Math.atan(y/a));
			System.out.println(theta);
		}
	}
}

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back

//#define int long long

#define upper(n,m) (n+m-1)/m
#define rounding(n) (int)((double)n+0.5)

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define ALL(a) a.begin(),a.end()

#define coutALL(i,a) {int i=0;for(int e:a) cout<<(i++?" ":"")<<e; cout<<endl;}
#define coutYN(a) cout<<(a?"Yes":"No")<<endl;
#define coutyn(a) cout<<(a?"yes":"no")<<endl;

#define deb cout<<"debug"<<endl
#define debn(n) cout<<"debug: "<<n<<endl

const int INF=INT_MAX;
const int MOD=(int)1e9+7;
const double EPS=1e-12;
//const int dx[]={0,1,0,-1},dy[]={-1,0,1,0};
const int dx[]={-1,-1,-1,0,1,1,1,0},dy[]={-1,0,1,1,1,0,-1,-1};

using namespace std;

typedef pair<int,int> P;
typedef long long LL;

LL ans;

void merge(vector <int> &A,int left,int mid,int right){

  int n1=mid-left;
  int n2=right-mid;
  int L[n1], R[n2];

  for(int i=0;i<n1;i++) L[i] = A[left + i];
  for(int i = 0;i<n2;i++) R[i] = A[mid + i];

  L[n1] = INF;
  R[n2] = INF;

  for(int i=0,j=0,k=left;k<right;k++){

    if(L[i]<=R[j]){

      A[k] = L[i];
      i++;

    }

    else {

      A[k] = R[j];
      j++;
      ans+=(LL)n1-(LL)i;

    }

  }

}

void mergeSort(vector <int> &A,int left,int right){

  if(left+1 < right){

    int mid = (left + right)/2;

    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);

  }

}

signed main(){

  int n;
  cin>>n;

  vector <int> a(n);
  REP(i,n) cin>>a[i];

  mergeSort(a,0,n);

  cout<<ans<<endl;

  return 0;

}


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

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll n;
    cin >> n;
    ll m = sqrt((long double)n);
    vector <ll> a;
    for (ll i = 1; i <= (ll)m; i++)
        if (n % i == 0 && n / i * i == n)
            a.push_back(i);
    if (n / 2 == 0)
        a.push_back(n / 2);
    ll ans = n - 1;
    for (ll &i : a){
        ll t = i + n / i - 2;
        ans = min (ans, t);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;

//#define int long long
//using ll = boost::multiprecision::cpp_int;
using ll = long long;
//constexpr int INF = 1e9;//INT_MAX=(1<<31)-1=2147483647
constexpr ll INF = (ll)1e18;//(1LL<<63)-1=9223372036854775807
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-9;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var) std::cout<<var<<std::endl
#define rep(i, n)   for(ll i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(ll i=1, i##_length=(n); i<=i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define PI (acos(-1))
template<typename T> inline T power(T x, T n){ return n ? power(x*x%MOD,n/2)*(n%2?x:1)%MOD : 1; }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/

constexpr ll N_MAX = 50;
constexpr ll V_I_MAX = 1000000000000000;

ll N, A, B;
ll v[N_MAX];

void input() {
	scanf("%lld%lld%lld", &N, &A, &B);
	rep(i, N) scanf("%lld", v + i);
}

void solve() {
	map<ll,ll> m;
	rep(i,N){
		m[-v[i]]++;
	}

	ll count=0;
	ll kindcount=0;
	map<ll,ll> buy;
	for(auto item:m){
		if(count+item.second<=A){
			buy[item.first]=item.second;
			count+=item.second;
			kindcount++;
			if(count==A)break;
		}else{
			buy[item.first]=A-count;
			count=A;
			kindcount++;
			break;
		}
	}

	double ave=0.0;
	for(auto b:buy){
		ave+=b.first*b.second;
	}
	ave/=-A;

	ll ans=0;
	if(kindcount==1){
		ll bfirst;
		for(auto b:buy){
			bfirst=b.first;
		}
		for(ll i=A;i<=B;i++){
			boost::multiprecision::cpp_int t=1;
			ll se=m[bfirst];
			rep(j,i){t*=se;se--;}
			repeq(j,i){t/=j;}
			ans+=(ll)t;
		}
	}else{
		boost::multiprecision::cpp_int tt=1;
		for(auto b:buy){
			boost::multiprecision::cpp_int t=1;
			ll se=m[b.first];
			rep(j,b.second){t*=se;se--;}
			repeq(j,b.second){t/=j;}
			tt*=t;
		}
		ans=(ll)tt;
	}
	printf("%.6f\n", ave);
	printf("%lld\n", ans);
}

signed main() {
	input();
	solve();
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<stack>
#include<queue>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	int ans = 0;
	for (int i = 1; i <= b - a; i++) {
		ans += i;
	}
	cout << ans - b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
const int maxx = 200005; 
vector<int> graph[maxx]; 
void dfs(int curr, int& cnt, int*  
             visited, vector<int>& duringdfs) 
{ 
    visited[curr] = 1; 
  
    // Number of nodes in this component 
    ++cnt; 
  
    // Stores the nodes which belong  
    // to current component 
    duringdfs.push_back(curr); 
    for (auto& child : graph[curr]) { 
  
        // If the child is not visited 
        if (visited[child] == 0) { 
            dfs(child, cnt, visited, duringdfs); 
        } 
    } 
} 
  
// Function to return the desired  
// count for every node in the graph 
void MaximumVisit(int n, int k) 
{ 
    // To keep track of nodes we visit 
    int visited[maxx]; 
  
    // Mark every node unvisited 
    memset(visited, 0, sizeof visited); 
    int ans[maxx]; 
  
    // No of connected elements for each node 
    memset(ans, 0, sizeof ans); 
    vector<int> duringdfs;  
    for (int i = 1; i <= n; ++i) { 
        duringdfs.clear(); 
        int cnt = 0; 
  
        // If a node is not visited, perform a DFS as  
        // this node belongs to a different component 
        // which is not yet visited 
        if (visited[i] == 0) { 
            cnt = 0; 
            dfs(i, cnt, visited, duringdfs); 
        } 
  
        // Now store the count of all the visited 
        // nodes for any particular component. 
        for (auto& x : duringdfs) { 
            ans[x] = cnt; 
        } 
    } 
     
int maxi=ans[1];
    for (int i = 2; i <= n; ++i) { 
        maxi=max(maxi,ans[i]);
    } 
    cout <<maxi; 
    return; 
} 
  
// Function to build the graph 
void MakeGraph(int M){
    for(int i=0;i<M;i++)
    {
        int x,y;
        cin>>x>>y;
    graph[x].push_back(y); 
    graph[y].push_back(x); 
    }
} 
int main() 
{ 
    int N,M;
    cin>>N>>M;
    MakeGraph(M); 
     
    MaximumVisit(N,M); 
    return 0; 
} 

Measured memory_bytes: 29060