akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(void)
{
	int k1,k2,h1,h2,a,b,c,d,w,x,y,v;
	scanf("%d %d",&h1,&h2);
	scanf("%d %d",&k1,&k2);
	scanf("%d %d %d %d",&a,&b,&c,&d);
	w=0; x=0;
	w=(h1*a)+(h2*b);
	x=(k1*a)+(k2*b);
	y=((h1/10)*c)+((h2/20)*d);
	v=((k1/10)*c)+((k2/20)*d);
	w=w+y;
	x=x+v;
	if(w<x){
		printf("kenjiro\n");
	}
	else if(w>x){
		printf("hiroshi\n");
	}
	else{
		printf("even\n");
	}
	return 0;
}


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

long long int A[200005],B[200005],P[200005];

int main()
{
	int N;
	scanf("%d",&N);
	
	int i;
	
	for (i=0;i<N;i++)
	scanf("%d",&P[i]);
	
	for (i=0;i<N;i++)
	{
		A[i]=(long long)(i)*N;
		B[i]=(long long)(N-1-i)*N;
	}
	
	for (i=1;i<N;i++)
	{
		A[P[i]-1]+=i;
	}
	
	for (i=0;i<N;i++)
	printf("%lld ",A[i]+1);
	printf("\n");
	
	for (i=0;i<N;i++)
	printf("%lld ",B[i]+1);
	
}

Measured memory_bytes: 1152
#include<stdio.h>
int main(void){
	int h = 1, w = 1, countah, countaw, counta=0;
	while (h != 0 && w != 0){


		scanf("%d", &h);
		scanf("%d", &w);

		counta = 0;
		for (countah = 1; countah <= h; countah++){

			for (countaw = 1; countaw <= w; countaw++){
				counta=counta++;
				if (counta % 2 != 0){
					printf("#");
				}

				if(counta%2==0){
					printf(".");
				}


			}
			if (w % 2 == 0){
				counta = counta++;
			}
		
				printf("\n");
			


		}
		if (h != 0 && w != 0){
			printf("\n");
		}
		
	}
	
	return 0;
}

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

int main(){
    int n, t;
    cin >> n >> t;
    int a[n];
    int idmin[n], idmax[n];


    rep(i, n){
        cin >> a[i];
    }

    idmin[0] = 0;
    idmax[n-1] = n-1;
    
    for (int i = 1; i < n; i++){
        if(a[idmin[i-1]] > a[i]){
            idmin[i] = i;
        }else{
            idmin[i] = idmin[i-1];
        }
    }

    for (int i = n-2; i >= 0; i--){
        if(a[idmax[i+1]] < a[i]){
            idmax[i] = i;
        }
        else{
            idmax[i] = idmax[i+1];
        }
    }
    
    int m = 0;
    rep(i, n){
        m = max(m, a[idmax[i]]-a[idmin[i]]);
    } 
    
    set<int> s;
    rep(i, n){
        if(a[idmax[i]] - a[idmin[i]] == m){
            s.insert(idmin[i]);
        }
    }

    cout << s.size() << endl;
    return 0;
}

Measured memory_bytes: 3712
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		String[][] in = new String[Integer.valueOf(r.readLine())][];
		
		for(int i=0; i<in.length; i++){
			in[i] = r.readLine().split(" ");
		}
		
		// START //
		int[] pts = new int[in.length];
		
		for(int t2=0; t2<in[0].length; t2++){
			for(int t1=0; t1<in.length; t1++){
				for(int t1c=0; t1c<in.length; t1c++){
					if(t1 != t1c && in[t1][t2].equals(in[t1c][t2])){
						break;
					}else{
						if(t1c+1 == in.length){
							pts[t1] += Integer.valueOf(in[t1][t2]);
						}
					}
				}
			}
		}
		
		for(int pt : pts){
			System.out.println(pt);
		}
		// E N D //
	}
}

Measured memory_bytes: 20120
#include <stdio.h>

int V[10005];

int main()
{

    int N, cont=0;

    scanf("%d", &N);

    // int *V = (int *) malloc(sizeof(int)*N);

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

        while (V[i] % 2 == 0)
        {
            cont++;
            V[i] /= 2;
        }
    }

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

    return 0;
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

ll N, x;
ll a[111111];

void print() {
   rep (i, N) {
      printf(" %2d", a[i]);
   }
   puts("");
}

int main() {
   cin >> N >> x;
   rep (i, N) cin >> a[i];

   ll ans = 0;
   repp (i, 1, N) {
      ll sum = a[i-1] + a[i];
      if (sum > x) {
         if ((sum-x) <= a[i]) {
            // debug("up");
            ll y = sum - x;
            ans += y;
            a[i] -= y;
         } else {
            // debug("down");
            ans += a[i];
            // debug(ans);
            sum -= a[i];
            a[i] = 0;
            // debug2(sum, x)
            ll y = sum - x;
            ans += y;
            // debug(ans);
         }
      }
   }
   cout << ans << endl;
   // print();

   return 0;
}

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

public class Main {

	static Scanner in = new Scanner(System.in);

	public static void main(String[] args) {
		int N = in.nextInt();
		int[] L = new int[N];
		for (int i = 0; i < N; i++) {
			L[i] = in.nextInt();
		}
		int max = Arrays.stream(L).max().getAsInt();
		int sum = Arrays.stream(L).sum();
		String ans = max < (sum - max) ? "Yes" : "No";
		System.out.println(ans);
	}
}


Measured memory_bytes: 29012
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<limits.h>

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define lld long long int

typedef struct node{
    lld a, b;
}node;

int cmp(const void* a, const void* b){
    lld x = ((node*)a)->a, y = ((node*)b)->a;
    if(x > y){
        return 1;
    }
    if(x < y){
        return -1;
    }
    return 0;
}

