akhauriyash/Code-Regression huggingface dataset:
#ifndef _WIN32
#include<iostream>
#endif 
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<tuple>
#include<complex>
#include<queue>
#include<functional>
using namespace std;
typedef long long LL;
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
template<typename T> bool chmin(T &l, T r) {
	bool res = l > r;
	if (res) {
		l = r;
	}
	return res;
}
#define IL inline
#define X real()
#define Y imag()
typedef complex<double> P;
typedef pair<P, P> LS;
typedef double D;
const D EPS = 1e-8;
IL D dot(P a, P b) {
	return a.X*b.X + a.Y*b.Y;
}
IL D cross(P a, P b) {
	return a.X*b.Y - a.Y*b.X;
}



struct cww {
	cww() {
		cout << fixed;
		cout << setprecision(10);
	}
}star;

IL D distance_P_LS(P p, LS ls) {
	P a, b, c = p;
	tie(a, b) = ls;
	if (dot(b - a, c - a) < EPS)return abs(c - a);
	if (dot(a - b, c - b) < EPS)return abs(c - b);
	return abs(cross(b - a, c - a)) / abs(b - a);
}

IL bool isintersected_LS_LS(LS p, LS q) {
	P a, b ,c ,d;
	tie(a, b) = p;
	tie(c, d) = q;
	if (abs(cross(b - a, d - c))<EPS) {
		if (abs(abs(b - c) + abs(a - c) - abs(a - b)) < EPS)return true;
		if (abs(abs(b - d) + abs(a - d) - abs(a - b)) < EPS)return true;
		if (abs(abs(a - c) + abs(a - d) - abs(c - d)) < EPS)return true;
		if (abs(abs(b - c) + abs(b - d) - abs(c - d)) < EPS)return true;

		return false;
	}
	return cross(b - a, c - a)*cross(b - a, d - a) < EPS && cross(d - c, a - c)*cross(d - c, b - c) < EPS;
}
IL D distance_LS_LS(LS p, LS q) {
	if (isintersected_LS_LS(p, q))return 0;
	P a, b, c, d;
	tie(a, b) = p;
	tie(c, d) = q;
	double e, f, g, h;
	e = distance_P_LS(a, q);
	f = distance_P_LS(b, q);
	g = distance_P_LS(c, p);
	h = distance_P_LS(d, p);
	return min({ e,f,g,h });
}
P rot(P p, double r) {
	return P(p.X*cos(r) - p.Y*sin(r), p.X*sin(r) + p.Y*cos(r));
}

const D PI = acos(-1);
const D FI = 72.0 / 180.0*PI;
typedef pair<double, int> pp;
const int ss[][2] = { {0,2},{0,3},{1,3},{1,4},{2,4} };
typedef priority_queue<pp, vector<pp>, greater<pp>> QUE;
int main() {
	int N, M, L;
	while (cin >> N >> M >> L, N) {
		vector<LS> ls(5*N);
		REP(i, N) {
			double x, y,a,r;
			cin >> x >> y >> a >> r;
			P p(x, y);
			vector<P> pt(5);
			pt[0] = rot(P(0, r), a/180.0*PI);
			REP(i, 4)pt[i + 1] = rot(pt[i], FI);
			REP(j, 5) {
				ls[i * 5 + j] = LS(p+pt[ss[j][0]], p+pt[ss[j][1]]);
			}
		}
		vector<vector<double>> dist(N * 5, vector<double>(N * 5));
		REP(i, 5*N)REP(j, 5*N) {
			if (i == j)dist[i][j] = 0;
			else dist[i][j] = distance_LS_LS(ls[i], ls[j]);
		}
		int S = 5 * (M - 1);
		int G = 5 * (L - 1);





		vector<double> res(N *5, 1e18);
		res[S] = 0;
		QUE que;
		que.push(pp(0,S));
		while (que.size()) {
			int v; double cost;
			tie(cost,v) = que.top();
			que.pop();
			if (cost > res[v])continue;
			REP(u, 5 * N) if(u!=v){
				double ncost = cost + dist[u][v];
				if (chmin(res[u], ncost))que.push(pp(ncost, u));
			}
		}
		cout << res[G] << endl;
	}
	return 0;
}

Measured memory_bytes: 5456
N = int(input())
li = list(map(int,input().split()))
if len(li) == 1:
    print(li[0])
    exit()
dp = [0,abs(li[1]-li[0])]
for i in range(2,N):
    dp.append(min(dp[i-1]+abs(li[i]-li[i-1]), dp[i-2]+abs(li[i]-li[i-2])))
print(dp[N-1])


Measured memory_bytes: 13980
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e18+10;

/*----------------------------------------------*/


signed main(){
  int n;
  cin>>n;
  vi p(n),q(n);
  rep(i,n) cin>>p[i];
  rep(i,n) cin>>q[i];
  
  vi v(n);
  rep(i,n) v[i]=i+1;


  int a=0,b=0,k=1;
  do{
    int fa=1,fb=1;
    rep(i,n){
      if(p[i]!=v[i]) fa=0;
      if(q[i]!=v[i]) fb=0;
    }
    if(fa==1){
      // rep(i,n)cout<<v[i];
      // cout<<endl;
      a=k;
    }
    if(fb==1) b=k;
    // if(a&&b) break;
    // rep(i,n) cout<<v[i];
    // cout<<endl;
    k++;
  }while(next_permutation(all(v)));
  
  cout<<abs(a-b)<<endl;
  // cout<<n<<endl;
  return 0;
}

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    int X, A; cin >> X >> A;
    if(X<A) cout << "0" << endl;
    else cout << "10" << endl;
}

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

