akhauriyash/Code-Regression huggingface dataset:
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

int main(void){
	ll n;
	cin >> n;
	Vec a(n);
	rep(i, n) cin >> a[i];

	ll b = 1, ans = 0;
	rep(i, n){
		if(!i){
			ans += a[i]-1;
			continue;
		}
		ll c = (a[i]-1)/(b+1);
		if(a[i] <= b+1) chmax(b, a[i]);
		else ans += c;
	}
	co(ans);

	return 0;
}


Measured memory_bytes: 1024
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val d = sc.nextInt()
    val t = sc.nextInt()
    val s = sc.nextInt()
    println(problem177a(d,t,s))
}

fun problem177a(d: Int, t: Int, s: Int): String {
    return if (d.toDouble() / s <= t) "Yes" else "No"
}

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

using namespace std;

#define intt long long 
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N = 200005;

int n, k;
double a[N], pref[N];

int main() {

	FAST;

	cin >> n >> k;
	for (int i = 1; i <= n; i ++) {
		int x;
		cin >> x;
		a[i] = 1.0 * (x + 1) / 2;
	}
	for (int i = 1; i <= n; i ++) {
		pref[i] = pref[i - 1] + a[i];
	}
	double ans = 0;
	for (int i = k; i <= n; i ++) {
		ans = max(ans, pref[i] - pref[i - k]);
	}
	cout << setprecision(9) << fixed << ans << '\n';
	return 0;
}

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

int main(){
  int N,T;
  cin>>N>>T;
  int c[N],t[N];
  int cost=100000;
  for (int i=0;i<N;i++){
    cin>>c[i]>>t[i];
  }
  for (int i=0;i<N;i++){
    if (t[i]<=T&&c[i]<cost){
      cost=c[i];
    }
  }
  if (cost<=1000){
    cout<<cost;
  }
  else{
    cout<<"TLE";
  }
  return 0;
}


