akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {

    int n, m;

    while(cin >> n >> m, n) {
        vector< int > h(1500), w(1500);
        for(int i = 0; i < n; i++) cin >> h[i];
        for(int i = 0; i < m; i++) cin >> w[i];

        int maxi = 0;
        vector< int > ww, hh;
        for(int i = 0; i < m; i++) {
            int sumw = 0;
            for(int j = i; j < m; j++) {
                sumw += w[j];
                maxi = max(maxi, sumw);
                ww.push_back(sumw);
            }
        }
        for(int i = 0; i < n; i++) {
            int sumh = 0;
            for(int j = i; j < n; j++) {
                sumh += h[j];
                maxi = max(maxi, sumh);
                hh.push_back(sumh);
            }
        }

        sort(hh.begin(), hh.end());
        sort(ww.begin(), ww.end());
        long long ans = 0;
        for(int i = 1; i <= maxi; i++) {
            ans += (long long)(upper_bound(hh.begin(), hh.end(), i) - lower_bound(hh.begin(), hh.end(), i)) * (upper_bound(ww.begin(), ww.end(), i) - lower_bound(ww.begin(), ww.end(), i));
        }
        cout << ans << endl;
    }
}



Measured memory_bytes: 19660
#if 1

#include <bits/stdc++.h>
using namespace std;
int n,m,ans,sum;
int c[15];
int cnt[15];
int a[15][15];
int p[15];


int main()
{
    cin >> n >> m;
    for(int i = 1;i <= m;i++)
    {
        cin >> cnt[i];
        for(int j = 1;j <= cnt[i];j++)
        {
            cin >> a[i][j];
        }
    }
    for(int i = 1;i <= m;i++)
    {
        cin >> p[i];
    }
    int ok = 0;
    for(int i = 0;i < (1 << n);i++)
    {
        ok = 0;
        int ccnt = 0;
        for(int j = 0;j < n;j++)
        {
            if(i & (1 << j))
            {
                c[j+1] = 1;
            }
            else c[j+1] = 0;
        }
        for(int j = 1;j <= m;j++)
        {
            ccnt = 0;
            for(int k = 1;k <= m;k++)
            {
                if(c[a[j][k]]) ccnt++;
            }
            if(ccnt % 2 != p[j])
            {
                ok = 1;
                break;
            }
        }
        ans += 1-ok;
    }
    printf("%d",ans);
}

#endif // 1++

Measured memory_bytes: 256
//SameIntegers.cpp (C)
#include <iostream>
using namespace std;

int main(){
  int A, B, C;
  int Ans = 0;
  cin >> A >> B >> C;
  if((A%2 == B%2)&&(A%2 == C%2)){
    int M = max(max(A,B),C);
    Ans = (3*M - A - B - C)/2;
  }else{
    if(A%2 == B%2) ++A, ++B, ++Ans;
    else if(A%2 == C%2) ++C, ++A, ++Ans;
    else  ++B, ++C, ++Ans;
    int M = max(max(A,B),C);
    Ans += (3*M - A - B - C)/2;
  }
  printf("%d\n",Ans);
}


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

