akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<string>
#define gc getchar()
using namespace std;
#define kk putchar(32)
#define hh putchar(10)
#define ll long long
template<class T>inline void qin(T &x){char a;T f(1);while((a=getchar())<48)
(a==45)&&(f=-1);for(x=a^48;(a=getchar())>47;x=(x<<3)+(x<<1)+(a^48));x*=f;}


int a[200004]; 
void Main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;++i){
		qin(a[i]);
		a[i]-=i;
	}
	sort(a+1,a+n+1);
	int b=a[(n+1)/2];
	ll ans=0;
	for(int i=1;i<=n;++i)ans+=abs(a[i]-b);
	cout<<ans;
}








int main(){Main();return 0;}





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

int main() {
	int n; cin >> n;
	int p; cin >> p;
	string s; cin >> s;
	if(p == 2 or p == 5) {
		map<int, int64_t> dp;
		int64_t ans = 0;
		for(int i = 0; i < n; ++i) {
			map<int, int64_t> nxt;
			int num = s[i] - '0';
			nxt[num % p]++;
			for(auto e : dp) {
				nxt[(e.first * 10 + num) % p] += e.second;
			}
			dp = nxt;
			ans += dp[0];
		}
		cout << ans << '\n';
		return 0;
	}
	int64_t cnt[p] = {};
	cnt[0] = 1;
	int now = 0;
	int mul = 1;
	int64_t ans = 0;
	for(int i = n - 1; i >= 0; --i) {
		now += (s[i] - '0') * mul;
		now %= p;
		mul *= 10;
		mul %= p;
		ans += cnt[now];
		cnt[now]++;
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 644
object Main extends App {
  val n = io.StdIn.readLine.toInt
  val ans = Iterator.continually(io.StdIn.readLine)
    .take(n)
    .map(_.split(" ").map(_.toInt))
    .map(in => {
      val Array(t, x, y) = in
      if (x + y > t) false
      else if ( ((t-x-y) & 1) == 1) false
      else true
    })
    .takeWhile(_ == true)
    .toArray

  println(if (ans.size == n) "Yes" else "No")
}

Measured memory_bytes: 60872
//Author rahuliitkgp

/*A thing of beauty is a joy forever,
Its loveliness increases,
it will never pass into nothingness.*/
//Men at Work :)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;

#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define INF (int)1e9 + (int)1e8
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void cpp() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int main(){
    cpp();
    ll n, w;
    cin>>n>>w;
    vector<pair<ll, ll> > v(n);
    for(ll i=0; i<n; i++){
        cin>>v[i].first>>v[i].second;
    }
    vector<vector<ll> >dp(n+1, vector<ll>(n*1000+1));
    dp[0][0] = 0;
    for(ll j=1; j<dp[0].size(); j++){
        dp[0][j] = INF;
    }
    for(ll i=1; i<=n; i++){
        for(ll j=1; j<=n*1000; j++){
            dp[i][j] = dp[i-1][j];
            if(j>=v[i-1].second){
                dp[i][j]=min(dp[i][j], dp[i-1][j-v[i-1].second]+v[i-1].first);
            }
        }
    }
    ll ans = 0;
    for(ll i=0; i<=n*1000; i++){
        if(dp[n][i]<=w){
            ans = i;
        }
    }
    cout<<ans<<endl;
    return 0;
}






Measured memory_bytes: 83228
N, M = map(int, input().split())
H = list(map(int, input().split()))
res = [1]*N
for i in range(M):
    a, b = map(int, input().split())
    if H[a-1] > H[b-1]:
        res[b-1] = 0
    elif H[a-1] < H[b-1]:
        res[a-1] = 0
    else:
        res[a-1] = 0
        res[b-1] = 0

print(sum(res))


Measured memory_bytes: 20144
def test():
    n = int(input())
    h = list(map(int,input().split()))
    ans = h[0]
    for i in range(n-1):
        if h[i] < h[i+1]:
            ans += h[i+1] - h[i]
    print(ans)


if __name__ == "__main__":
    test()


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


int main()
{
  	int N;
	cin >> N;
	int H[N];
	int count;
	int current_height;
	count = 1;
	for (int i=0;i<N;i++){
		cin >> H[i];
	}
	current_height = H[0];
	for (int i=1;i<N;i++){
		if (H[i] >= current_height){
			count += 1;
			current_height = H[i];
		}
	}		
	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
// ALDS 1_10_B
#include<cstdio>
#include<cstring>
#include<vector>
#define rep(i,a) for( int i = 0; i != (a); ++i )
#define repi(i,a,b) for( int i = (a); i != (b); ++i )

const int INF = 1<<28;

int n;
std::vector<int> r(100);
std::vector<std::vector<int> > dp( 100, std::vector<int>( 100, INF ) );

int main()
{
	scanf( "%d", &n );
	rep( i, n )
		scanf( "%d%d", &r[i], &r[i+1] );

	rep( i, n )
		dp[i][i] = 0;

	repi( k, 1, n ) rep( i, n-k ) repi( j, i, i+k )
		dp[i][i+k] = std::min( dp[i][i+k], dp[i][j]+dp[j+1][i+k]+r[i]*r[j+1]*r[i+k+1] );	

	printf( "%d\n", dp[0][n-1] );

	return 0;
}

Measured memory_bytes: 1076
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <unordered_map>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <memory>
#include <iomanip>
#include <type_traits>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
constexpr long long MOD = 1e9 + 7;
constexpr long long MAX = 1000000;

//long long MOD = 998244353;
constexpr ll INF = 1e17;
constexpr double PI = 3.141592653589793;
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; }

ll h, w;
vector<ll> dx = { -1, 0, 1, 0 };
vector<ll> dy = { 0, -1, 0, 1 };


bool isInField(ll x, ll y) {
    bool f = x >= 0 && x < w && y >= 0 && y < h;
    return f;
}

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

    ll n;
    cin >> n;
    vector<vector<ll>> cnt(10, vector<ll>(10));

    ll t = 1;
    for (size_t i = 1; i <= n; i++)
    {
        if (i >= (t * 10)) {
            t *= 10;
        }
        cnt[i / t][i % 10]++;
    }

    ll ans = 0;
    for (size_t i = 0; i < 10; i++)
    {
        for (size_t j = 0; j < 10; j++)
        {
            ans += cnt[i][j] * cnt[j][i];
        }
    }

    cout << ans << "\n";

    return 0;
}



Measured memory_bytes: 256
use proconio::*;

fn main() {
    input! {
        x: i64,
        n: usize,
        p: [i64; n]
    }
    
    if n == 0 {
        println!("{}", x);
        return;
    }

    let mut flag: [bool; 102] = [false; 102];
    for i in 0..n {
        flag[p[i] as usize] = true;
    }

    let mut min_diff = 101;
    let mut ans = x;
    for i in 0..=101 {
        if flag[i] { continue; }
        let diff = (i as i64 - x).abs();
        if diff < min_diff {
            min_diff = diff;
            ans = i as i64;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2172
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
      	int n = Integer.parseInt(sc.next());
      	int odd = 1;
      	for (int i = 0; i < n; i++) {
          	int a = Integer.parseInt(sc.next());
        	if (a % 2 == 0) odd *= 2;
        }
		System.out.println(Math.round(Math.pow(3, n) - odd));
    }
}

Measured memory_bytes: 21844
import sys
N = int(input())
A = list(map(int, input().split()))
total = sum(A)
num = [0] * (10 ** 5 + 1)
for a in A:
    num[a] += 1

Q = int(input())
for _ in range(Q):
    b, c = map(int, sys.stdin.readline().split())
    total -= b * num[b]
    total += c * num[b]
    num[c] += num[b]
    num[b] = 0
    print(total)

Measured memory_bytes: 21024
import sys
from heapq import *
sys.setrecursionlimit(10**8)

input = sys.stdin.readline

tree = [[] for _ in range(200001)]
res = [0]*200001

def dfs(p, pre):
    for child in tree[p]:
        if child == pre: continue
        res[child] += res[p]
        dfs(child, p)

def main():
    """ main """
    N, Q = map(int, input().split())
    for _ in range(N-1):
        a,b = map(int, input().split())
        tree[a].append(b)
        tree[b].append(a)
    for _ in range(Q):
        p,x = map(int, input().split())
        res[p] += x
    dfs(1, 0)

    print(*res[1:N+1])

if __name__ == '__main__':
    main()

Measured memory_bytes: 230956
#include <stdio.h>
#define N 100001

typedef struct{
  int parent;
  int left;
  int right;
} Node;

void getDepth(int,int);

int depth[N];
Node T[N];

int main(){
    int i,j,u,n,deg,id,k,sibling ,left,x,right,r;

    scanf("%d",&n);
    for(i = 0; i < n; i++){
      T[i].parent = -1;
      T[i].left = -1;
      T[i].right = -1;
    }

    for(i = 0; i < n; i++){
      scanf("%d %d",&id,&k);

      if (k != 0){
        scanf("%d",&sibling);
        T[sibling].parent = id;
        T[id].left = sibling;
        right = sibling;

        for(j = 1; j < k ; j++){
          scanf("%d",&sibling);
          T[sibling].parent = id;
          T[right].right = sibling;
          right = sibling;
        }
      }
    }

    for(i = 0; i < n; i++){
      if(T[i].parent == -1) r = i;
    }

    getDepth(r,0);

    for(i = 0; i < n; i++){
      printf("node %d: parent = %d, depth = %d, ",i,T[i].parent,depth[i]);

      if(T[i].parent == -1) printf("root, [");
      else if(T[i].left == -1) printf("leaf, [");
      else printf("internal node, [");

      x = T[i].left;
      if(x != -1){
        while(1){
          if(T[x].right == -1){
            printf("%d",x);
            break;
          }
          else{
            printf("%d, ",x);
            x = T[x].right;
          }
        }
      }
      printf("]\n");
    }
    return 0;
  }

void getDepth(int n ,int p){
  depth[n]=p;

  if(T[n].right != -1) getDepth(T[n].right,p);
  if(T[n].left != -1) getDepth(T[n].left, p+1);
  return;
}



Measured memory_bytes: 6380
N = int(input())
A = list(map(int,input().split()))
Lo = 0
L2 = 0
L4 = 0
for i in range(N):
    if A[i]%2==1:
        Lo+=1
    elif A[i]%4==0:
        L4+=1
    else:
        L2+=1
if Lo<=L4:
    print("Yes")
else:
    if Lo==L4+1 and L2==0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 85292
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int A,B,C,K;
		A=sc.nextInt();
		B=sc.nextInt();
		C=sc.nextInt();
		K=sc.nextInt();
		int max=A;
		if(A>=K) {
			max = K;
		}
		else if(A+B>=K) {
			max=A;
		}else {
			max=A-(K-A-B);
		}
		System.out.println(max);
		
	}
}