int main(){
    int n, m;
    scanf("%d %d", &n, &m);
    node x[n];
    rep(i, 0, n){
        scanf("%lld %lld", &x[i].a, &x[i].b);
    }
    qsort(x, n, sizeof(node), cmp);
    lld ans = 0;
    while(m > 0){
        rep(i, 0, n){
            if(m >= x[i].b){
                m -= x[i].b;
                ans += x[i].b * x[i].a;
            }else{
                ans += x[i].a * m;
                m = 0;
                break;
            }
            if(m == 0){
                break;
            }
        }
    }
    printf("%lld", ans);

    return 0;
}

Measured memory_bytes: 3324
#include <stdio.h>
int main(void)
{
    int A,B,C,a;
    scanf("%d %d %d",&A,&B,&C);
    a=A;
    A=B;
    B=a;
    a=A;
    A=C;
    C=a;
    printf("%d %d %d",A,B,C);

    return 0;

}


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

public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		Integer[] array = new Integer[3];
		for (int i = 0; i < 3; i++) {
			array[i] = new Integer(scan.nextInt());
		}
		Arrays.sort(array);
		System.out.printf("%d %d %d\n", array[0], array[1], array[2]);
	}
	public static void main(String[] args) {
		new Main().run();
	}
}

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

using namespace std;
const int maxn = 1e5+10;
int n,m;
int h[maxn],a,b;
vector<int> con[maxn];
int main(){
	int res = 0;
	cin >> n >> m;
	for(int i=1;i<=n;i++){
		scanf("%d",&h[i]);
	}
	for(int i=1;i<=m;i++){
		scanf("%d%d",&a,&b);
		con[a].push_back(b);
		con[b].push_back(a);
	}
	for(int i=1;i<=n;i++){
		int f = 0;
		if(con[i].size()){
			for(int j=0;j<con[i].size();j++){
				if(h[i]<=h[con[i][j]]){
					f = 1; break;
				}
			}
			if(!f) res++;
		}
		else res++;
	}
	cout << res << endl; 
	return 0;
} 

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

#define ll long long

signed main()
{
  int n;
  cin >> n ;
  ll ans=0;
  for(int i = 1; i<=n; ++i){
    if(!(i%3==0)&&!(i%5==0)){
      ans += i;
    }
  }
  cout << ans;
}

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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(M), B(M);
    vector<vector<bool>> G(N, vector<bool>(N));
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        A[i] = a; B[i] = b;
        G[a][b] = G[b][a] = true;
    }

    int res = 0;
    for (int i = 0; i < M; i++) {
        G[A[i]][B[i]] = G[B[i]][A[i]] = false;

        queue<int> que;
        vector<bool> visited(N, false);
        que.push(0);
        visited[0] = true;
        while (!que.empty()) {
            int u = que.front(); que.pop();
            for (int v = 0; v < N; v++) {
                if (G[u][v] && !visited[v]) {
                    que.push(v);
                    visited[v] = true;
                }
            }
        }

        for (int j = 0; j < N; j++) {
            if (!visited[j]) {
                res++;
                break;
            }
        }
        G[A[i]][B[i]] = G[B[i]][A[i]] = true;
    }

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

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

int main() {
    string str;
    stack<int> s;
    
    while (cin >> str) {
        if (str == "+" || str == "-" || str == "*" || str == "/") {
            int y = s.top();
            s.pop();
            
            int x = s.top();
            s.pop();
            
            int num;
            if (str == "+") {
                num = x + y;
            } else if (str == "-") {
                num = x - y;
            } else if (str == "*") {
                num = x * y;
            } else if (str == "/") {
                num = x / y;
            }
            
            s.push(num);
            
        } else {
            int n = atoi(str.c_str());
            s.push(n);
        }
    }
    
    cout << s.top() << endl;
}