int main(void){
  	char moji[200]={0};
	bool flag=true;
	cin >> moji ;

	int strnum = strlen(moji);
	int i;
	for( i=1; i <= strnum/2; i++)
	{
		if(moji[i-1] != moji[strnum-i]){
			break;
		}
	}
	if( strnum/2+1 != i ){
		flag = false;
	}
	strnum = (strlen(moji) -1) /2;
	for( i=1; i <= strnum/2; i++)
	{
		if(moji[i-1] != moji[strnum-i]){
			break;
		}
	}
	if( strnum/2+1 != i ){
		flag = false;
	}
	strnum = strlen(moji);

	for( i=(strnum+3)/2; i <= (strnum*2+(strnum+3))/4; i++)
	{
		if(moji[i-1] != moji[strnum-i]){
			break;
		}
	}
	if( (strnum*2+(strnum+3))/4+1 != i ){
		flag = false;
	}

	if( flag == true ){


		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
int main(){
	
	int s=0;
	int h=0,m=0;
	cin >> s;
	h=s/3600;
	s%=3600;
	m=s/60;
	s=s%60;
	cout << h << ":" << m << ":" << s << endl;
}

Measured memory_bytes: 1168
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
  int n,t; cin>>n>>t;
  int a[n]; rep(i,n) cin>>a[i];
  int ben=0,min_val=a[0],max_idx=0,max_val=a[0],cnt=1;
  reps(i,n-1){
    min_val = min(min_val, a[i]);
    if(ben==a[i]-min_val) cnt++;
    if(ben<a[i]-min_val) ben = a[i]-min_val, cnt = 1;
  }
  cout << cnt << endl;


  return 0;
}


Measured memory_bytes: 640
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

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

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

int main()
{
  ll A,B,C,K,M;
  cin>>A>>B>>C;
  cin>>K;

  for(int i=0;i<K;++i){
    M=max(A,max(B,C));
    if (M==A) {A*=2;}
    else if (M==B) {B*=2;}
    else {C*=2;}
  }

cout<<A+B+C<<endl;
}

Measured memory_bytes: 256
// OBïÄh2011 Day4 A : åKåNÌ

#include <iostream>
#include <vector>
#include <complex>
#include <algorithm>

using namespace std;

const double EPS = 1e-8;

int main(){
	int H, W;
	string f[600];
	while(cin >> H >> W){
		for(int i=H-1;i>=0;i--) cin >> f[i];

		vector< pair<double, int> > vd;
		// ÌæªÏíé¸_ð²×é.
		// X«(j/i)ðå«­µ½Æ«ÌÌæÌ¸àÁÄ¨­
		for(int i=1;i<=H;i++){
			for(int j=0;j<=W;j++){
				int cnt = 0;
				for(int k=0;k<4;k++){
					int ni = i-k%2;
					int nj = j-k/2;
					if(0<=ni&&ni<H&&0<=nj&&nj<W&&f[ni][nj]=='#') cnt++;
				}
				if(cnt == 1){
					if(0<=i-1&&i-1<H&&0<=j&&j<W&&f[i-1][j]=='#') vd.push_back(make_pair((double)j/i,  1));
					if(0<=i&&i<H&&0<=j-1&&j-1<W&&f[i][j-1]=='#') vd.push_back(make_pair((double)j/i, -1));
				}
				if(cnt == 3){
					if(0<=i-1&&i-1<H&&0<=j&&j<W&&f[i-1][j]=='.') vd.push_back(make_pair((double)j/i,  1));
					if(0<=i&&i<H&&0<=j-1&&j-1<W&&f[i][j-1]=='.') vd.push_back(make_pair((double)j/i, -1));
				}
			}
		}
		sort(vd.begin(), vd.end());

		int res = 1, cur = 1;
		// X«ðå«­µÄ¢«AÌæÌ¸ð²×é
		for(int i=0;i<vd.size(); ){
			int idx = i;
			while(idx < vd.size() && abs(vd[i].first-vd[idx].first) < EPS)
				cur += vd[idx++].second;
			i = idx;
			res = max(cur, res);
		}
		cout << res << endl;
	}
}

Measured memory_bytes: 2528
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int count = 0;
		for (int i = a; i <= b; i++) {
			if (c % i == 0) {
				count++;
			}
		}
		System.out.println(count);
		sc.close();
	}
}


Measured memory_bytes: 26228
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs

const int MAXN = 100500;

int n, k;
vector<pair<int, int>> v;
int sz[MAXN];
int types = 0;
priority_queue < pair<int, int> > q;
long long ans;
long long curAns;

int main() { 
  scanf("%d %d", &n, &k);

  for (int i = 0; i < n; i++) {
    int t, d;
    scanf("%d %d", &t, &d);
    v.push_back(make_pair(d, t));
  }

  sort(all(v));
  reverse(all(v));

  for (int i = 0; i < k; i++) {
    int curD = v[i].first, curT = v[i].second;
    ans += curD;
    if (sz[curT] == 0) {
      types++;
    }
    sz[curT]++;
    q.push(make_pair(-curD, curT));
  }
  ans += 1ll * types * types;
  curAns = ans;

  for (int i = k; i < n; i++) {
    int curD = v[i].first, curT = v[i].second;  
    if (sz[curT] == 0) {
      bool found = false;
      while (!found && !q.empty()) {
        pair<int, int> p = q.top();
        q.pop();
        if (sz[p.second] == 1) {
          continue;
        }
        sz[p.second]--;
        curAns -= (-p.first);
        found = true;
        break;
      }
      if (found) {
        sz[curT]++;
        curAns -= (1ll * types * types);
        types++;
        curAns += (1ll * types * types);
        q.push(make_pair(-curD, curT));
        curAns += curD;
      }
    } else {
      bool found = false;
      while (!found && !q.empty()) {
        pair<int, int> p = q.top();
        if (sz[p.second] == 1) {
          q.pop();
          continue;
        }
        if (-p.first < curD) {
          found = true;
          sz[p.second]--;
          curAns -= (-p.first);
          found = true;
        }
        break;
      }
      if (found) {
        sz[curT]++;
        curAns += curD;
        q.push(make_pair(-curD, curT));
      }
    }
    ans = max(ans, curAns);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);i++)
#define urep(i,a,n) for(ll i = (a);i>=(n);i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF 1000000009
typedef long long ll;
using namespace std;
ll N, M;
ll A, B;
ll ans[201];
int main() {
	cin >> N;
	rep(i, 1, N+1) {
		for (int j = 1; j <= i; j += 2) {
			if (i%j == 0)ans[i]++;
		}
	}
	ll ans1 = 0;
	rep(i, 1, N + 1) {
		if (ans[i] == 8)ans1++;
	}
	cout << ans1 << endl;
	cin >> ans[0];
	return 0;
}

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

using namespace std;
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<iomanip>
#include<stack>
#include<set>
#include<functional>
#include<map>