Measured memory_bytes: 35496
#include <bits/stdc++.h>
#define range(i, a, n) for(int (i) = (a); (i) < (n); (i)++)
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
using namespace std;
int main(void){
    int n; cin >> n;
    vector<int> a(n);
    for(auto & e : a) cin >> e;

    set<int> s;
    rep(i, n){
        int num = 0;
        rep(j, 9){
            if(i + j >= n) break;
            num *= 10;
            num += a[i + j];
            s.insert(num);
        }
    }

    int res = 0;
    for(auto & e : s){
        if(e != res){
            break;
        }
        res++;
    }

    cout << res << endl;

	return 0;
}

Measured memory_bytes: 3404
import math
import queue
import bisect
import heapq
import time
import itertools

mod = int(1e9+7)

def swap(a,b):
    return (b,a)

def gcd(a,b): #最大公約数
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def lcm(a,b): #最小公倍数
    return a/gcd(a,b)*b

def divisors(a): # 約数列挙
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def is_prime(a): #素数判定
    if a<2:
        return False
    elif a==2:
        return True
    elif a%2==0:
        return False
    sqrt_num = int(a**0.5)
    for i in range(3,sqrt_num+1,2):
        if a%i==0:
            return False
    return True

def prime_num(a): #素数列挙
    pn = [2]
    for i in range(3,int(a**0.5),2):
        prime = True
        for j in pn:
            if i%j==0:
                prime = False
                break
        if prime:
            pn.append(i)
    return pn