#define ed cout<<"\n";
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long 
#define ffor(i,a,b) for(ll i=(a);i<(ll)(b);++i)
#define rep(i, n) ffor(i,0,n)
#define All(obj) (obj).begin(),(obj).end()
#define INF ((ll)1e9+7)
#define c(a) cout<<a<<"\n";
using namespace std;

int main() {
	speed;
	int n, q;
	string s;
	cin >> n >> q>>s;
	vector<int>l(q);
	vector<int>r(q);
	ll dp[(int)1e5];
	dp[1] = 0;
	ffor(i, 1, n ) {
		if (s[i] == 'C'&&s[i - 1] == 'A')dp[i + 1] = dp[i] + 1;
		else dp[i + 1] = dp[i];
	}
	rep(i, q) {
		cin >> l[i] >> r[i];
	}
	rep(i, q ) {
		c(dp[r.at(i)] - dp[l.at(i)]);
	}
	ed;
	return 0; 
}



Measured memory_bytes: 2768
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define pi 3.1415
	 
int main()
{
	fastio;
	int n,m;
	cin>>n>>m;
	int A[m];
	int sum=0;
	for(int i=0;i<m;i++)
	{
		cin>>A[i];
		sum+=A[i];
	}
	if(sum>n)
	cout<<"-1\n";
	else
	cout<<n-sum<<endl;
	
	
	return 0;
	
	
}

Measured memory_bytes: 3624
import sys
MAX_INT = int(10e9)
MIN_NUM = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()
t = S()

cnt = 0
for i in range(3):
  if s[i] == t[i]:
    cnt += 1

print(cnt)

Measured memory_bytes: 38256
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <time.h>
#include <stdarg.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <functional>
#include <map>

#define ll long long

using namespace std;

ll
getValue(vector<ll> & seg, ll start, ll end) {
  if (start > end) return 0;

  ll ret = 0;
  while (1) {
    if (start > end) break;

    if (end % 2 == 0) {
      ret = max(ret, seg[end]);
      end--;
    }
    if (start % 2 == 1) {
      ret = max(ret, seg[start]);
      start++;
    }

    start /= 2;
    end /= 2;
  }

  return ret;
}

void
update(vector<ll> & seg, ll index, ll v) {
  ll i = index;
  seg[i] = v;
  while (1) {
    if (i == 0) break;

    i /= 2;
    seg[i] = max(seg[i*2], seg[i*2+1]);
  }
}

void
solve() {
  ll n;
  cin>>n;

  vector<ll> h(n), a(n);
  for (ll i=0; i<n; i++) { cin>>h[i]; h[i]--; }
  for (ll i=0; i<n; i++) cin>>a[i];

  vector<ll> seg(2 * n, 0);
  ll ans = 0;
  for (ll i=0; i<n; i++) {
    ll v = getValue(seg, n, h[i]+n-1) + a[i];
    ans = max(ans, v);
    update(seg, h[i]+n, v);

    //for (ll i=0; i<2*n; i++) cout<<seg[i]<<","; cout<<endl;
  }
  cout<<ans<<endl;
}

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

  ll t = 1;
  //cin>>t;

  while (t > 0) {
    t--;
    solve();
  }

  return 0;
}



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

 using namespace std;
 typedef long long ll;
 #define rep(i, n) for(int i = 0; i < (int)(n); i++)

 int main() {
   int N;
   cin >> N;
   vector<int> X(N), Xs(N);
   rep(i, N) {
     cin >> X.at(i);
     Xs.at(i) = X.at(i);
   }

   sort(Xs.begin(), Xs.end());

   rep(i, N) {
     if (X.at(i) <= Xs.at(N / 2 - 1)) cout << Xs.at(N / 2) << endl;
     else cout << Xs.at(N / 2 - 1) << endl;
   }
 }


Measured memory_bytes: 3712
// Author: Amey Bhavsar
// ID: bhavsar
// IDE: Geany/Ubuntu
// Platform: AtCoder Beginner Contest 174
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

#define rep(i,a,b) for(auto i=a;i<b;i++)
#define repD(i,a,b) for(auto i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

// to be used with algorithms that processes a container Eg: find(all(c),42)
#define all(x) (x).begin(), (x).end() //Forward traversal
#define rall(x) (x).rbegin, (x).rend() //reverse traversal
// traversal function to avoid long template definition
#define tr(c,i) for(__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)
//find version works for all containers. This is present in std namespace.
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define MOD 1000000007
// ll fe (ll x, ll y) {
	// ll ans = 1;
	// while (y>0) {
		// if (y&1) {
			// ans = (x*ans) % MOD;
		// }
		// y /= 2;
		// x = (x*x) % MOD;
	// }
	// return (ans % MOD);
// }

// ll modmul(ll a, ll b) {
    // return ((a%MOD) * (b%MOD)) % MOD;
// }

// ll modadd(ll a , ll b){
    // return((a%MOD)+(b%MOD)+MOD)%MOD;
// }

// ll modsub(ll a , ll b){
    // return((a%MOD) - (b%MOD) + MOD)%MOD;
// }