#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int dr[] = { 0, 1, 0, -1 };
const int dc[] = { 1, 0, -1, 0 };
#define NN 1
#define EE 0
#define WW 2
#define SS 3
typedef pair<int, int> P;
int main(){
	int N,M;
	while (cin >> N, N){
		set<P> gem;
		string s; int cnt;
		int r = 10, c = 10;
		REP(i, N){
			int a, b;
			cin >> a >> b;
			gem.insert({ b, a });
		}
		cin >> M;
		REP(i, M){
			cin >> s >> cnt;
			int d;
			if (s == "N")d = NN;
			if (s == "W")d = WW;
			if (s == "E")d = EE;
			if (s == "S")d = SS;
			REP(_, cnt){
				r = r + dr[d];
				c = c + dc[d];
				if (gem.count({ r, c }))gem.erase({ r, c });
			}

		}
		if (gem.size())cout << "No" << endl;
		else cout << "Yes" << endl;
	}

	return 0;
}

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

int main(){
  int n, A[100];
  cin >> n;
  for (int i = 0; i < n; i++) cin >> A[i];

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

  cout << endl;


return 0;
}

Measured memory_bytes: 3048
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>

const int MOD = 998244353;
const int kN = 300 + 5;
int n, m;
int a[kN][kN];

int power(int a, int b) {
  int ret = 1;
  while (b) {
    if (b & 1) ret = ret * 1LL * a % MOD;
    a = a * 1LL * a % MOD;
    b >>= 1;
  }
  return ret;
}

int gauss() {
  int ret = 0;
  for (int i = 0, p = 0; i < n; ++ i) {
    int k = -1;
    while (k == -1 && p != m) {
      for (int j = i; j < n; ++ j) {
        if (a[j][p]) {
          k = j;
          break;
        }
      }
      if (k == -1) {
        ++ p;
      }
    }
    if (k == -1) break;
    ret ++;
    for (int r = 0; r < m; ++ r)
      std::swap(a[i][r], a[k][r]);
    for (int w = i + 1; w < n; ++ w) {
      if (a[w][p]) {
        for (int r = 0; r < m; ++ r)
          a[w][r] ^= a[i][r];
      }
    }
    ++ p;
  }
  return ret;
}

int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++ i) {
    for (int j = 0; j < m; ++ j) {
      scanf("%d", &a[i][j]);
    }
  }
  int rank = gauss();
  int result = (power(2, n) - power(2, n - rank) + MOD) % MOD * 1LL * power(2, m - 1) % MOD;
  printf("%d\n", result);
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <chrono>
#include <queue>
#include <functional>

#define out(t) cout << (t) << "\n"

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef unsigned int uint;

int popcount(uint x) {
    x -= x >> 1 & 0x55555555;
    x = (x & 0x33333333) + (x >> 2 & 0x33333333);
    x = x + (x >> 4) & 0x0F0F0F0F;
    return x * 0x01010101 >> 24;
}

int tzcnt(uint x) {
    return popcount(~x & x - 1);
}

struct Point {
    int x, y;

    Point(int p, int q) : x(p), y(q) {}
};

ll ans[100];

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

    int A, B;
    cin >> A >> B;

    int ans = 0;

    for (int i = A; i <= B; ++i) {
        ans += (i / 10000) == (i % 10) && (i / 1000 % 10) == (i / 10 % 10);
    }

    out(ans);

    int aaa;
    cin >> aaa;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;

int N, K;
int h[100000];

signed main()
{
	cin >> N >> K;
	REP(i, N) cin >> h[i];

	int ans = 0;
	REP(i, N)
	{
		if (h[i] >= K)
			ans++;
	}
	cout << ans << endl;
}



Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int C = in.nextInt();
            int[][] D = new int[C][C];
            for (int r = 0; r < C; r++) {
                for (int c = 0; c < C; c++) {
                    D[r][c] = in.nextInt();
                }
            }
            int[][] color = new int[N][N];
            for (int r = 0; r < N; r++) {
                for (int c = 0; c < N; c++) {
                    color[r][c] = in.nextInt() - 1;
                }
            }

            int[][] count = new int[3][C];
            for (int r = 0; r < N; r++) {
                for (int c = 0; c < N; c++) {
                    count[(r + c) % 3][color[r][c]]++;
                }
            }

            int min = (int) 1e9;
            for (int c1 = 0; c1 < C; c1++) {
                for (int c2 = 0; c2 < C; c2++) {
                    if (c2 == c1) {
                        continue;
                    }
                    for (int c3 = 0; c3 < C; c3++) {
                        if (c3 == c1) {
                            continue;
                        }
                        if (c3 == c2) {
                            continue;
                        }
                        int sum = 0;
                        for (int j = 0; j < C; j++) {
                            sum += count[0][j] * D[j][c1];
                            sum += count[1][j] * D[j][c2];
                            sum += count[2][j] * D[j][c3];
                        }
                        min = Math.min(min, sum);
                    }
                }
            }

            System.out.println(min);
        }
    }
}


