akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

class UnionFind {
    int n;
    vector<int> uni;
public:
    explicit UnionFind(int n) : uni(static_cast<u32>(n), -1) , n(n){};

    int root(int a){
        if (uni[a] < 0) return a;
        else return (uni[a] = root(uni[a]));
    }

    bool unite(int a, int b) {
        a = root(a);
        b = root(b);
        if(a == b) return false;
        if(uni[a] > uni[b]) swap(a, b);
        uni[a] += uni[b];
        uni[b] = a;
        return true;
    }

    int size(int i){ return -uni[root(i)]; }
    bool same(int a, int b) { return root(a) == root(b); }
};

int main() {
    int n;
    while(cin >> n, n){
        vector<int> zx = {-MOD, MOD}, zy = {-MOD, MOD};
        vector<vector<int>> v;
        for (int i = 0; i < n; ++i) {
            int a, b, c, d;
            cin >> a >> d >> c >> b;
            zx.emplace_back(a); zx.emplace_back(c-1); zx.emplace_back(c);
            zy.emplace_back(b); zy.emplace_back(d-1); zy.emplace_back(d);
            v.emplace_back(vector<int>{b, a, d, c});
        }
        sort(zx.begin(), zx.end());
        zx.erase(unique(zx.begin(), zx.end()), zx.end());
        sort(zy.begin(), zy.end());
        zy.erase(unique(zy.begin(), zy.end()), zy.end());
        int h = zy.size(), w = zx.size();
        vector<vector<ll>> grid(h+2, vector<ll>(w+2, 0));
        auto fy = [&zy](int y){ return lower_bound(zy.begin(),zy.end(), y)-zy.begin(); };
        auto fx = [&zx](int x){ return lower_bound(zx.begin(),zx.end(), x) - zx.begin(); };
        for (int i = 0; i < n; ++i) {
            int y1 = fy(v[i][0])+1, x1 = fx(v[i][1])+1, y2 = fy(v[i][2])+1, x2 = fx(v[i][3])+1;
            grid[y1][x1] += 1LL<<i; grid[y1][x2] -= 1LL<<i; grid[y2][x1] -= 1LL<<i; grid[y2][x2] += 1LL<<i;
        }
        for (int i = 1; i < h+2; ++i) {
            for (int j = 0; j < w+2; ++j) {
                grid[i][j] += grid[i-1][j];
            }
        }
        for (int i = 0; i < h + 2; ++i) {
            for (int j = 1; j < w+2; ++j) {
                grid[i][j] += grid[i][j-1];
            }
        }


        int Y = grid.size(), X = grid[0].size();
        UnionFind uf(X*Y);
        for (int i = 0; i < Y; ++i) {
            for (int j = 0; j < X; ++j) {
                if(i && grid[i][j] == grid[i-1][j]) uf.unite(i*X+j, (i-1)*X+j);
                if(j && grid[i][j] == grid[i][j-1]) uf.unite(i*X+j, i*X+j-1);
            }
        }
        vector<int> ans;
        for (int i = 0; i < Y; ++i) {
            for (int j = 0; j < X; ++j) {
                ans.emplace_back(uf.root(i*X+j));
            }
        }
        sort(ans.begin(), ans.end());
        ans.erase(unique(ans.begin(), ans.end()), ans.end());
        cout << ans.size() << "\n";
    }
    return 0;
}


Measured memory_bytes: 3312
#include <bits/stdc++.h>
#define INF 1.0e9
using namespace std;
typedef long long ll;

int N;
const int MAX_N = 100;
int x[MAX_N], y[MAX_N], h[MAX_N];

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) cin >> x[i] >> y[i] >> h[i];
    int cx, cy, H;
    for (int cur_cx = 0; cur_cx <= 100; cur_cx++) {
        for (int cur_cy = 0; cur_cy <= 100; cur_cy++) {
            int cur_h;
            for (int i = 0; i < N; i++) {
                if (h[i] != 0) {
                    cur_h = h[i] + abs(x[i] - cur_cx) + abs(y[i] - cur_cy);
                }
            }
            bool flag = true;
            for (int i = 0; i < N; i++) {
                if (max(cur_h - abs(x[i] - cur_cx) - abs(y[i] - cur_cy), 0) != h[i]) {
                    flag = false;
                    break;
                }
            }
            if (flag) {
                cx = cur_cx;
                cy = cur_cy;
                H = cur_h;   
            }        
        }
    }
    cout << cx << " " << cy << " " << H << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define INF 0x3f3f3f3
#define LINF 0x3f3f3f3f3f3f3f
#define MAXN int(2*1e5)+5
#define fim '\n'
#define ll long long
#define f first
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << fim
#define debug2(x, y) cout << "DEBUG " << x << " " << y << fim
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< fim
#define debug4(x, y, z, o) cout << "DEBUG " << x << " " << y << " " << z<< " " << o << fim
#define max3(x, y, z) max(x, max(y, z))
#define ull unsigned long long
using namespace std;
using namespace __gnu_pbds;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<unsigned ll, pair<int, int> > piii;
typedef pair<pair<int, int>, int> piii2;
typedef tree<int,null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> indexed_set;
const ll MOD = 1e9+7;
 