int main() {
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	int n;
	cin >> n;
	
	string s;
	cin >> s;
	
	int l = 0, r = n-1, ans = 0;
	while (l<r) {
		if (s[l] == 'W' && s[r] == 'R') {
			swap(s[l],s[r]);
			ans++;
		} else if (s[l] == 'R' && s[r] == 'R') {
			l++;
		} else if (s[l] == 'R' && s[r] == 'W') {
			l++;
			r--;
			continue;
		} else {
			r--;
		}
	}
	// cout << s << '\n';
	cout << ans << '\n';
	
	
	
	return 0;
}


Measured memory_bytes: 3768
#include <cstdlib>
#include <iostream>
#include <string>
#include <time.h>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <vector>
#include <functional>
//#include "bits/stdc++.h"
using namespace std;
//using namespace std::vector;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)

#define huge 1000000007
typedef long long ll;
ll gcd(ll a, ll b);

int main(void) {

	ll N = 0;
	ll A = 0;
	ll B = 0;
	ll C = 0;
	ll D = 0;
	ll M = 0;
	//ll M = 0;
	//ll a[200] = {};
	//ll b[200] = {};
	//ll v[3] = {};
	//ll *a, *b, *x;
	string S,T,U[52];
	ll count = 0;
	ll count2 = 0;
	ll sum = 0;
	ll min = 100000;
	ll max = 0;
	ll smax = 0;
	ll max2 = 0;
	ll smax2 = 0;
	int tmax = 0;
	int tmax2 = 0;
	int flag = 0;
	char temp,head;
	//int is = 0;
	
	
	//char p;


	

	

	//cin >> S;
	
	//b = (ll *)malloc(M * sizeof(ll));
	//vector<pair<int,int>> ch(50);

	
	cin >> N;
	//a = (ll *)malloc(A * sizeof(ll));
	



	cout << 48-N << endl;
	//x = (ll *)malloc((N+1) * sizeof(ll));
	//c = (ll *)malloc((N) * sizeof(ll));
	//cin >> D >> G;
	//vector<pair<int,int>> tr(M);
	//vector<pair<int,int>> qes(Q);
	//sort(c.begin(), c.end());
	
	//cout << c[2] - c[1] << endl;

	

	/*A = N / 1000;
	N %= 1000;
	B = N / 100;
	N %= 100;
	C = N / 10;
	N %= 10;
	D = N;*/
	


	return 0;

}

ll gcd(ll a, ll b) {
	ll x = a * b;

	/* 自然数 a > b を確認・入替 */
	if (a<b) {
		ll tmp = a;
		a = b;
		b = tmp;
	}

	/* ユークリッドの互除法 */
	ll r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}


	return x/b;
}



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

int main() {
    int A1, A2, A3; cin >> A1 >> A2 >> A3;
    if (A1 + A2 + A3 >= 22) {
        cout << "bust" << endl;
    } else {
        cout << "win" << endl;
    }
}


Measured memory_bytes: 256
s = gets.chomp.split("")

left = s[0].to_i * 10 + s[1].to_i
right = s[2].to_i * 10 + s[3].to_i

mon_l = false
mon_r = false

if 0 < left and left < 13
    mon_l = true
end

if 0 < right and right < 13
    mon_r = true
end

if mon_l and mon_r 
    puts "AMBIGUOUS"
elsif mon_l 
    puts "MMYY"
elsif mon_r
    puts "YYMM"
else
    puts "NA"
end

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N;
    cin >> N;
    vec d(N);
    REP(i,0,N) cin >> d[i];
    
    ASC(d);
    PR(d[N/2]-d[N/2-1]);

    return 0;
}

/*



*/

Measured memory_bytes: 4052
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define mod 1000000007
#define MN 401000
 
typedef long long ll;
 
struct xxx{
    int u, v, c;
}e[MN];
 
int n, m;
int fa[MN], dep[MN]; ll sum = 0;
int Max[MN][20], st[MN][20];
bool used[MN];
int h[MN], nxt[2 * MN], to[2 * MN], cost[2 * MN], K = 0;
 
int Find(int x) {return fa[x] == x ? x : fa[x] = Find(fa[x]);}
 
void ins(int u, int v, int c) {nxt[++K] = h[u]; h[u] = K; to[K] = v; cost[K] = c;}
 
bool cmp(xxx a, xxx b) {return a.c < b.c;}
 
void kruskal()
{
    std::sort(e + 1, e + m + 1, cmp);
    for(int i = 1; i <= n; i++) fa[i] = i;
    for(int i = 1; i <= m; i++)
    {
        if(Find(e[i].u) != Find(e[i].v))
        {
            ins(e[i].u, e[i].v, e[i].c);
            ins(e[i].v, e[i].u, e[i].c);
            sum += e[i].c; used[i] = 1;
            fa[Find(e[i].u)] = Find(e[i].v);
        }
    }
}
 
void dfs(int x, int fa, int c)
{
    st[x][0] = fa; Max[x][0] = c; dep[x] = dep[fa] + 1;
    for(int i = 1; i <= 18; i++)
    {
        st[x][i] = st[st[x][i - 1]][i - 1];
        Max[x][i] = std::max(Max[x][i - 1], Max[st[x][i - 1]][i - 1]);
    }
    for(int i = h[x]; i; i = nxt[i])
        if(to[i] != fa) dfs(to[i], x, cost[i]);
}
 