Measured memory_bytes: 91296
#include <stdio.h>
int main(void){
    int D;

    scanf("%d",&D);
    
    if(D==25)
        printf("Christmas\n");
    else if(D==24)
        printf("Christmas Eve\n");
    else if(D==23)
        printf("Christmas Eve Eve\n");
    else if(D==22)
        printf("Christmas Eve Eve Eve\n");
        
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
	int ret=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-') w=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') ret=ret*10+ch-'0',ch=getchar();
	return w*ret;
}
double n;
int main()
{
	cin>>n;
	for(double i=1;i<=50000;i++)
	if((int)(i*1.08)==(int)n)
	{
		cout<<(int)i<<endl;
		return 0;
	}
	cout<<":("<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <limits.h>
#include <math.h>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
const ll INF = INT_MAX;


int main() {
  ll N,M;
  cin >> N >> M;
  vector<ll> x(N),y(N),z(N);
  vector<vector<ll> > sum(8,vector<ll>(N));
  repeat(i,N){
    cin >> x[i] >> y[i] >> z[i];
    sum[0][i] = x[i]+y[i]+z[i];
    sum[1][i] = x[i]+y[i]-z[i];
    sum[2][i] = x[i]-y[i]+z[i];
    sum[3][i] = x[i]-y[i]-z[i];
    sum[4][i] = -x[i]+y[i]+z[i];
    sum[5][i] = -x[i]+y[i]-z[i];
    sum[6][i] = -x[i]-y[i]+z[i];
    sum[7][i] = -x[i]-y[i]-z[i];
  }
  repeat(i,8){
    sort(sum[i].begin(),sum[i].end(),greater<ll>());
  }
  ll ans = 0;
  repeat(i,8){
    ll s=0;
    repeat(j,M){
      s+=sum[i][j];
    }
    ans = max(ans,s);
  }
  cout << ans << endl;
  return 0;
}


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

#define int long long

#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
typedef pair<pint,pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007;
const ll INF=1e18;

int N;
double A,T;
double h[1010];
double ans=INF,mincnt=INF;
    
signed main(){
    cin.tie(0);
	ios::sync_with_stdio(false);
    cin>>N>>T>>A;
rep(i,0,N){
    cin>>h[i];
    double x=T-h[i]*0.006;
    if(abs(A-x)<ans){
        ans=abs(A-x);
        mincnt=i+1;
    }
}
    
    cout<<mincnt<<endl;
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}

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

const string h = "lllllllrrrrrrrrrllllrlllrl";

int main() {
  string s;
  while (cin >> s, s[0] != '#') {
    int cur = -1;
    int ans = -1;
    for (auto&& c : s) {
      if (h[c - 'a'] == 'l') {
        if (cur != 0) ++ans;
        cur = 0;
      } else {
        if (cur != 1) ++ans;
        cur = 1;
      }
    }
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3156
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VLL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VB> VVB;

// conversion
#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)

// container
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define GSORT(c) sort((c).begin(), (c).end(), greater<decltype((c).front())>())
#define SZ(x) (INT((x).size()))
#define MEMSET(c, v) memset((c), v, sizeof(c))

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// constant
// const ll MOD = 1e9 + 7;
// const int INF = 1e9;
// const ll INF = 1e15;
// const int dx[4] = {0, -1, 1, 0};
// const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define yes(c) cout << ((c) ? "yes" : "no") << endl;

#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;


// --------------------------------------------------------


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

  int N;
  ll K;
  cin >> N >> K;

  VL num(100010, 0);

  REP(i, N) {
    ll a, b;
    cin >> a >> b;
    num[a] += b;
  }

  ll cnt = 0;
  NREP(i, 100000) {
    cnt += num[i];
    if (cnt >= K) {
      cout << i << endl;
      return 0;
    }
  }
}

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

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main()
{
  int N, K;
  cin >> N >> K;

  vector<int> P(N);
  rep(i, N) cin >> P[i];

  std::sort(P.begin(), P.end());
  int sum = 0;
  rep(i, K)
  {
    sum += P[i];
  }

  cout << sum << endl;

  return 0;
}


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

#define rep(i,a,b) for(int i=int(a);i<=int(b);++i)
#define nrep(i,a,b) for(int i=int(a);i>=int(b);--i)
#define trv(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define watch(x) cout<<"\n"<<#x<<" is "<<x<<"\n"
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define ZERO(box) memset(box, 0, sizeof(box));
#define pb push_back
#define mt make_tuple
#define eb emplace_back
#define chkbit(s, b) (s & (1<<b))
#define leadzero(a) __builtin_clz(a) // count leading zeroes
#define trailzero(a) __builtin_ctz(a) // count trailing zeroes
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<vi> vvi;
const int mod=1e9+7;


void solve(){
	string s;
	cin>>s;
	stack<char> st;
	for(char c:s){
		if(c=='0')st.push('0');
		else if(c=='1') st.push('1');
		else if(!st.empty()) st.pop();
	}
	string f="";
	while(!st.empty()) {
		f = st.top() + f;
		st.pop();
	}
	cout<<f;
}


int main(){
	int t=1;
	//cin>>t;
	while(t--){
		solve();	
	}	
	return 0;
}
/*input
10
*/

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {

  int N;
  do {
    scanf("%d", &N);
  } while (N < 1 || N > 20);

  int H[N];
  for (int i = 0; i < N; i++) {
    do {
      scanf("%d", &H[i]);
    } while (H[i] < 1 || H[i] > 100);
  }

  int m;
  int n = 1;
  for (int i = 1; i < N; i++) {
    m = 0;
    for (int j = i - 1; j >= 0; j--) {
      if (H[i] >= H[j]) {
	m++;
      }
    }
    if (m == i) {
      n++;
    }
  }

  printf("%d\n", n);

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, M;
  int x=0;
  cin >> N >> M;
  
  if(N!=0) x=N*(N-1)/2;
  if(M!=0) x+=M*(M-1)/2;
  
  cout << x << endl;

  return 0;
      
}

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

int main() {
    int N, W;

    scanf("%d%d", &N, &W);

    vector<int> weights(N + 1);
    vector<int> values(N + 1);

    for (int i = 1; i <= N; i++) {
        scanf("%d%d", &weights[i], &values[i]);
    }

    int sum = 0;

    for (int x : values) {
        sum += x;
    }

    vector<long long> dp(sum + 1, 1e18L + 5);
    dp[0] = 0;

    //dp[i] = minimum weight required to achieve sum i
    for (int i = 1; i <= N; i++) {
        for (int size = sum - values[i]; size >= 0; size--) {
            dp[size + values[i]] = min(dp[size + values[i]], dp[size] + weights[i]);
        }
    }

    int m = 0;

    for (int i = 1; i <= sum; i++) {
        if (dp[i] <= W) {
            m = max(m, (int)i);
        }
    }

    cout << m << endl;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;

const int NMAX = 200000;
int X, Y;
int C[NMAX+1];
int W[NMAX+1];

vector<int> byC[NMAX+1];
vector<int> byG[NMAX+1];

int P[NMAX+1];
int find(int u){return P[u]==u?u:P[u]=find(P[u]);}
void merge(int u,int v){
    u=find(u),v=find(v);
    P[u]=v;
}

typedef long long ll;
ll pinv[NMAX+1];
ll fact[NMAX+1];

int main(){
    int N; scanf("%d%d%d",&N,&X,&Y);
    for(int i=1;i<=N;i++) scanf("%d%d",C+i,W+i);

    for(int i=1;i<=N;i++){
        byC[C[i]].push_back(i);
    }
    
    for(int i=1;i<=N;i++) if(byC[i].size() == N) return !printf("1\n");

    for(int i=1;i<=N;i++){
        sort(byC[i].begin(), byC[i].end(), [&](int x,int y){
                return W[x]<W[y];
                });
    }

    int m1=-1, m2=-1;

    for(int i=1;i<=N;i++) if(!byC[i].empty()){
        int id = byC[i].front();
        if(m2==-1 || W[m2]>W[id]) m2 = id;
        if(m1==-1 || W[m1]>W[m2]) swap(m1,m2);
    }

    for(int i=1;i<=N;i++) P[i] = i;
    for(int i=1;i<=N;i++) if(!byC[i].empty()){
        int base = byC[i].front();
        int bridge = (m1==base ? m2 : m1);
        for(int j=1;j<byC[i].size();j++){
            int target = byC[i][j];
            if(W[base] + W[target] <= X || W[bridge] + W[target] <= Y)
                merge(base, target);
        }
    }

    vector<int> fronts;
    for(int i=1;i<=N;i++) if(!byC[i].empty()) fronts.push_back(byC[i].front());
    sort(fronts.begin(), fronts.end(), [&](int x,int y){
            return W[x]<W[y];
            });

    for(int i=1;i<fronts.size();i++) if(W[fronts[0]] + W[fronts[i]] <= Y)
        merge(fronts[0], fronts[i]);

    pinv[1] = 1;
    const ll MOD = 1e9+7;
    for(int i=2;i<=N;i++){
        pinv[i] = (MOD - pinv[MOD%i] * (MOD/i) % MOD) % MOD;
    }
    fact[1] = 1;
    for(int i=2;i<=N;i++) fact[i]=fact[i-1]*i%MOD;
    for(int i=1;i<=N;i++) byG[find(i)].push_back(i);

    ll ans = 1;
    for(int i=1;i<=N;i++) if(!byG[i].empty()){
        map<int,int> acc;
        ll cur = fact[byG[i].size()];
        for(int x:byG[i])
            acc[C[x]]++;

        for(auto& kv:acc) for(int i=1;i<=kv.second;i++)
            cur = cur * pinv[i] % MOD;

        ans = ans * cur % MOD;
    }

    printf("%lld\n",ans);
}


Measured memory_bytes: 28532
def input_from_console():
    n = int(input())
    s_list = []
    for i in range(n):
        s_list.append(input())
    return n, s_list


def count_ab_in_string(s_list):
    return sum([item.count('AB') for item in s_list])


def count_start_with_b(s_list):
    return sum([1 if item.startswith('B') and not item.endswith('A') else 0 for item in s_list])


def count_end_with_a(s_list):
    return sum([1 if not item.startswith('B') and item.endswith('A') else 0 for item in s_list])


def count_end_with_a_and_start_with_b(s_list):
    return sum([1 if item.endswith('A') and item.startswith('B') else 0 for item in s_list])


def main():
    n, s_list = input_from_console()
    contains_count = count_ab_in_string(s_list)
    b = count_start_with_b(s_list)
    a = count_end_with_a(s_list)
    connect_count = min(b, a)  # ..a b...


    should_be_paired = count_end_with_a_and_start_with_b(s_list)
    # print(a, b, connect_count, should_be_paired)

    if should_be_paired > 0:
        if connect_count > 0:
            print(sum([contains_count, should_be_paired, 1, connect_count - 1]))
        elif a > 0 or b > 0:
            print(sum([contains_count, should_be_paired]))
        else:
            print(sum([contains_count, should_be_paired, -1]))
    else:
        print(sum([contains_count, connect_count]))

if __name__ == "__main__":
    main()

Measured memory_bytes: 3700
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
const int INF = 1e9;
#define MAX 1000
int main(void) {
	int a,b;
	string s;
	cin >> a >> s >> b;
	if (s == "+") {
		cout << a + b << endl;
	}
	else {
		cout << a - b << endl;

	}
	return 0;
}

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

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

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

#define LL long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    cout << char(s1[0] + 'A' - 'a');
    cout << char(s2[0] + 'A' - 'a');
    cout << char(s3[0] + 'A' - 'a');
    cout << endl;
    return 0;
}



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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n, m, v, p;
  cin >> n >> m >> v >> p;
  vll as(n), bs(n);
  rep(i, n) cin >> as[i];
  rSort(as);

  bs[0] = 1;
  rep(i, n - 1) {
    bs[i + 1] = bs[i];
    if (as[i + 1] < as[i]) bs[i + 1] = i + 2;
  }

  vll csum(n + 1);
  csum[0] = 0;
  rep(i, n) csum[i + 1] = csum[i] + as[i];

  ll crescent1997 = 0;
  rep(i, n) {
    if (i + 1 <= p) {
      crescent1997++;
      continue;
    }
    if (as[p - 1] > as[i] + m) continue;
    ll vp = v - (p - 1) - (n - i);
    chmax(vp, 0LL);
    ll lhs = (as[i] + m) * (i - p + 1) - (csum[i] - csum[p - 1]);
    ll rhs = vp * m;
    if (lhs >= rhs) crescent1997++;
  }

  cout << crescent1997 << endl;

  return 0;
}


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

using namespace std;
using ll = long long int;
#define long ll

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    ll n, p;
    cin >> n >> p;

    string s;
    cin >> s;

    if(p==2 || p==5) {
        map<ll, ll> m;
        ll r = 0;
        for(ll i=0; i<n; i++) {
            map<ll, ll> nm;
            ll c = s[i]-'0';
            for(auto &t: m)
                nm[(t.first * 10 + c)%p] += t.second;
            m = nm;
            m[c%p]++;
            r += m[0];
        }
        cout << r << endl;
    } else {
        auto pow = [&](ll a, ll b) {
            ll r = 1;
            while(b) {
                if(b&1) (r *= a) %= p;
                (a *= a) %= p;
                b >>= 1;
            }
            return r;
        };
        
        vector<ll> imos(n);
        imos[0] = ((s[0] - '0') * pow(10,n))%p;
        for(ll i=1; i<n; i++) {
            ll c = s[i]-'0';
            imos[i] = (imos[i-1] + (c*pow(10,n-i))%p)%p;
        }

        vector<ll> m(p);
        ll r = 0;
        m[0] = 1;
        for(ll i=0; i<n; i++) {
            r += m[(imos[i])%p];
            m[imos[i]%p]++;
        }

        cout << r << endl;
    }
}