using namespace std;
 
int main() {
    int n;
    cin >> n;
    string v;
    cin >> v;
 
    int sum[4][n+5];
    memset(sum, 0, sizeof sum);
    for(int i = 0; i < n; i++) {
        if(i) {
            sum[0][i] += sum[0][i-1];
            sum[1][i] += sum[1][i-1];
            sum[2][i] += sum[2][i-1];
        }
        if(v[i] == 'R') {
            v[i] = 0;
            sum[0][i]++;
        }
        if(v[i] == 'G') {
           v[i] = 1;
           sum[1][i]++;
        }
        if(v[i] == 'B'){
         v[i] = 2;
         sum[2][i]++;
        }
    }
 
    ll ans = 0;
    for(int i = 0; i < n; i++)
        for(int j = i+1; j < n-1; j++) {
            if(v[i] == v[j])
                continue;
            for(int k = 0; k < 3; k++) {
 
                if(k == v[i] or k == v[j])
                    continue;
 
                ans += sum[k][n-1]-sum[k][j];
 
 
                
                if(j+(j-i) < n && v[j+(j-i)] == k) 
                    ans--;
 
               // debug3(i, j, ans);
            }
 
 
        }
    cout << ans << endl;
}

Measured memory_bytes: 3648
#include <iostream>
using namespace std;
#define MAX 2000000

int A[MAX+1], H;
void maxHeapify(int i) {
    int  l = 2*i;
    int  r = 2*i+1;
    int largest;
    if ( l <= H && A[l] > A[i] ) {
       largest = l;
    }else{
       largest = i;
    }

    if ( r <= H && A[r] > A[largest] ) {
        largest = r;

    }

    if (largest != i) {
        swap(A[i],A[largest]);
        maxHeapify(largest);
    }
}
int main (void) {
    int i;

    cin >> H;

    for(i = 1; i <= H ; i++ ) {
        cin >> A[i];
    }

    for(i = H/2 ; i >= 1 ; i--) {
        maxHeapify(i);
    }

    for ( i = 1 ; i <= H ; i++ ) {
        cout << " " << A[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 4928
import java.util.Scanner;
import java.util.Arrays;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.nextLine());
    int[] arr = Arrays.stream(sc.nextLine().split(" "))
      .mapToInt(Integer::parseInt)
      .toArray();
    int cnt = 0;
    int pow = 2;
    out: while (true) {
      for (int i = 0; i < n; i++) {
        if (arr[i] % pow != 0) {
          System.out.println(cnt);
          break out;
        }
      }
      cnt += 1;
      pow *= 2;
    }
  }
}