int qpow(int x, int p)
{
    int ans = 1;
    while(p)
    {
        if(p & 1) ans = 1ll * ans * x % mod;
        x = 1ll * x * x % mod; p >>= 1;
    }
    return ans;
}
 
int calc(int x, int y)
{
    int ans = 0;
    for(int i = 18; i >= 0; i--)
    {
        if(dep[st[x][i]] >= dep[y])
        {
            ans = std::max(ans, Max[x][i]);
            x = st[x][i];
        }
        if(dep[st[y][i]] >= dep[x])
        {
            ans = std::max(ans, Max[y][i]);
            y = st[y][i];
        }
    }
    if(x == y) return ans;
    for(int i = 18; i >= 0; i--)
    {
        if(st[x][i] != st[y][i])
        {
            ans = std::max(ans, Max[x][i]);
            ans = std::max(ans, Max[y][i]);
            x = st[x][i]; y = st[y][i];
        }
    }
    ans = std::max(ans, Max[x][0]);
    ans = std::max(ans, Max[y][0]);
    return ans;
}
 
int solve(ll x)
{
    if(sum >= x) return qpow(2, m);
    int ans = m - n + 2;
    for(int i = 1; i <= m; i++)
        if(!used[i] && sum + e[i].c - calc(e[i].u, e[i].v) < x) ans--;
    return qpow(2, ans);
}
 
int main()
{
    ll x; scanf("%d%d%lld", &n, &m, &x);
    for(int i = 1; i <= m; i++) scanf("%d%d%d", &e[i].u, &e[i].v, &e[i].c);
    kruskal(); dfs(1, 0, 0);
    printf("%d\n", (solve(x) - solve(x + 1) + mod) % mod);
}

Measured memory_bytes: 14720
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
    int h,w;
    cin >> h >> w;
    vector<vector<char>> v(h+2,vector<char>(w+2,'-'));
    rep(i,h){
        string s;
        cin >> s;
        rep(j,s.size()){
            v[i + 1][j + 1] = s[j];
        }
    }
    int mvx[8] = {1,1,1,0,0,-1,-1,-1};
    int mvy[8] = {1,0,-1,1,-1,1,0,-1};
    rep(i, h)
    {
        rep(j,w){
            if(v[i+1][j+1] != '.')
                continue;
            int cnt = 0;
            rep(k, 8)
            {
                if(v[i+1+mvx[k]][j+1+mvy[k]]=='#'){
                    cnt++;
                }
            }
            v[i + 1][j + 1] = '0' + cnt;
        }
    }
    rep(i,h){
        rep(j,w){
            cout << v[i + 1][j + 1];
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll A,B;
    cin >>A>>B;
    if(A+B>=10){
        cout<<"error"<<endl;
    }else{
        cout<<A+B<<endl;
    }



    return 0;
    

}

Measured memory_bytes: 3632
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class APainting {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int H, W, N;
        in>>H>>W>>N;
        if(H<W) swap(H, W);
        out<<(N+H-1)/H<<'\n';
    }
};


int main() {
	APainting solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (size_t i = 0; i < size_t(n); i++)
#define forn1(i,n) for (size_t i = 1; i <= size_t(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

const int MAX_N = 8;
int n, m;
bool g[MAX_N][MAX_N];

int main() {
    fastio();

    cin >> n >> m;
    forn(i, m) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a][b] = g[b][a] = true;
    }

    vi ord(n);
    iota(all(ord), 0);

    int ans = 0;
    do {
        bool ok = true;
        forn(i, n - 1) {
            ok &= g[ord[i]][ord[i + 1]];
        }
        ans += ok;
    } while (next_permutation(ord.begin() + 1, ord.end()));

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
typedef pair<int,int> P;

const int MOD=1000000007;
int INF=100100100100100;
map<int,int> po;
signed main(){
  int x,n;cin>>x>>n;
  rep(i,n){
    int t;cin>>t;
    po[t]++;
  }
  int ima=0;
  while(1){
    if(po[x-ima]==0){
      cout<<x-ima<<endl;
      break;
    }
    if(po[x+ima]==0){
      cout<<x+ima<<endl;
      break;
    }
    ima++;
  }
    
  return 0;
}


Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int H,W;
		String work[] = new String[2];

		while(true){

			try {
				work = br.readLine().split("[\\s]+");

				if(work[0].equals("0") && work[1].equals("0"))break;

				H = Integer.parseInt(work[0]);
				W = Integer.parseInt(work[1]);

				for(int col = 0; col < W; col++){
					System.out.printf("#");
				}
				System.out.printf("\n");

				for(int row = 1; row <= H-2; row++){
					System.out.printf("#");
					for(int col = 1; col <= W-2; col++){
						System.out.printf(".");
					}
					System.out.printf("#\n");
				}

				for(int col = 0; col < W; col++){
					System.out.printf("#");
				}
				System.out.printf("\n\n");


			} catch (IOException e) {

				e.printStackTrace();
			}
		}
	}
}




Measured memory_bytes: 57844
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n-1); i >= 0; i--)
#define all(v) (v).begin(),(v).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a/gcd(a,b)*b; }
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    rep(i,n-k) {
        if(a[i]<a[i+k]) {
            cout << "Yes" << "\n";
        } else {
            cout << "No" << "\n";
        }
    }
	return 0;
}