Measured memory_bytes: 2196
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef double ld;

int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n;
  cin >> n;
  vector<int> A(n);
  for(int i = 0;i<n;i++)cin >> A[i];
  vector<int> dp(n+1,0);
  for(int i = 0;i<n;i++){
  if(i==0)dp[i] = 0;
  else if(i==1)dp[i] = abs(A[i]-A[i-1]);
    else{
    dp[i] = min(dp[i-1]+abs(A[i-1]-A[i]),dp[i-2]+abs(A[i-2]-A[i]));
    }
  }
  cout << dp[n-1] << "\n";
	return 0;
}


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

long long  N;
long long l,r,am,an;
string ans;

void solver(long long m,long long n);
long long pow2(long long x,long long y);

int main(){
  long long sum=0,bfsum=0,n,x,min,max;
  while(1){
    cin >> N;
    if(N==0)break;
    n = 2;
    bfsum = 0;
    while(1){
      sum=(pow2(2,n)-n-1)*81;
      if(bfsum<N&&N<=sum){
	x = (pow2(2,n-1)-1)*9;
	l = (N-bfsum)/x;
	if((N-bfsum)%x!=0)l++;
	cout << l;
	if((N-bfsum)%x==0)solver(x,n);
	else solver((N-bfsum)%x,n);
	break;
      }
      bfsum = sum;
      n++;
    }
    if(l>r){
      max = l;
      min = r;
    }
    else {
      max = r;
      min = l;
    }
    for(long long i=0;i<an-2;i++){
      if((pow2(2,(an-3-i))&am)==pow2(2,(an-3-i)))cout << max;
      else cout << min;
    }
    cout << endl;
    ans = "";
  }
  return 0;
}