def prime_fact(a): #素因数分解
    sqrt = math.sqrt(a)
    res = []
    i = 2
    if is_prime(a):
        res.append(a)
    else:
        while a!=1:
            while a%i==0:
                res.append(i)
                a //= i
            i += 1
    return res

def main():
    s,t = input().split()
    ans = [t,s]
    print(''.join(ans))
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 38636
#include <iostream>
using namespace std;
int main(void){
    int H, W;
    while(1){
        cin>> H >> W;
        if(H==0 && W==0){
            break;
        }else{
            for(int i=0;i<H;i++){
                for(int j=0;j<W;j++){
                    if((i+j)%2==0){
                        cout<<"#";
                    }else{
                        cout<<".";
                    }
                }
                cout<<endl;
            }
            cout<<endl;
        }
    }
    
}



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

namespace ClassLibrary1
{
    public class ListNode
    {
        public int val;
        public ListNode next;
        public ListNode(int x) { val = x; }
    }


    public class Class1
    {

        static void Main(string[] args)
        {
            //            string[] s = Console.ReadLine().Split(' ');
            string s = Console.ReadLine();
            long k = long.Parse(Console.ReadLine());

            char[] ch = s.ToCharArray();
            if (ch.Length == 1)
            {
                Console.WriteLine(k / 2);
                return;
            }

            long op = 0;
            long cnt = 1;
            char tmp = ' ';
            for (int i = 0; i < ch.Length; i++)
            {
                if (tmp == ch[i])
                {
                    cnt++;
                }
                else
                {
                    op += cnt / 2;
                    cnt = 1;
                }
                tmp = ch[i];
            }
            op += cnt / 2;


            bool extra = false;
            if (ch[0] == ch[ch.Length - 1])
            {
                int ind = 0;
                int lastind = 0;
                for (int i = 0; i < ch.Length; i++)
                {
                    if (ch[i] != ch[0])
                    {
                        ind = i + 1;
                        break;
                    }
                }
                if (ind > 0)
                {
                    for (int i = 0; i < ch.Length; i++)
                    {
                        if (ch[ch.Length - i - 1] != ch[0])
                        {
                            lastind = i + 1;
                            break;
                        }
                    }
                    extra = ((ind + lastind) % 2 == 0);
                }
                else
                {
                    Console.WriteLine(ch.Length*k /2);
                    return;
                }
            }

            long cc = op * k;
            if (extra) cc += k - 1;
            Console.WriteLine(cc);

        }

        static int rec(int[] n, int i, int j, int x)
        {
            if (i + 1 == j)
            {
                return Math.Min(n[j], x);
            }
            return rec(n, i + 1, j, n[i]) + rec(n, i, j - 1, n[j]);
        }


    }
}


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

