akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const long double inf64=1.01e8;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

typedef complex<long double> point;

void solve(){
    int N;
    cin >> N;

    vector<point> ps(N);
    rep(i,0,N){
        long double x,y;
        cin >> x >> y;
        ps[i]=point(x,y);
    }

    vector<long double> ans(N);
    int loop=200000;
    long double r=1e12,pi=acosl(-1);
    rep(i,0,loop){
        long double theta=2*pi*i/loop;
        auto p=polar(r,theta);
        int idx=-1;
        long double mi=1e130;
        rep(j,0,N){
            if(norm(ps[j]-p)<mi){
                mi=norm(ps[j]-p);
                idx=j;
            }
        }
        assert(idx!=-1);
        ans[idx]+=1;
    }

    rep(i,0,N) cout << ans[i]/loop << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<math.h>
using namespace std;
int h, w, taikaku;
bool f;
int sol();
int sol2();
int main()
{
	while (1) {
		f = false;
		cin >> h >> w;
		taikaku = h * h + w * w;
		if (h == 0 && w == 0)return 0;
		sol();
		while (!f) {
			taikaku++;
			sol2();
		}
	}
}
int sol() {
	for (int i = h + 1; i < sqrt(taikaku); i++) {
		for (int j = i+1; j < sqrt(taikaku); j++) {
			if (i * i + j * j == taikaku) {
				cout << i << " " << j << endl;
				f = true;
				return 0;
			}
		}
	}
    return 0;
}
int sol2() {
	for (int i = 1; i < sqrt(taikaku); i++) {
		for (int j = i+1; j < sqrt(taikaku); j++) {
			if (i * i + j * j == taikaku) {
				cout << i << " " << j << endl;
				f = true;
				return 0;
			}
		}
	}
	return 0;
}



Measured memory_bytes: 3068
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<int(n);i++)
#define FOR(i,n,m) for(int i=n;i<int(m);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
using namespace std;

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

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

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

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int N_MAX=100010;