void solver(long long m,long long n){
  long long sum=0,x,bf=0;
  for(long long next=0;next<10;next++){
    if(l!=next){
      x = pow2(2,n-2);
      sum += x;
      if(sum>=m){
	r = next;
	am = m-bf-1;
	an = n;
	cout << r;
	return;
      }
    }
    else {
      x = (pow2(2,n-2)-1)*9;
      sum+=x;
      if(sum>=m){
	cout << l;
	solver(m-bf,n-1);
	return;
      }
    } 
    bf = sum;
  }
}

long long pow2(long long x,long long y){
  long long ans = 1;
  for(long long i=0;i<y;i++)ans *= x;
  return ans;
}



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

int main(){
	int N;
	std::cin >> N;
	std::vector<std::array<int,3>> abc(N);
	for(int i=0;i<N;++i)
		for(int j=0;j<3;++j)
			std::cin >> abc[i][j];
	std::vector<std::array<int,3>> dp(N+1);
	for(int i=0;i<N;++i){
		for(int j=0;j<3;++j){
			for(int k=0;k<3;++k){
				if(j==k)continue;
				dp[i+1][j]=std::max(
					dp[i+1][j],
					dp[i][k]+abc[i][k]
				);
			}
		}
	}
	int ans = 0;
	for(int i=0;i<3;++i)
		ans = std::max(ans, dp[N][i]);
	std::cout << ans << std::endl;
}


