akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
const int maxn=2e5+1;
const int MX=5e6+1;
ll a[51];
int main(){
    ll k;
    cin>>k;
    if (k%50==0){
        ll del=k/50;
        int n=50;
        cout<<n<<"\n";
        for(int i=1; i<=n; ++i)
            cout<<del+49<<" ";
        return 0;
    }
    ll ost=k%50;
    ost=50-ost;
    ll del=k/50;
    del++;
    int n=50;
    cout<<n<<"\n";
    for(int i=1; i<=n; ++i){
        a[i]=del+49;
    }
    for(int i=n; i>n-ost; --i){
        a[i]=a[i]+ost-51;
    }
    for(int i=1; i<=n-ost; ++i)
        a[i]+=ost;
    for(int i=1; i<=n; ++i)
        cout<<a[i]<<" ";

}


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

int main()
{
  int n;
  cin >> n;
  int ans[4]={0};
  string s;
  for(int i=0; i<n; i++){
    cin >> s;
    if(s=="AC")
      ans[0]++;
    else if(s=="WA")
      ans[1]++;
    else if(s=="TLE")
      ans[2]++;
    else if(s=="RE")
      ans[3]++; 
  }

  cout << "AC x " << ans[0] << endl;
  cout << "WA x " << ans[1] << endl;
  cout << "TLE x " << ans[2] << endl;
  cout << "RE x " << ans[3] << endl;

  return 0;
}

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

#define ll long long
queue<ll>m;

int main()
{
    int k;
    cin >> k;
    for (int i = 1; i <= 9; i++)
        m.push(i);

    int j = 1;

    while (j < k)
    {
        ll p = m.front();
        m.pop();
        j++;

        ll u = p % 10;

        if (u != 0)
            m.push(p * 10 + u - 1);

        m.push(p * 10 + u);

        if (u != 9)
            m.push(p * 10 + u + 1);
    }
    cout << m.front() << endl;
}


Measured memory_bytes: 1792
h, w, n = map(int,input().split())
 
xy_pos = dict()
 
for i in range(n):
    a, b = map(int, input().split())
    for k in range(-2,1):
        for l in range(-2,1):
            x = (a-1) + k
            y = (b-1) + l
            if (0 <= x <= h-3 and 0 <= y <= w-3):
                xy = str(x) + "x" + str(y)
                if xy in xy_pos:
                    xy_pos[xy] += 1
                else:
                    xy_pos[xy] = 1
 
ans = [0]*10                    
for v in xy_pos.values():
    ans[v] += 1
ans[0] = (h-2)*(w-2) - sum(ans)
for i in range(10):
    print(ans[i])

Measured memory_bytes: 126088
#include <bits/stdc++.h>
#define ll unsigned long long int
using namespace std;
int main()
{	
	int n,a[200000],el=1,c=0,i;
	cin>>n;
	for(i=0;i<n;i++)
	{	cin>>a[i];
		if(a[i]==el)
		{	c++;
			el++;
		}
	}
	if(c==0)
		cout<<-1<<endl;
	else cout<<n-c<<endl;
		
		
	
	
		
}


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