int main()
{
	stringstream ss;
    // 入力
    int A,B,C;
    cin>>A>>B>>C;

    if(A==B) {
    	cout<<C<<endl;
    } else if(B==C){
    	cout<<A<<endl;
    } else{
    	cout<<B<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define MOD 1000000007


long long power(long long a, long long b) {
    if (b == 0) {
        return 1;
    }
    
    long long result = 1;
    for (int i = 0; i < b; i++) {
        result *= a;
    }
    return result;
}

int main(int argc, char *argv[]) {
    long long N, P;
    cin >> N >> P;
    
    vector<long long> v;
    map<long long, long long> m;
    ll i;
    
    if (N == 1) {
        // do nothing
    } else {
        for (i = 2; i * i <= P; i++) {
            while (P % i == 0) {
                m[i]++;
//                v.push_back(i);
                P /= i;
            }
        }
    }
    
    if (P != 1) {
//        v.push_back(P);
            m[P]++;
    }
    
    long long ans = 1;
    for (auto p: m) {
        if (p.second < N) {
            continue;
        } else {
            ans *= power(p.first, (p.second / N));
        }
        //cout << p.first << " -> " << p.second << endl;
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
def examA():
    N = I()
    ans = 0
    print(ans)
    return

def examB():
    N, A, B, C, D = LI()
    for i in range(N-1):
        low = A + i*C - (N-1-i)*D
        up = A + i*D - (N-1-i)*C
        if low<=B<=up:
            print("YES")
            return
    print("NO")
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    N = I()
    V = [[]for _ in range(N)]
    for _ in range(N-1):
        x, y = LI()
        x -= 1; y -= 1
        V[x].append(y)
        V[y].append(x)
    def dfs(s,p):
        grundy = 0
        judge = len(V[s])
        if p==-1:
            judge += 1
        if judge==1:
            return grundy
        if judge==2:
            for v in V[s]:
                if v == p:
                    continue
                cur = dfs(v, s)
                grundy = cur+1
            return grundy
        for v in V[s]:
            if v==p:
                continue
            cur = dfs(v,s)+1
            #print(cur)
            grundy ^= cur

        return grundy
    ans = "Alice"
    if dfs(0,-1)==0:
        ans = "Bob"
    print(ans)
    return

def examE():
    N, H = LI()
    A = [LI()for _ in range(N)]


    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

from decimal import Decimal as dec
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def DI(): return dec(input())
def LDI(): return list(map(dec,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)


if __name__ == '__main__':
    examD()

"""

"""

Measured memory_bytes: 133792
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
using namespace std;
#define INF 1010101010
#define MOD 1000000007
#define LL long long

int main() {
    bool rect[100][100];
    int w, h, n;
    cin >> w >> h >> n;
    for (int i = 0; i < w; i++) for (int j = 0; j < h; j++) rect[i][j] = false;
    for (int i = 0; i < n; i++) {
        int x, y, a;
        cin >> x >> y >> a;
        switch (a) {
            case 1: for (int i = 0; i <= x-1; i++) for (int j = 0; j < h; j++) rect[i][j] = true; break;
            case 2: for (int i = w-1; i > x-1; i--) for (int j = 0; j < h; j++) rect[i][j] = true; break;
            case 3: for (int i = 0; i <= y-1; i++) for (int j = 0; j < w; j++) rect[j][i] = true; break;
            case 4: for (int i = h-1; i > y-1; i--) for (int j = 0; j < w; j++) rect[j][i] = true; break;
        }
    }
    int ans = 0;
    for (int i = 0; i < w; i++) for (int j = 0; j < h; j++) if(!rect[i][j]) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>
#include <list>
#include <stdio.h>
#include <sstream>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const ll mod = 1e9 + 7;
const ll inf = 1LL << 60;
const long double pi = 3.14159265358979323846;

// ****************************************CODE***************************************//

ll n;
ll h[100100];
ll dp[100100];

int main() {
    cin >> n;
    for(int i = 0; i < n; i++) cin >> h[i];
    for(int i = 0; i < 100100; i++) dp[i] = inf;

    dp[0] = 0;
    for(int i = 0; i < n; i++){
        dp[i+1] = min(dp[i+1], dp[i] + abs(h[i] - h[i+1]));
        dp[i+2] = min(dp[i+2], dp[i] + abs(h[i] - h[i+2]));
    }

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

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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 5;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

typedef pair<ll, ll> P;

const ll N = 2e5+5;
string s;
vector<P> v;
ll n,d,a,X,H,result,num[N];
vector<ll> b,c;
queue<P> q;

int main () {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> d >> a;
  rep(i,n) {
    cin >> X >> H;
    v.push_back(P(X,H));
  }
  VSORT(v);
  rep(i,n) {
    b.push_back(v[i].second);
    c.push_back(v[i].first);
  }
  ll num = 0;
  rep(i,n) {
    while(q.size() > 0 && q.front().first < v[i].first) {
      num -= q.front().second;
      q.pop();
    }
    v[i].second -= num * a;
    if (v[i].second > 0 ){
      ll temp = (v[i].second-1) / a + 1;
      q.push(P(v[i].first + 2 * d, temp));
      num += temp;
      result += temp;
    }
    //cout << i << " : " << num << endl;
  }
  cout << result << endl;
}


Measured memory_bytes: 9324
from itertools import product
N = int(input())
 
row = range(1, 10)
clo = range(1, 10)
 
A = 0
for row,clo in product(row,clo):
  if row*clo == N:
    A = "Yes"
if A != "Yes":
    A = "No"
print(A)

Measured memory_bytes: 38588
use std::io::stdin;

fn main() {
    let mut ab = String::new();
    stdin().read_line(&mut ab).unwrap();
    let ab: Vec<isize> = ab.trim().split_whitespace().flat_map(str::parse).collect();
    let (r, d, x) = (ab[0], ab[1], ab[2]);

    let mut v = x;
    for _ in 0..10 {
        v = r * v - d;
        println!("{}", v);
    }
}


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

using namespace std;

const int maxn = 1000 + 10;

int a,b,c,ans,a1,b1,c1;

int main()
{
    cin>>a>>b>>c;
    if(a == b && b == c && a % 2 == 0){
        cout<<-1;
        return 0;
    }
    while(a % 2 == 0 && b % 2 == 0 && c % 2 == 0)
    {
        a1 = b / 2 + c / 2;
        b1 = a / 2 + c / 2;
        c1 = a / 2 + b / 2;
        a = a1;
        b = b1;
        c = c1;
        ans++;
    }
    cout<<ans;
}


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

using namespace std;
using ll  = long long;
using ii  = pair < int , int >;
using i3  = pair < int , ii >;
using vi  = vector < int >;
using vii = vector < ii >;
using vi3 = vector < i3 >;

const int N = 2e5 + 5;
const ll INF = 1e12;
const double eps = 1e-9 , PI = acos(-1);

int n;
int a[N];
ll dp[N];

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

    dp[0] = 0;
    dp[1] = abs(a[0] - a[1]);
    for(int i = 2 ; i < n ; i ++){
        dp[i] = min(dp[i-1] + 1ll*abs(a[i] - a[i-1]) , dp[i-2] + 1ll*abs(a[i] - a[i-2]));
    }
    printf("%lld\n" , dp[n-1]);
}

main(){
    int t = 1;
    //scanf("%d" , &t);

    while( t -- ){
            solve();
    }

    return 0;
}





Measured memory_bytes: 1536
#include <cstring>
#include <cassert>
#include <utility>
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <bitset>
#include <chrono>
#include <cstdlib>
#include <functional>
#include <tuple>
#include <climits>
#include <limits>
#include <deque>
#include <list>
#include <array>
#include <stack>
#include <queue>
#include <random>
#include <complex>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
 
#define init ios::sync_with_stdio(0); cin.tie(NULL);cout.tie(NULL);
#define setpr(x) cout << setprecision((x))
#define PI atan(1)*4
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define mk(a , b) { min((a) , (b)) , max((a) , (b)) }
#define flush cout.flush()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endc "\n"
#define MOD 1000000007
#define mod(x) (x) %= MOD
 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pld;
 
ll gcd(ll a, ll b){
    while(true){
        if(a>b)
            swap(a,b);
        if (a == 0) 
            return b; 
        ll p = b % a  , q = a;
        a = p;
        b = q;
    }
}
 
ll powerMod(ll x,ll y){
    ll res = 1;
    x %= MOD;
    while(y > 0){
        if(y & 1)res = (res*x)%MOD;
        y = y >> 1;
        x = (x * x)%MOD;
    }
    return res%MOD;
}


//  ==========     //\\       //||     ||====//||
//      ||        //  \\        ||     ||   // ||
//      ||       //====\\       ||     ||  //  ||
//      ||      //      \\      ||     || //   ||
//  ========== //        \\  ========  ||//====|| 
//  code

vector< vector<ll> > matmul(vector< vector<ll> > a , vector< vector<ll> > b){
    vector< vector<ll> > c;
    c.resize((int)a.size() , vector<ll> ((int)b[0].size()));

    for(int i = 0; i < a.size(); i++){
        for(int j = 0; j < b[0].size(); j++){
            c[i][j] = 0;
            for(int k = 0; k < b.size(); k++){
                c[i][j] += a[i][k] * b[k][j];
                c[i][j] %= MOD;
            }
        }
    }
    return c;
}

vector< vector<ll> > matexp(vector< vector<ll> > basic, ll n){
    int nn = basic.size();
    vector< vector<ll> > ans(nn, vector<ll>(nn, 0));

    for(int i = 0; i < nn; i++){
        ans[i][i] = 1LL;
    }

    while(n){
        if(n % 2){
            ans = matmul(ans, basic);
        }
        basic = matmul(basic, basic);
        n /= 2LL;
    }
    return ans;
}


int32_t main(){
    init;
    ll n,i,j,k,l,p;
    cin >> n >> k;

    vector< vector<ll> > a(n, vector<ll>(n));

    for(auto &i : a){
        for(auto &j : i)
            cin >> j;
    }
    
    a = matexp(a, k);
    ll ans = 0;
    for(auto i : a)for(auto j : i) ans = (ans + j) % MOD;
    cout << ans << endc;
    return 0;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
int n, m, tot[100007], mx, cnt, x, y;
vector<int> e[100007];
int read()
{
    int num = 0;
    char c = getchar();
    while (c < '0' || c > '9')c = getchar();
    while (c >= '0' && c <= '9')num = num * 10 + c - '0', c = getchar();
    return num;
}
int dfs(int w, int f)
{
    if (w == x && f) { cout << "Yes" << endl; exit(0); }
    if (w == y)return 0;
    for (int i = 0, lim = e[w].size(); i < lim; i++)
        if (e[w][i] != f)dfs(e[w][i], w);
    return 0;
}
int main()
{
    n = read();
    m = read();
    for (int i = 1; i <= m; i++)
    {
        int a = read(), b = read();
        e[a].push_back(b);
        e[b].push_back(a);
        tot[a]++;
        tot[b]++;
    }
    for (int i = 1; i <= n; i++)
        if (tot[i] & 1) { cout << "No" << endl; return 0; }
        else
        {
            mx = max(mx, tot[i]);
            if (tot[i] == 4)
            {
                cnt++;
                if (x)y = i;
                else x = i;
            }
        }
    if (mx < 4 || (mx == 4 && cnt == 1)) { cout << "No" << endl; return 0; }
    if (mx > 4 || cnt > 2) { cout << "Yes" << endl; return 0; }
    dfs(x, 0);
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 7296
#include<iostream>
#include<vector>
#include <string.h>
using namespace std;
typedef long long ll;
const int MAX_N=1e7+2;
int cnt[MAX_N]={0,};


int main()
{
    for(int i=1;i<MAX_N;i++)
        for(int j=1;j<=MAX_N/i;j++) cnt[i*j]++;

    int N;
    cin>>N;
    ll sum=0;
    for(int i=1;i<=N;i++)
        sum+=(ll)cnt[i]*i;
    cout<<sum;
}


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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define RREP(i,s,n) for(lli i=s;i>=n;i--)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

signed main(){

	set<char> d;
	REP(i,0,3){
		char tmp;
		cin>>tmp;
		d.insert(tmp);
	}

	if(d.size()!=1)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;


	return 0;
}

Measured memory_bytes: 256
// Max Profit
// 最大利益
//
// 入力　n,n個のRt(t=0..n-1)
// 出力　最大利益
// 
// 1,
// 2,
// 3,

#include <cmath>
#include<iostream>

int main(){
	
	long maxv,minv,r;
	int i, j, n;

	maxv = -pow(10 , 9);

	// Input
	std::cin >> n;

	// Initial Number r[0]
	std::cin >> r;

	minv = r;

	// Search
	
	for (i=1;i<n;i++) {
		std::cin >> r;
		
		if (maxv < r - minv)maxv = r - minv;
		if (minv > r)minv = r;

		
	}

	std::cout << maxv	<< std::endl;

	return 0;
}	


Measured memory_bytes: 3100
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		boolean t1, t2= false, t3= false;
		String n1 = scn.next();
		String n2 = scn.next();
		String n3 = scn.next();
		t1 = true;
		while (true) {
			if(t1) {
				if(n1.isEmpty()) {
					System.out.println("A");
					break;
				}
				if(n1.charAt(0)=='b') {
					t1 = false;
					t2 = true;
				} else if(n1.charAt(0)=='c') {
					t1 = false;
					t3 = true;
				}
				n1 = n1.substring(1);
			}else if(t2) {
				if(n2.isEmpty()) {
					System.out.println("B");
					break;
				}
				if(n2.charAt(0)=='a') {
					t2 = false;
					t1 = true;
				} else if(n2.charAt(0)=='c') {
					t2 = false;
					t3 = true;
				}
				n2 = n2.substring(1);
			}else if(t3) {
				if(n3.isEmpty()) {
					System.out.println("C");
					break;
				}
				if(n3.charAt(0)=='b') {
					t3 = false;
					t2 = true;
				} else if(n3.charAt(0)=='a') {
					t3 = false;
					t1 = true;
				}
				n3 = n3.substring(1);
			}
		}
		scn.close();
	}
}

Measured memory_bytes: 23124
#include <stdio.h>
#include <stdlib.h>
 
int pu[4][4];
int t[4][4];
uint dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
 
void empty(int *,int *);
int dfs(int,int,int,int,const int);
int cal();
void swap(int *,int *);
 
int main() {
  int i,j,n,x,y,l;

  for(i=0; i<4; i++) {
    if(i<4)break;
  }
  
  for(i=0; i<4; i++) {
    for(j=0; j<4; j++)
      scanf("%d",&pu[i][j]);
  }
 
  empty(&x,&y);
  for(l=0; l<100; l++) {
    for(i=0; i<4; i++) {
      for(j=0; j<4; j++)
	t[i][j] = pu[i][j];
    }
 
    n = dfs(x,y,-1,0,l);
    if(n!=-1) {
      printf("%d\n",n);
      break;
    }
 
    for(i=0 ; i<4; i++) {
      for(j=0 ; j<4; j++)
	pu[i][j] = t[i][j];
    }
    n = -1;
    if(l==99)
      printf("%d\n",n);
  } 
  return 0;
}


void empty(int *x,int *y) {
  int i,j;
  for(i=0; i<4; i++) {
    for(j=0; j<4; j++) {
      if(!pu[i][j]) {
	*x = j;
	*y = i;
	return;
                
      }
    }
  }
}
 
 
void swap(int *n,int *m) {
  int t;
  t = *n;
  *n = *m;
  *m = t;
}
 
 
int cal() {
  int i,n,sum=0;
  for(i=0; i<16; i++) {
    n = pu[i/4][i%4];
    if(n) {
      n--;
      sum += abs(i/4 - n/4) + abs(i%4 - n%4);
    }
  }
    
  return sum;
    
}

int dfs(int x,int y,int p,int dep,const int lim) {
  int i,h,nx,ny,res;
 
  h = cal();
  if(h==0)
    return dep;
  if(dep+h>lim)
    return -1;
  for(i=0; i<4; i++) {
    nx = x+dx[i];
    ny = y+dy[i];
    if(~p && i==(p+2)%4)
      continue;
    if(!(0<=nx && nx<4 && 0<=ny && ny<4))
      continue;
    swap(&pu[y][x],&pu[ny][nx]);
    res = dfs(nx,ny,i,dep+1,lim);
    if(~res)
      return res;
    swap(&pu[y][x],&pu[ny][nx]);
  }
  return -1;
}
 



Measured memory_bytes: 2140
import sys

use_clipboard=True
bbn=1000000007
	
#+++++

def gf(v):
	if v == 0:
		return 0
	return len(str(v))
		
def main():
	a = int(input())
	ret=0
	for i in range(1, int((a**0.5)+1)):
		if a % i == 0:
			ret = gf(a//i)

	print(ret)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
class input_clipboard:
	def __init__(self,s):
		self.input_l=s.splitlines()
		self.ii=0
		
	def input(self):
		ret = self.input_l[self.ii]
		self.ii+=1
		return ret

if __name__ == "__main__":
	if sys.platform =='ios':
		if use_clipboard:
			import clipboard
			input_text=clipboard.get()
			ic=input_clipboard(input_text)
			input = lambda : ic.input()
		else:
			sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
typedef long long ll;

bool prime(int n){
    switch(n){
        case 2: return true;
    }
 
    if(n%2 == 0) return false;
 
    for(unsigned i = 3; i  *i <= n; i += 2){
        if(n%i == 0) return false;
    }
    return true;
}

int main(void)
{
    set<int> pri;
    int n, x;
    cin >> n;
    
    for (int i = 0; i < n; i++)
    {
        cin >> x;
        if (prime(x))
        {
            pri.insert(x);
        }
    }
    int prime_num = pri.size();
    cout << prime_num << endl;
}



Measured memory_bytes: 3088
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
		
		int A = sc.nextInt();
		int B = sc.nextInt();
        int C = sc.nextInt();
        
        if(C>=A && C<=B){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include<float.h>
using namespace std;
# define ll long long int
#define mm 1000000007
#define pb push_back
int main(){
	ios::sync_with_stdio(false);
  	cin.tie(0); cout.tie(0);
  	int t,n,i,ans=0,count=0;
    string s;
	cin>>s;
	string c;
	vector<string> v;
	int  j =0;
	n = s.length();
	int flag=0;
	for(i=0;i<n;i++)
	{		if((s[i]=='R' && flag==0 ) || (i==n-1)  )
	{
			v.pb(c);
			flag=1;
			c="";
	}
			if(s[i]=='R')
			{
				c+=s[i];
				flag=1;
			}
			if(s[i]=='L')
			{
				c+=s[i];
				flag=0;
			}
		
		}
		v[v.size()-1]+='L';

	for(int i=1;i<v.size();i++)
	{
		flag = 0;
		int countr=0,countl=0;
		for(j=0;j<v[i].length();j++){
			if(v[i][j]=='R') countr++;
			else countl++;
		}
		for(j=0;j<v[i].length();j++){
			if(v[i][j] == 'R' and v[i][j+1] == 'L'){
				if(v[i].length()%2 == 0){
					cout<<v[i].length()/2<<" ";
				}else if(countr%2 == 1){
					cout<<v[i].length()/2 + 1<<" ";
				}else{
					cout<<v[i].length()/2<<" ";
				}
				flag = 1;
			}else if(flag == 1){
				if(v[i].length()%2 == 0){
					cout<<v[i].length()/2<<" ";
				}else if(countl%2 == 1){
					cout<<v[i].length()/2 + 1<<" ";
				}else{
					cout<<v[i].length()/2<<" ";
				}
				flag = 0;
			}else{
				cout<<0<<" ";
			}
		}
	}
	}

Measured memory_bytes: 3272
#include<iostream>
#include<cstdio>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<map>
#include<numeric>
#include<stack>
#include<queue>
#include<functional>
#include<cassert>
#include<set>
#define rep(a,b) for(int a=0;a<b;++a)
#define REP(a,b,c,d) for(int a=b;a<c;a+=d)
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define mod 1000000007
using namespace std;
using ll = long long;
using p_i = pair<int, int>;
int main() {
	vector<char> S;
	char c;
	int Wnum = 0, loop = 0;
	ll ans = 0;
	while ((c = getchar()) != EOF) {
		if (c == '\n')break;
		S.push_back(c);
		if (S[loop] == 'W') {
			++Wnum;
			ans += (loop + 1 - Wnum);
		}
		++loop;
	}
	cout << ans << endl;
	cin >> ans;
}

Measured memory_bytes: 640
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//long long型の最大値(LLONG_MAX)など
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
typedef long double lb;

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

ll ryuka(ll num){
    if(num == 0){
        return 2;
    }else if(num == 1){
        return 1;
    }
    return ryuka(num-2) + ryuka(num-1);
}

int main() {
    ll N;
    cin >> N;
    vector<ll> L(N+1);

    L[0] = 2;
    L[1] = 1;
    for(ll i=2;i<L.size();i++){
        L[i] = L[i-2] + L[i-1];
    }

    cout << L[N] << endl;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
const int N=2e3+7;
int a[N];
int main(){
	int n,z,w,mi=1000000009,ma=-1;
	cin>>n>>z>>w;
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	if(n==1){
		printf("%d\n",abs(a[0]-w));return 0;
	}
	ma=max(abs( a[n-1]-a[n-2]),abs(a[n-1]-w) );
	printf("%d\n",ma);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define rrep(i, a, b) for (int i = (a); i < (b); ++i)
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

using tl = tuple<ll, ll, ll>;

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll n, m; cin>>n>>m;
    vvl to(n);
    rep(i, m) {
        ll v1, v2;
        cin>>v1>>v2; v1--; v2--;
        to[v1].push_back(v2);
        to[v2].push_back(v1);
    }

    queue<tl> q;
    q.emplace(0, 0, 0);
    vector<ll> previous(n, -1);
    while (!q.empty()) {
        tl t = q.front(); q.pop();
        ll v = get<0>(t);
        ll d = get<1>(t);
        ll p = get<2>(t);

        if (previous[v] != -1) continue;
        previous[v] = p;
        for (auto nv : to[v]) {
            q.emplace(nv, d + 1, v);
        }
    }
    cout<<"Yes"<<endl;
    rep(i, n - 1) {
        cout<<previous[i + 1] + 1<<endl;
    }
}

Measured memory_bytes: 19424
N=int(input())
C0=0
C1=0
C2=0
C3=0
for i in range(N):
  C=input()
  if C=="AC":
    C0+=1
  if C=="WA":
    C1+=1
  if C=="TLE":
    C2+=1
  if C=="RE":
    C3+=1
    
print("AC x {0}\nWA x {1}\nTLE x {2}\nRE x {3}".format(C0,C1,C2,C3))

Measured memory_bytes: 9204
N=int(input())
testimonies=[]

for i in range(N):
  A=int(input())
  testimony=[]
  for j in range(A):
    testimony.append(list(map(int,input().split())))
    testimony[-1][0]-=1
  testimonies.append(testimony)

ans=0
for i in range(2**N):
  isContradiction=False
  for j in range(N):
    if not i&1<<j:continue
    for x,y in testimonies[j]:
      if i&1<<x:x=1
      else:x=0
      if not x==y:
        isContradiction=True
        break
  if not isContradiction:
    ans=max(ans,bin(i).count("1"))
print(ans)

Measured memory_bytes: 9148
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] arr = new int[N];
        for(int i = 0; i < N; i++) {
            arr[i] = sc.nextInt();
        }

        int res = 0;
        while(N > 0) {
            N = N - K;
            res++;
            if(N==0) {
                break;
            }
            N++;
        }
        System.out.println(res);
    }
}


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

int main() {
  string n;
  cin >> n;
  
  for (int i=0; i<3; i++) {
    if (n.at(i) == '1') n.at(i) = '9';
    else n.at(i) = '1';
  }
  
  cout << n << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N,K; cin>>N>>K; 
  vi A(N);
  rep(i,0,N) cin>>A[i];
  vi dp(N+1);
  rep(i,0,N) dp[i+1]=dp[i]+A[i];
  vi B;
  REP(i,1,N){
    rep(j,0,i) B.pb(dp[i]-dp[j]);
  }
  int ans=0;
  REP(i,0,60){
    int k=60-i;
    int count=0;
    rep(j,0,B.size()){
      if((B[j]|(ans+(1ll<<k)))==B[j]) count++;
    }
    if(K<=count) ans+=(1ll<<k);
  }
  cout<<ans<<endl;
  }



Measured memory_bytes: 6516
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
#include <bitset>
/*
多倍長整数, cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

//#pragma gcc target ("avx2")
//#pragma gcc optimization ("o3")
//#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2LL) //等差数列の和、初項,末項,項数
#define pb push_back
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */
#define inf numeric_limits<double>::infinity();
#define linf numeric_limits<long double>::infinity()


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
constexpr long double eps = 1e-9;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	string s, t;
	scans(s);
	scans(t);
	t.pop_back();
	printyn(s == t);

	Please AC;
}

Measured memory_bytes: 3852
package main

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

type edge struct {
	to    int
	value int
}

var edges [][]edge
var vertex []int
var visited []bool

func fillNumber(x int) bool {
	visited[x] = true
	for _, e := range edges[x] {
		if !visited[e.to] {
			vertex[e.to] = vertex[x] + e.value
			if !fillNumber(e.to) {
				return false
			}
		} else if vertex[e.to] != vertex[x]+e.value {
			return false
		}
	}
	return true
}

func main() {
	in := IOInitialize()
	n, m := Int(in), Int(in)

	if m == 0 || m == 1 {
		fmt.Println("Yes")
		return
	}

	edges = make([][]edge, n)
	for i := range edges {
		edges[i] = make([]edge, 0, 4)
	}

	for i := 0; i < m; i++ {
		l, r, d := Int(in)-1, Int(in)-1, Int(in)
		edges[l] = append(edges[l], edge{to: r, value: d})
		edges[r] = append(edges[r], edge{to: l, value: -d})
	}

	vertex = make([]int, n)
	visited = make([]bool, n)

	for i := range visited {
		if !visited[i] {
			visited[i] = true
			if !fillNumber(i) {
				fmt.Println("No")
				return
			}
		}
	}
	fmt.Println("Yes")
}

//////////
//
//

func IOInitialize() *bufio.Scanner {
	t := bufio.NewScanner(os.Stdin)
	t.Split(bufio.ScanWords)
	return t
}

func Int(s *bufio.Scanner) int {
	if !s.Scan() {
		panic("\t\tThere is a FALSE not to want.")
	}

	value, err := strconv.Atoi(s.Text())
	if err != nil {
		panic("\t\tError:Failed to convert text to int,")
	}
	return value
}

func IntArray(s *bufio.Scanner, size int) []int {
	deepArray := make([]int, size)
	for i := range deepArray {
		deepArray[i] = Int(s)
	}
	return deepArray
}

func GraphSetByEdge(s *bufio.Scanner, v int) [][]int {
	g := make([][]int, v)
	for i := range g {
		g[i] = make([]int, 0)
	}
	for xxNonUsedInLoopI := 0; xxNonUsedInLoopI < v-1; xxNonUsedInLoopI++ {
		a, b := Int(s)-1, Int(s)-1
		g[a] = append(g[a], b)
		g[b] = append(g[b], a)
	}

	return g
}


Measured memory_bytes: 40064
import java.util.Arrays;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int[] Q = new int[N];
		int anser = 0;
		for(int i = 0; i<N ; i++) {
			Q[i] = sc.nextInt();
		}
		Arrays.sort(Q);
		System.out.println(Q[N/2]-Q[N/2-1]);

	}
}

Measured memory_bytes: 53056