Measured memory_bytes: 3176
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main() {
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int l, r;
		cin >> l >> r;
		ans += r - l +1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

static const int MOD = 100000;
using ll = int64_t;
using namespace std;

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

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

template<class T> void chmin(T &a, const T &b){ a = (a < b ? a : b); }
template<class T> void chmax(T &a, const T &b){ a = (a > b ? a : b); }

int main() {
    int w, h;
    while(cin >> w >> h, w|h){
        auto dp = make_v(h+1, w+1, 2, 2, 0);
        for (int i = 0; i <= h; ++i) dp[i][0][0][0] = 1;
        for (int i = 0; i <= w; ++i) dp[0][i][1][0] = 1;
        for (int i = 1; i < h; ++i) {
            for (int j = 1; j < w; ++j) {
                (dp[i][j][0][0] += dp[i-1][j][0][0] + dp[i-1][j][0][1]) %= MOD;
                (dp[i][j][0][1] += dp[i-1][j][1][0]) %= MOD;
                (dp[i][j][1][0] += dp[i][j-1][1][0] + dp[i][j-1][1][1]) %= MOD;
                (dp[i][j][1][1] += dp[i][j-1][0][0]) %= MOD;
            }
        }
        int ans = 0;
        for (int i = 0; i < 2; ++i) {
            for (int j = 0; j < 2; ++j) {
                (ans += dp[h-1][w-1][i][j]) %= MOD;
            }
        }
        cout << ans << "\n";
    }
    
    return 0;
}



Measured memory_bytes: 4532
#include<bits/stdc++.h>
#define LLI long long int
#define ULTRA 2134567890
#define de(x) if(x!=0 && MODE==x)
#define MODE 1
using namespace std;

int a[10007];
int b[10007];
int c[10007];

int main()
{
    int i,j;
    int H,N;

    scanf("%d %d", &H, &N);
    for( i=0; i<N; i++)
    {
        scanf("%d %d", &a[i], &b[i]);
    }

    for( i=0; i<=H; i++)
    {
        c[i] = ULTRA;
    }
    c[H] = 0;
    for( i=0; i<N; i++)
    {
        // printf(">>> %d\n", i);
        for( j = H; j >= 0; j--)
        {
            c[ max( j-a[i], 0) ] = min( c[j] + b[i], c[ max( j-a[i], 0)] );
        }
    }

    printf("%d\n", c[0]);

    return 0;
}

//
//          ___ ___  __________  __________
//         /////\  \/\   ______\/\\\\\\\\\\\  Code by ~Ice Tea~ of
//        //// \ \  \ \  \_____/\ \\\\_____/      New Empire of CHSH ...
//       ////   \ \  \ \  \      \ \\\\\\\\\\\
//      ////__   \ \  \ \  \      \ \\\\_____/
//     ///////\   \ \  \ \  \______\ \\\\_______   ________
//    ////____/    \ \__\ \___   ___\ \\\\\\\\\\\ _\  ___  \_
//   /__/           \/__/\/__/\  \__/\ \\\\_____//\  .\_/\_  \
//                           \ \  \   \ \\\\\\\\\\\\  \_\/_\  \
// ... with the AC Power of   \ \  \   \ \\\\_____/ \   _____  \
//   The Great Tsundere Doggy. \ \  \   \ \\\\     \ \  \  \ \  \
//                              \ \__\   \ \\\\\\\\\\ \__\  \ \__\
//                               \/__/    \/________/\/__/   \/__/
//


Measured memory_bytes: 256
function main(arg) {
  var inputs = arg.trim().split(' ');
  var A = inputs[0];
  var B = inputs[1];

  var isInt = Number.isInteger(Math.sqrt(parseInt(A + B)));
  console.log(isInt ? 'Yes' : 'No');
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <tuple>

#include <set>
#include <unordered_map>
#include <stack>
#include <map>

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
using ll = long long;
template<class T>bool chmaxj(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
void YesNo(bool y) { cout << (y ? "Yes" : "No") << endl; } //true==yes


#define INF 21474836

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



int main() {

	int A, B, K;
	cin >> K >> A >> B;

	bool ex = false;
	for (int i = A; i <= B; i++) {
		if (i%K == 0)ex = true;
	}
	
	if (ex)cout << "OK" << endl;
	else cout << "NG" << endl;

}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>

using namespace std;

long long dp[100000+10];

int main() {
  long long N;
  cin >> N;
  vector<long long> h(N);
  for (int i = 0; i < N; i++) {
    cin >> h[i];
  }
  dp[0] = 0;
  dp[1] = abs(h[1] - h[0]);
  for (int i = 2; i < N; i++) {
    dp[i] = min(abs(h[i]-h[i-1])+dp[i-1], abs(h[i]-h[i-2])+dp[i-2]);
  }
  cout << dp[N-1] << endl;
  return 0;
}

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

ll l[5000];

int main(){
	ll n;
	cin>>n;
	for(int i=0;i<n;i++)cin>>l[i];
	sort(l,l+n);
	l[n]=1e9;
	ll ans=0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(l[j+1]>=l[i]+l[j])continue;
			ll ok=j+1,ng=n;
			while(ng-ok>1){
				ll mid=(ok+ng)/2;
				if(l[mid]>=l[i]+l[j])ng=mid;
				else ok=mid;
			}
			ans+=ok-j;
		}
	}
	cout<<ans;
	return 0;
}


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

double mysqrt(double x){
	double l = 0 , r = x ;
	for(int i = 0 ; i < 64 ; i++){
		double m = (l+r)/2.0;
		if(m * m < x){
			l = m;
		}else{
			r = m;
		}
	}
	return l;
}


int main(){
	int p,n;
	while(cin >> p >> n , n){
		double sp = mysqrt(p);
		int a1 = 0 , b1 = 1 , a2 = p , b2 = 1;
		
		for(int i = 1 ; i <= n ; i++){
			int o = (int)(sp * i);
			for(int j = -2 ; j <= 2 ; j++){
				int w = o + j;
				if(__gcd(i,w) == 1 && w >= 0 && w <= n){
					if( (double)w/i < sp &&  a1*i < w*b1){
						a1 = w;
						b1 = i;
					}
					if((double)w/i > sp && a2*i > w*b2){
						a2 = w;
						b2 = i;
					}
				}
			}
		}

		cout << a2<< "/" << b2 << " " << a1 << "/" << b1 << endl;
	}
}

Measured memory_bytes: 864
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef pair<int, int>P;
/**********************************************/
int par[100005] = { 0 };
int r[100005] = { 0 };
struct edge {
	int from, to, cost;
};
int v, e;
edge es[100005];
int n, m, k;
int club[100005] = { 0 };
void init(int n) {
	for (int i = 0; i < n; i++) {
		par[i] = i;
		r[i] = 0;
	}
}

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

void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y) return;
	if (r[x] < r[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
	}
	if (r[x] == r[y]) r[x]++;
}

bool same(int x, int y) {
	if (find(x) == find(y)) return true;
	else return false;
}

bool comp(edge esx, edge esy) {
	return esx.cost < esy.cost;
}

int kruskal() {
	sort(es, es + e, comp);
	int res = 0;
	init(v + 5);
	for (int i = 0; i < e; i++) {
		if (!same(es[i].from, es[i].to)) {
			res += es[i].cost;
			unite(es[i].from, es[i].to);
		}
	}
	return res;
}

int main() {
	cin >> n >> m >> k;
	init(n + 5);
	//int pc = 0, px = 0;
	for (int i = 0; i < k; i++) {
		int num, a, b;
		cin >> num >> a >> b;
		if (num == 1) {
			int fa = find(a);
			int fb = find(b);
			if (club[fa] == 0 || club[fb] == 0 || club[fa] == club[fb]) {
				unite(a, b);
				club[fa] = max(club[fa], club[fb]);
			}
			else {
				cout << i + 1 << endl;
				return 0;
			}
		}
		else {
			int fa = find(a);
			if (club[fa] == 0) {
				club[fa] = b;
			}
			else if (club[fa] != b) {
				cout << i + 1 << endl;
				return 0;
			}
		}
	}
	cout << "0" << endl;
}


