akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	static StringBuilder builder = new StringBuilder();

	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		int n = Integer.parseInt(reader.readLine());
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(reader.readLine());
		}
		shellSort(a, n);
		for (int i = 0; i < n; i++) {
			builder.append(a[i]).append("\n");
		}
		System.out.print(builder);
	}

	private static void shellSort(int[] a, int n) {
		int[] g = new int[15];
		int m = 0;
		/*
		 * for (int i = 0; i < n; i = i * 3 + 1) { for (int j = m; 0 < j; j--) {
		 * g[j] = g[j - 1]; } g[0] = i; m++; } if (m == 0) { g[0] = 1; m = 1; }
		 */
		for (int i = 1; i <= n; i = i * 3 + 1) {
			g[m] = i;
			m++;
		}

		builder.append(m).append("\n");

		m--;
		int cnt = 0;
		for (int i = m; i >= 0; i--) {
			if (i != m)
				builder.append(" ");
			builder.append(g[i]);
			cnt += insertionSort(a, n, g[i]);
		}
		builder.append("\n").append(cnt).append("\n");
	}

	private static int insertionSort(int[] a, int n, int g) {
		int cnt = 0;
		for (int i = g; i < n; i++) {
			int key = a[i];
			int j = i - g;
			while (j >= 0 && a[j] > key) {
				a[j + g] = a[j];
				j = j - g;
				cnt++;
			}
			a[j + g] = key;
		}
		return cnt;
	}
}

Measured memory_bytes: 116276
#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
int r,c,n,cnt;
int getval(int x,int y) {
  if (x != 0 && x != r && y != 0 && y != c)
    return 0;
  if (x == 0) return y + 1;
  if (y == c) return c + 1 + x;
  if (x == r) return c + r + c - y + 1;
  if (y == 0) return c + r + c + r - x + 1; 
  assert(0);
}
struct data {
  int val,id;
  bool operator < (const data& x) const {
    return val < x.val;
  }
} dat[N];
int sta[N],top,vis[N];
int main() {
  int x,y,a,b;
  scanf("%d%d%d",&r,&c,&n);
  for (int i = 1 ; i <= n ; ++ i) {
    scanf("%d%d",&x,&y);
    a = getval(x,y);
    scanf("%d%d",&x,&y);
    b = getval(x,y);
    if (a && b) {
      dat[++cnt] = (data) {a,i};
      dat[++cnt] = (data) {b,i};
    }
  }
  sort(dat+1,dat+cnt+1);
  for (int i = 1 ; i <= cnt ; ++ i) {
    if (!vis[dat[i].id]) sta[++top] = dat[i].id, vis[dat[i].id] = 1;
    else {
      if (sta[top] == dat[i].id) top--;
      else return 0 * printf("NO\n");
    }
  }
  printf("YES\n");
  return 0;
}

Measured memory_bytes: 2432
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
const int inf = 1000000007;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % inf;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), inf - 2, inf) % inf * mod_pow(kai(y), inf - 2, inf) % inf;
}
int a[100010],b[100010];
signed main() {
	int n,ans=0,cnt=0;
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		if (a[i] < 0)cnt++;
		ans += abs(a[i]);
	}
	if (cnt % 2 == 0)cout << ans << endl;
	else {
		rep(i, n) {
			a[i]= abs(a[i]);
		}
		sort(a, a + n);
		cout << ans - a[0] * 2 << endl;
	}
}


Measured memory_bytes: 1024
N,M,C = map(int,input().split())
list_B = list(map(int,input().split()))

cnt = 0
list_A = []
for n in range(N):
  list_A = list(map(int,input().split()))
  out = 0
  for m in range(M):
    out += list_A[m] * list_B[m]

  out += C
  if out > 0:
    cnt += 1


print(cnt)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;
using TextReader = System.IO.TextReader;
using System.Text;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            return consoleReader.String.Count(c => c == '1');
        }

        #region いつもの
#pragma warning disable
        private ConsoleReader consoleReader;
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program(new ConsoleReader(Console.In)).Calc()); static string AllLines<T>(IEnumerable<T> source) => string.Join("\n", source);
    }
    public class ConsoleReader
    {
        private string[] ReadLineSplit() => textReader.ReadLine().Split(Array.Empty<char>(), StringSplitOptions.RemoveEmptyEntries);
        private string[] line = Array.Empty<string>();
        private int linePosition;
        private TextReader textReader;
        public ConsoleReader(TextReader tr) { textReader = tr; }
        public int Int => int.Parse(String);
        public long Long => long.Parse(String);
        public double Double => double.Parse(String);
        public string String
        {
            get
            {
                if (linePosition >= line.Length)
                {
                    linePosition = 0;
                    line = ReadLineSplit();
                }
                return line[linePosition++];
            }
        }
        public class SplitLine
        {
            private string[] splited;
            public SplitLine(ConsoleReader cr) { splited = cr.ReadLineSplit(); cr.line = Array.Empty<string>(); }
            public int[] Int => String.Select(x => int.Parse(x)).ToArray();
            public int[] Int0 => String.Select(x => int.Parse(x) - 1).ToArray();
            public long[] Long => String.Select(x => long.Parse(x)).ToArray();
            public double[] Double => String.Select(x => double.Parse(x)).ToArray();
            public string[] String => splited;
        }
        public SplitLine Split => new SplitLine(this);
        public class RepeatReader : IEnumerable<ConsoleReader>
        {
            ConsoleReader cr; int count;
            public RepeatReader(ConsoleReader cr, int count) { this.cr = cr; this.count = count; }
            public IEnumerator<ConsoleReader> GetEnumerator() => Enumerable.Repeat(cr, count).GetEnumerator();
            System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() => GetEnumerator();

            public IEnumerable<string> String => this.Select(cr => cr.String);
            public IEnumerable<int> Int => this.Select(cr => cr.Int);
            public IEnumerable<int> Int0 => this.Select(cr => cr.Int - 1);
            public IEnumerable<long> Long => this.Select(cr => cr.Long);
            public IEnumerable<double> Double => this.Select(cr => cr.Double);
        }
        public RepeatReader Repeat(int count) => new RepeatReader(this, count);
    }
    #endregion
}

