akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

#define REP(i,n) for(int i=0;i< (n);i++)
#define REPR(i, n) for(int i = (n);i >= 0;i--)
#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define FORR(i, m, n) for(int i = (m);i >= (n);i--)
#define SORT(v, n) std::sort(v, v+n);
#define VSORT(v) std::sort(v.begin(), v.end());
#define VRSORT(v) std::sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define ALL(obj) (obj).begin(),(obj).end()

using namespace std;

const int INF = 99999999;
const ll LINF = 9999999999999;

typedef pair<ll, ll> LP;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };



ll A[200001];
ll humidai=0;
ll N;
int main() {

	cin >> N;
	REP(i, N) {
		cin >> A[i];
	}

	REP(i, N) {
		if (i == 0)continue;
		if (A[i - 1] > A[i]) {
			humidai += A[i - 1] - A[i];
			A[i] = A[i - 1];
		}
	}
	cout << humidai;

	return 0;

}


Measured memory_bytes: 5132
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#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 long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

void solve(){
    string s;
    cin >> s;
    int n = sz(s);
    for (int i = 0; i < n; i+=2){
        if (!(s[i] == 'R' || s[i] == 'U' || s[i] == 'D')){
            cout << "No\n";
            return;
        }
    }

    for (int i = 1; i < n; i+=2){
        if (!(s[i] == 'L' || s[i] == 'U' || s[i] == 'D')) {
            cout << "No\n";
            return;
        }
    }
    cout << "Yes\n";
}

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

    //int t; cin >> t; while (t--)
        solve();
}

Measured memory_bytes: 3648
#include<cstdio>
#include<cstring>
#define MAXN 105
char a[MAXN],b[MAXN],c[MAXN];
int main()
{
    scanf("%s\n%s\n%s",a+1,b+1,c+1);
    int la=strlen(a+1),lb=strlen(b+1),lc=strlen(c+1);
    int na=2,nb=1,nc=1;
    char turn=a[1];
    while(1)
    {
        if(turn=='a')
        {
            if(na>la){printf("A\n"); return 0;}
            turn=a[na];
            na++;
        }
        if(turn=='b')
        {
            if(nb>lb){printf("B\n"); return 0;}
            turn=b[nb];
            nb++;
        }
        if(turn=='c')
        {
            if(nc>lc){printf("C\n"); return 0;}
            turn=c[nc];
            nc++;
        }
    }
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>

using namespace std;

const double PI = 3.14159;

int main()
{
	double x=0.0, y=0.0;
	int deg = 0;
	int d, t;
	char dummy;
	
	while (true) {
		cin >> d >> dummy >> t;
		if (d==0 && t==0) break;
		
		x += static_cast<double>(d) * sin(static_cast<double>(deg)*PI/180);
		y += static_cast<double>(d) * cos(static_cast<double>(deg)*PI/180);
		deg += t;
	}
	
	cout << static_cast<int>(x) << endl << static_cast<int>(y) << endl;
	
	return 0;
}

Measured memory_bytes: 3376
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

N = ri()
B = rl()

A = [B[0]]
for i in range(N-2):
	a = min(B[i], B[i+1])
	A.append(a)
A.append(B[-1])
print(sum(A))


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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }



int main() {
    int n; cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    int t = 0;
    int even = 0;
    int odd = 0;
    rep(i, n) {
        if(a[i]%4 == 0) {
            t++;
        } else {
            if(a[i]%2 == 0) even++;
            else odd++;
        }
    }
    if(even > 0) odd++;
    rep(i, odd) {
        if(t < 0) {
            cout << "No" << endl;
            return 0;
        }
        t--;
    }

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


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

using namespace std;
using ull = unsigned long long;

int main() {
    int A, B;
    cin >> A >> B;
    string S;
    cin >> S;

    bool ans = true;
    int i = 0;
    for (; i < A; ++i) {
        if (!isdigit(S[i])) {
            ans = false;
        }
    }
    if (S[i++] != '-') {
        ans = false;
    }
    for (; i < B + A + 1; ++i) {
        if (!isdigit(S[i])) {
            ans = false;
        }
    }
    if (ans) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program {
    static int Main(string[] args) {
        List<int> list = new List<int>();

        while (true) {
            string[] v = Console.ReadLine().Split(' ');
            int n = int.Parse(v[0]);
            int x = int.Parse(v[1]);
            if (n == 0 && x == 0) { break; }

            list.Add(Kensu(n, x));
        }

        for (int i = 0; i < list.Count; i++) {
            Console.WriteLine(list[i]);
        }

        return 0;
    }

    static int Kensu(int n, int x) {
        int cnt = 0;
        for (int a1 = 1; a1 <= n - 2; a1++) {
            for (int a2 = a1 + 1; a2 <= n - 1; a2++) {
                for (int a3 = a2 + 1; a3 <= n; a3++) {
                    if (a1 + a2 + a3 == x) { cnt++; }
                }
            }
        }

        return cnt;
    }
}


Measured memory_bytes: 15944
import math
a,b,c,d=map(int,input().split())
cd = c*d // math.gcd(c,d)
# b以下のc,d,cdの倍数の個数からa未満のc,d,cdの倍数個数をそれぞれ引く
s_c = b//c - (a-1)//c
s_d = b//d - (a-1)//d
s_cd = b//cd - (a-1)//cd
print((b-a+1)-s_c-s_d+s_cd)

Measured memory_bytes: 9116
import java.util.Scanner;

public class Main {

	public static long count(int p, int n) {
		long count = 0;
		for(int i = 1; Math.pow(p,  i) <= n; ++i) {
			count += (n / Math.pow(p, i));
		}
		return (count + 1);
	}
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		long ans = 1;
		int n;
		n = sc.nextInt();
		sc.close();
		
		int prime[];
		prime = new int[1001];
		
		prime[0] = -1;
		prime[1] = -1;
		for(int i = 2; i <= 1000; ++i) {
			if(prime[i] != -1) {
				prime[i] = 1;
				for(int j = 2; j * i <= 1000; ++j) {
					prime[i * j] = -1;
				}
			}
		}
		
		for(int i = 2; i <= n; ++i) {
			if(prime[i] == 1) {
				long tmp = count(i, n);
				ans *= (tmp % (long)(Math.pow(10,  9) + 7));
				ans %= (long)(Math.pow(10,  9) + 7);
			}
		}
		
		System.out.println(ans);
	}

}


Measured memory_bytes: 20948
import sys, heapq, bisect, math, fractions
from collections import deque
from collections import Counter
from collections import OrderedDict

N = int(input())
H = list(map(int, sys.stdin.readline().rsplit()))

res = 0
i = 0
ok = False

while ok is False:
    streak = False
    ok = True
    
    for i, h in enumerate(H):
        if h > 0:
            ok = False
            H[i] -= 1
            streak = True
        elif h == 0 and streak is True:
            streak = False
            res += 1
    else:
        if ok is False and streak is True:
            res += 1

print(res)

Measured memory_bytes: 5076
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
  int n;
  string s;
  cin >> s;
  n = s.size();
  vector<int> ans(n);
  rep(ri,2) {
    { // solve R
      int cnt = 0;
      rep(i,n) {
        if (s[i] == 'R') cnt++;
        else {
          ans[i] += cnt/2;
          ans[i-1] += (cnt+1)/2;
          cnt = 0;
        }
      }
    }
 
    reverse(ans.begin(), ans.end());
    reverse(s.begin(), s.end());
    rep(i,n) {
      if (s[i] == 'L') s[i] = 'R';
      else s[i] = 'L';
    }
  }
 
  rep(i,n) {
    printf("%d\n", ans[i]);
  }
  return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<stack>
#include<string>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

struct Node{
    int key;
    Node *right, *left, *parent;
};

Node *root, *NIL;

void inorder(Node *u){
    if(u==NIL) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void insert(int k){
    Node *y = NIL;
    Node *x = root;
    Node *z;
    
    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;
    
    while(x != NIL){
        y = x;
        if(z->key < x->key){
            x = x->left;
        }else{
            x = x->right;
        }
    }
    
    z->parent = y;
    if(y==NIL){
        root = z;
    }else{
        if(z->key < y->key){
            y->left = z;
        }else{
            y->right = z;
        }
    }
}

void preorder(Node *u){
    if(u==NIL) return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

int main(){
    int n, i, x ;
    string com;
    
    scanf("%d", &n);
    
    for(i=0 ; i<n ; i++){
        cin >> com;
        if(com == "insert"){
            scanf("%d", &x);
            insert(x);
        }else if(com == "print"){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
    return 0;
}



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

#define rep(i, a) for (int i = 0; i < (a); i++ )
#define FOR(i, m, n) for(int i = m; i < n; i++)
 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    int X, N;
    cin >> X >> N;
    set<int> S;
    rep(i,102) {
        S.insert(i);
    }
    rep(i,N) {
        int p;
        cin >> p;
        S.erase(p);
    }

    int d = 1000;
    int ans = 0;
    for (auto p: S) {
        if (abs(X-p)<d) {
            ans = p;
            d = abs(X-p);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k,x,y; cin>>n>>k>>x>>y;
    int ans = 0;
    if(n<=k){
        ans = n * x;
    }else{
        ans = k*x + (n-k)*y;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
while True:
	N, M = [ int(_) for _ in raw_input().split() ]
	if N == 0: break
	p = [ int(_) for _ in raw_input().split() ]
	p.sort()
	p.reverse()
	s = 0
	for i in xrange(N):
		if i % M != M - 1:
			s += p[i]
	print s
	

Measured memory_bytes: 4300
// 解説後
#include <array>
#include <iostream>

// xのMSBをn、yのMSBをmとする。
// n>mとすると、x>yとなり条件（x<=y）と矛盾するので、無視して良い。
// n<mとすると、y^x>x>(y mod x)となるので、数えなくて良い。
// => n=mのときだけを考えれば良い。

// このとき、y/xの商は1なので、(y mod x) = y-xとなり、考慮すべき条件はy-x=y^xとなる。
// => すべての桁において繰り下がりが起こらない組を数えれば良い。
// => i∈[0,m)において、i桁目のビット(x_i, y_i)が(1, 0)でない組を数えれば良い。
//
// 計算の効率性を高めるため、個数を累積的に数えたい。
// => 各条件が真かどうかで個数を分割して記録することを考える。
//    その条件は「x>=L」、「y<=R」、「MSBが一致する」の3つ。
//
// iビット目までを見たとき、(i+1)ビット目に値を加えるとする。
// (i+1)ビットまでを見たときの個数を加えた値によって変化した条件とともに記録する。
// => 最終的に、63ビット目までを見たときに条件がすべて真となる組の個数を計算できる。

// 条件を満たすかどうかのフラグ
constexpr uint32_t COND_L_BIT = 0b100;     // xがL以上かどうか
constexpr uint32_t COND_R_BIT = 0b010;     // yがR以下かどうか
constexpr uint32_t COND_MSB_BIT = 0b001;   // MSBが一致するか
constexpr uint32_t COND_ALL_BITS = 0b111;  // すべてを満たすか

template <typename T, size_t ROWS, size_t COLUMNS>
using Array2D = std::array<std::array<T, COLUMNS>, ROWS>;

int solve_F() {
  uint64_t L;  // 下限
  uint64_t R;  // 上限
  std::cin >> L >> R;

  // 0ビット目に値を加えたときの個数を記録する
  Array2D<uint64_t, 64, 8> counts{};  // [見た最大ビット][条件フラグのビットセット]
  auto f0 = [&](uint64_t x, uint64_t y) {
    uint32_t cond = 0;
    if (x >= (L & 1)) cond |= COND_L_BIT;
    if (y <= (R & 1)) cond |= COND_R_BIT;
    if (x == y) cond |= COND_MSB_BIT;

    counts[0][cond] += 1;
  };
  f0(0, 0);
  f0(0, 1);
  f0(1, 1);

  // 各条件に沿った組の個数を累積的に計算する
  for (size_t i = 0; i < counts.size() - 1; ++i) {
    const uint64_t l = (L >> (i + 1)) & 1;  // Lの(i+1)ビット目の値
    const uint64_t r = (R >> (i + 1)) & 1;  // Rの(i+1)ビット目の値

    for (uint32_t cond = 0; cond < 8; ++cond) {
      // condの状態の組の(i+1)ビット目に(x, y)を付け加えたときの個数を累積的に記録する
      auto f = [&, l, r](uint64_t x, uint64_t y) {
        uint32_t new_cond = 0;
        if (x == l) {
          new_cond |= cond & COND_L_BIT;
        } else if (x >= l) {
          new_cond |= COND_L_BIT;
        }

        if (y == r) {
          new_cond |= cond & COND_R_BIT;
        } else if (y <= r) {
          new_cond |= COND_R_BIT;
        }

        if (x == 0 && y == 0) {
          new_cond |= cond & COND_MSB_BIT;
        } else if (x == 1 && y == 1) {
          new_cond |= COND_MSB_BIT;
        }

          counts[i + 1][new_cond] += counts[i][cond] % 1'000'000'007;
        };
        f(0, 0);
        f(0, 1);
        f(1, 1);
      }
    }

    // 結果発表
    std::cout << counts[63][COND_ALL_BITS];

    return 0;
  }

  int main() { return solve_F(); }


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

s = list(input())
l = {
    "0": 0,
    "1": 0,
}

for v in s:
    if l.get(v):
        l[v] += 1
    else:
        l[v] = 1
        
print(min(l["0"], l["1"]) * 2)

Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll n,a,b;
	cin >> n >> a >> b;
	if((b-a)%2){
		ll m1 = a - 1;
		ll m2 = n - b;
//		cout << m1 << " " << m2 << endl;
		ll cnt = 0;
		if(m1 < m2){
			a = 1;
			b = b - m1;
			cnt = m1;
		}
		else{
			b = n;
			a += m2;
			cnt = m2;
		}
//		cout << a << " " << b << endl;
		cout << 1 + (b-a)/2 +cnt << endl;
	}
	else{
		cout << b - (a+b)/2 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
/**
 *    Author:  AKASH-ALAM       
**/
#include <bits/stdc++.h>
#define endl        '\n'
#define db          double
#define ld          long double
#define ll          long long
#define ull         unsigned long long
#define sqr(x)      (x) * (x)
#define gcd(a, b)   __gcd(a, b)
#define lcm(a, b)   ((a/gcd(a,b)) * b)
#define pf(x) 		push_front(x)
#define pb(x)       push_back(x)
#define eb(x)		emplace_back(x)
#define all(x)      (x).begin(), (x).end()
#define rall(x) 	(x).rbegin(), (x).rend()
#define sz(x) 		(int)x.size()
#define debug(x) 	cerr << #x << " = " << (x) <<endl
#define Fast_io    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

const ld PI = acos((ld)-1);
const int MOD = 1e9+7;
const ll INF = 1e18; 
using namespace std;

int main(){
    Fast_io;
    int n;  cin >> n;
    long long pow = 1;
    for(int i = 1; i <= n; i++) {
        pow *= i;
        pow = pow % MOD;
    }
    cout << pow << endl;
    return 0;
}


Measured memory_bytes: 3552
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
	    int x = scan.nextInt();
	    int y = scan.nextInt();


	   	System.out.println( x * y + " " + (x + y) * 2 );



	}

}

Measured memory_bytes: 25756
//STN
#include <iostream>
using namespace std;

void koukan(int*,int*);

int main()
{
	int a,b,c,d;
	cin >> a >> b >> c;
	while(1){
	if (a <= b && b <= c)
		break;
		else{
		if(a > b)
			koukan(&a,&b);
		if(b > c)
			koukan(&b,&c);
		}
	}
	cout << a << " " << b << " " << c << endl;
	return 0;
}

void koukan(int *a, int *b)
{
	int d;
	d = *a;
	*a = *b;
	*b = d;
}


Measured memory_bytes: 3068
a = list(map(int,input().split()))
b = list(map(int,input().split()))

su = 0
c = [0]
for  i in range(len(b)-2):
	c.append(0)

for i in range(a[0] - 1):
	c[i] = b[i+1] - b[i]

for i in range(len(c)):
	if a[2] <= c[i]*a[1]:
		su += a[2]
	else:
		su += c[i]*a[1]

print(su)

Measured memory_bytes: 63596
int main(void) {
int  t, i;
	long long reft,r,x,y,s,k;
	scanf("%d", &t);
	long long  a[300], b[300], c[300], d[300];
	for (i = 0; i <= t-1; i++) {
		scanf("%lld", &a[i]);
		scanf("%lld", &b[i]);
		scanf("%lld", &c[i]);
		scanf("%lld", &d[i]);
 
	}
 
	for (i = 0; i <= t-1; i++) {
		if (a[i] < b[i]) printf("No\n");
		else if (b[i] > d[i]) printf("No\n");
		else if (b[i]-1 <= c[i]) printf("Yes\n");
		else {	
				reft = a[i]%b[i];
			
			if (reft > c[i]) printf("No\n");
			else {
								x = d[i];
				y = b[i];
				
				r = x % y;
				while (r != 0) {
					x = y;
					y = r;
					r = x % y;
				}
				
				c[i]=c[i]-reft;
                                b[i]=b[i]-reft;
                                k=c[i]%y;
                                s=(c[i]-k)/y;
                                
 
 
				if ((s+1)*y<b[i]) printf("No\n");
				else printf("Yes\n");
 
			}
 
		}
 
	}
	return 0;
}

Measured memory_bytes: 128
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)
	letters := strings.Split(s, "")
	var ans []string
	for i, letter := range letters {
		if (i+1)%2 != 0 {
			ans = append(ans, letter)
		}
	}
	fmt.Println(strings.Join(ans, ""))
}


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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

// クエリあたりO(lonN)で処理できる
// 1-indexedなので注意
// 区間加算にも対応した BIT
template <class Abel> struct BIT {
    vector<Abel> dat[2];
    Abel UNITY_SUM = 0;                     // to be set
    
    /* [1, n] */
    BIT(int n) { init(n); }
    void init(int n) { for (int iter = 0; iter < 2; ++iter) dat[iter].assign(n + 1, UNITY_SUM); }
    
    /* a, b are 1-indexed, [a, b) */
    inline void sub_add(int p, int a, Abel x) {
        for (int i = a; i < (int)dat[p].size(); i += i & -i)
            dat[p][i] = dat[p][i] + x;
    }
    inline void add(int a, int b, Abel x) {
        sub_add(0, a, x * -(a - 1)); sub_add(1, a, x); sub_add(0, b, x * (b - 1)); sub_add(1, b, x * (-1));
    }
    
    /* a is 1-indexed, [a, b) */
    inline Abel sub_sum(int p, int a) {
        Abel res = UNITY_SUM;
        for (int i = a; i > 0; i -= i & -i) res = res + dat[p][i];
        return res;
    }
    inline Abel sum(int a, int b) {
        return sub_sum(0, b - 1) + sub_sum(1, b - 1) * (b - 1) - sub_sum(0, a - 1) - sub_sum(1, a - 1) * (a - 1);
    }
    
    /* debug */
    void print() {
        for (int i = 1; i < (int)dat[0].size(); ++i) cout << sum(i, i + 1) << ",";
        cout << endl;
    }
};

signed main()
{   
    gearup;
    ll n,k; cin >> n >> k;
    vl a(n);
    rep(i,n)cin>>a[i];

    rep(j,min(1LL*100,k)){
        vl imos(n+1);
        rep(i,n){
            ll left = max(i-a[i],0LL);
            ll right = min(n,i+a[i]+1);
            imos[left]++;
            imos[right]--;
        }
        rep(i,n){
            a[i] = imos[i];
            imos[i+1] += imos[i];
        }
    }
    rep(i,n){
        if(i) cout << " ";
        cout << a[i];
    }
    cout << endl;
}


Measured memory_bytes: 6348
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e9;
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
int main(){
	int n;
	while(cin>>n,n){
		vvi in(n,vi(4));
		rep(i,n)rep(j,4)cin>>in[i][j];
		map<int,map<int,vi> >m;
		vi h;
		rep(i,n)m[-in[i][2]][in[i][3]].pb(i);
		for(map<int,map<int,vi> >::iterator it=m.begin();it!=m.end();it++){
			int t=it->first;
			for(map<int,vi>::iterator itt=m[t].begin();itt!=m[t].end();itt++){
				vi out=itt->second;
//				rep(i,out.size())cout<<in[out[i]][0]<<endl;
				vector<pii>w;
				rep(i,out.size())w.pb(pii(in[out[i]][0],out[i]));
				sort(all(w));
				rep(i,w.size()){
					int co=0;
					bool H=false;
					rep(j,h.size())if(in[h[j]][1]==in[w[i].second][1])co++;
					if(h.size()<10){
						if(co<3)H=true;
					}else if(h.size()<20){
						if(co<2)H=true;
					}else if(h.size()<26){
						if(co<1)H=true;
					}
					if(H){
						h.pb(w[i].second);
						cout<<w[i].first<<endl;
					}
				}
			}
		}
	}
}

Measured memory_bytes: 1268
x,y,A,B,C = map(int, input().split())
a = sorted(map(int, input().split()))
b = sorted(map(int, input().split()))
c = list(map(int, input().split()))
aa = a[len(a)-x:]
bb = b[len(b)-y:]
for i in aa:
  c.append(i)
for i in bb:
  c.append(i)
c = sorted(c)
cc = c[len(c)-x-y:]
print(sum(cc))

Measured memory_bytes: 23328
#include <iostream>
using namespace std;
#define LEN 100005

typedef struct pp {
    char name[100];
    int t;
} P;

P Q[LEN];
int head, tail, n;

void enqueue(P x) {
    Q[tail] = x;
    tail = (tail + 1) % LEN;
}

P dequeue() {
    P x = Q[head];
    head = (head + 1) % LEN;
    return x;
}

int min(int a, int b) { return a < b ? a : b;};

int main() {
    int elaps = 0, c;
    int i, q;
    P u;
    cin >> n >> q;

    for (i = 1; i <= n; i++) {
        cin >> Q[i].name >> Q[i].t;
    }
    head = 1; tail = n + 1;

    while (head != tail) {
        u = dequeue();
        c = min(q, u.t);
        u.t -= c;
        elaps += c;
        if (u.t > 0) enqueue(u);
        else {
            cout << u.name << " " << elaps << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 13176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define rep(i, n)    for(ll i = 0; i < (n); ++i)
#define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fill(a)  memset(a, 0, sizeof (a))
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
const ll mod = 1e9+7;

int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll tt=1;
        // cin >> tt;
    while((tt)--){
        ll a[3]; cin >> a[0] >>a[1] >> a[2];
        sort(a,a+3);
        if(a[0]==a[1] and a[1]!=a[2]){
            cout << "Yes" << endl;
        }else if(a[1]==a[2] and a[0]!=a[1]){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

void insertionSort(vector<int>a, int n) {
	rep2(i,1, n) {
		int v = a[i];
		int j = i - 1;
		while (j >= 0 && a[j] > v) {
			a[j + 1] = a[j];
			j--;
		}
		a[j + 1] = v;
		rep(i, n-1 )cout << a[i] << " ";
		cout <<a[n-1]<< endl;
	}
}

int main() {
	int n;
	cin >> n;
	vector<int> r(n);
	for(int i=0;i<n;++i) {
		cin >> r[i];
	}
        rep(i, n-1 )cout << r[i] << " ";
		cout <<r[n-1]<< endl;
	insertionSort(r, n);
	
	}



Measured memory_bytes: 3160
import java.util.Scanner;
import java.util.Date;
import java.text.ParseException;
import java.text.SimpleDateFormat;

public class Main {
    public static void main(String[] args) {
        try { 
            Scanner scanner = new Scanner(System.in);
            String input_str = scanner.next();
            scanner.close();
            SimpleDateFormat sdFormat = new SimpleDateFormat("yyyy/MM/dd");
            Date input_date = sdFormat.parse(input_str);
            Date standard_date = sdFormat.parse("2019/04/30");
            if (input_date.compareTo(standard_date) > 0) {
                System.out.println("TBD");
            } else {
                System.out.println("Heisei");
            }
        } catch (ParseException e) {
            e.printStackTrace();
        }
    }

    Main() {
    }
}


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

int32_t main() {
	int n; cin>>n;
	int sum = 0;
	vector<int> a(n);
	for(int i = 0; i < n; i++){
		cin>>a[i];
	}
	for(int i = 0; i < n; i++){
		if(i % 2 == 0){
			sum += a[i];
		}
		else sum -= a[i];
	}
	vector<int> dp(n);
	dp[0] = sum;
	for(int i =1; i < n; ++i){
		dp[i] = (a[i-1] - dp[i-1] / 2) * 2;
	}
	for(int i = 0; i < n; i++){
		cout<<dp[i]<<" ";
	}
	cout<<endl;
}


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

long long gcd(long long x,long long y)
{
	return y==0 ? x : gcd(y,x%y);
}

int main()
{
	int N,M;
	while(cin>>N>>M,N){
		int r;
		cin>>r;

		//(PC,time)
		vector< vector<pair<int,int> > > in(M),out(M);

		for(int i=0;i<r;i++){
			int t,n,m,s;
			cin>>t>>n>>m>>s;

			if(s==0){
				out[m-1].push_back(make_pair(n,t));
			}else{
				in[m-1].push_back(make_pair(n,t));
			}
		}
		for(int i=0;i<M;i++){
			sort(in[i].begin(),in[i].end());
			sort(out[i].begin(),out[i].end());
		}

/*
		for(int i=0;i<N;i++){
			cout<<"student"<<i<<endl;
			for(int j=0;j<in[i].size();j++){
				cout<<"PC"<<in[i][j].first<<" in:"<<in[i][j].second<<endl;
				cout<<"PC"<<out[i][j].first<<" out:"<<out[i][j].second<<endl;
			}
		}
*/
		vector<vector<bool> > vb(M,vector<bool>(1261,false));


		for(int i=0;i<M;i++){
			for(int j=0;j<in[i].size();j++){
				int s=in[i][j].second,e=out[i][j].second;
				for(int k=s;k<e;k++) vb[i][k]=true;
			}
		}

//		for(int i=0;i<1261;i++) cout<<i<<" "<<vb[0][i]<<endl;

		int q;
		cin>>q;


		for(int i=0;i<q;i++){
			int s,e,m;
			cin>>s>>e>>m;
			int res=0;

			for(int j=s;j<e;j++){
				if(vb[m-1][j]){res++;}
			}

			cout<<res<<endl;
		}

	}

	return 0;
}

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

const int MAX_N = 1e5+2;
int N;
string s;
int ans[MAX_N];

bool go(int a1, int a2)
{
	ans[0]=a1;ans[1]=a2;
	if(!a1){ // truth
		if(s[0]=='o') ans[N-1]=a2;
		else ans[N-1]=a2^1;
	}else{  // lie
		if(s[0]=='o') ans[N-1]=a2^1;
		else ans[N-1]=a2;
	}
	for(int i=1;i<N-2;++i){
		// determine i+1
		int cur = ans[i];
		int prv = ans[i-1];
		if(!cur){ //truth
			if(s[i]=='o') ans[i+1]=prv;
			else ans[i+1]=prv^1;
		}else{ //lie
			if(s[i]=='o') ans[i+1]=prv^1;
			else ans[i+1]=prv;
		}
	}
	for(int i=0;i<N;++i)if(ans[i]<0)return false;
	for(int i=0;i<N;++i){
		int cur=ans[i];
		int prv = (i-1+N)%N;
		int nxt = (i+1)%N;
		if(!cur&&((s[i]=='o') != (ans[prv]==ans[nxt]))) return false;
		if(cur&&((s[i]=='x')!=(ans[prv]==ans[nxt]))) return false;
	}
	return true;
}

void solve()
{
	for(int f=0;f<2;++f)for(int s=0;s<2;++s){
		memset(ans,-1,sizeof(ans));
		if(go(f,s)){
			string t;
			for(int i=0;i<N;++i){
				if(ans[i]) t+='W';
				else t+='S';
			}
			cout << t << '\n';
			return;
		}
	}
	cout << -1 << '\n';
}

int main()
{
	cin >> N >> s;
	solve();
	return 0;
}

Measured memory_bytes: 4040
#!/usr/bin/env python
# encoding: utf-8

import sys


class Solution:
    def __init__(self):
        self.count = 0

    def shell_sort(self):
        _input = sys.stdin.readlines()
        array_length = int(_input[0])
        array = list(map(int, _input[1:]))

        G = [1]
        while True:
            g = G[0] * 3 + 1
            if g > array_length:
                break
            G.insert(0, g)

        g_length = len(G)
        result = []
        for j in range(g_length):
            result = self.insertion_sort(array=array, array_length=array_length, g=G[j])
            # print(result, 'r', G[j])

        print(g_length)
        print(*G)
        print(self.count)
        print(*result, sep='\n')

    def insertion_sort(self, array, array_length, g):
        # write your code here

        for i in range(g, array_length):
            v = array[i]
            j = i - g
            while j >= 0 and array[j] > v:
                array[j + g] = array[j]
                j -= g
                self.count += 1
            array[j + g] = v

        # print(" ".join(map(str, array)))
        return array


if __name__ == '__main__':
    solution = Solution()
    solution.shell_sort()

Measured memory_bytes: 134348
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] nums={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};
        System.out.println(nums[sc.nextInt()-1]);
        
        
        
 
    }



}

Measured memory_bytes: 22100
import sys

S = input()
acgt = 'ACGT'
ans = 0

for i in range(len(S)):
    tmp = 0
    for j in range(i, len(S)):
        if S[j] in acgt:
            tmp += 1
        else:
            break
    if tmp > ans:
        ans = tmp

print(ans)


Measured memory_bytes: 2940
n, m = map(int, input().split())
a = list(map(int, input().split()))
items = sum(a)
b = items * (1/(4*m))
popular = sorted(a, reverse=True)
popular_item = 0
for i in popular:
    if i >= b:
        popular_item += 1
if popular_item >= m:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fori(i,a,b) for(int i=a;i<=b;i++)
#define ford(i,a,b) for(int i=a;i>=b;i--)
#define pb push_back
#define mk make_pair



int main()
{
    int n;
    cin>>n;
    cout<<pow(n,3);
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{

    public Main(){
	Scanner sc = new Scanner(System.in);
	String str = sc.nextLine();
	str = str.replace("apple", "_");
	str = str.replace("peach", "apple");
	str = str.replace("_", "peach");
	System.out.println(str);
    }

    public static void main(String[] args){
	new Main();
    }
}

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

int main()
{
  int h, w;
  cin >> h >> w;
  vector<string> a(h);
  for (int i = 0; i < h; i++)
  {
    cin >> a[i];
  }
  for (int i = 0; i < w + 2; i++)
  {
    cout << "#";
  }
  cout << endl;
  for (int i = 0; i < h; i++)
  {
    cout << "#" << a[i]<< "#" << endl;
  }
  for (int i = 0; i < w + 2; i++)
  {
    cout << "#";
  }
  cout<<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll t;
  cin >> t;
  while(t--) {
    ll n;
    cin >> n;
    vec a(n);
    for(ll i=0;i<n;i++) cin >> a[i];
    string s;
    cin >> s;
    vec al;
    ll f=0;
    for(ll i=n-1;i>=0;i--) {
      for(ll t:al) {
        a[i]=min(a[i],a[i]^t);
      }
      al.push_back(a[i]);
      if(a[i]&&s[i]=='1') {
        f=1;
      }
    }
    cout << f << endl;
  }
}

Measured memory_bytes: 3496
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <stdlib.h>

using namespace std;
 
typedef long long i64;
typedef pair<i64, i64> P;

template<class T>
const T INF = numeric_limits<T>::max();
template<class T>
const T SINF = numeric_limits<T>::max() / 10;
static const i64 MOD = 1000000007;

//int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
//int dx[5] = {-1,0,0,0,1}, dy[5] = {0,-1,0,1,0};
//int dx[8] = {-1,0,1,1,1,0,-1,-1}, dy[8] = {1,1,1,0,-1,-1,-1,0};
//int dx[9] = {-1,0,1,1,1,0,-1,-1,0}, dy[9] = {1,1,1,0,-1,-1,-1,0,0};

struct edge {
  i64 from, to, cost;
  edge(i64 to, i64 cost) : from(-1), to(to), cost(cost) {}
  edge(i64 src, i64 to, i64 cost) : from(src), to(to), cost(cost) {}
};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//-----end of template-----//

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

	int k;
	cin >> k;
	if(k % 2) cout << k * k / 4 << endl;
	else cout << (k + 1) / 2 * (k / 2) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n, a, b; cin >> n >> a >> b;
    int ans =0;
    for (int i = 1; i <= n; i++) {
        int x = i, sum = 0;
        while (x > 0) {
            sum += x%10;
            x /= 10;
        }
        if (a <= sum && sum <= b) ans += i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstring>
#include<complex>
#include<stack>
#include<queue>
#include<unordered_map>
#include<map>

#define rep(i, a) for (int i = 0; i < (a); i++)

using namespace std;

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

  vector<long long int> a(n), b(n), c(n);
  rep(i, n) {
    cin >> a[i];
  }
  rep(i, n) {
    cin >> b[i];
  }
  rep(i, n) {
    cin >> c[i];
  }
  sort(a.begin(), a.end());
  sort(c.begin(), c.end());

  long long int ans = 0;
  rep(i, n) {
    long long int cnt_a = 0;
    long long int cnt_c = 0;

    cnt_a = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
    cnt_c = c.end() - upper_bound(c.begin(), c.end(), b[i]);

    ans += cnt_a * cnt_c;
  }
  cout << ans << endl;
}


Measured memory_bytes: 2560
import java.util.Scanner;

 
public class Main {
 
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] numbers = new int[N];
		boolean ans = true;
		for(int i = 0; i < N; i++) {
			numbers[i] = sc.nextInt(); 
		}
		for(int i = 0; i < N; i++) {
			if(numbers[i] % 2 == 0) {
				if((numbers[i] % 3 != 0) && (numbers[i] % 5 != 0) ) {
					ans = false;
				}
			}
		}
				
		if(ans) {
			System.out.println("APPROVED");
		}else {
			System.out.println("DENIED");
		}
		sc.close();
	}
	
}

Measured memory_bytes: 23764
import math
from collections import deque
def main():
    
    t = [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]
    a = int(input())
    
    print(t[a-1])


if __name__ == "__main__":
    main()

Measured memory_bytes: 3316
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())

a1=(a+9)//10*10
b1=(b+9)//10*10
c1=(c+9)//10*10
d1=(d+9)//10*10
e1=(e+9)//10*10

tmax=0
if tmax<a1-a:
	tmax=a1-a
if tmax<b1-b:
	tmax=b1-b
if tmax<c1-c:
	tmax=c1-c
if tmax<d1-d:
	tmax=d1-d
if tmax<e1-e:
	tmax=e1-e

print (a1+b1+c1+d1+e1-tmax)


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int negativeCount = 0;
        long minNum = Long.MAX_VALUE;
        long absSum = 0L;
        for (int i = 0; i < N; i++) {
            long a_i  = sc.nextLong();
            long abs = Math.abs(a_i);
            if (a_i < 0L) {
                negativeCount++;
            }
            absSum += abs;
            if (abs < minNum) {
                minNum = abs;
            }
        }
        System.out.println(negativeCount % 2 == 0 ? absSum : absSum - 2L * minNum);
    }
}


Measured memory_bytes: 48360
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <bitset>

using namespace std;
using ll = long long int;

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

  string ans;
  for (ll i = 0; i < (1 << 4); i++)
  {
    ll sum = S[0] - '0';
    for (ll j = 1; j < 4; j++)
    {
      if (bitset<4>(i)[j]) {
        sum += S[j] - '0';
      } else {
        sum -= S[j] - '0';
      }
    }

    if (sum == 7) {
      for (ll j = 1; j < 4; j++)
      {
        if (bitset<4>(i)[j]) {
          ans += '+';
        } else {
          ans += '-';
        }
      }
      ans += '=';
      break;
    }
  }
  S += '7';

  for (ll i = 0; i < 4; i++)
  {
    cout << S[i] << ans[i];    
  }
  cout << 7 << endl;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF 2000000000
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;
 
using namespace std;
 
int main(void){
  int A,B,c1,c2,c3,c4,c5,ans=0;
  cin >> A >> B;
  for(int i=A;i<=B;i++){
    c1=i/10000;
    c2=(i%10000)/1000;
    c3=(i%1000)/100;
    c4=(i%100)/10;
    c5=i%10;
    if(c1==c5 && c2==c4) ans++;
  }
  cout << ans << endl;
}

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

#define PI 4*atan(1)
#define INF 1e8

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

vector<int> a{1,3,5,7,8,10,12};
vector<int> b{4,6,9,11};
int c = 2;

bool search(vector<int> &a, int n){
  for(int i = 0; i < a.size(); i++){
    if(a[i] == n)return true;
  }
  return false;
}

int main(){
  int x, y;
  cin >> x >> y;
  if(search(a, x) == true && search(a,y) == true){
    cout << "Yes" << endl;
    return 0;
  }else if(search(b, x) == true && search(b, y) == true){
    cout << "Yes" << endl;
    return 0;
  }else if(c == x && c == y){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  
}


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

int main()
{
    string w,a = {"abcdefghijklmnopqrstuvwxyz"};
    cin >> w;
    int cnt[26] = {},flag = 0;
    for(int i = 0; i < w.length(); i++){
        for(int j = 0; j < 26; j++){
            if(w[i] == a[j]) cnt[j]++;
        }
    }
    for(int i = 0; i < 26; i++)
        if(cnt[i] % 2 != 0) flag = 1;

    cout << (flag == 0 ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// using std::gcd;
using std::make_pair;
using std::max;
using std::min;
using std::pair;
using std::sort;
using std::string;
using std::vector;
using lli  = long long;
using ulli = unsigned long long;

// pairの入出力
template <typename T1, typename T2>
std::istream &operator>>(std::istream &is, std::pair<T1, T2> &p) {
    is >> p.first >> p.second;
    return is;
}
template <typename T1, typename T2>
std::ostream &operator<<(std::ostream &os, const std::pair<T1, T2> &p) {
    os << p.first << " " << p.second;
    return os;
}

// vectorの入出力
template <typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &v) {
    for (T &in : v) is >> in;
    return is;
}
template <typename T>
std::ostream &operator<<(std::ostream &os, const std::vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) {
        os << v[i] << (i + 1 != v.size() ? " " : "");
    }
    return os;
}

// よく使う定数
// std::string ans[2] = {"No\n", "Yes\n"};
constexpr int MOD = 1'000'000'007;
// constexpr int MOD = 998'244'353;

// メイン
int main() {
    using std::cin;
    using std::cout;
    using std::endl;

    cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(10);

    /**/
    string t;
    cin >> t;
    for (int i = 0; i < t.length(); ++i) {
        if (t.at(i) == '?') t.at(i) = 'D';
    }
    cout << t << endl;
    return 0;
}

Measured memory_bytes: 3776
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
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; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
#define fs first
#define sc second
// 多倍長
#include <boost/rational.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using boost::rational;
using boost::multiprecision::cpp_int;

const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;


int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int x,n;
    cin >> x >> n;
    vector<int> d(102);
    rep(i, n){
        int p;
        cin >> p;
        d[p] = 1;
    }
    pint ans = pint(99999, -1);
    rep(i, 102){
        if(d[i] == 1) continue;
        chmin(ans, pint(abs(x - i), i));
    }
    print(ans.sc);


}



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

int main(){
  char s[4];
  cin >> s[0] >> s[1] >> s[2] >> s[3];
  if(s[0] == s[1] && s[2] == s[3] && s[1] != s[2])cout << "Yes" << endl;
  else if(s[0] == s[2] && s[1] == s[3] && s[2] != s[1])cout << "Yes" << endl;
  else if(s[0] == s[3] && s[1] == s[2] && s[3] != s[1])cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

int main() {
  int a, b, c, e, f, g;
  cin >> a >> b >> c;
  e = min(a,b);
  f = max(a,b);
  b = f;
  g = max(b,c);
  f = min(b,c);
  a = min(e,f);
  b = max(e,f);
  c = g;
  
  if(a == 5 && b == 5 && c == 7)
    cout <<"YES"<<endl;
  else
    cout <<"NO"<<endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
//DP(動的計画法)
//個数制限なしナップザック問題
//dp[i][j]=i個までを使ってAの和がjの時の最小コスト
//漸化式だと
//そのiの魔法使う場合
//dp[i+1][j+Ai]=min(～～～,dp[i][j]+Bi)
//そのiの魔法使わない場合
//dp[i+1][j+Ai]=min(～～～,dp[i][j]+Bi)
//またループで表すと、個数制限はないので,i番目の魔法をk回使う
//for(k=0,...,h/k)
//dp[i+1][j+kAi]=min(～～～,dp[i][j]+kBi)
//ただこの書き方だとO(NH^2)で時間足りないので、漸化式を少しいじる
//O(NH)
//dp[i+1][j]=min(dp[i][j],dp[i+1][j-A]+Bi)
//ただ問題によっては下のやつでも解ける
//dp[j]=min(～～,dp[j-A]+Bi)


class Program
{
    static public readonly int INF = 1001001001;
    static void Main(string[] args)
    {
        string[] In = Console.ReadLine().Split(' ');
        int h = int.Parse(In[0]);
        int n = int.Parse(In[1]);
        int[] Dp = new int[h + 1];
        Dp = Enumerable.Repeat(INF,h+1).ToArray();
        //ShowDp(Dp);
        Dp[0] = 0;
        for (int i=0; i < n; i++)
        {
            In = Console.ReadLine().Split(' ');
            int a = int.Parse(In[0]);
            int b = int.Parse(In[1]);
            for(int j=0; j < h; j++)
            {
                int nj = (int)Math.Min(j + a, h);//njは次の添え字、minは基本j+a使うが、配列外参照を防ぐためhもいれてる
                Dp[nj] = (int)Math.Min(Dp[nj], Dp[j]+b);
                //ShowDp(Dp);
            }
        }
        Console.WriteLine(Dp[h]);
    }
    static void ShowDp(int[] Dp)
    {
        foreach(var d in Dp)
        {
            if (d == INF) Console.Write(" *");
            else Console.Write(" "+d);
        }
        Console.WriteLine();
    }
}



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

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

const int MAXN = 1e5;

int N, K, S;

int main()
{
	int i, j;

	scanf("%d%d%d", &N, &K, &S);

	if(S!=1e9)
	{
		for(i=1; i<=K; i++) printf("%d ", S);
		for(i=K+1; i<=N; i++) printf("%d ", S+1);
	}
	else
	{
		for(i=1; i<=K; i++) printf("%d ", S);
		for(i=K+1; i<=N; i++) printf("%d ", 1);	
	}
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int INF = 1e+9;
const ll mod = 1000000007;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

int h[100010];
int dp[100010];

int main () {
  int N, K; cin >> N >> K;
  rep(i,N) cin >> h[i];

  rep(i,100010) dp[i] = INF;
  dp[0] = 0;
  for (int n = 0; n < N; n++) {
    for (int i = 1; i <= K; i++) {
      dp[n+i] = min(dp[n+i], dp[n]+abs(h[n]-h[n+i]));
    }
  }

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

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <cmath>
#include <math.h>
#include <map>
#include <algorithm>
#include <string>
using namespace std;

int main() {
	string S;
	cin >> S;
	for (int i = 1; i < 4; i++) {
		if (S.at(i - 1) == S.at(i)) {
			cout << "Bad" << endl;
			return 0;
		}
	}

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


Measured memory_bytes: 256