Measured memory_bytes: 2560
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;

int main()
{
    int n, m;
    string op;
    while(cin >> n && n) {
        char c1[100], c2[100];
        op = "";
        for(int i=0; i < n; ++i) cin >> c1[i] >> c2[i];
        cin >> m;
        for(int i=0; i < m; ++i) {
            char c;
            cin >> c;
            for(int j=0; j < n; ++j) {
                if (c == c1[j]) {
                    c = c2[j];
                    break;
                }
            }
            op += c;
        }
        cout << op << endl;
    }

    return 0;
}

Measured memory_bytes: 1324
l, r = map(int, input().split())
mod = 2019
_min = mod
for i in range(l, min(l + mod, r)):
  i_mod = i % mod
  for j in range(i + 1, min(i + mod, r) + 1):
    _min = min(_min, j % mod * i_mod % mod)
print(_min)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pci pair <char, int>
#define pld pair <ld, ld>
#define ppld pair <pld, pld>
#define ppll pair <pll, pll>
#define pldl pair <ld, ll>
#define vll vector <ll>
#define vvll vector <vll>
#define vpll vector <pll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define mll map <ll, ll>
#define fastmap gp_hash_table
#define cd complex <double>
#define vcd vector <cd>
#define PI 3.14159265358979
#define ordered_set tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update>
#pragma 03
using namespace std;
using namespace __gnu_pbds;
// LOL. Imagine choking on an 1747 problem...
// Atcoder's problems are beautiful as always though. 
// (which kinda explains why I'm so bad at it, I lack creativity...)
vll o;
vpll edges;
void term(){
	cout << -1 << endl; exit(0);
}
int main(){
	string s; cin >> s;
	ll n = s.length();
	for (ll i = 0; i < n; i++) if (s[i] == '1') o.pb(i);
	if (s[0] == '0') term();
	if (s[n - 1] == '1') term();
	for (ll i = 0; i < n - 1; i++){
		if (s[i] != s[n - 2 - i]) term(); 
	}
	ll k = o.size();
	ll cv = k + 1;
	for (ll i = 0; i < k; i++) edges.pb(mp(i, i + 1));
	for (ll i = 1; i < k; i++){
		for (ll j = 0; j < o[i] - o[i - 1] - 1; j++){
			edges.pb(mp(i, cv)); cv++;
		}
	} 
	for (ll i = 0; i < edges.size(); i++) cout << edges[i].fi + 1 << " " << edges[i].se + 1 << endl;
}