Measured memory_bytes: 13268
a,b,c,x,y = map(int,input().split())
if a+b < 2*c:
    print(a*x + b*y)
else:
    if x>y and a > 2*c:
        print(c*2*x)
    elif y>x and b > 2*c:
        print(c*2*y)
    elif x>=y and a <= 2*c:
        print(c*2*y+ (x-y)*a)
    elif y>=x and b <= 2*c:
        print(c*2*x+ (y-x)*b)

Measured memory_bytes: 3064
number = input()
number_list = list(number)

forward = number_list[0] + number_list[1]
back = number_list[2] + number_list[3]
if int(forward) < 13 and int(forward) > 0 and int(back) < 13 and int(back) > 0:
    print("AMBIGUOUS")
elif int(forward) < 13 and int(forward) > 0:
    print("MMYY")
elif int(back) > 0 and int(back) < 13:
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 3064
s = list(input())
ini = int(s[0])
count = 0
for i in range(1, len(s)):
    if i % 2 == 1:
        if int(s[i]) == ini:
            s[i] = -ini + 1
            count += 1
    else:
      if int(s[i]) != ini:
            s[i] = ini
            count += 1
print(count)

Measured memory_bytes: 54384
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <random>
using namespace std;
#define rep(i, a, n) for (int i = a; i < n; i++)
#define per(i, a, n) for (int i = n - 1; i >= a; i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef double db;
mt19937 mrand(random_device{}());
const ll mod = 1000000007;
int rnd(int x) { return mrand() % x; }
ll powmod(ll a, ll b)
{
	ll res = 1;
	a %= mod;
	assert(b >= 0);
	for (; b; b >>= 1)
	{
		if (b & 1)
			res = res * a % mod;
		a = a * a % mod;
	}
	return res;
}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

static uint MD = mod;
struct ModInt
{
	using M = ModInt;
	uint v;
	ModInt(ll _v = 0) { set_v(uint(_v % MD + MD)); }
	M &set_v(uint _v)
	{
		v = (_v < MD) ? _v : _v - MD;
		return *this;
	}
	explicit operator bool() const { return v != 0; }
	M operator-() const { return M() - *this; }
	M operator+(const M &r) const { return M().set_v(v + r.v); }
	M operator-(const M &r) const { return M().set_v(v + MD - r.v); }
	M operator*(const M &r) const { return M().set_v(uint(ull(v) * r.v % MD)); }
	M operator/(const M &r) const { return *this * r.inv(); }
	M &operator+=(const M &r) { return *this = *this + r; }
	M &operator-=(const M &r) { return *this = *this - r; }
	M &operator*=(const M &r) { return *this = *this * r; }
	M &operator/=(const M &r) { return *this = *this / r; }
	bool operator==(const M &r) const { return v == r.v; }
	M pow(ll n) const
	{
		M x = *this, r = 1;
		while (n)
		{
			if (n & 1)
				r *= x;
			x *= x;
			n >>= 1;
		}
		return r;
	}
	M inv() const { return pow(MD - 2); }
	friend ostream &operator<<(ostream &os, const M &r) { return os << r.v; }
};
using Mint = ModInt;
//head
// cin >> t;
// for (int cas = 1; cas <= t; ++cas)
// {
// 	cout << "Case #" << cas << ": ";
// }
int main()
{
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	vector<int> a(n);
	rep(i,0,n) {
		cin>>a[i];
	}
	vector<ll> dp(n+1,0);
	ll tmps = a[0];
	rep(i,2,n+1) {
		if(i&1) {
			tmps += a[i-1];
			dp[i] = max(a[i-1] + dp[i-2], dp[i-1]);
		}
		else {
			dp[i] = max(a[i-1] + dp[i-2], tmps);
		}
	}
	cout<<dp[n]<<endl;
	return 0;
}


Measured memory_bytes: 5576
from sys import stdin, stdout
import math
import bisect
import queue

w, d, n = map(int, input().strip().split())

mapper = [[-1000 for i in range(55)] for j in range(55)]
step = [[0, 1], [0, -1], [1, 0], [-1, 0]]

arr = []

for i in range(n):
    tmp = tuple(map(int, stdin.readline().strip().split()))
    arr.append(tmp)

flag = 1

for i in range(len(arr)):
    for j in range(i + 1, len(arr)):
        if abs(arr[i][0] - arr[j][0]) + abs(arr[i][1] - arr[j][1]) < abs(arr[i][2] - arr[j][2]):
            flag = 0
            break
    if flag == 0:
        break

if flag == 0:
    stdout.writelines('No\n')
else:
    for each in arr:
        mapper[each[0]][each[1]] = each[2]
        chk = [[0 for i in range(55)] for j in range(55)]
        chk[each[0]][each[1]] = 1
        pend = queue.Queue()
        pend.put(each)
        while pend.qsize():
            top = pend.get()
            for each in step:
                newpos = [top[0] - each[0], top[1] - each[1]]
                if newpos[0] > 0 and newpos[0] <= w and newpos[1] > 0 and newpos[1] <= d and chk[newpos[0]][newpos[1]] < 1:
                    mapper[newpos[0]][newpos[1]] = max(mapper[newpos[0]][newpos[1]], top[2] - 1)
                    chk[newpos[0]][newpos[1]] += 1
                    pend.put((newpos[0], newpos[1], mapper[newpos[0]][newpos[1]]))
    ans = 0
    for i in range(1, w + 1):
        for j in range(1, d + 1):
            ans += mapper[i][j]
    stdout.writelines(str(ans) + '\n')



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