Measured memory_bytes: 3980
n = int(input())
s = input()
r = 0
g = 0
b = 0
for i in range(n):
    if(s[i]=='R'):r+=1
    if(s[i]=='G'):g+=1
    if(s[i]=='B'):b+=1
rem = 0
for i in range(n-2):
    width = 1
    while i+width*2<n:
        if(s[i]!=s[i+width] and s[i+width]!=s[i+width*2] and s[i+width*2]!=s[i]):
            rem += 1
        width += 1
print(r*g*b-rem)

Measured memory_bytes: 73440
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

using VI = vector<int>;

#define ALL(a) (a).begin(),(a).end()
#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)
#define IN(v) int v;cin>>v;
#define OUT(v) cout<<v<<endl

int main() {
  IN(N);

  VI S;
  REP(i, N) {
    IN(s);
    S.push_back(s);
  }
  SORT(S);

  int ans = 0;
  IN(q);
  REP(i, q) {
    IN(t);
    if (binary_search(ALL(S), t))
      ++ans;
  }
  OUT(ans);

  return 0;
}



Measured memory_bytes: 3372
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
int main()
{
    int N,K;
    int A;
    std::cin >> N >> K;
    std::vector<int> h,maxmin;
    for(int i=0; i<N; i++){
        std::cin >>A;
        h.push_back(A);
    }
    std::sort(h.begin(),h.end());
    for(int i=0; i<N-K+1;i++){
        A=h[i+K-1] - h[i];
        maxmin.push_back(A);
    }
    int min;
    std::sort(maxmin.begin(),maxmin.end());
    std::cout << maxmin[0] << std::endl;
    return 0;
}

Measured memory_bytes: 1400
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

int main(){
	ll n,k;
	scanf("%lld%lld",&n,&k);
	ll ans=0;
	rep(i,0,n){
		ll x;
		scanf("%lld",&x);
		ans+=min(k-x,x);
	}
	printf("%lld",ans*2);
}

Measured memory_bytes: 128
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>


typedef long double ld;
typedef long long ll;

using namespace std;

int main() {
	ll a, b, v, w, t;
	cin >> a >> v >> b >> w >> t;

	ll dv = v - w;
	ll d = abs(b - a);
	if (dv <= 0) {
		cout << "NO" << endl;
		return 0;
	}
	if (t * dv >= d) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
	return 0;
}


Measured memory_bytes: 3564
from collections import defaultdict

n = int(input())
if n == 1:
	print(1)
else:
	balls = [list(map(int, input().split())) for _ in range(n)]

	d = defaultdict(lambda: 0)
	for x in range(n):
		for y in range(n):
			d[(balls[x][0] - balls[y][0], balls[x][1] - balls[y][1])] += 1

	del d[(0, 0)]
	print(n - max(d.values()))

Measured memory_bytes: 3828
// author -> LetsGoAC
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using    namespace std;
using    namespace __gnu_pbds; 
#define  ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
//  ordered_set os;
//  order_of_key (k) : Number of items strictly smaller than k .
//  *find_by_order(k) : K-th element in a set (counting from zero).
typedef  long double ld;
#define  int long long
typedef  pair<int,int> pii;
#define  RAGE ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  rep(i,n) for(i=0; i <n; i++)
#define  repv(i,k,n) for(int i=k; i<=n; i++)
#define  pb push_back
#define  mp make_pair
#define  F  first
#define  S  second
#define  sz(x)  (int)x.size()
#define  all(v) v.begin(),v.end()
#define  endl '\n'
#define  deb(x) cout<<#x<<" = "<<x<<endl
#define  gcd   __gcd
#define  inf   LLONG_MAX
#define  minf  LLONG_MIN 
#define  gi  greater<int> 
#define  gpi greater<pii>  
#define  sp(n) fixed<<setprecision(n)
vector   <int> Fact(100005 , 0);
const int mod = (int)(1e9+7);
int power(int x,int n)
{   
    if(n==0)    return 1;
    if(n==1)    return x%mod;
    if(n%2==0)  {   int y = power(x,n/2)%mod;return (y*y)%mod;}
    if(n&1)     {   int y = power(x,n-1);return (x%mod * y%mod)%mod;}
    return 0;
}
int modi(int n , int m)
{   //mod = m; // change const mod;
    int mod_inverse = power(n , m-2);
    return mod_inverse;
}
int  pct(int x){return __builtin_popcountll(x);}
int  lcm(int a,int b){return a*b/gcd(a,b);}
bool is_power_2(int n){return log2(n)==floor(log2(n));}
bool is_prime(int n){for(int i=2; i*i<=n; i++)if(n%i==0)return 0; return 1;}
void cal_fac()
{
     Fact[0] = Fact[1] = 1;
     for(int i=2; i<1e5; i++)
         Fact[i] = (Fact[i-1]*i)%mod;
}
int C(int n , int k)
{
    int res = Fact[n];
    res = (res * modi( Fact[k] , mod ))%mod;
    res = (res * modi( Fact[n-k] ,mod ))%mod;
    return res;
}
ld log(int n , int base)
{
    ld ans = 1.0 * log(n)/log(base);
    return ans;
}
void db()
{   
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}
void timeit()
{  
    #ifndef ONLINE_JUDGE
        cout<<"\nTime Elapsed: " <<sp(10)<< 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif
}
int     dx []    =  {-1 , 0 , 1 , 0 ,-1,-1, 1,  1};
int     dy []    =  { 0 , 1 , 0 ,-1 ,-1, 1, 1, -1};
char    dir[]    =  {'U','R','D','L'};
/* ---------------------- 1.cpp --------------------------------- */
const int maxn = 1e6+5;
void solve(int tc)
{   
    //  cout<<"Case #"<<tc<<": ";
    int n,i,j,k,m,q,l,r;
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max({a*c , a*d , b*c , b*d});
}   
signed main()
{
    // 1.cpp
    RAGE;
    //db();  
    int t=1;
    // cin>>t;
    for(int i=1; i<=t; i++)
    {
        solve(i);
    }
    //timeit();
    return 0;
}
/*
    1. To find 2's complement , inverse all the bits after 1st set bit. (right -> left.)
    2. continue , break;
*/