Measured memory_bytes: 4288
class MaxHeap:
    def __init__(self):
        self.__pq = []
        self.__length = 0

    def __str__(self):
        return self.__pq.__str__()
    
    def length(self):
        return self.__length
    
    def push(self,item):
        self.__pq.append(item)
        self.__length += 1
        i = self.__length - 1
        while i > 0:
            p = (i-1)//2
            tmp = self.__pq[p]
            if tmp >= item:
                break
            self.__pq[p] = item
            self.__pq[i] = tmp
            i = p
    
    def popMax(self):
        if self.__length == 0:
            return None
        ret = self.__pq[0]
        if self.__length == 1:
            self.__length -= 1
            return self.__pq.pop(0)
        self.__pq[0] = self.__pq.pop(self.__length-1)
        self.__length -= 1
        i = 0
        while 2*i+1 < self.__length:
            larger = 2*i+1
            if 2*i+2 < self.__length:
                if self.__pq[2*i+2] > self.__pq[larger]:
                    larger = 2*i+2
            tmp = self.__pq[larger]
            if tmp <= self.__pq[i]:
                break
            self.__pq[larger] = self.__pq[i]
            self.__pq[i] = tmp
            i = larger
        return ret
    
    def isempty(self):
        return self.__length == 0
from collections import defaultdict
X,Y,Z,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

PQ = MaxHeap()
used = defaultdict(bool)
PQ.push((A[0]+B[0]+C[0],0,0,0))
cnt = 0
arr = []
while cnt < K:
    s,i,j,k = PQ.popMax()
    if not used[(i,j,k)]:
        arr.append(s)
        used[(i,j,k)] = True
        if i+1 < X and not used[(i+1,j,k)]:
            PQ.push((A[i+1]+B[j]+C[k], i+1,j,k))
        if j+1 < Y and not used[(i,j+1,k)]:
            PQ.push((A[i]+B[j+1]+C[k], i,j+1,k))
        if k+1 < Z and not used[(i,j,k+1)]:
            PQ.push((A[i]+B[j]+C[k+1], i,j,k+1))
        cnt += 1
for i in range(K):
    print(arr[i])

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

typedef long long ll;

int main() {
    ll N;
    ll ans = 0;
    cin >> N;
    vector<ll>A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    ll pre = 0;
    for (int i = 0; i < N; i++) {
        if (A[i] == 0) {
            pre = 0;
            continue;
        }
        if (pre > 0) {
            ans += (A[i]+pre)/2;
            if ((A[i]+pre) % 2 == 0) {
                pre = 0;
            } else {
                pre = 1;
            }
        } else {
            ans += (A[i]/2);
            if (A[i] % 2 == 0) {
                pre = 0;
            } else {
                pre = 1;
            }
        }
    }
    cout << ans << endl;
}


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

int check_triangle(int a ,int b, int c)
{
	if(a<b+c && b<c+a && c<a+b)
    {
    	return 1;
    }
  	else
    {
    	return 0;
    }
  

}