int main(){
	int n;
	cin>>n;
	vector<int>a(n);
	REP(i,n)cin>>a[i];
	vector<ll>sum(n);
	sum[0]=a[0];
	for(int i=1;i<n;i++)sum[i]=sum[i-1]+a[i];

	ll ans=LONG_MAX;
	for(int j=1;j<n-1;j++){
		int i,k;
		i=lower_bound(sum.begin(),sum.begin()+j-1,sum[j]/2)-sum.begin();
		k=lower_bound(sum.begin()+j+1,sum.end(),sum[j]+(sum[n-1]-sum[j])/2)-sum.begin();

		//cout<<i<<" "<<j<<" "<<k<<endl;

		for(int ii=i-1;ii<=i+1;ii++){
			for(int kk=k-1;kk<=k+1;kk++){
				if(ii<0 || ii>=j || kk<0 || kk>=n)continue;

				ll mx=LONG_MIN;
				ll mn=LONG_MAX;
				mx=max(mx,sum[ii]);
				mx=max(mx,sum[j]-sum[ii]);
				mx=max(mx,sum[kk]-sum[j]);
				mx=max(mx,sum[n-1]-sum[kk]);
				mn=min(mn,sum[ii]);
				mn=min(mn,sum[j]-sum[ii]);
				mn=min(mn,sum[kk]-sum[j]);
				mn=min(mn,sum[n-1]-sum[kk]);
				ans=min(ans,mx-mn);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 2560
//==========================Head files==========================
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<set>
#include<iostream>
#include<map>
#define LL long long
#define db double
#define mp make_pair
#define pr pair<int, int>
#define fir first
#define sec second
#define pb push_back
#define ms(i, j) memset(i, j, sizeof i)
using namespace std;
//==========================Templates==========================
inline int read() {
    int x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
inline LL readl() {
    LL x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
int power(int a, int b) {
	int ans = 1;
	while (b) {
		if(b & 1) ans = ans * a;
		b >>= 1; a = a * a;
	}
	return ans;
}
int power_mod(int a, int b, int mod) {
	a %= mod;
	int ans = 1;
	while (b) {
		if(b & 1) ans = (ans * a) % mod;
		b >>= 1, a = (a * a) % mod;
	}
	return ans;
}
LL powerl(LL a, LL b) {
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = ans * a;
		b >>= 1ll;a = a * a;
	}
	return ans;
}
LL power_modl(LL a, LL b, LL mod) {
	a %= mod;
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = (ans * a) % mod;
		b >>= 1ll, a = (a * a) % mod;
	}
	return ans;
}
LL gcdl(LL a, LL b) {return b == 0 ? a : gcdl(b, a % b);}
LL abssl(LL a) {return a > 0 ? a : -a;}
int gcd(int a, int b) {return b == 0 ? a : gcd(b, a % b);}
int abss(int a) {return a > 0 ? a : -a;}
//==========================Main body==========================
#define LD "%I64d"
#define D "%d"
#define pt printf
#define sn scanf
#define pty printf("YES\n")
#define ptn printf("NO\n")
//==========================Code here==========================
LL n, a[200000 + 5], b[200000 + 5], ans;
int main() {
	cin >> n;
	for (LL i = 1; i <= n; ++i) scanf("%lld", &a[i]);
	for (LL i = n; i; --i) {
		LL now = 0;
		for (LL j = i; j <= n; j += i) now ^= b[j];
		if (now ^ a[i]) b[i] = 1;
		if (b[i]) ++ans;
	}
	cout << ans << endl;
	for (LL i = 1; i <= n; ++i) if (b[i]) printf("%lld ", i);
	return 0;
}

Measured memory_bytes: 3968
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		long[] w, v;
		long W;
		int n;
		Map<Long, Long> memo = new HashMap<>();
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			n = in.nextInt();
			W = in.nextLong();
			w = new long[n];
			v = new long[n];
			for (int i = 0; i < n; i++) {
				w[i] = in.nextLong();
				v[i] = in.nextLong();
			}

			long ans = func(0, 0);
			out.println(ans);
		}

		long func(int d, long now) {

			long key = (long)d<<32 | now;

			if (memo.containsKey(key)) {
				return memo.get(key);
			}

			if (d == n) {
				return 0;
			}

			long ret = 0;
			if (now + w[d] <= W) {
				ret += Math.max(func(d+1, now+w[d]) + v[d], func(d+1, now));
			} else {
				ret += func(d+1, now);
			}
			memo.put(key, ret);
			return ret;
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


Measured memory_bytes: 56660
#include <iostream>
using namespace std;
int main(){
  char a,b,c;
  cin>>a>>b>>c;
  if(a==b&&b==c){
    cout<<"Yes"<<endl;
    return 0;
  }
  cin>>a;
  if(a==b&&b==c){
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {


//	final int MOD = 1000000007;

//	public static int min = 3000000;

	public static void main(String[] args) {

		int ans = 0;
		Scanner sc = new Scanner(System.in);
		boolean f = false;

//		long k = sc.nextLong();
		int h1 = sc.nextInt();
		int m1 = sc.nextInt();
		int h2 = sc.nextInt();
		int m2 = sc.nextInt();
		int k = sc.nextInt();

//		String s = sc.next();

//		int[] ans = new int[n];

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

		while(!f) {
			if(h1 == h2 && m1 == m2) {
				f = true;
			}

			m1++;
			ans++;
			if(m1 >= 60) {
				h1++;
				m1 = 0;
			}
			if(h1 >= 24) {
				h1 = 0;
			}
		}

		ans -= (k + 1);

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

//		if(f) {
//			System.out.println("Yes");
//		} else {
//			System.out.println("No");
//		}

		System.out.println(ans);

		sc.close();
	}



}

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

using namespace std;

const int N = 105;
const long long inf = 8e18;

inline long long mul(long long x, long long y) {
  if (inf / x < y) return inf;
  else return x * y;
}

vector<int> g[N];

int dist[N];
int mx[N];
int n;

pair<int, long long> Solve(const vector<int> &a) {
  memset(dist, -1, sizeof dist);
  memset(mx, 0, sizeof mx);
  queue<int> que;
  for (int x : a) {
    dist[x] = 0;
    que.push(x);
    mx[0] = max(mx[0], (int) g[x].size() - (a.size() == 2));
  }
  int dep = 0;
  while (!que.empty()) {
    int v = que.front();
    que.pop();
    for (int to : g[v]) {
      if (dist[to] == -1) {
        dist[to] = dist[v] + 1;
        dep = max(dep, dist[to]);
        mx[dist[to]] = max(mx[dist[to]], (int) g[to].size() - 1);
        que.push(to);
      }
    }
  }
  long long res = (int) a.size();
  for (int i = 0; i < dep; i++) {
    res = mul(res, mx[i]);
  }
  return {dep, res};
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    --x; --y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  pair<int, long long> best = {n, inf};
  for (int i = 0; i < n; i++) {
    best = min(best, Solve({i}));
//    cerr << i << ' ' << best.first << ' ' << best.second << endl;
    for (int j : g[i]) {
      best = min(best, Solve({i, j}));
//      cerr << i << ' ' << j << ' ' << best.first << ' ' << best.second << endl;
    }
  }
  cout << best.first + 1 << ' ' << best.second << '\n';
  return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vs = vector<string>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  yn(a)    cout << ( (a)?"Yes\n":"No\n" );
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
const ll INF = 1e9+9, LINF = 1e18;


int main()
{
    ll a[3][3],x;
    rep(i,3)rep(j,3)cin>>a[i][j];

    x=a[0][0]-a[0][1];
    rep(i,3)if(x!=a[i][0]-a[i][1])cout<<"No\n",exit(0);
    x=a[0][1]-a[0][2];
    rep(i,3)if(x!=a[i][1]-a[i][2])cout<<"No\n",exit(0);
    x=a[0][0]-a[1][0];
    rep(i,3)if(x!=a[0][i]-a[1][i])cout<<"No\n",exit(0);
    x=a[1][0]-a[2][0];
    rep(i,3)if(x!=a[1][i]-a[2][i])cout<<"No\n",exit(0);


    cout<<"Yes\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lp(i,n) for(int i=0;i<n;i++)
#define rp(i,a,b) for(int i=a;i<b;i++)
using namespace std;
int main(){
	string S,ans;
	int w;
	cin>>S>>w;
	lp(i,S.size()){
		if(i%w==0){
			ans+=S[i];
		}
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
import itertools

w, h, n = map(int, input().split())
x = [None] * n
y = [None] * n
a = [None] * n
for i in range(n):
    x[i], y[i], a[i] = map(int, input().split())


area = [[False] * h for _ in range(w)]
for i in range(n):
    for p, q in itertools.product(range(w), range(h)):
        if a[i] == 1 and p < x[i]:  area[p][q] = True
        if a[i] == 2 and p >= x[i]: area[p][q] = True
        if a[i] == 3 and q < y[i]:  area[p][q] = True
        if a[i] == 4 and q >= y[i]: area[p][q] = True

print(sum(sum(1 for v in row if not v) for row in area))

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

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1e9+7;

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

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

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////
/*⁽⁽(ી₍₍⁽⁽(ી( ˆεˆ )ʃ)₎₎⁾⁾ʃ)₎₎*/
int main(){
	int m,n;
	while(true){
		cin >> m >> n;
		if ((m == 0) and (n == 0)) break;
		vector<bool> V(8000000);
		int S = m;
		REP(i,n){
			int T = S;
			while(T <= 7400000){
				V[T] = true;
				T += S;
			}

			while(true){
				if (V[S] == false) break;
				S++;
			}
		}

		FORq(i,m,7400000){
			if (V[i] == false){
				cout << i << endl;
				break;
			}
		}

	}
    return 0;
}



Measured memory_bytes: 4080
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	const int A = 10000;
	const int B =  5000;
	const int C =  1000;
	int z;
	int ans_x = -1;
	int ans_y = -1;
	int ans_z = -1;

	int N;
	int Y;
	
	cin >> N >> Y;

	// ちょうどYになる組み合わせを検索
	for (int i = 0; i <= N; i++) {
		
		for (int j= 0; j <= N - i; j++) {

			z = N - i - j;

			if (A * i + B * j + C * z == Y) {
				
				ans_x = i;
				ans_y = j;
				ans_z = z;

			}
		}
	}

	cout << ans_x << " " << ans_y << " " << ans_z << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main { 
	public static void main(String[] args) {
 		Scanner sc = new Scanner(System.in);
		int length = Integer.parseInt(sc.next());
        int target = Integer.parseInt(sc.next())-1;
      
      	List<String> list = new ArrayList<>();
		String s = sc.next();
      for (int x = 1; x <= length; x++) {
		list.add(s.substring(x-1,x));
      }

      String a = list.get(target);
      if(a.equals("A")) {
		list.set(target, "a");
      }else if(a.equals("B")) {
        list.set(target, "b");
      } else {
        list.set(target, "c");
      }
      
      String res = null;
      StringBuilder sb = new StringBuilder();
      for (String x:list) {
        sb.append(x);
      }
      System.out.println(sb.toString());
    }
}
      	

Measured memory_bytes: 21716
#include<stdio.h>

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

    int s[n];
    int flag[n];
    for (int i=0;i<n;i++){
        flag[i]=0;
    }

    for (int i=0;i<k;i++){
        scanf("%d",&d);
        for (int j=0;j<d;j++){
            scanf("%d",&s[j]);
            flag[s[j]-1]=1;
        }
    }

    int ans=0;

    for (int i=0;i<n;i++){
        // printf("flag[%d]=%d\n",i,flag[i]);
        if (flag[i]==0)
            ans=ans+1;
    }

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

    return 0;
}

Measured memory_bytes: 1732
#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>;
const int INF=1e9;

int main() {
  int h,w,n;
  cin >> h >> w >> n;
  vector<int> hs(h),ws(w);
  set<P> se;
  rep(i,n) {
    int p,q;
    cin >> p >> q;
    --p, --q;
    hs[p]++;
    ws[q]++;
    se.emplace(p,q);
  }
  int mh=0, mw=0;
  rep(i,h) mh = max(mh, hs[i]);
  rep(j,w) mw = max(mw, ws[j]);
  vector<int> is,js;
  rep(i,h) if(hs[i]==mh) is.push_back(i);
  rep(j,w) if(ws[j]==mw) js.push_back(j);
  int ans = mh + mw;
  for (int i : is) for (int j : js) {
    if (se.count(P(i,j))) continue;
    cout << ans << endl;
    return 0;
  }
  cout << ans-1 << endl;
  return 0;
}

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

const int N = 3001;
int dp[N][N];
int arr[N];

int32_t main(){

	int n ;
	cin >> n ; 
	for(int i=0;i<n;i++) cin >> arr[i] ; 

	for(int l=n-1;l>=0;l--){
		for(int r=l;r<n;r++){
			if( l == r ){
				dp[l][r] = arr[l];
			}else {
				dp[l][r] = max(arr[l] - dp[l+1][r],arr[r] - dp[l][r-1]);
			}
		}
	}

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


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

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

int main(int argc, char **argv)
{
	ll N, K;
	cin >> N >> K;

	ll res{0};

	for (ll b = K+1; b <= N; ++b)
	{
		ll times = N / b;
		res += times * (b-K);

		ll rem = N % b;
		res += max(rem - K + 1, 0ll);
	}

	if (K == 0)
		res -= N;

	std::cout << res << std::endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        String n = input.nextLine();
        String s;
        String total = "";
        int i = Integer.parseInt(n);
        s = input.nextLine();
        String[] arr = s.split(" ");
        String a1 = arr[0];
        String a2 = arr[1];
        for (int j = 0 ; j < i;j++){
            String s1 = Character.toString(a1.charAt(j));
            String s2 = Character.toString(a2.charAt(j));
            total += s1.concat(s2);
        }
        System.out.println(total);
    }
}


Measured memory_bytes: 23124
#include <iostream>

using namespace std;

int main() {
    int a, b, c, d, result;
    cin >> a >> b >> c >> d;

    if (a < c) {
        if (min(b, d) >= c) {
            result = min(b, d) - c;
        } else {
            result = 0;
        }

    } else if (a > c) {
        if (min(b, d) >= a) {
            result = min(b, d) - a;
        } else {
            result = 0;
        }

    } else {
        result = min(b, d) - a;
    }
    cout << result << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    string S; cin >> S;
    if(S.size()==1){
        cout << 1 << endl;
        return 0;
    }
    if(S.size()==2){
        if(S[0]==S[1]) cout << 1 << endl;
        else cout << 2 << endl;
        return 0;
    }
    int k=0;
    string t="";
    int c=0;
    for(int i=0;i<S.size();){
        string s=S.substr(i,1);
        if(t==s){
            if(i==S.size()-1){
                break;
            }
            t = S.substr(i,2);
            k++;
            i+=2;
        }else{
            t=s;
            k++;
            i++;
        }
    }
    
    cout << k << endl;
    return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P;
map<int, int> dp;
#define REP(i, n) for (int i = 0; i < n; i++)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, R;
  cin >> N >> R;
  if (N >= 10) {
    cout << R << endl;
    return 0;
  }
  cout << R + 100 * (10 - N) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(){
    ll INF=1001001001;
    ll n,m; cin>>n>>m;
    vector<ll> nes={0,2,5,5,4,5,6,3,7,6};
    vector<ll> a(m);
    rep(i,m) cin>>a[i];
    vector<ll> dp(n+1,(-1)*INF);
    dp[0]=0;
    rep(i,n){
        rep(j,m){
            if(i+1-nes[a[j]]<0)continue;
            chmax(dp[i+1],dp[i+1-nes[a[j]]]+1);
        }
    }
    sort(a.begin(),a.end(),greater<ll>());
    ll nn=dp[n];
    rep(i,nn){
        rep(j,m){
            if(n-nes[a[j]]>=0 && dp[n-nes[a[j]]]==dp[n]-1){cout<<a[j]; n-=nes[a[j]]; break;}
        }
    }
    cout<<endl;
}

Measured memory_bytes: 384
n,a,b = map(int, input().split())
s = input()
students_passed = 0
rank = 0
for i, j in enumerate(s):
    if students_passed < a+b and j == 'a':
        students_passed += 1
        print('Yes')
    elif students_passed < a+b and j == 'b' and rank <= b-1:
        rank += 1
        students_passed += 1
        print('Yes')
    else:
        print('No')
        

Measured memory_bytes: 9304
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		int answer = 2;
		while (answer <= N) {
			answer *= 2;
		}

		System.out.println(answer / 2);
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;
		private StringBuilder buffer = new StringBuilder();

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			int read = skip();
			do {
				buffer.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			String text = buffer.toString();
			buffer.delete(0, buffer.length());

			return text;
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}

Measured memory_bytes: 23252
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB push_back
#define PF push_front
#define FILL(a,b) memset(a,b,sizeof(a))
using namespace std;
double x[100005],y[100005],lx[100005],ly[100005],maxi=1e9;
int n;
double check(double p){
	double lowx=maxi*maxi,lowy=maxi*maxi,highx=-maxi*maxi,highy=-maxi*maxi,tx,ty;
	FOR(i,1,n){
		tx=x[i]+lx[i]*p;
		ty=y[i]+ly[i]*p;
		lowx=min(lowx,tx);
		highx=max(highx,tx);
		lowy=min(lowy,ty);
		highy=max(highy,ty);
	}
	RE (highx-lowx)*(highy-lowy);
}
int main(){
	double t1,t2,ans=maxi*maxi,t3,t4;
	scanf("%d",&n);
	char c[1];
	FOR(i,1,n){
		scanf("%lf%lf",&x[i],&y[i]);
		scanf("%s",c);
		if(c[0]=='R')lx[i]=1;
		else if(c[0]=='L')lx[i]=-1;
		else if(c[0]=='U')ly[i]=1;
		else ly[i]=-1;
	}
	double l=0,r=maxi;
	FOR(i,1,200){
		t1=(l+r+r)/3.0;
		t2=(l+r+l)/3.0;
		t3=check(t1);
		t4=check(t2);
		ans=min(ans,t3);
		ans=min(ans,t4);
		if(t3>t4){
			r=t1;
		}else l=t2;
	}
	printf("%.12f",ans);
	RE 0;
}



Measured memory_bytes: 3328
package main

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

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt(A ...*int) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.Atoi(L[i])
  }
}
func NextIntVec(A *[]int) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]int, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.Atoi(l)
  }
}
func NextFloat(A ...*float64) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.ParseFloat(L[i], 64)
  }
}
func NextFloatVec(A *[]float64) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]float64, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.ParseFloat(l, 64)
  }
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func WriteIntVec(A []int) {
  S := make([]string, len(A))
  for i, a := range A {
    S[i] = strconv.Itoa(a)
  }
  Write(strings.Join(S, " "))
}
func Output() {
  _ = writer.Flush()
}

func MaxInt(A ...int) int {
  max := A[0]
  for _, a := range A {
    if max < a { max = a }
  }
  return max
}
func MinInt(A ...int) int {
  min := A[0]
  for _, a := range A {
    if a < min { min = a }
  }
  return min
}
func SumInt(A ...int) int {
  sum := 0
  for _, a := range A {
    sum += a
  }
  return sum
}

func Find(R *[]int, v int) int {
  if v == (*R)[v] { return v }
  return Find(R, (*R)[v])
}
func Union(R, V *[]int, u, v int) (int, int) {
  ru, rv := Find(R, u), Find(R, v)
  if ru < rv {
    (*R)[rv] = ru
    (*V)[ru] += (*V)[rv]
    return (*V)[ru], rv
  } else if rv < ru {
    (*R)[ru] = rv
    (*V)[rv] += (*V)[ru]
    return (*V)[rv], ru
  }
  return (*V)[ru], -1
}

type Edge [][]int
func (E Edge) Len() int { return len(E) }
func (E Edge) Less(i, j int) bool { return E[i][2] < E[j][2] }
func (E Edge) Swap(i, j int) { E[i], E[j] = E[j], E[i] }

func Solve() {
  var N, M int
  NextInt(&N, &M)
  var X []int
  NextIntVec(&X)
  E := make([][]int, M)
  var x, y, c int
  for i := range E {
    NextInt(&x, &y, &c)
    x--
    y--
    E[i] = []int{x, y, c, 0, 0}
  }
  sort.Sort(Edge(E))
  R := make([]int, N)
  V := make([]int, N)
  for i, x := range X {
    R[i] = i
    V[i] = x
  }
  for i, e := range E {
    u, v := e[0], e[1]
    E[i][3], E[i][4] = Union(&R, &V, u, v)
  }
  cnt := 0
  S := make([]bool, N)
  for i := M - 1; 0 <= i; i-- {
    e := E[i]
    r := Find(&R, e[0])
    if S[r] { continue }
    if e[2] <= V[r] {
      S[r] = true
      continue
    }
    cnt++
    if e[4] < 0 { continue }
    V[r] -= V[e[4]]
    R[e[4]] = e[4]
  }
  Write(cnt)
  return
}

func main() {
  Solve()
  Output()
}

Measured memory_bytes: 15488
a, b = $stdin.readline.split(" ").map(&:to_i)

res = []
if b - a < 10
  res = (a..b).to_a
else
  loop do
    res << a
    a += 1
    break if a % 4 == 0
  end

  if b % 4 == 0
    res << b
  else
    loop do
      res << b
      break if b % 4 == 0
      b -= 1
    end
  end
end

ans = 0
res.each do |x|
  ans ^= x
end

puts ans


Measured memory_bytes: 3836
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
#define REP(i,x,n) for (int i=x; i<n; i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;

int main(){
  int n, k;
  cin >> n >> k;
  int cnt = 0;
  int i = 0;
  while (cnt < n){
    if (i == 0){
      cnt += k;
      i++;
      continue;
    }
    cnt += k - 1;
    i++;
  }
  cout << i << endl;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

const int N = 3e5 + 10;
const int MOD = 1e9 + 7;
const int64_t INF = 5e18;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

pair<int, int> a[N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i].first >> a[i].second;
    }
    for (int i = 0; i + 2 < n; i++) {
        int cnt = 0;
        if (a[i].first == a[i].second) {
            cnt++;
        }
        if (a[i + 1].first == a[i + 1].second) {
            cnt++;
        }
        if (a[i + 2].first == a[i + 2].second) {
            cnt++;
        }
        if (cnt == 3) {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
    return 0;
}


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

#define Omar45 ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define pb push_back
#define endl '\n'
#define MOD 1000000007
#define maxN 1e5
#define INF (ll)1e18 + 1;

ll n, k, x, total;
vector<ll> v;

ll myFunction(ll m) {
    for(int i = 0; i < n; i++) {
    ll l = -1, r = n;
    if(v[i] < 0) {
        while(r - l > 1) {
            ll mid = (l + r) / 2;
            if(v[i] * v[mid] < m)
                r = mid;
            else
                l = mid;
        }
        total += n - r;
        if(v[i] * v[i] < m)
            total--;
    }
    else {
        while(r - l > 1) {
            ll mid = (l + r) / 2;
            if(v[i] * v[mid] < m)
                l = mid;
            else
                r = mid;
        }
        total += r;
        if(v[i] * v[i] < m)
            total--;
    }
    }
    total /= 2;
}


int main() {
    Omar45
    cin >> n >> k;
    for(int i = 0; i < n; i++) {
        cin >> x;
        v.push_back(x);
    }
    sort(v.begin(),v.end());
    ll Left = -INF;
    ll Right = INF;
    while(Right - Left > 1) {
        ll mid = (Left + Right) / 2;
        total = 0;
        myFunction(mid);
        if (total < k)
            Left = mid;
        else
            Right = mid;
      }

    cout << Left << endl;
}


Measured memory_bytes: 2420
#include<iostream>
#include<vector>
using namespace std;
#define MAX 10001
int n,k,m;

int main(){
  while(1){
    cin>>n>>k>>m;    
    if(n==0&&k==0&&m==0)break;

    vector<int> t;
    for(int i=1;i<=n;i++)t.push_back(i);

    m--;
    for(int i=0;i<n-1;i++){
      t.erase(t.begin()+m);
      if(m==(int)t.size())m=0;
      m+=k-1;
      m%=(int)t.size();
    }
    cout<<t[0]<<endl;
  }
  return 0;
}

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

typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1e9+7,inf=mod*mod*3ll;;
#define rep(i,N) for(ll i=0; i<(N); i++)
#define rep1(i,N) for(ll i=1; i<(N); i++)
#define pb push_back

ll X;
int main(){

cin.tie(0);
ios::sync_with_stdio(false);

cin>>X;

rep1(i,200005){
	if(i*(i+1)>=2*X){
		cout<<i<<endl;
		return 0;
	}
}

}
	


Measured memory_bytes: 256
import bisect

N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
#print(A)
#print(B)
#print(C)

ans = 0

for i in B:
  a_num = bisect.bisect_left(A,i)
  c_num = bisect.bisect(C,i)
  ans += a_num*(N-c_num)


print(ans)

Measured memory_bytes: 29240
n = int(input())
l = list(map(int,input().split()))
ans = 0
for a in range(n-2):
    for b in range(a,n-1):
        for c in range(b,n):
            if l[a]+l[b] > l[c] and l[b]+l[c] > l[a] and l[c]+l[a] > l[b]:
                if l[a] != l[b] and l[b] != l[c] and l[a] != l[c]:
                    ans += 1
print(ans)

Measured memory_bytes: 9160
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
int gcd(int a,int b){
    if(a%b==0)return b;
    else return gcd(b,a%b);
}
class Union_Find{
private:
    vector<int> t,s;
public:
    Union_Find(int max_length){
        rep(i,max_length+1){
            t.push_back(i);
            s.push_back(1);
        }
    }
    void Union(int x,int y){
        if(same(x,y))return;
        int tx=Find(x),ty=Find(y);
        if(s[tx]<s[ty]){
            s[ty]+=s[tx];
            t[tx]=ty;
        }
        else if(s[tx]>s[ty]){
            s[tx]+=s[ty];
            t[ty]=tx;
        }
        else if(tx>ty){
            t[tx]=ty;
            s[ty]+=s[tx];
        }
        else{
            t[ty]=tx;
            s[tx]+=s[ty];
        }
    }
    int Find(int n){
        if(t[n]==n)return n;
        else return t[n]=Find(t[n]);
    }
    bool same(int x,int y){
        return Find(x)==Find(y);
    }
    int gets(int a){
        return s[a];
    }
};
signed main(){
    int n,m,a[100000],b[100000];
    stack<int> ans;
    cin>>n>>m;
    int memo=n*(n-1)/2;
    rep(i,m){
        cin>>a[i]>>b[i];
    }
    Union_Find tree(n);
    rep(i,m){
        ans.push(memo);
        if(tree.same(a[m-i-1],b[m-i-1]))continue;
        memo-=tree.gets(tree.Find(a[m-i-1]))*tree.gets(tree.Find(b[m-i-1]));
        tree.Union(a[m-i-1],b[m-i-1]);
    }
    rep(i,m){
        cout<<ans.top()<<endl;
        ans.pop();
    }
    return 0;
}

Measured memory_bytes: 5228
#include <cmath>
#include <iostream>
#include <vector>

using ll = long long;
#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using namespace std;

// 158 - c
int main(void) {
    int a, b;
    cin >> a >> b;

    int ans = -1;
    int _a, _b;
    repe(val, 10, 1250) {
        _a = (int)val * 0.08;
        _b = (int)val * 0.1;

        if (_a == a && _b == b) {
            ans = val;
            break;
        }
        if (_a > a || _b > b) break;
    }

    cout << ans << endl;

    return 0;
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vii;

struct Tree {
  typedef ll T;
  static constexpr T unit = INT_MIN; // f(unit, b) must equal b
  T f(T a, T b) { return max(a, b); } // (any associative fn)
  vector<T> s; int n;
  Tree(int n = 0, T def = unit) : s(2*n, def), n(n) {}
  void update(int pos, T val) {
    for (s[pos += n] = val; pos /= 2;)
      s[pos] = f(s[pos * 2], s[pos * 2 + 1]);
  }
  T query(int b, int e) { // query [b, e)
    T ra = unit, rb = unit;
    for (b += n, e += n; b < e; b /= 2, e /= 2) {
      if (b % 2) ra = f(ra, s[b++]);
      if (e % 2) rb = f(s[--e], rb);
    }
    return f(ra, rb);
  }
};

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);

  int n;
  cin >> n;

  vl h(n), a(n);
  Tree tr(n+1);
  rep(i,0,n) cin >> h[i];
  rep(i,0,n) cin >> a[i];

  ll ans = 0;
  rep(i,0,n) {
    ll t = a[i];
    ckmax(t, tr.query(0, h[i])+a[i]);
    tr.update(h[i], t);
    ckmax(ans, t);
  }

  cout << ans << '\n';

}

Measured memory_bytes: 6528
N,L = map(int,input().split())
if L >=0:
    eat = 0
else:
    eat = N - 1
    for m in range(N):
        if abs(L + m) < abs(L + eat):
            eat = m
aj = N*(N-1)//2
pie = (N-1)*L + aj - eat
print(pie)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b




signed main(){
	ll n; cin>>n;
	ll memo=MOD;
	ll ans=-(MOD*(ll)3);
	rep(i,0,n){
		ll a; cin>>a;
		if(i==0){
			memo=a;
			continue;
		}
		chmax(ans,a-memo);
		chmin(memo,a);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,wwwwwwwwwwwwwwwwwwwwwwwwww=0,s=0;
    cin>>n;
    for(int i=sqrt(n);i>0;--i)  
    if(n%i==0)
	{
        wwwwwwwwwwwwwwwwwwwwwwwwww=n/i;
        break;
    }
    while(wwwwwwwwwwwwwwwwwwwwwwwwww>0)
	{ 
        ++s;
        wwwwwwwwwwwwwwwwwwwwwwwwww/=10;
    }
    cout<<s<<endl;
    return 0;
}

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

int main(){
  int n,ans,sum;

  while(cin>>n,n){
    ans=0;
    for(int i=1;i<n/2+1;i++){
      sum=0;
      for(int l=i;sum<n;l++){
        sum+=l;
      }
      if(sum==n) ans++;
    }
    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 1144
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll x, y, n;std::cin >> n;
  vll t(n);
  re(i, n) std::cin >> t[i];
  ll M = 0, S = 0;
  re(i, n){
    S += t[i];
    M = max(M, t[i]);
  }
  ll m;std::cin >> m;
  re(i, m){
    std::cin >> x >> y;
    std::cout << S - t[x-1] + y << '\n';
  }
  return 0;
}


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

using namespace std;

const int N = 100010;

int cnt[N];

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int foo;
    cin >> foo;
    cnt[foo]++;
  }
  int best = 0;
  for (int i = 1; i < N - 1; i++) best = max(best, cnt[i - 1] + cnt[i] + cnt[i + 1]);
  cout << best << endl;
}


Measured memory_bytes: 640
# ABC052 B - Increment Decrement
# 2019/11/07

N, S = [s for s in open(0)]
# print(N, S)
list_S = [1 if i == 'I' else -1 for i in list(S)]
# print(list_S)

add_list = 0
ans = 0
for j in list_S:
    add_list += j
    ans = max(add_list,ans)

print(ans)

Measured memory_bytes: 3060
N, M = map(int, input().split())
K = [list(map(int, input().split())) for _ in range(N)]
cnt = 0
for i in range(1, M+1):
    for j in range(N):
        if i not in K[j][1:]:
            break
    else:
        cnt += 1
print(cnt)


Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>
int main(void)
{
	char a[1001];
	int len,i;
	scanf("%s",a);
	len=strlen(a);
	for(i=0;i<len;i++)	{
		if(a[i]=='A' || a[i]=='B'|| a[i]=='C'){
			a[i]=a[i]+23;
		}
		else {
			a[i]=a[i]-3;
		}
	}
	printf("%s\n",a);
	return 0;
}

Measured memory_bytes: 948
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 


using namespace std; 

#define make_pair MP

int main(){

	int N;

	//左，下，右，上
	const int dx[]={-1,0,1,0};
	const int dy[]={0,1,0,-1};

	while(cin>>N,N){

		vector<int> x(N),y(N);
		int left=0,right=0,top=0,bottom=0;


		x[0]=y[0]=0;

		for(int i=1;i<N;i++){
			int n,d;
			cin>>n>>d;

			x[i]=x[n]+dx[d];
			y[i]=y[n]+dy[d];

			left=min(left,x[i]);
			right=max(right,x[i]);
			top=min(top,y[i]);
			bottom=max(bottom,y[i]);
		}

		cout<<right-left+1<<" "<<bottom-top+1<<endl;

	}

	return 0;
}

Measured memory_bytes: 1196
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int sum=0;
    for(int i=0;i<s.length();i++){
      sum=sum+s.charAt(i)-'0';
    }
    if(sum%9==0){
      System.out.println("Yes");
    }
    else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 40352
N = int(input())
H = list(map(int, input().split()))
H.append(10**10)
hight = [0]*len(H)

last = H[0]
lasti = 0
cnt = 0
for i, h in enumerate(H):
    if i==0: continue
    if last >= h:
        cnt += 1
        last = h
        continue
    else:
        hight[lasti] = cnt
        lasti = i
        cnt = 0
        last = h
        continue
print(max(hight))

Measured memory_bytes: 14252
str = input()
q = int(input())

for i in range(q):
        buff = input()
        index = -1
        lst = []
        while True:
                jndex = buff.find(" ", index + 1)
                if jndex == -1:
                        lst.append(buff[index + 1 :])
                        break
                lst.append(buff[index + 1 : jndex])
                index = jndex
        
        lst[1] = int(lst[1])
        lst[2] = int(lst[2])

        if lst[0] == "print":
                print(str[lst[1]:lst[2]+1])
        elif lst[0] == "reverse":
                str = str[:lst[1]] + str[lst[1]:lst[2]+1][::-1] + str[lst[2]+1:]
        elif lst[0] == "replace":
                str = str[:lst[1]] + lst[3] + str[lst[2]+1:]


Measured memory_bytes: 5620
#include<stdio.h>
int main()
{
    int N,i,x;
    scanf("%d\n",&N);
    int A[N];
    for(i=0;i<N;i++){
        scanf("%d",&x);
        A[x-1]=i+1;
    }
    for(i=0;i<N;i++){
        printf("%d ",A[i]);
    }
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using ll = int_fast64_t;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
#define fast() ios::sync_with_stdio(false), cin.tie(nullptr)
#define digit(N) cout << fixed << setprecision((N))
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

set<ll> prime_factor(ll N)
{
	set<ll> S;
	for (ll i = 2; i * i <= N; i++)
	{
		if (N % i == 0)
			S.insert(i);
		while (N % i == 0)
			N /= i;
	}

	if (N != 1)
		S.insert(N);
	return S;
}

int main()
{
	ll N, ans = 0, M;
	cin >> N;
	set<ll> st = prime_factor(N);
	for (auto &p : st)
	{
		if (p == N)
		{
			ans++;
			break;
		}

		ll z = p, M = N;
		while (M % z == 0)
		{
			M /= z;
			z *= p;
			ans++;
		}
	}

	cout << ans << "\n";
}

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

int main(){
  string s;
  cin >> s;
  int n = s.size();
  deque<int> dq;

  for (int i = 0; i < n; i++)
  {
    char c = s[i];
    if(c=='0') dq.push_back(0);
    else if(c=='1') dq.push_back(1);
    else {
      if(dq.size()>0) dq.pop_back();
    }
  }

  for(int m:dq){
    cout << m;
  }
  cout << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#include <cassert>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define Cout(x) cout << x << endl;
#define check(v) rep(i,v.size()) cout << v[i] << endl;
#define vint(x) vector<int> x
#define vll(x) vector<long long> x
#define vstr(x) vector<string> x
const long long LLINF = 1LL<<60;
const int INF = 1e9;
const long long MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
#define pint pair<int,int>
#define pll pair<ll,ll>
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n; cin >> n;
    cout << (n-1)/2+1 << endl;

    return 0;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
B=[0]*3

MOD=10**9+7

ans=1
for i in range(N):
  cnt=0
  for j in range(3):
    if B[j]==A[i]:
      cnt+=1
  for j in range(3):
    if B[j]==A[i]:
      B[j]+=1
      break
  ans*=cnt
  ans%=MOD
print(ans)

Measured memory_bytes: 53996
# -*- coding: utf-8 -*-

import sys
import os
import math

def freq_op(A):
    B = []
    for a in A:
        B.append(A.count(a))
    return B

for s in sys.stdin:
    n = int(s)
    if n == 0:
        break

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

    cnt = 0
    while True:
        B = freq_op(A)
        cnt += 1
        if B == A:
            break
        else:
            A = B

    print(cnt - 1)
    print(*A)

Measured memory_bytes: 7668