Measured memory_bytes: 3892
/// kAAzuki Hoshino
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

 


signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
        
	

	map<string, int> mp;
	mp["SUN"] = 0;
	mp["MON"] = 1;
	mp["TUE"] = 2;
	mp["WED"] = 3;
	mp["THU"] = 4;
	mp["FRI"] = 5;
	mp["SAT"] = 6;

	string s;
	cin >> s;
	cout << (7-mp[s]) << endl;

	
    

return 0;
}
///....


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

struct PartiallyPersistentUnionFindTree {
    vector<int> par, time; vector<vector<pair<int, int>>> sz; int now;
    int operator[](int x) const { return find(x); }
    void build(int n) { par.assign(n, 1); time.assign(n, INT32_MAX); sz.assign(n, { { 0, 1 } }); now = 0; }
    int find(int t, int x) const { while (time[x] <= t) x = par[x]; return x; }
    int find(int x) const { return find(now, x); }
    bool same(int t, int x, int y) const { return find(t, x) == find(t, y); }
    bool same(int x, int y) const { return same(now, x, y); }
    int size(int t, int x) const {
        x = find(t, x);
        return prev(lower_bound(sz[x].begin(), sz[x].end(), make_pair(t + 1, 0)))->second;
    }
    int size(int x) const { return sz[find(x)].back().second; }
    bool unite(int x, int y) {
        ++now;
        if ((x = find(now, x)) == (y = find(now, y))) return 0;
        par[x] = max(par[x], par[y] + 1);
        par[y] = x;
        time[y] = now;
        sz[x].emplace_back(now, sz[x].back().second + sz[y].back().second);
        return 1;
    }
    bool uniteByRank(int x, int y) { return par[find(x)] < par[find(y)] ? unite(y, x) : unite(x, y); }
};

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(M), B(M);
    for (int i = 0; i < M; ++i) cin >> A[i] >> B[i], A[i]--, B[i]--;

    PartiallyPersistentUnionFindTree ppuf;
    ppuf.build(N);
    for (int i = M - 1; i >= 0; --i) {
        ppuf.uniteByRank(A[i], B[i]);
    }

    ll ans = 0;
    for (int i = 0; i < M; ++i) {
        if (ppuf.same(M - i, A[i], B[i]) ^ ppuf.same(M - i - 1, A[i], B[i])) {
            int s = ppuf.size(M - i - 1, A[i]), t = ppuf.size(M - i - 1, B[i]);
            ans += (ll)s * t;
        }
        cout << ans << endl;
    }
}

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

#define mx 100005
#define ll long long

int ar[mx];
char ch[mx];

int n,m,k,ii;

void solve()
{
    scanf("%d",&n);
    if(n>=400 && n<=599)
    {
        printf("8\n");
    }
    if(n>=600 && n<=799)
    {
        printf("7\n");
    }
    if(n>=800 && n<=999)
    {
        printf("6\n");
    }
    if(n>=1000 && n<=1199)
    {
        printf("5\n");
    }
    if(n>=1200 && n<=1399)
    {
        printf("4\n");
    }
    if(n>=1400 && n<=1599)
    {
        printf("3\n");
    }
    if(n>=1600 && n<=1799)
    {
        printf("2\n");
    }
    if(n>=1800 && n<=1999)
    {
        printf("1\n");
    }
}

int main()
{
   //freopen("in.txt","r",stdin);
   //freopen("out.txt","w",stdout);
   int t=1;
   //scanf("%d",&t);
   while(t--)solve();
   return 0;
}


Measured memory_bytes: 3756
s = input()
n = len(s)
s += s[-1]
ans = 0
pos = 0
is_len_1 = False
is_now = ""
while pos < n:
    if is_len_1:
        if s[pos - 1] == s[pos]:
            pos += 2
            is_len_1 = False
            is_now = s[pos : pos + 2]
        else:
            pos += 1
            is_now = s[pos : pos + 1]
    else:
        pos += 1
        is_len_1 = True
        is_now = s[pos : pos + 1]
    ans += 1
if pos == n + 1:
    ans -= 1
print(ans)


Measured memory_bytes: 9384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll n;
  cin>>n;
  vec a(n);
  vec b(n);
  for(ll i=0;i<n;i++) {
    cin >> a[i] >> b[i];
  }
  ll ans=0;
  for(ll i=n-1;i>-1;i--) {
    ans+=(b[i]-(a[i]+ans)%b[i])%b[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--) 
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que) priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
typedef vector<vector<int>> Matrix;
const int MOD = 1e9 + 7;
const int MAX = 1e7;
const int INF = numeric_limits<int>::max();

