akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int ban[1010][1010][2];
int M, N;
int D[4][2] = {{1, 0}, {0, -1}, {-1, 0}, {0, 1}};
bool isprime[1000010];
int px = 500;
int py = 500;


void solve() {
	int ans = 0;
	int ansp = 0;
	bool f = true;
	int cnt = 0;
	while(f) {
		f = false;
		for (int px2 = max(px - cnt, 0); px2 <= min(px + cnt, 1000); px2++) {
			int p = ban[py][px2][0];
			if (p == 0 or p > M) continue;
			f = true;
			if (isprime[p]) {
				ban[py][px2][1] += 1;
				if (ans < ban[py][px2][1] or (ans == ban[py][px2][1] and ansp < p)){
					ans = ban[py][px2][1];
					ansp = p;
				}
			}
			for (int j = -1; j <= 1; j++) {
				if(px2 + j < 0) continue;
				ban[py + 1][px2 + j][1] = max(ban[py + 1][px2 + j][1], ban[py][px2][1]);
			}
		}
		py ++;
		cnt ++;
	}
	cout << ans << " " << ansp << endl;
}


int main() {
	rep(i, 1000001) isprime[i] = true;
	for (int i = 2; i < 1000001; i++) {
		if (isprime[i]) {
			for(int i2 = i * 2; i2 < 1000001; i2 += i) {
				isprime[i2] = false;
			}
		}
	}
	isprime[1] = false;
	isprime[0] = false;
	int k = 1;
	int m = 1;
	int d = 0;
	ban[py][px][0] = k;
	while(k < 1000001) {
		rep(i, m) {
			k += 1;
			px += D[d][0];
			py += D[d][1];
			ban[py][px][0] = k;
		}
		if (d == 1 or d == 3) m ++;
		d = (d + 1) % 4;
	}
	cin >> M >> N;
	while (M) {
		rep(i, 1001) {
			rep(j, 1001) {
				ban[i][j][1] = 0;
			}
		}
		rep(i, 1001) {
			rep(j, 1001) {
			if(ban[i][j][0] == N) {
				px = j; 
				py = i;
				i = 100000;
				break;
			}}}
		solve();
		cin >> M >> N;
	}
}



Measured memory_bytes: 11928
package main

import (
	"fmt"
	"log"
)

func main() {

	const num = 5 //
	var p[num] int //
	var k int //
	var isConnected = true

	//
	for i := 0; i < num; i++{
		_, err := fmt.Scan(&p[i])
		if err != nil {
			log.Fatal(err)
		}
	}

	//
	_, err := fmt.Scan(&k)
	if err != nil {
		log.Fatal(err)
	}

	for i := 0; i < num; i++ {
		for j := i; j < num; j++{
			if p[j] - p[i] > k{
				isConnected = false
			}
		}
	}

	if isConnected {
		fmt.Println("Yay!")
	}else {
		fmt.Println(":(")
	}
}


Measured memory_bytes: 512
N, C = map(int, input().split())
D = [list(map(int, input().split())) for i in range(C)]
c = [list(map(int, input().split())) for i in range(N)]
r = [[(i + j + 2) % 3 for j in range(N)] for i in range(N)]
c0 = []
c1 = []
c2 = []
ans = 1000 * 500 * 500

for i in range(N):
    for j in range(N):
        if r[i][j] == 0:
            c0.append(c[i][j])
        elif r[i][j] == 1:
            c1.append(c[i][j])
        else:
            c2.append(c[i][j])

d0 = []

for i in range(C):
    d = 0
    for j in c0:
        d += D[j - 1][i]
    d0.append(d)

d1 = []
for i in range(C):
    d = 0
    for j in c1:
        d += D[j - 1][i]
    d1.append(d)

d2 = []
for i in range(C):
    d = 0
    for j in c2:
        d += D[j - 1][i]
    d2.append(d)

for i in range(C):
    for j in range(C):
        for k in range(C):
            if i != j and j != k and k != i:
                ans = min(ans, d0[i] + d1[j] + d2[k])

print(ans)

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