Measured memory_bytes: 27092
#include<iostream>
using namespace std;
int main(){
  int w;
  while(1){
  int m=3130;
    cin >> w;
    if(w==-1)break;
    w-=10;
    for(int i=0;w>0;i++){
      if(i<10)m-=125;
      if(i>=10&&i<20)m-=140;
      if(i>=20&&i<30)m-=160;
      if(i>=30)m-=160;
      w--;
    }
    cout << m << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define REP(i,n,s) for (int i = (s); i < (n); i++)
#define MOD 1000000007;
using namespace std;
typedef long long int LL;

int N, K;
LL p[101], l[256][101];

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

	cin >> N >> K;
	p[0] = 1;
	REP(i, N+1, 1) {
		p[i] = p[i-1]*i%MOD;
	}

	int a;
	LL tmp[256][101];
	REP(i, N, 0) {
		cin >> a;
		memset(tmp,0,sizeof(tmp));
		
		REP(j, 256, 0) {
			REP(k, 101, 0) {
				if (l[j][k] > 0) {
					tmp[j][k] = (tmp[j][k]+l[j][k])%MOD;
					tmp[j^a][k+1] = (tmp[j^a][k+1]+l[j][k])%MOD;
				}
			}
		}
		tmp[a][1]++;
		memcpy(l, tmp, sizeof(l));
	}
	LL res = 0;
	REP(i, 101, 1) {
		if (l[K][i] > 0) {
			res = (res+p[i]*l[K][i])%MOD;
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 640
n,m=map(int,input().split())
L=[]
R=[]
for i in range(m):
    l,r=map(int,input().split())
    L.append(l)
    R.append(r)
LL=max(L)
RR=min(R)
if LL<=RR:
    print(RR-LL+1)
else:
    print(0)

Measured memory_bytes: 16808
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    string T;
    cin >> T;
    int len = T.size();
    rep(i,len){
        if (T[i]  != '?') cout << T[i];
        else{
            cout << "D";
        }
    }
    cout << endl;
}


Measured memory_bytes: 3752
n, a =map(int, input().split())
x=list(map(int, input().split()))
x=[i-a for i in x]
memo=[[-1]*6000 for i in range(60)]
def dp(k, value):
    if k==n:
        if value==0:
            return 1
        else:
            return 0
    if memo[k][value]>=0:
        return memo[k][value]
    memo[k][value]=dp(k+1, value+x[k])+dp(k+1, value)
    return memo[k][value]
print(dp(0, 0)-1)

Measured memory_bytes: 6004
#include <iostream>
#include <algorithm>
#include<string>
#include<cmath>
#include<stack>
#include <vector>
#include<queue>
#include <random>
#include <cstdint>
#include <bitset>
#include <iomanip>
using namespace std;

int main() {
	int h, w;
	char a[500][500];
	cin >> h >> w;
	for (int i = 0; i < h; i++){
		for (int j = 0; j < w; j++){
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cout << (((i % 2 == 0 && j != w - 1) || (i % 2 == 1 && j == 0) || (a[i][j] == '#')) ? '#' : '.');
		}
		cout << endl;
	}
	cout << endl;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cout << (((i % 2 == 0 && j == w - 1) || (i % 2 == 1 && j != 0) || (a[i][j] == '#')) ? '#' : '.');
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define REP(a,b) for (int i = a; i <= (b); ++i) 
#define mREP(a,b) for (int i = a; i == (b); --i) 
typedef long long ll;
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
/*
	　　　  　 ,ﾍ／L──- 、
	　　　   　Lﾆ)r_」=＝= ｲ
	　　 　,ﾍ、i ﾉノλﾉﾊﾉﾍ
	　　   ,'　｀(ﾊﾘ ﾟ ヮﾟﾉi)　',
	　　 .i　　 >〈(つ,i!と)　　i
	　　  vﾍγk´_/___i,ゝﾍノ
	　　　　　 ｀ﾞr_,ｨ_ｧﾞ´
*/
int n;
ll tempsum = 0;
ll anssum = 1039242090;
cin >> n;
vector<int>a(n);
rep0(i, n - 1)cin >> a[i];
REP(-100, 100) {
	rep0(j, n - 1) {
		if (a[j] != i) {
			tempsum += (a[j] - i) * (a[j] - i);
		}
	}
	anssum = min(tempsum, anssum);
	tempsum = 0;
}
cout << anssum << endl;
return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        RemainderReminder solver = new RemainderReminder();
        solver.solve(1, in, out);
        out.close();
    }

    static class RemainderReminder {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long n = in.nextLong();
            long k = in.nextLong();
            long result = 0;
            if (k == 0) {
                out.println(n * n);
                return;
            }
            for (long b = k + 1; b <= n; b++) {
                result += (n / b) * (b - k);
                result += Math.max(0, n % b - k + 1);
            }
            out.println(result);
        }

    }
}



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

int main () {
  int a, b;
  cin >> a >> b;
  
  int i = 0;
  int hole_num = 1;
  int counter = 0;
  while (hole_num < b) {
    hole_num += a - 1;
    counter++;
  }
  cout << counter << endl;
}

Measured memory_bytes: 256
sum10 :: Double -> Double
sum10 = (*) (1 + 2 + 2/3 + 4/3 + 4/9 + 8/9 + 8/27 + 16/27 + 16/81 + 32/81)

main :: IO ()
main = putStr . unlines . map show . map (sum10 . read) . lines =<< getContents

Measured memory_bytes: 4312
f = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(f[k-1])


Measured memory_bytes: 2940
#include <iostream>
using namespace std;
int main(){
  string s;
  while(cin >> s, s != "#"){
    int y, m, d;
    cin >> y >> m >> d;
    if(y < 31) cout << s << " " << y << " " << m << " " << d << endl;
    else if(y > 31 || m > 4) cout << "? " << y-30 << " " << m << " " << d << endl;
    else cout << s << " " << y << " " << m << " " << d << endl;
  }
  return 0;
}



Measured memory_bytes: 3128
#include <cmath>
#include <queue>
#include <cstdio>
#include <iomanip>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define N 100010
#define ll long long
#define eps 1e-8
using namespace std;
inline ll read() 
{ 
    ll x=0,f=1;char ch=getchar(); 
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} 
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} 
    return x*f; 
}
ll A,B,C,D;
ll E,F; 
long double ans;
ll ansx,ansy;
int main()
{
	A=read(),B=read(),C=read(),D=read();
	E=read(),F=read();
	for(ll a=0;a<=101;a++)
	for(ll b=0;b<=101;b++)
	for(ll c=0;c<=101;c++)
	for(ll d=0;d<=101;d++)
	{
		ll x=100*A*a+100*B*b;
		ll y=C*c+D*d;
		if(y>(A*a+B*b)*E)continue ;
		//int z=min(x/100*E,y);
		ll z=y;
		if(x+y>F)continue ;
		if(x+z==0)continue ;
		long double now=(long double)(100*z)/(long double)(x+z);
		if(now-ans>eps)
		{
			ans=now;
			ansx=x;
			ansy=y;
		}
	}
	if(ans<eps)
	ansx=100*A;
	printf("%lld %lld",ansx+ansy,ansy);
}
/*
mdzzzzzzzzzzzzzzzz
*/

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;



int main(){
	int a[3];
	int k;

	for(int i=0;i<3;i++){
		scanf("%d", &a[i]);
	}
	scanf("%d", &k);

	sort(a,a+3);

	for(int i=0;i<k;i++){
		a[2] *= 2;
	}
	int ans = 0;
	for(int i=0;i<3;i++){
		ans += a[i];
	}


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

	return 0;
}


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