int main()
{
	int N;
 	cin>>N;
  	int A[N];
  	int i,check,j,k,counter=0;
  	for(i=0;i<N;i++)
    {
    	cin>>A[i];
    }
    
    sort(A,A+N);
    
  	for(i=0;i<N-2;i++)
    {
    	for(j=i+1;j<N-1;j++)
        {
        	for(k=j+1;k<N;k++)
            {
            	
              	if(A[k]<A[j]+A[i])
                {
                	counter++;
                }
            }
        }
    }
  	
  	cout<<counter;

	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

int vstack[200];

int main(){
	int si = 0;
	char op = '\0';
	int v;
	char t = '\0';
	while( scanf("%c", &t) != EOF ){
		if( t == '\n' ){ break; }
		if( t == ' ' ){ continue; }
		if( '0' <= t && t <= '9' ){
			v = t - '0';
			while( scanf("%c", &t) != EOF ){
				if( t == ' ' ){
					vstack[si] = v;
					si++;
					break;
				}
				v = 10 * v + t - '0';
			}
		}
		if( t == '+' ){
			vstack[si-2] = vstack[si-2] + vstack[si-1];
			si--;
		}
		if( t == '-' ){
			vstack[si-2] = vstack[si-2] - vstack[si-1];
			si--;
		}
		if( t == '*' ){
			vstack[si-2] = vstack[si-2] * vstack[si-1];
			si--;
		}
	}
	printf("%d\n", vstack[0]);
	return 0;
}

Measured memory_bytes: 536
import numpy as np
def main():
 
	buf = input().split()
	n = int(buf[0])
	k = int(buf[1])
	l = np.zeros(n)
	for i in range(n):
		l[i] = int(input())
 
	l = np.sort(l)
	min = -1
	for i in range(n-k+1):
		bufmin = l[i+k-1] - l[i]
		if (min == -1):
			min = bufmin
		elif (bufmin < min):
			min = bufmin
 
	print(int(min))
 
main()

Measured memory_bytes: 18984
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(const T a, const T b){return a>=0 ? a/b : (a+1)/b-1;}
template<class T> T div_ceil(const T a, const T b){return a>=0 ? (a-1)/b+1 : a/b;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 100010;

int main(){
    int b;
    while(scanf("%d", &b) && b){
        b *= 2;
        int a, len = 0;
        for(int s=1; s*s<=b; ++s)if(b%s == 0){
            int t = b/s;
            if((s+t-1)%2 == 1 || -s+t-1 < 0 || (-s+t-1)%2 == 1) continue;
            int n = (s+t-1)/2, k = (-s+t-1)/2;
            if(chmax(len, n-k)) a = k+1;
        }
        printf("%d %d\n", a, len);
    }
}


Measured memory_bytes: 3228
#include<bits/stdc++.h>
using namespace std;
#define R freopen("A.in","r",stdin);
#define W freopen("A.out","w",stdout);
const int maxn = 105;
const double eps=1e-10;
const double PI = acos(-1.0);
struct Point{double x, y;int id; Point(double x=0, double y=0, int id=0):x(x),y(y),id(id) { }};
typedef Point Vector;
int dcmp(double x) {if(fabs(x) < eps) return 0; else return x < 0 ? -1 : 1;}
Vector operator + (const Vector& A, const Vector& B) { return Vector(A.x+B.x, A.y+B.y); }
Vector operator - (const Point& A, const Point& B) { return Vector(A.x-B.x, A.y-B.y); }
double Cross(const Vector& A, const Vector& B) { return A.x*B.y - A.y*B.x; }
double Dot(Vector A, Vector B) { return A.x*B.x + A.y*B.y; }
double Length(Vector A) { return sqrt(Dot(A, A)); }
double Angle(Vector A, Vector B) { return acos(Dot(A, B) / Length(A) / Length(B)); }
bool operator < (const Point& p1, const Point& p2) { return p1.x < p2.x || (p1.x == p2.x && p1.y < p2.y);}
bool operator == (const Point& p1, const Point& p2) {return p1.x == p2.x && p1.y == p2.y;}
Point read_point(int id){double x, y;scanf("%lf%lf", &x, &y);return Point(x, y, id);};
ostream& operator <<(ostream &out,const Point& p){
    out<<p.id<<"("<<p.x<<","<<p.y<<")";
    return out;
}
Point p[maxn],ch[maxn];
int ConvexHull(int n)
{
    sort(p, p+n);
    int m = 0;
    for(int i = 0; i < n; i++)
    {
        while(m > 1 && dcmp(Cross(ch[m-1]-ch[m-2], p[i]-ch[m-2])) ==-1 ) m--;//叉乘<=0得到的凸包存在三点共线
        ch[m++] = p[i];
    }
    int k = m;
    for(int i = n-2; i >= 0; i--)
    {
        while(m > k && dcmp(Cross(ch[m-1]-ch[m-2], p[i]-ch[m-2])) == -1) m--;
        ch[m++] = p[i];
    }
    if(n > 1) m--;
    return min(m,n);
}
double CHAngle(int i,int m){return Angle(ch[(i+m-1)%m]-ch[i],ch[(i+1)%m]-ch[i]);}
double ans[maxn];
int n,f;
int main()
{
    
    cin>>n;
    for(int i=0; i<n; i++)
    {
        p[i]=read_point(i);
    }
    int m=min(ConvexHull(n),n);
    for(int i=0; i<m; i++)
    {
        Point la=ch[(i+m-1)%m],ne=ch[(i+1)%m],no=ch[i];
        ans[ch[i].id]=(PI-CHAngle(i,m))/(2*PI);
    }
    for(int i=0; i<n; i++)
    {
        printf("%.20f\n",ans[i]);
    }

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
const int N=400002;
char s[N];
int n,m,c[N],a,b,i,j,k,p;
int h[N],t[N],v[N],vis[N];
void add(int a,int b){
	t[++k]=h[a];h[a]=k;v[k]=b;
	t[++k]=h[b];h[b]=k;v[k]=a;
}
void init(){
	scanf("%s",s+1);
	while(s[n+1])n++;
	for(i=1;i<=n+1;i++)
		c[i]=s[i]-s[i-1];
	for(i=1,j=n+1;i<j;i++,j--)
		add(i,j);
	scanf("%d",&m);
	while(m--){
		scanf("%d%d",&a,&b);
		add(a,b+1);
	}
}
void dfs(int i){
	vis[i]=1;
	p+=c[i];
	for(int j=h[i];j;j=t[j])
		if(!vis[v[j]])
			dfs(v[j]);
}
void work(){

	for(i=1;i<=n;i++)
		if(!vis[i]){
			p=0;
			dfs(i);
			if(p%26!=0){
				printf("NO\n");
				return;
			}
		}
	printf("YES\n");
}
int main(){
	init();
	work();
	return 0;
}

Measured memory_bytes: 7380
# ABC109B - Shiritori
n = int(input())
data = [input().rstrip() for _ in range(n)]
used = [data[0]]

for i in range(1, n):
    if data[i][0] == data[i - 1][-1] and data[i] not in used:
        used.append(data[i])
    else:
        print("No")
        exit()
        
print("Yes")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll get(ll x){
  if(x==1) return 300000;
  else if(x==2) return 200000;
  else if(x==3) return 100000;
  return 0;
}
int main(){
  ll x,y;
  cin>>x>>y;
  ll ans=0;
  if(x==1&&y==1) ans=400000;
  cout<<ans+get(x)+get(y)<<endl;
}


Measured memory_bytes: 256
/* ex5_3.c Grid Compression
    dada__              */
#include<stdio.h>

int main(void){
    int row, col, i, j;
    scanf("%d %d", &row, &col); //行と列の数の入力
    int judge_row[row], judge_col[col];
    char grid[row][col];

    //各マス目の記号の入力
    for(i=0;i<row;i++){
        for(j=0;j<col;j++){
            scanf(" %c", &grid[i][j]);
        }
    }

    //各行について，取り除くかの判定
    for(i=0;i<row;i++){
        judge_row[i] = 0;
        for(j=0;j<col;j++){
            if(grid[i][j]=='#'){
                judge_row[i]=1;
            }
        }
    }
    //各列について，取り除くかの判定
     for(j=0;j<col;j++){
        judge_col[j] = 0;
        for(i=0;i<row;i++){
            if(grid[i][j]=='#'){
                judge_col[j]=1;
            }
        }
    }

    //各判定に基づいた出力
    for(i=0;i<row;i++){
        if(judge_row[i]==1){ //行の判定が1の場合に出力
            for(j=0;j<col;j++){
                if(judge_col[j]==1){//列の判定が1の場合に出力
                printf("%c", grid[i][j]);
                }
            }
        printf("\n");
        }
    }
    return 0;
}

Measured memory_bytes: 128
import java.util.*;
public class Main {
    public static void main(String [] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int num = X/500;
        int r = X%500;
        r/=5;
        System.out.println(num*1000+r*5);
    }
}

Measured memory_bytes: 22740
N, K = map(int, input().split())
X = list(map(int, input().split()))
ans = float("inf")
for left in range(0, N-K+1):
    right = left+K
    minus = 0
    plus = 0
    if X[left] < 0:
        minus = min(minus, X[left])
    if X[right-1] > 0:
        plus = max(plus, X[right-1])
    ans = min(ans, 2*abs(minus)+plus, abs(minus)+2*plus)
 
print(ans)

Measured memory_bytes: 62576
N = int(input())
dic = dict()

for _ in range(N):
	S = str(input())
	if S[0] in ["M", "A", "R", "C", "H"]:
		if S[0] in dic:
			dic[S[0]] += 1
		else:
			dic[S[0]] = 1

ans = 0

A = list(dic.values())
for i in range(len(A) - 2):
	for j in range(i + 1, len(A) - 1):
		for k in range(j + 1, len(A)):
			ans += A[i] * A[j] * A[k]
print(ans)

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

int culc(int n, int x){
    int cou=0;
    for (int i =1; i<=n-2; i++){
        for(int j =i+1; j<=n-1; j++){
            int sum1 = i + j;
            for(int k = j+1; k<=n; k++){
                if (sum1+ k==x){
                    cou +=1;
                }
            }
        }
    }
    return cou;
    
}

int main(){
    int n,x;
    while(1){
        cin >> n >> x;
        if (n == 0 && n== 0) break;
        else cout << culc(n,x) << endl;
    }
    return 0;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e12);
const ll mod = ll(1e9) + 7;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n){
        t *= i;
        t %= mod;
    }
    return t;
}

ll power(ll a, ll b){
    a %= mod;
    if(b == 0){
        return 1;
    }
    ll ans = power(a, b / 2);
    ans = ans * ans % mod;
    if(b % 2 == 1){
        ans = ans * a % mod;
    }
    return ans;
}

ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    ll ans = 1;
    for(ll i = 0; i < b; i++) {
        ans *= (a - i);
        ans /= (i + 1);
        ans %= mod;
    }
    return ans;
}

