akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
//#include<algorithm>
//#include<vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int dm = 1 << 21;
char dn[dm], * di = dn;
inline void putint(int X) {
	if (X == 0) {
		*di++ = '0';
		*di++ = ' ';
		return;
	}
	int keta = 0;
	char C[20];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = ' ';
}

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


	int N = getint();
	int kotae[200001];
	int h = N / 2;

	if (N & 1) {
		kotae[h] = getint();
		rep1(i, h) {
			kotae[h + i] = getint();
			kotae[h - i] = getint();
		}
	}
	else {
		rep1(i, h) {
			kotae[h + i - 1] = getint();
			kotae[h - i] = getint();
		}
	}

	rep(i, N) putint(kotae[i]);

	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
#define itn int
#define gI gi
#define int long long

using namespace std;

typedef long long ll;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

inline ll gl()
{
	ll f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

int po[103], ans, n, m, a[200003], minn = 200003;
char s[100003];

signed main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	n = gi();
	int xx = n, cnt = 0;
	while (xx)
	{
		xx = xx / 10, ++cnt;
	}
	po[1] = 1;
	for (int i = 2; i <= 8; i+=1) po[i] = po[i - 1] * 10;
	for (int i = 1; i <= n; i+=1)
	{
		int ii = i, x = 0, y = ii % 10;
		if (!y) continue;
		while (ii)
		{
			x = ii % 10, ii /= 10;
		}
		for (int j = 1; j <= cnt; j+=1)
		{
			if (j == 1)
			{
				if (x == y) ++ans;
			}
			else if (j < cnt) ans += po[j - 1];
			else
			{
				int xsl = y * po[cnt] + x, xxsl = xsl;
				for (int k = 2; k < cnt; k+=1)
				{
					xxsl += 9 * po[k];
				}
				if (n >= xsl) 
				{
					ans += (min(xxsl, n) - xsl) / 10 + 1;
				}
			}
		}
	}
	printf("%lld\n", ans);
	return 0;
}


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

using namespace std;

int main(){
	int n;
	double x[100] = {0},y[100] = {0},p_1 = 0,p_2 = 0,p_3 = 0,p_infinity = -1;
	scanf("%d",&n);
	for(int i = 0; i < n; i++) scanf("%lf",&x[i]);
	for(int i = 0; i < n; i++) scanf("%lf",&y[i]);

	for(int i = 0; i < n; i++){
		p_1 += abs(x[i] - y[i]);
		p_2 += (x[i] - y[i])*(x[i] - y[i]);
		p_3 += abs((x[i] - y[i])*(x[i] - y[i])*(x[i] - y[i]));
		p_infinity = (p_infinity >= abs(x[i] - y[i]))? p_infinity:abs(x[i] - y[i]);
 	}
	printf("%.6lf\n",p_1);
	printf("%.6lf\n",sqrt(p_2));
	printf("%.6f\n",cbrt(p_3));
	printf("%.6lf\n",p_infinity);

}



Measured memory_bytes: 2908
import bisect
N = int(input())

A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort()
B.sort()
C.sort()

# print (A, B ,C)
ans = 0
for i in B:
    # print (i)
    # print (bisect.bisect_left(A, i-0.1))
    ans += bisect.bisect_left(A, i-0.1) * (N-bisect.bisect_right(C, i+0.1))
print (ans)

Measured memory_bytes: 23360
#include<stdio.h>
int main(){
    int i, j, H, W;
    scanf("%d %d", &H, &W);
    while((H!=0)||(W!=0)){
        for(i=0; i<H ;i++){
            for(j=0; j<W; j++){
                if((i+j)%2 == 0)
                    printf("#");
                else
                    printf(".");
                if(j==(W-1))
                    printf("\n");               
            }
        }
        printf("\n");
        scanf("%d %d", &H, &W);
    }
    return 0;
}

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

int main()
{
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    if(A+B>C+D)
    {
        cout << "Left" << endl;
    }
    else if(A+B<C+D)
    {
        cout << "Right" << endl;
    }
    else
    {
        cout << "Balanced" << endl;
    }
    return 0;
}

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

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

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
 
#define fi first
#define se second
#define debug(x) cerr << #x << " : " << x << "\n"
typedef long long ll;
 
// code //


int main() {
	int n, mxNum = INT_MIN, minNum = INT_MAX;
	cin >> n;
	vector<int> a(n);
	for(int i = 0;  i < n; ++i) {
		cin >> a[i];
		mxNum = max(mxNum, a[i]);
		minNum = min(minNum, a[i]);
	}
	
	cout << mxNum - minNum;
}


Measured memory_bytes: 3548
#include "bits/stdc++.h"
using namespace std;

int main() {
	long long N;
	while (cin >> N) {
		if (N == 0) return 0;
		vector<pair<long long, long long> > VP(N);
		for (int i = 0; i < N; i++) cin >> VP[i].first >> VP[i].second;
		long long M;
		vector<vector<bool> > B(21, vector<bool>(21, false));
		long long X = 10, Y = 10;
		B[10][10] = true;
		cin >> M;
		for (int i = 0; i < M; i++) {
			char C;
			long long L;
			cin >> C >> L;
			if (C == 'N') {
				for (int j = 0; j < L; j++) {
					Y++;
					B[X][Y] = true;
				}
			}
			if (C == 'S') {
				for (int j = 0; j < L; j++) {
					Y--;
					B[X][Y] = true;
				}
			}
			if (C == 'E') {
				for (int j = 0; j < L; j++) {
					X++;
					B[X][Y] = true;
				}
			}
			if (C == 'W') {
				for (int j = 0; j < L; j++) {
					X--;
					B[X][Y] = true;
				}
			}
		}
		bool check = true;
		for (int i = 0; i < N; i++) {
			if (!B[VP[i].first][VP[i].second]) check = false;
		}
		cout << (check ? "Yes" : "No") << endl;
	}
}


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