void solve(long long A){
    cout <<  48 - A << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    solve(A);
    return 0;
}


Measured memory_bytes: 3692
import java.util.*;

public class Main {

    static class Edge implements Comparable<Edge> {
        int from, to, cost;

        public Edge(int from, int to, int cost) {
            this.from = from;
            this.to = to;
            this.cost = cost;
        }

        @Override
        public int compareTo(Edge o) {
            return cost - o.cost;
        }
    }

    static class Pair implements Comparable<Pair> {
        int id, pos;

        public Pair(int id, int pos) {
            this.id = id;
            this.pos = pos;
        }

        @Override
        public int compareTo(Pair o) {
            return pos - o.pos;
        }
    }

    static class UnionFind {
        int[] size;
        int[] id;

        public UnionFind(int n) {
            size = new int[n];
            id = new int[n];

            for (int i = 0; i < n; ++i) {
                size[i] = 1;
                id[i] = i;
            }
        }

        void unify(int p, int q) {
            int root1 = find(p);
            int root2 = find(q);

            if (size[root1] > size[root2]) {
                size[root1] += size[root2];
                id[root2] = root1;
            } else {
                size[root2] += size[root1];
                id[root1] = root2;
            }
        }

        int find(int p) {
            int root = p;
            while (root != id[root]) root = id[root];
            while (root != p) {
                int next = id[p];
                id[p] = root;
                p = next;
            }
            return root;
        }

        boolean connected(int p, int q) {
            return find(p) == find(q);
        }
    }

    static long kruskal() {
        long mstCost = 0;
        UnionFind uf = new UnionFind(N);
        PriorityQueue<Edge> pq = new PriorityQueue<>(edges);

        while (!pq.isEmpty()) {
            Edge edge = pq.poll();
            if (uf.connected(edge.from, edge.to)) continue;
            uf.unify(edge.from, edge.to);
            mstCost += edge.cost;

            if (uf.size[uf.find(0)] == N) break;
        }

        return mstCost;
    }

    static int N;
    static List<Edge> edges;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        N = Integer.parseInt(sc.next());
        List<Pair> X = new ArrayList<>();
        List<Pair> Y = new ArrayList<>();
        edges = new ArrayList<>();

        for (int i = 0; i < N; ++i) {
            X.add(new Pair(i, Integer.parseInt(sc.next())));
            Y.add(new Pair(i, Integer.parseInt(sc.next())));
        }

        Collections.sort(X);
        for (int i = 0; i < N-1; ++i) {
            int from = X.get(i).id;
            int to = X.get(i+1).id;
            edges.add(new Edge(from, to, X.get(i+1).pos - X.get(i).pos));
        }