Measured memory_bytes: 256
//https://atcoder.jp/contests/tenka1-2017-beginner/tasks/tenka1_2017_c
//C - 4/N
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
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;}
int main() {
#if LOCAL&01
    std::ifstream in("./test/sample-1.in"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#else
    cin.tie(0);
    ios::sync_with_stdio(false);
#endif
    ll N; cin>>N;    
    FOR(h,1,3501){
        FOR(n,1,3501){
            ll Nhn=N*h*n;
            ll tmp=4*n*h-N*h-N*n;
            if(tmp!=0&&Nhn%tmp==0){
                ll w=Nhn/tmp;
                if (w>0) {
					cout << h << " " << n << " " << w << endl;
					return 0;
                }
            }
        }
    }
    assert(0);
    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    int ans = 1;
    while(ans*2 <= n){
        ans *= 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3552
A, B, C, X, Y = map(int, input().split())
sum1 = A * X + B * Y
sum2 = A * (X - min(X, Y)) + B * (Y - min(X, Y)) + C * 2 * min(X, Y)
sum3 = C * 2 * max(X, Y)
print(min(sum1, sum2, sum3))

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

ll n,mx,arr[500010];

ll f(ll b)
{
    ll sum = 0;
    for(int i=0; i<n; i++) sum = sum+abs(arr[i]-(b+i+1));
    return sum;
}

int main()
{

    scanf("%lld",&n);
    mx = -1;
    for(int i=0; i<n; i++)
    {
        scanf("%lld",&arr[i]);
        mx = max(arr[i],mx);
    }
    ll lo = (-1)*mx;
    ll hi = mx;
    ll mid1,mid2,sm1,sm2;
    while(lo<hi-1)
    {
        mid1=lo+(hi-lo)/3;
        mid2=hi-(hi-lo+2)/3;
        sm1=f(mid1);
        sm2=f(mid2);
        if(sm1<=sm2)
        {
            hi=mid2;
        }
        else if(sm1>sm2)
        {
            lo=mid1+1;
        }
    }
    ll ans=f(lo);
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int c = sc.nextInt();
		int[][] a = new int[c][c];
		int[][] b = new int[n][n];
		for(int i = 0; i < c; i++) {
			for(int j = 0; j < c; j++) {
				a[i][j] = sc.nextInt();
			}
		}
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < n; j++) {
				b[i][j] = sc.nextInt() - 1;
			}
		}
		long[][] sum = new long[3][c];
		for(int i = 0; i < c; i++) {
			for(int j = 0; j < n; j++) {
				for(int k = 0; k < n; k++) {
					// 1つ目のグループをiに変えるのに必要なコスト
					if((j + k) % 3 == 0) {
						if(b[j][k] != i) sum[0][i] += a[b[j][k]][i];
					// 2つ目のグループをiに変えるのに必要なコスト
					} else if((j + k) % 3 == 1) {
						if(b[j][k] != i) sum[1][i] += a[b[j][k]][i];
					// 3つ目のグループをiに変えるのに必要なコスト
					} else {
						if(b[j][k] != i) sum[2][i] += a[b[j][k]][i];
					}
				}
			}
		}
		long ans = Long.MAX_VALUE;
		for(int i = 0; i < c; i++) {
			for(int j = 0; j < c; j++) {
				for(int k = 0; k < c; k++) {
					if(i == j || j == k || k == i) continue;
					long totalCost = sum[0][i] + sum[1][j] + sum[2][k];
					ans = Math.min(ans, totalCost);
 				}
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 90904
// AOJ 1242: Area of Polygons
// 2017.12.6 bal4u@uu

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

#define MIN(a,b) ((a)<=(b)?(a):(b))
#define MAX(a,b) ((a)>=(b)?(a):(b))

typedef struct { int x, y; } PP;
PP p[102];

typedef struct { int l, r; } E;
E e[102];

int cmp(E *a, E *b) { if (a->l - b->l) return a->l - b->l; return a->r - b->r; }

char buf[20], *bp;
int getint()
{
	int n = 0;
	if (*bp == '-') {
		bp++; while (*bp >= '0') n = (n<<3) + (n<<1) + (*bp++ & 0xf);
		bp++;
		return -n;
	}
	while (*bp >= '0') n = (n<<3) + (n<<1) + (*bp++ & 0xf);
	bp++;
	return n;
}

void calc(int i, int y, int *l, int *r)
{
	int d, n, w;

	d = p[i+1].y - p[i].y;
	n = (y - p[i].y)*(p[i+1].x - p[i].x);
	w = p[i].x + n / d;
	if (n % d == 0) *l = w, *r = w;
	else if ((n%d)*d < 0) *l = w-1, *r = w;
	else                  *l = w,   *r = w+1;
}

int main()
{
	int n, m, i, y, ymin, ymax, pre, ans;
	int la, ra, lb, rb;

	while (fgets(bp=buf, 10, stdin) && *bp != '0') {
		n = getint();
		fgets(bp=buf, 20, stdin);
		p[0].x = getint(), p[0].y = getint(), p[n] = p[0];
		ymin = ymax = p[0].y;
		for (i = 1; i < n; i++) {
			fgets(bp=buf, 20, stdin);
			p[i].x = getint(), p[i].y = getint();
			if      (p[i].y < ymin) ymin = p[i].y;
			else if (p[i].y > ymax) ymax = p[i].y;
		}

		ans = 0;
		for (y = ymin; y < ymax; y++) {
			for (m = 0, i = 0; i < n; i++) {
				if ((p[i].y <= y   && p[i+1].y <= y) ||
					(p[i].y >= y+1 && p[i+1].y >= y+1)) continue;
				calc(i, y, &la, &ra), calc(i, y+1, &lb, &rb);
				e[m].l = MIN(la, lb), e[m].r = MAX(ra, rb);
				m++;
			}
			qsort(e, m, sizeof(E), cmp);

			for (pre = -10000, i = 0; i < m; i+=2) {
				ans += e[i+1].r - MAX(e[i].l, pre);
				pre = e[i+1].r;
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

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


int main()
{
    int flag=1;
    string s,t;
    cin>>s>>t;

    if(s.length()==t.length()-1)
    {
        for(int i=0;i<s.length();i++) 
        {
            if(s[i]!=t[i])
            {
                flag=0;
                break;
            }    
        }
        if(flag) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3620
#include<stdio.h>
int main(void){
	int i, n;
	//値を入力
	scanf("%d", &n);
	//3の倍数,3のつく数字を出力
	for(i = 1; i <= n; i++){
		int x = i;
		if(x % 3 == 0){
			printf(" %d", i);
		}else{
			for(x = i; x > 0; x /= 10){
				if(x % 10 == 3){
					printf(" %d", i);
					break;
				}
			}
		}
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 600
import fractions
from functools import reduce

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
  
n, x = map(int, input().split())
l = list(map(int, input().split()))
d = [0]*n
for i in range(n):
  d[i] = abs(l[i]-x)
  
print(gcd_list(d))

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

using namespace std;

using i64 = long long;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;


template <typename T = i64>
bool chmax(T& a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}

template <typename T = i64>
bool chmin(T& a, T b){
    if(a > b){
        a = b;
        return true;
    }
    return false;
}


signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int m, n;
    cin >> m >> n;
    vector<i64> a(n);
    for(auto &x : a){
        cin >> x;
        --x;
    }
    int ans = 0;
    if(m == 2){
        int v = 0;
        for(int i = 0; i < n; ++i){
            if(a[i] % 2 == i % 2)
                ++v;
        }
        cout << min(n - v, v) << endl;
        return 0;
    }
    for(int i = 1; i < n; ++i){
        if(a[i] == a[i - 1]){
            ++ans;
            ++i;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long

signed main(){
	int N;
	cin >> N;
	vector<int> a(3 * N), b(3 * N), c(3 * N);
	for(int i = 0; i < 3 * N; ++i) {
		cin >> a[i];
	}

	priority_queue<int, vector<int>, greater<int>> Q;
	b[0] = a[0];
	Q.push(a[0]);
	for(int i = 1; i < N; ++i) {
		b[i] = b[i-1] + a[i];
		Q.push(a[i]);
	}
	// cout << b[N - 1] << " ";
	for(int i = N; i < 2 * N; ++i) {
		Q.push(a[i]);
		int p = Q.top(); Q.pop();
		b[i] = b[i-1] - p + a[i];
		// cout << b[N - 1] << " ";
	}
	// cout << endl;

	priority_queue<int> R;
	R.push(a[3 * N - 1]);
	c[3 * N - 1] = a[3 * N - 1];
	for(int i = 3 * N - 2; i >= 2 * N; --i) {
		c[i] = c[i+1] + a[i];
		R.push(a[i]);
	}
	// cout << c[2 * N] << " ";
	for(int i = 2 * N - 1; i >= N; --i) {
		R.push(a[i]);
		int p = R.top(); R.pop();
		// cerr << p << "K" << endl;
		c[i] = c[i+1] - p + a[i];
		//cout << b[i] << " ";
	}
	//cout << endl;

	int res = b[N-1] - c[N];
	for(int i = N; i <= 2 * N; ++i) {
		res = max(res, b[i - 1] - c[i]);
	}
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 9588
line = input().rstrip().split(' ')
n = int(line[0])
k = int(line[1])

line = input().rstrip().split(' ')
h = [0] * n
for i in range(n):
    h[i] = int(line[i])

h.sort(reverse=True)
ans = 0
for i in range(k, n):
    ans += h[i]

print(ans)

Measured memory_bytes: 26356
n=int(input())
a=[int(x) for x in input().rstrip().split()]
cnt=0
now=0
for i in range(n):
  while(now<n):
    if a[now]==i+1:
      cnt+=1
      break
    else:
      now+=1

if cnt==0:
  print(-1)
else:
  print(n-cnt)


Measured memory_bytes: 25768
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<queue>
#include<set>
#include<map>
using namespace std;
#define INTMAX 1000000000
#define MOD 1000000007
#define LL long long
#define VI vector<int>
#define VL vector<LL>
#define VVI vector<VI>
#define alf "abcdefghijklmnopqrstuvwxyz"


//segment tree
struct SegTree{
	VL seg;
	int segsize;
	void Revise(int id, LL x){
		seg[id] = x;
		while(id){
			id = (id - 1) / 2;
			seg[id] = max(seg[id * 2 + 1], seg[id * 2 + 2]);
		}
	}
	LL RMaxQ(int l, int r, int nl, int nr, int id){//[i, j)のRMaxQを求める
		if(nl >= r || nr <= l) return 0;//まったくかぶらない
		if(l<=nl&&nr<=r) return seg[id];//完全に入っている
		int mid = (nl + nr) / 2, chi = id * 2 + 1;
		return max(RMaxQ(l, r, nl, mid, chi), RMaxQ(l, r, mid, nr, chi + 1));
	}
	void sizedef(int n){//セグ木の初期化
		segsize = 1;
		while(n > segsize) segsize = (segsize << 1);
		for(int i=0; i< segsize * 2 - 1; i++) seg.push_back(0);
	}
};

int N, h[200002], a[200002];
SegTree Seg;//各高さにおける現状のmax

int main(){
	cin >> N;
	Seg.sizedef(N);
	for(int i=0; i<N; i++) cin >> h[i];
	for(int i=0; i<N; i++) cin >> a[i];
	for(int i=0; i<N; i++){
		h[i]--;
		Seg.Revise(h[i] + Seg.segsize - 1, Seg.RMaxQ(0, h[i], 0, Seg.segsize, 0) + a[i]);
		//高さがh[i]まででできる美しさの最大値をa[i]に加算してセグ木を更新
	}
	cout << Seg.seg[0] << endl;

	return 0;
}


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

struct Edge {
	int to;
	double cost;
};

struct State {
	int pos, bit;
	double sum;
	bool operator < (const State &rhs) const {
		return sum > rhs.sum;
	}
};

int n, m, p, a, b;
double t[8];
vector<vector<Edge>> g;
double dist[30][1 << 8];

void solve()
{
	const double INF = 9999;
	fill_n(*dist, 30 * (1 << 8), INF);
	
	priority_queue<State> pq;
	dist[a][0] = 0.0;
	pq.push({a, 0, 0.0});
	while (pq.size()){
		State c = pq.top(); pq.pop();
		if (dist[c.pos][c.bit] < c.sum) continue;
		for (Edge &e : g[c.pos]){
			for (int i = 0; i < n; i++){
				if (c.bit & (1 << i)) continue;
				double cost = e.cost / t[i];
				if (dist[e.to][c.bit | (1 << i)] > c.sum + cost){
					dist[e.to][c.bit | (1 << i)] = c.sum + cost;
					pq.push({e.to, c.bit | (1 << i), c.sum + cost});
				}
			}
		}
	}
	
	double res = INF;
	for (int i = 0; i < (1 << n); i++){
		res = min(res, dist[b][i]);
	}
	
	if (res == INF) puts("Impossible");
	else printf("%.20f\n", res);
}

int main()
{
	while (cin >> n >> m >> p >> a >> b, n){
		a--; b--;
		g.assign(m, vector<Edge>());
		
		for (int i = 0; i < n; i++){
			cin >> t[i];
		}
		
		for (int i = 0; i < p; i++){
			int x, y;
			double z;
			cin >> x >> y >> z;
			x--; y--;
			g[x].push_back({y, z});
			g[y].push_back({x, z});
		}
		
		solve();
	};
}

Measured memory_bytes: 2772
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
using namespace std;
void read(int &x){
    char ch;bool ok;
    for(ok=0,ch=getchar();!isdigit(ch);ch=getchar())if(ch=='-')ok=1;
    for(x=0;isdigit(ch);x=x*10+ch-'0',ch=getchar());if(ok)x=-x;
}
#define rg register
const int maxn=5e5+10,mod=1e9+7;
int n,m,l[maxn],r[maxn];char a[maxn];
long long ans;
int main(){
    scanf("%s",a+1);n=strlen(a+1);
    for(rg int i=2;i<=n+1;i++){
	if(a[i-1]=='>')l[i]=0;
	else l[i]=l[i-1]+(a[i-1]=='<');
    }
    for(rg int i=n-1;i>=0;i--){
	if(a[i+1]=='<')r[i]=0;
	else r[i]=r[i+1]+(a[i+1]=='>');
    }
    for(rg int i=0;i<=n;i++)ans+=max(l[i+1],r[i]);
    printf("\n%lld\n",ans);
}


Measured memory_bytes: 4608
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 766666, mo = 1e9+7, inv2 =(mo+1)/2;
int n,m,fac[N],ifac[N];
inline void add(int &x, int y){x=x+y<mo?x+y:x+y-mo;}
inline int power(int a, int n) {
	int res=1;
	while (n) {
		if (n&1) res=1LL*res*a%mo;
		a=1LL*a*a%mo; n>>=1;
	}
	return res;
}
int C(int n, int m){
	assert(n<N);
	return m>=0&&m<=n?1LL*fac[n]*ifac[m]%mo*ifac[n-m]%mo:0;
}
void init(int n){
	fac[0]=1;rep(i,1,n)fac[i]=1LL*fac[i-1]*i%mo;
	ifac[n]=power(fac[n],mo-2);per(i,n-1,0)ifac[i]=1LL*ifac[i+1]*(i+1)%mo;
}
int calc(int r){
	int res=0;
	rep(i,0,r)if(1LL*(1+i)*(n-m)<=r){
	//	cerr<<i<<endl;
		int lim=r-(1+i)*(n-m);
		for(int j=0;j<=m&&lim-(i+1)*j>=0;j++)
			res=(res+1LL*C(m,j)*(j&1?mo-1:1)%mo*C(n+lim-(i+1)*j,n))%mo;
		if(i){
		for(int j=0;j<=m&&lim-(i)*j>=0;j++)
			res=((res-1LL*C(m,j)*(j&1?mo-1:1)%mo*C(n+lim-(i)*j,n))%mo+mo)%mo;
		}
	}
	return ((C(r+n,n)-1LL*C(n,m)*res)%mo+mo)%mo;
}
int main() {
	init(N-1);read(n);read(m);m=n-m;int l,r;read(l);read(r);
//	cerr<<(calc(r))<<' '<<(calc(l-1)+mo)%mo<<endl;
	cout<<(calc(r)-calc(l-1)+mo)%mo;
	return 0;
}


Measured memory_bytes: 6272
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int result = 0;

			int n = scanner.nextInt();
			int d = scanner.nextInt();
			int x = scanner.nextInt();

			for (int i = 0; i < n; i++) {
				int a = scanner.nextInt();
				for (int j = 1; j <= d; j += a) {
					result++;
				}
			}
			result += x;

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


Measured memory_bytes: 21716
n = int(input())
d = {}
for i in range(n) :
    s = input()
    if s not in d :
        d[s] = 1
    else :
        d[s] += 1
m = max(d.values())
ans = []
for i in d :
    if d[i] == m :
        ans.append(i)
ans.sort()
for i in ans:
    print(i)

Measured memory_bytes: 32096
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>
#include <chrono>
#include <stack>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << " ";
    return a;
}

template <typename T1, typename T2> inline void chkmin(T1 &x, const T2 &y) {if (x > y) x = y;}
template <typename T1, typename T2> inline void chkmax(T1 &x, const T2 &y) {if (x < y) x = y;}


#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
    const int INF = 1e18;
    // const int mod = 2600000069;
    // const int p = 10;
    // const ld PI = 3.1415926535;
#else
    #define dbg(x)
    const int INF = 1e18;
    // const int mod = 2600000069;
    // const int p = 179;
    // const ld PI = 3.1415926535;
#endif

// #pragma GCC optimize("Ofast,no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,sse3,sse4")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC optimize("fast-math")
// #pragma GCC target("avx2")
// #pragma GCC optimize("section-anchors")
// #pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
// #pragma GCC optimize("vpt")
// #pragma GCC optimize("rename-registers")
// #pragma GCC optimize("move-loop-invariants")
// #pragma GCC optimize("unswitch-loops")
// #pragma GCC optimize("function-sections")
// #pragma GCC optimize("data-sections")

mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int sum = 0;
    if (k < a) {
        sum += k;
        k = 0;
    } else {
        sum += a;
        k -= a;
    }
    if (k < b) {
        k = 0;
    } else {
        k -= b;
    }
    sum += -k;
    cout << sum;
}
/*

*/  

Measured memory_bytes: 3616
package main

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

func main() {
	sc := NewScanner()
	A, B := sc.NextInt(), sc.NextInt()
	fmt.Println((A-1)*(B-1))
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    rep(i, n)
    {
        if (a[i] % 2 == 0 && a[i] % 3 != 0 && a[i] % 5 != 0)
        {
            cout << "DENIED" << endl;
            return 0;
        }
    }
    cout << "APPROVED" << endl;

    return 0;
}

Measured memory_bytes: 256
"""
                            pppppppppppppppppppp
                         ppppp  ppppppppppppppppppp
                      ppppppp    ppppppppppppppppppppp
                      pppppppp  pppppppppppppppppppppp
                      pppppppppppppppppppppppppppppppp
                              pppppppppppppppppppppppp
       ppppppppppppppppppppppppppppppppppppppppppppppp  pppppppppppppppppppp
      pppppppppppppppppppppppppppppppppppppppppppppppp  ppppppppppppppppppppp
     ppppppppppppppppppppppppppppppppppppppppppppppppp  pppppppppppppppppppppp
    ppppppppppppppppppppppppppppppppppppppppppppppp    pppppppppppppppppppppppp
   pppppppppppppppppppppppppppppppppppppppppppppp     pppppppppppppppppppppppppp
  ppppppppppppppppppppppppppppppppppppppppppppp      pppppppppppppppppppppppppppp
  pppppppppppppppppppppppppppppppp               pppppppppppppppppppppppppppppppp
  pppppppppppppppppppppppppppp     pppppppppppppppppppppppppppppppppppppppppppppp
  ppppppppppppppppppppppppppp    pppppppppppppppppppppppppppppppppppppppppppppppp
    pppppppppppppppppppppppp  pppppppppppppppppppppppppppppppppppppppppppppppppp
     ppppppppppppppppppppppp  ppppppppppppppppppppppppppppppppppppppppppppppppp
      pppppppppppppppppppppp  ppppppppppppppppppppppppppppppppppppppppppppppp
       ppppppppppppppppppppp  ppppppppppppppppppppppppppppppppppppppppppppp
                              pppppppppppppppppppppppp
                              pppppppppppppppppppppppppppppppp
                              pppppppppppppppppppppp  pppppppp
                              ppppppppppppppppppppp    ppppppp
                                 ppppppppppppppppppp  ppppp
                                    pppppppppppppppppppp
"""


import sys
from functools import lru_cache, cmp_to_key
from collections import defaultdict as dd, deque, Counter as C
from bisect import bisect_left as bl, bisect_right as br, bisect
from heapq import heapify, heappop, heappush
from math import ceil, log, floor, sqrt
mod = pow(10, 9) + 7
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(var, end="\n"): sys.stdout.write(str(var)+end)
def outa(*var, end="\n"): sys.stdout.write(' '.join(map(str, var)) + end)
def L(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]


answer = 0
s = data()
cnt = 0
for i in s:
    if i == "S":
        answer = max(answer, cnt)
        cnt = 0
    else:
        cnt += 1
out(max(answer, cnt))


Measured memory_bytes: 68124
n=int(input())
da=[[0 for i in range(n)] for i in range(n)]
for i in range(n):
    se=list(map(int,input().split()))
    for j in se[2:]:
        da[i][j-1]=1
for i in range(n):
    for j in range(n):
        if j==n-1:
            print(da[i][j])
        else:
            print(da[i][j],end=' ')
            


Measured memory_bytes: 6384
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    ll a, b, h;
    cin >> a >> b >> h;

    cout << (a + b) * h / 2 << endl;

    return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define repp(i, n) rep(i, n)
#define reppp(i, n) repp(i, n)
#define rrepp(i, n) rrep(i, n)
#define repss(i, n) reps(i, n)
#define repcc(i, n) repc(i, n)
#define repii(i, a, b) repi(i, a, b)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  f80 w;
  while (cin >> w) {
    if (w <= 48.0) cout << "light fly" << '\n';
    else if (w <= 51.0) cout << "fly" << '\n';
    else if (w <= 54.0) cout << "bantam" << '\n';
    else if (w <= 57.0) cout << "feather" << '\n';
    else if (w <= 60.0) cout << "light" << '\n';
    else if (w <= 64.0) cout << "light welter" << '\n';
    else if (w <= 69.0) cout << "welter" << '\n';
    else if (w <= 75.0) cout << "light middle" << '\n';
    else if (w <= 81.0) cout << "middle" << '\n';
    else if (w <= 91.0) cout << "light heavy" << '\n';
    else cout << "heavy" << '\n';
  }
}



Measured memory_bytes: 3108
#include <stdio.h>
#include <string>
#include <iostream>
#include <math.h>

using namespace std;
double T_area(double x1,double y1, double x2, double y2, double x3, double y3);

int main(){
    double x[3]={0};
    double y[3]={0};
    while(scanf("%lf",&x[0])!=EOF){
        scanf("%lf",&y[0]);
        scanf("%lf",&x[1]);
        scanf("%lf",&y[1]);
        scanf("%lf",&x[2]);
        scanf("%lf",&y[2]);
        
        double xp,yp;
        scanf("%lf",&xp);
        scanf("%lf",&yp);

        double S =T_area(x[0],y[0],x[1],y[1],x[2],y[2]);
        double S1, S2, S3;
        S1 =T_area(xp,yp,x[1],y[1],x[2],y[2]);
        S2 =T_area(x[0],y[0],xp,yp,x[2],y[2]);
        S3 =T_area(x[0],y[0],x[1],y[1],xp,yp);
        
        if(S1+S2+S3==S){
            printf("YES\n");
        }else{
            printf("NO\n");
        }
        
    }
    
    
}

double T_area(double x1,double y1, double x2, double y2, double x3, double y3){
    double S =fabs(x1*y2+x2*y3+x3*y1-y1*x2-y2*x3-y3*x1)/2;
    return S;
}

Measured memory_bytes: 1196
#include <iostream>
#define int long long
using namespace std;

int max3(int a, int b, int c) {
  if (a > b) {
    if (a < c) return c;
    else return a;
  } else {
    if (b < c) return c;
    else return b;
  }
}

int min3(int a, int b, int c) {
  if (a < b) {
    if (a < c) return a;
    else return c;
  } else {
    if (b < c) return b;
    else return c;
  }
}

signed main() {
  int H, W;
  cin >> H >> W;
  
  int ans = 100000000000;
  
  for (int i = 1; i < W; ++i) {
    int j = i / 2;
    int S_max = max3(j * H, (i - j) * H, (W - j) * H);
    int S_min = min3(j * H, (i - j) * H, (W - j) * H);
    if (S_max - S_min < ans) ans = S_max - S_min;
    
    j = i + (W - i) / 2;
    S_max = max3(i * H, (j - i) * H, (W - j) * H);
    S_min = min3(i * H, (j - i) * H, (W - j) * H);
    if (S_max - S_min < ans) ans = S_max - S_min;
    
    j = H / 2;
    S_max = max3(i * j, i * (H - j), H * (W - i));
    S_min = min3(i * j, i * (H - j), H * (W - i));
    if (S_max - S_min < ans) ans = S_max - S_min;
    
    S_max = max3(i * H, (W - i) * j, (W - i) * (H - j));
    S_min = min3(i * H, (W - i) * j, (W - i) * (H - j));
    if (S_max - S_min < ans) ans = S_max - S_min;
  }
  
  for (int i = 1; i < H; ++i) {
    int j = i / 2;
    int S_max = max3(j * W, (i - j) * W, (H - i) * W);
    int S_min = min3(j * W, (i - j) * W, (H - i) * W);
    if (S_max - S_min < ans) ans = S_max - S_min;
    
    j = i + (H - i) / 2;
    S_max = max3(i * W, (j - i) * W, (H - j) * W);
    S_min = min3(i * W, (j - i) * W, (H - j) * W);
    if (S_max - S_min < ans) ans = S_max - S_min;
    
    j = W / 2;
    S_max = max3(i * j, i * (W - j), (H - i) * W);
    S_min = min3(i * j, i * (W - j), (H - i) * W);
    if (S_max - S_min < ans) ans = S_max - S_min;
    
    S_max = max3(i * W, (H - i) * j, (H - i) * (W - j));
    S_min = min3(i * W, (H - i) * j, (H - i) * (W - j));
    if (S_max - S_min < ans) ans = S_max - S_min;
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
N, K = map(int, readline().split())
MOD = 10**9+7
table = [0]*(K+1)

for g in range(K, 0, -1):
    res = pow(K//g, N, MOD)
    for j in range(2*g, K+1, g):
        res = (res - table[j])%MOD
    table[g] = res
ans = 0
for g in range(1, K+1):
    ans = (ans + g*table[g])%MOD
print(ans)

Measured memory_bytes: 69080
#include <algorithm>
#include <complex>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

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

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::priority_queue;

using std::min;
using std::max;
using std::sort;
using std::abs;

int main(void) {
    int a, b;
    cin >> a >> b;

    if(a + b >= 10){
        cout << "error" << endl;
    }else{
        cout << (a + b) << endl;
    }

    return 0;
}


Measured memory_bytes: 256
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
ans = "War"

for i in range(X + 1, Y + 1):
    if i <= min(y) and i > max(x):
        ans = "No War"
        break

print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#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 INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define PI 3.141592653589793
using namespace std;
typedef long long ll;
using P = pair<int,int>;
  
int main()
{
  int A, B, H, M;
  cin >> A >> B >> H >> M;

  double deg = min(360.0-abs(6.0*M-(60.0*H+M)/2),abs(6.0*M-(60.0*H+M)/2));
  double radian = deg * PI / 180.0;
  cout << fixed << setprecision(20) << sqrt(A*A+B*B-2*A*B*cos(radian)) << endl;
}

Measured memory_bytes: 4192
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n;
    cin>>n;
    string s;
    if(n==0)
        s="0";
    while(n!=0){
        int cur=n%(-2);
        n/=(-2);
        if(cur<0){
            cur=abs(cur);
            n++;
        }
        s+=cur+48;
    }
    reverse(all(s));
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG



signed main() {
  int N; cin >> N;
  vector<int> d(N), dd(N);
  rep(i, N) cin >> d[i] >> dd[i];
  
  int k = 0;
  rep(i, N) {
    if(d[i] == dd[i]) k++;
    else k = 0;
    if(k >= 3) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  
  cout << "No" << endl;
  

}


Measured memory_bytes: 3632
//...Bismillahir Rahmanir Rahim...
// Code by    Asad Bin Saber

#include <bits/stdc++.h>

using namespace std;

// typedefs...
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;

// constants...
const double PI = acos(-1);

// defines...
#define MP make_pair
#define PB push_back
#define fi first
#define se second
#define si(a) scanf("%d", &a)
#define sii(a, b) scanf("%d%d", &a, &b)
#define siii(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define sl(a) scanf("%lld", &a)
#define sll(a, b) scanf("%lld%lld", &a, &b)
#define slll(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)

int gcd(int a, int b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}
ll lcm(ll a, ll b)
{
    return (a/gcd(a, b)*b);
}
ll comb(ll a, ll b)
{
    ll x = max(a-b, b), ans=1;

    for(ll K=a, L=1; K>=x+1; K--, L++){
        ans *= K;
        ans /= L;
    }

    return ans;
}


void task()
{
    //code here...
    
    ll n, q, a, b, sum=0;
    
    cin >> n;
    ll ara[n];
    vl mark(100001);
    for(int K=0; K<n; K++){ cin >> ara[K]; sum += ara[K]; mark[ara[K]]++;}
    
    cin >> q;
    while(q--){
		cin >> a >> b;
		mark[b] += mark[a];
		
		sum = sum - mark[a]*a + mark[a]*b;
		
		mark[a] = 0;
		
		cout << sum << "\n";
	}
}

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

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    task();

    return 0;
}




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

using namespace std;

int n,i,p[100005];

int main(){
	scanf("%d", &n);
	for(i = 1; i <= n; i++)
	scanf("%d", &p[i]);
	
	int res = 0;
	
	for(i = 1; i <= n; i++){
		if(p[p[i]] == i)
		res++;
	}
	
	printf("%d\n", res / 2);
}


Measured memory_bytes: 640
/*{{{*/
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB emplace_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int K,A,B;
    R(K,A,B);
    int v=K;
    while(v<A){
        v+=K;
    }
    W(v<=B?"OK":"NG");
    return 0;
}


Measured memory_bytes: 3724
#include <iostream>
#include <vector>
#include <cstring>

constexpr int MAX_N = 30;
constexpr int MAX_R = 1000;
constexpr int INF   = (1 << 29);

template<class T>
using vec = std::vector<T>;

void update(int &l, int r)
{
    if (l < r) l = r;
}

int main()
{
    int N, M, R;
    std::cin >> N >> M >> R;
    vec<int> ball(N);
    for (int i = 0; i < N; i++) {
        std::cin >> ball[i];
    }
    int d[MAX_N][MAX_N];
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            d[i][j] = (i != j) * INF;
        }
    }
    
    int a, b, c;
    for (int i = 0; i < M; i++) {
        std::cin >> a >> b >> c; a--; b--;
        d[a][b] = d[b][a] = c;
    }

    for (int k = 0; k < N; k++) {
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                d[i][j] = std::min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
    
    int res = 0;
    vec<vec<vec<int>>> dp(MAX_R + 1, vec<vec<int>>(MAX_N, vec<int>(MAX_N, -1)));
    dp[0][0][0] = 0;    
    
    for (int i = 0; i <= R; i++) {
        for (int prev = 0; prev < N; prev++) {
            for (int curr = 0; curr < N; curr++) { 
                if (dp[i][curr][prev] == -1 || i + d[curr][N - 1] > R) {
                    continue;
                }
                
                if (i + 15 <= R) {
                    update(dp[i + 15][curr][curr], dp[i][curr][prev] + ball[curr]);
                }
                
                if (curr == N - 1) {
                    update(res, dp[i][curr][prev]);
                }
                
                for (int next = 0; next < N; next++) {
                    if (curr == next) continue;
                    if (prev == next) {
                        if (2 * d[prev][curr] >= 15) {
                            int ni = i + d[prev][curr];
                            if (ni <= R) {
                                update(dp[ni][next][prev],
                                       dp[i][curr][prev] + ball[next]);
                            } 
                        } else {
                            int ni = i + (15 - d[prev][curr]);
                            if (ni <= R) {
                                update(dp[ni][next][prev],
                                       dp[i][curr][prev] + ball[next]);
                            } 
                        }
                    } else {
                        int ni = i + d[curr][next];                        
                        if (ni <= R) {
                            update(dp[ni][next][curr],
                                   dp[i][curr][prev] + ball[next]);
                        }
                    }
                }
            }
        }
    }
    
    std::cout << res << std::endl;
    return 0;
}

Measured memory_bytes: 7640
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b)     for(int i=a;i>=b;--i)
#define init(a, x) memset(a,x,sizeof(a))
#define ld long double
#define dd double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
typedef vector<pll> vplll;
ll mod = 1e9+7;
const ld PI = 2 * acos(0.0);
const vector<ll> dx = {1, -1, 0, 0};
const vector<ll> dy = {0, 0, 1, -1};
#define round(x, y) ((x + y - 1) / y)
#define ce(x, y) ((x + y - 1) / y)
#define amax(x, y) \
    if (y > x)     \
        x = y;
#define amin(x, y) \
    if (y < x)     \
        x = y;
#define lcm(x, y) ((x) * (y) / __gcd(x, y))
#define len(x) (ll) x.length()
#define sq(x) ((x) * (x))
#define cb(x) ((x) * (x) * (x))

ll fact[3001];
ll modi[3001];

ll power(ll x, ll a)
{
    ll sum=1;
    while(a>0)
    {
        if(a&1==1)
        {
            sum=x*sum;
            sum%=mod;
        }
        a>>=1;
        x=x*x;
        x%=mod;
    }
    return sum;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c,t,n,m,k,q; 
    t = 1;
    // cin>>t;
    fact[0] = 1;
    for(int i=1;i<=3000;i++)
    {
    	fact[i] = (i*fact[i-1])%mod;
    }
    for(int i=0;i<=3000;i++)
    {
    	modi[i] = power(fact[i], mod-2);
    }
    while(t--)
    {
    	cin>>n;
    	int l = n/3;
    	ll ans = 0;
    	for(int i=1;i<=l;i++)
    	{
    		// ans += calc(i, n);
    		m = n - 3*i;
    		ll ans1 = fact[m+i-1];
    		ans1 *= modi[i-1];
    		ans1 %= mod;
    		ans1 *= modi[m];
    		ans1 %= mod;
    		ans += ans1;
    		ans %= mod;
    	}
    	cout<<ans<<endl;
    }
    return 0;
}

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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

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

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

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

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

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}

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

int main(){
    bool flag=false;
    ll ans=1,sum=0;

    ll h;
    cin >>h;

    int cnt=0;
    while (h > 0){
        h >>= 1;
        cnt++;
        //db2(cnt,h);ln;
    }

    ans = (1LL<<(cnt)) - 1LL;

    //cout <<fixed<<setprecision(16)<< << endl;
    cout<<ans<<endl;
    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
typedef long long ll;
const int N=2e5+10;
int n,h[N],a[N];ll dp[N],t[N],ans;
inline int lowbit(int x){return x&-x;}
inline void update(int x,ll v){for(register int i=x;i<=n;i+=lowbit(i))t[i]=max(t[i],v);}
inline ll query(int x){ll sum=0;for(register int i=x;i;i-=lowbit(i))sum=max(sum,t[i]);return sum;}
int main(){
	scanf("%d",&n);
	for(register int i=1;i<=n;i++)scanf("%d",&h[i]);
	for(register int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(register int i=1;i<=n;i++)
		dp[i]=query(h[i]-1)+a[i],update(h[i],dp[i]),ans=max(ans,dp[i]);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4992