int main(){
  int N, T, ans = 1001;
  cin >> N >> T;
  int c[N], t[N];
  for (int i = 0; i < N; i++) {
    cin >> c[i] >> t[i];
    if (T >= t[i] && ans > c[i]) {
      ans = c[i];
    }
  }
  if (ans == 1001) {
    cout << "TLE" << endl;
  } else {
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;

int h,w,n;
char board[1005][1005];
int x[10],y[10];
bool check(int i, int j) {
	return (i >= 1) && (i <= h) && (j >= 1) && (j <= w) && (board[i][j] == '.');
}
int d[1005][1005];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(void){
    ll n;
    cin>>n;
    vector<ll>a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    if(n==1){
        cout<<1<<endl;
        return 0;
    }
    ll ans = 0;
    for(int i=0;i<n;){
        if(i==n-1){
            ans++,i++;
            continue;
        }
        if(a[i]<a[i+1]){
            while(true){
                if(i==n)break;
                if(a[i]<=a[i+1])i++;
                else {
                    i++;
                    break;
                }
            }
            ans++;
        }
        else{
            if(a[i]==a[i+1]) i++;            
            else{
                while(true){
                    if(i==n)break;
                    if(a[i]>=a[i+1])i++;
                    else {
                        i++;
                        break;
                    }
                }
                ans++;
            }
        }
        //cout<<ans<<endl;
    }
    cout<<ans<<endl;
    return 0;
}

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

int solve_testcase() {
  int N; cin >> N;
  if(N == 0) return 1;

  vector<int> P(N), d1(N), d2(N);
  int max_val = -1, ans = -1;
  for(int i=0; i<N; i++) {
    cin >> P[i] >> d1[i] >> d2[i];
    if(d1[i] + d2[i] > max_val) {
      max_val = d1[i] + d2[i];
      ans = P[i];
    }
  }
  cout << ans << " " << max_val << endl;
  return 0;
}

int main() {
  while(!solve_testcase());
  return 0;
}



Measured memory_bytes: 3128
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int main(void)
{
	int A, B;
	cin >> A >> B;
	string S;
	cin >> S;
	int cnt = 0;
	int pla = -1;
	int i = 0;
	for (char c : S) {
		if (c == '-') {
			++cnt;
			pla = i;
		}
		i++;
	}
	if (cnt == 1 && pla == A) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i,n) cin >> d[i];
    int ans = 0;
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = i+1; j < n; j++)
        {
            ans += d[i] * d[j];
        }
        
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  if (N==M) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3540
#include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>
#include <unistd.h>
#include <ctime>
#include <queue>
#include <cmath>
#include <set>

using namespace std;

#define TRACE(x) cerr << #x << " = " << x << endl
#define REP(i, n) for (int i=0; i<n; i++)
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
#define _ << " " <<

typedef long long ll;
typedef pair<int, int> P;
#define X first
#define Y second

const int MAX = 3005, MOD = 1e9 + 7;

int add(int a, int b) {
  a += b;
  if (a >= MOD) a -= MOD;
  return a;
}

int sub(int a, int b) {
  a -= b;
  if (a < 0) a += MOD;
  return a;
}

int mul(int a, int b) {
  return (int) (((ll) a * b) % MOD);
}

int eksp(int b, int e) {
  int r=1;
  for (; e; e/=2, b=mul(b, b))
    if (e & 1) r = mul(r, b);
  return r;
}

int invv(int x) {
  return eksp(x, MOD-2);
}

int n, q;
int dp[MAX][MAX];
int p[MAX];
//double dp[MAX][MAX];
int inv2;

int main()
{
  inv2 = invv(2);
  scanf("%d%d", &n, &q);
  //n = q = 3000;

  REP(i, n) {
    scanf("%d", &p[i]); p[i]--;
    //    p[i] = rand() % 1000;
  }

  REP(i, n) REP(j, n) {
    dp[i][j] = p[i] > p[j];
  }

  REP(qq, q) {
    int a, b;
    scanf("%d%d", &a, &b); a--; b--;
    // a = rand() % n;
    // b = rand() % n;
    //    dp[a][b] = dp[b][a] = mul(inv2, sub(1, isti[a][b]));
    dp[a][b] = dp[b][a] = mul(inv2, add(dp[a][b], dp[b][a]));

    REP(i, n) {
      if (i == a || i == b) continue;

      dp[a][i] = dp[b][i] = mul(inv2, add(dp[a][i], dp[b][i]));
      dp[i][a] = dp[i][b] = mul(inv2, add(dp[i][a], dp[i][b]));
    }
  }


  int sol = 0;
  REP(i, n) FOR(j, i+1, n)
    sol = add(sol, dp[i][j]);

  // REP(i, n) {
  //   FOR(j, i+1, n) printf("%d ", mul(eksp(2, q), dp[i][j]));
  //   printf("\n");
  // }

  sol = mul(sol, eksp(2, q));

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

  return 0;
}


Measured memory_bytes: 35456
#include<cstdio>

int n, k;
int cnt[1000][2000][2];
int dp[1000][2000];
int sum[1000][2000];

int main() {
    scanf("%d %d", &n, &k);
    for (int i = 0; i < n; i++) {
        int x, y;
        char c;
        scanf("%d %d %c", &x, &y, &c);
        int a = x % (2 * k);
        int b = y % (2 * k);
        if (a < k) cnt[a][b][c == 'W']++;
        else if (b < k) cnt[a - k][b + k][c == 'W']++;
        else cnt[a - k][b - k][c == 'W']++;
    }
    
    for (int i = 0; i < k; i++) {
        for (int j = 0; j < k; j++) {
            dp[i][0] += cnt[i][j][1];
        }
        for (int j = k; j < 2 * k; j++) {
            dp[i][0] += cnt[i][j][0];
        }
    }

    for (int i = 0; i < k; i++) {
        for (int j = 1; j < 2 * k; j++) {
            dp[i][j] = dp[i][j - 1] - cnt[i][j - 1][1]
                     + cnt[i][j - 1][0]
                     + cnt[i][(j + k - 1) % (2 * k)][1]
                     - cnt[i][(j + k - 1) % (2 * k)][0];
        }
    }

    int ans = 0;
    for (int j = 0; j < 2 *k; j++) {
        for (int i = 0; i < k; i++) {
            sum[0][j] += dp[i][j];
        }
        ans = (ans < sum[0][j]) ? sum[0][j] : ans;
    }
    for (int i = 1; i < k; i++) {
        for (int j = 0; j < 2 * k; j++) {
            sum[i][j] = sum[i - 1][j] - dp[i - 1][j]
                      + dp[i - 1][(j + k) % (2 * k)];
            ans = (ans < sum[i][j]) ? sum[i][j] : ans;
        }
    }

    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 31360
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 
#include <cctype>
#include <stack>
#include <queue>
#include <cstring>
#include <map>
 
using namespace std;



int main(){

	int n;
	cin>>n;

	long long x=1;
	int res=0;
	while(x<n){
		x*=3;
		res++;
	}
	cout<<res<<endl;

	return 0;
}

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
const int N = 100005;

int n, M;
vector<int> a[N];

int d[N];

void dfs(int x, int p)
{
    d[x] = 1;
    for (int i = 0; i < a[x].size(); ++i)
    {
        int h = a[x][i];
        if (h == p)
            continue;
        dfs(h, x);
        d[x] = (d[x] * 1LL * (d[h] + 1)) % M;
    }
}

int ans[N];

void dfs1(int x, int p, int dp)
{
    ans[x] = (d[x] * 1LL * (dp + 1)) % M;
    vector<int> pp(a[x].size()), ss(a[x].size());
    for (int i = 0; i < a[x].size(); ++i)
    {
        int h = a[x][i];
        if (i)
            pp[i] = pp[i - 1];
        else
            pp[i] = 1;
        if (h == p)
            continue;
        pp[i] = (pp[i] * 1LL * (d[h] + 1)) % M;
    }
    for (int i = a[x].size() - 1; i >= 0; --i)
    {
        int h = a[x][i];
        if (i < a[x].size() - 1)
            ss[i] = ss[i + 1];
        else
            ss[i] = 1;
        if (h == p)
            continue;
        ss[i] = (ss[i] * 1LL * (d[h] + 1)) % M;
    }
    for (int i = 0; i < a[x].size(); ++i)
    {
        int h = a[x][i];
        if (h == p)
            continue;
        int u = 1;
        if (i)
            u = (u * 1LL * pp[i - 1]) % M;
        if (i < a[x].size() - 1)
            u = (u * 1LL * ss[i + 1]) % M;
        dfs1(h, x, ((dp + 1) * 1LL * u) % M);
    }
}

int main()
{
    scanf("%d%d", &n, &M);
    for (int i = 0; i < n - 1; ++i)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        a[x].push_back(y);
        a[y].push_back(x);
    }
    dfs(1, 1);
    dfs1(1, 1, 0);
    for (int i = 1; i <= n; ++i)
        printf("%d\n", ans[i]);
    return 0;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define int long long int

#define mp make_pair
#define pb push_back

int32_t main()
{
     IOS;
     
     int n,k,t,ans=0;
     
     cin>>n>>k;
     
     t=n/k;
     
     if(k%2!=0)
     {
          cout<<t*t*t;
          return 0;
     }
     else
     {
          ans=t*t*t;
          if((n%k)>=(k/2))
          t+=1;
          ans+=(t*t*t);
          cout<<ans;
     }
     return 0;
}
 

Measured memory_bytes: 256
#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#else
#define NDEBUG
#include <bits/stdc++.h>
#endif

using namespace std;
using large = long long;

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

    int steps = 0;
    while (b <= a) {
        b *= 2;
        steps++;
    }
    while (c <= b) {
        c *= 2;
        steps++;
    }

    cout << (steps <= k ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define INF 1000000000

int main() {
    int a,b,ans;
    cin >> a >> b;
    ans = (a==b ? 2*a : 2*max(a,b)-1);
    cout << ans << endl;
}

Measured memory_bytes: 3608
use std::io;
use std::collections::VecDeque;

fn main() {
    let mut input = Input::new();
    let a = input.next_i64();
    let b = input.next_i64();
    let c = input.next_i64();
    let mut vec = vec![a, b, c];
    if vec.iter().filter(|x| *x % 2 == 0).count() > 0 {
        println!(0);
    } else {
        vec.sort_by(|a, b| a.cmp(b));
        println!("{}", vec[0] * vec[1]);
    }
}

struct Input {
    queue: VecDeque<String>,
}

impl Input {
    fn new() -> Input {
        Input { queue: VecDeque::new() }
    }

    fn next(&mut self) -> String {
        if self.queue.is_empty() {
            let mut line = String::new();
            let _ = io::stdin().read_line(&mut line);
            for x in line.split_whitespace() {
                self.queue.push_back(String::from(x));
            }
        }
        return self.queue.pop_front().unwrap();
    }

    fn next_i64(&mut self) -> i64 {
        return self.next().parse::<i64>().unwrap();
    }
}

Measured memory_bytes: 4352
#include<stdio.h>
#define	true 1
#define	false 0

int a[21],n;
int solve(int i,int m);

int main(){
  int i,q,m;

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

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m);
    if(solve(0,m)==false)
      printf("no\n");
    else printf("yes\n");
  }

  return 0;
}

int solve(i,m){
  int res;
  if(m==0) return true;
  if(i>=n) return false;
  res=solve(i+1,m) || solve(i+1,m-a[i]);
    return res;
}

Measured memory_bytes: 580
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int N, A, B, C, D;
	int space = 0, rock = 0;
	string S;
	bool ans = true, jumpover = false;;

	cin >> N >> A >> B >> C >> D >> S;
	A--, B--, C--, D--;

	repc(i, A, max(C, D)) {
		if (S[i] == '#') rock++;
		else rock = 0;
		if (rock >= 2) ans = false;
	}

	if (D < C) {
		repc(i, B - 1, D + 1) {
			if (S[i] == '.') space++;
			else space = 0;
			if (space >= 3) jumpover = true;
		}
		if (!jumpover) ans = false;
	}

	cout << (ans ? "Yes" : "No") << endl;

	return 0;
}