        Collections.sort(Y);
        for (int i = 0; i < N-1; ++i) {
            int from = Y.get(i).id;
            int to = Y.get(i+1).id;
            edges.add(new Edge(from, to, Y.get(i+1).pos - Y.get(i).pos));
        }

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

Measured memory_bytes: 67668
#include<bits/stdc++.h>
using namespace std;
int N;
int S[200000];

bool check(int x){
  int d=N/x;
  for(int i=d;i<N;i++)
    if(S[i]!=S[i-d])return false;
  return true;
}

int main(){
  scanf("%d",&N);
  for(int i=0;i<N;i++)
    scanf("%d",&S[i]);

  int ans=1;
  for(int i=1;i*i<=N;i++){
    if(N%i==0){
      int a=i,b=N/i;
      if(check(a))ans=max(ans,a);
      if(check(b))ans=max(ans,b);
    }
  }
  printf("%d\n",ans);
  return 0;
}

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

int main(){
  string A,B;
  cin >> A >> B;
  if(A<B){
    cout << "<" << endl;
  }
  else if(A==B){
    cout << "=" << endl;
  }
  else{
    cout << ">" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll n;
    cin >> n;
    vector<PII> v(n);
    REP(i, n) {
        ll x, l;
        cin >> x >> l;
        v[i] = {x+l, x-l};
    }
    sort(ALL(v));
    dump(v);

    ll last = -INF, ret = 0;
    REP(i, n) {
        ll l = v[i].second, r = v[i].first;
        if(last <= l) {
            ret++;
            last = r;
        }
    }
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long
#define ff first
#define ss second

template <class T>
void print(vector<T>& v){
    for(T x:v) cout<<x<<" ";
    cout<<"\n";
}
void inp(vector<int>& v, int n){
    for (int i=0; i<n; ++i) scanf("%d", &v[i]);
}


void sol(){
    int n;
    cin>>n;
    ll res=0;
    int prev=0;
    vector<int> v(n);
    inp(v, n);
    for (int i:v){
        if (i<prev) res+=prev-i;
        prev=max(prev, i);
    }
    printf("%lld\n", res);
    return;
}

int main() {
    // int t;
    // cin>>t;
    // t++;
    // for (int i=1; i<t; ++i){
        // cout<<"Case #"<<i<<": ";
        sol();
    // }
    return 0;
}

Measured memory_bytes: 3980
N,K = map(int,input().split())
P = list(map(int,input().split()))
T = [0]*N

for i in range(N):
    P[i] = (1 + P[i])/2

if N == K:
    print(sum(P))

else:
    for i in range(1,N):
        P[i] += P[i-1]

    for i in range(K,N):
        T[i] = P[i] - P[i-K]

    T = T[K:]

    print(max(T))

Measured memory_bytes: 31956
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		boolean flag =true;
		int h;
		int w;
		String mark = "#";
		while(flag){
			h = sc.nextInt();
			w = sc.nextInt();
			if(h == 0 && w == 0){
				break;
			}
			for(int i = 0;i < h;i++){
				for(int j = 0;j < w;j++){
					if(j % 2 == i % 2){
						mark = "#";
					}else{
						mark = ".";
					}
					System.out.print(mark);
				}
				System.out.println();
			}
			System.out.println();
		}	
	}
}


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

string to_string(string s) {
    return '"' + s + '"';
}

string to_string(const char* s) {
    return to_string((string) s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

void test_case() {
    char c;
    cin >> c;
    cout << char(c + 1) << "\n";
}

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


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

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	string S;
	cin >> S;

	int ans = 0;
	int n = S.size();

	for (int ii = 0; ii < n; ++ii){
		for (int len = 1; len <= n - ii; ++len){
			string tmp = S.substr(ii, len);
			bool ok = true;
			for (int kk = 0; kk < len; ++kk){
				bool cond1 = (tmp[kk] == 'A');
				bool cond2 = (tmp[kk] == 'C');
				bool cond3 = (tmp[kk] == 'G');
				bool cond4 = (tmp[kk] == 'T');
				if (cond1||cond2||cond3||cond4){
				} else {
					ok = false;
				}
			}
			if (ok){
				ans = max(ans, len);
			}
		}
	}

	cout << ans << "\n";

	return 0;
}


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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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






int main()
{
    FAST();

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

    int a,b,c;
    cin >> a >> b >> c;
    if(a+b+c >= 22)cout << "bust";
    else cout << "win";
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (unsigned long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (unsigned long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end())
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 (a > b) {a = b; return 1;} return 0; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl

// gcc拡張マクロ
#define gcd __gcd
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using  ll = long long;
using ull = unsigned long long;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    int t;
    string ans;
    cin >> t;
    REP(i, t) {
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        if (a < b || d < b) {
            ans += "No\n";
        } else if (c >= b) {
            ans += "Yes\n";
        } else {
            if (a % b > c) {
                ans += "No\n";
            } else {
                ll g = gcd(b, d);
                ll amax = a % g + (b - g);
                ans += amax > c ? "No\n" : "Yes\n";
            }
        }
    }
    cout << ans << flush;
    
}

Measured memory_bytes: 256
#include <stdio.h>

int gcd(int, int);

int main(void)
{
	int x, y, temp;
	scanf("%d %d",&x,&y);
	if(y > x) {
		temp = x;
		x = y;
		y = temp;
	}
	printf("%d\n",gcd(x,y));
	return 0;
}

int gcd(int x, int y)
{
	if(y == 0) {
		return x;
	} else {
		return gcd(y, x%y);
	}
}

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

using namespace std;

int main()
{
    int a, b; cin >> a >> b;
    if (a > b) swap(a, b);
    if (a == 1) {
        if (b == 2) cout << 3 << "\n";
        else cout << 2 << "\n";
        return 0;
    }
    cout << 1 << "\n";
}


Measured memory_bytes: 384
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

int main(void) {
	double r;

	cin >> r;

	cout << fixed << setprecision(6) << r * r * M_PI << " " << 2 * r * M_PI << endl;

	return 0;
}

Measured memory_bytes: 3276
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,int> T;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
int N;
int A[12];
int ans;
queue<T> que[2];
map<ll,int> ma[2];
ll encode(vector<int> vec)
{
	ll res = 0ll;
	for(int i=0;i<N;i++)res = (res<<4)+vec[i];
	return res;
}
vector<int> decode(ll res)
{
	vector<int> v;
	for(int i=0;i<N;i++)
	{
		v.pb(((1<<4)-1)&res);
		res >>= 4;
	}
	reverse(all(v));
	return v;
}
void bfs(int f,ll start)
{
	queue<T> &q = que[f];
	map<ll,int> &m = ma[f];
	q.push(T(start,0));
	m[start]=0;
	while(!q.empty())
	{
		T a = q.front();
		q.pop();
		vector<int> v = decode(a.fi);
		vector<int> tmp = v;
		if(a.sec>=(N-1)/2)return;
		for(int i=0;i<N;i++)
		{
			for(int j=i+1;j<N;j++)
			{
				for(int k=i;k<=j;k++)tmp[j-(k-i)]=v[k];
				ll e = encode(tmp);
				if(m.find(e)==m.end())
				{
					m[e]=a.sec+1;
					q.push(T(e,a.sec+1));
				}
				for(int k=i;k<=j;k++)tmp[k]=v[k];
			}
		}
	}
}
int main()
{
	scanf("%d",&N);
	for(int i=0;i<N;i++)scanf("%d",&A[i]);
	vector<int> vec;
	for(int i=0;i<N;i++)vec.pb(A[i]);
	bfs(0,encode(vec));
	for(int i=0;i<N;i++)vec[i]=i+1;
	bfs(1,encode(vec));
	ans = N-1;
	map<ll,int>::iterator it1,it2;
	it1=ma[0].begin();it2=ma[1].begin();
	while(1)
	{
		if(it1==ma[0].end()||it2==ma[1].end())break;
		else if(it1->fi < it2->fi)it1++;
		else if(it1->fi > it2->fi)it2++;
		else
		{
			ans = min(ans,it1->sec+it2->sec);
			it1++;
			it2++;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 40476
N = int(input())
slist = list(map(int, input().split()))
ans = 0
for C in range(1,N-1,1):
    score = 0
    for k in range((N-1)//C):
        if (k-1)*C == N-1-k*C: #一つ前に選んだところ
            break
        if 2*k*C == N-1: #今から選ぶ二つが同じところ
            break
        score += slist[k*C]+slist[N-1-k*C]
        ans = max(ans, score)
print(ans)

Measured memory_bytes: 14332
<?php

while (true) {
    fscanf(STDIN, '%s', $nums);
    if (feof(STDIN)) {
        break;
    }
    $nums = str_split($nums);
    for ($i = 0; $i < 13; $i++) {
        $nums[$i] = (int) $nums[$i];
    }
    $result = array();
    for ($i = 1; $i <= 9; $i++) {
        $a = $nums;
        $a[] = $i;
        sort($a);
        $hash = array();
        foreach ($a as $v) {
            if (!isset($hash[$v])) {
                $hash[$v] = 0;
            }
            $hash[$v]++;
        }
        if ($hash[$i] > 4) {
            continue;
        }
        $stack = array(array($hash, false));
        while (count($stack)) {
            $node = array_pop($stack);
            $h = update($node[0]);
            $f = $node[1];
            if (count($h) === 0) {
                $result[] = $i;
                break;
            }
            $keys = array_keys($h);
            if (!$f && $h[$keys[0]] >= 2) {
                $t = $h;
                $t[$keys[0]] -= 2;
                $stack[] = array($t, true);
            }
            if ($h[$keys[0]] >= 3) {
                $t = $h;
                $t[$keys[0]] -= 3;
                $stack[] = array($t, $f);
            }
            if (isset($keys[2]) && $keys[2] - $keys[0] === 2) {
                for ($j = 0; $j < 3; $j++) {
                    $h[$keys[$j]]--;
                }
                $stack[] = array($h, $f);
            }
        }
    }
    echo count($result) > 0 ? implode(' ', $result) : 0;
    echo PHP_EOL;
}

function update($nums) {
    foreach ($nums as $k => $v) {
        if ($v === 0) {
            unset($nums[$k]);
        }
    }
    return $nums;
}

Measured memory_bytes: 6760
moji = str(input())
N = len(moji)
FM = moji[:N//2]
if N % 2 == 0:
    LM = moji[-1:(N//2)-1:-1]
else:
    LM = moji[-1:(N//2):-1]
ct = 0

for i in range(N//2):
    if FM[i] != LM[i]:
        ct += 1

print(ct)
    


Measured memory_bytes: 9052
#![allow(unused)]

use std::cmp;
use std::io::{self, BufRead};
use std::iter;

macro_rules! destruct_ {
  ($e: expr, ()) => (
    assert!($e.next().is_none())
  );
  ($e: expr, ($arg: ident, $( $args: ident, )*)) => (
    $arg = $e.next().unwrap();
    destruct_!($e, ($($args,)*))
  );
  ($e: expr, ($arg: ident $(, $args: ident )*)) => (
    $arg = $e.next().unwrap();
    destruct_!($e, ($($args,)*))
  );
}

macro_rules! into {
  ($e: expr, $($name: ident)*) => {
    let mut iter = $e.into_iter();
    destruct_!(iter, ($($name)*));
  }
}

macro_rules! get {
  ($i: ident) => (
    let stdin = io::stdin();
    let mut $i = Vec::new();
    for line in stdin.lock().lines() {
      $i.push(
        line
          .unwrap()
          .split_whitespace()
          .map(|a| a.parse().unwrap())
          .collect()
      );
    }
  )
}

macro_rules! p {
  ($a: expr) => (
    println!("{:?}", $a);
  )
}

fn main() {
  let mut args: Vec<Vec<String>>;
  let mut rgb: Vec<String>;
  get!(args);
  into!(args, rgb);
  let mut d = String::new();
  d.push_str(&rgb[0].clone());
  d.push_str(&rgb[1].clone());
  d.push_str(&rgb[2].clone());

  let n: i32 = d.parse().unwrap();
  if n % 4 == 0 {
    println!("YES");
  } else {
    println!("NO");
  }
}


Measured memory_bytes: 4352
n = int(input())
c = input().split();d = c[:]
for i in range(n-1):
    for j in  range(n-i-1):
        if c[j][1] > c[j+1][1]:c[j:j+2]=c[j+1],c[j]
    m = i
    for j in range(i,n):
        if d[m][1]>d[j][1]:m=j
    d[i],d[m]=d[m],d[i]
print(*c);print("Stable")
print(*d);print(["Not s","S"][c==d]+"table")



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

// infty
#define ULLINF (ULLONG_MAX)
#define LLINF  (LLONG_MAX)
#define IINF   (INT_MAX)
#define INF    (1<<29)

// math
#define Sq(x) ((x)*(x))

// container utility
#define ALL(x) (x).begin(), (x).end()
#define MP make_pair
#define PB push_back
#define EACH(it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();it++)

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

// typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef vector<VI> VVI;

typedef long long ll;

// pair util
#define FST first
#define SND second

// range validator
#define CK(n,a,b) (a<=n && n<b)

// conversion
template<class T> inline string toStr(T a) { ostringstream oss_; oss_ << a; return oss_.str(); }
inline int toInt(string s) { return atoi(s.c_str()); }

// prime
bool isPrime(int a) { for(int i=2; i*i <=a; i++) if(a%i == 0) return false; return true; }

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

//////////////////////////////////////////////////////////////


double c(double a, double b) {
  return a*60+b;
}

int main() {
  
  double a, b;
  while(cin >> a >> b) {
    string res = "NA";
    if(a < c(1,10) && b < c(2,28)) res = "E";
    if(a < c(0,55) && b < c(1,56)) res = "D";
    if(a < c(0,50) && b < c(1,45)) res = "C";
    if(a < c(0,43) && b < c(1,29)) res = "B";
    if(a < c(0,40) && b < c(1,23)) res = "A";
    if(a < 37.5 && b < c(1,17)) res = "AA";
    if(a < 35.5 && b < c(1,11)) res = "AAA";

    cout << res << endl;
  }
  
  return 0;
}

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

int main() {
  int n,k,ans=0,a;
  cin >> n >> k;
  vector<int> v(n+1,0);
  r(i,n){
    cin >> a;  v[a]++;
  }
  sort(v.begin(),v.end());
  ans=accumulate(v.begin(),v.begin()+n+1-k,0);
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<ll>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  int n,m;
  cin >> n >> m;
  vector<set<pair<int,int>>> k(n);
  int aa,bb,cc;
  set<pair<pair<int,int>,int>> s;
  rep(i,m){
    int a,b,c;
    cin >> a >> b >> c;
    a--;
    b--;
    k[a].insert(make_pair(b,c));
    k[b].insert(make_pair(a,-1*c));
    aa=a;
    bb=b;
    cc=c;
    s.insert(make_pair(make_pair(a,b),c));
  }
  int y=2000000000;
  vector<int> dist(n,y);
  while(s.size()!=0){
    pair<pair<int,int>,int> x=*s.begin();
    s.erase(x);
    aa=x.first.first;
    bb=x.first.second;
    cc=x.second;
    dist[aa]=0;
    queue<pair<pair<int,int>,int>> q;
    q.push(make_pair(make_pair(aa,bb),cc));
    k[aa].erase(make_pair(bb,cc));
    k[bb].erase(make_pair(aa,-1*cc));
    //s.erase(make_pair(make_pair(aa,bb),cc));
    while(q.size()!=0){
      pair<pair<int,int>,int> z=q.front();
      q.pop();
      int a=z.first.first,b=z.first.second,c=z.second;
      if(dist[b]!=y){
        if(dist[b]-dist[a]!=c){
          //cout << dist[0] << dist[1] << dist[2] << endl;
          //cout << b << a << c << dist[b] << dist[a] << endl;
          cout << "No" << endl;
          return 0;
        }
      }
      else dist[b]=dist[a]+c;
      for(pair<int,int> e: k[a]){
        int bbb=e.first,ccc=e.second;
        if(s.count(make_pair(make_pair(a,bbb),ccc)))s.erase(make_pair(make_pair(a,bbb),ccc));
        else s.erase(make_pair(make_pair(bbb,a),-1*ccc));
        k[bbb].erase(make_pair(a,-1*ccc));
        q.push(make_pair(make_pair(a,bbb),ccc));
      }
      k[a].clear();
      for(pair<int,int> e: k[b]){
        int aaa=e.first,ccc=e.second;
        if(s.count(make_pair(make_pair(b,aaa),ccc)))s.erase(make_pair(make_pair(b,aaa),ccc));
        else s.erase(make_pair(make_pair(aaa,b),-1*ccc));
        k[aaa].erase(make_pair(b,-1*ccc));
        q.push(make_pair(make_pair(b,aaa),ccc));
      }
      k[b].clear();
      
    }
  }
  cout << "Yes" << endl;
}   


Measured memory_bytes: 37888
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
using namespace std;
vector<int> Dist,Clouds;
int dx[8]={1,1,1,0,0,-1,-1,-1},dy[8]={-1,0,1,-1,1,-1,0,1};

int main(){
	int ans=0,b;
	for(int i=0;i<5;i++){
		cin>>b;
		if(b<40)ans+=40;
		else ans+=b;
	}
	cout<<ans/5<<endl;
}

Measured memory_bytes: 1160
import math
N,D = map(int,input().split())
X = [list(map(int,input().split())) for i in range(N)]

ans = 0
for i in range(N):
    if math.sqrt((X[i][0])**2+(X[i][1])**2) <= D:
        ans += 1
    
print(ans)

Measured memory_bytes: 45464
const int LG = 21;
const int FN = 400005;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long INFLL = 1e18;

#include <bits/stdc++.h>

using namespace std;

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

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define pb push_back
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

int cx[4] = {-1, 0, 1, 0};
int cy[4] = {0, -1, 0, 1};
string Ans[2] = {"No", "Yes"};
string ANS[2] = {"NO", "YES"};

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll rev(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(FN);
    __ufact.resize(FN);
    __rev.resize(FN);
    __rev[1] = 1;
    for (int i = 2; i < FN; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < FN; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (k < 0 || k > n) return 0;
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

int Root(int x, vector<int> &root)
{
    if (x == root[x]) return x;
    return root[x] = Root(root[x], root);
}

void Merge(int v, int u, vector<int> &root, vector<int> &sz)
{
    v = Root(v, root), u = Root(u, root);
    if (v == u) return;
    if (sz[v] < sz[u])
    {
        sz[u] += sz[v];
        root[v] = u;
    }
    else
    {
        sz[v] += sz[u];
        root[u] = v;
    }
}

int ok(int x, int n)
{
    return 0 <= x && x < n;
}

void bfs(int v, vi &dist, vector<vi> &graph)
{
    fill(all(dist), -1);
    dist[v] = 0;
    vi q = {v};
    for (int i = 0; i < q.size(); i++)
    {
        for (auto u : graph[q[i]])
        {
            if (dist[u] == -1)
            {
                dist[u] = dist[q[i]] + 1;
                q.push_back(u);
            }
        }
    }
}


signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    char c;
    cin >> c;
    cout << (char)(c + 1);
}

/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.
*/


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int n,m,ans;
int main()
{
	scanf("%d %d",&n,&m);
	ans=n-m;
	if(ans<0)ans=0;
	printf("%d\n",ans);
	return 0;
}

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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;



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

	int n;cin>>n;

	vector<int> p(n);

	for(int i=0; i<n; i++){
		cin>>p[i];
	}

	int cnt=0;
	for(int i=1; i<n-1; i++){
		if(p[i-1] <p[i] && p[i] <p[i+1])cnt++;
		if(p[i-1] >p[i] && p[i] >p[i+1])cnt++;
	}

	writeln(cnt);


}




Measured memory_bytes: 256
import io.StdIn.{readInt, readLine}
object Main extends App {
  val n = readInt
  val ls = readLine.split(" ").map(_.toInt)

  def different(i1: Int, i2: Int, i3: Int): Boolean = i1 != i2 && i2 != i3 && i3 != i1
  def makeable(i1: Int, i2: Int, i3: Int): Boolean = {
    val sorted = Seq(i1, i2, i3).sorted
    sorted(2) < sorted(0) + sorted(1)
  }

  val count = for (i <- 0 until n-2; j <- i until n-1; k <- j until n) yield {
    val li = ls(i)
    val lj = ls(j)
    val lk = ls(k)
    if (different(li, lj, lk) && makeable(li, lj, lk)) 1
    else 0
  }

  val result = count.sum
  println(result)
}


Measured memory_bytes: 58300
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<par<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int x,y;
    cin>>x>>y;
    cout<<x+y/2<<endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.Queue;

public class Main implements Runnable{

	public static void main(String[] args) {
		new Thread(null,new Main(), "" ,Runtime.getRuntime().maxMemory()).start();
	}
	
	int gcd(int a,int b) {
		return a==0?b:gcd(b%a,a);
	}
	
	public void run() {
		FastScanner sc=new FastScanner();
		int n=sc.nextInt();
		int[] a=new int[n];
		for(int i=0;i<n;++i)a[i]=sc.nextInt();
		Arrays.sort(a);
		System.out.println(a[n-1]-a[0]);
	}
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
}

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

Measured memory_bytes: 23252
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

ll gcd(ll a,ll b){
  if(a%b == 0) return b;
  else return gcd(b,a%b);
}

int main(){
  int n;
  cin >> n;
  int x[n];
  int g = 0;
  for(int i=0;i<n;i++){
    cin >> x[i];
    g += x[i];
  }
  g /= n;
  ll ans = 100000000000000;
  ll temp = 0;
  for(int i=g;i<g+2;i++){
    temp = 0;
    for(int j=0;j<n;j++){
      temp += pow((x[j]-i),2);
    }
    ans = min(ans,temp);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <climits>
 
using namespace std;
 
double EPS = 1e-10;
 
int main() {
    double ax, ay, bx, by, cx, cy, dx, dy;
 
    while( cin >> ax >> ay >> bx >> by >> cx >> cy >> dx >> dy ) {
        bx -= ax; by -= ay;
        dx -= cx; dy -= cy;
 
        if( abs((bx * dx) + (by * dy)) < EPS ) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
}

Measured memory_bytes: 3044