vector<string> makenum(0);
ll n,m;

int make(string s){
    if(s.size() == n){
        makenum.push_back(s);
    }else{
        nfor(i, s[s.size() - 1], m + '0' + 1){
            string S = s + char(i);
            make(S);
        }
    }
    return 0;
}

int main(){
    ll q;
    cin >> n >> m >> q;
    vector<ll> a(q),b(q),c(q),d(q);
    rep0(i, q)cin >> a[i] >> b[i] >> c[i] >> d[i];
    make("1");
    ll ans = 0;
    rep0(i, makenum.size()){
        string check = makenum[i];
        ll cnt = 0;
        rep0(j, q){
            if(check[b[j] - 1] - check[a[j] - 1] == c[j])cnt += d[j];
        }
        ans = max(ans,cnt);
    }
    pf(ans);
    return 0;
}

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

char s[13];

int main(){
    cin >> s;
    for(int i = 0; i < 12; i++){
        cout << s[i];
        if(i == 3){
            cout << " ";
        }
    }
    cout <<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+233;

char s[maxn],t[maxn];

int main(){
	cin>>s>>t;
	int ans = maxn;
	int n1=strlen(s);
	int n2=strlen(t);
	for(int i=0;i+n2<=n1;i++){
		int sum = 0;
		for(int j=0;j<n2;j++){
			if(s[j+i]!=t[j]) sum++;
		}
		ans = min(ans,sum);
	}     
	cout<<ans<<endl;
}

Measured memory_bytes: 3596
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)n;i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)
typedef long long ll;

int par[3000003];
int ran[3000003];
void init(int n){
Rep(i,n){
par[i]=i;
ran[i]=0;
}
}
int find(int x){
if(par[x]==x){
return x;
}
else{
par[x]=find(par[x]);
return par[x];
}
}
void unite(int x,int y){
x=find(x);
y=find(y);
if(x==y) return;
if(ran[x]<ran[y]){
par[x]=y;
}
else{
par[y]=x;
if(ran[x]==ran[y]) ran[x]++;
}
}
bool same(int x,int y){
return find(x)==find(y);
}

int N,M;
int p[100002],x[100002],y[100002];