int main(void) {
    int a, b;
    cin >> a >> b;
    int ans = max(a, b);
    if (a > b) {
        ans += max(a - 1, b);
    } else {
        ans += max(a, b - 1);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for(int i = a; i < b; i++)
int N;
string s;
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> s;
    int cnt = 0;

    rep(i, 0, 3) {
        if(s[i] == 'R') {
            cnt++;
        }
    }
    if(s[1] == 'S' && cnt == 2) {
        cnt = 1;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//do {
//    print(v);
//  } while (std::next_permutation(v.begin(), v.end()));

struct UnionFind {
	vector<int> par;
	vector<int> rank;
	vector<int> diff_weight;

	UnionFind(int n = 1, int SUM_UNITY = 0) {
		init(n, SUM_UNITY);
	}

	void init(int n = 1, int SUM_UNITY = 0) {
		par.resize(n); rank.resize(n); diff_weight.resize(n);
		for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
	}

	int root(int x) {
		if (par[x] == x) {
			return x;
		}
		else {
			int r = root(par[x]);
			diff_weight[x] += diff_weight[par[x]];
			return par[x] = r;
		}
	}

	int weight(int x) {
		root(x);
		return diff_weight[x];
	}

	bool issame(int x, int y) {
		return root(x) == root(y);
	}

	bool merge(int x, int y, int w) {
		w += weight(x); w -= weight(y);
		x = root(x); y = root(y);
		if (x == y) return false;
		if (rank[x] < rank[y]) swap(x, y), w = -w;
		if (rank[x] == rank[y]) ++rank[x];
		par[y] = x;
		diff_weight[y] = w;
		return true;
	}

	int diff(int x, int y) {
		return weight(y) - weight(x);
	}
};
signed main(){
cin.tie(0);
ios::sync_with_stdio(false);
	int N,M;
	cin >> N >> M;
	VI L(M);
	VI R(M);
	VI D(M);
	UnionFind uni(N);

	REP(i, M) {
		cin >> L[i] >> R[i] >> D[i];
		L[i]--;
		R[i]--;
		uni.merge(L[i], R[i], D[i]);
	
		if (uni.diff(L[i], R[i]) == D[i])continue;
		else {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
	return 0;
}



Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll ar[500009],br[500009];
int main()
{
    ll a,b,c,i,j,k=0;
    cin>>a;
    for(i=1;i<=a;i++)
    {
        cin>>ar[i];
    }
    ar[a+1]=99999999999;
    j=0;
    for(i=2;i<=a+1;i++)
    {
        if(ar[i]>ar[i-1])
        {
            k=max(j,k);
            j=0;
        }
        else
        {
            j++;
        }
    }
    cout<<k;
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)
ll c[50][50] = {};
ll A[50] = {};
ll B[50] = {};
bool v[50] = {};
ll N, M;
ll cnt = 0;

void dfs(int i) {
	rep(j, 0, N) {
		if (i != j && c[i][j] == 1 && !v[j])
		{
			v[j] = true;
			dfs(j);
			v[j] = false;
		}
	}

	bool allvisited = true;
	rep(j, 0, N) {
		if (!v[j]) {
			allvisited = false;
			break;
		}
	}
	if (allvisited) {
		cnt++;
	}
}
int main() {
	cin >> N >> M;

	rep(i, 0, M) {
		ll a, b; cin >> a >> b;
		c[a - 1][b - 1] = 1;
		c[b - 1][a - 1] = 1;
	}

	v[0] = true;
	dfs(0);

	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  char *s=(char *)malloc(sizeof(char)*100001);
  scanf("%s",s);
  int n=0;
  while(s[n]!='\0') n++;
  char c=s[n/2];
  int k=n/2;
  while(k<n && s[k]==c && s[n-1-k]==c) k++;
  printf("%d\n",k);
  return;
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 256
#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;

template <typename T>
struct edge {
    int from, to;
    T cost;

    edge(int to, T cost) : from(-1), to(to), cost(cost) {}
    edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}

    explicit operator int() const {return to;}
};


int main() {
    int n, m, l, k, a, h;
    auto f = [&](int i, int j){return i+j*n; };
    while(cin >> n >> m >> l >> k >> a >> h, n){
        vector<vector<edge<int>>> G(n*(m+1));
        for (int i = 0; i < l; ++i) {
            int x;
            cin >> x;
            for (int j = 0; j < m; ++j) {
                G[f(x, j)].emplace_back(f(x, j+1), 1);
            }
        }
        for (int i = 0; i < k; ++i) {
            int x, y, t;
            cin >> x >> y >> t;
            for (int j = t; j <= m; ++j) {
                G[f(x, j)].emplace_back(f(y, j-t), t);
                G[f(y, j)].emplace_back(f(x, j-t), t);
            }
        }
        vector<int> dist(n*(m+1), INF<int>);
        vector<bool> visited(n*(m+1), false);
        dist[f(a, m)] = 0;
        using P = pair<int, int>;
        priority_queue<P, vector<P>, greater<> > Q;
        Q.emplace(0, f(a, m));
        while(!Q.empty()){
            int cost; int i;
            tie(cost, i) = Q.top(); Q.pop();
            if(dist[i] < cost) continue;
            for (auto &&e : G[i]) {
                auto c = cost + e.cost;
                if(dist[e.to] <= c) continue;
                dist[e.to] = c;
                Q.emplace(dist[e.to], e.to);
            }
        }
        int ans = INF<int>;
        for (int i = 0; i <= m; ++i) {
            ans = min(ans, dist[f(h, i)]);
        }
        if(ans == INF<int>) puts("Help!");
        else cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 5300
import java.util.Arrays;
import java.util.Scanner;
  
  
public class Main {
    static boolean[] isDist;
    static int N;
    static int M;
    static int p;
    public static int INF = 1 << 24;
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        N = stdIn.nextInt();
        M = stdIn.nextInt();
        p = stdIn.nextInt();
        Limit = N*50;
        isDist = new boolean[N];
        for(int i = 0; i < M ;i++) {
            int d = stdIn.nextInt();
            isDist[d] = true;
        }
        boolean[] isDist2 = Arrays.copyOf(isDist,N);
          
        solv(1,p,0,0,false,isDist);
        solv(-1,p,0,0,false,isDist2);
        System.out.println(min);
          
    }
    static int min = 1 << 24; 
    static int Limit;
    public static void solv(int vec, int now, int coun, int cos, boolean alC,boolean[] isDist) {
          
        int nowp = now;
        int cost = cos;
        int count = coun;
        while(true) {
            if(min <= cost)return;
            if(nowp == N) nowp = 0;
            else if(nowp == -1) nowp = N-1;
            if(count == M ) {
                if(min > cost)min = cost;
                return;
            }
            if(isDist[nowp]) {
                  
                isDist[nowp] = false;
                count++;
                if(!alC && cost < Limit) {
                    boolean[] isDist2 = Arrays.copyOf(isDist, N);
                      
                    solv(vec*-1,nowp+vec*-1,count,cost+100,true,isDist2);
                }
            }
            if(count == M ) {
                if(min > cost)min = cost;
                return;
            }
            while(true) {
                if(nowp == N) nowp = 0;
                else if(nowp == -1) nowp = N-1;
                if(!isDist[nowp]) {
                    nowp += vec;
                    cost += 100;
                }
                else {
                    break;
                }
            }
        }
    }
}

Measured memory_bytes: 159920
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long sum = 0;
		for (int i = 0; i < N; i++) {
			if ((i + 1) % 3 != 0 && (i + 1) % 5 != 0) {
				sum += (i + 1);
			}
		}

		System.out.println(sum);
	}
}


Measured memory_bytes: 27196
#include <stdio.h>
#include <algorithm>
using namespace std;
using ll = long long;

char s[50], out[50];
int main() {
	scanf("%s", s);
	if (s[0] == 'S')
		printf("Cloudy\n");
	else if (s[0] == 'C')
		printf("Rainy\n");
	else
		printf("Sunny\n");
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
// #define ll int128_t
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
#define endl '\n'
#define all(x) x.begin(),x.end()
#define f(i,j,l) for(i=j;i<l;i++)
#define smax(a,b) a=max(a,b)
// #if !defined(ONLINE_JUDGE)
// #include "debugging.h"
// #endif
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
// erase,insert same as normal set

// int const mod = 7340033;
int const mod = 1e9+7;
int power(int a,int b,int m){
    int res = 1;
    while(b){
        if(b&1){
            res = res*a;
            res %= m;
        }
        a=a*a;
        a%=m;
        b=b/2;
    }
    return res;
}
 
int inverse(int x){
    return power(x,mod-2,mod);
}

int const N = 2e5+555;
int const inf = 2e16;

void solve(){  
    int n,i,j,l,m;
    cin>>n>>m;
    int ans = n*(n-1)/2;
    ans = ans + m*(m-1)/2;

    cout<<ans<<endl;
}       


int32_t main(){
    IOS;
    int t;
    t = 1;
    // precompute();
    // cin>>t;
    for(int tt=1;tt<=t;tt++){
        solve();
    }
    return 0;
}

/*

*/

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;

struct edge {
    int to, cost;
};

int H, W;
bool marked[100][100];
int sum;

void BFS(pii st) {
    queue<pii> que;
    que.push(st);
    sum++;
    marked[st.first][st.second] = false;
    while (que.size() > 0) {
        pii base = que.front();
        que.pop();
        pii mv[4] = {pii(-1, 0), pii(1, 0), pii(0, -1), pii(0, 1)};
        int basex = base.first;
        int basey = base.second;
        for (int i = 0; i < 4; i++) {
            int x = basex + mv[i].first;
            int y = basey + mv[i].second;
            if (x >= 0 && x < H && y >= 0 && y < W) {
                if (marked[x][y]) {
                    que.push(pii(x, y));
                    sum++;
                    marked[x][y] = false;
                }
            }
        }
    }
}

int main() {
    while (true) {
        cin >> W >> H;
        if (W == 0) {
            break;
        }
        for (int i = 0; i < H; i++) {
            fill(marked[i], marked[i] + W, true);
        }
        pii st;
        for (int i = 0; i < H; i++) {
            string s;
            cin >> s;
            for (int j = 0; j < W; j++) {
                if (s[j] == '#') {
                    marked[i][j] = false;
                } else if (s[j] == '@') {
                    st = pii(i, j);
                }
            }
        }
        sum = 0;
        BFS(st);
        cout << sum << endl;
    }
}



Measured memory_bytes: 3120
use std::io::*;
use std::str::FromStr;
 
/* 
The read function reads a string according to each one. 
*/
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


//main function
fn main() {
    let k: i32 = read();
    let n: usize = read();
    let mut a: Vec<i32> = Vec::with_capacity(n);
    unsafe{
	a.set_len(n);
    }
    for i in 0..n{
	let number: i32 = read();
	a[i] = number;
    }

    let mut max: i32 = 0;
    for i in 0..n-1{
	max = if max < a[i+1]-a[i] { a[i+1]-a[i]} else { max };
    }
    max = if max < (k-a[n-1])+a[0] { k-a[n-1]+a[0]} else {max}; 
    println!("{}",k-max);
    
}


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

int main() {
	int N, K;
	cin >> N >> K;
	vector<pair<long long, long long>> P;
	vector<long long> X, Y;
	for (int i = 0; i < N; i++) {
		long long x, y;
		cin >> x >> y;
		auto p = make_pair(x, y);
		P.push_back(p);
		X.push_back(x);
		Y.push_back(y);
	}
	sort(X.begin(), X.end());
	sort(Y.begin(), Y.end());

	long long Ans = (X[N-1] - X[0]) * (Y[N-1] - Y[0]);
	for (int l = 0; l < N - 1; l++) {
		for (int r = l + 1; r < N; r++) {
			for (int d = 0; d < N - 1; d++) {
				for (int u = d + 1; u < N; u++) {
					int Inside = 0;
					for (int i = 0; i < N; i++) {
						if (X[l] <= P[i].first && P[i].first <= X[r] && Y[d] <= P[i].second && P[i].second <= Y[u]) {
							Inside += 1;
						}
					}
					if (Inside >= K) {
						long long area = (X[r] - X[l]) * (Y[u] - Y[d]);
						Ans = min(area, Ans);
					}
				}
			}
		}
	}
	cout << Ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>

using namespace std;

int main(){

	int N;
	int A[200001];
	long long S[200001];

	cin >> N;
	for (int i = 1; i <= N; i++) cin >> A[i];
	S[0] = 0;
	for (int i = 1; i <= N; i++) S[i] = S[i - 1] + A[i];

	sort(S, S + N + 1);

	long long result = 0;
	
	long long cur = S[0];
	S[N + 1] = 777777777;
	long long count = 1;
	for (int i = 1; i <= N+1; i++){
		if (cur == S[i]) count++;
		else {
			result += count * (count - 1) / 2;
			cur = S[i];
			count = 1;
		}
	}

	cout << result << endl;

	return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}

// TODO: write
int main() {
  int n;cin>>n;
  vector<ll> l(n+1);
  l[0] = 2;l[1] = 1;
  for(int i = 2;i <= n;++i){
    l[i] = l[i-1] + l[i-2];
  }
  print(l[n]);
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,n) for(int i=1;i<(int)(n);i++)

typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { //最大公約数
  if (b==0) return a;
  else return gcd(b, a%b);
}

ll lcm(ll a, ll b) { //最小公倍数
  return a * b / gcd(a, b);
}

ll digit_sum(ll a){ //10進桁和
  ll ans=0;
  while(a>0){
    ans+=a%10;
    a/=10;
  }
  return ans;
}



int main()
{
  ll n,m,x,a[110];
  cin>>n>>m>>x;
  rep(i,m)cin>>a[i];
  ll m1=0,m2=0;

  rep(i,m){
    if(a[i]>=1&&a[i]<=x)m1++;
    if(a[i]>x&&a[i]<n)m2++;
  }
  cout<<min(m1,m2)<<endl;
  return 0;
}


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

#define INF 10000
#define MAXN 8
#define MAXM 30

int T[MAXN];
int G[MAXM][MAXM];
double dp[MAXM][1 << MAXN];
bool used[MAXM][1 << MAXN];
int n, m, p, a, b;

double dijkstra(){
    for (int i = 0; i < MAXM; i++) {
        for (int j = 0; j < (1 << MAXN); j++) {
            dp[i][j] = INF;
            used[i][j] = false;
        }
    }
    dp[a][(1 << n) - 1] = 0;
    
    while (true) {
        int v = -1;
        int w;
        for (int u = 0; u < m; u++) {
            for (int s = 0; s < (1 << n); s++) {
                if (!used[u][s] && (v == -1 || dp[u][s] < dp[v][s])) {
                    v = u; w = s;
                }
            }
        }
        if (v == -1) {
            break;
        }
        used[v][w] = true;
        for (int u = 0; u < m; u++) {
            for (int i = 0; i < n; i++) {
                if (G[v][u] == INF) {
                    continue;
                }
                if (w >> i & 1) {
                    dp[u][w & ~(1 << i)] = min(dp[u][w & ~(1 << i)], dp[v][w] + (double)G[v][u] / T[i]);
                }
            }
        }
    }

    double ans = INF;
    for (int i = 0; i < (1 << n); i++) {
        ans = min(ans, dp[b][i]);
    }
    return ans;
}

int main()
{
    int x, y ,z;
    while (true) {
        cin >> n >> m >> p >> a >> b;
        if (n == 0 && m == 0) {
            break;
        }
        a--; b--;
        for (int i = 0; i < MAXM; i++) {
            for (int j = 0; j < MAXM; j++) {
                G[i][j] = INF;
            }
        }
        for (int i = 0; i < MAXM; i++) {
            G[i][i] = 0;
        }
        for (int i = 0; i < n; i++) {
            cin >> T[i];
        }
        for (int i = 0; i < p; i++) {
            cin >> x >> y >> z;
            x--; y--;
            G[x][y] = G[y][x] = z;
        }
        double res = dijkstra();
        if (res == INF) {
            cout << "Impossible" << endl;
        }else{
            printf("%.3f\n", res);
        }
    }
    

    return 0;
}

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

using namespace std;

#define endl '\n'
#define ll long long

const ll mod = 1e9 + 7;
const ll maxn = 2e8 + 5;
const double pi = 3.1415926535897932384626433832795028841971693993751058209749445923078;
//iostream::sync_with_stdio(false);

ll gcd(ll a, ll b)
{
	while (b != 0)
	{
		int t = b;
		b = a % b;
		a = t;
	}
	return a;
}
int main()
{
	int n;
	cin >> n;
	int h = 0;
	for(int i = 1; i <= 3; i++)
	{
		if (n % 10 == 7)
		{
			h = 1;
			break;
		}
		else
		{
			n /= 10;
		}
	}
	if (h)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 3628
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <set>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>

#include <cstdlib>  // for abs

#include <iomanip>

using namespace std;
int main()
{
  // Standard incantation to set up fast IO.
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n, k;
  cin >> n >> k;
  if (n <= 1) {
    cout << 0 << '\n';
    return 0;
  }
  int a[n];
  int ans[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  ans[0] = 0;
  ans[1] = abs(a[1] - a[0]);
  if (n == 2) {
    cout << ans[1] << '\n';
    return 0;
  }
  for (int i = 2; i < n; i++) {
    int mmin = -1;
    for (int kk = 1; kk <= k; kk++) {
      int idx = i - kk;
      if (idx < 0) break;
      int cur = ans[idx] + abs(a[i] - a[idx]);
      if ((mmin == -1) || (cur < mmin)) {
	mmin = cur;
      }
    }
    ans[i] = mmin;
  }
  cout << ans[n-1] << '\n';
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<limits.h>
#include<memory.h>
//#include <bits/stdc++.h>
typedef long long LL;
using namespace std;

int main() 
{
	int a, b;
	cin >> a >> b;
	int sum = b;
	sum += a * 3;
	cout << sum / 2;
	return 0;
}


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

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

#ifndef INPUTS_DIR
#define INPUTS_DIR "./"
#endif

int d(int n) {
    int ans = 0;
    while (n) {
        ans += n % 10;
        n /= 10;
    }
    return ans;
}

void solve(ll N) {
    int ans = 1e9;
    for (int i = 1; i < N; i++) {
        ans = min(ans, d(i) + d(N - i));
    }
    cout << ans << endl;
}


void main_(istream &cin) {
    ll N;
    cin >> N;
    solve(N);
}

int main() {
#ifdef INTELLIJ
    ifstream ifs(string(INPUTS_DIR) + "in_1.txt");
    if (ifs.is_open()) {
        main_(ifs);
        ifs.close();
    } else {
        cerr << "Error: no input." << endl;
    }
#else
    ios::sync_with_stdio(false);
    cin.tie(0);
    main_(cin);
#endif
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,p,q,na,ans;
signed main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>p>>q;
		if(p==q)na++;
		else na=0;
		ans=max(ans,na);
	}
	if(ans>=3)printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 3632
import java.util.*;

class Main{
	public static void main(String[]args){
		Scanner s = new Scanner(System.in);
		
		for(int i=0;;i++){
			int a = s.nextInt();
			String op = s.next();
			int b = s.nextInt();
			
			if(op.equals("?")){
				break;
			}
			else if(op.equals("+")) System.out.println(a + b);
			else if(op.equals("-")) System.out.println(a - b);
			else if(op.equals("*")) System.out.println(a * b);
			else if(op.equals("/")) System.out.println(a / b);
		}
	}
}


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

int main() {
  int n;cin>>n;bool a=false;
  rep(i,n){char s;cin>>s;if(s=='Y')a=true;
          }
  if(a)puts("Four");else puts("Three");
}

Measured memory_bytes: 256
def solve(a,b,c,x):
    ans = 0
    for i in range(a+1):
        for j in range(b+1):
            for k in range(c+1):
                tmp = 500*i + 100*j + 50*k
                if tmp==x:
                    ans += 1
    return ans
            
inf = [int(input()) for i in range(4)]
print(solve(inf[0],inf[1],inf[2],inf[3]))

Measured memory_bytes: 3316
from collections import deque
m=[[1,0],[-1,0],[0,1],[0,-1]]
h,w=map(int,input().split())
l=list()
l.append('#'*(w+2))
for i in range(h):
    j=input()
    l.append('#'+j+'#')
l.append('#'*(w+2))
def bfs(a,b):
  s=[[-1 for j in i] for i in l]
  s[a][b]=0
  q=deque([[a,b]])
  while len(q)>0:
    x,y=q.popleft()
    for i,j in m:
      if l[x+i][y+j]=='.' and s[x+i][y+j]==-1:
        q.append([x+i,y+j])
        s[x+i][y+j]=s[x][y]+1
        num = s[x+i][y+j]
  return num
ans = []
for i in range(h+2):
  for j in range(w+2):
    if l[i][j] == '.':
      ans.append(bfs(i,j))
print(max(ans))

Measured memory_bytes: 9340
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	mint operator^(const ll& t)const {
		if (!t) return 1;
		mint a = *this^(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;


///////////////////////////
int main() {
	
	ll N, K;
	cin >> N >> K;

	vvvmint dp(N + 1, vvmint(N + 1, vmint(2 * N * N + 1, 0)));

	dp[0][0][N * N] = 1;
	
	repn(i, N)rep(j, N + 1)rep(k, 2 * N * N+1) {
		if (k + 2 * i <= 2 * N * N)dp[i][j][k] += dp[i - 1][j][k + 2 * i];

		if (j > 0) dp[i][j][k] += dp[i - 1][j - 1][k] * (i - j) * 2;

		if (j > 1 && k - 2 * i >= 0)dp[i][j][k] += dp[i - 1][j - 2][k - 2 * i] * (i - j + 1) * (i - j + 1);

		if (j > 0) dp[i][j][k] += dp[i - 1][j - 1][k];

		//cout << i << j << k << " " << dp[i][j][k] << endl << flush;
	}

	cout << dp[N][N][N * N + K] << endl;

}


Measured memory_bytes: 103936
n=int(input())
L=list(map(int,input().split()))
dp=[]
dp.append(0)
dp.append(abs(L[0]-L[1]))
for i in range(2, n):
    dp.append( min( dp[i-2]+abs(L[i]-L[i-2]), dp[i-1]+abs(L[i]-L[i-1]) ) )
print(dp[n-1])



Measured memory_bytes: 13980
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  int n, count = 0, maxi = 0;
  cin >> n;
  vector<int> a(n);

  for (int i = 0; i < n; i++){
    cin >> a[i];
  }
  for (int i = 0; i < n - 1; i++){
    if(a[i]>=a[i+1]){
      count++;
      maxi = max(maxi, count);
    }else{
      count = 0;
    }
  }
  
  cout << maxi << "\n";
  return 0;
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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 (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N, D;
	int P[11][11];
	cin >> N >> D;
	rep(i, 0, N)rep(j,0,D)
	{
		cin >> P[i][j];
	}

	int ans = 0;
	rep(i, 0, N)rep(j, i + 1, N)
	{
		int s = 0;
		rep(k, 0, D)
		{
			s += (P[i][k] - P[j][k])*(P[i][k] - P[j][k]);
		}
		if (s == ((int)sqrt(s))*((int)sqrt(s)))
		{
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;

long long h[100010];

long long dp[100010];

int main() {
	int N; cin >> N;
	int K;cin >> K;
	for (int i = 0; i < N; ++i) cin >> h[i];


	for (int i = 0; i < N; ++i) dp[i] = INF;

	dp[0]=0;
	for (int i = 1; i < N; ++i) {
		for(int j=1;j<=K;j++){
			if(i-j>=0)
				chmin(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
		}
	}

	cout << dp[N-1] << endl;
}

Measured memory_bytes: 1792
n=int(input())
li=[]
ans=0
fl=1

for i in range(n):
    li.append(int(input()))

li.sort()

for j in range(n-1):
    if li[j]!=li[j+1]:
        if fl%2==1:
            ans+=1
            fl=1
        else:
            fl=1
    else:
        fl+=1


if fl%2==1:
    ans+=1

print(ans)

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

int main(void){
    int x;
    cin >> x;
    
    for(int i = 1;i <= 10000;i++){
        if(i * x % 360 == 0){
            cout << i << endl;
            break;
        }
        /*if(i * (180 - x) % 360 == 0){
            cout << i << endl;
            break;
        }*/
    }
    
    //cout << ans << endl;
}

Measured memory_bytes: 3624
import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")
logging.disable(logging.CRITICAL)

W, H, x, y  = (int(x) for x in input().split())

max_menseki = float(W) * float(H) / 2.0
if W / 2 == x and H / 2 == y:
    print("{:f}".format(max_menseki) + " " + str(1))
else:
    print("{:f}".format(max_menseki) + " " + str(0))

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

template <class T>
inline void read(T &x) {
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar()) f ^= c == '-';
    for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x) {
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    T y = 1;
	int len = 1;
    for (; y <= x / 10; y *= 10) ++len;
    for (; len; --len, x %= y, y /= 10) putchar(x / y + 48);
}

int n, k, ans;

int main() {
	read(n), read(k);
	for (int x, i = 1; i <= n; ++i) {
		read(x);
		ans += x >= k;
	}
	write(ans);
	putchar('\n'); 
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main() {
	int n = 0;
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '+') {
			n++;
		}
		else {
			n--;
		}
	}
	cout << n << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdlib.h>

using namespace std;
int main()
{
  int A, B, C, K;

  cin >> A >> B >> C >> K;
  if (A > K)
  {
    cout << K << endl;
  }
  else if (A + B >= K)
  {
    cout << A << endl;
  }
  else
  {
    cout << A - (K - A - B) << endl;
  }

  return 0;
}

Measured memory_bytes: 3636
//Heaplax
//别让自己后悔
#include<bits/stdc++.h>
#define LL long long
#define LOG(x) cerr<<#x<<" = "<<x<<endl
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;
}
using namespace std;
int n;
bool ok=1;
int main()
{
	re(n);
	for(int x;n--;)
	{
		re(x);
		ok^=x&1;
	}
	puts(ok?"YES":"NO");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
  string n;
  cin >> n;
  rep(i, 3) {
    if(n[i] == '7') {
      cout << "Yes";
      return 0;
    }
  }
  cout << "No";
}


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

typedef long long ll;

#define rep(i, n) REP(i, 0, n)
#define REP(i, s, e) for(int i = (int)s; i < (int)(e); ++i)

#define X real()
#define Y imag()
#define x(p) real(p)
#define y(p) imag(p)
#define curr(P, i) P[i]
#define next(P, i) P[(i+1)%P.size()]
#define prev(P, i) P[(i-1+P.size())%P.size()]

const double EPS = 1e-8;
const double INF = 1e12;
const double PI = acos(-1);

typedef double D;
typedef complex<D> P;
namespace std{
  bool operator < (const P& a, const P& b) {
    return x(a) != x(b) ? x(a) < x(b) : y(a) < y(b);
  }
}

D dot(const P& a, const P& b) {
  return x(conj(a)*b);
}
D cross(const P& a, const P& b) {
  return y(conj(a)*b);
}

struct L : public vector<P> {
  L(const P&a, const P& b) {
    push_back(a);
    push_back(b);
  }
};

typedef vector<P> G;

struct C {
  P p; D r;
};

int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if(cross(b, c) > 0) return +1; //ccw
  if(cross(b, c) < 0) return -1; //cw
  if(dot(b, c) < 0)   return +2; //c-a-b on line
  if(norm(b) < norm(c)) return -2; //a-b-c on line
  return 0;
}

P projection(const L& l, const P& p) {
  D t = dot(p - l[0], l[0] - l[1]) / norm(l[0]- l[1]);
  return l[0] + t * (l[0] - l[1]);
}
P refrection(const L& l, const P& p) {
  return p + 2.0 * (projection(l, p) - p);
}
int main() {
  D x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  P a(x1, y1), b(x2, y2);
  int q;
  cin >> q;
  cout << fixed << setprecision(20);
  rep(i, q) {
    D x, y;
    cin >> x >> y;
    P c(x, y);
    int k = ccw(a, b, c);
    if(k == 1) cout << "COUNTER_CLOCKWISE" << endl;
    else if(k == -1) cout << "CLOCKWISE" << endl;
    else if(k == +2) cout << "ONLINE_BACK" << endl;
    else if(k == -2) cout << "ONLINE_FRONT" << endl;
    else cout << "ON_SEGMENT" << endl;
  }
  return 0;
}

Measured memory_bytes: 3260
#include <stdio.h>

int main()
{

   int x, h, m, s;
   scanf( "%d", &x );
   
   h = x/3600;
   m = x%3600/60;
   s = x%60;

   printf( "%d:%d:%d\n", h,m,s );

  return 0;
}


Measured memory_bytes: 2764
package main


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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var s string
	if sc.Scan() {
		s = sc.Text()
	}

	a, _:= strconv.Atoi(s)
	ans := 0

	for i := 1; i <= a; i++ {
		t := len(strconv.Itoa(i))
		if t % 2 == 1{
			ans++
		}
	}
	fmt.Println(ans)
}

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

const int maxn=4e5,maxm=8e5;
int n,q,s[maxn];
int bg[maxn],nt[maxm],to[maxm],e;

void insert(int x,int y) {
	nt[++e]=bg[x];
	to[e]=y;
	bg[x]=e;
}

void dfs(int x,int fa) {
	int i,u;
	s[x]+=s[fa];
	for (i=bg[x];i;i=nt[i]) {
		u=to[i];
		if (u==fa) continue;
		dfs(u,x);
	}
}

int main() {
	int i,x,y;
	scanf("%d%d",&n,&q);
	for (i=1;i<n;i++) {
		scanf("%d%d",&x,&y);
		insert(x,y);
		insert(y,x);
	}
	while (q--) {
		scanf("%d%d",&x,&y);
		s[x]+=y;
	}
	dfs(1,0);
	for (i=1;i<=n;i++) printf("%d ",s[i]);
	return 0;
}

Measured memory_bytes: 16768
//sppsfver - 20.08.2020
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using pll = pair <ll, ll>;
const int MAX = 1e5+5;

ll n, r, w, ans;
string s;

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

	cin >> n >> s;
	for (auto x : s){
		x == 'R' ? r++ : w++;
	}
	for (int i = n-w; i < n; i++){
		ans += (s[i] == 'R');
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

int main(){
    int n,k; cin >> n >> k;
    vector<int> h(n);

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

    int count = 0;

    for(int i = 0; i < n; i++){
        if(h[i] >= k) count++;
    }
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    int n, cnt = 0;
    string s;

    cin >> s;

    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'x') {
            cnt++;
        }
        if (cnt > 7) {
            cout << "NO" << endl;
            return (0);
        }
    }

    cout << "YES" << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long X = sc.nextLong();
		long K = sc.nextLong();
		long D = sc.nextLong();
		if (X==0) {
			if (K%2==0) {
				System.out.println(0);
			} else {
				System.out.println(D);
			}
		} else if (X>0) {
			long t = X/D;
			if (K<=t) {
				System.out.println(X-K*D);
			} else {
				long temp = K-t;
				if (temp %2==0) {
					System.out.println(X-t*D);
				} else {
					System.out.println(Math.abs(X-(t+1)*D));
				}
			}
		} else {
			long t = X/D;
			if (K<=-t) {
				System.out.println(Math.abs(X+K*D));
			} else {
				long temp = K-t;
				if (temp %2==0) {
					System.out.println(Math.abs(X-t*D));
				} else {
					System.out.println(Math.abs(X-(t-1)*D));
				}
			}
		}
	}
}

Measured memory_bytes: 35664
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
void min_self(ll& a, ll b) {
    a = min(a, b);
}

const ll INF = 1e18L + 5;

int main() {
    int n, W;
    scanf("%d%d", &n, &W);
    vector<int> weight(n), value(n);
    for(int i = 0; i < n; ++i) {
        scanf("%d%d", &weight[i], &value[i]);
    }
    int sum_value = 0;
    for(int x : value) {
        sum_value += x;
    }
    vector<ll> dp(sum_value + 1, INF); // 0 ... W
    dp[0] = 0;
    for(int item = 0; item < n; ++item) {
        for(int value_already = sum_value - value[item]; value_already >= 0; --value_already) {
            min_self(dp[value_already+value[item]], dp[value_already] + weight[item]);
        }
    }
    ll answer = 0;
    for(int i = 0; i <= sum_value; ++i) {
        if(dp[i] <= W) {
            answer = max(answer, (ll) i);
        }
    }
    printf("%lld\n", answer);
}

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

long long n, k, arr[200001], ans;

long long f(long long n){
	if(n==1) return 1;
	else return 2*f(n/2)+1;
}

int main(){
	cin>>n;
	
	cout<<f(n)<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int> ,null_type,less<pair<int,int> >,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
long long MOD = 1e9+7;
pair<int,int> dx[4] = {{1,0},{-1,0},{0,1},{0,-1}};
long long fastpow(long long x,long long k)
{
    if(!k)
        return 1;
    if(k & 1)
        return ((x * fastpow(x,k-1) % MOD) % MOD) % MOD;
    long long ans = fastpow(x,k/2);
    ans %= MOD;
    ans *= ans;
    ans %= MOD;
    return ans;
}
long long sumF(long long x)
{
    int s = 0;
    while(x)
        s += x%10,x /= 10;
    return s;
}
int arr[100005];
int DP[100005];
int n,k;
int solve(int idx)
{
    if(idx == n)
        return 0;
    if(DP[idx] != -1)
        return DP[idx];
    int C = 1e9;
    for(int i = 1;i <= k && idx + i <= n;i++)
        C = min(C,abs(arr[idx] - arr[idx+i]) + solve(idx + i));
    return DP[idx] = C;
}
int main()
{
    memset(DP,-1,sizeof DP);
    cin >> n >> k;
    for(int i = 1;i <= n;i++)
        cin >> arr[i];
    cout << solve(1);
    return 0;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (int i = m; i < (n); ++i)
using namespace std;
using ll = long long;

int main(){
    int n;
    cin >> n;
    vector<int> ar(n);
    rep(i,n){
        cin >> ar[i];
    }
    int le, ri;
    bool t = true;
    int cnt = 0;
    while (t){
        t = false;
        rep(i,n-1){
            if (ar[i] > ar[i+1]){
                le = ar[i+1];
                ri = ar[i];
                ar[i] = le;
                ar[i+1] = ri;
                cnt++;
                t = true;
            }
        }
    }
    rep(j,n-1){
        cout << ar[j] << " ";
    }
    cout << ar[n-1] << endl;
    cout << cnt << endl;
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n; cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i] -= i + 1;
  }
  sort(a.begin(), a.end());
  int b = a[n/2];
  long long s = 0;
  for (int &x : a) {
    s += abs(x - b);
  }
  cout << s << '\n';
  return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);		
		
		int w = scan.nextInt();
		int h = scan.nextInt();
		int x = scan.nextInt();
		int y = scan.nextInt();
		int r = scan.nextInt();

		if (0 <= y-r && y+r <= h && 0 <= x-r && x+r <= w) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
			
		scan.close();

	}

}

Measured memory_bytes: 17328
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

const int MAX=1<<20;
int N,dat[2*MAX-1];

//初期化
void init(int n){
  N=1;
  while(N<n) N*=2; 
  for(int i=0;i<2*N-1;i++) dat[i]=0;
}

//k番目(0-index)をaに変更
void update(int k,int a){
  k+=N-1;
  dat[k]=a;
  while(k>0){
    k=(k-1)/2;
    dat[k]=gcd(dat[k*2+1],dat[k*2+2]);
  }
}

//[a,b)なので0-indexならa--,b--;
int query(int a,int b,int k,int l,int r){
  if(r<=a || b<=l) return 0;
  if(a<=l && r<=b) return dat[k];
  int vl=query(a,b,k*2+1,l,(l+r)/2);
  int vr=query(a,b,k*2+2,(l+r)/2,r);
  return gcd(vl,vr);
}

int main(){
  int n;
  cin>>n;
  init(n);
  
  int x;
  rep(i,n){
    cin>>x;
    update(i,x);
  }
  
  int ma=0,tmp;
  rep(i,n){
    tmp=dat[i+N-1];
    update(i,0);
    ma=max(ma,query(0,n,0,0,N));
    update(i,tmp);
  }
  cout<<ma<<endl;
  
  return 0;
}

Measured memory_bytes: 4604
#include <iostream>
using namespace std;
int main(){
    int a , b;
    cin >> a >> b;
    if (a > b){
        cout << "a > b" << endl;
        
    }
    else if (a == b){
        cout << "a == b" << endl;
        
    }
    else{
        cout << "a < b" << endl;
    }
    return 0;
}


Measured memory_bytes: 3068