Measured memory_bytes: 644
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	h, w := iScan(), iScan()
	fmt.Println(strings.Repeat("#", w+2))
	for i := 0; i < h; i++ {
		fmt.Println("#" + Scan() + "#")
	}
	fmt.Println(strings.Repeat("#", w+2))
}


Measured memory_bytes: 1776
import java.util.*;
import java.util.stream.*;
class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n,taro,hanako;
        taro = 0;
        hanako = 0;
        n = input.nextInt();
        String a,b;
        for (int i = 0; i < n; i++){
            a = input.next();
            b = input.next();
            int key = a.compareTo(b);
            if (key > 0){
                taro += 3;
            } else if (key < 0){
                hanako += 3;
            } else {
                taro += 1;
                hanako += 1;
            }
        }
        System.out.printf("%d %d\n",taro,hanako);
    }
}


Measured memory_bytes: 30532
from itertools import accumulate
from bisect import bisect_right, bisect_left

N = int(input())
A = list(map(int, input().split()))

# 累積和を前計算
cumsum = list(accumulate(A))
cumsum.insert(0, 0)  # out of index 対策


ans = float('inf')
# 真ん中を全探索
for i in range(2, N-1):
    #print(cumsum[:i], cumsum[i:])
    # 左の真ん中
    LC = cumsum[i] / 2

    LX = bisect_left(cumsum, LC)
    #print(LX)
    # 超えるべきか超えないべきか
    if abs(cumsum[LX-1] - LC) < abs(cumsum[LX] - LC):
        LX -= 1

    # 右の真ん中
    RC = (cumsum[N] + cumsum[i]) / 2
    RX = bisect_left(cumsum, RC)
    # 超えるべきか超えないべきか
    if abs(cumsum[RX-1] - RC) < abs(cumsum[RX] - RC):
        RX -= 1

    P, Q, R, S = cumsum[LX], cumsum[i]-cumsum[LX], cumsum[RX]-cumsum[i], cumsum[N]-cumsum[RX]
    ans = min(ans, max(P, Q, R, S) - min(P, Q, R, S))