int main()
{
  double N;
  cin >> N;
  double tmp = 0.0;
  int ans = 0;
  bool can = false;
  for (int i = 1; i <= N; i++)
  {
    tmp = i * 1.08;
    if ((int)tmp == N)
    {
      ans = i;
      can = true;
      break;
    }
  }
  if (can)
    cout << ans << endl;
  else
    cout << ":(" << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF = 1 << 29;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
const int MAX_N = 200100;
int N;
vector<int> A;
ll sum[MAX_N];
int main() {
  cin >> N;
  A.resize(N);
  for (auto &val : A){
    cin >> val;
  }
  for (int i = 0; i < N; i++){
    sum[i+1] = sum[i] + A[i];
  }
  ll res = 1LL << 60;
  for (int i = 1; i < N; i++){
    ll x = sum[i];
    ll y = sum[N] - sum[i];
    res = min(res, abs(x - y));
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 2560
#include <iostream>
using namespace std;
int main() 
{
	int a, b, c, d, e, f, g, h, A, B;
	cin >> a >> b >> c >> d;
	cin >> e >> f >> g >> h;
	A = a + b + c + d;
	B = e + f + g + h;
	if (A >= B) {
		cout << A << endl;
	}
	else
		cout << B << endl;
	return 0;
}


Measured memory_bytes: 3064
/* ---------- STL Libraries ---------- */

// 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;


/* ---------- Type Abbreviation ---------- */

template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

using ll = long long;
using PL = P<ll, ll>;
using PS = P<string, ll>;

using VI = V<int>;
using VVI = V<VI>;
using VL = V<ll>;
using VVL = V<VL>;
using VS = V<string>;
using VB = V<bool>;
using VVB = V<VB>;
using VPL = V<PL>;
using VPS = V<PS>;

#define fst first
#define snd second


/* ---------- 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 ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define GSORT(c) sort(ALL(c), greater<decltype((c).front())>())
#define SZ(x) (LL((x).size()))


/* ---------- repetition ---------- */

#define FOR(i, a, b) for (ll 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 (ll i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// Usual REP runs from 0 to n-1 (R: n to 0)
// Natural REP runs from 1 to n (R: n to 1)


/* ---------- Constants ---------- */

// const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const ll dx[4] = {0, -1, 1, 0};
// const ll dy[4] = {-1, 0, 0, 1};
// const ll dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const ll dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};


/* ---------- Debug ---------- */
#define GET_VAR_NAME(variable) #variable

#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

template <typename T>

void testVector(T& v) {
  REP(i, SZ(v)) {
    cout << i << ":" << v << endl;
  }
}


/* ^^^^^^^^^^^^^^^ Settting Part ^^^^^^^^^^^^^^^ */

/* ---------- Variances ---------- */

int N, M, X;
int cost0, costN;

/* ---------- Functions ---------- */


/* ---------- Main Function ---------- */

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

  cin >> N >> M >> X;
  REP(i, M) {
    int A;
    cin >> A;
    if (A < X) {
      cost0++;
    } else {
      costN++;
    }
  }
  cout << min(cost0, costN) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int m, f, r;
  int mf;

  scanf("%d %d %d", &m, &f, &r);
  mf = m + f;
  while(m != -1 || f != -1 || r != -1) {
    if(m == -1 || f == -1) {
      printf("F\n");
    } else if(mf >= 80) {
      printf("A\n");
    } else if(65 <= mf && mf < 80) {
      printf("B\n");
    } else if(50 <= mf && mf < 65) {
      printf("C\n");
    } else if(30 <= mf && mf < 50) {
      if(r >= 50) {
        printf("C\n");
      } else {
        printf("D\n");
      }
    } else {
      printf("F\n");
    }
    scanf("%d %d %d", &m, &f, &r);
    mf = m + f;
  }
  return 0;
}

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

typedef long long ll;
const int MAXN = 3010;

ll Pow(ll a, ll b, ll MOD)
{
	ll ans = 1;
	for(; b; b >>= 1)
	{
		if(b & 1) ans = ans * a % MOD;
		a = a * a % MOD;
	}
	return ans;
}

int n; ll MOD;
ll C[MAXN][MAXN];
ll S[MAXN][MAXN];

ll calc(int i)
{
	ll res = 0, now = 1;
	ll P1 = Pow(2, Pow(2, n - i, MOD - 1), MOD);
	ll P2 = Pow(2, n - i, MOD);
	for(int j = 0; j <= i; ++j)
	{
		res += S[i + 1][j + 1] * now % MOD;
		res %= MOD; now = now * P2 % MOD;
	}
	res = res * P1 % MOD * C[n][i] % MOD;
	return res;
}

int main()
{
	scanf("%d %lld", &n, &MOD);
	C[0][0] = S[0][0] = 1;
	for(int i = 1; i <= n + 1; ++i)
	{
		C[i][0] = 1, S[i][0] = 0;
		for(int j = 1; j <= i; ++j)
		{
			C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % MOD;
			S[i][j] = (S[i - 1][j - 1] + S[i - 1][j] * j % MOD) % MOD;
		}
	}
	ll ans = 0;
	for(int i = 0; i <= n; ++i)
	{
		if(i & 1) ans = (ans - calc(i)) % MOD;
		else ans = (ans + calc(i)) % MOD;
	}
	printf("%lld\n", (ans + MOD) % MOD);
	return 0;
}

Measured memory_bytes: 139904
// AtCoder ARC065 D - 連結
// 2019.8.28 bal4u

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef long long ll;

#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)

int in() {   // 非負整数の入力
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

void out(int n) { // 非負整数の表示（出力）
	int i; char b[30];

	i = 0; while (n) b[i++] = n % 10 + '0', n /= 10;
	while (i--) pc(b[i]);
	pc('\n');
}

#define MAX 400010
/* UNION-FIND library */
int id[MAX], size[MAX];
void init(int n) { int i; for (i = 0; i < n; i++)
	id[i] = i, size[i] = 1;
}
int root(int i) { while (i != id[i]) id[i] = id[id[i]], i = id[i]; return i; }
void unite(int p, int q) {
    int i = root(p), j = root(q); if (i == j) return;
    if (size[i] < size[j]) id[i] = j, size[j] += size[i]; else id[j] = i, size[i] += size[j];
}

int N;
typedef struct { int id; ll x; } T;
T g[200005]; int w;
int ans[200005];

void Usort(T *a, int n) {
	int i, k;
#define B 8
#define BMSK 255 // (1<<8)-1
	ll t1[1 << B], t2[1 << B];
	
	T *tmp = malloc(n * sizeof(T));	
	for (k = 0; k < 8; ++k) {
		memset(t1, 0, sizeof(t1)), memset(t2, 0, sizeof(t2));
		for (i = 0; i < n; ++i)	t1[(a[i].x >> k*B) & BMSK]++;
		for (i = 0; i < BMSK; ++i) t1[i+1] += t1[i];
		i = n; while (i--) tmp[--t1[(a[i].x >> k*B) & BMSK]] = a[i];
		k++;
		for (i = 0; i < n; ++i) t2[(tmp[i].x >> k*B) & BMSK]++;
		for (i = 0; i < BMSK; ++i) t2[i+1] += t2[i];
		i = n; while (i--) a[--t2[(tmp[i].x >> k*B) & BMSK]] = tmp[i];
	}
	free(tmp);
//for (i = 0; i < n; ++i) printf("[%d] %lld,%d\n", i, a[i].x, a[i].id);
}

int main()
{
	int i, j, k, K, L, a, b;
	
	N = in(), K = in(), L = in();
	init((N << 1) + 2);
	while (K--) {
		a = in() << 1, b = in() << 1;
		unite(a, b);
	}
	while (L--) {
		a = (in() << 1) + 1, b = (in() << 1) + 1;
		unite(a, b);
	}
	
	for (i = 1; i <= N; ++i) {
		g[w].id = i, g[w++].x = ((ll)root(i<<1) << 19) | root((i<<1)+1);
	}
	Usort(g, w);

	j = 0; while (j < w) {
		k = j++; while (j < w && g[k].x == g[j].x) j++;
		for (i = k; i < j; ++i) ans[g[i].id] = j-k;
	}
//	for (i = 1; i <= N; ++i) printf("[%d] %d\n", i, ans[i]);
	for (i = 1; i <= N; ++i) out(ans[i]);
	return 0;
}


Measured memory_bytes: 10240
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
int main(){
  ll n;
  cin >> n;
  string s;
  vector<ll>march(5);
  for(int i=0; i<n; i++){
    cin >> s;
    if(s[0]=='M')march[0]++;
    if(s[0]=='A')march[1]++;
    if(s[0]=='R')march[2]++;
    if(s[0]=='C')march[3]++;
    if(s[0]=='H')march[4]++;
  }
  
  ll ans=0;
  for(int i=0; i<3; i++){
    for(int j=i+1; j<4; j++){
     for(int k=j+1; k<5; k++){
       
       ans+=march[i]*march[j]*march[k];
       
     } 
    }  
  }
  
  cout << ans << endl;
  
}

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


int main(){
	int i;
	int j=0;
	int k;

	char S[11];
	char Cpy[11];

	scanf("%s",S);

	// printf("nagasa = %d\n",strlen(S));
	

	for(i=0;i<strlen(S);i++){
		if(S[i] == '0'){
			Cpy[j] = '0';
			// printf("Cpy[%d]=%c\n",j,Cpy[j]);
			// printf("S[%d]=%c\n",i,S[i]);
			j++;
		}
		else if(S[i] == '1'){
			Cpy[j] = '1';
			// printf("Cpy[%d]=%c\n",j,Cpy[j]);
			// printf("S[%d]=%c\n",i,S[i]);
			j++;
		}
		else{
			// printf("S[%d]=%c\n",i,S[i]);
			for(k=j;k>=0;k--){
				if(Cpy[k-1] != 'x'){
					Cpy[k-1] = 'x';
					// printf("Cpy[%d]=%c\n",k,Cpy[k]);
					break;
				}
			}	
		}
		
	}

	for(k=0;k<j;k++){
		if (Cpy[k] == 'x'){
			continue;
		}
		printf("%c",Cpy[k]);
		
	}
	printf("\n");

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int n,flag=1;
  unsigned long long a,product,max=1e18;
  cin>>n;
   cin>>a;
   product=a;
   for(int i=2;i<=n;i++)
  {
     max=max/a;
     cin>>a;
     if(a==0)
     {
       cout<<0<<endl;
       exit(0);
     }
     if(a<=max)
      product*=a;
     else{
       flag=-1;
     }
  }
  if(flag==1)
  cout<<product;
  else
  {
    cout<<-1;
  }
  return 0;
}


Measured memory_bytes: 3616
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--)
#define REP(i, n) for(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)
#define REP1(i, n) for(int i=1; i<=(n); i++)
#define RREP1(i, n) for(int i=(n); i>=1; i--)
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()
#define out(...) printf(__VA_ARGS__)
#define chmax(a,b) a = max(a,b)
#define chmin(a,b) a = min(a,b)
#if DEBUG
#define debug(...) printf(__VA_ARGS__)
#else
#define debug(...) /* ... */
#endif

void solve();
signed main()
{
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

/*================================*/
#if DEBUG
#define SIZE 100
#else
#define SIZE 123450
#endif

int N,X;

void solve() {
    cin>>X>>N;
    set<int> S;
    int a;
    REP(i,N) {
        cin>>a;
        S.insert(a);
    }
    int ans = -INT_MAX;
    FOR(i,X-200,X+200) {
        if (!S.count(i)) {
            if (abs(ans-X) > abs(i-X)) {
                ans = i;
            }
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 3656
k = int(input())
A,B = input().split()
a = int(A)
b = int(B)
x = 0
for y in range(a,b+1):
  if y % k == 0:
    x = x+1
  else:
    x = x
if x == 0:
  print('NG')
else:
  print('OK')
  

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

int main(){
while(1){
	int n,m,loc=1,in,b[1002],ans;
	scanf("%d%d",&n,&m);
	if(n==0&&m==0)break;
	for(int i=1;i<=n;i++)scanf("%d",&b[i]);
	for(int i=1;i<=m;i++){
		scanf("%d",&in);
		loc+=in;
		if(loc>=n){ans=i; break;}
		loc+=b[loc];
		if(loc>=n){ans=i; break;}
	}
	for(int i=ans+1;i<=m;i++)scanf("%d",&in);
	printf("%d\n",ans);
}
}

Measured memory_bytes: 1176
from collections import defaultdict

a,b = map(int,input().split())

k=defaultdict(lambda:defaultdict(int))

for _ in range(b):
    p,s = input().split()

    if k[p].get('AC'):
        continue

    k[p][s] += 1

x = y = 0

for i,j in k.items():
    if j.get('AC'):
        x+=1
        if j.get('WA'):
            y+=j['WA']

    # print(i,j)


print(x,y)

Measured memory_bytes: 51104
#include<iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <math.h>
#include <unordered_map>
using namespace std;

int main()
{
	std::string str;
	int a = 0;

	std::cin >> str;

	for (int i = 0; i < str.length(); i++) {
		if(str[i] == '+')
			a++;
		else if(str[i] == '-')
			a--;
	}

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

	return 0;
}


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

int N;
int S[114514];
int T[114514];
int U[114514];
char buf[114514];

bool Check2(int K) {
  int p = 1;
  int q = 0;
  int turn = 0;
  int cnt = 0;
  while (1) {
    if (turn) {
      if (K+p > N) break;
      if (S[K+p]) {
        S[K+p] = 0;
        S[p] ^= 1;
      }
      p++;
    } else {
      if (q+K+1 > N) break;
      if (S[q]) {
        S[q] = 0;
        S[q+K+1] ^= 1;
      }
      q++;
    }
    turn ^= 1;
  }

  for (int i=0; i<N; i++) {
    cnt += S[i];
  }
  return !cnt;
}

bool Check(int K) {
  for (int i=0; i<2; i++) {
    for (int j=0; j<2; j++) {
      copy(T, T+N, S);
      S[N] = i;
      S[0] ^= j;
      S[K] ^= j; 
      if (Check2(K)) return true;
    }
  }
  return false;
}

int main() {
  scanf("%s", buf);
  N = strlen(buf);

  bool all = true;
  for (int i=0; i<N; i++) {
    U[i] = T[i] = buf[i] == '1';
    if (T[0] != T[i]) all = false;
  }
  
  if (all) {
    printf("%d\n", N);
    return 0;
  }

  for (int i=1; i<N; i++) {
    T[i] = (U[i]+U[i-1])%2;
  }

  int low = 0;
  int high = N;
  while (high - low > 1) {
    int mid = (high+low)/2;
    if (Check(mid)) low = mid;
    else high = mid;
  }
  printf("%d\n", low);
}


Measured memory_bytes: 1536
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  int N, K, S;

  cin >> N >> K >> S;

  ll e9 = 1000000000;

  for (int i=0; i<N; i++) {
    if (i < K) {
      printf("%d", S);
    } else {
      printf("%d", S == e9 ? S - 1 : S + 1);
    }

    if (i == N-1)
      printf("\n");
    else
      printf(" ");
  }

  return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

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

using namespace std;
int main(void)
{
  string s;
  int n;
  int anum='z'+1;
  cin >> s >> n;
  REP(i,s.size()){
    if(s[i]!='a' && n >= anum-s[i]){
      n-=anum-s[i];
      s[i]='a';
    }
  }
  s[s.size()-1]+=n%26;
  cout << s << endl;
  return 0;
}


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

int main(){
    long int n;
    cin>>n;
    vector<int>a(n+1);
    vector<int>b(n);
    long int sou=0;
    for(int i=0;i<n+1;i++){
        cin>>a.at(i);
        sou+=a.at(i);
    }
    for(int i=0;i<n;i++){
        cin>>b.at(i);
        if(a.at(i)>=b.at(i))a.at(i)-=b.at(i);
        else{
            a.at(i+1)=a.at(i+1)-b.at(i)+a.at(i);
            a.at(i)=0;
            if(a.at(i+1)<0)a.at(i+1)=0;
            else int unko=0;
        }
    }
    long int after=0;
    long int ans;
    for(int i=0;i<n+1;i++){
        after+=a.at(i);
    }
    ans=sou-after;
    cout<<ans<<endl;

}

Measured memory_bytes: 1024
from collections import Counter

N,M = map(int,input().split())
src = [list(map(lambda x:int(x)-1,input().split())) for i in range(N)]

removed = [0] * M
idxes = [0] * N
ans = N
for _ in range(M-1):
    ctr = Counter([src[i][idxes[i]] for i in range(N)])
    k,most = ctr.most_common(1)[0]
    ans = min(ans, most)
    removed[k] = 1
    for i in range(N):
        while removed[src[i][idxes[i]]]:
            idxes[i] += 1
print(ans)


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<double, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF DBL_MAX

double sx,sy,tx,ty;
ll n;
double x[1010],y[1010],r[1010];
double d[1010][1010];
double dist[1010];

int main(){
	cin>>sx>>sy>>tx>>ty>>n;
  rep(i,n)cin>>x[i]>>y[i]>>r[i];
  rep(i,1010)rep(j,1010)d[i][j]=INF;
  rep(i,n)rep(j,n){
    if(i==j)d[i][j]=0.0;
    else d[i][j]=max(0.0,sqrt(pow(x[i]-x[j],2)+pow(y[i]-y[j],2))-r[i]-r[j]);
  }
  rep(i,n){
    d[i][n]=d[n][i]=max(0.0,sqrt(pow(sx-x[i],2)+pow(sy-y[i],2))-r[i]);
    d[i][n+1]=d[n+1][i]=max(0.0,sqrt(pow(tx-x[i],2)+pow(ty-y[i],2))-r[i]);
  }
  d[n][n+1]=d[n+1][n]=sqrt(pow(sx-tx,2)+pow(sy-ty,2));
  priority_queue<P,vector<P>,greater<P> > que;
  que.push(P(0.0,n));
  rep(i,n+2)dist[i]=INF;
  while(que.size()){
    ll v=que.top().se;
    double nd=que.top().fi;
    que.pop();
    if(dist[v]!=INF)continue;
    dist[v]=nd;
    rep(j,n+2){
      //if(dist[j]!=INF)continue;
      que.push(P(nd+d[v][j],j));
    }
  }
  printf("%.10f\n", dist[n+1]);
	return 0;
}


Measured memory_bytes: 26728
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T>inline ostream& operator<<(ostream& is, vector<T>& v) { for (int i = 0; i < v.size(); ++i)cout << v[i] << (i == v.size() - 1 ? "" : " "); return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }
inline void print() { cout << "\n"; }
template<class T, class... Ts>inline void print(const T& a, const Ts&... ts) { cout << a << " "; print(ts...); }

int main() {
    init();

    int a, b, h; cin >> a >> b >> h;
    print((a + b) * h / 2);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;

    cin>>n>>k;
    vector<int> v(n),dp(k+1);
    for(int i=0;i<n;i++)cin>>v[i];
    for(int i=0;i<=k;i++)
    {
        if(!dp[i])
            for(auto x:v)
                if(i+x<=k)
                    dp[i+x]=1;
    }
    cout<<(dp[k]?"First":"Second");
    return 0;
}


Measured memory_bytes: 3776
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

// Palindromic Numbers

int
solve(int A, int B)
{
  int ret = 0;
  for (int i = A; i <= B; i++)
  {
    if (i / 10000 == i % 10
        && i / 1000 % 10 == i / 10 % 10)
    {
      ret++;
    }
  }
  return ret;
}

int
main()
{
  int A, B;
  cin >> A >> B;
  cout << solve(A, B) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int A,B;
    scanf("%d",&A);
    scanf("%d",&B);
    if((A==2&&B==3)||(A==3&&B==2))
    {
      printf("1\n");
    }
    else if((A==1&&B==2)||(A==2&&B==1))
    {
      printf("3\n");
    }

    else
    {
       printf("2\n");
    }

}


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

bool judge_triangle(int j_edge[])
{
    std::sort(j_edge, j_edge + 3);
    return j_edge[2] * j_edge[2] == j_edge[0] * j_edge[0] + j_edge[1] * j_edge[1];
}

int main()
{
    int num;
    std::cin >> num; 

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

        int edge[3];
        std::cin >> edge[0] >> edge[1] >> edge[2];

        if(judge_triangle(edge)) {
            std::cout << "YES" << std::endl;
        } else {
            std::cout << "NO" << std::endl;
        }

    }
}

// "j_edge" to "j_edge+3" ha "array j_edge" no memory jyou no
// adress no hajimari to owari wo simesu. 
// Yoku miru to kou natteru ==> [hajimari, owari)

Measured memory_bytes: 3156
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<bitset>
using namespace std;

long func_f(long a) {
	if (a % 2 == 0) {
		return (a / 2);
	}
	else {
		return (3 * a + 1);
	}
}


int main() {

	long s;
	cin >> s;

	vector<long> a;
	a.push_back(s);

	long cnt = 1;

	while (cnt == 1) {
		a.push_back(func_f(a.back()));
		cnt = count(a.begin(), a.end(), a.back());
	}

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

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
#define DEBUG
#ifdef DEBUG
	#define debug printf
#else
	#define debug(...)
#endif
int main(int argc, char const *argv[])
{
	int n,H,W,ans = 0;
	cin>>n>>H>>W;
	while(n--)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		ans += min(x / H,y / W);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
#define INF 10000000
using namespace std;

int n,m,a,res;
int t[100][100],u[100];
queue<int>qu;
int mincost[100],used[100];
void init(){
  for(int i=0;i<100;i++)for(int j=0;j<100;j++)t[i][j]=INF;
  for(int i=0;i<100;i++){
    mincost[i]=u[i]=INF;
    used[i]=0;
  }
}
int main(){
  while(cin>>n>>m&&n){
    init();
    for(int j=0;j<n;j++){
      for(int i=0;i<m;i++){
	cin>>a;
	if(a==0)continue;
	u[i]=min(u[i],a);
      }
    }
    for(int i=0;i<m;i++){
      t[i][m]=t[m][i]=u[i];
    }
    
    

    for(int i=0;i<m-1;i++){
      for(int j=0;j<m-1-i;j++){
	cin>>a;
	if(!a)continue;
	t[i][j+i+1]=a;
	
	t[j+i+1][i]=t[i][j+i+1];
      }
    }
    m++;
    /*
    for(int i=0;i<m;i++){
      for(int j=0;j<m;j++){
	if(t[i][j]==INF)printf("%2d ",-1);
	else printf("%2d ",t[i][j]);
      }
      cout<<endl;
    }
    */
    res=0;
    mincost[0]=0;
    while(1){
      int v=-1;
      for(int u=0;u<m;u++){
	if(!used[u]&&(v==-1||mincost[u]<mincost[v]))v=u;
      }
      if(v==-1)break;
      used[v]=1;
      res+=mincost[v];
      for(int u=0;u<m;u++){
	mincost[u]=min(mincost[u],t[v][u]);
      }
    }
    cout<<res<<endl;
  }
  return 0;
}

Measured memory_bytes: 1236
//This Code was made by Chinese_zjc_.
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<bitset>
#include<cmath>
#include<queue>
#include<stack>
#include<string>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<map>
#include<set>
#include<time.h>
// #include<windows.h>
#define int long long
#define PI 3.14159265358979323
#define INF 0x3fffffffffffffff
using namespace std;
int l[105],n,ans;
signed main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i=1;i<=n;++i)
    {
        cin>>l[i];
    }
    sort(l+1,l+1+n);
    for(int i=1;i<=n;++i)
    {
        for(int j=i+1;j<=n;++j)
        {
            if(l[i]==l[j])
            {
                continue;
            }
            for(int k=j+1;k<=n;++k)
            {
                if(l[j]==l[k])
                {
                    continue;
                }
                if(l[i]+l[j]>l[k])
                {
                    ++ans;
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3648
N = int(input())
A = [int(_) for _ in input().split()]

ans = 1
updown = False
up = False

for i in range(N-1):
    if updown:
        if (up and A[i] > A[i+1]) or (not up and A[i] < A[i+1]):
            ans += 1
            updown = False
            up = False
    else:
        if A[i] < A[i+1]:
            updown = True
            up = True
        elif A[i] > A[i+1]:
            updown = True

print(ans)

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

int main(){
    string A,B,C;
    while(cin>>A,A[0]!='0'){
        cin>>B>>C;
        int len=A.size();
        int dp[len+1][2];
        fill(dp[0],dp[len+1],0);
        dp[0][0]=1;
        for(int i=1;i<=len;i++){
            int a,b,c;
            a=(A[len-i]=='?'?-1:A[len-i]-'0');
            b=(B[len-i]=='?'?-1:B[len-i]-'0');
            c=(C[len-i]=='?'?-1:C[len-i]-'0');
            for(int ai=0;ai<10;ai++){
                if(a!=-1&&ai!=a) continue;
                if(i==len&&ai==0) continue;
                for(int bi=0;bi<10;bi++){
                    if(b!=-1&&bi!=b) continue;
                    if(i==len&&bi==0) continue;
                    int ci=ai+bi;
                    if(c==-1){
                        if(ci<10){
                            dp[i][0]+=dp[i-1][0];
                            dp[i][0]%=1000000007;
                        }else{
                            dp[i][1]+=dp[i-1][0];
                            dp[i][1]%=1000000007;
                        }
                    }else{
                        if(ci<10&&c==ci){
                            dp[i][0]+=dp[i-1][0];
                            dp[i][0]%=1000000007;
                        }else if(ci>=10&&c==ci-10){
                            dp[i][1]+=dp[i-1][0];
                            dp[i][1]%=1000000007;
                        }
                    }
                    ci++;
                    if(c==-1){
                        if(ci<10){
                            dp[i][0]+=dp[i-1][1];
                            dp[i][0]%=1000000007;
                        }else{
                            dp[i][1]+=dp[i-1][1];
                            dp[i][1]%=1000000007;
                        }
                    }else{
                        if(ci<10&&c==ci){
                            dp[i][0]+=dp[i-1][1];
                            dp[i][0]%=1000000007;
                        }else if(ci>=10&&c==ci-10){
                            dp[i][1]+=dp[i-1][1];
                            dp[i][1]%=1000000007;
                        }
                    }
                }
            }
            // cout<<dp[i][0]<<' '<<dp[i][1]<<endl;
        }
        cout<<dp[len][0]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3212
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.NoSuchElementException;

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
    	return (int)nextLong();
    }
}

public class Main {

	public static void main(String[] args) {
		new Main().run();
	}
	
	void run() {
		FastScanner sc=new FastScanner();
		int ac=0,wa=0,tle=0,re=0;
		int N=sc.nextInt();
		for (int i=0;i<N;++i) {
			String s=sc.next();
			if (s.equals("AC")) ++ac;
			else if (s.equals("WA")) ++wa;
			else if (s.equals("TLE")) ++tle;
			else if (s.equals("RE")) ++re;
		}
		System.out.println("AC x "+ac);
		System.out.println("WA x "+wa);
		System.out.println("TLE x "+tle);
		System.out.println("RE x "+re);

	}
	
	
	
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
}



Measured memory_bytes: 46724
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	iv, _ := strconv.Atoi(scanString())
	return iv
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 100001), 100001*100)
}

func main() {
	n := scanInt()
	ans := make(map[string]bool, n)
	for i := 0; i < n; i++ {
		s := scanString()
		ans[s] = true
	}
	fmt.Println(len(ans))
}


Measured memory_bytes: 11016
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

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

const int UF_MAX_N = 201010;

int uf_parant[UF_MAX_N];
int uf_rank[UF_MAX_N];
int uf_group_size[UF_MAX_N];

void init(int n) {
  for (int i = 0; i < n; i++) {
    uf_parant[i] = i;
    uf_rank[i] = 0;
    uf_group_size[i] = 1;
  }
}

int find(int x) {
  if (uf_parant[x] == x) {
    return x;
  } else {
    return uf_parant[x] = find(uf_parant[x]);
  }
}

int get_size(int x) {
  x = find(x);
  return uf_group_size[x];
}

void unite(int x, int y) {
  x = find(x);
  y = find(y);
  if (x == y) return;

  if (uf_rank[x] < uf_rank[y]) {
    uf_parant[x] = y;
    uf_group_size[y] += uf_group_size[x];
  } else {
    uf_parant[y] = x;
    uf_group_size[x] += uf_group_size[y];
    if (uf_rank[x] == uf_rank[y]) uf_rank[x]++;
  }
}

bool same(int x, int y) { return find(x) == find(y); }

int N, K, L;
int road[201010], rail[201010];
map<Pii, int> cnt;

int main() {
  init(201000);
  cin >> N >> K >> L;
  rep(i, 0, K) {
    int p, q;
    cin >> p >> q;
    unite(p, q);
  }
  repe(i, 1, N) { road[i] = find(i); }

  init(201000);
  rep(i, 0, L) {
    int r, s;
    cin >> r >> s;
    unite(r, s);
  }
  repe(i, 1, N) { rail[i] = find(i); }

  repe(i, 1, N) { ++cnt[Pii(road[i], rail[i])]; }

  repe(i, 1, N) { cout << cnt[Pii(road[i], rail[i])] << " "; }
}


Measured memory_bytes: 18828
# include <bits/stdc++.h>
# define ll long long
using namespace std;
const ll mod = 1e9 + 7, N = 3e5 + 10;
ll a[N], res, count_ones[65], count_zeros[65]; 
int main(){
	int n;
	cin >> n;
	for(int i = 1; i <= n; i ++) cin >> a[i];
	for(int i = n; i >= 1; i --){
		ll cur = a[i];
		for(ll j = 0; j <= 62; j ++){
			if((1ll << j) & cur){
				res += (ll)count_zeros[j] * ((1ll << j) % mod);
			} else{
			    res += (ll)count_ones[j] * ((1ll << j) % mod);
			}
		}
		for(ll j = 0; j <= 62; j ++){
			if((1ll << j) & cur) count_ones[j] ++;
			else count_zeros[j] ++;
		}
		res %= mod;
	}
	cout << res << '\n';
}


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

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

int main(){
    ll n,ans=0;
    cin >> n;
    for(ll i=1;i<=n;i++){
        for(ll j=1;j<=n;j++){
            if(i*j<=n-1) ans++;
            if(i*j>=n) break;
        }
    }
    
    cout << ans << endl;

    return 0;
}











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


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

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] V = new int[N];
    int[] C = new int[N];
    int[] P = new int[N];
    int max =0;
    for (int i=0; i<N; i++) {
      V[i] = sc.nextInt();
    }
    for (int i=0; i<N; i++) {
      C[i] = sc.nextInt();
      P[i] = V[i] - C[i];
      if (P[i] > 0) {
        max += P[i];
      }
    }
    System.out.println(max);
  }
}

Measured memory_bytes: 22740
#[allow(unused_imports)]
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(n: usize, d: usize, x: [[isize; d]; n]);

    let mut ar = Vec::new();
    for i in 0..200 {
        ar.push(i * i);
    }

    let mut count = 0;

    for i in 0..n {
        for j in i + 1..n {
            let mut sum = 0;
            for k in 0..d {
                sum += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            }
            if ar.contains(&sum) {
                count += 1;
            }
        }
    }
    println!("{}", count);
}


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

int n,p[100001],d[100001];
vector<int> v[100001];

int dfs(int a){
    int s;
    vector<int> e;
    if(v[a].empty()){
        return 0;
    }
    e.reserve(v[a].size());
    int ans=0;
    for(int i=0;i<v[a].size();i++){
        e.push_back(dfs(v[a][i]));
    }
    s=v[a].size();
    sort(e.begin(),e.end());
    for(int i=0;i<s;i++){
        ans=max(ans,e[i]+s-i);
    }
    return ans;
}

int main(){
    scanf("%d",&n);
    int ans=0;
    for(int i=2;i<=n;i++){
        scanf("%d",&p[i]);
        v[p[i]].push_back(i);
    }
    printf("%d\n",dfs(1));
}

Measured memory_bytes: 18560
class Combination:
    def __init__(self, n_max=10**6, mod=10**9+7):
        # self._n_max = n_max
        self._fac, self._finv, self._inv = [0]*n_max, [0]*n_max, [0]*n_max
        self._fac[0], self._fac[1] = 1, 1
        self._finv[0], self._finv[1] = 1, 1
        self._inv[1] = 1
        self._mod = mod
        for i in range(2, n_max):
            self._fac[i] = self._fac[i - 1] * i % self._mod
            self._inv[i] = self._mod - self._inv[self._mod%i] * (self._mod // i) % self._mod
            self._finv[i] = self._finv[i - 1] * self._inv[i] % self._mod
    def com(self, n, r):
        if n < r: return 0
        if n < 0 or r < 0: return 0
        return self._fac[n] * (self._finv[r] * self._finv[n - r] % self._mod) % self._mod

    def perm(self,n,r):
        if n < r: return 0
        if n < 0 or r < 0: return 0
        return self._fac[n] * (self._finv[n-r] % self._mod) % self._mod


n = int(input())
xl = list(map(int, input().split()))
com = Combination(10**5+1)
MOD = 10**9+7

# print(com.perm(0,0),com.perm(1,1))

csum = 0
ans = 0
for i in range(n-1):
    diff = xl[i+1]-xl[i]
    val = com.com(n-1,i+1)*com.perm(i,i)*com.perm(n-2-i,n-2-i)
    # print(val,'-')
    csum += val
    csum %= MOD
    ans += diff*csum
    ans %= MOD

print(ans)

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

using ll = long long;

#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define len(x) int((x).size())

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define randint(n) uniform_int_distribution<int>(1, (n))(rng)

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

	#ifdef ARTHUR_LOCAL
		ifstream cin("input.txt");
	#endif

	int a;
	cin>>a;

	cout << a + a*a + a*a*a << endl;
}

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


int d[200] = {}, f[200] = {};

vector<int> G[200];

int func(int pos, int time){
  if(d[pos] > 0){
    return time;
  }
  d[pos] = time;
  time += 1;
  for(int to : G[pos]){
    time = func(to, time);
  }
  f[pos] = time;
  time += 1;
  return time;
}


int main(){
	// input

	int n;
	cin >> n;

	for ( int i= 0; i<n ;i ++){
		int u, k;
		cin >> u >> k;
		for (int j= 0; j<k;j++){
			int v;
			cin >> v;
			G[u].push_back(v);
		}
	}

	int time = 1;
	for( int i = 1; i<=n;i++){
		if(d[i] == 0){
			time = func(i, time);
		}
		cout << i << " " << d[i] << " " << f[i] << endl;

	}
	return 0;
}


Measured memory_bytes: 3168
#include <iostream>
#include <vector>
#include <string.h>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
#include <cmath>
#include <map>
#include <set>
#include <assert.h>
#define REP(i,n) for(ll i=0;i<(n);i++)
#define MOD 1000000007
#define int long long
#ifdef int
const long long INF = LLONG_MAX / 10;
#else
const int INF = 1010101010;
#endif
using namespace std;
typedef long long ll;
typedef vector<vector<ll> > mat;
typedef pair<int, int> P;
//typedef pair<double, double> P;
const int dx[9] = {-1, 0, 0, 1, -1, -1, 1, 1, 0};
const int dy[9] = {0, -1, 1, 0, -1, 1, -1, 1, 0};
 
int N;
P red[110];   //x, y
P blue[110];  //x, y

bool r_used[110];

signed main()
{
  cin >> N;
  REP(i,N) {
    cin >> red[i].first >> red[i].second;
  }
  REP(i,N) {
    cin >> blue[i].first >> blue[i].second;
  }

  sort(blue, blue + N);
  sort(red, red + N);
  int ans = 0;
  REP(i,N) {
    int ymax = -1;
    int idx = -1;
    REP(j,N) {
      if (blue[i].first <= red[j].first) break;
      if (!r_used[j] && red[j].second < blue[i].second && idx == -1) {
        idx = j;
        ymax = red[j].second;
      } else if (!r_used[j] && red[j].second < blue[i].second && red[j].second > ymax) {
        idx = j;
        ymax = red[j].second;
      }
    } 
    if (idx != -1) {
      r_used[idx] = true;
      ans++;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256