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

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

int main(){
    int A,B,C,K;
    cin>>A>>B>>C;
    cin>>K;
    bool ok=false;
    int a,b,c;
    
    REP(i,K+1){
        REP(j,K+1){
            REP(k,K+1){
                if(i+j+k>K) continue;
                a=A*pow(2,i);
                b=B*pow(2,j);
                c=C*pow(2,k);
                if(b>a&&c>b) ok=true;
            }
        }
    }

    if(ok){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 4024
#include<stdio.h>

int main(){
  int N,K;
  long M,m,sum=0;
  scanf("%d",&N);
  scanf("%d",&K);
  for(long a=K;a<=N+1;a++){
   m=a*(a-1)/2;
   M=a*(2*N-a+1)/2;
   sum+=M-m+1;
  };
  printf("%ld",sum%1000000007);
};
  

Measured memory_bytes: 1732
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>

#include <inttypes.h>
using namespace std;

int main()
{
	uint64_t N = 100001;
	vector<bool> is_prime(N + 1, true);
	is_prime[0] = is_prime[1] = false;

	for (uint64_t i = 2; i * i <= N; i++) {
		if (!is_prime[i])
			continue;
		for (uint64_t j = i; i * j <= N; j++)
			is_prime[i * j] = false;
	}

	vector<bool> is_2017(N, false);
	for (uint64_t i = 0; i < N; i++) {
		if (is_prime[i] && is_prime[(i + 1) / 2])
			is_2017[i] = true;
	}

	vector<int32_t> count(N, 0);
	for (uint64_t i = 1; i < N; i++) {
		count[i] = count[i - 1];
		if (is_2017[i])
			count[i]++;
	}

	int32_t Q;
	scanf("%d", &Q);

	for (int32_t i = 0; i < Q; i++) {
		int32_t l, r;
		scanf("%d%d", &l, &r);
		printf("%d\n", count[r] - count[l] + (is_2017[l] ? 1 : 0));
	}

	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
    ll n,i,j,k,s=0,c=1,x=1,t,a;
    cin>>k>>n;
    for(i=1;i<=n;i++)
    {
      cin>>a;
      s+=a;
    }
  if(k-s>=0)
    cout<<k-s;
  else cout<<-1;
}


Measured memory_bytes: 3600
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;

class point{
public:	
	int x;
	int y;
	bool exist;
	point(){
		this->x = 0;
		this->y = 0;
		this->exist = true;
	}
	static bool sortx(const point& left, const point& right){
		return left.x < right.x;
	}
	static bool sorty(const point& left, const point& right){
		return left.y < right.y;
	}
};

int main(){
	/*input*/
	int n;	cin >> n;
	vector<point>red(n);
	vector<point>blue(n);
	for(int i = 0; i < n; i++){
		cin >> red[i].x >> red[i].y;
	}
	for(int i = 0; i < n; i++){
		cin >> blue[i].x >> blue[i].y;
	}
	/*calculation*/
	int ans = 0;
	sort(blue.begin(), blue.end(), point::sortx);
	sort(red.rbegin(), red.rend(), point::sorty);
	for(int i = 0; i < n; i++){	//blue
		for(int j = 0; j < n; j++){	//red
			if(blue[i].x >= red[j].x && blue[i].y >= red[j].y && blue[i].exist && red[j].exist){
				ans++;
				blue[i].exist = false;
				red[j].exist = false;
			}
		}
	}
	/*output*/
	cout << ans << endl;
	/*debug*/
	/*
	for(int i = 0; i < n; i++){
		printf("blue[%d]:(%d, %d, %d), red[%d]:(%d, %d, %d)\n", i, blue[i].x, blue[i].y, (blue[i].exist)?1:0, i, red[i].x, red[i].y, (red[i].exist)?1:0);
	}
	*/
}


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

bool palindrome_or_not(string A)
{
    bool t_or_f = true;
    for (int i = 0; i <= (A.size() - 1) / 2; i++)
    {
        if (A[i] != A[A.size() - 1 - i]) t_or_f = false;
    }
    return t_or_f;
}

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

    string S_excluding_x = "";
    for (int i = 0; i < S.size(); i++)
    {
        if (S[i] != 'x')
        {
            S_excluding_x += S[i];
        }
    }

    if (S_excluding_x.size() == 0) // S = "xxxx...xxx"
    {
        cout << 0 << endl;
        return 0;
    }
    
    if (! palindrome_or_not(S_excluding_x))
    {
        cout << -1 << endl;
        return 0;
    }

    // 回文の中心を探す
    int p_S = -1, p_S_x = -1;
    int center[2] = {};
    for (int i = 0; i < S.size(); i++)
    {
        p_S++;
        if (S[p_S] != 'x')
        {
            p_S_x++;
            if (p_S_x == (S_excluding_x.size() - 1) / 2)
            {
                center[0] = p_S;
            }
            if (p_S_x == S_excluding_x.size() / 2)
            {
                center[1] = p_S;
                break;
            }
        }
    }
    // 回文の中心は
    // S_excluding_xの長さが奇数の時、center[0]（= center[1]）
    // _excluding_xの長さが偶数の時、center[0]とcenter[1]の中心

    // S[center[0]] ～ S[0] と S[center[1]] ～ S[S.size() - 1]を比較し
    //足りない'x'を補充する
    int ans = 0;
    int start_left = center[0], goal_left = center[0] - 1;
    int start_right = center[1], goal_right = center[1] + 1;

    // Sの両端に'a'をくっつける
    S = 'a' + S + 'a';
    start_left++; goal_left++;
    start_right++; goal_right++;

    while (goal_left != 0 || goal_right != S.size() - 1)
    {
        while (S[goal_left] == 'x')
        {
            goal_left--;
        }
        while (S[goal_right] == 'x')
        {
            goal_right++;
        }

        ans += abs(abs(goal_left - start_left) - abs(goal_right - start_right));

        start_left = goal_left;
        start_right = goal_right;

        if (goal_left != 0) goal_left--;
        if (goal_right != S.size() - 1) goal_right++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

long long mod = 1000000007;
int N, K;
long long A[1<<20];
multiset<pair<long long, int> > m1, m2;

int main() {
  //freopen("input.in","r",stdin);
  //freopen("output.out","w",stdout);

  cin >> N >> K;
  K = N - K; // remove K elements

  long long ans = 0, temp = 1;
  for (size_t i = 0; i < N; i++) {
    long long d = 0;
    int t = 0;

    cin >> t >> d;
    A[t]++;
    m1.insert({d, t});
    ans += d;
  }

  for (size_t i = 1; i <= N; i++) {
    if(A[i] > 0) {
      ans += temp;
      temp += 2;
    }
  }

  temp -= 2;

  while (K) {

    if(m1.size() > 0) {
      pair<long long, int> pi = *(m1.begin());
      if(A[pi.second] == 1) {
        m1.erase(m1.begin());
        m2.insert(pi);
        continue;
      }
    }

    if(m2.size() == 0) {
      pair<long long, int> pi = *(m1.begin());
      m1.erase(m1.begin());
      ans = ans - pi.first;
      A[pi.second]--;
      K--;
    } else if(m1.size() == 0) {
      pair<long long, int> pi = *(m2.begin());
      m2.erase(m2.begin());
      ans = ans - temp - pi.first;
      temp -= 2;
      A[pi.second]--;
      K--;
    } else {
      pair<long long, int> p1 = *(m1.begin());
      pair<long long, int> p2 = *(m2.begin());

      if(p1.first <= p2.first + temp) {
        pair<long long, int> pi = *(m1.begin());
        m1.erase(m1.begin());
        ans = ans - pi.first;
        A[pi.second]--;
        K--;
      } else {
        pair<long long, int> pi = *(m2.begin());
        m2.erase(m2.begin());
        ans = ans - temp - pi.first;
        temp -= 2;
        A[pi.second]--;
        K--;
      }
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 7296
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int height = sc.nextInt();
            int width = sc.nextInt();
            if(height == 0 && width ==0){
                break;
            }
            for(int i = 0; i < height; i++){
                for(int j = 0; j < width; j++){
                    System.out.print("#");
                }
                System.out.print("\n");
            }
            System.out.print("\n");
        }
    }
}


Measured memory_bytes: 36788
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <random>
#include <cassert>
#include <numeric>
#define ll long long int
#define LL unsigned long long
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
using namespace std;

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};
const int MOD = 1000000007;



int main() {
    ll d,n,ans; cin >> d >> n;
    if(n == 100) {
        ans = pow(100,d) * (n + 1ll);
    }else{
        ans = pow(100,d) * n;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long

void solve(){
	int n;
	cin >> n;
	vector<int> a(n);
	for(auto &x: a) cin >> x;
	vector<int> dp(n,0);
	for(int i=n-2; i>=0;i--){
		dp[i] = dp[i+1] + abs(a[i] - a[i+1]);
		if(i != n-2) dp[i] = min(dp[i], dp[i+2] + abs(a[i] - a[i+2]));
	}
	cout << dp[0];
}

int main(){
	FAST(); 
	int t = 1; 
	// cin >> t; 
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int R = scan.nextInt();
        int G = scan.nextInt();
        System.out.println(2*G-R);
    }
}


Measured memory_bytes: 22100
import math

a,b,n = map(int,input().split())

c = 0
ans = -1
for i in range(1,n//b+2) :
    x = b*i-1
    if x > n :
        x = n
        c = 1
    if ans >= math.floor((a*x)/b)-a*math.floor(x/b) :
        break
    ans = math.floor((a*x)/b)-a*math.floor(x/b)
    if c == 1 :
        break

print(ans)

Measured memory_bytes: 62180
package main

import (
	"fmt"
)

func main() {
	var h, w, ans uint
	fmt.Scan(&h, &w)
	if val := h * w; val%2 == 1 {
		ans = val/2 + 1
	} else {
		ans = val / 2
	}
	if h == 1 || w == 1 {
		ans = 1
	}
	fmt.Print(ans)
}


Measured memory_bytes: 512
#include <stdio.h>
#include <math.h>
#include <cmath>
#include <iostream>

using namespace std;

typedef long long int ll;

const long long INF = 0x3f3f3f3f3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9; 
 
int main(void){
    int n,k;
    scanf("%d", &n);
    scanf("%d", &k);

    ll h[n];
    ll costs[n];
    costs[n - 1] = 0;

    for( int i = 0; i < n; ++i ){
        ll height;
        scanf("%lld", &height);
        h[i] = height;
    }
    for( int i = n - 2; i >= 0; --i ){
        ll c = INF;

        for (int a = 1; a <= k && a < n - i; ++a) {
            int jump_to = i + a;
            ll jump_cost = abs(h[jump_to] - h[i]) + costs[jump_to];
            c = (c > jump_cost) ? jump_cost : c;
        }
        costs[i] = c;
    }
    printf("%lld", costs[0]);
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  priority_queue<int> d;
  int temp_d;
  for (int i = 0; i < N; i++) {
    cin >> temp_d;
    d.push(temp_d);
  }
  int a, b;
  for (int i = 0; i < N / 2 - 1; i++) {
    d.pop();
  }
  a = d.top();
  d.pop();
  b = d.top();
  
  cout << a - b;
}

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


Measured memory_bytes: 3100
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;

/**
 * N 人の社員からなる会社があり、各社員には 1, ..., N の社員番号が割り当てられています。 社員番号 1
 * の社員以外の全ての社員には、自分より社員番号が小さい直属の上司がちょうど 1 人います。 X さんが Y さんの直属の上司であるとき、Y さんは X
 * さんの直属の部下であるといいます。 社員番号 i の社員の直属の上司の社員番号が A_i
 * であることが与えられます。各社員について直属の部下が何人いるか求めてください。 Input: N A_2 ... A_N
 */
public final class Main {
  public static void main(final String[] args) throws Exception {
    try (final BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); final PrintWriter out = new PrintWriter(System.out)) {
      execute(in, out);
      out.flush();
    }
  }

  private static void execute(final BufferedReader in, final PrintWriter out) throws Exception {
    int n = readInt(in);
    int[] a = readIntArray(in); // A_2 ... A_N
    int[] r = new int[n];
    for (int an : a) {
      r[an - 1]++;
    }
    for (int rn : r) {
      out.println(rn);
    }
  }

  public static int readInt(final BufferedReader in) throws IOException {
    return Integer.parseInt(in.readLine());
  }

  public static int[] readIntArray(final BufferedReader in) throws IOException {
    return Arrays.stream(in.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
  }
}


Measured memory_bytes: 63740
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = sc.nextInt();
		int[] m = new int[n];
		
		int min = 0;
		int count = 0;
		
		for (int i = 0; i < n; i++) {
			m[i] = sc.nextInt();
			if(i == 0) {
				min = m[0];
			}
			if(i != 0 && m[i] < min) {
				min = m[i];
			}
			if(x - m[i] > 0) {
				x -= m[i];
				count++;
			}
		}
		sc.close();
		while(x >= min) {
			x -= min;
			count++;
		}
		System.out.println(count);
	}
}

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

#define R register
#define ll long long
#define sum(a, b, mod) (((a) + (b)) % mod)

const int MaxN = 1e4 + 10;
const int inf = 0x3f3f3f3f;

struct edge
{
    int next, to;
};

char s[MaxN];
edge e[MaxN];
int n, ans, cnt;
int a[MaxN], head[MaxN], dis[MaxN], size[MaxN], min[MaxN];

void init()
{
    for (int i = 1; i <= n; i++)
        dis[i] = size[i] = min[i] = 0;
}

void add_edge(int u, int v)
{
    ++cnt;
    e[cnt].to = v;
    e[cnt].next = head[u];
    head[u] = cnt;
}

inline int read()
{
    int x = 0;
    char ch = getchar();
    while (ch > '9' || ch < '0')
        ch = getchar();
    while (ch <= '9' && ch >= '0')
        x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
    return x;
}

void dfs(int u, int fa)
{
    size[u] = a[u];
    int maxp = 0;
    for (int i = head[u]; i; i = e[i].next)
    {
        int v = e[i].to;
        if (v == fa) continue;
        dfs(v, u), size[u] += size[v];
        dis[u] += dis[v], maxp = (dis[v] > dis[maxp]) ? v : maxp;
    }
    if (min[maxp] + dis[maxp] > dis[u])
        min[u] = min[maxp] + dis[maxp] - dis[u] + size[u];
    else
        min[u] = (dis[u] & 1) + size[u];
    dis[u] += size[u];
    if(!fa) dis[u] -= size[u], min[u] -= size[u];
    
}

int main()
{
    ans = inf;
    n = read(), scanf("%s", s + 1);
    for (int i = 1; i <= n; i++)
        a[i] = s[i] - '0';
    for (int i = 1; i < n; i++)
    {
        int u = read(), v = read();
        add_edge(u, v), add_edge(v, u);
    }
    for (int i = 1; i <= n; i++)
    {
        init(), dfs(i, 0);
        if (!min[i]) ans = std::min(ans, dis[i] / 2);
    }
    printf("%d\n", (ans == inf) ? -1 : ans);
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,b,c,d,p,priceX=0,priceY=0;
    cin>>a>>b>>c>>d>>p;
    //X社
    priceX=a*p;
    //Y社
    if (c>=p) {
        priceY=b;
    } else {
        priceY=(p-c)*d+b;
    }
    cout<<min(priceX,priceY)<<endl;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const int MOD = 1000000007;
/* テンプレートここまで */

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

int main() {
  int N, W;
  cin >> N >> W;

  vector<int> v(N+1, 0), w(N+1, 0);

  FOR(i, 1, N+1){
    cin >> w[i] >> v[i];
  }

  int V_MAX = 1000;
  vector<vector<ll>> dp(N+1, vector<ll>(N*V_MAX + 1,W+1));

  FOR(i, 0, N+1){
    dp[i][0] = 0;
  }

  FOR(i, 0, N){
    REP(j, N*V_MAX){
      if(dp[i][j] <= W) chmin(dp[i+1][j+v[i+1]], dp[i][j] + w[i+1]);
      chmin(dp[i+1][j], dp[i][j]);
    }
  }

  int ans = 0;
  REP(i, N*V_MAX+1){
    if (dp[N][i] <= W) chmax(ans, i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 80256
S = input()
N = len(S)
if (S == S[::-1] and S[: (N - 1) // 2:-1] == S[:(N - 1) // 2] and S[N:(N + 3) // 2 - 2:-1] == S[(N + 3) // 2 - 1:]):
    #print(S[::-1], S[: (N - 1) // 2:-1], S[N:(N + 3) // 2 - 2:-1])
    #print(S[::-1], S[:(N - 1) // 2], S[(N + 3) // 2 - 1:])
    print('Yes')
else: print('No')


Measured memory_bytes: 2940
#include <iostream>
#include <string>
using namespace std;
int main(){
    int n,k,sum;
    cin >> n >> k;
    sum = 0;
    int s[n];
    for(int i=0; i<n; i++){
        s[i] = 0;
    }
    for(int i=0; i<n; i++){
        int d;
        cin >> d;
        for(int j=0; j<d; j++){
            int e;
            cin >> e;
            s[e-1] = 1;
        }
    }
    for(int i=0; i<n; i++){
        if(s[i]==0){
            sum++;
        }
    }
    cout << sum;
}

Measured memory_bytes: 3192
import java.util.*;

public class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        String t = sc.nextLine();
        String u = s+s;
        if (u.contains(t)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23124
#include<cstdio>
#include<algorithm>
#include<map>
using namespace std;
int n,m,q;
long long ans[15];
map<int,map<int,int> >mp;
int main()
{
	scanf("%d%d%d",&n,&m,&q);
	while(q--)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		for(int i=max(2,x-1);i<=min(n-1,x+1);i++)
			for(int j=max(2,y-1);j<=min(m-1,y+1);j++)
			{
				ans[mp[i][j]]-=1ll;
				mp[i][j]++;
				ans[mp[i][j]]+=1ll;
			}
	}
	ans[0]+=1ll*(n-2)*(m-2);
	for(int i=0;i<=9;i++)
		printf("%lld\n",ans[i]);
}

Measured memory_bytes: 70528
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main(void) {

    int n;
    cin>>n;
    vi v(n);
    rep(i,n)cin>>v[i];
    ll ans=0;
    int amari=0;
    for(int i=0;i<n;i++){
        ans+=(v[i]+amari)/2;
        if(v[i]>0)amari=(v[i]+amari)%2;
        else amari=0;
        // cout<<i<<" "<<ans<<endl;
    }
    // rep(i,n)cout<<v[i]<<" ";
    fin(ans);
}

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

#define     F       first
#define     S       second
typedef pair<int, int>  pi;
typedef long long       ll;

const int MAX=1e7+9;
int cnt[MAX];
ll ans[MAX];

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

    for (int i=1; i<MAX; ++i) {
        for (int j=i; j<MAX; j+=i) {
            ++cnt[j];
        }
    }

    for (int i=1; i<MAX; ++i) {
        ans[i]=1LL*i*cnt[i]+ans[i-1];
    }

    int n;
    cin >> n;
    cout << ans[n];

    return 0;
}


Measured memory_bytes: 120840
#include<iostream>

#include<string.h>

using namespace std;

int main() 

{

    char a[100010];

	cin >> a;

	int x = a[strlen(a) - 1] - '0';

	if (x == 3)

	{

		cout << "bon" << endl;

	}

	else if (x == 0 || x == 1 || x == 6 || x == 8)

	{

		cout << "pon" << endl;

	}

	else

		cout << "hon" << endl;

}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define ff first
#define ss second
#define inf 9e18
#define pii pair<int,int>
#define fastio ios_base::sync_with_stdio(0);  cin.tie(0); cout.tie(0);
using namespace std;
int32_t main()
{
    
    fastio
   
    
    int n,k;
    cin>>n>>k;
    int dp[n+2],a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=0;i<n;i++)
        dp[i] = INT_MAX;

    dp[n-1] = 0;
    if(n-2>=0)
        dp[n-2] = abs(a[n-1]-a[n-2]);
    for(int i=n-3;i>=0;i--)
        for(int j=i+1;j<min(n,i+k+1);j++)
            dp[i] = min(abs(a[i]-a[j])+dp[j],dp[i]);
    
    cout<<dp[0];
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep0(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<string, int, int> TU;
typedef tuple<int, int, int> TI;

int main()
{
    int W,H,x,y;
    cin >> W >> H >> x >> y;
    cout << (double)W*H/2  << " ";
    if(x==(double)W/2&&y==(double)H/2){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }
}


Measured memory_bytes: 3764
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  (m1 : _) <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  (m2 : _) <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  print $ if m1 /= m2 then 1 else 0

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 508
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;

int field[33][33];
int sum[33][33];
int num[33][33][33][33];
int msz[33][33][33][33];

int H,W,S;
int all;

const int inf=1<<29;

int get(int i1,int i2,int j1,int j2){
	i1--;j1--;
	return sum[i2][j2]-sum[i1][j2]-sum[i2][j1]+sum[i1][j1];
}

int main(){
	while(true){
		scanf("%d%d%d",&H,&W,&S);
		if(H==0&&W==0) return 0;
		for(int i=1;i<=H;i++)for(int j=1;j<=W;j++)scanf("%d",&field[i][j]);
		memset(sum,0,sizeof(sum));
		for(int i=1;i<=H;i++) for(int j=1;j<=W;j++){
			sum[i][j]=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+field[i][j];
		}
		int x=sum[H][W]-S;
		memset(num,-1,sizeof(num));
		memset(msz,-1,sizeof(msz));
		for(int i=1;i<=H;i++)for(int j=1;j<=W;j++){
			if(field[i][j]<x){
				num[i][i][j][j]=-inf;
				msz[i][i][j][j]=-inf;
			}else{
				num[i][i][j][j]=1;
				msz[i][i][j][j]=field[i][j];
			}
		}
//		printf("aa%d %d\n",get(1,2,1,2),sum[2][3]);
		for(int id=0;id<=H-1;id++) for(int jd=0;jd<=W-1;jd++){
		if(id==0&&jd==0) continue;
			for(int i=1;i+id<=H;i++){
				for(int j=1;j+jd<=W;j++){
					int i1=i,i2=i+id,j1=j,j2=j+jd;
					int cAll=get(i1,i2,j1,j2);
					if(cAll<x){
						num[i1][i2][j1][j2]=-inf;
						msz[i1][i2][j1][j2]=-inf;
						continue;
					}
					num[i1][i2][j1][j2]=1;
					msz[i1][i2][j1][j2]=cAll;
					if(id!=0){
						for(int si=i1;si<i2;si++){
							//[i][si],[si+1][i2]
							int nnum=num[i1][si][j1][j2]+num[si+1][i2][j1][j2];
							int nmsz=min(msz[i1][si][j1][j2],msz[si+1][i2][j1][j2]);
							int &cnum=num[i1][i2][j1][j2];
							int &cmsz=msz[i1][i2][j1][j2];
							if(cnum<nnum||(cnum==nnum&&cmsz<nmsz)){
								cnum=nnum;
								cmsz=nmsz;
							}
						}
					}
					if(jd!=0){
						for(int sj=j1;sj<j2;sj++){
							int nnum=num[i1][i2][j1][sj]+num[i1][i2][sj+1][j2];
							int nmsz=min(msz[i1][i2][j1][sj],msz[i1][i2][sj+1][j2]);
							int &cnum=num[i1][i2][j1][j2];
							int &cmsz=msz[i1][i2][j1][j2];
							if(cnum<nnum||(cnum==nnum&&cmsz<nmsz)){
								cnum=nnum;
								cmsz=nmsz;
							}
						}
					}
				}
			}
		}
		printf("%d %d\n",num[1][H][1][W],msz[1][H][1][W]-x);
	}
	return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

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

    int n;
    while (cin >> n, n)
    {
        vector<string> s(n);
        for (int i = 0; i < n; i++)
            cin >> s[i];
        vector<int> cnt(n, 0);
        for (int i = 1; i < n; i++)
        {
            int len = s[i].length();
            for (int j = 0; j < len; j++)
                if (s[i][j] == '.')
                    cnt[i]++;
            s[i][cnt[i] - 1] = '+';
        }
        for (int i = 3; i < n; i++)
        {
            int pre = -1;
            for (int j = i - 1; j >= 1; j--)
            {
                if (cnt[j] < cnt[i])
                    break;
                if (cnt[j] == cnt[i])
                {   
                    pre = j;
                    break;
                }
            }
            if (pre == -1)
                continue;
            for (int j = i - 1; pre + 1 <= j; j--)
            {
                s[j][cnt[i]-1] = '|';
            }
        }
        cout << s[0] << endl;
        for (int i = 1; i < n; i++)
        {
            int len = s[i].length();
            for (int j = 0; j < len; j++)
                if (s[i][j] == '.')
                    s[i][j] = ' ';
            cout << s[i] << endl;
        }
    }
}



Measured memory_bytes: 3480
#include <iostream>
#include <vector>
#include <stack>
using namespace std;
void drop(vector<vector<int> > &field, int h){
  for(int i = 0; i < h; ++i){
    for(int j = h-1; j > 0; --j){
      for(int k = 0; k < 5; ++k){
        if(field[j][k] == 0){
           swap(field[j-1][k], field[j][k]);
        }
      }
    }
  }
}
int erase(vector<vector<int> > &field, int h){
  int ret = 0;
  for(int i = 0; i < h; ++i){
    for(int j = 0; j < 3; ++j){
      // search
      int len = 1;
      for(int k = j+1; k < 5; ++k){
        if(field[i][j] != field[i][k]){
          break;
        }
        ++len;          
        }
      if(len >= 3){
        ret += field[i][j] * len;
        for(int k = j; k < j + len; ++k){
          field[i][k] = 0;
        }
      }
    }
  }
  return ret;
}
int main(){
  int h;
  while(true){
    cin >> h;
    if(h == 0){
      break;
    }
    vector<vector<int> > field(h, vector<int>(5));
    for(int i = 0; i < h; ++i){
      for(int j = 0; j < 5; ++j){
        cin >> field[i][j];
      }
    }
    int ans = 0;
    while(true){
      int point = erase(field, h);
      if(point == 0){
        break;
      }
      ans += point;
      drop(field, h);
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1220
using System;
using System.Collections.Generic;

namespace ConsoleApplication1
{    

    
    class Program
    {       

        static int Parent(int i)
        {
            return i / 2;
        }

        static int Left(int i)
        {
            return 2 * i;
        }
        
        static int Right(int i)
        {
            return 2 * i + 1;
        }

        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            long[] A = new long[n + 1];

            string[] input = Console.ReadLine().Split();

            for(int i = 1; i <= n; i++)
            {
                A[i] = long.Parse(input[i - 1]);
            }

            int v = 0;

            for (int i = 1; i <= n; i++)
            {
                Console.Write($"node {i}: ");
                Console.Write($"key = {A[i]}, ");
                v = Parent(i);
                if(v >= 1)
                {
                    Console.Write($"parent key = {A[v]}, ");
                }
                v = Left(i);
                if(v <= n)
                {
                    Console.Write($"left key = {A[v]}, ");
                }
                v = Right(i);
                if (v <= n)
                {
                    Console.Write($"right key = {A[v]}, ");
                }
                Console.WriteLine();
            }
        }
    }
}



Measured memory_bytes: 15968
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>

//using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

template<typename T> void chmax(T& a, T b) { a = std::max(a, b); }
template<typename T> void chmin(T& a, T b) { a = std::min(a, b); }
template<typename T> void chadd(T& a, T b) { a = a + b; }

namespace {  // 名前なし名前空間
	// gcd, lcm は C++17 でstdに標準入りしたので言語のバージョンに注意
	// 最大公約数
	ll gcd(ll a, ll b) {
		if (b == 0) return a;
		return gcd(b, a % b);
	}

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

int main() {

	int n;
	std::cin >> n;
	std::vector<int> a(n);
	rep(i, n) std::cin >> a[i];

	std::vector<int> ans(n);

	rep(i, n) {
		ans[a[i] - 1] = i + 1;
	}

	rep(i, n) {
		std::cout << ans[i] << " ";
	}
	std::cout << std::endl;

	return 0;
}


Measured memory_bytes: 1664
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace ABC
{
    class ABC165D
    {
        const bool TESTING = false;
        const string FILE = "/tmp/data.txt";

        static void Main(string[] args)
        {
            if (TESTING)
            {
                Console.SetIn(new StreamReader(FILE));
            }
            var line = Console.ReadLine();
            var sa = line.Split(' ');
            long a = long.Parse(sa[0]);
            long b = long.Parse(sa[1]);
            long n = long.Parse(sa[2]);

            long result = 0;
            if (n < b)
            {
                result = proc(a, b, n);
            }
            else
            {
                result = proc(a, b, b - 1);
            }
            /*
            for (long x = b - 1; x <= n; x += b)
            {
                /*
                long r = proc(a, b, x);
                if (r >= result)
                {
                    result = r;
                }
                else
                {
                    break;
                }
                result = Math.Max(result, proc(a, b, x));
//                Console.WriteLine("" + x + ":" + proc(a, b, x));
            }
        */
            Console.WriteLine(result);

#if DEBUG
            Console.WriteLine();
#endif
        }

        private static long proc(long a, long b, long x)
        {
            return (a * x) / b - a * (x / b);
        }
    }
}


Measured memory_bytes: 27460
import math 
A,B,X = map(int,input().split())

t = 0
if (A**2)*B/X >= 2:
    t = float((A*(B**2))/(2*X))
else:
    t = float((2*(A**2)*B-2*X)/(A**3))

print(math.atan(t)*180/math.pi)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cassert>

using namespace std;

using lint = long long;
using ldouble = long double;

struct Node {
    int val;
    Node *lch, *rch;
};

using pNode = Node*;

string S;
int itr;

Node* parse() {
    if (S[itr] != '(') return nullptr;

    pNode node = new Node;

    ++itr;
    node->lch = parse();
    assert(S[itr] == ')');

    node->val = 0;
    itr += 2;
    while (S[itr] != ']') {
        (node->val *= 10) += S[itr] - '0';
        ++itr;
    }

    itr += 2;
    node->rch = parse();
    assert(S[itr] == ')');

    ++itr;
    return node;
}

string tos(Node* node) {
    if (node == nullptr) return "";
    return "(" + tos(node->lch) + ")" +
           "[" + to_string(node->val) + "]" +
           "(" + tos(node->rch) + ")";
}

Node* merge(Node* s, Node* t) {
    if (s == nullptr || t == nullptr) return nullptr;

    pNode node = new Node;
    node->lch = merge(s->lch, t->lch);
    node->val = s->val + t->val;
    node->rch = merge(s->rch, t->rch);

    return node;
}

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

    S = s;
    itr = 0;
    auto str = parse();
    assert(itr == S.length());

    S = t;
    itr = 0;
    auto ttr = parse();
    assert(itr == S.length());

    auto mtr = merge(str, ttr);

    cout << tos(mtr) << endl;
    return 0;
}



Measured memory_bytes: 3336
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
using namespace std;
using ll = long long;
int main() {
    float d,t,s;
    cin >> d >> t >> s;
    cout << (t >= d / s ? "Yes" : "No") << endl;
    return 0;
}

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

// boost
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

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

  ll n;
  cin >> n;
  string c;
  cin >> c;

  ll ans = INF;

  ll cnt = 0;
  rep(i, n) {
    if (c[i] == 'R')
      cnt++;
  }
  chmin(ans, cnt);

  cnt = 0;
  rep(i, n) {
    if (c[i] == 'W')
      cnt++;
  }
  chmin(ans, cnt);

  ll l = 0, r = ans;
  while (l < r) {
    ll cen = (l + r) / 2;

    ll lidx = 0;
    ll ridx = n - 1;

    rep(i, cen) {
      while (lidx < ridx && c[lidx] != 'W') {
        lidx++;
      }
      while (lidx < ridx && c[ridx] != 'R') {
        ridx--;
      }

      lidx++;
      ridx--;
    }

    while (lidx < ridx && c[lidx] != 'W') {
      lidx++;
    }
    while (lidx < ridx && c[ridx] != 'R') {
      ridx--;
    }

    if (lidx >= ridx) {
      r = cen;
    } else {
      l = cen + 1;
    }
  }

  chmin(ans, l);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3772
import sys

sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# 文字列アルゴリズム
# Z-Algorithm
# ZAlgorithm

# AC

N = int(input())
S = list(input())

ans = 0


def Z_Algorithm(S):
    L = len(S)
    Z = [0] * L
    Z[0] = L

    i = 1
    j = 0

    while i < L:
        # 同じなら引き伸ばす
        # 前回のjを引き継ぐ
        while i + j < L and S[j] == S[i + j]:
            j += 1
        Z[i] = j

        # j = 0なら次
        if j == 0:
            i += 1
            continue

        # 同じ数字分横にずらす
        # 右にそれ以上の文字があればcontinue
        k = 1
        while k < j and k + Z[k] < j:
            Z[i + k] = Z[k]
            k += 1

        i += k
        j -= k

    return Z


ans = 0
for i in range(N):
    Z = Z_Algorithm(S[i:])

    L = len(Z)
    for j in range(1, L):
        l = min(Z[j], j)
        ans = max(l, ans)

print(ans)


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

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

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            int x = in.nextInt();

            int[] a = in.nextIntArray(m);

            int cnt1 = 0;
            int cnt2 = 0;
            for (int i = 0; i < m; i++) {
                if (a[i] < x) cnt1++;
                if (a[i] > x) cnt2++;
            }

            out.println(Math.min(cnt1, cnt2));
        }

    }

    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
            st = new StringTokenizer("");
        }

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

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

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

    }
}



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

typedef long long   ll;
typedef long double ld;
using namespace std;
const int MOD=1e9+7;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }


    int chk[(n+1)/2]={};
    if(n%2==0){
        for(int i = 0; i < n; i++) {
            chk[(a[i]-1)/2]++;
        }
    }
    else{
        chk[0]++;
        for(int i = 0; i < n; i++) {
            chk[a[i]/2]++;
        }
    }

    bool jud=true;
    for(int i = 0; i < (n+1)/2; i++) {
        if(chk[i]!=2) jud=false;
    }
    if(jud){
        ll ans=1;
        for(int i = 0; i < n/2; i++) {
            ans=ans*2%MOD;
        }
        cout << ans << "\n";
    }
    else cout << 0 << "\n";

    return 0;
}

Measured memory_bytes: 896
#include<stdio.h>
#define MAX 100

int main(void)
{
  int i, j, k, N, NN;
  int a, b, aa, bb, temp, ranknum, check;
  int max;
  int team[MAX];
  int rank[MAX];

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

  NN = N*(N-1)/2;

  for(i=1;i<=NN;i++)
    {
      scanf("%d %d %d %d",&a,&b,&aa,&bb);
      if(aa>bb)
	team[a]+=3;
      if(bb>aa)
	team[b]+=3;
      if(aa==bb)
	{
	  team[a]+=1;
	  team[b]+=1;
	}
      //printf("%d %d %d %d\n",a,b,aa,bb);
    }
  //printf("%d %d %d %d %d\n",team[1],team[2],team[3],team[4],team[5]);

  /* ???1

  temp = 0;
  k = N;
  check = 0;
  //i???team?????????,j???temp??¨???????????????team?????????
  for(i=1;i<=N;i++)
    {
      for(j=1;j<=k;i++)
	{	  
	  if(temp>team[j])
	    {
	      temp = team[j];
	      t = j;
	      check = 0;
	    }
	  else if(temp==team[j])
	    {
	      temp = team[j];
	      t = j;
	      check = 1;
	    }
	}
      if(check==0)
	{
	  rank[t] = i;
	  temp = team[t];
	  k = N;
	}
      else if(check==1)
	{
	  rank[t] = i;
	  temp = team[t];
	  k = t - 1;
	  i--;
	}
    }
  
  for(i=1;i<=N;i++)
    {
      printf("%d\n",rank[i]);
    }
  */

  max = 0;
  for(i=1;i<=N;i++)
    {
      if(max<team[i])
	{
	  max = team[i];
	  temp = i;
	}
    }
  rank[temp] = 1;
  //printf("%d\n",temp);
  
  temp = max;
  ranknum = 1;
  for(;temp>=0;temp--)
    {
      for(j=N;j>0;j--)
	{
	  if(team[j]==temp)
	    {
	      rank[j] = ranknum;
	      //check = 1;
	      check++;
	    }
	}
      /*
      if(check==1)
	  ranknum++;
      */
      ranknum = ranknum + check;
      check = 0;
    }
  
  for(i=1;i<=N;i++)
    {
      printf("%d\n",rank[i]);
    }

  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define float long double
#define f(i,a,b) for(int i = a;i < b;i++)
#define ff(i,a,b)  for(int i = a-1;i>=b;i--)
#define endl '\n'
#define IOS ios_base::sync_with_stdio(false), cin.tie(NULL)
const int mod = 1e9+7;

int32_t main()
{
   IOS;
   int n,i,j,k;
   cin>>n;
   int ans = 0;
   f(i,1,n+1)
      f(j,1,n+1)
        f(k,1,n+1)
          ans += __gcd(i,__gcd(j,k));
    cout<<ans<<endl;
}

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

const int maxn = 1e5 ;
int a[maxn] ;

int main(){

    ios::sync_with_stdio(0) ;
    int n ;
    cin >> n ;
    for(int i = 0; i < n; i++)
        cin >> a[i] ;
    sort(a,a+n) ;
    cout << a[n/2] - a[n/2-1] ;

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod998 = 998244353;
const ll intmax = 2147483647;
const ll llmax = 9223372036854775807;
const char sp = ' ';

struct edge {
	int to, num;
};

int N, res[100000], K;
bool vis[100000];
vector<edge>v[100000];
set<int>st[100000];

void dfs(int x, int a) {
	vis[x] = true;
	int i = 1;
	for (edge e : v[x]) {
		if (vis[e.to])continue;
		if (i == a)i++;
		res[e.num] = i;
		dfs(e.to, i);
		i++;
	}
}

int main() {
	cin >> N;
	for (int i = 0; i < N - 1; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		v[a].push_back({ b,i });
		v[b].push_back({ a,i });
	}
	for (int i = 0; i < N; i++) {
		K = max(K, (int)v[i].size());
	}
	cout << K << endl;
	dfs(0, 0);
	for (int i = 0; i < N - 1; i++) {
		cout << res[i] << endl;
	}
}

Measured memory_bytes: 12288
E = list(map(int, input().split()))
A = E[0]
B = E[1]
C = E[2]
D = E[3]

while True:
  C = C - B 
  if C <= 0:
    print("Yes")
    break
  else:
    A = A - D
    if A <= 0:
      print("No")
      break

Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//using ll = long long;
using P = pair<int,int>;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	vector<int> G[610];
	int n,m,a[200000],b[200000];
	cin >> n >> m;
	for(int i = 0;i < m;i++){
		cin >> a[i] >> b[i]; a[i]--;b[i]--;
		G[a[i]].push_back(b[i]);
	}
	double p[610] = {1},e[610] = {};
	for(int i = 0;i < n;i++){
		for(int to : G[i]){
			p[to] += p[i] / G[i].size();
		}
	}
	for(int i = n - 1;i >= 0;i--){
		for(int to : G[i]){
			e[i] += (e[to] + 1) / G[i].size();
		}
	}
	double mi = e[0];
	for(int i = 0;i < m;i++){
		if(G[a[i]].size() == 1) continue;
		double ea = 0;
		for(int to : G[a[i]]){
			if(to != b[i]) ea += (e[to] + 1) / (G[a[i]].size() - 1);
		}
		chmin(mi,e[0] + p[a[i]] * (ea - e[a[i]]));
	}
	printf("%.12lf\n",mi);
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
#define fi first
#define sd second
#define ll long long
 
using namespace std;
 
const int maxn = 200200;
const int base = 1e9+7;
const ll inf = 1000000009;
 
pair<ll, int> p[maxn],q[maxn];
int n,l[maxn],r[maxn],id[maxn],t[maxn],f[maxn];
 
void update(int i,int k) {
    while (i<=n+1) {
        t[i] = (t[i]+k)%base;
        i+=(i&-i);
    }
}
 
int get(int i) {
    int res=0;
    while (i>0) {
        res = (res+t[i])%base;
        i-=(i&-i);
    }
    return res;
}
 
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
 //   freopen("in.txt","r",stdin);
    cin>>n;
    for (int i=1;i<=n;i++) {
        ll x;
        int v;
        cin>>x>>v;
        p[i] = make_pair(x,v);
    }
    sort(p+1,p+n+1);
    for (int i=1;i<=n;i++) {
        ll s;
        s = p[i].fi + inf*p[i].sd;
        q[i] = make_pair(s,i);
    }
    sort(q+1,q+n+1);
    //cout<<"fuck"<<endl;
    for (int i=1;i<=n;i++) id[q[i].sd] = i;
   // for (int i=1;i<=n;i++) cout<<id[i]<<" ";
    for (int i=1;i<=n;i++) {
        r[i] = id[i];
        if (i>1) r[i] = max(r[i],r[i-1]);
    }
    for (int i=n;i>=1;i--) {
        l[i] = id[i];
        if (i<n) l[i] = min(l[i],l[i+1]);
    }
    //cout<<"fuck"<<endl;
    update(1,1);
    //cout<<get(4)<<"fd"<<endl;
    for (int i=1;i<=n;i++) {
        //cout<<l[i]<<" "<<r[i];
        int sum = (get(r[i]+1) - get(l[i]-1) + base)%base;
        f[r[i]] = (f[r[i]] + sum)%base;
      //  cout<<sum<<endl;
        update(r[i]+1,sum);
    }
    cout<<f[n]<<endl;
}

Measured memory_bytes: 10368