int main() {
  int M1, D1, M2, D2;
  cin >> M1 >> D1 >> M2 >> D2;
  int ans = 1;
  
  if (M1 == M2 && D1+1==D2) ans = 0;
  
  cout << ans << endl;
  
}

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

class Node{
public:
	int depth;
	int height;
	
	int parent;
	int sibling;
	
	int degree;
	int u,v;
	
};

void Depth(Node *node,int cur, int dp){
	
	node[cur].depth = dp;
	if(node[cur].u+1)Depth(node,node[cur].u,dp+1);
	if(node[cur].v+1)Depth(node,node[cur].v,dp+1);
}

void Height(Node *node,int cur){
	
	if(node[cur].degree == 0){
		node[cur].height = 0;
		return;
	}
	
	if(node[cur].u+1)Height(node,node[cur].u);
	if(node[cur].v+1)Height(node,node[cur].v);
	
	if(node[cur].u == -1 && node[cur].v != -1){
		node[cur].height = node[ node[cur].v ].height + 1;
	}
	else if(node[cur].v == -1 && node[cur].u != -1){
		node[cur].height = node[ node[cur].u ].height + 1;
	}
	else{
		node[cur].height = [](int x,int y){return (x>y?x:y);}(node[node[cur].u].height,node[node[cur].v].height)+1;
	}
}

int main() {
	
	int n;
	Node *node;
	
	cin>>n;
	node = new Node[n];
	for(int i=0;i<n;++i){node[i].parent = -1;node[i].sibling = -1;}
	
	
	for(int i=0;i<n;++i){
		int id;
		int u,v;
		int deg=0;
		
		cin>>id>>u>>v;
		node[id].u = u;
		node[id].v = v;
		
		if(u != -1){
			node[u].parent = id;
			node[u].sibling = v;
			deg++;
		}
		if(v != -1){
			node[v].parent = id;
			node[v].sibling = u;
			deg++;
		}
		node[id].degree = deg;
	}
	
	int root;
	for(int i=0;i<n;++i)if(node[i].parent == -1)root = i;
	
	Depth(node,root,0);
	Height(node,root);
	
	for(int i=0;i<n;++i){
		printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",
			i,node[i].parent,node[i].sibling,node[i].degree,node[i].depth,node[i].height
		);
		
		if( i==root )puts("root");
		else if(node[i].degree == 0)puts("leaf");
		else puts("internal node");
	}
	
	return 0;
}

Measured memory_bytes: 1172
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

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

    int mx = min(a+b, b+c);
    mx = min(mx, c+a);

    cout << mx << endl;
    return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define MAX_N 2000000
long long dp[MAX_N];
long long euler(int p) {
	long long q = p;
	for (int i = 2; i*i <= p; i++) {
		if (p%i == 0) { q *= (i - 1); q /= i; }
		while (p%i == 0) { p /= i; }
	}
	if (p != 1) { q *= (p - 1); q /= p; }
	return q;
}
int main() {
	dp[0] = 1;
	for (int i = 1; i < MAX_N; i++) {
		dp[i] = euler(i) + dp[i - 1];
	}
	int T, N;
	cin >> T;
	for (int i = 0; i < T; i++) { cin >> N; cout << dp[N] << endl; }
	return 0;
}

Measured memory_bytes: 16780
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<char> vi;
typedef vector<vi> vii;
int main( ) {
    //freopen("A.01.in","r",stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    vii a(3, vi(3));
    rep(i, 0, 3){
        rep(j, 0, 3){
            cin >> a[i][j];
        }
    }
    cout << a[0][0] << a[1][1] << a[2][2] << endl; 
    return 0;
}

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

int main(){
	int flag=0;
	int flag1=0;
	int a; cin >> a;
	if((a%100)>12 || (a%100)==0){
		flag=1;
		flag1=1;
	}
	else{
		flag=0;
		flag1=0;
	}
	if((a/100)>12 || (a/100==0)){
		flag1=1;
	}
	else{
		flag1=0;
	}
	if(flag==1 && flag1==1){
		cout << "NA";
	}
	else if(flag==1 && flag1==0){
		cout << "MMYY";
	}
	else if(flag==0 && flag1==1){
		cout << "YYMM";
	}
	else if(flag==0 && flag1==0){
		cout << "AMBIGUOUS";
	}
}

Measured memory_bytes: 256
import collections
n = int(input())
a = list(map(int,input().split()))
mae = []
usi = []
for i in range(0,n,2):
  mae.append(a[i])
for i in range(1,n,2):
  usi.append(a[i])
mae = collections.Counter(mae)
usi = collections.Counter(usi)
mae = mae.most_common()
usi = usi.most_common()
if mae[0][0] != usi[0][0]:
  print(n-mae[0][1]-usi[0][1])
else:
  try:
    t = mae[0][1] + usi[1][1]
  except:
    t = 0
  try:
    s = mae[1][1] + usi[0][1]
  except:
    s = 0
  u = mae[0][1]
  print(n-max(t,s,u))