int main(){
 int n,d,res=0; cin>>n>>d;
 double x[n][d];

 REP(i,n){
   REP(j,d){
     cin>>x[i][j];
   }
 }



 REP(i,n){
   FOR(j,i+1,n){
     double diff=0;
     REP(k,d){
       diff+=pow(abs(x[i][k]-x[j][k]),2);

     }
     diff=pow(diff,0.5);
     //cout<<diff<<endl;
     REP(k,1000){
       if(diff==k){
         res++;
         break;
       }
     }
   }
 }
 

 cout<<res<<endl;

}

Measured memory_bytes: 384
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    cnt=0
    N=I()
    S=input()
    now="A"
    for i in range(N):
        if S[i]!=now:
            cnt+=1
        now=S[i]
        
    print(cnt)

main()


Measured memory_bytes: 68316
//compiledef
#include <bits/stdc++.h>
#define rep(i, n) for(i=0;i<(n);i++)
#define per(i, n) for(i=(n);i>0;i--)
#define repx(i, n, x) for(i=(x);i<(n);i++)
#define xper(i, n, x) for(i=(n);i>(x);i--)
#define pback push_back

//c++def
using namespace std;
typedef long long int ll;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
int a[265];
int near(char t, int i){
	if(t == 'p') return floor(i/2);
	if(t == 'l') return i*2;
	if(t == 'r') return i*2+1;
	return 0;
}

int main(){
	int tmp;
	int n;
	int i;
	cin >>n;
	for(i = 1;i<=n;i++){
		scanf("%d", &a[i]);
	}
	for(i=1;i<=n;i++){
		cout << "node "<< i<<": key = "<<a[i]<<", ";
		tmp = near('p', i);
		if(tmp<=n && tmp >0) cout << "parent key = "<< a[tmp] << ", ";
		tmp = near('l', i);
		if(tmp<=n && tmp >0) cout << "left key = " << a[tmp] << ", ";
		tmp = near('r', i);
		if(tmp<=n && tmp >0) cout << "right key = " << a[tmp] << ", ";
		cout << endl;
	}
}



Measured memory_bytes: 3172
while True:
	try:
		a,b,c = map(str, raw_input().replace("+","=").split("="))
		i = 1 if a!=a[0]=="X" or b!=b[0]=="X" or c!=c[0]=="X" else 0
		for x in range(i,10):
			if eval((a+"+"+b+"=="+c).replace("X",str(x))):
				print x
				break
		else:
			print "NA"
	except:
		break

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

int main(){
  string s;
  cin>>s;
  if(s=="SUN"){
    cout<<7;
  }else if(s=="MON"){
    cout<<6;
  }else if(s=="TUE"){
    cout<<5;
  }else if(s=="WED"){
    cout<<4;
  }else if(s=="THU"){
    cout<<3;
  }else if(s=="FRI"){
    cout<<2;
  }else if(s=="SAT"){
    cout<<1;
  }
}
    


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

using namespace std;

const int M = 262144;

int A[M], tr[M << 1];
int n, q;

void update(int p, int x) {
    tr[p | M] = x;
    for (p = (p | M) >> 1; p != 0; p >>= 1)
        tr[p] = max(tr[p << 1], tr[p << 1 | 1]);
}

int query(int l, int r) {
    int res = -1;
    for (l += M - 1, r += M + 1; (l ^ r) != 1; l >>= 1, r >>= 1) {
        if ((~l & 1) == 1)
            res = max(res, tr[l ^ 1]);
        if ((r & 1) == 1)
            res = max(res, tr[r ^ 1]);
    }
    return res;
}

int main() {
    scanf("%d%d", &n, &q);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &A[i]);
        tr[i | M] = A[i];
    }
    for (int i = M - 1; i != 0; --i)
        tr[i] = max(tr[i << 1], tr[i << 1 | 1]);
    while (q-- != 0) {
        int t, x, y;
        scanf("%d%d%d", &t, &x, &y);
        if (t == 1)
            update(x, y);
        if (t == 2)
            printf("%d\n", query(x, y));
        if (t == 3) {
            int l = x, r = n, res = n + 1;
            while (l <= r) {
                int mid = (l + r) >> 1;
                if (y <= query(x, mid)) {
                    res = mid;
                    r = mid - 1;
                } else
                    l = mid + 1;
            }
            printf("%d\n", res);
        }
    }
    return 0;
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<ll,int> pii;
typedef vector<ll> VL; const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}

int main()
{
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int a,b,c,d;
	cin >>a >>b >>c >>d;
	while(1){
		if(c>0){
			c -= b;
			if(c<1){ puts("Yes"); return 0;}
		}
		if(a>0){
			a -= d;
			if(a<1){ puts("No"); return 0;}
		}
	}
	return 0;
}


Measured memory_bytes: 3596
#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>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    if (a % b == 0) return b;
    return gcd(b, a % b);

}

class Solve {
public:
    void input() {

    }