int main(){
    cin>>N>>M;
    rep(i,N) cin>>p[i];
    rep(j,M) cin>>x[j]>>y[j];
    init(N);
    rep(j,M) unite(x[j],y[j]);
    int ans=0;
    rep(i,N){
        if(same(i,p[i])){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

#define fo(i, n) for(ll i = 0; i < n; i++)
#define endl "\n"
#define of(i, n) for(ll i = n - 1; i >= 0; i--)
#define ll long long
#define vec vector<ll>
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define rep(i,j,n) for (int i = j; i <= n; ++i)
ll mod= 1e9+7;


int dx[4]={0,-1,0,1};
int dy[4]={1,0,-1,0};
int vis[600][600];
int cnt=0,k;
ll n,m;
//int a[600][600];
vector<string> v;
vector<pair<int,int> > str;
int cnt2=0;
bool check(int x,int y){
    if(x<n && x>=0 && y<m && y>=0)return 1;
    return 0;
}

void dfs(int x,int y)
{
    vis[x][y]=1;
    cnt++;
    //cout<<cnt<<" "<<x<<" "<<y<<endl;
    if(v[x][y]=='.' && cnt>cnt2-k)
    {
        //cout<<cnt<<" "<<x<<" "<<y<<endl;
        str.push_back(make_pair(x,y));
    }
    rep(i,0,3)
    {
        int xx = x+dx[i];
        int yy = y+dy[i];
        if(check(xx,yy) && vis[xx][yy]==0)
        {
            if(v[xx][yy]=='.') dfs(xx,yy);
        }
    }



}

int main()
{
    int k;
    cin>>k;
	string s;
	cin>>s;
	if(s.length()<=k) cout<<s<<endl;
	else
    {
        string st = s.substr(0,k);
        st+="...";
        cout<<st<<endl;
    }


}


Measured memory_bytes: 3576
#include<stdio.h>

int main(void)
{
  int a[5010]={};
  int tr;
  int i,j;
  int n;
  int max;

  for(scanf("%d",&n);n;scanf("%d",&n))
    {
      for(i=0;i<5010;i++)a[i]=0;
      max=0x80000000;
      for(i=1;i<=n;i++)
        {
          scanf("%d",&tr);
          a[i]=a[i-1]+tr;
        }
      for(i=0;i<n;i++)
        for(j=i+1;j<=n;j++)
          {
            tr=a[j]-a[i];
            if(max<tr)
              max=tr;
          }
      printf("%d\n",max);
    }

}

Measured memory_bytes: 2600
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var i [2]int
	if sc.Scan() {
		input := sc.Text()
		for j, v := range strings.Split(input, " ") {
			i[j], _ = strconv.Atoi(v)
		}
	}

	fmt.Printf("%d %d\n", i[0]*i[1], (i[0]+i[1])*2)
}



Measured memory_bytes: 1100
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
typedef long long ll;
using namespace std;

int r, g, b;
const int INF = 10e8;
void YetAnotherDieGame(){

	ll x;
	cin >> x;
	ll m = x % 11;
	ll res = (x / 11) * 2;
	res += (m > 6 ? 2 : (m > 0) ? 1 : 0);
	cout << res << endl;
}

int main() {
	YetAnotherDieGame();
	return 0;
}



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

int main(){
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    int x=tx-sx, y=ty-sy;

    string ans;

    for(int i=0;i<x;i++) ans.push_back('R');
    for(int i=0;i<y;i++) ans.push_back('U');
    for(int i=0;i<x;i++) ans.push_back('L');
    for(int i=0;i<=y;i++) ans.push_back('D');
    for(int i=0;i<=x;i++) ans.push_back('R');
    for(int i=0;i<=y;i++) ans.push_back('U');
    ans.push_back('L');
    ans.push_back('U');
    for(int i=0;i<=x;i++) ans.push_back('L');
    for(int i=0;i<=y;i++) ans.push_back('D');
    ans.push_back('R');

    for(int i=0;i<ans.size();i++) cout<<ans.at(i);
    cout<<endl;
}

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

signed main(){
  int N;
  cin>>N;
  vector<int> H(N);
  rep(i,N)cin>>H[i];
  int ans=0,co=0;
  rep(i,N-1){
    if(H[i]>=H[i+1]){
      co++;
      ans=max(ans,co);
    }
    if(H[i]<H[i+1])co=0;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int INF = 1001001001;
const ll LINF = 1e18;

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    T r;
    while((r=a%b)) {
        a = b; b = r;
    }
    return b;
}

int main() {   
    int N; cin >> N;
    ll a, idx = 1; vl as(N + 1, 0), rs(N + 1, 0);
    while (cin >> a) {
        as[idx] = a;
        rs[idx] = a - idx;
        idx++;
    }
    sort(rs.begin() + 1, rs.end(), greater<ll>());
    ll ret = LINF;
    ll tmp1 = 0;
    ll b1 = rs[N / 2];
    for (int i = 1; i <= N; i++) {
        tmp1 += abs(as[i] - (b1 + i));
    }
    ret = min(ret, tmp1);
    
    ll tmp2 = 0;
    ll b2 = rs[N / 2 + 1];
    for (int i = 1; i <= N; i++) {
        tmp2 += abs(as[i] - (b2 + i));
    }
    ret = min(ret, tmp2);
    
    cout << ret << endl;
    return 0;
}



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

typedef long lint;
typedef long long llint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

llint gcd(llint a, llint b) {
    if (a<b) swap(a, b);

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

llint lcm(llint a, llint b) {
    return (a*b/gcd(a, b));
}

int main(void) {
    llint n;
    cin >> n;

    vector<llint> a(n);
    for(int in=0;in<n;in++) {
        cin >> a.at(in);
    }
    
    llint ans = 0;
    for(int in=0;in<n;in++) {
        ans += a.at(in)-1;
    }

    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {

    int N, K;
    cin >> N >> K;
    int h = 0;
    int count = 0;
    rep(i,N) {
        cin >> h;
        if (h >= K) count++;
    }

    cout << count << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int dx[8]={-1,-1,-1,0,0,1,1,1},dy[8]={-1,0,1,-1,1,-1,0,1};
bool check(int n,int m,int x,int y){return x>=0&&x<n&&y>=0&&y<m;}
 
bool dp[1<<20];
int main() {
  int T,n=5,m=4;
  cin >> T;
  while(T--) {
    int d[20];
    for(int i=0; i<20; i++) cin >> d[i];
    memset(dp,0,sizeof(dp));
    dp[(1<<20)-1]=1;
    int ans=1<<29;
    for(int t=(1<<20)-1; t>=0; t--) {
      if(dp[t]) ans=min(ans,__builtin_popcount(t));
      else continue;
      P a[n][m];
      memset(a,-1,sizeof(a));
      for(int i=0,k=0; i<20; i++) {
        if(t&(1<<i)) {
          a[k/m][k%m]=P(d[i],i);
          k++;
        }
      }
      for(int i=0; i<n; i++) {
        for(int j=0; j<m; j++) {
          if(a[i][j].first==-1) break;
          for(int k=0; k<8; k++) {
            int x=i+dx[k],y=j+dy[k];
            if(!check(n,m,x,y)) continue;
            if(a[i][j].first==a[x][y].first) {
              dp[t^(1<<a[i][j].second)^(1<<a[x][y].second)]|=dp[t];
            }
          }
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 4064
#include <iostream>

#define int long long

using namespace std;

const int N = 2e5 + 10;

int32_t main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);    
    int x, y;
    cin >> x >> y;
    for (int i = 0; i <= x; ++i)
    {
        if (i * 2 + (x - i) * 4 == y)
        {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
    return 0;
}

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

int main(){
    int ans=0;
    string s;
    cin >>s;
    for(int i=0;i<s.size();i++){
        if(s[i] == 'x') ans ++;
    }
    cout <<(ans>=8 ? "NO" : "YES")<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const ll LINF = 1LL<<60;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    if (fopen("input.in", "r")) {
        freopen("input.in", "r", stdin);
        freopen("output.out", "w", stdout);
    }

    string s, t; cin >> s >> t;
    vector<vector<ll>> dp(s.size()+1, vector<ll>(t.size()+1, 0));
    vector<vector<bool>> sol(s.size()+1, vector<bool>(t.size()+1, false));
    s = " " + s;
    t = " " + t;

    for (int i = 0; i < s.size(); i++) {
        for (int j = 0; j < t.size(); j++) {
            // take s
            if (i+1 < s.size()) dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
            // take t
            if (j+1 < t.size()) dp[i][j+1] = max(dp[i][j+1], dp[i][j]);
            // take both
            if (i+1 < s.size() && j+1 < t.size()) dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j]+(s[i+1]==t[j+1]?1:0));
        }
    }

    int i = s.size()-1, j = t.size()-1;
    string ans = "";

    while (i > 0 && j > 0) {
        if (s[i] == t[j]) ans += s[i], i--, j--;
        else if (dp[i-1][j] > dp[i][j-1]) i--;
        else j--;
    }

    string rans(ans.rbegin(), ans.rend());
    cout << rans << endl;

    return 0;
}

Measured memory_bytes: 71936
#include <iostream>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>

using namespace std;
typedef long long ll;


typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする

vector<int> G[100005];
std::vector<P> tree[100010];

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

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define re(i,a,b) for(i=a;i<=b;i++)

ll i,j,ii,jj;
ll n,m;
ll num,sum;
bitset<2000005> dp;

int main(){
    cin>>n;
    dp[0]=1;
    for(i=0;i<n;i++){
        cin>>m;
        sum+=m;
        dp |= dp<<m;
    }
    for(i=(sum+1)/2;i<=2000004;i++){
        if(dp[i]){
            p(i);
            return 0;
        }
    }
    return 0;
}


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

using namespace std;
#define rep(i, N) for(int i=0;i<int(N);++i)
#define rep1(i, N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

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

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

const int INF = (ll) 1e9;
const ll INFLL = (ll) 1e18 + 1;
const ll MOD = (ll) 1e9 + 7;
const double PI = acos(-1.0);

/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/
int N, M;
vector<int> H;
vvec<int> G;

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

    cin >> N >> M;
    H.resize(N);
    rep(i, N)cin >> H[i];
    G.resize(N);
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    int ans = 0;
    rep(i,N){
        bool ok = true;
        for(auto nv: G[i]){
            if(H[i] <= H[nv])ok = false;
        }
        if(ok)ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 8724
import sys


def dfs(v, d, c, e):
    if (dp[v][d] != 0):
        return dp[v][d]

    if (d == 0):
        dp[v][d] = c
        return dp[v][d]

    for u in e[v]:
        dp[u][d-1] = dfs(u, d-1, c, e)

    dp[v][d] = dfs(v, d-1, c, e)
    return dp[v][d]

stdin = sys.stdin

ns = lambda: stdin.readline()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

dp = [[0]*11 for i in range(10**5+1)]
e = [[] for i in range(10**5+1)]

N, M = na()
for i in range(M):
    a, b = na()
    a -= 1
    b -= 1
    e[a].append(b)
    e[b].append(a)
    
Q = ni()
qv = [[0,0,0] for i in range(Q)]
for i in range(Q):
    v, d, c = na()
    v -= 1
    qv[Q-1-i][0] = v
    qv[Q-1-i][1] = d
    qv[Q-1-i][2] = c

for i in range(Q):
    dfs(qv[i][0],qv[i][1],qv[i][2],e)

for i in range(N):
    print (dp[i][0])

Measured memory_bytes: 57684
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

// 島のindexは0はじまり
int N, M; //  島数N、要望数M
vector< pair<int, int> > request;
const int INF = 1000000;

int main() {
  cin >> N >> M;
  for (int i = 0; i < M; ++i) {
    int a, b;
    cin >> a >> b;
    request.push_back(pair<int, int>(a - 1, b - 1)); // 0始まりにする
  }
  sort(request.begin(), request.end());
  vector< pair<int, int> >::iterator end = request.end();
  int left = 0, right = N - 1;
  int area = 1;
  for (vector< pair<int, int> >::iterator it = request.begin(); it != end; ++it) {
    int a = (*it).first, b = (*it).second;
    // いま考えている「重なった範囲」に対して
    // 1. 内包されているケース(left <= a < b <= right)
    // 2. 重なっているケース(left <= a < right < b)
    // 3. 完全にはずれているケース(left < right < a < b)
    if (b <= right) {
      left = a;
      right = b;
    } else if (a < right && right < b) {
      left = a;
    } else if (right <= a) {
      left = a;
      right = b;
      area += 1;
    }
  }
  cout << area << endl;
}


Measured memory_bytes: 1400
import java.util.Scanner;
class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i=0; i<n; i++) {
        	a[i] = sc.nextInt();
        }
        for (int i=n-1; i>-1; i--) {
        	if (i == n-1) {
        		System.out.print(a[i]);
        	} else {
        		System.out.print(" " + a[i]);
        	}
        }
        System.out.println();
    }
}


Measured memory_bytes: 26188