Measured memory_bytes: 64772
N = gets.to_i
H = gets.split(" ").map(&:to_i)
dp = []
(10 ** 5).times{|i|
    dp[i] = 10**9
}
dp[0] = 0
dp[1] = (H[0] - H[1]).abs
(2...N).each{|i|
    dp[i] = dp[i] > dp[i-1] + (H[i-1] - H[i]).abs ? dp[i-1] + (H[i-1] - H[i]).abs : dp[i]
    dp[i] = dp[i] > dp[i-2] + (H[i-2] - H[i]).abs ? dp[i-2] + (H[i-2] - H[i]).abs : dp[i]
}
puts dp[N-1]

Measured memory_bytes: 8844
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
typedef pair<int, int> P;


signed main(){
	string s;
    cin >> s;
    int n = s.size();
    int ans = 0;
    for(int i = 0; i < (1 << (n - 1)); i++){
        int tmp = 0;
        rep(j, 0, n - 1){
            tmp = 10 * tmp + (s[j] - '0');
            if(i & (1 << j)){
                // cout << i << " " << j << ' ' << tmp << endl;
                ans += tmp;
                tmp = 0;
            }
        }
        // cout << i << ' ' <<  tmp * 10 + (s[n - 1] - '0') << endl;
        ans += tmp * 10 + (s[n - 1] - '0');
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
const int Q=1<<17;
char s[Q];
int sm[Q];
int f[3];
const int MOD=1e9+7;
inline int add(int a,int b)
{a+=b;return a>=MOD?a-MOD:a;}
int main()
{
    scanf("%s",s+1);
    int n=strlen(s+1);
    int fl=0;
    for(int i=1;i<=n;i++){
        sm[i]=(sm[i-1]+(s[i]=='a'?1:2))%3;
        if(i>1&&s[i]==s[i-1])fl=1;
    }
    if(!fl)return printf("1")&0;
    for(int i=n;i>=0;--i){
        int now=sm[i]==sm[n];
        now=add(now,add(f[(sm[i]+1)%3],f[(sm[i]+2)%3]));
        f[sm[i]]=now;
    }
    printf("%d",add(f[1],f[2]));
    return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(int i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,ll> P;
typedef long double ld;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    ll d, a;
    cin >> n >> d >> a;
    vector<P> p(n);
    rep (i, n) cin >> p[i].second >> p[i].first;
    sort(all(p), [](P x, P y){return x.second < y.second;});
    rep (i, n) p[i].first = (p[i].first - 1) / a + 1;
    int imo[n + 1] = {};
    ll ans = 0;
    rep (i, n) {
        if (p[i].first + imo[i] > 0) {
            int ok = i - 1, ng = n;
            while (ng - ok > 1) {
                int med = (ng + ok) / 2;
                if (p[med].second - p[i].second <= 2 * d) ok = med;
                else ng = med;
            }
            int tmp = p[i].first + imo[i];
            imo[i] -= tmp;
            imo[ok + 1] += tmp;
            ans += tmp;
        }
        imo[i + 1] += imo[i];
    }
    cout << ans << "\n";
    return 0;
}

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

using namespace std;

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

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second

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

const int N = 200500;
const int M = 500;
const int MOD = 1e9 + 7;
const int alpha = 26;
const double PI = acos(-1);

ll n;
ll c[N];
vector<pair<int, int> > pos[N];
ll depth[N];
ll sz[N];
int t = 0;
ll in[N], out[N];
vector<int> graph[N];
vector<int> ch[N];

void dfs(int v, int p, int de)
{
    depth[v] = de;
    in[v] = t++;
    sz[v] = 1;
    for (auto u : graph[v]) if (u != p)
    {
        dfs(u, v, de + 1);
        ch[v].push_back(u);
        sz[v] += sz[u];
    }
    out[v] = t - 1;
}

ll fenw[N];

ll Get1(ll pos)
{
    ll res = 0;
    while (pos >= 0)
    {
        res += fenw[pos];
        pos = (pos & (pos + 1)) - 1;
    }
    return res;
}

void Add1(ll pos, ll val)
{
    while (pos < N)
    {
        fenw[pos] += val;
        pos = pos | (pos + 1);
    }
}

ll Get(ll pos)
{
	ll x = Get1(pos);
	return x;
}

void Add(ll pos, ll val)
{
	Add1(pos, val);
}

ll f(ll x)
{
	return x * (x + 1) / 2;
}

signed main()
{
    #ifdef ONLINE_JUDGE
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
    #endif // ONLINE_JUDGE
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> c[i];
    }
    for (int i = 1; i < n; i++)
    {
        int a, b;
        cin >> a >> b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    dfs(1, 0, 0);
    for (int i = 1; i <= n; i++)
    {
        pos[c[i]].push_back({depth[i], i});
    }
    for (int i = 1; i <= n; i++)
    {
        if (pos[i].size() == 0)
        {
            cout << 0 << "\n";
            continue;
        }
        sort(rall(pos[i]));
        ll ans = f(n);
        vector<pll> st;
        for (auto it : pos[i])
        {
            int v = it.second;
            ll cursz = sz[v] - Get(out[v]) + Get(in[v] - 1);
            Add(in[v], cursz);
            st.push_back({in[v], cursz});
            for (auto u : ch[v])
            {
                ll cursz = sz[u] - Get(out[u]) + Get(in[u] - 1);
                ans = ans - f(cursz);
            }
        }
        if (c[1] != i)
        {
        	ans = ans - f(sz[1] - Get(out[1]) + Get(in[1] - 1));
        }
        while (st.size())
        {
        	Add(st.back().first, -st.back().second);
        	st.pop_back();
        }
        cout << ans << "\n";
    }
}


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

const int AS = 1000000;

int main() {
    int s;
    cin >> s;
    vector<int> a(AS+1);
    a.at(1) = s;
    int ret = -1;
    auto f = [](int n, vector<int> &a, int end) {
        for (int j = 1; j < end; j++) {
            if (a.at(j) == n) {return j;}
        }
        return -1;
    };
    int n;
    for (int i = 2; i < AS; i++) {
        n = a.at(i-1);
        a.at(i) = (n%2==0) ? n/2 : n*3 + 1;
        int tmp = f(a.at(i), a, i);
        if (tmp != -1) {
            ret = i;
            break;
        }
    }
    cout << ret << endl;
}

Measured memory_bytes: 4096
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#define type 26

int constant(int day)//1~26 順番
{
  return day%type+1;
}
int get_random()//1~26 ランダム
{
  return rand()%type+1;
}
int max(int s[][type+1],int day)
{
  int m,max_score=0,i;
  for(i=1;i<=type;i++)
  {
    if(s[day][i]>max_score){
      max_score=s[day][i];
      m=i;
    }
  }
  return m;
}
void cal(int select,int c[type+1],int last[type+1],int s[][type+1],int day,int sum[])
{
  int i;
  sum[day]=sum[day-1]+s[day][select];
  for(i=1;i<=type;i++){
    sum[day]-=c[i]*(day-last[i]);
  }
}
void change(int c[type+1],int last[type+1],int s[][type+1],int sum[],int schedul[],int D)
{
  int d,t,old,total=0,i,j;
  d=rand()%D+1;
  t=rand()%type+1;
  old=schedul[d];
  schedul[d]=t;
  for(i=1;i<=type;i++) last[i]=0;
  for(i=1;i<=D;i++){
    total+=s[i][schedul[i]];
    last[schedul[i]]=i;
    for(j=1;j<=type;j++){
     total-=c[j]*(i-last[j]);
   }
  }
  if(total>sum[D]){
  //  printf("change\n");
    sum[D]=total;
  }
  else{
    schedul[d]=old;
  }
}
int main(void)
{
  int D,c[type+1],i,j;
  clock_t start,stop;
  srand((unsigned int)time(NULL));
  scanf("%d",&D);//D=365
  int s[D+1][type+1],last[type+1],sum[D+1],schedul[D+1];
  for(i=0;i<=D;i++) sum[i]=0;
  for(i=1;i<=type;i++) last[i]=0;
  for(i=1;i<=type;i++) scanf("%d",&c[i]);
  for(i=1;i<D+1;i++){
    for(j=1;j<=type;j++) scanf("%d",&s[i][j]);
  }
  start=clock();
  for(i=1;i<D+1;i++){
    int select;
    select=max(s,i);
    last[select]=i;
    schedul[i]=select;
    cal(select,c,last,s,i,sum);
    //printf("%d\n",sum[i]);
  }
  int count=0;
  stop=start;
  while((double)(stop - start) / CLOCKS_PER_SEC<1.98){
    change(c,last,s,sum,schedul,D);
    count++;
    stop=clock();
  }
  /*
  printf("count:%d\n",count);
  printf("time:%f\n",(double)(stop - start) / CLOCKS_PER_SEC);
  printf("%d\n",sum[D]);
  printf("確認\n");
  int total=0;
  for(i=1;i<=type;i++) last[i]=0;
  for(i=1;i<=D;i++){
    total+=s[i][schedul[i]];
    last[schedul[i]]=i;
    for(j=1;j<=type;j++){
     total-=c[j]*(i-last[j]);
   }
  }
  printf("%d\n",total);
*/
  for(i=1;i<=D;i++) printf("%d\n",schedul[i]);
  return 0;
}


Measured memory_bytes: 1816
<?php
$stdins = array();
while(true){
    $stdin = trim(fgets(STDIN));
    if($stdin === '') break;
    $stdins[] = $stdin;
}

$works = explode(" ", $stdins[1]);
$works[0] + $works[1];

$N = $stdins[0];
$D = $works[0];
$X = $works[1];

$total = $X;
for($i=0;$i<$N;$i++){
    $power = $stdins[2+$i];
    for($j=1;$j<=$D;$j++){
        // print("OK: $i $j $power ".($j%$power)."\n");
        if($power == 1 || $j%$power == 1){
            $total += 1;
        }
    }
}
print($total);
//print_r(get_defined_vars(true));


Measured memory_bytes: 3828
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		
		String str = stdIn.nextLine();
		String[] s = str.split(" ");
		StringBuilder result = new StringBuilder();
		for(int i = 0; i < s.length; i++){
			if( s[i].equals("apple") ){
				s[i] = "peach";
			} else if( s[i].equals("peach") ){
				s[i] = "apple";
			} else if( s[i].length() > 5 ){
				int start = 0;
				int indexA;
				int indexP;
				while( (indexA = s[i].indexOf("apple", start)) >= 0 || (indexP = s[i].indexOf("peach", start)) >= 0 ){
					indexP = s[i].indexOf("peach", start);
					int key = indexA;
					if( key < 0 ){
						key = indexP;
					} else if( indexP >= 0 && key > indexP ){
						key = indexP;
					}
				//	System.out.println(key);
					StringBuilder temp = new StringBuilder(s[i]);
					if( s[i].charAt(key) == 'a' ){
						temp.replace(key, key+5, "peach");
					} else {
						temp.replace(key, key+5, "apple");
					}
					s[i] = temp.toString();
					start = key+5;
				}
			}
			result.append(s[i] + " ");
		}
		result.deleteCharAt(result.length()-1);
		System.out.println(result);
	}
}

Measured memory_bytes: 12000
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = readLn >>= print . lucas 2 1 0

lucas :: Integer -> Integer -> Int -> Int -> Integer
lucas !a _ _ 0 = a
lucas _ !b _ 1 = b
lucas !a !b k n
	| k == n = a
	| otherwise = lucas b ( a + b ) ( k + 1 ) n


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;
 
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;
 
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 GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }


signed main()
{
  int n; cin>>n;
  int ans=n/2;
  if(n%2==0)ans--;
  cout<<ans<<endl;
}


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

using namespace std;

int main (void) {
    int K, S;
    cin >> K >> S;

    long long ans = 0;
    for ( int x = 0; x <= K; x++ ) {
        for ( int y = 0; y <= K; y++ ) {
            int z = S - x - y;
            if ( z < 0 ) break;
            if ( K < z ) continue;
            ans++;
        }
    }

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


Measured memory_bytes: 3608
F = [[[0] * 10 for i in range(3)] for i in range(4)]
n = int(input())
for i in range(n):
 b, f, r, v = map(int, input().split())
 F[b-1][f-1][r-1] += v
for x in range(0, 4):
 for y in range(0, 3):
  for z in range(0, 10):
   print(" {0}".format(F[x][y][z]), end = '')
  print()
 if x != 3:
  print("#" * 20)

Measured memory_bytes: 7736
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		double T = Integer.parseInt(scanner.next());
		double X = Integer.parseInt(scanner.next());
		
		double ans = T / X;
		
		BigDecimal bigDecimal = new BigDecimal(ans);
		
		bigDecimal = bigDecimal.setScale(7,  BigDecimal.ROUND_HALF_UP);
		
		System.out.printf("%.7f", bigDecimal);
	}
}