    void solve() {
        input();
        int N, M;
        cin >> N >> M;
        vector<int> tabe(M + 1);
        rep(i, 0, N) {
            int k;
            cin >> k;
            rep(j, 0, k) {
                int tmp;
                cin >> tmp;
                tabe[tmp]++;
            }
        }
        int ans = 0;
        for (int i = 1; i <= M; ++i) {
            if (tabe[i] == N) ans++;
        }
        cout << ans << endl;
    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 888
import java.util.Scanner;

public class Main {

    public static String converter(String number, int base, int dest){
        return Integer.toString(Integer.parseInt(number, base), dest);
    }

    private static int converter(String number, int dest){
        return converter(number, 10, dest).length();
    }

    private static int stamina(int[] A, int n){
        int res = Integer.MAX_VALUE;
        for(int p = 1; p <= 1000; p++){
            int sum = 0;
            for(int a: A){
                sum += ((a - p) * (a - p));
            }
            res = Math.min(sum, res);
        }
        return res;
    }
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] dest = new int[n];
        for(int i = 0; i < n; i++){
            dest[i] = scanner.nextInt();
        }
        System.out.println(stamina(dest, n));
    }
}


Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <list>

using namespace std;

map<long long,long long> mp,mp2;

void init(long long X){
    for(long long i=1;pow(i,5)<X;i++){
        long long tmp=pow(i,5);
        mp[i]=tmp;
        mp2[tmp]=i;
    }
}



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

    cin>>X;

    init(100000000*X);

    if(mp2[X] != 0){
        A=mp2[X];
        B=0;

        cout<<A<<" "<<B<<endl;

    return 0;
    }else{
        for(auto itr = mp.begin(); itr != mp.end() ; ++itr){
            for(auto itr2 = mp.begin(); itr2 != mp.end();++itr2){
                if(mp[itr->first] + mp[itr2 -> first] == X){
                    A=itr->first;
                    B=0-itr2->first;
                }else if(mp[itr->first] - mp[itr2 -> first] == X){
                    A = itr->first;
                    B=  itr2->first ;
                }
            }
        }

    }



    cout<<A<<" "<<B<<endl;

    return 0;
}



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

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

    vector<set<int>> p(26);
    rep(i,n) {
        int j = s[i]-'a';
        p[j].insert(i);
    }

    vector<int> ans;
    rep(i,q) {
        int t;
        cin >> t;
        if(t == 1) {
            int iq;
            string cq;
            cin >> iq >> cq;            
            p[int(s[iq-1]-'a')].erase(iq-1);
            p[int(cq[0]-'a')].insert(iq-1);
            s[iq-1] = cq[0];
        }
        else {
            int l,r;
            cin >> l >> r;
            int cnt = 0;
            rep(j,26) {
                auto itr_l = p[j].lower_bound(l-1);
                auto itr_r = p[j].upper_bound(r-1);
                if(itr_l != itr_r) ++cnt;
            }
            ans.push_back(cnt);
        }
    }

    for(auto cnt:ans) cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 26244
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

int32_t main(){
	IOS;
	string a, b;
	cin >> a >> b;
	bool pos = true;
	for(int i = 0; i < a.size(); i++)
		if( a[i] != b[i] )
			pos = false;

	if( pos )
		cout << "Yes\n";
	else
		cout << "No\n";
	return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
#define reset(a,b) memset(a,b,sizeof a);
#define ALL(x) x.begin(),x.end()
 
template <typename T>
void cetak(T t){cout << t << ')' << endl;}
template <typename T, typename... V>
void cetak(T t, V... v) {cout << t; if (sizeof...(v)) cerr << ", "; cetak(v...);}
 
#define debug(x...) cout<< '(' << #x << ") = ("; cetak(x) 
#define sz(x) (int)(x.size())
#define lt(x) (int)(x.length())

const int MOD = 1e9 + 7;
const int mx = 2e6 + 10;

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

long long fak[mx], inv[mx];

long long C(int n, int k){
    if(k < 0) return 0;
    if(k > n) return 0;
    return fak[n] * inv[n - k] % MOD * inv[k] % MOD;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    fak[0] = inv[0] = 1;
    for(int i = 1; i <= 2e6; i++) fak[i] = fak[i - 1] * i % MOD;
    inv[2000000] = POW(fak[2000000], MOD - 2);
    for(int i = 2e6 - 1; i >= 0; i--) inv[i] = inv[i + 1] * (i + 1) % MOD;
    int x, y;
    cin >> x >> y;
    int total = x + y;
    if(total % 3 > 0){
        cout << 0 << endl;
        return 0;
    }
    total /= 3;
    x -= total;
    y -= total;
    int mini = min(x, y);
    cout << C(total, x) << endl;
}

Measured memory_bytes: 31488
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<30;

typedef long long ll;

int main() {
  ll n;
  while(cin>>n,n) {
    string oct;
    while (n != 0) {
      oct = string(1,'0'+n%8) + oct;
      n /= 8;
    }
    FOR(it, oct) {
      if (*it >= '5')
        (*it)++;
      if (*it >= '4')
        (*it)++;
    }
    cout << oct << endl;
  }
}

Measured memory_bytes: 908
N = int(input())
P = list(map(float, input().split()))

dp = [[0] * (N + 1) for _ in range(N + 1)]
dp[0][0] = 1

for i in range(N):
    for j in range(i + 1):
        dp[i + 1][j] += dp[i][j] * (1 - P[i])
        dp[i + 1][j + 1] += dp[i][j] * P[i]

ans = 0

for i in range(N // 2 + 1, N + 1):
    ans += dp[N][i]

print(ans)


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

  int N,check=0;
  char S;
  
  for(int i=1;i<=100;i++){
	cin >> S;
    if(S=='Y'){
      check = 1;
      break;
    }
  }
  if(check == 1)
    cout << "Four";
  else
    cout << "Three";
}

Measured memory_bytes: 256