Measured memory_bytes: 4144
#include <stdio.h>
int main()
{
    int n,rem=0,count=0;
    scanf("%d",&n);
    while(n)
    {
        rem=n%10;
        if(rem==2)
        count++;
        n=n/10;
        rem=0;
    }
    printf("%d",count);
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <math.h>

int main(){
	int a[4],b[4],hit,blow,i,k;
	while(0<=scanf("%d %d %d %d",&a[0],&a[1],&a[2],&a[3]) & 0<=scanf("%d %d %d %d",&b[0],&b[1],&b[2],&b[3])){
		hit=0;
		blow=0;
		for(i=0;i<=3;i++){
			if(a[i]==b[i]){
				++hit;
			}
			for(k=0;k<=3;k++){
				if(a[i]==b[k]){
					++blow;
				}
			}
		}
		
		blow=blow-hit;
		printf("%d %d\n",hit,blow);
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    int N,W; cin >> N >> W;
    vector<vector<int>> wv(4);
    int w0,v0; cin >> w0 >> v0;
    wv[0].push_back(v0);
    repr(i,1,N){
        int w,v; cin >> w >> v;
        if(w == w0) wv[0].push_back(v);
        else if(w == w0+1) wv[1].push_back(v);
        else if(w == w0+2) wv[2].push_back(v);
        else wv[3].push_back(v);
    }
    rep(i,4){
        sort(wv[i].begin(),wv[i].end(),greater<int>());
    }
    ll ans = 0;
    rep(i,wv[0].size()+1)rep(j,wv[1].size()+1)rep(k,wv[2].size()+1)rep(l,wv[3].size()+1){
        ll tmp = 0;
        ll sum = 0;
        rep(m,i) sum += w0,tmp += wv[0][m];
        rep(m,j) sum += w0+1,tmp += wv[1][m];
        rep(m,k) sum += w0+2,tmp += wv[2][m];
        rep(m,l) sum += w0+3,tmp += wv[3][m];
        if(sum <= W) ans = max(ans,tmp);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<P, int> PP;
const int mod = 1000000007;

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

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

    int N;
    while (1)
    {
        cin >> N;
        if (N == 0)
            break;
        int field[400][400] = {};
        field[200][200] = 1;
        vector<P> v(N);
        v[0] = P(200, 200);
        rep(i, N - 1)
        {
            int n, d;
            cin >> n >> d;
            P pos = v[n];
            int y = pos.first + dy[d], x = pos.second + dx[d];
            field[y][x] = 1;
            v[i + 1] = P(y, x);
        }
        int h = 0, w = 0, cnt_h = 0, cnt_w = 0;
        rep(i, 400)
        {
            bool f = false;
            rep(j, 400) if (field[i][j]) f = true;
            if (f)
                cnt_h++;
            else
                h = max(h, cnt_h), cnt_h = 0;
        }
        h = max(h, cnt_h);
        rep(j, 400)
        {
            bool f = false;
            rep(i, 400) if (field[i][j]) f = true;
            if (f)
                cnt_w++;
            else
                w = max(w, cnt_w), cnt_w = 0;
        }
        w = max(w, cnt_w);
        cout << w << " " << h << endl;
    }
}


Measured memory_bytes: 4368
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)

def solve():
    MOD = 10**9 + 7

    N = int(input())
    adjL = [[] for _ in range(N)]
    for _ in range(N-1):
        a, b = map(int, input().split())
        a, b = a-1, b-1
        adjL[a].append(b)
        adjL[b].append(a)

    sizeSubtrees = [0] * N
    sizeAdjss = [[] for _ in range(N)]

    def dfs(vNow, vPar):
        sizeSubtrees[vNow] = 1
        for v2 in adjL[vNow]:
            if v2 == vPar: continue
            s = dfs(v2, vNow)
            sizeAdjss[vNow].append(s)
            sizeSubtrees[vNow] += s
        sizeAdjss[vNow].append(N-sizeSubtrees[vNow])
        return sizeSubtrees[vNow]

    dfs(0, -1)

    def getPows(base, n, MOD):
        pows = [1] * (n+1)
        for x in range(1, n+1):
            pows[x] = (pows[x-1] * base) % MOD
        return pows
    pow2s = getPows(2, N, MOD)

    nums = [0] * N
    for v in range(N):
        num = pow2s[N-1] - 1
        for sizeAdj in sizeAdjss[v]:
            num -= pow2s[sizeAdj] - 1
            num %= MOD
        nums[v] = num

    ans = sum(nums) % MOD * pow(pow2s[N], MOD-2, MOD) % MOD
    print(ans)


solve()


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

int main() {
  int n;
  cin >> n;
  vector<double> v(n);
  rep(i, n) cin >> v[i];
  sort(v.begin(), v.end());
  double ans = v[0];
  rep(i, n) ans = (ans + v[i]) / 2;
  printf("%.10lf\n", ans);
  return 0;
}

Measured memory_bytes: 256
//ProblemC

//#define USE_STDIO
//#define USE_LOG
//#define FILE_ERR

#ifdef _MYPC
#include "mypc.h"
#endif // _MYPC

#ifndef debug
#define debug(...)
#endif // !LOG

#ifndef REDIRECT_STDIO
#define REDIRECT_STDIO
#endif // REDIRECT_STDIO

//include
#include <iostream>
#include <string>
#include <vector>
#include <bitset>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <memory>
#include <complex>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iomanip>

using namespace std;

//int
using ll = long long;
using ull = unsigned long long;
using uint = unsigned;

//pair
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;

//vector
template<typename T>
using vt = std::vector<T>;
using vi = vt<int>;
using vvi = vt<vi>;
using vvvi = vt<vvi>;
using vl = vt<ll>;
using vvl = vt<vl>;
using vvvl = vt<vvl>;
using vb = vt<bool>;
using vpii = vt<pii>;

static inline ll Solve();

int main(int argc, char* argv[]) {
	REDIRECT_STDIO;

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

void dfs(unordered_map<string, ll>& ret, const string& s, size_t i, string& a, string& b) {
	if (i == s.length()) {
		ret[a + '#' + b] += 1;
	}
	else {
		a.push_back(s[i]);
		dfs(ret, s, i + 1, a, b);
		a.pop_back();

		b.push_back(s[i]);
		dfs(ret, s, i + 1, a, b);
		b.pop_back();
	}
}

auto make_map(const string& s) {
	unordered_map<string, ll> m;
	string a, b;
	dfs(m, s, 0, a, b);
	return m;
}

//ProblemC
ll Solve() {
	int n;
	string s;
	cin >> n >> s;

	string s1 = s.substr(0, n);
	string s2 = s.substr(n, n);
	std::reverse(s2.begin(), s2.end());

	auto m1 = make_map(s1);
	auto m2 = make_map(s2);

	if (m1.size() > m2.size()) {
		std::swap(m1, m2);
	}

	ll ans = 0;
	for (auto& it1 : m1) {
		auto it2 = m2.find(it1.first);
		if (it2 != m2.end()) {
			ans += it1.second * it2->second;
		}
	}
	return ans;
}


Measured memory_bytes: 67060