print(ans)


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

int gcd(int x, int y){
	if(x < y) swap(x, y);
	while(y != 0){
		int z = y;
		y = x % y;
		x = z;
	}
	return x;
}

int main(){
	int N; cin >> N;
	int V[N], C[N];
	for(int i=0; i<N; i++){
		cin >> V[i];
	}
	for(int i=0; i<N; i++){
		cin >> C[i];
	}
	int ans = 0;
	for(int i=0; i<N; i++){
		if(V[i] > C[i]) ans += (V[i] - C[i]);
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> A(N+1);
    vector<int> B(N);
    for(int i = 0; i < N+1; i++){
        cin >> A.at(i);
    }
    for(int i = 0; i < N; i++){
        cin >> B.at(i);
    }
    
    long long int count = 0;

    for(int i = 0; i < N; i++){
        if(A.at(i) - B.at(i) >= 0){
            count += B.at(i);
        }
        else if(B.at(i) - A.at(i) - A.at(i+1) >= 0){
            count += A.at(i) + A.at(i+1);
            A.at(i+1) = 0;
        }
        else{
            count += B.at(i);
            A.at(i+1) = A.at(i+1) - (B.at(i) - A.at(i));
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		
		String[] s = br.readLine().split(" ");
		StringBuilder sb = new StringBuilder();
		for(int ind = 1; ind <= n; ++ind) {
			sb.append("node " + ind + ": key = " + s[ind - 1] + ", ");
			if(0 < ind/2 && ind/2 <= n) {
				sb.append("parent key = " + s[ind/2 - 1] + ", ");
			}
			if(ind * 2 <= n){
				sb.append("left key = " + s[ind * 2 - 1] + ", ");
			}
			if(ind * 2 + 1 <= n){
				sb.append("right key = " + s[ind * 2 + 1 - 1] + ", ");
			}
			sb.append("\n");
		}
		
		System.out.print(sb);
	}

}

Measured memory_bytes: 24156
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

#define ALL(x) x.begin(),x.end()
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const double PI=3.1415926535;

int main(){
    int N,M;
    cin>>N>>M;
    int L=0,R=9999999;
    for(int i=0;i<M;i++){
        int Li,Ri;
        cin>>Li>>Ri;
        L=max(L,Li);R=min(R,Ri);
    }
    cout<<max(0,R-L+1)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define N 100010
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
int Max(int &a,int b){return a=max(a,b);}
int Min(int &a,int b){return a=min(a,b);}


int A[N];
int n,T;
int find(int s,int x){
  return A + s - (lower_bound(A,A+s,x));
}

int dp[N];
signed main(){

  cin>>n>>T;
  for(int i=0;i<n;i++) cin>>A[i];
  sort(A,A+n);
  A[n] = 1LL<<50;
  
  dp[0] = 1;
  for(int i=1;i<n;i++){
    dp[i] = (dp[i-1] * (1 + find(i,A[i]-T)))%mod;
  }
  cout<<dp[n-1]<<endl;
  return 0;
}

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

const int MAX = 1e5 + 10;

int main()
{
	ll n,x; cin>>n>>x;
	ll a[MAX];
	for(int i=0;i<n;i++) cin>>a[i];
	ll c = 0;
	for(int i=1;i<n;i++){
		if(a[i]+a[i-1]>x){
			ll diff = a[i]+a[i-1]-x;
			
			c += min(a[i],diff);
			a[i] -= min(a[i],diff);

			if(a[i]+a[i-1]>x){
				diff = a[i]+a[i-1]-x;
				c += diff;
				a[i-1] -= diff;
			}

		}
	}	

	cout<<c;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(void){
    int W,H,x,y,r;
    cin>>W>>H>>x>>y>>r;
    if(W<x+r||H<y+r||0>x-r||0>y-r){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }
}



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

const int N = 1e5 + 10;
int n, a[N];

int main() {
    cin >> n;
    rep(i, 1, n) scanf("%d", &a[i]);
    sort(a + 1, a + n + 1, greater<int>());
    rep(i, 1, n) {
        if (i + 1 > a[i + 1]) {
            int j = 0;
            while (a[j + i + 1] == i) ++j;
            puts((((a[i] - i) & 1) || (j & 1)) ? "First" : "Second");
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 4064
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define MaxN 20
using namespace std;
char S[MaxN],T[MaxN];
int main(){
	scanf("%s",S);
	scanf("%s",T);
	bool flag=true;
	for(int i=0; i<strlen(S); i++)
		if( S[i] != T[i] ){
			flag=false;
			break;
		}
	if( flag )
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
} 

Measured memory_bytes: 3168
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long ll;
const int INF=1001001001;
int main(){
  int n;
  string s;
  cin>>n>>s;
  int tmp=n/2;
  bool flag=true;
  if (n%2!=0) flag=false;
  for (int i=0;i<tmp;++i){
    if (s[i]!=s[tmp+i]){
      flag=false;
      break;
    }
    else{
      continue;
    }
  }
  if (flag)  cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2000000000
using namespace std;
typedef long long ll;
int read(){
    int f = 1, x = 0;
    char c = getchar();
    while(c < '0' || c > '9'){if(c == '-') f = -f; c = getchar();}
    while(c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar();
    return f * x; 
}
const int arr[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int n;
void init(){
    n = read();
}
void solve(){
    cout << arr[n - 1] << endl;    
}
int main(){
    init();
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void) {
	char o[50];
	char e[50];
	scanf("%s", o);
	scanf("%s", e);
	int len = strlen(o)+ strlen(e);

	int k = 0;
	int x = 0;
	for (int i = 0; i < len; ++i) {
		if (i % 2 == 0) {
			printf("%c", o[k]);
			++k;
		}
		else {
			printf("%c", e[x]);
			++x;
		}
	}

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  string s;
  cin >> s;
  int n=s.size();
  s+='R';
  int r=0,l=0,mid=0;
  int ans[n];
  n++;
  rep(i,n)ans[i]=0;
  rep(i,n){
    if(s[i]=='R'){
      if(l==0)r++;
      else{
        ans[mid]=l/2+r-r/2;
        ans[mid+1]=l-l/2+r/2;
        r=1;
        l=0;
      }  
    }
    else{
      if(l>0)l++;
      else{
        l=1;
        mid=i-1;
      }
    }
  }
  rep(i,n-2)cout << ans[i] << " ";
  cout << ans[n-2] << endl;
}

Measured memory_bytes: 1024
import java.util.*;
class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), m = sc.nextInt(), c= sc.nextInt();
        String ans = (n + m < c)? "No": "Yes";
        System.out.println(ans);
    }
}

Measured memory_bytes: 22996
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007
#define pi atan(1) * 4

int main()
{
	string s;
	cin >> s;
	cout << s.substr(0, s.length() - 8) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;
 
ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;
 
#define Endl endl
 
map<string, string> mp, mpg, mpa;
 
 
/*--------------------template--------------------*/
 
int main() {
 
    cin >> n >> m;
    ans = 1;
    ll a, b;
    REP(i, n) {
        ans = min(ans * 2, ans + m);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t n;
    cin >> n;

    vector<int64_t> a(n);
    bool has_one = false;
    for (auto&& aa : a) {
        char c;
        cin >> c;
        aa = c - '0' - 1;

        if (aa == 1) {
            has_one = true;
        }
    }

    bool f = false;
    for (auto i : irange(0L, n)) {
        if (has_one ? (a[i] == 1) : (a[i] > 0)) {
            // C(n - 1, i) = 1 mod 2
            if (n - 1 == (i | (n - 1 - i))) {
                f = !f;
            }
        }
    }

    if (f) {
        cout << (has_one ? 1 : 2) << endl;
    } else {
        cout << 0 << endl;
    }
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

vector<int> a;

int main(){
    string s;
    ll k;
    cin>>s>>k;
    int n=s.length();
    ll an=0,an0=0;
    if(n==1){
        cout<<k/2<<endl;
        return 0;
    }

    if(s[0]==s[n-1]){
        ll a=1,b=1;
        for(int i=1;i<n;i++){
            if(s[i-1]==s[i]) a++;
            else break;
        }
        for(int i=n-1;i>=1;i--){
            if(s[i-1]==s[i]) b++;
            else break;
        }
        an0-=(a/2+b/2-(a+b)/2)*(k-1);
    }
    for(int i=1;i<n;i++){
        if(s[i-1]==s[i]){
            s[i]='0';
            an++;
        }
    }
    an*=k;
    an+=an0;
    cout<<min(an,n*k/2)<<endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrep(i,a,b) for(int i=(int)(a);i>=(int)(b);--i)
#define fore(i,a) for(auto &i:a)
#define all(a) (a).begin(),(a).end()
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
using ll = long long; constexpr int inf = INT_MAX / 2; constexpr ll infl = 1LL << 60;
template<class T>void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T>void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T>void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T>void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
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){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }}
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }

void _main() {
  string X;
  cin >> X;
  int n = X.size();
  int cnt_s = 0;
  int ans = 0;

  rep(i, 0, n) {
    if (X[i] == 'T') {
      if (cnt_s > 0) {
        cnt_s--;
      } else {
        ans++;
      }
    } else {
      cnt_s++;
    }
  }
  ans += cnt_s;

  cout << ans << endl;
}

Measured memory_bytes: 720
#include "bits/stdc++.h"
using namespace std;

int main(void) {
  int N;
  cin >> N;
  float ans = 0;
  float rate = 380000;

  for ( int i = 0; i < N; i++ ) {
    float x;
    string u;
    cin >> x >> u;
    if ( u == "JPY" ) ans += x;
    else ans += x * rate;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
# Problem: https://atcoder.jp/contests/abc091/tasks/abc091_b
# Python 1st Try

import sys
from collections import defaultdict
# import heapq,copy
# from collections import deque
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]


def solver(plusCardNum, plusCards, minusCardNum, minusCards):
    result = 0
    selectString = defaultdict(int)
    for j in range(plusCardNum):
    #    print("{}".format(plusCards[j]))
        selectString[plusCards[j]] = selectString[plusCards[j]] + 1
    for j in range(minusCardNum):
        selectString[minusCards[j]] = selectString[minusCards[j]] - 1
    keyList = list(selectString.keys())
    for j in range(0, len(keyList)):
        if result < selectString.get(keyList[j]):
            result = selectString.get(keyList[j])
    return result


if __name__ == "__main__":
    N = II()
    NList = []
    for _ in range(0, N, +1):
        NList.append(input())
    M = II()
    MList = []
    for _ in range(0, M, +1):
        MList.append(input())
    print("{}".format(solver(N, NList, M, MList)))


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

#define CIN2(a,b) long long a,b;cin >> a >> b;
#define rep(i,n) for(int i=0,i##_len=(n); i<i##_len; ++i)

int main(){
    int n;cin >> n;
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    int ans = 0,maxh = 0;
    rep(i,n){
        if(v[i]>=maxh){
            ans++;
            maxh = v[i];
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 384
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char ch = sc.next().charAt(0);
        if (Character.isLowerCase(ch)) {
            System.out.println('a');
        } else {
            System.out.println('A');
        }
    }
}

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

#define int long long
//typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif



signed main() {
    int N;
    cin >> N;
    int c[123456]={0};
    
    rep(i,N){
        int a; cin >> a;
        c[a]++;
    }
    bool f = true;
    rep(i,N){
        if(N%2==1){
            if(i==0){
                if(c[i]!=1)f = false;
            }
            else if(i%2==0){
                if(c[i]!=2) f = false;
            }else if(i%2==1 && c[i]!=0) f=false;
        }else{
            if(i%2==0 && c[i]!=0) f = false;
            if(i%2==1 && c[i]!=2) f=false;
        }
    }
    if(!f) cout << 0 << endl;
    else{
        int ans = 1;
        rep(i,N/2) (ans*=2)%=mod;
        cout << ans << endl;
    }
    
    return 0;
}


Measured memory_bytes: 1152
#include "bits/stdc++.h"
using namespace std;

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

	for(int i=0;i<s.size();i++) {
		if(s.at(i) == '0') a += '0';
		if(s.at(i) == '1') a += '1';
		if(s.at(i) == 'B' && a.size() != 0) a.pop_back();
	}

	cout << a << endl;
}


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

#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, init, n) for(int i = init; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define fi first
#define se second

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to, cost;
};

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);

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

string day[7] = {"thu", "fri", "sat", "sun", "mon", "tue", "wed",};

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

    int X;
    cin >> X;

    cout << day[X % 7] << endl;
    
    return 0;
}


Measured memory_bytes: 3192
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long ll;
const int MAXN = 36;

struct card {
	char suit, value;
};

bool orstable(struct card *A, struct card *B, int N) {
	rep(i, N) {
		if (A[i].suit != B[i].suit)return false;
	}
	return true;
}

void bubblesort(struct card *A, int N) {
	int flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = N - 2; j >= i; j--) {
			if (A[j].value > A[j + 1].value) {
				swap(A[j], A[j + 1]);
				flag = 1;
			}
		}
	}
}

void selectionsort(struct card *A, int N) {
	for (int i = 0; i < N - 1; i++) {
		int minj = i;
		for (int j = i + 1; j < N; j++) {
			if (A[minj].value > A[j].value)minj = j;
		}
		if (minj != i) {
			swap(A[minj], A[i]);
		}
	}
}

int main() {
	card c1[MAXN], c2[MAXN];
	int N;
	cin >> N;
	rep(i, N)cin >> c1[i].suit >> c1[i].value;
	rep(i, N)c2[i] = c1[i];
	bubblesort(c1, N);
	selectionsort(c2, N);

	rep(i, N) {
		if (i != N - 1)cout << c1[i].suit << c1[i].value << " ";
		else cout << c1[i].suit << c1[i].value << endl;
	}
	cout << "Stable" << endl;

	rep(i, N) {
		if (i != N - 1)cout << c2[i].suit << c2[i].value << " ";
		else cout << c2[i].suit << c2[i].value << endl;
	}
	if (orstable(c1,c2,N))cout << "Stable" << endl;
	else cout << "Not stable" << endl;

	return 0;
}


Measured memory_bytes: 3088
#include <cstdio>
#include <algorithm>
#define LL long long
using namespace std;
LL width[35];
LL cal(LL x1,LL y1,LL x2,LL y2,int level){
	LL w;
	if(level==0)return abs(y1-y2);//路径上一直未遇到黑色方块
	w=width[level-1];//当前级别level,深入到9个level-1级别中进行处理
	if(x1/w!=x2/w)return abs(x1-x2)+abs(y1-y2);//处在不同层中，可用曼哈顿距离处理
	if(x1/w==1&&abs(y1/w-y2/w)>=2)//x1/w==x2/w  处于同一层，且在456这一层
		return abs(y1-y2)+min(x1%w+1+x2%w+1,(w-x1%w)+(w-x2%w));//x1%w+1+x2%w+1向左推进，(w-x1%w)+(w-x2%w)向右推进
	return cal(x1%w,y1,x2%w,y2,level-1);//当前处理不了，只能深入到level-级别中进行处理，固定abs(y1-y2),针对x进行处理,因x1/w==x2/w，故可取模
}
int main(){
	int i,q;
	width[0]=1;
	for(i=1;i<=29;i++)width[i]=width[i-1]*3;
	LL x1,y1,x2,y2;
	scanf("%d",&q);
	while(q--){
		scanf("%lld%lld%lld%lld",&x1,&y1,&x2,&y2);
		x1--,y1--,x2--,y2--;//涉及取模运算，故第1行变成第0行，故第1列变成第0列
		if(abs(x1-x2)>abs(y1-y2))swap(x1,y1),swap(x2,y2);//抓住图形具有对称性，避免出现258的情况。
		printf("%lld\n",cal(x1,y1,x2,y2,30));
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(){
	int ans=0,i,j,m,n,k,kion[201],low[201],high[201],deta[201],dp[201][201]={0};
	scanf("%d%d",&n,&k);
	for(i=0;i<n;i++)scanf("%d",&kion[i]);
	for(i=0;i<k;i++){
		scanf("%d%d%d",&low[i],&high[i],&deta[i]);
		for(j=0;j<n;j++){
			if(kion[j]<low[i] || high[i]<kion[j])dp[j][i]=-1;
		}
	}
	for(i=0;i<n-1;i++){
		for(j=0;j<k;j++){
			if(dp[i][j]!=-1){
				for(m=0;m<k;m++){
					if(dp[i+1][m]!=-1)if(abs(deta[m]-deta[j])+dp[i][j]>dp[i+1][m]||dp[i+1][m]==0)dp[i+1][m]=abs(deta[m]-deta[j])+dp[i][j];
				}
			}
			
		}
		
	}
	for(i=0;i<k;i++)if(dp[n-1][i]>ans)ans=dp[n-1][i];
	printf("%d\n",ans);
	
	return 0;
}


Measured memory_bytes: 2048
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var N int
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &N)

	ab := make([]point, N)
	for i := 0; i < N; i++ {
		pt := point{}
		scanner.Scan()
		fmt.Sscanf(scanner.Text(), "%d %d", &pt.x, &pt.y)
		ab[i] = pt
	}
	cd := make([]point, N)
	for i := 0; i < N; i++ {
		pt := point{}
		scanner.Scan()
		fmt.Sscanf(scanner.Text(), "%d %d", &pt.x, &pt.y)
		cd[i] = pt
	}

	abPoints = make([]Record, N)
	cdPoints = make([]Record, N)

	for i, pt := range ab {
		abPoints[i] = Record{pt}
	}
	for i, pt := range cd {
		cdPoints[i] = Record{pt}
	}

	sort.Sort(abPoints)
	sort.Sort(cdPoints)

	doneAb := make(map[Record]struct{})
	for _, cdPoint := range cdPoints {
		opponent := Record{pt: point{-1, -1}}
		for _, abPoint := range abPoints {
			if _, e := doneAb[abPoint]; e {
				continue
			}
			if abPoint.pt.x > cdPoint.pt.x {
				break
			}
			if abPoint.pt.isSub(cdPoint.pt) && abPoint.pt.y > opponent.pt.y {
				opponent = abPoint
			}
		}
		if opponent.pt.x != -1 {
			doneAb[opponent] = struct{}{}
		}
	}
	fmt.Println(len(doneAb))
}

type point struct {
	x, y int
}

func (pt *point) isSub(o point) bool {
	return pt.x < o.x && pt.y < o.y
}

var abPoints Records
var cdPoints Records

type Record struct {
	pt point
}

type Records []Record

func (r Records) Len() int {
	return len(r)
}
func (r Records) Swap(i, j int) {
	r[i], r[j] = r[j], r[i]
}

func (r Records) Less(i, j int) bool {
	return r[i].pt.x < r[j].pt.x
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl


int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a,b,h,m;cin>>a>>b>>h>>m;
  const double pi=3.14159265358979;
  double theta=abs(m/60.0-(60*h+m)/720.0)*2*pi;
  double ans=sqrt(a*a+b*b-2*a*b*cos(theta));
  printf("%.10f\n",ans);
  return 0;
}

Measured memory_bytes: 4184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N = in();
    vector<int> A(N+1);
    vector<int> B(N+1);
    A[0] = 0;
    B[0] = 0;
    REP(i,N){
        A[i+1] = in() + A[i];
    }
    REP(i,N){
        B[i+1] = in() + B[i];
    }
    int maxa = 0;
    REP(i,N){
        chmax(maxa,A[i+1]-B[i] + B[N]);
    }
    cout << maxa << "\n";
}

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

int main(){
    vector<int> H;
    vector<int> W;
    int h;
    int w;
    
    while(1){
      cin >> h >> w;
      if(h==0 && w==0) break;
      H.push_back(h);
      W.push_back(w);
    }
    
    for(int i=0;i<H.size();i++){
      if(H[i]==0 && W[i]==0) break;
      for(int j=0;j<H[i];j++){
	for(int k=0;k<W[i];k++){
	  cout << "#";
	}
	cout << endl;
      }
      cout << endl;
    }
   
    return 0;
}



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

int main(){
  int first = (cin >> (first), first),
      second = (cin >> (second), second),
      third = (cin >> (third), third);

  if((first+second == third) || (second+third == first) || (first+third == second))
   cout << "Yes";
  else
   cout << "No";

  //system("pause");
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    unsigned long long N, sum = 0;
    scanf("%lld", &N);

    for(unsigned long long i = 1; i <= N; i++){
        if(i % 3 != 0 && i % 5 != 0){
            sum += i;
        }
    }
    printf("%lld\n", sum);
    return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
int a,b,c,d,e,f;
int m,duong=0;
int main()
{
    cin.tie(NULL);
    cin>>a>>b>>c>>d>>e>>f;
    m=a;
    for (int i=0;i*a<=f/100;i++)
        for (int j=0;i*a+j*b<=f/100;j++)
        {
            int w=i*a+j*b;
            int tam=0;
            for (int x=0;x*c<=min(e*w,f-w*100);x++)
                for (int y=0;y*d+x*c<=min(e*w,f-w*100);y++)
                    tam=max(tam,x*c+y*d);
            if (duong*w<tam*m)
            {
                m=w;
                duong=tam;
            }
        }
    cout<<m*100+duong<<" "<<duong;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 100
int main(){
  int n,array[N],i,j,tmp,count=0,flag=0;
  scanf("%d",&n);

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

for(i = 0;i < n;i++){
  for(j = n-1;j > i;j--){
    if(array[j] < array[j-1]){
      tmp = array[j];
      array[j] = array[j-1]; 
      array[j-1] = tmp;
      count++;    
}
  }
}

  for(i = 0;i < n-1;i++){
    printf("%d ",array[i]);
}  
  printf("%d\n",array[n-1]);
 printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 600
#include <iostream>
using namespace std;
string st,xst;
int main()
{
    cin >> st;
    for( int i = 0 ;i < st.size () ;i ++ )
        if( st[ i ] == '0' || st[ i ] == '1' ) xst += st[i]; 
        else
            if(xst.size()>0) 
            xst.erase(xst.size()-1,1);
    cout<<xst<<endl; 
    return 0; 
}

Measured memory_bytes: 256
#line 2 "header.hpp"

//%snippet.set('header')%
//%snippet.fold()%
#ifndef HEADER_H
#define HEADER_H

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

// varibable settings
#define int long long
const int INF = 1e18;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _rrep(i, n) rrepi(i, 0, n)
#define rrepi(i, a, b) for (int i = (int)((b)-1); i >= (int)(a); --i)
#define r_rep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(i, a) for (auto &&i : a)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
#define ub upper_bound
#define lb lower_bound
#define lpos(A, x) (lower_bound(all(A), x) - A.begin())
#define upos(A, x) (upper_bound(all(A), x) - A.begin())
template <class T>
inline void chmax(T &a, const T &b) {
    if ((a) < (b)) (a) = (b);
}
template <class T>
inline void chmin(T &a, const T &b) {
    if ((a) > (b)) (a) = (b);
}

#define divceil(a, b) ((a) + (b)-1) / (b)
#define is_in(x, a, b) ((a) <= (x) && (x) < (b))
#define uni(x)    \
    sort(all(x)); \
    x.erase(unique(all(x)), x.end())
#define slice(l, r) substr(l, r - l)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int, int> pii;
typedef tuple<int, int, int> iii;

template <typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast {
    Fast() {
        std::cin.tie(0);
        ios::sync_with_stdio(false);
    }
} fast;
void check_input() {
    assert(cin.eof() == 0);
    int tmp;
    cin >> tmp;
    assert(cin.eof() == 1);
}

#if defined(PCM) || defined(LOCAL)
#else
#define dump(...) ;
#define dump_1d(...) ;
#define dump_2d(...) ;
#define cerrendl ;
#endif

#endif /* HEADER_H */
//%snippet.end()%
#line 2 "solve.cpp"

signed main() {
    //input
    int n,m;cin>>n>>m;
    vector<int> h(n);
    rep(i, n) {
        cin>>h[i];
    }
    dump(h);

    vector<int> nex(n);
    rep(i, m){
        int a,b;cin>>a>>b;
        a--;b--;
        chmax(nex[a], h[b]);
        chmax(nex[b], h[a]);
    }

    //solve
    int ans = 0;
    rep(i, n) if (h[i]>nex[i]) ans++;
    cout << ans << endl;

    return 0; 
}


Measured memory_bytes: 4780