Measured memory_bytes: 22868
N,K=gets.split.map(&:to_i)
A=gets.split.map(&:to_i)

COUNT=Array.new(40,0)
A.each do |a|
    40.times do |i|
        COUNT[i]+=1 if a[i]==1
    end
end
DP=Array.new(40){Array.new(2)}

def get_val(order,underflag)
    return DP[order][underflag] if DP[order][underflag]
    val_0=2**order*COUNT[order]
    val_01=2**order*[COUNT[order],N-COUNT[order]].max
    if order!=0
        g01,g0=get_val(order-1,1),get_val(order-1,0)
    else
        g01,g0=0,0
    end
    ans=-1
    if underflag==1
        ans=val_01+g01
    elsif K[order]==1
        ans=[val_0+g01,val_01+g0].max
    else
        ans=val_0+g0
    end
    return DP[order][underflag]=ans
end

p get_val(39,0)

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

template<typename T>
istream& operator >> (istream& istr, vector<T>& vec){
    for(T& x: vec) istr >> x;
    return istr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<T>& vec){
    if(!vec.empty()){
        ostr << vec.front();
        for(auto itr = ++vec.begin(); itr != vec.end(); itr++)
            ostr << " " << *itr;
    }
    return ostr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<vector<T>>& mat){
    if(!mat.empty()){
        ostr << mat.front();
        for(auto itr = ++mat.begin(); itr != mat.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, pair<T,U>& p){
    ostr << p.first << " " << p.second;
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, vector<pair<T,U>>& mat){
    if(!mat.empty()){
        ostr << mat.front();
        for(auto itr = ++mat.begin(); itr != mat.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

typedef long long ll;
typedef vector<ll> vll;
typedef vector<char> vc;
// vll x(n); x[i]=a;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
// vvll x(m,vi(n)); x[i][j]=a;
typedef pair<ll,ll> pll;
typedef vector<pair<ll,ll>> vpll;
// vpll x(n); x[i]={a,b}; x[i].first/second;

#define PI 3.1415926535897932
#define REP(i,n) for(ll i=0; i<(n); i++)
#define RREP(i,n) for(ll i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORR(i,a,b) for(ll i=(b)-1; i>=(a); i--)
#define dump(x) cout << #x << " = " << (x) << endl
#define all(x) (x).begin(),(x).end()
// sort(all(x));

int main(){
    ll n, k, ans = 0, tmp = 0;
    cin >> n >> k;
    vll a(n);
    cin >> a;
    REP(i,n) if(a[i]>=k) ans++;
    cout << ans << endl;
    return 0;
}


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

int main()
{
    int a,b;
    cin >> a >> b;
    
    if((a*b)%2==0)
    {
        cout << "No";
    }
    else
    {
        cout << "Yes";
    }
}


Measured memory_bytes: 3008
#include<iostream>
#include<cstdio>
using namespace std;
const int mod=1e9+7;
int n,k,dp[2005];
long long power(long long x,int k) {
	if(k<0) return 1;
	long long y=1;
	while(k) if(k&1) (y*=x)%=mod,(x*=x)%=mod,k>>=1; else (x*=x)%=mod,k>>=1;
	return y;
}
int main() {
	scanf("%d%d",&n,&k),dp[0]=1;
	for(int i=1;i<n;i++,dp[0]=dp[1]) for(int j=i;j;j--) dp[j]=(dp[j+1]+dp[j-1])%mod;
	return !printf("%d\n",1ll*dp[n-k]*power(2,n-k-1)%mod);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iterator>
#include <string>
#define rep(i, cc, n) for (int i = cc; i < n; ++i)
using namespace std;
using ll = long long;

int main()
{
    int D;
    cin >> D;

    vector<int> C(26);
    vector<int> conts(26, 0);
    rep(i, 0, 26)
    {
        int c;
        cin >> c;

        C[i] = c;
    }

    vector<vector<int>> S(D, vector<int>(26));
    rep(i, 0, D)
    {
        rep(j, 0, 26)
        {
            int s;
            cin >> s;
            S.at(i).at(j) = s;
        }
    }

    rep(d, 1, D + 1)
    {
        int max = 0;
        int memo = 0;
        rep(j, 0, 26)
        {
            rep(k, 0, 26)
            {

                int satit = 0;
                if (k == j)
                {
                    satit += S.at(d - 1).at(j);
                }
                else
                {
                    satit -= C[j] * (d - conts[j]);
                }

                if (satit > max)
                {
                    max = satit;
                    memo = k;
                }
            }
        }
        cout << memo + 1 << endl;
        conts[memo] = d;
    }
}


Measured memory_bytes: 3268
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
//const long long mod = 1000000007;
const long long mod = 998244353;
int main() {
	int N;
	scanf("%d", &N);
	std::string* s = new std::string[N];
	for (int i = 0; i < N; i++) {
		char q[11];
		scanf("%s", q);
		std::sort(q, q + 10);
		s[i] = q;
	}
	std::sort(s, s + N);
	std::string c;
	long long n = -1;
	long long res = 0;
	for (int i = 1; i < N; i++) {
		if (n == -1) {
			if (s[i] == s[i - 1]) {
				n = 2;
				c = s[i];
			}
		}
		else {
			if (s[i] == c) {
				n++;
			}
			else {
				res += n * (n - 1) / 2;
				n = -1;
			}
		}
	}
	if (n != -1) {
		res += n * (n - 1) / 2;
	}
	printf("%lld", res);
	return 0;
}

Measured memory_bytes: 5760
#include <stdio.h>
#define N 100000

int binarySearch(int x);

int s[N], t[N], n, q;

int main()
{
  int i, j, c=0;;

  scanf("%d", &n);
  for(i=0; i<n; i++)
    scanf("%d", &s[i]);

  scanf("%d", &q);
  for(i=0; i<q; i++)
    scanf("%d", &t[i]);

  
  for(i=0; i<q; i++){
    if(binarySearch(i)!=-1) c++;
  }
  printf("%d\n",c);

  return 0;
}

int binarySearch(int x)
{
  int left = 0, right = n, mid=0;

  while(left<right){
    mid = (left + right) / 2;
    if(s[mid] == t[x]) return mid;
    else if(t[x]<s[mid]) right = mid;
    else left = mid + 1;
  }
  return -1;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int n, m, c;cin >> n >> m >> c;
    vector<int> b(m);
    int ans = 0;
    inc(i, 0, m) cin >> b[i];
    inc(i, 0, n){
        int sum = c;
        inc(j, 0, m){
            int a;cin >> a;
            sum += a*b[j];
        }
        if(sum > 0) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
// by newbiechd
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>

// DELETE the debugging information!
#define debug(x) std::cerr << #x << " = " << (x) << std::endl

int read() {
  int f = 0;
  char ch;
  while (!isdigit(ch = getchar()));
  do f = 10 * f + (ch ^ '0');
  while (isdigit(ch = getchar()));
  return f;
}

const int N_MAX = 100003, mod = 1e9 + 7;
char s[N_MAX];
int dp[N_MAX];

int main() {
  scanf("%s", s + 1);
  int n = strlen(s + 1), lst = n + 1, sum = 0;
  dp[n + 1] = 1;
  for (int i = n; i > 0; --i) {
    sum = (sum + s[i] - 'a' + 1) % 3;
    if (s[i] == s[i + 1])
      lst = i + 1;
    dp[i] = (dp[i + 1] + dp[lst + 1] + (sum == 0)) % mod;
  }
  printf("%d\n", lst <= n ? (dp[1] - (sum == 0) + mod) % mod : 1);
  return 0;
}


Measured memory_bytes: 768
//??:2s   空?:512MB
//?意:要求求出最短的字典序最小的括号序列
//要求移?n次可以使他合法
//算法:通?枚???,...)))(((....,??是n*(n+1)/2的最?解
//所以?个之?就可以将最左?的(向左移?相?的位置
//可以??理出所有的n*(n+1)/2 
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
ll f[50005];
int chuli(int n){
	for(int i=1;i<=50000;i++){
		f[i]=i*(i+1)/2;
		if(f[i]>=n)return i;
	}	
}
void print(int x){
	for(int i=1;i<=x;i++)
		printf(")");
	for(int i=1;i<=x;i++)
		printf("(");
	printf("\n");
}
int main(){
//	freopen("a.in","r",stdin);
	int n;
	scanf("%d",&n);
	int ans=chuli(n);
	if(f[ans]==n)print(ans);
	else{
		int delt=f[ans]-n;
		for(int i=1;i<=ans-f[ans]+n;i++)
			printf(")");
		printf("(");
		for(int i=ans-f[ans]+n+2;i<=ans+1;i++)
			printf(")");
		for(int i=1;i<=ans-1;i++)
			printf("(");
		printf("\n");
	}
	return 0;
} 

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

typedef long long ll;
//loop
#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 FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//STL
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

//const
#define MOD 1000000007 //10^9+7:合同式の法

//acronym
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

void Main() {
    vector<int> pack(3);
    REP(i,3) {
        cin >> pack.at(i);
    }
    sort(ALL(pack));
    if (pack[0] + pack[1] == pack[2]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	Main();
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<pii>
#define read(FILE)  freopen(FILE, "r", stdin);
#define out(FILE) freopen(FILE, "w", stdout);
#define clr(x, y) memset(x,y,sizeof(x));
#define IO ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(),x.end()
#define rep(i, m, n) for(int i=m ; i<n ; i++)
#define forr(i, m, n) for(ll i=m ; i<=n ; i++)
#define endl '\n'
#define pb push_back
#define re return
const int N = 2e5 + 5;
const ll OO = 1e9+7;
using namespace std;
ll n;
ll arr[N];
ll dp[N][3];
ll knap1(ll i ,ll c)
{
    if(i>=n)
        return 0;
    if(dp[i][c]!=LONG_LONG_MAX)
        return dp[i][c];
    if(c==0)
        return dp[i][c]=max(arr[i]+knap1(i+2,0),max(arr[i+1]+knap1(i+3,1),arr[i+2]+knap1(i+4,2)));
    if(c==1)
        return dp[i][c]=max(arr[i]+knap1(i+2,1),arr[i+1]+knap1(i+3,2));
    else
        return dp[i][c]=arr[i]+knap1(i+2,2);
}
ll knap(ll i ,ll c)
{
    if(i>=n)
        return 0;
    if(dp[i][c]!=LONG_LONG_MAX)
        return dp[i][c];
    if(c==0)
        return dp[i][c]=max(arr[i]+knap(i+2,0),arr[i+1]+knap(i+3,1));
    else
        return dp[i][c]=arr[i]+knap(i+2,1);
}
int main()
{
    cin>>n;
    rep(i,0,n)
    {
        cin>>arr[i];
    }
    rep(i,0,N){
        rep(j,0,3){
            dp[i][j]=LONG_LONG_MAX;
        }
    }

    ll sum=0;
    if(n%2==0)
        cout<<knap(0,0);
    else
        cout<<knap1(0,0);
    return 0;
}


Measured memory_bytes: 20780
#include <iostream>
#include <string>
#include <utility>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
#include <tuple>
using namespace std;
using ll=long long;
ll gcd(ll a,ll b){return (b==0?a:gcd(b,a%b));}
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,n) for(int i=a;i<n;i++)
constexpr ll INF=1000000011;

int main (){
    int a,b;
    cin >> a >> b;

    if(a>b*2){
        cout << a-b*2 << endl;
    }
    else {
        cout << "0" << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define mod 1000000007
typedef long long int ll;
ll dp[100001];
int u(const void *a, const void *b){
    return *(ll*)a-*(ll*)b;
}
int d(const void *a, const void *b){
    return *(ll*)b-*(ll*)a;
}
int z(int a){
  if(a<1)a*=-1;
  return a;
}
int min(int a,int b){
  if(a>b)return b;
  return a;
}
int max(int a,int b){
  if(a>b)return a;
  return b;
}
int gcd(int a,int b){
  if(!b)return a;
  return gcd(b,a%b);
}
int main(void) {
  int t,n,ans,a[4]={6,4,3,2};
  FOR(4){
    scanf("%d %d",&t,&n);
    PRN(a[t-1]*n*1000);
  }
  return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pii;
#define RI(a) scanf("%d",&a)
#define RII(a,b) scanf("%d%d",&a,&b)
#define RIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define F first
#define S second
#define REP(i,n) for(int i=0;i<(n);i++)
#define mp make_pair
#define pb push_back
#define forn(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define ford(i, a, n) for (int i = (int)(n - 1); i >= (int)(a); --i)
#define fore(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second

const int MOD = 1e9+7;
const int inf = 1e9+9;
const long long INF = 1e18+3;
const ld eps = 1e-9;
int main(){
    int n;
    cin>>n;

    int a[n+1],ans=0;
    fore(i,1,n) cin>>a[i];
    fore(i,1,n) if(i==a[a[i]] && i!=a[i]) ans++;
    ans>>=1;
    cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 640
#include<stdio.h>

/*ûj BMI©çQQðø¢½lÅär·é*/

int main(){
  int i,h,w,n,j,no=100000000;
  double BMI,BMI2=1000,BMIH;

  while(1){
    scanf("%d",&n);
    if(n==0)break; /*whileI¹ð*/

    for(j=0;j<n;j++){
      scanf("%d%d%d",&i,&h,&w);
      BMI=(double)w/((h/100.0)*(h/100.0));
      BMIH=(BMI-22);

      if(BMIH<0)
	{
	  BMIH=-BMIH;
	}

      if(BMIH<BMI2)
	{
	  BMI2=BMIH;
	  no=i;
	}
      else if(BMIH==BMI && i<no)
	{
	  no=i;
	}
      
    }/*E for*/

    printf("%d\n",no);
    no=100000000;
    BMI2=1000;
  } /*E while*/
  
    return 0;
}/*E main*/

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
    double a, b, h, m; cin >> a >> b >> h >> m;
    double theta_x = 30 * h + 6*(m/12.0);
    double theta_y = 6 * m;
    double theta = abs(theta_x - theta_y);
    double cs = cos(M_PI /180.0 * theta);
    double ans = sqrt(a*a + b*b - 2*a*b*cs);
    printf("%10.10f\n", ans);
}


Measured memory_bytes: 4168
#include <bits/stdc++.h>
using namespace std;
#define pi pair<int,int>
#define ff first
#define ss second
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#define int long long
#include "string"

int32_t main(){
	boost;
	int n,k;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	int sum = 0;
	for(int i=0;i<k;i++)
		sum += a[i];
	cout<<sum<<endl;				
}

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

int main()
{
    long long n,k;
    cin>>n>>k;
    long long a[n];
    for(long long i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    long long ans=0;
    for(long long i=0;i<=n-k-1;i++){
        ans+=a[i];
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 1792
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const [X, Y] = input[0].map(Number);

  for (let i = 0; i <= X; i++) {
    if (Y === i * 2 + (X - i) * 4) {
      return "Yes";
    }
  }

  return "No";
};

console.log(main(read()));


Measured memory_bytes: 29636